aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile247
1 files changed, 41 insertions, 206 deletions
diff --git a/Makefile b/Makefile
index 19c28edf3..28b041ce0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
1# Makefile for busybox 1# Makefile for busybox
2# 2#
3# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org> 3# Copyright (C) 1999-2002 Erik Andersen <andersee@debian.org>
4# 4#
5# This program is free software; you can redistribute it and/or modify 5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by 6# it under the terms of the GNU General Public License as published by
@@ -17,175 +17,13 @@
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18# 18#
19 19
20PROG := busybox 20TOPDIR:= $(shell /bin/pwd)/
21VERSION := 0.61.pre 21include $(TOPDIR).config
22BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z") 22include $(TOPDIR)Rules.mak
23TOPDIR := ${shell /bin/pwd} 23SUBDIRS:=applets archival archival/libunarchive console-tools \
24HOSTCC := gcc 24 editors fileutils findutils init miscutils modutils networking \
25HOSTCFLAGS:= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer 25 procps pwd_grp pwd_grp/libpwd_grp shell shellutils sysklogd \
26 26 textutils util-linux libbb
27
28# What OS are you compiling busybox for? This allows you to include
29# OS specific things, syscall overrides, etc.
30TARGET_OS := linux
31
32# With a modern GNU make(1) (highly recommended, that's what all the
33# developers use), all of the following configuration values can be
34# overridden at the command line. For example:
35# make CROSS=powerpc-linux- BB_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
36
37# If you want to add some simple compiler switches (like -march=i686),
38# especially from the command line, use this instead of CFLAGS directly.
39# For optimization overrides, it's better still to set OPTIMIZATION.
40CFLAGS_EXTRA =
41
42# If you want a static binary, turn this on.
43DOSTATIC = false
44
45# Set the following to `true' to make a debuggable build.
46# Leave this set to `false' for production use.
47DODEBUG = false
48
49# This enables compiling with dmalloc ( http://dmalloc.com/ )
50# which is an excellent public domain mem leak and malloc problem
51# detector. To enable dmalloc, before running busybox you will
52# want to first set up your environment.
53# eg: `export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile`
54# The debug= value is generated using the following command
55# dmalloc -p log-stats -p log-non-free -p log-bad-space -p log-elapsed-time \
56# -p check-fence -p check-heap -p check-lists -p check-blank \
57# -p check-funcs -p realloc-copy -p allow-free-null
58# Do not enable this for production builds...
59DODMALLOC = false
60
61# Electric-fence is another very useful malloc debugging library.
62# Do not enable this for production builds...
63DOEFENCE = false
64
65# If you want large file summit support, turn this on.
66# This has no effect if you don't have a kernel with lfs
67# support, and a system with libc-2.1.3 or later.
68# Some of the programs that can benefit from lfs support
69# are dd, gzip, mount, tar, and mkfs_minix.
70# LFS allows you to use the above programs for files
71# larger than 2GB!
72DOLFS = false
73
74# If you have a "pristine" source directory, point BB_SRC_DIR to it.
75# Experimental and incomplete; tell the mailing list
76# <busybox@busybox.net> if you do or don't like it so far.
77BB_SRC_DIR =
78
79# If you are running a cross compiler, you may want to set CROSS
80# to something more interesting, like "arm-linux-".
81CROSS =
82CC = $(CROSS)gcc
83AR = $(CROSS)ar
84AS = $(CROSS)as
85LD = $(CROSS)ld
86NM = $(CROSS)nm
87STRIP = $(CROSS)strip
88CPP = $(CC) -E
89MAKEFILES = $(TOPDIR)/.config
90export VERSION BUILDTIME TOPDIR HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
91
92
93# To compile vs uClibc, just use the compiler wrapper built by uClibc...
94# Everything should compile and work as expected these days...
95#CC = /usr/i386-linux-uclibc/usr/bin/i386-uclibc-gcc
96
97# To compile vs some other alternative libc, you may need to use/adjust
98# the following lines to meet your needs...
99#
100# If you are using Red Hat 6.x with the compatible RPMs (for developing under
101# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
102# using the compatible RPMs (compat-*) at http://www.redhat.com !
103#LIBCDIR=/usr/i386-glibc20-linux
104#
105# The following is used for libc5 (if you install altgcc and libc5-altdev
106# on a Debian system).
107#LIBCDIR=/usr/i486-linuxlibc1
108#
109# For other libraries, you are on your own...
110#LDFLAGS+=-nostdlib
111#LIBRARIES = $(LIBCDIR)/lib/libc.a -lgcc
112#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
113#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
114
115# use '-Os' optimization if available, else use -O2
116OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null \
117 >/dev/null 2>&1; then echo "-Os"; else echo "-O2" ; fi}
118GCC_STACK_BOUNDRY := ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc /dev/null \
119 >/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; else echo "" ; fi}
120OPTIMIZATIONS=$(OPTIMIZATION) -fomit-frame-pointer $(GCC_STACK_BOUNDRY) #-fstrict-aliasing -march=i386 -mcpu=i386 -malign-functions=0 -malign-jumps=0
121WARNINGS=-Wall -Wstrict-prototypes -Wshadow
122CFLAGS = -I$(TOPDIR)/include
123ARFLAGS = -r
124
125#
126#--------------------------------------------------------
127# If you're going to do a lot of builds with a non-vanilla configuration,
128# it makes sense to adjust parameters above, so you can type "make"
129# by itself, instead of following it by the same half-dozen overrides
130# every time. The stuff below, on the other hand, is probably less
131# prone to casual user adjustment.
132#
133
134ifeq ($(strip $(DOLFS)),true)
135 # For large file summit support
136 CFLAGS+=-D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64
137endif
138ifeq ($(strip $(DODMALLOC)),true)
139 # For testing mem leaks with dmalloc
140 CFLAGS+=-DDMALLOC
141 LIBRARIES = -ldmalloc
142 # Force debug=true, since this is useless when not debugging...
143 DODEBUG = true
144else
145 ifeq ($(strip $(DOEFENCE)),true)
146 LIBRARIES = -lefence
147 # Force debug=true, since this is useless when not debugging...
148 DODEBUG = true
149 endif
150endif
151ifeq ($(strip $(DODEBUG)),true)
152 CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
153 LDFLAGS += -Wl,-warn-common
154 STRIPCMD = /bin/true -Not_stripping_since_we_are_debugging
155else
156 CFLAGS += $(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE
157 LDFLAGS += -s -Wl,-warn-common
158 STRIPCMD = $(STRIP) --remove-section=.note --remove-section=.comment
159endif
160ifeq ($(strip $(DOSTATIC)),true)
161 LDFLAGS += --static
162endif
163
164ifndef $(PREFIX)
165 PREFIX = `pwd`/_install
166endif
167
168# Additional complications due to support for pristine source dir.
169# Include files in the build directory should take precedence over
170# the copy in BB_SRC_DIR, both during the compilation phase and the
171# shell script that finds the list of object files.
172# Work in progress by <ldoolitt@recycle.lbl.gov>.
173#
174ifneq ($(strip $(BB_SRC_DIR)),)
175 VPATH = $(BB_SRC_DIR)
176endif
177
178OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
179CFLAGS += $(CROSS_CFLAGS)
180ifdef BB_INIT_SCRIPT
181 CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
182endif
183
184# Put user-supplied flags at the end, where they
185# have a chance of winning.
186CFLAGS += $(CFLAGS_EXTRA)
187
188.EXPORT_ALL_VARIABLES:
189 27
190all: do-it-all 28all: do-it-all
191 29
@@ -196,7 +34,8 @@ ifeq (.config,$(wildcard .config))
196include .config 34include .config
197ifeq (.depend,$(wildcard .depend)) 35ifeq (.depend,$(wildcard .depend))
198include .depend 36include .depend
199do-it-all: busybox busybox.links doc 37do-it-all: busybox busybox.links #doc
38include $(patsubst %,%/Makefile.in, $(SUBDIRS))
200else 39else
201CONFIGURATION = depend 40CONFIGURATION = depend
202do-it-all: depend 41do-it-all: depend
@@ -207,18 +46,9 @@ do-it-all: menuconfig
207endif 46endif
208 47
209 48
210SUBDIRS =applets archival archival/libunarchive console-tools editors \ 49busybox: depend $(libraries-y)
211 fileutils findutils init miscutils modutils networking procps \ 50 $(CC) $(LDFLAGS) $(libraries-y) $(LIBRARIES) -o $@
212 pwd_grp shell shellutils sysklogd textutils util-linux libbb 51 $(STRIPCMD) $@
213
214bbsubdirs: $(patsubst %, _dir_%, $(SUBDIRS))
215
216$(patsubst %, _dir_%, $(SUBDIRS)) : dummy include/config/MARKER
217 $(MAKE) CFLAGS="$(CFLAGS)" -C $(patsubst _dir_%, %, $@)
218
219busybox: config.h dep-files bbsubdirs
220 $(CC) $(LDFLAGS) -o $@ applets/busybox.o $(shell find $(SUBDIRS) -name \*.a) $(LIBRARIES)
221 $(STRIPCMD) $(PROG)
222 52
223busybox.links: applets/busybox.mkll 53busybox.links: applets/busybox.mkll
224 - $(SHELL) $^ >$@ 54 - $(SHELL) $^ >$@
@@ -291,52 +121,52 @@ docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
291 - mkdir -p docs 121 - mkdir -p docs
292 (cd docs/busybox.net; sgmltools -b html ../busybox.sgml) 122 (cd docs/busybox.net; sgmltools -b html ../busybox.sgml)
293 123
124
125
294# The nifty new buildsystem stuff 126# The nifty new buildsystem stuff
295scripts/mkdep: scripts/mkdep.c 127$(TOPDIR)scripts/mkdep: scripts/mkdep.c
296 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c 128 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
297 129
298scripts/split-include: scripts/split-include.c 130$(TOPDIR)scripts/split-include: scripts/split-include.c
299 $(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c 131 $(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
300 132
301dep-files: scripts/mkdep 133$(TOPDIR).depend: $(TOPDIR)scripts/mkdep
302 @if [ ! -f .depend ] ; then \ 134 rm -f .depend .hdepend;
303 rm -f .depend .hdepend; \ 135 mkdir -p $(TOPDIR)include/config;
304 mkdir -p $(TOPDIR)/include/config; \ 136 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
305 scripts/mkdep -I $(TOPDIR)/include -- \ 137 scripts/mkdep -I $(TOPDIR)include -- \
306 `find $(TOPDIR) -name \*.c -print` >> .depend; \ 138 `find $(TOPDIR) -name \*.c -print` >> .depend;
307 scripts/mkdep -I $(TOPDIR)/include -- \ 139 scripts/mkdep -I $(TOPDIR)include -- \
308 `find $(TOPDIR) -name \*.h -print` >> .hdepend; \ 140 `find $(TOPDIR) -name \*.h -print` >> .hdepend;
309 $(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)" ; \ 141 $(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)" ;
310 fi;
311
312
313depend dep: config.h dep-files
314 @ echo -e "\n\nNow run 'make' to build BusyBox\n\n" 142 @ echo -e "\n\nNow run 'make' to build BusyBox\n\n"
315 143
144depend dep: $(TOPDIR)include/config.h $(TOPDIR).depend
145
316BB_SHELL := ${shell if [ -x "$$BASH" ]; then echo $$BASH; \ 146BB_SHELL := ${shell if [ -x "$$BASH" ]; then echo $$BASH; \
317 else if [ -x /bin/bash ]; then echo /bin/bash; \ 147 else if [ -x /bin/bash ]; then echo /bin/bash; \
318 else echo sh; fi ; fi} 148 else echo sh; fi ; fi}
319 149
320include/config/MARKER: scripts/split-include include/config.h 150include/config/MARKER: depend $(TOPDIR)scripts/split-include
321 scripts/split-include include/config.h include/config 151 scripts/split-include include/config.h include/config
322 @ touch include/config/MARKER 152 @ touch include/config/MARKER
323 153
324config.h: 154$(TOPDIR)include/config.h:
325 @if [ ! -f include/config.h ] ; then \ 155 @if [ ! -f $(TOPDIR)include/config.h ] ; then \
326 make oldconfig; \ 156 make oldconfig; \
327 fi; 157 fi;
328 158
329menuconfig: 159menuconfig:
330 mkdir -p $(TOPDIR)/include/config 160 mkdir -p $(TOPDIR)include/config
331 $(MAKE) -C scripts/lxdialog all 161 $(MAKE) -C scripts/lxdialog all
332 $(BB_SHELL) scripts/Menuconfig sysdeps/$(TARGET_OS)/config.in 162 $(BB_SHELL) scripts/Menuconfig sysdeps/$(TARGET_OS)/config.in
333 163
334config: 164config:
335 mkdir -p $(TOPDIR)/include/config 165 mkdir -p $(TOPDIR)include/config
336 $(BB_SHELL) scripts/Configure sysdeps/$(TARGET_OS)/config.in 166 $(BB_SHELL) scripts/Configure sysdeps/$(TARGET_OS)/config.in
337 167
338oldconfig: 168oldconfig:
339 mkdir -p $(TOPDIR)/include/config 169 mkdir -p $(TOPDIR)include/config
340 $(BB_SHELL) scripts/Configure -d sysdeps/$(TARGET_OS)/config.in 170 $(BB_SHELL) scripts/Configure -d sysdeps/$(TARGET_OS)/config.in
341 171
342 172
@@ -359,7 +189,10 @@ dummy:
359 189
360endif 190endif
361 191
362include Rules.mak 192
193%.o: %.c
194 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
195
363 196
364# Testing... 197# Testing...
365test tests: 198test tests:
@@ -407,9 +240,11 @@ dist release: distclean doc
407 240
408 241
409 242
410.PHONY: tags check 243.PHONY: tags check depend
244
411tags: 245tags:
412 ctags -R . 246 ctags -R .
413 247
414check: busybox 248check: busybox
415 cd testsuite && ./runtest 249 cd testsuite && ./runtest
250