periodic(8): Sync with FreeBSD current
[dragonfly.git] / share / mk / bsd.sys.mk
blob4bc3220d63d9e8699056106c8acf97fbec23ee99
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
4 # sources.
6 CSTD?= gnu99
8 .if ${CSTD} == "k&r"
9 CFLAGS += -traditional
10 .elif ${CSTD} == "c89" || ${CSTD} == "c90"
11 CFLAGS += -std=iso9899:1990
12 .elif ${CSTD} == "c94" || ${CSTD} == "c95"
13 CFLAGS += -std=iso9899:199409
14 .elif ${CSTD} == "c99"
15 CFLAGS += -std=iso9899:1999
16 .else
17 CFLAGS += -std=${CSTD}
18 .endif
20 # Explicitly clear _cnowarnflags (should not be used in Makefiles).
21 _cnowarnflags=
23 # Enable various levels of compiler warning checks. These may be
24 # overridden (e.g. if using a non-gcc compiler) by defining NO_WARNS.
26 .if !defined(NO_WARNS)
27 . if defined(WARNS)
28 . if ${WARNS} >= 1
29 CWARNFLAGS += -Wmissing-include-dirs -Wsystem-headers
30 . if !defined(NO_WERROR) && (${CCVER} == "gcc47" || ${CCVER} == "gcc50")
31 CWARNFLAGS += -Werror
32 . endif
33 . endif
34 . if ${WARNS} >= 2
35 CWARNFLAGS += -Wall -Wformat-security -Winit-self
36 _cnowarnflags += -Wno-pointer-sign
37 . endif
38 . if ${WARNS} >= 3
39 CWARNFLAGS += -Wextra -Wstrict-prototypes\
40 -Wmissing-prototypes -Wpointer-arith\
41 -Wold-style-definition
42 _cnowarnflags += -Wno-unused-parameter
43 . endif
44 . if ${WARNS} >= 4
45 CWARNFLAGS += -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch\
46 -Wshadow -Wcast-align -Wunused-parameter
47 . endif
48 . if ${WARNS} >= 6
49 CWARNFLAGS += -Wchar-subscripts -Winline -Wnested-externs\
50 -Wredundant-decls
51 . endif
52 . if ${WARNS} >= 2 && ${WARNS} <= 4
53 # XXX Delete -Wmaybe-uninitialized by default for now -- the compiler doesn't
54 # XXX always get it right.
55 . if ${CCVER:Mgcc*}
56 _cnowarnflags += -Wno-maybe-uninitialized
57 . else
58 _cnowarnflags += -Wno-uninitialized
59 . endif
60 . endif
61 # Activate gcc47's -Wunused-but-set-variable (which is in -Wall) and
62 # -Wunused-but-set-parameter (which is in -Wextra) only at WARNS >= 4
63 # (which is the level when also -Wunused-parameter comes into play).
64 . if ${WARNS} >= 2 && ${WARNS} <= 3 && ${CCVER:Mgcc*}
65 _cnowarnflags += -Wno-unused-but-set-variable
66 . endif
67 . if ${WARNS} == 3 && ${CCVER:Mgcc*}
68 _cnowarnflags += -Wno-unused-but-set-parameter
69 . endif
70 . if ${WARNS} == 3 && (${CCVER:Mgcc49} || ${CCVER:Mgcc[5-]*})
71 _cnowarnflags += -Wno-unused-value
72 . endif
73 . if ${WARNS} >= 2 && ${CCVER:Mgcc4[789]}
74 _cnowarnflags += -Wno-error=maybe-uninitialized\
75 -Wno-error=uninitialized\
76 -Wno-error=shadow
77 . endif
78 # Disable -Werror selectively for -Os and -Og compilations. Both -Winline and
79 # -Wmaybe-uninitialized are noisy and should be caught by standard -O and -O2.
80 # These are still useful diagnostics while investigating compilation issues.
81 . if defined(WORLD_CCOPTLEVEL) && (${WORLD_CCOPTLEVEL:Mg} || ${WORLD_CCOPTLEVEL:Ms})
82 . if ${WARNS} >= 6
83 CWARNFLAGS += -Wno-error=inline
84 . endif
85 . if ${WARNS} >= 5 && ${CCVER:Mgcc*}
86 CWARNFLAGS += -Wno-error=maybe-uninitialized
87 . endif
88 . endif
89 . endif
91 . if defined(FORMAT_AUDIT)
92 WFORMAT = 1
93 . endif
94 . if defined(WFORMAT)
95 . if ${WFORMAT} > 0
96 CWARNFLAGS += -Wformat=2
97 . if !defined(NO_WERROR) && (${CCVER} == "gcc47" || ${CCVER} == "gcc50")
98 CWARNFLAGS += -Werror
99 . endif
100 . endif
101 . endif
102 .endif
104 .if defined(NO_WARRAY_BOUNDS)
105 _cnowarnflags += -Wno-array-bounds
106 .endif
107 .if defined(NO_STRICT_OVERFLOW)
108 CFLAGS += -fno-strict-overflow
109 .endif
110 .if defined(NO_STRICT_ALIASING)
111 CFLAGS += -fno-strict-aliasing
112 .endif
115 # Add -Wno-foo flags last
116 .if !defined(WARNS_AUDIT)
117 CWARNFLAGS += ${_cnowarnflags}
118 .endif
120 # Allow user-specified additional warning flags
121 CFLAGS += ${CWARNFLAGS}
123 # Tell bmake not to mistake standard targets for things to be searched for
124 # or expect to ever be up-to-date
125 PHONY_NOTMAIN = afterdepend afterinstall all beforedepend beforeinstall \
126 beforelinking build build-tools buildfiles buildincludes \
127 checkdpadd clean cleandepend cleandir cleanobj configure \
128 depend dependall distclean distribute exe extract fetch \
129 html includes install installfiles installincludes lint \
130 obj objlink objs objwarn patch realall realdepend \
131 realinstall regress subdir-all subdir-depend subdir-install \
132 tags whereobj
134 # if given PROG matches anything in the PHONY list, exclude it.
135 .PHONY: ${PHONY_NOTMAIN:N${PROG:U}}
136 .NOTMAIN: ${PHONY_NOTMAIN}