// Copyright (C) 2023 Andrew Rioux // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . use fs_extra::dir::{copy, CopyOptions}; fn main() { if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows" { println!("cargo:rustc-lib-lib=pcap"); } else { let libpcap_src = format!("{}/pcap_src", std::env::var("OUT_DIR").unwrap()); let mut options = CopyOptions::new(); options.copy_inside = true; copy(std::env!("SPARSE_BUILD_LIBPCAP"), &libpcap_src, &options); let dst = cmake::Config::new(&libpcap_src) .define("BUILD_SHARED_LIBS", "OFF") .define("BUILD_WITH_LIBNL", "OFF") .define("DISABLE_BLUETOOTH", "ON") .define("DISABLE_DAG", "ON") .define("DISABLE_DBUS", "ON") .define("DISABLE_DPDK", "ON") .define("DISABLE_LINUX_USBMON", "ON") .define("DISABLE_NETMAP", "ON") .define("DISABLE_RDMA", "ON") .define("DISABLE_SEPTEL", "ON") .define("DISABLE_SNF", "ON") .define("DISABLE_TC", "ON") .define("PCAP_TYPE", "linux") .build(); // panic!("hahahahah test {}", dst.display()); println!("cargo:rustc-link-search=native={}/lib", dst.display()); println!("cargo:rustc-link-search=native={}/lib64", dst.display()); println!("cargo:rustc-link-lib=static=pcap"); } }