Wed May 3 08:34:23 2017 UTC ()
Add support to USE_LANGUAGES for C++ standards from c++0x to gnu++14.

This allows packages to specify the version of the standard that they
require, and the infrastructure then distils that down in a similar way
to GCC_REQD to the newest standard, avoiding clashes with different -std
requirements based on CXXFLAGS.

Broad concensus on tech-pkg and tested in bulk builds.


(jperkin)
diff -r1.83 -r1.84 pkgsrc/mk/compiler.mk

cvs diff -r1.83 -r1.84 pkgsrc/mk/compiler.mk (expand / switch to unified diff)

--- pkgsrc/mk/compiler.mk 2016/11/10 20:59:43 1.83
+++ pkgsrc/mk/compiler.mk 2017/05/03 08:34:23 1.84
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: compiler.mk,v 1.83 2016/11/10 20:59:43 joerg Exp $ 1# $NetBSD: compiler.mk,v 1.84 2017/05/03 08:34:23 jperkin Exp $
2# 2#
3# This Makefile fragment implements handling for supported C/C++/Fortran 3# This Makefile fragment implements handling for supported C/C++/Fortran
4# compilers. 4# compilers.
5# 5#
6# The following variables may be set by the pkgsrc user in mk.conf: 6# The following variables may be set by the pkgsrc user in mk.conf:
7# 7#
8# PKGSRC_COMPILER 8# PKGSRC_COMPILER
9# A list of values specifying the chain of compilers to be used by 9# A list of values specifying the chain of compilers to be used by
10# pkgsrc to build packages. 10# pkgsrc to build packages.
11# 11#
12# Valid values are: 12# Valid values are:
13# ccc Compaq C Compilers (Tru64) 13# ccc Compaq C Compilers (Tru64)
14# ccache compiler cache (chainable) 14# ccache compiler cache (chainable)
@@ -32,28 +32,29 @@ @@ -32,28 +32,29 @@
32# over the C compiler instead of using the system Fortran 32# over the C compiler instead of using the system Fortran
33# compiler. The chain should always end in a real compiler. 33# compiler. The chain should always end in a real compiler.
34# This should only be set in /etc/mk.conf. 34# This should only be set in /etc/mk.conf.
35# 35#
36# COMPILER_USE_SYMLINKS 36# COMPILER_USE_SYMLINKS
37# If set to yes, use symlinks for the compiler drivers, otherwise 37# If set to yes, use symlinks for the compiler drivers, otherwise
38# shell scripts are created. The default is yes. 38# shell scripts are created. The default is yes.
39# 39#
40# The following variables may be set by a package: 40# The following variables may be set by a package:
41# 41#
42# USE_LANGUAGES 42# USE_LANGUAGES
43# Lists the languages used in the source code of the package, 43# Lists the languages used in the source code of the package,
44# and is used to determine the correct compilers to install. 44# and is used to determine the correct compilers to install.
45# Valid values are: c, c99, c++, fortran, fortran77, java, objc, 45# Valid values are: c, c99, c++, c++0x, gnu++0x, c++11, gnu++11,
46# obj-c++, and ada. The default is "c". 46# c++14, gnu++14, fortran, fortran77, java, objc, obj-c++, and
 47# ada. The default is "c".
47# 48#
48# The following variables are defined, and available for testing in 49# The following variables are defined, and available for testing in
49# package Makefiles: 50# package Makefiles:
50# 51#
51# CC_VERSION 52# CC_VERSION
52# The compiler and version being used, e.g., 53# The compiler and version being used, e.g.,
53# 54#
54# .include "../../mk/compiler.mk" 55# .include "../../mk/compiler.mk"
55# 56#
56# .if !empty(CC_VERSION:Mgcc-3*) 57# .if !empty(CC_VERSION:Mgcc-3*)
57# ... 58# ...
58# .endif 59# .endif
59# 60#
@@ -147,26 +148,43 @@ PKG_LD?= /usr/bin/ld @@ -147,26 +148,43 @@ PKG_LD?= /usr/bin/ld
147.endif 148.endif
148 149
149# Strip the leading paths from the toolchain variables since we manipulate 150# Strip the leading paths from the toolchain variables since we manipulate
150# the PATH to use the correct executable. 151# the PATH to use the correct executable.
151# 152#
152.for _var_ in ${_COMPILER_STRIP_VARS} 153.for _var_ in ${_COMPILER_STRIP_VARS}
153. if empty(${_var_}:C/^/_asdf_/1:N_asdf_*) 154. if empty(${_var_}:C/^/_asdf_/1:N_asdf_*)
154${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T} 155${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T}
155. else 156. else
156${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T} ${${_var_}:C/^/_asdf_/1:N_asdf_*} 157${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T} ${${_var_}:C/^/_asdf_/1:N_asdf_*}
157. endif 158. endif
158.endfor 159.endfor
159 160
 161# Pass the compiler flag based on the most recent version of the C++ standard
 162# required. We currently assume that each standard is a superset of all that
 163# come after it.
 164#
 165# If and when the flags differ between compilers we can push this down into
 166# the respective mk/compiler/*.mk files.
 167#
 168_CXX_VERSION_REQD=
 169.for _version_ in gnu++14 c++14 gnu++11 c++11 gnu++0x c++0x
 170. if empty(_CXX_VERSION_REQD) && !empty(USE_LANGUAGES:M${_version_})
 171USE_LANGUAGES+= c++
 172_CXX_VERSION_REQD= ${_version_}
 173_WRAP_EXTRA_ARGS.CXX+= -std=${_CXX_VERSION_REQD}
 174CWRAPPERS_PREPEND.cxx+= -std=${_CXX_VERSION_REQD}
 175. endif
 176.endfor
 177
160.if defined(ABI) && !empty(ABI) 178.if defined(ABI) && !empty(ABI)
161_WRAP_EXTRA_ARGS.CC+= ${_COMPILER_ABI_FLAG.${ABI}} 179_WRAP_EXTRA_ARGS.CC+= ${_COMPILER_ABI_FLAG.${ABI}}
162_WRAP_EXTRA_ARGS.CXX+= ${_COMPILER_ABI_FLAG.${ABI}} 180_WRAP_EXTRA_ARGS.CXX+= ${_COMPILER_ABI_FLAG.${ABI}}
163_WRAP_EXTRA_ARGS.FC+= ${_COMPILER_ABI_FLAG.${ABI}} 181_WRAP_EXTRA_ARGS.FC+= ${_COMPILER_ABI_FLAG.${ABI}}
164CWRAPPERS_PREPEND.cc+= ${_COMPILER_ABI_FLAG.${ABI}} 182CWRAPPERS_PREPEND.cc+= ${_COMPILER_ABI_FLAG.${ABI}}
165CWRAPPERS_PREPEND.cxx+= ${_COMPILER_ABI_FLAG.${ABI}} 183CWRAPPERS_PREPEND.cxx+= ${_COMPILER_ABI_FLAG.${ABI}}
166CWRAPPERS_PREPEND.f77+= ${_COMPILER_ABI_FLAG.${ABI}} 184CWRAPPERS_PREPEND.f77+= ${_COMPILER_ABI_FLAG.${ABI}}
167.endif 185.endif
168 186
169# If the languages are not requested, force them not to be available 187# If the languages are not requested, force them not to be available
170# in the generated wrappers. 188# in the generated wrappers.
171# 189#
172_FAIL_WRAPPER.CC= ${WRKDIR}/.compiler/bin/c-fail-wrapper 190_FAIL_WRAPPER.CC= ${WRKDIR}/.compiler/bin/c-fail-wrapper