1################################################################################
2#
3# elf2flt
4#
5################################################################################
6
7ELF2FLT_VERSION = 2024.02
8ELF2FLT_SITE = $(call github,uclinux-dev,elf2flt,v$(ELF2FLT_VERSION))
9ELF2FLT_LICENSE = GPL-2.0+
10ELF2FLT_LICENSE_FILES = LICENSE.TXT
11
12HOST_ELF2FLT_DEPENDENCIES = host-binutils host-zlib
13
14# 0001-elf2flt-handle-binutils-2.34.patch
15HOST_ELF2FLT_AUTORECONF = YES
16
17# elf2flt needs to link against libbfd.a and libiberty.a which are
18# provided by host-binutils, but not installed, so we poke directly
19# into the host-binutils build directory. Turns out that the location
20# of libbfd.a has changed in binutils >= 2.41, so we special case
21# binutils 2.39 and 2.40, which are the two remaining versions still
22# using the "old" path". Note: the ARC-special binutils version is not
23# considered because Buildroot only supports ARC CPUs with a MMU and
24# therefore host-elf2flt is never used on ARC. libiberty.a has
25# remained at the same location.
26ifeq ($(BR2_BINUTILS_VERSION_2_40_X),y)
27HOST_ELF2FLT_LIBBFD_PATH = $(HOST_BINUTILS_DIR)/bfd/libbfd.a
28else
29HOST_ELF2FLT_LIBBFD_PATH = $(HOST_BINUTILS_DIR)/bfd/.libs/libbfd.a
30endif
31
32# It is not exactly a host variant, but more a cross variant, which is
33# why we pass a special --target option.
34HOST_ELF2FLT_CONF_OPTS = \
35	--with-bfd-include-dir=$(HOST_BINUTILS_DIR)/bfd/ \
36	--with-binutils-include-dir=$(HOST_BINUTILS_DIR)/include/ \
37	--with-libbfd=$(HOST_ELF2FLT_LIBBFD_PATH) \
38	--with-libiberty=$(HOST_BINUTILS_DIR)/libiberty/libiberty.a \
39	--target=$(GNU_TARGET_NAME) \
40	--disable-werror
41
42HOST_ELF2FLT_LIBS = -lz -ldl
43
44HOST_ELF2FLT_CONF_ENV = LIBS="$(HOST_ELF2FLT_LIBS)"
45
46# Hardlinks between binaries in different directories cause a problem
47# with rpath fixup, so we de-hardlink those binaries, and replace them
48# with copies instead. Note that elf2flt will rename ld to ld.real
49# before installing its own ld, but we already took care of the
50# original ld from binutils so that it is already de-hardlinked. So
51# ld is now the one from elf2flt, and we want to de-hardlinke it.
52ELF2FLT_TOOLS = elf2flt flthdr ld
53define HOST_ELF2FLT_FIXUP_HARDLINKS
54	$(foreach tool,$(ELF2FLT_TOOLS),\
55		rm -f $(HOST_DIR)/$(GNU_TARGET_NAME)/bin/$(tool) && \
56		cp -a $(HOST_DIR)/bin/$(GNU_TARGET_NAME)-$(tool) \
57			$(HOST_DIR)/$(GNU_TARGET_NAME)/bin/$(tool)
58	)
59endef
60HOST_ELF2FLT_POST_INSTALL_HOOKS += HOST_ELF2FLT_FIXUP_HARDLINKS
61
62$(eval $(host-autotools-package))
63