aboutsummaryrefslogtreecommitdiff
path: root/openssl-sys/build.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2015-02-03 10:04:37 -0800
committerSteven Fackler <[email protected]>2015-02-03 10:04:37 -0800
commit361e5f44fa50edd6b603717de409724620d0e01b (patch)
tree056f6516949c0892651448a2c64fc4a55f48f572 /openssl-sys/build.rs
parentMerge pull request #153 from mbrubeck/android (diff)
downloadrust-openssl-361e5f44fa50edd6b603717de409724620d0e01b.tar.xz
rust-openssl-361e5f44fa50edd6b603717de409724620d0e01b.zip
Move openssl-sys build.rs
Diffstat (limited to 'openssl-sys/build.rs')
-rw-r--r--openssl-sys/build.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/openssl-sys/build.rs b/openssl-sys/build.rs
new file mode 100644
index 00000000..a5d3f2d1
--- /dev/null
+++ b/openssl-sys/build.rs
@@ -0,0 +1,43 @@
+#![feature(core, collections, os)]
+
+extern crate "pkg-config" as pkg_config;
+
+use std::os;
+
+fn main() {
+ let target = os::getenv("TARGET").unwrap();
+ let is_android = target.find_str("android").is_some();
+
+ // Without hackory, pkg-config will only look for host libraries.
+ // So, abandon ship if we're cross compiling.
+ if !is_android && !pkg_config::target_supported() {
+ panic!("unsupported target");
+ }
+
+ if pkg_config::find_library("openssl").is_err() {
+ let mut flags = if is_android {
+ " -l crypto:static -l ssl:static"
+ } else {
+ " -l crypto -l ssl"
+ }.to_string();
+
+ let win_pos = target.find_str("windows")
+ .or(target.find_str("win32"))
+ .or(target.find_str("win64"));
+
+ // It's fun, but it looks like win32 and win64 both
+ // have all the libs with 32 sufix
+ if win_pos.is_some() {
+ flags.push_str(" -l gdi32 -l wsock32");
+ }
+
+ if is_android {
+ let path = os::getenv("OPENSSL_PATH").expect("Android does not provide openssl libraries, please \
+ build them yourselves (instructions in the README) \
+ and provide their location through $OPENSSL_PATH.");
+ flags.push_str(format!(" -L {}", path).as_slice());
+ }
+
+ println!("cargo:rustc-flags={}", flags);
+ }
+}