aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-02-17 00:42:47 +0000
committerEric Andersen <andersen@codepoet.org>2001-02-17 00:42:47 +0000
commit19f86207f5c9cdcd192295e3ac3130a40f180d39 (patch)
treed84d5ef8a6914a3a2b77c360471d195f0c32a8e2 /Makefile
parent69c8572f296380df78a20818ca9208b35b7dbd16 (diff)
downloadbusybox-w32-19f86207f5c9cdcd192295e3ac3130a40f180d39.tar.gz
busybox-w32-19f86207f5c9cdcd192295e3ac3130a40f180d39.tar.bz2
busybox-w32-19f86207f5c9cdcd192295e3ac3130a40f180d39.zip
Update the build system for pristine source directory builds. This
update is primarily work done by Larry Doolittle, but I did some touchups of my own to make it work for me, -Erik
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile129
1 files changed, 89 insertions, 40 deletions
diff --git a/Makefile b/Makefile
index 588f8e0a2..e0f888087 100644
--- a/Makefile
+++ b/Makefile
@@ -72,7 +72,7 @@ DOLFS = false
72# If you have a "pristine" source directory, point BB_SRC_DIR to it. 72# If you have a "pristine" source directory, point BB_SRC_DIR to it.
73# Experimental and incomplete; tell the mailing list 73# Experimental and incomplete; tell the mailing list
74# <busybox@opensource.lineo.com> if you do or don't like it so far. 74# <busybox@opensource.lineo.com> if you do or don't like it so far.
75BB_SRC_DIR = . 75BB_SRC_DIR =
76 76
77# If you are running a cross compiler, you may want to set this 77# If you are running a cross compiler, you may want to set this
78# to something more interesting, like "powerpc-linux-". 78# to something more interesting, like "powerpc-linux-".
@@ -94,14 +94,21 @@ STRIPTOOL = $(CROSS)strip
94#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) 94#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
95#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp") 95#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
96 96
97#--------------------------------------------------------
98
99# use '-Os' optimization if available, else use -O2 97# use '-Os' optimization if available, else use -O2
100OPTIMIZATION = $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ 98OPTIMIZATION := $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
101 then echo "-Os"; else echo "-O2" ; fi) 99 then echo "-Os"; else echo "-O2" ; fi)
102 100
103WARNINGS = -Wall 101WARNINGS = -Wall
104 102
103#
104#--------------------------------------------------------
105# If you're going to do a lot of builds with a non-vanilla configuration,
106# it makes sense to adjust parameters above, so you can type "make"
107# by itself, instead of following it by the same half-dozen overrides
108# every time. The stuff below, on the other hand, is probably less
109# prone to casual user adjustment.
110#
111
105ifeq ($(strip $(DOLFS)),true) 112ifeq ($(strip $(DOLFS)),true)
106 # For large file summit support 113 # For large file summit support
107 CFLAGS+=-D_FILE_OFFSET_BITS=64 114 CFLAGS+=-D_FILE_OFFSET_BITS=64
@@ -142,22 +149,48 @@ ifndef $(PREFIX)
142endif 149endif
143 150
144# Additional complications due to support for pristine source dir. 151# Additional complications due to support for pristine source dir.
145# Config.h in the build directory should take precedence over the 152# Include files in the build directory should take precedence over
146# copy in BB_SRC_DIR, both during the compilation phase and the 153# the copy in BB_SRC_DIR, both during the compilation phase and the
147# shell script that finds the list of object files. 154# shell script that finds the list of object files.
148#
149# Work in progress by <ldoolitt@recycle.lbl.gov>. 155# Work in progress by <ldoolitt@recycle.lbl.gov>.
150# If it gets in your way, set DISABLE_VPATH=yes 156#
151ifeq ($(strip $(DISABLE_VPATH)),yes) 157ifneq ($(strip $(BB_SRC_DIR)),)
152 CONFIG_H = Config.h 158 VPATH = $(BB_SRC_DIR)
153else
154 VPATH = .:$(BB_SRC_DIR)
155 CONFIG_LIST = $(addsuffix /Config.h,$(subst :, ,$(VPATH)))
156 CONFIG_H = $(word 1,$(shell ls -f -1 $(CONFIG_LIST) 2>/dev/null))
157 CFLAGS += -I- $(patsubst %,-I%,$(subst :, ,$(VPATH)))
158endif 159endif
159 160#ifneq ($(strip $(VPATH)),)
160OBJECTS = $(shell $(BB_SRC_DIR)/busybox.sh $(CONFIG_H) $(BB_SRC_DIR)) busybox.o messages.o usage.o utility.o 161# CFLAGS += -I- -I. $(patsubst %,-I%,$(subst :, ,$(VPATH)))
162#endif
163
164# We need to set APPLET_SOURCES to something like
165# $(shell busybox.sh Config.h)
166# but in a manner that works with VPATH and BB_SRC_DIR.
167# Possible ways to approach this:
168#
169# 1. Explicitly search through .:$(VPATH) for busybox.sh and config.h,
170# then $(shell $(BUSYBOX_SH) $(CONFIG_H) $(BB_SRC_DIR))
171#
172# 2. Explicity search through .:$(VPATH) for slist.mk,
173# then $(shell $(MAKE) -f $(SLIST_MK) VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR))
174#
175# 3. Create slist.mk in this directory, with commands embedded in
176# a $(shell ...) command, and $(MAKE) it immediately.
177#
178# 4. Use a real rule within this makefile to create a file that sets
179# APPLET_SOURCE_LIST, then include that file. Has complications
180# with the first trip through the makefile (before processing the
181# include) trying to do too much, and a spurious warning the first
182# time make is run.
183#
184# This is option 3:
185#
186#APPLET_SOURCES = $(shell \
187# echo -e 'all: busybox.sh Config.h\n\t@ $$(SHELL) $$^ $$(BB_SRC_DIR)' >slist.mk; \
188# make -f slist.mk VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR) \
189#)
190# And option 4:
191-include applet_source_list
192
193OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o messages.o usage.o utility.o
161CFLAGS += $(CROSS_CFLAGS) 194CFLAGS += $(CROSS_CFLAGS)
162CFLAGS += -DBB_VER='"$(VERSION)"' 195CFLAGS += -DBB_VER='"$(VERSION)"'
163CFLAGS += -DBB_BT='"$(BUILDTIME)"' 196CFLAGS += -DBB_BT='"$(BUILDTIME)"'
@@ -166,20 +199,29 @@ ifdef BB_INIT_SCRIPT
166endif 199endif
167 200
168ifneq ($(strip $(USE_SYSTEM_PWD_GRP)),true) 201ifneq ($(strip $(USE_SYSTEM_PWD_GRP)),true)
169 PWD_LIB = pwd_grp/libpwd.a 202 PWD_GRP = pwd_grp
170 LIBRARIES += $(PWD_LIB) 203 PWD_GRP_DIR = $(BB_SRC_DIR)$(PWD_GRP)
204 PWD_LIB = libpwd.a
205 LIBRARIES += $(PWD_LIB)
206 PWD_CSRC=__getpwent.c pwent.c getpwnam.c getpwuid.c putpwent.c getpw.c \
207 fgetpwent.c __getgrent.c grent.c getgrnam.c getgrgid.c fgetgrent.c \
208 initgroups.c setgroups.c
209 PWD_OBJS=$(patsubst %.c,$(PWD_GRP)/%.o, $(PWD_CSRC))
210 PWD_CFLAGS = -I$(PWD_GRP_DIR)
171else 211else
172 CFLAGS += -DUSE_SYSTEM_PWD_GRP 212 CFLAGS += -DUSE_SYSTEM_PWD_GRP
173endif 213endif
174 214
175
176# Put user-supplied flags at the end, where they 215# Put user-supplied flags at the end, where they
177# have a chance of winning. 216# have a chance of winning.
178CFLAGS += $(CFLAGS_EXTRA) 217CFLAGS += $(CFLAGS_EXTRA)
179 218
180.EXPORT_ALL_VARIABLES: 219.EXPORT_ALL_VARIABLES:
181 220
182all: busybox busybox.links doc 221all: applet_source_list busybox busybox.links doc
222
223applet_source_list: busybox.sh Config.h
224 (echo -n "APPLET_SOURCES := "; $(SHELL) $^ $(BB_SRC_DIR)) > $@
183 225
184doc: olddoc 226doc: olddoc
185 227
@@ -191,12 +233,12 @@ docs/BusyBox.txt: docs/busybox.pod
191 @echo BusyBox Documentation 233 @echo BusyBox Documentation
192 @echo 234 @echo
193 -mkdir -p docs 235 -mkdir -p docs
194 -pod2text $(BB_SRC_DIR)/docs/busybox.pod > docs/BusyBox.txt 236 -pod2text $< > $@
195 237
196docs/BusyBox.1: docs/busybox.pod 238docs/BusyBox.1: docs/busybox.pod
197 - mkdir -p docs 239 - mkdir -p docs
198 - pod2man --center=BusyBox --release="version $(VERSION)" \ 240 - pod2man --center=BusyBox --release="version $(VERSION)" \
199 $(BB_SRC_DIR)/docs/busybox.pod > docs/BusyBox.1 241 $< > $@
200 242
201docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html 243docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html
202 -@ rm -f docs/BusyBox.html 244 -@ rm -f docs/BusyBox.html
@@ -204,7 +246,7 @@ docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html
204 246
205docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod 247docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
206 -@ mkdir -p docs/busybox.lineo.com 248 -@ mkdir -p docs/busybox.lineo.com
207 - pod2html --noindex $(BB_SRC_DIR)/docs/busybox.pod > \ 249 - pod2html --noindex $< > \
208 docs/busybox.lineo.com/BusyBox.html 250 docs/busybox.lineo.com/BusyBox.html
209 -@ rm -f pod2html* 251 -@ rm -f pod2html*
210 252
@@ -236,55 +278,62 @@ docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
236 (cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml) 278 (cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
237 279
238 280
239
240busybox: $(PWD_LIB) $(OBJECTS) 281busybox: $(PWD_LIB) $(OBJECTS)
241 $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES) 282 $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES)
242 $(STRIP) 283 $(STRIP)
243 284
244$(PWD_LIB): 285# Without VPATH, rule expands to "/bin/sh busybox.mkll Config.h applets.h"
245 $(MAKE) -eC pwd_grp 286# but with VPATH, some or all of those file names are resolved to the
246 287# directories in which they live.
247busybox.links: Config.h applets.h 288busybox.links: busybox.mkll Config.h applets.h
248 - $(BB_SRC_DIR)/busybox.mkll $(CONFIG_H) $(BB_SRC_DIR)/applets.h >$@ 289 - $(SHELL) $^ >$@
249 290
250nfsmount.o cmdedit.o: %.o: %.h 291nfsmount.o cmdedit.o: %.o: %.h
251$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile 292$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile
293 $(CC) $(CFLAGS) -I- -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
294
295$(PWD_OBJS): %.o: %.c pwd_lib_objdir Config.h busybox.h applets.h Makefile
296 $(CC) $(CFLAGS) $(PWD_CFLAGS) -c $< -o $*.o
297
298$(PWD_LIB): $(PWD_OBJS)
299 $(AR) $(ARFLAGS) $(PWD_LIB) $^
300
301pwd_lib_objdir:
302 mkdir -p $(PWD_GRP)
252 303
253usage.o: usage.h 304usage.o: usage.h
254 305
255utility.o: loop.h 306utility.o: loop.h
256 307
257loop.h: mk_loop_h.sh 308loop.h: mk_loop_h.sh
258 @ sh $< 309 @ $(SHELL) $< > $@
259 310
260test tests: 311test tests:
261 cd tests && $(MAKE) all 312 cd tests && $(MAKE) all
262 313
263clean: 314clean:
264 - cd tests && $(MAKE) clean 315 - cd tests && $(MAKE) clean
265 - cd pwd_grp && $(MAKE) clean
266 - rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \ 316 - rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
267 docs/busybox.lineo.com/BusyBox.html 317 docs/busybox.lineo.com/BusyBox.html
268 - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \ 318 - rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
269 docs/busybox.pdf docs/busybox.lineo.com/busybox.html 319 docs/busybox.pdf docs/busybox.lineo.com/busybox.html
270 - rm -f multibuild.log Config.h.orig 320 - rm -f multibuild.log Config.h.orig
271 - rm -rf docs/busybox _install 321 - rm -rf docs/busybox _install $(PWD_LIB)
272 - rm -f busybox.links loop.h *~ *.o core 322 - rm -f busybox.links loop.h *~ slist.mk core applet_source_list
323 - find -name *.o | xargs rm -f;
273 324
274distclean: clean 325distclean: clean
275 - rm -f busybox 326 - rm -f busybox
276 - cd tests && $(MAKE) distclean 327 - cd tests && $(MAKE) distclean
277 328
278install: busybox busybox.links 329install: install.sh busybox busybox.links
279 $(BB_SRC_DIR)/install.sh $(PREFIX) 330 $(SHELL) $< $(PREFIX)
280 331
281install-hardlinks: busybox busybox.links 332install-hardlinks: install.sh busybox busybox.links
282 $(BB_SRC_DIR)/install.sh $(PREFIX) --hardlinks 333 $(SHELL) $< $(PREFIX) --hardlinks
283 334
284debug_pristine: 335debug_pristine:
285 @ echo VPATH=\"$(VPATH)\" 336 @ echo VPATH=\"$(VPATH)\"
286 @ echo CONFIG_LIST=\"$(CONFIG_LIST)\"
287 @ echo CONFIG_H=\"$(CONFIG_H)\"
288 @ echo OBJECTS=\"$(OBJECTS)\" 337 @ echo OBJECTS=\"$(OBJECTS)\"
289 338
290dist release: distclean doc 339dist release: distclean doc