1# $FreeBSD: src/share/mk/bsd.sys.mk,v 1.3.2.5 2002/07/03 16:59:14 des Exp $ 2# 3# This file contains common settings used for building DragonFly 4# sources. 5 6CSTD?= gnu99 7 8.if ${CSTD} == "k&r" 9CFLAGS += -traditional 10.elif ${CSTD} == "c89" || ${CSTD} == "c90" 11CFLAGS += -std=iso9899:1990 12.elif ${CSTD} == "c94" || ${CSTD} == "c95" 13CFLAGS += -std=iso9899:199409 14.elif ${CSTD} == "c99" 15CFLAGS += -std=iso9899:1999 16.else 17CFLAGS += -std=${CSTD} 18.endif 19 20# Enable various levels of compiler warning checks. These may be 21# overridden (e.g. if using a non-gcc compiler) by defining NO_WARNS. 22 23.if !defined(NO_WARNS) 24. if defined(WARNS) 25. if ${WARNS} >= 1 26CWARNFLAGS += -Wmissing-include-dirs -Wsystem-headers 27. if !defined(NO_WERROR) && ${CCVER:Mgcc*} 28CWARNFLAGS += -Werror 29. endif 30. endif 31. if ${WARNS} >= 2 32CWARNFLAGS += -Wall -Wformat-security -Winit-self -Wno-pointer-sign 33. endif 34. if ${WARNS} >= 3 35CWARNFLAGS += -Wextra -Wno-unused-parameter -Wstrict-prototypes\ 36 -Wmissing-prototypes -Wpointer-arith\ 37 -Wold-style-definition 38. endif 39. if ${WARNS} >= 4 40CWARNFLAGS += -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch\ 41 -Wshadow -Wcast-align -Wunused-parameter 42. endif 43. if ${WARNS} >= 6 44CWARNFLAGS += -Wchar-subscripts -Winline -Wnested-externs\ 45 -Wredundant-decls 46. endif 47. if ${WARNS} >= 2 && ${WARNS} <= 4 48# XXX Delete -Wmaybe-uninitialized by default for now -- the compiler doesn't 49# XXX always get it right. 50. if ${CCVER:Mgcc*} 51CWARNFLAGS += -Wno-maybe-uninitialized 52. else 53CWARNFLAGS += -Wno-uninitialized 54. endif 55. endif 56# Activate gcc47's -Wunused-but-set-variable (which is in -Wall) and 57# -Wunused-but-set-parameter (which is in -Wextra) only at WARNS >= 4 58# (which is the level when also -Wunused-parameter comes into play). 59# unused-local-typedef warnings were introduced by gcc4.8, are in -Wall 60. if ${WARNS} >= 2 && ${WARNS} <= 3 && ${CCVER:Mgcc*} 61CWARNFLAGS += -Wno-unused-but-set-variable 62. endif 63. if ${WARNS} == 3 && ${CCVER:Mgcc*} 64CWARNFLAGS += -Wno-unused-but-set-parameter 65. endif 66. if ${WARNS} == 3 && (${CCVER:Mgcc4[89]} || ${CCVER:Mgcc5*}) 67CWARNFLAGS += -Wno-unused-local-typedefs 68. endif 69. if ${WARNS} == 3 && (${CCVER:Mgcc49} || ${CCVER:Mgcc5*}) 70CWARNFLAGS += -Wno-unused-value 71. endif 72. if ${WARNS} >= 2 && ${CCVER:Mgcc4[789]} 73CWARNFLAGS += -Wno-error=maybe-uninitialized\ 74 -Wno-error=uninitialized\ 75 -Wno-error=shadow 76. endif 77# Disable -Werror selectively for -Os and -Og compilations. Both -Winline and 78# -Wmaybe-uninitialized are noisy and should be caught by standard -O and -O2. 79# These are still useful diagnostics while investigating compilation issues. 80. if defined(WORLD_CCOPTLEVEL) && (${WORLD_CCOPTLEVEL:Mg} || ${WORLD_CCOPTLEVEL:Ms}) 81. if ${WARNS} >= 6 82CWARNFLAGS += -Wno-error=inline 83. endif 84. if ${WARNS} >= 5 && ${CCVER:Mgcc*} 85CWARNFLAGS += -Wno-error=maybe-uninitialized 86. endif 87. endif 88. endif 89 90. if defined(FORMAT_AUDIT) 91WFORMAT = 1 92. endif 93. if defined(WFORMAT) 94. if ${WFORMAT} > 0 95CWARNFLAGS += -Wformat=2 -Wno-format-extra-args 96. if !defined(NO_WERROR) && ${CCVER:Mgcc*} 97CWARNFLAGS += -Werror 98. endif 99. endif 100. endif 101.endif 102 103.if defined(NO_WARRAY_BOUNDS) 104CWARNFLAGS += -Wno-array-bounds 105.endif 106.if defined(NO_STRICT_OVERFLOW) 107CFLAGS += -fno-strict-overflow 108.endif 109.if defined(NO_STRICT_ALIASING) 110CFLAGS += -fno-strict-aliasing 111.endif 112 113 114# Allow user-specified additional warning flags 115CFLAGS += ${CWARNFLAGS} 116 117# Tell bmake not to mistake standard targets for things to be searched for 118# or expect to ever be up-to-date 119PHONY_NOTMAIN = afterdepend afterinstall all beforedepend beforeinstall \ 120 beforelinking build build-tools buildfiles buildincludes \ 121 checkdpadd clean cleandepend cleandir cleanobj configure \ 122 depend dependall distclean distribute exe extract fetch \ 123 html includes install installfiles installincludes lint \ 124 obj objlink objs objwarn patch realall realdepend \ 125 realinstall regress subdir-all subdir-depend subdir-install \ 126 tags whereobj 127 128# if given PROG matches anything in the PHONY list, exclude it. 129.PHONY: ${PHONY_NOTMAIN:N${PROG:U}} 130.NOTMAIN: ${PHONY_NOTMAIN} 131