mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-28 01:28:59 +00:00
8ce3873a28
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>
118 lines
2.9 KiB
Makefile
118 lines
2.9 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
PKG_NAME:=elfutils
|
|
PKG_VERSION:=0.191
|
|
PKG_RELEASE:=2
|
|
|
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
|
PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION)
|
|
PKG_HASH:=df76db71366d1d708365fc7a6c60ca48398f14367eb2b8954efc8897147ad871
|
|
|
|
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
|
|
|
|
PKG_PROGRAMS:=elflint findtextrel elfcmp unstrip stack elfcompress elfclassify srcfiles
|
|
|
|
PKG_SUBDIRS := \
|
|
libgnu \
|
|
config \
|
|
lib \
|
|
libelf \
|
|
libcpu \
|
|
backends \
|
|
libebl \
|
|
libdwelf \
|
|
libdwfl \
|
|
libdw \
|
|
src
|
|
|
|
PKG_GNULIB_BASE:=libgnu
|
|
|
|
PKG_GNULIB_ARGS = \
|
|
--dir=$(HOST_BUILD_DIR) \
|
|
--local-dir=$(STAGING_DIR_HOST)/share/gnulib \
|
|
--source-base=$(PKG_GNULIB_BASE) \
|
|
--libtool \
|
|
--avoid=reallocarray \
|
|
--import
|
|
|
|
PKG_GNULIB_MODS = \
|
|
argp \
|
|
fallocate-posix \
|
|
fnmatch-gnu \
|
|
fts \
|
|
obstack \
|
|
progname \
|
|
strchrnul \
|
|
tsearch
|
|
|
|
include $(INCLUDE_DIR)/host-build.mk
|
|
|
|
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
|
|
|
|
HOST_MAKE_FLAGS += \
|
|
DEFAULT_INCLUDES='-I. -I$$$$(top_builddir) -I$$$$(top_srcdir)/$(PKG_GNULIB_BASE)' \
|
|
AM_LDFLAGS='$$$$(STACK_USAGE_NO_ERROR)' \
|
|
LIBS+='$$$$(if $$$$(findstring $(lastword $(PKG_SUBDIRS)),$$$$(subdir)), $$$$($(PKG_GNULIB_BASE)))' \
|
|
LIBS+='$$$$(wildcard $$$$($(PKG_GNULIB_BASE)_fallocate-posix))' \
|
|
LIBS+='$$$$(wildcard $$$$($(PKG_GNULIB_BASE)_tsearch))' \
|
|
REPLACE_FCNTL=0 REPLACE_FREE=0 REPLACE_FSTAT=0 REPLACE_OPEN=0 \
|
|
bin_PROGRAMS='$(PKG_PROGRAMS)' EXEEXT=
|
|
|
|
ifeq ($(HOST_OS),Darwin)
|
|
HOST_CFLAGS += -I/opt/homebrew/include
|
|
endif
|
|
|
|
HOST_CFLAGS += -Wno-error -fPIC
|
|
HOST_CXXFLAGS += -O2
|
|
|
|
HOST_CONFIGURE_ARGS += \
|
|
--without-libintl-prefix \
|
|
--without-libiconv-prefix \
|
|
--disable-debuginfod \
|
|
--disable-libdebuginfod \
|
|
--disable-nls \
|
|
--disable-shared \
|
|
--enable-static \
|
|
--without-lzma \
|
|
--without-bzlib \
|
|
--without-zstd
|
|
|
|
ifeq ($(HOST_OS),Darwin)
|
|
HOST_CONFIGURE_ARGS += --disable-symbol-versioning
|
|
endif
|
|
|
|
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
|
|
|
|
Hooks/HostConfigure/Pre := Host/Gnulib $(Hooks/HostConfigure/Pre)
|
|
define Host/Gnulib
|
|
$(STAGING_DIR_HOST)/bin/gnulib-tool $(PKG_GNULIB_ARGS) $(PKG_GNULIB_MODS);
|
|
ln -sf ../lib/eu-config.h $(HOST_BUILD_DIR)/libgnu/;
|
|
endef
|
|
|
|
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
|
|
|
|
define Host/Uninstall
|
|
-$(call Host/Compile/Default,uninstall)
|
|
endef
|
|
|
|
$(eval $(call HostBuild))
|