2022-03-28 15:40:30 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
|
|
|
|
PKG_NAME:=elfutils
|
2024-03-04 05:04:36 +00:00
|
|
|
PKG_VERSION:=0.191
|
2024-04-30 09:08:46 +00:00
|
|
|
PKG_RELEASE:=2
|
2022-03-28 15:40:30 +00:00
|
|
|
|
|
|
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
|
|
|
PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION)
|
2024-03-04 05:04:36 +00:00
|
|
|
PKG_HASH:=df76db71366d1d708365fc7a6c60ca48398f14367eb2b8954efc8897147ad871
|
2022-03-28 15:40:30 +00:00
|
|
|
|
|
|
|
PKG_LICENSE:=GPL-3.0-or-later
|
|
|
|
PKG_LICENSE_FILES:=COPYING COPYING-GPLV2 COPYING-LGPLV3
|
|
|
|
PKG_CPE_ID:=cpe:/a:elfutils_project:elfutils
|
|
|
|
|
|
|
|
PKG_FIXUP:=autoreconf
|
|
|
|
PKG_INSTALL:=1
|
|
|
|
|
2024-05-01 19:21:38 +00:00
|
|
|
PKG_PROGRAMS:=elflint findtextrel elfcmp unstrip stack elfcompress elfclassify srcfiles
|
|
|
|
|
2024-04-07 19:28:03 +00:00
|
|
|
PKG_SUBDIRS := \
|
|
|
|
libgnu \
|
|
|
|
config \
|
|
|
|
lib \
|
|
|
|
libelf \
|
|
|
|
libcpu \
|
|
|
|
backends \
|
|
|
|
libebl \
|
|
|
|
libdwelf \
|
|
|
|
libdwfl \
|
2024-05-01 19:21:38 +00:00
|
|
|
libdw \
|
|
|
|
src
|
2024-04-07 19:28:03 +00:00
|
|
|
|
2024-04-05 08:42:14 +00:00
|
|
|
PKG_GNULIB_BASE:=libgnu
|
|
|
|
|
|
|
|
PKG_GNULIB_ARGS = \
|
|
|
|
--dir=$(HOST_BUILD_DIR) \
|
|
|
|
--local-dir=$(STAGING_DIR_HOST)/share/gnulib \
|
|
|
|
--source-base=$(PKG_GNULIB_BASE) \
|
|
|
|
--libtool \
|
2024-04-08 03:28:51 +00:00
|
|
|
--avoid=reallocarray \
|
2024-04-05 08:42:14 +00:00
|
|
|
--import
|
|
|
|
|
|
|
|
PKG_GNULIB_MODS = \
|
|
|
|
argp \
|
2024-06-10 18:43:04 +00:00
|
|
|
fallocate-posix \
|
2024-05-01 19:21:38 +00:00
|
|
|
fnmatch-gnu \
|
2024-04-05 08:42:14 +00:00
|
|
|
fts \
|
|
|
|
obstack \
|
|
|
|
progname \
|
|
|
|
strchrnul \
|
|
|
|
tsearch
|
|
|
|
|
2022-03-28 15:40:30 +00:00
|
|
|
include $(INCLUDE_DIR)/host-build.mk
|
|
|
|
|
tools/elfutils: do not use libtool for all subdirectories
Importing gnulib in order to have a local portable library
to link against for missing functions currently requires
using libtool to produce the libgnu.la library.
Ideally, linking would be simple if the rest of the libraries
built by elfutils were also built using libtool, as linking
them together would not require any manipulations of library paths.
However, upstream elfutils does not support building the libraries
statically with libtool, so using libtool comes at the cost
of creating a huge patch to introduce that functionality.
For building on macOS, it turns out that libgnu.la is only needed
for building the binaries, and that just one or two objects from libgnu
are needed to build the libraries, so in this case, it would be simple
to add the specific non-libtool-wrapped library and objects
to the link paths as needed, rather than use libtool to link
the libtool wrappers, which greatly reduces the need to patch.
Not using libtool also makes the original Makefile definitions for LIBADD
once again be the right ones to use. However, to be portable,
for libdw the wildcard function needs to be used in order to exclude
special archive members like "__.SYMDEF" which are not compiled objects
because some BSD-like versions of ar include that metadata in the list,
or because the library included may have objects from another subdirectory.
Also, the rest of the subdirectories have custom "LDLIBS" variables
meant for building shared objects only, so define the LIBADD variables
with objects from those existing definitions so that when building only
the static versions of the libraries, those objects can still be included.
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/15690
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-05-18 00:11:58 +00:00
|
|
|
export $(PKG_GNULIB_BASE)=$(HOST_BUILD_DIR)/$(PKG_GNULIB_BASE)/.libs/$(PKG_GNULIB_BASE).a
|
|
|
|
export $(PKG_GNULIB_BASE)_fallocate-posix=$(HOST_BUILD_DIR)/$(PKG_GNULIB_BASE)/$(PKG_GNULIB_BASE)_la-posix_fallocate.o
|
|
|
|
export $(PKG_GNULIB_BASE)_tsearch=$(HOST_BUILD_DIR)/$(PKG_GNULIB_BASE)/$(PKG_GNULIB_BASE)_la-tsearch.o
|
tools/elfutils: do not directly link gnulib to libelf
The compiled library resulting from importing gnulib has been
linked to libelf in order to easily cover other link dependencies.
However, this is not appropriate for linking libelf to other programs
as it bloats the resulting libelf library, and may result in
multiple defintions of symbols based on whether or not
certain modules from gnulib are included while elfutils
already has it's own definition of a function.
This is not a problem while building elfutils, because gnulib has
it's own way of creating function aliases and special declarations
that allow the linker to ignore the original function definitions,
however, when libelf is used to link to something else,
this results in an error at link time.
The gnulib manual recommended linking the libraries directly,
but those who have written it may not have considered how this
can affect the ability to link that library in other builds,
they likely assume the build targets would not be a dependency.
Fix this by removing the linking between gnulib and libelf
and instead overriding Make variables in order to add linking
between gnulib and each of the binaries provided by elfutils,
using Make functions to avoid applying it to other subdirectories.
The function tdestroy() would still be missing on macOS,
but the existence of the gnulib tsearch object having been built
is an indicator of whether or not it is needed
because it is only built conditionally by gnulib,
so include linking that object only when it exists.
Block the unnecessary replacement of some functions by gnulib
so that future linking with libelf doesn't require
the associated gnulib "rpl" prefixed functions.
These replacements are very strict in order to correct
minor bugs that don't have a real impact in almost all cases
or new standards requirements that are not yet in effect or used.
Tested-by: Georgi Valkov <gvalkov@gmail.com> # macOS
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/15368
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-05-01 21:47:26 +00:00
|
|
|
|
2024-05-01 19:21:38 +00:00
|
|
|
HOST_MAKE_FLAGS += \
|
2024-05-18 03:47:54 +00:00
|
|
|
DEFAULT_INCLUDES='-I. -I$$$$(top_builddir) -I$$$$(top_srcdir)/$(PKG_GNULIB_BASE)' \
|
2024-05-01 19:21:38 +00:00
|
|
|
AM_LDFLAGS='$$$$(STACK_USAGE_NO_ERROR)' \
|
tools/elfutils: do not directly link gnulib to libelf
The compiled library resulting from importing gnulib has been
linked to libelf in order to easily cover other link dependencies.
However, this is not appropriate for linking libelf to other programs
as it bloats the resulting libelf library, and may result in
multiple defintions of symbols based on whether or not
certain modules from gnulib are included while elfutils
already has it's own definition of a function.
This is not a problem while building elfutils, because gnulib has
it's own way of creating function aliases and special declarations
that allow the linker to ignore the original function definitions,
however, when libelf is used to link to something else,
this results in an error at link time.
The gnulib manual recommended linking the libraries directly,
but those who have written it may not have considered how this
can affect the ability to link that library in other builds,
they likely assume the build targets would not be a dependency.
Fix this by removing the linking between gnulib and libelf
and instead overriding Make variables in order to add linking
between gnulib and each of the binaries provided by elfutils,
using Make functions to avoid applying it to other subdirectories.
The function tdestroy() would still be missing on macOS,
but the existence of the gnulib tsearch object having been built
is an indicator of whether or not it is needed
because it is only built conditionally by gnulib,
so include linking that object only when it exists.
Block the unnecessary replacement of some functions by gnulib
so that future linking with libelf doesn't require
the associated gnulib "rpl" prefixed functions.
These replacements are very strict in order to correct
minor bugs that don't have a real impact in almost all cases
or new standards requirements that are not yet in effect or used.
Tested-by: Georgi Valkov <gvalkov@gmail.com> # macOS
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/15368
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-05-01 21:47:26 +00:00
|
|
|
LIBS+='$$$$(if $$$$(findstring $(lastword $(PKG_SUBDIRS)),$$$$(subdir)), $$$$($(PKG_GNULIB_BASE)))' \
|
2024-06-10 18:43:04 +00:00
|
|
|
LIBS+='$$$$(wildcard $$$$($(PKG_GNULIB_BASE)_fallocate-posix))' \
|
tools/elfutils: do not directly link gnulib to libelf
The compiled library resulting from importing gnulib has been
linked to libelf in order to easily cover other link dependencies.
However, this is not appropriate for linking libelf to other programs
as it bloats the resulting libelf library, and may result in
multiple defintions of symbols based on whether or not
certain modules from gnulib are included while elfutils
already has it's own definition of a function.
This is not a problem while building elfutils, because gnulib has
it's own way of creating function aliases and special declarations
that allow the linker to ignore the original function definitions,
however, when libelf is used to link to something else,
this results in an error at link time.
The gnulib manual recommended linking the libraries directly,
but those who have written it may not have considered how this
can affect the ability to link that library in other builds,
they likely assume the build targets would not be a dependency.
Fix this by removing the linking between gnulib and libelf
and instead overriding Make variables in order to add linking
between gnulib and each of the binaries provided by elfutils,
using Make functions to avoid applying it to other subdirectories.
The function tdestroy() would still be missing on macOS,
but the existence of the gnulib tsearch object having been built
is an indicator of whether or not it is needed
because it is only built conditionally by gnulib,
so include linking that object only when it exists.
Block the unnecessary replacement of some functions by gnulib
so that future linking with libelf doesn't require
the associated gnulib "rpl" prefixed functions.
These replacements are very strict in order to correct
minor bugs that don't have a real impact in almost all cases
or new standards requirements that are not yet in effect or used.
Tested-by: Georgi Valkov <gvalkov@gmail.com> # macOS
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/15368
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-05-01 21:47:26 +00:00
|
|
|
LIBS+='$$$$(wildcard $$$$($(PKG_GNULIB_BASE)_tsearch))' \
|
|
|
|
REPLACE_FCNTL=0 REPLACE_FREE=0 REPLACE_FSTAT=0 REPLACE_OPEN=0 \
|
2024-05-01 19:21:38 +00:00
|
|
|
bin_PROGRAMS='$(PKG_PROGRAMS)' EXEEXT=
|
|
|
|
|
2024-05-15 23:43:00 +00:00
|
|
|
HOST_CPPFLAGS += "'-I$$$$(top_srcdir)/lib'"
|
|
|
|
|
2023-01-11 17:41:22 +00:00
|
|
|
ifeq ($(HOST_OS),Darwin)
|
|
|
|
HOST_CFLAGS += -I/opt/homebrew/include
|
|
|
|
endif
|
|
|
|
|
2023-11-01 16:44:43 +00:00
|
|
|
HOST_CFLAGS += -Wno-error -fPIC
|
2024-05-31 13:47:15 +00:00
|
|
|
HOST_CXXFLAGS += -O2
|
2023-01-11 17:41:22 +00:00
|
|
|
|
2022-03-28 15:40:30 +00:00
|
|
|
HOST_CONFIGURE_ARGS += \
|
2023-01-11 17:41:22 +00:00
|
|
|
--without-libintl-prefix \
|
|
|
|
--without-libiconv-prefix \
|
2022-03-28 15:40:30 +00:00
|
|
|
--disable-debuginfod \
|
|
|
|
--disable-libdebuginfod \
|
|
|
|
--disable-nls \
|
|
|
|
--disable-shared \
|
2023-01-11 17:41:22 +00:00
|
|
|
--enable-static \
|
2022-03-28 15:40:30 +00:00
|
|
|
--without-lzma \
|
2023-11-01 17:37:45 +00:00
|
|
|
--without-bzlib \
|
2022-03-28 15:40:30 +00:00
|
|
|
--without-zstd
|
|
|
|
|
2023-01-11 17:41:22 +00:00
|
|
|
ifeq ($(HOST_OS),Darwin)
|
|
|
|
HOST_CONFIGURE_ARGS += --disable-symbol-versioning
|
|
|
|
endif
|
|
|
|
|
2024-05-18 03:47:54 +00:00
|
|
|
HOST_CONFIGURE_VARS += \
|
|
|
|
ac_cv_search_argp_parse=yes \
|
|
|
|
ac_cv_search_fts_close=yes \
|
|
|
|
ac_cv_search__obstack_free=yes \
|
|
|
|
ac_cv_buildid=yes
|
|
|
|
|
2023-01-11 17:41:22 +00:00
|
|
|
Hooks/HostConfigure/Pre := Host/Gnulib $(Hooks/HostConfigure/Pre)
|
|
|
|
define Host/Gnulib
|
2024-04-05 08:42:14 +00:00
|
|
|
$(STAGING_DIR_HOST)/bin/gnulib-tool $(PKG_GNULIB_ARGS) $(PKG_GNULIB_MODS);
|
2023-01-11 17:41:22 +00:00
|
|
|
endef
|
2022-05-18 22:53:49 +00:00
|
|
|
|
2024-04-07 19:28:03 +00:00
|
|
|
define Host/Compile
|
|
|
|
$(call Host/Compile/Default,SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))')
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Host/Install
|
|
|
|
$(call Host/Compile/Default,install SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))')
|
|
|
|
endef
|
|
|
|
|
2022-09-28 08:23:56 +00:00
|
|
|
define Host/Uninstall
|
|
|
|
-$(call Host/Compile/Default,uninstall)
|
|
|
|
endef
|
|
|
|
|
2022-03-28 15:40:30 +00:00
|
|
|
$(eval $(call HostBuild))
|