2012-09-13 16:00:46 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
|
2014-05-10 16:37:44 +00:00
|
|
|
# Setup variables for the compiler
|
|
|
|
#
|
2014-12-06 03:12:57 +00:00
|
|
|
# COMPILER_TYPE is the major type of compiler. Currently gcc and clang support
|
|
|
|
# automatic detection. 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...
|
2014-05-10 16:37:44 +00:00
|
|
|
#
|
2014-12-06 03:12:57 +00:00
|
|
|
# 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).
|
2014-05-10 16:37:44 +00:00
|
|
|
#
|
2014-12-06 03:12:57 +00:00
|
|
|
# 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.
|
2014-05-10 16:37:44 +00:00
|
|
|
#
|
|
|
|
# This file may be included multiple times, but only has effect the first time.
|
|
|
|
#
|
|
|
|
|
2014-05-07 18:15:02 +00:00
|
|
|
.if !target(__<bsd.compiler.mk>__)
|
|
|
|
__<bsd.compiler.mk>__:
|
|
|
|
|
2015-10-20 20:15:25 +00:00
|
|
|
# Try to import COMPILER_TYPE and COMPILER_VERSION from parent make.
|
|
|
|
# The value is only used/exported for the same environment that impacts
|
|
|
|
# CC and COMPILER_* settings here.
|
|
|
|
_exported_vars= COMPILER_TYPE COMPILER_VERSION
|
|
|
|
_cc_hash= ${CC}${MACHINE}${PATH}
|
|
|
|
_cc_hash:= ${_cc_hash:hash}
|
2015-10-20 20:37:00 +00:00
|
|
|
# Only import if none of the vars are set somehow else.
|
|
|
|
_can_export= yes
|
|
|
|
.for var in ${_exported_vars}
|
|
|
|
.if defined(${var})
|
|
|
|
_can_export= no
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
.if ${_can_export} == yes
|
2015-10-20 20:15:25 +00:00
|
|
|
.for var in ${_exported_vars}
|
|
|
|
.if defined(${var}.${_cc_hash})
|
|
|
|
${var}= ${${var}.${_cc_hash}}
|
|
|
|
.endif
|
|
|
|
.endfor
|
2015-10-20 20:37:00 +00:00
|
|
|
.endif
|
2015-10-20 20:15:25 +00:00
|
|
|
|
2013-10-12 23:49:26 +00:00
|
|
|
.if ${MACHINE} == "common"
|
2015-06-10 19:36:53 +00:00
|
|
|
# common is a pseudo machine for architecture independent
|
|
|
|
# generated files - thus there is no compiler.
|
2013-10-12 23:49:26 +00:00
|
|
|
COMPILER_TYPE= none
|
2014-08-19 06:50:54 +00:00
|
|
|
COMPILER_VERSION= 0
|
2015-05-26 21:52:57 +00:00
|
|
|
.elif !defined(COMPILER_TYPE) || !defined(COMPILER_VERSION)
|
2015-10-31 02:07:30 +00:00
|
|
|
_v!= ${CC} --version || echo 0.0.0
|
2013-10-12 23:49:26 +00:00
|
|
|
|
2012-09-13 16:00:46 +00:00
|
|
|
.if !defined(COMPILER_TYPE)
|
2014-05-23 14:34:22 +00:00
|
|
|
. if ${CC:T:M*gcc*}
|
2012-09-13 16:00:46 +00:00
|
|
|
COMPILER_TYPE:= gcc
|
2014-05-23 14:34:22 +00:00
|
|
|
. elif ${CC:T:M*clang*}
|
2012-09-13 16:00:46 +00:00
|
|
|
COMPILER_TYPE:= clang
|
2014-05-10 16:37:44 +00:00
|
|
|
. elif ${_v:Mgcc}
|
2012-09-13 16:00:46 +00:00
|
|
|
COMPILER_TYPE:= gcc
|
2014-05-10 16:37:44 +00:00
|
|
|
. elif ${_v:M\(GCC\)}
|
2012-09-13 16:00:46 +00:00
|
|
|
COMPILER_TYPE:= gcc
|
2014-05-10 16:37:44 +00:00
|
|
|
. elif ${_v:Mclang}
|
2012-09-13 16:00:46 +00:00
|
|
|
COMPILER_TYPE:= clang
|
2014-05-10 16:37:44 +00:00
|
|
|
. else
|
2013-03-01 03:25:43 +00:00
|
|
|
.error Unable to determine compiler type for ${CC}. Consider setting COMPILER_TYPE.
|
2012-09-13 16:00:46 +00:00
|
|
|
. endif
|
|
|
|
.endif
|
2014-05-10 16:37:44 +00:00
|
|
|
.if !defined(COMPILER_VERSION)
|
|
|
|
COMPILER_VERSION!=echo ${_v:M[1-9].[0-9]*} | awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}'
|
|
|
|
.endif
|
|
|
|
.undef _v
|
2014-12-06 04:02:56 +00:00
|
|
|
.endif
|
2012-09-26 17:25:15 +00:00
|
|
|
|
2015-10-20 20:15:25 +00:00
|
|
|
# Export the values so sub-makes don't have to look them up again, using the
|
|
|
|
# hash key computed above.
|
|
|
|
.for var in ${_exported_vars}
|
|
|
|
${var}.${_cc_hash}:= ${${var}}
|
|
|
|
.export-env ${var}.${_cc_hash}
|
|
|
|
.undef ${var}.${_cc_hash}
|
|
|
|
.endfor
|
|
|
|
|
2014-10-21 19:58:23 +00:00
|
|
|
.if ${COMPILER_TYPE} == "clang" || \
|
|
|
|
(${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800)
|
2012-09-26 17:25:15 +00:00
|
|
|
COMPILER_FEATURES= c++11
|
|
|
|
.else
|
|
|
|
COMPILER_FEATURES=
|
|
|
|
.endif
|
2014-05-07 18:15:02 +00:00
|
|
|
|
|
|
|
.endif # !target(__<bsd.compiler.mk>__)
|