| 1 |
fn main() { |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); |
| 9 |
|
| 10 |
let needs_libinotify = match target_os.as_str() { |
| 11 |
"netbsd" | "openbsd" => true, |
| 12 |
_ => false, |
| 13 |
}; |
| 14 |
|
| 15 |
if needs_libinotify { |
| 16 |
|
| 17 |
|
| 18 |
let lib_dir = std::process::Command::new("pkg-config") |
| 19 |
.args(["--variable=libdir", "libinotify"]) |
| 20 |
.output() |
| 21 |
.ok() |
| 22 |
.filter(|o| o.status.success()) |
| 23 |
.and_then(|o| String::from_utf8(o.stdout).ok()) |
| 24 |
.map(|s| s.trim().to_owned()) |
| 25 |
.unwrap_or_else(|| "/usr/local/lib".to_owned()); |
| 26 |
|
| 27 |
println!("cargo:rustc-link-search=native={lib_dir}"); |
| 28 |
println!("cargo:rustc-link-lib=inotify"); |
| 29 |
} |
| 30 |
} |