openwrt/package/libs/pcre2/Makefile
Petr Štetiar 20295c071a pcre2: fix host compilation of libselinux by enabling PIC
libselinux-3.5 fails to compile in Fedora 38 container due to the
following:

 cc -O2 -I/openwrt/staging_dir/host/include -I/openwrt/staging_dir/hostpkg/include -I/openwrt/staging_dir/target-x86_64_musl/host/include -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 -I/openwrt/staging_dir/hostpkg/include -L/openwrt/staging_dir/host/lib -L/openwrt/staging_dir/hostpkg/lib -L/openwrt/staging_dir/target-x86_64_musl/host/lib -Wl,-rpath=/openwrt/staging_dir/hostpkg/lib -shared -o libselinux.so.1 avc.lo avc_internal.lo avc_sidtab.lo booleans.lo callbacks.lo canonicalize_context.lo checkAccess.lo check_context.lo checkreqprot.lo compute_av.lo compute_create.lo compute_member.lo compute_relabel.lo compute_user.lo context.lo deny_unknown.lo disable.lo enabled.lo fgetfilecon.lo freecon.lo freeconary.lo fsetfilecon.lo get_context_list.lo get_default_type.lo get_initial_context.lo getenforce.lo getfilecon.lo getpeercon.lo init.lo is_customizable_type.lo label.lo label_db.lo label_file.lo label_media.lo label_support.lo label_x.lo lgetfilecon.lo load_policy.lo lsetfilecon.lo mapping.lo matchmediacon.lo matchpathcon.lo policyvers.lo procattr.lo query_user_context.lo regex.lo reject_unknown.lo selinux_check_securetty_context.lo selinux_config.lo selinux_internal.lo selinux_restorecon.lo sestatus.lo setenforce.lo setexecfilecon.lo setfilecon.lo setrans_client.lo seusers.lo sha1.lo stringrep.lo validatetrans.lo -L/openwrt/staging_dir/hostpkg/lib -lpcre2-8 -lfts -ldl -Wl,-soname,libselinux.so.1,--version-script=libselinux.map,-z,defs,-z,relro
 /usr/bin/ld: /openwrt/staging_dir/hostpkg/lib/libpcre2-8.a(pcre2_compile.c.o): relocation R_X86_64_32S against symbol `_pcre2_ucd_stage1_8' can not be used when making a shared object; recompile with -fPIC
 /usr/bin/ld: failed to set dynamic section sizes: bad value

So lets fix it by enabling build of host static library with the
position independent code option enabled.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
(cherry picked from commit 12494f5b8a)
2023-05-31 23:10:06 +02:00

110 lines
2.9 KiB
Makefile

#
# Copyright (C) 2017 Shane Peelar
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=pcre2
PKG_VERSION:=10.42
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://github.com/PCRE2Project/pcre2/releases/download/$(PKG_NAME)-$(PKG_VERSION)
PKG_HASH:=8d36cd8cb6ea2a4c2bb358ff6411b0c788633a2a45dabbf1aeb4b701d1b5e840
PKG_MAINTAINER:=Shane Peelar <lookatyouhacker@gmail.com>
PKG_LICENSE:=BSD-3-Clause
PKG_LICENSE_FILES:=LICENCE
PKG_CPE_ID:=cpe:/a:pcre:pcre
PKG_CONFIG_DEPENDS:=\
CONFIG_PACKAGE_libpcre2-16 \
CONFIG_PACKAGE_libpcre2-32 \
CONFIG_PCRE2_JIT_ENABLED
PKG_BUILD_DEPENDS:=zlib
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/cmake.mk
define Package/libpcre2/default
SECTION:=libs
CATEGORY:=Libraries
URL:=https://www.pcre.org/
endef
define Package/libpcre2/config
source "$(SOURCE)/Config.in"
endef
define Package/libpcre2
$(call Package/libpcre2/default)
TITLE:=A Perl Compatible Regular Expression library
endef
define Package/libpcre2-16
$(call Package/libpcre2/default)
TITLE:=A Perl Compatible Regular Expression library (16bit support)
endef
define Package/libpcre2-32
$(call Package/libpcre2/default)
TITLE:=A Perl Compatible Regular Expression library (32bit support)
endef
CMAKE_HOST_OPTIONS += \
-DBUILD_SHARED_LIBS=OFF \
-DPCRE2_BUILD_PCRE2_8=ON \
-DPCRE2_BUILD_PCRE2_16=ON \
-DPCRE2_BUILD_PCRE2_32=ON \
-DPCRE2_DEBUG=OFF \
-DPCRE2_DISABLE_PERCENT_ZT=ON \
-DPCRE2_SUPPORT_JIT=OFF \
-DPCRE2_SHOW_REPORT=OFF \
-DPCRE2_BUILD_PCRE2GREP=OFF \
-DPCRE2_BUILD_TESTS=OFF \
-DPCRE2_STATIC_PIC=ON
CMAKE_OPTIONS += \
-DBUILD_SHARED_LIBS=ON \
-DPCRE2_BUILD_PCRE2_8=ON \
-DPCRE2_BUILD_PCRE2_16=O$(if $(CONFIG_PACKAGE_libpcre2-16),N,FF) \
-DPCRE2_BUILD_PCRE2_32=O$(if $(CONFIG_PACKAGE_libpcre2-32),N,FF) \
-DPCRE2_DEBUG=OFF \
-DPCRE2_DISABLE_PERCENT_ZT=ON \
-DPCRE2_SUPPORT_JIT=O$(if $(CONFIG_PCRE2_JIT_ENABLED),N,FF) \
-DPCRE2_SHOW_REPORT=OFF \
-DPCRE2_BUILD_PCRE2GREP=OFF \
-DPCRE2_BUILD_TESTS=OFF
define Build/InstallDev
$(call Build/InstallDev/cmake,$(1))
$(SED) 's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' $(1)/usr/bin/pcre2-config
$(INSTALL_DIR) $(2)/bin
$(LN) ../../usr/bin/pcre2-config $(2)/bin/pcre2-config
endef
define Package/libpcre2/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2-{8,posix}.so* $(1)/usr/lib/
endef
define Package/libpcre2-16/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2-16.so* $(1)/usr/lib/
endef
define Package/libpcre2-32/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2-32.so* $(1)/usr/lib/
endef
$(eval $(call BuildPackage,libpcre2))
$(eval $(call BuildPackage,libpcre2-16))
$(eval $(call BuildPackage,libpcre2-32))
$(eval $(call HostBuild))