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