bsd.sys.mk revision 115640
1203134Sthompsa# $FreeBSD: head/share/mk/bsd.sys.mk 115640 2003-06-01 21:33:05Z obrien $
2203134Sthompsa#
3203134Sthompsa# This file contains common settings used for building FreeBSD
4203134Sthompsa# sources.
5205042Sthompsa
6205042Sthompsa# Enable various levels of compiler warning checks.  These may be
7203134Sthompsa# overridden (e.g. if using a non-gcc compiler) by defining NO_WARNS.
8203134Sthompsa
9203134Sthompsa# for GCC:  http://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_3.html#IDX143
10203134Sthompsa
11203134Sthompsa.if !defined(PROG_CXX)
12203134SthompsaCSTD		?=	c99
13203134Sthompsa. if ${CSTD} == "k&r"
14203134SthompsaCFLAGS		+=	-traditional
15203134Sthompsa. elif ${CSTD} == "c89" || ${CSTD} == "c90"
16203134SthompsaCFLAGS		+=	-std=iso9899:1990
17203134Sthompsa. elif ${CSTD} == "c94" || ${CSTD} == "c95"
18203134SthompsaCFLAGS		+=	-std=iso9899:199409
19203134Sthompsa. elif ${CSTD} == "c99"
20203134SthompsaCFLAGS		+=	-std=iso9899:1999
21203134Sthompsa. else
22203134SthompsaCFLAGS		+=	-std=${CSTD}
23203134Sthompsa. endif
24203134Sthompsa.endif
25203134Sthompsa
26203134Sthompsa.if !defined(NO_WARNS)
27203134Sthompsa. if defined(WARNS)
28203134Sthompsa.  if ${WARNS} > 0
29203134SthompsaCFLAGS		+=	-Wsystem-headers
30203134Sthompsa.   if !defined(NO_WERROR)
31203134SthompsaCFLAGS		+=	-Werror
32203134Sthompsa.   endif
33203134Sthompsa.  endif
34203134Sthompsa.  if ${WARNS} > 1
35203134SthompsaCFLAGS		+=	-Wall -Wno-format-y2k
36203134Sthompsa.  endif
37203134Sthompsa.  if ${WARNS} > 2
38203134SthompsaCFLAGS		+=	-W -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
39203134Sthompsa.  endif
40203134Sthompsa.  if ${WARNS} > 3
41203134SthompsaCFLAGS		+=	-Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align
42203134Sthompsa.  endif
43203134Sthompsa#	XXX: the warning that was here became problematic.
44203134Sthompsa#.  if ${WARNS} > 4
45203134Sthompsa# BDECFLAGS
46203134Sthompsa.  if ${WARNS} > 5
47203134Sthompsa.   if defined(CSTD)
48203134SthompsaCFLAGS		+=	-pedantic
49203134Sthompsa.   endif
50203134SthompsaCFLAGS		+=	-Wbad-function-cast -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls
51203134Sthompsa.  endif
52203134Sthompsa.  if ${WARNS} > 1 && ${WARNS} < 5
53203134Sthompsa# XXX Delete -Wuninitialized by default for now -- the compiler doesn't
54203134Sthompsa# XXX always get it right.
55203134SthompsaCFLAGS		+=	-Wno-uninitialized
56203134Sthompsa.  endif
57203134Sthompsa. endif
58203134Sthompsa
59203134Sthompsa. if defined(FORMAT_AUDIT)
60203134SthompsaWFORMAT		=	1
61203134Sthompsa. endif
62203134Sthompsa. if defined(WFORMAT)
63203134Sthompsa.  if ${WFORMAT} > 0
64203134Sthompsa#CFLAGS		+=	-Wformat-nonliteral -Wformat-security -Wno-format-extra-args
65203134SthompsaCFLAGS		+=	-Wformat=2 -Wno-format-extra-args
66203134Sthompsa.   if !defined(NO_WERROR)
67203134SthompsaCFLAGS		+=	-Werror
68203134Sthompsa.   endif
69203134Sthompsa.  endif
70203134Sthompsa. endif
71203134Sthompsa.endif
72203134Sthompsa
73203134Sthompsa# Allow user-specified additional warning flags
74203134SthompsaCFLAGS		+=	${CWARNFLAGS}
75203134Sthompsa