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