3 # This file contains common settings used for building FreeBSD
6 # Enable various levels of compiler warning checks. These may be
7 # overridden (e.g. if using a non-gcc compiler) by defining NO_WARNS.
9 # for GCC: http://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_3.html#IDX143
11 # the default is gnu99 for now
14 .if !defined(NO_WARNS) && ${CC} != "icc"
16 CFLAGS += -traditional
17 . elif ${CSTD} == "c89" || ${CSTD} == "c90"
18 CFLAGS += -std=iso9899:1990
19 . elif ${CSTD} == "c94" || ${CSTD} == "c95"
20 CFLAGS += -std=iso9899:199409
21 . elif ${CSTD} == "c99"
22 CFLAGS += -std=iso9899:1999
24 CFLAGS += -std=${CSTD}
26 # -pedantic is problematic because it also imposes namespace restrictions
30 CWARNFLAGS += -Wsystem-headers
31 . if !defined(NO_WERROR)
36 CWARNFLAGS += -Wall -Wno-format-y2k
39 CWARNFLAGS += -W -Wno-unused-parameter -Wstrict-prototypes\
40 -Wmissing-prototypes -Wpointer-arith
43 CWARNFLAGS += -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch\
44 -Wshadow -Wcast-align -Wunused-parameter
48 CWARNFLAGS += -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls
50 . if ${WARNS} >= 2 && ${WARNS} <= 4
51 # XXX Delete -Wuninitialized by default for now -- the compiler doesn't
52 # XXX always get it right.
53 CWARNFLAGS += -Wno-uninitialized
55 . if !defined(WITH_GCC3)
56 CWARNFLAGS += -Wno-pointer-sign
60 . if defined(FORMAT_AUDIT)
65 #CWARNFLAGS += -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
66 CWARNFLAGS += -Wformat=2 -Wno-format-extra-args
67 . if !defined(NO_WERROR)
74 .if defined(IGNORE_PRAGMA)
75 CWARNFLAGS += -Wno-unknown-pragmas
78 .if ${MK_SSP} != "no" && ${CC} != "icc" && ${MACHINE_ARCH} != "ia64" && \
79 ${MACHINE_ARCH} != "arm" && ${MACHINE_ARCH} != "mips"
80 # Don't use -Wstack-protector as it breaks world with -Werror.
81 SSP_CFLAGS ?= -fstack-protector
82 CFLAGS += ${SSP_CFLAGS}
85 # Allow user-specified additional warning flags
86 CFLAGS += ${CWARNFLAGS}