1240468Sbrooks# $FreeBSD$
2240468Sbrooks
3279793Sdim# Setup variables for the compiler
4279793Sdim#
5279793Sdim# COMPILER_TYPE is the major type of compiler. Currently gcc and clang support
6279793Sdim# automatic detection. Other compiler types can be shoe-horned in, but require
7279793Sdim# explicit setting of the compiler type. The compiler type can also be set
8279793Sdim# explicitly if, say, you install gcc as clang...
9279793Sdim#
10279793Sdim# COMPILER_VERSION is a numeric constant equal to:
11279793Sdim#     major * 10000 + minor * 100 + tiny
12279793Sdim# It too can be overriden on the command line. When testing it, be sure to
13279793Sdim# make sure that you are limiting the test to a specific compiler. Testing
14279793Sdim# against 30300 for gcc likely isn't  what you wanted (since versions of gcc
15279793Sdim# prior to 4.2 likely have no prayer of working).
16279793Sdim#
17279793Sdim# COMPILER_FEATURES will contain one or more of the following, based on
18279793Sdim# compiler support for that feature:
19279793Sdim#
20279793Sdim# - c++11 : supports full (or nearly full) C++11 programming environment.
21279793Sdim#
22279793Sdim# This file may be included multiple times, but only has effect the first time.
23279793Sdim#
24279793Sdim
25279793Sdim.if !defined(COMPILER_TYPE) || !defined(COMPILER_VERSION)
26279793Sdim_v!=	${CC} --version 2>/dev/null || echo 0.0.0
27240468Sbrooks.if !defined(COMPILER_TYPE)
28279793Sdim. if ${CC:T:M*gcc*}
29240468SbrooksCOMPILER_TYPE:=	gcc  
30279793Sdim. elif ${CC:T:M*clang*}
31240468SbrooksCOMPILER_TYPE:=	clang
32279793Sdim. elif ${_v:Mgcc}
33240468SbrooksCOMPILER_TYPE:=	gcc
34279793Sdim. elif ${_v:M\(GCC\)}
35240468SbrooksCOMPILER_TYPE:=	gcc
36279793Sdim. elif ${_v:Mclang}
37240468SbrooksCOMPILER_TYPE:=	clang
38279793Sdim. else
39247527Sbrooks.error Unable to determine compiler type for ${CC}.  Consider setting COMPILER_TYPE.
40240468Sbrooks. endif
41240468Sbrooks.endif
42279793Sdim.if !defined(COMPILER_VERSION)
43293109SdimCOMPILER_VERSION!=echo "${_v:M[1-9].[0-9]*}" | awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}'
44279793Sdim.endif
45279793Sdim.undef _v
46279793Sdim.endif
47240966Sbrooks
48279793Sdim.if ${COMPILER_TYPE} == "clang" || \
49279793Sdim	(${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800)
50240966SbrooksCOMPILER_FEATURES=	c++11
51240966Sbrooks.else
52240966SbrooksCOMPILER_FEATURES=
53240966Sbrooks.endif
54