blob: 424218cfa682d91ffb5ee23e786f186b0ff1b52b [file] [log] [blame]
Eric Andersenc4996011999-10-20 22:08:37 +00001# Makefile for busybox
2#
Erik Andersen9ffdaa62000-02-11 21:55:04 +00003# Copyright (C) 1999-2000 Erik Andersen <andersee@debian.org>
4# Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org>
5#
Eric Andersenc4996011999-10-20 22:08:37 +00006# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19#
20
Erik Andersen7c4b2f32000-02-29 21:49:22 +000021PROG := busybox
Erik Andersene90f4042000-04-21 21:53:58 +000022VERSION := 0.44
Erik Andersen1ad302a2000-03-24 00:54:46 +000023BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z")
John Beppucbd66282000-04-13 22:57:45 +000024export VERSION
Eric Andersencc8ed391999-10-05 16:24:54 +000025
Erik Andersenfac10d72000-02-07 05:29:42 +000026# Set the following to `true' to make a debuggable build.
27# Leave this set to `false' for production use.
Erik Andersen9ffdaa62000-02-11 21:55:04 +000028# eg: `make DODEBUG=true tests'
Erik Andersen3fe7f9f2000-04-19 03:59:10 +000029DODEBUG = false
Eric Andersen21943ce1999-10-13 18:04:51 +000030
Erik Andersenf3b3d172000-04-09 18:24:05 +000031# If you want a static binary, turn this on.
Erik Andersenc0dac182000-04-06 07:24:45 +000032DOSTATIC = false
Eric Andersencc8ed391999-10-05 16:24:54 +000033
Erik Andersene90f4042000-04-21 21:53:58 +000034# Figure out what arch we are on (not used at the moment)
35ARCH := $(shell uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/')
36
Eric Andersencc8ed391999-10-05 16:24:54 +000037
Erik Andersenfac10d72000-02-07 05:29:42 +000038CC = gcc
Eric Andersend80e8511999-11-16 00:46:00 +000039
Erik Andersen4f3f7572000-04-28 00:18:56 +000040GCCMAJVERSION = $(shell $(CC) --version | cut -f1 -d'.')
41GCCMINVERSION = $(shell $(CC) --version | cut -f2 -d'.')
Erik Andersenfac10d72000-02-07 05:29:42 +000042
43
44GCCSUPPORTSOPTSIZE = $(shell \
45if ( test $(GCCMAJVERSION) -eq 2 ) ; then \
46 if ( test $(GCCMINVERSION) -ge 66 ) ; then \
47 echo "true"; \
48 else \
49 echo "false"; \
50 fi; \
51else \
52 if ( test $(GCCMAJVERSION) -gt 2 ) ; then \
53 echo "true"; \
54 else \
55 echo "false"; \
56 fi; \
Eric Andersend80e8511999-11-16 00:46:00 +000057fi; )
58
59
60ifeq ($(GCCSUPPORTSOPTSIZE), true)
Erik Andersenfac10d72000-02-07 05:29:42 +000061 OPTIMIZATION = -Os
Eric Andersend80e8511999-11-16 00:46:00 +000062else
Erik Andersenfac10d72000-02-07 05:29:42 +000063 OPTIMIZATION = -O2
Eric Andersend80e8511999-11-16 00:46:00 +000064endif
Eric Andersencc8ed391999-10-05 16:24:54 +000065
Erik Andersen9ffdaa62000-02-11 21:55:04 +000066# Allow alternative stripping tools to be used...
67ifndef $(STRIPTOOL)
68 STRIPTOOL = strip
69endif
70
Erik Andersen03ccce62000-05-02 05:31:00 +000071# TODO: Try compiling vs other libcs.
72# See what -nostdinc and -nostdlib do for them.
Erik Andersen5afc8642000-05-02 00:07:56 +000073# also try --prefix=/usr/my-libc-stuff
Erik Andersen9ffdaa62000-02-11 21:55:04 +000074
Eric Andersencc8ed391999-10-05 16:24:54 +000075# -D_GNU_SOURCE is needed because environ is used in init.c
Eric Andersen17d49ef1999-10-06 20:25:32 +000076ifeq ($(DODEBUG),true)
Erik Andersene132f4b2000-02-09 04:16:43 +000077 CFLAGS += -Wall -g -D_GNU_SOURCE
Erik Andersen0817d132000-04-09 15:17:40 +000078 LDFLAGS =
Erik Andersen9ffdaa62000-02-11 21:55:04 +000079 STRIP =
Eric Andersen17d49ef1999-10-06 20:25:32 +000080else
Erik Andersenfac10d72000-02-07 05:29:42 +000081 CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
82 LDFLAGS = -s
Erik Andersen7c4b2f32000-02-29 21:49:22 +000083 STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
Eric Andersena7093171999-10-23 05:42:08 +000084 #Only staticly link when _not_ debugging
85 ifeq ($(DOSTATIC),true)
Erik Andersenfac10d72000-02-07 05:29:42 +000086 LDFLAGS += --static
Eric Andersena7093171999-10-23 05:42:08 +000087 endif
Eric Andersen17d49ef1999-10-06 20:25:32 +000088endif
89
Eric Anderseneded54b1999-11-12 08:03:23 +000090ifndef $(PREFIX)
Erik Andersenfac10d72000-02-07 05:29:42 +000091 PREFIX = `pwd`/_install
Eric Andersen17d49ef1999-10-06 20:25:32 +000092endif
Eric Andersen17d49ef1999-10-06 20:25:32 +000093
Erik Andersenfac10d72000-02-07 05:29:42 +000094LIBRARIES =
Erik Andersene2729152000-02-18 21:34:17 +000095OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o
Erik Andersenfac10d72000-02-07 05:29:42 +000096CFLAGS += -DBB_VER='"$(VERSION)"'
97CFLAGS += -DBB_BT='"$(BUILDTIME)"'
Erik Andersend387d011999-12-21 02:55:11 +000098ifdef BB_INIT_SCRIPT
Erik Andersen9ffdaa62000-02-11 21:55:04 +000099 CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
Erik Andersend387d011999-12-21 02:55:11 +0000100endif
101
Erik Andersen0a704e82000-05-03 03:19:06 +0000102all: busybox busybox.links doc
103
104doc: BusyBox.txt BusyBox.1 BusyBox.html
105
106BusyBox.txt: docs/busybox.pod
107 @echo
108 @echo BusyBox Documentation
109 @echo
110 pod2text docs/busybox.pod > BusyBox.txt
111
112BusyBox.1: docs/busybox.pod
113 pod2man --center=BusyBox --release="version $(VERSION)" docs/busybox.pod > BusyBox.1
114
115BusyBox.html: docs/busybox.pod
116 pod2html docs/busybox.pod > BusyBox.html
117 - rm -f pod2html*
118
119clean:
Eric Andersencc8ed391999-10-05 16:24:54 +0000120
121busybox: $(OBJECTS)
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000122 $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES)
Erik Andersen7c4b2f32000-02-29 21:49:22 +0000123 $(STRIP)
Erik Andersen1d1d9502000-04-21 01:26:49 +0000124
Erik Andersenfac10d72000-02-07 05:29:42 +0000125busybox.links: busybox.def.h
Eric Andersen96bcfd31999-11-12 01:30:18 +0000126 - ./busybox.mkll | sort >$@
Eric Andersen1667fb41999-11-27 20:34:28 +0000127
Erik Andersen1d1d9502000-04-21 01:26:49 +0000128regexp.o nfsmount.o cmdedit.o: %.o: %.h
Erik Andersena3e57ca2000-04-19 03:38:01 +0000129$(OBJECTS): %.o: busybox.def.h internal.h %.c Makefile
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000130
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000131test tests:
132 cd tests && $(MAKE) all
133
Eric Andersencc8ed391999-10-05 16:24:54 +0000134clean:
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000135 - rm -f busybox.links *~ *.o core
Eric Andersend00c2621999-12-07 08:37:31 +0000136 - rm -rf _install
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000137 - cd tests && $(MAKE) clean
Erik Andersen0a704e82000-05-03 03:19:06 +0000138 - rm -f BusyBox.html BusyBox.1 BusyBox.txt pod2html*
Eric Andersencc8ed391999-10-05 16:24:54 +0000139
140distclean: clean
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000141 - rm -f busybox
142 - cd tests && $(MAKE) distclean
Eric Andersencc8ed391999-10-05 16:24:54 +0000143
Eric Andersen07274581999-11-21 21:50:07 +0000144install: busybox busybox.links
Eric Andersen80974fa1999-11-13 04:51:47 +0000145 ./install.sh $(PREFIX)
Eric Andersen17d49ef1999-10-06 20:25:32 +0000146
Erik Andersen0a704e82000-05-03 03:19:06 +0000147dist release: distclean doc
Erik Andersenfac10d72000-02-07 05:29:42 +0000148 cd ..; \
149 rm -rf busybox-$(VERSION); \
150 cp -a busybox busybox-$(VERSION); \
151 \
152 find busybox-$(VERSION)/ -type d \
153 -name CVS \
154 -print \
155 | xargs rm -rf; \
156 \
157 find busybox-$(VERSION)/ -type f \
158 -name .cvsignore \
159 -print \
160 | xargs rm -f; \
161 \
162 tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;