* Makefile.in: added variables CHILL_FOR_TARGET, CHILLFLAGS,
[deliverable/binutils-gdb.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 ifndef host
19 error:
20 @echo You must set the variable \"host\" to use this Makefile ; exit 1
21 else
22
23 ### from here to very near the end of the file is the real guts of this
24 ### Makefile, and it is not seen if the variable 'host' is not set
25
26 ###
27 ### START EDITTING HERE!!!
28 ### These things will need to be set differently for each release.
29 ###
30
31 ### from which cvs tree are we working?
32 TREE := devo
33
34 ### binaries should be installed into?
35 ROOTING := /usr/cygnus
36
37 ### When working from a tagged set of source, this should be the tag. If not,
38 ### then set the macro to be empty.
39 CVS_TAG :=
40
41 ### The name of the cvs module for this release. The intersection of
42 ### CVS_MODULE and CVS_TAG defines the source files in this release.
43 CVS_MODULE := latest
44
45 ### Historically, this was identical to CVS_TAG. This is changing.
46 RELEASE_TAG := latest-921229
47
48 ### Historically, binaries were installed here. This is changing.
49 release_root := $(ROOTING)/$(RELEASE_TAG)
50
51 ### STOP EDITTING HERE!!!
52 ### With luck, eventually, nothing else will need to be editted.
53
54 TIME := time
55 GCC := gcc -O -g
56 GNUC := "CC=$(GCC)"
57 CFLAGS := -g
58 GNU_MAKE := /usr/latest/bin/make -w
59
60 override MAKE := make
61 override MFLAGS :=
62 #override MAKEFLAGS :=
63
64 SHELL := /bin/sh
65
66 FLAGS_TO_PASS := \
67 "GCC=$(GCC)" \
68 "CFLAGS=$(CFLAGS)" \
69 "TIME=$(TIME)" \
70 "MF=$(MF)" \
71 "host=$(host)"
72
73
74 prefixes = -prefix=$(release_root) -exec-prefix=$(release_root)/H-$(host)
75 relbindir = $(release_root)/H-$(host)/bin
76
77
78 ### general config stuff
79 WORKING_DIR := $(host)-objdir
80 STAGE1DIR := $(WORKING_DIR).1
81 STAGE2DIR := $(WORKING_DIR).2
82 STAGE3DIR := $(WORKING_DIR).3
83 INPLACEDIR := $(host)-in-place
84 HOLESDIR := $(host)-holes
85
86 .PHONY: all
87 ifdef target
88 ##
89 ## This is a cross compilation
90 ##
91 arch = $(host)-x-$(target)
92 config = $(host) -target=$(target)
93 NATIVEDIR := $(arch)-native-objdir
94 CYGNUSDIR := $(arch)-cygnus-objdir
95 LATESTDIR := $(arch)-latest-objdir
96 FLAGS_TO_PASS := $(FLAGS_TO_PASS) "target=$(target)"
97
98 all: do-native do-latest
99 build-all: build-native build-latest
100
101 else
102 ##
103 ## This is a native compilation
104 ##
105 all: $(host)-stamp-3stage-done
106 #all: in-place do1 do2 do3 comparison
107 endif
108
109 everything: do-cross
110 #everything: in-place do1 do2 do3 comparison do-cygnus
111
112 .PHONY: do-native
113 do-native: $(host)-stamp-holes $(arch)-stamp-native
114 do-native-config: $(arch)-stamp-native-configured
115 build-native: $(host)-stamp-holes $(arch)-stamp-native-checked
116 config-native: $(host)-stamp-holes $(arch)-stamp-native-configured
117
118 $(arch)-stamp-native:
119 PATH=`pwd`/$(HOLESDIR) ; \
120 export PATH ; \
121 SHELL=sh ; export SHELL ; \
122 $(TIME) $(GNU_MAKE) -f test-build.mk $(arch)-stamp-native-installed $(FLAGS_TO_PASS)
123 if [ -f CLEAN_ALL ] ; then rm -rf $(NATIVEDIR) ; else true ; fi
124 touch $(arch)-stamp-native
125
126 $(arch)-stamp-native-installed: $(arch)-stamp-native-checked
127 cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) install
128 cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) install-info
129 touch $@
130
131 $(arch)-stamp-native-checked: $(arch)-stamp-native-built
132 # cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) check
133 touch $@
134
135 $(arch)-stamp-native-built: $(arch)-stamp-native-configured
136 cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) all
137 cd $(NATIVEDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) info
138 touch $@
139
140 $(arch)-stamp-native-configured:
141 [ -d $(NATIVEDIR) ] || mkdir $(NATIVEDIR)
142 (cd $(NATIVEDIR) ; \
143 $(TIME) ../$(TREE)/configure $(config) -v -srcdir=../$(TREE) \
144 $(prefixes))
145 touch $@
146
147
148 .PHONY: do-cygnus
149 do-cygnus: $(host)-stamp-holes $(arch)-stamp-cygnus
150 build-cygnus: $(host)-stamp-holes $(arch)-stamp-cygnus-checked
151 config-cygnus: $(host)-stamp-holes $(arch)-stamp-cygnus-configured
152
153 $(arch)-stamp-cygnus:
154 [ -f $(relbindir)/gcc ] || (echo "must have gcc available"; exit 1)
155 PATH=$(relbindir):`pwd`/$(HOLESDIR) ; \
156 export PATH ; \
157 SHELL=sh ; export SHELL ; \
158 echo ; gcc -v ; echo ; \
159 $(TIME) $(GNU_MAKE) -f test-build.mk $(arch)-stamp-cygnus-installed $(FLAGS_TO_PASS)
160 if [ -f CLEAN_ALL ] ; then rm -rf $(CYGNUSDIR) ; else true ; fi
161 touch $(arch)-stamp-cygnus
162
163 $(arch)-stamp-cygnus-installed: $(arch)-stamp-cygnus-checked
164 cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install
165 cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install-info
166 touch $@
167
168 $(arch)-stamp-cygnus-checked: $(arch)-stamp-cygnus-built
169 # cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) check
170 touch $@
171
172 $(arch)-stamp-cygnus-built: $(arch)-stamp-cygnus-configured
173 cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) all
174 cd $(CYGNUSDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) info
175 touch $@
176
177 $(arch)-stamp-cygnus-configured:
178 [ -d $(CYGNUSDIR) ] || mkdir $(CYGNUSDIR)
179 cd $(CYGNUSDIR) ; \
180 $(TIME) ../$(TREE)/configure $(config) -v -srcdir=../$(TREE) $(prefixes)
181 touch $@
182
183 .PHONY: do-latest
184 do-latest: $(host)-stamp-holes $(arch)-stamp-latest
185 build-latest: $(host)-stamp-holes $(arch)-stamp-latest-checked
186
187 $(arch)-stamp-latest:
188 PATH=/usr/latest/bin:`pwd`/$(HOLESDIR) ; \
189 export PATH ; \
190 SHELL=sh ; export SHELL ; \
191 $(TIME) $(GNU_MAKE) -f test-build.mk $(arch)-stamp-latest-installed $(FLAGS_TO_PASS)
192 touch $(arch)-stamp-latest
193
194 $(arch)-stamp-latest-installed: $(arch)-stamp-latest-checked
195 cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install
196 cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) install-info
197 touch $@
198
199 $(arch)-stamp-latest-checked: $(arch)-stamp-latest-built
200 # cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) check
201 touch $@
202
203 $(arch)-stamp-latest-built: $(arch)-stamp-latest-configured
204 cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) all
205 cd $(LATESTDIR) ; $(TIME) $(MAKE) $(FLAGS_TO_PASS) $(GNUC) info
206 touch $@
207
208 $(arch)-stamp-latest-configured:
209 [ -d $(LATESTDIR) ] || mkdir $(LATESTDIR)
210 cd $(LATESTDIR) ; \
211 $(TIME) ../$(TREE)/configure $(config) -v -srcdir=../$(TREE) $(prefixes)
212 touch $@
213
214
215 .PHONY: in-place
216 in-place: $(host)-stamp-in-place
217
218 $(host)-stamp-in-place:
219 PATH=/bin:/usr/bin:/usr/ucb ; \
220 export PATH ; \
221 SHELL=/bin/sh ; export SHELL ; \
222 $(TIME) $(GNU_MAKE) -f test-build.mk $(host)-stamp-in-place-installed host=$(host) $(FLAGS_TO_PASS)
223 touch $@
224 if [ -f CLEAN_ALL ] ; then \
225 rm -rf $(INPLACEDIR) ; \
226 else \
227 mv $(INPLACEDIR) $(STAGE1DIR) ; \
228 fi
229
230 $(host)-stamp-in-place-installed: $(host)-stamp-in-place-checked
231 cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" install host=$(host)
232 cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" install-info host=$(host)
233 touch $@
234
235 $(host)-stamp-in-place-checked: $(host)-stamp-in-place-built
236 # cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" check host=$(host)
237 touch $@
238
239 $(host)-stamp-in-place-built: $(host)-stamp-in-place-configured
240 cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" all host=$(host)
241 cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" info host=$(host)
242 touch $@
243
244 $(host)-stamp-in-place-configured: $(host)-stamp-in-place-cp
245 cd $(INPLACEDIR) ; $(TIME) ./configure $(host) -v $(prefixes)
246 touch $@
247
248 $(host)-stamp-in-place-cp:
249 rm -rf $(INPLACEDIR)
250 mkdir $(INPLACEDIR)
251 (cd $(TREE) ; tar cf - .) | (cd $(INPLACEDIR) ; tar xf -)
252 touch $@
253
254 $(host)-stamp-3stage-done: do1 do2 do3 comparison
255 touch $@
256
257
258 .PHONY: do1
259 do1: $(host)-stamp-holes $(host)-stamp-stage1
260 do1-config: $(host)-stamp-stage1-configured
261 do1-build: $(host)-stamp-stage1-checked
262
263 $(host)-stamp-stage1:
264 if [ -d $(STAGE1DIR) ] ; then \
265 mv $(STAGE1DIR) $(WORKING_DIR) ; \
266 else \
267 true ; \
268 fi
269 PATH=`pwd`/$(HOLESDIR) ; \
270 export PATH ; \
271 SHELL=sh ; export SHELL ; \
272 $(TIME) $(GNU_MAKE) -f test-build.mk $(host)-stamp-stage1-installed host=$(host) $(FLAGS_TO_PASS) $(NATIVEC)
273 touch $@
274 if [ -f CLEAN_ALL ] ; then \
275 rm -rf $(WORKING_DIR) ; \
276 else \
277 mv $(WORKING_DIR) $(STAGE1DIR) ; \
278 fi
279
280 $(host)-stamp-stage1-installed: $(host)-stamp-stage1-checked
281 cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" install host=$(host)
282 cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" install-info host=$(host)
283 ifeq ($(host),rs6000-ibm-aix)
284 rm $(relbindir)/make
285 endif
286 touch $@
287
288 $(host)-stamp-stage1-checked: $(host)-stamp-stage1-built
289 # cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" check host=$(host)
290 touch $@
291
292 $(host)-stamp-stage1-built: $(host)-stamp-stage1-configured
293 cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" all host=$(host)
294 cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" info host=$(host)
295 touch $@
296
297 $(host)-stamp-stage1-configured:
298 [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
299 cd $(WORKING_DIR) ; \
300 $(TIME) ../$(TREE)/configure $(host) -v -srcdir=../$(TREE) $(prefixes)
301 touch $@
302
303 .PHONY: do2
304 do2: $(HOLESDIR) $(host)-stamp-stage2
305
306 $(host)-stamp-stage2:
307 if [ -d $(STAGE2DIR) ] ; then \
308 mv $(STAGE2DIR) $(WORKING_DIR) ; \
309 else \
310 true ; \
311 fi
312 PATH=$(relbindir):`pwd`/$(HOLESDIR) ; \
313 export PATH ; \
314 SHELL=sh ; export SHELL ; \
315 $(TIME) $(GNU_MAKE) $(FLAGS_TO_PASS) -f test-build.mk -w $(host)-stamp-stage2-installed
316 mv $(WORKING_DIR) $(STAGE2DIR)
317 touch $@
318
319
320 $(host)-stamp-stage2-installed: $(host)-stamp-stage2-checked
321 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" install host=$(host)
322 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" install-info host=$(host)
323 touch $@
324
325 $(host)-stamp-stage2-checked: $(host)-stamp-stage2-built
326 # cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
327 touch $@
328
329 $(host)-stamp-stage2-built: $(host)-stamp-stage2-configured
330 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" all host=$(host)
331 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" info host=$(host)
332 touch $@
333
334 $(host)-stamp-stage2-configured:
335 [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
336 cd $(WORKING_DIR) ; \
337 $(TIME) ../$(TREE)/configure $(host) -v -srcdir=../$(TREE) $(prefixes)
338 touch $@
339
340 .PHONY: do3
341 do3: $(HOLESDIR) $(host)-stamp-stage3
342
343 $(host)-stamp-stage3:
344 if [ -d $(STAGE3DIR) ] ; then \
345 mv $(STAGE3DIR) $(WORKING_DIR) ; \
346 else \
347 true ; \
348 fi
349 PATH=$(relbindir):`pwd`/$(HOLESDIR) ; \
350 export PATH ; \
351 SHELL=sh ; export SHELL ; \
352 $(TIME) $(GNU_MAKE) $(FLAGS_TO_PASS) -f test-build.mk -w $(host)-stamp-stage3-checked
353 mv $(WORKING_DIR) $(STAGE3DIR)
354 touch $@
355
356
357 $(host)-stamp-stage3-installed: $(host)-stamp-stage3-checked
358 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" install host=$(host)
359 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" install-info host=$(host)
360 touch $@
361
362 $(host)-stamp-stage3-checked: $(host)-stamp-stage3-built
363 # cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
364 touch $@
365
366 $(host)-stamp-stage3-built: $(host)-stamp-stage3-configured
367 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" all host=$(host)
368 cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" info host=$(host)
369 touch $@
370
371 $(host)-stamp-stage3-configured:
372 [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
373 cd $(WORKING_DIR) ; \
374 $(TIME) ../$(TREE)/configure $(host) -v -srcdir=../$(TREE) $(prefixes)
375 touch $@
376
377 # These things are needed by a three-stage, but are not included locally.
378
379 HOLES := \
380 [ \
381 ar \
382 as \
383 awk \
384 basename \
385 cat \
386 cc \
387 chmod \
388 cmp \
389 cp \
390 date \
391 diff \
392 echo \
393 egrep \
394 ex \
395 expr \
396 find \
397 grep \
398 head \
399 hostname \
400 install \
401 ld \
402 lex \
403 ln \
404 ls \
405 make \
406 mkdir \
407 mv \
408 nm \
409 pwd \
410 ranlib \
411 rm \
412 rmdir \
413 sed \
414 sh \
415 sort \
416 test \
417 time \
418 touch \
419 tr \
420 true \
421 wc \
422 whoami
423
424 ### so far only sun make supports VPATH
425 ifeq ($(subst sun3,sun4,$(host)),sun4)
426 MAKE_HOLE :=
427 else
428 MAKE_HOLE := make
429 endif
430
431 ### solaris 2 -- don't use /usr/ucb/cc
432 ifeq (sparc-sun-solaris2,$(host))
433 PARTIAL_HOLE_DIRS := /opt/cygnus/bin
434 CC_HOLE := cc
435 else
436 CC_HOLE :=
437 endif
438
439 ### rs6000 as is busted. We cache a patched version in unsupported.
440 ifeq ($(host),rs6000-ibm-aix)
441 AS_HOLE := as
442 else
443 AS_HOLE :=
444 endif
445
446 ### These things are also needed by a three-stage, but in this case, the GNU version of the tool is required.
447 PARTIAL_HOLES := \
448 $(AS_HOLE) \
449 $(MAKE_HOLE) \
450 $(CC_HOLE) \
451 flex \
452 m4
453
454 ### look in these directories for things missing from a three-stage
455 HOLE_DIRS := \
456 $(HOLE_DIRS) \
457 /bin \
458 /usr/bin \
459 /usr/ucb \
460 /usr/ccs/bin \
461 /usr/unsupported/bin
462
463 ### look in these directories for alternate versions of some tools.
464 PARTIAL_HOLE_DIRS := \
465 /usr/latest/bin \
466 /usr/progressive/bin \
467 $(PARTIAL_HOLE_DIRS) \
468 /usr/vintage/bin \
469 /usr/unsupported/bin
470
471 $(HOLESDIR): $(host)-stamp-holes
472
473 $(host)-stamp-holes:
474 -rm -rf $(HOLESDIR)
475 -mkdir $(HOLESDIR)
476 @for i in $(HOLES) ; do \
477 found= ; \
478 for j in $(HOLE_DIRS) ; do \
479 if [ -x $$j/$$i ] ; then \
480 ln -s $$j/$$i $(HOLESDIR) || cp $$j/$$i $(HOLESDIR) ; \
481 echo $$i from $$j ; \
482 found=t ; \
483 break ; \
484 fi ; \
485 done ; \
486 case "$$found" in \
487 t) ;; \
488 *) echo $$i is NOT found ;; \
489 esac ; \
490 done
491 @for i in $(PARTIAL_HOLES) ; do \
492 found= ; \
493 for j in $(PARTIAL_HOLE_DIRS) ; do \
494 if [ -x $$j/$$i ] ; then \
495 rm -f $(HOLESDIR)/$$i ; \
496 cp $$j/$$i $(HOLESDIR)/$$i || exit 1; \
497 echo $$i from $$j ; \
498 found=t ; \
499 break ; \
500 fi ; \
501 done ; \
502 case "$$found" in \
503 t) ;; \
504 *) echo $$i is NOT found ;; \
505 esac ; \
506 done
507 touch $@
508
509 .PHONY: comparison
510 comparison: $(host)-stamp-3stage-compared
511
512 $(host)-stamp-3stage-compared:
513 rm -f .bad-compare
514 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)
515 for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
516 tail +10c $(STAGE2DIR)/$$i > foo1 ; \
517 tail +10c $(STAGE3DIR)/$$i > foo2 ; \
518 if cmp foo1 foo2 ; then \
519 true ; \
520 else \
521 echo $$i ; \
522 touch .bad-compare ; \
523 fi ; \
524 done
525 rm -f foo1 foo2
526 else
527 for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
528 cmp $(STAGE2DIR)/$$i $(STAGE3DIR)/$$i || touch .bad-compare ; \
529 done
530 endif
531 if [ -f CLEAN_ALL ] ; then \
532 rm -rf $(STAGE2DIR) $(STAGE3DIR) ; \
533 else \
534 if [ -f CLEAN_STAGES ] ; then \
535 if [ -f .bad-compare ] ; then \
536 true ; \
537 else \
538 rm -rf $(STAGE1DIR) $(STAGE2DIR) ; \
539 fi ; \
540 else true ; \
541 fi ; \
542 fi
543 touch $@
544
545 .PHONY: clean
546 clean:
547 rm -rf $(HOLESDIR) $(INPLACEDIR) $(WORKING_DIR)* $(host)-stamp-* *~
548
549 .PHONY: very
550 very:
551 rm -rf $(TREE)
552
553 force:
554
555 endif # host
556
557 ### Local Variables:
558 ### fill-column: 131
559 ### End:
This page took 0.042748 seconds and 4 git commands to generate.