Adjust install a bit...
[platform/upstream/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.35
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=false
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
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
34
35 # -D_GNU_SOURCE is needed because environ is used in init.c
36 ifeq ($(DODEBUG),true)
37     CFLAGS=-Wall -g -D_GNU_SOURCE -DDEBUG_INIT
38     STRIP=
39     LDFLAGS=
40 else
41     CFLAGS=-Wall -Os -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
42     LDFLAGS= -s
43     STRIP= strip --remove-section=.note --remove-section=.comment $(PROG)
44     #Only staticly link when _not_ debugging 
45     ifeq ($(DOSTATIC),true)
46         LDFLAGS+= --static
47     endif
48     
49 endif
50
51 ifndef $(PREFIX)
52     PREFIX=`pwd`/busybox_install
53 endif
54
55 LIBRARIES=
56 OBJECTS=$(shell ./busybox.sh)
57 CFLAGS+= -DBB_VER='"$(VERSION)"'
58 CFLAGS+= -DBB_BT='"$(BUILDTIME)"'
59
60 all: busybox busybox.links
61
62 busybox: $(OBJECTS)
63         $(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES)
64         $(STRIP)
65
66 busybox.links:
67         - ./busybox.mkll | sort >$@
68         
69 clean:
70         - rm -f $(PROG) busybox.links *~ *.o core 
71         - rm -rf busybox_install
72
73 distclean: clean
74         - rm -f $(PROG)
75
76 force:
77
78 $(OBJECTS):  busybox.def.h internal.h Makefile
79
80 install: busybox
81         install.sh $(PREFIX)
82
83 whichversion:
84         @echo $(VERSION)
85
86 release: distclean
87         (cd .. ; cp -a busybox busybox-$(VERSION); tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)) 
88