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