]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - share/mk/bsd.sys.mk
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.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 ${CSTD} == "k&r"
15 CFLAGS          += -traditional
16 .elif ${CSTD} == "c89" || ${CSTD} == "c90"
17 CFLAGS          += -std=iso9899:1990
18 .elif ${CSTD} == "c94" || ${CSTD} == "c95"
19 CFLAGS          += -std=iso9899:199409
20 .elif ${CSTD} == "c99"
21 CFLAGS          += -std=iso9899:1999
22 .else
23 CFLAGS          += -std=${CSTD}
24 .endif
25 .if !defined(NO_WARNS)
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 -Wunused-parameter
45 .   if !defined(NO_WCAST_ALIGN)
46 CWARNFLAGS      +=      -Wcast-align
47 .   endif
48 .  endif
49 # BDECFLAGS
50 .  if ${WARNS} >= 6
51 CWARNFLAGS      +=      -Wchar-subscripts -Winline -Wnested-externs\
52                         -Wredundant-decls -Wold-style-definition
53 .  endif
54 .  if ${WARNS} >= 2 && ${WARNS} <= 4
55 # XXX Delete -Wuninitialized by default for now -- the compiler doesn't
56 # XXX always get it right.
57 CWARNFLAGS      +=      -Wno-uninitialized
58 .  endif
59 CWARNFLAGS      +=      -Wno-pointer-sign
60 . endif
61
62 . if defined(FORMAT_AUDIT)
63 WFORMAT         =       1
64 . endif
65 . if defined(WFORMAT)
66 .  if ${WFORMAT} > 0
67 #CWARNFLAGS     +=      -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
68 CWARNFLAGS      +=      -Wformat=2 -Wno-format-extra-args
69 .   if !defined(NO_WERROR)
70 CWARNFLAGS      +=      -Werror
71 .   endif
72 .  endif
73 . endif
74 . if defined(NO_WFORMAT)
75 CWARNFLAGS      +=      -Wno-format
76 . endif
77 .endif
78
79 .if defined(IGNORE_PRAGMA)
80 CWARNFLAGS      +=      -Wno-unknown-pragmas
81 .endif
82
83 .if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
84     ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
85 # Don't use -Wstack-protector as it breaks world with -Werror.
86 SSP_CFLAGS      ?=      -fstack-protector
87 CFLAGS          +=      ${SSP_CFLAGS}
88 .endif
89
90 # Allow user-specified additional warning flags
91 CFLAGS          +=      ${CWARNFLAGS}