z8kgen: temp file to generate z8k-opc.h from
[external/binutils.git] / test-build.mk
1 ###
2 ### Makefile used to three-stage build a tree of source code.  Also used to
3 ### compile other bundles, first with cc, then with gcc.
4 ###
5
6 ### This file was written and is maintained by K. Richard Pixley,
7 ### <rich@cygnus.com>.
8
9 ### Every invocation of this Makefile needs to have a variable set (host), 
10 ### which is the named used for ./configure, and also the prefix for the
11 ### various files and directories used in a three stage.
12
13 ifndef host
14 error:; @echo You must set the variable \"host\" to use this Makefile ; exit 1
15 else
16
17 ### from here to very near the end of the file is the real guts of this 
18 ### Makefile, and it is not seen if the variable 'host' is not set 
19
20 ###
21 ### START EDITTING HERE!!!
22 ### These things will need to be set differently for each release.
23 ###
24
25 ### from which cvs tree are we working?
26 TREE := devo
27
28 ### binaries should be installed into?
29 ROOTING := /usr/cygnus
30
31 ### When working from a tagged set of source, this should be the tag.  If not,
32 ### then set the macro to be empty.
33 #CVS_TAG := -r emacs-920529
34 CVS_TAG :=
35
36 ### The name of the cvs module for this release.  The intersection of
37 ### CVS_MODULE and CVS_TAG defines the source files in this release.
38 CVS_MODULE := devo
39
40 ### Historically, this was identical to CVS_TAG.  This is changing.
41 RELEASE_TAG := latest
42
43 ### Historically, binaries were installed here.  This is changing.
44 release_root := $(ROOTING)/$(RELEASE_TAG)
45
46 ### STOP EDITTING HERE!!!
47 ### With luck, eventually, nothing else will need to be editted.
48
49 TIME := time
50 GCC := gcc -O
51 GNU_MAKE := /usr/latest/bin/make
52 override MAKE := make
53 override MAKEFLAGS :=
54 override MFLAGS :=
55
56 SHELL := /bin/sh
57
58 .NOEXPORT:
59
60 FLAGS_TO_PASS := \
61         "GCC=$(GCC)" \
62         "TIME=$(TIME)" \
63         "MF=$(MF)"
64
65 ### general config stuff
66 WORKING_DIR := $(host)-objdir
67 STAGE1DIR := $(WORKING_DIR).1
68 STAGE2DIR := $(WORKING_DIR).2
69 STAGE3DIR := $(WORKING_DIR).3
70 INPLACEDIR := $(host)-in-place
71 HOLESDIR := $(host)-holes
72
73 .PHONY: all
74 all:    $(TREE)-stamp-co do1 do2 do3 comparison
75
76 .PHONY: in-place
77 in-place:       $(host)-stamp-in-place
78
79 $(host)-stamp-in-place: $(TREE)-stamp-co
80         PATH=/bin:/usr/bin:/usr/ucb ; \
81                 export PATH ; \
82                 SHELL=/bin/sh ; export SHELL ; \
83                 $(TIME) $(GNU_MAKE) -f test-build.mk $(host)-stamp-in-place-installed host=$(host) $(FLAGS_TO_PASS)
84         touch $@
85
86 $(host)-stamp-in-place-installed: $(host)-stamp-in-place-checked
87         (cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) install host=$(host))
88         (cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) install-info host=$(host))
89         touch $@
90
91 $(host)-stamp-in-place-checked: $(host)-stamp-in-place-built
92 #       (cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) check host=$(host))
93         touch $@
94
95 $(host)-stamp-in-place-built: $(host)-stamp-in-place-configured
96         (cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) all host=$(host))
97         (cd $(INPLACEDIR) ; $(TIME) $(MAKE) $(MF) info host=$(host))
98         touch $@
99
100 $(host)-stamp-in-place-configured: $(host)-stamp-in-place-cp
101         (cd $(INPLACEDIR) ; \
102                 $(TIME) ./configure $(host) -v \
103                         -prefix=$(release_root) \
104                         -exec_prefix=$(release_root)/H-$(host))
105         touch $@
106
107 $(host)-stamp-in-place-cp:
108         rm -rf $(INPLACEDIR)
109         mkdir $(INPLACEDIR)
110         (cd $(TREE) ; tar cf - .) | (cd $(INPLACEDIR) ; tar xf -)
111         touch $@
112
113 .PHONY: do1
114 do1:    $(host)-stamp-holes $(host)-stamp-stage1
115
116 $(host)-stamp-stage1:
117         if [ -d $(STAGE1DIR) ] ; then \
118                 mv $(STAGE1DIR) $(WORKING_DIR) ; \
119         else \
120                 true ; \
121         fi
122         PATH=`pwd`/$(HOLESDIR) ; \
123                 export PATH ; \
124                 SHELL=sh ; export SHELL ; \
125                 $(TIME) $(GNU_MAKE) -f test-build.mk $(host)-stamp-stage1-installed host=$(host) $(FLAGS_TO_PASS)
126         touch $@
127         mv $(WORKING_DIR) $(STAGE1DIR)
128
129 $(host)-stamp-stage1-installed: $(host)-stamp-stage1-checked
130         (cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) install host=$(host))
131         (cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) install-info host=$(host))
132         touch $@
133
134 $(host)-stamp-stage1-checked: $(host)-stamp-stage1-built
135 #       (cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) check host=$(host))
136         touch $@
137
138 $(host)-stamp-stage1-built: $(host)-stamp-stage1-configured
139         (cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) all host=$(host))
140         (cd $(WORKING_DIR) ; $(TIME) $(MAKE) $(MF) info host=$(host))
141         touch $@
142
143 $(host)-stamp-stage1-configured:
144         [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
145         (cd $(WORKING_DIR) ; \
146                 $(TIME) ../$(TREE)/configure $(host) -v -srcdir=../$(TREE) \
147                         -prefix=$(release_root) \
148                         -exec_prefix=$(release_root)/H-$(host))
149         touch $@
150
151 .PHONY: do2
152 do2:    $(HOLESDIR) $(host)-stamp-stage2
153
154 $(host)-stamp-stage2:
155         if [ -d $(STAGE2DIR) ] ; then \
156                 mv $(STAGE2DIR) $(WORKING_DIR) ; \
157         else \
158                 true ; \
159         fi
160         PATH=$(release_root)/H-$(host)/bin:`pwd`/$(HOLESDIR) ; \
161                 export PATH ; \
162                 SHELL=sh ; export SHELL ; \
163                 $(TIME) $(MAKE) -f test-build.mk -w $(STAGE2DIR) host=$(host) $(FLAGS_TO_PASS)
164         touch $@
165
166 $(STAGE2DIR): $(host)-stamp-stage2-installed
167         mv $(WORKING_DIR) $(STAGE2DIR)
168
169 $(host)-stamp-stage2-installed: $(host)-stamp-stage2-checked
170         (cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) "CC=$(GCC)" install host=$(host))
171         (cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) "CC=$(GCC)" install-info host=$(host))
172         touch $@
173
174 $(host)-stamp-stage2-checked: $(host)-stamp-stage2-built
175 #       (cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) "CC=$(GCC)" check host=$(host))
176         touch $@
177
178 $(host)-stamp-stage2-built: $(host)-stamp-stage2-configured
179         (cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) "CC=$(GCC)" all host=$(host))
180         (cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) "CC=$(GCC)" info host=$(host))
181         touch $@
182
183 $(host)-stamp-stage2-configured:
184         [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
185         (cd $(WORKING_DIR) ; \
186                 $(TIME) ../$(TREE)/configure $(host) -v -srcdir=../$(TREE) \
187                         -prefix=$(release_root) \
188                         -exec_prefix=$(release_root)/H-$(host))
189         touch $@
190
191 .PHONY: do3
192 do3:    $(HOLESDIR) $(host)-stamp-stage3
193
194 $(host)-stamp-stage3:
195         if [ -d $(TREE)/gcc ] ; then \
196                 if [ -d $(STAGE3DIR) ] ; then \
197                         mv $(STAGE3DIR) $(WORKING_DIR) ; \
198                 else \
199                         true ; \
200                 fi ; \
201                 PATH=$(release_root)/H-$(host)/bin:`pwd`/$(HOLESDIR) ; \
202                         export PATH ; \
203                         SHELL=sh ; export SHELL ; \
204                         $(TIME) $(MAKE) -f test-build.mk -w $(STAGE3DIR) host=$(host) $(FLAGS_TO_PASS) ; \
205         else \
206                 true ; \
207         fi
208         touch $@
209
210 $(STAGE3DIR): $(host)-stamp-stage3-checked
211         mv $(WORKING_DIR) $(STAGE3DIR)
212
213 $(host)-stamp-stage3-installed: $(host)-stamp-stage3-checked
214         (cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) "CC=$(GCC)" install host=$(host))
215         (cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) "CC=$(GCC)" install-info host=$(host))
216         touch $@
217
218 $(host)-stamp-stage3-checked: $(host)-stamp-stage3-built
219 #       (cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) "CC=$(GCC)" check host=$(host))
220         touch $@
221
222 $(host)-stamp-stage3-built: $(host)-stamp-stage3-configured
223         (cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) "CC=$(GCC)" all host=$(host))
224         (cd $(WORKING_DIR) ; $(TIME) $(MAKE) -w $(MF) "CC=$(GCC)" info host=$(host))
225         touch $@
226
227 $(host)-stamp-stage3-configured:
228         [ -d $(WORKING_DIR) ] || mkdir $(WORKING_DIR)
229         (cd $(WORKING_DIR) ; \
230                 $(TIME) ../$(TREE)/configure $(host) -v -srcdir=../$(TREE) \
231                         -prefix=$(release_root) \
232                         -exec_prefix=$(release_root)/H-$(host))
233         touch $@
234
235 # These things are needed by a three-stage, but are not included locally.
236
237 HOLES := \
238         [ \
239         ar \
240         as \
241         awk \
242         basename \
243         cat \
244         cc \
245         chmod \
246         cmp \
247         cp \
248         date \
249         diff \
250         echo \
251         egrep \
252         ex \
253         expr \
254         find \
255         grep \
256         hostname \
257         install \
258         ld \
259         lex \
260         ln \
261         ls \
262         make \
263         mkdir \
264         mv \
265         nm \
266         pwd \
267         ranlib \
268         rm \
269         rmdir \
270         sed \
271         sh \
272         sort \
273         test \
274         time \
275         touch \
276         tr \
277         true \
278         wc \
279         whoami
280
281 ### so far only sun make supports VPATH
282 ifeq ($(subst sun3,sun4,$(host)),sun4)
283 MAKE_HOLE :=
284 else
285 MAKE_HOLE := make
286 endif
287
288 ### rs6000 as is busted.  We cache a patched version in unsupported.
289 ifeq ($(subst sun3,rs6000,$(host)),rs6000)
290 AS_HOLE := as
291 else
292 AS_HOLE :=
293 endif
294
295 ### These things are also needed by a three-stage, but in this case, the GNU version of the tool is required.
296 PARTIAL_HOLES := \
297         $(AS_HOLE) \
298         $(MAKE_HOLE) \
299         flex \
300         m4
301
302 ### look in these directories for things missing from a three-stage
303 HOLE_DIRS := \
304         /bin \
305         /usr/bin \
306         /usr/ucb \
307         /usr/unsupported/bin
308
309 ### look in these directories for alternate versions of some tools.
310 PARTIAL_HOLE_DIRS := \
311         /usr/latest/bin \
312         /usr/progressive/bin \
313         /usr/vintage/bin \
314         /usr/unsupported/bin
315
316 $(HOLESDIR): $(host)-stamp-holes
317
318 $(host)-stamp-holes:
319         -rm -rf $(HOLESDIR)
320         -mkdir $(HOLESDIR)
321         for i in $(HOLES) ; do \
322                 found= ; \
323                 for j in $(HOLE_DIRS) ; do \
324                         if [ -x $$j/$$i ] ; then \
325                                 cp $$j/$$i $(HOLESDIR) ; \
326                                 echo $$i from $$j ; \
327                                 found=t ; \
328                                 break ; \
329                         fi ; \
330                 done ; \
331                 case "$$found" in \
332                 t) ;; \
333                 *) echo $$i is NOT found ;; \
334                 esac ; \
335         done
336         for i in $(PARTIAL_HOLES) ; do \
337                 found= ; \
338                 for j in $(PARTIAL_HOLE_DIRS) ; do \
339                         if [ -x $$j/$$i ] ; then \
340                                 rm -f $(HOLESDIR)/$$i ; \
341                                 cp $$j/$$i $(HOLESDIR)/$$i || exit 1; \
342                                 echo $$i from $$j ; \
343                                 found=t ; \
344                                 break ; \
345                         fi ; \
346                 done ; \
347                 case "$$found" in \
348                 t) ;; \
349                 *) echo $$i is NOT found ;; \
350                 esac ; \
351         done
352         touch $@
353
354 .PHONY: comparison
355 comparison:
356 ifeq ($(subst rs6000,iris4,$(subst decstation,iris4,$(host))),iris4)
357         if [ -d $(TREE)/gcc ] ; then \
358                 for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
359                         tail +10c $(STAGE2DIR)/$$i > foo1 ; \
360                         tail +10c $(STAGE3DIR)/$$i > foo2 ; \
361                         cmp foo1 foo2 || echo $$i ; \
362                 done ; \
363         else \
364                 true ; \
365         fi
366 else
367         if [ -d $(TREE)/gcc ] ; then \
368                 for i in `cd $(STAGE3DIR) ; find . -name \*.o -print` ; do \
369                         cmp $(STAGE2DIR)/$$i $(STAGE3DIR)/$$i ; \
370                 done ; \
371         else \
372                 true ; \
373         fi
374 endif
375
376 .PHONY: clean
377 clean:
378         rm -rf $(HOLESDIR) $(INPLACEDIR) $(WORKING_DIR)* $(host)-stamp-* *~
379
380 .PHONY: very
381 very:
382         rm -rf $(TREE)  $(TREE)-stamp-co
383
384 .PHONY: $(TREE)
385 $(TREE): $(TREE)-stamp-co
386
387 $(TREE)-stamp-co:
388         rm -rf $(TREE)
389         $(TIME) cvs co $(CVS_TAG) $(CVS_MODULE)
390         touch $@
391
392 force:
393
394 endif # host
395
396 ### Local Variables:
397 ### fill-column: 131
398 ### End: