summary refs log tree commit diff
path: root/pkgs/build-support/cc-wrapper/setup-hook.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/cc-wrapper/setup-hook.sh')
-rw-r--r--pkgs/build-support/cc-wrapper/setup-hook.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/pkgs/build-support/cc-wrapper/setup-hook.sh b/pkgs/build-support/cc-wrapper/setup-hook.sh
new file mode 100644
index 00000000000..e8ab44b3d6f
--- /dev/null
+++ b/pkgs/build-support/cc-wrapper/setup-hook.sh
@@ -0,0 +1,47 @@
+export NIX_CC=@out@
+
+addCVars () {
+    if [ -d $1/include ]; then
+        export NIX_CFLAGS_COMPILE+=" -isystem $1/include"
+    fi
+
+    if [ -d $1/lib64 -a ! -L $1/lib64 ]; then
+        export NIX_LDFLAGS+=" -L$1/lib64"
+    fi
+
+    if [ -d $1/lib ]; then
+        export NIX_LDFLAGS+=" -L$1/lib"
+    fi
+
+    if test -d $1/Library/Frameworks; then
+        export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -F$1/Library/Frameworks"
+    fi
+}
+
+envHooks+=(addCVars)
+
+# Note: these come *after* $out in the PATH (see setup.sh).
+
+if [ -n "@cc@" ]; then
+    addToSearchPath PATH @cc@/bin
+fi
+
+if [ -n "@binutils_bin@" ]; then
+    addToSearchPath PATH @binutils_bin@/bin
+fi
+
+if [ -n "@libc_bin@" ]; then
+    addToSearchPath PATH @libc_bin@/bin
+fi
+
+if [ -n "@coreutils_bin@" ]; then
+    addToSearchPath PATH @coreutils_bin@/bin
+fi
+
+if [ -z "$crossConfig" ]; then
+    export CC=@real_cc@
+    export CXX=@real_cxx@
+else
+    export BUILD_CC=@real_cc@
+    export BUILD_CXX=@real_cxx@
+fi