blob: 7a8337003f7c7e6030e99d270f8c0aeed075067a [file] [log] [blame]
Eric Andersenc4996011999-10-20 22:08:37 +00001# Makefile for busybox
2#
Eric Andersenc7bda1c2004-03-15 08:29:22 +00003# Copyright (C) 1999-2004 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;
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000144
Eric Andersenaaab46b2003-01-11 18:02:51 +0000145depend dep: include/config.h .depend
Eric Andersen85208e22002-04-12 12:05:57 +0000146
Eric Andersenc9f20d92002-12-05 08:41:41 +0000147include/config/MARKER: depend scripts/split-include
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000148 scripts/split-include include/config.h include/config
149 @ touch include/config/MARKER
150
Eric Andersenc9f20d92002-12-05 08:41:41 +0000151include/config.h: .config
152 @if [ ! -x ./scripts/config/conf ] ; then \
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000153 $(MAKE) -C scripts/config conf; \
Eric Andersen3cd27602001-10-24 07:58:02 +0000154 fi;
Glenn L McGrath6376b582003-09-24 15:48:29 +0000155 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersen85208e22002-04-12 12:05:57 +0000156
157%.o: %.c
158 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
159
Eric Andersenc9f20d92002-12-05 08:41:41 +0000160finished2:
161 @echo
162 @echo Finished installing...
163 @echo
Eric Andersen19f86202001-02-17 00:42:47 +0000164
Eric Andersen068b6b02002-12-13 22:53:28 +0000165else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000166
167all: menuconfig
168
Eric Andersenc9f20d92002-12-05 08:41:41 +0000169# configuration
170# ---------------------------------------------------------------------------
171
Eric Andersen068b6b02002-12-13 22:53:28 +0000172scripts/config/conf:
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000173 $(MAKE) -C scripts/config conf
Eric Andersen068b6b02002-12-13 22:53:28 +0000174 -@if [ ! -f .config ] ; then \
Glenn L McGrath6376b582003-09-24 15:48:29 +0000175 cp $(CONFIG_DEFCONFIG) .config; \
Eric Andersen068b6b02002-12-13 22:53:28 +0000176 fi
177scripts/config/mconf:
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000178 $(MAKE) -C scripts/config ncurses conf mconf
Eric Andersenc9f20d92002-12-05 08:41:41 +0000179 -@if [ ! -f .config ] ; then \
Glenn L McGrath6376b582003-09-24 15:48:29 +0000180 cp $(CONFIG_DEFCONFIG) .config; \
Eric Andersenc9f20d92002-12-05 08:41:41 +0000181 fi
182
183menuconfig: scripts/config/mconf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000184 @./scripts/config/mconf $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000185
186config: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000187 @./scripts/config/conf $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000188
189oldconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000190 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000191
192randconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000193 @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000194
195allyesconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000196 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Eric Andersen8ee69432004-04-06 11:46:56 +0000197 sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
198 sed -i -e "s/^USING_CROSS_COMPILER.*/# USING_CROSS_COMPILER is not set/" .config
Eric Andersenb07ae7b2004-04-06 11:51:45 +0000199 sed -i -e "s/^CONFIG_STATIC.*/# CONFIG_STATIC is not set/" .config
200 sed -i -e "s/^CONFIG_SELINUX.*/# CONFIG_SELINUX is not set/" .config
Eric Andersen8ee69432004-04-06 11:46:56 +0000201 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000202
203allnoconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000204 @./scripts/config/conf -n $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000205
206defconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000207 @./scripts/config/conf -d $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000208
209test tests: busybox
210 # Note that 'tests' is depricated. Use 'make check' instead
211 # To use the nice new testsuite....
Mark Whitleyd2117e92001-03-10 00:51:29 +0000212 cd tests && ./tester.sh
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000213
Eric Andersenc9f20d92002-12-05 08:41:41 +0000214check: busybox
215 cd testsuite && ./runtest
216
Eric Andersencc8ed391999-10-05 16:24:54 +0000217clean:
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000218 - $(MAKE) -C tests clean
Eric Andersen53310252000-07-04 19:42:23 +0000219 - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
Eric Andersena39342b2002-10-08 19:31:04 +0000220 docs/busybox.pdf docs/busybox.pod docs/busybox.net/busybox.html \
Eric Andersen24e098a2003-08-22 20:53:38 +0000221 docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
222 docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
223 docs/busybox.net/BusyBox.html busybox.links libbb/loop.h \
224 .config.old .hdepend busybox
225 - rm -rf _install
Eric Andersenc7bda1c2004-03-15 08:29:22 +0000226 - find . -name .\*.flags -exec rm -f {} \;
Eric Andersen87715172002-07-31 03:45:05 +0000227 - find . -name \*.o -exec rm -f {} \;
228 - find . -name \*.a -exec rm -f {} \;
Eric Andersencc8ed391999-10-05 16:24:54 +0000229
230distclean: clean
Eric Andersena9953432003-01-27 22:11:59 +0000231 - rm -f scripts/split-include scripts/mkdep
232 - rm -rf include/config include/config.h
233 - find . -name .depend -exec rm -f {} \;
Eric Andersenc9f20d92002-12-05 08:41:41 +0000234 rm -f .config .config.old .config.cmd
Eric Andersena9953432003-01-27 22:11:59 +0000235 - $(MAKE) -C scripts/config clean
Eric Andersencc8ed391999-10-05 16:24:54 +0000236
Eric Andersenc9f20d92002-12-05 08:41:41 +0000237release: distclean #doc
Erik Andersenfac10d72000-02-07 05:29:42 +0000238 cd ..; \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000239 rm -rf $(PROG)-$(VERSION); \
240 cp -a busybox $(PROG)-$(VERSION); \
Erik Andersenfac10d72000-02-07 05:29:42 +0000241 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000242 find $(PROG)-$(VERSION)/ -type d \
Erik Andersenfac10d72000-02-07 05:29:42 +0000243 -name CVS \
244 -print \
Eric Andersen53b55ac2001-03-16 07:43:53 +0000245 -exec rm -rf {} \; ; \
Erik Andersenfac10d72000-02-07 05:29:42 +0000246 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000247 find $(PROG)-$(VERSION)/ -type f \
Eric Andersenb0b732b2000-07-06 23:17:16 +0000248 -name .\#* \
249 -print \
Eric Andersen53b55ac2001-03-16 07:43:53 +0000250 -exec rm -f {} \; ; \
Eric Andersenb0b732b2000-07-06 23:17:16 +0000251 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000252 tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000253
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000254tags:
255 ctags -R .
Matt Kraai4e05da82001-11-19 19:47:56 +0000256
Eric Andersenc9f20d92002-12-05 08:41:41 +0000257
Eric Andersen068b6b02002-12-13 22:53:28 +0000258endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000259
260.PHONY: dummy subdirs release distclean clean config oldconfig \
261 menuconfig tags check test tests depend
262
Eric Andersen85208e22002-04-12 12:05:57 +0000263