bsd.sys.mk (236528) | bsd.sys.mk (240468) |
---|---|
1# $FreeBSD: head/share/mk/bsd.sys.mk 236528 2012-06-03 20:35:41Z dim $ | 1# $FreeBSD: head/share/mk/bsd.sys.mk 240468 2012-09-13 16:00:46Z brooks $ |
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-4.2.1/gcc/Warning-Options.html 10 | 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-4.2.1/gcc/Warning-Options.html 10 |
11.include <bsd.compiler.mk> 12 |
|
11# the default is gnu99 for now 12CSTD?= gnu99 13 14.if ${CSTD} == "k&r" 15CFLAGS+= -traditional 16.elif ${CSTD} == "c89" || ${CSTD} == "c90" 17CFLAGS+= -std=iso9899:1990 18.elif ${CSTD} == "c94" || ${CSTD} == "c95" --- 4 unchanged lines hidden (view full) --- 23CFLAGS+= -std=${CSTD} 24.endif # CSTD 25.if !defined(NO_WARNS) 26# -pedantic is problematic because it also imposes namespace restrictions 27#CFLAGS+= -pedantic 28.if defined(WARNS) 29.if ${WARNS} >= 1 30CWARNFLAGS+= -Wsystem-headers | 13# the default is gnu99 for now 14CSTD?= gnu99 15 16.if ${CSTD} == "k&r" 17CFLAGS+= -traditional 18.elif ${CSTD} == "c89" || ${CSTD} == "c90" 19CFLAGS+= -std=iso9899:1990 20.elif ${CSTD} == "c94" || ${CSTD} == "c95" --- 4 unchanged lines hidden (view full) --- 25CFLAGS+= -std=${CSTD} 26.endif # CSTD 27.if !defined(NO_WARNS) 28# -pedantic is problematic because it also imposes namespace restrictions 29#CFLAGS+= -pedantic 30.if defined(WARNS) 31.if ${WARNS} >= 1 32CWARNFLAGS+= -Wsystem-headers |
31.if !defined(NO_WERROR) && ((${MK_CLANG_IS_CC} == "no" && \ 32 ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang)) | 33.if !defined(NO_WERROR) && (${COMPILER_TYPE} != "clang" \ 34 || !defined(NO_WERROR.clang)) |
33CWARNFLAGS+= -Werror 34.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang) 35.endif # WARNS >= 1 36.if ${WARNS} >= 2 37CWARNFLAGS+= -Wall -Wno-format-y2k 38.endif # WARNS >= 2 39.if ${WARNS} >= 3 40CWARNFLAGS+= -W -Wno-unused-parameter -Wstrict-prototypes\ 41 -Wmissing-prototypes -Wpointer-arith 42.endif # WARNS >= 3 43.if ${WARNS} >= 4 44CWARNFLAGS+= -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow\ 45 -Wunused-parameter | 35CWARNFLAGS+= -Werror 36.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang) 37.endif # WARNS >= 1 38.if ${WARNS} >= 2 39CWARNFLAGS+= -Wall -Wno-format-y2k 40.endif # WARNS >= 2 41.if ${WARNS} >= 3 42CWARNFLAGS+= -W -Wno-unused-parameter -Wstrict-prototypes\ 43 -Wmissing-prototypes -Wpointer-arith 44.endif # WARNS >= 3 45.if ${WARNS} >= 4 46CWARNFLAGS+= -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow\ 47 -Wunused-parameter |
46.if !defined(NO_WCAST_ALIGN) && ((${MK_CLANG_IS_CC} == "no" && \ 47 ${CC:T:Mclang} != "clang") || !defined(NO_WCAST_ALIGN.clang)) | 48.if !defined(NO_WCAST_ALIGN) && (${COMPILER_TYPE} != "clang" \ 49 || !defined(NO_WCAST_ALIGN.clang)) |
48CWARNFLAGS+= -Wcast-align 49.endif # !NO_WCAST_ALIGN && (!CLANG || !NO_WCAST_ALIGN.clang) 50.endif # WARNS >= 4 51# BDECFLAGS 52.if ${WARNS} >= 6 53CWARNFLAGS+= -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls\ 54 -Wold-style-definition 55.endif # WARNS >= 6 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 # WARNS >=2 && WARNS <= 4 61CWARNFLAGS+= -Wno-pointer-sign 62# Clang has more warnings enabled by default, and when using -Wall, so if WARNS 63# is set to low values, these have to be disabled explicitly. | 50CWARNFLAGS+= -Wcast-align 51.endif # !NO_WCAST_ALIGN && (!CLANG || !NO_WCAST_ALIGN.clang) 52.endif # WARNS >= 4 53# BDECFLAGS 54.if ${WARNS} >= 6 55CWARNFLAGS+= -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls\ 56 -Wold-style-definition 57.endif # WARNS >= 6 58.if ${WARNS} >= 2 && ${WARNS} <= 4 59# XXX Delete -Wuninitialized by default for now -- the compiler doesn't 60# XXX always get it right. 61CWARNFLAGS+= -Wno-uninitialized 62.endif # WARNS >=2 && WARNS <= 4 63CWARNFLAGS+= -Wno-pointer-sign 64# Clang has more warnings enabled by default, and when using -Wall, so if WARNS 65# is set to low values, these have to be disabled explicitly. |
64.if (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && \ 65 !defined(EARLY_BUILD) | 66.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) |
66.if ${WARNS} <= 6 67CWARNFLAGS+= -Wno-empty-body -Wno-string-plus-int 68.endif # WARNS <= 6 69.if ${WARNS} <= 3 70CWARNFLAGS+= -Wno-tautological-compare -Wno-unused-value\ 71 -Wno-parentheses-equality -Wno-unused-function -Wno-conversion 72.endif # WARNS <= 3 73.if ${WARNS} <= 2 --- 10 unchanged lines hidden (view full) --- 84 85.if defined(FORMAT_AUDIT) 86WFORMAT= 1 87.endif # FORMAT_AUDIT 88.if defined(WFORMAT) 89.if ${WFORMAT} > 0 90#CWARNFLAGS+= -Wformat-nonliteral -Wformat-security -Wno-format-extra-args 91CWARNFLAGS+= -Wformat=2 -Wno-format-extra-args | 67.if ${WARNS} <= 6 68CWARNFLAGS+= -Wno-empty-body -Wno-string-plus-int 69.endif # WARNS <= 6 70.if ${WARNS} <= 3 71CWARNFLAGS+= -Wno-tautological-compare -Wno-unused-value\ 72 -Wno-parentheses-equality -Wno-unused-function -Wno-conversion 73.endif # WARNS <= 3 74.if ${WARNS} <= 2 --- 10 unchanged lines hidden (view full) --- 85 86.if defined(FORMAT_AUDIT) 87WFORMAT= 1 88.endif # FORMAT_AUDIT 89.if defined(WFORMAT) 90.if ${WFORMAT} > 0 91#CWARNFLAGS+= -Wformat-nonliteral -Wformat-security -Wno-format-extra-args 92CWARNFLAGS+= -Wformat=2 -Wno-format-extra-args |
92.if (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && \ 93 !defined(EARLY_BUILD) | 93.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) |
94.if ${WARNS} <= 3 95CWARNFLAGS+= -Wno-format-nonliteral 96.endif # WARNS <= 3 97.endif # CLANG | 94.if ${WARNS} <= 3 95CWARNFLAGS+= -Wno-format-nonliteral 96.endif # WARNS <= 3 97.endif # CLANG |
98.if !defined(NO_WERROR) && ((${MK_CLANG_IS_CC} == "no" && \ 99 ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang)) | 98.if !defined(NO_WERROR) && (${COMPILER_TYPE} != "clang" \ 99 || !defined(NO_WERROR.clang)) |
100CWARNFLAGS+= -Werror 101.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang) 102.endif # WFORMAT > 0 103.endif # WFORMAT | 100CWARNFLAGS+= -Werror 101.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang) 102.endif # WFORMAT > 0 103.endif # WFORMAT |
104.if defined(NO_WFORMAT) || ((${MK_CLANG_IS_CC} != "no" || \ 105 ${CC:T:Mclang} == "clang") && defined(NO_WFORMAT.clang)) | 104.if defined(NO_WFORMAT) || (${COMPILER_TYPE} == "clang" && defined(NO_WFORMAT.clang)) |
106CWARNFLAGS+= -Wno-format 107.endif # NO_WFORMAT || (CLANG && NO_WFORMAT.clang) 108.endif # !NO_WARNS 109 110.if defined(IGNORE_PRAGMA) 111CWARNFLAGS+= -Wno-unknown-pragmas 112.endif # IGNORE_PRAGMA 113 | 105CWARNFLAGS+= -Wno-format 106.endif # NO_WFORMAT || (CLANG && NO_WFORMAT.clang) 107.endif # !NO_WARNS 108 109.if defined(IGNORE_PRAGMA) 110CWARNFLAGS+= -Wno-unknown-pragmas 111.endif # IGNORE_PRAGMA 112 |
114.if (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && \ 115 !defined(EARLY_BUILD) | 113.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) |
116CLANG_NO_IAS= -no-integrated-as 117CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\ 118 -mllvm -enable-load-pre=false -mllvm -simplifycfg-dup-ret 119CFLAGS+= -Qunused-arguments 120.endif # CLANG 121 122.if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \ 123 ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" 124# Don't use -Wstack-protector as it breaks world with -Werror. 125SSP_CFLAGS?= -fstack-protector 126CFLAGS+= ${SSP_CFLAGS} 127.endif # SSP && !IA64 && !ARM && !MIPS 128 129# Allow user-specified additional warning flags 130CFLAGS+= ${CWARNFLAGS} | 114CLANG_NO_IAS= -no-integrated-as 115CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\ 116 -mllvm -enable-load-pre=false -mllvm -simplifycfg-dup-ret 117CFLAGS+= -Qunused-arguments 118.endif # CLANG 119 120.if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \ 121 ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" 122# Don't use -Wstack-protector as it breaks world with -Werror. 123SSP_CFLAGS?= -fstack-protector 124CFLAGS+= ${SSP_CFLAGS} 125.endif # SSP && !IA64 && !ARM && !MIPS 126 127# Allow user-specified additional warning flags 128CFLAGS+= ${CWARNFLAGS} |