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-930202
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 :=
75 prefixes = --prefix=$(release_root) --exec_prefix=$(release_root)/H-$(host)
76 relbindir = $(release_root)/H-$(host)/bin
79 ### general config stuff
80 WORKING_DIR := $(host)-objdir
81 STAGE1DIR := $(WORKING_DIR).1
82 STAGE2DIR := $(WORKING_DIR).2
83 STAGE3DIR := $(WORKING_DIR).3
84 INPLACEDIR := $(host)-in-place
85 HOLESDIR := $(host)-holes
87 SET_HOLES := SHELL=sh ; PATH=`pwd`/$(HOLESDIR) ; export PATH ; export SHELL ;
88 SET_CYGNUS_PATH := SHELL=sh ; PATH=$(relbindir):`pwd`/$(HOLESDIR) ; export PATH ; export SHELL ;
89 SET_LATEST_PATH := SHELL=sh ; PATH=/usr/latest/bin:`pwd`/$(HOLESDIR) ; export PATH ; export SHELL ;
96 ## This is a cross compilation
98 arch = $(host)-x-$(target)
99 config = $(host) -target=$(target)
100 NATIVEDIR := $(arch)-native-objdir
101 CYGNUSDIR := $(arch)-cygnus-objdir
102 LATESTDIR := $(arch)-latest-objdir
103 FLAGS_TO_PASS := $(FLAGS_TO_PASS) "target=$(target)"
105 all: do-native do-latest
106 build-all: build-native build-latest
110 ## This is a native compilation
112 all: $(host)-stamp-3stage-done
113 #all: in-place do1 do2 do3 comparison
117 #everything: in-place do1 do2 do3 comparison do-cygnus
120 do-native: $(host)-stamp-holes $(arch)-stamp-native
121 do-native-config: $(arch)-stamp-native-configured
122 build-native: $(host)-stamp-holes $(arch)-stamp-native-checked
123 config-native: $(host)-stamp-holes $(arch)-stamp-native-configured
125 $(arch)-stamp-native: $(host)-stamp-holes
126 $(SET_HOLES) $(TIME) $(GNU_MAKE) -f test-build.mk $(arch)-stamp-native-installed $(FLAGS_TO_PASS)
127 if [ -f CLEAN_ALL ] ; then rm -rf $(NATIVEDIR) ; else true ; fi
128 touch $(arch)-stamp-native
130 $(arch)-stamp-native-installed: $(host)-stamp-holes $(arch)-stamp-native-checked
131 $(SET_HOLES) cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) install
132 $(SET_HOLES) cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) install-info
135 $(arch)-stamp-native-checked: $(arch)-stamp-native-built
136 # cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) check
139 $(arch)-stamp-native-built: $(host)-stamp-holes $(arch)-stamp-native-configured
140 $(SET_HOLES) cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) all
141 $(SET_HOLES) cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) info
144 $(arch)-stamp-native-configured: $(host)-stamp-holes
145 [ -d $(NATIVEDIR) ] || mkdir $(NATIVEDIR)
146 $(SET_HOLES) cd $(NATIVEDIR) ; $(TIME) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes)
151 do-cygnus: $(host)-stamp-holes $(arch)-stamp-cygnus
152 build-cygnus: $(host)-stamp-holes $(arch)-stamp-cygnus-checked
153 config-cygnus: $(host)-stamp-holes $(arch)-stamp-cygnus-configured
155 $(arch)-stamp-cygnus:
156 [ -f $(relbindir)/gcc ] || (echo "must have gcc available"; exit 1)
157 $(SET_CYGNUS_PATH) $(TIME) $(GNU_MAKE) -f test-build.mk $(arch)-stamp-cygnus-installed $(FLAGS_TO_PASS)
158 if [ -f CLEAN_ALL ] ; then rm -rf $(CYGNUSDIR) ; else true ; fi
159 touch $(arch)-stamp-cygnus
161 $(arch)-stamp-cygnus-installed: $(host)-stamp-holes $(arch)-stamp-cygnus-checked
162 $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install
163 $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install-info
166 $(arch)-stamp-cygnus-checked: $(host)-stamp-holes $(arch)-stamp-cygnus-built
167 # cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) check
170 $(arch)-stamp-cygnus-built: $(host)-stamp-holes $(arch)-stamp-cygnus-configured
171 $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) all
172 $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) info
175 $(arch)-stamp-cygnus-configured: $(host)-stamp-holes
176 [ -d $(CYGNUSDIR) ] || mkdir $(CYGNUSDIR)
177 $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes)
181 do-latest: $(host)-stamp-holes $(arch)-stamp-latest
182 build-latest: $(host)-stamp-holes $(arch)-stamp-latest-checked
184 $(arch)-stamp-latest:
185 $(SET_LATEST_PATH) $(TIME) $(GNU_MAKE) -f test-build.mk $(arch)-stamp-latest-installed $(FLAGS_TO_PASS)
186 touch $(arch)-stamp-latest
188 $(arch)-stamp-latest-installed: $(arch)-stamp-latest-checked
189 $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install
190 $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install-info
193 $(arch)-stamp-latest-checked: $(arch)-stamp-latest-built
194 # $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) check
197 $(arch)-stamp-latest-built: $(arch)-stamp-latest-configured
198 $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) all
199 $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) info
202 $(arch)-stamp-latest-configured:
203 [ -d $(LATESTDIR) ] || mkdir $(LATESTDIR)
204 $(SET_LATEST_PATH) cd $(LATESTDIR) ; \
205 $(TIME) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes)
210 in-place: $(host)-stamp-in-place
212 $(host)-stamp-in-place:
213 PATH=/bin:/usr/bin:/usr/ucb ; \
215 SHELL=/bin/sh ; export SHELL ; \
216 $(TIME) $(GNU_MAKE) -f test-build.mk $(host)-stamp-in-place-installed host=$(host) $(FLAGS_TO_PASS)
218 if [ -f CLEAN_ALL ] ; then \
219 rm -rf $(INPLACEDIR) ; \
221 mv $(INPLACEDIR) $(STAGE1DIR) ; \
224 $(host)-stamp-in-place-installed: $(host)-stamp-in-place-checked
225 cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" install host=$(host)
226 cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" install-info host=$(host)
229 $(host)-stamp-in-place-checked: $(host)-stamp-in-place-built
230 # cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" check host=$(host)
233 $(host)-stamp-in-place-built: $(host)-stamp-in-place-configured
234 cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" all host=$(host)
235 cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" info host=$(host)
238 $(host)-stamp-in-place-configured: $(host)-stamp-in-place-cp
239 cd $(INPLACEDIR) ; $(TIME) ./configure $(host) -v $(prefixes)
242 $(host)-stamp-in-place-cp:
245 (cd $(TREE) ; tar cf - .) | (cd $(INPLACEDIR) ; tar xf -)
248 $(host)-stamp-3stage-done: do1 do2 do3 comparison
253 do1: $(host)-stamp-holes $(host)-stamp-stage1
254 do1-config: $(host)-stamp-holes $(host)-stamp-stage1-configured
255 do1-build: $(host)-stamp-holes $(host)-stamp-stage1-checked
257 $(host)-stamp-stage1:
258 if [ -d $(STAGE1DIR) ] ; then \
259 mv $(STAGE1DIR) $(WORKING_DIR) ; \
263 $(SET_HOLES) $(TIME) $(GNU_MAKE) -f test-build.mk $(FLAGS_TO_PASS) host=$(host) $(host)-stamp-stage1-installed
265 if [ -f CLEAN_ALL ] ; then \
266 rm -rf $(WORKING_DIR) ; \
268 mv $(WORKING_DIR) $(STAGE1DIR) ; \
271 $(host)-stamp-stage1-installed: $(host)-stamp-stage1-checked
272 $(SET_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" install host=$(host)
273 $(SET_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" install-info host=$(host)
274 ifeq ($(host),rs6000-ibm-aix)
279 $(host)-stamp-stage1-checked: $(host)-stamp-stage1-built
280 # $(SET_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" check host=$(host)
283 $(host)-stamp-stage1-built: $(host)-stamp-stage1-configured
284 $(SET_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" all host=$(host)
285 $(SET_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" info host=$(host)
288 $(host)-stamp-stage1-configured:
289 [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
290 $(SET_HOLES) cd $(WORKING_DIR) ; \
291 $(TIME) ../$(TREE)/configure $(host) -v --srcdir=../$(TREE) $(prefixes)
295 do2: $(HOLESDIR) $(host)-stamp-stage2
297 $(host)-stamp-stage2:
298 if [ -d $(STAGE2DIR) ] ; then \
299 mv $(STAGE2DIR) $(WORKING_DIR) ; \
303 $(SET_CYGNUS_PATH) $(TIME) $(GNU_MAKE) $(FLAGS_TO_PASS) -f test-build.mk -w $(host)-stamp-stage2-installed
304 mv $(WORKING_DIR) $(STAGE2DIR)
308 $(host)-stamp-stage2-installed: $(host)-stamp-stage2-checked
309 $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install host=$(host)
310 $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install-info host=$(host)
313 $(host)-stamp-stage2-checked: $(host)-stamp-stage2-built
314 # $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
317 $(host)-stamp-stage2-built: $(host)-stamp-stage2-configured
318 $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" all host=$(host)
319 $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" info host=$(host)
322 $(host)-stamp-stage2-configured:
323 [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
324 $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; \
325 $(TIME) ../$(TREE)/configure $(host) -v --srcdir=../$(TREE) $(prefixes)
329 do3: $(HOLESDIR) $(host)-stamp-stage3
331 $(host)-stamp-stage3:
332 if [ -d $(STAGE3DIR) ] ; then \
333 mv $(STAGE3DIR) $(WORKING_DIR) ; \
337 $(SET_CYGNUS_PATH) $(TIME) $(GNU_MAKE) $(FLAGS_TO_PASS) -f test-build.mk -w $(host)-stamp-stage3-checked
338 mv $(WORKING_DIR) $(STAGE3DIR)
342 $(host)-stamp-stage3-installed: $(host)-stamp-stage3-checked
343 $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install host=$(host)
344 $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install-info host=$(host)
347 $(host)-stamp-stage3-checked: $(host)-stamp-stage3-built
348 # $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
351 $(host)-stamp-stage3-built: $(host)-stamp-stage3-configured
352 $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" all host=$(host)
353 $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" info host=$(host)
356 $(host)-stamp-stage3-configured:
357 [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
358 $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; \
359 $(TIME) ../$(TREE)/configure $(host) -v --srcdir=../$(TREE) $(prefixes)
362 # These things are needed by a three-stage, but are not included locally.
412 ### so far only sun make supports VPATH
413 ifeq ($(subst sun3,sun4,$(host)),sun4)
419 ### solaris 2 -- don't use /usr/ucb/cc
420 ifeq (sparc-sun-solaris2,$(host))
421 SET_HOLES := SHELL=sh ; PATH=/opt/SUNWspro/bin:`pwd`/$(HOLESDIR) ; export PATH ; export SHELL ;
422 HOLE_DIRS := /usr/ccs/bin
423 PARTIAL_HOLE_DIRS := /opt/SUNWspro/bin
427 ### rs6000 as is busted. We cache a patched version in unsupported.
428 ifeq ($(host),rs6000-ibm-aix)
434 ### These things are also needed by a three-stage, but in this case, the GNU version of the tool is required.
442 ### look in these directories for things missing from a three-stage
450 ### look in these directories for alternate versions of some tools.
451 PARTIAL_HOLE_DIRS := \
453 /usr/progressive/bin \
454 $(PARTIAL_HOLE_DIRS) \
458 $(HOLESDIR): $(host)-stamp-holes
463 @for i in $(HOLES) ; do \
465 for j in $(HOLE_DIRS) ; do \
466 if [ -x $$j/$$i ] ; then \
467 ln -s $$j/$$i $(HOLESDIR) || cp $$j/$$i $(HOLESDIR) ; \
468 echo $$i from $$j ; \
475 *) echo $$i is NOT found ;; \
478 @for i in $(PARTIAL_HOLES) ; do \
480 for j in $(PARTIAL_HOLE_DIRS) ; do \
481 if [ -x $$j/$$i ] ; then \
482 rm -f $(HOLESDIR)/$$i ; \
483 cp $$j/$$i $(HOLESDIR)/$$i || exit 1; \
484 echo $$i from $$j ; \
491 *) echo $$i is NOT found ;; \
497 comparison: $(host)-stamp-3stage-compared
499 $(host)-stamp-3stage-compared:
501 ifeq ($(subst i386-sco3.2v4,mips-sgi-irix4,$(subst rs6000-ibm-aix,mips-sgi-irix4,$(subst mips-dec-ultrix,mips-sgi-irix4,$(host)))),mips-sgi-irix4)
502 for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
503 tail +10c $(STAGE2DIR)/$$i > foo1 ; \
504 tail +10c $(STAGE3DIR)/$$i > foo2 ; \
505 if cmp foo1 foo2 ; then \
509 touch .bad-compare ; \
514 for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
515 cmp $(STAGE2DIR)/$$i $(STAGE3DIR)/$$i || touch .bad-compare ; \
518 if [ -f CLEAN_ALL ] ; then \
519 rm -rf $(STAGE2DIR) $(STAGE3DIR) ; \
521 if [ -f CLEAN_STAGES ] ; then \
522 if [ -f .bad-compare ] ; then \
525 rm -rf $(STAGE1DIR) $(STAGE2DIR) ; \
534 rm -rf $(HOLESDIR) $(INPLACEDIR) $(WORKING_DIR)* $(host)-stamp-* *~