diff --git a/Cargo.toml b/Cargo.toml index 6f3eaf20..005e2950 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,3 +31,5 @@ vcpkg = "0.2" # noted in `contrib/README.contrib`, these routines are experimental and not # vetted, use at your own risk! asm = [] +# Enable this feature if you want to have a staticly linked libz +static = [] diff --git a/build.rs b/build.rs index 4fa03379..75c043ad 100644 --- a/build.rs +++ b/build.rs @@ -21,7 +21,8 @@ fn main() { // also don't run pkg-config on macOS/FreeBSD/DragonFly. That'll end up printing // `-L /usr/lib` which wreaks havoc with linking to an OpenSSL in /usr/local/lib // (Homebrew, Ports, etc.) - let want_static = env::var("LIBZ_SYS_STATIC").unwrap_or(String::new()) == "1"; + let want_static = + cfg!(feature = "static") || env::var("LIBZ_SYS_STATIC").unwrap_or(String::new()) == "1"; if !wants_asm && !want_static && !target.contains("msvc") && // pkg-config just never works here diff --git a/systest/Cargo.toml b/systest/Cargo.toml index b85f7a31..7734fa75 100644 --- a/systest/Cargo.toml +++ b/systest/Cargo.toml @@ -10,3 +10,6 @@ libc = "0.2" [build-dependencies] ctest = "0.1" + +[features] +libz-static = ["libz-sys/static"]