OSDN Git Service

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