From c76778a3af3b87743509b38803351434a58a8d6b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 12 Jun 2017 19:38:16 -0700 Subject: [PATCH] Fix build on windows-gnu --- lzma-sys/build.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lzma-sys/build.rs b/lzma-sys/build.rs index eb78f0b6..b1e642ea 100644 --- a/lzma-sys/build.rs +++ b/lzma-sys/build.rs @@ -133,17 +133,29 @@ fn main() { } run(&mut cmd); - run(Command::new("make") + run(make() .arg(&format!("-j{}", env::var("NUM_JOBS").unwrap())) .current_dir(&dst.join("build"))); // Unset DESTDIR or liblzma.a ends up in it and cargo can't find it env::remove_var("DESTDIR"); - run(Command::new("make") + run(make() .arg("install") .current_dir(&dst.join("build/src/liblzma"))); } } +fn make() -> Command { + let mut cmd = Command::new("make"); + + // We're using the MSYS make which doesn't work with the mingw32-make-style + // MAKEFLAGS, so remove that from the env if present. + if cfg!(windows) { + cmd.env_remove("MAKEFLAGS").env_remove("MFLAGS"); + } + + return cmd +} + fn try_run(cmd: &mut Command) -> bool { println!("running: {:?}", cmd); t!(cmd.status()).success()