2 ### Makefile used to three-stage build a tree of source code. Also used to
3 ### compile other bundles, first with cc, then with gcc.
7 ### USE OF THIS FILE REQUIRES GNU MAKE!!!
10 ### The first versions of the file were written by Rich Pixley (rich@cygnus.com).
11 ### Many subsequent additions (and current maintainance by) david d `zoo' zuhn,
14 ### Every invocation of this Makefile needs to have a variable set (host),
15 ### which is the named used for ./configure, and also the prefix for the
16 ### various files and directories used in a three stage.
20 @echo You must set the variable \"host\" to use this Makefile ; exit 1
23 ### from here to very near the end of the file is the real guts of this
24 ### Makefile, and it is not seen if the variable 'host' is not set
27 ### START EDITTING HERE!!!
28 ### These things will need to be set differently for each release.
31 ### from which cvs tree are we working?
34 ### binaries should be installed into?
35 ROOTING := /usr/cygnus
37 ### When working from a tagged set of source, this should be the tag. If not,
38 ### then set the macro to be empty.
41 ### The name of the cvs module for this release. The intersection of
42 ### CVS_MODULE and CVS_TAG defines the source files in this release.
45 ### Historically, this was identical to CVS_TAG. This is changing.
46 RELEASE_TAG := latest-921224
48 ### Historically, binaries were installed here. This is changing.
49 release_root := $(ROOTING)/$(RELEASE_TAG)
51 ### STOP EDITTING HERE!!!
52 ### With luck, eventually, nothing else will need to be editted.
58 GNU_MAKE := /usr/latest/bin/make -w
62 #override MAKEFLAGS :=
74 prefixes = -prefix=$(release_root) -exec-prefix=$(release_root)/H-$(host)
75 relbindir = $(release_root)/H-$(host)/bin
78 ### general config stuff
79 WORKING_DIR := $(host)-objdir
80 STAGE1DIR := $(WORKING_DIR).1
81 STAGE2DIR := $(WORKING_DIR).2
82 STAGE3DIR := $(WORKING_DIR).3
83 INPLACEDIR := $(host)-in-place
84 HOLESDIR := $(host)-holes
89 ## This is a cross compilation
91 arch = $(host)-x-$(target)
92 config = $(host) -target=$(target)
93 NATIVEDIR := $(arch)-native-objdir
94 CYGNUSDIR := $(arch)-cygnus-objdir
95 LATESTDIR := $(arch)-latest-objdir
96 FLAGS_TO_PASS := $(FLAGS_TO_PASS) "target=$(target)"
98 all: do-native do-latest
99 build-all: build-native build-latest
103 ## This is a native compilation
105 all: $(host)-stamp-3stage-done
106 #all: in-place do1 do2 do3 comparison
110 #everything: in-place do1 do2 do3 comparison do-cygnus
113 do-native: $(host)-stamp-holes $(arch)-stamp-native
114 do-native-config: $(arch)-stamp-native-configured
115 build-native: $(host)-stamp-holes $(arch)-stamp-native-checked
116 config-native: $(host)-stamp-holes $(arch)-stamp-native-configured
118 $(arch)-stamp-native:
119 PATH=`pwd`/$(HOLESDIR) ; \
121 SHELL=sh ; export SHELL ; \
122 $(TIME) $(GNU_MAKE) -f test-build.mk $(arch)-stamp-native-installed $(FLAGS_TO_PASS)
123 if [ -f CLEAN_ALL ] ; then rm -rf $(NATIVEDIR) ; else true ; fi
124 touch $(arch)-stamp-native
126 $(arch)-stamp-native-installed: $(arch)-stamp-native-checked
127 cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) install
128 cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) install-info
131 $(arch)-stamp-native-checked: $(arch)-stamp-native-built
132 # cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) check
135 $(arch)-stamp-native-built: $(arch)-stamp-native-configured
136 cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) all
137 cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) info
140 $(arch)-stamp-native-configured:
141 [ -d $(NATIVEDIR) ] || mkdir $(NATIVEDIR)
143 $(TIME) ../$(TREE)/configure $(config) -v -srcdir=../$(TREE) \
149 do-cygnus: $(host)-stamp-holes $(arch)-stamp-cygnus
150 build-cygnus: $(host)-stamp-holes $(arch)-stamp-cygnus-checked
151 config-cygnus: $(host)-stamp-holes $(arch)-stamp-cygnus-configured
153 $(arch)-stamp-cygnus:
154 [ -f $(relbindir)/gcc ] || (echo "must have gcc available"; exit 1)
155 PATH=$(relbindir):`pwd`/$(HOLESDIR) ; \
157 SHELL=sh ; export SHELL ; \
158 echo ; gcc -v ; echo ; \
159 $(TIME) $(GNU_MAKE) -f test-build.mk $(arch)-stamp-cygnus-installed $(FLAGS_TO_PASS)
160 if [ -f CLEAN_ALL ] ; then rm -rf $(CYGNUSDIR) ; else true ; fi
161 touch $(arch)-stamp-cygnus
163 $(arch)-stamp-cygnus-installed: $(arch)-stamp-cygnus-checked
164 cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install
165 cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install-info
168 $(arch)-stamp-cygnus-checked: $(arch)-stamp-cygnus-built
169 # cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) check
172 $(arch)-stamp-cygnus-built: $(arch)-stamp-cygnus-configured
173 cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) all
174 cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) info
177 $(arch)-stamp-cygnus-configured:
178 [ -d $(CYGNUSDIR) ] || mkdir $(CYGNUSDIR)
180 $(TIME) ../$(TREE)/configure $(config) -v -srcdir=../$(TREE) $(prefixes)
184 do-latest: $(host)-stamp-holes $(arch)-stamp-latest
185 build-latest: $(host)-stamp-holes $(arch)-stamp-latest-checked
187 $(arch)-stamp-latest:
188 PATH=/usr/latest/bin:`pwd`/$(HOLESDIR) ; \
190 SHELL=sh ; export SHELL ; \
191 $(TIME) $(GNU_MAKE) -f test-build.mk $(arch)-stamp-latest-installed $(FLAGS_TO_PASS)
192 touch $(arch)-stamp-latest
194 $(arch)-stamp-latest-installed: $(arch)-stamp-latest-checked
195 cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install
196 cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install-info
199 $(arch)-stamp-latest-checked: $(arch)-stamp-latest-built
200 # cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) check
203 $(arch)-stamp-latest-built: $(arch)-stamp-latest-configured
204 cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) all
205 cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) info
208 $(arch)-stamp-latest-configured:
209 [ -d $(LATESTDIR) ] || mkdir $(LATESTDIR)
211 $(TIME) ../$(TREE)/configure $(config) -v -srcdir=../$(TREE) $(prefixes)
216 in-place: $(host)-stamp-in-place
218 $(host)-stamp-in-place:
219 PATH=/bin:/usr/bin:/usr/ucb ; \
221 SHELL=/bin/sh ; export SHELL ; \
222 $(TIME) $(GNU_MAKE) -f test-build.mk $(host)-stamp-in-place-installed host=$(host) $(FLAGS_TO_PASS)
224 if [ -f CLEAN_ALL ] ; then \
225 rm -rf $(INPLACEDIR) ; \
227 mv $(INPLACEDIR) $(STAGE1DIR) ; \
230 $(host)-stamp-in-place-installed: $(host)-stamp-in-place-checked
231 cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" install host=$(host)
232 cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" install-info host=$(host)
235 $(host)-stamp-in-place-checked: $(host)-stamp-in-place-built
236 # cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" check host=$(host)
239 $(host)-stamp-in-place-built: $(host)-stamp-in-place-configured
240 cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" all host=$(host)
241 cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" info host=$(host)
244 $(host)-stamp-in-place-configured: $(host)-stamp-in-place-cp
245 cd $(INPLACEDIR) ; $(TIME) ./configure $(host) -v $(prefixes)
248 $(host)-stamp-in-place-cp:
251 (cd $(TREE) ; tar cf - .) | (cd $(INPLACEDIR) ; tar xf -)
254 $(host)-stamp-3stage-done: do1 do2 do3 comparison
259 do1: $(host)-stamp-holes $(host)-stamp-stage1
260 do1-config: $(host)-stamp-stage1-configured
261 do1-build: $(host)-stamp-stage1-checked
263 $(host)-stamp-stage1:
264 if [ -d $(STAGE1DIR) ] ; then \
265 mv $(STAGE1DIR) $(WORKING_DIR) ; \
269 PATH=`pwd`/$(HOLESDIR) ; \
271 SHELL=sh ; export SHELL ; \
272 $(TIME) $(GNU_MAKE) -f test-build.mk $(host)-stamp-stage1-installed host=$(host) $(FLAGS_TO_PASS) $(NATIVEC)
274 if [ -f CLEAN_ALL ] ; then \
275 rm -rf $(WORKING_DIR) ; \
277 mv $(WORKING_DIR) $(STAGE1DIR) ; \
280 $(host)-stamp-stage1-installed: $(host)-stamp-stage1-checked
281 cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" install host=$(host)
282 cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" install-info host=$(host)
283 ifeq ($(host),rs6000-ibm-aix)
288 $(host)-stamp-stage1-checked: $(host)-stamp-stage1-built
289 # cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" check host=$(host)
292 $(host)-stamp-stage1-built: $(host)-stamp-stage1-configured
293 cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" all host=$(host)
294 cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" info host=$(host)
297 $(host)-stamp-stage1-configured:
298 [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
299 cd $(WORKING_DIR) ; \
300 $(TIME) ../$(TREE)/configure $(host) -v -srcdir=../$(TREE) $(prefixes)
304 do2: $(HOLESDIR) $(host)-stamp-stage2
306 $(host)-stamp-stage2:
307 if [ -d $(STAGE2DIR) ] ; then \
308 mv $(STAGE2DIR) $(WORKING_DIR) ; \
312 PATH=$(relbindir):`pwd`/$(HOLESDIR) ; \
314 SHELL=sh ; export SHELL ; \
315 $(TIME) $(GNU_MAKE) $(FLAGS_TO_PASS) -f test-build.mk -w $(host)-stamp-stage2-installed
316 mv $(WORKING_DIR) $(STAGE2DIR)
320 $(host)-stamp-stage2-installed: $(host)-stamp-stage2-checked
321 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" install host=$(host)
322 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" install-info host=$(host)
325 $(host)-stamp-stage2-checked: $(host)-stamp-stage2-built
326 # cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
329 $(host)-stamp-stage2-built: $(host)-stamp-stage2-configured
330 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" all host=$(host)
331 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" info host=$(host)
334 $(host)-stamp-stage2-configured:
335 [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
336 cd $(WORKING_DIR) ; \
337 $(TIME) ../$(TREE)/configure $(host) -v -srcdir=../$(TREE) $(prefixes)
341 do3: $(HOLESDIR) $(host)-stamp-stage3
343 $(host)-stamp-stage3:
344 if [ -d $(STAGE3DIR) ] ; then \
345 mv $(STAGE3DIR) $(WORKING_DIR) ; \
349 PATH=$(relbindir):`pwd`/$(HOLESDIR) ; \
351 SHELL=sh ; export SHELL ; \
352 $(TIME) $(GNU_MAKE) $(FLAGS_TO_PASS) -f test-build.mk -w $(host)-stamp-stage3-checked
353 mv $(WORKING_DIR) $(STAGE3DIR)
357 $(host)-stamp-stage3-installed: $(host)-stamp-stage3-checked
358 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" install host=$(host)
359 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" install-info host=$(host)
362 $(host)-stamp-stage3-checked: $(host)-stamp-stage3-built
363 # cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
366 $(host)-stamp-stage3-built: $(host)-stamp-stage3-configured
367 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" all host=$(host)
368 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" info host=$(host)
371 $(host)-stamp-stage3-configured:
372 [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
373 cd $(WORKING_DIR) ; \
374 $(TIME) ../$(TREE)/configure $(host) -v -srcdir=../$(TREE) $(prefixes)
377 # These things are needed by a three-stage, but are not included locally.
424 ### so far only sun make supports VPATH
425 ifeq ($(subst sun3,sun4,$(host)),sun4)
431 ### solaris 2 -- don't use /usr/ucb/cc
432 ifeq (sparc-sun-solaris2,$(host))
433 PARTIAL_HOLE_DIRS := /opt/cygnus/bin
439 ### rs6000 as is busted. We cache a patched version in unsupported.
440 ifeq ($(host),rs6000-ibm-aix)
446 ### These things are also needed by a three-stage, but in this case, the GNU version of the tool is required.
454 ### look in these directories for things missing from a three-stage
463 ### look in these directories for alternate versions of some tools.
464 PARTIAL_HOLE_DIRS := \
466 /usr/progressive/bin \
467 $(PARTIAL_HOLE_DIRS) \
471 $(HOLESDIR): $(host)-stamp-holes
476 @for i in $(HOLES) ; do \
478 for j in $(HOLE_DIRS) ; do \
479 if [ -x $$j/$$i ] ; then \
480 cp $$j/$$i $(HOLESDIR) ; \
481 echo $$i from $$j ; \
488 *) echo $$i is NOT found ;; \
491 @for i in $(PARTIAL_HOLES) ; do \
493 for j in $(PARTIAL_HOLE_DIRS) ; do \
494 if [ -x $$j/$$i ] ; then \
495 rm -f $(HOLESDIR)/$$i ; \
496 cp $$j/$$i $(HOLESDIR)/$$i || exit 1; \
497 echo $$i from $$j ; \
504 *) echo $$i is NOT found ;; \
510 comparison: $(host)-stamp-3stage-compared
512 $(host)-stamp-3stage-compared:
514 ifeq ($(subst rs6000-ibm-aix,mips-sgi-irix4,$(subst mips-dec-ultrix,mips-sgi-irix4,$(host))),mips-sgi-irix4)
515 for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
516 tail +10c $(STAGE2DIR)/$$i > foo1 ; \
517 tail +10c $(STAGE3DIR)/$$i > foo2 ; \
518 if cmp foo1 foo2 ; then \
522 touch .bad-compare ; \
527 for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
528 cmp $(STAGE2DIR)/$$i $(STAGE3DIR)/$$i || touch .bad-compare ; \
531 if [ -f CLEAN_ALL ] ; then \
532 rm -rf $(STAGE2DIR) $(STAGE3DIR) ; \
534 if [ -f CLEAN_STAGES ] ; then \
535 if [ -f .bad-compare ] ; then \
538 rm -rf $(STAGE1DIR) $(STAGE2DIR) ; \
546 rm -rf $(HOLESDIR) $(INPLACEDIR) $(WORKING_DIR)* $(host)-stamp-* *~