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