blob: 6f49f0a527964858b0b4b956607620bcf48ffd24 [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 Andersen4d1d0111999-12-17 18:44:15 +000020VERSION=0.40
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 Andersen0881de72000-01-05 09:34:26 +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" )
Eric Andersend80e8511999-11-16 00:46:00 +000036
37GCCSUPPORTSOPTSIZE=$(shell \
38if ( test $(GCCMAJVERSION) -eq 2 ) ; then \
Eric Andersenab746ab1999-11-18 20:33:45 +000039 if ( test $(GCCMINVERSION) -ge 91 ) ; then \
Eric Andersend80e8511999-11-16 00:46:00 +000040 echo "true"; \
41 else \
42 echo "false"; \
43 fi; \
44else \
45 if ( test $(GCCMAJVERSION) -gt 2 ) ; then \
46 echo "true"; \
47 else \
48 echo "false"; \
49 fi; \
50fi; )
51
52
53ifeq ($(GCCSUPPORTSOPTSIZE), true)
54 OPTIMIZATION=-Os
55else
56 OPTIMIZATION=-O2
57endif
Eric Andersencc8ed391999-10-05 16:24:54 +000058
Eric Andersencc8ed391999-10-05 16:24:54 +000059# -D_GNU_SOURCE is needed because environ is used in init.c
Eric Andersen17d49ef1999-10-06 20:25:32 +000060ifeq ($(DODEBUG),true)
Eric Andersena9c95ea1999-11-15 17:33:30 +000061 CFLAGS+=-Wall -g -D_GNU_SOURCE -DDEBUG_INIT
Eric Andersen17d49ef1999-10-06 20:25:32 +000062 STRIP=
Eric Andersen8341a151999-10-08 17:14:14 +000063 LDFLAGS=
Eric Andersen17d49ef1999-10-06 20:25:32 +000064else
Eric Andersend80e8511999-11-16 00:46:00 +000065 CFLAGS+=-Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
Eric Andersen8341a151999-10-08 17:14:14 +000066 LDFLAGS= -s
Eric Andersence8f3b91999-10-20 07:03:36 +000067 STRIP= strip --remove-section=.note --remove-section=.comment $(PROG)
Eric Andersena7093171999-10-23 05:42:08 +000068 #Only staticly link when _not_ debugging
69 ifeq ($(DOSTATIC),true)
70 LDFLAGS+= --static
71 endif
72
Eric Andersen17d49ef1999-10-06 20:25:32 +000073endif
74
Eric Anderseneded54b1999-11-12 08:03:23 +000075ifndef $(PREFIX)
Eric Andersend00c2621999-12-07 08:37:31 +000076 PREFIX=`pwd`/_install
Eric Andersen17d49ef1999-10-06 20:25:32 +000077endif
Eric Andersen17d49ef1999-10-06 20:25:32 +000078
Eric Andersena07f0b01999-10-22 19:49:09 +000079LIBRARIES=
Eric Andersen596e5461999-10-07 08:30:23 +000080OBJECTS=$(shell ./busybox.sh)
Eric Andersencc8ed391999-10-05 16:24:54 +000081CFLAGS+= -DBB_VER='"$(VERSION)"'
82CFLAGS+= -DBB_BT='"$(BUILDTIME)"'
Erik Andersend387d011999-12-21 02:55:11 +000083ifdef BB_INIT_SCRIPT
Erik Andersen96e2abd2000-01-07 11:40:44 +000084 CFLAGS += -DINIT_SCRIPT=${BB_INIT_SCRIPT}
Erik Andersend387d011999-12-21 02:55:11 +000085endif
86
Eric Andersen96bcfd31999-11-12 01:30:18 +000087all: busybox busybox.links
Eric Andersencc8ed391999-10-05 16:24:54 +000088
89busybox: $(OBJECTS)
Eric Andersenf8d650c1999-10-19 23:27:54 +000090 $(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES)
Eric Andersence8f3b91999-10-20 07:03:36 +000091 $(STRIP)
Eric Andersencc8ed391999-10-05 16:24:54 +000092
Eric Andersen96bcfd31999-11-12 01:30:18 +000093busybox.links:
94 - ./busybox.mkll | sort >$@
Eric Andersen1667fb41999-11-27 20:34:28 +000095
Eric Andersencc8ed391999-10-05 16:24:54 +000096clean:
Eric Andersenf8d650c1999-10-19 23:27:54 +000097 - rm -f $(PROG) busybox.links *~ *.o core
Eric Andersend00c2621999-12-07 08:37:31 +000098 - rm -rf _install
Eric Andersencc8ed391999-10-05 16:24:54 +000099
100distclean: clean
Eric Andersenf8d650c1999-10-19 23:27:54 +0000101 - rm -f $(PROG)
Eric Andersencc8ed391999-10-05 16:24:54 +0000102
Eric Andersen9d3aba71999-10-06 09:04:55 +0000103$(OBJECTS): busybox.def.h internal.h Makefile
Eric Andersen17d49ef1999-10-06 20:25:32 +0000104
Eric Andersen07274581999-11-21 21:50:07 +0000105install: busybox busybox.links
Eric Andersen80974fa1999-11-13 04:51:47 +0000106 ./install.sh $(PREFIX)
Eric Andersen17d49ef1999-10-06 20:25:32 +0000107
Eric Andersended62591999-11-18 00:19:26 +0000108dist: release
109
Eric Andersen96bcfd31999-11-12 01:30:18 +0000110release: distclean
Eric Andersended62591999-11-18 00:19:26 +0000111 (cd .. ; rm -rf busybox-$(VERSION) ; cp -a busybox busybox-$(VERSION); rm -rf busybox-$(VERSION)/CVS busybox-$(VERSION)/.cvsignore ; tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION))
Eric Andersen96bcfd31999-11-12 01:30:18 +0000112
Eric Andersen1667fb41999-11-27 20:34:28 +0000113