4f85cc9614dcddcb6f30cc4f662921ff56cdfd7c
[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:=3
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 PKG_INSTALL:=1
24
25 #Busybox use it's own PIE config flag and LDFLAGS are used with ld, not gcc.
26 PKG_ASLR_PIE:=0
27
28 PKG_LICENSE:=GPL-2.0
29 PKG_LICENSE_FILES:=LICENSE archival/libarchive/bz/LICENSE
30 PKG_CPE_ID:=cpe:/a:busybox:busybox
31
32 include $(INCLUDE_DIR)/package.mk
33
34 ifeq ($(DUMP),)
35 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep '^CONFIG_BUSYBOX_' $(TOPDIR)/.config | mkhash md5)
36 endif
37
38 BUSYBOX_SYM=$(if $(CONFIG_BUSYBOX_CUSTOM),CONFIG,DEFAULT)
39 BUSYBOX_IF_ENABLED=$(if $(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_$(1)),$(2))
40
41 define Package/busybox
42 SECTION:=base
43 CATEGORY:=Base system
44 MAINTAINER:=Felix Fietkau <nbd@nbd.name>
45 TITLE:=Core utilities for embedded Linux
46 URL:=http://busybox.net/
47 DEPENDS:=+BUSYBOX_USE_LIBRPC:librpc +BUSYBOX_CONFIG_PAM:libpam +BUSYBOX_CONFIG_NTPD:jsonfilter
48 MENU:=1
49 PROVIDES:=ip
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
78 LDLIBS:=m crypt
79 LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc pthread)
80 ifdef CONFIG_BUSYBOX_USE_LIBRPC
81 LDLIBS += rpc
82 endif
83 ifeq ($(CONFIG_USE_GLIBC),y)
84 LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
85 endif
86
87 MAKE_VARS :=
88 MAKE_FLAGS += \
89 EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
90 EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
91 LDLIBS="$(LDLIBS)" \
92 SKIP_STRIP=y
93 ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
94 MAKE_FLAGS += V=1
95 endif
96
97 MAKE_INSTALL_FLAGS += CONFIG_PREFIX="$(PKG_INSTALL_DIR)"
98
99
100 define Build/Configure
101 grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" > $(PKG_BUILD_DIR)/.config
102 yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) oldconfig
103 endef
104
105 define Package/busybox/install
106 $(INSTALL_DIR) $(1)/etc/init.d
107 $(CP) $(PKG_INSTALL_DIR)/* $(1)/
108 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_CROND),)
109 $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
110 endif
111 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),)
112 $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
113 $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug
114 endif
115 -rm -rf $(1)/lib64
116 endef
117
118 $(eval $(call BuildPackage,busybox))