busybox: update to 1.30.0
[oweals/openwrt.git] / package / utils / busybox / Makefile
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
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=busybox
11 PKG_VERSION:=1.30.0
12 PKG_RELEASE:=1
13 PKG_FLAGS:=essential
14
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:=9553da068c0a30b1b8b72479908c1ba58672e2be7b535363a88de5e0f7bc04ce
19
20 PKG_BUILD_DEPENDS:=BUSYBOX_USE_LIBRPC:librpc BUSYBOX_CONFIG_PAM:libpam
21 PKG_BUILD_PARALLEL:=1
22 PKG_CHECK_FORMAT_SECURITY:=0
23
24 #Busybox use it's own PIE config flag and LDFLAGS are used with ld, not gcc.
25 PKG_ASLR_PIE:=0
26
27 PKG_LICENSE:=GPL-2.0
28 PKG_LICENSE_FILES:=LICENSE archival/libarchive/bz/LICENSE
29 PKG_CPE_ID:=cpe:/a:busybox:busybox
30
31 include $(INCLUDE_DIR)/package.mk
32
33 ifeq ($(DUMP),)
34   STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep '^CONFIG_BUSYBOX_' $(TOPDIR)/.config | mkhash md5)
35 endif
36
37 BUSYBOX_SYM=$(if $(CONFIG_BUSYBOX_CUSTOM),CONFIG,DEFAULT)
38 BUSYBOX_IF_ENABLED=$(if $(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_$(1)),$(2))
39
40 define Package/busybox
41   SECTION:=base
42   CATEGORY:=Base system
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
47   MENU:=1
48   ALTERNATIVES:=\
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) \
61
62 endef
63
64 define Package/busybox/description
65  The Swiss Army Knife of embedded Linux.
66  It slices, it dices, it makes Julian Fries.
67 endef
68
69 define Package/busybox/config
70         source "$(SOURCE)/Config.in"
71 endef
72
73 # don't create a version string containing the actual timestamp
74 export KCONFIG_NOTIMESTAMP=1
75
76
77 ifndef CONFIG_USE_MUSL
78 LDLIBS:=m crypt
79 endif
80
81 LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc pthread)
82 ifdef CONFIG_BUSYBOX_USE_LIBRPC
83   LDLIBS += rpc
84 endif
85 ifeq ($(CONFIG_USE_GLIBC),y)
86   LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
87 endif
88
89 TARGET_CFLAGS += -flto
90 TARGET_LDFLAGS += -flto=jobserver -fuse-linker-plugin
91
92 MAKE_VARS :=
93 MAKE_FLAGS += \
94         EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
95         EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
96         LDLIBS="$(LDLIBS)" \
97         LD="$(TARGET_CC)" \
98         SKIP_STRIP=y
99 ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
100   MAKE_FLAGS += V=1
101 endif
102
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
106 endef
107
108 define Build/Compile
109         $(call Build/Compile/Default, \
110                 CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
111                 all install \
112         )
113 endef
114
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
120 endif
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
124 endif
125         -rm -rf $(1)/lib64
126 endef
127
128 $(eval $(call BuildPackage,busybox))