blob: 4a7195314d0c3013cde74b30ba67da502c496e2e [file] [log] [blame]
Eric Andersenc4996011999-10-20 22:08:37 +00001# Makefile for busybox
2#
Eric Andersen85208e22002-04-12 12:05:57 +00003# Copyright (C) 1999-2002 Erik Andersen <andersee@debian.org>
Erik Andersen9ffdaa62000-02-11 21:55:04 +00004#
Eric Andersenc4996011999-10-20 22:08:37 +00005# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18#
19
Eric Andersen85208e22002-04-12 12:05:57 +000020TOPDIR:= $(shell /bin/pwd)/
21include $(TOPDIR).config
22include $(TOPDIR)Rules.mak
23SUBDIRS:=applets archival archival/libunarchive console-tools \
24 editors fileutils findutils init miscutils modutils networking \
Robert Griebl1fca5582002-06-04 20:45:46 +000025 procps loginutils shell shellutils sysklogd \
26 textutils util-linux libbb libpwdgrp
Eric Andersenab050f52001-01-27 06:01:43 +000027
Eric Andersenbdfd0d72001-10-24 05:00:29 +000028all: do-it-all
Eric Andersen00814662001-04-26 23:29:10 +000029
Eric Andersenbdfd0d72001-10-24 05:00:29 +000030#
31# Make "config" the default target if there is no configuration file or
32# "depend" the target if there is no top-level dependency information.
33ifeq (.config,$(wildcard .config))
34include .config
35ifeq (.depend,$(wildcard .depend))
36include .depend
Eric Andersen85208e22002-04-12 12:05:57 +000037do-it-all: busybox busybox.links #doc
38include $(patsubst %,%/Makefile.in, $(SUBDIRS))
Eric Andersenbdfd0d72001-10-24 05:00:29 +000039else
40CONFIGURATION = depend
41do-it-all: depend
42endif
43else
44CONFIGURATION = menuconfig
45do-it-all: menuconfig
46endif
Erik Andersen0a704e82000-05-03 03:19:06 +000047
Eric Andersen3cd27602001-10-24 07:58:02 +000048
Eric Andersen85208e22002-04-12 12:05:57 +000049busybox: depend $(libraries-y)
Robert Griebld378c312002-07-19 00:05:54 +000050 $(CC) $(LDFLAGS) -o $@ $(libraries-y) $(LIBRARIES)
Eric Andersen85208e22002-04-12 12:05:57 +000051 $(STRIPCMD) $@
Eric Andersenbdfd0d72001-10-24 05:00:29 +000052
53busybox.links: applets/busybox.mkll
54 - $(SHELL) $^ >$@
55
56install: applets/install.sh busybox busybox.links
57 $(SHELL) $< $(PREFIX)
58
Eric Andersen1f30a412002-04-13 13:39:48 +000059uninstall: busybox busybox.links
60 for i in `cat busybox.links` ; do rm -f $$PREFIX$$i; done
61
Eric Andersenbdfd0d72001-10-24 05:00:29 +000062install-hardlinks: applets/install.sh busybox busybox.links
63 $(SHELL) $< $(PREFIX) --hardlinks
64
65
66# Documentation Targets
Eric Andersen67536ff2000-07-06 22:53:22 +000067doc: olddoc
Eric Andersen53310252000-07-04 19:42:23 +000068
69# Old Docs...
John Beppu94e50542001-04-05 19:42:03 +000070olddoc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
71
Eric Andersen1552ff72001-10-31 11:07:12 +000072docs/busybox.pod : docs/busybox_header.pod include/usage.h docs/busybox_footer.pod
John Beppu94e50542001-04-05 19:42:03 +000073 - ( cat docs/busybox_header.pod; \
Eric Andersen1552ff72001-10-31 11:07:12 +000074 docs/autodocifier.pl include/usage.h; \
John Beppu94e50542001-04-05 19:42:03 +000075 cat docs/busybox_footer.pod ) > docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +000076
Eric Andersen67536ff2000-07-06 22:53:22 +000077docs/BusyBox.txt: docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +000078 @echo
79 @echo BusyBox Documentation
80 @echo
Eric Andersen29be79c2000-12-01 22:57:44 +000081 -mkdir -p docs
Eric Andersen19f86202001-02-17 00:42:47 +000082 -pod2text $< > $@
Eric Andersen53310252000-07-04 19:42:23 +000083
Eric Andersen67536ff2000-07-06 22:53:22 +000084docs/BusyBox.1: docs/busybox.pod
Eric Andersen09a34e52000-12-01 19:40:18 +000085 - mkdir -p docs
Eric Andersen29be79c2000-12-01 22:57:44 +000086 - pod2man --center=BusyBox --release="version $(VERSION)" \
Eric Andersen19f86202001-02-17 00:42:47 +000087 $< > $@
Eric Andersen53310252000-07-04 19:42:23 +000088
Eric Andersen2423b122001-12-08 01:56:15 +000089docs/BusyBox.html: docs/busybox.net/BusyBox.html
Eric Andersen1cf81662001-02-17 15:55:15 +000090 - mkdir -p docs
Eric Andersene2f6e122000-12-01 19:55:04 +000091 -@ rm -f docs/BusyBox.html
Eric Andersen2423b122001-12-08 01:56:15 +000092 -@ ln -s busybox.net/BusyBox.html docs/BusyBox.html
Eric Andersen53310252000-07-04 19:42:23 +000093
Eric Andersen2423b122001-12-08 01:56:15 +000094docs/busybox.net/BusyBox.html: docs/busybox.pod
95 -@ mkdir -p docs/busybox.net
Eric Andersen19f86202001-02-17 00:42:47 +000096 - pod2html --noindex $< > \
Eric Andersen2423b122001-12-08 01:56:15 +000097 docs/busybox.net/BusyBox.html
Eric Andersen36763742001-04-24 21:46:07 +000098 -@ rm -f pod2htm*
Erik Andersen0a704e82000-05-03 03:19:06 +000099
Eric Andersen67536ff2000-07-06 22:53:22 +0000100
101# New docs based on DOCBOOK SGML
Eric Andersen488aac22000-09-24 02:42:48 +0000102newdoc: docs/busybox.txt docs/busybox.pdf docs/busybox/busyboxdocumentation.html
Eric Andersen67536ff2000-07-06 22:53:22 +0000103
104docs/busybox.txt: docs/busybox.sgml
105 @echo
106 @echo BusyBox Documentation
107 @echo
Eric Andersen09a34e52000-12-01 19:40:18 +0000108 - mkdir -p docs
Eric Andersen868c0572000-12-02 00:44:48 +0000109 (cd docs; sgmltools -b txt busybox.sgml)
Eric Andersen67536ff2000-07-06 22:53:22 +0000110
111docs/busybox.dvi: docs/busybox.sgml
Eric Andersen09a34e52000-12-01 19:40:18 +0000112 - mkdir -p docs
Eric Andersen868c0572000-12-02 00:44:48 +0000113 (cd docs; sgmltools -b dvi busybox.sgml)
Eric Andersen67536ff2000-07-06 22:53:22 +0000114
Eric Andersena2c83d82000-07-07 20:52:56 +0000115docs/busybox.ps: docs/busybox.sgml
Eric Andersen09a34e52000-12-01 19:40:18 +0000116 - mkdir -p docs
Eric Andersen868c0572000-12-02 00:44:48 +0000117 (cd docs; sgmltools -b ps busybox.sgml)
Eric Andersen67536ff2000-07-06 22:53:22 +0000118
Eric Andersena2c83d82000-07-07 20:52:56 +0000119docs/busybox.pdf: docs/busybox.ps
Eric Andersen09a34e52000-12-01 19:40:18 +0000120 - mkdir -p docs
Eric Andersen868c0572000-12-02 00:44:48 +0000121 (cd docs; ps2pdf busybox.ps)
Eric Andersen67536ff2000-07-06 22:53:22 +0000122
Eric Andersen488aac22000-09-24 02:42:48 +0000123docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
Eric Andersen09a34e52000-12-01 19:40:18 +0000124 - mkdir -p docs
Eric Andersen2423b122001-12-08 01:56:15 +0000125 (cd docs/busybox.net; sgmltools -b html ../busybox.sgml)
Eric Andersen67536ff2000-07-06 22:53:22 +0000126
Eric Andersen85208e22002-04-12 12:05:57 +0000127
128
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000129# The nifty new buildsystem stuff
Eric Andersen85208e22002-04-12 12:05:57 +0000130$(TOPDIR)scripts/mkdep: scripts/mkdep.c
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000131 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
Eric Andersen67536ff2000-07-06 22:53:22 +0000132
Eric Andersen85208e22002-04-12 12:05:57 +0000133$(TOPDIR)scripts/split-include: scripts/split-include.c
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000134 $(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
Erik Andersen1d1d9502000-04-21 01:26:49 +0000135
Eric Andersen85208e22002-04-12 12:05:57 +0000136$(TOPDIR).depend: $(TOPDIR)scripts/mkdep
137 rm -f .depend .hdepend;
138 mkdir -p $(TOPDIR)include/config;
139 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
140 scripts/mkdep -I $(TOPDIR)include -- \
141 `find $(TOPDIR) -name \*.c -print` >> .depend;
142 scripts/mkdep -I $(TOPDIR)include -- \
143 `find $(TOPDIR) -name \*.h -print` >> .hdepend;
144 $(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)" ;
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000145 @ echo -e "\n\nNow run 'make' to build BusyBox\n\n"
146
Eric Andersen85208e22002-04-12 12:05:57 +0000147depend dep: $(TOPDIR)include/config.h $(TOPDIR).depend
148
Eric Andersen3ec5c692002-03-20 01:32:25 +0000149BB_SHELL := ${shell if [ -x "$$BASH" ]; then echo $$BASH; \
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000150 else if [ -x /bin/bash ]; then echo /bin/bash; \
151 else echo sh; fi ; fi}
152
Eric Andersen85208e22002-04-12 12:05:57 +0000153include/config/MARKER: depend $(TOPDIR)scripts/split-include
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000154 scripts/split-include include/config.h include/config
155 @ touch include/config/MARKER
156
Eric Andersen85208e22002-04-12 12:05:57 +0000157$(TOPDIR)include/config.h:
158 @if [ ! -f $(TOPDIR)include/config.h ] ; then \
Eric Andersen3cd27602001-10-24 07:58:02 +0000159 make oldconfig; \
160 fi;
161
Eric Andersenaba75462002-04-27 00:06:47 +0000162$(TOPDIR).config:
Eric Andersen8610f912002-06-06 13:00:47 +0000163 @if [ ! -f $(TOPDIR).config ] ; then \
164 cp $(TOPDIR)sysdeps/$(TARGET_OS)/defconfig $(TOPDIR).config; \
165 fi;
166
167menuconfig: $(TOPDIR).config
Eric Andersenaba75462002-04-27 00:06:47 +0000168 mkdir -p $(TOPDIR)include/config
169 $(MAKE) -C scripts/lxdialog all
170 $(BB_SHELL) scripts/Menuconfig sysdeps/$(TARGET_OS)/config.in
171
Eric Andersen8610f912002-06-06 13:00:47 +0000172config: $(TOPDIR).config
Eric Andersen85208e22002-04-12 12:05:57 +0000173 mkdir -p $(TOPDIR)include/config
Eric Andersen3ec5c692002-03-20 01:32:25 +0000174 $(BB_SHELL) scripts/Configure sysdeps/$(TARGET_OS)/config.in
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000175
Eric Andersen8610f912002-06-06 13:00:47 +0000176oldconfig: $(TOPDIR).config
Eric Andersen85208e22002-04-12 12:05:57 +0000177 mkdir -p $(TOPDIR)include/config
Eric Andersen3ec5c692002-03-20 01:32:25 +0000178 $(BB_SHELL) scripts/Configure -d sysdeps/$(TARGET_OS)/config.in
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000179
180
181ifdef CONFIGURATION
182..$(CONFIGURATION):
183 @echo
184 @echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'"
185 @echo
186 $(MAKE) $(CONFIGURATION)
187 @echo
188 @echo "Successful. Try re-making (ignore the error that follows)"
189 @echo
190 exit 1
191
192dummy:
193
Eric Andersen0b7d70c2001-08-02 20:56:16 +0000194else
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000195
196dummy:
197
Eric Andersen0b7d70c2001-08-02 20:56:16 +0000198endif
Eric Andersen19f86202001-02-17 00:42:47 +0000199
Eric Andersen85208e22002-04-12 12:05:57 +0000200
201%.o: %.c
202 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
203
Eric Andersen19f86202001-02-17 00:42:47 +0000204
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000205# Testing...
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000206test tests:
Mark Whitleyd2117e92001-03-10 00:51:29 +0000207 # old way of doing it
208 #cd tests && $(MAKE) all
209 # new way of doing it
210 cd tests && ./tester.sh
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000211
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000212# Cleanup
Eric Andersencc8ed391999-10-05 16:24:54 +0000213clean:
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000214 - $(MAKE) -C tests clean
215 - $(MAKE) -C scripts/lxdialog clean
Eric Andersen67536ff2000-07-06 22:53:22 +0000216 - rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
Eric Andersen2423b122001-12-08 01:56:15 +0000217 docs/busybox.net/BusyBox.html
Eric Andersen53310252000-07-04 19:42:23 +0000218 - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
Eric Andersen2423b122001-12-08 01:56:15 +0000219 docs/busybox.pdf docs/busybox.net/busybox.html \
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000220 docs/busybox _install pod2htm* *.gdb *.elf *~ core
Eric Andersen3ec5c692002-03-20 01:32:25 +0000221 - rm -f busybox busybox.links libbb/loop.h .config.old .hdepend
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000222 - rm -f scripts/split-include scripts/mkdep .*config.log
223 - rm -rf include/config include/config.h
Eric Andersen87715172002-07-31 03:45:05 +0000224 - find . -name .\*.flags -exec rm -f {} \;
225 - find . -name .depend -exec rm -f {} \;
226 - find . -name \*.o -exec rm -f {} \;
227 - find . -name \*.a -exec rm -f {} \;
Eric Andersencc8ed391999-10-05 16:24:54 +0000228
229distclean: clean
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000230 - rm -f busybox
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000231 - cd tests && $(MAKE) distclean
Eric Andersencc8ed391999-10-05 16:24:54 +0000232
Erik Andersen0a704e82000-05-03 03:19:06 +0000233dist release: distclean doc
Erik Andersenfac10d72000-02-07 05:29:42 +0000234 cd ..; \
235 rm -rf busybox-$(VERSION); \
236 cp -a busybox busybox-$(VERSION); \
237 \
238 find busybox-$(VERSION)/ -type d \
239 -name CVS \
240 -print \
Eric Andersen53b55ac2001-03-16 07:43:53 +0000241 -exec rm -rf {} \; ; \
Erik Andersenfac10d72000-02-07 05:29:42 +0000242 \
243 find busybox-$(VERSION)/ -type f \
Eric Andersenb0b732b2000-07-06 23:17:16 +0000244 -name .\#* \
245 -print \
Eric Andersen53b55ac2001-03-16 07:43:53 +0000246 -exec rm -f {} \; ; \
Eric Andersenb0b732b2000-07-06 23:17:16 +0000247 \
Erik Andersenfac10d72000-02-07 05:29:42 +0000248 tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000249
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000250
251
Eric Andersen85208e22002-04-12 12:05:57 +0000252.PHONY: tags check depend
253
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000254tags:
255 ctags -R .
Matt Kraai4e05da82001-11-19 19:47:56 +0000256
257check: busybox
258 cd testsuite && ./runtest
Eric Andersen85208e22002-04-12 12:05:57 +0000259