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 pwd_grp pwd_grp/libpwd_grp shell shellutils sysklogd \
26 textutils util-linux libbb
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 install-hardlinks: applets/install.sh busybox busybox.links
60 $(SHELL) $< $(PREFIX) --hardlinks
63 # Documentation Targets
67 olddoc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
69 docs/busybox.pod : docs/busybox_header.pod include/usage.h docs/busybox_footer.pod
70 - ( cat docs/busybox_header.pod; \
71 docs/autodocifier.pl include/usage.h; \
72 cat docs/busybox_footer.pod ) > docs/busybox.pod
74 docs/BusyBox.txt: docs/busybox.pod
76 @echo BusyBox Documentation
81 docs/BusyBox.1: docs/busybox.pod
83 - pod2man --center=BusyBox --release="version $(VERSION)" \
86 docs/BusyBox.html: docs/busybox.net/BusyBox.html
88 -@ rm -f docs/BusyBox.html
89 -@ ln -s busybox.net/BusyBox.html docs/BusyBox.html
91 docs/busybox.net/BusyBox.html: docs/busybox.pod
92 -@ mkdir -p docs/busybox.net
93 - pod2html --noindex $< > \
94 docs/busybox.net/BusyBox.html
98 # New docs based on DOCBOOK SGML
99 newdoc: docs/busybox.txt docs/busybox.pdf docs/busybox/busyboxdocumentation.html
101 docs/busybox.txt: docs/busybox.sgml
103 @echo BusyBox Documentation
106 (cd docs; sgmltools -b txt busybox.sgml)
108 docs/busybox.dvi: docs/busybox.sgml
110 (cd docs; sgmltools -b dvi busybox.sgml)
112 docs/busybox.ps: docs/busybox.sgml
114 (cd docs; sgmltools -b ps busybox.sgml)
116 docs/busybox.pdf: docs/busybox.ps
118 (cd docs; ps2pdf busybox.ps)
120 docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
122 (cd docs/busybox.net; sgmltools -b html ../busybox.sgml)
126 # The nifty new buildsystem stuff
127 $(TOPDIR)scripts/mkdep: scripts/mkdep.c
128 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
130 $(TOPDIR)scripts/split-include: scripts/split-include.c
131 $(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
133 $(TOPDIR).depend: $(TOPDIR)scripts/mkdep
134 rm -f .depend .hdepend;
135 mkdir -p $(TOPDIR)include/config;
136 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
137 scripts/mkdep -I $(TOPDIR)include -- \
138 `find $(TOPDIR) -name \*.c -print` >> .depend;
139 scripts/mkdep -I $(TOPDIR)include -- \
140 `find $(TOPDIR) -name \*.h -print` >> .hdepend;
141 $(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)" ;
142 @ echo -e "\n\nNow run 'make' to build BusyBox\n\n"
144 depend dep: $(TOPDIR)include/config.h $(TOPDIR).depend
146 BB_SHELL := ${shell if [ -x "$$BASH" ]; then echo $$BASH; \
147 else if [ -x /bin/bash ]; then echo /bin/bash; \
148 else echo sh; fi ; fi}
150 include/config/MARKER: depend $(TOPDIR)scripts/split-include
151 scripts/split-include include/config.h include/config
152 @ touch include/config/MARKER
154 $(TOPDIR)include/config.h:
155 @if [ ! -f $(TOPDIR)include/config.h ] ; then \
160 mkdir -p $(TOPDIR)include/config
161 $(MAKE) -C scripts/lxdialog all
162 $(BB_SHELL) scripts/Menuconfig sysdeps/$(TARGET_OS)/config.in
165 mkdir -p $(TOPDIR)include/config
166 $(BB_SHELL) scripts/Configure sysdeps/$(TARGET_OS)/config.in
169 mkdir -p $(TOPDIR)include/config
170 $(BB_SHELL) scripts/Configure -d sysdeps/$(TARGET_OS)/config.in
176 @echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'"
178 $(MAKE) $(CONFIGURATION)
180 @echo "Successful. Try re-making (ignore the error that follows)"
194 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
199 # old way of doing it
200 #cd tests && $(MAKE) all
201 # new way of doing it
202 cd tests && ./tester.sh
206 - $(MAKE) -C tests clean
207 - $(MAKE) -C scripts/lxdialog clean
208 - rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
209 docs/busybox.net/BusyBox.html
210 - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
211 docs/busybox.pdf docs/busybox.net/busybox.html \
212 docs/busybox _install pod2htm* *.gdb *.elf *~ core
213 - rm -f busybox busybox.links libbb/loop.h .config.old .hdepend
214 - rm -f scripts/split-include scripts/mkdep .*config.log
215 - rm -rf include/config include/config.h
216 - find -name .\*.flags -o -name .depend -exec rm -f {} \;
217 - find -name \*.o -exec rm -f {} \;
218 - find -name \*.a -exec rm -f {} \;
222 - cd tests && $(MAKE) distclean
224 dist release: distclean doc
226 rm -rf busybox-$(VERSION); \
227 cp -a busybox busybox-$(VERSION); \
229 find busybox-$(VERSION)/ -type d \
232 -exec rm -rf {} \; ; \
234 find busybox-$(VERSION)/ -type f \
237 -exec rm -f {} \; ; \
239 tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
243 .PHONY: tags check depend
249 cd testsuite && ./runtest