summary refs log tree commit diff
path: root/pkgs/build-support/bintools-wrapper/add-flags.sh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2017-08-28 14:56:08 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2017-12-13 16:08:18 -0500
commit8e557ed2c58e6ce48a8d05dbc57ef84e98b4cecd (patch)
tree1f981fdaa6de98e84214b0feb76795812dbfe10f /pkgs/build-support/bintools-wrapper/add-flags.sh
parent4f869bccc14fb2fa19df130e76c022765ecda924 (diff)
downloadnixpkgs-8e557ed2c58e6ce48a8d05dbc57ef84e98b4cecd.tar
nixpkgs-8e557ed2c58e6ce48a8d05dbc57ef84e98b4cecd.tar.gz
nixpkgs-8e557ed2c58e6ce48a8d05dbc57ef84e98b4cecd.tar.bz2
nixpkgs-8e557ed2c58e6ce48a8d05dbc57ef84e98b4cecd.tar.lz
nixpkgs-8e557ed2c58e6ce48a8d05dbc57ef84e98b4cecd.tar.xz
nixpkgs-8e557ed2c58e6ce48a8d05dbc57ef84e98b4cecd.tar.zst
nixpkgs-8e557ed2c58e6ce48a8d05dbc57ef84e98b4cecd.zip
bintools-wrapper: Init
Factor a bintools (i.e. binutils / cctools) wrapper out of cc-wrapper. While
only LD is wrapped, the setup hook defines environment variables on behalf of
other utilites.
Diffstat (limited to 'pkgs/build-support/bintools-wrapper/add-flags.sh')
-rw-r--r--pkgs/build-support/bintools-wrapper/add-flags.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/pkgs/build-support/bintools-wrapper/add-flags.sh b/pkgs/build-support/bintools-wrapper/add-flags.sh
new file mode 100644
index 00000000000..7d118d20fc6
--- /dev/null
+++ b/pkgs/build-support/bintools-wrapper/add-flags.sh
@@ -0,0 +1,40 @@
+# See cc-wrapper for comments.
+var_templates_list=(
+    NIX+IGNORE_LD_THROUGH_GCC
+    NIX+LDFLAGS
+    NIX+LDFLAGS_BEFORE
+    NIX+LDFLAGS_AFTER
+    NIX+LDFLAGS_HARDEN
+)
+var_templates_bool=(
+    NIX+SET_BUILD_ID
+    NIX+DONT_SET_RPATH
+)
+
+declare -a role_infixes=()
+if [ "${NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_BUILD:-}" ]; then
+    role_infixes+=(_BUILD_)
+fi
+if [ "${NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_HOST:-}" ]; then
+    role_infixes+=(_)
+fi
+if [ "${NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_TARGET:-}" ]; then
+    role_infixes+=(_TARGET_)
+fi
+
+for var in "${var_templates_list[@]}"; do
+    mangleVarList "$var" "${role_infixes[@]}"
+done
+for var in "${var_templates_bool[@]}"; do
+    mangleVarBool "$var" "${role_infixes[@]}"
+done
+
+if [ -e @out@/nix-support/libc-ldflags ]; then
+    NIX_@infixSalt@_LDFLAGS+=" $(< @out@/nix-support/libc-ldflags)"
+fi
+
+if [ -e @out@/nix-support/libc-ldflags-before ]; then
+    NIX_@infixSalt@_LDFLAGS_BEFORE="$(< @out@/nix-support/libc-ldflags-before) $NIX_@infixSalt@_LDFLAGS_BEFORE"
+fi
+
+export NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET=1