From: Roy Marples Date: Wed, 20 Feb 2008 10:12:40 +0000 (+0000) Subject: Test each CC flag we want to set so we will work on other compilers such as pcc when... X-Git-Tag: v3.2.3~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3261396e1cf43efb4fdcc48d969c9b8634fa0a83;p=thirdparty%2Fdhcpcd.git Test each CC flag we want to set so we will work on other compilers such as pcc when it matures a little. --- diff --git a/mk/cc.mk b/mk/cc.mk index a1669716..475741ce 100644 --- a/mk/cc.mk +++ b/mk/cc.mk @@ -1,7 +1,7 @@ # Copyright 2008 Roy Marples # 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})