80e8846a56b1d56575cb7c93d9fa60f166c3be38
[openwrt/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:=2
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,FIND, 100:/usr/bin/find:/bin/busybox) \
50 $(call BUSYBOX_IF_ENABLED,FLOCK, 100:/usr/bin/flock:/bin/busybox) \
51 $(call BUSYBOX_IF_ENABLED,FREE, 100:/usr/bin/free:/bin/busybox) \
52 $(call BUSYBOX_IF_ENABLED,IP, 100:/sbin/ip:/bin/busybox) \
53 $(call BUSYBOX_IF_ENABLED,KILL, 100:/bin/kill:/bin/busybox) \
54 $(call BUSYBOX_IF_ENABLED,PGREP, 100:/usr/bin/pgrep:/bin/busybox) \
55 $(call BUSYBOX_IF_ENABLED,PKILL, 100:/usr/bin/pkill:/bin/busybox) \
56 $(call BUSYBOX_IF_ENABLED,PMAP, 100:/usr/bin/pmap:/bin/busybox) \
57 $(call BUSYBOX_IF_ENABLED,PS, 100:/bin/ps:/bin/busybox) \
58 $(call BUSYBOX_IF_ENABLED,PWDX, 100:/usr/bin/pwdx:/bin/busybox) \
59 $(call BUSYBOX_IF_ENABLED,TOP, 100:/usr/bin/top:/bin/busybox) \
60 $(call BUSYBOX_IF_ENABLED,UPTIME, 100:/usr/bin/uptime:/bin/busybox) \
61 $(call BUSYBOX_IF_ENABLED,WATCH, 100:/bin/watch:/bin/busybox) \
62 $(call BUSYBOX_IF_ENABLED,XARGS, 100:/usr/bin/xargs:/bin/busybox) \
63
64 endef
65
66 define Package/busybox/description
67 The Swiss Army Knife of embedded Linux.
68 It slices, it dices, it makes Julian Fries.
69 endef
70
71 define Package/busybox/config
72 source "$(SOURCE)/Config.in"
73 endef
74
75 # don't create a version string containing the actual timestamp
76 export KCONFIG_NOTIMESTAMP=1
77
78
79 ifndef CONFIG_USE_MUSL
80 LDLIBS:=m crypt
81 endif
82
83 LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc pthread)
84 ifdef CONFIG_BUSYBOX_USE_LIBRPC
85 LDLIBS += rpc
86 endif
87 ifeq ($(CONFIG_USE_GLIBC),y)
88 LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
89 endif
90
91 TARGET_CFLAGS += -flto
92 TARGET_LDFLAGS += -flto=jobserver -fuse-linker-plugin
93
94 MAKE_VARS :=
95 MAKE_FLAGS += \
96 EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
97 EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
98 LDLIBS="$(LDLIBS)" \
99 LD="$(TARGET_CC)" \
100 SKIP_STRIP=y
101 ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
102 MAKE_FLAGS += V=1
103 endif
104
105 define Build/Configure
106 grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" > $(PKG_BUILD_DIR)/.config
107 yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) oldconfig
108 endef
109
110 define Build/Compile
111 $(call Build/Compile/Default, \
112 CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
113 all install \
114 )
115 endef
116
117 define Package/busybox/install
118 $(INSTALL_DIR) $(1)/etc/init.d
119 $(CP) $(PKG_INSTALL_DIR)/* $(1)/
120 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_CROND),)
121 $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
122 endif
123 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),)
124 $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
125 $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug
126 endif
127 -rm -rf $(1)/lib64
128 endef
129
130 $(eval $(call BuildPackage,busybox))