use std::{env::var, path::PathBuf};
use bindgen::Builder;
fn main() {
let statik = cfg!(feature = "static");
#[cfg(feature = "openssl")]
pkg_config::Config::new().statik(statik).probe("libcrypto").unwrap();
let bindings = Builder::default()
.header("jitterentropy-include.h")
.generate()
.unwrap();
let mut bindings_path = PathBuf::from(var("OUT_DIR").unwrap());
bindings_path.push("jitterentropy-bindings.rs");
bindings
.write_to_file(&bindings_path)
.expect("Could not write bindings to file");
let found_jitterentropy = pkg_config::Config::new()
.atleast_version("3.7")
.statik(statik)
.probe("jitterentropy");
if found_jitterentropy.is_err() {
let lib_path = std::env::var("JITTERENTROPY_LIB_DIR")
.unwrap_or_else(|_| "/usr/lib".to_string());
println!("cargo:rustc-link-search=native={lib_path}");
if statik {
println!("cargo:rustc-link-lib=static=jitterentropy");
} else {
println!("cargo:rustc-link-lib=jitterentropy");
}
}
}