--- /dev/null
+use std::path::Path;
+use std::fs;
+
+fn main() {
+ let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
+ let lib_dir = Path::new(&manifest_dir).join("../build/lib");
+ let config_mk = Path::new(&manifest_dir).join("../config.mk");
+
+ println!("cargo:rustc-link-search=native={}", lib_dir.display());
+ println!("cargo:rustc-link-lib=static=uitk");
+ println!("cargo:rustc-link-lib=static=ucx");
+
+ let content = fs::read_to_string(&config_mk)
+ .expect(&format!("Failed to read {}", config_mk.display()));
+ for line in content.lines() {
+ if line.starts_with("TK_LDFLAGS") {
+ let parts: Vec<&str> = line.split_whitespace().collect();
+ for token in &parts[2..] {
+ if let Some(lib) = token.strip_prefix("-l") {
+ println!("cargo:rustc-link-lib={}", lib);
+ } else if token.starts_with("-L") {
+ let path = &token[2..];
+ println!("cargo:rustc-link-search=native={}", path);
+ } else if token.starts_with("-R") {
+ let path = &token[2..];
+ println!("cargo:rustc-link-arg=-Wl,-rpath,{}", path);
+ } else {
+ println!("cargo:rustc-link-arg={}", token);
+ }
+ }
+ }
+ }
+}