bsd.sys.mk revision 180012
1# $FreeBSD: head/share/mk/bsd.sys.mk 180012 2008-06-25 21:33:28Z ru $
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.  if !defined(WITH_GCC3)
55CWARNFLAGS	+=	-Wno-pointer-sign
56.  endif
57. endif
58
59. if defined(FORMAT_AUDIT)
60WFORMAT		=	1
61. endif
62. if defined(WFORMAT)
63.  if ${WFORMAT} > 0
64#CWARNFLAGS	+=	-Wformat-nonliteral -Wformat-security -Wno-format-extra-args
65CWARNFLAGS	+=	-Wformat=2 -Wno-format-extra-args
66.   if !defined(NO_WERROR)
67CWARNFLAGS	+=	-Werror
68.   endif
69.  endif
70. endif
71.endif
72
73.if defined(IGNORE_PRAGMA)
74CWARNFLAGS	+=	-Wno-unknown-pragmas
75.endif
76
77.if ${MK_SSP} != "no" && ${CC} != "icc" && ${MACHINE_ARCH} != "ia64"
78# Don't use -Wstack-protector as it breaks world with -Werror.
79SSP_CFLAGS	?=	-fstack-protector
80CFLAGS		+=	${SSP_CFLAGS}
81.endif
82
83# Allow user-specified additional warning flags
84CFLAGS		+=	${CWARNFLAGS}
85