From 89f8af55f11b01e68cbfc6d10537413140261721 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 30 Jun 2014 19:51:43 +0200 Subject: [PATCH] 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. --- .../development/compilers/gcc/4.8/default.nix | 23 ++++++++++++------- pkgs/stdenv/nix/default.nix | 9 +++++++- 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 21487a09dcd2..10d6992ede1c 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 78e5b84a841e..84bcea7f643d 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;};