From: Roy Marples Date: Fri, 24 Aug 2007 11:05:38 +0000 (+0000) Subject: Loopify the pmake gcc flag detection X-Git-Tag: v3.2.3~204 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1d07a4ec414fa76dfb3ea837f63a7699187a9c8;p=thirdparty%2Fdhcpcd.git Loopify the pmake gcc flag detection --- diff --git a/Makefile b/Makefile index af449ee0..53b77e8f 100644 --- a/Makefile +++ b/Makefile @@ -1,32 +1,28 @@ +# Should work for both GNU make and BSD make VERSION = 3.1.5 CFLAGS ?= -O2 -pipe -# Should work for both GNU make and BSD make - # Saying that, this function only works with GNU Make :/ check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ - then echo "$(1)"; else echo "$(2)"; fi) + then echo "$(1)"; else echo "$(2)"; fi) # Luckily we can do this more long winded thing with pmake used by the BSDs -# FIXME: Look into making this into a loop -WAFTST != if $(CC) -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ - then echo "-Wdeclaration-after-statement"; fi -WSEQ != if $(CC) -Wsequence-point -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ - then echo "-Wsequence-point"; fi -WEXTRA != if $(CC) -Wextra -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ - then echo "-Wextra"; fi +WEXTRA != for x in -Wdeclaration-after-statement -Wsequence-point -Wextra ; do \ + if $(CC) -Wdeclaration-after-statement -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 # IMPORTANT: We should be using c99 instead of gnu99 but for some reason # generic linux headers as of 2.6.19 don't allow this in asm/types.h CFLAGS += -pedantic -std=gnu99 \ - -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) $(WAFTST) $(WSEQ) $(WEXTRA) + -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) # -Werrror is a good flag to use for development, but some platforms may # have buggy headers from time to time, so you may need to comment this out @@ -47,7 +43,7 @@ TARGET = $(SBIN_TARGETS) dhcpcd_H = version.h dhcpcd_OBJS = arp.o client.o common.o configure.o dhcp.o dhcpcd.o duid.o \ - info.o interface.o ipv4ll.o logger.o signals.o socket.o + info.o interface.o ipv4ll.o logger.o signals.o socket.o # Darwin needs this, but we have no way of detecting this atm #LIBRESOLV = -lresolv