xref: /freebsd/share/mk/bsd.compiler.mk (revision 0572ccaa4543b0abef8ef81e384c1d04de9f3da1)
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_v!=	${CC} --version
25.if !defined(COMPILER_TYPE)
26. if ${CC:T:Mgcc*}
27COMPILER_TYPE:=	gcc
28. elif ${CC:T:Mclang}
29COMPILER_TYPE:=	clang
30. elif ${_v:Mgcc}
31COMPILER_TYPE:=	gcc
32. elif ${_v:M\(GCC\)}
33COMPILER_TYPE:=	gcc
34. elif ${_v:Mclang}
35COMPILER_TYPE:=	clang
36. else
37.error Unable to determine compiler type for ${CC}.  Consider setting COMPILER_TYPE.
38. endif
39.endif
40.if !defined(COMPILER_VERSION)
41COMPILER_VERSION!=echo ${_v:M[1-9].[0-9]*} | awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}'
42.endif
43.undef _v
44
45.if ${COMPILER_TYPE} == "clang"
46COMPILER_FEATURES=	c++11
47.else
48COMPILER_FEATURES=
49.endif
50
51.endif	# !target(__<bsd.compiler.mk>__)
52