libselinux: opt-out of lto usage
[openwrt/staging/hauke.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.5
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/$(PKG_VERSION)
14 PKG_HASH:=9a3a3705ac13a2ccca2de6d652b6356fead10f36fb33115c185c5ccdf29eec19
15
16 PKG_LICENSE:=libselinux-1.0
17 PKG_LICENSE_FILES:=LICENSE
18 PKG_MAINTAINER:=Thomas Petazzoni <thomas.petazzoni@bootlin.com>
19 PKG_CPE_ID:=cpe:/a:selinuxproject:libselinux
20
21 PKG_BUILD_FLAGS:=no-lto
22
23 HOST_BUILD_DEPENDS:=libsepol/host musl-fts/host pcre2/host
24
25 include $(INCLUDE_DIR)/package.mk
26 include $(INCLUDE_DIR)/host-build.mk
27
28 LIBSELINUX_UTILS := \
29 avcstat \
30 compute_av \
31 compute_create \
32 compute_member \
33 compute_relabel \
34 getconlist \
35 getdefaultcon \
36 getenforce \
37 getfilecon \
38 getpidcon \
39 getsebool \
40 getseuser \
41 matchpathcon \
42 policyvers \
43 sefcontext_compile \
44 selabel_digest \
45 selabel_get_digests_all_partial_matches \
46 selabel_lookup \
47 selabel_lookup_best_match \
48 selabel_partial_match \
49 selinux_check_access \
50 selinux_check_securetty_context \
51 selinuxenabled \
52 selinuxexeccon \
53 setenforce \
54 setfilecon \
55 togglesebool \
56 validatetrans
57
58 LIBSELINUX_ALTS := \
59 getenforce \
60 getsebool \
61 matchpathcon \
62 selinuxenabled \
63 setenforce
64
65 $(eval $(foreach a,$(LIBSELINUX_ALTS),ALTS_$(a):=300:/usr/sbin/$(a):/usr/sbin/libselinux-$(a)$(newline)))
66
67 define Package/libselinux/Default
68 TITLE:=Runtime SELinux library
69 URL:=http://selinuxproject.org/page/Main_Page
70 endef
71
72 define Package/libselinux
73 $(call Package/libselinux/Default)
74 SECTION:=libs
75 CATEGORY:=Libraries
76 DEPENDS:=+libsepol +libpcre2 +USE_MUSL:musl-fts
77 endef
78
79 define Package/libselinux/description
80 libselinux is the runtime SELinux library that provides
81 interfaces (e.g. library functions for the SELinux kernel
82 APIs like getcon(), other support functions like
83 getseuserbyname()) to SELinux-aware applications. libselinux
84 may use the shared libsepol to manipulate the binary policy
85 if necessary (e.g. to downgrade the policy format to an
86 older version supported by the kernel) when loading policy.
87 endef
88
89 define GenUtilPkg
90 define Package/$(1)
91 $(call Package/libselinux/Default)
92 TITLE+= $(2) utility
93 SECTION:=utils
94 DEPENDS:=+libselinux
95 CATEGORY:=Utilities
96 SUBMENU:=libselinux tools
97 ALTERNATIVES:=$(ALTS_$(2))
98 endef
99
100 define Package/$(1)/description
101 libselinux version of the $(2) utility.
102 endef
103 endef
104
105 $(foreach a,$(LIBSELINUX_UTILS),$(eval $(call GenUtilPkg,libselinux-$(a),$(a))))
106
107 # Needed to link libselinux utilities, which link against
108 # libselinux.so, which indirectly depends on libpcre2.so, installed in
109 # $(STAGING_DIR_HOSTPKG).
110 HOST_LDFLAGS += -Wl,-rpath="$(STAGING_DIR_HOSTPKG)/lib"
111
112 HOST_MAKE_FLAGS += \
113 PREFIX=$(STAGING_DIR_HOSTPKG) \
114 SHLIBDIR=$(STAGING_DIR_HOSTPKG)/lib \
115 FTS_LDLIBS=-lfts
116
117 ifeq ($(CONFIG_USE_MUSL),y)
118 MAKE_FLAGS += FTS_LDLIBS=-lfts
119 TARGET_CFLAGS += -D_LARGEFILE64_SOURCE
120 endif
121
122 MAKE_FLAGS += \
123 SHLIBDIR=/usr/lib \
124 OS=Linux
125
126 define Build/Compile
127 $(call Build/Compile/Default,all)
128 endef
129
130 define Build/Install
131 $(call Build/Install/Default,install)
132 endef
133
134 define Build/InstallDev
135 $(INSTALL_DIR) $(1)/usr/include
136 $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
137 $(INSTALL_DIR) $(1)/usr/lib
138 $(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
139 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
140 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libselinux.pc $(1)/usr/lib/pkgconfig/
141 $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libselinux.pc
142 $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libselinux.pc
143 endef
144
145 define Package/libselinux/install
146 $(INSTALL_DIR) $(1)/usr/lib
147 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libselinux.so.* $(1)/usr/lib/
148 endef
149
150 define BuildUtil
151 define Package/$(1)/install
152 $(INSTALL_DIR) $$(1)/usr/sbin
153 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/$(2) $$(1)/usr/sbin/$(if $(ALTS_$(2)),libselinux-$(2),$(2))
154 endef
155
156 $$(eval $$(call BuildPackage,$(1)))
157 endef
158
159 $(eval $(call HostBuild))
160 $(eval $(call BuildPackage,libselinux))
161 $(foreach a,$(LIBSELINUX_UTILS),$(eval $(call BuildUtil,libselinux-$(a),$(a))))