busybox: add alternatives specs for those also provided by procps-ng
[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.26.2
12 PKG_RELEASE:=6
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:=da3e44913fc1a9c9b7c5337ea5292da518683cbff32be630777f565d6036af16
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 PKG_LICENSE:=GPL-2.0
25 PKG_LICENSE_FILES:=LICENSE archival/libarchive/bz/LICENSE
26
27 include $(INCLUDE_DIR)/package.mk
28
29 ifeq ($(DUMP),)
30 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep '^CONFIG_BUSYBOX_' $(TOPDIR)/.config | mkhash md5)
31 endif
32
33 ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
34 BB_MAKE_VERBOSE := V=1
35 else
36 BB_MAKE_VERBOSE :=
37 endif
38
39 define Package/busybox
40 SECTION:=base
41 CATEGORY:=Base system
42 MAINTAINER:=Felix Fietkau <nbd@nbd.name>
43 TITLE:=Core utilities for embedded Linux
44 URL:=http://busybox.net/
45 DEPENDS:=+BUSYBOX_USE_LIBRPC:librpc +BUSYBOX_CONFIG_PAM:libpam +BUSYBOX_CONFIG_NTPD:jsonfilter
46 MENU:=1
47 ALTERNATIVES:=\
48 $(if $(CONFIG_BUSYBOX_DEFAULT_KILL), 100:/bin/kill:/bin/busybox) \
49 $(if $(CONFIG_BUSYBOX_DEFAULT_PS), 100:/bin/ps:/bin/busybox) \
50 $(if $(CONFIG_BUSYBOX_DEFAULT_WATCH), 100:/bin/watch:/bin/busybox) \
51 $(if $(CONFIG_BUSYBOX_DEFAULT_IP), 100:/sbin/ip:/bin/busybox) \
52 $(if $(CONFIG_BUSYBOX_DEFAULT_FREE), 100:/usr/bin/free:/bin/busybox) \
53 $(if $(CONFIG_BUSYBOX_DEFAULT_PGREP), 100:/usr/bin/pgrep:/bin/busybox) \
54 $(if $(CONFIG_BUSYBOX_DEFAULT_PKILL), 100:/usr/bin/pkill:/bin/busybox) \
55 $(if $(CONFIG_BUSYBOX_DEFAULT_PMAP), 100:/usr/bin/pmap:/bin/busybox) \
56 $(if $(CONFIG_BUSYBOX_DEFAULT_PWDX), 100:/usr/bin/pwdx:/bin/busybox) \
57 $(if $(CONFIG_BUSYBOX_DEFAULT_TOP), 100:/usr/bin/top:/bin/busybox) \
58 $(if $(CONFIG_BUSYBOX_DEFAULT_UPTIME), 100:/usr/bin/uptime:/bin/busybox) \
59
60 endef
61
62 define Package/busybox/description
63 The Swiss Army Knife of embedded Linux.
64 It slices, it dices, it makes Julian Fries.
65 endef
66
67 define Package/busybox/config
68 source "$(SOURCE)/Config.in"
69 endef
70
71 BUSYBOX_SYM=$(if $(CONFIG_BUSYBOX_CUSTOM),CONFIG,DEFAULT)
72
73 # don't create a version string containing the actual timestamp
74 export KCONFIG_NOTIMESTAMP=1
75
76 define Build/Configure
77 rm -f $(PKG_BUILD_DIR)/.configured*
78 grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" > $(PKG_BUILD_DIR)/.config
79 yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) \
80 CC="$(TARGET_CC)" \
81 CROSS_COMPILE="$(TARGET_CROSS)" \
82 KBUILD_HAVE_NLS=no \
83 ARCH="$(ARCH)" \
84 $(BB_MAKE_VERBOSE) \
85 oldconfig
86 endef
87
88 LDLIBS:=m crypt
89 ifdef CONFIG_BUSYBOX_USE_LIBRPC
90 TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
91 export LDFLAGS=$(TARGET_LDFLAGS)
92 LDLIBS += rpc
93 endif
94
95 ifdef CONFIG_BUSYBOX_CONFIG_PAM
96 TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
97 export LDFLAGS=$(TARGET_LDFLAGS)
98 LDLIBS += pam pam_misc pthread
99 endif
100
101 ifdef CONFIG_BUSYBOX_DEFAULT_NSLOOKUP_LEDE
102 ifeq ($(CONFIG_USE_GLIBC),y)
103 LDLIBS += resolv
104 endif
105 endif
106
107 define Build/Compile
108 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
109 CC="$(TARGET_CC)" \
110 CROSS_COMPILE="$(TARGET_CROSS)" \
111 KBUILD_HAVE_NLS=no \
112 EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
113 ARCH="$(ARCH)" \
114 SKIP_STRIP=y \
115 LDLIBS="$(LDLIBS)" \
116 $(BB_MAKE_VERBOSE) \
117 all
118 rm -rf $(PKG_INSTALL_DIR)
119 $(FIND) $(PKG_BUILD_DIR) -lname "*busybox" -exec rm \{\} \;
120 $(MAKE) -C $(PKG_BUILD_DIR) \
121 CC="$(TARGET_CC)" \
122 CROSS_COMPILE="$(TARGET_CROSS)" \
123 EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
124 ARCH="$(ARCH)" \
125 CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
126 LDLIBS="$(LDLIBS)" \
127 $(BB_MAKE_VERBOSE) \
128 install
129 endef
130
131 define Package/busybox/install
132 $(INSTALL_DIR) $(1)/etc/init.d
133 $(CP) $(PKG_INSTALL_DIR)/* $(1)/
134 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_CROND),)
135 $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
136 endif
137 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),)
138 $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
139 $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug
140 endif
141 -rm -rf $(1)/lib64
142 endef
143
144 $(eval $(call BuildPackage,busybox))