diff options
author | Roy Marples <roy@marples.name> | 2007-04-08 17:39:59 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-04-08 17:39:59 +0000 |
commit | 049948eb099fcdba631a54ff3b30aa7312e942e1 (patch) | |
tree | b85b92cb42dbc060074c61a36688115f150e2cca | |
parent | 6e2ef07dd32af0a672266401bad550a072ff0443 (diff) |
Only use some gcc flags if gcc actually supports them.
-rw-r--r-- | src/Makefile | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/Makefile b/src/Makefile index 4dd0e901..33509c30 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,15 +4,29 @@ CC ?= gcc CFLAGS ?= -Wall -O2 -pipe + +# 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) + +# 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) -Wextra -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ + then echo "-Wdeclaration-after-statement"; fi +WSEQ != if $(CC) -Wextra -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 + +# Loads of nice flags to ensure our code is good CFLAGS += -pedantic -std=c99 \ -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 - -# Early GCC versions don't support these flags, so you may need to comment -# this line out -CFLAGS += -Wsequence-point -Wextra -Wdeclaration-after-statement + -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) # For debugging. -Werror is pointless due to ISO C issues with dlsym #CFLAGS += -ggdb |