2001-05-19 23:18:21 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
# This file contains common settings used for building FreeBSD
|
|
|
|
# sources.
|
|
|
|
|
|
|
|
# Enable various levels of compiler warning checks. These may be
|
|
|
|
# overridden (e.g. if using a non-gcc compiler) by defining NO_WARNS.
|
|
|
|
|
2002-05-10 01:58:16 +00:00
|
|
|
# for GCC: http://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_3.html#IDX143
|
|
|
|
|
2009-03-14 17:55:16 +00:00
|
|
|
# the default is gnu99 for now
|
|
|
|
CSTD ?= gnu99
|
|
|
|
|
2011-04-19 18:09:21 +00:00
|
|
|
.if ${CSTD} == "k&r"
|
2006-08-11 17:28:59 +00:00
|
|
|
CFLAGS += -traditional
|
2011-04-19 18:09:21 +00:00
|
|
|
.elif ${CSTD} == "c89" || ${CSTD} == "c90"
|
2006-08-11 17:28:59 +00:00
|
|
|
CFLAGS += -std=iso9899:1990
|
2011-04-19 18:09:21 +00:00
|
|
|
.elif ${CSTD} == "c94" || ${CSTD} == "c95"
|
2006-08-11 17:28:59 +00:00
|
|
|
CFLAGS += -std=iso9899:199409
|
2011-04-19 18:09:21 +00:00
|
|
|
.elif ${CSTD} == "c99"
|
2006-08-11 17:28:59 +00:00
|
|
|
CFLAGS += -std=iso9899:1999
|
2011-04-19 18:09:21 +00:00
|
|
|
.else
|
2006-08-11 17:28:59 +00:00
|
|
|
CFLAGS += -std=${CSTD}
|
2009-10-22 11:45:35 +00:00
|
|
|
.endif
|
2011-04-19 18:09:21 +00:00
|
|
|
.if !defined(NO_WARNS)
|
2006-08-11 17:28:59 +00:00
|
|
|
# -pedantic is problematic because it also imposes namespace restrictions
|
|
|
|
#CFLAGS += -pedantic
|
2001-05-19 23:18:21 +00:00
|
|
|
. if defined(WARNS)
|
2005-01-16 21:08:31 +00:00
|
|
|
. if ${WARNS} >= 1
|
2004-01-11 10:29:55 +00:00
|
|
|
CWARNFLAGS += -Wsystem-headers
|
2002-07-07 18:47:52 +00:00
|
|
|
. if !defined(NO_WERROR)
|
2004-01-11 10:29:55 +00:00
|
|
|
CWARNFLAGS += -Werror
|
2002-07-07 18:47:52 +00:00
|
|
|
. endif
|
2001-05-19 23:18:21 +00:00
|
|
|
. endif
|
2005-01-16 21:08:31 +00:00
|
|
|
. if ${WARNS} >= 2
|
2004-01-11 10:29:55 +00:00
|
|
|
CWARNFLAGS += -Wall -Wno-format-y2k
|
2001-12-15 06:02:15 +00:00
|
|
|
. endif
|
2005-01-16 21:08:31 +00:00
|
|
|
. if ${WARNS} >= 3
|
2005-01-16 21:18:16 +00:00
|
|
|
CWARNFLAGS += -W -Wno-unused-parameter -Wstrict-prototypes\
|
|
|
|
-Wmissing-prototypes -Wpointer-arith
|
2001-12-15 06:02:15 +00:00
|
|
|
. endif
|
2005-01-16 21:08:31 +00:00
|
|
|
. if ${WARNS} >= 4
|
2005-01-16 21:18:16 +00:00
|
|
|
CWARNFLAGS += -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch\
|
2010-02-18 02:06:57 +00:00
|
|
|
-Wshadow -Wunused-parameter
|
|
|
|
. if !defined(NO_WCAST_ALIGN)
|
|
|
|
CWARNFLAGS += -Wcast-align
|
|
|
|
. endif
|
2001-05-19 23:18:21 +00:00
|
|
|
. endif
|
2002-04-10 02:45:22 +00:00
|
|
|
# BDECFLAGS
|
2005-01-16 21:08:31 +00:00
|
|
|
. if ${WARNS} >= 6
|
2009-12-31 00:07:26 +00:00
|
|
|
CWARNFLAGS += -Wchar-subscripts -Winline -Wnested-externs\
|
|
|
|
-Wredundant-decls -Wold-style-definition
|
2002-04-10 02:45:22 +00:00
|
|
|
. endif
|
2005-01-16 21:08:31 +00:00
|
|
|
. if ${WARNS} >= 2 && ${WARNS} <= 4
|
2002-01-05 20:17:50 +00:00
|
|
|
# XXX Delete -Wuninitialized by default for now -- the compiler doesn't
|
|
|
|
# XXX always get it right.
|
2004-01-11 10:29:55 +00:00
|
|
|
CWARNFLAGS += -Wno-uninitialized
|
2002-01-05 20:17:50 +00:00
|
|
|
. endif
|
2007-05-19 04:41:05 +00:00
|
|
|
CWARNFLAGS += -Wno-pointer-sign
|
2001-05-19 23:18:21 +00:00
|
|
|
. endif
|
|
|
|
|
|
|
|
. if defined(FORMAT_AUDIT)
|
|
|
|
WFORMAT = 1
|
|
|
|
. endif
|
|
|
|
. if defined(WFORMAT)
|
|
|
|
. if ${WFORMAT} > 0
|
2004-01-11 10:29:55 +00:00
|
|
|
#CWARNFLAGS += -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
|
|
|
|
CWARNFLAGS += -Wformat=2 -Wno-format-extra-args
|
2002-07-07 18:47:52 +00:00
|
|
|
. if !defined(NO_WERROR)
|
2004-01-11 10:29:55 +00:00
|
|
|
CWARNFLAGS += -Werror
|
2002-07-07 18:47:52 +00:00
|
|
|
. endif
|
2001-05-19 23:32:19 +00:00
|
|
|
. endif
|
2001-05-19 23:18:21 +00:00
|
|
|
. endif
|
2011-03-07 09:28:21 +00:00
|
|
|
. if defined(NO_WFORMAT)
|
|
|
|
CWARNFLAGS += -Wno-format
|
|
|
|
. endif
|
2001-05-19 23:18:21 +00:00
|
|
|
.endif
|
|
|
|
|
2006-11-04 04:39:05 +00:00
|
|
|
.if defined(IGNORE_PRAGMA)
|
|
|
|
CWARNFLAGS += -Wno-unknown-pragmas
|
|
|
|
.endif
|
|
|
|
|
2011-04-19 18:09:21 +00:00
|
|
|
.if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
|
|
|
|
${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
|
2008-06-25 21:33:28 +00:00
|
|
|
# Don't use -Wstack-protector as it breaks world with -Werror.
|
|
|
|
SSP_CFLAGS ?= -fstack-protector
|
|
|
|
CFLAGS += ${SSP_CFLAGS}
|
|
|
|
.endif
|
|
|
|
|
2001-05-19 23:18:21 +00:00
|
|
|
# Allow user-specified additional warning flags
|
|
|
|
CFLAGS += ${CWARNFLAGS}
|