use std::env; use std::path::PathBuf; use std::process::Command; fn main() { let out_dir = env::var_os("OUT_DIR") .map(|s| PathBuf::from(s).join("libhtp")) .unwrap(); let build_dir = out_dir.join("build"); let install_dir = out_dir.join("install"); let libdir = install_dir.join("lib"); if !build_dir.exists() { std::fs::create_dir_all(&out_dir).unwrap(); Command::new("git") .arg("clone") .arg("https://github.com/OISF/libhtp.git") .arg("build") .current_dir(out_dir) .spawn() .expect("git failed") .wait() .unwrap(); } if !libdir.join("libhtp.a").exists() { Command::new("./autogen.sh") .current_dir(&build_dir) .spawn() .expect("./autogen.sh failed") .wait() .expect("./autogen.sh failed"); Command::new("./configure") .arg(&format!("--prefix={}", install_dir.display())) .arg("--disable-shared") .current_dir(&build_dir) .spawn() .expect("./configure failed") .wait() .expect("./configure failed"); Command::new("make") .current_dir(&build_dir) .spawn() .expect("make failed") .wait() .expect("make failed"); Command::new("make") .arg("install") .current_dir(&build_dir) .spawn() .expect("make failed") .wait() .expect("make failed"); } println!("cargo:rustc-link-lib=static=htp"); println!( "cargo:rustc-link-search=native={}", libdir.display() ); println!("cargo:rustc-link-lib=z"); }