diff --git a/Cargo.toml b/Cargo.toml index 5469c1e..022cb72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ compiletest_rs = { version = "0.3", optional = true } [build-dependencies] cc = { version = "1.0", optional = true } +pkg-config = "0.3.11" [dev-dependencies] rustyline = "1.0.0" @@ -38,4 +39,4 @@ criterion = "0.2.0" [[bench]] name = "benchmark" -harness = false \ No newline at end of file +harness = false diff --git a/build.rs b/build.rs index 5d83dcb..eaa8526 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,9 @@ #[cfg(feature = "builtin-lua")] extern crate cc; +#[cfg(not(feature = "builtin-lua"))] +extern crate pkg_config; + fn main() { #[cfg(feature = "builtin-lua")] { @@ -62,4 +65,8 @@ fn main() { .file("lua/lzio.c") .compile("liblua5.3.a"); } + #[cfg(not(feature = "builtin-lua"))] + { + pkg_config::Config::new().atleast_version("5.3").probe("lua").unwrap(); + } } diff --git a/src/ffi.rs b/src/ffi.rs index 69e432b..dd435c4 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -78,7 +78,6 @@ pub const LUA_GCSETPAUSE: c_int = 6; pub const LUA_GCSETSTEPMUL: c_int = 7; pub const LUA_GCISRUNNING: c_int = 9; -#[link(name = "lua5.3")] extern "C" { pub fn lua_newstate(alloc: lua_Alloc, ud: *mut c_void) -> *mut lua_State; pub fn lua_close(state: *mut lua_State);