diff --git a/build.rs b/build.rs index 2a620ec..7615bed 100644 --- a/build.rs +++ b/build.rs @@ -1,16 +1,11 @@ extern crate cc; -use std::process::Command; fn main() { - let output = Command::new("uname").output() - .expect("failed to get uname"); - let compiler = match output.stdout.as_slice() { - b"Darwin\n" => "x86_64-elf-gcc", - b"Linux\n" => "gcc", - _ => panic!("unknown os") - }; - cc::Build::new() - .compiler(compiler) - .file("src/test.c") - .compile("cobj"); + let mut build = cc::Build::new(); + + let compiler = if build.get_compiler().is_like_clang() + { "x86_64-elf-gcc" } else {"gcc"}; + build.compiler(compiler) + .file("src/test.c") + .compile("cobj"); } \ No newline at end of file