diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 109 |
1 files changed, 62 insertions, 47 deletions
@@ -15,71 +15,74 @@ | |||
15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
16 | # | 16 | # |
17 | 17 | ||
18 | PROG := busybox | ||
19 | VERSION := 0.42 | ||
20 | BUILDTIME := $(shell TZ=GMT date "+%Y%m%d-%H%M") | ||
18 | 21 | ||
19 | PROG=busybox | 22 | # Set the following to `true' to make a debuggable build. |
20 | VERSION=0.42 | 23 | # Leave this set to `false' for production use. |
21 | BUILDTIME=$(shell date "+%Y%m%d-%H%M") | 24 | # eg: `make DODEBUG=true' |
25 | DODEBUG = false | ||
22 | 26 | ||
23 | # Comment out the following to make a debuggable build | ||
24 | # Leave this off for production use. | ||
25 | DODEBUG=false | ||
26 | # If you want a static binary, turn this on. I can't think | 27 | # 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 | # of many situations where anybody would ever want it static, |
28 | # but... | 29 | # but... |
29 | DOSTATIC=false | 30 | DOSTATIC = false |
30 | 31 | ||
31 | #This will choke on a non-debian system | 32 | # This will choke on a non-debian system |
32 | ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'` | 33 | ARCH =`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'` |
33 | 34 | ||
34 | GCCMAJVERSION=$(shell $(CC) --version | sed -n "s/^\([^\.]*\).*/\1/p" ) | 35 | CC = gcc |
35 | GCCMINVERSION=$(shell $(CC) --version | sed -n "s/^[^\.]*\.\([^\.]*\)[\.].*/\1/p" ) | 36 | |
36 | 37 | GCCMAJVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\1/p") | |
37 | GCCSUPPORTSOPTSIZE=$(shell \ | 38 | GCCMINVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\2/p") |
38 | if ( test $(GCCMAJVERSION) -eq 2 ) ; then \ | 39 | |
39 | if ( test $(GCCMINVERSION) -ge 66 ) ; then \ | 40 | |
40 | echo "true"; \ | 41 | GCCSUPPORTSOPTSIZE = $(shell \ |
41 | else \ | 42 | if ( test $(GCCMAJVERSION) -eq 2 ) ; then \ |
42 | echo "false"; \ | 43 | if ( test $(GCCMINVERSION) -ge 66 ) ; then \ |
43 | fi; \ | 44 | echo "true"; \ |
44 | else \ | 45 | else \ |
45 | if ( test $(GCCMAJVERSION) -gt 2 ) ; then \ | 46 | echo "false"; \ |
46 | echo "true"; \ | 47 | fi; \ |
47 | else \ | 48 | else \ |
48 | echo "false"; \ | 49 | if ( test $(GCCMAJVERSION) -gt 2 ) ; then \ |
49 | fi; \ | 50 | echo "true"; \ |
51 | else \ | ||
52 | echo "false"; \ | ||
53 | fi; \ | ||
50 | fi; ) | 54 | fi; ) |
51 | 55 | ||
52 | 56 | ||
53 | ifeq ($(GCCSUPPORTSOPTSIZE), true) | 57 | ifeq ($(GCCSUPPORTSOPTSIZE), true) |
54 | OPTIMIZATION=-Os | 58 | OPTIMIZATION = -Os |
55 | else | 59 | else |
56 | OPTIMIZATION=-O2 | 60 | OPTIMIZATION = -O2 |
57 | endif | 61 | endif |
58 | 62 | ||
59 | # -D_GNU_SOURCE is needed because environ is used in init.c | 63 | # -D_GNU_SOURCE is needed because environ is used in init.c |
60 | ifeq ($(DODEBUG),true) | 64 | ifeq ($(DODEBUG),true) |
61 | CFLAGS+=-Wall -g -D_GNU_SOURCE -DDEBUG_INIT | 65 | CFLAGS += -Wall -g -D_GNU_SOURCE -DDEBUG_INIT |
62 | STRIP= | 66 | STRIP = |
63 | LDFLAGS= | 67 | LDFLAGS = |
64 | else | 68 | else |
65 | CFLAGS+=-Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE | 69 | CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE |
66 | LDFLAGS= -s | 70 | LDFLAGS = -s |
67 | STRIP= strip --remove-section=.note --remove-section=.comment $(PROG) | 71 | STRIP = strip --remove-section=.note --remove-section=.comment $(PROG) |
68 | #Only staticly link when _not_ debugging | 72 | #Only staticly link when _not_ debugging |
69 | ifeq ($(DOSTATIC),true) | 73 | ifeq ($(DOSTATIC),true) |
70 | LDFLAGS+= --static | 74 | LDFLAGS += --static |
71 | endif | 75 | endif |
72 | |||
73 | endif | 76 | endif |
74 | 77 | ||
75 | ifndef $(PREFIX) | 78 | ifndef $(PREFIX) |
76 | PREFIX=`pwd`/_install | 79 | PREFIX = `pwd`/_install |
77 | endif | 80 | endif |
78 | 81 | ||
79 | LIBRARIES= | 82 | LIBRARIES = |
80 | OBJECTS=$(shell ./busybox.sh) | 83 | OBJECTS = $(shell ./busybox.sh) messages.o utility.o |
81 | CFLAGS+= -DBB_VER='"$(VERSION)"' | 84 | CFLAGS += -DBB_VER='"$(VERSION)"' |
82 | CFLAGS+= -DBB_BT='"$(BUILDTIME)"' | 85 | CFLAGS += -DBB_BT='"$(BUILDTIME)"' |
83 | ifdef BB_INIT_SCRIPT | 86 | ifdef BB_INIT_SCRIPT |
84 | CFLAGS += -DINIT_SCRIPT=${BB_INIT_SCRIPT} | 87 | CFLAGS += -DINIT_SCRIPT=${BB_INIT_SCRIPT} |
85 | endif | 88 | endif |
@@ -90,7 +93,7 @@ busybox: $(OBJECTS) | |||
90 | $(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES) | 93 | $(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES) |
91 | $(STRIP) | 94 | $(STRIP) |
92 | 95 | ||
93 | busybox.links: | 96 | busybox.links: busybox.def.h |
94 | - ./busybox.mkll | sort >$@ | 97 | - ./busybox.mkll | sort >$@ |
95 | 98 | ||
96 | clean: | 99 | clean: |
@@ -100,7 +103,7 @@ clean: | |||
100 | distclean: clean | 103 | distclean: clean |
101 | - rm -f $(PROG) | 104 | - rm -f $(PROG) |
102 | 105 | ||
103 | $(OBJECTS): busybox.def.h internal.h Makefile | 106 | $(OBJECTS): %.o: %.c busybox.def.h internal.h Makefile messages.c |
104 | 107 | ||
105 | install: busybox busybox.links | 108 | install: busybox busybox.links |
106 | ./install.sh $(PREFIX) | 109 | ./install.sh $(PREFIX) |
@@ -108,6 +111,18 @@ install: busybox busybox.links | |||
108 | dist: release | 111 | dist: release |
109 | 112 | ||
110 | release: distclean | 113 | release: distclean |
111 | (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)) | 114 | cd ..; \ |
112 | 115 | rm -rf busybox-$(VERSION); \ | |
113 | 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)/; | ||