busybox: alternatives: accomodate CONFIG_BUSYBOX_CUSTOM=y
[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:=7
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 BUSYBOX_SYM=$(if $(CONFIG_BUSYBOX_CUSTOM),CONFIG,DEFAULT)
40 BUSYBOX_IF_ENABLED=$(if $(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_$(1)),$(2))
41
42 define Package/busybox
43 SECTION:=base
44 CATEGORY:=Base system
45 MAINTAINER:=Felix Fietkau <nbd@nbd.name>
46 TITLE:=Core utilities for embedded Linux
47 URL:=http://busybox.net/
48 DEPENDS:=+BUSYBOX_USE_LIBRPC:librpc +BUSYBOX_CONFIG_PAM:libpam +BUSYBOX_CONFIG_NTPD:jsonfilter
49 MENU:=1
50 ALTERNATIVES:=\
51 $(call BUSYBOX_IF_ENABLED,KILL, 100:/bin/kill:/bin/busybox) \
52 $(call BUSYBOX_IF_ENABLED,PS, 100:/bin/ps:/bin/busybox) \
53 $(call BUSYBOX_IF_ENABLED,WATCH, 100:/bin/watch:/bin/busybox) \
54 $(call BUSYBOX_IF_ENABLED,IP, 100:/sbin/ip:/bin/busybox) \
55 $(call BUSYBOX_IF_ENABLED,FREE, 100:/usr/bin/free:/bin/busybox) \
56 $(call BUSYBOX_IF_ENABLED,PGREP, 100:/usr/bin/pgrep:/bin/busybox) \
57 $(call BUSYBOX_IF_ENABLED,PKILL, 100:/usr/bin/pkill:/bin/busybox) \
58 $(call BUSYBOX_IF_ENABLED,PMAP, 100:/usr/bin/pmap:/bin/busybox) \
59 $(call BUSYBOX_IF_ENABLED,PWDX, 100:/usr/bin/pwdx:/bin/busybox) \
60 $(call BUSYBOX_IF_ENABLED,TOP, 100:/usr/bin/top:/bin/busybox) \
61 $(call BUSYBOX_IF_ENABLED,UPTIME, 100:/usr/bin/uptime:/bin/busybox) \
62
63 endef
64
65 define Package/busybox/description
66 The Swiss Army Knife of embedded Linux.
67 It slices, it dices, it makes Julian Fries.
68 endef
69
70 define Package/busybox/config
71 source "$(SOURCE)/Config.in"
72 endef
73
74 # don't create a version string containing the actual timestamp
75 export KCONFIG_NOTIMESTAMP=1
76
77 define Build/Configure
78 rm -f $(PKG_BUILD_DIR)/.configured*
79 grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" > $(PKG_BUILD_DIR)/.config
80 yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) \
81 CC="$(TARGET_CC)" \
82 CROSS_COMPILE="$(TARGET_CROSS)" \
83 KBUILD_HAVE_NLS=no \
84 ARCH="$(ARCH)" \
85 $(BB_MAKE_VERBOSE) \
86 oldconfig
87 endef
88
89 LDLIBS:=m crypt
90 ifdef CONFIG_BUSYBOX_USE_LIBRPC
91 TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
92 export LDFLAGS=$(TARGET_LDFLAGS)
93 LDLIBS += rpc
94 endif
95
96 ifdef CONFIG_BUSYBOX_CONFIG_PAM
97 TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
98 export LDFLAGS=$(TARGET_LDFLAGS)
99 LDLIBS += pam pam_misc pthread
100 endif
101
102 ifdef CONFIG_BUSYBOX_DEFAULT_NSLOOKUP_LEDE
103 ifeq ($(CONFIG_USE_GLIBC),y)
104 LDLIBS += resolv
105 endif
106 endif
107
108 define Build/Compile
109 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
110 CC="$(TARGET_CC)" \
111 CROSS_COMPILE="$(TARGET_CROSS)" \
112 KBUILD_HAVE_NLS=no \
113 EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
114 ARCH="$(ARCH)" \
115 SKIP_STRIP=y \
116 LDLIBS="$(LDLIBS)" \
117 $(BB_MAKE_VERBOSE) \
118 all
119 rm -rf $(PKG_INSTALL_DIR)
120 $(FIND) $(PKG_BUILD_DIR) -lname "*busybox" -exec rm \{\} \;
121 $(MAKE) -C $(PKG_BUILD_DIR) \
122 CC="$(TARGET_CC)" \
123 CROSS_COMPILE="$(TARGET_CROSS)" \
124 EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
125 ARCH="$(ARCH)" \
126 CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
127 LDLIBS="$(LDLIBS)" \
128 $(BB_MAKE_VERBOSE) \
129 install
130 endef
131
132 define Package/busybox/install
133 $(INSTALL_DIR) $(1)/etc/init.d
134 $(CP) $(PKG_INSTALL_DIR)/* $(1)/
135 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_CROND),)
136 $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
137 endif
138 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),)
139 $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
140 $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug
141 endif
142 -rm -rf $(1)/lib64
143 endef
144
145 $(eval $(call BuildPackage,busybox))