xref: /dragonfly/share/mk/bsd.sys.mk (revision 9e6611d4)
1# $FreeBSD: src/share/mk/bsd.sys.mk,v 1.3.2.5 2002/07/03 16:59:14 des Exp $
2#
3# This file contains common settings used for building DragonFly
4# sources.
5
6CSTD?=	gnu99
7
8.if ${CSTD} == "k&r"
9CFLAGS		+= -traditional
10.elif ${CSTD} == "c89" || ${CSTD} == "c90"
11CFLAGS		+= -std=iso9899:1990
12.elif ${CSTD} == "c94" || ${CSTD} == "c95"
13CFLAGS		+= -std=iso9899:199409
14.elif ${CSTD} == "c99"
15CFLAGS		+= -std=iso9899:1999
16.else
17CFLAGS		+= -std=${CSTD}
18.endif
19
20# Explicitly clear _cnowarnflags (should not be used in Makefiles).
21_cnowarnflags=
22
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.
25
26.if !defined(NO_WARNS)
27. if defined(WARNS)
28.  if ${WARNS} >= 1
29CWARNFLAGS	+=	-Wmissing-include-dirs -Wsystem-headers
30.   if !defined(NO_WERROR) && (${CCVER} == "gcc47" || ${CCVER} == "gcc50")
31CWARNFLAGS	+=	-Werror
32.   endif
33.  endif
34.  if ${WARNS} >= 2
35CWARNFLAGS	+=	-Wall -Wformat-security -Winit-self
36_cnowarnflags	+=	-Wno-pointer-sign
37.  endif
38.  if ${WARNS} >= 3
39CWARNFLAGS	+=	-Wextra -Wstrict-prototypes\
40			-Wmissing-prototypes -Wpointer-arith\
41			-Wold-style-definition
42_cnowarnflags	+=	-Wno-unused-parameter
43.  endif
44.  if ${WARNS} >= 4
45CWARNFLAGS	+=	-Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch\
46			-Wshadow -Wcast-align -Wunused-parameter
47.  endif
48.  if ${WARNS} >= 6
49CWARNFLAGS	+=	-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
83CWARNFLAGS	+=	-Wno-error=inline
84.   endif
85.   if ${WARNS} >= 5 && ${CCVER:Mgcc*}
86CWARNFLAGS	+=	-Wno-error=maybe-uninitialized
87.   endif
88.  endif
89. endif
90
91. if defined(FORMAT_AUDIT)
92WFORMAT		=	1
93. endif
94. if defined(WFORMAT)
95.  if ${WFORMAT} > 0
96CWARNFLAGS	+=	-Wformat=2
97.   if !defined(NO_WERROR) && (${CCVER} == "gcc47" || ${CCVER} == "gcc50")
98CWARNFLAGS	+=	-Werror
99.   endif
100.  endif
101. endif
102.endif
103
104.if defined(NO_WARRAY_BOUNDS)
105_cnowarnflags	+=      -Wno-array-bounds
106.endif
107.if defined(NO_STRICT_OVERFLOW)
108CFLAGS		+=	-fno-strict-overflow
109.endif
110.if defined(NO_STRICT_ALIASING)
111CFLAGS		+=      -fno-strict-aliasing
112.endif
113
114
115# Add -Wno-foo flags last
116.if !defined(WARNS_AUDIT)
117CWARNFLAGS	+=	${_cnowarnflags}
118.endif
119
120# Allow user-specified additional warning flags
121CFLAGS		+=	${CWARNFLAGS}
122
123# Tell bmake not to mistake standard targets for things to be searched for
124# or expect to ever be up-to-date
125PHONY_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
133
134# if given PROG matches anything in the PHONY list, exclude it.
135.PHONY: ${PHONY_NOTMAIN:N${PROG:U}}
136.NOTMAIN: ${PHONY_NOTMAIN}
137