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 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 18 | PROG := busybox |
| 19 | VERSION := 0.42 |
| 20 | BUILDTIME := $(shell TZ=GMT date "+%Y%m%d-%H%M") |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 21 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 22 | # Set the following to `true' to make a debuggable build. |
| 23 | # Leave this set to `false' for production use. |
| 24 | # eg: `make DODEBUG=true' |
| 25 | DODEBUG = false |
Eric Andersen | 21943ce | 1999-10-13 18:04:51 +0000 | [diff] [blame] | 26 | |
Eric Andersen | a709317 | 1999-10-23 05:42:08 +0000 | [diff] [blame] | 27 | # If you want a static binary, turn this on. I can't think |
| 28 | # of many situations where anybody would ever want it static, |
| 29 | # but... |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 30 | DOSTATIC = false |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 31 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 32 | # This will choke on a non-debian system |
| 33 | ARCH =`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'` |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 34 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 35 | CC = gcc |
Eric Andersen | d80e851 | 1999-11-16 00:46:00 +0000 | [diff] [blame] | 36 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 37 | GCCMAJVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\1/p") |
| 38 | GCCMINVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\2/p") |
| 39 | |
| 40 | |
| 41 | GCCSUPPORTSOPTSIZE = $(shell \ |
| 42 | if ( test $(GCCMAJVERSION) -eq 2 ) ; then \ |
| 43 | if ( test $(GCCMINVERSION) -ge 66 ) ; then \ |
| 44 | echo "true"; \ |
| 45 | else \ |
| 46 | echo "false"; \ |
| 47 | fi; \ |
| 48 | else \ |
| 49 | if ( test $(GCCMAJVERSION) -gt 2 ) ; then \ |
| 50 | echo "true"; \ |
| 51 | else \ |
| 52 | echo "false"; \ |
| 53 | fi; \ |
Eric Andersen | d80e851 | 1999-11-16 00:46:00 +0000 | [diff] [blame] | 54 | fi; ) |
| 55 | |
| 56 | |
| 57 | ifeq ($(GCCSUPPORTSOPTSIZE), true) |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 58 | OPTIMIZATION = -Os |
Eric Andersen | d80e851 | 1999-11-16 00:46:00 +0000 | [diff] [blame] | 59 | else |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 60 | OPTIMIZATION = -O2 |
Eric Andersen | d80e851 | 1999-11-16 00:46:00 +0000 | [diff] [blame] | 61 | endif |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 62 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 63 | # -D_GNU_SOURCE is needed because environ is used in init.c |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 64 | ifeq ($(DODEBUG),true) |
Erik Andersen | e132f4b | 2000-02-09 04:16:43 +0000 | [diff] [blame] | 65 | CFLAGS += -Wall -g -D_GNU_SOURCE |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 66 | STRIP = |
| 67 | LDFLAGS = |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 68 | else |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 69 | CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE |
| 70 | LDFLAGS = -s |
| 71 | STRIP = strip --remove-section=.note --remove-section=.comment $(PROG) |
Eric Andersen | a709317 | 1999-10-23 05:42:08 +0000 | [diff] [blame] | 72 | #Only staticly link when _not_ debugging |
| 73 | ifeq ($(DOSTATIC),true) |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 74 | LDFLAGS += --static |
Eric Andersen | a709317 | 1999-10-23 05:42:08 +0000 | [diff] [blame] | 75 | endif |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 76 | endif |
| 77 | |
Eric Andersen | eded54b | 1999-11-12 08:03:23 +0000 | [diff] [blame] | 78 | ifndef $(PREFIX) |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 79 | PREFIX = `pwd`/_install |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 80 | endif |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 81 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 82 | LIBRARIES = |
| 83 | OBJECTS = $(shell ./busybox.sh) messages.o utility.o |
| 84 | CFLAGS += -DBB_VER='"$(VERSION)"' |
| 85 | CFLAGS += -DBB_BT='"$(BUILDTIME)"' |
Erik Andersen | d387d01 | 1999-12-21 02:55:11 +0000 | [diff] [blame] | 86 | ifdef BB_INIT_SCRIPT |
Erik Andersen | 96e2abd | 2000-01-07 11:40:44 +0000 | [diff] [blame] | 87 | CFLAGS += -DINIT_SCRIPT=${BB_INIT_SCRIPT} |
Erik Andersen | d387d01 | 1999-12-21 02:55:11 +0000 | [diff] [blame] | 88 | endif |
| 89 | |
Eric Andersen | 96bcfd3 | 1999-11-12 01:30:18 +0000 | [diff] [blame] | 90 | all: busybox busybox.links |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 91 | |
| 92 | busybox: $(OBJECTS) |
Eric Andersen | f8d650c | 1999-10-19 23:27:54 +0000 | [diff] [blame] | 93 | $(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES) |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 94 | $(STRIP) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 95 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 96 | busybox.links: busybox.def.h |
Eric Andersen | 96bcfd3 | 1999-11-12 01:30:18 +0000 | [diff] [blame] | 97 | - ./busybox.mkll | sort >$@ |
Eric Andersen | 1667fb4 | 1999-11-27 20:34:28 +0000 | [diff] [blame] | 98 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 99 | clean: |
Eric Andersen | f8d650c | 1999-10-19 23:27:54 +0000 | [diff] [blame] | 100 | - rm -f $(PROG) busybox.links *~ *.o core |
Eric Andersen | d00c262 | 1999-12-07 08:37:31 +0000 | [diff] [blame] | 101 | - rm -rf _install |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 102 | |
| 103 | distclean: clean |
Eric Andersen | f8d650c | 1999-10-19 23:27:54 +0000 | [diff] [blame] | 104 | - rm -f $(PROG) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 105 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 106 | $(OBJECTS): %.o: %.c busybox.def.h internal.h Makefile messages.c |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 107 | |
Eric Andersen | 0727458 | 1999-11-21 21:50:07 +0000 | [diff] [blame] | 108 | install: busybox busybox.links |
Eric Andersen | 80974fa | 1999-11-13 04:51:47 +0000 | [diff] [blame] | 109 | ./install.sh $(PREFIX) |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 110 | |
Eric Andersen | ded6259 | 1999-11-18 00:19:26 +0000 | [diff] [blame] | 111 | dist: release |
| 112 | |
Eric Andersen | 96bcfd3 | 1999-11-12 01:30:18 +0000 | [diff] [blame] | 113 | release: distclean |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 114 | cd ..; \ |
| 115 | rm -rf busybox-$(VERSION); \ |
| 116 | cp -a busybox busybox-$(VERSION); \ |
| 117 | \ |
| 118 | find busybox-$(VERSION)/ -type d \ |
| 119 | -name CVS \ |
| 120 | -print \ |
| 121 | | xargs rm -rf; \ |
| 122 | \ |
| 123 | find busybox-$(VERSION)/ -type f \ |
| 124 | -name .cvsignore \ |
| 125 | -print \ |
| 126 | | xargs rm -f; \ |
| 127 | \ |
| 128 | tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/; |