2008-01-09 17:14:43 +05:30
|
|
|
# Copyright 2008 Roy Marples <roy@marples.name>
|
2008-01-06 00:55:55 +05:30
|
|
|
|
|
|
|
# Setup some good default CFLAGS
|
|
|
|
|
2008-01-09 17:14:43 +05:30
|
|
|
CFLAGS?= -O2 -pipe
|
2008-01-06 00:55:55 +05:30
|
|
|
|
2008-02-19 22:19:28 +05:30
|
|
|
CSTD?= c99
|
|
|
|
_CSTD_SH= if test -n "${CSTD}"; then echo "-std=${CSTD}"; else echo ""; fi
|
|
|
|
_CSTD!= ${_CSTD_SH}
|
2008-02-19 23:21:20 +05:30
|
|
|
CFLAGS+= ${_CSTD}$(shell ${_CSTD_SH})
|
2008-02-19 22:19:28 +05:30
|
|
|
|
2008-01-06 00:55:55 +05:30
|
|
|
# GNU Make way of detecting gcc flags we can use
|
2008-01-09 17:14:43 +05:30
|
|
|
check_gcc=$(shell if ${CC} $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
|
|
|
|
then echo "$(1)"; else echo "$(2)"; fi)
|
2008-01-06 00:55:55 +05:30
|
|
|
|
|
|
|
# pmake check for extra cflags
|
2008-01-09 17:14:43 +05:30
|
|
|
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; \
|
2008-01-06 00:55:55 +05:30
|
|
|
then echo -n "$$x "; fi \
|
|
|
|
done
|
|
|
|
|
|
|
|
# Loads of nice flags to ensure our code is good
|
2008-01-18 16:57:49 +05:30
|
|
|
CFLAGS+= -pedantic \
|
2008-01-09 17:14:43 +05:30
|
|
|
-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}
|