Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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.31.1
  10. PKG_RELEASE:=4
  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:=d0f940a72f648943c1f2211e0e3117387c31d765137d92bd8284a3fb9752a998
  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. ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_FEATURE_SUID),)
  25. PKG_FILE_MODES:=/bin/busybox:root:root:4755
  26. endif
  27. include $(INCLUDE_DIR)/package.mk
  28. ifeq ($(DUMP),)
  29. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep '^CONFIG_BUSYBOX_' $(TOPDIR)/.config | mkhash md5)
  30. endif
  31. BUSYBOX_SYM=$(if $(CONFIG_BUSYBOX_CUSTOM),CONFIG,DEFAULT)
  32. BUSYBOX_IF_ENABLED=$(if $(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_$(1)),$(2))
  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. endef
  43. define Package/busybox
  44. $(call Package/busybox/Default)
  45. CONFLICTS:=busybox-selinux
  46. VARIANT:=default
  47. endef
  48. define Package/busybox-selinux
  49. $(call Package/busybox/Default)
  50. TITLE += with SELinux support
  51. DEPENDS += +libselinux
  52. VARIANT:=selinux
  53. PROVIDES:=busybox
  54. endef
  55. define Package/busybox/description
  56. The Swiss Army Knife of embedded Linux.
  57. It slices, it dices, it makes Julian Fries.
  58. endef
  59. define Package/busybox/config
  60. source "$(SOURCE)/Config.in"
  61. endef
  62. ifdef CONFIG_BUSYBOX_CONFIG_FEATURE_SYSLOG
  63. define Package/busybox/conffiles
  64. /etc/syslog.conf
  65. endef
  66. Package/busybox-selinux/conffiles = $(Package/busybox/conffiles)
  67. endif
  68. # don't create a version string containing the actual timestamp
  69. export KCONFIG_NOTIMESTAMP=1
  70. ifndef CONFIG_USE_MUSL
  71. LDLIBS:=m crypt
  72. endif
  73. LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc pthread)
  74. ifeq ($(CONFIG_USE_GLIBC),y)
  75. LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
  76. endif
  77. ifeq ($(BUILD_VARIANT),selinux)
  78. LDLIBS += selinux sepol
  79. endif
  80. TARGET_CFLAGS += -flto
  81. TARGET_LDFLAGS += -flto=jobserver -fuse-linker-plugin
  82. MAKE_VARS :=
  83. MAKE_FLAGS += \
  84. EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
  85. EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
  86. LDLIBS="$(LDLIBS)" \
  87. LD="$(TARGET_CC)" \
  88. SKIP_STRIP=y
  89. ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
  90. MAKE_FLAGS += V=1
  91. endif
  92. define Build/Configure
  93. rm -f $(PKG_BUILD_DIR)/.config
  94. touch $(PKG_BUILD_DIR)/.config
  95. ifeq ($(DEVICE_TYPE),nas)
  96. echo "CONFIG_HDPARM=y" >> $(PKG_BUILD_DIR)/.config
  97. endif
  98. ifeq ($(BUILD_VARIANT),selinux)
  99. cat $(TOPDIR)/$(SOURCE)/selinux.config >> $(PKG_BUILD_DIR)/.config
  100. endif
  101. grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" >> $(PKG_BUILD_DIR)/.config
  102. yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) oldconfig
  103. endef
  104. define Build/Compile
  105. $(call Build/Compile/Default, \
  106. CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
  107. all install \
  108. )
  109. endef
  110. define Package/busybox/install
  111. $(INSTALL_DIR) $(1)/etc/init.d
  112. $(INSTALL_DIR) $(1)/usr/sbin
  113. $(CP) $(PKG_INSTALL_DIR)/* $(1)/
  114. ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_CROND),)
  115. $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
  116. endif
  117. ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),)
  118. $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
  119. $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug
  120. endif
  121. -rm -rf $(1)/lib64
  122. endef
  123. Package/busybox-selinux/install = $(Package/busybox/install)
  124. $(eval $(call BuildPackage,busybox))
  125. $(eval $(call BuildPackage,busybox-selinux))