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