Fix gcc-4.0.1 compile error for i386-freebsd4.10 target.
[external/binutils.git] / Makefile.tpl
1 [+ AutoGen5 template -*- Mode: Makefile -*-
2 in
3 +]
4
5 # Makefile.in is generated from Makefile.tpl by 'autogen Makefile.def'.
6 #
7 # Makefile for directory with subdirs to build.
8 #   Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
9 #   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation
10 #
11 # This file is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
15
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 #
25
26 # -------------------------------
27 # Standard Autoconf-set variables
28 # -------------------------------
29 VPATH=@srcdir@
30
31 build_alias=@build_alias@
32 build=@build@
33 host_alias=@host_alias@
34 host=@host@
35 target_alias=@target_alias@
36 target=@target@
37
38 program_transform_name = @program_transform_name@
39
40 prefix = @prefix@
41 exec_prefix = @exec_prefix@
42
43 srcdir = @srcdir@
44
45 bindir = @bindir@
46 sbindir = @sbindir@
47 libexecdir = @libexecdir@
48 datadir = @datadir@
49 sysconfdir = @sysconfdir@
50 sharedstatedir = @sharedstatedir@
51 localstatedir = @localstatedir@
52 libdir = @libdir@
53 includedir = @includedir@
54 oldincludedir = @oldincludedir@
55 infodir = @infodir@
56 mandir = @mandir@
57 man1dir = $(mandir)/man1
58 man2dir = $(mandir)/man2
59 man3dir = $(mandir)/man3
60 man4dir = $(mandir)/man4
61 man5dir = $(mandir)/man5
62 man6dir = $(mandir)/man6
63 man7dir = $(mandir)/man7
64 man8dir = $(mandir)/man8
65 man9dir = $(mandir)/man9
66
67 INSTALL = @INSTALL@
68 INSTALL_PROGRAM = @INSTALL_PROGRAM@
69 INSTALL_SCRIPT = @INSTALL_SCRIPT@
70 INSTALL_DATA = @INSTALL_DATA@
71 LN = @LN@
72 LN_S = @LN_S@
73
74 # -------------------------------------------------
75 # Miscellaneous non-standard autoconf-set variables
76 # -------------------------------------------------
77
78 # The gcc driver likes to know the arguments it was configured with.
79 TOPLEVEL_CONFIGURE_ARGUMENTS=@TOPLEVEL_CONFIGURE_ARGUMENTS@
80
81 tooldir = @tooldir@
82 build_tooldir = @build_tooldir@
83
84 GDB_NLM_DEPS = 
85
86 # This is the name of the environment variable used for the path to
87 # the libraries.
88 RPATH_ENVVAR = @RPATH_ENVVAR@
89
90 # This is the list of directories to be built for the build system.
91 BUILD_CONFIGDIRS = libiberty
92 # Build programs are put under this directory.
93 BUILD_SUBDIR = @build_subdir@
94 # This is set by the configure script to the arguments to use when configuring
95 # directories built for the build system.
96 BUILD_CONFIGARGS = @build_configargs@ --with-build-subdir="$(BUILD_SUBDIR)"
97
98 # This is the list of variables to export in the environment when
99 # configuring any subdirectory.  It must also be exported whenever
100 # recursing into a build directory in case that directory's Makefile
101 # re-runs configure.
102 BASE_EXPORTS = \
103         FLEX="$(FLEX)"; export FLEX; \
104         LEX="$(LEX)"; export LEX; \
105         BISON="$(BISON)"; export BISON; \
106         YACC="$(YACC)"; export YACC; \
107         M4="$(M4)"; export M4; \
108         MAKEINFO="$(MAKEINFO)"; export MAKEINFO;
109
110 # This is the list of variables to export in the environment when
111 # configuring subdirectories for the build system.
112 BUILD_EXPORTS = \
113         $(BASE_EXPORTS) \
114         AR="$(AR_FOR_BUILD)"; export AR; \
115         AS="$(AS_FOR_BUILD)"; export AS; \
116         CC="$(CC_FOR_BUILD)"; export CC; \
117         CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \
118         CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
119         CXX="$(CXX_FOR_BUILD)"; export CXX; \
120         CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \
121         GCJ="$(GCJ_FOR_BUILD)"; export GCJ; \
122         GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \
123         DLLTOOL="$(DLLTOOL_FOR_BUILD)"; export DLLTOOL; \
124         LD="$(LD_FOR_BUILD)"; export LD; \
125         LDFLAGS="$(LDFLAGS_FOR_BUILD)"; export LDFLAGS; \
126         NM="$(NM_FOR_BUILD)"; export NM; \
127         RANLIB="$(RANLIB_FOR_BUILD)"; export RANLIB; \
128         WINDRES="$(WINDRES_FOR_BUILD)"; export WINDRES;
129
130 # This is the list of directories to built for the host system.
131 SUBDIRS = @configdirs@
132 # This is set by the configure script to the arguments to use when configuring
133 # directories built for the host system.
134 HOST_CONFIGARGS = @host_configargs@
135 # Host programs are put under this directory, which is . except if building
136 # with srcdir=..
137 HOST_SUBDIR = @host_subdir@
138 # This is the list of variables to export in the environment when
139 # configuring subdirectories for the host system.
140 HOST_EXPORTS = \
141         $(BASE_EXPORTS) \
142         CC="$(CC)"; export CC; \
143         CFLAGS="$(CFLAGS)"; export CFLAGS; \
144         CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
145         CXX="$(CXX)"; export CXX; \
146         CXXFLAGS="$(CXXFLAGS)"; export CXXFLAGS; \
147         AR="$(AR)"; export AR; \
148         AS="$(AS)"; export AS; \
149         CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \
150         DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \
151         LD="$(LD)"; export LD; \
152         LDFLAGS="$(LDFLAGS)"; export LDFLAGS; \
153         NM="$(NM)"; export NM; \
154         RANLIB="$(RANLIB)"; export RANLIB; \
155         WINDRES="$(WINDRES)"; export WINDRES; \
156         OBJCOPY="$(OBJCOPY)"; export OBJCOPY; \
157         OBJDUMP="$(OBJDUMP)"; export OBJDUMP; \
158         TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \
159         GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \
160         GMPINC="$(HOST_GMPINC)"; export GMPINC; \
161         $(RPATH_ENVVAR)=`echo "$(HOST_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR);
162
163 # Similar, for later GCC stages.
164 POSTSTAGE1_HOST_EXPORTS = \
165         $(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \
166         $(HOST_EXPORTS) \
167         CC="$(STAGE_CC_WRAPPER) $$r/$(HOST_SUBDIR)/prev-gcc/xgcc$(exeext) \
168           -B$$r/$(HOST_SUBDIR)/prev-gcc/ -B$(build_tooldir)/bin/"; export CC; \
169         CC_FOR_BUILD="$(STAGE_CC_WRAPPER) \
170           $$r/$(HOST_SUBDIR)/prev-gcc/xgcc$(exeext) \
171           -B$$r/$(HOST_SUBDIR)/prev-gcc/ \
172           -B$(build_tooldir)/bin/"; export CC_FOR_BUILD;
173
174 # This is set by the configure script to the list of directories which
175 # should be built using the target tools.
176 TARGET_CONFIGDIRS = @target_configdirs@
177 # Target libraries are put under this directory:
178 TARGET_SUBDIR = @target_subdir@
179 # This is set by the configure script to the arguments to use when configuring
180 # directories built for the target.
181 TARGET_CONFIGARGS = @target_configargs@ --with-target-subdir="$(TARGET_SUBDIR)"
182 # This is the list of variables to export in the environment when
183 # configuring subdirectories for the host system.
184 BASE_TARGET_EXPORTS = \
185         $(BASE_EXPORTS) \
186         AR="$(AR_FOR_TARGET)"; export AR; \
187         AS="$(AS_FOR_TARGET)"; export AS; \
188         CC="$(CC_FOR_TARGET)"; export CC; \
189         CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
190         CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
191         CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \
192         CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
193         GCJ="$(GCJ_FOR_TARGET)"; export GCJ; \
194         GFORTRAN="$(GFORTRAN_FOR_TARGET)"; export GFORTRAN; \
195         DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \
196         LD="$(LD_FOR_TARGET)"; export LD; \
197         LDFLAGS="$(LDFLAGS_FOR_TARGET)"; export LDFLAGS; \
198         NM="$(NM_FOR_TARGET)"; export NM; \
199         RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \
200         WINDRES="$(WINDRES_FOR_TARGET)"; export WINDRES; \
201         $(RPATH_ENVVAR)=`echo "$(HOST_LIB_PATH)$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR);
202
203 RAW_CXX_TARGET_EXPORTS = \
204         $(BASE_TARGET_EXPORTS) \
205         CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
206         CXX="$(RAW_CXX_FOR_TARGET)"; export CXX;
207
208 NORMAL_TARGET_EXPORTS = \
209         $(BASE_TARGET_EXPORTS) \
210         CXX="$(CXX_FOR_TARGET)"; export CXX;
211
212 # Where to find GMP
213 HOST_GMPLIBS = @gmplibs@
214 HOST_GMPINC = @gmpinc@
215
216 # ----------------------------------------------
217 # Programs producing files for the BUILD machine
218 # ----------------------------------------------
219
220 SHELL = @config_shell@
221
222 # pwd command to use.  Allow user to override default by setting PWDCMD in
223 # the environment to account for automounters.  The make variable must not
224 # be called PWDCMD, otherwise the value set here is passed to make
225 # subprocesses and overrides the setting from the user's environment.
226 # Don't use PWD since it is a common shell environment variable and we
227 # don't want to corrupt it.
228 PWD_COMMAND = $${PWDCMD-pwd}
229
230 # compilers to use to create programs which must be run in the build
231 # environment.
232 CC_FOR_BUILD = @CC_FOR_BUILD@
233 CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
234
235 CXX_FOR_BUILD = $(CXX)
236
237 # Special variables passed down in EXTRA_GCC_FLAGS.  They are defined
238 # here so that they can be overridden by Makefile fragments.
239 BUILD_PREFIX = @BUILD_PREFIX@
240 BUILD_PREFIX_1 = @BUILD_PREFIX_1@
241
242 # Flags to pass to stage2 and later makes.  They are defined
243 # here so that they can be overridden by Makefile fragments.
244 BOOT_CFLAGS= -g -O2
245
246 CONFIGURED_BISON = @CONFIGURED_BISON@
247 BISON = `if [ -f $$r/$(BUILD_SUBDIR)/bison/tests/bison ] ; then \
248             echo $$r/$(BUILD_SUBDIR)/bison/tests/bison ; \
249          else \
250             echo ${CONFIGURED_BISON} ; \
251          fi`
252
253 CONFIGURED_YACC = @CONFIGURED_YACC@
254 YACC = `if [ -f $$r/$(BUILD_SUBDIR)/bison/tests/bison ] ; then \
255             echo $$r/$(BUILD_SUBDIR)/bison/tests/bison -y ; \
256         elif [ -f $$r/$(BUILD_SUBDIR)/byacc/byacc ] ; then \
257             echo $$r/$(BUILD_SUBDIR)/byacc/byacc ; \
258         else \
259             echo ${CONFIGURED_YACC} ; \
260         fi`
261
262 CONFIGURED_FLEX = @CONFIGURED_FLEX@
263 FLEX = `if [ -f $$r/$(BUILD_SUBDIR)/flex/flex ] ; \
264         then echo $$r/$(BUILD_SUBDIR)/flex/flex ; \
265         else echo ${CONFIGURED_FLEX} ; fi`
266
267 CONFIGURED_LEX = @CONFIGURED_LEX@
268 LEX = `if [ -f $$r/$(BUILD_SUBDIR)/flex/flex ] ; \
269         then echo $$r/$(BUILD_SUBDIR)/flex/flex ; \
270         else echo ${CONFIGURED_LEX} ; fi`
271
272 CONFIGURED_M4 = @CONFIGURED_M4@
273 M4 = `if [ -f $$r/$(BUILD_SUBDIR)/m4/m4 ] ; \
274         then echo $$r/$(BUILD_SUBDIR)/m4/m4 ; \
275         else echo ${CONFIGURED_M4} ; fi`
276
277 # For an installed makeinfo, we require it to be from texinfo 4.2 or
278 # higher, else we use the "missing" dummy.  We also pass the subdirectory
279 # makeinfo even if only the Makefile is there, because Texinfo builds its
280 # manual when made, and it requires its own version.
281 CONFIGURED_MAKEINFO = @CONFIGURED_MAKEINFO@
282 MAKEINFO = `if [ -f $$r/$(BUILD_SUBDIR)/texinfo/makeinfo/Makefile ] ; \
283         then echo $$r/$(BUILD_SUBDIR)/texinfo/makeinfo/makeinfo ; \
284         else if (${CONFIGURED_MAKEINFO} --version \
285           | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[2-9]|[5-9])') >/dev/null 2>&1; \
286         then echo ${CONFIGURED_MAKEINFO}; else echo $$s/missing makeinfo; fi; fi`
287
288 # This just becomes part of the MAKEINFO definition passed down to
289 # sub-makes.  It lets flags be given on the command line while still
290 # using the makeinfo from the object tree.
291 # (Default to avoid splitting info files by setting the threshold high.)
292 MAKEINFOFLAGS = --split-size=5000000
293
294 # FIXME: expect may become a build tool?
295 EXPECT = `if [ -f $$r/$(HOST_SUBDIR)/expect/expect ] ; \
296         then echo $$r/$(HOST_SUBDIR)/expect/expect ; \
297         else echo expect ; fi`
298
299 RUNTEST = `if [ -f $$s/dejagnu/runtest ] ; \
300         then echo $$s/dejagnu/runtest ; \
301         else echo runtest ; fi`
302
303 # ---------------------------------------------
304 # Programs producing files for the HOST machine
305 # ---------------------------------------------
306
307 AS = @AS@
308
309 AR = @AR@
310 AR_FLAGS = rc
311
312 CC = @CC@
313 CFLAGS = @CFLAGS@
314 LIBCFLAGS = $(CFLAGS)
315
316 CXX = @CXX@
317 CXXFLAGS = @CXXFLAGS@
318 LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
319
320 DLLTOOL = @DLLTOOL@
321
322 NM = @NM@
323
324 LD = @LD@
325 LDFLAGS = 
326
327 RANLIB = @RANLIB@
328
329 WINDRES = @WINDRES@
330
331 PICFLAG = 
332
333 # -----------------------------------------------
334 # Programs producing files for the TARGET machine
335 # -----------------------------------------------
336
337 FLAGS_FOR_TARGET = @FLAGS_FOR_TARGET@
338
339 AR_FOR_TARGET=@AR_FOR_TARGET@
340 CONFIGURED_AR_FOR_TARGET=@CONFIGURED_AR_FOR_TARGET@
341 USUAL_AR_FOR_TARGET = ` \
342   if [ -f $$r/$(HOST_SUBDIR)/binutils/ar ] ; then \
343     echo $$r/$(HOST_SUBDIR)/binutils/ar ; \
344   else \
345     if [ '$(host)' = '$(target)' ] ; then \
346       echo $(AR); \
347     else \
348       echo $(CONFIGURED_AR_FOR_TARGET) ; \
349     fi; \
350   fi`
351
352 AS_FOR_TARGET=@AS_FOR_TARGET@
353 CONFIGURED_AS_FOR_TARGET=@CONFIGURED_AS_FOR_TARGET@
354 USUAL_AS_FOR_TARGET = ` \
355   if [ -f $$r/$(HOST_SUBDIR)/gas/as-new ] ; then \
356     echo $$r/$(HOST_SUBDIR)/gas/as-new ; \
357   elif [ -f $$r/$(HOST_SUBDIR)/gcc/as ]; then \
358     echo $$r/$(HOST_SUBDIR)/gcc/as ; \
359   else \
360     if [ '$(host)' = '$(target)' ] ; then \
361       echo $(AS); \
362     else \
363       echo $(CONFIGURED_AS_FOR_TARGET) ; \
364     fi; \
365   fi`
366
367 CC_FOR_TARGET=$(STAGE_CC_WRAPPER) @CC_FOR_TARGET@ $(FLAGS_FOR_TARGET)
368 CONFIGURED_CC_FOR_TARGET=@CONFIGURED_CC_FOR_TARGET@
369 USUAL_CC_FOR_TARGET = ` \
370   if [ -f $$r/$(HOST_SUBDIR)/gcc/xgcc ] ; then \
371     echo $$r/$(HOST_SUBDIR)/gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/ ; \
372   else \
373     if [ '$(host)' = '$(target)' ] ; then \
374       echo $(CC); \
375     else \
376       echo $(CONFIGURED_CC_FOR_TARGET) ; \
377     fi; \
378   fi`
379
380 # During gcc bootstrap, if we use some random cc for stage1 then
381 # CFLAGS will be just -g.  We want to ensure that TARGET libraries
382 # (which we know are built with gcc) are built with optimizations so
383 # prepend -O2 when setting CFLAGS_FOR_TARGET.
384 CFLAGS_FOR_TARGET = -O2 $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
385 SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
386
387 # If GCC_FOR_TARGET is not overriden on the command line, then this
388 # variable is passed down to the gcc Makefile, where it is used to
389 # build libgcc2.a.  We define it here so that it can itself be
390 # overridden on the command line.
391 GCC_FOR_TARGET=@GCC_FOR_TARGET@
392 CONFIGURED_GCC_FOR_TARGET=@CONFIGURED_GCC_FOR_TARGET@
393 USUAL_GCC_FOR_TARGET = $(STAGE_CC_WRAPPER) \
394   $$r/$(HOST_SUBDIR)/gcc/xgcc -B$$r/$(HOST_SUBDIR)/gcc/ $(FLAGS_FOR_TARGET)
395 LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
396
397 CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @CXX_FOR_TARGET@ $(FLAGS_FOR_TARGET)
398 CONFIGURED_CXX_FOR_TARGET=@CONFIGURED_CXX_FOR_TARGET@
399 USUAL_CXX_FOR_TARGET = ` \
400   if [ -f $$r/$(HOST_SUBDIR)/gcc/g++ ] ; then \
401     (echo $$r/$(HOST_SUBDIR)/gcc/g++ -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++; \
402     test ! -f $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags || $(SHELL) $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags --build-includes; \
403     echo -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs) | tr '\015\012' '  '; \
404   else \
405     if [ '$(host)' = '$(target)' ] ; then \
406       echo $(CXX); \
407     else \
408       echo $(CONFIGURED_CXX_FOR_TARGET) ; \
409     fi; \
410   fi`
411
412 RAW_CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @RAW_CXX_FOR_TARGET@ $(FLAGS_FOR_TARGET)
413 USUAL_RAW_CXX_FOR_TARGET = ` \
414   if [ -f $$r/$(HOST_SUBDIR)/gcc/xgcc ] ; then \
415     echo $$r/$(HOST_SUBDIR)/gcc/xgcc -shared-libgcc -B$$r/$(HOST_SUBDIR)/gcc -nostdinc++ -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs; \
416   else \
417     if [ '$(host)' = '$(target)' ] ; then \
418       echo $(CXX); \
419     else \
420       echo $(CONFIGURED_CXX_FOR_TARGET) ; \
421     fi; \
422   fi`
423
424 CXXFLAGS_FOR_TARGET = $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET)
425 LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
426
427 GCJ_FOR_TARGET=$(STAGE_CC_WRAPPER) @GCJ_FOR_TARGET@ $(FLAGS_FOR_TARGET)
428 CONFIGURED_GCJ_FOR_TARGET=@CONFIGURED_GCJ_FOR_TARGET@
429 USUAL_GCJ_FOR_TARGET = ` \
430   if [ -f $$r/$(HOST_SUBDIR)/gcc/gcj ] ; then \
431     echo $$r/$(HOST_SUBDIR)/gcc/gcj -B$$r/$(HOST_SUBDIR)/gcc ; \
432   else \
433     if [ '$(host)' = '$(target)' ] ; then \
434       echo $(GCJ); \
435     else \
436       echo $(CONFIGURED_GCJ_FOR_TARGET) ; \
437     fi; \
438   fi`
439
440 GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@ $(FLAGS_FOR_TARGET)
441 CONFIGURED_GFORTRAN_FOR_TARGET=@CONFIGURED_GFORTRAN_FOR_TARGET@
442 USUAL_GFORTRAN_FOR_TARGET = ` \
443   if [ -f $$r/$(HOST_SUBDIR)/gcc/gfortran ] ; then \
444     echo $$r/$(HOST_SUBDIR)/gcc/gfortran -B$$r/$(HOST_SUBDIR)/gcc ; \
445   else \
446     if [ '$(host)' = '$(target)' ] ; then \
447       echo $(GFORTRAN); \
448     else \
449       echo $(CONFIGURED_GFORTRAN_FOR_TARGET) ; \
450     fi; \
451   fi`
452
453
454 DLLTOOL_FOR_TARGET=@DLLTOOL_FOR_TARGET@
455 CONFIGURED_DLLTOOL_FOR_TARGET=@CONFIGURED_DLLTOOL_FOR_TARGET@
456 USUAL_DLLTOOL_FOR_TARGET = ` \
457   if [ -f $$r/$(HOST_SUBDIR)/binutils/dlltool ] ; then \
458     echo $$r/$(HOST_SUBDIR)/binutils/dlltool ; \
459   else \
460     if [ '$(host)' = '$(target)' ] ; then \
461       echo $(DLLTOOL); \
462     else \
463       echo $(CONFIGURED_DLLTOOL_FOR_TARGET) ; \
464     fi; \
465   fi`
466
467 LD_FOR_TARGET=@LD_FOR_TARGET@
468 CONFIGURED_LD_FOR_TARGET=@CONFIGURED_LD_FOR_TARGET@
469 USUAL_LD_FOR_TARGET = ` \
470   if [ -f $$r/$(HOST_SUBDIR)/ld/ld-new ] ; then \
471     echo $$r/$(HOST_SUBDIR)/ld/ld-new ; \
472   elif [ -f $$r/$(HOST_SUBDIR)/gcc/collect-ld ]; then \
473     echo $$r/$(HOST_SUBDIR)/gcc/collect-ld ; \
474   else \
475     if [ '$(host)' = '$(target)' ] ; then \
476       echo $(LD); \
477     else \
478       echo $(CONFIGURED_LD_FOR_TARGET) ; \
479     fi; \
480   fi`
481
482 LDFLAGS_FOR_TARGET = 
483
484 NM_FOR_TARGET=@NM_FOR_TARGET@
485 CONFIGURED_NM_FOR_TARGET=@CONFIGURED_NM_FOR_TARGET@
486 USUAL_NM_FOR_TARGET = ` \
487   if [ -f $$r/$(HOST_SUBDIR)/binutils/nm-new ] ; then \
488     echo $$r/$(HOST_SUBDIR)/binutils/nm-new ; \
489   elif [ -f $$r/$(HOST_SUBDIR)/gcc/nm ]; then \
490     echo $$r/$(HOST_SUBDIR)/gcc/nm ; \
491   else \
492     if [ '$(host)' = '$(target)' ] ; then \
493       echo $(NM); \
494     else \
495       echo $(CONFIGURED_NM_FOR_TARGET) ; \
496     fi; \
497   fi`
498
499 RANLIB_FOR_TARGET=@RANLIB_FOR_TARGET@
500 CONFIGURED_RANLIB_FOR_TARGET=@CONFIGURED_RANLIB_FOR_TARGET@
501 USUAL_RANLIB_FOR_TARGET = ` \
502   if [ -f $$r/$(HOST_SUBDIR)/binutils/ranlib ] ; then \
503     echo $$r/$(HOST_SUBDIR)/binutils/ranlib ; \
504   else \
505     if [ '$(host)' = '$(target)' ] ; then \
506       if [ x'$(RANLIB)' != x ]; then \
507          echo $(RANLIB); \
508       else \
509          echo ranlib; \
510       fi; \
511     else \
512       echo $(CONFIGURED_RANLIB_FOR_TARGET) ; \
513     fi; \
514   fi`
515
516 WINDRES_FOR_TARGET=@WINDRES_FOR_TARGET@
517 CONFIGURED_WINDRES_FOR_TARGET=@CONFIGURED_WINDRES_FOR_TARGET@
518 USUAL_WINDRES_FOR_TARGET = ` \
519   if [ -f $$r/$(HOST_SUBDIR)/binutils/windres ] ; then \
520     echo $$r/$(HOST_SUBDIR)/binutils/windres ; \
521   else \
522     if [ '$(host)' = '$(target)' ] ; then \
523       echo $(WINDRES); \
524     else \
525       echo $(CONFIGURED_WINDRES_FOR_TARGET) ; \
526     fi; \
527   fi`
528
529 PICFLAG_FOR_TARGET = 
530
531 # ------------------------------------
532 # Miscellaneous targets and flag lists
533 # ------------------------------------
534
535 # The first rule in the file had better be this one.  Don't put any above it.
536 # This lives here to allow makefile fragments to contain dependencies.
537 @default_target@:
538
539 #### host and target specific makefile fragments come in here.
540 @target_makefile_frag@
541 @alphaieee_frag@
542 @ospace_frag@
543 @host_makefile_frag@
544 ###
545
546 # This is the list of directories that may be needed in RPATH_ENVVAR
547 # so that prorgams built for the target machine work.
548 TARGET_LIB_PATH = [+ FOR target_modules +][+
549   IF lib_path +]$(TARGET_LIB_PATH_[+module+])[+ ENDIF lib_path +][+
550   ENDFOR target_modules +]$(HOST_LIB_PATH_gcc)
551 [+ FOR target_modules +][+ IF lib_path +]
552 @if target-[+module+]
553 TARGET_LIB_PATH_[+module+] = $$r/$(TARGET_SUBDIR)/[+module+]/[+lib_path+]:
554 @endif target-[+module+]
555 [+ ENDIF lib_path +][+ ENDFOR target_modules +]
556
557
558 # This is the list of directories that may be needed in RPATH_ENVVAR
559 # so that programs built for the host machine work.
560 HOST_LIB_PATH = [+ FOR host_modules +][+
561   IF lib_path +]$(HOST_LIB_PATH_[+module+])[+ ENDIF lib_path +][+
562   ENDFOR host_modules +]
563
564 # Define HOST_LIB_PATH_gcc here, for the sake of TARGET_LIB_PATH, ouch
565 @if gcc
566 HOST_LIB_PATH_gcc = $$r/$(HOST_SUBDIR)/gcc:$$r/$(HOST_SUBDIR)/prev-gcc:
567 @endif gcc
568
569 [+ FOR host_modules +][+ IF lib_path +]
570 @if [+module+]
571 HOST_LIB_PATH_[+module+] = \
572   $$r/$(HOST_SUBDIR)/[+module+]/[+lib_path+]:[+ IF bootstrap
573   +]$$r/$(HOST_SUBDIR)/prev-[+module+]/[+lib_path+]:[+ ENDIF bootstrap +]
574 @endif [+module+]
575 [+ ENDIF lib_path +][+ ENDFOR host_modules +]
576
577 # Flags to pass down to all sub-makes.
578 BASE_FLAGS_TO_PASS = [+ FOR flags_to_pass +]\
579         "[+flag+]=$([+flag+])" [+ ENDFOR flags_to_pass +]\
580         "CONFIG_SHELL=$(SHELL)" \
581         "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" 
582
583 # We leave this in just in case, but it is not needed anymore.
584 RECURSE_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS)
585
586 # Flags to pass down to most sub-makes, in which we're building with
587 # the host environment.
588 EXTRA_HOST_FLAGS = \
589         'AR=$(AR)' \
590         'AS=$(AS)' \
591         'CC=$(CC)' \
592         'CXX=$(CXX)' \
593         'DLLTOOL=$(DLLTOOL)' \
594         'LD=$(LD)' \
595         'NM=$(NM)' \
596         'RANLIB=$(RANLIB)' \
597         'WINDRES=$(WINDRES)'
598
599 FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)
600
601 # Flags that are concerned with the location of the X11 include files
602 # and library files
603 #
604 # NOTE: until the top-level is getting the values via autoconf, it only
605 # causes problems to have this top-level Makefile overriding the autoconf-set
606 # values in child directories.  Only variables that don't conflict with
607 # autoconf'ed ones should be passed by X11_FLAGS_TO_PASS for now.
608 #
609 X11_FLAGS_TO_PASS = \
610         'X11_EXTRA_CFLAGS=$(X11_EXTRA_CFLAGS)' \
611         'X11_EXTRA_LIBS=$(X11_EXTRA_LIBS)'
612
613 # Flags to pass down to makes which are built with the target environment.
614 # The double $ decreases the length of the command line; the variables
615 # are set in BASE_FLAGS_TO_PASS, and the sub-make will expand them.
616 EXTRA_TARGET_FLAGS = \
617         'AR=$$(AR_FOR_TARGET)' \
618         'AS=$$(AS_FOR_TARGET)' \
619         'CC=$$(CC_FOR_TARGET)' \
620         'CFLAGS=$$(CFLAGS_FOR_TARGET)' \
621         'CXX=$$(CXX_FOR_TARGET)' \
622         'CXXFLAGS=$$(CXXFLAGS_FOR_TARGET)' \
623         'DLLTOOL=$$(DLLTOOL_FOR_TARGET)' \
624         'LD=$$(LD_FOR_TARGET)' \
625         'LDFLAGS=$$(LDFLAGS_FOR_TARGET)' \
626         'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET)' \
627         'LIBCXXFLAGS=$$(LIBCXXFLAGS_FOR_TARGET)' \
628         'NM=$$(NM_FOR_TARGET)' \
629         'RANLIB=$$(RANLIB_FOR_TARGET)' \
630         'WINDRES=$$(WINDRES_FOR_TARGET)'
631
632 TARGET_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)
633
634 # Flags to pass down to gcc.  gcc builds a library, libgcc.a, so it
635 # unfortunately needs the native compiler and the target ar and
636 # ranlib.
637 # If any variables are added here, they must be added to do-*, below.
638 # The BUILD_* variables are a special case, which are used for the gcc
639 # cross-building scheme.
640 EXTRA_GCC_FLAGS = \
641         'BUILD_PREFIX=$(BUILD_PREFIX)' \
642         'BUILD_PREFIX_1=$(BUILD_PREFIX_1)' \
643         "GCC_FOR_TARGET=$(GCC_FOR_TARGET)" \
644         "`echo 'LANGUAGES=$(LANGUAGES)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
645         "`echo 'STMP_FIXPROTO=$(STMP_FIXPROTO)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
646         "`echo 'LIMITS_H_TEST=$(LIMITS_H_TEST)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
647         "`echo 'LIBGCC2_CFLAGS=$(LIBGCC2_CFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
648         "`echo 'LIBGCC2_DEBUG_CFLAGS=$(LIBGCC2_DEBUG_CFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
649         "`echo 'LIBGCC2_INCLUDES=$(LIBGCC2_INCLUDES)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
650         "`echo 'STAGE1_CFLAGS=$(STAGE1_CFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
651         "`echo 'BOOT_CFLAGS=$(BOOT_CFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
652         "`echo 'BOOT_ADAFLAGS=$(BOOT_ADAFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"
653
654 GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(EXTRA_GCC_FLAGS)
655
656 .PHONY: configure-host
657 configure-host: [+
658   FOR host_modules +] \
659     maybe-configure-[+module+][+
660   ENDFOR host_modules +]
661 .PHONY: configure-target
662 configure-target: [+
663   FOR target_modules +] \
664     maybe-configure-target-[+module+][+
665   ENDFOR target_modules +]
666
667 # The target built for a native non-bootstrap build.
668 .PHONY: all
669 all: unstage all-host all-target stage
670
671 .PHONY: all-build
672 all-build: [+
673   FOR build_modules +] \
674     maybe-all-build-[+module+][+
675   ENDFOR build_modules +]
676 .PHONY: all-host
677 all-host: [+
678   FOR host_modules +] \
679     maybe-all-[+module+][+
680   ENDFOR host_modules +]
681 .PHONY: all-target
682 all-target: [+
683   FOR target_modules +] \
684     maybe-all-target-[+module+][+
685   ENDFOR target_modules +]
686
687 # Do a target for all the subdirectories.  A ``make do-X'' will do a
688 # ``make X'' in all subdirectories (because, in general, there is a
689 # dependency (below) of X upon do-X, a ``make X'' will also do this,
690 # but it may do additional work as well).
691 [+ FOR recursive_targets +]
692 .PHONY: do-[+make_target+]
693 do-[+make_target+]: unstage [+make_target+]-host [+make_target+]-target stage
694
695 .PHONY: [+make_target+]-host
696 [+make_target+]-host: [+
697   FOR host_modules +] \
698     maybe-[+make_target+]-[+module+][+
699   ENDFOR host_modules +]
700
701 .PHONY: [+make_target+]-target
702 [+make_target+]-target: [+
703   FOR target_modules +] \
704     maybe-[+make_target+]-target-[+module+][+
705   ENDFOR target_modules +]
706 [+ ENDFOR recursive_targets +]
707
708 # Here are the targets which correspond to the do-X targets.
709
710 .PHONY: info installcheck dvi html install-info
711 .PHONY: clean distclean mostlyclean maintainer-clean realclean
712 .PHONY: local-clean local-distclean local-maintainer-clean
713 info: do-info
714 installcheck: do-installcheck
715 dvi: do-dvi
716 html: do-html
717
718 # Make sure makeinfo is built before we do a `make info', if we're
719 # in fact building texinfo.
720 do-info: maybe-all-texinfo
721
722 install-info: do-install-info dir.info
723         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
724         if [ -f dir.info ] ; then \
725           $(INSTALL_DATA) dir.info $(DESTDIR)$(infodir)/dir.info ; \
726         else true ; fi
727
728 local-clean:
729         -rm -f *.a TEMP errs core *.o *~ \#* TAGS *.E *.log
730
731 local-distclean:
732         -rm -f Makefile config.status config.cache mh-frag mt-frag
733         -rm -f multilib.out multilib.tmp maybedep.tmp serdep.tmp
734         -if [ "$(TARGET_SUBDIR)" != "." ]; then \
735           rm -rf $(TARGET_SUBDIR); \
736         else true; fi
737         -rm -rf $(BUILD_SUBDIR)
738         -if [ "$(HOST_SUBDIR)" != "." ]; then \
739           rm -rf $(HOST_SUBDIR); \
740         else true; fi
741         -rm -f texinfo/po/Makefile texinfo/po/Makefile.in texinfo/info/Makefile
742         -rm -f texinfo/doc/Makefile texinfo/po/POTFILES
743         -rmdir texinfo/doc texinfo/info texinfo/intl texinfo/lib 2>/dev/null
744         -rmdir texinfo/makeinfo texinfo/po texinfo/util 2>/dev/null
745         -rmdir fastjar gcc libiberty texinfo zlib 2>/dev/null
746
747 local-maintainer-clean:
748         @echo "This command is intended for maintainers to use;"
749         @echo "it deletes files that may require special tools to rebuild."
750
751 clean: do-clean local-clean
752 mostlyclean: do-mostlyclean local-clean
753 distclean: do-distclean local-clean local-distclean
754 maintainer-clean: local-maintainer-clean do-maintainer-clean local-clean 
755 maintainer-clean: local-distclean
756 realclean: maintainer-clean
757
758 # Extra dependency for clean-target, owing to the mixed nature of gcc
759 clean-target: clean-target-libgcc
760 clean-target-libgcc:
761         test ! -d gcc/libgcc || \
762         (cd gcc/libgcc && find . -type d -print) | \
763         while read d; do rm -f gcc/$$d/libgcc.a || : ; done
764         -rm -rf gcc/libgcc
765         -rm -f gcc/stmp-dirs
766
767 # Check target.
768
769 .PHONY: check do-check
770 check: do-check
771
772 # Only include modules actually being configured and built.
773 do-check: unstage [+
774   FOR host_modules +] \
775     maybe-check-[+module+][+
776   ENDFOR host_modules +][+
777   FOR target_modules +] \
778     maybe-check-target-[+module+][+
779   ENDFOR target_modules +] stage
780
781 # Automated reporting of test results.
782
783 warning.log: build.log
784         $(srcdir)/contrib/warn_summary build.log > $@
785
786 mail-report.log:
787         if test x'$(BOOT_CFLAGS)' != x''; then \
788             BOOT_CFLAGS='$(BOOT_CFLAGS)'; export BOOT_CFLAGS; \
789         fi; \
790         $(srcdir)/contrib/test_summary -t >$@
791         chmod +x $@
792         echo If you really want to send e-mail, run ./$@ now
793
794 mail-report-with-warnings.log: warning.log
795         if test x'$(BOOT_CFLAGS)' != x''; then \
796             BOOT_CFLAGS='$(BOOT_CFLAGS)'; export BOOT_CFLAGS; \
797         fi; \
798         $(srcdir)/contrib/test_summary -t -i warning.log >$@
799         chmod +x $@
800         echo If you really want to send e-mail, run ./$@ now
801
802 # Installation targets.
803
804 .PHONY: install uninstall
805 install: installdirs install-host install-target
806
807 .PHONY: install-host-nogcc
808 install-host-nogcc: [+
809   FOR host_modules +][+ IF (not (= (get "module") "gcc")) +] \
810     maybe-install-[+module+][+ ENDIF +][+
811   ENDFOR host_modules +]
812
813 .PHONY: install-host
814 install-host: [+
815   FOR host_modules +] \
816     maybe-install-[+module+][+
817   ENDFOR host_modules +]
818
819 .PHONY: install-target
820 install-target: [+
821   FOR target_modules +] \
822     maybe-install-target-[+module+][+
823   ENDFOR target_modules +]
824
825 uninstall:
826         @echo "the uninstall target is not supported in this tree"
827
828 .PHONY: install.all
829 install.all: install-no-fixedincludes
830         @if [ -f ./gcc/Makefile ] ; then \
831                 r=`${PWD_COMMAND}` ; export r ; \
832                 $(HOST_EXPORTS) \
833                 (cd ./gcc && \
834                 $(MAKE) $(FLAGS_TO_PASS) install-headers) ; \
835         else \
836                 true ; \
837         fi
838
839 # install-no-fixedincludes is used because Cygnus can not distribute
840 # the fixed header files.
841 .PHONY: install-no-fixedincludes
842 install-no-fixedincludes: installdirs install-host-nogcc \
843         install-target gcc-no-fixedincludes
844
845 ### other supporting targets
846
847 MAKEDIRS= \
848         $(DESTDIR)$(prefix) \
849         $(DESTDIR)$(exec_prefix)
850 .PHONY: installdirs
851 installdirs: mkinstalldirs
852         $(SHELL) $(srcdir)/mkinstalldirs $(MAKEDIRS)
853
854 dir.info: do-install-info
855         if [ -f $(srcdir)/texinfo/gen-info-dir ] ; then \
856           $(srcdir)/texinfo/gen-info-dir $(DESTDIR)$(infodir) $(srcdir)/texinfo/dir.info-template > dir.info.new ; \
857           mv -f dir.info.new dir.info ; \
858         else true ; \
859         fi
860
861 dist:
862         @echo "Building a full distribution of this tree isn't done"
863         @echo "via 'make dist'.  Check out the etc/ subdirectory" 
864
865 etags tags: TAGS
866
867 # Right now this just builds TAGS in each subdirectory.  emacs19 has the
868 # ability to use several tags files at once, so there is probably no need
869 # to combine them into one big TAGS file (like CVS 1.3 does).  We could
870 # (if we felt like it) have this Makefile write a piece of elisp which
871 # the user could load to tell emacs19 where all the TAGS files we just
872 # built are.
873 TAGS: do-TAGS
874
875 # ------------------------------------
876 # Macros for configure and all targets
877 # ------------------------------------
878
879 [+ DEFINE configure +]
880 .PHONY: configure-[+prefix+][+module+] maybe-configure-[+prefix+][+module+]
881 maybe-configure-[+prefix+][+module+]:
882 @if [+prefix+][+module+]
883 maybe-configure-[+prefix+][+module+]: configure-[+prefix+][+module+]
884 configure-[+prefix+][+module+]: [+deps+]
885         @[+ IF bootstrap +]test -f stage_last && exit 0; \
886         [+ ENDIF bootstrap +]test ! -f [+subdir+]/[+module+]/Makefile || exit 0; \
887         $(SHELL) $(srcdir)/mkinstalldirs [+subdir+]/[+module+] ; \
888         r=`${PWD_COMMAND}`; export r; \
889         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
890         [+exports+] \
891         echo Configuring in [+subdir+]/[+module+]; \
892         cd "[+subdir+]/[+module+]" || exit 1; \
893         case $(srcdir) in \
894           /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
895           *) topdir=`echo [+subdir+]/[+module+]/ | \
896                 sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
897         esac; \
898         srcdiroption="--srcdir=$${topdir}/[+module+]"; \
899         libsrcdir="$$s/[+module+]"; \
900         [+ IF no-config-site +]rm -f no-such-file || : ; \
901         CONFIG_SITE=no-such-file [+ ENDIF +]$(SHELL) $${libsrcdir}/configure \
902           [+args+] $${srcdiroption} [+extra_configure_flags+] \
903           || exit 1
904 @endif [+prefix+][+module+]
905
906 [+ IF bootstrap +]
907 [+ FOR bootstrap_stage +]
908 .PHONY: configure-stage[+id+]-[+prefix+][+module+] maybe-configure-stage[+id+]-[+prefix+][+module+]
909 maybe-configure-stage[+id+]-[+prefix+][+module+]:
910 @if [+module+]-bootstrap
911 maybe-configure-stage[+id+]-[+prefix+][+module+]: configure-stage[+id+]-[+prefix+][+module+]
912 configure-stage[+id+]-[+prefix+][+module+]: [+deps+]
913         @$(MAKE) stage[+id+]-start
914         @[ -f [+subdir+]/[+module+]/Makefile ] && exit 0 || : ; \
915         r=`${PWD_COMMAND}`; export r; \
916         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
917         [+exports+][+ IF prev +] \
918         [+poststage1_exports+][+ ENDIF prev +] \
919         echo Configuring stage [+id+] in [+subdir+]/[+module+] ; \
920         cd [+subdir+]/[+module+] || exit 1; \
921         case $(srcdir) in \
922           /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
923           *) topdir=`echo [+subdir+]/[+module+]/ | \
924                 sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
925         esac; \
926         srcdiroption="--srcdir=$${topdir}/[+module+]"; \
927         libsrcdir="$$s/[+module+]"; \
928         $(SHELL) $${libsrcdir}/configure \
929           [+args+] $${srcdiroption} \
930           [+stage_configure_flags+] [+extra_configure_flags+]
931 @endif [+module+]-bootstrap
932 [+ ENDFOR bootstrap_stage +]
933 [+ ENDIF bootstrap +]
934 [+ ENDDEF +]
935
936 [+ DEFINE all +]
937 .PHONY: all-[+prefix+][+module+] maybe-all-[+prefix+][+module+]
938 maybe-all-[+prefix+][+module+]:
939 @if [+prefix+][+module+]
940 TARGET-[+prefix+][+module+]=[+
941   IF target +][+target+][+ ELSE +]all[+ ENDIF target +]
942 maybe-all-[+prefix+][+module+]: all-[+prefix+][+module+]
943 all-[+prefix+][+module+]: configure-[+prefix+][+module+]
944         @[+ IF bootstrap +]test -f stage_last && exit 0; \
945         [+ ENDIF bootstrap +]r=`${PWD_COMMAND}`; export r; \
946         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
947         [+exports+] \
948         (cd [+subdir+]/[+module+] && \
949           $(MAKE) [+args+] [+extra_make_flags+] $(TARGET-[+prefix+][+module+]))
950 @endif [+prefix+][+module+]
951
952 [+ IF bootstrap +]
953 [+ FOR bootstrap_stage +]
954 .PHONY: all-stage[+id+]-[+prefix+][+module+] maybe-all-stage[+id+]-[+prefix+][+module+]
955 .PHONY: clean-stage[+id+]-[+prefix+][+module+] maybe-clean-stage[+id+]-[+prefix+][+module+]
956 maybe-all-stage[+id+]-[+prefix+][+module+]:
957 maybe-clean-stage[+id+]-[+prefix+][+module+]:
958 @if [+module+]-bootstrap
959 maybe-all-stage[+id+]-[+prefix+][+module+]: all-stage[+id+]-[+prefix+][+module+]
960 all-stage[+id+]: all-stage[+id+]-[+prefix+][+module+]
961 all-stage[+id+]-[+prefix+][+module+]: configure-stage[+id+]-[+prefix+][+module+]
962         @$(MAKE) stage[+id+]-start
963         @r=`${PWD_COMMAND}`; export r; \
964         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
965         [+exports+][+ IF prev +] \
966         [+poststage1_exports+][+ ENDIF prev +] \
967         cd [+subdir+]/[+module+] && \
968         $(MAKE) [+args+] [+ IF prev
969                 +][+poststage1_args+][+ ENDIF prev
970                 +] [+stage_make_flags+] [+extra_make_flags+]
971
972 maybe-clean-stage[+id+]-[+prefix+][+module+]: clean-stage[+id+]-[+prefix+][+module+]
973 clean-stage[+id+]: clean-stage[+id+]-[+prefix+][+module+]
974 clean-stage[+id+]-[+prefix+][+module+]:
975         @[ -f [+subdir+]/[+module+]/Makefile ] || [ -f [+subdir+]/stage[+id+]-[+module+]/Makefile ] \
976           || exit 0 ; \
977         [ -f [+subdir+]/[+module+]/Makefile ] || $(MAKE) stage[+id+]-start ; \
978         cd [+subdir+]/[+module+] && \
979         $(MAKE) [+args+] [+ IF prev +] \
980                 [+poststage1_args+] [+ ENDIF prev +] \
981                 [+stage_make_flags+] [+extra_make_flags+] clean
982 @endif [+module+]-bootstrap
983
984 [+ ENDFOR bootstrap_stage +]
985 [+ ENDIF bootstrap +]
986 [+ ENDDEF +]
987
988 # --------------------------------------
989 # Modules which run on the build machine
990 # --------------------------------------
991 [+ FOR build_modules +]
992 [+ configure prefix="build-" subdir="$(BUILD_SUBDIR)" exports="$(BUILD_EXPORTS)"
993              args="$(BUILD_CONFIGARGS)" no-config-site=true +]
994
995 [+ all prefix="build-" subdir="$(BUILD_SUBDIR)" exports="$(BUILD_EXPORTS)" +]
996 [+ ENDFOR build_module +]
997
998 # --------------------------------------
999 # Modules which run on the host machine
1000 # --------------------------------------
1001 [+ FOR host_modules +]
1002 [+ configure prefix="" subdir="$(HOST_SUBDIR)"
1003              exports="$(HOST_EXPORTS)"
1004              poststage1_exports="$(POSTSTAGE1_HOST_EXPORTS)"
1005              args="$(HOST_CONFIGARGS)" +]
1006
1007 [+ all prefix="" subdir="$(HOST_SUBDIR)"
1008        exports="$(HOST_EXPORTS)"
1009        poststage1_exports="$(POSTSTAGE1_HOST_EXPORTS)"
1010        args="$(FLAGS_TO_PASS)"
1011        poststage1_args="$(POSTSTAGE1_FLAGS_TO_PASS)" +]
1012
1013 .PHONY: check-[+module+] maybe-check-[+module+]
1014 maybe-check-[+module+]:
1015 @if [+module+]
1016 maybe-check-[+module+]: check-[+module+]
1017 [+ IF no_check +]
1018 check-[+module+]:
1019 [+ ELIF no_check_cross +]
1020 # This module is only tested in a native toolchain.
1021 check-[+module+]:
1022         @if [ '$(host)' = '$(target)' ] ; then \
1023           r=`${PWD_COMMAND}`; export r; \
1024           s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1025           $(HOST_EXPORTS) \
1026           (cd $(HOST_SUBDIR)/[+module+] && \
1027             $(MAKE) $(FLAGS_TO_PASS) [+extra_make_flags+] check); \
1028         fi
1029 [+ ELSE check +]
1030 check-[+module+]:
1031         @r=`${PWD_COMMAND}`; export r; \
1032         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1033         $(HOST_EXPORTS) \
1034         (cd $(HOST_SUBDIR)/[+module+] && \
1035           $(MAKE) $(FLAGS_TO_PASS) [+extra_make_flags+] check)
1036 [+ ENDIF no_check +]
1037 @endif [+module+]
1038
1039 .PHONY: install-[+module+] maybe-install-[+module+]
1040 maybe-install-[+module+]:
1041 @if [+module+]
1042 maybe-install-[+module+]: install-[+module+]
1043 [+ IF no_install +]
1044 install-[+module+]:
1045 [+ ELSE install +]
1046 install-[+module+]: installdirs
1047         @r=`${PWD_COMMAND}`; export r; \
1048         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1049         $(HOST_EXPORTS) \
1050         (cd $(HOST_SUBDIR)/[+module+] && \
1051           $(MAKE) $(FLAGS_TO_PASS) [+extra_make_flags+] install)
1052 [+ ENDIF no_install +]
1053 @endif [+module+]
1054
1055 # Other targets (info, dvi, etc.)
1056 [+ FOR recursive_targets +]
1057 .PHONY: maybe-[+make_target+]-[+module+] [+make_target+]-[+module+]
1058 maybe-[+make_target+]-[+module+]:
1059 @if [+module+]
1060 maybe-[+make_target+]-[+module+]: [+make_target+]-[+module+]
1061 [+ IF (match-value? = "missing" (get "make_target") ) +]
1062 # [+module+] doesn't support [+make_target+].
1063 [+make_target+]-[+module+]:
1064 [+ ELSE +]
1065 [+make_target+]-[+module+]: [+
1066   FOR depend +]\
1067     [+depend+]-[+module+] [+
1068   ENDFOR depend +]
1069         @[ -f ./[+module+]/Makefile ] || exit 0; \
1070         r=`${PWD_COMMAND}`; export r; \
1071         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1072         $(HOST_EXPORTS) \
1073         for flag in $(EXTRA_HOST_FLAGS) [+extra_make_flags+]; do \
1074           eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
1075         done; \
1076         echo "Doing [+make_target+] in [+module+]" ; \
1077         (cd $(HOST_SUBDIR)/[+module+] && \
1078           $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
1079                   "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
1080                   "RANLIB=$${RANLIB}" \
1081                   "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" \
1082                   [+make_target+]) \
1083           || exit 1
1084 [+ ENDIF +]
1085 @endif [+module+]
1086 [+ ENDFOR recursive_targets +]
1087 [+ ENDFOR host_modules +]
1088
1089 # ---------------------------------------
1090 # Modules which run on the target machine
1091 # ---------------------------------------
1092 [+ FOR target_modules +]
1093
1094 # There's only one multilib.out.  Cleverer subdirs shouldn't need it copied.
1095 @if target-[+module+]
1096 $(TARGET_SUBDIR)/[+module+]/multilib.out: multilib.out
1097         $(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/[+module+] ; \
1098         rm -f $(TARGET_SUBDIR)/[+module+]/Makefile || : ; \
1099         cp multilib.out $(TARGET_SUBDIR)/[+module+]/multilib.out
1100 @endif target-[+module+]
1101
1102 [+ IF raw_cxx +]
1103 [+ configure prefix="target-" subdir="$(TARGET_SUBDIR)"
1104              deps=(string-append "$(TARGET_SUBDIR)/" (get "module") "/multilib.out")
1105              exports="$(RAW_CXX_TARGET_EXPORTS)"
1106              args="$(TARGET_CONFIGARGS)" no-config-site=true +]
1107
1108 [+ all prefix="target-" subdir="$(TARGET_SUBDIR)"
1109        exports="$(RAW_CXX_TARGET_EXPORTS)"
1110        args="$(TARGET_FLAGS_TO_PASS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'" +]
1111 [+ ELSE +]
1112 [+ configure prefix="target-" subdir="$(TARGET_SUBDIR)"
1113              deps=(string-append "$(TARGET_SUBDIR)/" (get "module") "/multilib.out")
1114              exports="$(NORMAL_TARGET_EXPORTS)"
1115              args="$(TARGET_CONFIGARGS)" no-config-site=true +]
1116
1117 [+ all prefix="target-" subdir="$(TARGET_SUBDIR)"
1118        exports="$(NORMAL_TARGET_EXPORTS)"
1119        args="$(TARGET_FLAGS_TO_PASS)" +]
1120 [+ ENDIF +]
1121
1122 .PHONY: check-target-[+module+] maybe-check-target-[+module+]
1123 maybe-check-target-[+module+]:
1124 @if target-[+module+]
1125 maybe-check-target-[+module+]: check-target-[+module+]
1126 [+ IF no_check +]
1127 # Dummy target for uncheckable module.
1128 check-target-[+module+]:
1129 [+ ELSE check +]
1130 check-target-[+module+]:
1131         @r=`${PWD_COMMAND}`; export r; \
1132         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \[+
1133 IF raw_cxx +]
1134         $(RAW_CXX_TARGET_EXPORTS) \[+
1135 ELSE normal_cxx +]
1136         $(NORMAL_TARGET_EXPORTS) \[+
1137 ENDIF raw_cxx +]
1138         (cd $(TARGET_SUBDIR)/[+module+] && \
1139           $(MAKE) $(TARGET_FLAGS_TO_PASS) [+
1140             IF raw_cxx 
1141               +] 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)' [+ 
1142             ENDIF raw_cxx 
1143           +] [+extra_make_flags+] check)
1144 [+ ENDIF no_check +]
1145 @endif target-[+module+]
1146
1147 .PHONY: install-target-[+module+] maybe-install-target-[+module+]
1148 maybe-install-target-[+module+]:
1149 @if target-[+module+]
1150 maybe-install-target-[+module+]: install-target-[+module+]
1151 [+ IF no_install +]
1152 # Dummy target for uninstallable.
1153 install-target-[+module+]:
1154 [+ ELSE install +]
1155 install-target-[+module+]: installdirs
1156         @r=`${PWD_COMMAND}`; export r; \
1157         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \[+
1158 IF raw_cxx +]
1159         $(RAW_CXX_TARGET_EXPORTS) \[+
1160 ELSE normal_cxx +]
1161         $(NORMAL_TARGET_EXPORTS) \[+
1162 ENDIF raw_cxx +]
1163         (cd $(TARGET_SUBDIR)/[+module+] && \
1164           $(MAKE) $(TARGET_FLAGS_TO_PASS) [+extra_make_flags+] install)
1165 [+ ENDIF no_install +]
1166 @endif target-[+module+]
1167
1168 # Other targets (info, dvi, etc.)
1169 [+ FOR recursive_targets +]
1170 .PHONY: maybe-[+make_target+]-target-[+module+] [+make_target+]-target-[+module+]
1171 maybe-[+make_target+]-target-[+module+]:
1172 @if target-[+module+]
1173 maybe-[+make_target+]-target-[+module+]: [+make_target+]-target-[+module+]
1174 [+ IF (match-value? = "missing" (get "make_target") ) +]
1175 # [+module+] doesn't support [+make_target+].
1176 [+make_target+]-target-[+module+]:
1177 [+ ELSE +]
1178 [+make_target+]-target-[+module+]: [+
1179   FOR depend +]\
1180     [+depend+]-target-[+module+] [+
1181   ENDFOR depend +]
1182         @[ -f $(TARGET_SUBDIR)/[+module+]/Makefile ] || exit 0 ; \
1183         r=`${PWD_COMMAND}`; export r; \
1184         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \[+
1185 IF raw_cxx +]
1186         $(RAW_CXX_TARGET_EXPORTS) \[+
1187 ELSE normal_cxx +]
1188         $(NORMAL_TARGET_EXPORTS) \[+
1189 ENDIF raw_cxx +]
1190         echo "Doing [+make_target+] in $(TARGET_SUBDIR)/[+module+]" ; \
1191         for flag in $(EXTRA_TARGET_FLAGS); do \
1192           eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
1193         done; \
1194         (cd $(TARGET_SUBDIR)/[+module+] && \
1195           $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
1196                   "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
1197                   "RANLIB=$${RANLIB}" \
1198                   "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" \
1199                   [+extra_make_flags+] [+make_target+]) \
1200           || exit 1
1201 [+ ENDIF +]
1202 @endif target-[+module+]
1203 [+ ENDFOR recursive_targets +]
1204 [+ ENDFOR target_modules +]
1205
1206 # ----------
1207 # GCC module
1208 # ----------
1209
1210 @if gcc-no-bootstrap
1211 # GCC has some more recursive targets, which trigger the old
1212 # (but still current, until the toplevel bootstrap project
1213 # is finished) compiler bootstrapping rules.
1214
1215 GCC_STRAP_TARGETS = bootstrap bootstrap-lean bootstrap2 bootstrap2-lean bootstrap3 bootstrap3-lean bootstrap4 bootstrap4-lean bubblestrap quickstrap cleanstrap restrap
1216 .PHONY: $(GCC_STRAP_TARGETS)
1217 $(GCC_STRAP_TARGETS): all-prebootstrap configure-gcc
1218         @r=`${PWD_COMMAND}`; export r; \
1219         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1220         $(HOST_EXPORTS) \
1221         echo "Bootstrapping the compiler"; \
1222         $(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,:[ :]*,:,g;s,^[ :]*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \
1223         cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) $@
1224         @r=`${PWD_COMMAND}`; export r; \
1225         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1226         case "$@" in \
1227           *bootstrap4-lean ) \
1228             msg="Comparing stage3 and stage4 of the compiler"; \
1229             compare=compare3-lean ;; \
1230           *bootstrap4 ) \
1231             msg="Comparing stage3 and stage4 of the compiler"; \
1232             compare=compare3 ;; \
1233           *-lean ) \
1234             msg="Comparing stage2 and stage3 of the compiler"; \
1235             compare=compare-lean ;; \
1236           * ) \
1237             msg="Comparing stage2 and stage3 of the compiler"; \
1238             compare=compare ;; \
1239         esac; \
1240         $(HOST_EXPORTS) \
1241         echo "$$msg"; \
1242         cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) $$compare
1243         @r=`${PWD_COMMAND}`; export r; \
1244         s=`cd $(srcdir); ${PWD_COMMAND}` ; export s; \
1245         echo "Building runtime libraries"; \
1246         $(MAKE) $(RECURSE_FLAGS_TO_PASS) all
1247
1248 profiledbootstrap: all-prebootstrap configure-gcc
1249         @r=`${PWD_COMMAND}`; export r; \
1250         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1251         $(HOST_EXPORTS) \
1252         $(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,:[ :]*,:,g;s,^[ :]*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \
1253         echo "Bootstrapping training compiler"; \
1254         cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) stageprofile_build
1255         @r=`${PWD_COMMAND}`; export r; \
1256         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1257         $(HOST_EXPORTS) \
1258         echo "Building feedback based compiler"; \
1259         cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) stagefeedback_build
1260         @r=`${PWD_COMMAND}`; export r; \
1261         s=`cd $(srcdir); ${PWD_COMMAND}` ; export s; \
1262         echo "Building runtime libraries"; \
1263         $(MAKE) $(RECURSE_FLAGS_TO_PASS) all
1264
1265 .PHONY: cross
1266 cross: all-build all-gas all-ld
1267         @r=`${PWD_COMMAND}`; export r; \
1268         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1269         $(HOST_EXPORTS) \
1270         echo "Building the C and C++ compiler"; \
1271         cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) LANGUAGES="c c++"
1272         @r=`${PWD_COMMAND}`; export r; \
1273         s=`cd $(srcdir); ${PWD_COMMAND}` ; export s; \
1274         echo "Building runtime libraries"; \
1275         $(MAKE) $(RECURSE_FLAGS_TO_PASS) LANGUAGES="c c++" all
1276 @endif gcc-no-bootstrap
1277
1278 @if gcc
1279 .PHONY: check-gcc-c++
1280 check-gcc-c++:
1281         @if [ -f ./gcc/Makefile ] ; then \
1282           r=`${PWD_COMMAND}`; export r; \
1283           s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1284           $(HOST_EXPORTS) \
1285           (cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) check-c++); \
1286         else \
1287           true; \
1288         fi
1289
1290 .PHONY: check-c++
1291 check-c++: check-target-libstdc++-v3 check-gcc-c++
1292
1293 # Install the gcc headers files, but not the fixed include files,
1294 # which Cygnus is not allowed to distribute.  This rule is very
1295 # dependent on the workings of the gcc Makefile.in.
1296 .PHONY: gcc-no-fixedincludes
1297 gcc-no-fixedincludes:
1298         @if [ -f ./gcc/Makefile ]; then \
1299           rm -rf gcc/tmp-include; \
1300           mv gcc/include gcc/tmp-include 2>/dev/null; \
1301           mkdir gcc/include; \
1302           cp $(srcdir)/gcc/gsyslimits.h gcc/include/syslimits.h; \
1303           touch gcc/stmp-fixinc gcc/include/fixed; \
1304           rm -f gcc/stmp-headers gcc/stmp-int-hdrs; \
1305           r=`${PWD_COMMAND}`; export r; \
1306           s=`cd $(srcdir); ${PWD_COMMAND}` ; export s; \
1307           $(HOST_EXPORTS) \
1308           (cd ./gcc && \
1309            $(MAKE) $(GCC_FLAGS_TO_PASS) install); \
1310           rm -rf gcc/include; \
1311           mv gcc/tmp-include gcc/include 2>/dev/null; \
1312         else true; fi
1313 @endif gcc
1314
1315 # ---------------------
1316 # GCC bootstrap support
1317 # ---------------------
1318
1319 # We track the current stage (the one in 'gcc') in the stage_current file.
1320 # stage_last instead tracks the stage that was built last.  These targets
1321 # are dummy when toplevel bootstrap is not active.
1322
1323 .PHONY: unstage
1324 unstage:
1325 @if gcc-bootstrap
1326         @[ -f stage_current ] || $(MAKE) `cat stage_last`-start
1327 @endif gcc-bootstrap
1328
1329 .PHONY: stage
1330 stage:
1331 @if gcc-bootstrap
1332         @$(MAKE) `cat stage_current`-end
1333 @endif gcc-bootstrap
1334
1335 # We name the build directories for the various stages "stage1-gcc",
1336 # "stage2-gcc","stage3-gcc", etc.
1337
1338 # Since the 'compare' process will fail (on debugging information) if any
1339 # directory names are different, we need to link the gcc directory for
1340 # the previous stage to a constant name ('gcc-prev'), and to make the name of
1341 # the build directories constant as well. For the latter, we use naked names
1342 # like 'gcc', because the scripts in that directory assume it.  We use
1343 # mv on platforms where symlinks to directories do not work or are not
1344 # reliable.
1345
1346 # At the end of the bootstrap, a symlink to 'stage3-gcc' named 'gcc' must
1347 # be kept, so that libraries can find it.  Ick!
1348
1349 # It would be best to preinstall gcc into a staging area (and in the
1350 # future, gather there all prebootstrap packages).  This would allow
1351 # assemblers and linkers can be bootstrapped as well as the compiler
1352 # (both in a combined tree, or separately).  This however requires some
1353 # change to the gcc driver, again in order to avoid comparison failures.
1354
1355 # Bugs: This is crippled when doing parallel make, the `make all-host'
1356 # and `make all-target' phases can be parallelized.
1357
1358
1359 # 'touch' doesn't work right on some platforms.
1360 STAMP = echo timestamp > 
1361
1362 # Only build the C compiler for stage1, because that is the only one that
1363 # we can guarantee will build with the native compiler, and also it is the
1364 # only thing useful for building stage2. STAGE1_CFLAGS (via CFLAGS),
1365 # MAKEINFO and MAKEINFOFLAGS are explicitly passed here to make them
1366 # overrideable (for a bootstrap build stage1 also builds gcc.info).
1367
1368 STAGE1_CFLAGS=@stage1_cflags@
1369 STAGE1_LANGUAGES=@stage1_languages@
1370
1371 # We only want to compare .o files, so set this!
1372 objext = .o
1373
1374 # Flags to pass to stage2 and later makes.
1375 POSTSTAGE1_FLAGS_TO_PASS = \
1376         CC="$${CC}" CC_FOR_BUILD="$${CC_FOR_BUILD}" \
1377         STAGE_PREFIX=$$r/prev-gcc/ \
1378         CFLAGS="$(BOOT_CFLAGS)" \
1379         ADAC="\$$(CC)"
1380
1381 # For stage 1:
1382 # * We force-disable intermodule optimizations, even if
1383 #   --enable-intermodule was passed, since the installed compiler probably
1384 #   can't handle them.  Luckily, autoconf always respects
1385 #   the last argument when conflicting --enable arguments are passed.
1386 # * Likewise, we force-disable coverage flags, since the installed compiler
1387 #   probably has never heard of them.
1388 # * We build only C (and possibly Ada).
1389
1390 [+ FOR bootstrap-stage +]
1391 .PHONY: stage[+id+]-start stage[+id+]-end
1392
1393 stage[+id+]-start::
1394         @[ -f stage_current ] && $(MAKE) `cat stage_current`-end || : ; \
1395         echo stage[+id+] > stage_current ; \
1396         echo stage[+id+] > stage_last; \
1397         $(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR) $(TARGET_SUBDIR)[+
1398    FOR host_modules +][+ IF bootstrap +]
1399 @if [+ module +]
1400         @cd $(HOST_SUBDIR); [ -d stage[+id+]-[+module+] ] || \
1401           mkdir stage[+id+]-[+module+]; \
1402         set stage[+id+]-[+module+] [+module+] ; \
1403         @CREATE_LINK_TO_DIR@ [+ IF prev +] ; \
1404         set stage[+prev+]-[+module+] prev-[+module+] ; \
1405         @CREATE_LINK_TO_DIR@ [+ ENDIF prev +]
1406 @endif [+ module +][+ ENDIF bootstrap +][+ ENDFOR host_modules +][+
1407    FOR target_modules +][+ IF bootstrap +]
1408 @if target-[+ module +]
1409         @cd $(TARGET_SUBDIR); [ -d stage[+id+]-[+module+] ] || \
1410           mkdir stage[+id+]-[+module+]; \
1411         set stage[+id+]-[+module+] [+module+] ; \
1412         @CREATE_LINK_TO_DIR@ [+ IF prev +] ; \
1413         set stage[+prev+]-[+module+] prev-[+module+] ; \
1414         @CREATE_LINK_TO_DIR@ [+ ENDIF prev +]
1415 @endif target-[+ module +][+ ENDIF bootstrap +][+ ENDFOR target_modules +]
1416
1417 stage[+id+]-end::
1418         @rm -f stage_current[+ FOR host_modules +][+ IF bootstrap +]
1419 @if [+ module +]
1420         @cd $(HOST_SUBDIR); set [+module+] stage[+id+]-[+module+] ; \
1421         @UNDO_LINK_TO_DIR@ [+ IF prev +] ; \
1422         set prev-[+module+] stage[+prev+]-[+module+] ; \
1423         @UNDO_LINK_TO_DIR@ [+ ENDIF prev +]
1424 @endif [+ module +][+ ENDIF bootstrap +][+ ENDFOR host_modules +][+
1425    FOR target_modules +][+ IF bootstrap +]
1426 @if target-[+ module +]
1427         @cd $(HOST_SUBDIR); set [+module+] stage[+id+]-[+module+] ; \
1428         @UNDO_LINK_TO_DIR@ [+ IF prev +] ; \
1429         set prev-[+module+] stage[+prev+]-[+module+] ; \
1430         @UNDO_LINK_TO_DIR@ [+ ENDIF prev +]
1431 @endif [+ module +][+ ENDIF bootstrap +][+ ENDFOR target_modules +]
1432
1433 # Bubble a bugfix through all the stages up to stage [+id+].  They
1434 # are remade, but not reconfigured.  The next stage (if any) will not
1435 # be reconfigured as well.
1436 .PHONY: stage[+id+]-bubble
1437 stage[+id+]-bubble:: [+ IF prev +]stage[+prev+]-bubble[+ ENDIF +][+IF lean +]
1438         @bootstrap_lean@-rm -rf stage[+lean+]-* ; $(STAMP) stage[+lean+]-lean[+ ENDIF lean +]
1439         @if test -f stage[+id+]-lean [+
1440           IF prev +]|| test -f stage[+prev+]-lean [+ ENDIF prev +] ; then \
1441           echo Skipping rebuild of stage[+id+] ; \
1442         else \
1443           $(MAKE) $(RECURSE_FLAGS_TO_PASS) NOTPARALLEL= all-stage[+id+]; \
1444         fi
1445
1446 .PHONY: all-stage[+id+] clean-stage[+id+]
1447 do-clean: clean-stage[+id+]
1448
1449 # FIXME: Will not need to be conditional when toplevel bootstrap is the
1450 # only possibility, but now it conflicts with no-bootstrap rules
1451 @if gcc-bootstrap
1452 [+ IF compare-target +]
1453 [+compare-target+]:
1454         @if test -f stage[+prev+]-lean; then \
1455           echo Cannot compare object files as stage [+prev+] was deleted. ; \
1456           exit 0 ; \
1457         fi; \
1458         [ -f stage_current ] && $(MAKE) `cat stage_current`-end || : ; \
1459         @r=`${PWD_COMMAND}`; export r; \
1460         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1461         rm -f .bad_compare ; \
1462         cd stage[+id+]-gcc; \
1463         files=`find . -name "*$(objext)" -print` ; \
1464         cd .. ; \
1465         for file in $${files} ; do \
1466           f1=$$r/stage[+prev+]-gcc/$$file; f2=$$r/stage[+id+]-gcc/$$file; \
1467           @do_compare@ > /dev/null 2>&1; \
1468           test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \
1469         done ; \
1470         if [ -f .bad_compare ]; then \
1471           echo "Bootstrap comparison failure!"; \
1472           cat .bad_compare; \
1473           exit 1; \
1474         else \
1475           true; \
1476         fi ; \
1477         $(STAMP) [+compare-target+][+ IF prev +]
1478         @bootstrap_lean@-rm -rf stage[+prev+]-* ; $(STAMP) stage[+prev+]-lean[+ ENDIF prev +]
1479 [+ ENDIF compare-target +]
1480
1481 [+ IF bootstrap-target +]
1482 .PHONY: [+bootstrap-target+]
1483 [+bootstrap-target+]: stage[+id+]-bubble [+compare-target+] all
1484 [+ ENDIF bootstrap-target +]
1485
1486 # Rules to wipe a stage and all the following ones, also used for cleanstrap
1487 [+ IF prev +]distclean-stage[+prev+]:: distclean-stage[+id+] [+ ENDIF prev +]
1488 .PHONY: distclean-stage[+id+]
1489 distclean-stage[+id+]::
1490         [ -f stage_current ] && $(MAKE) `cat stage_current`-end || :
1491         rm -rf stage[+id+]-* [+
1492           IF compare-target +][+compare-target+] [+ ENDIF compare-target +]
1493
1494 [+ IF cleanstrap-target +]
1495 .PHONY: [+cleanstrap-target+]
1496 [+cleanstrap-target+]: distclean [+bootstrap-target+]
1497 [+ ENDIF cleanstrap-target +]
1498 @endif gcc-bootstrap
1499
1500 [+ ENDFOR bootstrap-stage +]
1501
1502 stageprofile-end::
1503         $(MAKE) distclean-stagefeedback
1504
1505 stagefeedback-start::
1506         @r=`${PWD_COMMAND}`; export r; \
1507         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1508         for i in prev-*; do \
1509           j=`echo $$i | sed s/^prev-//` ; \
1510           cd $$r/$$i && \
1511           { find . -type d | sort | sed 's,.*,$(SHELL) '"$$s"'/mkinstalldirs "../'$$j'/&",' | $(SHELL) ; } && \
1512           { find . -name '*.*da' | sed 's,.*,$(LN) -f "&" "../'$$j'/&",' | $(SHELL) ; } ; \
1513         done
1514
1515 @if gcc-bootstrap
1516 NOTPARALLEL = .NOTPARALLEL
1517 $(NOTPARALLEL):
1518 do-distclean: distclean-stage1
1519 @endif gcc-bootstrap
1520
1521 # --------------------------------------
1522 # Dependencies between different modules
1523 # --------------------------------------
1524
1525 # Generic dependencies for target modules on host stuff, especially gcc
1526 [+ FOR target_modules +][+ IF bootstrap +]
1527 @if gcc-bootstrap[+ FOR bootstrap_stage +]
1528 configure-stage[+id+]-target-[+module+]: maybe-all-stage[+id+]-gcc[+ ENDFOR +]
1529 @endif gcc-bootstrap[+ ENDIF bootstrap +]
1530 configure-target-[+module+]: maybe-all-gcc
1531 [+ ENDFOR target_modules +]
1532
1533 [+ FOR lang_env_dependencies +]
1534 configure-target-[+module+]: maybe-all-target-newlib maybe-all-target-libgloss
1535 [+ IF cxx +]configure-target-[+module+]: maybe-all-target-libstdc++-v3
1536 [+ ENDIF cxx +][+ ENDFOR lang_env_dependencies +]
1537
1538 # There are two types of dependencies here: 'hard' dependencies, where one
1539 # module simply won't build without the other; and 'soft' dependencies, where
1540 # if the depended-on module is missing, the depending module will do without
1541 # or find a substitute somewhere (perhaps installed).  Soft dependencies
1542 # are made here to depend on a 'maybe-' target.  If you're not sure,
1543 # it's safer to use a soft dependency.
1544
1545 [+ ;; These Scheme functions build the bulk of the dependencies.
1546    ;; dep-target builds a string like "maybe-all-MODULE_KIND-gcc",
1547    ;; where "maybe-" is only included if HARD is true, and all-gcc
1548    ;; is taken from VAR-NAME.
1549    (define dep-target (lambda (module-kind var-name hard)
1550       (string-append
1551          (if hard "" "maybe-")
1552          (dep-subtarget var-name)
1553          module-kind
1554          (dep-module var-name)
1555       )))
1556
1557    ;; make-dep builds a dependency from the MODULE and ON AutoGen vars.
1558    (define make-dep (lambda (module-kind on-kind)
1559       (string-append
1560          (dep-target module-kind "module" #t) ": "
1561          (dep-target on-kind "on" (exist? "hard")))))
1562
1563    ;; dep-subtarget extracts everything up to the first dash in the given
1564    ;; AutoGen variable, for example it extracts "all-" out of "all-gcc".
1565    (define dep-subtarget (lambda (var-name)
1566       (substring (get var-name) 0 (+ 1 (string-index (get var-name) #\-)))))
1567
1568    ;; dep-module extracts everything up to the first dash in the given
1569    ;; AutoGen variable, for example it extracts "gcc" out of "all-gcc".
1570    (define dep-module (lambda (var-name)
1571       (substring (get var-name) (+ 1 (string-index (get var-name) #\-)))))
1572
1573    ;; dep-stage builds a string for the prefix of a bootstrap stage.
1574    (define dep-stage (lambda ()
1575       (string-append
1576          "stage"
1577          (get "id")
1578          "-")))
1579
1580    ;; dep-maybe is the same as the AutoGen expression "- hard 'maybe-'"
1581    ;; but is written in Scheme.
1582    (define dep-maybe (lambda ()
1583       (if (exist? "hard") "" "maybe-")))
1584
1585    ;; dep-kind returns "normal" if the dependency is on an "install" target,
1586    ;; or if either module is not bootstrapped.  It returns "bootstrap" for
1587    ;; configure or build dependencies between bootstrapped modules; it returns
1588    ;; "prebootstrap" for configure or build dependencies of bootstrapped
1589    ;; modules on a build module (e.g. all-gcc on all-build-bison).  All this
1590    ;; is only necessary for host modules.
1591    (define dep-kind (lambda ()
1592       (if (and (hash-ref boot-modules (dep-module "module"))
1593                (=* (dep-module "on") "build-"))
1594           "prebootstrap"
1595
1596           (if (or (= (dep-subtarget "on") "install-")
1597                   (not (hash-ref boot-modules (dep-module "module")))
1598                   (not (hash-ref boot-modules (dep-module "on"))))
1599               "normal"
1600               "bootstrap"))))
1601
1602    ;; We now build the hash table that is used by dep-kind.
1603    (define boot-modules (make-hash-table 113))
1604 +]
1605
1606 [+ FOR host_modules +][+
1607    (if (exist? "bootstrap")
1608        (hash-create-handle! boot-modules (get "module") #t))
1609    "" +][+ ENDFOR host_modules +]
1610 [+ FOR target_modules +][+
1611    (if (exist? "bootstrap")
1612        (hash-create-handle! boot-modules (string-append "target-" (get "module")) #t))
1613    "" +][+ ENDFOR target_modules +]
1614
1615 # With all the machinery above in place, it is pretty easy to generate
1616 # dependencies.  Host dependencies are a bit more complex because we have
1617 # to check for bootstrap/prebootstrap dependencies.  To resolve
1618 # prebootstrap dependencies, prebootstrap modules are gathered in
1619 # a hash table.
1620 [+ FOR dependencies +][+ (make-dep "" "") +]
1621 [+ CASE (dep-kind) +]
1622 [+ == "prebootstrap"
1623      +][+ FOR bootstrap_stage +]
1624 [+ (make-dep (dep-stage) "") +][+
1625        ENDFOR bootstrap_stage +]
1626 all-prebootstrap: [+ (dep-target "" "on" (exist? "hard")) +]
1627 [+ == "bootstrap"
1628      +][+ FOR bootstrap_stage +]
1629 [+ (make-dep (dep-stage) (dep-stage)) +][+
1630        ENDFOR bootstrap_stage +]
1631 [+ ESAC +][+
1632 ENDFOR dependencies +]
1633
1634 # Non-toplevel bootstrap rules must depend on several packages, to be built
1635 # before gcc.  Another wart that will go away, hopefully soon.
1636 @if gcc-no-bootstrap
1637 [+ FOR host_modules +][+
1638    IF (and (not (= (get "module") "gcc"))
1639            (hash-ref boot-modules (get "module"))) +]
1640 all-prebootstrap: maybe-all-[+module+][+
1641    ENDIF +][+
1642 ENDFOR host_modules +]
1643 @endif gcc-no-bootstrap
1644
1645 GDB_TK = @GDB_TK@
1646 all-gdb: $(gdbnlmrequirements) $(GDB_TK)
1647
1648 # Serialization dependencies.  Host configures don't work well in parallel to
1649 # each other, due to contention over config.cache.  Target configures and 
1650 # build configures are similar.
1651 @serialization_dependencies@
1652
1653 # --------------------------------
1654 # Regenerating top level configury
1655 # --------------------------------
1656
1657 # Multilib.out tells target dirs what multilibs they should build.
1658 # There is really only one copy.  We use the 'timestamp' method to
1659 # work around various timestamp bugs on some systems.
1660 # We use move-if-change so that it's only considered updated when it
1661 # actually changes, because it has to depend on a phony target.
1662 multilib.out: maybe-all-gcc
1663         @r=`${PWD_COMMAND}`; export r; \
1664         echo "Checking multilib configuration..."; \
1665         $(CC_FOR_TARGET) --print-multi-lib > multilib.tmp 2> /dev/null ; \
1666         $(SHELL) $(srcdir)/move-if-change multilib.tmp multilib.out ; \
1667
1668 # Rebuilding Makefile.in, using autogen.
1669 AUTOGEN = autogen
1670 $(srcdir)/Makefile.in: @MAINT@ $(srcdir)/Makefile.tpl $(srcdir)/Makefile.def
1671         cd $(srcdir) && $(AUTOGEN) Makefile.def
1672
1673 # Rebuilding Makefile.
1674 Makefile: $(srcdir)/Makefile.in config.status
1675         CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
1676
1677 config.status: configure
1678         CONFIG_SHELL="$(SHELL)" $(SHELL) ./config.status --recheck
1679
1680 # Rebuilding configure.
1681 AUTOCONF = autoconf
1682 $(srcdir)/configure: @MAINT@ $(srcdir)/configure.in $(srcdir)/config/acx.m4
1683         cd $(srcdir) && $(AUTOCONF)
1684
1685 # ------------------------------
1686 # Special directives to GNU Make
1687 # ------------------------------
1688
1689 # Don't pass command-line variables to submakes.
1690 .NOEXPORT:
1691 MAKEOVERRIDES=
1692
1693 # end of Makefile.in