blob: 6543e1f898e3b60144493d144941033167ce356e [file] [log] [blame]
Eric Andersenc4996011999-10-20 22:08:37 +00001# 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 Andersenfac10d72000-02-07 05:29:42 +000018PROG := busybox
19VERSION := 0.42
20BUILDTIME := $(shell TZ=GMT date "+%Y%m%d-%H%M")
Eric Andersencc8ed391999-10-05 16:24:54 +000021
Erik Andersenfac10d72000-02-07 05:29:42 +000022# Set the following to `true' to make a debuggable build.
23# Leave this set to `false' for production use.
24# eg: `make DODEBUG=true'
25DODEBUG = false
Eric Andersen21943ce1999-10-13 18:04:51 +000026
Eric Andersena7093171999-10-23 05:42:08 +000027# 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 Andersenfac10d72000-02-07 05:29:42 +000030DOSTATIC = false
Eric Andersencc8ed391999-10-05 16:24:54 +000031
Erik Andersenfac10d72000-02-07 05:29:42 +000032# This will choke on a non-debian system
33ARCH =`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
Eric Andersencc8ed391999-10-05 16:24:54 +000034
Erik Andersenfac10d72000-02-07 05:29:42 +000035CC = gcc
Eric Andersend80e8511999-11-16 00:46:00 +000036
Erik Andersenfac10d72000-02-07 05:29:42 +000037GCCMAJVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\1/p")
38GCCMINVERSION = $(shell $(CC) --version | sed -n "s/^[^0-9]*\([0-9]\)\.\([0-9].*\)[\.].*/\2/p")
39
40
41GCCSUPPORTSOPTSIZE = $(shell \
42if ( test $(GCCMAJVERSION) -eq 2 ) ; then \
43 if ( test $(GCCMINVERSION) -ge 66 ) ; then \
44 echo "true"; \
45 else \
46 echo "false"; \
47 fi; \
48else \
49 if ( test $(GCCMAJVERSION) -gt 2 ) ; then \
50 echo "true"; \
51 else \
52 echo "false"; \
53 fi; \
Eric Andersend80e8511999-11-16 00:46:00 +000054fi; )
55
56
57ifeq ($(GCCSUPPORTSOPTSIZE), true)
Erik Andersenfac10d72000-02-07 05:29:42 +000058 OPTIMIZATION = -Os
Eric Andersend80e8511999-11-16 00:46:00 +000059else
Erik Andersenfac10d72000-02-07 05:29:42 +000060 OPTIMIZATION = -O2
Eric Andersend80e8511999-11-16 00:46:00 +000061endif
Eric Andersencc8ed391999-10-05 16:24:54 +000062
Eric Andersencc8ed391999-10-05 16:24:54 +000063# -D_GNU_SOURCE is needed because environ is used in init.c
Eric Andersen17d49ef1999-10-06 20:25:32 +000064ifeq ($(DODEBUG),true)
Erik Andersene132f4b2000-02-09 04:16:43 +000065 CFLAGS += -Wall -g -D_GNU_SOURCE
Erik Andersenfac10d72000-02-07 05:29:42 +000066 STRIP =
67 LDFLAGS =
Eric Andersen17d49ef1999-10-06 20:25:32 +000068else
Erik Andersenfac10d72000-02-07 05:29:42 +000069 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 Andersena7093171999-10-23 05:42:08 +000072 #Only staticly link when _not_ debugging
73 ifeq ($(DOSTATIC),true)
Erik Andersenfac10d72000-02-07 05:29:42 +000074 LDFLAGS += --static
Eric Andersena7093171999-10-23 05:42:08 +000075 endif
Eric Andersen17d49ef1999-10-06 20:25:32 +000076endif
77
Eric Anderseneded54b1999-11-12 08:03:23 +000078ifndef $(PREFIX)
Erik Andersenfac10d72000-02-07 05:29:42 +000079 PREFIX = `pwd`/_install
Eric Andersen17d49ef1999-10-06 20:25:32 +000080endif
Eric Andersen17d49ef1999-10-06 20:25:32 +000081
Erik Andersenfac10d72000-02-07 05:29:42 +000082LIBRARIES =
83OBJECTS = $(shell ./busybox.sh) messages.o utility.o
84CFLAGS += -DBB_VER='"$(VERSION)"'
85CFLAGS += -DBB_BT='"$(BUILDTIME)"'
Erik Andersend387d011999-12-21 02:55:11 +000086ifdef BB_INIT_SCRIPT
Erik Andersen96e2abd2000-01-07 11:40:44 +000087 CFLAGS += -DINIT_SCRIPT=${BB_INIT_SCRIPT}
Erik Andersend387d011999-12-21 02:55:11 +000088endif
89
Eric Andersen96bcfd31999-11-12 01:30:18 +000090all: busybox busybox.links
Eric Andersencc8ed391999-10-05 16:24:54 +000091
92busybox: $(OBJECTS)
Eric Andersenf8d650c1999-10-19 23:27:54 +000093 $(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES)
Eric Andersence8f3b91999-10-20 07:03:36 +000094 $(STRIP)
Eric Andersencc8ed391999-10-05 16:24:54 +000095
Erik Andersenfac10d72000-02-07 05:29:42 +000096busybox.links: busybox.def.h
Eric Andersen96bcfd31999-11-12 01:30:18 +000097 - ./busybox.mkll | sort >$@
Eric Andersen1667fb41999-11-27 20:34:28 +000098
Eric Andersencc8ed391999-10-05 16:24:54 +000099clean:
Eric Andersenf8d650c1999-10-19 23:27:54 +0000100 - rm -f $(PROG) busybox.links *~ *.o core
Eric Andersend00c2621999-12-07 08:37:31 +0000101 - rm -rf _install
Eric Andersencc8ed391999-10-05 16:24:54 +0000102
103distclean: clean
Eric Andersenf8d650c1999-10-19 23:27:54 +0000104 - rm -f $(PROG)
Eric Andersencc8ed391999-10-05 16:24:54 +0000105
Erik Andersenfac10d72000-02-07 05:29:42 +0000106$(OBJECTS): %.o: %.c busybox.def.h internal.h Makefile messages.c
Eric Andersen17d49ef1999-10-06 20:25:32 +0000107
Eric Andersen07274581999-11-21 21:50:07 +0000108install: busybox busybox.links
Eric Andersen80974fa1999-11-13 04:51:47 +0000109 ./install.sh $(PREFIX)
Eric Andersen17d49ef1999-10-06 20:25:32 +0000110
Eric Andersended62591999-11-18 00:19:26 +0000111dist: release
112
Eric Andersen96bcfd31999-11-12 01:30:18 +0000113release: distclean
Erik Andersenfac10d72000-02-07 05:29:42 +0000114 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)/;