9701f4f0ad1db040bd7e88ac235527ecbe9801ba
[oweals/busybox.git] / Makefile
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
18
19 PROG=busybox
20 VERSION=0.31
21 BUILDTIME=$(shell date "+%Y%m%d-%H%M")
22
23 # Comment out the following to make a debuggable build
24 # Leave this off for production use.
25 #DODEBUG=true
26
27 #This will choke on a non-debian system
28 ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
29
30
31 # -D_GNU_SOURCE is needed because environ is used in init.c
32 ifeq ($(DODEBUG),true)
33     CFLAGS=-Wall -g -D_GNU_SOURCE
34     STRIP=
35     LDFLAGS=
36 else
37     CFLAGS=-Wall -Os -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
38     LDFLAGS= -s
39     STRIP= strip --remove-section=.note --remove-section=.comment $(PROG)
40 endif
41
42 ifndef $(prefix)
43     prefix=`pwd`
44 endif
45 BINDIR=$(prefix)
46
47 LIBRARIES=-lc
48 OBJECTS=$(shell ./busybox.sh)
49 CFLAGS+= -DBB_VER='"$(VERSION)"'
50 CFLAGS+= -DBB_BT='"$(BUILDTIME)"'
51
52 all: busybox links
53
54 busybox: $(OBJECTS)
55         $(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES)
56         $(STRIP)
57
58 links:
59         - ./busybox.mkll | sort >busybox.links
60         
61 clean:
62         - rm -f $(PROG) busybox.links *~ *.o core 
63
64 distclean: clean
65         - rm -f $(PROG)
66
67 force:
68
69 $(OBJECTS):  busybox.def.h internal.h Makefile
70
71 install:    $(PROG)
72         install.sh $(BINDIR)
73