]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - share/mk/bsd.sys.mk
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / share / mk / bsd.sys.mk
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 # the default is gnu99 for now
12 CSTD            ?= gnu99
13
14 .if !defined(NO_WARNS) && ${CC} != "icc"
15 . if ${CSTD} == "k&r"
16 CFLAGS          += -traditional
17 . elif ${CSTD} == "c89" || ${CSTD} == "c90"
18 CFLAGS          += -std=iso9899:1990
19 . elif ${CSTD} == "c94" || ${CSTD} == "c95"
20 CFLAGS          += -std=iso9899:199409
21 . elif ${CSTD} == "c99"
22 CFLAGS          += -std=iso9899:1999
23 . else
24 CFLAGS          += -std=${CSTD}
25 . endif
26 # -pedantic is problematic because it also imposes namespace restrictions
27 #CFLAGS         += -pedantic
28 . if defined(WARNS)
29 .  if ${WARNS} >= 1
30 CWARNFLAGS      +=      -Wsystem-headers
31 .   if !defined(NO_WERROR)
32 CWARNFLAGS      +=      -Werror
33 .   endif
34 .  endif
35 .  if ${WARNS} >= 2
36 CWARNFLAGS      +=      -Wall -Wno-format-y2k
37 .  endif
38 .  if ${WARNS} >= 3
39 CWARNFLAGS      +=      -W -Wno-unused-parameter -Wstrict-prototypes\
40                         -Wmissing-prototypes -Wpointer-arith
41 .  endif
42 .  if ${WARNS} >= 4
43 CWARNFLAGS      +=      -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch\
44                         -Wshadow -Wcast-align -Wunused-parameter
45 .  endif
46 # BDECFLAGS
47 .  if ${WARNS} >= 6
48 CWARNFLAGS      +=      -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls
49 .  endif
50 .  if ${WARNS} >= 2 && ${WARNS} <= 4
51 # XXX Delete -Wuninitialized by default for now -- the compiler doesn't
52 # XXX always get it right.
53 CWARNFLAGS      +=      -Wno-uninitialized
54 .  endif
55 .  if !defined(WITH_GCC3)
56 CWARNFLAGS      +=      -Wno-pointer-sign
57 .  endif
58 . endif
59
60 . if defined(FORMAT_AUDIT)
61 WFORMAT         =       1
62 . endif
63 . if defined(WFORMAT)
64 .  if ${WFORMAT} > 0
65 #CWARNFLAGS     +=      -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
66 CWARNFLAGS      +=      -Wformat=2 -Wno-format-extra-args
67 .   if !defined(NO_WERROR)
68 CWARNFLAGS      +=      -Werror
69 .   endif
70 .  endif
71 . endif
72 .endif
73
74 .if defined(IGNORE_PRAGMA)
75 CWARNFLAGS      +=      -Wno-unknown-pragmas
76 .endif
77
78 .if ${MK_SSP} != "no" && ${CC} != "icc" && ${MACHINE_ARCH} != "ia64" && \
79         ${MACHINE_ARCH} != "arm" && ${MACHINE_ARCH} != "mips"
80 # Don't use -Wstack-protector as it breaks world with -Werror.
81 SSP_CFLAGS      ?=      -fstack-protector
82 CFLAGS          +=      ${SSP_CFLAGS}
83 .endif
84
85 # Allow user-specified additional warning flags
86 CFLAGS          +=      ${CWARNFLAGS}