zstd-seekable 0.1.8

Bindings to the seekable version of ZStandard.
Documentation
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")
        .file("xxh64.c")
        .opt_level(3)
        .include("zstd/lib/common")
        .include("zstd/lib")
        .compile("zstdseek");

    let out_dir = std::env::var("OUT_DIR").unwrap();
    let out_dirp = std::path::Path::new(&out_dir);
    std::fs::create_dir_all(&out_dir).unwrap();

    if cfg!(target_family = "windows") && cfg!(target_arch = "x86") {
        std::fs::copy("libzstd-win32.lib", &out_dirp.join("zstd.lib")).unwrap();
        // Link with static library in this directory.
        println!("cargo:rustc-link-search={}", out_dir);
        println!("cargo:rustc-link-lib=zstd");
    } else if cfg!(target_family = "windows") && cfg!(target_arch = "x86") {
        std::fs::copy("libzstd-win64.lib", &out_dirp.join("zstd.lib")).unwrap();
        // Link with static library in this directory.
        println!("cargo:rustc-link-search={}", out_dir);
        println!("cargo:rustc-link-lib=zstd");
    } else {
        if pkg_config::Config::new()
            .range_version("1.4.0".."1.5.0")
            .statik(true)
            .probe("libzstd")
            .is_err()
        {
            // Make
            let options = fs_extra::dir::CopyOptions::new()
                .skip_exist(true);
            let out = out_dirp.join("zstd");
            std::fs::create_dir_all(&out).unwrap();
            fs_extra::dir::copy("zstd/lib", &out, &options).unwrap();
            let dir = out.join("lib");
            let mut make = std::process::Command::new("make")
                .current_dir(&dir)
                .spawn()
                .unwrap();
            let status = make.wait().unwrap();
            assert!(status.success());
            println!("cargo:rustc-link-search={}", dir.display());
            println!("cargo:rustc-link-lib=zstd");
        } else {
            // Already found by pkg-config
        }
    }

    if pkg_config::probe_library("libxxhash").is_err() {
        println!("cargo:rustc-link-lib=xxhash");
    }
}