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