fn main() {
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
if matches!(target_os.as_str(), "freebsd" | "netbsd" | "openbsd") {
let lib_dir = std::process::Command::new("pkg-config")
.args(["--variable=libdir", "libinotify"])
.output()
.ok()
.filter(|o| o.status.success())
.and_then(|o| String::from_utf8(o.stdout).ok())
.map(|s| s.trim().to_owned())
.unwrap_or_else(|| "/usr/local/lib".to_owned());
println!("cargo:rustc-link-search=native={lib_dir}");
println!("cargo:rustc-link-lib=inotify");
}
}