1
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2024-06-17 12:43:56 +02:00
openwrt/tools/elfutils/Makefile
Michael Pratt 20ed56ec8b tools/elfutils: use locally declared static reallocarray()
On macOS, stdlib.h in the standard include paths does not provide
reallocarray() while both elfutils and gnulib do, however they are
declared differently, leading to an error:

  ./system.h:101:1: error: static declaration of 'reallocarray' follows non-static declaration
  reallocarray (void *ptr, size_t nmemb, size_t size)

A normal "configure && make" build cycle results in both declarations
being enabled as a result of both elfutils and gnulib having completely
separate configure checks where gnulib uses an internal placeholder symbol
HAVE_REALLOCARRAY, and elfutils uses a standard autoconf macro
HAVE_DECL_REALLOCARRAY.

Fix this by excluding the import of the reallocarray module which causes
gnulib checks in the configure stage to not even consider whether to
declare reallocarray later on, so the decision is only between the
standard include stdlib.h and the elfutils header.

Tested-by: Georgi Valkov <gvalkov@gmail.com> # MacOS
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
2024-04-25 21:33:51 +02:00

94 lines
1.8 KiB
Makefile

# SPDX-License-Identifier: GPL-2.0-only
include $(TOPDIR)/rules.mk
PKG_NAME:=elfutils
PKG_VERSION:=0.191
PKG_RELEASE:=1
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_SUBDIRS := \
libgnu \
config \
lib \
libelf \
libcpu \
backends \
libebl \
libdwelf \
libdwfl \
libdw
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 \
dirname \
fts \
obstack \
progname \
strchrnul \
tsearch
include $(INCLUDE_DIR)/host-build.mk
ifeq ($(HOST_OS),Darwin)
HOST_CFLAGS += -I/opt/homebrew/include
endif
HOST_CFLAGS += -Wno-error -fPIC
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
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))