blob: a705bac32b9e4dd6b8a352141797218acd476482 [file] [log] [blame]
Eric Andersenc4996011999-10-20 22:08:37 +00001# Makefile for busybox
2#
Eric Andersenc7bda1c2004-03-15 08:29:22 +00003# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
Erik Andersen9ffdaa62000-02-11 21:55:04 +00004#
Rob Landleya7e14db2005-09-11 01:16:47 +00005# Licensed under GPLv2, see the file LICENSE in this tarball for details.
Eric Andersenc4996011999-10-20 22:08:37 +00006#
7
Rob Landleyd9872aa2006-05-27 21:24:16 +00008# You shouldn't have to edit anything in this file for configuration
9# purposes, try "make help" or read http://busybox.net/FAQ.html.
10
11.PHONY: dummy subdirs release distclean clean config oldconfig menuconfig \
12 tags check test depend dep buildtree hosttools _all checkhelp \
13 sizes bloatcheck baseline objsizes
14
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +000015noconfig_targets := menuconfig config oldconfig randconfig hosttools \
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +000016 defconfig allyesconfig allnoconfig allbareconfig \
Rob Landley19808fe2006-03-13 03:19:46 +000017 clean distclean help \
Eric Andersenbcf27242005-02-13 22:15:59 +000018 release tags
Eric Andersen7daa0762004-10-08 07:46:08 +000019
Bernhard Reutner-Fischere5de3842006-06-10 14:58:33 +000020nocheck_targets := clean distclean help release tags
21
Bernhard Reutner-Fischer1c943eb2005-09-26 16:01:43 +000022# the toplevel sourcedir
Eric Andersen7daa0762004-10-08 07:46:08 +000023ifndef top_srcdir
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000024top_srcdir=$(CURDIR)
Eric Andersen7daa0762004-10-08 07:46:08 +000025endif
Bernhard Reutner-Fischer1c943eb2005-09-26 16:01:43 +000026# toplevel directory of the object-tree
Eric Andersen7daa0762004-10-08 07:46:08 +000027ifndef top_builddir
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000028top_builddir=$(CURDIR)
Eric Andersen7daa0762004-10-08 07:46:08 +000029endif
30
Mike Frysinger9d6e0832005-07-31 22:50:17 +000031export srctree=$(top_srcdir)
Eric Andersen7daa0762004-10-08 07:46:08 +000032vpath %/Config.in $(srctree)
33
Glenn L McGrath3238ea12003-02-15 10:53:40 +000034DIRS:=applets archival archival/libunarchive coreutils console-tools \
35 debianutils editors findutils init miscutils modutils networking \
Mike Frysinger1b4e1da2006-05-08 03:24:36 +000036 networking/libiproute networking/udhcp procps loginutils shell \
Mike Frysingerd89e6292005-04-24 05:07:59 +000037 sysklogd util-linux e2fsprogs libpwdgrp coreutils/libcoreutils libbb
Eric Andersenab050f52001-01-27 06:01:43 +000038
Eric Andersen7daa0762004-10-08 07:46:08 +000039SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
40
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000041# That's our default target when none is given on the command line
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000042_all:
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000043
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000044CONFIG_CONFIG_IN = $(top_srcdir)/Config.in
Eric Andersen7daa0762004-10-08 07:46:08 +000045
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +000046ifeq ($(BUILD_SRC),)
Eric Andersen7daa0762004-10-08 07:46:08 +000047ifdef O
48 ifeq ("$(origin O)", "command line")
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +000049 BUILD_OUTPUT := $(O)
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000050 top_builddir := $(O)
Eric Andersen7daa0762004-10-08 07:46:08 +000051 endif
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000052else
53# If no alternate output-dir was specified, we build in cwd
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +000054# We are using BUILD_OUTPUT nevertheless to make sure that we create
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000055# Rules.mak and the toplevel Makefile, in case they don't exist.
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +000056 BUILD_OUTPUT := $(top_builddir)
57endif
58
59# see if we are in verbose mode
60BUILD_VERBOSE :=
61ifdef V
62 ifeq ("$(origin V)", "command line")
63 BUILD_VERBOSE := $(V)
64 endif
65endif
66ifdef VERBOSE
67 ifeq ("$(origin VERBOSE)", "command line")
68 BUILD_VERBOSE := $(VERBOSE)
69 endif
70endif
71
72ifneq ($(strip $(BUILD_VERBOSE)),)
73 export BUILD_VERBOSE
74 CHECK_VERBOSE := -v
75# ARFLAGS+=v
Eric Andersen7daa0762004-10-08 07:46:08 +000076endif
77
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000078ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
Bernhard Reutner-Fischere5de3842006-06-10 14:58:33 +000079# pull in settings early
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000080-include $(top_srcdir)/Rules.mak
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +000081endif
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000082
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000083# All object directories.
84OBJ_DIRS := $(DIRS)
85all_tree := $(patsubst %,$(top_builddir)/%,$(OBJ_DIRS) scripts scripts/config include)
86all_tree: $(all_tree)
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +000087$(all_tree):
88 @mkdir -p "$@"
89
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +000090ifneq ($(BUILD_OUTPUT),)
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000091# Invoke a second make in the output directory, passing relevant variables
92# Check that the output directory actually exists
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +000093saved-output := $(BUILD_OUTPUT)
94BUILD_OUTPUT := $(shell cd $(BUILD_OUTPUT) && /bin/pwd)
95$(if $(wildcard $(BUILD_OUTPUT)),, \
Eric Andersen7daa0762004-10-08 07:46:08 +000096 $(error output directory "$(saved-output)" does not exist))
97
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000098.PHONY: $(MAKECMDGOALS)
Eric Andersen7daa0762004-10-08 07:46:08 +000099
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +0000100$(filter-out _all,$(MAKECMDGOALS)) _all: $(BUILD_OUTPUT)/Rules.mak $(BUILD_OUTPUT)/Makefile all_tree
101 $(Q)$(MAKE) -C $(BUILD_OUTPUT) \
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000102 top_srcdir=$(top_srcdir) \
103 top_builddir=$(top_builddir) \
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +0000104 BUILD_SRC=$(top_srcdir) \
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000105 -f $(CURDIR)/Makefile $@
106
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +0000107$(BUILD_OUTPUT)/Rules.mak:
Eric Andersen7daa0762004-10-08 07:46:08 +0000108 @echo > $@
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000109 @echo top_srcdir=$(top_srcdir) >> $@
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +0000110 @echo top_builddir=$(BUILD_OUTPUT) >> $@
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000111 @echo include $(top_srcdir)/Rules.mak >> $@
Eric Andersen7daa0762004-10-08 07:46:08 +0000112
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +0000113$(BUILD_OUTPUT)/Makefile:
Eric Andersen7daa0762004-10-08 07:46:08 +0000114 @echo > $@
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000115 @echo top_srcdir=$(top_srcdir) >> $@
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +0000116 @echo top_builddir=$(BUILD_OUTPUT) >> $@
117 @echo BUILD_SRC='$$(top_srcdir)' >> $@
118 @echo include '$$(BUILD_SRC)'/Makefile >> $@
Eric Andersen7daa0762004-10-08 07:46:08 +0000119
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000120# Leave processing to above invocation of make
121skip-makefile := 1
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +0000122endif # ifneq ($(BUILD_OUTPUT),)
123endif # ifeq ($(BUILD_SRC),)
Eric Andersen7daa0762004-10-08 07:46:08 +0000124
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000125ifeq ($(skip-makefile),)
Eric Andersen7daa0762004-10-08 07:46:08 +0000126
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000127# We only need a copy of the Makefile for the config targets and reuse
128# the rest from the source directory, i.e. we do not cp ALL_MAKEFILES.
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000129scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile
130 cp $< $@
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000131
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000132_all: all
Glenn L McGrath6376b582003-09-24 15:48:29 +0000133
Rob Landleyd24eaac2005-09-26 15:49:41 +0000134help:
135 @echo 'Cleaning:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000136 @echo ' clean - delete temporary files created by build'
137 @echo ' distclean - delete all non-source files (including .config)'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000138 @echo
139 @echo 'Build:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000140 @echo ' all - Executable and documentation'
141 @echo ' busybox - the swiss-army executable'
142 @echo ' doc - docs/BusyBox.{txt,html,1}'
Bernhard Reutner-Fischerfa61ca72006-06-16 17:19:39 +0000143 @echo ' html - create html-based cross-reference'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000144 @echo
145 @echo 'Configuration:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000146 @echo ' allnoconfig - disable all symbols in .config'
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000147 @echo ' allyesconfig - enable all symbols in .config (see defconfig)'
148 @echo ' allbareconfig - enable all applets without any sub-features'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000149 @echo ' config - text based configurator (of last resort)'
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000150 @echo ' defconfig - set .config to largest generic configuration'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000151 @echo ' menuconfig - interactive curses-based configurator'
152 @echo ' oldconfig - resolve any unresolved symbols in .config'
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +0000153 @echo ' hosttools - build sed for the host.'
154 @echo ' You can use these commands if the commands on the host'
155 @echo ' is unusable. Afterwards use it like:'
156 @echo ' make SED="$(top_builddir)/sed"'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000157 @echo
158 @echo 'Installation:'
Eric Andersena6db0ee2006-03-20 17:50:08 +0000159 @echo ' install - install busybox into $(PREFIX)'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000160 @echo ' uninstall'
161 @echo
162 @echo 'Development:'
Rob Landley0fbe7dd2006-05-28 01:40:26 +0000163 @echo ' baseline - create busybox_old for bloatcheck.'
Rob Landley0690d152006-05-11 17:33:10 +0000164 @echo ' bloatcheck - show size difference between old and new versions'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000165 @echo ' check - run the test suite for all applets'
Bernhard Reutner-Fischer3916b2a2006-05-04 11:38:33 +0000166 @echo ' checkhelp - check for missing help-entries in Config.in'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000167 @echo ' randconfig - generate a random configuration'
168 @echo ' release - create a distribution tarball'
169 @echo ' sizes - show size of all enabled busybox symbols'
Bernhard Reutner-Fischer06a81d32006-04-26 10:10:25 +0000170 @echo ' objsizes - show size of each .o object built'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000171 @echo
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000172
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000173
174include $(top_srcdir)/Rules.mak
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000175
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000176ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000177
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000178# Default target if none was requested explicitly
Bernhard Reutner-Fischera25d83b2006-03-13 19:30:06 +0000179all: menuconfig
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000180
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000181# warn if no configuration exists and we are asked to build a non-config target
182.config:
183 @echo ""
184 @echo "No $(top_builddir)/$@ found!"
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000185 @echo "Please refer to 'make help', section Configuration."
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000186 @echo ""
187 @exit 1
188
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000189# configuration
190# ---------------------------------------------------------------------------
191
192scripts/config/conf: scripts/config/Makefile
Mike Frysingerb38673f2006-02-02 01:41:53 +0000193 $(Q)$(MAKE) -C scripts/config conf
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000194 -@if [ ! -f .config ] ; then \
195 touch .config; \
196 fi
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000197
198scripts/config/mconf: scripts/config/Makefile
Mike Frysingerb38673f2006-02-02 01:41:53 +0000199 $(Q)$(MAKE) -C scripts/config ncurses conf mconf
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000200 -@if [ ! -f .config ] ; then \
201 touch .config; \
202 fi
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000203
204menuconfig: scripts/config/mconf
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000205 @[ -f .config ] || $(MAKE) $(MAKEFLAGS) defconfig
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000206 @./scripts/config/mconf $(CONFIG_CONFIG_IN)
207
208config: scripts/config/conf
209 @./scripts/config/conf $(CONFIG_CONFIG_IN)
210
211oldconfig: scripts/config/conf
212 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
213
214randconfig: scripts/config/conf
215 @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
216
217allyesconfig: scripts/config/conf
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000218 @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000219
220allnoconfig: scripts/config/conf
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000221 @./scripts/config/conf -n $(CONFIG_CONFIG_IN) > /dev/null
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000222
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000223# defconfig is allyesconfig minus any features that are specialized enough
224# or cause enough behavior change that the user really should switch them on
225# manually if that's what they want. Sort of "maximum sane config".
Rob Landleya167ec52006-01-31 02:42:50 +0000226
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000227defconfig: scripts/config/conf
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000228 @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null
Bernhard Reutner-Fischer273430a2006-07-04 08:26:55 +0000229 @$(SED) -i -r -e "s/^(CONFIG_(DEBUG.*|STATIC|SELINUX|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP|UDHCP_DEBUG)|INSTALL_NO_USR))=.*/# \1 is not set/" .config
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000230 @./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
Rob Landleya167ec52006-01-31 02:42:50 +0000231
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000232
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +0000233allbareconfig: scripts/config/conf
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000234 @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null
Bernhard Reutner-Fischer273430a2006-07-04 08:26:55 +0000235 @$(SED) -i -r -e "s/^(CONFIG_(DEBUG|STATIC|SELINUX|DEVFSD|NC_GAPING_SECURITY_HOLE|BUILD_AT_ONCE)).*/# \1 is not set/" .config
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000236 @$(SED) -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +0000237 @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000238 @yes n | ./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
Bernhard Reutner-Fischera9d89132005-10-07 18:45:03 +0000239
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +0000240hosttools:
241 $(Q)cp .config .config.bak || noold=yea
242 $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" allnoconfig
243 $(Q)mv .config .config.in
244 $(Q)(grep -v CONFIG_SED .config.in ; \
245 echo "CONFIG_SED=y" ; ) > .config
246 $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" oldconfig include/bb_config.h
247 $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" busybox
248 $(Q)[ -f .config.bak ] && mv .config.bak .config || rm .config
249 mv busybox sed
250 @echo "Now do: $(MAKE) SED=$(top_builddir)/sed <target>"
251
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000252else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersen00814662001-04-26 23:29:10 +0000253
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000254all: busybox busybox.links doc
255
256# In this section, we need .config
Eric Andersen7daa0762004-10-08 07:46:08 +0000257-include $(top_builddir)/.config.cmd
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000258include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
Eric Andersen7daa0762004-10-08 07:46:08 +0000259
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000260endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000261
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000262-include $(top_builddir)/.config
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000263-include $(top_builddir)/.depend
264
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000265
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000266ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000267libraries-y:=
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000268# Which parts of the internal libs are requested?
269# Per default we only want what was actually selected.
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000270# -a denotes all while -y denotes the selected ones.
271ifeq ($(strip $(CONFIG_FEATURE_FULL_LIBBUSYBOX)),y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000272LIBRARY_DEFINE:=$(LIBRARY_DEFINE-a)
273LIBRARY_SRC :=$(LIBRARY_SRC-a)
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000274else # CONFIG_FEATURE_FULL_LIBBUSYBOX
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000275LIBRARY_DEFINE:=$(LIBRARY_DEFINE-y)
276LIBRARY_SRC :=$(LIBRARY_SRC-y)
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000277endif # CONFIG_FEATURE_FULL_LIBBUSYBOX
278APPLET_SRC:=$(APPLET_SRC-y)
279APPLETS_DEFINE:=$(APPLETS_DEFINE-y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000280else # CONFIG_BUILD_AT_ONCE
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000281# no --combine, build archives out of the individual .o
282# This was the old way the binary was built.
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000283libbusybox-obj:=archival/libunarchive/libunarchive.a \
284 networking/libiproute/libiproute.a \
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000285 libpwdgrp/libpwdgrp.a \
286 coreutils/libcoreutils/libcoreutils.a \
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000287 libbb/libbb.a
288libbusybox-obj:=$(patsubst %,$(top_builddir)/%,$(libbusybox-obj))
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000289
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000290ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000291# linking against libbusybox, so don't build the .a already contained in the .so
292libraries-y:=$(filter-out $(libbusybox-obj),$(libraries-y))
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000293endif # CONFIG_FEATURE_SHARED_BUSYBOX
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000294endif # CONFIG_BUILD_AT_ONCE
295
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000296
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000297ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
298LD_LIBBUSYBOX:=libbusybox.so
299LIBBUSYBOX_SONAME:=$(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)
300DO_INSTALL_LIBS:=$(LD_LIBBUSYBOX) \
301 $(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
302 $(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION)
Bernhard Reutner-Fischer2b398be2006-04-03 21:16:52 +0000303endif # CONFIG_BUILD_LIBBUSYBOX
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000304
305ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
306ifneq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000307# --combine but not linking against libbusybox, so compile all
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000308BUSYBOX_SRC := $(LIBRARY_SRC)
309BUSYBOX_DEFINE:= $(LIBRARY_DEFINE)
310endif # !CONFIG_FEATURE_SHARED_BUSYBOX
311$(LIBBUSYBOX_SONAME): $(LIBRARY_SRC)
312else # CONFIG_BUILD_AT_ONCE
313$(LIBBUSYBOX_SONAME): $(libbusybox-obj)
314endif # CONFIG_BUILD_AT_ONCE
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000315
316ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
317LDBUSYBOX:=-L$(top_builddir) -lbusybox
318endif
319
320ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000321$(LIBBUSYBOX_SONAME):
322ifndef MAJOR_VERSION
323 $(error MAJOR_VERSION needed for $@ is not defined)
324endif
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +0000325 $(do_link.so) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000326 -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +0000327 -Wl,-z,combreloc
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000328 @rm -f $(DO_INSTALL_LIBS)
329 @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done
Mike Frysingerb38673f2006-02-02 01:41:53 +0000330 $(do_strip)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000331
332endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
333
Bernhard Reutner-Fischerd8e87a02006-05-19 18:37:34 +0000334busybox_unstripped: .depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(libraries-y)
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +0000335 $(do_link)
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000336
337busybox: busybox_unstripped
338 $(Q)cp busybox_unstripped busybox
Mike Frysingerb38673f2006-02-02 01:41:53 +0000339 $(do_strip)
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000340
Mike Frysinger586ea612006-04-21 01:18:07 +0000341%.bflt: %_unstripped
342 $(do_elf2flt)
343
Rob Landleya930bd32005-12-16 06:12:46 +0000344busybox.links: $(top_srcdir)/applets/busybox.mkll include/bb_config.h $(top_srcdir)/include/applets.h
Mike Frysingerb38673f2006-02-02 01:41:53 +0000345 $(Q)-$(SHELL) $^ >$@
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000346
Eric Andersen63024862004-10-13 17:45:57 +0000347install: $(top_srcdir)/applets/install.sh busybox busybox.links
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000348 $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000349 $(SHELL) $< $(PREFIX) $(INSTALL_OPTS)
Eric Andersen13879102004-08-26 23:13:00 +0000350ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
351 @echo
352 @echo
353 @echo --------------------------------------------------
354 @echo You will probably need to make your busybox binary
355 @echo setuid root to ensure all configured applets will
356 @echo work properly.
357 @echo --------------------------------------------------
358 @echo
359endif
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000360
Glenn L McGrath87470de2003-08-29 12:20:31 +0000361uninstall: busybox.links
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000362 rm -f $(PREFIX)/bin/busybox
363 for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000364ifneq ($(strip $(DO_INSTALL_LIBS)),n)
365 for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000366 rm -f $(PREFIX)$$i; \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000367 done
368endif
Eric Andersen1f30a412002-04-13 13:39:48 +0000369
Mike Frysingerce0cf1d2005-09-24 05:47:52 +0000370check test: busybox
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +0000371 bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite SED="$(SED)" \
372 $(SHELL) $(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE)
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000373
Bernhard Reutner-Fischer3916b2a2006-05-04 11:38:33 +0000374checkhelp:
375 $(Q)$(top_srcdir)/scripts/checkhelp.awk \
376 $(wildcard $(patsubst %,%/Config.in,$(SRC_DIRS) ./))
Rob Landleyd9872aa2006-05-27 21:24:16 +0000377
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000378sizes: busybox_unstripped
379 $(NM) --size-sort $(<)
Rob Landleyd9872aa2006-05-27 21:24:16 +0000380
Rob Landleyf8a80842006-05-07 19:26:53 +0000381bloatcheck: busybox_old busybox_unstripped
Rob Landley92d8b352006-05-08 20:48:12 +0000382 @$(top_srcdir)/scripts/bloat-o-meter busybox_old busybox_unstripped
Rob Landley16890752005-09-02 00:41:53 +0000383
Rob Landleyd9872aa2006-05-27 21:24:16 +0000384baseline: busybox_unstripped
385 @mv busybox_unstripped busybox_old
386
Bernhard Reutner-Fischer06a81d32006-04-26 10:10:25 +0000387objsizes: busybox_unstripped
388 $(SHELL) $(top_srcdir)/scripts/objsizes
389
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000390# Documentation Targets
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000391doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
John Beppu94e50542001-04-05 19:42:03 +0000392
Mike Frysingerf37529d2006-02-05 22:15:39 +0000393docs/busybox.pod : $(top_srcdir)/docs/busybox_header.pod $(top_srcdir)/include/usage.h $(top_srcdir)/docs/busybox_footer.pod $(top_srcdir)/docs/autodocifier.pl
Mike Frysingerb38673f2006-02-02 01:41:53 +0000394 $(disp_doc)
395 $(Q)-mkdir -p docs
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000396 $(Q)-( cat $(top_srcdir)/docs/busybox_header.pod ; \
397 $(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h ; \
398 cat $(top_srcdir)/docs/busybox_footer.pod ; ) > docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +0000399
Eric Andersen67536ff2000-07-06 22:53:22 +0000400docs/BusyBox.txt: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000401 $(disp_doc)
402 $(Q)-mkdir -p docs
403 $(Q)-pod2text $< > $@
Eric Andersen53310252000-07-04 19:42:23 +0000404
Eric Andersen67536ff2000-07-06 22:53:22 +0000405docs/BusyBox.1: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000406 $(disp_doc)
407 $(Q)-mkdir -p docs
408 $(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
Eric Andersen19f86202001-02-17 00:42:47 +0000409 $< > $@
Eric Andersen53310252000-07-04 19:42:23 +0000410
Eric Andersen2423b122001-12-08 01:56:15 +0000411docs/BusyBox.html: docs/busybox.net/BusyBox.html
Mike Frysingerb38673f2006-02-02 01:41:53 +0000412 $(disp_doc)
413 $(Q)-mkdir -p docs
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000414 $(Q)-rm -f docs/BusyBox.html
Mike Frysingerb38673f2006-02-02 01:41:53 +0000415 $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
Eric Andersen53310252000-07-04 19:42:23 +0000416
Eric Andersen2423b122001-12-08 01:56:15 +0000417docs/busybox.net/BusyBox.html: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000418 $(Q)-mkdir -p docs/busybox.net
419 $(Q)-pod2html --noindex $< > \
Eric Andersen2423b122001-12-08 01:56:15 +0000420 docs/busybox.net/BusyBox.html
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000421 $(Q)-rm -f pod2htm*
Erik Andersen0a704e82000-05-03 03:19:06 +0000422
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000423# The nifty new dependency stuff
"Vladimir N. Oleynik"5e60dc42005-09-12 12:33:27 +0000424scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c
Mike Frysinger12ef09b2006-04-29 04:19:10 +0000425 $(do_link.h)
Erik Andersen1d1d9502000-04-21 01:26:49 +0000426
"Vladimir N. Oleynik"6732af22006-02-15 12:29:37 +0000427DEP_INCLUDES := include/bb_config.h
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000428
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000429ifeq ($(strip $(CONFIG_BBCONFIG)),y)
430DEP_INCLUDES += include/bbconfigopts.h
431
Bernhard Reutner-Fischer42f091a2006-06-15 21:35:35 +0000432include/bbconfigopts.h: .config $(top_srcdir)/scripts/config/mkconfigs
Mike Frysingerb38673f2006-02-02 01:41:53 +0000433 $(disp_gen)
434 $(Q)$(top_srcdir)/scripts/config/mkconfigs > $@
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000435endif
436
Bernhard Reutner-Fischer30ead9a2006-05-21 09:02:12 +0000437ifeq ($(strip $(CONFIG_FEATURE_COMPRESS_USAGE)),y)
Bernhard Reutner-Fischer4148afe2006-05-21 15:05:49 +0000438USAGE_BIN:=scripts/usage
Paul Foxe3324502006-07-06 20:00:43 +0000439$(USAGE_BIN): $(top_srcdir)/scripts/usage.c .config \
440 $(top_srcdir)/include/usage.h
Bernhard Reutner-Fischer30ead9a2006-05-21 09:02:12 +0000441 $(do_link.h)
Rob Landley7e21d5f2006-04-27 23:34:46 +0000442
443DEP_INCLUDES += include/usage_compressed.h
Bernhard Reutner-Fischer30ead9a2006-05-21 09:02:12 +0000444
Paul Foxe3324502006-07-06 20:00:43 +0000445include/usage_compressed.h: .config $(USAGE_BIN) \
446 $(top_srcdir)/scripts/usage_compressed
447 $(Q)SED="$(SED)" $(SHELL) $(top_srcdir)/scripts/usage_compressed \
448 "$(top_builddir)/scripts" > $@
Bernhard Reutner-Fischer30ead9a2006-05-21 09:02:12 +0000449endif # CONFIG_FEATURE_COMPRESS_USAGE
Rob Landley7e21d5f2006-04-27 23:34:46 +0000450
Bernhard Reutner-Fischer4148afe2006-05-21 15:05:49 +0000451# workaround alleged bug in make-3.80, make-3.81
452.NOTPARALLEL: .depend
453
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000454depend dep: .depend
Bernhard Reutner-Fischer4148afe2006-05-21 15:05:49 +0000455.depend: scripts/bb_mkdep $(USAGE_BIN) $(DEP_INCLUDES)
Mike Frysingerb38673f2006-02-02 01:41:53 +0000456 $(disp_gen)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000457 $(Q)rm -f .depend
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000458 $(Q)mkdir -p include/config
459 $(Q)scripts/bb_mkdep -I $(top_srcdir)/include $(top_srcdir) > $@.tmp
Mike Frysingerb38673f2006-02-02 01:41:53 +0000460 $(Q)mv $@.tmp $@
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000461
"Vladimir N. Oleynik"6732af22006-02-15 12:29:37 +0000462include/bb_config.h: .config
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000463 @if [ ! -x $(top_builddir)/scripts/config/conf ] ; then \
464 $(MAKE) -C scripts/config conf; \
465 fi;
Eric Andersen7daa0762004-10-08 07:46:08 +0000466 @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersen85208e22002-04-12 12:05:57 +0000467
Eric Andersencc8ed391999-10-05 16:24:54 +0000468clean:
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000469 - $(MAKE) -C scripts/config $@
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000470 - rm -f docs/busybox.dvi docs/busybox.ps \
Eric Andersenf7300882004-04-06 15:26:25 +0000471 docs/busybox.pod docs/busybox.net/busybox.html \
Eric Andersen24e098a2003-08-22 20:53:38 +0000472 docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
473 docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
"Vladimir N. Oleynik"9394b232006-01-23 11:24:58 +0000474 docs/busybox.net/BusyBox.html busybox.links \
Bernhard Reutner-Fischera5972112006-03-06 14:19:15 +0000475 libbusybox.so* \
Paul Foxe3324502006-07-06 20:00:43 +0000476 .config.old busybox busybox_unstripped \
477 include/usage_compressed.h scripts/usage
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000478 - rm -r -f _install testsuite/links
Bernhard Reutner-Fischerfa61ca72006-06-16 17:19:39 +0000479 - find . -name .\*.flags -o -name \*.o -o -name \*.om -o -name \*.syn \
Rob Landley31e36102006-03-09 22:01:05 +0000480 -o -name \*.os -o -name \*.osm -o -name \*.a | xargs rm -f
Eric Andersencc8ed391999-10-05 16:24:54 +0000481
482distclean: clean
Mike Frysinger59e46112006-05-10 05:19:27 +0000483 rm -f scripts/bb_mkdep scripts/usage
Bernhard Reutner-Fischer3c8c0692006-05-21 10:04:46 +0000484 rm -r -f include/config include/config.h $(DEP_INCLUDES)
Mike Frysinger59e46112006-05-10 05:19:27 +0000485 find . -name .depend'*' -print0 | xargs -0 rm -f
Rob Landley1f9145c2006-07-12 21:31:16 +0000486 find . -name '*.rej' -print0 | xargs -0 rm -f
Mike Frysinger59e46112006-05-10 05:19:27 +0000487 rm -f .hdepend
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000488 rm -f .config .config.old .config.cmd
Eric Andersencc8ed391999-10-05 16:24:54 +0000489
Eric Andersenc9f20d92002-12-05 08:41:41 +0000490release: distclean #doc
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000491 cd ..; \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000492 rm -r -f $(PROG)-$(VERSION); \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000493 cp -a busybox $(PROG)-$(VERSION); \
494 \
495 find $(PROG)-$(VERSION)/ -type d \
Eric Andersen4306bb12005-08-17 00:03:23 +0000496 -name .svn \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000497 -print \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000498 -exec rm -r -f {} \; ; \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000499 \
500 find $(PROG)-$(VERSION)/ -type f \
501 -name .\#* \
502 -print \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000503 -exec rm -f {} \; ; \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000504 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000505 tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000506
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000507tags:
508 ctags -R .
Matt Kraai4e05da82001-11-19 19:47:56 +0000509
Bernhard Reutner-Fischerfa61ca72006-06-16 17:19:39 +0000510# documentation, cross-reference
511# Modern distributions already ship synopsis packages (e.g. debian)
512# If you have an old distribution go to http://synopsis.fresco.org/
513syn_tgt := $(wildcard $(patsubst %,%/*.c,$(SRC_DIRS)))
514syn := $(patsubst %.c, %.syn, $(syn_tgt))
515
516%.syn: %.c
517 synopsis -p C -l Comments.SSDFilter,Comments.Previous $(INCS) -Wp,verbose,debug,preprocess,cppflags="'$(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) $(APPLETS_DEFINE) $(BUSYBOX_DEFINE)'" -o $@ $<
518html: $(syn)
519 synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
520
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000521
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000522endif # ifeq ($(skip-makefile),)
523