use std::env;
use std::fs;
use std::path::Path;
use std::process::Command;
const TINYCDB_VERSION: &'static str = "0.78";
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let tinycdb_folder = format!("tinycdb-{}", TINYCDB_VERSION);
let tinycdb_path = Path::new("deps")
.join(&tinycdb_folder);
Command::new("make").arg("-C")
.arg(&tinycdb_path)
.arg("clean")
.status().unwrap();
Command::new("make").arg("-C")
.arg(&tinycdb_path)
.arg("piclib")
.status().unwrap();
let built_path = tinycdb_path.join("libcdb_pic.a");
let output_path = Path::new(&out_dir).join("libcdb.a");
fs::copy(&built_path, &output_path).unwrap();
println!("cargo:rustc-flags=-L {} -l static=cdb", out_dir);
}