sparse/pcap-sys/build.rs
Andrew Rioux af5ceb66ab
Added Windows support for the bind shell
Brings in support from winpcap as npcap has a restrictive license
2024-01-24 19:12:45 -05:00

53 lines
2.3 KiB
Rust

// 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 <http://www.gnu.org/licenses/>.
use fs_extra::dir::{copy, CopyOptions};
fn main() {
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows" {
println!("cargo:rustc-link-search=native={}", std::env::var("SPARSE_BUILD_WINPCAP").unwrap());
println!("cargo:rustc-link-search=native={}/x64", std::env::var("SPARSE_BUILD_WINPCAP").unwrap());
println!("cargo:rustc-link-lib=wpcap");
} else {
let libpcap_src = format!("{}/pcap_src", std::env::var("OUT_DIR").unwrap());
let mut options = CopyOptions::new();
options.copy_inside = true;
options.skip_exist = true;
copy(std::env::var("SPARSE_BUILD_LIBPCAP").unwrap(), &libpcap_src, &options).expect("could not copy libpcap source code to build");
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");
}
}