bsd.sys.mk revision 161214
1# $FreeBSD: head/share/mk/bsd.sys.mk 161214 2006-08-11 17:28:59Z des $
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(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# -pedantic is problematic because it also imposes namespace restrictions
25#CFLAGS		+= -pedantic
26. endif
27. if defined(WARNS)
28.  if ${WARNS} >= 1
29CWARNFLAGS	+=	-Wsystem-headers
30.   if !defined(NO_WERROR)
31CWARNFLAGS	+=	-Werror
32.   endif
33.  endif
34.  if ${WARNS} >= 2
35CWARNFLAGS	+=	-Wall -Wno-format-y2k
36.  endif
37.  if ${WARNS} >= 3
38CWARNFLAGS	+=	-W -Wno-unused-parameter -Wstrict-prototypes\
39			-Wmissing-prototypes -Wpointer-arith
40.  endif
41.  if ${WARNS} >= 4
42CWARNFLAGS	+=	-Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch\
43			-Wshadow -Wcast-align -Wunused-parameter
44.  endif
45# BDECFLAGS
46.  if ${WARNS} >= 6
47CWARNFLAGS	+=	-Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls
48.  endif
49.  if ${WARNS} >= 2 && ${WARNS} <= 4
50# XXX Delete -Wuninitialized by default for now -- the compiler doesn't
51# XXX always get it right.
52CWARNFLAGS	+=	-Wno-uninitialized
53.  endif
54. endif
55
56. if defined(FORMAT_AUDIT)
57WFORMAT		=	1
58. endif
59. if defined(WFORMAT)
60.  if ${WFORMAT} > 0
61#CWARNFLAGS	+=	-Wformat-nonliteral -Wformat-security -Wno-format-extra-args
62CWARNFLAGS	+=	-Wformat=2 -Wno-format-extra-args
63.   if !defined(NO_WERROR)
64CWARNFLAGS	+=	-Werror
65.   endif
66.  endif
67. endif
68.endif
69
70# Allow user-specified additional warning flags
71CFLAGS		+=	${CWARNFLAGS}
72