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