add uniq to holes, ccross changes
[platform/upstream/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 GCC             := $(host)-gcc -O
38 GNUC            := CC="$(GCC)"
39 CFLAGS          := -g
40 CXXFLAGS        := -g -O
41 GNU_MAKE        := /usr/latest/bin/make -w 
42 MAKEINFOFLAGS   :=
43
44 override MAKE           := make
45 override MFLAGS         :=
46 #override MAKEFLAGS     :=
47
48 SHELL := /bin/sh
49
50 ifndef build
51 build := $(host)
52 endif
53
54 ifndef target
55 target := $(host)
56 endif
57
58 ifneq ($(build),$(host))
59
60 # We are building on a machine other than the host.  We rely upon
61 # previously built cross-compilers from the build machine to the host
62 # (used to build the executables) and from the build machine to the
63 # target (used to build the libraries).
64
65 AR              := $(host)-ar
66 AR_FOR_TARGET   := $(target)-ar
67 AS              := $(host)-as
68 AS_FOR_TARGET   := $(target)-as
69 CC              := $(host)-gcc
70 CC_FOR_BUILD    := gcc
71 CC_FOR_TARGET   := $(target)-gcc
72 CXX             := $(host)-c++
73 CXX_FOR_TARGET  := $(target)-c++
74 GCC             := $(host)-gcc -O
75 GXX             := $(host)-g++
76 GXX_FOR_TARGET  := $(target)-g++
77 HOST_PREFIX     := $(build)-
78 HOST_PREFIX_1   := $(build)-
79 MAKEINFO        := makeinfo
80 MUNCH_NM        := $(host)-nm
81 NM              := $(host)-nm
82 NM_FOR_TARGET   := $(target)-nm
83 RANLIB          := $(host)-ranlib
84 RANLIB_FOR_TARGET       := $(target)-ranlib
85
86 FLAGS_TO_PASS := \
87         "AR=$(AR)" \
88         "AR_FOR_TARGET=$(AR_FOR_TARGET)" \
89         "AS=$(AS)" \
90         "AS_FOR_TARGET=$(AS_FOR_TARGET)" \
91         "CC=$(CC)" \
92         "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
93         "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
94         "CXX=$(CXX)" \
95         "CXX_FOR_TARGET=$(CXX_FOR_TARGET)" \
96         "CFLAGS=$(CFLAGS)" \
97         "CXXFLAGS=$(CXXFLAGS)" \
98         "GCC=$(GCC)" \
99         "HOST_PREFIX=$(HOST_PREFIX)" \
100         "HOST_PREFIX_1=$(HOST_PREFIX_1)" \
101         "MAKEINFO=$(MAKEINFO)" \
102         "MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \
103         "MF=$(MF)" \
104         "MUNCH_NM=$(MUNCH_NM)" \
105         "NM=$(NM)" \
106         "NM_FOR_TARGET=$(NM_FOR_TARGET)" \
107         "RANLIB=$(RANLIB)" \
108         "RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET)" \
109         "RELEASE_TAG=$(RELEASE_TAG)" \
110         "TIME=$(TIME)" \
111         "build=$(build)" \
112         "host=$(host)"
113
114 # We must pass the build cross host tools in the environment of
115 # configure, so that autoconf scripts will run the right programs.
116 configenv := AR="$(AR)" CC="$(CC)" RANLIB="$(RANLIB)"
117
118 else
119
120 # This is a normal build on the host machine.
121
122 FLAGS_TO_PASS := \
123         "GCC=$(GCC)" \
124         "CFLAGS=$(CFLAGS)" \
125         "CXXFLAGS=$(CXXFLAGS)" \
126         "TIME=$(TIME)" \
127         "MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \
128         "MF=$(MF)" \
129         "host=$(host)" \
130         "RELEASE_TAG=$(RELEASE_TAG)"
131
132 ifneq  '$(CC)' 'cc'
133 FLAGS_TO_PASS := "CC=$(CC)" $(FLAGS_TO_PASS)
134 endif
135
136 configenv :=
137
138 endif
139
140
141 # These are the prefixes used for Cygnus builds.
142 prefixes        = --prefix=$(release_root) --exec-prefix=$(release_root)/H-$(host)
143
144 relbindir       = $(release_root)/H-$(host)/bin
145
146 ### general config stuff
147 WORKING_DIR     := $(host)-objdir
148 STAGE1DIR       := $(WORKING_DIR).1
149 STAGE2DIR       := $(WORKING_DIR).2
150 STAGE3DIR       := $(WORKING_DIR).3
151 INPLACEDIR      := $(host)-in-place
152
153 # Arrange to find the needed programs.  If we are building on a
154 # machine other than the host, we must find the cross-compilers.
155
156 ifneq ($(build),$(host))
157
158 holesys         := $(build)
159 HOLESSTAMP      := $(holesys)-stamp-holes $(build)-x-$(host)-stamp-holes $(build)-x-$(target)-stamp-holes
160 HOLESDIR        := $(holesys)-holes
161 BUILD_HOST_HOLES_DIR    := $(build)-x-$(host)-holes
162 BUILD_TARGET_HOLES_DIR  := $(build)-x-$(target)-holes
163
164 SET_NATIVE_HOLES := SHELL=sh ; PATH=`pwd`/$(HOLESDIR):`pwd`/$(BUILD_HOST_HOLES_DIR):`pwd`/$(BUILD_TARGET_HOLES_DIR) ; export PATH ; export SHELL ;
165 SET_CYGNUS_PATH  := SHELL=sh ; PATH=`pwd`/$(HOLESDIR):`pwd`/$(BUILD_HOST_HOLES_DIR):`pwd`/$(BUILD_TARGET_HOLES_DIR) ; export PATH ; export SHELL ;
166 SET_LATEST_PATH  := SHELL=sh ; PATH=/usr/latest/bin:`pwd`/$(HOLESDIR):`pwd`/$(BUILD_HOST_HOLES_DIR):`pwd`/$(BUILD_TARGET_HOLES_DIR) ; export PATH ; export SHELL ;
167
168 else
169
170 holesys         := $(host)
171 HOLESSTAMP      := $(holesys)-stamp-holes
172 HOLESDIR        := $(holesys)-holes
173
174 SET_NATIVE_HOLES := SHELL=sh ; PATH=`pwd`/$(HOLESDIR) ; export PATH ; export SHELL ;
175 SET_CYGNUS_PATH  := SHELL=sh ; PATH=$(relbindir):`pwd`/$(HOLESDIR) ; export PATH ; export SHELL ;
176 SET_LATEST_PATH  := SHELL=sh ; PATH=/usr/latest/bin:`pwd`/$(HOLESDIR) ; export PATH ; export SHELL ;
177
178 endif
179
180 .PHONY: all
181 ifneq ($(target),$(host))
182 ##
183 ## This is a cross compilation
184 ##
185 arch            = $(host)-x-$(target)
186 config          = -host=$(host) -target=$(target)
187 FLAGS_TO_PASS   := $(FLAGS_TO_PASS) "target=$(target)"
188
189 ifneq ($(build),$(host))
190 all:    do-cygnus do-latest
191 build-all: build-cygnus build-latest
192 else
193 all:    do-native do-latest
194 build-all: build-native build-latest
195 endif
196
197 ifeq ($(target),mips-idt-ecoff)
198 configargs      := $(configargs) -with-gnu-as -with-stabs
199 endif
200
201 ifeq ($(host),i386-go32)
202 ifeq ($(subst mips-idt-ecoff,sparclite-aout,$(target)),sparclite-aout)
203 configargs      := $(configargs) -with-gnu-ld
204 endif
205 endif
206
207 else
208 ##
209 ## This is a native compilation
210 ##
211 arch            = $(host)
212 config          = -host=$(host)
213 ifneq ($(build),$(host))
214 all:    do-cygnus do-latest
215 else
216 all:    $(host)-stamp-3stage-done
217 endif
218 #all:   in-place do1 do2 do3 comparison
219
220 ifeq ($(subst mips-sgi-irix4,mips-dec-ultrix,$(host)),mips-dec-ultrix)
221 configargs      := $(configargs) -with-gnu-as -with-stabs
222 endif
223
224 endif
225
226 ifeq ($(target),m68k-hp-hpux)
227 configargs      := $(configargs) -with-gnu-as
228 endif
229
230
231 NATIVEDIR       := $(arch)-native-objdir
232 CYGNUSDIR       := $(arch)-cygnus-objdir
233 LATESTDIR       := $(arch)-latest-objdir
234
235
236 everything:      do-cross 
237 #everything:    in-place do1 do2 do3 comparison do-cygnus 
238
239 .PHONY: do-native
240 do-native: $(HOLESSTAMP) $(arch)-stamp-native
241 do-native-config: $(arch)-stamp-native-configured
242 build-native: $(HOLESSTAMP) $(arch)-stamp-native-checked
243 config-native: $(HOLESSTAMP) $(arch)-stamp-native-configured
244
245 $(arch)-stamp-native: $(HOLESSTAMP)
246         $(SET_NATIVE_HOLES) $(TIME) $(GNU_MAKE) -f test-build.mk  $(arch)-stamp-native-installed $(FLAGS_TO_PASS) 
247         if [ -f CLEAN_ALL ] ; then rm -rf $(NATIVEDIR) ; else true ; fi
248         touch $(arch)-stamp-native
249
250 $(arch)-stamp-native-installed: $(HOLESSTAMP) $(arch)-stamp-native-checked
251         $(SET_NATIVE_HOLES) cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) install 
252         $(SET_NATIVE_HOLES) cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) install-info 
253         touch $@
254
255 $(arch)-stamp-native-checked: $(arch)-stamp-native-built
256 #       cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) check 
257         touch $@
258
259 $(arch)-stamp-native-built: $(HOLESSTAMP) $(arch)-stamp-native-configured
260         $(SET_NATIVE_HOLES) cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) all 
261         $(SET_NATIVE_HOLES) cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) info 
262         touch $@
263
264 $(arch)-stamp-native-configured: $(HOLESSTAMP)
265         [ -d $(NATIVEDIR) ] || mkdir $(NATIVEDIR)
266         $(SET_NATIVE_HOLES) cd $(NATIVEDIR) ; $(configenv) $(TIME) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes) $(configargs)
267         touch $@
268
269
270 .PHONY: do-cygnus
271 do-cygnus: $(HOLESSTAMP) $(arch)-stamp-cygnus
272 build-cygnus: $(HOLESSTAMP) $(arch)-stamp-cygnus-checked
273 config-cygnus: $(HOLESSTAMP) $(arch)-stamp-cygnus-configured
274
275 vault-cygnus: $(HOLESSTAMP) $(arch)-stamp-cygnus-built
276         $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) vault-install 
277         
278
279 $(arch)-stamp-cygnus: 
280         [ -f $(relbindir)/$(host)-gcc ] || (echo "must have gcc available"; exit 1)
281         $(SET_CYGNUS_PATH) $(TIME) $(GNU_MAKE) -f test-build.mk $(arch)-stamp-cygnus-installed  $(FLAGS_TO_PASS)
282         if [ -f CLEAN_ALL ] ; then rm -rf $(CYGNUSDIR) ; else true ; fi
283         touch $(arch)-stamp-cygnus
284
285 $(arch)-stamp-cygnus-installed:  $(HOLESSTAMP) $(arch)-stamp-cygnus-checked
286         $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install 
287         $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install-info
288         touch $@
289
290 $(arch)-stamp-cygnus-checked: $(HOLESSTAMP) $(arch)-stamp-cygnus-built
291 #       cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) check 
292         touch $@
293
294 $(arch)-stamp-cygnus-built:  $(HOLESSTAMP) $(arch)-stamp-cygnus-configured
295         $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) all 
296         $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) info 
297         touch $@
298
299 $(arch)-stamp-cygnus-configured:  $(HOLESSTAMP)
300         [ -d $(CYGNUSDIR) ] || mkdir $(CYGNUSDIR)
301         $(SET_CYGNUS_PATH) cd $(CYGNUSDIR) ; $(GNUC) $(configenv) $(TIME) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes) $(configargs)
302         touch $@
303
304 .PHONY: do-latest
305 do-latest: $(HOLESSTAMP) $(arch)-stamp-latest
306 build-latest: $(HOLESSTAMP) $(arch)-stamp-latest-checked
307
308 $(arch)-stamp-latest:
309         $(SET_LATEST_PATH) $(TIME) $(GNU_MAKE) -f test-build.mk $(arch)-stamp-latest-installed  $(FLAGS_TO_PASS)
310         touch $(arch)-stamp-latest
311
312 $(arch)-stamp-latest-installed:  $(HOLESSTAMP) $(arch)-stamp-latest-checked
313         $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install 
314         $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install-info 
315         touch $@
316
317 $(arch)-stamp-latest-checked: $(arch)-stamp-latest-built
318 #       $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) check 
319         touch $@
320
321 $(arch)-stamp-latest-built: $(arch)-stamp-latest-configured
322         $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) all 
323         $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) info 
324         touch $@
325
326 $(arch)-stamp-latest-configured:
327         [ -d $(LATESTDIR) ] || mkdir $(LATESTDIR)
328         $(SET_LATEST_PATH) cd $(LATESTDIR) ; $(GNUC) $(configenv) $(TIME) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes) $(configargs)
329         touch $@
330
331
332 .PHONY: in-place
333 in-place:       $(host)-stamp-in-place
334
335 $(host)-stamp-in-place: 
336         PATH=/bin:/usr/bin:/usr/ucb ; \
337           export PATH ; \
338           SHELL=/bin/sh ; export SHELL ; \
339           $(TIME) $(GNU_MAKE) -f test-build.mk $(host)-stamp-in-place-installed host=$(host) $(FLAGS_TO_PASS)
340         touch $@
341         if [ -f CLEAN_ALL ] ; then \
342           rm -rf $(INPLACEDIR) ; \
343         else \
344           mv $(INPLACEDIR) $(STAGE1DIR) ; \
345         fi
346
347 $(host)-stamp-in-place-installed: $(host)-stamp-in-place-checked
348         cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" install host=$(host)
349         cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" install-info host=$(host)
350         touch $@
351
352 $(host)-stamp-in-place-checked: $(host)-stamp-in-place-built
353 #       cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" check host=$(host)
354         touch $@
355
356 $(host)-stamp-in-place-built: $(host)-stamp-in-place-configured
357         cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" all host=$(host)
358         cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" info host=$(host)
359         touch $@
360
361 $(host)-stamp-in-place-configured: $(host)-stamp-in-place-cp
362         cd $(INPLACEDIR) ; $(configenv) $(TIME) ./configure $(config) -v $(prefixes) $(configargs)
363         touch $@
364
365 $(host)-stamp-in-place-cp:
366         rm -rf $(INPLACEDIR)
367         mkdir $(INPLACEDIR)
368         (cd $(TREE) ; tar cf - .) | (cd $(INPLACEDIR) ; tar xf -)
369         touch $@
370
371 $(host)-stamp-3stage-done: do1 do2 do3 comparison
372         touch $@
373
374
375 .PHONY: do1
376 do1:        $(HOLESSTAMP) $(host)-stamp-stage1
377 do1-config: $(HOLESSTAMP) $(host)-stamp-stage1-configured
378 do1-build:  $(HOLESSTAMP) $(host)-stamp-stage1-checked
379
380 do1-vault: $(HOLESSTAMP) $(host)-stamp-stage1-built
381         if [ -d $(WORKING_DIR).1 ] ; then \
382           $(SET_NATIVE_HOLES) cd $(WORKING_DIR).1 ; $(MAKE) $(FLAGS_TO_PASS) host=$(host) "CFLAGS=$(CFLAGS)" vault-install ; \
383         else \
384           $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; $(MAKE) $(FLAGS_TO_PASS) host=$(host) "CFLAGS=$(CFLAGS)" vault-install ; \
385         fi
386
387 $(host)-stamp-stage1:
388         if [ -d $(STAGE1DIR) ] ; then \
389                 mv $(STAGE1DIR) $(WORKING_DIR) ; \
390         else \
391                 true ; \
392         fi
393         $(SET_NATIVE_HOLES) $(TIME) $(GNU_MAKE) -f test-build.mk $(FLAGS_TO_PASS) host=$(host) $(host)-stamp-stage1-installed
394         touch $@
395         if [ -f CLEAN_ALL ] ; then \
396           rm -rf $(WORKING_DIR) ; \
397         else \
398           mv $(WORKING_DIR) $(STAGE1DIR) ; \
399         fi
400
401 $(host)-stamp-stage1-installed: $(host)-stamp-stage1-checked
402         $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" install host=$(host)
403         $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" install-info host=$(host)
404 ifeq ($(host),rs6000-ibm-aix)
405         -rm $(relbindir)/make
406 endif
407         touch $@
408
409 $(host)-stamp-stage1-checked: $(host)-stamp-stage1-built
410 #       $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" check host=$(host)
411         touch $@
412
413 $(host)-stamp-stage1-built: $(host)-stamp-stage1-configured
414         $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" all host=$(host)
415         $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) "CFLAGS=$(CFLAGS)" info host=$(host)
416         touch $@
417
418 $(host)-stamp-stage1-configured:
419         [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
420         $(SET_NATIVE_HOLES) cd $(WORKING_DIR) ; \
421           $(configenv) $(TIME) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes) $(configargs)
422         touch $@
423
424 .PHONY: do2
425 do2:    $(HOLESDIR) $(host)-stamp-stage2
426
427 do2-vault: $(HOLESSTAMP) $(host)-stamp-stage2-built
428         if [ -d $(WORKING_DIR).2 ] ; then \
429           $(SET_CYGNUS_PATH) cd $(WORKING_DIR).2 ; $(MAKE) $(FLAGS_TO_PASS) host=$(host) "CFLAGS=$(CFLAGS)" vault-install ; \
430         else \
431           $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(MAKE) $(FLAGS_TO_PASS) host=$(host) "CFLAGS=$(CFLAGS)" vault-install ; \
432         fi
433
434
435
436 $(host)-stamp-stage2:
437         if [ -d $(STAGE2DIR) ] ; then \
438                 mv $(STAGE2DIR) $(WORKING_DIR) ; \
439         else \
440                 true ; \
441         fi
442         $(SET_CYGNUS_PATH) $(TIME) $(GNU_MAKE) $(FLAGS_TO_PASS) -f test-build.mk -w $(host)-stamp-stage2-installed
443         mv $(WORKING_DIR) $(STAGE2DIR)
444         touch $@
445
446
447 $(host)-stamp-stage2-installed: $(host)-stamp-stage2-checked
448         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install host=$(host)
449         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install-info host=$(host)
450         touch $@
451
452 $(host)-stamp-stage2-checked: $(host)-stamp-stage2-built
453 #       $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
454         touch $@
455
456 $(host)-stamp-stage2-built: $(host)-stamp-stage2-configured
457         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" all host=$(host)
458         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" info host=$(host)
459         touch $@
460
461 $(host)-stamp-stage2-configured:
462         [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
463         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; \
464           $(configenv) $(GNUC) $(TIME) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes) $(configargs)
465         touch $@
466
467 .PHONY: do3
468 do3:    $(HOLESDIR) $(host)-stamp-stage3
469
470 do3-vault: $(HOLESSTAMP) $(host)-stamp-stage3-built
471         if [ -d $(WORKING_DIR).3 ] ; then \
472           $(SET_CYGNUS_PATH) cd $(WORKING_DIR).3 ; $(MAKE) $(FLAGS_TO_PASS) host=$(host) "CFLAGS=$(CFLAGS)" vault-install ; \
473         else \
474           $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(MAKE) $(FLAGS_TO_PASS) host=$(host) "CFLAGS=$(CFLAGS)" vault-install ; \
475         fi
476
477 $(host)-stamp-stage3:
478         if [ -d $(STAGE3DIR) ] ; then \
479                 mv $(STAGE3DIR) $(WORKING_DIR) ; \
480         else \
481                 true ; \
482         fi
483         $(SET_CYGNUS_PATH) $(TIME) $(GNU_MAKE) $(FLAGS_TO_PASS) -f test-build.mk -w $(host)-stamp-stage3-checked 
484         mv $(WORKING_DIR) $(STAGE3DIR) 
485         touch $@
486
487
488 $(host)-stamp-stage3-installed: $(host)-stamp-stage3-checked
489         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install host=$(host)
490         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" install-info host=$(host)
491         touch $@
492
493 $(host)-stamp-stage3-checked: $(host)-stamp-stage3-built
494 #       $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
495         touch $@
496
497 $(host)-stamp-stage3-built: $(host)-stamp-stage3-configured
498         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" all host=$(host)
499         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(FLAGS_TO_PASS) $(GNUC) "CFLAGS=$(CFLAGS)" info host=$(host)
500         touch $@
501
502 $(host)-stamp-stage3-configured:
503         [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
504         $(SET_CYGNUS_PATH) cd $(WORKING_DIR) ; \
505           $(configenv) $(GNUC) $(TIME) ../$(TREE)/configure $(config) -v --srcdir=../$(TREE) $(prefixes) $(configargs)
506         touch $@
507
508 # These things are needed by a three-stage, but are not included locally.
509
510 HOLES := \
511         [ \
512         ar \
513         as \
514         awk \
515         basename \
516         cat \
517         cc \
518         chmod \
519         chgrp \
520         chown \
521         cmp \
522         cp \
523         cpio \
524         date \
525         diff \
526         dirname \
527         echo \
528         egrep \
529         ex \
530         expr \
531         false \
532         find \
533         grep \
534         head \
535         hostname \
536         install \
537         ld \
538         lex \
539         ln \
540         ls \
541         make \
542         mkdir \
543         mv \
544         nm \
545         pwd \
546         ranlib \
547         rm \
548         rmdir \
549         sed \
550         sh \
551         sort \
552         tar \
553         test \
554         time \
555         touch \
556         tr \
557         true \
558         uname \
559         uniq \
560         uudecode \
561         wc \
562         whoami
563
564 ### so far only sun make supports VPATH
565 ifeq ($(subst sun3,sun4,$(holesys)),sun4)
566 MAKE_HOLE :=
567 else
568 MAKE_HOLE := make
569 endif
570
571 ### solaris 2 -- don't use /usr/ucb/cc
572 ifeq (sparc-sun-solaris2,$(holesys))
573 SET_NATIVE_HOLES := SHELL=sh ; PATH=/opt/SUNWspro/bin:`pwd`/$(HOLESDIR) ; export PATH ; export SHELL ;
574 HOLE_DIRS := /usr/ccs/bin
575 CC_HOLE :=
576 NUKEM := cc 
577 endif
578
579 ### These things are also needed by a three-stage, but in this case, the GNU version of the tool is required.
580 PARTIAL_HOLES := \
581         $(MAKE_HOLE) \
582         $(CC_HOLE) \
583         flex \
584         m4
585
586 ### look in these directories for things missing from a three-stage
587 HOLE_DIRS := \
588         $(HOLE_DIRS) \
589         /bin \
590         /usr/bin \
591         /usr/ucb \
592         /usr/unsupported/bin
593
594 ### look in these directories for alternate versions of some tools.
595 PARTIAL_HOLE_DIRS := \
596         /usr/latest/bin \
597         /usr/progressive/bin \
598         $(PARTIAL_HOLE_DIRS) \
599         /usr/vintage/bin \
600         /usr/unsupported/bin
601
602 $(HOLESDIR): $(holesys)-stamp-holes
603
604 $(holesys)-stamp-holes:
605         -rm -rf $(HOLESDIR)
606         -mkdir $(HOLESDIR)
607         @for i in $(HOLES) ; do \
608                 found= ; \
609                 for j in $(HOLE_DIRS) ; do \
610                         if [ -x $$j/$$i ] ; then \
611                                 ln -s $$j/$$i $(HOLESDIR) || cp $$j/$$i $(HOLESDIR) ; \
612                                 echo $$i from $$j ; \
613                                 found=t ; \
614                                 break ; \
615                         fi ; \
616                 done ; \
617                 case "$$found" in \
618                 t) ;; \
619                 *) echo $$i is NOT found ;; \
620                 esac ; \
621         done
622         @for i in $(PARTIAL_HOLES) ; do \
623                 found= ; \
624                 for j in $(PARTIAL_HOLE_DIRS) ; do \
625                         if [ -x $$j/$$i ] ; then \
626                                 rm -f $(HOLESDIR)/$$i ; \
627                                 cp $$j/$$i $(HOLESDIR)/$$i || exit 1; \
628                                 echo $$i from $$j ; \
629                                 found=t ; \
630                                 break ; \
631                         fi ; \
632                 done ; \
633                 case "$$found" in \
634                 t) ;; \
635                 *) echo $$i is NOT found ;; \
636                 esac ; \
637         done
638 ifdef NUKEM
639         cd $(HOLESDIR); rm -f $(NUKEM)
640 endif
641         touch $@
642
643 # Get the cross-tools for build cross host when not building on the host.
644
645 BUILD_HOST_HOLES := \
646         byacc \
647         gcc \
648         makeinfo \
649         $(AR) \
650         $(AS) \
651         $(CC) \
652         $(CXX) \
653         $(GXX) \
654         $(NM) \
655         $(RANLIB)
656
657 BUILD_HOLES_DIRS := $(release_root)/H-$(build)/bin $(PARTIAL_HOLE_DIRS)
658
659 ifdef BUILD_HOST_HOLES_DIR
660 $(BUILD_HOST_HOLES_DIR): $(build)-x-$(host)-stamp-holes
661 endif
662
663 ifneq ($(build),$(host))
664 $(build)-x-$(host)-stamp-holes:
665         -rm -rf $(BUILD_HOST_HOLES_DIR)
666         -mkdir $(BUILD_HOST_HOLES_DIR)
667         @for i in $(BUILD_HOST_HOLES) ; do \
668                 found= ; \
669                 for j in $(BUILD_HOLES_DIRS) ; do \
670                         if [ -x $$j/$$i ] ; then \
671                                 ln -s $$j/$$i $(BUILD_HOST_HOLES_DIR) || cp $$j/$$i $(BUILD_HOST_HOLES_DIR) ; \
672                                 echo $$i from $$j ; \
673                                 found=t ; \
674                                 break ; \
675                         fi ; \
676                 done ; \
677                 case "$$found" in \
678                 t) ;; \
679                 *) echo $$i is NOT found ;; \
680                 esac ; \
681         done
682         touch $@
683 endif
684
685 # Get the cross tools for build cross target when not building on the host.
686
687 BUILD_TARGET_HOLES := \
688         byacc \
689         gcc \
690         makeinfo \
691         $(AR_FOR_TARGET) \
692         $(AS_FOR_TARGET) \
693         $(CC_FOR_TARGET) \
694         $(CXX_FOR_TARGET) \
695         $(GXX_FOR_TARGET) \
696         $(NM_FOR_TARGET) \
697         $(RANLIB_FOR_TARGET)
698
699 ifdef BUILD_TARGET_HOLES_DIR
700 $(BUILD_TARGET_HOLES_DIR): $(build)-x-$(target)-stamp-holes
701 endif
702
703 ifneq ($(build),$(target))
704 $(build)-x-$(target)-stamp-holes:
705         -rm -rf $(BUILD_TARGET_HOLES_DIR)
706         -mkdir $(BUILD_TARGET_HOLES_DIR)
707         @for i in $(BUILD_TARGET_HOLES) ; do \
708                 found= ; \
709                 for j in $(BUILD_HOLES_DIRS) ; do \
710                         if [ -x $$j/$$i ] ; then \
711                                 ln -s $$j/$$i $(BUILD_TARGET_HOLES_DIR) || cp $$j/$$i $(BUILD_TARGET_HOLES_DIR) ; \
712                                 echo $$i from $$j ; \
713                                 found=t ; \
714                                 break ; \
715                         fi ; \
716                 done ; \
717                 case "$$found" in \
718                 t) ;; \
719                 *) echo $$i is NOT found ;; \
720                 esac ; \
721         done
722         touch $@
723 endif
724
725 .PHONY: comparison
726 comparison: $(host)-stamp-3stage-compared
727
728 $(host)-stamp-3stage-compared:
729         rm -f .bad-compare
730 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)
731         for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
732                 tail +10c $(STAGE2DIR)/$$i > foo1 ; \
733                 tail +10c $(STAGE3DIR)/$$i > foo2 ; \
734                 if cmp foo1 foo2 ; then \
735                         true ; \
736                 else \
737                         echo $$i ; \
738                         touch .bad-compare ; \
739                 fi ; \
740         done
741         rm -f foo1 foo2
742 else
743         for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
744                 cmp $(STAGE2DIR)/$$i $(STAGE3DIR)/$$i || touch .bad-compare ; \
745         done
746 endif
747         if [ -f CLEAN_ALL ] ; then \
748           rm -rf $(STAGE2DIR) $(STAGE3DIR) ; \
749         else \
750           if [ -f CLEAN_STAGES ] ; then \
751             if [ -f .bad-compare ] ; then \
752               true ; \
753             else \
754               rm -rf $(STAGE1DIR) $(STAGE2DIR) ; \
755             fi ; \
756           else true ; \
757           fi ; \
758         fi
759         touch $@        
760
761 .PHONY: clean
762 clean:
763         rm -rf $(HOLESDIR) $(INPLACEDIR) $(WORKING_DIR)* $(host)-stamp-* *~
764
765 .PHONY: very
766 very:
767         rm -rf $(TREE)
768
769 force:
770
771 endif # host
772
773 ### Local Variables:
774 ### fill-column: 131
775 ### End: