busybox: add back support for top-level menuconfig based config overrides (can be...
[openwrt.git] / package / utils / busybox / Makefile
1
2 # Copyright (C) 2006-2013 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.19.4
12 PKG_RELEASE:=7
13 PKG_FLAGS:=essential
14
15 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
16 PKG_SOURCE_URL:=http://www.busybox.net/downloads \
17                 http://distfiles.gentoo.org/distfiles/
18 PKG_MD5SUM:=9c0cae5a0379228e7b55e5b29528df8e
19
20 PKG_CONFIG_DEPENDS:=CONFIG_BUSYBOX_CONFIG_FEATURE_MOUNT_NFS
21 PKG_BUILD_PARALLEL:=1
22
23 PKG_LICENSE:=GPLv2 BSD-4c
24 PKG_LICENSE_FILES:=LICENSE archival/libarchive/bz/LICENSE
25
26 include $(INCLUDE_DIR)/package.mk
27
28 ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
29   BB_MAKE_VERBOSE := V=1
30 else
31   BB_MAKE_VERBOSE :=
32 endif
33
34 define Package/busybox
35   SECTION:=base
36   CATEGORY:=Base system
37   MAINTAINER:=Nicolas Thill <nico@openwrt.org>
38   TITLE:=Core utilities for embedded Linux
39   URL:=http://busybox.net/
40   DEPENDS:=+BUSYBOX_ENABLE_NFS_MOUNT:librpc
41   MENU:=1
42 endef
43
44 define Package/busybox/description
45  The Swiss Army Knife of embedded Linux.
46  It slices, it dices, it makes Julian Fries.
47 endef
48
49 define Package/busybox/config
50         source "$(SOURCE)/Config.in"
51 endef
52
53 CONFIG_TEMPLATE:=./config/default
54
55 LDLIBS:=m crypt
56 ifdef CONFIG_BUSYBOX_CONFIG_FEATURE_MOUNT_NFS
57   TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
58   export LDFLAGS=$(TARGET_LDFLAGS)
59   LDLIBS += rpc
60 endif
61
62 CONFIG_TEMPLATE:=+ $(CONFIG_TEMPLATE) $(PKG_BUILD_DIR)/.config.build
63
64 ENV_CONFIG:=$(wildcard $(TOPDIR)/env/busybox-config)
65 ifneq ($(ENV_CONFIG),)
66   CONFIG_TEMPLATE:=+ $(CONFIG_TEMPLATE) $(ENV_CONFIG)
67   STAMP_CONFIGURED:=$(STAMP_CONFIGURED)_$(shell $(SH_FUNC) md5s < $(ENV_CONFIG))
68 endif
69
70 define Build/Configure
71         grep -E '^(# )?CONFIG_BUSYBOX_CONFIG_' $(TOPDIR)/.config | \
72                 sed -e 's,CONFIG_BUSYBOX_CONFIG_,CONFIG_,' > $(PKG_BUILD_DIR)/.config.build
73         $(SCRIPT_DIR)/kconfig.pl $(CONFIG_TEMPLATE) > $(PKG_BUILD_DIR)/.config
74         yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) \
75                 CC="$(TARGET_CC)" \
76                 CROSS_COMPILE="$(TARGET_CROSS)" \
77                 KBUILD_HAVE_NLS=no \
78                 ARCH="$(ARCH)" \
79                 $(BB_MAKE_VERBOSE) \
80                 oldconfig
81 endef
82
83 ifdef CONFIG_GCC_VERSION_LLVM
84   TARGET_CFLAGS += -fnested-functions
85 endif
86
87 define Build/Compile
88         +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
89                 CC="$(TARGET_CC)" \
90                 CROSS_COMPILE="$(TARGET_CROSS)" \
91                 KBUILD_HAVE_NLS=no \
92                 EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
93                 ARCH="$(ARCH)" \
94                 SKIP_STRIP=y \
95                 LDLIBS="$(LDLIBS)" \
96                 $(BB_MAKE_VERBOSE) \
97                 all
98         rm -rf $(PKG_INSTALL_DIR)
99         $(FIND) $(PKG_BUILD_DIR) -lname "*busybox" -exec rm \{\} \;
100         $(MAKE) -C $(PKG_BUILD_DIR) \
101                 CC="$(TARGET_CC)" \
102                 CROSS_COMPILE="$(TARGET_CROSS)" \
103                 EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
104                 ARCH="$(ARCH)" \
105                 CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
106                 LDLIBS="$(LDLIBS)" \
107                 $(BB_MAKE_VERBOSE) \
108                 install
109 endef
110
111 define Package/busybox/install
112         $(INSTALL_DIR) $(1)/etc/init.d
113         $(CP) $(PKG_INSTALL_DIR)/* $(1)/
114         $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
115         $(INSTALL_BIN) ./files/telnet $(1)/etc/init.d/telnet
116         $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
117         -rm -rf $(1)/lib64
118 endef
119
120 $(eval $(call BuildPackage,busybox))