From d39f4505a16ac8fc618dafe6b541f9674a1dad2c Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 25 May 2016 23:28:14 -0500 Subject: [PATCH] Compatibility with older versions of GCC --- Makefile | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e88a8c4..29c7560 100644 --- a/Makefile +++ b/Makefile @@ -35,11 +35,20 @@ endif ############################################################################## -#### Common compiler flags; not intended to be overridden +#### Common compiler flags. +#### Flags given here are not intended to be overridden, but you can add more +#### by defining CFLAGS in the environment or on the 'make' command line. -override CFLAGS += -O2 -fomit-frame-pointer -std=c99 -I. -Icommon \ - -Wall -Wpedantic -Wundef -Wdeclaration-after-statement \ - -Wmissing-prototypes -Wstrict-prototypes +override CFLAGS := \ + $(CFLAGS) -O2 -fomit-frame-pointer -std=c99 -I. -Icommon \ + -Wall -Wundef \ + $(call cc-option,-Wpedantic) \ + $(call cc-option,-Wdeclaration-after-statement) \ + $(call cc-option,-Wmissing-prototypes) \ + $(call cc-option,-Wstrict-prototypes) + +cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null \ + 1>&2 2>/dev/null; then echo $(1); fi) ##############################################################################