fn main() {
println!("cargo:rerun-if-changed=zstd/contrib/seekable_format/zstdseek_compress.c");
println!("cargo:rerun-if-changed=zstd/contrib/seekable_format/zstdseek_decompress.c");
cc::Build::new()
.file("zstd/contrib/seekable_format/zstdseek_compress.c")
.file("zstd/contrib/seekable_format/zstdseek_decompress.c")
.opt_level(3)
.include("zstd/lib/common")
.include("zstd/lib")
.compile("zstdseek");
if pkg_config::Config::new()
.statik(true)
.probe("libzstd")
.is_err()
{
let mut cc = cc::Build::new();
for &dir in &["zstd/lib/common", "zstd/lib/compress", "zstd/lib/decompress"] {
cc.include(dir);
for entry in std::fs::read_dir(dir).unwrap() {
let entry = entry.unwrap();
let path = entry.path();
let name = path.file_name();
if let Some(f) = name {
let ext = std::path::Path::new(f).extension().map(|v| v.to_str().unwrap());
if ext == Some("c") || ext == Some("S") {
cc.file(path);
}
}
}
}
cc.opt_level(3).compile("zstd");
} else {
pkg_config::Config::new()
.statik(true)
.probe("libxxhash")
.is_ok();
}
}