]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/bsd.compiler.mk
MFV illumos r266986:
[FreeBSD/FreeBSD.git] / share / mk / bsd.compiler.mk
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 2>/dev/null || echo 0.0.0
25 .if !defined(COMPILER_TYPE)
26 . if ${CC:T:M*gcc*}
27 COMPILER_TYPE:= gcc  
28 . elif ${CC:T:M*clang*}
29 COMPILER_TYPE:= clang
30 . elif ${_v:Mgcc}
31 COMPILER_TYPE:= gcc
32 . elif ${_v:M\(GCC\)}
33 COMPILER_TYPE:= gcc
34 . elif ${_v:Mclang}
35 COMPILER_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)
41 COMPILER_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"
46 COMPILER_FEATURES=      c++11
47 .else
48 COMPILER_FEATURES=
49 .endif
50
51 .endif  # !target(__<bsd.compiler.mk>__)