Makefile 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #
  2. # Copyright (C) 2006-2020 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. PKG_NAME:=busybox
  9. PKG_VERSION:=1.33.1
  10. PKG_RELEASE:=1
  11. PKG_FLAGS:=essential
  12. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  13. PKG_SOURCE_URL:=https://www.busybox.net/downloads \
  14. http://sources.buildroot.net
  15. PKG_HASH:=12cec6bd2b16d8a9446dd16130f2b92982f1819f6e1c5f5887b6db03f5660d28
  16. PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam
  17. PKG_BUILD_PARALLEL:=1
  18. PKG_CHECK_FORMAT_SECURITY:=0
  19. #Busybox use it's own PIE config flag and LDFLAGS are used with ld, not gcc.
  20. PKG_ASLR_PIE:=0
  21. PKG_LICENSE:=GPL-2.0
  22. PKG_LICENSE_FILES:=LICENSE archival/libarchive/bz/LICENSE
  23. PKG_CPE_ID:=cpe:/a:busybox:busybox
  24. BUSYBOX_SYM=$(if $(CONFIG_BUSYBOX_CUSTOM),CONFIG,DEFAULT)
  25. BUSYBOX_IF_ENABLED=$(if $(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_$(1)),$(2))
  26. ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_FEATURE_SUID),)
  27. PKG_FILE_MODES:=/bin/busybox:root:root:4755
  28. endif
  29. include $(INCLUDE_DIR)/package.mk
  30. ifeq ($(DUMP),)
  31. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep '^CONFIG_BUSYBOX_' $(TOPDIR)/.config | $(MKHASH) md5)
  32. endif
  33. # All files provided by busybox will serve as fallback alternatives by opkg.
  34. # There should be no need to enumerate ALTERNATIVES entries here
  35. define Package/busybox/Default
  36. SECTION:=base
  37. CATEGORY:=Base system
  38. MAINTAINER:=Felix Fietkau <[email protected]>
  39. TITLE:=Core utilities for embedded Linux
  40. URL:=http://busybox.net/
  41. DEPENDS:=+BUSYBOX_CONFIG_PAM:libpam +BUSYBOX_CONFIG_NTPD:jsonfilter
  42. USERID:=ntp=123:ntp=123
  43. endef
  44. define Package/busybox
  45. $(call Package/busybox/Default)
  46. CONFLICTS:=busybox-selinux
  47. VARIANT:=default
  48. endef
  49. define Package/busybox-selinux
  50. $(call Package/busybox/Default)
  51. TITLE += with SELinux support
  52. DEPENDS += +libselinux
  53. VARIANT:=selinux
  54. PROVIDES:=busybox
  55. endef
  56. define Package/busybox/description
  57. The Swiss Army Knife of embedded Linux.
  58. It slices, it dices, it makes Julian Fries.
  59. endef
  60. define Package/busybox/config
  61. source "$(SOURCE)/Config.in"
  62. endef
  63. ifdef CONFIG_BUSYBOX_CONFIG_FEATURE_SYSLOG
  64. define Package/busybox/conffiles
  65. /etc/syslog.conf
  66. endef
  67. Package/busybox-selinux/conffiles = $(Package/busybox/conffiles)
  68. endif
  69. # don't create a version string containing the actual timestamp
  70. export KCONFIG_NOTIMESTAMP=1
  71. ifndef CONFIG_USE_MUSL
  72. LDLIBS:=m crypt
  73. endif
  74. LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc pthread)
  75. ifeq ($(CONFIG_USE_GLIBC),y)
  76. LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
  77. endif
  78. ifeq ($(BUILD_VARIANT),selinux)
  79. LDLIBS += selinux sepol
  80. endif
  81. TARGET_CFLAGS += -flto
  82. TARGET_LDFLAGS += -flto=jobserver -fuse-linker-plugin
  83. MAKE_VARS :=
  84. MAKE_FLAGS += \
  85. EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
  86. EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
  87. LDLIBS="$(LDLIBS)" \
  88. LD="$(TARGET_CC)" \
  89. SKIP_STRIP=y
  90. ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
  91. MAKE_FLAGS += V=1
  92. endif
  93. define Build/Configure
  94. rm -f $(PKG_BUILD_DIR)/.config
  95. touch $(PKG_BUILD_DIR)/.config
  96. ifeq ($(DEVICE_TYPE),nas)
  97. echo "CONFIG_HDPARM=y" >> $(PKG_BUILD_DIR)/.config
  98. endif
  99. ifeq ($(BUILD_VARIANT),selinux)
  100. cat $(TOPDIR)/$(SOURCE)/selinux.config >> $(PKG_BUILD_DIR)/.config
  101. endif
  102. grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" >> $(PKG_BUILD_DIR)/.config
  103. yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) oldconfig
  104. endef
  105. define Build/Compile
  106. $(call Build/Compile/Default, \
  107. CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
  108. all install \
  109. )
  110. endef
  111. define Package/busybox/install
  112. $(INSTALL_DIR) $(1)/etc/init.d
  113. $(INSTALL_DIR) $(1)/usr/sbin
  114. $(CP) $(PKG_INSTALL_DIR)/* $(1)/
  115. ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_CROND),)
  116. $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
  117. endif
  118. ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),)
  119. $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
  120. $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug
  121. $(INSTALL_DIR) $(1)/etc/capabilities $(1)/usr/share/acl.d
  122. $(INSTALL_DATA) ./files/ntpd.capabilities $(1)/etc/capabilities/ntpd.json
  123. $(INSTALL_DATA) ./files/ntpd_acl.json $(1)/usr/share/acl.d/ntpd.json
  124. endif
  125. -rm -rf $(1)/lib64
  126. endef
  127. Package/busybox-selinux/install = $(Package/busybox/install)
  128. $(eval $(call BuildPackage,busybox))
  129. $(eval $(call BuildPackage,busybox-selinux))