blob: 64293b8c7a0d2a97a86b94f6bae812d0aa45097e [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
Eric Andersenc9f20d92002-12-05 08:41:41 +00008#--------------------------------------------------------------
9# You shouldn't need to mess with anything beyond this point...
10#--------------------------------------------------------------
11noconfig_targets := menuconfig config oldconfig randconfig \
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +000012 defconfig allyesconfig allnoconfig allbareconfig \
Bernhard Reutner-Fischera5972112006-03-06 14:19:15 +000013 clean distclean \
Eric Andersenbcf27242005-02-13 22:15:59 +000014 release tags
Eric Andersen7daa0762004-10-08 07:46:08 +000015
Bernhard Reutner-Fischer1c943eb2005-09-26 16:01:43 +000016# the toplevel sourcedir
Eric Andersen7daa0762004-10-08 07:46:08 +000017ifndef top_srcdir
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +000018# make-3.79.1 didn't support MAKEFILE_LIST
19# for building out-of-tree, users of make-3.79.1 still have to pass top_srcdir=
20# to make: make -f /srcs/busybox/Makefile top_srcdir=/srcs/busybox
21ifdef MAKEFILE_LIST
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000022top_srcdir:=$(shell cd $(dir $(firstword $(MAKEFILE_LIST))) && pwd)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +000023else
24top_srcdir:=$(CURDIR)
25endif
Eric Andersen7daa0762004-10-08 07:46:08 +000026endif
Bernhard Reutner-Fischer1c943eb2005-09-26 16:01:43 +000027# toplevel directory of the object-tree
Eric Andersen7daa0762004-10-08 07:46:08 +000028ifndef top_builddir
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000029top_builddir:=$(CURDIR)
Eric Andersen7daa0762004-10-08 07:46:08 +000030endif
31
Mike Frysinger9d6e0832005-07-31 22:50:17 +000032export srctree=$(top_srcdir)
Eric Andersen7daa0762004-10-08 07:46:08 +000033vpath %/Config.in $(srctree)
34
Glenn L McGrath3238ea12003-02-15 10:53:40 +000035DIRS:=applets archival archival/libunarchive coreutils console-tools \
36 debianutils editors findutils init miscutils modutils networking \
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000037 networking/libiproute networking/udhcp procps loginutils shell \
Mike Frysingerd89e6292005-04-24 05:07:59 +000038 sysklogd util-linux e2fsprogs libpwdgrp coreutils/libcoreutils libbb
Eric Andersenab050f52001-01-27 06:01:43 +000039
Eric Andersen7daa0762004-10-08 07:46:08 +000040SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
41
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000042# That's our default target when none is given on the command line
43.PHONY: _all
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000044
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000045_all: all
Eric Andersen7daa0762004-10-08 07:46:08 +000046
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000047# see if we are in verbose mode
48ifdef VERBOSE
49 CHECK_VERBOSE := -v
50 PACKAGE_BE_VERBOSE := $(VERBOSE)
51endif
52ifdef V
53 CHECK_VERBOSE := -v
54 PACKAGE_BE_VERBOSE := $(V)
55endif
Eric Andersen7daa0762004-10-08 07:46:08 +000056
57ifdef O
58 ifeq ("$(origin O)", "command line")
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000059 PACKAGE_OUTPUTDIR := $(shell cd $(O) && pwd)
60 top_builddir := $(PACKAGE_OUTPUTDIR)
Eric Andersen7daa0762004-10-08 07:46:08 +000061 endif
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000062else
63# If no alternate output-dir was specified, we build in cwd
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000064 PACKAGE_OUTPUTDIR := $(top_builddir)
Eric Andersen7daa0762004-10-08 07:46:08 +000065endif
66
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000067define check_gcc
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +000068$(if $(2),$(if $(shell $(CC) $(2) -S -o /dev/null -xc /dev/null > /dev/null 2>&1 && echo y),$(2),$(if $(3),$(3))),$(if $(3),$(3)))
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000069endef
70
71define check_ld
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +000072$(if $(2),$(if $(shell $(LD) $(2) -o /dev/null -b binary /dev/null > /dev/null 2>&1 && echo y),$(shell echo \-Wl,$(2)),$(if $(3),$(3))),$(if $(3),$(3)))
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000073endef
74
75#######################################################################
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +000076# make-3.79.1 doesn't support order-only prerequisites..
77ifeq ($(MAKE_VERSION),3.79.1)
78|: $(^) ;
79endif
80#######################################################################
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000081
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +000082
Bernhard Reutner-Fischer8c7a7e62005-10-13 10:40:18 +000083
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000084# Handle building out of tree
85ifneq ($(top_builddir),$(top_srcdir))
86all_tree := $(patsubst %,$(top_builddir)/%,$(DIRS) scripts scripts/config include include/config)
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +000087$(all_tree):
88 @mkdir -p "$@"
89
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000090saved-output := $(PACKAGE_OUTPUTDIR)
91
92$(if $(wildcard $(PACKAGE_OUTPUTDIR)),, \
Eric Andersen7daa0762004-10-08 07:46:08 +000093 $(error output directory "$(saved-output)" does not exist))
94
Bernhard Reutner-Fischer9b6b8942006-03-02 17:38:15 +000095.PHONY: $(filter $(noconfig_targets),$(MAKECMDGOALS))
Eric Andersen7daa0762004-10-08 07:46:08 +000096
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000097$(PACKAGE_OUTPUTDIR)/Rules.mak:
Eric Andersen7daa0762004-10-08 07:46:08 +000098 @echo > $@
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000099 @echo top_srcdir=$(top_srcdir) >> $@
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000100 @echo top_builddir=$(PACKAGE_OUTPUTDIR) >> $@
101 @echo include $$\(top_srcdir\)/Rules.mak >> $@
Eric Andersen7daa0762004-10-08 07:46:08 +0000102
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000103$(PACKAGE_OUTPUTDIR)/Makefile:
Eric Andersen7daa0762004-10-08 07:46:08 +0000104 @echo > $@
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000105 @echo top_srcdir=$(top_srcdir) >> $@
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000106 @echo top_builddir=$(PACKAGE_OUTPUTDIR) >> $@
107 @echo PACKAGE_SOURCEDIR='$$(top_srcdir)' >> $@
108 @echo include '$$(PACKAGE_SOURCEDIR)'/Makefile >> $@
Eric Andersen7daa0762004-10-08 07:46:08 +0000109
Eric Andersen7daa0762004-10-08 07:46:08 +0000110
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000111buildtree := $(all_tree) $(PACKAGE_OUTPUTDIR)/Rules.mak $(PACKAGE_OUTPUTDIR)/Makefile
Eric Andersen7daa0762004-10-08 07:46:08 +0000112
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000113# We only need a copy of the Makefile for the config targets and reuse
114# the rest from the source directory, i.e. we do not cp ALL_MAKEFILES.
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000115scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile | $(buildtree)
116 @cp $(top_srcdir)/scripts/config/Makefile $@
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000117
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000118else
119all_tree := include/config
120$(all_tree):
121 @mkdir -p "$@"
122buildtree := $(all_tree)
123endif # ifneq ($(PACKAGE_OUTPUTDIR),$(top_srcdir))
Glenn L McGrath6376b582003-09-24 15:48:29 +0000124
Rob Landleyd24eaac2005-09-26 15:49:41 +0000125help:
126 @echo 'Cleaning:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000127 @echo ' clean - delete temporary files created by build'
128 @echo ' distclean - delete all non-source files (including .config)'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000129 @echo
130 @echo 'Build:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000131 @echo ' all - Executable and documentation'
132 @echo ' busybox - the swiss-army executable'
133 @echo ' doc - docs/BusyBox.{txt,html,1}'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000134 @echo
135 @echo 'Configuration:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000136 @echo ' allnoconfig - disable all symbols in .config'
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000137 @echo ' allyesconfig - enable all symbols in .config (see defconfig)'
138 @echo ' allbareconfig - enable all applets without any sub-features'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000139 @echo ' config - text based configurator (of last resort)'
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000140 @echo ' defconfig - set .config to largest generic configuration'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000141 @echo ' menuconfig - interactive curses-based configurator'
142 @echo ' oldconfig - resolve any unresolved symbols in .config'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000143 @echo
144 @echo 'Installation:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000145 @echo ' install - install busybox into $prefix'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000146 @echo ' uninstall'
147 @echo
148 @echo 'Development:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000149 @echo ' check - run the test suite for all applets'
150 @echo ' randconfig - generate a random configuration'
151 @echo ' release - create a distribution tarball'
152 @echo ' sizes - show size of all enabled busybox symbols'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000153 @echo
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000154 @echo 'Make flags:'
155 @echo ' V=<number> - print verbose make output (default: unset)'
156 @echo ' 0 print CC invocations'
157 @echo ' 1'
158 @echo ' 2 also print when make enters a directory'
159 @echo ' 3 also verbosely print shell invocations'
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000160
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000161-include $(top_srcdir)/Rules.mak
162
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000163ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000164# Default target if none was requested explicitly
Rob Landley9dc69132006-03-13 02:52:23 +0000165all: menuconfig ;
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000166
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000167ifneq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000168# warn if no configuration exists and we are asked to build a non-config target
169.config:
170 @echo ""
171 @echo "No $(top_builddir)/$@ found!"
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000172 @echo "Please refer to 'make help', section Configuration."
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000173 @echo ""
174 @exit 1
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000175else
176# Avoid implicit rule to kick in by using an empty command
177.config: $(buildtree) ;
178endif
179endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
180
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000181
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000182# configuration
183# ---------------------------------------------------------------------------
184
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000185CONFIG_CONFIG_IN = $(top_srcdir)/Config.in
186
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000187scripts/config/conf: scripts/config/Makefile
Mike Frysingerb38673f2006-02-02 01:41:53 +0000188 $(Q)$(MAKE) -C scripts/config conf
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000189
190scripts/config/mconf: scripts/config/Makefile
Mike Frysingerb38673f2006-02-02 01:41:53 +0000191 $(Q)$(MAKE) -C scripts/config ncurses conf mconf
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000192
193menuconfig: scripts/config/mconf
Rob Landley9dc69132006-03-13 02:52:23 +0000194 @[ -f .config ] || make $(MAKEFLAGS) defconfig
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000195 @./scripts/config/mconf $(CONFIG_CONFIG_IN)
196
197config: scripts/config/conf
198 @./scripts/config/conf $(CONFIG_CONFIG_IN)
199
200oldconfig: scripts/config/conf
201 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
202
203randconfig: scripts/config/conf
204 @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
205
206allyesconfig: scripts/config/conf
207 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000208 @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER)=.*/# \1 is not set/" .config
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000209 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
210
211allnoconfig: scripts/config/conf
212 @./scripts/config/conf -n $(CONFIG_CONFIG_IN)
213
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000214# defconfig is allyesconfig minus any features that are specialized enough
215# or cause enough behavior change that the user really should switch them on
216# manually if that's what they want. Sort of "maximum sane config".
Rob Landleya167ec52006-01-31 02:42:50 +0000217
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000218defconfig: scripts/config/conf
Rob Landleya167ec52006-01-31 02:42:50 +0000219 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000220 @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER|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
Rob Landleya167ec52006-01-31 02:42:50 +0000221 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
222
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +0000223allbareconfig: scripts/config/conf
224 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000225 @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG|STATIC|SELINUX|DEVFSD|NC_GAPING_SECURITY_HOLE|BUILD_AT_ONCE)).*/# \1 is not set/" .config
226 @$(SED) -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +0000227 @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config
228 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischera9d89132005-10-07 18:45:03 +0000229
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000230ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersen00814662001-04-26 23:29:10 +0000231
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000232# Load all Config.in
Eric Andersen7daa0762004-10-08 07:46:08 +0000233-include $(top_builddir)/.config.cmd
Eric Andersen7daa0762004-10-08 07:46:08 +0000234
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000235endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000236
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000237include $(patsubst %,%/Makefile.in,$(SRC_DIRS))
238
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000239ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
240# Finally pull in the dependencies (headers and other includes) of the
241# individual object files
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000242-include $(top_builddir)/.depend
243
Bernhard Reutner-Fischerc8e278f2006-03-02 18:13:05 +0000244$(top_builddir)/applets/applets.o: $(top_builddir)/.config
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000245# Everything is set.
246
247all: busybox busybox.links doc ;
248
249# Two modes of operation: legacy and IMA
250# Legacy mode builds each object through an individual invocation of CC
251# IMA compiles all sources at once (aka IPO aka IPA etc.)
252
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000253ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000254libraries-y:=
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000255# Which parts of the internal libs are requested?
256# Per default we only want what was actually selected.
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000257# -a denotes all while -y denotes the selected ones.
258ifeq ($(strip $(CONFIG_FEATURE_FULL_LIBBUSYBOX)),y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000259LIBRARY_DEFINE:=$(LIBRARY_DEFINE-a)
260LIBRARY_SRC :=$(LIBRARY_SRC-a)
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000261else # CONFIG_FEATURE_FULL_LIBBUSYBOX
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000262LIBRARY_DEFINE:=$(LIBRARY_DEFINE-y)
263LIBRARY_SRC :=$(LIBRARY_SRC-y)
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000264endif # CONFIG_FEATURE_FULL_LIBBUSYBOX
265APPLET_SRC:=$(APPLET_SRC-y)
266APPLETS_DEFINE:=$(APPLETS_DEFINE-y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000267else # CONFIG_BUILD_AT_ONCE
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000268# no --combine, build archives out of the individual .o
269# This was the old way the binary was built.
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000270libbusybox-obj:=archival/libunarchive/libunarchive.a \
271 networking/libiproute/libiproute.a \
272 libpwdgrp/libpwdgrp.a coreutils/libcoreutils/libcoreutils.a \
273 libbb/libbb.a
274libbusybox-obj:=$(patsubst %,$(top_builddir)/%,$(libbusybox-obj))
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000275ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000276# linking against libbusybox, so don't build the .a already contained in the .so
277libraries-y:=$(filter-out $(libbusybox-obj),$(libraries-y))
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000278endif # CONFIG_FEATURE_SHARED_BUSYBOX
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000279
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000280endif # CONFIG_BUILD_AT_ONCE
281
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000282ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
283LD_LIBBUSYBOX:=libbusybox.so
284LIBBUSYBOX_SONAME:=$(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)
285DO_INSTALL_LIBS:=$(LD_LIBBUSYBOX) \
286 $(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
287 $(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION)
288
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000289endif # CONFIG_BUILD_LIBBUSYBOX
290
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000291ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
292ifneq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000293# --combine but not linking against libbusybox, so compile lib*.c
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000294BUSYBOX_SRC := $(LIBRARY_SRC)
295BUSYBOX_DEFINE:= $(LIBRARY_DEFINE)
296endif # !CONFIG_FEATURE_SHARED_BUSYBOX
297$(LIBBUSYBOX_SONAME): $(LIBRARY_SRC)
298else # CONFIG_BUILD_AT_ONCE
299$(LIBBUSYBOX_SONAME): $(libbusybox-obj)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000300AR_INTRO:=-Wl,--whole-archive
301AR_EXTRO:=-Wl,--no-whole-archive
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000302endif # CONFIG_BUILD_AT_ONCE
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000303
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000304
305ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
306LDBUSYBOX:=-L$(top_builddir) -lbusybox
307endif
308
309ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000310$(LIBBUSYBOX_SONAME):
311ifndef MAJOR_VERSION
312 $(error MAJOR_VERSION needed for $@ is not defined)
313endif
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000314 $(do_link) $(LIB_CFLAGS) $(CFLAGS_COMBINE) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000315 -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
Bernhard Reutner-Fischer08a1b502006-01-27 15:45:56 +0000316 -Wl,-z,combreloc $(LIB_LDFLAGS) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000317 -o $(@) \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000318 -Wl,--start-group \
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000319 $(LIBRARY_DEFINE) $(AR_INTRO) $(^) $(AR_EXTRO) \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000320 -Wl,--end-group
321 @rm -f $(DO_INSTALL_LIBS)
322 @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done
Mike Frysingerb38673f2006-02-02 01:41:53 +0000323 $(do_strip)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000324
325endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
326
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000327busybox_unstripped: $(top_builddir)/.depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(libraries-y)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000328 $(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
329 $(foreach f,$(^:.o=.c),$(CFLAGS-$(notdir $(patsubst %/$,%,$(dir $(f))))-$(notdir $(f)))) \
330 $(CFLAGS-$(@)) \
331 -o $@ -Wl,--start-group \
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000332 $(APPLETS_DEFINE) $(APPLET_SRC) \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000333 $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) \
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000334 $(libraries-y) \
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000335 $(LDBUSYBOX) $(LIBRARIES) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000336 -Wl,--end-group
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000337
338busybox: busybox_unstripped
339 $(Q)cp busybox_unstripped busybox
Mike Frysingerb38673f2006-02-02 01:41:53 +0000340 $(do_strip)
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000341
Rob Landleya930bd32005-12-16 06:12:46 +0000342busybox.links: $(top_srcdir)/applets/busybox.mkll include/bb_config.h $(top_srcdir)/include/applets.h
Mike Frysingerb38673f2006-02-02 01:41:53 +0000343 $(Q)-$(SHELL) $^ >$@
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000344
Eric Andersen63024862004-10-13 17:45:57 +0000345install: $(top_srcdir)/applets/install.sh busybox busybox.links
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000346 $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000347 $(SHELL) $< $(PREFIX) $(INSTALL_OPTS)
Eric Andersen13879102004-08-26 23:13:00 +0000348ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
349 @echo
350 @echo
351 @echo --------------------------------------------------
352 @echo You will probably need to make your busybox binary
353 @echo setuid root to ensure all configured applets will
354 @echo work properly.
355 @echo --------------------------------------------------
356 @echo
357endif
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000358
Glenn L McGrath87470de2003-08-29 12:20:31 +0000359uninstall: busybox.links
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000360 rm -f $(PREFIX)/bin/busybox
361 for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000362ifneq ($(strip $(DO_INSTALL_LIBS)),n)
363 for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000364 rm -f $(PREFIX)$$i; \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000365 done
366endif
Eric Andersen1f30a412002-04-13 13:39:48 +0000367
Mike Frysingerce0cf1d2005-09-24 05:47:52 +0000368check test: busybox
Eric Andersen7daa0762004-10-08 07:46:08 +0000369 bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \
Bernhard Reutner-Fischere34e8782005-10-06 12:48:03 +0000370 $(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE)
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000371
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000372sizes: busybox_unstripped
373 $(NM) --size-sort $(<)
Rob Landley16890752005-09-02 00:41:53 +0000374
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000375# Documentation Targets
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000376doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html ;
John Beppu94e50542001-04-05 19:42:03 +0000377
Mike Frysingerf37529d2006-02-05 22:15:39 +0000378docs/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 +0000379 $(disp_doc)
380 $(Q)-mkdir -p docs
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000381 $(Q)-( cat $(top_srcdir)/docs/busybox_header.pod ; \
382 $(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h ; \
383 cat $(top_srcdir)/docs/busybox_footer.pod ; ) > docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +0000384
Eric Andersen67536ff2000-07-06 22:53:22 +0000385docs/BusyBox.txt: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000386 $(disp_doc)
387 $(Q)-mkdir -p docs
388 $(Q)-pod2text $< > $@
Eric Andersen53310252000-07-04 19:42:23 +0000389
Eric Andersen67536ff2000-07-06 22:53:22 +0000390docs/BusyBox.1: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000391 $(disp_doc)
392 $(Q)-mkdir -p docs
393 $(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
Eric Andersen19f86202001-02-17 00:42:47 +0000394 $< > $@
Eric Andersen53310252000-07-04 19:42:23 +0000395
Eric Andersen2423b122001-12-08 01:56:15 +0000396docs/BusyBox.html: docs/busybox.net/BusyBox.html
Mike Frysingerb38673f2006-02-02 01:41:53 +0000397 $(disp_doc)
398 $(Q)-mkdir -p docs
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000399 $(Q)-rm -f docs/BusyBox.html
Mike Frysingerb38673f2006-02-02 01:41:53 +0000400 $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
Eric Andersen53310252000-07-04 19:42:23 +0000401
Eric Andersen2423b122001-12-08 01:56:15 +0000402docs/busybox.net/BusyBox.html: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000403 $(Q)-mkdir -p docs/busybox.net
404 $(Q)-pod2html --noindex $< > \
Eric Andersen2423b122001-12-08 01:56:15 +0000405 docs/busybox.net/BusyBox.html
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000406 $(Q)-rm -f pod2htm*
Erik Andersen0a704e82000-05-03 03:19:06 +0000407
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000408# The nifty new dependency stuff
"Vladimir N. Oleynik"5e60dc42005-09-12 12:33:27 +0000409scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000410 $(do_link.h)
Erik Andersen1d1d9502000-04-21 01:26:49 +0000411
"Vladimir N. Oleynik"6732af22006-02-15 12:29:37 +0000412DEP_INCLUDES := include/bb_config.h
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000413
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000414ifeq ($(strip $(CONFIG_BBCONFIG)),y)
415DEP_INCLUDES += include/bbconfigopts.h
416
417include/bbconfigopts.h: .config
Mike Frysingerb38673f2006-02-02 01:41:53 +0000418 $(disp_gen)
419 $(Q)$(top_srcdir)/scripts/config/mkconfigs > $@
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000420endif
421
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000422depend dep: $(top_builddir)/.depend ;
423$(top_builddir)/.depend: $(buildtree) scripts/bb_mkdep $(DEP_INCLUDES)
Mike Frysingerb38673f2006-02-02 01:41:53 +0000424 $(disp_gen)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000425 $(Q)rm -f .depend
426 $(Q)scripts/bb_mkdep $(MKDEP_ARGS) \
427 -I $(top_srcdir)/include $(top_srcdir) > $@.tmp
Mike Frysingerb38673f2006-02-02 01:41:53 +0000428 $(Q)mv $@.tmp $@
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000429
"Vladimir N. Oleynik"6732af22006-02-15 12:29:37 +0000430include/bb_config.h: .config
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000431 $(disp_gen)
Eric Andersen7daa0762004-10-08 07:46:08 +0000432 @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersen85208e22002-04-12 12:05:57 +0000433
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000434endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
435
Eric Andersencc8ed391999-10-05 16:24:54 +0000436clean:
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000437 - rm -f docs/busybox.dvi docs/busybox.ps \
Eric Andersenf7300882004-04-06 15:26:25 +0000438 docs/busybox.pod docs/busybox.net/busybox.html \
Eric Andersen24e098a2003-08-22 20:53:38 +0000439 docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
440 docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
"Vladimir N. Oleynik"9394b232006-01-23 11:24:58 +0000441 docs/busybox.net/BusyBox.html busybox.links \
Bernhard Reutner-Fischera5972112006-03-06 14:19:15 +0000442 libbusybox.so* \
Mike Frysinger33b45a02006-03-05 16:25:19 +0000443 .config.old busybox busybox_unstripped
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000444 - rm -r -f _install testsuite/links
Rob Landley31e36102006-03-09 22:01:05 +0000445 - find . -name .\*.flags -o -name \*.o -o -name \*.om \
446 -o -name \*.os -o -name \*.osm -o -name \*.a | xargs rm -f
Eric Andersencc8ed391999-10-05 16:24:54 +0000447
448distclean: clean
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000449 - $(MAKE) -C scripts/config clean
450 - rm -f scripts/bb_mkdep
451 - rm -r -f include/config $(DEP_INCLUDES)
Rob Landley31e36102006-03-09 22:01:05 +0000452 - find . -name .depend'*' | xargs rm -f
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000453 rm -f .config .config.old .config.cmd
Eric Andersencc8ed391999-10-05 16:24:54 +0000454
Eric Andersenc9f20d92002-12-05 08:41:41 +0000455release: distclean #doc
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000456 cd ..; \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000457 rm -r -f $(PROG)-$(VERSION); \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000458 cp -a busybox $(PROG)-$(VERSION); \
459 \
460 find $(PROG)-$(VERSION)/ -type d \
Eric Andersen4306bb12005-08-17 00:03:23 +0000461 -name .svn \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000462 -print \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000463 -exec rm -r -f {} \; ; \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000464 \
465 find $(PROG)-$(VERSION)/ -type f \
466 -name .\#* \
467 -print \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000468 -exec rm -f {} \; ; \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000469 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000470 tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000471
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000472tags:
473 ctags -R .
Matt Kraai4e05da82001-11-19 19:47:56 +0000474
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000475# keep these in sync with noconfig_targets above!
476.PHONY: dummy subdirs check test depend dep buildtree \
477 menuconfig config oldconfig randconfig \
478 defconfig allyesconfig allnoconfig allbareconfig \
479 clean distclean \
480 release tags
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000481