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-4.2.1/gcc/Warning-Options.html
11 # the default is gnu99 for now
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
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" && \
32 ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang))
34 .endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang)
37 CWARNFLAGS+= -Wall -Wno-format-y2k
40 CWARNFLAGS+= -W -Wno-unused-parameter -Wstrict-prototypes\
41 -Wmissing-prototypes -Wpointer-arith
44 CWARNFLAGS+= -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow\
46 .if !defined(NO_WCAST_ALIGN) && ((${MK_CLANG_IS_CC} == "no" && \
47 ${CC:T:Mclang} != "clang") || !defined(NO_WCAST_ALIGN.clang))
48 CWARNFLAGS+= -Wcast-align
49 .endif # !NO_WCAST_ALIGN && (!CLANG || !NO_WCAST_ALIGN.clang)
53 CWARNFLAGS+= -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls\
54 -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
60 .endif # WARNS >=2 && WARNS <= 4
61 CWARNFLAGS+= -Wno-pointer-sign
62 # Clang has more warnings enabled by default, and when using -Wall, so if WARNS
63 # is set to low values, these have to be disabled explicitly.
64 .if (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && \
67 CWARNFLAGS+= -Wno-empty-body -Wno-string-plus-int
70 CWARNFLAGS+= -Wno-tautological-compare -Wno-unused-value\
71 -Wno-parentheses-equality -Wno-unused-function -Wno-conversion
74 CWARNFLAGS+= -Wno-switch -Wno-switch-enum
77 CWARNFLAGS+= -Wno-parentheses
79 .if defined(NO_WARRAY_BOUNDS)
80 CWARNFLAGS+= -Wno-array-bounds
81 .endif # NO_WARRAY_BOUNDS
85 .if defined(FORMAT_AUDIT)
90 #CWARNFLAGS+= -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
91 CWARNFLAGS+= -Wformat=2 -Wno-format-extra-args
92 .if (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && \
95 CWARNFLAGS+= -Wno-format-nonliteral
98 .if !defined(NO_WERROR) && ((${MK_CLANG_IS_CC} == "no" && \
99 ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang))
101 .endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang)
104 .if defined(NO_WFORMAT) || ((${MK_CLANG_IS_CC} != "no" || \
105 ${CC:T:Mclang} == "clang") && defined(NO_WFORMAT.clang))
106 CWARNFLAGS+= -Wno-format
107 .endif # NO_WFORMAT || (CLANG && NO_WFORMAT.clang)
110 .if defined(IGNORE_PRAGMA)
111 CWARNFLAGS+= -Wno-unknown-pragmas
112 .endif # IGNORE_PRAGMA
114 .if (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && \
115 !defined(EARLY_BUILD)
116 CLANG_NO_IAS= -no-integrated-as
117 CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\
118 -mllvm -enable-load-pre=false -mllvm -simplifycfg-dup-ret
119 CFLAGS+= -Qunused-arguments
122 .if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
123 ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
124 # Don't use -Wstack-protector as it breaks world with -Werror.
125 SSP_CFLAGS?= -fstack-protector
126 CFLAGS+= ${SSP_CFLAGS}
127 .endif # SSP && !IA64 && !ARM && !MIPS
129 # Allow user-specified additional warning flags
130 CFLAGS+= ${CWARNFLAGS}