2017-06-22 21:03:20 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
|
|
|
|
# Setup variables for the linker.
|
|
|
|
#
|
|
|
|
# LINKER_TYPE is the major type of linker. Currently binutils and lld support
|
|
|
|
# automatic detection.
|
|
|
|
#
|
|
|
|
# LINKER_VERSION is a numeric constant equal to:
|
|
|
|
# major * 10000 + minor * 100 + tiny
|
|
|
|
# It too can be overridden on the command line.
|
|
|
|
#
|
2017-06-22 21:03:24 +00:00
|
|
|
# These variables with an X_ prefix will also be provided if XLD is set.
|
|
|
|
#
|
2017-06-22 21:03:20 +00:00
|
|
|
# This file may be included multiple times, but only has effect the first time.
|
|
|
|
#
|
|
|
|
|
|
|
|
.if !target(__<bsd.linker.mk>__)
|
|
|
|
__<bsd.linker.mk>__:
|
|
|
|
|
2017-06-22 21:03:24 +00:00
|
|
|
.for ld X_ in LD $${_empty_var_} XLD X_
|
|
|
|
.if ${ld} == "LD" || !empty(XLD)
|
|
|
|
.if ${ld} == "LD" || (${ld} == "XLD" && ${XLD} != ${LD})
|
|
|
|
|
|
|
|
_ld_version!= ${${ld}} --version 2>/dev/null | head -n 1 || echo none
|
2017-06-22 21:03:20 +00:00
|
|
|
.if ${_ld_version} == "none"
|
2017-06-22 21:03:24 +00:00
|
|
|
.error Unable to determine linker type from ${ld}=${${ld}}
|
2017-06-22 21:03:20 +00:00
|
|
|
.endif
|
|
|
|
.if ${_ld_version:[1..2]} == "GNU ld"
|
2017-06-22 21:03:24 +00:00
|
|
|
${X_}LINKER_TYPE= binutils
|
2017-06-22 21:03:20 +00:00
|
|
|
_v= ${_ld_version:[3]}
|
|
|
|
.elif ${_ld_version:[1]} == "LLD"
|
2017-06-22 21:03:24 +00:00
|
|
|
${X_}LINKER_TYPE= lld
|
2017-06-22 21:03:20 +00:00
|
|
|
_v= ${_ld_version:[2]}
|
|
|
|
.else
|
2017-06-22 21:03:24 +00:00
|
|
|
.error Unknown linker from ${ld}=${${ld}}: ${_ld_version}
|
2017-06-22 21:03:20 +00:00
|
|
|
.endif
|
2017-06-22 21:03:24 +00:00
|
|
|
${X_}LINKER_VERSION!= echo "${_v:M[1-9].[0-9]*}" | \
|
|
|
|
awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}'
|
|
|
|
.undef _ld_version
|
|
|
|
.undef _v
|
|
|
|
.endif # ${ld} == "LD" || (${ld} == "XLD" && ${XLD} != ${LD})
|
|
|
|
|
|
|
|
.endif # ${ld} == "LD" || !empty(XLD)
|
|
|
|
.endfor # .for ld in LD XLD
|
|
|
|
|
2017-06-22 21:03:20 +00:00
|
|
|
|
|
|
|
.endif # !target(__<bsd.linker.mk>__)
|