From 2d17335f6869f88e5bbcef4f1c7a3329e5860ccb Mon Sep 17 00:00:00 2001
From: aszlig <aszlig@redmoonstudios.org>
Date: Wed, 12 Mar 2014 06:21:17 +0100
Subject: [PATCH] gcc-cross-wrapper: Allow to pass US X min version.

This allows to pass a new attribute osxMinVersion to crossSystem, which
specifies the minimum Mac OS X version you want to be compatible to.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
---
 pkgs/build-support/gcc-cross-wrapper/builder.sh  | 4 ++++
 pkgs/build-support/gcc-cross-wrapper/default.nix | 1 +
 2 files changed, 5 insertions(+)

diff --git a/pkgs/build-support/gcc-cross-wrapper/builder.sh b/pkgs/build-support/gcc-cross-wrapper/builder.sh
index 5a5bd45a8f81..18d26b3e9451 100644
--- a/pkgs/build-support/gcc-cross-wrapper/builder.sh
+++ b/pkgs/build-support/gcc-cross-wrapper/builder.sh
@@ -26,6 +26,10 @@ if test -z "$nativeLibc"; then
       fi
     fi
 
+    if [ -n "$osxMinVersion" ]; then
+        cflagsCompile="$cflagsCompile -mmacosx-version-min=$osxMinVersion"
+    fi
+
     echo "$cflagsCompile -B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags
 
     echo "-L$libc/lib -rpath $libc/lib -rpath-link $libc/lib" > $out/nix-support/libc-ldflags
diff --git a/pkgs/build-support/gcc-cross-wrapper/default.nix b/pkgs/build-support/gcc-cross-wrapper/default.nix
index b2e30be10ef7..d3494b83a87b 100644
--- a/pkgs/build-support/gcc-cross-wrapper/default.nix
+++ b/pkgs/build-support/gcc-cross-wrapper/default.nix
@@ -46,6 +46,7 @@ stdenv.mkDerivation {
   addFlags = ./add-flags;
   inherit nativeTools nativeLibc nativePrefix gcc libc binutils;
   crossConfig = if cross != null then cross.config else null;
+  osxMinVersion = cross.osxMinVersion or null;
   gccLibs = if gcc != null then gccLibs else null;
   name = chosenName;
   langC = if nativeTools then true else gcc.langC;