summaryrefslogtreecommitdiff
path: root/mk/compiler
diff options
context:
space:
mode:
authorjperkin <jperkin@pkgsrc.org>2022-07-05 17:32:24 +0000
committerjperkin <jperkin@pkgsrc.org>2022-07-05 17:32:24 +0000
commit5a3d1af2d7a6c0ed8ff87f491e85df1385cf7145 (patch)
tree67659afe759ecac8566507f844e5660245524cb4 /mk/compiler
parente2599434fcbef2e4a36803c8a1ed5464eaedf64e (diff)
downloadpkgsrc-5a3d1af2d7a6c0ed8ff87f491e85df1385cf7145.tar.gz
mk: Add support for newer C standards.
For now the GCC "c99 == gnu99" override is kept, but gnu99 is now supported as a specific value for USE_LANGUAGES, so we may want to be specific where required. c11 and c17 (and the corresponding gnu11/gnu17 versions) are newly supported.
Diffstat (limited to 'mk/compiler')
-rw-r--r--mk/compiler/clang.mk6
-rw-r--r--mk/compiler/gcc.mk16
2 files changed, 15 insertions, 7 deletions
diff --git a/mk/compiler/clang.mk b/mk/compiler/clang.mk
index 66625977c30..7310a20533b 100644
--- a/mk/compiler/clang.mk
+++ b/mk/compiler/clang.mk
@@ -1,4 +1,4 @@
-# $NetBSD: clang.mk,v 1.35 2022/03/13 06:26:57 nia Exp $
+# $NetBSD: clang.mk,v 1.36 2022/07/05 17:32:24 jperkin Exp $
#
# This is the compiler definition for the clang compiler.
#
@@ -121,6 +121,10 @@ _NOERROR_IMPLICIT_cmd= ${CCPATH} -\#\#\# -E -x c /dev/null 2>&1 \
CWRAPPERS_PREPEND.cc+= ${_NOERROR_IMPLICIT_cmd:sh}
.endif
+.for _version_ in ${_C_STD_VERSIONS}
+_C_STD_FLAG.${_version_}?= -std=${_version_}
+.endfor
+
.for _version_ in ${_CXX_STD_VERSIONS}
_CXX_STD_FLAG.${_version_}?= -std=${_version_}
.endfor
diff --git a/mk/compiler/gcc.mk b/mk/compiler/gcc.mk
index d688db08a03..e039eaf8a61 100644
--- a/mk/compiler/gcc.mk
+++ b/mk/compiler/gcc.mk
@@ -1,4 +1,4 @@
-# $NetBSD: gcc.mk,v 1.243 2022/06/16 15:46:22 adam Exp $
+# $NetBSD: gcc.mk,v 1.244 2022/07/05 17:32:24 jperkin Exp $
#
# This is the compiler definition for the GNU Compiler Collection.
#
@@ -101,6 +101,8 @@ _DEF_VARS.gcc= \
_USE_GCC_SHLIB _USE_PKGSRC_GCC \
_WRAP_EXTRA_ARGS.CC \
_EXTRA_CC_DIRS \
+ _C_STD_VERSIONS \
+ ${_C_STD_VERSIONS:@std@_C_STD_FLAG.${std}@} \
_CXX_STD_VERSIONS \
${_CXX_STD_VERSIONS:@std@_CXX_STD_FLAG.${std}@} \
_MKPIE_CFLAGS.gcc _MKPIE_LDFLAGS \
@@ -221,6 +223,13 @@ _GCC_VERSION= 0
.endif
_GCC_PKG= gcc-${_GCC_VERSION:C/-.*$//}
+.for _version_ in ${_C_STD_VERSIONS}
+_C_STD_FLAG.${_version_}?= -std=${_version_}
+.endfor
+# XXX: pkgsrc historically hardcoded c99=gnu99 so we retain that for now, but
+# we should look at removing this and be explicit in packages where required.
+_C_STD_FLAG.c99= -std=gnu99
+
.for _version_ in ${_CXX_STD_VERSIONS}
_CXX_STD_FLAG.${_version_}?= -std=${_version_}
. if !empty(_GCC_VERSION:M[34].[1234].*)
@@ -384,11 +393,6 @@ _LANGUAGES.gcc+= ${LANGUAGES.gcc:M${_lang_}}
_WRAP_EXTRA_ARGS.cc+= -fcommon
CWRAPPERS_PREPEND.cc+= -fcommon
-.if !empty(USE_LANGUAGES:Mc99)
-_WRAP_EXTRA_ARGS.CC+= -std=gnu99
-CWRAPPERS_APPEND.cc+= -std=gnu99
-.endif
-
.if ${_PKGSRC_MKPIE} == "yes"
_MKPIE_CFLAGS.gcc= -fPIC
_MKPIE_FCFLAGS.gcc= -fPIC