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 ${CC:T:Micc} != "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}
27 .if !defined(NO_WARNS) && ${CC:T:Micc} != "icc"
28 # -pedantic is problematic because it also imposes namespace restrictions
32 CWARNFLAGS += -Wsystem-headers
33 . if !defined(NO_WERROR)
38 CWARNFLAGS += -Wall -Wno-format-y2k
41 CWARNFLAGS += -W -Wno-unused-parameter -Wstrict-prototypes\
42 -Wmissing-prototypes -Wpointer-arith
45 CWARNFLAGS += -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch\
46 -Wshadow -Wunused-parameter
47 . if !defined(NO_WCAST_ALIGN)
48 CWARNFLAGS += -Wcast-align
53 CWARNFLAGS += -Wchar-subscripts -Winline -Wnested-externs\
54 -Wredundant-decls -Wold-style-definition
56 . if ${WARNS} >= 2 && ${WARNS} <= 4
57 # XXX Delete -Wuninitialized by default for now -- the compiler doesn't
58 # XXX always get it right.
59 CWARNFLAGS += -Wno-uninitialized
61 CWARNFLAGS += -Wno-pointer-sign
64 . if defined(FORMAT_AUDIT)
69 #CWARNFLAGS += -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
70 CWARNFLAGS += -Wformat=2 -Wno-format-extra-args
71 . if !defined(NO_WERROR)
78 .if defined(IGNORE_PRAGMA)
79 CWARNFLAGS += -Wno-unknown-pragmas
82 .if ${MK_SSP} != "no" && ${CC:T:Micc} != "icc" && \
83 ${MACHINE_CPUARCH} != "ia64" && \
84 ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
85 # Don't use -Wstack-protector as it breaks world with -Werror.
86 SSP_CFLAGS ?= -fstack-protector
87 CFLAGS += ${SSP_CFLAGS}
90 # Allow user-specified additional warning flags
91 CFLAGS += ${CWARNFLAGS}