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