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