]> Git Repo - binutils.git/blob - test-build.mk
Update to match revised bfd-in.h.
[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 ([email protected]).
11 ### Many subsequent additions (and current maintainance by) david d `zoo' zuhn,
12 ### ([email protected]).
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-921118
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         touch $@
284
285 $(host)-stamp-stage1-checked: $(host)-stamp-stage1-built
286 #       cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" check host=$(host)
287         touch $@
288
289 $(host)-stamp-stage1-built: $(host)-stamp-stage1-configured
290         cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" all host=$(host)
291         cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) "CFLAGS=$(CFLAGS)" info host=$(host)
292         touch $@
293
294 $(host)-stamp-stage1-configured:
295         [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
296         cd $(WORKING_DIR) ; \
297           $(TIME) ../$(TREE)/configure $(host) -v -srcdir=../$(TREE) $(prefixes)
298         touch $@
299
300 .PHONY: do2
301 do2:    $(HOLESDIR) $(host)-stamp-stage2
302
303 $(host)-stamp-stage2:
304         if [ -d $(STAGE2DIR) ] ; then \
305                 mv $(STAGE2DIR) $(WORKING_DIR) ; \
306         else \
307                 true ; \
308         fi
309         PATH=$(relbindir):`pwd`/$(HOLESDIR) ; \
310           export PATH ; \
311           SHELL=sh ; export SHELL ; \
312           $(TIME) $(GNU_MAKE) $(FLAGS_TO_PASS) -f test-build.mk -w $(host)-stamp-stage2-installed
313         mv $(WORKING_DIR) $(STAGE2DIR)
314         touch $@
315
316
317 $(host)-stamp-stage2-installed: $(host)-stamp-stage2-checked
318         cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" install host=$(host)
319         cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" install-info host=$(host)
320         touch $@
321
322 $(host)-stamp-stage2-checked: $(host)-stamp-stage2-built
323 #       cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
324         touch $@
325
326 $(host)-stamp-stage2-built: $(host)-stamp-stage2-configured
327         cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" all host=$(host)
328         cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" info host=$(host)
329         touch $@
330
331 $(host)-stamp-stage2-configured:
332         [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
333         cd $(WORKING_DIR) ; \
334           $(TIME) ../$(TREE)/configure $(host) -v -srcdir=../$(TREE) $(prefixes)
335         touch $@
336
337 .PHONY: do3
338 do3:    $(HOLESDIR) $(host)-stamp-stage3
339
340 $(host)-stamp-stage3:
341         if [ -d $(STAGE3DIR) ] ; then \
342                 mv $(STAGE3DIR) $(WORKING_DIR) ; \
343         else \
344                 true ; \
345         fi
346         PATH=$(relbindir):`pwd`/$(HOLESDIR) ; \
347           export PATH ; \
348           SHELL=sh ; export SHELL ; \
349           $(TIME) $(GNU_MAKE) $(FLAGS_TO_PASS) -f test-build.mk -w $(host)-stamp-stage3-checked 
350         mv $(WORKING_DIR) $(STAGE3DIR) 
351         touch $@
352
353
354 $(host)-stamp-stage3-installed: $(host)-stamp-stage3-checked
355         cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" install host=$(host)
356         cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" install-info host=$(host)
357         touch $@
358
359 $(host)-stamp-stage3-checked: $(host)-stamp-stage3-built
360 #       cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" check host=$(host)
361         touch $@
362
363 $(host)-stamp-stage3-built: $(host)-stamp-stage3-configured
364         cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" all host=$(host)
365         cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) $(GNUC) "CFLAGS=$(CFLAGS)" info host=$(host)
366         touch $@
367
368 $(host)-stamp-stage3-configured:
369         [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
370         cd $(WORKING_DIR) ; \
371           $(TIME) ../$(TREE)/configure $(host) -v -srcdir=../$(TREE) $(prefixes)
372         touch $@
373
374 # These things are needed by a three-stage, but are not included locally.
375
376 HOLES := \
377         [ \
378         ar \
379         as \
380         awk \
381         basename \
382         cat \
383         cc \
384         chmod \
385         cmp \
386         cp \
387         date \
388         diff \
389         echo \
390         egrep \
391         ex \
392         expr \
393         find \
394         grep \
395         head \
396         hostname \
397         install \
398         ld \
399         lex \
400         ln \
401         ls \
402         make \
403         mkdir \
404         mv \
405         nm \
406         pwd \
407         ranlib \
408         rm \
409         rmdir \
410         sed \
411         sh \
412         sort \
413         test \
414         time \
415         touch \
416         tr \
417         true \
418         wc \
419         whoami
420
421 ### so far only sun make supports VPATH
422 ifeq ($(subst sun3,sun4,$(host)),sun4)
423 MAKE_HOLE :=
424 else
425 MAKE_HOLE := make
426 endif
427
428 ### solaris 2 -- don't use /usr/ucb/cc
429 ifeq (sparc-sun-solaris2,$(host))
430 CC_HOLE := cc
431 else
432 CC_HOLE :=
433 endif
434
435 ### rs6000 as is busted.  We cache a patched version in unsupported.
436 ifeq ($(host),rs6000-ibm-aix)
437 AS_HOLE := as
438 else
439 AS_HOLE :=
440 endif
441
442 ### These things are also needed by a three-stage, but in this case, the GNU version of the tool is required.
443 PARTIAL_HOLES := \
444         $(AS_HOLE) \
445         $(MAKE_HOLE) \
446         $(CC_HOLE) \
447         flex \
448         m4
449
450 ### look in these directories for things missing from a three-stage
451 HOLE_DIRS := \
452         /bin \
453         /usr/bin \
454         /usr/ucb \
455         /usr/ccs/bin \
456         /usr/unsupported/bin
457
458 ### look in these directories for alternate versions of some tools.
459 PARTIAL_HOLE_DIRS := \
460         /usr/latest/bin \
461         /usr/progressive/bin \
462         /opt/cygnus/bin \
463         /usr/vintage/bin \
464         /usr/unsupported/bin
465
466 $(HOLESDIR): $(host)-stamp-holes
467
468 $(host)-stamp-holes:
469         -rm -rf $(HOLESDIR)
470         -mkdir $(HOLESDIR)
471         @for i in $(HOLES) ; do \
472                 found= ; \
473                 for j in $(HOLE_DIRS) ; do \
474                         if [ -x $$j/$$i ] ; then \
475                                 cp $$j/$$i $(HOLESDIR) ; \
476                                 echo $$i from $$j ; \
477                                 found=t ; \
478                                 break ; \
479                         fi ; \
480                 done ; \
481                 case "$$found" in \
482                 t) ;; \
483                 *) echo $$i is NOT found ;; \
484                 esac ; \
485         done
486         @for i in $(PARTIAL_HOLES) ; do \
487                 found= ; \
488                 for j in $(PARTIAL_HOLE_DIRS) ; do \
489                         if [ -x $$j/$$i ] ; then \
490                                 rm -f $(HOLESDIR)/$$i ; \
491                                 cp $$j/$$i $(HOLESDIR)/$$i || exit 1; \
492                                 echo $$i from $$j ; \
493                                 found=t ; \
494                                 break ; \
495                         fi ; \
496                 done ; \
497                 case "$$found" in \
498                 t) ;; \
499                 *) echo $$i is NOT found ;; \
500                 esac ; \
501         done
502         touch $@
503
504 .PHONY: comparison
505 comparison: $(host)-stamp-3stage-compared
506
507 $(host)-stamp-3stage-compared:
508         rm -f .bad-compare
509 ifeq ($(subst rs6000-ibm-aix,mips-sgi-irix4,$(subst mips-dec-ultrix,mips-sgi-irix4,$(host))),mips-sgi-irix4)
510         for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
511                 tail +10c $(STAGE2DIR)/$$i > foo1 ; \
512                 tail +10c $(STAGE3DIR)/$$i > foo2 ; \
513                 if cmp foo1 foo2 ; then \
514                         true ; \
515                 else \
516                         echo $$i ; \
517                         touch .bad-compare ; \
518                 fi ; \
519         done
520         rm -f foo1 foo2
521 else
522         for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
523                 cmp $(STAGE2DIR)/$$i $(STAGE3DIR)/$$i || touch .bad-compare ; \
524         done
525 endif
526         if [ -f CLEAN_ALL ] ; then \
527           rm -rf $(STAGE2DIR) $(STAGE3DIR) ; \
528         else \
529           if [ -f CLEAN_STAGES ] ; then \
530             if [ -f .bad-compare ] ; then \
531               true ; \
532             else \
533               rm -rf $(STAGE1DIR) $(STAGE2DIR) ; \
534             fi ; \
535           fi ; \
536         fi
537         touch $@        
538
539 .PHONY: clean
540 clean:
541         rm -rf $(HOLESDIR) $(INPLACEDIR) $(WORKING_DIR)* $(host)-stamp-* *~
542
543 .PHONY: very
544 very:
545         rm -rf $(TREE)
546
547 force:
548
549 endif # host
550
551 ### Local Variables:
552 ### fill-column: 131
553 ### End:
This page took 0.053265 seconds and 4 git commands to generate.