xref: /freebsd/share/mk/bsd.sys.mk (revision 09e8dea79366f1e5b3a73e8a271b26e4b6bf2e6a)
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)
12. if defined(WARNS)
13.  if ${WARNS} > 0
14.  endif
15.  if ${WARNS} > 1
16CFLAGS		+=	-Wall -Wno-format-y2k
17.  endif
18.  if ${WARNS} > 2
19CFLAGS		+=	-W -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
20.  endif
21.  if ${WARNS} > 3
22CFLAGS		+=	-Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align
23.  endif
24.  if ${WARNS} > 4
25CFLAGS		+=	-Wuninitialized
26.  endif
27# BDECFLAGS
28.  if ${WARNS} > 5
29CFLAGS		+=	-ansi -pedantic -Wbad-function-cast -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls
30.  endif
31.  if ${WARNS} > 1 && ${WARNS} < 5
32# XXX Delete -Wuninitialized by default for now -- the compiler doesn't
33# XXX always get it right.
34CFLAGS		+=	-Wno-uninitialized
35.  endif
36. endif
37
38. if defined(FORMAT_AUDIT)
39WFORMAT		=	1
40. endif
41. if defined(WFORMAT)
42.  if ${WFORMAT} > 0
43#CFLAGS		+=	-Wformat-nonliteral -Wformat-security -Wno-format-extra-args
44CFLAGS		+=	-Wformat=2 -Wno-format-extra-args
45.  endif
46. endif
47.endif
48
49# Allow user-specified additional warning flags
50CFLAGS		+=	${CWARNFLAGS}
51
52# FreeBSD prior to 4.5 didn't have the __FBSDID() macro in <sys/cdefs.h>.
53.if defined(BOOTSTRAPPING)
54CFLAGS+=	-D__FBSDID=__RCSID
55.endif
56