6dbd54d746c06523e19115e5b902f6d7e1d5173f
[openwrt/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.22.1
12 PKG_RELEASE:=1
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:=337d1a15ab1cb1d4ed423168b1eb7d7e
19
20 PKG_BUILD_DEPENDS:=BUSYBOX_USE_LIBRPC:librpc
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 ifeq ($(DUMP),)
29 STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell $(SH_FUNC) grep '^CONFIG_BUSYBOX_' $(TOPDIR)/.config | md5s)
30 endif
31
32 ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
33 BB_MAKE_VERBOSE := V=1
34 else
35 BB_MAKE_VERBOSE :=
36 endif
37
38 define Package/busybox
39 SECTION:=base
40 CATEGORY:=Base system
41 MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
42 TITLE:=Core utilities for embedded Linux
43 URL:=http://busybox.net/
44 DEPENDS:=+BUSYBOX_USE_LIBRPC:librpc
45 MENU:=1
46 endef
47
48 define Package/busybox/description
49 The Swiss Army Knife of embedded Linux.
50 It slices, it dices, it makes Julian Fries.
51 endef
52
53 define Package/busybox/config
54 source "$(SOURCE)/Config.in"
55 endef
56
57 BUSYBOX_SYM=$(if $(CONFIG_BUSYBOX_CUSTOM),CONFIG,DEFAULT)
58
59 define Build/Configure
60 rm -f $(PKG_BUILD_DIR)/.configured*
61 grep 'CONFIG_BUSYBOX_$(BUSYBOX_SYM)' $(TOPDIR)/.config | sed -e "s,\\(# \)\\?CONFIG_BUSYBOX_$(BUSYBOX_SYM)_\\(.*\\),\\1CONFIG_\\2,g" > $(PKG_BUILD_DIR)/.config
62 yes 'n' | $(MAKE) -C $(PKG_BUILD_DIR) \
63 CC="$(TARGET_CC)" \
64 CROSS_COMPILE="$(TARGET_CROSS)" \
65 KBUILD_HAVE_NLS=no \
66 ARCH="$(ARCH)" \
67 $(BB_MAKE_VERBOSE) \
68 oldconfig
69 endef
70
71 ifdef CONFIG_GCC_VERSION_LLVM
72 TARGET_CFLAGS += -fnested-functions
73 endif
74
75 LDLIBS:=m crypt
76 ifdef CONFIG_BUSYBOX_USE_LIBRPC
77 TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
78 export LDFLAGS=$(TARGET_LDFLAGS)
79 LDLIBS += rpc
80 endif
81
82 define Build/Compile
83 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
84 CC="$(TARGET_CC)" \
85 CROSS_COMPILE="$(TARGET_CROSS)" \
86 KBUILD_HAVE_NLS=no \
87 EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
88 ARCH="$(ARCH)" \
89 SKIP_STRIP=y \
90 LDLIBS="$(LDLIBS)" \
91 $(BB_MAKE_VERBOSE) \
92 all
93 rm -rf $(PKG_INSTALL_DIR)
94 $(FIND) $(PKG_BUILD_DIR) -lname "*busybox" -exec rm \{\} \;
95 $(MAKE) -C $(PKG_BUILD_DIR) \
96 CC="$(TARGET_CC)" \
97 CROSS_COMPILE="$(TARGET_CROSS)" \
98 EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
99 ARCH="$(ARCH)" \
100 CONFIG_PREFIX="$(PKG_INSTALL_DIR)" \
101 LDLIBS="$(LDLIBS)" \
102 $(BB_MAKE_VERBOSE) \
103 install
104 endef
105
106 define Package/busybox/install
107 $(INSTALL_DIR) $(1)/etc/init.d
108 $(CP) $(PKG_INSTALL_DIR)/* $(1)/
109 $(INSTALL_BIN) ./files/cron $(1)/etc/init.d/cron
110 $(INSTALL_BIN) ./files/telnet $(1)/etc/init.d/telnet
111 $(INSTALL_BIN) ./files/sysntpd $(1)/etc/init.d/sysntpd
112 -rm -rf $(1)/lib64
113 endef
114
115 $(eval $(call BuildPackage,busybox))