libselinux: fix build on non-Linux systems
[openwrt/staging/rmilecki.git] / package / libs / libselinux / Makefile
1 #
2 # This is free software, licensed under the GNU General Public License v2.
3 # See /LICENSE for more information.
4 #
5
6 include $(TOPDIR)/rules.mk
7
8 PKG_NAME:=libselinux
9 PKG_VERSION:=3.1
10 PKG_RELEASE:=1
11
12 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
13 PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/20200710
14 PKG_HASH:=ea5dcbb4d859e3f999c26a13c630da2f16dff9462e3cc8cb7b458ac157d112e7
15 HOST_BUILD_DEPENDS:=libsepol/host pcre/host
16
17 PKG_MAINTAINER:=Thomas Petazzoni <thomas.petazzoni@bootlin.com>
18
19 include $(INCLUDE_DIR)/package.mk
20
21 define Package/libselinux
22 SECTION:=libs
23 DEPENDS:=+libsepol +libpcre +musl-fts
24 CATEGORY:=Libraries
25 TITLE:=Runtime SELinux library
26 URL:=http://selinuxproject.org/page/Main_Page
27 endef
28
29 define Package/libselinux/description
30 libselinux is the runtime SELinux library that provides
31 interfaces (e.g. library functions for the SELinux kernel
32 APIs like getcon(), other support functions like
33 getseuserbyname()) to SELinux-aware applications. libselinux
34 may use the shared libsepol to manipulate the binary policy
35 if necessary (e.g. to downgrade the policy format to an
36 older version supported by the kernel) when loading policy.
37 endef
38
39 include $(INCLUDE_DIR)/host-build.mk
40
41 # Needed to link libselinux utilities, which link against
42 # libselinux.so, which indirectly depends on libpcre.so, installed in
43 # $(STAGING_DIR_HOSTPKG).
44 HOST_LDFLAGS += -Wl,-rpath="$(STAGING_DIR_HOSTPKG)/lib"
45
46 HOST_MAKE_FLAGS += \
47 PREFIX=$(STAGING_DIR_HOSTPKG) \
48 SHLIBDIR=$(STAGING_DIR_HOSTPKG)/lib
49
50 MAKE_FLAGS += \
51 FTS_LDLIBS=-lfts \
52 SHLIBDIR=/usr/lib \
53 OS=Linux
54
55 define Build/Compile
56 $(call Build/Compile/Default,all)
57 endef
58
59 define Build/Install
60 $(call Build/Install/Default,install)
61 endef
62
63 define Build/InstallDev
64 $(INSTALL_DIR) $(1)/usr/include
65 $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
66 $(INSTALL_DIR) $(1)/usr/lib
67 $(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
68 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
69 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libselinux.pc $(1)/usr/lib/pkgconfig/
70 $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libselinux.pc
71 $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libselinux.pc
72 endef
73
74 define Package/libselinux/install
75 $(INSTALL_DIR) $(1)/usr/lib
76 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libselinux.so.* $(1)/usr/lib/
77 endef
78
79 $(eval $(call HostBuild))
80 $(eval $(call BuildPackage,libselinux))