]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Test each CC flag we want to set so we will work on other compilers such as pcc when...
authorRoy Marples <roy@marples.name>
Wed, 20 Feb 2008 10:12:40 +0000 (10:12 +0000)
committerRoy Marples <roy@marples.name>
Wed, 20 Feb 2008 10:12:40 +0000 (10:12 +0000)
mk/cc.mk

index a166971697eac0cd5f155770ff14dc3fb834d36a..475741cefb7387430e05c8c179da866d07f1c7cc 100644 (file)
--- a/mk/cc.mk
+++ b/mk/cc.mk
@@ -1,7 +1,7 @@
 # Copyright 2008 Roy Marples <roy@marples.name>
 
 # Setup some good default CFLAGS
-CFLAGS?=       -O2 -pipe
+CFLAGS?=       -O2
 
 # Default to using the C99 standard
 CSTD?=         c99
@@ -9,23 +9,15 @@ _CSTD_SH=     if test -n "${CSTD}"; then echo "-std=${CSTD}"; else echo ""; fi
 _CSTD!=                ${_CSTD_SH}
 CFLAGS+=       ${_CSTD}$(shell ${_CSTD_SH})
 
-# GNU Make way of detecting gcc flags we can use
-check_gcc=$(shell if ${CC} $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
-       then echo "$(1)"; else echo "$(2)"; fi)
-
-# pmake check for extra cflags 
-WEXTRA!= for x in -Wdeclaration-after-statement -Wsequence-point -Wextra; do \
-       if ${CC} $$x -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
-       then echo -n "$$x "; fi \
-       done
-
-# Loads of nice flags to ensure our code is good
-CFLAGS+=       -pedantic \
-               -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
+# Try and use some good cc flags
+_CC_FLAGS=     -pedantic -pipe -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
                -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
                -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
                -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
-               $(call check_gcc, -Wdeclaration-after-statement) \
-               $(call check_gcc, -Wsequence-point) \
-               $(call check_gcc, -Wextra) ${WEXTRA}
-
+               -Wdeclaration-after-statement -Wsequence-point -Wextra
+_CC_FLAGS_SH=  for f in ${_CC_FLAGS}; do \
+               if ${CC} $$f -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
+               then printf "%s" "$$f "; fi \
+               done
+_CC_FLAGS!=    ${_CC_FLAGS_SH}
+CFLAGS+=       ${_CC_FLAGS}$(shell ${CC_FLAGS_SH})