blob: d38c2c35b00fc53a84ff64c3fdff58ae513b3524 [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
Glenn L McGrath6376b582003-09-24 15:48:29 +000039CONFIG_CONFIG_IN = sysdeps/$(TARGET_OS)/Config.in
40CONFIG_DEFCONFIG = sysdeps/$(TARGET_OS)/defconfig
41
Eric Andersen068b6b02002-12-13 22:53:28 +000042ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersen00814662001-04-26 23:29:10 +000043
Eric Andersend4fcb802003-07-15 00:28:26 +000044all: busybox busybox.links doc
Erik Andersen0a704e82000-05-03 03:19:06 +000045
Eric Andersenc9f20d92002-12-05 08:41:41 +000046# In this section, we need .config
47-include .config.cmd
48include $(patsubst %,%/Makefile.in, $(DIRS))
Eric Andersen3cd27602001-10-24 07:58:02 +000049
Eric Andersen1c25ba92003-06-25 05:18:48 +000050busybox: .depend include/config.h $(libraries-y)
Glenn L McGrathd72e34c2003-09-20 00:59:35 +000051 $(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
Eric Andersen85208e22002-04-12 12:05:57 +000052 $(STRIPCMD) $@
Eric Andersenbdfd0d72001-10-24 05:00:29 +000053
Eric Andersenb6071ea2003-06-25 03:26:04 +000054busybox.links: applets/busybox.mkll include/config.h
Eric Andersenbdfd0d72001-10-24 05:00:29 +000055 - $(SHELL) $^ >$@
56
57install: applets/install.sh busybox busybox.links
58 $(SHELL) $< $(PREFIX)
59
Glenn L McGrath87470de2003-08-29 12:20:31 +000060uninstall: busybox.links
61 rm -f $(PREFIX)/bin/busybox
62 for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
Eric Andersen1f30a412002-04-13 13:39:48 +000063
Eric Andersenbdfd0d72001-10-24 05:00:29 +000064install-hardlinks: applets/install.sh busybox busybox.links
65 $(SHELL) $< $(PREFIX) --hardlinks
66
67
68# Documentation Targets
Eric Andersen67536ff2000-07-06 22:53:22 +000069doc: olddoc
Eric Andersen53310252000-07-04 19:42:23 +000070
71# Old Docs...
John Beppu94e50542001-04-05 19:42:03 +000072olddoc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
73
Eric Andersen1552ff72001-10-31 11:07:12 +000074docs/busybox.pod : docs/busybox_header.pod include/usage.h docs/busybox_footer.pod
John Beppu94e50542001-04-05 19:42:03 +000075 - ( cat docs/busybox_header.pod; \
Eric Andersen1552ff72001-10-31 11:07:12 +000076 docs/autodocifier.pl include/usage.h; \
John Beppu94e50542001-04-05 19:42:03 +000077 cat docs/busybox_footer.pod ) > docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +000078
Eric Andersen67536ff2000-07-06 22:53:22 +000079docs/BusyBox.txt: docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +000080 @echo
81 @echo BusyBox Documentation
82 @echo
Eric Andersen29be79c2000-12-01 22:57:44 +000083 -mkdir -p docs
Eric Andersen19f86202001-02-17 00:42:47 +000084 -pod2text $< > $@
Eric Andersen53310252000-07-04 19:42:23 +000085
Eric Andersen67536ff2000-07-06 22:53:22 +000086docs/BusyBox.1: docs/busybox.pod
Eric Andersen09a34e52000-12-01 19:40:18 +000087 - mkdir -p docs
Eric Andersen29be79c2000-12-01 22:57:44 +000088 - pod2man --center=BusyBox --release="version $(VERSION)" \
Eric Andersen19f86202001-02-17 00:42:47 +000089 $< > $@
Eric Andersen53310252000-07-04 19:42:23 +000090
Eric Andersen2423b122001-12-08 01:56:15 +000091docs/BusyBox.html: docs/busybox.net/BusyBox.html
Eric Andersen1cf81662001-02-17 15:55:15 +000092 - mkdir -p docs
Eric Andersene2f6e122000-12-01 19:55:04 +000093 -@ rm -f docs/BusyBox.html
Eric Andersen2423b122001-12-08 01:56:15 +000094 -@ ln -s busybox.net/BusyBox.html docs/BusyBox.html
Eric Andersen53310252000-07-04 19:42:23 +000095
Eric Andersen2423b122001-12-08 01:56:15 +000096docs/busybox.net/BusyBox.html: docs/busybox.pod
97 -@ mkdir -p docs/busybox.net
Eric Andersen19f86202001-02-17 00:42:47 +000098 - pod2html --noindex $< > \
Eric Andersen2423b122001-12-08 01:56:15 +000099 docs/busybox.net/BusyBox.html
Eric Andersen36763742001-04-24 21:46:07 +0000100 -@ rm -f pod2htm*
Erik Andersen0a704e82000-05-03 03:19:06 +0000101
Eric Andersen67536ff2000-07-06 22:53:22 +0000102
103# New docs based on DOCBOOK SGML
Eric Andersen488aac22000-09-24 02:42:48 +0000104newdoc: docs/busybox.txt docs/busybox.pdf docs/busybox/busyboxdocumentation.html
Eric Andersen67536ff2000-07-06 22:53:22 +0000105
106docs/busybox.txt: docs/busybox.sgml
107 @echo
108 @echo BusyBox Documentation
109 @echo
Eric Andersen09a34e52000-12-01 19:40:18 +0000110 - mkdir -p docs
Eric Andersen868c0572000-12-02 00:44:48 +0000111 (cd docs; sgmltools -b txt busybox.sgml)
Eric Andersen67536ff2000-07-06 22:53:22 +0000112
113docs/busybox.dvi: docs/busybox.sgml
Eric Andersen09a34e52000-12-01 19:40:18 +0000114 - mkdir -p docs
Eric Andersen868c0572000-12-02 00:44:48 +0000115 (cd docs; sgmltools -b dvi busybox.sgml)
Eric Andersen67536ff2000-07-06 22:53:22 +0000116
Eric Andersena2c83d82000-07-07 20:52:56 +0000117docs/busybox.ps: docs/busybox.sgml
Eric Andersen09a34e52000-12-01 19:40:18 +0000118 - mkdir -p docs
Eric Andersen868c0572000-12-02 00:44:48 +0000119 (cd docs; sgmltools -b ps busybox.sgml)
Eric Andersen67536ff2000-07-06 22:53:22 +0000120
Eric Andersena2c83d82000-07-07 20:52:56 +0000121docs/busybox.pdf: docs/busybox.ps
Eric Andersen09a34e52000-12-01 19:40:18 +0000122 - mkdir -p docs
Eric Andersen868c0572000-12-02 00:44:48 +0000123 (cd docs; ps2pdf busybox.ps)
Eric Andersen67536ff2000-07-06 22:53:22 +0000124
Eric Andersen488aac22000-09-24 02:42:48 +0000125docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
Eric Andersen09a34e52000-12-01 19:40:18 +0000126 - mkdir -p docs
Eric Andersen2423b122001-12-08 01:56:15 +0000127 (cd docs/busybox.net; sgmltools -b html ../busybox.sgml)
Eric Andersen67536ff2000-07-06 22:53:22 +0000128
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000129# The nifty new buildsystem stuff
Eric Andersenc9f20d92002-12-05 08:41:41 +0000130scripts/mkdep: scripts/mkdep.c
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000131 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
Eric Andersen67536ff2000-07-06 22:53:22 +0000132
Eric Andersenc9f20d92002-12-05 08:41:41 +0000133scripts/split-include: scripts/split-include.c
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000134 $(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
Erik Andersen1d1d9502000-04-21 01:26:49 +0000135
Eric Andersenc9f20d92002-12-05 08:41:41 +0000136.depend: scripts/mkdep
Eric Andersen85208e22002-04-12 12:05:57 +0000137 rm -f .depend .hdepend;
Eric Andersenc9f20d92002-12-05 08:41:41 +0000138 mkdir -p include/config;
Eric Andersen85208e22002-04-12 12:05:57 +0000139 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
Eric Andersenc9f20d92002-12-05 08:41:41 +0000140 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)" ;
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000145
Eric Andersenaaab46b2003-01-11 18:02:51 +0000146depend dep: include/config.h .depend
Eric Andersen85208e22002-04-12 12:05:57 +0000147
Eric Andersenc9f20d92002-12-05 08:41:41 +0000148include/config/MARKER: depend scripts/split-include
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000149 scripts/split-include include/config.h include/config
150 @ touch include/config/MARKER
151
Eric Andersenc9f20d92002-12-05 08:41:41 +0000152include/config.h: .config
153 @if [ ! -x ./scripts/config/conf ] ; then \
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000154 $(MAKE) -C scripts/config conf; \
Eric Andersen3cd27602001-10-24 07:58:02 +0000155 fi;
Glenn L McGrath6376b582003-09-24 15:48:29 +0000156 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersen85208e22002-04-12 12:05:57 +0000157
158%.o: %.c
159 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
160
Eric Andersenc9f20d92002-12-05 08:41:41 +0000161finished2:
162 @echo
163 @echo Finished installing...
164 @echo
Eric Andersen19f86202001-02-17 00:42:47 +0000165
Eric Andersen068b6b02002-12-13 22:53:28 +0000166else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000167
168all: menuconfig
169
Eric Andersenc9f20d92002-12-05 08:41:41 +0000170# configuration
171# ---------------------------------------------------------------------------
172
Eric Andersen068b6b02002-12-13 22:53:28 +0000173scripts/config/conf:
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000174 $(MAKE) -C scripts/config conf
Eric Andersen068b6b02002-12-13 22:53:28 +0000175 -@if [ ! -f .config ] ; then \
Glenn L McGrath6376b582003-09-24 15:48:29 +0000176 cp $(CONFIG_DEFCONFIG) .config; \
Eric Andersen068b6b02002-12-13 22:53:28 +0000177 fi
178scripts/config/mconf:
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000179 $(MAKE) -C scripts/config ncurses conf mconf
Eric Andersenc9f20d92002-12-05 08:41:41 +0000180 -@if [ ! -f .config ] ; then \
Glenn L McGrath6376b582003-09-24 15:48:29 +0000181 cp $(CONFIG_DEFCONFIG) .config; \
Eric Andersenc9f20d92002-12-05 08:41:41 +0000182 fi
183
184menuconfig: scripts/config/mconf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000185 @./scripts/config/mconf $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000186
187config: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000188 @./scripts/config/conf $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000189
190oldconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000191 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000192
193randconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000194 @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000195
196allyesconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000197 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000198
199allnoconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000200 @./scripts/config/conf -n $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000201
202defconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000203 @./scripts/config/conf -d $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000204
205test tests: busybox
206 # Note that 'tests' is depricated. Use 'make check' instead
207 # To use the nice new testsuite....
Mark Whitleyd2117e92001-03-10 00:51:29 +0000208 cd tests && ./tester.sh
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000209
Eric Andersenc9f20d92002-12-05 08:41:41 +0000210check: busybox
211 cd testsuite && ./runtest
212
Eric Andersencc8ed391999-10-05 16:24:54 +0000213clean:
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000214 - $(MAKE) -C tests clean
Eric Andersen53310252000-07-04 19:42:23 +0000215 - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
Eric Andersena39342b2002-10-08 19:31:04 +0000216 docs/busybox.pdf docs/busybox.pod docs/busybox.net/busybox.html \
Eric Andersen24e098a2003-08-22 20:53:38 +0000217 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
Eric Andersen87715172002-07-31 03:45:05 +0000222 - find . -name .\*.flags -exec rm -f {} \;
Eric Andersen87715172002-07-31 03:45:05 +0000223 - find . -name \*.o -exec rm -f {} \;
224 - find . -name \*.a -exec rm -f {} \;
Eric Andersencc8ed391999-10-05 16:24:54 +0000225
226distclean: clean
Eric Andersena9953432003-01-27 22:11:59 +0000227 - rm -f scripts/split-include scripts/mkdep
228 - rm -rf include/config include/config.h
229 - find . -name .depend -exec rm -f {} \;
Eric Andersenc9f20d92002-12-05 08:41:41 +0000230 rm -f .config .config.old .config.cmd
Eric Andersena9953432003-01-27 22:11:59 +0000231 - $(MAKE) -C scripts/config clean
Eric Andersencc8ed391999-10-05 16:24:54 +0000232
Eric Andersenc9f20d92002-12-05 08:41:41 +0000233release: distclean #doc
Erik Andersenfac10d72000-02-07 05:29:42 +0000234 cd ..; \
235 rm -rf busybox-$(VERSION); \
236 cp -a busybox busybox-$(VERSION); \
237 \
238 find busybox-$(VERSION)/ -type d \
239 -name CVS \
240 -print \
Eric Andersen53b55ac2001-03-16 07:43:53 +0000241 -exec rm -rf {} \; ; \
Erik Andersenfac10d72000-02-07 05:29:42 +0000242 \
243 find busybox-$(VERSION)/ -type f \
Eric Andersenb0b732b2000-07-06 23:17:16 +0000244 -name .\#* \
245 -print \
Eric Andersen53b55ac2001-03-16 07:43:53 +0000246 -exec rm -f {} \; ; \
Eric Andersenb0b732b2000-07-06 23:17:16 +0000247 \
Erik Andersenfac10d72000-02-07 05:29:42 +0000248 tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000249
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000250tags:
251 ctags -R .
Matt Kraai4e05da82001-11-19 19:47:56 +0000252
Eric Andersenc9f20d92002-12-05 08:41:41 +0000253
Eric Andersen068b6b02002-12-13 22:53:28 +0000254endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000255
256.PHONY: dummy subdirs release distclean clean config oldconfig \
257 menuconfig tags check test tests depend
258
Eric Andersen85208e22002-04-12 12:05:57 +0000259