# SPDX-License-Identifier: SPDX-License-Identifier: LGPL-2.1-or-later
#
# workarounds.mk - workarounds for weird stuff behavior

LD_FLAVOR := $(shell $(LD) --version | grep -E '^(LLD|GNU ld)'|sed 's/ .*//g')
LD_VERSION := $(shell $(LD) --version | grep -E '^(LLD|GNU ld)'|sed 's/.* //')
# I haven't tested 2.36 here; 2.35 is definitely broken and 2.37 seems to work
LD_DASH_T := $(shell \
	if [ "x${LD_FLAVOR}" == xLLD ] ; then \
		echo '-T' ; \
	elif [ "x${LD_FLAVOR}" == xGNU ] ; then \
		if echo "${LD_VERSION}" | grep -q -E '^2\.3[789]|^2\.[456789]|^[3456789]|^[[:digit:]][[:digit:]]' ; then \
			echo '-T' ; \
		else \
			echo "" ; \
		fi ; \
	else \
		echo "Your linker is not supported" ; \
		exit 1 ; \
	fi)

export LD_DASH_T

# vim:ft=make

# SPDX-License-Identifier: SPDX-License-Identifier: LGPL-2.1-or-later
#
# workarounds.mk - workarounds for weird stuff behavior

LD_FLAVOR := $(shell $(LD) --version | grep -E '^(LLD|GNU ld)'|sed 's/ .*//g')
LD_VERSION := $(shell $(LD) --version | grep -E '^(LLD|GNU ld)'|sed 's/.* //')
# I haven't tested 2.36 here; 2.35 is definitely broken and 2.37 seems to work
LD_DASH_T := $(shell \
	if [ "x${LD_FLAVOR}" = xLLD ] ; then \
		echo '-T' ; \
	elif [ "x${LD_FLAVOR}" = xGNU ] ; then \
		if echo "${LD_VERSION}" | grep -q -E '^2\.3[789]|^2\.[456789]|^[3456789]|^[[:digit:]][[:digit:]]' ; then \
			echo '-T' ; \
		else \
			echo "" ; \
		fi ; \
	else \
		echo "Your linker is not supported" ; \
		exit 1 ; \
	fi)

export LD_DASH_T

# vim:ft=make

Fix linker string comparison for dash
Fix linker string comparison for dash

Calling out to shell results in /bin/sh, so using a Bash-ism there won't
necesssarily work.  In particular, this breaks on Debian.

Suggested-by: Martin Haaß <0bcc71a06885df29d6584e5a7969eb3dd1cba680@gmail.com>
Resolves: #193
Signed-off-by: Robbie Harwood <3f8631879978f4cea53bf1163760f1ac18f9cb08@redhat.com>
