blob: 7e37ed40d6811e6e57af4703d486313251ac3796 [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 \
Rob Landley19808fe2006-03-13 03:19:46 +000013 clean distclean help \
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-Fischerdf100942006-03-13 19:04:00 +000018top_srcdir=$(CURDIR)
Eric Andersen7daa0762004-10-08 07:46:08 +000019endif
Bernhard Reutner-Fischer1c943eb2005-09-26 16:01:43 +000020# toplevel directory of the object-tree
Eric Andersen7daa0762004-10-08 07:46:08 +000021ifndef top_builddir
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000022top_builddir=$(CURDIR)
Eric Andersen7daa0762004-10-08 07:46:08 +000023endif
24
Mike Frysinger9d6e0832005-07-31 22:50:17 +000025export srctree=$(top_srcdir)
Eric Andersen7daa0762004-10-08 07:46:08 +000026vpath %/Config.in $(srctree)
27
Glenn L McGrath3238ea12003-02-15 10:53:40 +000028DIRS:=applets archival archival/libunarchive coreutils console-tools \
29 debianutils editors findutils init miscutils modutils networking \
Mike Frysinger1b4e1da2006-05-08 03:24:36 +000030 networking/libiproute networking/udhcp procps loginutils shell \
Mike Frysingerd89e6292005-04-24 05:07:59 +000031 sysklogd util-linux e2fsprogs libpwdgrp coreutils/libcoreutils libbb
Eric Andersenab050f52001-01-27 06:01:43 +000032
Eric Andersen7daa0762004-10-08 07:46:08 +000033SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
34
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000035# That's our default target when none is given on the command line
36.PHONY: _all
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000037_all:
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000038
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000039CONFIG_CONFIG_IN = $(top_srcdir)/Config.in
Eric Andersen7daa0762004-10-08 07:46:08 +000040
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000041ifeq ($(KBUILD_SRC),)
Eric Andersen7daa0762004-10-08 07:46:08 +000042
43ifdef O
44 ifeq ("$(origin O)", "command line")
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000045 KBUILD_OUTPUT := $(O)
46 top_builddir := $(O)
Eric Andersen7daa0762004-10-08 07:46:08 +000047 endif
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000048else
49# If no alternate output-dir was specified, we build in cwd
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000050# We are using KBUILD_OUTPUT nevertheless to make sure that we create
51# Rules.mak and the toplevel Makefile, in case they don't exist.
52 KBUILD_OUTPUT := $(top_builddir)
Eric Andersen7daa0762004-10-08 07:46:08 +000053endif
54
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000055ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
56# pull in OS specific commands like cp, mkdir, etc. early
57-include $(top_srcdir)/Rules.mak
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +000058endif
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000059
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000060# All object directories.
61OBJ_DIRS := $(DIRS)
62all_tree := $(patsubst %,$(top_builddir)/%,$(OBJ_DIRS) scripts scripts/config include)
63all_tree: $(all_tree)
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +000064$(all_tree):
65 @mkdir -p "$@"
66
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000067ifneq ($(KBUILD_OUTPUT),)
68# Invoke a second make in the output directory, passing relevant variables
69# Check that the output directory actually exists
70saved-output := $(KBUILD_OUTPUT)
71KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
72$(if $(wildcard $(KBUILD_OUTPUT)),, \
Eric Andersen7daa0762004-10-08 07:46:08 +000073 $(error output directory "$(saved-output)" does not exist))
74
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000075.PHONY: $(MAKECMDGOALS)
Eric Andersen7daa0762004-10-08 07:46:08 +000076
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000077$(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile all_tree
78 $(Q)$(MAKE) -C $(KBUILD_OUTPUT) \
79 top_srcdir=$(top_srcdir) \
80 top_builddir=$(top_builddir) \
81 KBUILD_SRC=$(top_srcdir) \
82 -f $(CURDIR)/Makefile $@
83
84$(KBUILD_OUTPUT)/Rules.mak:
Eric Andersen7daa0762004-10-08 07:46:08 +000085 @echo > $@
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000086 @echo top_srcdir=$(top_srcdir) >> $@
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000087 @echo top_builddir=$(KBUILD_OUTPUT) >> $@
88 @echo include $(top_srcdir)/Rules.mak >> $@
Eric Andersen7daa0762004-10-08 07:46:08 +000089
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000090$(KBUILD_OUTPUT)/Makefile:
Eric Andersen7daa0762004-10-08 07:46:08 +000091 @echo > $@
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000092 @echo top_srcdir=$(top_srcdir) >> $@
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000093 @echo top_builddir=$(KBUILD_OUTPUT) >> $@
94 @echo KBUILD_SRC='$$(top_srcdir)' >> $@
95 @echo include '$$(KBUILD_SRC)'/Makefile >> $@
Eric Andersen7daa0762004-10-08 07:46:08 +000096
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000097# Leave processing to above invocation of make
98skip-makefile := 1
99endif # ifneq ($(KBUILD_OUTPUT),)
100endif # ifeq ($(KBUILD_SRC),)
Eric Andersen7daa0762004-10-08 07:46:08 +0000101
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000102ifeq ($(skip-makefile),)
Eric Andersen7daa0762004-10-08 07:46:08 +0000103
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000104# We only need a copy of the Makefile for the config targets and reuse
105# the rest from the source directory, i.e. we do not cp ALL_MAKEFILES.
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000106scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile
107 cp $< $@
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000108
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000109_all: all
Glenn L McGrath6376b582003-09-24 15:48:29 +0000110
Rob Landleyd24eaac2005-09-26 15:49:41 +0000111help:
112 @echo 'Cleaning:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000113 @echo ' clean - delete temporary files created by build'
114 @echo ' distclean - delete all non-source files (including .config)'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000115 @echo
116 @echo 'Build:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000117 @echo ' all - Executable and documentation'
118 @echo ' busybox - the swiss-army executable'
119 @echo ' doc - docs/BusyBox.{txt,html,1}'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000120 @echo
121 @echo 'Configuration:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000122 @echo ' allnoconfig - disable all symbols in .config'
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000123 @echo ' allyesconfig - enable all symbols in .config (see defconfig)'
124 @echo ' allbareconfig - enable all applets without any sub-features'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000125 @echo ' config - text based configurator (of last resort)'
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000126 @echo ' defconfig - set .config to largest generic configuration'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000127 @echo ' menuconfig - interactive curses-based configurator'
128 @echo ' oldconfig - resolve any unresolved symbols in .config'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000129 @echo
130 @echo 'Installation:'
Eric Andersena6db0ee2006-03-20 17:50:08 +0000131 @echo ' install - install busybox into $(PREFIX)'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000132 @echo ' uninstall'
133 @echo
134 @echo 'Development:'
Rob Landleyf8a80842006-05-07 19:26:53 +0000135 @echo ' bloatcheck - show size difference between busybox_unstripped'
Bernhard Reutner-Fischer24318302006-05-09 11:29:56 +0000136 @echo ' and busybox_old'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000137 @echo ' check - run the test suite for all applets'
Bernhard Reutner-Fischer3916b2a2006-05-04 11:38:33 +0000138 @echo ' checkhelp - check for missing help-entries in Config.in'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000139 @echo ' randconfig - generate a random configuration'
140 @echo ' release - create a distribution tarball'
141 @echo ' sizes - show size of all enabled busybox symbols'
Bernhard Reutner-Fischer06a81d32006-04-26 10:10:25 +0000142 @echo ' objsizes - show size of each .o object built'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000143 @echo
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000144
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000145
146include $(top_srcdir)/Rules.mak
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000147
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000148ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000149
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000150# Default target if none was requested explicitly
Bernhard Reutner-Fischera25d83b2006-03-13 19:30:06 +0000151all: menuconfig
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000152
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000153# warn if no configuration exists and we are asked to build a non-config target
154.config:
155 @echo ""
156 @echo "No $(top_builddir)/$@ found!"
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000157 @echo "Please refer to 'make help', section Configuration."
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000158 @echo ""
159 @exit 1
160
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000161# configuration
162# ---------------------------------------------------------------------------
163
164scripts/config/conf: scripts/config/Makefile
Mike Frysingerb38673f2006-02-02 01:41:53 +0000165 $(Q)$(MAKE) -C scripts/config conf
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000166 -@if [ ! -f .config ] ; then \
167 touch .config; \
168 fi
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000169
170scripts/config/mconf: scripts/config/Makefile
Mike Frysingerb38673f2006-02-02 01:41:53 +0000171 $(Q)$(MAKE) -C scripts/config ncurses conf mconf
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000172 -@if [ ! -f .config ] ; then \
173 touch .config; \
174 fi
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000175
176menuconfig: scripts/config/mconf
Rob Landley9dc69132006-03-13 02:52:23 +0000177 @[ -f .config ] || make $(MAKEFLAGS) defconfig
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000178 @./scripts/config/mconf $(CONFIG_CONFIG_IN)
179
180config: scripts/config/conf
181 @./scripts/config/conf $(CONFIG_CONFIG_IN)
182
183oldconfig: scripts/config/conf
184 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
185
186randconfig: scripts/config/conf
187 @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
188
189allyesconfig: scripts/config/conf
190 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000191 @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER)=.*/# \1 is not set/" .config
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000192 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
193
194allnoconfig: scripts/config/conf
195 @./scripts/config/conf -n $(CONFIG_CONFIG_IN)
196
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000197# defconfig is allyesconfig minus any features that are specialized enough
198# or cause enough behavior change that the user really should switch them on
199# manually if that's what they want. Sort of "maximum sane config".
Rob Landleya167ec52006-01-31 02:42:50 +0000200
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000201defconfig: scripts/config/conf
Rob Landleya167ec52006-01-31 02:42:50 +0000202 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000203 @$(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 +0000204 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
205
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000206
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +0000207allbareconfig: scripts/config/conf
208 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000209 @$(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
210 @$(SED) -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +0000211 @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config
Rob Landley786988f2006-03-22 15:24:24 +0000212 @yes n | ./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Bernhard Reutner-Fischera9d89132005-10-07 18:45:03 +0000213
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000214else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersen00814662001-04-26 23:29:10 +0000215
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000216all: busybox busybox.links doc
217
218# In this section, we need .config
Eric Andersen7daa0762004-10-08 07:46:08 +0000219-include $(top_builddir)/.config.cmd
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000220include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
Eric Andersen7daa0762004-10-08 07:46:08 +0000221
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000222endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000223
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000224-include $(top_builddir)/.config
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000225-include $(top_builddir)/.depend
226
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000227
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000228ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000229libraries-y:=
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000230# Which parts of the internal libs are requested?
231# Per default we only want what was actually selected.
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000232# -a denotes all while -y denotes the selected ones.
233ifeq ($(strip $(CONFIG_FEATURE_FULL_LIBBUSYBOX)),y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000234LIBRARY_DEFINE:=$(LIBRARY_DEFINE-a)
235LIBRARY_SRC :=$(LIBRARY_SRC-a)
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000236else # CONFIG_FEATURE_FULL_LIBBUSYBOX
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000237LIBRARY_DEFINE:=$(LIBRARY_DEFINE-y)
238LIBRARY_SRC :=$(LIBRARY_SRC-y)
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000239endif # CONFIG_FEATURE_FULL_LIBBUSYBOX
240APPLET_SRC:=$(APPLET_SRC-y)
241APPLETS_DEFINE:=$(APPLETS_DEFINE-y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000242else # CONFIG_BUILD_AT_ONCE
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000243# no --combine, build archives out of the individual .o
244# This was the old way the binary was built.
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000245libbusybox-obj:=archival/libunarchive/libunarchive.a \
246 networking/libiproute/libiproute.a \
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000247 libpwdgrp/libpwdgrp.a \
248 coreutils/libcoreutils/libcoreutils.a \
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000249 libbb/libbb.a
250libbusybox-obj:=$(patsubst %,$(top_builddir)/%,$(libbusybox-obj))
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000251
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000252ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000253# linking against libbusybox, so don't build the .a already contained in the .so
254libraries-y:=$(filter-out $(libbusybox-obj),$(libraries-y))
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000255endif # CONFIG_FEATURE_SHARED_BUSYBOX
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000256endif # CONFIG_BUILD_AT_ONCE
257
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000258
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000259ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
260LD_LIBBUSYBOX:=libbusybox.so
261LIBBUSYBOX_SONAME:=$(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)
262DO_INSTALL_LIBS:=$(LD_LIBBUSYBOX) \
263 $(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
264 $(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION)
Bernhard Reutner-Fischer2b398be2006-04-03 21:16:52 +0000265endif # CONFIG_BUILD_LIBBUSYBOX
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000266
267ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
268ifneq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000269# --combine but not linking against libbusybox, so compile all
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000270BUSYBOX_SRC := $(LIBRARY_SRC)
271BUSYBOX_DEFINE:= $(LIBRARY_DEFINE)
272endif # !CONFIG_FEATURE_SHARED_BUSYBOX
273$(LIBBUSYBOX_SONAME): $(LIBRARY_SRC)
274else # CONFIG_BUILD_AT_ONCE
275$(LIBBUSYBOX_SONAME): $(libbusybox-obj)
276endif # CONFIG_BUILD_AT_ONCE
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000277
278ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
279LDBUSYBOX:=-L$(top_builddir) -lbusybox
280endif
281
282ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000283$(LIBBUSYBOX_SONAME):
284ifndef MAJOR_VERSION
285 $(error MAJOR_VERSION needed for $@ is not defined)
286endif
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000287 $(do_link) $(LIB_CFLAGS) $(CFLAGS_COMBINE) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000288 -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
Bernhard Reutner-Fischer08a1b502006-01-27 15:45:56 +0000289 -Wl,-z,combreloc $(LIB_LDFLAGS) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000290 -o $(@) \
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000291 -Wl,--start-group -Wl,--whole-archive \
292 $(LIBRARY_DEFINE) $(^) \
293 -Wl,--no-whole-archive -Wl,--end-group
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000294 @rm -f $(DO_INSTALL_LIBS)
295 @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done
Mike Frysingerb38673f2006-02-02 01:41:53 +0000296 $(do_strip)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000297
298endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
299
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000300busybox_unstripped: .depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(libraries-y)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000301 $(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000302 -o $@ -Wl,--start-group \
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000303 $(APPLETS_DEFINE) $(APPLET_SRC) \
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000304 $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000305 $(LDBUSYBOX) $(LIBRARIES) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000306 -Wl,--end-group
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000307
308busybox: busybox_unstripped
309 $(Q)cp busybox_unstripped busybox
Mike Frysingerb38673f2006-02-02 01:41:53 +0000310 $(do_strip)
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000311
Mike Frysinger586ea612006-04-21 01:18:07 +0000312%.bflt: %_unstripped
313 $(do_elf2flt)
314
Rob Landleya930bd32005-12-16 06:12:46 +0000315busybox.links: $(top_srcdir)/applets/busybox.mkll include/bb_config.h $(top_srcdir)/include/applets.h
Mike Frysingerb38673f2006-02-02 01:41:53 +0000316 $(Q)-$(SHELL) $^ >$@
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000317
Eric Andersen63024862004-10-13 17:45:57 +0000318install: $(top_srcdir)/applets/install.sh busybox busybox.links
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000319 $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000320 $(SHELL) $< $(PREFIX) $(INSTALL_OPTS)
Eric Andersen13879102004-08-26 23:13:00 +0000321ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
322 @echo
323 @echo
324 @echo --------------------------------------------------
325 @echo You will probably need to make your busybox binary
326 @echo setuid root to ensure all configured applets will
327 @echo work properly.
328 @echo --------------------------------------------------
329 @echo
330endif
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000331
Glenn L McGrath87470de2003-08-29 12:20:31 +0000332uninstall: busybox.links
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000333 rm -f $(PREFIX)/bin/busybox
334 for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000335ifneq ($(strip $(DO_INSTALL_LIBS)),n)
336 for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000337 rm -f $(PREFIX)$$i; \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000338 done
339endif
Eric Andersen1f30a412002-04-13 13:39:48 +0000340
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000341# see if we are in verbose mode
342KBUILD_VERBOSE :=
343ifdef V
344 ifeq ("$(origin V)", "command line")
345 KBUILD_VERBOSE := $(V)
346 endif
347endif
348ifneq ($(strip $(KBUILD_VERBOSE)),)
349 CHECK_VERBOSE := -v
350# ARFLAGS+=v
351endif
Mike Frysingerce0cf1d2005-09-24 05:47:52 +0000352check test: busybox
Eric Andersen7daa0762004-10-08 07:46:08 +0000353 bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \
Bernhard Reutner-Fischere34e8782005-10-06 12:48:03 +0000354 $(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE)
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000355
Bernhard Reutner-Fischer3916b2a2006-05-04 11:38:33 +0000356.PHONY: checkhelp
357checkhelp:
358 $(Q)$(top_srcdir)/scripts/checkhelp.awk \
359 $(wildcard $(patsubst %,%/Config.in,$(SRC_DIRS) ./))
Bernhard Reutner-Fischer06a81d32006-04-26 10:10:25 +0000360.PHONY: sizes
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000361sizes: busybox_unstripped
362 $(NM) --size-sort $(<)
Rob Landleyf8a80842006-05-07 19:26:53 +0000363.PHONY: bloatcheck
364bloatcheck: busybox_old busybox_unstripped
Rob Landley92d8b352006-05-08 20:48:12 +0000365 @$(top_srcdir)/scripts/bloat-o-meter busybox_old busybox_unstripped
Rob Landley16890752005-09-02 00:41:53 +0000366
Bernhard Reutner-Fischer06a81d32006-04-26 10:10:25 +0000367.PHONY: objsizes
368objsizes: busybox_unstripped
369 $(SHELL) $(top_srcdir)/scripts/objsizes
370
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000371# Documentation Targets
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000372doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
John Beppu94e50542001-04-05 19:42:03 +0000373
Mike Frysingerf37529d2006-02-05 22:15:39 +0000374docs/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 +0000375 $(disp_doc)
376 $(Q)-mkdir -p docs
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000377 $(Q)-( cat $(top_srcdir)/docs/busybox_header.pod ; \
378 $(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h ; \
379 cat $(top_srcdir)/docs/busybox_footer.pod ; ) > docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +0000380
Eric Andersen67536ff2000-07-06 22:53:22 +0000381docs/BusyBox.txt: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000382 $(disp_doc)
383 $(Q)-mkdir -p docs
384 $(Q)-pod2text $< > $@
Eric Andersen53310252000-07-04 19:42:23 +0000385
Eric Andersen67536ff2000-07-06 22:53:22 +0000386docs/BusyBox.1: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000387 $(disp_doc)
388 $(Q)-mkdir -p docs
389 $(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
Eric Andersen19f86202001-02-17 00:42:47 +0000390 $< > $@
Eric Andersen53310252000-07-04 19:42:23 +0000391
Eric Andersen2423b122001-12-08 01:56:15 +0000392docs/BusyBox.html: docs/busybox.net/BusyBox.html
Mike Frysingerb38673f2006-02-02 01:41:53 +0000393 $(disp_doc)
394 $(Q)-mkdir -p docs
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000395 $(Q)-rm -f docs/BusyBox.html
Mike Frysingerb38673f2006-02-02 01:41:53 +0000396 $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
Eric Andersen53310252000-07-04 19:42:23 +0000397
Eric Andersen2423b122001-12-08 01:56:15 +0000398docs/busybox.net/BusyBox.html: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000399 $(Q)-mkdir -p docs/busybox.net
400 $(Q)-pod2html --noindex $< > \
Eric Andersen2423b122001-12-08 01:56:15 +0000401 docs/busybox.net/BusyBox.html
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000402 $(Q)-rm -f pod2htm*
Erik Andersen0a704e82000-05-03 03:19:06 +0000403
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000404# The nifty new dependency stuff
"Vladimir N. Oleynik"5e60dc42005-09-12 12:33:27 +0000405scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c
Mike Frysinger12ef09b2006-04-29 04:19:10 +0000406 $(do_link.h)
Erik Andersen1d1d9502000-04-21 01:26:49 +0000407
"Vladimir N. Oleynik"6732af22006-02-15 12:29:37 +0000408DEP_INCLUDES := include/bb_config.h
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000409
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000410ifeq ($(strip $(CONFIG_BBCONFIG)),y)
411DEP_INCLUDES += include/bbconfigopts.h
412
413include/bbconfigopts.h: .config
Mike Frysingerb38673f2006-02-02 01:41:53 +0000414 $(disp_gen)
415 $(Q)$(top_srcdir)/scripts/config/mkconfigs > $@
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000416endif
417
Rob Landley7e21d5f2006-04-27 23:34:46 +0000418scripts/usage: $(top_srcdir)/scripts/usage.c .config
Mike Frysinger12ef09b2006-04-29 04:19:10 +0000419 $(do_link.h) -I$(top_srcdir)/include
Rob Landley7e21d5f2006-04-27 23:34:46 +0000420
421DEP_INCLUDES += include/usage_compressed.h
422include/usage_compressed.h: .config scripts/usage
423 $(Q)sh $(top_srcdir)/scripts/usage_compressed "$(top_srcdir)/scripts" > $@
424
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000425depend dep: .depend
426.depend: scripts/bb_mkdep $(DEP_INCLUDES)
Mike Frysingerb38673f2006-02-02 01:41:53 +0000427 $(disp_gen)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000428 $(Q)rm -f .depend
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000429 $(Q)mkdir -p include/config
430 $(Q)scripts/bb_mkdep -I $(top_srcdir)/include $(top_srcdir) > $@.tmp
Mike Frysingerb38673f2006-02-02 01:41:53 +0000431 $(Q)mv $@.tmp $@
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000432
"Vladimir N. Oleynik"6732af22006-02-15 12:29:37 +0000433include/bb_config.h: .config
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000434 @if [ ! -x $(top_builddir)/scripts/config/conf ] ; then \
435 $(MAKE) -C scripts/config conf; \
436 fi;
Eric Andersen7daa0762004-10-08 07:46:08 +0000437 @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersen85208e22002-04-12 12:05:57 +0000438
Eric Andersencc8ed391999-10-05 16:24:54 +0000439clean:
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000440 - $(MAKE) -C scripts/config $@
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000441 - rm -f docs/busybox.dvi docs/busybox.ps \
Eric Andersenf7300882004-04-06 15:26:25 +0000442 docs/busybox.pod docs/busybox.net/busybox.html \
Eric Andersen24e098a2003-08-22 20:53:38 +0000443 docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
444 docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
"Vladimir N. Oleynik"9394b232006-01-23 11:24:58 +0000445 docs/busybox.net/BusyBox.html busybox.links \
Bernhard Reutner-Fischera5972112006-03-06 14:19:15 +0000446 libbusybox.so* \
Mike Frysinger33b45a02006-03-05 16:25:19 +0000447 .config.old busybox busybox_unstripped
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000448 - rm -r -f _install testsuite/links
Rob Landley31e36102006-03-09 22:01:05 +0000449 - find . -name .\*.flags -o -name \*.o -o -name \*.om \
450 -o -name \*.os -o -name \*.osm -o -name \*.a | xargs rm -f
Eric Andersencc8ed391999-10-05 16:24:54 +0000451
452distclean: clean
Mike Frysinger59e46112006-05-10 05:19:27 +0000453 rm -f scripts/bb_mkdep scripts/usage
454 rm -r -f include/config include/_usage.h include/config.h $(DEP_INCLUDES)
455 find . -name .depend'*' -print0 | xargs -0 rm -f
456 rm -f .hdepend
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000457 rm -f .config .config.old .config.cmd
Eric Andersencc8ed391999-10-05 16:24:54 +0000458
Eric Andersenc9f20d92002-12-05 08:41:41 +0000459release: distclean #doc
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000460 cd ..; \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000461 rm -r -f $(PROG)-$(VERSION); \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000462 cp -a busybox $(PROG)-$(VERSION); \
463 \
464 find $(PROG)-$(VERSION)/ -type d \
Eric Andersen4306bb12005-08-17 00:03:23 +0000465 -name .svn \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000466 -print \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000467 -exec rm -r -f {} \; ; \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000468 \
469 find $(PROG)-$(VERSION)/ -type f \
470 -name .\#* \
471 -print \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000472 -exec rm -f {} \; ; \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000473 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000474 tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000475
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000476tags:
477 ctags -R .
Matt Kraai4e05da82001-11-19 19:47:56 +0000478
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000479
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000480endif # ifeq ($(skip-makefile),)
481
482.PHONY: dummy subdirs release distclean clean config oldconfig \
483 menuconfig tags check test depend dep buildtree