blob: 7fcdd45e56b85227b23d36a127bd8c5486588aca [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
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000165all: defconfig 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
194 @./scripts/config/mconf $(CONFIG_CONFIG_IN)
195
196config: scripts/config/conf
197 @./scripts/config/conf $(CONFIG_CONFIG_IN)
198
199oldconfig: scripts/config/conf
200 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
201
202randconfig: scripts/config/conf
203 @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
204
205allyesconfig: scripts/config/conf
206 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000207 @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER)=.*/# \1 is not set/" .config
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000208 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
209
210allnoconfig: scripts/config/conf
211 @./scripts/config/conf -n $(CONFIG_CONFIG_IN)
212
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000213# defconfig is allyesconfig minus any features that are specialized enough
214# or cause enough behavior change that the user really should switch them on
215# manually if that's what they want. Sort of "maximum sane config".
Rob Landleya167ec52006-01-31 02:42:50 +0000216
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000217defconfig: scripts/config/conf
Rob Landleya167ec52006-01-31 02:42:50 +0000218 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000219 @$(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 +0000220 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
221
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +0000222allbareconfig: scripts/config/conf
223 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000224 @$(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
225 @$(SED) -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +0000226 @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config
227 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischera9d89132005-10-07 18:45:03 +0000228
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000229ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersen00814662001-04-26 23:29:10 +0000230
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000231# Load all Config.in
Eric Andersen7daa0762004-10-08 07:46:08 +0000232-include $(top_builddir)/.config.cmd
Eric Andersen7daa0762004-10-08 07:46:08 +0000233
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000234endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000235
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000236include $(patsubst %,%/Makefile.in,$(SRC_DIRS))
237
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000238ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
239# Finally pull in the dependencies (headers and other includes) of the
240# individual object files
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000241-include $(top_builddir)/.depend
242
Bernhard Reutner-Fischerc8e278f2006-03-02 18:13:05 +0000243$(top_builddir)/applets/applets.o: $(top_builddir)/.config
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000244# Everything is set.
245
246all: busybox busybox.links doc ;
247
248# Two modes of operation: legacy and IMA
249# Legacy mode builds each object through an individual invocation of CC
250# IMA compiles all sources at once (aka IPO aka IPA etc.)
251
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000252ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000253libraries-y:=
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000254# Which parts of the internal libs are requested?
255# Per default we only want what was actually selected.
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000256# -a denotes all while -y denotes the selected ones.
257ifeq ($(strip $(CONFIG_FEATURE_FULL_LIBBUSYBOX)),y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000258LIBRARY_DEFINE:=$(LIBRARY_DEFINE-a)
259LIBRARY_SRC :=$(LIBRARY_SRC-a)
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000260else # CONFIG_FEATURE_FULL_LIBBUSYBOX
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000261LIBRARY_DEFINE:=$(LIBRARY_DEFINE-y)
262LIBRARY_SRC :=$(LIBRARY_SRC-y)
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000263endif # CONFIG_FEATURE_FULL_LIBBUSYBOX
264APPLET_SRC:=$(APPLET_SRC-y)
265APPLETS_DEFINE:=$(APPLETS_DEFINE-y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000266else # CONFIG_BUILD_AT_ONCE
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000267# no --combine, build archives out of the individual .o
268# This was the old way the binary was built.
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000269libbusybox-obj:=archival/libunarchive/libunarchive.a \
270 networking/libiproute/libiproute.a \
271 libpwdgrp/libpwdgrp.a coreutils/libcoreutils/libcoreutils.a \
272 libbb/libbb.a
273libbusybox-obj:=$(patsubst %,$(top_builddir)/%,$(libbusybox-obj))
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000274ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000275# linking against libbusybox, so don't build the .a already contained in the .so
276libraries-y:=$(filter-out $(libbusybox-obj),$(libraries-y))
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000277endif # CONFIG_FEATURE_SHARED_BUSYBOX
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000278
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000279endif # CONFIG_BUILD_AT_ONCE
280
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000281ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
282LD_LIBBUSYBOX:=libbusybox.so
283LIBBUSYBOX_SONAME:=$(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)
284DO_INSTALL_LIBS:=$(LD_LIBBUSYBOX) \
285 $(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
286 $(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION)
287
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000288endif # CONFIG_BUILD_LIBBUSYBOX
289
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000290ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
291ifneq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000292# --combine but not linking against libbusybox, so compile lib*.c
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000293BUSYBOX_SRC := $(LIBRARY_SRC)
294BUSYBOX_DEFINE:= $(LIBRARY_DEFINE)
295endif # !CONFIG_FEATURE_SHARED_BUSYBOX
296$(LIBBUSYBOX_SONAME): $(LIBRARY_SRC)
297else # CONFIG_BUILD_AT_ONCE
298$(LIBBUSYBOX_SONAME): $(libbusybox-obj)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000299AR_INTRO:=-Wl,--whole-archive
300AR_EXTRO:=-Wl,--no-whole-archive
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000301endif # CONFIG_BUILD_AT_ONCE
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000302
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000303
304ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
305LDBUSYBOX:=-L$(top_builddir) -lbusybox
306endif
307
308ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000309$(LIBBUSYBOX_SONAME):
310ifndef MAJOR_VERSION
311 $(error MAJOR_VERSION needed for $@ is not defined)
312endif
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000313 $(do_link) $(LIB_CFLAGS) $(CFLAGS_COMBINE) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000314 -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
Bernhard Reutner-Fischer08a1b502006-01-27 15:45:56 +0000315 -Wl,-z,combreloc $(LIB_LDFLAGS) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000316 -o $(@) \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000317 -Wl,--start-group \
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000318 $(LIBRARY_DEFINE) $(AR_INTRO) $(^) $(AR_EXTRO) \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000319 -Wl,--end-group
320 @rm -f $(DO_INSTALL_LIBS)
321 @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done
Mike Frysingerb38673f2006-02-02 01:41:53 +0000322 $(do_strip)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000323
324endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
325
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000326busybox_unstripped: $(top_builddir)/.depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(libraries-y)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000327 $(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
328 $(foreach f,$(^:.o=.c),$(CFLAGS-$(notdir $(patsubst %/$,%,$(dir $(f))))-$(notdir $(f)))) \
329 $(CFLAGS-$(@)) \
330 -o $@ -Wl,--start-group \
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000331 $(APPLETS_DEFINE) $(APPLET_SRC) \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000332 $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) \
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000333 $(libraries-y) \
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000334 $(LDBUSYBOX) $(LIBRARIES) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000335 -Wl,--end-group
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
Rob Landleya930bd32005-12-16 06:12:46 +0000341busybox.links: $(top_srcdir)/applets/busybox.mkll include/bb_config.h $(top_srcdir)/include/applets.h
Mike Frysingerb38673f2006-02-02 01:41:53 +0000342 $(Q)-$(SHELL) $^ >$@
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000343
Eric Andersen63024862004-10-13 17:45:57 +0000344install: $(top_srcdir)/applets/install.sh busybox busybox.links
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000345 $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000346 $(SHELL) $< $(PREFIX) $(INSTALL_OPTS)
Eric Andersen13879102004-08-26 23:13:00 +0000347ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
348 @echo
349 @echo
350 @echo --------------------------------------------------
351 @echo You will probably need to make your busybox binary
352 @echo setuid root to ensure all configured applets will
353 @echo work properly.
354 @echo --------------------------------------------------
355 @echo
356endif
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000357
Glenn L McGrath87470de2003-08-29 12:20:31 +0000358uninstall: busybox.links
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000359 rm -f $(PREFIX)/bin/busybox
360 for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000361ifneq ($(strip $(DO_INSTALL_LIBS)),n)
362 for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000363 rm -f $(PREFIX)$$i; \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000364 done
365endif
Eric Andersen1f30a412002-04-13 13:39:48 +0000366
Mike Frysingerce0cf1d2005-09-24 05:47:52 +0000367check test: busybox
Eric Andersen7daa0762004-10-08 07:46:08 +0000368 bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \
Bernhard Reutner-Fischere34e8782005-10-06 12:48:03 +0000369 $(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE)
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000370
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000371sizes: busybox_unstripped
372 $(NM) --size-sort $(<)
Rob Landley16890752005-09-02 00:41:53 +0000373
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000374# Documentation Targets
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000375doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html ;
John Beppu94e50542001-04-05 19:42:03 +0000376
Mike Frysingerf37529d2006-02-05 22:15:39 +0000377docs/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 +0000378 $(disp_doc)
379 $(Q)-mkdir -p docs
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000380 $(Q)-( cat $(top_srcdir)/docs/busybox_header.pod ; \
381 $(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h ; \
382 cat $(top_srcdir)/docs/busybox_footer.pod ; ) > docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +0000383
Eric Andersen67536ff2000-07-06 22:53:22 +0000384docs/BusyBox.txt: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000385 $(disp_doc)
386 $(Q)-mkdir -p docs
387 $(Q)-pod2text $< > $@
Eric Andersen53310252000-07-04 19:42:23 +0000388
Eric Andersen67536ff2000-07-06 22:53:22 +0000389docs/BusyBox.1: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000390 $(disp_doc)
391 $(Q)-mkdir -p docs
392 $(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
Eric Andersen19f86202001-02-17 00:42:47 +0000393 $< > $@
Eric Andersen53310252000-07-04 19:42:23 +0000394
Eric Andersen2423b122001-12-08 01:56:15 +0000395docs/BusyBox.html: docs/busybox.net/BusyBox.html
Mike Frysingerb38673f2006-02-02 01:41:53 +0000396 $(disp_doc)
397 $(Q)-mkdir -p docs
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000398 $(Q)-rm -f docs/BusyBox.html
Mike Frysingerb38673f2006-02-02 01:41:53 +0000399 $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
Eric Andersen53310252000-07-04 19:42:23 +0000400
Eric Andersen2423b122001-12-08 01:56:15 +0000401docs/busybox.net/BusyBox.html: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000402 $(Q)-mkdir -p docs/busybox.net
403 $(Q)-pod2html --noindex $< > \
Eric Andersen2423b122001-12-08 01:56:15 +0000404 docs/busybox.net/BusyBox.html
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000405 $(Q)-rm -f pod2htm*
Erik Andersen0a704e82000-05-03 03:19:06 +0000406
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000407# The nifty new dependency stuff
"Vladimir N. Oleynik"5e60dc42005-09-12 12:33:27 +0000408scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000409 $(do_link.h)
Erik Andersen1d1d9502000-04-21 01:26:49 +0000410
"Vladimir N. Oleynik"6732af22006-02-15 12:29:37 +0000411DEP_INCLUDES := include/bb_config.h
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000412
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000413ifeq ($(strip $(CONFIG_BBCONFIG)),y)
414DEP_INCLUDES += include/bbconfigopts.h
415
416include/bbconfigopts.h: .config
Mike Frysingerb38673f2006-02-02 01:41:53 +0000417 $(disp_gen)
418 $(Q)$(top_srcdir)/scripts/config/mkconfigs > $@
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000419endif
420
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000421depend dep: $(top_builddir)/.depend ;
422$(top_builddir)/.depend: $(buildtree) scripts/bb_mkdep $(DEP_INCLUDES)
Mike Frysingerb38673f2006-02-02 01:41:53 +0000423 $(disp_gen)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000424 $(Q)rm -f .depend
425 $(Q)scripts/bb_mkdep $(MKDEP_ARGS) \
426 -I $(top_srcdir)/include $(top_srcdir) > $@.tmp
Mike Frysingerb38673f2006-02-02 01:41:53 +0000427 $(Q)mv $@.tmp $@
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000428
"Vladimir N. Oleynik"6732af22006-02-15 12:29:37 +0000429include/bb_config.h: .config
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000430 $(disp_gen)
Eric Andersen7daa0762004-10-08 07:46:08 +0000431 @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersen85208e22002-04-12 12:05:57 +0000432
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000433endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
434
Eric Andersencc8ed391999-10-05 16:24:54 +0000435clean:
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000436 - rm -f docs/busybox.dvi docs/busybox.ps \
Eric Andersenf7300882004-04-06 15:26:25 +0000437 docs/busybox.pod docs/busybox.net/busybox.html \
Eric Andersen24e098a2003-08-22 20:53:38 +0000438 docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
439 docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
"Vladimir N. Oleynik"9394b232006-01-23 11:24:58 +0000440 docs/busybox.net/BusyBox.html busybox.links \
Bernhard Reutner-Fischera5972112006-03-06 14:19:15 +0000441 libbusybox.so* \
Mike Frysinger33b45a02006-03-05 16:25:19 +0000442 .config.old busybox busybox_unstripped
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000443 - rm -r -f _install testsuite/links
444 - find . -name .\*.flags -exec rm -f {} \;
445 - find . -name \*.o -exec rm -f {} \;
446 - find . -name \*.om -exec rm -f {} \;
447 - find . -name \*.os -exec rm -f {} \;
Mike Frysinger56ee7792006-03-05 18:04:23 +0000448 - find . -name \*.osm -exec rm -f {} \;
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000449 - find . -name \*.a -exec rm -f {} \;
Eric Andersencc8ed391999-10-05 16:24:54 +0000450
451distclean: clean
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000452 - $(MAKE) -C scripts/config clean
453 - rm -f scripts/bb_mkdep
454 - rm -r -f include/config $(DEP_INCLUDES)
455 - find . -name .depend'*' -exec rm -f {} \;
456 rm -f .config .config.old .config.cmd
Eric Andersencc8ed391999-10-05 16:24:54 +0000457
Eric Andersenc9f20d92002-12-05 08:41:41 +0000458release: distclean #doc
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000459 cd ..; \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000460 rm -r -f $(PROG)-$(VERSION); \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000461 cp -a busybox $(PROG)-$(VERSION); \
462 \
463 find $(PROG)-$(VERSION)/ -type d \
Eric Andersen4306bb12005-08-17 00:03:23 +0000464 -name .svn \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000465 -print \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000466 -exec rm -r -f {} \; ; \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000467 \
468 find $(PROG)-$(VERSION)/ -type f \
469 -name .\#* \
470 -print \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000471 -exec rm -f {} \; ; \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000472 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000473 tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000474
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000475tags:
476 ctags -R .
Matt Kraai4e05da82001-11-19 19:47:56 +0000477
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000478# keep these in sync with noconfig_targets above!
479.PHONY: dummy subdirs check test depend dep buildtree \
480 menuconfig config oldconfig randconfig \
481 defconfig allyesconfig allnoconfig allbareconfig \
482 clean distclean \
483 release tags
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000484