1# $Id: compiler.mk,v 1.15 2025/08/09 22:42:24 sjg Exp $ 2# 3# @(#) Copyright (c) 2019, Simon J. Gerraty 4# 5# SPDX-License-Identifier: BSD-2-Clause 6# 7# Please send copies of changes and bug-fixes to: 8# sjg@crufty.net 9# 10 11.if !target(__${.PARSEFILE}__) 12__${.PARSEFILE}__: .NOTMAIN 13 14.if ${MACHINE} == "common" 15COMPILER_TYPE = none 16COMPILER_VERSION = 0 17.endif 18.if empty(COMPILER_TYPE) || empty(COMPILER_VERSION) 19# gcc does not always say gcc 20_v != (${CC} --version) 2> /dev/null | \ 21 ${EGREP:Uegrep} -i 'clang|cc|[1-9]\.[0-9]|Free Software Foundation'; echo 22.if empty(COMPILER_TYPE) 23.if ${_v:Mclang} != "" 24COMPILER_TYPE = clang 25.elif ${_v:M[Gg][Cc][Cc]} != "" || ${_v:MFoundation*} != "" || ${CC:Ucc:T:M*gcc*} != "" 26COMPILER_TYPE = gcc 27.endif 28.endif 29.if empty(COMPILER_VERSION) 30COMPILER_VERSION != echo "${_v:M[1-9][0-9]*.[0-9]*}:[1]" | \ 31 awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}' 32.endif 33.undef _v 34.endif 35# just in case we don't recognize compiler 36COMPILER_TYPE ?= unknown 37COMPILER_VERSION ?= 0 38.endif 39