blob: 6d03c82f925058684bc5edd38acdfd82606a74db [file] [log] [blame]
Eric Andersenc4996011999-10-20 22:08:37 +00001# Makefile for busybox
2#
Eric Andersenc7bda1c2004-03-15 08:29:22 +00003# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
Erik Andersen9ffdaa62000-02-11 21:55:04 +00004#
Rob Landleya7e14db2005-09-11 01:16:47 +00005# Licensed under GPLv2, see the file LICENSE in this tarball for details.
Eric Andersenc4996011999-10-20 22:08:37 +00006#
7
Rob Landleyd9872aa2006-05-27 21:24:16 +00008# You shouldn't have to edit anything in this file for configuration
9# purposes, try "make help" or read http://busybox.net/FAQ.html.
10
11.PHONY: dummy subdirs release distclean clean config oldconfig menuconfig \
12 tags check test depend dep buildtree hosttools _all checkhelp \
13 sizes bloatcheck baseline objsizes
14
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +000015noconfig_targets := menuconfig config oldconfig randconfig hosttools \
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +000016 defconfig allyesconfig allnoconfig allbareconfig \
Rob Landley19808fe2006-03-13 03:19:46 +000017 clean distclean help \
Eric Andersenbcf27242005-02-13 22:15:59 +000018 release tags
Eric Andersen7daa0762004-10-08 07:46:08 +000019
Bernhard Reutner-Fischer1c943eb2005-09-26 16:01:43 +000020# the toplevel sourcedir
Eric Andersen7daa0762004-10-08 07:46:08 +000021ifndef top_srcdir
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000022top_srcdir=$(CURDIR)
Eric Andersen7daa0762004-10-08 07:46:08 +000023endif
Bernhard Reutner-Fischer1c943eb2005-09-26 16:01:43 +000024# toplevel directory of the object-tree
Eric Andersen7daa0762004-10-08 07:46:08 +000025ifndef top_builddir
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000026top_builddir=$(CURDIR)
Eric Andersen7daa0762004-10-08 07:46:08 +000027endif
28
Mike Frysinger9d6e0832005-07-31 22:50:17 +000029export srctree=$(top_srcdir)
Eric Andersen7daa0762004-10-08 07:46:08 +000030vpath %/Config.in $(srctree)
31
Glenn L McGrath3238ea12003-02-15 10:53:40 +000032DIRS:=applets archival archival/libunarchive coreutils console-tools \
33 debianutils editors findutils init miscutils modutils networking \
Mike Frysinger1b4e1da2006-05-08 03:24:36 +000034 networking/libiproute networking/udhcp procps loginutils shell \
Mike Frysingerd89e6292005-04-24 05:07:59 +000035 sysklogd util-linux e2fsprogs libpwdgrp coreutils/libcoreutils libbb
Eric Andersenab050f52001-01-27 06:01:43 +000036
Eric Andersen7daa0762004-10-08 07:46:08 +000037SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
38
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000039# That's our default target when none is given on the command line
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000040_all:
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000041
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000042CONFIG_CONFIG_IN = $(top_srcdir)/Config.in
Eric Andersen7daa0762004-10-08 07:46:08 +000043
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000044ifeq ($(KBUILD_SRC),)
Eric Andersen7daa0762004-10-08 07:46:08 +000045
46ifdef O
47 ifeq ("$(origin O)", "command line")
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000048 KBUILD_OUTPUT := $(O)
49 top_builddir := $(O)
Eric Andersen7daa0762004-10-08 07:46:08 +000050 endif
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000051else
52# If no alternate output-dir was specified, we build in cwd
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000053# We are using KBUILD_OUTPUT nevertheless to make sure that we create
54# Rules.mak and the toplevel Makefile, in case they don't exist.
55 KBUILD_OUTPUT := $(top_builddir)
Eric Andersen7daa0762004-10-08 07:46:08 +000056endif
57
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000058ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
59# pull in OS specific commands like cp, mkdir, etc. early
60-include $(top_srcdir)/Rules.mak
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +000061endif
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +000062
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000063# All object directories.
64OBJ_DIRS := $(DIRS)
65all_tree := $(patsubst %,$(top_builddir)/%,$(OBJ_DIRS) scripts scripts/config include)
66all_tree: $(all_tree)
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +000067$(all_tree):
68 @mkdir -p "$@"
69
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000070ifneq ($(KBUILD_OUTPUT),)
71# Invoke a second make in the output directory, passing relevant variables
72# Check that the output directory actually exists
73saved-output := $(KBUILD_OUTPUT)
74KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
75$(if $(wildcard $(KBUILD_OUTPUT)),, \
Eric Andersen7daa0762004-10-08 07:46:08 +000076 $(error output directory "$(saved-output)" does not exist))
77
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000078.PHONY: $(MAKECMDGOALS)
Eric Andersen7daa0762004-10-08 07:46:08 +000079
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000080$(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile all_tree
81 $(Q)$(MAKE) -C $(KBUILD_OUTPUT) \
82 top_srcdir=$(top_srcdir) \
83 top_builddir=$(top_builddir) \
84 KBUILD_SRC=$(top_srcdir) \
85 -f $(CURDIR)/Makefile $@
86
87$(KBUILD_OUTPUT)/Rules.mak:
Eric Andersen7daa0762004-10-08 07:46:08 +000088 @echo > $@
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000089 @echo top_srcdir=$(top_srcdir) >> $@
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000090 @echo top_builddir=$(KBUILD_OUTPUT) >> $@
91 @echo include $(top_srcdir)/Rules.mak >> $@
Eric Andersen7daa0762004-10-08 07:46:08 +000092
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000093$(KBUILD_OUTPUT)/Makefile:
Eric Andersen7daa0762004-10-08 07:46:08 +000094 @echo > $@
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +000095 @echo top_srcdir=$(top_srcdir) >> $@
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +000096 @echo top_builddir=$(KBUILD_OUTPUT) >> $@
97 @echo KBUILD_SRC='$$(top_srcdir)' >> $@
98 @echo include '$$(KBUILD_SRC)'/Makefile >> $@
Eric Andersen7daa0762004-10-08 07:46:08 +000099
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000100# Leave processing to above invocation of make
101skip-makefile := 1
102endif # ifneq ($(KBUILD_OUTPUT),)
103endif # ifeq ($(KBUILD_SRC),)
Eric Andersen7daa0762004-10-08 07:46:08 +0000104
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000105ifeq ($(skip-makefile),)
Eric Andersen7daa0762004-10-08 07:46:08 +0000106
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000107# We only need a copy of the Makefile for the config targets and reuse
108# the rest from the source directory, i.e. we do not cp ALL_MAKEFILES.
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000109scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile
110 cp $< $@
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000111
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000112_all: all
Glenn L McGrath6376b582003-09-24 15:48:29 +0000113
Rob Landleyd24eaac2005-09-26 15:49:41 +0000114help:
115 @echo 'Cleaning:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000116 @echo ' clean - delete temporary files created by build'
117 @echo ' distclean - delete all non-source files (including .config)'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000118 @echo
119 @echo 'Build:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000120 @echo ' all - Executable and documentation'
121 @echo ' busybox - the swiss-army executable'
122 @echo ' doc - docs/BusyBox.{txt,html,1}'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000123 @echo
124 @echo 'Configuration:'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000125 @echo ' allnoconfig - disable all symbols in .config'
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000126 @echo ' allyesconfig - enable all symbols in .config (see defconfig)'
127 @echo ' allbareconfig - enable all applets without any sub-features'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000128 @echo ' config - text based configurator (of last resort)'
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000129 @echo ' defconfig - set .config to largest generic configuration'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000130 @echo ' menuconfig - interactive curses-based configurator'
131 @echo ' oldconfig - resolve any unresolved symbols in .config'
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +0000132 @echo ' hosttools - build sed for the host.'
133 @echo ' You can use these commands if the commands on the host'
134 @echo ' is unusable. Afterwards use it like:'
135 @echo ' make SED="$(top_builddir)/sed"'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000136 @echo
137 @echo 'Installation:'
Eric Andersena6db0ee2006-03-20 17:50:08 +0000138 @echo ' install - install busybox into $(PREFIX)'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000139 @echo ' uninstall'
140 @echo
141 @echo 'Development:'
Rob Landleyd9872aa2006-05-27 21:24:16 +0000142 @echo ' baseline - create busybox_old for bloatcheck.
Rob Landley0690d152006-05-11 17:33:10 +0000143 @echo ' bloatcheck - show size difference between old and new versions'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000144 @echo ' check - run the test suite for all applets'
Bernhard Reutner-Fischer3916b2a2006-05-04 11:38:33 +0000145 @echo ' checkhelp - check for missing help-entries in Config.in'
"Vladimir N. Oleynik"b7576992006-01-23 11:39:05 +0000146 @echo ' randconfig - generate a random configuration'
147 @echo ' release - create a distribution tarball'
148 @echo ' sizes - show size of all enabled busybox symbols'
Bernhard Reutner-Fischer06a81d32006-04-26 10:10:25 +0000149 @echo ' objsizes - show size of each .o object built'
Rob Landleyd24eaac2005-09-26 15:49:41 +0000150 @echo
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000151
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000152
153include $(top_srcdir)/Rules.mak
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000154
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000155ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000156
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000157# Default target if none was requested explicitly
Bernhard Reutner-Fischera25d83b2006-03-13 19:30:06 +0000158all: menuconfig
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000159
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000160# warn if no configuration exists and we are asked to build a non-config target
161.config:
162 @echo ""
163 @echo "No $(top_builddir)/$@ found!"
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000164 @echo "Please refer to 'make help', section Configuration."
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000165 @echo ""
166 @exit 1
167
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000168# configuration
169# ---------------------------------------------------------------------------
170
171scripts/config/conf: scripts/config/Makefile
Mike Frysingerb38673f2006-02-02 01:41:53 +0000172 $(Q)$(MAKE) -C scripts/config conf
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000173 -@if [ ! -f .config ] ; then \
174 touch .config; \
175 fi
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000176
177scripts/config/mconf: scripts/config/Makefile
Mike Frysingerb38673f2006-02-02 01:41:53 +0000178 $(Q)$(MAKE) -C scripts/config ncurses conf mconf
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000179 -@if [ ! -f .config ] ; then \
180 touch .config; \
181 fi
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000182
183menuconfig: scripts/config/mconf
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000184 @[ -f .config ] || $(MAKE) $(MAKEFLAGS) defconfig
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000185 @./scripts/config/mconf $(CONFIG_CONFIG_IN)
186
187config: scripts/config/conf
188 @./scripts/config/conf $(CONFIG_CONFIG_IN)
189
190oldconfig: scripts/config/conf
191 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
192
193randconfig: scripts/config/conf
194 @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
195
196allyesconfig: scripts/config/conf
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000197 @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000198 @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER)=.*/# \1 is not set/" .config
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000199 @./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000200
201allnoconfig: scripts/config/conf
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000202 @./scripts/config/conf -n $(CONFIG_CONFIG_IN) > /dev/null
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000203
Rob Landley1ab4c3d2006-02-08 18:50:17 +0000204# defconfig is allyesconfig minus any features that are specialized enough
205# or cause enough behavior change that the user really should switch them on
206# manually if that's what they want. Sort of "maximum sane config".
Rob Landleya167ec52006-01-31 02:42:50 +0000207
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000208defconfig: scripts/config/conf
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000209 @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000210 @$(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
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000211 @./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
Rob Landleya167ec52006-01-31 02:42:50 +0000212
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000213
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +0000214allbareconfig: scripts/config/conf
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000215 @./scripts/config/conf -y $(CONFIG_CONFIG_IN) > /dev/null
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000216 @$(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
217 @$(SED) -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config
Bernhard Reutner-Fischerbe5c1032005-10-08 11:08:28 +0000218 @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config
Bernhard Reutner-Fischer351c8322006-05-19 18:33:34 +0000219 @yes n | ./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
Bernhard Reutner-Fischera9d89132005-10-07 18:45:03 +0000220
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +0000221hosttools:
222 $(Q)cp .config .config.bak || noold=yea
223 $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" allnoconfig
224 $(Q)mv .config .config.in
225 $(Q)(grep -v CONFIG_SED .config.in ; \
226 echo "CONFIG_SED=y" ; ) > .config
227 $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" oldconfig include/bb_config.h
228 $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" busybox
229 $(Q)[ -f .config.bak ] && mv .config.bak .config || rm .config
230 mv busybox sed
231 @echo "Now do: $(MAKE) SED=$(top_builddir)/sed <target>"
232
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000233else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersen00814662001-04-26 23:29:10 +0000234
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000235all: busybox busybox.links doc
236
237# In this section, we need .config
Eric Andersen7daa0762004-10-08 07:46:08 +0000238-include $(top_builddir)/.config.cmd
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000239include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
Eric Andersen7daa0762004-10-08 07:46:08 +0000240
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000241endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000242
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000243-include $(top_builddir)/.config
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000244-include $(top_builddir)/.depend
245
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000246
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000247ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000248libraries-y:=
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000249# Which parts of the internal libs are requested?
250# Per default we only want what was actually selected.
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000251# -a denotes all while -y denotes the selected ones.
252ifeq ($(strip $(CONFIG_FEATURE_FULL_LIBBUSYBOX)),y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000253LIBRARY_DEFINE:=$(LIBRARY_DEFINE-a)
254LIBRARY_SRC :=$(LIBRARY_SRC-a)
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000255else # CONFIG_FEATURE_FULL_LIBBUSYBOX
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000256LIBRARY_DEFINE:=$(LIBRARY_DEFINE-y)
257LIBRARY_SRC :=$(LIBRARY_SRC-y)
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000258endif # CONFIG_FEATURE_FULL_LIBBUSYBOX
259APPLET_SRC:=$(APPLET_SRC-y)
260APPLETS_DEFINE:=$(APPLETS_DEFINE-y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000261else # CONFIG_BUILD_AT_ONCE
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000262# no --combine, build archives out of the individual .o
263# This was the old way the binary was built.
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000264libbusybox-obj:=archival/libunarchive/libunarchive.a \
265 networking/libiproute/libiproute.a \
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000266 libpwdgrp/libpwdgrp.a \
267 coreutils/libcoreutils/libcoreutils.a \
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000268 libbb/libbb.a
269libbusybox-obj:=$(patsubst %,$(top_builddir)/%,$(libbusybox-obj))
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000270
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000271ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000272# linking against libbusybox, so don't build the .a already contained in the .so
273libraries-y:=$(filter-out $(libbusybox-obj),$(libraries-y))
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000274endif # CONFIG_FEATURE_SHARED_BUSYBOX
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000275endif # CONFIG_BUILD_AT_ONCE
276
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000277
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000278ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
279LD_LIBBUSYBOX:=libbusybox.so
280LIBBUSYBOX_SONAME:=$(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)
281DO_INSTALL_LIBS:=$(LD_LIBBUSYBOX) \
282 $(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
283 $(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION)
Bernhard Reutner-Fischer2b398be2006-04-03 21:16:52 +0000284endif # CONFIG_BUILD_LIBBUSYBOX
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000285
286ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
287ifneq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000288# --combine but not linking against libbusybox, so compile all
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000289BUSYBOX_SRC := $(LIBRARY_SRC)
290BUSYBOX_DEFINE:= $(LIBRARY_DEFINE)
291endif # !CONFIG_FEATURE_SHARED_BUSYBOX
292$(LIBBUSYBOX_SONAME): $(LIBRARY_SRC)
293else # CONFIG_BUILD_AT_ONCE
294$(LIBBUSYBOX_SONAME): $(libbusybox-obj)
295endif # CONFIG_BUILD_AT_ONCE
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000296
297ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
298LDBUSYBOX:=-L$(top_builddir) -lbusybox
299endif
300
301ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000302$(LIBBUSYBOX_SONAME):
303ifndef MAJOR_VERSION
304 $(error MAJOR_VERSION needed for $@ is not defined)
305endif
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000306 $(do_link) $(LIB_CFLAGS) $(CFLAGS_COMBINE) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000307 -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
Bernhard Reutner-Fischer08a1b502006-01-27 15:45:56 +0000308 -Wl,-z,combreloc $(LIB_LDFLAGS) \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000309 -o $(@) \
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +0000310 $(LD_START_GROUP) $(LD_WHOLE_ARCHIVE) \
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000311 $(LIBRARY_DEFINE) $(^) \
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +0000312 $(LD_NO_WHOLE_ARCHIVE) $(LD_END_GROUP)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000313 @rm -f $(DO_INSTALL_LIBS)
314 @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done
Mike Frysingerb38673f2006-02-02 01:41:53 +0000315 $(do_strip)
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000316
317endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
318
Bernhard Reutner-Fischerd8e87a02006-05-19 18:37:34 +0000319busybox_unstripped: .depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(libraries-y)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000320 $(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +0000321 -o $@ $(LD_START_GROUP) \
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000322 $(APPLETS_DEFINE) $(APPLET_SRC) \
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000323 $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000324 $(LDBUSYBOX) $(LIBRARIES) \
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +0000325 $(LD_END_GROUP)
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000326
327busybox: busybox_unstripped
328 $(Q)cp busybox_unstripped busybox
Mike Frysingerb38673f2006-02-02 01:41:53 +0000329 $(do_strip)
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000330
Mike Frysinger586ea612006-04-21 01:18:07 +0000331%.bflt: %_unstripped
332 $(do_elf2flt)
333
Rob Landleya930bd32005-12-16 06:12:46 +0000334busybox.links: $(top_srcdir)/applets/busybox.mkll include/bb_config.h $(top_srcdir)/include/applets.h
Mike Frysingerb38673f2006-02-02 01:41:53 +0000335 $(Q)-$(SHELL) $^ >$@
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000336
Eric Andersen63024862004-10-13 17:45:57 +0000337install: $(top_srcdir)/applets/install.sh busybox busybox.links
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000338 $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000339 $(SHELL) $< $(PREFIX) $(INSTALL_OPTS)
Eric Andersen13879102004-08-26 23:13:00 +0000340ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
341 @echo
342 @echo
343 @echo --------------------------------------------------
344 @echo You will probably need to make your busybox binary
345 @echo setuid root to ensure all configured applets will
346 @echo work properly.
347 @echo --------------------------------------------------
348 @echo
349endif
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000350
Glenn L McGrath87470de2003-08-29 12:20:31 +0000351uninstall: busybox.links
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000352 rm -f $(PREFIX)/bin/busybox
353 for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000354ifneq ($(strip $(DO_INSTALL_LIBS)),n)
355 for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000356 rm -f $(PREFIX)$$i; \
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000357 done
358endif
Eric Andersen1f30a412002-04-13 13:39:48 +0000359
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000360# see if we are in verbose mode
361KBUILD_VERBOSE :=
362ifdef V
363 ifeq ("$(origin V)", "command line")
364 KBUILD_VERBOSE := $(V)
365 endif
366endif
367ifneq ($(strip $(KBUILD_VERBOSE)),)
368 CHECK_VERBOSE := -v
369# ARFLAGS+=v
370endif
Rob Landleyd9872aa2006-05-27 21:24:16 +0000371
Mike Frysingerce0cf1d2005-09-24 05:47:52 +0000372check test: busybox
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +0000373 bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite SED="$(SED)" \
374 $(SHELL) $(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE)
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000375
Bernhard Reutner-Fischer3916b2a2006-05-04 11:38:33 +0000376checkhelp:
377 $(Q)$(top_srcdir)/scripts/checkhelp.awk \
378 $(wildcard $(patsubst %,%/Config.in,$(SRC_DIRS) ./))
Rob Landleyd9872aa2006-05-27 21:24:16 +0000379
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000380sizes: busybox_unstripped
381 $(NM) --size-sort $(<)
Rob Landleyd9872aa2006-05-27 21:24:16 +0000382
Rob Landleyf8a80842006-05-07 19:26:53 +0000383bloatcheck: busybox_old busybox_unstripped
Rob Landley92d8b352006-05-08 20:48:12 +0000384 @$(top_srcdir)/scripts/bloat-o-meter busybox_old busybox_unstripped
Rob Landley16890752005-09-02 00:41:53 +0000385
Rob Landleyd9872aa2006-05-27 21:24:16 +0000386baseline: busybox_unstripped
387 @mv busybox_unstripped busybox_old
388
Bernhard Reutner-Fischer06a81d32006-04-26 10:10:25 +0000389objsizes: busybox_unstripped
390 $(SHELL) $(top_srcdir)/scripts/objsizes
391
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000392# Documentation Targets
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000393doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
John Beppu94e50542001-04-05 19:42:03 +0000394
Mike Frysingerf37529d2006-02-05 22:15:39 +0000395docs/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 +0000396 $(disp_doc)
397 $(Q)-mkdir -p docs
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000398 $(Q)-( cat $(top_srcdir)/docs/busybox_header.pod ; \
399 $(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h ; \
400 cat $(top_srcdir)/docs/busybox_footer.pod ; ) > docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +0000401
Eric Andersen67536ff2000-07-06 22:53:22 +0000402docs/BusyBox.txt: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000403 $(disp_doc)
404 $(Q)-mkdir -p docs
405 $(Q)-pod2text $< > $@
Eric Andersen53310252000-07-04 19:42:23 +0000406
Eric Andersen67536ff2000-07-06 22:53:22 +0000407docs/BusyBox.1: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000408 $(disp_doc)
409 $(Q)-mkdir -p docs
410 $(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
Eric Andersen19f86202001-02-17 00:42:47 +0000411 $< > $@
Eric Andersen53310252000-07-04 19:42:23 +0000412
Eric Andersen2423b122001-12-08 01:56:15 +0000413docs/BusyBox.html: docs/busybox.net/BusyBox.html
Mike Frysingerb38673f2006-02-02 01:41:53 +0000414 $(disp_doc)
415 $(Q)-mkdir -p docs
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000416 $(Q)-rm -f docs/BusyBox.html
Mike Frysingerb38673f2006-02-02 01:41:53 +0000417 $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
Eric Andersen53310252000-07-04 19:42:23 +0000418
Eric Andersen2423b122001-12-08 01:56:15 +0000419docs/busybox.net/BusyBox.html: docs/busybox.pod
Mike Frysingerb38673f2006-02-02 01:41:53 +0000420 $(Q)-mkdir -p docs/busybox.net
421 $(Q)-pod2html --noindex $< > \
Eric Andersen2423b122001-12-08 01:56:15 +0000422 docs/busybox.net/BusyBox.html
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000423 $(Q)-rm -f pod2htm*
Erik Andersen0a704e82000-05-03 03:19:06 +0000424
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000425# The nifty new dependency stuff
"Vladimir N. Oleynik"5e60dc42005-09-12 12:33:27 +0000426scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c
Mike Frysinger12ef09b2006-04-29 04:19:10 +0000427 $(do_link.h)
Erik Andersen1d1d9502000-04-21 01:26:49 +0000428
"Vladimir N. Oleynik"6732af22006-02-15 12:29:37 +0000429DEP_INCLUDES := include/bb_config.h
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000430
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000431ifeq ($(strip $(CONFIG_BBCONFIG)),y)
432DEP_INCLUDES += include/bbconfigopts.h
433
434include/bbconfigopts.h: .config
Mike Frysingerb38673f2006-02-02 01:41:53 +0000435 $(disp_gen)
436 $(Q)$(top_srcdir)/scripts/config/mkconfigs > $@
"Vladimir N. Oleynik"cef737f2005-09-21 07:49:34 +0000437endif
438
Bernhard Reutner-Fischer30ead9a2006-05-21 09:02:12 +0000439ifeq ($(strip $(CONFIG_FEATURE_COMPRESS_USAGE)),y)
Bernhard Reutner-Fischer4148afe2006-05-21 15:05:49 +0000440USAGE_BIN:=scripts/usage
441$(USAGE_BIN): $(top_srcdir)/scripts/usage.c
Bernhard Reutner-Fischer30ead9a2006-05-21 09:02:12 +0000442 $(do_link.h)
Rob Landley7e21d5f2006-04-27 23:34:46 +0000443
444DEP_INCLUDES += include/usage_compressed.h
Bernhard Reutner-Fischer30ead9a2006-05-21 09:02:12 +0000445
Bernhard Reutner-Fischer4148afe2006-05-21 15:05:49 +0000446include/usage_compressed.h: .config $(USAGE_BIN)
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +0000447 $(Q)SED="$(SED)" $(SHELL) $(top_srcdir)/scripts/usage_compressed "$(top_builddir)/scripts" > $@
Bernhard Reutner-Fischer30ead9a2006-05-21 09:02:12 +0000448endif # CONFIG_FEATURE_COMPRESS_USAGE
Rob Landley7e21d5f2006-04-27 23:34:46 +0000449
Bernhard Reutner-Fischer4148afe2006-05-21 15:05:49 +0000450# workaround alleged bug in make-3.80, make-3.81
451.NOTPARALLEL: .depend
452
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000453depend dep: .depend
Bernhard Reutner-Fischer4148afe2006-05-21 15:05:49 +0000454.depend: scripts/bb_mkdep $(USAGE_BIN) $(DEP_INCLUDES)
Mike Frysingerb38673f2006-02-02 01:41:53 +0000455 $(disp_gen)
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000456 $(Q)rm -f .depend
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000457 $(Q)mkdir -p include/config
458 $(Q)scripts/bb_mkdep -I $(top_srcdir)/include $(top_srcdir) > $@.tmp
Mike Frysingerb38673f2006-02-02 01:41:53 +0000459 $(Q)mv $@.tmp $@
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000460
"Vladimir N. Oleynik"6732af22006-02-15 12:29:37 +0000461include/bb_config.h: .config
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000462 @if [ ! -x $(top_builddir)/scripts/config/conf ] ; then \
463 $(MAKE) -C scripts/config conf; \
464 fi;
Eric Andersen7daa0762004-10-08 07:46:08 +0000465 @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersen85208e22002-04-12 12:05:57 +0000466
Eric Andersencc8ed391999-10-05 16:24:54 +0000467clean:
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000468 - $(MAKE) -C scripts/config $@
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000469 - rm -f docs/busybox.dvi docs/busybox.ps \
Eric Andersenf7300882004-04-06 15:26:25 +0000470 docs/busybox.pod docs/busybox.net/busybox.html \
Eric Andersen24e098a2003-08-22 20:53:38 +0000471 docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
472 docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
"Vladimir N. Oleynik"9394b232006-01-23 11:24:58 +0000473 docs/busybox.net/BusyBox.html busybox.links \
Bernhard Reutner-Fischera5972112006-03-06 14:19:15 +0000474 libbusybox.so* \
Mike Frysinger33b45a02006-03-05 16:25:19 +0000475 .config.old busybox busybox_unstripped
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000476 - rm -r -f _install testsuite/links
Rob Landley31e36102006-03-09 22:01:05 +0000477 - find . -name .\*.flags -o -name \*.o -o -name \*.om \
478 -o -name \*.os -o -name \*.osm -o -name \*.a | xargs rm -f
Eric Andersencc8ed391999-10-05 16:24:54 +0000479
480distclean: clean
Mike Frysinger59e46112006-05-10 05:19:27 +0000481 rm -f scripts/bb_mkdep scripts/usage
Bernhard Reutner-Fischer3c8c0692006-05-21 10:04:46 +0000482 rm -r -f include/config include/config.h $(DEP_INCLUDES)
Mike Frysinger59e46112006-05-10 05:19:27 +0000483 find . -name .depend'*' -print0 | xargs -0 rm -f
484 rm -f .hdepend
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000485 rm -f .config .config.old .config.cmd
Eric Andersencc8ed391999-10-05 16:24:54 +0000486
Eric Andersenc9f20d92002-12-05 08:41:41 +0000487release: distclean #doc
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000488 cd ..; \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000489 rm -r -f $(PROG)-$(VERSION); \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000490 cp -a busybox $(PROG)-$(VERSION); \
491 \
492 find $(PROG)-$(VERSION)/ -type d \
Eric Andersen4306bb12005-08-17 00:03:23 +0000493 -name .svn \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000494 -print \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000495 -exec rm -r -f {} \; ; \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000496 \
497 find $(PROG)-$(VERSION)/ -type f \
498 -name .\#* \
499 -print \
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000500 -exec rm -f {} \; ; \
Mike Frysingerfcafa4b2005-08-01 20:48:00 +0000501 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000502 tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000503
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000504tags:
505 ctags -R .
Matt Kraai4e05da82001-11-19 19:47:56 +0000506
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000507
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000508endif # ifeq ($(skip-makefile),)
509