From 52f8dd01a1ff314c9049c579b06c9df363e15777 Mon Sep 17 00:00:00 2001 From: Richard PALO Date: Sat, 1 Nov 2014 08:18:10 +0100 Subject: [PATCH] add USE_LANGUAGES support for c11 and c++11 update compiler.mk and compiler/{clang.mk,gcc.mk} as well as wrapper/transform-gcc to support c11 and c++11 update CWRAPPERS needs as well for c99, c11 and c++11 --- mk/compiler.mk | 14 ++++++++++---- mk/compiler/clang.mk | 21 +++++++++++++++++++++ mk/compiler/gcc.mk | 27 ++++++++++++++++++++++----- mk/wrapper/transform-gcc | 4 ++++ 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/mk/compiler.mk b/mk/compiler.mk index 9e49242..9f4a187 100644 --- a/mk/compiler.mk +++ b/mk/compiler.mk @@ -42,8 +42,9 @@ # USE_LANGUAGES # Lists the languages used in the source code of the package, # and is used to determine the correct compilers to install. -# Valid values are: c, c99, c++, fortran, fortran77, java, objc, -# obj-c++, and ada. The default is "c". +# Valid values are: c, c99, c11, c++, c++11, fortran, fortran77, +# java, objc, obj-c++, and ada. +# The default is "c". # # The following variables are defined, and available for testing in # package Makefiles: @@ -72,11 +73,16 @@ _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) +# Add c support if c99 or C11 is set +.if !empty(USE_LANGUAGES:Mc99) || !empty(USE_LANGUAGES:Mc11) USE_LANGUAGES+= c .endif +# add c++ support if c++11 is set +.if !empty(USE_LANGUAGES:Mc++11) +USE_LANGUAGES+= c++ +.endif + COMPILER_USE_SYMLINKS?= yes _COMPILERS= ccc gcc icc ido mipspro mipspro-ucode \ diff --git a/mk/compiler/clang.mk b/mk/compiler/clang.mk index dec52a1..24593a2 100644 --- a/mk/compiler/clang.mk +++ b/mk/compiler/clang.mk @@ -67,6 +67,27 @@ PKGSRC_FORTRAN?=g95 . include "../../mk/compiler/${PKGSRC_FORTRAN}.mk" .endif +# check c std in reverse order to privilege latest standard +.if !empty(USE_LANGUAGES:Mc11) +_WRAP_EXTRA_ARGS.CC+= -std=c11 +CWRAPPERS_APPEND.cc+= -std=c11 +.elif !empty(USE_LANGUAGES:Mc99) +_WRAP_EXTRA_ARGS.CC+= -std=c99 +CWRAPPERS_APPEND.cc+= -std=c99 +.endif + +# check c++ std in reverse order to privilege latest standard +# refer to http://clang.llvm.org/cxx_status.html +# PM: this section presumes pkgsrc is using clang >= 3.4 +# +.if !empty(USE_LANGUAGES:Mc++11) +# clang 3.3 and later needed for c++11 +_WRAP_EXTRA_ARGS.CXX+= -std=c++11 +CWRAPPERS_APPEND.cxx+= -std=c++11 +# By default, Clang builds C++ code according to the C++98 standard, +# with many C++11 features accepted as extensions. +.endif + _WRAP_EXTRA_ARGS.CC+= -Qunused-arguments CWRAPPERS_APPEND.cc+= -Qunused-arguments _WRAP_EXTRA_ARGS.CXX+= -Qunused-arguments diff --git a/mk/compiler/gcc.mk b/mk/compiler/gcc.mk index 3fb8532..2a5c227 100644 --- a/mk/compiler/gcc.mk +++ b/mk/compiler/gcc.mk @@ -92,8 +92,9 @@ USE_PKGSRC_GCC_RUNTIME?=no GCC_REQD+= 2.8.0 -# gcc2 doesn't support c99 and amd64 -.if !empty(USE_LANGUAGES:Mc99) || ${MACHINE_ARCH} == "x86_64" +# gcc2 doesn't support c99, c11 and amd64 +.if !empty(USE_LANGUAGES:Mc99) || !empty(USE_LANGUAGES:Mc11) ||\ + ${MACHINE_ARCH} == "x86_64" GCC_REQD+= 3.0 .endif @@ -333,9 +334,25 @@ _LANGUAGES.gcc= # empty _LANGUAGES.gcc+= ${LANGUAGES.gcc:M${_lang_}} .endfor -.if !empty(USE_LANGUAGES:Mc99) -_WRAP_EXTRA_ARGS.CC+= -std=gnu99 -CWRAPPERS_APPEND.cc+= -std=gnu99 +# check c std in reverse order to privilege latest standard +# +.if !empty(USE_LANGUAGES:Mc11) +# GCC 4.7 and later needed for c11 (although not complete) +GCC_REQD+= 4.7 +_WRAP_EXTRA_ARGS.CC+= -std=c11 +CWRAPPERS_APPEND.cc+= -std=c11 +.elif !empty(USE_LANGUAGES:Mc99) +_WRAP_EXTRA_ARGS.CC+= -std=c99 +CWRAPPERS_APPEND.cc+= -std=c99 +.endif + +# check c++ std in reverse order to privilege latest standard +# +.if !empty(USE_LANGUAGES:Mc++11) +# GCC 4.7 and later needed for c++11 (although still experimental) +GCC_REQD+= 4.7 +_WRAP_EXTRA_ARGS.CXX+= -std=c++11 +CWRAPPERS_APPEND.cxx+= -std=c++11 .endif # GCC has this annoying behaviour where it advocates in a multi-line diff --git a/mk/wrapper/transform-gcc b/mk/wrapper/transform-gcc index 3dd6624..4cddc59 100644 --- a/mk/wrapper/transform-gcc +++ b/mk/wrapper/transform-gcc @@ -78,6 +78,10 @@ case $arg in -std=c99 |\ -std=gnu89 |\ -std=gnu99 |\ +-std=c11 |\ +-std=gnu11 |\ +-std=c++11 |\ +-std=gnu++11 |\ -W |\ -W[cLlS],* |\ -Wall |\ -- 2.6.3