OSDN Git Service

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