Eric Andersen | c499601 | 1999-10-20 22:08:37 +0000 | [diff] [blame] | 1 | # Makefile for busybox |
| 2 | # |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 3 | # Copyright (C) 1999-2000 Erik Andersen <andersee@debian.org> |
| 4 | # Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org> |
| 5 | # |
Eric Andersen | c499601 | 1999-10-20 22:08:37 +0000 | [diff] [blame] | 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 | |
Erik Andersen | 7c4b2f3 | 2000-02-29 21:49:22 +0000 | [diff] [blame] | 21 | PROG := busybox |
Eric Andersen | c6cdf58 | 2000-06-21 22:50:59 +0000 | [diff] [blame] | 22 | VERSION := 0.45 |
Erik Andersen | 1ad302a | 2000-03-24 00:54:46 +0000 | [diff] [blame] | 23 | BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z") |
John Beppu | cbd6628 | 2000-04-13 22:57:45 +0000 | [diff] [blame] | 24 | export VERSION |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 25 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 26 | # Set the following to `true' to make a debuggable build. |
| 27 | # Leave this set to `false' for production use. |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 28 | # eg: `make DODEBUG=true tests' |
Eric Andersen | 854e115 | 2000-06-13 06:57:56 +0000 | [diff] [blame] | 29 | DODEBUG = false |
Eric Andersen | 21943ce | 1999-10-13 18:04:51 +0000 | [diff] [blame] | 30 | |
Erik Andersen | f3b3d17 | 2000-04-09 18:24:05 +0000 | [diff] [blame] | 31 | # If you want a static binary, turn this on. |
Erik Andersen | c0dac18 | 2000-04-06 07:24:45 +0000 | [diff] [blame] | 32 | DOSTATIC = false |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 33 | |
Erik Andersen | 499f65f | 2000-05-16 20:07:38 +0000 | [diff] [blame] | 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... |
Eric Andersen | 1e03add | 2000-07-06 09:56:35 +0000 | [diff] [blame] | 36 | #GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp") |
| 37 | #CFLAGS+=-nostdinc -fno-builtin -I/home/andersen/CVS/uC-libc/include -I$(GCCINCDIR) |
Eric Andersen | 28c88a9 | 2000-06-20 21:03:24 +0000 | [diff] [blame] | 38 | #LDFLAGS+=-nostdlib |
| 39 | #LIBRARIES = /home/andersen/CVS/uC-libc/libc.a |
Erik Andersen | 499f65f | 2000-05-16 20:07:38 +0000 | [diff] [blame] | 40 | |
| 41 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 42 | CC = gcc |
Eric Andersen | d80e851 | 1999-11-16 00:46:00 +0000 | [diff] [blame] | 43 | |
Erik Andersen | 3d427ac | 2000-05-12 19:38:40 +0000 | [diff] [blame] | 44 | # use '-Os' optimization if available, else use -O2 |
| 45 | OPTIMIZATION = $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ |
| 46 | then echo "-Os"; else echo "-O2" ; fi) |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 47 | |
| 48 | |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 49 | # Allow alternative stripping tools to be used... |
| 50 | ifndef $(STRIPTOOL) |
| 51 | STRIPTOOL = strip |
| 52 | endif |
| 53 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 54 | # -D_GNU_SOURCE is needed because environ is used in init.c |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 55 | ifeq ($(DODEBUG),true) |
Eric Andersen | a44790f | 2000-06-28 20:11:28 +0000 | [diff] [blame] | 56 | CFLAGS += -Wall -g -D_GNU_SOURCE |
Eric Andersen | 28c88a9 | 2000-06-20 21:03:24 +0000 | [diff] [blame] | 57 | LDFLAGS += |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 58 | STRIP = |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 59 | else |
Eric Andersen | a44790f | 2000-06-28 20:11:28 +0000 | [diff] [blame] | 60 | CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE |
Eric Andersen | 28c88a9 | 2000-06-20 21:03:24 +0000 | [diff] [blame] | 61 | LDFLAGS += -s |
Erik Andersen | 7c4b2f3 | 2000-02-29 21:49:22 +0000 | [diff] [blame] | 62 | STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG) |
Eric Andersen | a709317 | 1999-10-23 05:42:08 +0000 | [diff] [blame] | 63 | #Only staticly link when _not_ debugging |
| 64 | ifeq ($(DOSTATIC),true) |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 65 | LDFLAGS += --static |
Erik Andersen | 23dea9b | 2000-05-13 00:28:25 +0000 | [diff] [blame] | 66 | # |
| 67 | #use '-ffunction-sections -fdata-sections' and '--gc-sections' if they work |
| 68 | #to try and strip out any unused junk. Doesn't do much for me, but you may |
| 69 | #want to give it a shot... |
| 70 | # |
| 71 | #ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \ |
Erik Andersen | 499f65f | 2000-05-16 20:07:38 +0000 | [diff] [blame] | 72 | # -o /dev/null -xc /dev/null 2>/dev/null && $(LD) --gc-sections -v >/dev/null && echo 1),1) |
| 73 | # CFLAGS += -ffunction-sections -fdata-sections |
| 74 | # LDFLAGS += --gc-sections |
Erik Andersen | 23dea9b | 2000-05-13 00:28:25 +0000 | [diff] [blame] | 75 | #endif |
Eric Andersen | a709317 | 1999-10-23 05:42:08 +0000 | [diff] [blame] | 76 | endif |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 77 | endif |
| 78 | |
Eric Andersen | eded54b | 1999-11-12 08:03:23 +0000 | [diff] [blame] | 79 | ifndef $(PREFIX) |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 80 | PREFIX = `pwd`/_install |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 81 | endif |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 82 | |
Erik Andersen | e272915 | 2000-02-18 21:34:17 +0000 | [diff] [blame] | 83 | OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 84 | CFLAGS += -DBB_VER='"$(VERSION)"' |
| 85 | CFLAGS += -DBB_BT='"$(BUILDTIME)"' |
Erik Andersen | d387d01 | 1999-12-21 02:55:11 +0000 | [diff] [blame] | 86 | ifdef BB_INIT_SCRIPT |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 87 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' |
Erik Andersen | d387d01 | 1999-12-21 02:55:11 +0000 | [diff] [blame] | 88 | endif |
| 89 | |
Eric Andersen | 67536ff | 2000-07-06 22:53:22 +0000 | [diff] [blame] | 90 | all: busybox busybox.links doc |
Erik Andersen | 0a704e8 | 2000-05-03 03:19:06 +0000 | [diff] [blame] | 91 | |
Eric Andersen | 67536ff | 2000-07-06 22:53:22 +0000 | [diff] [blame] | 92 | doc: olddoc |
Eric Andersen | 5331025 | 2000-07-04 19:42:23 +0000 | [diff] [blame] | 93 | |
| 94 | # Old Docs... |
Eric Andersen | 67536ff | 2000-07-06 22:53:22 +0000 | [diff] [blame] | 95 | olddoc: docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html |
Eric Andersen | 5331025 | 2000-07-04 19:42:23 +0000 | [diff] [blame] | 96 | |
Eric Andersen | 67536ff | 2000-07-06 22:53:22 +0000 | [diff] [blame] | 97 | docs/BusyBox.txt: docs/busybox.pod |
Eric Andersen | 5331025 | 2000-07-04 19:42:23 +0000 | [diff] [blame] | 98 | @echo |
| 99 | @echo BusyBox Documentation |
| 100 | @echo |
| 101 | - pod2text docs/busybox.pod > docs/BusyBox.txt |
| 102 | |
Eric Andersen | 67536ff | 2000-07-06 22:53:22 +0000 | [diff] [blame] | 103 | docs/BusyBox.1: docs/busybox.pod |
Eric Andersen | 5331025 | 2000-07-04 19:42:23 +0000 | [diff] [blame] | 104 | - pod2man --center=BusyBox --release="version $(VERSION)" docs/busybox.pod > docs/BusyBox.1 |
| 105 | |
Eric Andersen | 67536ff | 2000-07-06 22:53:22 +0000 | [diff] [blame] | 106 | docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html |
Eric Andersen | 5331025 | 2000-07-04 19:42:23 +0000 | [diff] [blame] | 107 | - rm -f docs/BusyBox.html |
| 108 | - ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html |
| 109 | |
Eric Andersen | 67536ff | 2000-07-06 22:53:22 +0000 | [diff] [blame] | 110 | docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod |
Eric Andersen | 2086e3d | 2000-07-04 22:17:01 +0000 | [diff] [blame] | 111 | - pod2html --noindex docs/busybox.pod > docs/busybox.lineo.com/BusyBox.html |
Erik Andersen | 0a704e8 | 2000-05-03 03:19:06 +0000 | [diff] [blame] | 112 | - rm -f pod2html* |
| 113 | |
Eric Andersen | 67536ff | 2000-07-06 22:53:22 +0000 | [diff] [blame] | 114 | |
| 115 | # New docs based on DOCBOOK SGML |
| 116 | newdoc: docs/busybox.txt docs/busybox.pdf docs/busybox/busybox.html |
| 117 | |
| 118 | docs/busybox.txt: docs/busybox.sgml |
| 119 | @echo |
| 120 | @echo BusyBox Documentation |
| 121 | @echo |
| 122 | (cd docs; sgmltools -b txt busybox.sgml) |
| 123 | |
| 124 | docs/busybox.dvi: docs/busybox.sgml |
| 125 | (cd docs; sgmltools -b dvi busybox.sgml) |
| 126 | |
Eric Andersen | a2c83d8 | 2000-07-07 20:52:56 +0000 | [diff] [blame] | 127 | docs/busybox.ps: docs/busybox.sgml |
Eric Andersen | 67536ff | 2000-07-06 22:53:22 +0000 | [diff] [blame] | 128 | (cd docs; sgmltools -b ps busybox.sgml) |
| 129 | |
Eric Andersen | a2c83d8 | 2000-07-07 20:52:56 +0000 | [diff] [blame] | 130 | docs/busybox.pdf: docs/busybox.ps |
Eric Andersen | 67536ff | 2000-07-06 22:53:22 +0000 | [diff] [blame] | 131 | (cd docs; ps2pdf busybox.ps) |
| 132 | |
| 133 | docs/busybox/busybox.html: docs/busybox.sgml |
| 134 | (cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml) |
| 135 | |
| 136 | |
| 137 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 138 | busybox: $(OBJECTS) |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 139 | $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES) |
Erik Andersen | 7c4b2f3 | 2000-02-29 21:49:22 +0000 | [diff] [blame] | 140 | $(STRIP) |
Erik Andersen | 1d1d950 | 2000-04-21 01:26:49 +0000 | [diff] [blame] | 141 | |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 142 | busybox.links: busybox.def.h |
Eric Andersen | 96bcfd3 | 1999-11-12 01:30:18 +0000 | [diff] [blame] | 143 | - ./busybox.mkll | sort >$@ |
Eric Andersen | 1667fb4 | 1999-11-27 20:34:28 +0000 | [diff] [blame] | 144 | |
Erik Andersen | 1d1d950 | 2000-04-21 01:26:49 +0000 | [diff] [blame] | 145 | regexp.o nfsmount.o cmdedit.o: %.o: %.h |
Erik Andersen | a3e57ca | 2000-04-19 03:38:01 +0000 | [diff] [blame] | 146 | $(OBJECTS): %.o: busybox.def.h internal.h %.c Makefile |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 147 | |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 148 | test tests: |
| 149 | cd tests && $(MAKE) all |
| 150 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 151 | clean: |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 152 | - rm -f busybox.links *~ *.o core |
Eric Andersen | d00c262 | 1999-12-07 08:37:31 +0000 | [diff] [blame] | 153 | - rm -rf _install |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 154 | - cd tests && $(MAKE) clean |
Eric Andersen | 67536ff | 2000-07-06 22:53:22 +0000 | [diff] [blame] | 155 | - rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \ |
| 156 | docs/busybox.lineo.com/BusyBox.html |
Eric Andersen | 5331025 | 2000-07-04 19:42:23 +0000 | [diff] [blame] | 157 | - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \ |
| 158 | docs/busybox.pdf docs/busybox.lineo.com/busybox.html |
| 159 | - rm -rf docs/busybox |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 160 | |
| 161 | distclean: clean |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 162 | - rm -f busybox |
| 163 | - cd tests && $(MAKE) distclean |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 164 | |
Eric Andersen | 0727458 | 1999-11-21 21:50:07 +0000 | [diff] [blame] | 165 | install: busybox busybox.links |
Eric Andersen | 80974fa | 1999-11-13 04:51:47 +0000 | [diff] [blame] | 166 | ./install.sh $(PREFIX) |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 167 | |
Erik Andersen | 0a704e8 | 2000-05-03 03:19:06 +0000 | [diff] [blame] | 168 | dist release: distclean doc |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 169 | cd ..; \ |
| 170 | rm -rf busybox-$(VERSION); \ |
| 171 | cp -a busybox busybox-$(VERSION); \ |
| 172 | \ |
| 173 | find busybox-$(VERSION)/ -type d \ |
| 174 | -name CVS \ |
| 175 | -print \ |
| 176 | | xargs rm -rf; \ |
| 177 | \ |
| 178 | find busybox-$(VERSION)/ -type f \ |
| 179 | -name .cvsignore \ |
| 180 | -print \ |
| 181 | | xargs rm -f; \ |
| 182 | \ |
Eric Andersen | b0b732b | 2000-07-06 23:17:16 +0000 | [diff] [blame] | 183 | find busybox-$(VERSION)/ -type f \ |
| 184 | -name .\#* \ |
| 185 | -print \ |
| 186 | | xargs rm -f; \ |
| 187 | \ |
Erik Andersen | fac10d7 | 2000-02-07 05:29:42 +0000 | [diff] [blame] | 188 | tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/; |
Mark Whitley | dd23b8b | 2000-07-10 23:00:47 +0000 | [diff] [blame^] | 189 | |
| 190 | .PHONY: tags |
| 191 | tags: |
| 192 | ctags -R . |