pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/mk



Module Name:    pkgsrc
Committed By:   jperkin
Date:           Tue Jul  5 17:32:25 UTC 2022

Modified Files:
        pkgsrc/mk: compiler.mk
        pkgsrc/mk/compiler: clang.mk gcc.mk

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 pkgsrc/mk/compiler.mk
cvs rdiff -u -r1.35 -r1.36 pkgsrc/mk/compiler/clang.mk
cvs rdiff -u -r1.243 -r1.244 pkgsrc/mk/compiler/gcc.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/mk/compiler.mk
diff -u pkgsrc/mk/compiler.mk:1.97 pkgsrc/mk/compiler.mk:1.98
--- pkgsrc/mk/compiler.mk:1.97  Sun Apr 10 19:54:02 2022
+++ pkgsrc/mk/compiler.mk       Tue Jul  5 17:32:24 2022
@@ -1,4 +1,4 @@
-# $NetBSD: compiler.mk,v 1.97 2022/04/10 19:54:02 riastradh Exp $
+# $NetBSD: compiler.mk,v 1.98 2022/07/05 17:32:24 jperkin Exp $
 #
 # This Makefile fragment implements handling for supported C/C++/Fortran
 # compilers.
@@ -48,9 +48,9 @@
 #      This is used to determine the correct compilers to make
 #      visible to the build environment, installing them if
 #      necessary.  Flags such as -std=c++99 are also added.
-#      Valid values are: c, c99, c++, c++03, gnu++03, c++0x, gnu++0x,
-#      c++11, gnu++11, c++14, gnu++14, c++17, gnu++17, c++20, gnu++20,
-#      fortran, fortran77, java, objc, obj-c++, and ada.
+#      Valid values are: c, c99, gnu99, c11, gnu11, c17, gnu17, c++, c++03,
+#      gnu++03, c++0x, gnu++0x, c++11, gnu++11, c++14, gnu++14, c++17,
+#      gnu++17, c++20, gnu++20, fortran, fortran77, java, objc, obj-c++, ada.
 #      The default is "c".
 #
 #       The above is partly aspirational.  As an example c++11 does
@@ -83,10 +83,12 @@ _SYS_VARS.compiler= CC_VERSION
 # Since most packages need a C compiler, this is the default value.
 USE_LANGUAGES?=        c
 
-# Add c support if c99 is set
-.if !empty(USE_LANGUAGES:Mc99)
-USE_LANGUAGES+=        c
-.endif
+_C_STD_VERSIONS=       c99 gnu99 c11 gnu11 c17 gnu17
+.for _version_ in ${_C_STD_VERSIONS}
+.  if !empty(USE_LANGUAGES:M${_version_})
+USE_LANGUAGES+=                c
+.  endif
+.endfor
 
 _CXX_STD_VERSIONS=     gnu++20 c++20 gnu++17 c++17 gnu++14 c++14 gnu++11 c++11 gnu++0x c++0x gnu++03 c++03
 .for _version_ in ${_CXX_STD_VERSIONS}
@@ -178,13 +180,19 @@ ${_var_}:=        ${${_var_}:C/^/_asdf_/1:M_asd
 .  endif
 .endfor
 
-# Pass the compiler flag based on the most recent version of the C++ standard
-# required.  We currently assume that each standard is a superset of all that
-# come after it.
-#
-# If and when the flags differ between compilers we can push this down into
-# the respective mk/compiler/*.mk files.
-#
+# Pass the compiler flag based on the most recent version of the C or C++
+# standard required.  We currently assume that each standard is a superset of
+# all that come after it.
+#
+_C_VERSION_REQD=
+.for _version_ in ${_C_STD_VERSIONS}
+.  if empty(_C_VERSION_REQD) && !empty(USE_LANGUAGES:M${_version_})
+_C_VERSION_REQD=       ${_version_}
+_WRAP_EXTRA_ARGS.CC+=  ${_C_STD_FLAG.${_C_VERSION_REQD}}
+CWRAPPERS_PREPEND.cc+= ${_C_STD_FLAG.${_C_VERSION_REQD}}
+.  endif
+.endfor
+
 _CXX_VERSION_REQD=
 .for _version_ in ${_CXX_STD_VERSIONS}
 .  if empty(_CXX_VERSION_REQD) && !empty(USE_LANGUAGES:M${_version_})

Index: pkgsrc/mk/compiler/clang.mk
diff -u pkgsrc/mk/compiler/clang.mk:1.35 pkgsrc/mk/compiler/clang.mk:1.36
--- pkgsrc/mk/compiler/clang.mk:1.35    Sun Mar 13 06:26:57 2022
+++ pkgsrc/mk/compiler/clang.mk Tue Jul  5 17:32:24 2022
@@ -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} -\#\#\#
 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

Index: pkgsrc/mk/compiler/gcc.mk
diff -u pkgsrc/mk/compiler/gcc.mk:1.243 pkgsrc/mk/compiler/gcc.mk:1.244
--- pkgsrc/mk/compiler/gcc.mk:1.243     Thu Jun 16 15:46:22 2022
+++ pkgsrc/mk/compiler/gcc.mk   Tue Jul  5 17:32:24 2022
@@ -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${_lan
 _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



Home | Main Index | Thread Index | Old Index