Eric Andersen | c499601 | 1999-10-20 22:08:37 +0000 | [diff] [blame] | 1 | # 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 Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 18 | |
Eric Andersen | f8d650c | 1999-10-19 23:27:54 +0000 | [diff] [blame] | 19 | PROG=busybox |
Erik Andersen | 4d1d011 | 1999-12-17 18:44:15 +0000 | [diff] [blame] | 20 | VERSION=0.40 |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 21 | BUILDTIME=$(shell date "+%Y%m%d-%H%M") |
Eric Andersen | 21943ce | 1999-10-13 18:04:51 +0000 | [diff] [blame] | 22 | |
| 23 | # Comment out the following to make a debuggable build |
| 24 | # Leave this off for production use. |
Erik Andersen | 0881de7 | 2000-01-05 09:34:26 +0000 | [diff] [blame] | 25 | DODEBUG=false |
Eric Andersen | a709317 | 1999-10-23 05:42:08 +0000 | [diff] [blame] | 26 | # 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... |
| 29 | DOSTATIC=false |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 30 | |
| 31 | #This will choke on a non-debian system |
| 32 | ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'` |
| 33 | |
Erik Andersen | 4d1d011 | 1999-12-17 18:44:15 +0000 | [diff] [blame] | 34 | GCCMAJVERSION=$(shell $(CC) --version | sed -n "s/^\([^\.]*\).*/\1/p" ) |
| 35 | GCCMINVERSION=$(shell $(CC) --version | sed -n "s/^[^\.]*\.\([^\.]*\)[\.].*/\1/p" ) |
Eric Andersen | d80e851 | 1999-11-16 00:46:00 +0000 | [diff] [blame] | 36 | |
| 37 | GCCSUPPORTSOPTSIZE=$(shell \ |
| 38 | if ( test $(GCCMAJVERSION) -eq 2 ) ; then \ |
Eric Andersen | ab746ab | 1999-11-18 20:33:45 +0000 | [diff] [blame] | 39 | if ( test $(GCCMINVERSION) -ge 91 ) ; then \ |
Eric Andersen | d80e851 | 1999-11-16 00:46:00 +0000 | [diff] [blame] | 40 | echo "true"; \ |
| 41 | else \ |
| 42 | echo "false"; \ |
| 43 | fi; \ |
| 44 | else \ |
| 45 | if ( test $(GCCMAJVERSION) -gt 2 ) ; then \ |
| 46 | echo "true"; \ |
| 47 | else \ |
| 48 | echo "false"; \ |
| 49 | fi; \ |
| 50 | fi; ) |
| 51 | |
| 52 | |
| 53 | ifeq ($(GCCSUPPORTSOPTSIZE), true) |
| 54 | OPTIMIZATION=-Os |
| 55 | else |
| 56 | OPTIMIZATION=-O2 |
| 57 | endif |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 58 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 59 | # -D_GNU_SOURCE is needed because environ is used in init.c |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 60 | ifeq ($(DODEBUG),true) |
Eric Andersen | a9c95ea | 1999-11-15 17:33:30 +0000 | [diff] [blame] | 61 | CFLAGS+=-Wall -g -D_GNU_SOURCE -DDEBUG_INIT |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 62 | STRIP= |
Eric Andersen | 8341a15 | 1999-10-08 17:14:14 +0000 | [diff] [blame] | 63 | LDFLAGS= |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 64 | else |
Eric Andersen | d80e851 | 1999-11-16 00:46:00 +0000 | [diff] [blame] | 65 | CFLAGS+=-Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE |
Eric Andersen | 8341a15 | 1999-10-08 17:14:14 +0000 | [diff] [blame] | 66 | LDFLAGS= -s |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 67 | STRIP= strip --remove-section=.note --remove-section=.comment $(PROG) |
Eric Andersen | a709317 | 1999-10-23 05:42:08 +0000 | [diff] [blame] | 68 | #Only staticly link when _not_ debugging |
| 69 | ifeq ($(DOSTATIC),true) |
| 70 | LDFLAGS+= --static |
| 71 | endif |
| 72 | |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 73 | endif |
| 74 | |
Eric Andersen | eded54b | 1999-11-12 08:03:23 +0000 | [diff] [blame] | 75 | ifndef $(PREFIX) |
Eric Andersen | d00c262 | 1999-12-07 08:37:31 +0000 | [diff] [blame] | 76 | PREFIX=`pwd`/_install |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 77 | endif |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 78 | |
Eric Andersen | a07f0b0 | 1999-10-22 19:49:09 +0000 | [diff] [blame] | 79 | LIBRARIES= |
Eric Andersen | 596e546 | 1999-10-07 08:30:23 +0000 | [diff] [blame] | 80 | OBJECTS=$(shell ./busybox.sh) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 81 | CFLAGS+= -DBB_VER='"$(VERSION)"' |
| 82 | CFLAGS+= -DBB_BT='"$(BUILDTIME)"' |
Erik Andersen | d387d01 | 1999-12-21 02:55:11 +0000 | [diff] [blame] | 83 | ifdef BB_INIT_SCRIPT |
Erik Andersen | 96e2abd | 2000-01-07 11:40:44 +0000 | [diff] [blame] | 84 | CFLAGS += -DINIT_SCRIPT=${BB_INIT_SCRIPT} |
Erik Andersen | d387d01 | 1999-12-21 02:55:11 +0000 | [diff] [blame] | 85 | endif |
| 86 | |
Eric Andersen | 96bcfd3 | 1999-11-12 01:30:18 +0000 | [diff] [blame] | 87 | all: busybox busybox.links |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 88 | |
| 89 | busybox: $(OBJECTS) |
Eric Andersen | f8d650c | 1999-10-19 23:27:54 +0000 | [diff] [blame] | 90 | $(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES) |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 91 | $(STRIP) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 92 | |
Eric Andersen | 96bcfd3 | 1999-11-12 01:30:18 +0000 | [diff] [blame] | 93 | busybox.links: |
| 94 | - ./busybox.mkll | sort >$@ |
Eric Andersen | 1667fb4 | 1999-11-27 20:34:28 +0000 | [diff] [blame] | 95 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 96 | clean: |
Eric Andersen | f8d650c | 1999-10-19 23:27:54 +0000 | [diff] [blame] | 97 | - rm -f $(PROG) busybox.links *~ *.o core |
Eric Andersen | d00c262 | 1999-12-07 08:37:31 +0000 | [diff] [blame] | 98 | - rm -rf _install |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 99 | |
| 100 | distclean: clean |
Eric Andersen | f8d650c | 1999-10-19 23:27:54 +0000 | [diff] [blame] | 101 | - rm -f $(PROG) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 102 | |
Eric Andersen | 9d3aba7 | 1999-10-06 09:04:55 +0000 | [diff] [blame] | 103 | $(OBJECTS): busybox.def.h internal.h Makefile |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 104 | |
Eric Andersen | 0727458 | 1999-11-21 21:50:07 +0000 | [diff] [blame] | 105 | install: busybox busybox.links |
Eric Andersen | 80974fa | 1999-11-13 04:51:47 +0000 | [diff] [blame] | 106 | ./install.sh $(PREFIX) |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 107 | |
Eric Andersen | ded6259 | 1999-11-18 00:19:26 +0000 | [diff] [blame] | 108 | dist: release |
| 109 | |
Eric Andersen | 96bcfd3 | 1999-11-12 01:30:18 +0000 | [diff] [blame] | 110 | release: distclean |
Eric Andersen | ded6259 | 1999-11-18 00:19:26 +0000 | [diff] [blame] | 111 | (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 Andersen | 96bcfd3 | 1999-11-12 01:30:18 +0000 | [diff] [blame] | 112 | |
Eric Andersen | 1667fb4 | 1999-11-27 20:34:28 +0000 | [diff] [blame] | 113 | |