xref: /freebsd/share/mk/bsd.sys.mk (revision 390e8cc2974df1888369c06339ef8e0e92b312b6)
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
11CSTD		?=
12.if ${CSTD} != ""
13. if ${CSTD} == "k&r"
14CFLAGS		+=	-traditional
15. elif ${CSTD} == "c89" || ${CSTD} == "c90"
16CFLAGS		+=	-std=iso9899:1990
17. elif ${CSTD} == "c94" || ${CSTD} == "c95"
18CFLAGS		+=	-std=iso9899:199409
19. elif ${CSTD} == "c99"
20CFLAGS		+=	-std=iso9899:1999
21. else
22CFLAGS		+=	-std=${CSTD}
23. endif
24.endif
25
26.if !defined(NO_WARNS)
27. if defined(WARNS)
28.  if ${WARNS} > 0
29CFLAGS		+=	-Wsystem-headers
30.   if !defined(NO_WERROR)
31CFLAGS		+=	-Werror
32.   endif
33.  endif
34.  if ${WARNS} > 1
35CFLAGS		+=	-Wall -Wno-format-y2k
36.  endif
37.  if ${WARNS} > 2
38CFLAGS		+=	-W -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
39.  endif
40.  if ${WARNS} > 3
41CFLAGS		+=	-Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align
42.  endif
43#	XXX: the warning that was here became problematic.
44#.  if ${WARNS} > 4
45# BDECFLAGS
46.  if ${WARNS} > 5
47.   if ${CSTD} != ""
48CFLAGS		+=	-pedantic
49.   endif
50CFLAGS		+=	-Wbad-function-cast -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls
51.  endif
52.  if ${WARNS} > 1 && ${WARNS} < 5
53# XXX Delete -Wuninitialized by default for now -- the compiler doesn't
54# XXX always get it right.
55CFLAGS		+=	-Wno-uninitialized
56.  endif
57. endif
58
59. if defined(FORMAT_AUDIT)
60WFORMAT		=	1
61. endif
62. if defined(WFORMAT)
63.  if ${WFORMAT} > 0
64#CFLAGS		+=	-Wformat-nonliteral -Wformat-security -Wno-format-extra-args
65CFLAGS		+=	-Wformat=2 -Wno-format-extra-args
66.   if !defined(NO_WERROR)
67CFLAGS		+=	-Werror
68.   endif
69.  endif
70. endif
71.endif
72
73# Allow user-specified additional warning flags
74CFLAGS		+=	${CWARNFLAGS}
75