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