bsd.sys.mk revision 220863
176861Skris# $FreeBSD: head/share/mk/bsd.sys.mk 220863 2011-04-19 18:09:21Z dim $ 276861Skris# 376861Skris# This file contains common settings used for building FreeBSD 476861Skris# sources. 576861Skris 676861Skris# Enable various levels of compiler warning checks. These may be 776861Skris# overridden (e.g. if using a non-gcc compiler) by defining NO_WARNS. 876861Skris 996316Sobrien# for GCC: http://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_3.html#IDX143 1096316Sobrien 11189801Srdivacky# the default is gnu99 for now 12189801SrdivackyCSTD ?= gnu99 13189801Srdivacky 14220863Sdim.if ${CSTD} == "k&r" 15161214SdesCFLAGS += -traditional 16220863Sdim.elif ${CSTD} == "c89" || ${CSTD} == "c90" 17161214SdesCFLAGS += -std=iso9899:1990 18220863Sdim.elif ${CSTD} == "c94" || ${CSTD} == "c95" 19161214SdesCFLAGS += -std=iso9899:199409 20220863Sdim.elif ${CSTD} == "c99" 21161214SdesCFLAGS += -std=iso9899:1999 22220863Sdim.else 23161214SdesCFLAGS += -std=${CSTD} 24198365Sru.endif 25220863Sdim.if !defined(NO_WARNS) 26161214Sdes# -pedantic is problematic because it also imposes namespace restrictions 27161214Sdes#CFLAGS += -pedantic 2876861Skris. if defined(WARNS) 29140359Sobrien. if ${WARNS} >= 1 30124372SruCWARNFLAGS += -Wsystem-headers 3199542Sobrien. if !defined(NO_WERROR) 32124372SruCWARNFLAGS += -Werror 3399542Sobrien. endif 3476861Skris. endif 35140359Sobrien. if ${WARNS} >= 2 36124372SruCWARNFLAGS += -Wall -Wno-format-y2k 3776861Skris. endif 38140359Sobrien. if ${WARNS} >= 3 39140361SobrienCWARNFLAGS += -W -Wno-unused-parameter -Wstrict-prototypes\ 40140361Sobrien -Wmissing-prototypes -Wpointer-arith 4187976Sobrien. endif 42140359Sobrien. if ${WARNS} >= 4 43140361SobrienCWARNFLAGS += -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch\ 44204025Smarcel -Wshadow -Wunused-parameter 45204025Smarcel. if !defined(NO_WCAST_ALIGN) 46204025SmarcelCWARNFLAGS += -Wcast-align 47204025Smarcel. endif 4887976Sobrien. endif 4994332Sobrien# BDECFLAGS 50140359Sobrien. if ${WARNS} >= 6 51201300SedCWARNFLAGS += -Wchar-subscripts -Winline -Wnested-externs\ 52201300Sed -Wredundant-decls -Wold-style-definition 5394332Sobrien. endif 54140359Sobrien. if ${WARNS} >= 2 && ${WARNS} <= 4 5588936Sdwmalone# XXX Delete -Wuninitialized by default for now -- the compiler doesn't 5688936Sdwmalone# XXX always get it right. 57124372SruCWARNFLAGS += -Wno-uninitialized 5888936Sdwmalone. endif 59169723SkanCWARNFLAGS += -Wno-pointer-sign 6076861Skris. endif 6176861Skris 6276861Skris. if defined(FORMAT_AUDIT) 6376861SkrisWFORMAT = 1 6476861Skris. endif 6576861Skris. if defined(WFORMAT) 6676861Skris. if ${WFORMAT} > 0 67124372Sru#CWARNFLAGS += -Wformat-nonliteral -Wformat-security -Wno-format-extra-args 68124372SruCWARNFLAGS += -Wformat=2 -Wno-format-extra-args 6999542Sobrien. if !defined(NO_WERROR) 70124372SruCWARNFLAGS += -Werror 7199542Sobrien. endif 7276861Skris. endif 7376861Skris. endif 74219368Spjd. if defined(NO_WFORMAT) 75219368SpjdCWARNFLAGS += -Wno-format 76219368Spjd. endif 7776861Skris.endif 7876861Skris 79163971Sjb.if defined(IGNORE_PRAGMA) 80163971SjbCWARNFLAGS += -Wno-unknown-pragmas 81163971Sjb.endif 82163971Sjb 83220863Sdim.if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \ 84220863Sdim ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" 85180012Sru# Don't use -Wstack-protector as it breaks world with -Werror. 86180012SruSSP_CFLAGS ?= -fstack-protector 87180012SruCFLAGS += ${SSP_CFLAGS} 88180012Sru.endif 89180012Sru 9076861Skris# Allow user-specified additional warning flags 9176861SkrisCFLAGS += ${CWARNFLAGS} 92