diff --git a/Cargo.toml b/Cargo.toml index 9734ece..4d26016 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,7 @@ libc = "0.2.86" async_support = ["async-trait", "futures-channel", "futures-core", "futures-io", "futures-util", "futures-executor"] futures_support = ["async_support", "blocking"] tokio_support = ["async_support", "tokio", "tokio-util"] +static = [] [dev-dependencies] tempfile = "3.1" diff --git a/src/build.rs b/src/build.rs index 4d073d4..26e71e7 100644 --- a/src/build.rs +++ b/src/build.rs @@ -24,10 +24,35 @@ fn find_libarchive() { std::env::set_var("PKG_CONFIG_PATH", MACOS_HOMEBREW_LIBARCHIVE_PATH); } + if cfg!(feature = "static") { + pkg_config::Config::new() + .atleast_version("0.98.1") + .statik(cfg!(feature = "static")) + .probe("libb2") + .expect("Unable to find libb2"); + + pkg_config::Config::new() + .atleast_version("1.9.4") + .statik(cfg!(feature = "static")) + .probe("liblz4") + .expect("Unable to find liblz4"); + + pkg_config::Config::new() + .atleast_version("1.5.6") + .statik(cfg!(feature = "static")) + .probe("libzstd") + .expect("Unable to find libzstd"); + } + pkg_config::Config::new() .atleast_version("3.2.0") + .statik(cfg!(feature = "static")) .probe("libarchive") .expect("Unable to find libarchive"); + + if cfg!(feature = "static") { + println!("cargo:rustc-link-lib=static=archive"); + } } #[cfg(target_env = "msvc")]