more cleanup
[external/binutils.git] / test-build.mk
1 ###
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.
4 ###
5
6 ###
7 ### USE OF THIS FILE REQUIRES GNU MAKE!!!
8 ###
9
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,
12 ### (zoo@cygnus.com).
13
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.
17
18 ### The variable target may be set for the target of a cross-compilation.
19
20 ### The variable build may be to build a tree on a machine other than the host.
21
22 ifndef host
23 error:
24         @echo You must set the variable \"host\" to use this Makefile ; exit 1
25 else
26
27 ### from here to very near the end of the file is the real guts of this 
28 ### Makefile, and it is not seen if the variable 'host' is not set 
29
30 ### from which cvs tree are we working?
31 TREE := devo
32
33 include $(TREE)/release-info
34
35
36 TIME            := time
37 CONFIG_SHELL    := 
38 GCC             := $(host)-gcc -O 
39 GNUC            := CC="$(GCC)"
40 CFLAGS          := -g
41 CXXFLAGS        := -g -O
42 GNU_MAKE        := /usr/latest/bin/make -w 
43 MAKEINFOFLAGS   :=
44
45 override MAKE           := make -w
46 override MFLAGS         :=
47 #override MAKEFLAGS     :=
48
49 SHELL := /bin/sh
50
51 ifndef build
52 build := $(host)
53 endif
54
55 ifndef target
56 target := $(host)
57 endif
58
59 ifeq ($(patsubst %-lynx,lynx,$(host)),lynx)
60 SHELL := /bin/bash
61 GNU_MAKE := $(MAKE)
62 CONFIG_SHELL    := /bin/bash
63 endif
64
65 ifneq ($(build),$(host))
66
67 # We are building on a machine other than the host.  We rely upon
68 # previously built cross-compilers from the build machine to the host
69 # (used to build the executables) and from the build machine to the
70 # target (used to build the libraries).
71
72 AR              := $(host)-ar
73 AR_FOR_TARGET   := $(target)-ar
74 AS              := $(host)-as
75 AS_FOR_TARGET   := $(target)-as
76 BISON           := byacc
77 CC              := $(host)-gcc
78 CC_FOR_BUILD    := gcc
79 CC_FOR_TARGET   := $(target)-gcc
80 CXX             := $(host)-c++
81 CXX_FOR_TARGET  := $(target)-c++
82 GCC             := $(host)-gcc -O
83 GXX             := $(host)-g++
84 GXX_FOR_TARGET  := $(target)-g++
85 HOST_PREFIX     := $(build)-
86 HOST_PREFIX_1   := $(build)-
87 LEX             := flex
88 MAKEINFO        := makeinfo
89 MUNCH_NM        := $(host)-nm
90 NM              := $(host)-nm
91 NM_FOR_TARGET   := $(target)-nm
92 RANLIB          := $(host)-ranlib
93 RANLIB_FOR_TARGET       := $(target)-ranlib
94 YACC            := $(BISON)
95
96 ifeq ($(host),i386-go32)
97 MAKEINFOFLAGS = --no-split
98 endif
99
100 FLAGS_TO_PASS := \
101         "AR=$(AR)" \
102         "AR_FOR_TARGET=$(AR_FOR_TARGET)" \
103         "AS=$(AS)" \
104         "AS_FOR_TARGET=$(AS_FOR_TARGET)" \
105         "BISON=$(BISON)" \
106         "CC=$(CC)" \
107         "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
108         "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
109         "CXX=$(CXX)" \
110         "CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \
111         "CFLAGS=$(CFLAGS)" \
112         "CXXFLAGS=$(CXXFLAGS)" \
113         "GCC=$(GCC)" \
114         "HOST_PREFIX=$(HOST_PREFIX)" \
115         "HOST_PREFIX_1=$(HOST_PREFIX_1)" \
116         "LEX=$(LEX)" \
117         "MAKEINFO=$(MAKEINFO)" \
118         "MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \
119         "MF=$(MF)" \
120         "MUNCH_NM=$(MUNCH_NM)" \
121         "NM=$(NM)" \
122         "NM_FOR_TARGET=$(NM_FOR_TARGET)" \
123         "RANLIB=$(RANLIB)" \
124         "RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET)" \
125         "RELEASE_TAG=$(RELEASE_TAG)" \
126         "RUNTEST=$(relbindir)/runtest" \
127         "SHELL=$(SHELL)" \
128         "TIME=$(TIME)" \
129         "YACC=$(YACC)" \
130         "build=$(build)" \
131         "host=$(host)"
132
133 # We must pass the build cross host tools in the environment of
134 # configure, so that autoconf scripts will run the right programs.
135 configenv := AR="$(AR)" CC="$(CC)" RANLIB="$(RANLIB)"
136
137 else
138
139 # This is a normal build on the host machine.
140
141 FLAGS_TO_PASS := \
142         "GCC=$(GCC)" \
143         "CFLAGS=$(CFLAGS)" \
144         "CXXFLAGS=$(CXXFLAGS)" \
145         "TIME=$(TIME)" \
146         "MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \
147         "MF=$(MF)" \
148         "host=$(host)" \
149         "RELEASE_TAG=$(RELEASE_TAG)" \
150         "SHELL=$(SHELL)" 
151
152 configenv :=
153
154 endif
155
156 #### we need to change the default C compiler for some hosts
157 ifeq ($(host),sparc-sun-solaris2)
158 CC := cc -Xs
159 endif
160
161 ifeq ($(host),mips-sgi-irix4)
162 CC := cc -cckr -Wf,-XNg1500 -Wf,-XNk1000 -Wf,-XNh2000
163 endif
164
165 ifeq ($(host),mips-mips-riscos5)
166 CC := cc -non_shared -systype sysv
167 endif
168
169 ifeq ($(host),mips-dec-ultrix)
170 CC := cc -Wf,-XNg1000
171 endif
172
173 ifeq ($(host),m68k-sun-sunos4.1.1)
174 CC := cc -J
175 endif
176
177
178 # We want to use stabs for MIPS targets.
179 ifeq ($(target),mips-idt-ecoff)
180 configargs = -with-stabs
181 endif
182
183 ifeq ($(target),mips-dec-ultrix)
184 configargs = -with-stabs
185 endif
186
187 ifeq ($(target),mips-sgi-irix4)
188 configargs = -with-stabs
189 endif
190
191 # We must use stabs for SVR4 targets.
192 ifeq ($(target),i386-sysv4.2)
193 configargs = -with-stabs
194 endif
195
196 ifneq ($(CC), 'cc')
197 FLAGS_TO_PASS := "CC=$(CC)" $(FLAGS_TO_PASS)
198 endif
199
200 #### and on some, we need CONFIG_SHELL
201 ifeq ($(patsubst %-lynxos,lynxos,$(host)),lynxos)
202 FLAGS_TO_PASS := "CONFIG_SHELL=$(CONFIG_SHELL)" $(FLAGS_TO_PASS)
203 endif
204
205
206 # These are the prefixes used for Cygnus builds.
207 prefixes        = --prefix=$(release_root) --exec-prefix=$(release_root)/H-$(host)
208
209 relbindir       = $(release_root)/H-$(build)/bin
210
211 ### general config stuff
212 WORKING_DIR     := $(host)-objdir
213 STAGE1DIR       := $(WORKING_DIR).1
214 STAGE2DIR       := $(WORKING_DIR).2
215 STAGE3DIR       := $(WORKING_DIR).3
216 STAGE4DIR       := $(WORKING_DIR).4
217 INPLACEDIR      := $(host)-in-place
218
219 # Arrange to find the needed programs.  If we are building on a
220 # machine other than the host, we must find the cross-compilers.
221
222 ifneq ($(build),$(host))
223
224 holesys         := $(build)
225 HOLESSTAMP      := $(holesys)-stamp-holes $(build)-x-$(host)-stamp-holes $(build)-x-$(target)-stamp-holes
226 HOLESDIR        := $(holesys)-holes
227 BUILD_HOST_HOLES_DIR    := $(build)-x-$(host)-holes
228 BUILD_TARGET_HOLES_DIR  := $(build)-x-$(target)-holes
229
230 SET_NATIVE_HOLES := SHELL=$(SHELL) ; PATH=`pwd`/$(HOLESDIR):`pwd`/$(BUILD_HOST_HOLES_DIR):`pwd`/$(BUILD_TARGET_HOLES_DIR) ; export PATH ; export SHELL ;
231 SET_CYGNUS_PATH  := SHELL=$(SHELL) ; PATH=`pwd`/$(HOLESDIR):`pwd`/$(BUILD_HOST_HOLES_DIR):`pwd`/$(BUILD_TARGET_HOLES_DIR) ; export PATH ; export SHELL ;
232 SET_LATEST_PATH  := SHELL=$(SHELL) ; PATH=/usr/latest/bin:`pwd`/$(HOLESDIR):`pwd`/$(BUILD_HOST_HOLES_DIR):`pwd`/$(BUILD_TARGET_HOLES_DIR) ; export PATH ; export SHELL ;
233
234 else
235
236 holesys         := $(host)
237 HOLESSTAMP      := $(holesys)-stamp-holes
238 HOLESDIR        := $(holesys)-holes
239
240 SET_NATIVE_HOLES := SHELL=$(SHELL) ; PATH=`pwd`/$(HOLESDIR) ; export PATH ; export SHELL ;
241 SET_CYGNUS_PATH  := SHELL=$(SHELL) ; PATH=$(relbindir):`pwd`/$(HOLESDIR) ; export PATH ; export SHELL ;
242 SET_LATEST_PATH  := SHELL=$(SHELL) ; PATH=/usr/latest/bin:`pwd`/$(HOLESDIR) ; export PATH ; export SHELL ;
243
244 endif
245
246 .PHONY: all
247 ifneq ($(target),$(host))
248 ##
249 ## This is a cross compilation
250 ##
251 arch            = $(host)-x-$(target)
252 config          = -host=$(host) -target=$(target)
253 FLAGS_TO_PASS   := $(FLAGS_TO_PASS) "target=$(target)"
254
255 ifneq ($(build),$(host))
256 all:    do-cygnus do-latest
257 build-all: build-cygnus build-latest
258 else
259 all:    do-native do-latest
260 build-all: build-native build-latest
261 endif
262
263
264 else
265 ##
266 ## This is a native compilation
267 ##
268 arch            = $(host)
269 config          = -host=$(host)
270 ifneq ($(build),$(host))
271 all:    do-cygnus do-latest
272 else
273 all:    $(host)-stamp-3stage-done
274 endif
275 #all:   in-place do1 do2 do3 comparison
276
277 endif
278
279 NATIVEDIR       := $(arch)-native-objdir
280 CYGNUSDIR       := $(arch)-cygnus-objdir
281 LATESTDIR       := $(arch)-latest-objdir
282 DOSDIR          := dos-x-$(target)-objdir
283
284 everything:      do-cross 
285 #everything:    in-place do1 do2 do3 comparison do-cygnus 
286
287 .PHONY: dos
288 dos:
289         $(MAKE) -f test-build.mk CFLAGS= build=$(host) host=i386-go32 target=$(target) do-dos
290 dos-path:
291         $(MAKE) -f test-build.mk CFLAGS= build=$(host) host=i386-go32 target=$(target) path-dos
292
293 .PHONY: do-dos
294 do-dos: $(HOLESSTAMP) dos-x-$(target)-stamp-done
295 build-dos: $(HOLESSTAMP) dos-x-$(target)-stamp-dos-checked
296 config-dos: $(HOLESSTAMP) dos-x-$(target)-stamp-dos-configured
297 path-dos:
298         @echo "$(SET_CYGNUS_PATH)"
299
300 dos-x-$(target)-stamp-done: 
301         [ -f $(relbindir)/$(host)-gcc ] || (echo "must have gcc available"; exit 1)
302         $(SET_CYGNUS_PATH) $(TIME) $(GNU_MAKE) -f test-build.mk dos-x-$(target)-stamp-installed  $(FLAGS_TO_PASS)
303         if [ -f CLEAN_ALL -o -f CLEAN_CROSSES ] ; then rm -rf $(DOSDIR) ; else true ; fi
304         touch $@
305
306 dos-x-$(target)-stamp-installed: $(HOLESSTAMP) dos-x-$(target)-stamp-intermediate
307         [ -d dos-x-$(target)-installed ] || mkdir dos-x-$(target)-installed
308         $(SET_CYGNUS_PATH) $(TREE)/release/mkdosrel dos-x-$(target)-intermediate \
309           dos-x-$(target)-installed $(target)
310 #       (cd dos-x-$(target)-installed; find . -print | $(TREE)/release/make8.3)
311         touch $@
312
313 dos-x-$(target)-stamp-intermediate:  $(HOLESSTAMP) dos-x-$(target)-stamp-dos-checked
314         [ -d dos-x-$(target)-intermediate ] || mkdir dos-x-$(target)-intermediate
315         dir=`pwd` ; export dir ; \
316         $(SET_CYGNUS_PATH) cd $(DOSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) \
317           prefix=$$dir/dos-x-$(target)-intermediate install install-info 
318         touch $@
319
320 dos-x-$(target)-stamp-dos-checked: $(HOLESSTAMP) dos-x-$(target)-stamp-dos-built
321 #       cd $(DOSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) check 
322         touch $@
323
324 dos-x-$(target)-stamp-dos-built:  $(HOLESSTAMP) dos-x-$(target)-stamp-dos-configured
325         $(SET_CYGNUS_PATH) cd $(DOSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) all info
326         touch $@
327
328 dos-x-$(target)-stamp-dos-configured:  $(HOLESSTAMP)
329         [ -d $(DOSDIR) ] || mkdir $(DOSDIR)
330         $(SET_CYGNUS_PATH) cd $(DOSDIR) ; $(GNUC) $(configenv) $(TIME) $(CONFIG_SHELL) \
331           ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) --prefix=/cygnus \
332           --program-transform-name='' $(configargs)
333         touch $@
334
335
336
337
338 .PHONY: do-native
339 do-native: $(HOLESSTAMP) $(arch)-stamp-native
340 do-native-config: $(arch)-stamp-native-configured
341 build-native: $(HOLESSTAMP) $(arch)-stamp-native-checked
342 config-native: $(HOLESSTAMP) $(arch)-stamp-native-configured
343
344 $(arch)-stamp-native: $(HOLESSTAMP)
345         $(SET_NATIVE_HOLES) $(TIME) $(GNU_MAKE) -f test-build.mk  $(arch)-stamp-native-installed $(FLAGS_TO_PASS) 
346         if [ -f CLEAN_ALL -o -f CLEAN_CROSSES ] ; then rm -rf $(NATIVEDIR) ; else true ; fi
347         touch $(arch)-stamp-native
348
349 $(arch)-stamp-native-installed: $(HOLESSTAMP) $(arch)-stamp-native-checked
350         $(SET_NATIVE_HOLES) cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) install 
351         $(SET_NATIVE_HOLES) cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) install-info 
352         touch $@
353
354 $(arch)-stamp-native-checked: $(arch)-stamp-native-built
355 #       cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) check 
356         touch $@
357
358 $(arch)-stamp-native-built: $(HOLESSTAMP) $(arch)-stamp-native-configured
359         $(SET_NATIVE_HOLES) cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) all 
360         $(SET_NATIVE_HOLES) cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) info 
361         touch $@
362
363 $(arch)-stamp-native-configured: $(HOLESSTAMP)
364         [ -d $(NATIVEDIR) ] || mkdir $(NATIVEDIR)
365         $(SET_NATIVE_HOLES) cd $(NATIVEDIR) ; $(configenv) CC="$(CC)" $(TIME) $(CONFIG_SHELL) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes) $(configargs)
366         touch $@
367
368
369 .PHONY: do-cygnus
370 do-cygnus: $(HOLESSTAMP) $(arch)-stamp-cygnus
371 build-cygnus: $(HOLESSTAMP) $(arch)-stamp-cygnus-checked
372 config-cygnus: $(HOLESSTAMP) $(arch)-stamp-cygnus-configured
373 path-cygnus:
374         $(SET_CYGNUS_PATH) echo $$PATH
375
376 vault-cygnus: $(HOLESSTAMP) $(arch)-stamp-cygnus-built
377         $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) vault-install 
378         
379
380 $(arch)-stamp-cygnus: 
381         [ -f $(relbindir)/$(host)-gcc ] || (echo "must have gcc available"; exit 1)
382         $(SET_CYGNUS_PATH) $(TIME) $(GNU_MAKE) -f test-build.mk $(arch)-stamp-cygnus-installed  $(FLAGS_TO_PASS)
383         if [ -f CLEAN_ALL -o -f CLEAN_CROSSES ] ; then rm -rf $(CYGNUSDIR) ; else true ; fi
384         touch $(arch)-stamp-cygnus
385
386 $(arch)-stamp-cygnus-installed:  $(HOLESSTAMP) $(arch)-stamp-cygnus-checked
387         $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install 
388         $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install-info
389         if [ -f VAULT-INSTALL ] ; then \
390           $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(MAKE) $(FLAGS_TO_PASS) $(GNUC) vault-install ; \
391         else true ; fi
392         touch $@
393
394 $(arch)-stamp-cygnus-checked: $(HOLESSTAMP) $(arch)-stamp-cygnus-built
395 #       cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) check 
396         touch $@
397
398 $(arch)-stamp-cygnus-built:  $(HOLESSTAMP) $(arch)-stamp-cygnus-configured
399         $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) all 
400         $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) info 
401         touch $@
402
403 $(arch)-stamp-cygnus-configured:  $(HOLESSTAMP)
404         [ -d $(CYGNUSDIR) ] || mkdir $(CYGNUSDIR)
405         $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(configenv) $(GNUC) $(TIME) $(CONFIG_SHELL) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes) $(configargs)
406         touch $@
407
408 .PHONY: do-latest
409 do-latest: $(HOLESSTAMP) $(arch)-stamp-latest
410 build-latest: $(HOLESSTAMP) $(arch)-stamp-latest-checked
411
412 $(arch)-stamp-latest:
413         $(SET_LATEST_PATH) $(TIME) $(GNU_MAKE) -f test-build.mk $(arch)-stamp-latest-installed  $(FLAGS_TO_PASS)
414         touch $(arch)-stamp-latest
415
416 $(arch)-stamp-latest-installed:  $(HOLESSTAMP) $(arch)-stamp-latest-checked
417         $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install 
418         $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install-info 
419         touch $@
420
421 $(arch)-stamp-latest-checked: $(arch)-stamp-latest-built
422 #       $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) check 
423         touch $@
424
425 $(arch)-stamp-latest-built: $(arch)-stamp-latest-configured
426         $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) all 
427         $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) info 
428         touch $@
429
430 $(arch)-stamp-latest-configured:
431         [ -d $(LATESTDIR) ] || mkdir $(LATESTDIR)
432         $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(configenv) $(GNUC) $(TIME) $(CONFIG_SHELL) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes) $(configargs)
433         touch $@
434
435
436 .PHONY: in-place
437 in-place:       $(host)-stamp-in-place
438
439 $(host)-stamp-in-place: 
440         PATH=/bin:/usr/bin:/usr/ucb ; \
441           export PATH ; \
442           SHELL=/bin/sh ; export SHELL ; \
443           $(TIME) $(GNU_MAKE) -f test-build.mk $(host)-stamp-in-place-installed host=$(host) $(FLAGS_TO_PASS)
444         touch $@
445         if [ -f CLEAN_ALL ] ; then \
446           rm -rf $(INPLACEDIR) ; \
447         else \
448           mv $(INPLACEDIR) $(STAGE1DIR) ; \
449         fi
450
451 $(host)-stamp-in-place-installed: $(host)-stamp-in-place-checked
452         cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" install host=$(host)
453         cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" install-info host=$(host)
454         touch $@
455
456 $(host)-stamp-in-place-checked: $(host)-stamp-in-place-built
457 #       cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" check host=$(host)
458         touch $@
459
460 $(host)-stamp-in-place-built: $(host)-stamp-in-place-configured
461         cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" all host=$(host)
462         cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" info host=$(host)
463         touch $@
464
465 $(host)-stamp-in-place-configured: $(host)-stamp-in-place-cp
466         cd $(INPLACEDIR) ; $(configenv) CC="$(CC)" $(TIME) $(CONFIG_SHELL) ./configure $(config) -v $(prefixes) $(configargs)
467         touch $@
468
469 $(host)-stamp-in-place-cp:
470         rm -rf $(INPLACEDIR)
471         mkdir $(INPLACEDIR)
472         (cd $(TREE) ; tar cf - .) | (cd $(INPLACEDIR) ; tar xf -)
473         touch $@
474
475 $(host)-stamp-3stage-done: do1 do2 do3 comparison
476         touch $@
477
478
479 .PHONY: do1
480 do1:        $(HOLESSTAMP) $(host)-stamp-stage1
481 do1-config: $(HOLESSTAMP) $(host)-stamp-stage1-configured
482 do1-build:  $(HOLESSTAMP) $(host)-stamp-stage1-checked
483
484 do1-vault: $(HOLESSTAMP) $(host)-stamp-stage1-built
485         if [ -d $(WORKING_DIR).1 ] ; then \
486           $(SET_NATIVE_HOLES) cd $(WORKING_DIR).1 ; $(MAKE) $(FLAGS_TO_PASS) host=$(host) "CFLAGS=$(CFLAGS)" vault-install ; \
487         else \
488           $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; $(MAKE) $(FLAGS_TO_PASS) host=$(host) "CFLAGS=$(CFLAGS)" vault-install ; \
489         fi
490
491 $(host)-stamp-stage1:
492         if [ -d $(STAGE1DIR) ] ; then \
493                 mv $(STAGE1DIR) $(WORKING_DIR) ; \
494         else \
495                 true ; \
496         fi
497         $(SET_NATIVE_HOLES) $(TIME) $(GNU_MAKE) -f test-build.mk $(FLAGS_TO_PASS) host=$(host) $(host)-stamp-stage1-installed
498         touch $@
499         if [ -f CLEAN_ALL ] ; then \
500           rm -rf $(WORKING_DIR) ; \
501         else \
502           mv $(WORKING_DIR) $(STAGE1DIR) ; \
503         fi
504
505 $(host)-stamp-stage1-installed: $(host)-stamp-stage1-checked
506         $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" install host=$(host)
507         $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" install-info host=$(host)
508 ifeq ($(host),rs6000-ibm-aix)
509         -rm $(relbindir)/make
510 endif
511         touch $@
512
513 $(host)-stamp-stage1-checked: $(host)-stamp-stage1-built
514 #       $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" check host=$(host)
515         touch $@
516
517 $(host)-stamp-stage1-built: $(host)-stamp-stage1-configured
518         $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" all host=$(host)
519         $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" info host=$(host)
520         touch $@
521
522 $(host)-stamp-stage1-configured:
523         [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
524         $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; \
525           $(configenv) CC="$(CC)" $(TIME) $(CONFIG_SHELL) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes) $(configargs)
526         touch $@
527
528 .PHONY: do2
529 do2:    $(HOLESDIR) $(host)-stamp-stage2
530
531 do2-vault: $(HOLESSTAMP) $(host)-stamp-stage2-built
532         if [ -d $(WORKING_DIR).2 ] ; then \
533           $(SET_CYGNUS_PATH) cd $(WORKING_DIR).2 ; $(MAKE) $(FLAGS_TO_PASS) host=$(host) "CFLAGS=$(CFLAGS)" vault-install ; \
534         else \
535           $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(MAKE) $(FLAGS_TO_PASS) host=$(host) "CFLAGS=$(CFLAGS)" vault-install ; \
536         fi
537
538
539
540 $(host)-stamp-stage2:
541         if [ -d $(STAGE2DIR) ] ; then \
542                 mv $(STAGE2DIR) $(WORKING_DIR) ; \
543         else \
544                 true ; \
545         fi
546         $(SET_CYGNUS_PATH) $(TIME) $(GNU_MAKE) $(FLAGS_TO_PASS) -f test-build.mk -w $(host)-stamp-stage2-installed
547         mv $(WORKING_DIR) $(STAGE2DIR)
548         touch $@
549
550
551 $(host)-stamp-stage2-installed: $(host)-stamp-stage2-checked
552         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install host=$(host)
553         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install-info host=$(host)
554         touch $@
555
556 $(host)-stamp-stage2-checked: $(host)-stamp-stage2-built
557 #       $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
558         touch $@
559
560 $(host)-stamp-stage2-built: $(host)-stamp-stage2-configured
561         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" all host=$(host)
562         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" info host=$(host)
563         touch $@
564
565 $(host)-stamp-stage2-configured:
566         [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
567         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; \
568           $(configenv) $(GNUC) $(TIME) $(CONFIG_SHELL) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes) $(configargs)
569         touch $@
570
571 .PHONY: do3
572 do3:    $(HOLESDIR) $(host)-stamp-stage3
573
574 do3-vault: $(HOLESSTAMP) $(host)-stamp-stage3-built
575         if [ -d $(WORKING_DIR).3 ] ; then \
576           $(SET_CYGNUS_PATH) cd $(WORKING_DIR).3 ; $(MAKE) $(FLAGS_TO_PASS) host=$(host) "CFLAGS=$(CFLAGS)" vault-install ; \
577         else \
578           $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(MAKE) $(FLAGS_TO_PASS) host=$(host) "CFLAGS=$(CFLAGS)" vault-install ; \
579         fi
580
581 $(host)-stamp-stage3:
582         if [ -d $(STAGE3DIR) ] ; then \
583                 mv $(STAGE3DIR) $(WORKING_DIR) ; \
584         else \
585                 true ; \
586         fi
587         $(SET_CYGNUS_PATH) $(TIME) $(GNU_MAKE) $(FLAGS_TO_PASS) -f test-build.mk -w $(host)-stamp-stage3-installed
588         mv $(WORKING_DIR) $(STAGE3DIR) 
589         touch $@
590
591
592 $(host)-stamp-stage3-installed: $(host)-stamp-stage3-checked
593         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install host=$(host)
594         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install-info host=$(host)
595         if [ -f VAULT-INSTALL ] ; then \
596           $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(MAKE) $(FLAGS_TO_PASS) $(GNUC) vault-install ; \
597         else true ; fi
598         touch $@
599
600 $(host)-stamp-stage3-checked: $(host)-stamp-stage3-built
601 #       $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
602         touch $@
603
604 $(host)-check-3stage: $(host)-stamp-stage3
605         $(SET_CYGNUS_PATH) cd $(STAGE3DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
606         touch $@
607
608 $(host)-stamp-stage3-built: $(host)-stamp-stage3-configured
609         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" all host=$(host)
610         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" info host=$(host)
611         touch $@
612
613 $(host)-stamp-stage3-configured:
614         [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
615         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; \
616           $(configenv) $(GNUC) $(TIME) $(CONFIG_SHELL) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes) $(configargs)
617         touch $@
618
619 .PHONY: do4
620 do4:    $(HOLESDIR) $(host)-stamp-stage4
621
622 $(host)-stamp-stage4:
623         if [ -d $(STAGE4DIR) ] ; then \
624                 mv $(STAGE4DIR) $(WORKING_DIR) ; \
625         else \
626                 true ; \
627         fi
628         $(SET_CYGNUS_PATH) $(TIME) $(GNU_MAKE) $(FLAGS_TO_PASS) -f test-build.mk -w $(host)-stamp-stage4-checked 
629         mv $(WORKING_DIR) $(STAGE4DIR) 
630         touch $@
631
632
633 $(host)-stamp-stage4-installed: $(host)-stamp-stage4-checked
634         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install host=$(host)
635         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install-info host=$(host)
636         touch $@
637
638 $(host)-stamp-stage4-checked: $(host)-stamp-stage4-built
639 #       $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
640         touch $@
641
642 $(host)-stamp-stage4-built: $(host)-stamp-stage4-configured
643         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" all host=$(host)
644         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" info host=$(host)
645         touch $@
646
647 $(host)-stamp-stage4-configured:
648         [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
649         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; \
650           $(configenv) $(GNUC) $(TIME) $(CONFIG_SHELL) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes) $(configargs)
651         touch $@
652
653 # These things are needed by a three-stage, but are not included locally.
654
655 HOLES := \
656         [ \
657         ar \
658         as \
659         awk \
660         basename \
661         cat \
662         cc \
663         chmod \
664         chgrp \
665         chown \
666         cmp \
667         cp \
668         cpio \
669         date \
670         diff \
671         dirname \
672         echo \
673         egrep \
674         ex \
675         expr \
676         false \
677         find \
678         grep \
679         head \
680         hostname \
681         install \
682         ld \
683         lex \
684         ln \
685         ls \
686         make \
687         mkdir \
688         mv \
689         nm \
690         pwd \
691         ranlib \
692         rm \
693         rmdir \
694         sed \
695         sh \
696         sleep \
697         sort \
698         tar \
699         test \
700         time \
701         touch \
702         tr \
703         true \
704         uname \
705         uniq \
706         uudecode \
707         wc \
708         whoami
709
710 ### so far only sun make supports VPATH
711 ifeq ($(subst sun3,sun4,$(holesys)),sun4)
712 MAKE_HOLE :=
713 else
714 MAKE_HOLE := make
715 endif
716
717 ### solaris 2 -- don't use /usr/ucb/cc
718 ifeq (sparc-sun-solaris2,$(holesys))
719 SET_NATIVE_HOLES := SHELL=$(SHELL) ; PATH=/opt/SUNWspro/bin:`pwd`/$(HOLESDIR) ; export PATH ; export SHELL ;
720 HOLE_DIRS := /usr/ccs/bin
721 CC_HOLE :=
722 NUKEM := cc 
723 endif
724
725 ifeq ($(host),i386-go32)
726 DOS_HOLES := aout2exe doschk file
727 endif
728
729 ifeq ($(host),i386-lynx)
730 MAKE_HOLE := make
731 endif
732
733 ifeq ($(host),m68k-lynx)
734 MAKE_HOLE := make
735 endif
736
737 ### These things are also needed by a three-stage, but in this case, the GNU version of the tool is required.
738 PARTIAL_HOLES := \
739         $(MAKE_HOLE) \
740         $(CC_HOLE) \
741         $(DOS_HOLES) \
742         flex \
743         m4
744
745 ### look in these directories for things missing from a three-stage
746 HOLE_DIRS := \
747         $(HOLE_DIRS) \
748         /bin \
749         /usr/bin \
750         /usr/ucb \
751         /usr/unsupported/bin
752
753 ### look in these directories for alternate versions of some tools.
754 PARTIAL_HOLE_DIRS := \
755         /usr/latest/bin \
756         /usr/progressive/bin \
757         $(PARTIAL_HOLE_DIRS) \
758         /usr/vintage/bin \
759         /usr/unsupported/bin \
760         $(HOLE_DIRS)
761
762 $(HOLESDIR): $(holesys)-stamp-holes
763
764 $(holesys)-stamp-holes:
765         -rm -rf $(HOLESDIR)
766         -mkdir $(HOLESDIR)
767         @for i in $(HOLES) ; do \
768                 found= ; \
769                 for j in $(HOLE_DIRS) ; do \
770                         if [ -x $$j/$$i ] ; then \
771                                 ln -s $$j/$$i $(HOLESDIR) || cp $$j/$$i $(HOLESDIR) ; \
772                                 echo $$i from $$j ; \
773                                 found=t ; \
774                                 break ; \
775                         fi ; \
776                 done ; \
777                 case "$$found" in \
778                 t) ;; \
779                 *) echo $$i is NOT found ;; \
780                 esac ; \
781         done
782         @for i in $(PARTIAL_HOLES) ; do \
783                 found= ; \
784                 for j in $(PARTIAL_HOLE_DIRS) ; do \
785                         if [ -x $$j/$$i ] ; then \
786                                 rm -f $(HOLESDIR)/$$i ; \
787                                 cp $$j/$$i $(HOLESDIR)/$$i || exit 1; \
788                                 echo $$i from $$j ; \
789                                 found=t ; \
790                                 break ; \
791                         fi ; \
792                 done ; \
793                 case "$$found" in \
794                 t) ;; \
795                 *) echo $$i is NOT found ;; \
796                 esac ; \
797         done
798 ifdef NUKEM
799         cd $(HOLESDIR); rm -f $(NUKEM)
800 endif
801         touch $@
802
803 # Get the cross-tools for build cross host when not building on the host.
804
805 BUILD_HOST_HOLES := \
806         byacc \
807         gcc \
808         makeinfo \
809         $(AR) \
810         $(AS) \
811         $(CC) \
812         $(CXX) \
813         $(GXX) \
814         $(NM) \
815         $(RANLIB)
816
817 BUILD_HOLES_DIRS := $(release_root)/H-$(build)/bin $(PARTIAL_HOLE_DIRS)
818
819 ifdef BUILD_HOST_HOLES_DIR
820 $(BUILD_HOST_HOLES_DIR): $(build)-x-$(host)-stamp-holes
821 endif
822
823 ifneq ($(build),$(host))
824 $(build)-x-$(host)-stamp-holes:
825         -rm -rf $(BUILD_HOST_HOLES_DIR)
826         -mkdir $(BUILD_HOST_HOLES_DIR)
827         @for i in $(BUILD_HOST_HOLES) ; do \
828                 found= ; \
829                 for j in $(BUILD_HOLES_DIRS) ; do \
830                         if [ -x $$j/$$i ] ; then \
831                                 ln -s $$j/$$i $(BUILD_HOST_HOLES_DIR) || cp $$j/$$i $(BUILD_HOST_HOLES_DIR) ; \
832                                 echo $$i from $$j ; \
833                                 found=t ; \
834                                 break ; \
835                         fi ; \
836                 done ; \
837                 case "$$found" in \
838                 t) ;; \
839                 *) echo $$i is NOT found ;; \
840                 esac ; \
841         done
842         touch $@
843 endif
844
845 # Get the cross tools for build cross target when not building on the host.
846
847 BUILD_TARGET_HOLES := \
848         byacc \
849         gcc \
850         makeinfo \
851         $(AR_FOR_TARGET) \
852         $(AS_FOR_TARGET) \
853         $(CC_FOR_TARGET) \
854         $(CXX_FOR_TARGET) \
855         $(GXX_FOR_TARGET) \
856         $(NM_FOR_TARGET) \
857         $(RANLIB_FOR_TARGET)
858
859 ifdef BUILD_TARGET_HOLES_DIR
860 $(BUILD_TARGET_HOLES_DIR): $(build)-x-$(target)-stamp-holes
861 endif
862
863 ifneq ($(build),$(target))
864 $(build)-x-$(target)-stamp-holes:
865         -rm -rf $(BUILD_TARGET_HOLES_DIR)
866         -mkdir $(BUILD_TARGET_HOLES_DIR)
867         @for i in $(BUILD_TARGET_HOLES) ; do \
868                 found= ; \
869                 for j in $(BUILD_HOLES_DIRS) ; do \
870                         if [ -x $$j/$$i ] ; then \
871                                 ln -s $$j/$$i $(BUILD_TARGET_HOLES_DIR) || cp $$j/$$i $(BUILD_TARGET_HOLES_DIR) ; \
872                                 echo $$i from $$j ; \
873                                 found=t ; \
874                                 break ; \
875                         fi ; \
876                 done ; \
877                 case "$$found" in \
878                 t) ;; \
879                 *) echo $$i is NOT found ;; \
880                 esac ; \
881         done
882         touch $@
883 endif
884
885 .PHONY: comparison
886 comparison: $(host)-stamp-3stage-compared
887 comparison-stage3to4: $(host)-stamp-4stage-compared
888
889 $(host)-stamp-3stage-compared:
890         rm -f .bad-compare
891 ifeq ($(patsubst %-lynx,mips-sgi-irix4,$(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)
892         for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
893                 tail +10c $(STAGE2DIR)/$$i > foo1 ; \
894                 tail +10c $(STAGE3DIR)/$$i > foo2 ; \
895                 if cmp foo1 foo2 ; then \
896                         true ; \
897                 else \
898                         echo $$i ; \
899                         touch .bad-compare ; \
900                 fi ; \
901         done
902         rm -f foo1 foo2
903 else
904         for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
905                 cmp $(STAGE2DIR)/$$i $(STAGE3DIR)/$$i || touch .bad-compare ; \
906         done
907 endif
908         if [ -f CLEAN_ALL ] ; then \
909           rm -rf $(STAGE2DIR) $(STAGE3DIR) ; \
910         else \
911           if [ -f CLEAN_STAGES ] ; then \
912             if [ -f .bad-compare ] ; then \
913               true ; \
914             else \
915               rm -rf $(STAGE1DIR) $(STAGE2DIR) ; \
916             fi ; \
917           else true ; \
918           fi ; \
919         fi
920         touch $@        
921
922 $(host)-stamp-4stage-compared:
923         rm -f .bad-compare
924 ifeq ($(patsubst %-lynx,mips-sgi-irix4,$(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)
925         for i in `cd $(STAGE4DIR) ; find . -name \*.o -print` ; do \
926                 tail +10c $(STAGE3DIR)/$$i > foo1 ; \
927                 tail +10c $(STAGE4DIR)/$$i > foo2 ; \
928                 if cmp foo1 foo2 ; then \
929                         true ; \
930                 else \
931                         echo $$i ; \
932                         touch .bad-compare ; \
933                 fi ; \
934         done
935         rm -f foo1 foo2
936 else
937         for i in `cd $(STAGE4DIR) ; find . -name \*.o -print` ; do \
938                 cmp $(STAGE3DIR)/$$i $(STAGE4DIR)/$$i || touch .bad-compare ; \
939         done
940 endif
941         if [ -f CLEAN_ALL ] ; then \
942           rm -rf $(STAGE2DIR) $(STAGE3DIR) $(STAGE4DIR) ; \
943         else \
944           if [ -f CLEAN_STAGES ] ; then \
945             if [ -f .bad-compare ] ; then \
946               true ; \
947             else \
948               rm -rf $(STAGE1DIR) $(STAGE2DIR) $(STAGE3DIR) ; \
949             fi ; \
950           else true ; \
951           fi ; \
952         fi
953
954 .PHONY: clean
955 clean:
956         rm -rf $(HOLESDIR) $(INPLACEDIR) $(WORKING_DIR)* $(host)-stamp-* *~
957
958 .PHONY: very
959 very:
960         rm -rf $(TREE)
961
962 force:
963
964 endif # host
965
966 ### Local Variables:
967 ### fill-column: 131
968 ### End: