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
15 CFLAGS += -traditional
16 .elif ${CSTD} == "c89" || ${CSTD} == "c90"
17 CFLAGS += -std=iso9899:1990
18 .elif ${CSTD} == "c94" || ${CSTD} == "c95"
19 CFLAGS += -std=iso9899:199409
20 .elif ${CSTD} == "c99"
21 CFLAGS += -std=iso9899:1999
23 CFLAGS += -std=${CSTD}
25 .if !defined(NO_WARNS)
26 # -pedantic is problematic because it also imposes namespace restrictions
30 CWARNFLAGS += -Wsystem-headers
31 . if !defined(NO_WERROR) && ((${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang))
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 -Wunused-parameter
45 . if !defined(NO_WCAST_ALIGN) && ((${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang") || !defined(NO_WCAST_ALIGN.clang))
46 CWARNFLAGS += -Wcast-align
51 CWARNFLAGS += -Wchar-subscripts -Winline -Wnested-externs\
52 -Wredundant-decls -Wold-style-definition
54 . if ${WARNS} >= 2 && ${WARNS} <= 4
55 # XXX Delete -Wuninitialized by default for now -- the compiler doesn't
56 # XXX always get it right.
57 CWARNFLAGS += -Wno-uninitialized
59 CWARNFLAGS += -Wno-pointer-sign
60 # Clang has more warnings enabled by default, and when using -Wall, so if WARNS
61 # is set to low values, these have to be disabled explicitly.
62 . if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang"
64 CWARNFLAGS += -Wno-tautological-compare -Wno-unused-value\
65 -Wno-parentheses-equality -Wno-unused-function\
69 CWARNFLAGS += -Wno-switch-enum -Wno-empty-body
72 CWARNFLAGS += -Wno-parentheses
74 . if defined(NO_WARRAY_BOUNDS)
75 CWARNFLAGS += -Wno-array-bounds
80 . if defined(FORMAT_AUDIT)
85 #CWARNFLAGS += -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
86 CWARNFLAGS += -Wformat=2 -Wno-format-extra-args
87 . if !defined(NO_WERROR) && ((${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang))
92 . if defined(NO_WFORMAT) || ((${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && defined(NO_WFORMAT.clang))
93 CWARNFLAGS += -Wno-format
97 .if defined(IGNORE_PRAGMA)
98 CWARNFLAGS += -Wno-unknown-pragmas
101 .if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang"
102 CLANG_NO_IAS = -no-integrated-as
103 CLANG_OPT_SMALL = -mllvm -stack-alignment=8 \
104 -mllvm -inline-threshold=3 \
105 -mllvm -enable-load-pre=false \
106 -mllvm -simplifycfg-dup-ret
109 .if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
110 ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
111 # Don't use -Wstack-protector as it breaks world with -Werror.
112 SSP_CFLAGS ?= -fstack-protector
113 CFLAGS += ${SSP_CFLAGS}
116 # Allow user-specified additional warning flags
117 CFLAGS += ${CWARNFLAGS}