build.rs 642 Bytes
Newer Older
1 2
extern crate cc;

Jeremy Soller's avatar
Jeremy Soller committed
3
use std::env;
4 5

fn main() {
Jeremy Soller's avatar
Jeremy Soller committed
6 7 8 9 10 11 12 13
    let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");

    cc::Build::new()
        .flag("-nostdinc")
        .flag("-nostdlib")
        .flag("-I")
        .flag(&format!("{}/include", crate_dir))
        .flag("-fno-stack-protector")
14
        .flag("-Wno-expansion-to-defined")
Jeremy Soller's avatar
Jeremy Soller committed
15 16 17 18
        .file("src/c/dlmalloc.c")
        .file("src/c/fcntl.c")
        .file("src/c/stack_chk.c")
        .file("src/c/stdio.c")
Jeremy Soller's avatar
Jeremy Soller committed
19
        .file("src/c/stdlib.c")
Jeremy Soller's avatar
Jeremy Soller committed
20 21
        .file("src/c/unistd.c")
        .compile("relibc_c");
22 23 24

    println!("cargo:rustc-link-lib=static=relibc_c");
}