Yet another major rework of the BusyBox config system, using the considerably
[oweals/busybox.git] / Makefile
1 # Makefile for busybox
2 #
3 # Copyright (C) 1999-2002 Erik Andersen <andersee@debian.org>
4 #
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.
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
20 #--------------------------------------------------------------
21 # You shouldn't need to mess with anything beyond this point...
22 #--------------------------------------------------------------
23 noconfig_targets := menuconfig config oldconfig randconfig \
24         defconfig allyesconfig allnoconfig clean distclean \
25         release tags
26 TOPDIR=./
27 include Rules.mak
28
29 DIRS:=applets archival archival/libunarchive console-tools debianutils \
30         editors fileutils findutils init miscutils modutils networking \
31         networking/libiproute networking/udhcp procps loginutils shell \
32         shellutils sysklogd textutils util-linux libbb libpwdgrp
33
34 ifdef include_config
35
36 all: busybox busybox.links #doc
37
38 # In this section, we need .config
39 -include .config.cmd
40 include $(patsubst %,%/Makefile.in, $(DIRS))
41
42 busybox: depend $(libraries-y)
43         $(CC) $(LDFLAGS) -o $@ $(libraries-y) $(LIBRARIES)
44         $(STRIPCMD) $@
45
46 busybox.links: applets/busybox.mkll
47         - $(SHELL) $^ >$@
48
49 install: applets/install.sh busybox busybox.links
50         $(SHELL) $< $(PREFIX)
51
52 uninstall: busybox busybox.links
53         for i in `cat busybox.links` ; do rm -f $$PREFIX$$i; done
54
55 install-hardlinks: applets/install.sh busybox busybox.links
56         $(SHELL) $< $(PREFIX) --hardlinks
57
58
59 # Documentation Targets
60 doc: olddoc
61
62 # Old Docs...
63 olddoc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
64
65 docs/busybox.pod : docs/busybox_header.pod include/usage.h docs/busybox_footer.pod
66         - ( cat docs/busybox_header.pod; \
67             docs/autodocifier.pl include/usage.h; \
68             cat docs/busybox_footer.pod ) > docs/busybox.pod
69
70 docs/BusyBox.txt: docs/busybox.pod
71         @echo
72         @echo BusyBox Documentation
73         @echo
74         -mkdir -p docs
75         -pod2text $< > $@
76
77 docs/BusyBox.1: docs/busybox.pod
78         - mkdir -p docs
79         - pod2man --center=BusyBox --release="version $(VERSION)" \
80                 $< > $@
81
82 docs/BusyBox.html: docs/busybox.net/BusyBox.html
83         - mkdir -p docs
84         -@ rm -f docs/BusyBox.html
85         -@ ln -s busybox.net/BusyBox.html docs/BusyBox.html
86
87 docs/busybox.net/BusyBox.html: docs/busybox.pod
88         -@ mkdir -p docs/busybox.net
89         -  pod2html --noindex $< > \
90             docs/busybox.net/BusyBox.html
91         -@ rm -f pod2htm*
92
93
94 # New docs based on DOCBOOK SGML
95 newdoc: docs/busybox.txt docs/busybox.pdf docs/busybox/busyboxdocumentation.html
96
97 docs/busybox.txt: docs/busybox.sgml
98         @echo
99         @echo BusyBox Documentation
100         @echo
101         - mkdir -p docs
102         (cd docs; sgmltools -b txt busybox.sgml)
103
104 docs/busybox.dvi: docs/busybox.sgml
105         - mkdir -p docs
106         (cd docs; sgmltools -b dvi busybox.sgml)
107
108 docs/busybox.ps: docs/busybox.sgml
109         - mkdir -p docs
110         (cd docs; sgmltools -b ps busybox.sgml)
111
112 docs/busybox.pdf: docs/busybox.ps
113         - mkdir -p docs
114         (cd docs; ps2pdf busybox.ps)
115
116 docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
117         - mkdir -p docs
118         (cd docs/busybox.net; sgmltools -b html ../busybox.sgml)
119
120 # The nifty new buildsystem stuff
121 scripts/mkdep: scripts/mkdep.c
122         $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
123
124 scripts/split-include: scripts/split-include.c
125         $(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
126
127 .depend: scripts/mkdep
128         rm -f .depend .hdepend;
129         mkdir -p include/config;
130         $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
131         scripts/mkdep -I include -- \
132                 `find . -name \*.c -print` >> .depend;
133         scripts/mkdep -I include -- \
134                 `find . -name \*.h -print` >> .hdepend;
135         $(MAKE) $(patsubst %,_sfdep_%,$(DIRS)) _FASTDEP_ALL_SUB_DIRS="$(DIRS)" ;
136
137 depend dep: include/config.h .depend
138
139 include/config/MARKER: depend scripts/split-include
140         scripts/split-include include/config.h include/config
141         @ touch include/config/MARKER
142
143 include/config.h: .config
144         @if [ ! -x ./scripts/config/conf ] ; then \
145             make -C scripts/config; \
146         fi;
147         @./scripts/config/conf -o sysdeps/$(TARGET_OS)/Config.in
148
149 %.o: %.c
150         $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
151
152 finished2:
153         @echo
154         @echo Finished installing...
155         @echo
156
157 else # ifdef include_config
158
159 all: menuconfig
160
161 ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
162 # Targets which don't need .config
163
164 # configuration
165 # ---------------------------------------------------------------------------
166
167 scripts/config/conf scripts/config/mconf:
168         make -C scripts/config
169         -@if [ ! -f .config ] ; then \
170                 cp sysdeps/$(TARGET_OS)/defconfig .config; \
171         fi
172
173 menuconfig: scripts/config/mconf
174         @./scripts/config/mconf sysdeps/$(TARGET_OS)/Config.in
175
176 config: scripts/config/conf
177         @./scripts/config/conf sysdeps/$(TARGET_OS)/Config.in
178
179 oldconfig: scripts/config/conf
180         @./scripts/config/conf -o sysdeps/$(TARGET_OS)/Config.in
181
182 randconfig: scripts/config/conf
183         @./scripts/config/conf -r sysdeps/$(TARGET_OS)/Config.in
184
185 allyesconfig: scripts/config/conf
186         @./scripts/config/conf -y sysdeps/$(TARGET_OS)/Config.in
187
188 allnoconfig: scripts/config/conf
189         @./scripts/config/conf -n sysdeps/$(TARGET_OS)/Config.in
190
191 defconfig: scripts/config/conf
192         @./scripts/config/conf -d sysdeps/$(TARGET_OS)/Config.in
193
194 test tests: busybox
195         # Note that 'tests' is depricated.  Use 'make check' instead
196         # To use the nice new testsuite....
197         cd tests && ./tester.sh
198
199 check: busybox
200         cd testsuite && ./runtest
201
202 clean:
203         - $(MAKE) -C tests clean
204         - $(MAKE) -C scripts/lxdialog clean
205         - rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
206             docs/busybox.net/BusyBox.html
207         - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
208             docs/busybox.pdf docs/busybox.pod docs/busybox.net/busybox.html \
209             docs/busybox _install pod2htm* *.gdb *.elf *~ core
210         - rm -f busybox busybox.links libbb/loop.h .config.old .hdepend
211         - rm -f scripts/split-include scripts/mkdep .*config.log
212         - rm -rf include/config include/config.h
213         - find . -name .\*.flags -exec rm -f {} \;   
214         - find . -name .depend -exec rm -f {} \;
215         - find . -name \*.o -exec rm -f {} \;
216         - find . -name \*.a -exec rm -f {} \;
217
218 distclean: clean
219         rm -f .config .config.old .config.cmd
220
221 release: distclean #doc
222         cd ..;                                  \
223         rm -rf busybox-$(VERSION);              \
224         cp -a busybox busybox-$(VERSION);       \
225                                                 \
226         find busybox-$(VERSION)/ -type d        \
227                                  -name CVS      \
228                                  -print         \
229                 -exec rm -rf {} \; ;            \
230                                                 \
231         find busybox-$(VERSION)/ -type f        \
232                                  -name .\#*     \
233                                  -print         \
234                 -exec rm -f {} \;  ;            \
235                                                 \
236         tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
237
238 tags:
239         ctags -R .
240
241
242 endif # ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
243 endif # ifdef include_config
244
245 .PHONY: dummy subdirs release distclean clean config oldconfig \
246         menuconfig tags check test tests depend
247
248