Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #
  2. # Copyright (C) 2006-2016 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.29.3
  10. PKG_RELEASE:=3
  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:=97648636e579462296478e0218e65e4bc1e9cd69089a3b1aeb810bff7621efb7
  16. PKG_BUILD_DEPENDS:=BUSYBOX_USE_LIBRPC:librpc 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. include $(INCLUDE_DIR)/package.mk
  25. ifeq ($(DUMP),)
  26. STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep '^CONFIG_BUSYBOX_' $(TOPDIR)/.config | mkhash md5)
  27. endif
  28. BUSYBOX_SYM=$(if $(CONFIG_BUSYBOX_CUSTOM),CONFIG,DEFAULT)
  29. BUSYBOX_IF_ENABLED=$(if $(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_$(1)),$(2))
  30. define Package/busybox
  31. SECTION:=base
  32. CATEGORY:=Base system
  33. MAINTAINER:=Felix Fietkau <nbd@nbd.name>
  34. TITLE:=Core utilities for embedded Linux
  35. URL:=http://busybox.net/
  36. DEPENDS:=+BUSYBOX_USE_LIBRPC:librpc +BUSYBOX_CONFIG_PAM:libpam +BUSYBOX_CONFIG_NTPD:jsonfilter
  37. MENU:=1
  38. ALTERNATIVES:=\
  39. $(call BUSYBOX_IF_ENABLED,FLOCK, 100:/usr/bin/flock:/bin/busybox) \
  40. $(call BUSYBOX_IF_ENABLED,FREE, 100:/usr/bin/free:/bin/busybox) \
  41. $(call BUSYBOX_IF_ENABLED,IP, 100:/sbin/ip:/bin/busybox) \
  42. $(call BUSYBOX_IF_ENABLED,KILL, 100:/bin/kill:/bin/busybox) \
  43. $(call BUSYBOX_IF_ENABLED,PGREP, 100:/usr/bin/pgrep:/bin/busybox) \
  44. $(call BUSYBOX_IF_ENABLED,PKILL, 100:/usr/bin/pkill:/bin/busybox) \
  45. $(call BUSYBOX_IF_ENABLED,PMAP, 100:/usr/bin/pmap:/bin/busybox) \
  46. $(call BUSYBOX_IF_ENABLED,PS, 100:/bin/ps:/bin/busybox) \
  47. $(call BUSYBOX_IF_ENABLED,PWDX, 100:/usr/bin/pwdx:/bin/busybox) \
  48. $(call BUSYBOX_IF_ENABLED,TOP, 100:/usr/bin/top:/bin/busybox) \
  49. $(call BUSYBOX_IF_ENABLED,UPTIME, 100:/usr/bin/uptime:/bin/busybox) \
  50. $(call BUSYBOX_IF_ENABLED,WATCH, 100:/bin/watch:/bin/busybox) \
  51. endef
  52. define Package/busybox/description
  53. The Swiss Army Knife of embedded Linux.
  54. It slices, it dices, it makes Julian Fries.
  55. endef
  56. define Package/busybox/config
  57. source "$(SOURCE)/Config.in"
  58. endef
  59. # don't create a version string containing the actual timestamp
  60. export KCONFIG_NOTIMESTAMP=1
  61. ifndef CONFIG_USE_MUSL
  62. LDLIBS:=m crypt
  63. endif
  64. LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc pthread)
  65. ifdef CONFIG_BUSYBOX_USE_LIBRPC
  66. LDLIBS += rpc
  67. endif
  68. ifeq ($(CONFIG_USE_GLIBC),y)
  69. LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_LIBRECMC,resolv)
  70. endif
  71. TARGET_CFLAGS += -flto
  72. TARGET_LDFLAGS += -flto=jobserver -fuse-linker-plugin
  73. MAKE_VARS :=
  74. MAKE_FLAGS += \
  75. EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
  76. EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
  77. LDLIBS="$(LDLIBS)" \
  78. LD="$(TARGET_CC)" \
  79. SKIP_STRIP=y
  80. ifneq ($(findstring c,$(LIBRECMC_VERBOSE)),)
  81. MAKE_FLAGS += V=1
  82. endif
  83. define Build/Configure
  84. grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" > $(PKG_BUILD_DIR)/.config
  85. yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) oldconfig
  86. endef
  87. define Build/Compile
  88. $(call Build/Compile/Default, \
  89. CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
  90. all install \
  91. )
  92. endef
  93. define Package/busybox/install
  94. $(INSTALL_DIR) $(1)/etc/init.d
  95. $(CP) $(PKG_INSTALL_DIR)/* $(1)/
  96. ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_CROND),)
  97. $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
  98. endif
  99. ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),)
  100. $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
  101. $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug
  102. endif
  103. -rm -rf $(1)/lib64
  104. endef
  105. $(eval $(call BuildPackage,busybox))