busybox: strip off ALTERNATIVES spec
[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:=5
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 # All files provided by busybox will serve as fallback alternatives by opkg.
41 # There should be no need to enumerate ALTERNATIVES entries here
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_CONFIG_PAM:libpam +BUSYBOX_CONFIG_NTPD:jsonfilter
49 MENU:=1
50 endef
51
52 define Package/busybox/description
53 The Swiss Army Knife of embedded Linux.
54 It slices, it dices, it makes Julian Fries.
55 endef
56
57 define Package/busybox/config
58 source "$(SOURCE)/Config.in"
59 endef
60
61 ifdef CONFIG_BUSYBOX_CONFIG_FEATURE_SYSLOG
62 define Package/busybox/conffiles
63 /etc/syslog.conf
64 endef
65 endif
66
67 # don't create a version string containing the actual timestamp
68 export KCONFIG_NOTIMESTAMP=1
69
70
71 ifndef CONFIG_USE_MUSL
72 LDLIBS:=m crypt
73 endif
74
75 LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc pthread)
76 ifeq ($(CONFIG_USE_GLIBC),y)
77 LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
78 endif
79
80 TARGET_CFLAGS += -flto
81 TARGET_LDFLAGS += -flto=jobserver -fuse-linker-plugin
82
83 MAKE_VARS :=
84 MAKE_FLAGS += \
85 EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
86 EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
87 LDLIBS="$(LDLIBS)" \
88 LD="$(TARGET_CC)" \
89 SKIP_STRIP=y
90 ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
91 MAKE_FLAGS += V=1
92 endif
93
94 define Build/Configure
95 grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" > $(PKG_BUILD_DIR)/.config
96 yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) oldconfig
97 endef
98
99 define Build/Compile
100 $(call Build/Compile/Default, \
101 CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
102 all install \
103 )
104 endef
105
106 define Package/busybox/install
107 $(INSTALL_DIR) $(1)/etc/init.d
108 $(INSTALL_DIR) $(1)/usr/sbin
109 $(CP) $(PKG_INSTALL_DIR)/* $(1)/
110 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_CROND),)
111 $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
112 endif
113 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),)
114 $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
115 $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug
116 endif
117 -rm -rf $(1)/lib64
118 endef
119
120 $(eval $(call BuildPackage,busybox))