From c412de44136e10a346759de27e739406564d1bad Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 26 Jul 2025 14:18:21 -0400 Subject: build/flags-if: Handle -std=* specially --- build/flags-if.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'build') diff --git a/build/flags-if.sh b/build/flags-if.sh index 4cbfbc9..f7b4f33 100755 --- a/build/flags-if.sh +++ b/build/flags-if.sh @@ -33,11 +33,23 @@ OUTPUT="" OLD_FLAGS=" $XCPPFLAGS $XCFLAGS $XLDFLAGS $XLDLIBS " add_flag() { - if [ "${OLD_FLAGS#* $1 }" = "$OLD_FLAGS" ]; then - FLAGS="${FLAGS}${FLAGS:+ }$1" - else - return 1 - fi + case "$1" in + -std=*) + # Don't overwrite -std=* flags + case "$OLD_FLAGS" in + *\ -std=*) + return 1 + ;; + esac + ;; + *) + if [ "${OLD_FLAGS#* $1 }" != "$OLD_FLAGS" ]; then + return 1 + fi + ;; + esac + + FLAGS="${FLAGS}${FLAGS:+ }$1" } try_cc() { -- cgit v1.2.3