Bump version number to 0.45
[oweals/busybox.git] / Makefile
1 # Makefile for busybox
2 #
3 # Copyright (C) 1999-2000 Erik Andersen <andersee@debian.org>
4 # Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #
20
21 PROG      := busybox
22 VERSION   := 0.45
23 BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z")
24 export VERSION
25
26 # Set the following to `true' to make a debuggable build.
27 # Leave this set to `false' for production use.
28 # eg: `make DODEBUG=true tests'
29 DODEBUG = false
30
31 # If you want a static binary, turn this on.
32 DOSTATIC = false
33
34 # To compile vs an alternative libc, you may need to use/adjust
35 # the following lines to meet your needs.  This is how I did it...
36 #CFLAGS+=-nostdinc -I/home/andersen/CVS/uC-libc/include -I/usr/include/linux
37 #LDFLAGS+=-nostdlib
38 #LIBRARIES = /home/andersen/CVS/uC-libc/libc.a
39
40
41 CC = gcc
42
43 # use '-Os' optimization if available, else use -O2
44 OPTIMIZATION = $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
45     then echo "-Os"; else echo "-O2" ; fi)
46
47
48 # Allow alternative stripping tools to be used...
49 ifndef $(STRIPTOOL)
50     STRIPTOOL = strip
51 endif
52
53 # -D_GNU_SOURCE is needed because environ is used in init.c
54 ifeq ($(DODEBUG),true)
55     CFLAGS += -Wall -g -fno-builtin -D_GNU_SOURCE
56     LDFLAGS += 
57     STRIP   =
58 else
59     CFLAGS  += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
60     LDFLAGS  += -s
61     STRIP    = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
62     #Only staticly link when _not_ debugging 
63     ifeq ($(DOSTATIC),true)
64         LDFLAGS += --static
65         #
66         #use '-ffunction-sections -fdata-sections' and '--gc-sections' if they work
67         #to try and strip out any unused junk.  Doesn't do much for me, but you may
68         #want to give it a shot...
69         #
70         #ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
71         #       -o /dev/null -xc /dev/null 2>/dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1)
72         #       CFLAGS += -ffunction-sections -fdata-sections
73         #       LDFLAGS += --gc-sections
74         #endif
75     endif
76 endif
77
78 ifndef $(PREFIX)
79     PREFIX = `pwd`/_install
80 endif
81
82
83 OBJECTS   = $(shell ./busybox.sh) busybox.o messages.o utility.o
84 CFLAGS    += -DBB_VER='"$(VERSION)"'
85 CFLAGS    += -DBB_BT='"$(BUILDTIME)"'
86 ifdef BB_INIT_SCRIPT
87     CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
88 endif
89
90 all: busybox busybox.links doc
91
92 doc: docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
93
94 docs/BusyBox.txt: docs/busybox.pod
95         @echo
96         @echo BusyBox Documentation
97         @echo
98         - pod2text docs/busybox.pod > docs/BusyBox.txt
99
100 docs/BusyBox.1: docs/busybox.pod
101         - pod2man --center=BusyBox --release="version $(VERSION)" docs/busybox.pod > docs/BusyBox.1
102
103 docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html
104         - rm -f docs/BusyBox.html
105         - ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
106
107 docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
108         - pod2html docs/busybox.pod > docs/busybox.lineo.com/BusyBox.html
109         - rm -f pod2html*
110
111 busybox: $(OBJECTS)
112         $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES)
113         $(STRIP)
114
115 busybox.links: busybox.def.h
116         - ./busybox.mkll | sort >$@
117
118 regexp.o nfsmount.o cmdedit.o: %.o: %.h
119 $(OBJECTS): %.o: busybox.def.h internal.h  %.c Makefile
120
121 test tests:
122         cd tests && $(MAKE) all
123
124 clean:
125         - rm -f busybox.links *~ *.o core
126         - rm -rf _install
127         - cd tests && $(MAKE) clean
128         - rm -f docs/BusyBox.html docs/busybox.lineo.com/BusyBox.html \
129                 docs/BusyBox.1 docs/BusyBox.txt pod2html*
130
131 distclean: clean
132         - rm -f busybox
133         - cd tests && $(MAKE) distclean
134
135 install: busybox busybox.links
136         ./install.sh $(PREFIX)
137
138 dist release: distclean doc
139         cd ..;                                  \
140         rm -rf busybox-$(VERSION);              \
141         cp -a busybox busybox-$(VERSION);       \
142                                                 \
143         find busybox-$(VERSION)/ -type d        \
144                                  -name CVS      \
145                                  -print         \
146                 | xargs rm -rf;                 \
147                                                 \
148         find busybox-$(VERSION)/ -type f        \
149                                  -name .cvsignore \
150                                  -print         \
151                 | xargs rm -f;                  \
152                                                 \
153         tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;