xref: /freebsd/share/mk/bsd.sys.mk (revision 4f29da19bd44f0e99f021510460a81bf754c21d2)
1# $FreeBSD$
2#
3# This file contains common settings used for building FreeBSD
4# sources.
5
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.
8
9# for GCC:  http://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_3.html#IDX143
10
11.if !defined(NO_WARNS) && ${CC} != "icc"
12. if defined(WARNS)
13.  if ${WARNS} >= 1
14CWARNFLAGS	+=	-Wsystem-headers
15.   if !defined(NO_WERROR)
16CWARNFLAGS	+=	-Werror
17.   endif
18.  endif
19.  if ${WARNS} >= 2
20CWARNFLAGS	+=	-Wall -Wno-format-y2k
21.  endif
22.  if ${WARNS} >= 3
23CWARNFLAGS	+=	-W -Wno-unused-parameter -Wstrict-prototypes\
24			-Wmissing-prototypes -Wpointer-arith
25.  endif
26.  if ${WARNS} >= 4
27CWARNFLAGS	+=	-Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch\
28			-Wshadow -Wcast-align -Wunused-parameter
29.  endif
30# BDECFLAGS
31.  if ${WARNS} >= 6
32CWARNFLAGS	+=	-Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls
33.  endif
34.  if ${WARNS} >= 2 && ${WARNS} <= 4
35# XXX Delete -Wuninitialized by default for now -- the compiler doesn't
36# XXX always get it right.
37CWARNFLAGS	+=	-Wno-uninitialized
38.  endif
39. endif
40
41. if defined(FORMAT_AUDIT)
42WFORMAT		=	1
43. endif
44. if defined(WFORMAT)
45.  if ${WFORMAT} > 0
46#CWARNFLAGS	+=	-Wformat-nonliteral -Wformat-security -Wno-format-extra-args
47CWARNFLAGS	+=	-Wformat=2 -Wno-format-extra-args
48.   if !defined(NO_WERROR)
49CWARNFLAGS	+=	-Werror
50.   endif
51.  endif
52. endif
53.endif
54
55# Allow user-specified additional warning flags
56CFLAGS		+=	${CWARNFLAGS}
57