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