blob: 8afd6986328e50025cbfcc7f342432ec8c72bbf8 [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)
60
Glenn L McGrath87470de2003-08-29 12:20:31 +000061uninstall: busybox.links
62 rm -f $(PREFIX)/bin/busybox
63 for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
Eric Andersen1f30a412002-04-13 13:39:48 +000064
Eric Andersenbdfd0d72001-10-24 05:00:29 +000065install-hardlinks: applets/install.sh busybox busybox.links
66 $(SHELL) $< $(PREFIX) --hardlinks
67
68
69# Documentation Targets
Eric Andersenf7300882004-04-06 15:26:25 +000070doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
John Beppu94e50542001-04-05 19:42:03 +000071
Eric Andersen1552ff72001-10-31 11:07:12 +000072docs/busybox.pod : docs/busybox_header.pod include/usage.h docs/busybox_footer.pod
John Beppu94e50542001-04-05 19:42:03 +000073 - ( cat docs/busybox_header.pod; \
Eric Andersen1552ff72001-10-31 11:07:12 +000074 docs/autodocifier.pl include/usage.h; \
John Beppu94e50542001-04-05 19:42:03 +000075 cat docs/busybox_footer.pod ) > docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +000076
Eric Andersen67536ff2000-07-06 22:53:22 +000077docs/BusyBox.txt: docs/busybox.pod
Eric Andersen53310252000-07-04 19:42:23 +000078 @echo
79 @echo BusyBox Documentation
80 @echo
Eric Andersen29be79c2000-12-01 22:57:44 +000081 -mkdir -p docs
Eric Andersen19f86202001-02-17 00:42:47 +000082 -pod2text $< > $@
Eric Andersen53310252000-07-04 19:42:23 +000083
Eric Andersen67536ff2000-07-06 22:53:22 +000084docs/BusyBox.1: docs/busybox.pod
Eric Andersen09a34e52000-12-01 19:40:18 +000085 - mkdir -p docs
Eric Andersen29be79c2000-12-01 22:57:44 +000086 - pod2man --center=BusyBox --release="version $(VERSION)" \
Eric Andersen19f86202001-02-17 00:42:47 +000087 $< > $@
Eric Andersen53310252000-07-04 19:42:23 +000088
Eric Andersen2423b122001-12-08 01:56:15 +000089docs/BusyBox.html: docs/busybox.net/BusyBox.html
Eric Andersen1cf81662001-02-17 15:55:15 +000090 - mkdir -p docs
Eric Andersene2f6e122000-12-01 19:55:04 +000091 -@ rm -f docs/BusyBox.html
Eric Andersen2423b122001-12-08 01:56:15 +000092 -@ ln -s busybox.net/BusyBox.html docs/BusyBox.html
Eric Andersen53310252000-07-04 19:42:23 +000093
Eric Andersen2423b122001-12-08 01:56:15 +000094docs/busybox.net/BusyBox.html: docs/busybox.pod
95 -@ mkdir -p docs/busybox.net
Eric Andersen19f86202001-02-17 00:42:47 +000096 - pod2html --noindex $< > \
Eric Andersen2423b122001-12-08 01:56:15 +000097 docs/busybox.net/BusyBox.html
Eric Andersen36763742001-04-24 21:46:07 +000098 -@ rm -f pod2htm*
Erik Andersen0a704e82000-05-03 03:19:06 +000099
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000100# The nifty new buildsystem stuff
Eric Andersenc9f20d92002-12-05 08:41:41 +0000101scripts/mkdep: scripts/mkdep.c
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000102 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
Eric Andersen67536ff2000-07-06 22:53:22 +0000103
Eric Andersenc9f20d92002-12-05 08:41:41 +0000104scripts/split-include: scripts/split-include.c
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000105 $(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
Erik Andersen1d1d9502000-04-21 01:26:49 +0000106
Eric Andersenc9f20d92002-12-05 08:41:41 +0000107.depend: scripts/mkdep
Eric Andersen85208e22002-04-12 12:05:57 +0000108 rm -f .depend .hdepend;
Eric Andersenc9f20d92002-12-05 08:41:41 +0000109 mkdir -p include/config;
Eric Andersen85208e22002-04-12 12:05:57 +0000110 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
Eric Andersenc9f20d92002-12-05 08:41:41 +0000111 scripts/mkdep -I include -- \
Eric Andersen515881c2004-04-06 15:19:52 +0000112 `find -name \*.c -print | sed -e "s,^./,,"` >> .depend;
Eric Andersenc9f20d92002-12-05 08:41:41 +0000113 scripts/mkdep -I include -- \
Eric Andersen515881c2004-04-06 15:19:52 +0000114 `find -name \*.h -print | sed -e "s,^./,,"` >> .hdepend;
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000115
Eric Andersenaaab46b2003-01-11 18:02:51 +0000116depend dep: include/config.h .depend
Eric Andersen85208e22002-04-12 12:05:57 +0000117
Eric Andersenc9f20d92002-12-05 08:41:41 +0000118include/config/MARKER: depend scripts/split-include
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000119 scripts/split-include include/config.h include/config
120 @ touch include/config/MARKER
121
Eric Andersenc9f20d92002-12-05 08:41:41 +0000122include/config.h: .config
123 @if [ ! -x ./scripts/config/conf ] ; then \
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000124 $(MAKE) -C scripts/config conf; \
Eric Andersen3cd27602001-10-24 07:58:02 +0000125 fi;
Glenn L McGrath6376b582003-09-24 15:48:29 +0000126 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersen85208e22002-04-12 12:05:57 +0000127
128%.o: %.c
129 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
130
Eric Andersenc9f20d92002-12-05 08:41:41 +0000131finished2:
132 @echo
133 @echo Finished installing...
134 @echo
Eric Andersen19f86202001-02-17 00:42:47 +0000135
Eric Andersen068b6b02002-12-13 22:53:28 +0000136else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000137
138all: menuconfig
139
Eric Andersenc9f20d92002-12-05 08:41:41 +0000140# configuration
141# ---------------------------------------------------------------------------
142
Eric Andersen068b6b02002-12-13 22:53:28 +0000143scripts/config/conf:
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000144 $(MAKE) -C scripts/config conf
Eric Andersen068b6b02002-12-13 22:53:28 +0000145 -@if [ ! -f .config ] ; then \
Glenn L McGrath6376b582003-09-24 15:48:29 +0000146 cp $(CONFIG_DEFCONFIG) .config; \
Eric Andersen068b6b02002-12-13 22:53:28 +0000147 fi
148scripts/config/mconf:
Glenn L McGrathb19c73d2003-08-29 13:25:55 +0000149 $(MAKE) -C scripts/config ncurses conf mconf
Eric Andersenc9f20d92002-12-05 08:41:41 +0000150 -@if [ ! -f .config ] ; then \
Glenn L McGrath6376b582003-09-24 15:48:29 +0000151 cp $(CONFIG_DEFCONFIG) .config; \
Eric Andersenc9f20d92002-12-05 08:41:41 +0000152 fi
153
154menuconfig: scripts/config/mconf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000155 @./scripts/config/mconf $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000156
157config: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000158 @./scripts/config/conf $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000159
160oldconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000161 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000162
163randconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000164 @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000165
166allyesconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000167 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
Eric Andersen8ee69432004-04-06 11:46:56 +0000168 sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
169 sed -i -e "s/^USING_CROSS_COMPILER.*/# USING_CROSS_COMPILER is not set/" .config
Eric Andersenb07ae7b2004-04-06 11:51:45 +0000170 sed -i -e "s/^CONFIG_STATIC.*/# CONFIG_STATIC is not set/" .config
171 sed -i -e "s/^CONFIG_SELINUX.*/# CONFIG_SELINUX is not set/" .config
Eric Andersen8ee69432004-04-06 11:46:56 +0000172 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000173
174allnoconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000175 @./scripts/config/conf -n $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000176
177defconfig: scripts/config/conf
Glenn L McGrath6376b582003-09-24 15:48:29 +0000178 @./scripts/config/conf -d $(CONFIG_CONFIG_IN)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000179
Eric Andersenc9f20d92002-12-05 08:41:41 +0000180check: busybox
181 cd testsuite && ./runtest
182
Eric Andersencc8ed391999-10-05 16:24:54 +0000183clean:
Eric Andersenf7300882004-04-06 15:26:25 +0000184 - rm -f docs/busybox.dvi docs/busybox.ps \
185 docs/busybox.pod docs/busybox.net/busybox.html \
Eric Andersen24e098a2003-08-22 20:53:38 +0000186 docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
187 docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
188 docs/busybox.net/BusyBox.html busybox.links libbb/loop.h \
189 .config.old .hdepend busybox
190 - rm -rf _install
Eric Andersenc7bda1c2004-03-15 08:29:22 +0000191 - find . -name .\*.flags -exec rm -f {} \;
Eric Andersen87715172002-07-31 03:45:05 +0000192 - find . -name \*.o -exec rm -f {} \;
193 - find . -name \*.a -exec rm -f {} \;
Eric Andersencc8ed391999-10-05 16:24:54 +0000194
195distclean: clean
Eric Andersena9953432003-01-27 22:11:59 +0000196 - rm -f scripts/split-include scripts/mkdep
197 - rm -rf include/config include/config.h
198 - find . -name .depend -exec rm -f {} \;
Eric Andersenc9f20d92002-12-05 08:41:41 +0000199 rm -f .config .config.old .config.cmd
Eric Andersena9953432003-01-27 22:11:59 +0000200 - $(MAKE) -C scripts/config clean
Eric Andersencc8ed391999-10-05 16:24:54 +0000201
Eric Andersenc9f20d92002-12-05 08:41:41 +0000202release: distclean #doc
Erik Andersenfac10d72000-02-07 05:29:42 +0000203 cd ..; \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000204 rm -rf $(PROG)-$(VERSION); \
205 cp -a busybox $(PROG)-$(VERSION); \
Erik Andersenfac10d72000-02-07 05:29:42 +0000206 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000207 find $(PROG)-$(VERSION)/ -type d \
Erik Andersenfac10d72000-02-07 05:29:42 +0000208 -name CVS \
209 -print \
Eric Andersen53b55ac2001-03-16 07:43:53 +0000210 -exec rm -rf {} \; ; \
Erik Andersenfac10d72000-02-07 05:29:42 +0000211 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000212 find $(PROG)-$(VERSION)/ -type f \
Eric Andersenb0b732b2000-07-06 23:17:16 +0000213 -name .\#* \
214 -print \
Eric Andersen53b55ac2001-03-16 07:43:53 +0000215 -exec rm -f {} \; ; \
Eric Andersenb0b732b2000-07-06 23:17:16 +0000216 \
Glenn L McGrath0874a612003-11-17 10:26:43 +0000217 tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000218
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000219tags:
220 ctags -R .
Matt Kraai4e05da82001-11-19 19:47:56 +0000221
Eric Andersenc9f20d92002-12-05 08:41:41 +0000222
Eric Andersen068b6b02002-12-13 22:53:28 +0000223endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
Eric Andersenc9f20d92002-12-05 08:41:41 +0000224
225.PHONY: dummy subdirs release distclean clean config oldconfig \
Eric Andersen8f41bfc2004-07-20 06:04:28 +0000226 menuconfig tags check test depend
Eric Andersenc9f20d92002-12-05 08:41:41 +0000227
Eric Andersen85208e22002-04-12 12:05:57 +0000228