xref: /dflybsd-src/contrib/bmake/mk/compiler.mk (revision 9e7ae5a0527a977cab412aede3a532cfe2903bbb)
1*6eef5f0cSAntonio Huete Jimenez# $Id: compiler.mk,v 1.11 2022/09/09 17:44:29 sjg Exp $
2ca58f742SDaniel Fojt#
3ca58f742SDaniel Fojt#	@(#) Copyright (c) 2019, Simon J. Gerraty
4ca58f742SDaniel Fojt#
5ca58f742SDaniel Fojt#	This file is provided in the hope that it will
6ca58f742SDaniel Fojt#	be of use.  There is absolutely NO WARRANTY.
7ca58f742SDaniel Fojt#	Permission to copy, redistribute or otherwise
8ca58f742SDaniel Fojt#	use this file is hereby granted provided that
9ca58f742SDaniel Fojt#	the above copyright notice and this notice are
10ca58f742SDaniel Fojt#	left intact.
11ca58f742SDaniel Fojt#
12ca58f742SDaniel Fojt#	Please send copies of changes and bug-fixes to:
13ca58f742SDaniel Fojt#	sjg@crufty.net
14ca58f742SDaniel Fojt#
15ca58f742SDaniel Fojt
16ca58f742SDaniel Fojt.if !target(__${.PARSEFILE}__)
17*6eef5f0cSAntonio Huete Jimenez__${.PARSEFILE}__: .NOTMAIN
18ca58f742SDaniel Fojt
19ca58f742SDaniel Fojt.if ${MACHINE} == "common"
20ca58f742SDaniel FojtCOMPILER_TYPE = none
21ca58f742SDaniel FojtCOMPILER_VERSION = 0
22ca58f742SDaniel Fojt.endif
23ca58f742SDaniel Fojt.if empty(COMPILER_TYPE) || empty(COMPILER_VERSION)
24ca58f742SDaniel Fojt# gcc does not always say gcc
25*6eef5f0cSAntonio Huete Jimenez_v != (${CC} --version) 2> /dev/null | \
26*6eef5f0cSAntonio Huete Jimenez	${EGREP:Uegrep} -i 'clang|cc|[1-9]\.[0-9]|Free Software Foundation'; echo
27ca58f742SDaniel Fojt.if empty(COMPILER_TYPE)
28ca58f742SDaniel Fojt.if ${_v:Mclang} != ""
29ca58f742SDaniel FojtCOMPILER_TYPE = clang
30*6eef5f0cSAntonio Huete Jimenez.elif ${_v:M[Gg][Cc][Cc]} != "" || ${_v:MFoundation*} != "" || ${CC:T:M*gcc*} != ""
31ca58f742SDaniel FojtCOMPILER_TYPE = gcc
32ca58f742SDaniel Fojt.endif
33ca58f742SDaniel Fojt.endif
34ca58f742SDaniel Fojt.if empty(COMPILER_VERSION)
35ca58f742SDaniel FojtCOMPILER_VERSION != echo "${_v:M[1-9].[0-9]*}:[1]" | \
36ca58f742SDaniel Fojt	awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}'
37ca58f742SDaniel Fojt.endif
38ca58f742SDaniel Fojt.undef _v
39ca58f742SDaniel Fojt.endif
40ca58f742SDaniel Fojt# just in case we don't recognize compiler
41ca58f742SDaniel FojtCOMPILER_TYPE ?= unknown
42ca58f742SDaniel FojtCOMPILER_VERSION ?= 0
43ca58f742SDaniel Fojt.endif
44