1# $FreeBSD$ 2 3# Setup variables for the compiler 4# 5# COMPILTER_TYPE is the major type of compiler. Currently gcc and clang support 6# automatic detetion. Other compiler types can be shoe-horned in, but require explicit 7# setting of the compiler type. The compiler type can also be set explicitly if, say, 8# you install gcc as clang... 9# 10# COMPILER_VERSION is a numeric constant equal to major * 10000 + minor * 100 + tiny. It 11# too can be overriden on the command line. When testing it, be sure to make sure that you 12# are limiting the test to a specific compiler. Testing against 30300 for gcc likely isn't 13# what you wanted (since versions of gcc prior to 4.2 likely have no prayer of working). 14# 15# COMPILER_FEATURES will contain one or more of the following, based on compiler support 16# for that feature: c++11 (supports full (or nearly full) C++11 programming environment). 17# 18# This file may be included multiple times, but only has effect the first time. 19# 20 21.if !target(__<bsd.compiler.mk>__) 22__<bsd.compiler.mk>__: 23 24.if ${MACHINE} == "common" 25COMPILER_TYPE= none 26COMPILER_VERSION= 0 27.else 28_v!= ${CC} --version 2>/dev/null || echo 0.0.0 29.endif 30 31.if !defined(COMPILER_TYPE) 32. if ${CC:T:M*gcc*} 33COMPILER_TYPE:= gcc 34. elif ${CC:T:M*clang*} 35COMPILER_TYPE:= clang 36. elif ${_v:Mgcc} 37COMPILER_TYPE:= gcc 38. elif ${_v:M\(GCC\)} 39COMPILER_TYPE:= gcc 40. elif ${_v:Mclang} 41COMPILER_TYPE:= clang 42. else 43.error Unable to determine compiler type for ${CC}. Consider setting COMPILER_TYPE. 44. endif 45.endif 46.if !defined(COMPILER_VERSION) 47COMPILER_VERSION!=echo ${_v:M[1-9].[0-9]*} | awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}' 48.endif 49.undef _v 50 51.if ${COMPILER_TYPE} == "clang" || \ 52 (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800) 53COMPILER_FEATURES= c++11 54.else 55COMPILER_FEATURES= 56.endif 57 58.endif # !target(__<bsd.compiler.mk>__) 59