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-02-20 16:04:11 +05:30
|
|
|
CFLAGS?= -O2
|
2008-01-06 00:55:55 +05:30
|
|
|
|
2008-02-20 16:04:11 +05:30
|
|
|
# Default to using the C99 standard
|
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-09-18 19:19:58 +05:30
|
|
|
# Try and use some good cc flags if we're building from git
|
|
|
|
# We don't use -pedantic as it will warn about our perfectly valid
|
|
|
|
# use of %m in our logger.
|
|
|
|
_CCFLAGS= -Wall -Wextra -Wimplicit -Wshadow -Wformat=2 \
|
|
|
|
-Wmissing-prototypes -Wmissing-declarations \
|
|
|
|
-Wmissing-noreturn -Wmissing-format-attribute \
|
|
|
|
-Wnested-externs \
|
|
|
|
-Winline -Wwrite-strings -Wcast-align -Wcast-qual \
|
|
|
|
-Wpointer-arith \
|
|
|
|
-Wdeclaration-after-statement -Wsequence-point
|
|
|
|
|
|
|
|
# We should be using -Wredundant-decls, but our library hidden proto stuff
|
|
|
|
# gives loads of warnings. I don't fully understand it (the hidden proto,
|
|
|
|
# not the warning) so we just silence the warning.
|
|
|
|
|
|
|
|
_CC_FLAGS_SH= for f in ${_CCFLAGS}; do \
|
|
|
|
if echo "int main(void) { return 0;} " | \
|
|
|
|
${CC} $$f -S -xc -o /dev/null - ; \
|
2008-02-20 16:04:11 +05:30
|
|
|
then printf "%s" "$$f "; fi \
|
2008-09-18 19:19:58 +05:30
|
|
|
done;
|
2008-02-20 16:04:11 +05:30
|
|
|
_CC_FLAGS!= ${_CC_FLAGS_SH}
|
2008-09-18 19:19:58 +05:30
|
|
|
CFLAGS+= ${_CC_FLAGS}$(shell ${_CC_FLAGS_SH})
|