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# Universally disable -Werror until src/ is in better shape for GCC 4.2 12NO_WERROR= 13 14.if !defined(NO_WARNS) && ${CC} != "icc" 15. if defined(CSTD) 16. if ${CSTD} == "k&r" 17CFLAGS += -traditional 18. elif ${CSTD} == "c89" || ${CSTD} == "c90" 19CFLAGS += -std=iso9899:1990 20. elif ${CSTD} == "c94" || ${CSTD} == "c95" 21CFLAGS += -std=iso9899:199409 22. elif ${CSTD} == "c99" 23CFLAGS += -std=iso9899:1999 24. else 25CFLAGS += -std=${CSTD} 26. endif 27# -pedantic is problematic because it also imposes namespace restrictions 28#CFLAGS += -pedantic 29. endif 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 -Wcast-align -Wunused-parameter 47. endif 48# BDECFLAGS 49. if ${WARNS} >= 6 50CWARNFLAGS += -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls 51. endif 52. if ${WARNS} >= 2 && ${WARNS} <= 4 53# XXX Delete -Wuninitialized by default for now -- the compiler doesn't 54# XXX always get it right. 55CWARNFLAGS += -Wno-uninitialized 56. endif 57. if !defined(WITH_GCC3) 58CWARNFLAGS += -Wno-pointer-sign 59. endif 60. endif 61 62. if defined(FORMAT_AUDIT) 63WFORMAT = 1 64. endif 65. if defined(WFORMAT) 66. if ${WFORMAT} > 0 67#CWARNFLAGS += -Wformat-nonliteral -Wformat-security -Wno-format-extra-args 68CWARNFLAGS += -Wformat=2 -Wno-format-extra-args 69. if !defined(NO_WERROR) 70CWARNFLAGS += -Werror 71. endif 72. endif 73. endif 74.endif 75 76.if defined(IGNORE_PRAGMA) 77CWARNFLAGS += -Wno-unknown-pragmas 78.endif 79 80# Allow user-specified additional warning flags 81CFLAGS += ${CWARNFLAGS} 82