blob: 29897ef4e11cb793c441de18fd37ed56286232c9 [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 Andersen515881c2004-04-06 15:19:52 +000049-include $(TOPDIR).depend
Eric Andersen3cd27602001-10-24 07:58:02 +000050
Eric Andersen1c25ba92003-06-25 05:18:48 +000051busybox: .depend include/config.h $(libraries-y)
Glenn L McGrathd72e34c2003-09-20 00:59:35 +000052 $(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
Eric Andersen85208e22002-04-12 12:05:57 +000053 $(STRIPCMD) $@
Eric Andersenbdfd0d72001-10-24 05:00:29 +000054
Eric Andersenb6071ea2003-06-25 03:26:04 +000055busybox.links: applets/busybox.mkll include/config.h
Eric Andersenbdfd0d72001-10-24 05:00:29 +000056 - $(SHELL) $^ >$@
57
58install: applets/install.sh busybox busybox.links
59 $(SHELL) $< $(PREFIX)
Eric Andersen13879102004-08-26 23:13:00 +000060ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
61 @echo
62 @echo
63 @echo --------------------------------------------------
64 @echo You will probably need to make your busybox binary
65 @echo setuid root to ensure all configured applets will
66 @echo work properly.
67 @echo --------------------------------------------------
68 @echo
69endif
Eric Andersenbdfd0d72001-10-24 05:00:29 +000070
Glenn L McGrath87470de2003-08-29 12:20:31 +000071uninstall: busybox.links
72 rm -f $(PREFIX)/bin/busybox
73 for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
Eric Andersen1f30a412002-04-13 13:39:48 +000074
Eric Andersenbdfd0d72001-10-24 05:00:29 +000075install-hardlinks: applets/install.sh busybox busybox.links
76 $(SHELL) $< $(PREFIX) --hardlinks
77
78
79# Documentation Targets
Eric Andersenf7300882004-04-06 15:26:25 +000080doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
John Beppu94e50542001-04-05 19:42:03 +000081
Eric Andersen1552ff72001-10-31 11:07:12 +000082docs/busybox.pod : docs/busybox_header.pod include/usage.h docs/busybox_footer.pod
John Beppu94e50542001-04-05 19:42:03 +000083 - ( cat docs/busybox_header.pod; \
Eric Andersen1552ff72001-10-31 11:07:12 +000084 docs/autodocifier.pl include/usage.h; \
John Beppu94e50542001-04-05 19:42:03 +000085 cat docs/busybox_footer.pod ) > docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +000086
Eric Andersen67536ff2000-07-06 22:53:22 +000087docs/BusyBox.txt: docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +000088 @echo
89 @echo BusyBox Documentation
90 @echo
Eric Andersen29be79c2000-12-01 22:57:44 +000091 -mkdir -p docs
Eric Andersen19f86202001-02-17 00:42:47 +000092 -pod2text $< > $@
Eric Andersen53310252000-07-04 19:42:23 +000093
Eric Andersen67536ff2000-07-06 22:53:22 +000094docs/BusyBox.1: docs/busybox.pod
Eric Andersen09a34e52000-12-01 19:40:18 +000095 - mkdir -p docs
Eric Andersen29be79c2000-12-01 22:57:44 +000096 - pod2man --center=BusyBox --release="version $(VERSION)" \
Eric Andersen19f86202001-02-17 00:42:47 +000097 $< > $@
Eric Andersen53310252000-07-04 19:42:23 +000098
Eric Andersen2423b122001-12-08 01:56:15 +000099docs/BusyBox.html: docs/busybox.net/BusyBox.html
Eric Andersen1cf81662001-02-17 15:55:15 +0000100 - mkdir -p docs
Eric Andersene2f6e122000-12-01 19:55:04 +0000101 -@ rm -f docs/BusyBox.html
Eric Andersen2423b122001-12-08 01:56:15 +0000102 -@ ln -s busybox.net/BusyBox.html docs/BusyBox.html
Eric Andersen53310252000-07-04 19:42:23 +0000103
Eric Andersen2423b122001-12-08 01:56:15 +0000104docs/busybox.net/BusyBox.html: docs/busybox.pod
105 -@ mkdir -p docs/busybox.net
Eric Andersen19f86202001-02-17 00:42:47 +0000106 - pod2html --noindex $< > \
Eric Andersen2423b122001-12-08 01:56:15 +0000107 docs/busybox.net/BusyBox.html
Eric Andersen36763742001-04-24 21:46:07 +0000108 -@ rm -f pod2htm*
Erik Andersen0a704e82000-05-03 03:19:06 +0000109
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000110# The nifty new buildsystem stuff
Eric Andersenc9f20d92002-12-05 08:41:41 +0000111scripts/mkdep: scripts/mkdep.c
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000112 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
Eric Andersen67536ff2000-07-06 22:53:22 +0000113
Eric Andersenc9f20d92002-12-05 08:41:41 +0000114scripts/split-include: scripts/split-include.c
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000115 $(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
Erik Andersen1d1d9502000-04-21 01:26:49 +0000116
Eric Andersenc9f20d92002-12-05 08:41:41 +0000117.depend: scripts/mkdep
Eric Andersen85208e22002-04-12 12:05:57 +0000118 rm -f .depend .hdepend;
Eric Andersenc9f20d92002-12-05 08:41:41 +0000119 mkdir -p include/config;
Eric Andersen85208e22002-04-12 12:05:57 +0000120 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
Eric Andersenc9f20d92002-12-05 08:41:41 +0000121 scripts/mkdep -I include -- \
Eric Andersen515881c2004-04-06 15:19:52 +0000122 `find -name \*.c -print | sed -e "s,^./,,"` >> .depend;
Eric Andersenc9f20d92002-12-05 08:41:41 +0000123 scripts/mkdep -I include -- \
Eric Andersen515881c2004-04-06 15:19:52 +0000124 `find -name \*.h -print | sed -e "s,^./,,"` >> .hdepend;
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000125
Eric Andersenaaab46b2003-01-11 18:02:51 +0000126depend dep: include/config.h .depend
Eric Andersen85208e22002-04-12 12:05:57 +0000127
Eric Andersenc9f20d92002-12-05 08:41:41 +0000128include/config/MARKER: depend scripts/split-include
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000129 scripts/split-include include/config.h include/config
130 @ touch include/config/MARKER
131
Eric Andersenc9f20d92002-12-05 08:41:41 +0000132include/config.h: .config
133 @if [ ! -x ./scripts/config/conf ] ; then \
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000134 $(MAKE) -C scripts/config conf; \
Eric Andersen3cd27602001-10-24 07:58:02 +0000135 fi;
Glenn L McGrath6376b582003-09-24 15:48:29 +0000136 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersen85208e22002-04-12 12:05:57 +0000137
138%.o: %.c
139 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
140
Eric Andersenc9f20d92002-12-05 08:41:41 +0000141finished2:
142 @echo
143 @echo Finished installing...
144 @echo
Eric Andersen19f86202001-02-17 00:42:47 +0000145
Eric Andersen068b6b02002-12-13 22:53:28 +0000146else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000147
148all: menuconfig
149
Eric Andersenc9f20d92002-12-05 08:41:41 +0000150# configuration
151# ---------------------------------------------------------------------------
152
Eric Andersen068b6b02002-12-13 22:53:28 +0000153scripts/config/conf:
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000154 $(MAKE) -C scripts/config conf
Eric Andersen068b6b02002-12-13 22:53:28 +0000155 -@if [ ! -f .config ] ; then \
Glenn L McGrath6376b582003-09-24 15:48:29 +0000156 cp $(CONFIG_DEFCONFIG) .config; \
Eric Andersen068b6b02002-12-13 22:53:28 +0000157 fi
158scripts/config/mconf:
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000159 $(MAKE) -C scripts/config ncurses conf mconf
Eric Andersenc9f20d92002-12-05 08:41:41 +0000160 -@if [ ! -f .config ] ; then \
Glenn L McGrath6376b582003-09-24 15:48:29 +0000161 cp $(CONFIG_DEFCONFIG) .config; \
Eric Andersenc9f20d92002-12-05 08:41:41 +0000162 fi
163
164menuconfig: scripts/config/mconf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000165 @./scripts/config/mconf $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000166
167config: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000168 @./scripts/config/conf $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000169
170oldconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000171 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000172
173randconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000174 @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000175
176allyesconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000177 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Eric Andersen8ee69432004-04-06 11:46:56 +0000178 sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
179 sed -i -e "s/^USING_CROSS_COMPILER.*/# USING_CROSS_COMPILER is not set/" .config
Eric Andersenb07ae7b2004-04-06 11:51:45 +0000180 sed -i -e "s/^CONFIG_STATIC.*/# CONFIG_STATIC is not set/" .config
181 sed -i -e "s/^CONFIG_SELINUX.*/# CONFIG_SELINUX is not set/" .config
Eric Andersen8ee69432004-04-06 11:46:56 +0000182 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000183
184allnoconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000185 @./scripts/config/conf -n $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000186
187defconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000188 @./scripts/config/conf -d $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000189
Eric Andersenc9f20d92002-12-05 08:41:41 +0000190check: busybox
191 cd testsuite && ./runtest
192
Eric Andersencc8ed391999-10-05 16:24:54 +0000193clean:
Eric Andersenf7300882004-04-06 15:26:25 +0000194 - rm -f docs/busybox.dvi docs/busybox.ps \
195 docs/busybox.pod docs/busybox.net/busybox.html \
Eric Andersen24e098a2003-08-22 20:53:38 +0000196 docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
197 docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
198 docs/busybox.net/BusyBox.html busybox.links libbb/loop.h \
199 .config.old .hdepend busybox
200 - rm -rf _install
Eric Andersenc7bda1c2004-03-15 08:29:22 +0000201 - find . -name .\*.flags -exec rm -f {} \;
Eric Andersen87715172002-07-31 03:45:05 +0000202 - find . -name \*.o -exec rm -f {} \;
203 - find . -name \*.a -exec rm -f {} \;
Eric Andersencc8ed391999-10-05 16:24:54 +0000204
205distclean: clean
Eric Andersena9953432003-01-27 22:11:59 +0000206 - rm -f scripts/split-include scripts/mkdep
207 - rm -rf include/config include/config.h
208 - find . -name .depend -exec rm -f {} \;
Eric Andersenc9f20d92002-12-05 08:41:41 +0000209 rm -f .config .config.old .config.cmd
Eric Andersena9953432003-01-27 22:11:59 +0000210 - $(MAKE) -C scripts/config clean
Eric Andersencc8ed391999-10-05 16:24:54 +0000211
Eric Andersenc9f20d92002-12-05 08:41:41 +0000212release: distclean #doc
Erik Andersenfac10d72000-02-07 05:29:42 +0000213 cd ..; \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000214 rm -rf $(PROG)-$(VERSION); \
215 cp -a busybox $(PROG)-$(VERSION); \
Erik Andersenfac10d72000-02-07 05:29:42 +0000216 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000217 find $(PROG)-$(VERSION)/ -type d \
Erik Andersenfac10d72000-02-07 05:29:42 +0000218 -name CVS \
219 -print \
Eric Andersen53b55ac2001-03-16 07:43:53 +0000220 -exec rm -rf {} \; ; \
Erik Andersenfac10d72000-02-07 05:29:42 +0000221 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000222 find $(PROG)-$(VERSION)/ -type f \
Eric Andersenb0b732b2000-07-06 23:17:16 +0000223 -name .\#* \
224 -print \
Eric Andersen53b55ac2001-03-16 07:43:53 +0000225 -exec rm -f {} \; ; \
Eric Andersenb0b732b2000-07-06 23:17:16 +0000226 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000227 tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000228
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000229tags:
230 ctags -R .
Matt Kraai4e05da82001-11-19 19:47:56 +0000231
Eric Andersenc9f20d92002-12-05 08:41:41 +0000232
Eric Andersen068b6b02002-12-13 22:53:28 +0000233endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000234
235.PHONY: dummy subdirs release distclean clean config oldconfig \
Eric Andersen8f41bfc2004-07-20 06:04:28 +0000236 menuconfig tags check test depend
Eric Andersenc9f20d92002-12-05 08:41:41 +0000237
Eric Andersen85208e22002-04-12 12:05:57 +0000238