bsd.sys.mk revision 189801
176861Skris# $FreeBSD: head/share/mk/bsd.sys.mk 189801 2009-03-14 17:55:16Z rdivacky $ 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 14126890Strhodes.if !defined(NO_WARNS) && ${CC} != "icc" 15189801Srdivacky. if ${CSTD} == "k&r" 16161214SdesCFLAGS += -traditional 17189801Srdivacky. elif ${CSTD} == "c89" || ${CSTD} == "c90" 18161214SdesCFLAGS += -std=iso9899:1990 19189801Srdivacky. elif ${CSTD} == "c94" || ${CSTD} == "c95" 20161214SdesCFLAGS += -std=iso9899:199409 21189801Srdivacky. elif ${CSTD} == "c99" 22161214SdesCFLAGS += -std=iso9899:1999 23189801Srdivacky. else 24161214SdesCFLAGS += -std=${CSTD} 25189801Srdivacky. endif 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\ 44140361Sobrien -Wshadow -Wcast-align -Wunused-parameter 4587976Sobrien. endif 4694332Sobrien# BDECFLAGS 47140359Sobrien. if ${WARNS} >= 6 48125884SdesCWARNFLAGS += -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls 4994332Sobrien. endif 50140359Sobrien. if ${WARNS} >= 2 && ${WARNS} <= 4 5188936Sdwmalone# XXX Delete -Wuninitialized by default for now -- the compiler doesn't 5288936Sdwmalone# XXX always get it right. 53124372SruCWARNFLAGS += -Wno-uninitialized 5488936Sdwmalone. endif 55169961Sobrien. if !defined(WITH_GCC3) 56169723SkanCWARNFLAGS += -Wno-pointer-sign 57169961Sobrien. endif 5876861Skris. endif 5976861Skris 6076861Skris. if defined(FORMAT_AUDIT) 6176861SkrisWFORMAT = 1 6276861Skris. endif 6376861Skris. if defined(WFORMAT) 6476861Skris. if ${WFORMAT} > 0 65124372Sru#CWARNFLAGS += -Wformat-nonliteral -Wformat-security -Wno-format-extra-args 66124372SruCWARNFLAGS += -Wformat=2 -Wno-format-extra-args 6799542Sobrien. if !defined(NO_WERROR) 68124372SruCWARNFLAGS += -Werror 6999542Sobrien. endif 7076861Skris. endif 7176861Skris. endif 7276861Skris.endif 7376861Skris 74163971Sjb.if defined(IGNORE_PRAGMA) 75163971SjbCWARNFLAGS += -Wno-unknown-pragmas 76163971Sjb.endif 77163971Sjb 78180605Scognet.if ${MK_SSP} != "no" && ${CC} != "icc" && ${MACHINE_ARCH} != "ia64" && \ 79180731Simp ${MACHINE_ARCH} != "arm" && ${MACHINE_ARCH} != "mips" 80180012Sru# Don't use -Wstack-protector as it breaks world with -Werror. 81180012SruSSP_CFLAGS ?= -fstack-protector 82180012SruCFLAGS += ${SSP_CFLAGS} 83180012Sru.endif 84180012Sru 8576861Skris# Allow user-specified additional warning flags 8676861SkrisCFLAGS += ${CWARNFLAGS} 87