package/dhcp/S80dhcp-server: allow empty INTERFACES
[buildroot-gz.git] / package / busybox / busybox.mk
blob7f6dbd693259196efc5d575563a58fc157dac57f
1 ################################################################################
3 # busybox
5 ################################################################################
7 BUSYBOX_VERSION = 1.24.1
8 BUSYBOX_SITE = http://www.busybox.net/downloads
9 BUSYBOX_SOURCE = busybox-$(BUSYBOX_VERSION).tar.bz2
10 BUSYBOX_LICENSE = GPLv2
11 BUSYBOX_LICENSE_FILES = LICENSE
13 BUSYBOX_CFLAGS = \
14 $(TARGET_CFLAGS)
16 BUSYBOX_LDFLAGS = \
17 $(TARGET_LDFLAGS)
19 # Link against libtirpc if available so that we can leverage its RPC
20 # support for NFS mounting with BusyBox
21 ifeq ($(BR2_PACKAGE_LIBTIRPC),y)
22 BUSYBOX_DEPENDENCIES += libtirpc host-pkgconf
23 BUSYBOX_CFLAGS += "`$(PKG_CONFIG_HOST_BINARY) --cflags libtirpc`"
24 # Don't use LDFLAGS for -ltirpc, because LDFLAGS is used for
25 # the non-final link of modules as well.
26 BUSYBOX_CFLAGS_busybox += "`$(PKG_CONFIG_HOST_BINARY) --libs libtirpc`"
27 endif
29 BUSYBOX_BUILD_CONFIG = $(BUSYBOX_DIR)/.config
30 # Allows the build system to tweak CFLAGS
31 BUSYBOX_MAKE_ENV = \
32 $(TARGET_MAKE_ENV) \
33 CFLAGS="$(BUSYBOX_CFLAGS)" \
34 CFLAGS_busybox="$(BUSYBOX_CFLAGS_busybox)"
35 BUSYBOX_MAKE_OPTS = \
36 CC="$(TARGET_CC)" \
37 ARCH=$(KERNEL_ARCH) \
38 PREFIX="$(TARGET_DIR)" \
39 EXTRA_LDFLAGS="$(BUSYBOX_LDFLAGS)" \
40 CROSS_COMPILE="$(TARGET_CROSS)" \
41 CONFIG_PREFIX="$(TARGET_DIR)" \
42 SKIP_STRIP=y
44 ifndef BUSYBOX_CONFIG_FILE
45 BUSYBOX_CONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_BUSYBOX_CONFIG))
46 endif
48 BUSYBOX_KCONFIG_FILE = $(BUSYBOX_CONFIG_FILE)
49 BUSYBOX_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES))
50 BUSYBOX_KCONFIG_EDITORS = menuconfig xconfig gconfig
51 BUSYBOX_KCONFIG_OPTS = $(BUSYBOX_MAKE_OPTS)
53 define BUSYBOX_PERMISSIONS
54 /bin/busybox f 4755 0 0 - - - - -
55 endef
57 # If mdev will be used for device creation enable it and copy S10mdev to /etc/init.d
58 ifeq ($(BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV),y)
59 define BUSYBOX_INSTALL_MDEV_SCRIPT
60 $(INSTALL) -D -m 0755 package/busybox/S10mdev \
61 $(TARGET_DIR)/etc/init.d/S10mdev
62 endef
63 define BUSYBOX_INSTALL_MDEV_CONF
64 $(INSTALL) -D -m 0644 package/busybox/mdev.conf \
65 $(TARGET_DIR)/etc/mdev.conf
66 endef
67 define BUSYBOX_SET_MDEV
68 $(call KCONFIG_ENABLE_OPT,CONFIG_MDEV,$(BUSYBOX_BUILD_CONFIG))
69 $(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_MDEV_CONF,$(BUSYBOX_BUILD_CONFIG))
70 $(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_MDEV_EXEC,$(BUSYBOX_BUILD_CONFIG))
71 $(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_MDEV_LOAD_FIRMWARE,$(BUSYBOX_BUILD_CONFIG))
72 endef
73 endif
75 # sha passwords need USE_BB_CRYPT_SHA
76 ifeq ($(BR2_TARGET_GENERIC_PASSWD_SHA256)$(BR2_TARGET_GENERIC_PASSWD_SHA512),y)
77 define BUSYBOX_SET_CRYPT_SHA
78 $(call KCONFIG_ENABLE_OPT,CONFIG_USE_BB_CRYPT_SHA,$(BUSYBOX_BUILD_CONFIG))
79 endef
80 endif
82 ifeq ($(BR2_USE_MMU),y)
83 define BUSYBOX_SET_MMU
84 $(call KCONFIG_DISABLE_OPT,CONFIG_NOMMU,$(BUSYBOX_BUILD_CONFIG))
85 endef
86 else
87 define BUSYBOX_SET_MMU
88 $(call KCONFIG_ENABLE_OPT,CONFIG_NOMMU,$(BUSYBOX_BUILD_CONFIG))
89 $(call KCONFIG_DISABLE_OPT,CONFIG_SWAPONOFF,$(BUSYBOX_BUILD_CONFIG))
90 $(call KCONFIG_DISABLE_OPT,CONFIG_ASH,$(BUSYBOX_BUILD_CONFIG))
91 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH,$(BUSYBOX_BUILD_CONFIG))
92 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_BASH_COMPAT,$(BUSYBOX_BUILD_CONFIG))
93 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_BRACE_EXPANSION,$(BUSYBOX_BUILD_CONFIG))
94 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_HELP,$(BUSYBOX_BUILD_CONFIG))
95 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_INTERACTIVE,$(BUSYBOX_BUILD_CONFIG))
96 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_SAVEHISTORY,$(BUSYBOX_BUILD_CONFIG))
97 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_JOB,$(BUSYBOX_BUILD_CONFIG))
98 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_TICK,$(BUSYBOX_BUILD_CONFIG))
99 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_IF,$(BUSYBOX_BUILD_CONFIG))
100 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_LOOPS,$(BUSYBOX_BUILD_CONFIG))
101 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_CASE,$(BUSYBOX_BUILD_CONFIG))
102 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_FUNCTIONS,$(BUSYBOX_BUILD_CONFIG))
103 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_LOCAL,$(BUSYBOX_BUILD_CONFIG))
104 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_RANDOM_SUPPORT,$(BUSYBOX_BUILD_CONFIG))
105 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_EXPORT_N,$(BUSYBOX_BUILD_CONFIG))
106 $(call KCONFIG_ENABLE_OPT,CONFIG_HUSH_MODE_X,$(BUSYBOX_BUILD_CONFIG))
107 endef
108 endif
110 define BUSYBOX_SET_LARGEFILE
111 $(call KCONFIG_ENABLE_OPT,CONFIG_LFS,$(BUSYBOX_BUILD_CONFIG))
112 $(call KCONFIG_ENABLE_OPT,CONFIG_FDISK_SUPPORT_LARGE_DISKS,$(BUSYBOX_BUILD_CONFIG))
113 endef
115 define BUSYBOX_SET_IPV6
116 $(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_IPV6,$(BUSYBOX_BUILD_CONFIG))
117 $(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_IFUPDOWN_IPV6,$(BUSYBOX_BUILD_CONFIG))
118 endef
120 # If we're using static libs do the same for busybox
121 ifeq ($(BR2_STATIC_LIBS),y)
122 define BUSYBOX_PREFER_STATIC
123 $(call KCONFIG_ENABLE_OPT,CONFIG_STATIC,$(BUSYBOX_BUILD_CONFIG))
124 endef
125 endif
127 # Disable shadow passwords support if unsupported by the C library
128 ifeq ($(BR2_TOOLCHAIN_HAS_SHADOW_PASSWORDS),)
129 define BUSYBOX_INTERNAL_SHADOW_PASSWORDS
130 $(call KCONFIG_ENABLE_OPT,CONFIG_USE_BB_PWD_GRP,$(BUSYBOX_BUILD_CONFIG))
131 $(call KCONFIG_ENABLE_OPT,CONFIG_USE_BB_SHADOW,$(BUSYBOX_BUILD_CONFIG))
132 endef
133 endif
135 # We also need to use internal shadow password functions when using
136 # the musl C library, since some of them are not yet implemented by
137 # musl.
139 # Do not use utmp/wmtp support. wmtp support is not available in musl,
140 # and utmp support is not sufficient for Busybox.
141 ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
142 define BUSYBOX_MUSL_TWEAKS
143 $(call KCONFIG_ENABLE_OPT,CONFIG_USE_BB_PWD_GRP,$(BUSYBOX_BUILD_CONFIG))
144 $(call KCONFIG_ENABLE_OPT,CONFIG_USE_BB_SHADOW,$(BUSYBOX_BUILD_CONFIG))
145 $(call KCONFIG_DISABLE_OPT,CONFIG_FEATURE_UTMP,$(BUSYBOX_BUILD_CONFIG))
146 $(call KCONFIG_DISABLE_OPT,CONFIG_FEATURE_WTMP,$(BUSYBOX_BUILD_CONFIG))
147 endef
148 endif
150 define BUSYBOX_INSTALL_UDHCPC_SCRIPT
151 if grep -q CONFIG_UDHCPC=y $(@D)/.config; then \
152 $(INSTALL) -m 0755 -D package/busybox/udhcpc.script \
153 $(TARGET_DIR)/usr/share/udhcpc/default.script; \
154 $(INSTALL) -m 0755 -d \
155 $(TARGET_DIR)/usr/share/udhcpc/default.script.d; \
157 endef
159 ifeq ($(BR2_INIT_BUSYBOX),y)
160 define BUSYBOX_SET_INIT
161 $(call KCONFIG_ENABLE_OPT,CONFIG_INIT,$(BUSYBOX_BUILD_CONFIG))
162 endef
163 endif
165 ifeq ($(BR2_PACKAGE_BUSYBOX_SELINUX),y)
166 BUSYBOX_DEPENDENCIES += host-pkgconf libselinux libsepol
167 define BUSYBOX_SET_SELINUX
168 $(call KCONFIG_ENABLE_OPT,CONFIG_SELINUX,$(BUSYBOX_BUILD_CONFIG))
169 $(call KCONFIG_ENABLE_OPT,CONFIG_SELINUXENABLED,$(BUSYBOX_BUILD_CONFIG))
170 endef
171 endif
173 define BUSYBOX_INSTALL_LOGGING_SCRIPT
174 if grep -q CONFIG_SYSLOGD=y $(@D)/.config; then \
175 $(INSTALL) -m 0755 -D package/busybox/S01logging \
176 $(TARGET_DIR)/etc/init.d/S01logging; \
177 else rm -f $(TARGET_DIR)/etc/init.d/S01logging; fi
178 endef
180 ifeq ($(BR2_INIT_BUSYBOX),y)
181 define BUSYBOX_INSTALL_INITTAB
182 $(INSTALL) -D -m 0644 package/busybox/inittab $(TARGET_DIR)/etc/inittab
183 endef
184 endif
186 ifeq ($(BR2_PACKAGE_BUSYBOX_WATCHDOG),y)
187 define BUSYBOX_SET_WATCHDOG
188 $(call KCONFIG_ENABLE_OPT,CONFIG_WATCHDOG,$(BUSYBOX_BUILD_CONFIG))
189 endef
190 define BUSYBOX_INSTALL_WATCHDOG_SCRIPT
191 $(INSTALL) -D -m 0755 package/busybox/S15watchdog \
192 $(TARGET_DIR)/etc/init.d/S15watchdog
193 $(SED) s/PERIOD/$(call qstrip,$(BR2_PACKAGE_BUSYBOX_WATCHDOG_PERIOD))/ \
194 $(TARGET_DIR)/etc/init.d/S15watchdog
195 endef
196 endif
198 # PAM support requires thread support in the toolchain
199 ifeq ($(BR2_PACKAGE_LINUX_PAM)$(BR2_TOOLCHAIN_HAS_THREADS),yy)
200 define BUSYBOX_LINUX_PAM
201 $(call KCONFIG_ENABLE_OPT,CONFIG_PAM,$(BUSYBOX_BUILD_CONFIG))
202 endef
203 BUSYBOX_DEPENDENCIES += linux-pam
204 endif
206 # Telnet support
207 define BUSYBOX_INSTALL_TELNET_SCRIPT
208 if grep -q CONFIG_FEATURE_TELNETD_STANDALONE=y $(@D)/.config; then \
209 $(INSTALL) -m 0755 -D package/busybox/S50telnet \
210 $(TARGET_DIR)/etc/init.d/S50telnet ; \
212 endef
214 # Enable "noclobber" in install.sh, to prevent BusyBox from overwriting any
215 # full-blown versions of apps installed by other packages with sym/hard links.
216 define BUSYBOX_NOCLOBBER_INSTALL
217 $(SED) 's/^noclobber="0"$$/noclobber="1"/' $(@D)/applets/install.sh
218 endef
220 define BUSYBOX_KCONFIG_FIXUP_CMDS
221 $(BUSYBOX_SET_MMU)
222 $(BUSYBOX_SET_LARGEFILE)
223 $(BUSYBOX_SET_IPV6)
224 $(BUSYBOX_PREFER_STATIC)
225 $(BUSYBOX_SET_MDEV)
226 $(BUSYBOX_SET_CRYPT_SHA)
227 $(BUSYBOX_LINUX_PAM)
228 $(BUSYBOX_INTERNAL_SHADOW_PASSWORDS)
229 $(BUSYBOX_SET_INIT)
230 $(BUSYBOX_SET_WATCHDOG)
231 $(BUSYBOX_SET_SELINUX)
232 $(BUSYBOX_MUSL_TWEAKS)
233 endef
235 define BUSYBOX_CONFIGURE_CMDS
236 $(BUSYBOX_NOCLOBBER_INSTALL)
237 endef
239 define BUSYBOX_BUILD_CMDS
240 $(BUSYBOX_MAKE_ENV) $(MAKE) $(BUSYBOX_MAKE_OPTS) -C $(@D)
241 endef
243 define BUSYBOX_INSTALL_TARGET_CMDS
244 $(BUSYBOX_MAKE_ENV) $(MAKE) $(BUSYBOX_MAKE_OPTS) -C $(@D) install
245 $(BUSYBOX_INSTALL_INITTAB)
246 $(BUSYBOX_INSTALL_UDHCPC_SCRIPT)
247 $(BUSYBOX_INSTALL_MDEV_CONF)
248 endef
250 define BUSYBOX_INSTALL_INIT_SYSV
251 $(BUSYBOX_INSTALL_MDEV_SCRIPT)
252 $(BUSYBOX_INSTALL_LOGGING_SCRIPT)
253 $(BUSYBOX_INSTALL_WATCHDOG_SCRIPT)
254 $(BUSYBOX_INSTALL_TELNET_SCRIPT)
255 endef
257 # Checks to give errors that the user can understand
258 # Must be before we call to kconfig-package
259 ifeq ($(BR2_PACKAGE_BUSYBOX)$(BR_BUILDING),yy)
260 ifeq ($(call qstrip,$(BR2_PACKAGE_BUSYBOX_CONFIG)),)
261 $(error No BusyBox configuration file specified, check your BR2_PACKAGE_BUSYBOX_CONFIG setting)
262 endif
263 endif
265 $(eval $(kconfig-package))