blob: b99bb4f18926d52fa6217c753c4ebaa722d0d4ca [file] [log] [blame]
Eric Andersenc4996011999-10-20 22:08:37 +00001# Makefile for busybox
2#
Eric Andersencb81e642003-07-14 21:21:08 +00003# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
Erik Andersen9ffdaa62000-02-11 21:55:04 +00004#
Eric Andersenc4996011999-10-20 22:08:37 +00005# 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
Eric Andersenc9f20d92002-12-05 08:41:41 +000020#--------------------------------------------------------------
21# You shouldn't need to mess with anything beyond this point...
22#--------------------------------------------------------------
23noconfig_targets := menuconfig config oldconfig randconfig \
24 defconfig allyesconfig allnoconfig clean distclean \
25 release tags
26TOPDIR=./
27include Rules.mak
28
Glenn L McGrath3238ea12003-02-15 10:53:40 +000029DIRS:=applets archival archival/libunarchive coreutils console-tools \
30 debianutils editors findutils init miscutils modutils networking \
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000031 networking/libiproute networking/udhcp procps loginutils shell \
Eric Anderseneac20452003-07-29 07:45:05 +000032 sysklogd util-linux libpwdgrp coreutils/libcoreutils libbb
Eric Andersenab050f52001-01-27 06:01:43 +000033
Eric Andersen9e480452003-07-03 10:07:04 +000034ifeq ($(strip $(CONFIG_SELINUX)),y)
35CFLAGS += -I/usr/include/selinux
36LIBRARIES += -lsecure
37endif
38
Eric Andersen068b6b02002-12-13 22:53:28 +000039ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersen00814662001-04-26 23:29:10 +000040
Eric Andersend4fcb802003-07-15 00:28:26 +000041all: busybox busybox.links doc
Erik Andersen0a704e82000-05-03 03:19:06 +000042
Eric Andersenc9f20d92002-12-05 08:41:41 +000043# In this section, we need .config
44-include .config.cmd
45include $(patsubst %,%/Makefile.in, $(DIRS))
Eric Andersen3cd27602001-10-24 07:58:02 +000046
Eric Andersen1c25ba92003-06-25 05:18:48 +000047busybox: .depend include/config.h $(libraries-y)
Robert Griebld378c312002-07-19 00:05:54 +000048 $(CC) $(LDFLAGS) -o $@ $(libraries-y) $(LIBRARIES)
Eric Andersen85208e22002-04-12 12:05:57 +000049 $(STRIPCMD) $@
Eric Andersenbdfd0d72001-10-24 05:00:29 +000050
Eric Andersenb6071ea2003-06-25 03:26:04 +000051busybox.links: applets/busybox.mkll include/config.h
Eric Andersenbdfd0d72001-10-24 05:00:29 +000052 - $(SHELL) $^ >$@
53
54install: applets/install.sh busybox busybox.links
55 $(SHELL) $< $(PREFIX)
56
Glenn L McGrath87470de2003-08-29 12:20:31 +000057uninstall: busybox.links
58 rm -f $(PREFIX)/bin/busybox
59 for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
Eric Andersen1f30a412002-04-13 13:39:48 +000060
Eric Andersenbdfd0d72001-10-24 05:00:29 +000061install-hardlinks: applets/install.sh busybox busybox.links
62 $(SHELL) $< $(PREFIX) --hardlinks
63
64
65# Documentation Targets
Eric Andersen67536ff2000-07-06 22:53:22 +000066doc: olddoc
Eric Andersen53310252000-07-04 19:42:23 +000067
68# Old Docs...
John Beppu94e50542001-04-05 19:42:03 +000069olddoc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
70
Eric Andersen1552ff72001-10-31 11:07:12 +000071docs/busybox.pod : docs/busybox_header.pod include/usage.h docs/busybox_footer.pod
John Beppu94e50542001-04-05 19:42:03 +000072 - ( cat docs/busybox_header.pod; \
Eric Andersen1552ff72001-10-31 11:07:12 +000073 docs/autodocifier.pl include/usage.h; \
John Beppu94e50542001-04-05 19:42:03 +000074 cat docs/busybox_footer.pod ) > docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +000075
Eric Andersen67536ff2000-07-06 22:53:22 +000076docs/BusyBox.txt: docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +000077 @echo
78 @echo BusyBox Documentation
79 @echo
Eric Andersen29be79c2000-12-01 22:57:44 +000080 -mkdir -p docs
Eric Andersen19f86202001-02-17 00:42:47 +000081 -pod2text $< > $@
Eric Andersen53310252000-07-04 19:42:23 +000082
Eric Andersen67536ff2000-07-06 22:53:22 +000083docs/BusyBox.1: docs/busybox.pod
Eric Andersen09a34e52000-12-01 19:40:18 +000084 - mkdir -p docs
Eric Andersen29be79c2000-12-01 22:57:44 +000085 - pod2man --center=BusyBox --release="version $(VERSION)" \
Eric Andersen19f86202001-02-17 00:42:47 +000086 $< > $@
Eric Andersen53310252000-07-04 19:42:23 +000087
Eric Andersen2423b122001-12-08 01:56:15 +000088docs/BusyBox.html: docs/busybox.net/BusyBox.html
Eric Andersen1cf81662001-02-17 15:55:15 +000089 - mkdir -p docs
Eric Andersene2f6e122000-12-01 19:55:04 +000090 -@ rm -f docs/BusyBox.html
Eric Andersen2423b122001-12-08 01:56:15 +000091 -@ ln -s busybox.net/BusyBox.html docs/BusyBox.html
Eric Andersen53310252000-07-04 19:42:23 +000092
Eric Andersen2423b122001-12-08 01:56:15 +000093docs/busybox.net/BusyBox.html: docs/busybox.pod
94 -@ mkdir -p docs/busybox.net
Eric Andersen19f86202001-02-17 00:42:47 +000095 - pod2html --noindex $< > \
Eric Andersen2423b122001-12-08 01:56:15 +000096 docs/busybox.net/BusyBox.html
Eric Andersen36763742001-04-24 21:46:07 +000097 -@ rm -f pod2htm*
Erik Andersen0a704e82000-05-03 03:19:06 +000098
Eric Andersen67536ff2000-07-06 22:53:22 +000099
100# New docs based on DOCBOOK SGML
Eric Andersen488aac22000-09-24 02:42:48 +0000101newdoc: docs/busybox.txt docs/busybox.pdf docs/busybox/busyboxdocumentation.html
Eric Andersen67536ff2000-07-06 22:53:22 +0000102
103docs/busybox.txt: docs/busybox.sgml
104 @echo
105 @echo BusyBox Documentation
106 @echo
Eric Andersen09a34e52000-12-01 19:40:18 +0000107 - mkdir -p docs
Eric Andersen868c0572000-12-02 00:44:48 +0000108 (cd docs; sgmltools -b txt busybox.sgml)
Eric Andersen67536ff2000-07-06 22:53:22 +0000109
110docs/busybox.dvi: docs/busybox.sgml
Eric Andersen09a34e52000-12-01 19:40:18 +0000111 - mkdir -p docs
Eric Andersen868c0572000-12-02 00:44:48 +0000112 (cd docs; sgmltools -b dvi busybox.sgml)
Eric Andersen67536ff2000-07-06 22:53:22 +0000113
Eric Andersena2c83d82000-07-07 20:52:56 +0000114docs/busybox.ps: docs/busybox.sgml
Eric Andersen09a34e52000-12-01 19:40:18 +0000115 - mkdir -p docs
Eric Andersen868c0572000-12-02 00:44:48 +0000116 (cd docs; sgmltools -b ps busybox.sgml)
Eric Andersen67536ff2000-07-06 22:53:22 +0000117
Eric Andersena2c83d82000-07-07 20:52:56 +0000118docs/busybox.pdf: docs/busybox.ps
Eric Andersen09a34e52000-12-01 19:40:18 +0000119 - mkdir -p docs
Eric Andersen868c0572000-12-02 00:44:48 +0000120 (cd docs; ps2pdf busybox.ps)
Eric Andersen67536ff2000-07-06 22:53:22 +0000121
Eric Andersen488aac22000-09-24 02:42:48 +0000122docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
Eric Andersen09a34e52000-12-01 19:40:18 +0000123 - mkdir -p docs
Eric Andersen2423b122001-12-08 01:56:15 +0000124 (cd docs/busybox.net; sgmltools -b html ../busybox.sgml)
Eric Andersen67536ff2000-07-06 22:53:22 +0000125
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000126# The nifty new buildsystem stuff
Eric Andersenc9f20d92002-12-05 08:41:41 +0000127scripts/mkdep: scripts/mkdep.c
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000128 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
Eric Andersen67536ff2000-07-06 22:53:22 +0000129
Eric Andersenc9f20d92002-12-05 08:41:41 +0000130scripts/split-include: scripts/split-include.c
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000131 $(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
Erik Andersen1d1d9502000-04-21 01:26:49 +0000132
Eric Andersenc9f20d92002-12-05 08:41:41 +0000133.depend: scripts/mkdep
Eric Andersen85208e22002-04-12 12:05:57 +0000134 rm -f .depend .hdepend;
Eric Andersenc9f20d92002-12-05 08:41:41 +0000135 mkdir -p include/config;
Eric Andersen85208e22002-04-12 12:05:57 +0000136 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
Eric Andersenc9f20d92002-12-05 08:41:41 +0000137 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)" ;
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000142
Eric Andersenaaab46b2003-01-11 18:02:51 +0000143depend dep: include/config.h .depend
Eric Andersen85208e22002-04-12 12:05:57 +0000144
Eric Andersenc9f20d92002-12-05 08:41:41 +0000145include/config/MARKER: depend scripts/split-include
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000146 scripts/split-include include/config.h include/config
147 @ touch include/config/MARKER
148
Eric Andersenc9f20d92002-12-05 08:41:41 +0000149include/config.h: .config
150 @if [ ! -x ./scripts/config/conf ] ; then \
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000151 $(MAKE) -C scripts/config conf; \
Eric Andersen3cd27602001-10-24 07:58:02 +0000152 fi;
Eric Andersenc9f20d92002-12-05 08:41:41 +0000153 @./scripts/config/conf -o sysdeps/$(TARGET_OS)/Config.in
Eric Andersen85208e22002-04-12 12:05:57 +0000154
155%.o: %.c
156 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
157
Eric Andersenc9f20d92002-12-05 08:41:41 +0000158finished2:
159 @echo
160 @echo Finished installing...
161 @echo
Eric Andersen19f86202001-02-17 00:42:47 +0000162
Eric Andersen068b6b02002-12-13 22:53:28 +0000163else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000164
165all: menuconfig
166
Eric Andersenc9f20d92002-12-05 08:41:41 +0000167# configuration
168# ---------------------------------------------------------------------------
169
Eric Andersen068b6b02002-12-13 22:53:28 +0000170scripts/config/conf:
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000171 $(MAKE) -C scripts/config conf
Eric Andersen068b6b02002-12-13 22:53:28 +0000172 -@if [ ! -f .config ] ; then \
173 cp sysdeps/$(TARGET_OS)/defconfig .config; \
174 fi
175scripts/config/mconf:
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000176 $(MAKE) -C scripts/config ncurses conf mconf
Eric Andersenc9f20d92002-12-05 08:41:41 +0000177 -@if [ ! -f .config ] ; then \
178 cp sysdeps/$(TARGET_OS)/defconfig .config; \
179 fi
180
181menuconfig: scripts/config/mconf
182 @./scripts/config/mconf sysdeps/$(TARGET_OS)/Config.in
183
184config: scripts/config/conf
185 @./scripts/config/conf sysdeps/$(TARGET_OS)/Config.in
186
187oldconfig: scripts/config/conf
188 @./scripts/config/conf -o sysdeps/$(TARGET_OS)/Config.in
189
190randconfig: scripts/config/conf
191 @./scripts/config/conf -r sysdeps/$(TARGET_OS)/Config.in
192
193allyesconfig: scripts/config/conf
194 @./scripts/config/conf -y sysdeps/$(TARGET_OS)/Config.in
195
196allnoconfig: scripts/config/conf
197 @./scripts/config/conf -n sysdeps/$(TARGET_OS)/Config.in
198
199defconfig: scripts/config/conf
200 @./scripts/config/conf -d sysdeps/$(TARGET_OS)/Config.in
201
202test tests: busybox
203 # Note that 'tests' is depricated. Use 'make check' instead
204 # To use the nice new testsuite....
Mark Whitleyd2117e92001-03-10 00:51:29 +0000205 cd tests && ./tester.sh
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000206
Eric Andersenc9f20d92002-12-05 08:41:41 +0000207check: busybox
208 cd testsuite && ./runtest
209
Eric Andersencc8ed391999-10-05 16:24:54 +0000210clean:
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000211 - $(MAKE) -C tests clean
Eric Andersen53310252000-07-04 19:42:23 +0000212 - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
Eric Andersena39342b2002-10-08 19:31:04 +0000213 docs/busybox.pdf docs/busybox.pod docs/busybox.net/busybox.html \
Eric Andersen24e098a2003-08-22 20:53:38 +0000214 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
Eric Andersen87715172002-07-31 03:45:05 +0000219 - find . -name .\*.flags -exec rm -f {} \;
Eric Andersen87715172002-07-31 03:45:05 +0000220 - find . -name \*.o -exec rm -f {} \;
221 - find . -name \*.a -exec rm -f {} \;
Eric Andersencc8ed391999-10-05 16:24:54 +0000222
223distclean: clean
Eric Andersena9953432003-01-27 22:11:59 +0000224 - rm -f scripts/split-include scripts/mkdep
225 - rm -rf include/config include/config.h
226 - find . -name .depend -exec rm -f {} \;
Eric Andersenc9f20d92002-12-05 08:41:41 +0000227 rm -f .config .config.old .config.cmd
Eric Andersena9953432003-01-27 22:11:59 +0000228 - $(MAKE) -C scripts/config clean
Eric Andersencc8ed391999-10-05 16:24:54 +0000229
Eric Andersenc9f20d92002-12-05 08:41:41 +0000230release: distclean #doc
Erik Andersenfac10d72000-02-07 05:29:42 +0000231 cd ..; \
232 rm -rf busybox-$(VERSION); \
233 cp -a busybox busybox-$(VERSION); \
234 \
235 find busybox-$(VERSION)/ -type d \
236 -name CVS \
237 -print \
Eric Andersen53b55ac2001-03-16 07:43:53 +0000238 -exec rm -rf {} \; ; \
Erik Andersenfac10d72000-02-07 05:29:42 +0000239 \
240 find busybox-$(VERSION)/ -type f \
Eric Andersenb0b732b2000-07-06 23:17:16 +0000241 -name .\#* \
242 -print \
Eric Andersen53b55ac2001-03-16 07:43:53 +0000243 -exec rm -f {} \; ; \
Eric Andersenb0b732b2000-07-06 23:17:16 +0000244 \
Erik Andersenfac10d72000-02-07 05:29:42 +0000245 tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000246
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000247tags:
248 ctags -R .
Matt Kraai4e05da82001-11-19 19:47:56 +0000249
Eric Andersenc9f20d92002-12-05 08:41:41 +0000250
Eric Andersen068b6b02002-12-13 22:53:28 +0000251endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000252
253.PHONY: dummy subdirs release distclean clean config oldconfig \
254 menuconfig tags check test tests depend
255
Eric Andersen85208e22002-04-12 12:05:57 +0000256