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