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