Makefile 4.1 KB

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