| 1 | // SPDX-License-Identifier: Apache-2.0 or MIT |
| 2 | // |
| 3 | // Copyright 2021 Sony Group Corporation |
| 4 | // |
| 5 | |
| 6 | use std::{env, path, str}; |
| 7 | |
| 8 | const LIBSECCOMP_LIB_PATH: &str = "LIBSECCOMP_LIB_PATH"; |
| 9 | |
| 10 | fn main() { |
| 11 | println!("cargo:rerun-if-env-changed={}", LIBSECCOMP_LIB_PATH); |
| 12 | |
| 13 | if let Ok(path) = env::var(LIBSECCOMP_LIB_PATH) { |
| 14 | println!("cargo:rustc-link-search=native={}", path); |
| 15 | let pkgconfig = path::Path::new(&path).join("pkgconfig"); |
| 16 | env::set_var("PKG_CONFIG_PATH", pkgconfig); |
| 17 | } |
| 18 | |
| 19 | let target = env::var("TARGET").unwrap_or_default(); |
| 20 | let host = env::var("HOST").unwrap_or_default(); |
| 21 | if target != host { |
| 22 | env::set_var("PKG_CONFIG_ALLOW_CROSS", "1"); |
| 23 | } |
| 24 | |
| 25 | if pkg_config::Config::new() |
| 26 | .atleast_version("2.6.0") |
| 27 | .probe("libseccomp") |
| 28 | .is_ok() |
| 29 | { |
| 30 | println!("cargo:rustc-cfg=libseccomp_v2_6"); |
| 31 | } |
| 32 | } |