blob: 2fec59e474e5a33c7e472cb4ef4e66b64221a56d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#![feature(env, path, core)]
extern crate "pkg-config" as pkg_config;
extern crate gcc;
use std::env;
fn main() {
let lib_dir = env::var("OPENSSL_LIB_DIR").ok();
let include_dir = env::var("OPENSSL_INCLUDE_DIR").ok();
if lib_dir.is_none() && include_dir.is_none() {
if let Ok(info) = pkg_config::find_library("openssl") {
build_old_openssl_shim(info.include_paths);
return;
}
}
let (libcrypto, libssl) = if env::var("TARGET").unwrap().contains("windows") {
("eay32", "ssl32")
} else {
("crypto", "ssl")
};
let mode = if env::var_os("OPENSSL_STATIC").is_some() {
"static"
} else {
"dylib"
};
if let Some(lib_dir) = lib_dir {
println!("cargo:rustc-flags=-L native={}", lib_dir);
}
println!("cargo:rustc-flags=-l {0}={1} -l {0}={2}", mode, libcrypto, libssl);
let mut include_dirs = vec![];
if let Some(include_dir) = include_dir {
include_dirs.push(Path::new(include_dir));
}
build_old_openssl_shim(include_dirs);
}
fn build_old_openssl_shim(include_paths: Vec<Path>) {
let mut config = gcc::Config::new();
for path in include_paths {
config.include(path);
}
config.file("src/old_openssl_shim.c")
.compile("libold_openssl_shim.a");
}
|