xref: /freebsd/contrib/bmake/mk/compiler.mk (revision c59c3bf34db360695f07735bebc76a768cac5afc)
1*c59c3bf3SSimon J. Gerraty# SPDX-License-Identifier: BSD-2-Clause
2*c59c3bf3SSimon J. Gerraty#
3*c59c3bf3SSimon J. Gerraty# $Id: compiler.mk,v 1.14 2024/02/19 00:05:50 sjg Exp $
449caa483SSimon J. Gerraty#
549caa483SSimon J. Gerraty#	@(#) Copyright (c) 2019, Simon J. Gerraty
649caa483SSimon J. Gerraty#
749caa483SSimon J. Gerraty#	This file is provided in the hope that it will
849caa483SSimon J. Gerraty#	be of use.  There is absolutely NO WARRANTY.
949caa483SSimon J. Gerraty#	Permission to copy, redistribute or otherwise
1049caa483SSimon J. Gerraty#	use this file is hereby granted provided that
1149caa483SSimon J. Gerraty#	the above copyright notice and this notice are
1249caa483SSimon J. Gerraty#	left intact.
1349caa483SSimon J. Gerraty#
1449caa483SSimon J. Gerraty#	Please send copies of changes and bug-fixes to:
1549caa483SSimon J. Gerraty#	sjg@crufty.net
1649caa483SSimon J. Gerraty#
1749caa483SSimon J. Gerraty
1849caa483SSimon J. Gerraty.if !target(__${.PARSEFILE}__)
1912904384SSimon J. Gerraty__${.PARSEFILE}__: .NOTMAIN
2049caa483SSimon J. Gerraty
2149caa483SSimon J. Gerraty.if ${MACHINE} == "common"
2249caa483SSimon J. GerratyCOMPILER_TYPE = none
2349caa483SSimon J. GerratyCOMPILER_VERSION = 0
2449caa483SSimon J. Gerraty.endif
2549caa483SSimon J. Gerraty.if empty(COMPILER_TYPE) || empty(COMPILER_VERSION)
2649caa483SSimon J. Gerraty# gcc does not always say gcc
2712904384SSimon J. Gerraty_v != (${CC} --version) 2> /dev/null | \
284fde40d9SSimon J. Gerraty	${EGREP:Uegrep} -i 'clang|cc|[1-9]\.[0-9]|Free Software Foundation'; echo
2949caa483SSimon J. Gerraty.if empty(COMPILER_TYPE)
3049caa483SSimon J. Gerraty.if ${_v:Mclang} != ""
3149caa483SSimon J. GerratyCOMPILER_TYPE = clang
32*c59c3bf3SSimon J. Gerraty.elif ${_v:M[Gg][Cc][Cc]} != "" || ${_v:MFoundation*} != "" || ${CC:Ucc:T:M*gcc*} != ""
3349caa483SSimon J. GerratyCOMPILER_TYPE = gcc
3449caa483SSimon J. Gerraty.endif
3549caa483SSimon J. Gerraty.endif
3649caa483SSimon J. Gerraty.if empty(COMPILER_VERSION)
37d5e0a182SSimon J. GerratyCOMPILER_VERSION != echo "${_v:M[1-9][0-9]*.[0-9]*}:[1]" | \
3849caa483SSimon J. Gerraty	awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}'
3949caa483SSimon J. Gerraty.endif
4049caa483SSimon J. Gerraty.undef _v
4149caa483SSimon J. Gerraty.endif
4249caa483SSimon J. Gerraty# just in case we don't recognize compiler
4349caa483SSimon J. GerratyCOMPILER_TYPE ?= unknown
4449caa483SSimon J. GerratyCOMPILER_VERSION ?= 0
4549caa483SSimon J. Gerraty.endif
46