blob: 90a1a21fd0db0f5785058d5044703a89431afe79 [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 Andersene2729152000-02-18 21:34:17 +000022VERSION := 0.43
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 Andersenfac10d72000-02-07 05:29:42 +000034# This will choke on a non-debian system
35ARCH =`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
Eric Andersencc8ed391999-10-05 16:24:54 +000036
Erik Andersenfac10d72000-02-07 05:29:42 +000037CC = gcc
Eric Andersend80e8511999-11-16 00:46:00 +000038
Erik Andersenfac10d72000-02-07 05:29:42 +000039GCCMAJVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\1/p")
40GCCMINVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\2/p")
41
42
43GCCSUPPORTSOPTSIZE = $(shell \
44if ( test $(GCCMAJVERSION) -eq 2 ) ; then \
45 if ( test $(GCCMINVERSION) -ge 66 ) ; then \
46 echo "true"; \
47 else \
48 echo "false"; \
49 fi; \
50else \
51 if ( test $(GCCMAJVERSION) -gt 2 ) ; then \
52 echo "true"; \
53 else \
54 echo "false"; \
55 fi; \
Eric Andersend80e8511999-11-16 00:46:00 +000056fi; )
57
58
59ifeq ($(GCCSUPPORTSOPTSIZE), true)
Erik Andersenfac10d72000-02-07 05:29:42 +000060 OPTIMIZATION = -Os
Eric Andersend80e8511999-11-16 00:46:00 +000061else
Erik Andersenfac10d72000-02-07 05:29:42 +000062 OPTIMIZATION = -O2
Eric Andersend80e8511999-11-16 00:46:00 +000063endif
Eric Andersencc8ed391999-10-05 16:24:54 +000064
Erik Andersen9ffdaa62000-02-11 21:55:04 +000065# Allow alternative stripping tools to be used...
66ifndef $(STRIPTOOL)
67 STRIPTOOL = strip
68endif
69
70
Eric Andersencc8ed391999-10-05 16:24:54 +000071# -D_GNU_SOURCE is needed because environ is used in init.c
Eric Andersen17d49ef1999-10-06 20:25:32 +000072ifeq ($(DODEBUG),true)
Erik Andersene132f4b2000-02-09 04:16:43 +000073 CFLAGS += -Wall -g -D_GNU_SOURCE
Erik Andersen0817d132000-04-09 15:17:40 +000074 LDFLAGS =
Erik Andersen9ffdaa62000-02-11 21:55:04 +000075 STRIP =
Eric Andersen17d49ef1999-10-06 20:25:32 +000076else
Erik Andersenfac10d72000-02-07 05:29:42 +000077 CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
78 LDFLAGS = -s
Erik Andersen7c4b2f32000-02-29 21:49:22 +000079 STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
Eric Andersena7093171999-10-23 05:42:08 +000080 #Only staticly link when _not_ debugging
81 ifeq ($(DOSTATIC),true)
Erik Andersenfac10d72000-02-07 05:29:42 +000082 LDFLAGS += --static
Eric Andersena7093171999-10-23 05:42:08 +000083 endif
Eric Andersen17d49ef1999-10-06 20:25:32 +000084endif
85
Eric Anderseneded54b1999-11-12 08:03:23 +000086ifndef $(PREFIX)
Erik Andersenfac10d72000-02-07 05:29:42 +000087 PREFIX = `pwd`/_install
Eric Andersen17d49ef1999-10-06 20:25:32 +000088endif
Eric Andersen17d49ef1999-10-06 20:25:32 +000089
Erik Andersenfac10d72000-02-07 05:29:42 +000090LIBRARIES =
Erik Andersene2729152000-02-18 21:34:17 +000091OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o
Erik Andersenfac10d72000-02-07 05:29:42 +000092CFLAGS += -DBB_VER='"$(VERSION)"'
93CFLAGS += -DBB_BT='"$(BUILDTIME)"'
Erik Andersend387d011999-12-21 02:55:11 +000094ifdef BB_INIT_SCRIPT
Erik Andersen9ffdaa62000-02-11 21:55:04 +000095 CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
Erik Andersend387d011999-12-21 02:55:11 +000096endif
97
Erik Andersen9cf3bfa2000-04-13 18:49:43 +000098all: busybox busybox.links docs
Eric Andersencc8ed391999-10-05 16:24:54 +000099
100busybox: $(OBJECTS)
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000101 $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES)
Erik Andersen7c4b2f32000-02-29 21:49:22 +0000102 $(STRIP)
Erik Andersen26702fe2000-04-17 16:44:46 +0000103
Erik Andersenfac10d72000-02-07 05:29:42 +0000104busybox.links: busybox.def.h
Eric Andersen96bcfd31999-11-12 01:30:18 +0000105 - ./busybox.mkll | sort >$@
Eric Andersen1667fb41999-11-27 20:34:28 +0000106
Erik Andersena6c75222000-04-18 00:00:52 +0000107docs:
108 $(MAKE) -C docs
109
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000110regexp.o nfsmount.o: %.o: %.h
Erik Andersena3e57ca2000-04-19 03:38:01 +0000111$(OBJECTS): %.o: busybox.def.h internal.h %.c Makefile
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000112
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000113test tests:
114 cd tests && $(MAKE) all
115
Eric Andersencc8ed391999-10-05 16:24:54 +0000116clean:
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000117 - rm -f busybox.links *~ *.o core
Eric Andersend00c2621999-12-07 08:37:31 +0000118 - rm -rf _install
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000119 - cd tests && $(MAKE) clean
Eric Andersencc8ed391999-10-05 16:24:54 +0000120
121distclean: clean
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000122 - rm -f busybox
123 - cd tests && $(MAKE) distclean
Eric Andersencc8ed391999-10-05 16:24:54 +0000124
Eric Andersen07274581999-11-21 21:50:07 +0000125install: busybox busybox.links
Eric Andersen80974fa1999-11-13 04:51:47 +0000126 ./install.sh $(PREFIX)
Eric Andersen17d49ef1999-10-06 20:25:32 +0000127
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000128dist release: distclean
Erik Andersena6c75222000-04-18 00:00:52 +0000129 $(MAKE) -C docs
Erik Andersenfac10d72000-02-07 05:29:42 +0000130 cd ..; \
131 rm -rf busybox-$(VERSION); \
132 cp -a busybox busybox-$(VERSION); \
133 \
134 find busybox-$(VERSION)/ -type d \
135 -name CVS \
136 -print \
137 | xargs rm -rf; \
138 \
139 find busybox-$(VERSION)/ -type f \
140 -name .cvsignore \
141 -print \
142 | xargs rm -f; \
143 \
144 tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;