blob: 91d4bd1c4495502691a98b9ba4837a7be1339d0a [file] [log] [blame]
Eric Andersenc4996011999-10-20 22:08:37 +00001# Makefile for busybox
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11# General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16#
17
Eric Andersencc8ed391999-10-05 16:24:54 +000018
Eric Andersenf8d650c1999-10-19 23:27:54 +000019PROG=busybox
Erik Andersen05df2392000-01-13 04:43:48 +000020VERSION=0.41
Eric Andersencc8ed391999-10-05 16:24:54 +000021BUILDTIME=$(shell date "+%Y%m%d-%H%M")
Eric Andersen21943ce1999-10-13 18:04:51 +000022
23# Comment out the following to make a debuggable build
24# Leave this off for production use.
Erik Andersen766f9c72000-01-08 21:20:49 +000025DODEBUG=false
Eric Andersena7093171999-10-23 05:42:08 +000026# If you want a static binary, turn this on. I can't think
27# of many situations where anybody would ever want it static,
28# but...
29DOSTATIC=false
Eric Andersencc8ed391999-10-05 16:24:54 +000030
31#This will choke on a non-debian system
32ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
33
Erik Andersen4d1d0111999-12-17 18:44:15 +000034GCCMAJVERSION=$(shell $(CC) --version | sed -n "s/^\([^\.]*\).*/\1/p" )
35GCCMINVERSION=$(shell $(CC) --version | sed -n "s/^[^\.]*\.\([^\.]*\)[\.].*/\1/p" )
Erik Andersen31638212000-01-15 22:28:50 +000036GCCEGCS=$(shell $(CC) --version | sed -n "s/.*\(egcs\).*/\1/p" )
Eric Andersend80e8511999-11-16 00:46:00 +000037
38GCCSUPPORTSOPTSIZE=$(shell \
39if ( test $(GCCMAJVERSION) -eq 2 ) ; then \
Erik Andersen31638212000-01-15 22:28:50 +000040 if ( test $(GCCMINVERSION) -ge 66 ) ; then \
Eric Andersend80e8511999-11-16 00:46:00 +000041 echo "true"; \
42 else \
43 echo "false"; \
44 fi; \
45else \
46 if ( test $(GCCMAJVERSION) -gt 2 ) ; then \
47 echo "true"; \
48 else \
49 echo "false"; \
50 fi; \
51fi; )
52
Erik Andersen31638212000-01-15 22:28:50 +000053GCCISEGCS=$(shell \
54if ( test "x$(GCCEGCS)" == "xegcs" ) ; then \
55 echo "true"; \
56 else \
57 echo "false"; \
58 fi; )
59
60EGCSEXTREMEFLAGS = -m386 -mcpu=i386 -march=i386 -malign-jumps=1 -malign-loops=1 -malign-functions=1
61GCCEXTREMEFLAGS = -m386 -malign-jumps=1 -malign-loops=1 -malign-functions=1
62
63ifeq ($(GCCISEGCS), true)
64 EXTREMEFLAGS = $(EGCSEXTREMEFLAGS)
65else
66 EXTREMEFLAGS = $(GCCEXTREMEFLAGS)
67endif
Eric Andersend80e8511999-11-16 00:46:00 +000068
69ifeq ($(GCCSUPPORTSOPTSIZE), true)
Erik Andersen31638212000-01-15 22:28:50 +000070 OPTIMIZATION=-Os $(EXTREMEFLAGS)
Eric Andersend80e8511999-11-16 00:46:00 +000071else
Erik Andersen31638212000-01-15 22:28:50 +000072 OPTIMIZATION=-O2 $(EXTREMEFLAGS)
Eric Andersend80e8511999-11-16 00:46:00 +000073endif
Eric Andersencc8ed391999-10-05 16:24:54 +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)
Eric Andersena9c95ea1999-11-15 17:33:30 +000077 CFLAGS+=-Wall -g -D_GNU_SOURCE -DDEBUG_INIT
Eric Andersen17d49ef1999-10-06 20:25:32 +000078 STRIP=
Eric Andersen8341a151999-10-08 17:14:14 +000079 LDFLAGS=
Eric Andersen17d49ef1999-10-06 20:25:32 +000080else
Eric Andersend80e8511999-11-16 00:46:00 +000081 CFLAGS+=-Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
Eric Andersen8341a151999-10-08 17:14:14 +000082 LDFLAGS= -s
Eric Andersence8f3b91999-10-20 07:03:36 +000083 STRIP= strip --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)
86 LDFLAGS+= --static
87 endif
88
Eric Andersen17d49ef1999-10-06 20:25:32 +000089endif
90
Eric Anderseneded54b1999-11-12 08:03:23 +000091ifndef $(PREFIX)
Eric Andersend00c2621999-12-07 08:37:31 +000092 PREFIX=`pwd`/_install
Eric Andersen17d49ef1999-10-06 20:25:32 +000093endif
Eric Andersen17d49ef1999-10-06 20:25:32 +000094
Eric Andersena07f0b01999-10-22 19:49:09 +000095LIBRARIES=
Eric Andersen596e5461999-10-07 08:30:23 +000096OBJECTS=$(shell ./busybox.sh)
Eric Andersencc8ed391999-10-05 16:24:54 +000097CFLAGS+= -DBB_VER='"$(VERSION)"'
98CFLAGS+= -DBB_BT='"$(BUILDTIME)"'
Erik Andersend387d011999-12-21 02:55:11 +000099ifdef BB_INIT_SCRIPT
Erik Andersen96e2abd2000-01-07 11:40:44 +0000100 CFLAGS += -DINIT_SCRIPT=${BB_INIT_SCRIPT}
Erik Andersend387d011999-12-21 02:55:11 +0000101endif
102
Eric Andersen96bcfd31999-11-12 01:30:18 +0000103all: busybox busybox.links
Eric Andersencc8ed391999-10-05 16:24:54 +0000104
105busybox: $(OBJECTS)
Eric Andersenf8d650c1999-10-19 23:27:54 +0000106 $(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES)
Eric Andersence8f3b91999-10-20 07:03:36 +0000107 $(STRIP)
Eric Andersencc8ed391999-10-05 16:24:54 +0000108
Eric Andersen96bcfd31999-11-12 01:30:18 +0000109busybox.links:
110 - ./busybox.mkll | sort >$@
Eric Andersen1667fb41999-11-27 20:34:28 +0000111
Eric Andersencc8ed391999-10-05 16:24:54 +0000112clean:
Eric Andersenf8d650c1999-10-19 23:27:54 +0000113 - rm -f $(PROG) busybox.links *~ *.o core
Eric Andersend00c2621999-12-07 08:37:31 +0000114 - rm -rf _install
Eric Andersencc8ed391999-10-05 16:24:54 +0000115
116distclean: clean
Eric Andersenf8d650c1999-10-19 23:27:54 +0000117 - rm -f $(PROG)
Eric Andersencc8ed391999-10-05 16:24:54 +0000118
Eric Andersen9d3aba71999-10-06 09:04:55 +0000119$(OBJECTS): busybox.def.h internal.h Makefile
Eric Andersen17d49ef1999-10-06 20:25:32 +0000120
Eric Andersen07274581999-11-21 21:50:07 +0000121install: busybox busybox.links
Eric Andersen80974fa1999-11-13 04:51:47 +0000122 ./install.sh $(PREFIX)
Eric Andersen17d49ef1999-10-06 20:25:32 +0000123
Eric Andersended62591999-11-18 00:19:26 +0000124dist: release
125
Eric Andersen96bcfd31999-11-12 01:30:18 +0000126release: distclean
Erik Andersen9b5c0b72000-01-07 18:33:06 +0000127 (cd .. ; rm -rf busybox-$(VERSION) ; cp -a busybox busybox-$(VERSION); rm -rf busybox-$(VERSION)/CVS busybox-$(VERSION)/scripts/CVS busybox-$(VERSION)/docs/CVS busybox-$(VERSION)/.cvsignore ; tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION))
Eric Andersen96bcfd31999-11-12 01:30:18 +0000128
Eric Andersen1667fb41999-11-27 20:34:28 +0000129