1 # $FreeBSD: src/share/mk/bsd.sys.mk,v 1.3.2.5 2002/07/03 16:59:14 des Exp $
3 # This file contains common settings used for building DragonFly
6 # Support handling -W flags for both host cc and target cc.
7 .if defined(__USE_HOST_CCVER)
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 # Explicitly clear _cnowarnflags (should not be used in Makefiles).
30 # Enable various levels of compiler warning checks. These may be
31 # overridden (e.g. if using a non-gcc compiler) by defining NO_WARNS.
33 .if !defined(NO_WARNS)
36 CWARNFLAGS += -Wmissing-include-dirs -Wsystem-headers
37 . if !defined(NO_WERROR) && (${_WCCVER} == "gcc47" || ${_WCCVER} == "gcc80")
42 CWARNFLAGS += -Wall -Wformat-security -Winit-self
45 CWARNFLAGS += -Wextra -Wstrict-prototypes\
46 -Wmissing-prototypes -Wpointer-arith\
47 -Wold-style-definition
50 CWARNFLAGS += -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch\
51 -Wshadow -Wcast-align -Wunused-parameter
54 CWARNFLAGS += -Wchar-subscripts -Winline -Wnested-externs\
57 . if ${WARNS} >= 2 && ${WARNS} <= 6
58 # Delete -Wno-pointer-sign from -Wall by default (C only).
59 _cnowarnflags += -Wno-pointer-sign
61 . if ${WARNS} >= 2 && ${WARNS} <= 4
62 # XXX Delete -Wmaybe-uninitialized by default for now -- the compiler doesn't
63 # XXX always get it right.
65 _cnowarnflags += -Wno-maybe-uninitialized
67 _cnowarnflags += -Wno-uninitialized
71 # Delete -Wno-unused-parameter from -Wextra by default only if WARNS < 4.
72 _cnowarnflags += -Wno-unused-parameter
74 # Delete -Wformat-* family that give little benefits, same for stringop.
75 . if ${WARNS} >= 2 && ${WARNS} <= 6 && ${_WCCVER:Mgcc8*}
76 _cnowarnflags += -Wno-format-overflow -Wno-format-truncation
77 _cnowarnflags += -Wno-stringop-truncation
79 . if ${WARNS} >= 1 && ${WARNS} <= 6 && ${_WCCVER:Mgcc8*}
80 _cnowarnflags += -Wno-stringop-overflow
82 # Activate gcc47's -Wunused-but-set-variable (which is in -Wall) and
83 # -Wunused-but-set-parameter (which is in -Wextra) only at WARNS >= 4
84 # (which is the level when also -Wunused-parameter comes into play).
85 . if ${WARNS} >= 2 && ${WARNS} <= 3 && ${_WCCVER:Mgcc*}
86 _cnowarnflags += -Wno-unused-but-set-variable
88 . if ${WARNS} == 3 && ${_WCCVER:Mgcc*}
89 _cnowarnflags += -Wno-unused-but-set-parameter
91 . if ${WARNS} == 3 && (${_WCCVER:Mgcc49} || ${_WCCVER:Mgcc[5-]*})
92 _cnowarnflags += -Wno-unused-value
94 . if ${WARNS} == 3 && ${_WCCVER:Mgcc8*}
95 _cnowarnflags += -Wno-implicit-fallthrough
97 . if ${WARNS} >= 2 && ${_WCCVER:Mgcc4[789]}
98 _cnowarnflags += -Wno-error=maybe-uninitialized\
99 -Wno-error=uninitialized\
102 # Disable -Werror selectively for -Os and -Og compilations. Both -Winline and
103 # -Wmaybe-uninitialized are noisy and should be caught by standard -O and -O2.
104 # These are still useful diagnostics while investigating compilation issues.
105 . if defined(WORLD_CCOPTLEVEL) && (${WORLD_CCOPTLEVEL:Mg} || ${WORLD_CCOPTLEVEL:Ms})
107 CWARNFLAGS += -Wno-error=inline
109 . if ${WARNS} >= 5 && ${_WCCVER:Mgcc*}
110 CWARNFLAGS += -Wno-error=maybe-uninitialized
115 . if defined(FORMAT_AUDIT)
118 . if defined(WFORMAT)
120 CWARNFLAGS += -Wformat=2
121 . if !defined(NO_WERROR) && (${_WCCVER} == "gcc47" || ${_WCCVER} == "gcc80")
122 CWARNFLAGS += -Werror
128 # Build world with -fno-common. This will be default with GCC 10.
130 .if ${_WCCVER:Ngcc1[0-9][0-9]}
131 CFLAGS += -fno-common
134 .if defined(NO_WCAST_FUNCTION_TYPE) && ${WARNS} >= 3 && ${_WCCVER:Mgcc8*}
135 _cnowarnflags += -Wno-cast-function-type
137 .if defined(NO_WARRAY_BOUNDS)
138 _cnowarnflags += -Wno-array-bounds
140 .if defined(NO_STRICT_OVERFLOW)
141 CFLAGS += -fno-strict-overflow
143 .if defined(NO_STRICT_ALIASING)
144 CFLAGS += -fno-strict-aliasing
148 # Add -Wno-foo flags last
149 .if !defined(WARNS_AUDIT)
150 CWARNFLAGS += ${_cnowarnflags}
153 # Allow user-specified additional warning flags
154 CFLAGS += ${CWARNFLAGS}
156 # Tell bmake not to mistake standard targets for things to be searched for
157 # or expect to ever be up-to-date
158 PHONY_NOTMAIN = afterdepend afterinstall all beforedepend beforeinstall \
159 beforelinking build build-tools buildfiles buildincludes \
160 checkdpadd clean cleandepend cleandir cleanobj configure \
161 depend dependall distclean distribute exe extract fetch \
162 html includes install installfiles installincludes lint \
163 obj objlink objs objwarn patch realall realdepend \
164 realinstall regress subdir-all subdir-depend subdir-install \
167 # if given PROG matches anything in the PHONY list, exclude it.
168 .PHONY: ${PHONY_NOTMAIN:N${PROG:U}}
169 .NOTMAIN: ${PHONY_NOTMAIN}