Repository: trifectatechfoundation/bzip2-rs (language: rust)

Issue:
bzip2-sys: features=["static"]?
Would it be possible to have `static` feature like `libz-sys` does?:

https://github.com/rust-lang/libz-sys/blob/master/Cargo.toml#L35

/cc https://github.com/alexcrichton/xz2-rs/issues/62


Discussion / hints:

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 21f0c3f2..38f81bfb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -31,3 +31,5 @@ tokio-core = "0.1"
 
 [features]
 tokio = ["tokio-io", "futures"]
+# Enable this feature if you want to have a statically linked bzip2
+static = ["bzip2-sys/static"]
diff --git a/bzip2-sys/Cargo.toml b/bzip2-sys/Cargo.toml
index f82edc09..34e88c75 100644
--- a/bzip2-sys/Cargo.toml
+++ b/bzip2-sys/Cargo.toml
@@ -24,3 +24,7 @@ libc = "0.2"
 [build-dependencies]
 pkg-config = "0.3.9"
 cc = "1.0"
+
+[features]
+# Enable this feature if you want to have a statically linked bzip2
+static = []
diff --git a/bzip2-sys/build.rs b/bzip2-sys/build.rs
index adea7a1d..feb004ca 100644
--- a/bzip2-sys/build.rs
+++ b/bzip2-sys/build.rs
@@ -12,7 +12,8 @@ fn main() {
     if target.contains("windows") {
         cfg.define("_WIN32", None);
         cfg.define("BZ_EXPORT", None);
-    } else {
+    } else if !cfg!(feature = "static") {
+        // pkg-config doesn't guarantee static link
         if pkg_config::Config::new()
             .cargo_metadata(true)
             .probe("bzip2")


Test patch: