aboutsummaryrefslogtreecommitdiff
path: root/share/mk/bsd.compiler.mk
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2014-08-19 06:50:54 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2014-08-19 06:50:54 +0000
commitee7b0571c2c18bdec848ed2044223cc88db29bd8 (patch)
treeb04f4bd7cd887f50e7d98af35f46b9834ff86c80 /share/mk/bsd.compiler.mk
parentffda191e301f128a62c152fde92b692548367fca (diff)
parent15fc2873832ea5b9b639e701bbbf2e73af8b6a88 (diff)
downloadsrc-ee7b0571c2c18bdec848ed2044223cc88db29bd8.tar.gz
src-ee7b0571c2c18bdec848ed2044223cc88db29bd8.zip
Merge head from 7/28
Notes
Notes: svn path=/projects/bmake/; revision=270164
Diffstat (limited to 'share/mk/bsd.compiler.mk')
-rw-r--r--share/mk/bsd.compiler.mk46
1 files changed, 31 insertions, 15 deletions
diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk
index ca15d656596c..933d540b18e7 100644
--- a/share/mk/bsd.compiler.mk
+++ b/share/mk/bsd.compiler.mk
@@ -1,39 +1,55 @@
# $FreeBSD$
+# Setup variables for the compiler
+#
+# COMPILTER_TYPE is the major type of compiler. Currently gcc and clang support
+# automatic detetion. Other compiler types can be shoe-horned in, but require explicit
+# setting of the compiler type. The compiler type can also be set explicitly if, say,
+# you install gcc as clang...
+#
+# COMPILER_VERSION is a numeric constant equal to major * 10000 + minor * 100 + tiny. It
+# too can be overriden on the command line. When testing it, be sure to make sure that you
+# are limiting the test to a specific compiler. Testing against 30300 for gcc likely isn't
+# what you wanted (since versions of gcc prior to 4.2 likely have no prayer of working).
+#
+# COMPILER_FEATURES will contain one or more of the following, based on compiler support
+# for that feature: c++11 (supports full (or nearly full) C++11 programming environment).
+#
+# This file may be included multiple times, but only has effect the first time.
+#
+
.if !target(__<bsd.compiler.mk>__)
__<bsd.compiler.mk>__:
.if ${MACHINE} == "common"
COMPILER_TYPE= none
+COMPILER_VERSION= 0
+.else
+_v!= ${CC} --version 2>/dev/null || echo 0.0.0
.endif
.if !defined(COMPILER_TYPE)
-. if ${CC:T:Mgcc*}
+. if ${CC:T:M*gcc*}
COMPILER_TYPE:= gcc
-. elif ${CC:T:Mclang}
+. elif ${CC:T:M*clang*}
COMPILER_TYPE:= clang
-. else
-_COMPILER_VERSION!= ${CC} --version
-. if ${_COMPILER_VERSION:Mgcc}
+. elif ${_v:Mgcc}
COMPILER_TYPE:= gcc
-. elif ${_COMPILER_VERSION:M\(GCC\)}
+. elif ${_v:M\(GCC\)}
COMPILER_TYPE:= gcc
-. elif ${_COMPILER_VERSION:Mclang}
+. elif ${_v:Mclang}
COMPILER_TYPE:= clang
-. else
+. else
.error Unable to determine compiler type for ${CC}. Consider setting COMPILER_TYPE.
-. endif
-. undef _COMPILER_VERSION
. endif
.endif
+.if !defined(COMPILER_VERSION)
+COMPILER_VERSION!=echo ${_v:M[1-9].[0-9]*} | awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}'
+.endif
+.undef _v
.if ${COMPILER_TYPE} == "clang"
COMPILER_FEATURES= c++11
-.if !defined(_COMPILER_VERSION)
-_COMPILER_VERSION!= ${CC} --version
-.endif
-# some warnings are version specific
-COMPILER_VERSION:= ${_COMPILER_VERSION:M[1-9].[0-9]*}
.else
COMPILER_FEATURES=
.endif