libselinux: update to version 3.2
[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.2
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/3.2
14 PKG_HASH:=df758ef1d9d4811051dd901ea6b029ae334ffd7c671c128beb16bce1e25ac161
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 +USE_MUSL: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 ifeq ($(CONFIG_USE_MUSL),y)
113 MAKE_FLAGS += FTS_LDLIBS=-lfts
114 endif
115
116 MAKE_FLAGS += \
117 SHLIBDIR=/usr/lib \
118 OS=Linux
119
120 define Build/Compile
121 $(call Build/Compile/Default,all)
122 endef
123
124 define Build/Install
125 $(call Build/Install/Default,install)
126 endef
127
128 define Build/InstallDev
129 $(INSTALL_DIR) $(1)/usr/include
130 $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
131 $(INSTALL_DIR) $(1)/usr/lib
132 $(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
133 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
134 $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libselinux.pc $(1)/usr/lib/pkgconfig/
135 $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libselinux.pc
136 $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libselinux.pc
137 endef
138
139 define Package/libselinux/install
140 $(INSTALL_DIR) $(1)/usr/lib
141 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libselinux.so.* $(1)/usr/lib/
142 endef
143
144 define BuildUtil
145 define Package/$(1)/install
146 $(INSTALL_DIR) $$(1)/usr/sbin
147 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/$(2) $$(1)/usr/sbin/$(if $(ALTS_$(2)),libselinux-$(2),$(2))
148 endef
149
150 $$(eval $$(call BuildPackage,$(1)))
151 endef
152
153 $(eval $(call HostBuild))
154 $(eval $(call BuildPackage,libselinux))
155 $(foreach a,$(LIBSELINUX_UTILS),$(eval $(call BuildUtil,libselinux-$(a),$(a))))