busybox: add missing TARGET_CPPFLAGS and TARGET_LDFLAGS
[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 PKG_LICENSE:=GPL-2.0
26 PKG_LICENSE_FILES:=LICENSE archival/libarchive/bz/LICENSE
27 PKG_CPE_ID:=cpe:/a:busybox:busybox
28
29 include $(INCLUDE_DIR)/package.mk
30
31 ifeq ($(DUMP),)
32 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep '^CONFIG_BUSYBOX_' $(TOPDIR)/.config | mkhash md5)
33 endif
34
35 BUSYBOX_SYM=$(if $(CONFIG_BUSYBOX_CUSTOM),CONFIG,DEFAULT)
36 BUSYBOX_IF_ENABLED=$(if $(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_$(1)),$(2))
37
38 define Package/busybox
39 SECTION:=base
40 CATEGORY:=Base system
41 MAINTAINER:=Felix Fietkau <nbd@nbd.name>
42 TITLE:=Core utilities for embedded Linux
43 URL:=http://busybox.net/
44 DEPENDS:=+BUSYBOX_USE_LIBRPC:librpc +BUSYBOX_CONFIG_PAM:libpam +BUSYBOX_CONFIG_NTPD:jsonfilter
45 MENU:=1
46 PROVIDES:=ip
47 ALTERNATIVES:=\
48 $(call BUSYBOX_IF_ENABLED,KILL, 100:/bin/kill:/bin/busybox) \
49 $(call BUSYBOX_IF_ENABLED,PS, 100:/bin/ps:/bin/busybox) \
50 $(call BUSYBOX_IF_ENABLED,WATCH, 100:/bin/watch:/bin/busybox) \
51 $(call BUSYBOX_IF_ENABLED,IP, 100:/sbin/ip:/bin/busybox) \
52 $(call BUSYBOX_IF_ENABLED,FREE, 100:/usr/bin/free:/bin/busybox) \
53 $(call BUSYBOX_IF_ENABLED,PGREP, 100:/usr/bin/pgrep:/bin/busybox) \
54 $(call BUSYBOX_IF_ENABLED,PKILL, 100:/usr/bin/pkill:/bin/busybox) \
55 $(call BUSYBOX_IF_ENABLED,PMAP, 100:/usr/bin/pmap:/bin/busybox) \
56 $(call BUSYBOX_IF_ENABLED,PWDX, 100:/usr/bin/pwdx:/bin/busybox) \
57 $(call BUSYBOX_IF_ENABLED,TOP, 100:/usr/bin/top:/bin/busybox) \
58 $(call BUSYBOX_IF_ENABLED,UPTIME, 100:/usr/bin/uptime:/bin/busybox) \
59
60 endef
61
62 define Package/busybox/description
63 The Swiss Army Knife of embedded Linux.
64 It slices, it dices, it makes Julian Fries.
65 endef
66
67 define Package/busybox/config
68 source "$(SOURCE)/Config.in"
69 endef
70
71 # don't create a version string containing the actual timestamp
72 export KCONFIG_NOTIMESTAMP=1
73
74
75 LDLIBS:=m crypt
76 LDLIBS += $(call BUSYBOX_IF_ENABLED,PAM,pam pam_misc pthread)
77 ifdef CONFIG_BUSYBOX_USE_LIBRPC
78 LDLIBS += rpc
79 endif
80 ifeq ($(CONFIG_USE_GLIBC),y)
81 LDLIBS += $(call BUSYBOX_IF_ENABLED,NSLOOKUP_OPENWRT,resolv)
82 endif
83
84 MAKE_VARS :=
85 MAKE_FLAGS += \
86 EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
87 EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
88 LDLIBS="$(LDLIBS)" \
89 SKIP_STRIP=y
90 ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
91 MAKE_FLAGS += V=1
92 endif
93
94 MAKE_INSTALL_FLAGS += CONFIG_PREFIX="$(PKG_INSTALL_DIR)"
95
96
97 define Build/Configure
98 grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" > $(PKG_BUILD_DIR)/.config
99 yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) oldconfig
100 endef
101
102 define Package/busybox/install
103 $(INSTALL_DIR) $(1)/etc/init.d
104 $(CP) $(PKG_INSTALL_DIR)/* $(1)/
105 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_CROND),)
106 $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
107 endif
108 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_NTPD),)
109 $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
110 $(INSTALL_BIN) ./files/ntpd-hotplug $(1)/usr/sbin/ntpd-hotplug
111 endif
112 -rm -rf $(1)/lib64
113 endef
114
115 $(eval $(call BuildPackage,busybox))