xref: /freebsd/share/mk/bsd.sys.mk (revision 9207b4cff7b8d483f4dd3c62266c2b58819eb7f9)
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.if !defined(NO_WARNS)
10. if defined(WARNS)
11.  if ${WARNS} > 0
12.   if !defined(NO_WERROR)
13CFLAGS		+=	-Werror
14.   endif
15.  endif
16.  if ${WARNS} > 1
17CFLAGS		+=	-Wall
18# XXX Delete -Wuninitialized by default for now -- the compiler doesn't
19# XXX always get it right.
20CFLAGS		+=	-Wno-uninitialized
21.  endif
22.  if ${WARNS} > 2
23CFLAGS		+=	-W -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
24.  endif
25.  if ${WARNS} > 3
26CFLAGS		+=	-Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align
27.  endif
28. endif
29
30. if defined(FORMAT_AUDIT)
31WFORMAT		=	1
32. endif
33. if defined(WFORMAT)
34.  if ${WFORMAT} > 0
35CFLAGS		+=	-Wnon-const-format -Wno-format-extra-args
36.   if !defined(NO_WERROR)
37CFLAGS		+=	-Werror
38.   endif
39.  endif
40. endif
41.endif
42
43# Allow user-specified additional warning flags
44CFLAGS		+=	${CWARNFLAGS}
45