2 # Copyright (C) 2006-2016 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 include $(TOPDIR)/rules.mk
15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
16 PKG_SOURCE_URL:=https://www.busybox.net/downloads \
17 http://sources.buildroot.net
18 PKG_HASH:=97648636e579462296478e0218e65e4bc1e9cd69089a3b1aeb810bff7621efb7
20 PKG_BUILD_DEPENDS:=BUSYBOX_USE_LIBRPC:librpc BUSYBOX_CONFIG_PAM:libpam
22 PKG_CHECK_FORMAT_SECURITY:=0
24 #Busybox use it's own PIE config flag and LDFLAGS are used with ld, not gcc.
28 PKG_LICENSE_FILES:=LICENSE archival/libarchive/bz/LICENSE
29 PKG_CPE_ID:=cpe:/a:busybox:busybox
31 include $(INCLUDE_DIR)/package.mk
34 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep '^CONFIG_BUSYBOX_' $(TOPDIR)/.config | mkhash md5)
37 BUSYBOX_SYM=$(if $(CONFIG_BUSYBOX_CUSTOM),CONFIG,DEFAULT)
38 BUSYBOX_IF_ENABLED=$(if $(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_$(1)),$(2))
40 define Package/busybox
43 MAINTAINER:=Felix Fietkau <nbd@nbd.name>
44 TITLE:=Core utilities for embedded Linux
45 URL:=http://busybox.net/
46 DEPENDS:=+BUSYBOX_USE_LIBRPC:librpc +BUSYBOX_CONFIG_PAM:libpam +BUSYBOX_CONFIG_NTPD:jsonfilter
49 $(call BUSYBOX_IF_ENABLED,FLOCK, 100:/usr/bin/flock:/bin/busybox) \
50 $(call BUSYBOX_IF_ENABLED,FREE, 100:/usr/bin/free:/bin/busybox) \
51 $(call BUSYBOX_IF_ENABLED,IP, 100:/sbin/ip:/bin/busybox) \
52 $(call BUSYBOX_IF_ENABLED,KILL, 100:/bin/kill:/bin/busybox) \
53 $(call BUSYBOX_IF_ENABLED,PGREP, 100:/usr/bin/pgrep:/bin/busybox) \
54 $(call BUSYBOX_IF_ENABLED,PKILL, 100:/usr/bin/pkill:/bin/busybox) \
55 $(call BUSYBOX_IF_ENABLED,PMAP, 100:/usr/bin/pmap:/bin/busybox) \
56 $(call BUSYBOX_IF_ENABLED,PS, 100:/bin/ps:/bin/busybox) \
57 $(call BUSYBOX_IF_ENABLED,PWDX, 100:/usr/bin/pwdx:/bin/busybox) \
58 $(call BUSYBOX_IF_ENABLED,TOP, 100:/usr/bin/top:/bin/busybox) \
59 $(call BUSYBOX_IF_ENABLED,UPTIME, 100:/usr/bin/uptime:/bin/busybox) \
60 $(call BUSYBOX_IF_ENABLED,WATCH, 100:/bin/watch:/bin/busybox) \
64 define Package/busybox/description
65 The Swiss Army Knife of embedded Linux.
66 It slices, it dices, it makes Julian Fries.
69 define Package/busybox/config
70 source "$(SOURCE)/Config.in"
73 # don't create a version string containing the actual timestamp
74 export KCONFIG_NOTIMESTAMP=1
77 ifndef CONFIG_USE_MUSL
81 LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc pthread)
82 ifdef CONFIG_BUSYBOX_USE_LIBRPC
85 ifeq ($(CONFIG_USE_GLIBC),y)
86 LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
89 TARGET_CFLAGS += -flto
90 TARGET_LDFLAGS += -flto=jobserver -fuse-linker-plugin
94 EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
95 EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
99 ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
103 define Build/Configure
104 grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" > $(PKG_BUILD_DIR)/.config
105 yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) oldconfig
109 $(call Build/Compile/Default, \
110 CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
115 define Package/busybox/install
116 $(INSTALL_DIR) $(1)/etc/init.d
117 $(CP) $(PKG_INSTALL_DIR)/* $(1)/
118 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_CROND),)
119 $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
121 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),)
122 $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
123 $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug
128 $(eval $(call BuildPackage,busybox))