Home | History | Annotate | Download | only in mk
      1 # Copyright 2008 Roy Marples <roy (a] marples.name>
      2 
      3 # Setup some good default CFLAGS
      4 CFLAGS?=	-Os
      5 
      6 # Default to using the C99 standard
      7 CSTD?=		c99
      8 _CSTD_SH=	if test -n "${CSTD}"; then echo "-std=${CSTD}"; else echo ""; fi
      9 _CSTD!=		${_CSTD_SH}
     10 CFLAGS+=	${_CSTD}$(shell ${_CSTD_SH})
     11 
     12 # Try and use some good cc flags if we're building from git
     13 _CCFLAGS=	-pedantic -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
     14 		-Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
     15 		-Wbad-function-cast -Wnested-externs -Wcomment -Winline \
     16 		-Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
     17 		-Wdeclaration-after-statement -Wsequence-point -Wextra
     18 _CC_FLAGS_SH=	if ! test -d .git; then echo ""; else for f in ${_CCFLAGS}; do \
     19 		if ${CC} $$f -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
     20 		then printf "%s" "$$f "; fi \
     21 		done; fi
     22 _CC_FLAGS!=	${_CC_FLAGS_SH}
     23 CFLAGS+=	${_CC_FLAGS}$(shell ${_CC_FLAGS_SH})
     24 
     25 _GGDB_SH=	if test "${DEBUG}" = "yes"; then echo "-ggdb -DDEBUG"; else echo ""; fi
     26 _GGDB!=		${_GGDB_SH}
     27 GGDB=		${_GGDB}$(shell ${_GGDB_SH})
     28 CFLAGS+=	${GGDB}
     29