use std::env;
fn main() {
let mut build = cc::Build::new();
build.file("libspng/spng/spng.c");
if let Some(libz_include) = env::var_os("DEP_Z_INCLUDE") {
build.include(libz_include);
}
if cfg!(target_feature = "sse4.1") {
build.define("SPNG_SSE", Some("4"));
} else if cfg!(target_feature = "ssse3") {
build.define("SPNG_SSE", Some("3"));
}
build.compile("spng");
println!("cargo:include=libspng/spng");
println!("cargo:rustc-link-lib=static={}", libname());
}
#[cfg(not(feature = "zlib-ng"))]
fn libname() -> &'static str {
"z"
}
#[cfg(feature = "zlib-ng")]
fn libname() -> &'static str {
let target = env::var("TARGET").unwrap();
if target.contains("windows") {
if target.contains("msvc") && env::var("OPT_LEVEL").unwrap() == "0" {
"zlibd"
} else {
"zlib"
}
} else {
"z"
}
}