summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-06-30 19:51:43 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-07-01 11:01:36 +0200
commit89f8af55f11b01e68cbfc6d10537413140261721 (patch)
tree6ae4520e499e8b7e3806a5732ac941894f68fa03 /pkgs
parent55e8e0ef9bf2c927edbdcc05097a1e7185184cba (diff)
downloadnixpkgs-89f8af55f11b01e68cbfc6d10537413140261721.tar
nixpkgs-89f8af55f11b01e68cbfc6d10537413140261721.tar.gz
nixpkgs-89f8af55f11b01e68cbfc6d10537413140261721.tar.bz2
nixpkgs-89f8af55f11b01e68cbfc6d10537413140261721.tar.lz
nixpkgs-89f8af55f11b01e68cbfc6d10537413140261721.tar.xz
nixpkgs-89f8af55f11b01e68cbfc6d10537413140261721.tar.zst
nixpkgs-89f8af55f11b01e68cbfc6d10537413140261721.zip
Darwin: Use xcrun to get the path to the SDK
Recent versions of Xcode don't install headers in /usr/include but
in a directory like

  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include

So use that instead, falling back to /usr/include in case of an older
version of Xcode.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/compilers/gcc/4.8/default.nix23
-rw-r--r--pkgs/stdenv/nix/default.nix9
2 files changed, 23 insertions, 9 deletions
diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix
index 21487a09dcd..10d6992ede1 100644
--- a/pkgs/development/compilers/gcc/4.8/default.nix
+++ b/pkgs/development/compilers/gcc/4.8/default.nix
@@ -303,14 +303,21 @@ stdenv.mkDerivation ({
         "\"--with-host-libstdcxx=-Wl,-rpath,\$prefix/lib/amd64 -lstdc++\"
          \"--with-boot-ldflags=-L../prev-x86_64-pc-solaris2.11/libstdc++-v3/src/.libs\""}
     );
-    ${stdenv.lib.optionalString (stdenv.isSunOS && stdenv.is64bit)
-      ''
-        export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
-        export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
-        export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
-        export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET"
-      ''}
-    '';
+  '' + stdenv.lib.optionalString (stdenv.isSunOS && stdenv.is64bit) ''
+    export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
+    export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
+    export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
+    export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET"
+  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+    if xcodePath=$(/usr/bin/xcrun --show-sdk-path); then
+      configureFlagsArray+=(--with-native-system-header-dir=$xcodePath/usr/include)
+      makeFlagsArray+=( \
+       CFLAGS_FOR_BUILD=-F$xcodePath/System/Library/Frameworks \
+       CFLAGS_FOR_TARGET=-F$xcodePath/System/Library/Frameworks \
+       FLAGS_FOR_TARGET=-F$xcodePath/System/Library/Frameworks \
+      )
+    fi
+  '';
 
   dontDisableStatic = true;
 
diff --git a/pkgs/stdenv/nix/default.nix b/pkgs/stdenv/nix/default.nix
index 78e5b84a841..84bcea7f643 100644
--- a/pkgs/stdenv/nix/default.nix
+++ b/pkgs/stdenv/nix/default.nix
@@ -16,7 +16,14 @@ import ../generic rec {
         stripAllFlags=" " # the Darwin "strip" command doesn't know "-s"
         xargsFlags=" "
       fi
-    '';
+    '' + (if stdenv.isDarwin then ''
+      export NIX_CFLAGS_COMPILE="--sysroot=/var/empty"
+      if xcodePath=$(/usr/bin/xcrun --show-sdk-path 2> /dev/null); then
+        NIX_CFLAGS_COMPILE+=" -idirafter $xcodePath/usr/include -F$xcodePath/System/Library/Frameworks"
+      else
+        NIX_CFLAGS_COMPILE+=" -idirafter /usr/include -F/System/Library/Frameworks"
+      fi
+    '' else "");
 
   initialPath = (import ../common-path.nix) {pkgs = pkgs;};