2016-06-15 22:34:13 +08:00
|
|
|
extern crate gcc;
|
2015-03-27 03:47:51 +08:00
|
|
|
extern crate pkg_config;
|
2015-02-24 04:22:34 +08:00
|
|
|
|
2016-06-15 22:34:13 +08:00
|
|
|
#[cfg(not(feature = "bundled"))]
|
2015-02-24 04:22:34 +08:00
|
|
|
fn main() {
|
2016-06-15 22:34:13 +08:00
|
|
|
use std::env;
|
|
|
|
use std::fs;
|
|
|
|
|
2015-12-02 00:33:48 +08:00
|
|
|
// Allow users to specify where to find SQLite.
|
|
|
|
let lib_dir = match env::var("SQLITE3_LIB_DIR") {
|
|
|
|
Ok(dir) => dir,
|
|
|
|
Err(_) => {
|
|
|
|
// See if pkg-config can do everything for us.
|
|
|
|
if pkg_config::find_library("sqlite3").is_ok() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to fall back to /usr/lib if pkg-config failed.
|
|
|
|
match fs::metadata("/usr/lib") {
|
|
|
|
Ok(ref attr) if attr.is_dir() => "/usr/lib".to_owned(),
|
|
|
|
_ => panic!("Could not find sqlite3. Try setting SQLITE3_LIB_DIR."),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
println!("cargo:rustc-link-lib=sqlite3");
|
|
|
|
println!("cargo:rustc-link-search={}", lib_dir);
|
2015-02-24 04:22:34 +08:00
|
|
|
}
|
2016-06-15 22:34:13 +08:00
|
|
|
|
|
|
|
#[cfg(feature = "bundled")]
|
|
|
|
fn main() {
|
|
|
|
gcc::compile_library("libsqlite3.a", &["sqlite3/sqlite3.c"]);
|
|
|
|
}
|