summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2003-05-01 14:36:27 +0000
committerdes <des@FreeBSD.org>2003-05-01 14:36:27 +0000
commitd147648191012b2ae9e1dc5d8e7e61ba4fa1b195 (patch)
tree8979b70be7a719d3bcd23783b08b390e83d0d578
parentc7b799cc919aa786b000681139a33c9079e9dbf4 (diff)
downloadFreeBSD-src-d147648191012b2ae9e1dc5d8e7e61ba4fa1b195.zip
FreeBSD-src-d147648191012b2ae9e1dc5d8e7e61ba4fa1b195.tar.gz
Add a mechanism to allow Makefiles to specify the particular C dialect
in which the source code is written. This is controlled by the CSTD variable, which can have one of the following values: - "k&r" => -traditional - "c89" or "c90" => -std=iso9899:1990 - "c94" or "c95" => -std=iso9899:199409 - "c99" => -std=iso9899:1999 The corresponding option is added to CFLAGS regardless of WARNS level. This also removes -ansi from WARNS level 6, but adds -Wno-long-long to work around a weird gcc bug (-ansi, which is supposedly equivalent to -std=iso9899:1990, seems to turn long long warnings off instead of on) If CSTD is undefined, CFLAGS are unchanged except for the -ansi / -Wno-long-long change mentioned above for WARNS level 6.
-rw-r--r--share/mk/bsd.sys.mk13
1 files changed, 12 insertions, 1 deletions
diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
index 0b164a9..65d8e6f 100644
--- a/share/mk/bsd.sys.mk
+++ b/share/mk/bsd.sys.mk
@@ -9,6 +9,17 @@
# for GCC: http://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_3.html#IDX143
.if !defined(NO_WARNS)
+. if defined(CSTD)
+. if ${CSTD} == "k&r"
+CFLAGS += -traditional
+. elif ${CSTD} == "c89" || ${CSTD} == "c90"
+CFLAGS += -std=iso9899:1990
+. elif ${CSTD} == "c94" || ${CSTD} == "c95"
+CFLAGS += -std=iso9899:199409
+. elif ${CSTD} == "c99"
+CFLAGS += -std=iso9899:1999
+. endif
+. endif
. if defined(WARNS)
. if ${WARNS} > 0
CFLAGS += -Wsystem-headers
@@ -27,7 +38,7 @@ CFLAGS += -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-al
. endif
# BDECFLAGS
. if ${WARNS} > 5
-CFLAGS += -ansi -pedantic -Wbad-function-cast -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls
+CFLAGS += -pedantic -Wno-long-long -Wbad-function-cast -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls
. endif
. if ${WARNS} > 1 && ${WARNS} < 5
# XXX Delete -Wuninitialized by default for now -- the compiler doesn't
OpenPOWER on IntegriCloud