blob: d9d0b7c6c509b9cd9e5ff0ec6ab9f83533468bb5 [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 \
Eric Andersenbcf27242005-02-13 22:15:59 +000013 release tags
Eric Andersen7daa0762004-10-08 07:46:08 +000014
Bernhard Reutner-Fischer1c943eb2005-09-26 16:01:43 +000015# the toplevel sourcedir
Eric Andersen7daa0762004-10-08 07:46:08 +000016ifndef top_srcdir
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000017top_srcdir:=$(shell cd $(dir $(firstword $(MAKEFILE_LIST))) && pwd)
Eric Andersen7daa0762004-10-08 07:46:08 +000018endif
Bernhard Reutner-Fischer1c943eb2005-09-26 16:01:43 +000019# toplevel directory of the object-tree
Eric Andersen7daa0762004-10-08 07:46:08 +000020ifndef top_builddir
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000021top_builddir:=$(CURDIR)
Eric Andersen7daa0762004-10-08 07:46:08 +000022endif
23
Mike Frysinger9d6e0832005-07-31 22:50:17 +000024export srctree=$(top_srcdir)
Eric Andersen7daa0762004-10-08 07:46:08 +000025vpath %/Config.in $(srctree)
26
Glenn L McGrath3238ea12003-02-15 10:53:40 +000027DIRS:=applets archival archival/libunarchive coreutils console-tools \
28 debianutils editors findutils init miscutils modutils networking \
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000029 networking/libiproute networking/udhcp procps loginutils shell \
Mike Frysingerd89e6292005-04-24 05:07:59 +000030 sysklogd util-linux e2fsprogs libpwdgrp coreutils/libcoreutils libbb
Eric Andersenab050f52001-01-27 06:01:43 +000031
Eric Andersen7daa0762004-10-08 07:46:08 +000032SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
33
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000034# That's our default target when none is given on the command line
35.PHONY: _all
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000036
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000037_all: all
Eric Andersen7daa0762004-10-08 07:46:08 +000038
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000039# see if we are in verbose mode
40ifdef VERBOSE
41 CHECK_VERBOSE := -v
42 PACKAGE_BE_VERBOSE := $(VERBOSE)
43endif
44ifdef V
45 CHECK_VERBOSE := -v
46 PACKAGE_BE_VERBOSE := $(V)
47endif
Eric Andersen7daa0762004-10-08 07:46:08 +000048
49ifdef O
50 ifeq ("$(origin O)", "command line")
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000051 PACKAGE_OUTPUTDIR := $(shell cd $(O) && pwd)
52 top_builddir := $(PACKAGE_OUTPUTDIR)
Eric Andersen7daa0762004-10-08 07:46:08 +000053 endif
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000054else
55# If no alternate output-dir was specified, we build in cwd
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000056 PACKAGE_OUTPUTDIR := $(top_builddir)
Eric Andersen7daa0762004-10-08 07:46:08 +000057endif
58
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000059#######################################################################
60# Try to workaround bugs in make
61
62# Workaround for bugs in make-3.80
63# eval is broken if it is in a conditional
64
65#$ cat 3.80-eval-in-cond.mak
66#all:: ; @echo it
67#define Y
68# all:: ; @echo worked
69#endef
70#ifdef BAR
71#$(eval $(Y))
72#endif
73#$ make -f 3.80-eval-in-cond.mak
74#it
75#$ make -f 3.80-eval-in-cond.mak BAR=set
76#3.80-eval-in-cond.mak:5: *** missing `endif'. Stop.
77
78# This was fixed in December 2003.
79define check_gcc
80$(eval $(1)+=$(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))))
81endef
82
83define check_ld
84$(eval $(1)+=$(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))))
85endef
86
87#######################################################################
88
89
Bernhard Reutner-Fischer8c7a7e62005-10-13 10:40:18 +000090-include $(top_srcdir)/Rules.mak
Bernhard Reutner-Fischer8c7a7e62005-10-13 10:40:18 +000091
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000092# Handle building out of tree
93ifneq ($(top_builddir),$(top_srcdir))
94all_tree := $(patsubst %,$(top_builddir)/%,$(DIRS) scripts scripts/config include include/config)
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +000095$(all_tree):
96 @mkdir -p "$@"
97
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000098saved-output := $(PACKAGE_OUTPUTDIR)
99
100$(if $(wildcard $(PACKAGE_OUTPUTDIR)),, \
Eric Andersen7daa0762004-10-08 07:46:08 +0000101 $(error output directory "$(saved-output)" does not exist))
102
103.PHONY: $(MAKECMDGOALS)
104
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000105$(PACKAGE_OUTPUTDIR)/Rules.mak:
Eric Andersen7daa0762004-10-08 07:46:08 +0000106 @echo > $@
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000107 @echo top_srcdir=$(top_srcdir) >> $@
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000108 @echo top_builddir=$(PACKAGE_OUTPUTDIR) >> $@
109 @echo include $$\(top_srcdir\)/Rules.mak >> $@
Eric Andersen7daa0762004-10-08 07:46:08 +0000110
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000111$(PACKAGE_OUTPUTDIR)/Makefile:
Eric Andersen7daa0762004-10-08 07:46:08 +0000112 @echo > $@
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000113 @echo top_srcdir=$(top_srcdir) >> $@
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000114 @echo top_builddir=$(PACKAGE_OUTPUTDIR) >> $@
115 @echo PACKAGE_SOURCEDIR='$$(top_srcdir)' >> $@
116 @echo include '$$(PACKAGE_SOURCEDIR)'/Makefile >> $@
Eric Andersen7daa0762004-10-08 07:46:08 +0000117
Eric Andersen7daa0762004-10-08 07:46:08 +0000118
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000119buildtree := $(all_tree) $(PACKAGE_OUTPUTDIR)/Rules.mak $(PACKAGE_OUTPUTDIR)/Makefile
Eric Andersen7daa0762004-10-08 07:46:08 +0000120
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000121# We only need a copy of the Makefile for the config targets and reuse
122# the rest from the source directory, i.e. we do not cp ALL_MAKEFILES.
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000123scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile | $(buildtree)
124 @cp $(top_srcdir)/scripts/config/Makefile $@
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000125
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000126else
127all_tree := include/config
128$(all_tree):
129 @mkdir -p "$@"
130buildtree := $(all_tree)
131endif # ifneq ($(PACKAGE_OUTPUTDIR),$(top_srcdir))
Glenn L McGrath6376b582003-09-24 15:48:29 +0000132
Rob Landleyd24eaac2005-09-26 15:49:41 +0000133help:
134 @echo 'Cleaning:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000135 @echo ' clean - delete temporary files created by build'
136 @echo ' distclean - delete all non-source files (including .config)'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000137 @echo
138 @echo 'Build:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000139 @echo ' all - Executable and documentation'
140 @echo ' busybox - the swiss-army executable'
141 @echo ' doc - docs/BusyBox.{txt,html,1}'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000142 @echo
143 @echo 'Configuration:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000144 @echo ' allnoconfig - disable all symbols in .config'
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000145 @echo ' allyesconfig - enable all symbols in .config (see defconfig)'
146 @echo ' allbareconfig - enable all applets without any sub-features'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000147 @echo ' config - text based configurator (of last resort)'
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000148 @echo ' defconfig - set .config to largest generic configuration'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000149 @echo ' menuconfig - interactive curses-based configurator'
150 @echo ' oldconfig - resolve any unresolved symbols in .config'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000151 @echo
152 @echo 'Installation:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000153 @echo ' install - install busybox into $prefix'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000154 @echo ' uninstall'
155 @echo
156 @echo 'Development:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000157 @echo ' check - run the test suite for all applets'
158 @echo ' randconfig - generate a random configuration'
159 @echo ' release - create a distribution tarball'
160 @echo ' sizes - show size of all enabled busybox symbols'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000161 @echo
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000162 @echo 'Make flags:'
163 @echo ' V=<number> - print verbose make output (default: unset)'
164 @echo ' 0 print CC invocations'
165 @echo ' 1'
166 @echo ' 2 also print when make enters a directory'
167 @echo ' 3 also verbosely print shell invocations'
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000168
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000169ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000170# Default target if none was requested explicitly
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000171all: defconfig menuconfig ;
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000172
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000173ifneq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000174# warn if no configuration exists and we are asked to build a non-config target
175.config:
176 @echo ""
177 @echo "No $(top_builddir)/$@ found!"
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000178 @echo "Please refer to 'make help', section Configuration."
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000179 @echo ""
180 @exit 1
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000181else
182# Avoid implicit rule to kick in by using an empty command
183.config: $(buildtree) ;
184endif
185endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
186
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000187
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000188# configuration
189# ---------------------------------------------------------------------------
190
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000191CONFIG_CONFIG_IN = $(top_srcdir)/Config.in
192
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000193scripts/config/conf: scripts/config/Makefile
Mike Frysingerb38673f2006-02-02 01:41:53 +0000194 $(Q)$(MAKE) -C scripts/config conf
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000195
196scripts/config/mconf: scripts/config/Makefile
Mike Frysingerb38673f2006-02-02 01:41:53 +0000197 $(Q)$(MAKE) -C scripts/config ncurses conf mconf
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000198
199menuconfig: scripts/config/mconf
200 @./scripts/config/mconf $(CONFIG_CONFIG_IN)
201
202config: scripts/config/conf
203 @./scripts/config/conf $(CONFIG_CONFIG_IN)
204
205oldconfig: scripts/config/conf
206 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
207
208randconfig: scripts/config/conf
209 @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
210
211allyesconfig: scripts/config/conf
212 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000213 @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER)=.*/# \1 is not set/" .config
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000214 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
215
216allnoconfig: scripts/config/conf
217 @./scripts/config/conf -n $(CONFIG_CONFIG_IN)
218
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000219# defconfig is allyesconfig minus any features that are specialized enough
220# or cause enough behavior change that the user really should switch them on
221# manually if that's what they want. Sort of "maximum sane config".
Rob Landleya167ec52006-01-31 02:42:50 +0000222
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000223defconfig: scripts/config/conf
Rob Landleya167ec52006-01-31 02:42:50 +0000224 @./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|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 +0000226 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
227
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +0000228allbareconfig: scripts/config/conf
229 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000230 @$(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
231 @$(SED) -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +0000232 @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config
233 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischera9d89132005-10-07 18:45:03 +0000234
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000235ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersen00814662001-04-26 23:29:10 +0000236
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000237# Load all Config.in
Eric Andersen7daa0762004-10-08 07:46:08 +0000238-include $(top_builddir)/.config.cmd
Eric Andersen7daa0762004-10-08 07:46:08 +0000239
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000240endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000241
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000242# convert $(DIRS) to upper case. Use sed instead of tr since we're already
243# depending on it.
244DIRS_UPPER:=$(shell echo $(DIRS) | $(SED) 'h;y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/')
245
246# First populate the variables ..._OBJ-y ...OBJ-m et al
247$(foreach d,$(DIRS_UPPER),$(eval $(notdir $(d))-y:=))
248$(foreach d,$(DIRS_UPPER),$(eval $(notdir $(d))-m:=))
249
250include $(patsubst %,%/Makefile.in,$(SRC_DIRS))
251
252# Then we need the dependencies for ..._OBJ
253define dir_pattern.o
254ifeq ($(os),.os)
255# write patterns for both .os and .o
256$(if $($(1)_OBJ.os),$($(1)_OBJ.os:.os=.o): $(top_builddir)/$(2)/%.o: $(top_srcdir)/$(2)/%.c)
257endif
258$(if $($(1)_OBJ$(os)),$($(1)_OBJ$(os)): $(top_builddir)/$(2)/%$(os): $(top_srcdir)/$(2)/%.c)
259$(if $($(1)_OBJ),$($(1)_OBJ): $(top_builddir)/$(2)/%.o: $(top_srcdir)/$(2)/%.c)
260
261lib-obj-y+=$($(1)_OBJ) $($(1)_OBJ.o) $($(1)_OBJ.os)
262lib-mobj-y+=$($(1)_MOBJ.o) $($(1)_MOBJ.os)
263bin-obj-y+=$($(1)_OBJ:.os=.o) $($(1)_OBJ.o:.os=.o) $($(1)_OBJ.os:.os=.o)
264bin-mobj-y+=$($(1)_MOBJ.o:.osm=.om) $($(1)_MOBJ.os:.osm=.om)
265endef
266# The actual directory patterns for .o*
267$(foreach d,$(DIRS),$(eval $(call dir_pattern.o,$(subst /,_,$(d)),$(d))))
268
269ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
270# Finally pull in the dependencies (headers and other includes) of the
271# individual object files
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000272-include $(top_builddir)/.depend
273
274
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000275# Everything is set.
276
277all: busybox busybox.links doc ;
278
279# Two modes of operation: legacy and IMA
280# Legacy mode builds each object through an individual invocation of CC
281# IMA compiles all sources at once (aka IPO aka IPA etc.)
282
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000283ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000284# We are not building .o
285bin-obj-y:=
286bin-mobj-y:=
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000287# Which parts of the internal libs are requested?
288# Per default we only want what was actually selected.
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000289# -a denotes all while -y denotes the selected ones.
290ifeq ($(strip $(CONFIG_FEATURE_FULL_LIBBUSYBOX)),y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000291LIBRARY_DEFINE:=$(LIBRARY_DEFINE-a)
292LIBRARY_SRC :=$(LIBRARY_SRC-a)
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000293else # CONFIG_FEATURE_FULL_LIBBUSYBOX
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000294LIBRARY_DEFINE:=$(LIBRARY_DEFINE-y)
295LIBRARY_SRC :=$(LIBRARY_SRC-y)
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000296endif # CONFIG_FEATURE_FULL_LIBBUSYBOX
297APPLET_SRC:=$(APPLET_SRC-y)
298APPLETS_DEFINE:=$(APPLETS_DEFINE-y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000299else # CONFIG_BUILD_AT_ONCE
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000300# no --combine, build archives out of the individual .o
301# This was the old way the binary was built.
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000302libbusybox-obj:=$(archival_libunarchive_OBJ$(os)) \
303 $(networking_libiproute_OBJ$(os)) \
304 $(libpwdgrp_MOBJ$(os)) \
305 $(coreutils_libcoreutils_OBJ$(os)) \
306 $(libbb_OBJ$(os)) $(libbb_MOBJ$(os))
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000307
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000308ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000309# linking against libbusybox, so don't build the .o already contained in the .so
310bin-obj-y:=$(filter-out $(libbusybox-obj) $(libbusybox-obj:.os=.o),$(bin-obj-y))
311bin-mobj-y:=$(filter-out $(libbusybox-obj) $(libbusybox-obj:.osm=.om),$(bin-mobj-y))
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000312endif # CONFIG_FEATURE_SHARED_BUSYBOX
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000313endif # CONFIG_BUILD_AT_ONCE
314
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000315# build an .a to keep .hash et al small
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000316ifneq ($(bin-obj-y)$(bin-mobj-y),)
317 applets.a:=$(bin-obj-y) $(bin-mobj-y)
318endif
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000319ifdef applets.a
320applets.a: $(applets.a)
321 $(do_ar)
322bin-obj.a=applets.a
323endif
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000324
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000325ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
326LD_LIBBUSYBOX:=libbusybox.so
327LIBBUSYBOX_SONAME:=$(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)
328DO_INSTALL_LIBS:=$(LD_LIBBUSYBOX) \
329 $(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
330 $(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION)
331
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000332endif # CONFIG_BUILD_LIBBUSYBOX
333
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000334ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
335ifneq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000336# --combine but not linking against libbusybox, so compile lib*.c
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000337BUSYBOX_SRC := $(LIBRARY_SRC)
338BUSYBOX_DEFINE:= $(LIBRARY_DEFINE)
339endif # !CONFIG_FEATURE_SHARED_BUSYBOX
340$(LIBBUSYBOX_SONAME): $(LIBRARY_SRC)
341else # CONFIG_BUILD_AT_ONCE
342$(LIBBUSYBOX_SONAME): $(libbusybox-obj)
343endif # CONFIG_BUILD_AT_ONCE
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000344
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000345
346ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
347LDBUSYBOX:=-L$(top_builddir) -lbusybox
348endif
349
350ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000351$(LIBBUSYBOX_SONAME):
352ifndef MAJOR_VERSION
353 $(error MAJOR_VERSION needed for $@ is not defined)
354endif
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000355 $(do_link) $(LIB_CFLAGS) $(LIB_LDFLAGS) $(CFLAGS_COMBINE) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000356 -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
Bernhard Reutner-Fischer08a1b502006-01-27 15:45:56 +0000357 -Wl,-z,combreloc $(LIB_LDFLAGS) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000358 -o $(@) \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000359 -Wl,--start-group \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000360 $(LIBRARY_DEFINE) $(^) \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000361 -Wl,--end-group
362 @rm -f $(DO_INSTALL_LIBS)
363 @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done
Mike Frysingerb38673f2006-02-02 01:41:53 +0000364 $(do_strip)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000365
366endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
367
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000368busybox_unstripped: $(top_builddir)/.depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(bin-obj.a)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000369 $(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
370 $(foreach f,$(^:.o=.c),$(CFLAGS-$(notdir $(patsubst %/$,%,$(dir $(f))))-$(notdir $(f)))) \
371 $(CFLAGS-$(@)) \
372 -o $@ -Wl,--start-group \
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000373 $(APPLETS_DEFINE) $(APPLET_SRC) \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000374 $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) \
375 $(bin-obj.a) \
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000376 $(LDBUSYBOX) $(LIBRARIES) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000377 -Wl,--end-group
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000378
379busybox: busybox_unstripped
380 $(Q)cp busybox_unstripped busybox
Mike Frysingerb38673f2006-02-02 01:41:53 +0000381 $(do_strip)
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000382
Rob Landleya930bd32005-12-16 06:12:46 +0000383busybox.links: $(top_srcdir)/applets/busybox.mkll include/bb_config.h $(top_srcdir)/include/applets.h
Mike Frysingerb38673f2006-02-02 01:41:53 +0000384 $(Q)-$(SHELL) $^ >$@
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000385
Eric Andersen63024862004-10-13 17:45:57 +0000386install: $(top_srcdir)/applets/install.sh busybox busybox.links
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000387 $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000388 $(SHELL) $< $(PREFIX) $(INSTALL_OPTS)
Eric Andersen13879102004-08-26 23:13:00 +0000389ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
390 @echo
391 @echo
392 @echo --------------------------------------------------
393 @echo You will probably need to make your busybox binary
394 @echo setuid root to ensure all configured applets will
395 @echo work properly.
396 @echo --------------------------------------------------
397 @echo
398endif
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000399
Glenn L McGrath87470de2003-08-29 12:20:31 +0000400uninstall: busybox.links
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000401 rm -f $(PREFIX)/bin/busybox
402 for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000403ifneq ($(strip $(DO_INSTALL_LIBS)),n)
404 for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000405 rm -f $(PREFIX)$$i; \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000406 done
407endif
Eric Andersen1f30a412002-04-13 13:39:48 +0000408
Mike Frysingerce0cf1d2005-09-24 05:47:52 +0000409check test: busybox
Eric Andersen7daa0762004-10-08 07:46:08 +0000410 bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \
Bernhard Reutner-Fischere34e8782005-10-06 12:48:03 +0000411 $(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE)
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000412
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000413sizes: busybox_unstripped
414 $(NM) --size-sort $(<)
Rob Landley16890752005-09-02 00:41:53 +0000415
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000416# Documentation Targets
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000417doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html ;
John Beppu94e50542001-04-05 19:42:03 +0000418
Mike Frysingerf37529d2006-02-05 22:15:39 +0000419docs/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 +0000420 $(disp_doc)
421 $(Q)-mkdir -p docs
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000422 $(Q)-( cat $(top_srcdir)/docs/busybox_header.pod ; \
423 $(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h ; \
424 cat $(top_srcdir)/docs/busybox_footer.pod ; ) > docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +0000425
Eric Andersen67536ff2000-07-06 22:53:22 +0000426docs/BusyBox.txt: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000427 $(disp_doc)
428 $(Q)-mkdir -p docs
429 $(Q)-pod2text $< > $@
Eric Andersen53310252000-07-04 19:42:23 +0000430
Eric Andersen67536ff2000-07-06 22:53:22 +0000431docs/BusyBox.1: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000432 $(disp_doc)
433 $(Q)-mkdir -p docs
434 $(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
Eric Andersen19f86202001-02-17 00:42:47 +0000435 $< > $@
Eric Andersen53310252000-07-04 19:42:23 +0000436
Eric Andersen2423b122001-12-08 01:56:15 +0000437docs/BusyBox.html: docs/busybox.net/BusyBox.html
Mike Frysingerb38673f2006-02-02 01:41:53 +0000438 $(disp_doc)
439 $(Q)-mkdir -p docs
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000440 $(Q)-rm -f docs/BusyBox.html
Mike Frysingerb38673f2006-02-02 01:41:53 +0000441 $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
Eric Andersen53310252000-07-04 19:42:23 +0000442
Eric Andersen2423b122001-12-08 01:56:15 +0000443docs/busybox.net/BusyBox.html: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000444 $(Q)-mkdir -p docs/busybox.net
445 $(Q)-pod2html --noindex $< > \
Eric Andersen2423b122001-12-08 01:56:15 +0000446 docs/busybox.net/BusyBox.html
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000447 $(Q)-rm -f pod2htm*
Erik Andersen0a704e82000-05-03 03:19:06 +0000448
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000449# The nifty new dependency stuff
"Vladimir N. Oleynik"5e60dc42005-09-12 12:33:27 +0000450scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000451 $(do_link.h)
Erik Andersen1d1d9502000-04-21 01:26:49 +0000452
"Vladimir N. Oleynik"6732af22006-02-15 12:29:37 +0000453DEP_INCLUDES := include/bb_config.h
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000454
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000455ifeq ($(strip $(CONFIG_BBCONFIG)),y)
456DEP_INCLUDES += include/bbconfigopts.h
457
458include/bbconfigopts.h: .config
Mike Frysingerb38673f2006-02-02 01:41:53 +0000459 $(disp_gen)
460 $(Q)$(top_srcdir)/scripts/config/mkconfigs > $@
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000461endif
462
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000463depend dep: $(top_builddir)/.depend ;
464$(top_builddir)/.depend: $(buildtree) scripts/bb_mkdep $(DEP_INCLUDES)
Mike Frysingerb38673f2006-02-02 01:41:53 +0000465 $(disp_gen)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000466 $(Q)rm -f .depend
467 $(Q)scripts/bb_mkdep $(MKDEP_ARGS) \
468 -I $(top_srcdir)/include $(top_srcdir) > $@.tmp
Mike Frysingerb38673f2006-02-02 01:41:53 +0000469 $(Q)mv $@.tmp $@
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000470
"Vladimir N. Oleynik"6732af22006-02-15 12:29:37 +0000471include/bb_config.h: .config
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000472 $(disp_gen)
Eric Andersen7daa0762004-10-08 07:46:08 +0000473 @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersen85208e22002-04-12 12:05:57 +0000474
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000475endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
476
Eric Andersencc8ed391999-10-05 16:24:54 +0000477clean:
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000478 - rm -f docs/busybox.dvi docs/busybox.ps \
Eric Andersenf7300882004-04-06 15:26:25 +0000479 docs/busybox.pod docs/busybox.net/busybox.html \
Eric Andersen24e098a2003-08-22 20:53:38 +0000480 docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
481 docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
"Vladimir N. Oleynik"9394b232006-01-23 11:24:58 +0000482 docs/busybox.net/BusyBox.html busybox.links \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000483 $(DO_INSTALL_LIBS) $(LIBBUSYBOX_SONAME) \
Rob Landley90252bb2005-09-20 14:09:57 +0000484 .config.old busybox
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000485 - rm -r -f _install testsuite/links
486 - find . -name .\*.flags -exec rm -f {} \;
487 - find . -name \*.o -exec rm -f {} \;
488 - find . -name \*.om -exec rm -f {} \;
489 - find . -name \*.os -exec rm -f {} \;
490 - find . -name \*.a -exec rm -f {} \;
Eric Andersencc8ed391999-10-05 16:24:54 +0000491
492distclean: clean
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000493 - $(MAKE) -C scripts/config clean
494 - rm -f scripts/bb_mkdep
495 - rm -r -f include/config $(DEP_INCLUDES)
496 - find . -name .depend'*' -exec rm -f {} \;
497 rm -f .config .config.old .config.cmd
Eric Andersencc8ed391999-10-05 16:24:54 +0000498
Eric Andersenc9f20d92002-12-05 08:41:41 +0000499release: distclean #doc
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000500 cd ..; \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000501 rm -r -f $(PROG)-$(VERSION); \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000502 cp -a busybox $(PROG)-$(VERSION); \
503 \
504 find $(PROG)-$(VERSION)/ -type d \
Eric Andersen4306bb12005-08-17 00:03:23 +0000505 -name .svn \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000506 -print \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000507 -exec rm -r -f {} \; ; \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000508 \
509 find $(PROG)-$(VERSION)/ -type f \
510 -name .\#* \
511 -print \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000512 -exec rm -f {} \; ; \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000513 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000514 tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000515
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000516tags:
517 ctags -R .
Matt Kraai4e05da82001-11-19 19:47:56 +0000518
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000519# keep these in sync with noconfig_targets above!
520.PHONY: dummy subdirs check test depend dep buildtree \
521 menuconfig config oldconfig randconfig \
522 defconfig allyesconfig allnoconfig allbareconfig \
523 clean distclean \
524 release tags