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.

Changed files
+23 -9
pkgs
development
compilers
gcc
stdenv
+15 -8
pkgs/development/compilers/gcc/4.8/default.nix
···
"\"--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"
-
''}
-
'';
dontDisableStatic = true;
···
"\"--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.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;
+8 -1
pkgs/stdenv/nix/default.nix
···
stripAllFlags=" " # the Darwin "strip" command doesn't know "-s"
xargsFlags=" "
fi
-
'';
initialPath = (import ../common-path.nix) {pkgs = pkgs;};
···
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;};