3 # Copyright (C) 1999-2002 Erik Andersen <andersee@debian.org>
5 # 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.
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.
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
20 TOPDIR:= $(shell /bin/pwd)/
21 include $(TOPDIR).config
22 include $(TOPDIR)Rules.mak
23 SUBDIRS:=applets archival archival/libunarchive console-tools \
24 editors fileutils findutils init miscutils modutils networking \
25 procps loginutils shell shellutils sysklogd \
26 textutils util-linux libbb libpwdgrp
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.
33 ifeq (.config,$(wildcard .config))
35 ifeq (.depend,$(wildcard .depend))
37 do-it-all: busybox busybox.links #doc
38 include $(patsubst %,%/Makefile.in, $(SUBDIRS))
40 CONFIGURATION = depend
44 CONFIGURATION = menuconfig
49 busybox: depend $(libraries-y)
50 $(CC) $(LDFLAGS) $(libraries-y) $(LIBRARIES) -o $@
53 busybox.links: applets/busybox.mkll
56 install: applets/install.sh busybox busybox.links
59 uninstall: busybox busybox.links
60 for i in `cat busybox.links` ; do rm -f $$PREFIX$$i; done
62 install-hardlinks: applets/install.sh busybox busybox.links
63 $(SHELL) $< $(PREFIX) --hardlinks
66 # Documentation Targets
70 olddoc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
72 docs/busybox.pod : docs/busybox_header.pod include/usage.h docs/busybox_footer.pod
73 - ( cat docs/busybox_header.pod; \
74 docs/autodocifier.pl include/usage.h; \
75 cat docs/busybox_footer.pod ) > docs/busybox.pod
77 docs/BusyBox.txt: docs/busybox.pod
79 @echo BusyBox Documentation
84 docs/BusyBox.1: docs/busybox.pod
86 - pod2man --center=BusyBox --release="version $(VERSION)" \
89 docs/BusyBox.html: docs/busybox.net/BusyBox.html
91 -@ rm -f docs/BusyBox.html
92 -@ ln -s busybox.net/BusyBox.html docs/BusyBox.html
94 docs/busybox.net/BusyBox.html: docs/busybox.pod
95 -@ mkdir -p docs/busybox.net
96 - pod2html --noindex $< > \
97 docs/busybox.net/BusyBox.html
101 # New docs based on DOCBOOK SGML
102 newdoc: docs/busybox.txt docs/busybox.pdf docs/busybox/busyboxdocumentation.html
104 docs/busybox.txt: docs/busybox.sgml
106 @echo BusyBox Documentation
109 (cd docs; sgmltools -b txt busybox.sgml)
111 docs/busybox.dvi: docs/busybox.sgml
113 (cd docs; sgmltools -b dvi busybox.sgml)
115 docs/busybox.ps: docs/busybox.sgml
117 (cd docs; sgmltools -b ps busybox.sgml)
119 docs/busybox.pdf: docs/busybox.ps
121 (cd docs; ps2pdf busybox.ps)
123 docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
125 (cd docs/busybox.net; sgmltools -b html ../busybox.sgml)
129 # The nifty new buildsystem stuff
130 $(TOPDIR)scripts/mkdep: scripts/mkdep.c
131 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
133 $(TOPDIR)scripts/split-include: scripts/split-include.c
134 $(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
136 $(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)" ;
145 @ echo -e "\n\nNow run 'make' to build BusyBox\n\n"
147 depend dep: $(TOPDIR)include/config.h $(TOPDIR).depend
149 BB_SHELL := ${shell if [ -x "$$BASH" ]; then echo $$BASH; \
150 else if [ -x /bin/bash ]; then echo /bin/bash; \
151 else echo sh; fi ; fi}
153 include/config/MARKER: depend $(TOPDIR)scripts/split-include
154 scripts/split-include include/config.h include/config
155 @ touch include/config/MARKER
157 $(TOPDIR)include/config.h:
158 @if [ ! -f $(TOPDIR)include/config.h ] ; then \
163 @if [ ! -f $(TOPDIR).config ] ; then \
164 cp $(TOPDIR)sysdeps/$(TARGET_OS)/defconfig $(TOPDIR).config; \
167 menuconfig: $(TOPDIR).config
168 mkdir -p $(TOPDIR)include/config
169 $(MAKE) -C scripts/lxdialog all
170 $(BB_SHELL) scripts/Menuconfig sysdeps/$(TARGET_OS)/config.in
172 config: $(TOPDIR).config
173 mkdir -p $(TOPDIR)include/config
174 $(BB_SHELL) scripts/Configure sysdeps/$(TARGET_OS)/config.in
176 oldconfig: $(TOPDIR).config
177 mkdir -p $(TOPDIR)include/config
178 $(BB_SHELL) scripts/Configure -d sysdeps/$(TARGET_OS)/config.in
184 @echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'"
186 $(MAKE) $(CONFIGURATION)
188 @echo "Successful. Try re-making (ignore the error that follows)"
202 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
207 # old way of doing it
208 #cd tests && $(MAKE) all
209 # new way of doing it
210 cd tests && ./tester.sh
214 - $(MAKE) -C tests clean
215 - $(MAKE) -C scripts/lxdialog clean
216 - rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
217 docs/busybox.net/BusyBox.html
218 - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
219 docs/busybox.pdf docs/busybox.net/busybox.html \
220 docs/busybox _install pod2htm* *.gdb *.elf *~ core
221 - rm -f busybox busybox.links libbb/loop.h .config.old .hdepend
222 - rm -f scripts/split-include scripts/mkdep .*config.log
223 - rm -rf include/config include/config.h
224 - 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 {} \;
231 - cd tests && $(MAKE) distclean
233 dist release: distclean doc
235 rm -rf busybox-$(VERSION); \
236 cp -a busybox busybox-$(VERSION); \
238 find busybox-$(VERSION)/ -type d \
241 -exec rm -rf {} \; ; \
243 find busybox-$(VERSION)/ -type f \
246 -exec rm -f {} \; ; \
248 tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
252 .PHONY: tags check depend
258 cd testsuite && ./runtest