Makefile 4.1 KB

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