1# $FreeBSD$ 2 3# Setup variables for the linker. 4# 5# LINKER_TYPE is the major type of linker. Currently binutils and lld support 6# automatic detection. 7# 8# LINKER_VERSION is a numeric constant equal to: 9# major * 10000 + minor * 100 + tiny 10# It too can be overridden on the command line. 11# 12# These variables with an X_ prefix will also be provided if XLD is set. 13# 14# This file may be included multiple times, but only has effect the first time. 15# 16 17.if !target(__<bsd.linker.mk>__) 18__<bsd.linker.mk>__: 19 20.for ld X_ in LD $${_empty_var_} XLD X_ 21.if ${ld} == "LD" || !empty(XLD) 22.if ${ld} == "LD" || (${ld} == "XLD" && ${XLD} != ${LD}) 23 24_ld_version!= ${${ld}} --version 2>/dev/null | head -n 1 || echo none 25.if ${_ld_version} == "none" 26.error Unable to determine linker type from ${ld}=${${ld}} 27.endif 28.if ${_ld_version:[1..2]} == "GNU ld" 29${X_}LINKER_TYPE= binutils 30_v= ${_ld_version:[3]} 31.elif ${_ld_version:[1]} == "LLD" 32${X_}LINKER_TYPE= lld 33_v= ${_ld_version:[2]} 34.else 35.error Unknown linker from ${ld}=${${ld}}: ${_ld_version} 36.endif 37${X_}LINKER_VERSION!= echo "${_v:M[1-9].[0-9]*}" | \ 38 awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}' 39.undef _ld_version 40.undef _v 41.endif # ${ld} == "LD" || (${ld} == "XLD" && ${XLD} != ${LD}) 42 43.endif # ${ld} == "LD" || !empty(XLD) 44.endfor # .for ld in LD XLD 45 46 47.endif # !target(__<bsd.linker.mk>__) 48