From d147648191012b2ae9e1dc5d8e7e61ba4fa1b195 Mon Sep 17 00:00:00 2001 From: des Date: Thu, 1 May 2003 14:36:27 +0000 Subject: 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. --- share/mk/bsd.sys.mk | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'share/mk/bsd.sys.mk') 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 -- cgit v1.1