Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #
  2. # This is free software, licensed under the GNU General Public License v2.
  3. # See /LICENSE for more information.
  4. #
  5. include $(TOPDIR)/rules.mk
  6. PKG_NAME:=libselinux
  7. PKG_VERSION:=3.1
  8. PKG_RELEASE:=3
  9. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  10. PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/20200710
  11. PKG_HASH:=ea5dcbb4d859e3f999c26a13c630da2f16dff9462e3cc8cb7b458ac157d112e7
  12. HOST_BUILD_DEPENDS:=libsepol/host pcre/host
  13. PKG_LICENSE:=libselinux-1.0
  14. PKG_LICENSE_FILES:=LICENSE
  15. PKG_MAINTAINER:=Thomas Petazzoni <[email protected]>
  16. include $(INCLUDE_DIR)/package.mk
  17. include $(INCLUDE_DIR)/host-build.mk
  18. LIBSELINUX_UTILS := \
  19. avcstat \
  20. compute_av \
  21. compute_create \
  22. compute_member \
  23. compute_relabel \
  24. getconlist \
  25. getdefaultcon \
  26. getenforce \
  27. getfilecon \
  28. getpidcon \
  29. getsebool \
  30. getseuser \
  31. matchpathcon \
  32. policyvers \
  33. sefcontext_compile \
  34. selabel_digest \
  35. selabel_get_digests_all_partial_matches \
  36. selabel_lookup \
  37. selabel_lookup_best_match \
  38. selabel_partial_match \
  39. selinux_check_access \
  40. selinux_check_securetty_context \
  41. selinuxenabled \
  42. selinuxexeccon \
  43. setenforce \
  44. setfilecon \
  45. togglesebool \
  46. validatetrans
  47. LIBSELINUX_ALTS := \
  48. getenforce \
  49. getsebool \
  50. matchpathcon \
  51. selinuxenabled \
  52. setenforce
  53. $(eval $(foreach a,$(LIBSELINUX_ALTS),ALTS_$(a):=300:/usr/sbin/$(a):/usr/sbin/libselinux-$(a)$(newline)))
  54. define Package/libselinux/Default
  55. TITLE:=Runtime SELinux library
  56. URL:=http://selinuxproject.org/page/Main_Page
  57. endef
  58. define Package/libselinux
  59. $(call Package/libselinux/Default)
  60. SECTION:=libs
  61. CATEGORY:=Libraries
  62. DEPENDS:=+libsepol +libpcre +USE_MUSL:musl-fts
  63. endef
  64. define Package/libselinux/description
  65. libselinux is the runtime SELinux library that provides
  66. interfaces (e.g. library functions for the SELinux kernel
  67. APIs like getcon(), other support functions like
  68. getseuserbyname()) to SELinux-aware applications. libselinux
  69. may use the shared libsepol to manipulate the binary policy
  70. if necessary (e.g. to downgrade the policy format to an
  71. older version supported by the kernel) when loading policy.
  72. endef
  73. define GenUtilPkg
  74. define Package/$(1)
  75. $(call Package/libselinux/Default)
  76. TITLE+= $(2) utility
  77. SECTION:=utils
  78. DEPENDS:=+libselinux
  79. CATEGORY:=Utilities
  80. SUBMENU:=libselinux tools
  81. ALTERNATIVES:=$(ALTS_$(2))
  82. endef
  83. define Package/$(1)/description
  84. libselinux version of the $(2) utility.
  85. endef
  86. endef
  87. $(foreach a,$(LIBSELINUX_UTILS),$(eval $(call GenUtilPkg,libselinux-$(a),$(a))))
  88. # Needed to link libselinux utilities, which link against
  89. # libselinux.so, which indirectly depends on libpcre.so, installed in
  90. # $(STAGING_DIR_HOSTPKG).
  91. HOST_LDFLAGS += -Wl,-rpath="$(STAGING_DIR_HOSTPKG)/lib"
  92. HOST_MAKE_FLAGS += \
  93. PREFIX=$(STAGING_DIR_HOSTPKG) \
  94. SHLIBDIR=$(STAGING_DIR_HOSTPKG)/lib
  95. ifeq ($(CONFIG_USE_MUSL),y)
  96. MAKE_FLAGS += FTS_LDLIBS=-lfts
  97. endif
  98. MAKE_FLAGS += \
  99. SHLIBDIR=/usr/lib \
  100. OS=Linux
  101. define Build/Compile
  102. $(call Build/Compile/Default,all)
  103. endef
  104. define Build/Install
  105. $(call Build/Install/Default,install)
  106. endef
  107. define Build/InstallDev
  108. $(INSTALL_DIR) $(1)/usr/include
  109. $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
  110. $(INSTALL_DIR) $(1)/usr/lib
  111. $(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
  112. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  113. $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libselinux.pc $(1)/usr/lib/pkgconfig/
  114. $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libselinux.pc
  115. $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libselinux.pc
  116. endef
  117. define Package/libselinux/install
  118. $(INSTALL_DIR) $(1)/usr/lib
  119. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libselinux.so.* $(1)/usr/lib/
  120. endef
  121. define BuildUtil
  122. define Package/$(1)/install
  123. $(INSTALL_DIR) $$(1)/usr/sbin
  124. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/$(2) $$(1)/usr/sbin/$(if $(ALTS_$(2)),libselinux-$(2),$(2))
  125. endef
  126. $$(eval $$(call BuildPackage,$(1)))
  127. endef
  128. $(eval $(call HostBuild))
  129. $(eval $(call BuildPackage,libselinux))
  130. $(foreach a,$(LIBSELINUX_UTILS),$(eval $(call BuildUtil,libselinux-$(a),$(a))))