summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbuild/flags-if.sh20
1 files changed, 14 insertions, 6 deletions
diff --git a/build/flags-if.sh b/build/flags-if.sh
index 098b2d3..7de7bbd 100755
--- a/build/flags-if.sh
+++ b/build/flags-if.sh
@@ -7,10 +7,18 @@
set -eu
-FLAGS=$(sed -n '\|^///|{s|^/// ||; s|[^=]*= ||; p}' "$1")
+OLD_FLAGS="$XCC $XCPPFLAGS $XCFLAGS $XLDFLAGS $XLDLIBS"
+NEW_FLAGS=$(sed -n '\|^///|{s|^/// ||; s|[^=]*= ||; p}' "$1")
+build/cc.sh "$@" $NEW_FLAGS || exit 1
-if build/cc.sh "$@" $FLAGS; then
- sed -n 's|^/// \(.*=.*\)|\1|p' "$1"
-else
- exit 1
-fi
+# De-duplicate against the existing flags
+while IFS="" read -r line; do
+ case "$line" in
+ ///*=*)
+ flag="${line#*= }"
+ if [ "${OLD_FLAGS#*"$flag"}" = "$OLD_FLAGS" ]; then
+ printf '%s\n' "${line#/// }"
+ fi
+ ;;
+ esac
+done <"$1"