2005-12-19 Paolo Bonzini <bonzini@gnu.org>
[external/binutils.git] / Makefile.tpl
1 [+ AutoGen5 template -*- Mode: Makefile -*-
2 in
3 +]
4
5 # Makefile.in is generated from Makefile.tpl by 'autogen Makefile.def'.
6 #
7 # Makefile for directory with subdirs to build.
8 #   Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
9 #   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation
10 #
11 # This file is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
15
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 #
25
26 # -------------------------------
27 # Standard Autoconf-set variables
28 # -------------------------------
29 VPATH=@srcdir@
30
31 build_alias=@build_alias@
32 build=@build@
33 host_alias=@host_alias@
34 host=@host@
35 target_alias=@target_alias@
36 target=@target@
37
38 program_transform_name = @program_transform_name@
39
40 prefix = @prefix@
41 exec_prefix = @exec_prefix@
42
43 srcdir = @srcdir@
44
45 bindir = @bindir@
46 sbindir = @sbindir@
47 libexecdir = @libexecdir@
48 datadir = @datadir@
49 sysconfdir = @sysconfdir@
50 sharedstatedir = @sharedstatedir@
51 localstatedir = @localstatedir@
52 libdir = @libdir@
53 includedir = @includedir@
54 oldincludedir = @oldincludedir@
55 infodir = @infodir@
56 mandir = @mandir@
57 man1dir = $(mandir)/man1
58 man2dir = $(mandir)/man2
59 man3dir = $(mandir)/man3
60 man4dir = $(mandir)/man4
61 man5dir = $(mandir)/man5
62 man6dir = $(mandir)/man6
63 man7dir = $(mandir)/man7
64 man8dir = $(mandir)/man8
65 man9dir = $(mandir)/man9
66
67 INSTALL = @INSTALL@
68 INSTALL_PROGRAM = @INSTALL_PROGRAM@
69 INSTALL_SCRIPT = @INSTALL_SCRIPT@
70 INSTALL_DATA = @INSTALL_DATA@
71 LN = @LN@
72 LN_S = @LN_S@
73
74 # -------------------------------------------------
75 # Miscellaneous non-standard autoconf-set variables
76 # -------------------------------------------------
77
78 # The gcc driver likes to know the arguments it was configured with.
79 TOPLEVEL_CONFIGURE_ARGUMENTS=@TOPLEVEL_CONFIGURE_ARGUMENTS@
80
81 tooldir = @tooldir@
82 build_tooldir = @build_tooldir@
83
84 GDB_NLM_DEPS = 
85
86 # This is the name of the environment variable used for the path to
87 # the libraries.
88 RPATH_ENVVAR = @RPATH_ENVVAR@
89
90 # This is the list of directories to be built for the build system.
91 BUILD_CONFIGDIRS = libiberty
92 # Build programs are put under this directory.
93 BUILD_SUBDIR = @build_subdir@
94 # This is set by the configure script to the arguments to use when configuring
95 # directories built for the build system.
96 BUILD_CONFIGARGS = @build_configargs@ --with-build-subdir="$(BUILD_SUBDIR)"
97
98 # This is the list of variables to export in the environment when
99 # configuring any subdirectory.  It must also be exported whenever
100 # recursing into a build directory in case that directory's Makefile
101 # re-runs configure.
102 BASE_EXPORTS = \
103         FLEX="$(FLEX)"; export FLEX; \
104         LEX="$(LEX)"; export LEX; \
105         BISON="$(BISON)"; export BISON; \
106         YACC="$(YACC)"; export YACC; \
107         M4="$(M4)"; export M4; \
108         MAKEINFO="$(MAKEINFO)"; export MAKEINFO;
109
110 # This is the list of variables to export in the environment when
111 # configuring subdirectories for the build system.
112 BUILD_EXPORTS = \
113         $(BASE_EXPORTS) \
114         AR="$(AR_FOR_BUILD)"; export AR; \
115         AS="$(AS_FOR_BUILD)"; export AS; \
116         CC="$(CC_FOR_BUILD)"; export CC; \
117         CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \
118         CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
119         CXX="$(CXX_FOR_BUILD)"; export CXX; \
120         CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \
121         GCJ="$(GCJ_FOR_BUILD)"; export GCJ; \
122         GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \
123         DLLTOOL="$(DLLTOOL_FOR_BUILD)"; export DLLTOOL; \
124         LD="$(LD_FOR_BUILD)"; export LD; \
125         LDFLAGS="$(LDFLAGS_FOR_BUILD)"; export LDFLAGS; \
126         NM="$(NM_FOR_BUILD)"; export NM; \
127         RANLIB="$(RANLIB_FOR_BUILD)"; export RANLIB; \
128         WINDRES="$(WINDRES_FOR_BUILD)"; export WINDRES;
129
130 # This is the list of directories to built for the host system.
131 SUBDIRS = @configdirs@
132 # This is set by the configure script to the arguments to use when configuring
133 # directories built for the host system.
134 HOST_CONFIGARGS = @host_configargs@
135 # Host programs are put under this directory, which is . except if building
136 # with srcdir=..
137 HOST_SUBDIR = @host_subdir@
138 # This is the list of variables to export in the environment when
139 # configuring subdirectories for the host system.  We need to pass
140 # some to the GCC configure because of its hybrid host/target nature.
141 HOST_EXPORTS = \
142         $(BASE_EXPORTS) \
143         CC="$(CC)"; export CC; \
144         CFLAGS="$(CFLAGS)"; export CFLAGS; \
145         CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
146         CXX="$(CXX)"; export CXX; \
147         CXXFLAGS="$(CXXFLAGS)"; export CXXFLAGS; \
148         AR="$(AR)"; export AR; \
149         AS="$(AS)"; export AS; \
150         CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \
151         DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \
152         LD="$(LD)"; export LD; \
153         LDFLAGS="$(LDFLAGS)"; export LDFLAGS; \
154         NM="$(NM)"; export NM; \
155         RANLIB="$(RANLIB)"; export RANLIB; \
156         WINDRES="$(WINDRES)"; export WINDRES; \
157         OBJCOPY="$(OBJCOPY)"; export OBJCOPY; \
158         OBJDUMP="$(OBJDUMP)"; export OBJDUMP; \
159         AR_FOR_TARGET="$(AR_FOR_TARGET)"; export AR_FOR_TARGET; \
160         AS_FOR_TARGET="$(AS_FOR_TARGET)"; export AS_FOR_TARGET; \
161         GCC_FOR_TARGET="$(GCC_FOR_TARGET)"; export GCC_FOR_TARGET; \
162         LD_FOR_TARGET="$(LD_FOR_TARGET)"; export LD_FOR_TARGET; \
163         NM_FOR_TARGET="$(NM_FOR_TARGET)"; export NM_FOR_TARGET; \
164         OBJDUMP_FOR_TARGET="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP_FOR_TARGET; \
165         RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)"; export RANLIB_FOR_TARGET; \
166         TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \
167         GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \
168         GMPINC="$(HOST_GMPINC)"; export GMPINC; \
169 @if gcc-bootstrap
170         $(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \
171 @endif gcc-bootstrap
172         $(RPATH_ENVVAR)=`echo "$(HOST_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR);
173
174 # Similar, for later GCC stages.
175 POSTSTAGE1_HOST_EXPORTS = \
176         $(HOST_EXPORTS) \
177         CC="$(STAGE_CC_WRAPPER) $$r/$(HOST_SUBDIR)/prev-gcc/xgcc$(exeext) \
178           -B$$r/$(HOST_SUBDIR)/prev-gcc/ -B$(build_tooldir)/bin/"; export CC; \
179         CC_FOR_BUILD="$(STAGE_CC_WRAPPER) \
180           $$r/$(HOST_SUBDIR)/prev-gcc/xgcc$(exeext) \
181           -B$$r/$(HOST_SUBDIR)/prev-gcc/ \
182           -B$(build_tooldir)/bin/"; export CC_FOR_BUILD;
183
184 # This is set by the configure script to the list of directories which
185 # should be built using the target tools.
186 TARGET_CONFIGDIRS = @target_configdirs@
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_ADAFLAGS=
259 BOOT_LDFLAGS=
260
261 BISON = @BISON@
262 YACC = @YACC@
263 FLEX = @FLEX@
264 LEX = @LEX@
265 M4 = @M4@
266 MAKEINFO = @MAKEINFO@
267 EXPECT = @EXPECT@
268 RUNTEST = @RUNTEST@
269
270 # This just becomes part of the MAKEINFO definition passed down to
271 # sub-makes.  It lets flags be given on the command line while still
272 # using the makeinfo from the object tree.
273 # (Default to avoid splitting info files by setting the threshold high.)
274 MAKEINFOFLAGS = --split-size=5000000
275
276 # ---------------------------------------------
277 # Programs producing files for the HOST machine
278 # ---------------------------------------------
279
280 AS = @AS@
281 AR = @AR@
282 AR_FLAGS = rc
283 CC = @CC@
284 CXX = @CXX@
285 DLLTOOL = @DLLTOOL@
286 LD = @LD@
287 LIPO = @LIPO@
288 NM = @NM@
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 +]\
393         "[+flag+]=$([+flag+])" [+ ENDFOR flags_to_pass +]\
394         "CONFIG_SHELL=$(SHELL)" \
395         "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" 
396
397 # We leave this in just in case, but it is not needed anymore.
398 RECURSE_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS)
399
400 # Flags to pass down to most sub-makes, in which we're building with
401 # the host environment.
402 EXTRA_HOST_FLAGS = \
403         'AR=$(AR)' \
404         'AS=$(AS)' \
405         'CC=$(CC)' \
406         'CXX=$(CXX)' \
407         'DLLTOOL=$(DLLTOOL)' \
408         'LD=$(LD)' \
409         'LIPO=$(LIPO)' \
410         'NM=$(NM)' \
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         'ADAFLAGS=$$(ADAFLAGS_FOR_TARGET)' \
435         'AR=$$(AR_FOR_TARGET)' \
436         'AS=$(COMPILER_AS_FOR_TARGET)' \
437         'CC=$$(CC_FOR_TARGET)' \
438         'CFLAGS=$$(CFLAGS_FOR_TARGET)' \
439         'CXX=$$(CXX_FOR_TARGET)' \
440         'CXXFLAGS=$$(CXXFLAGS_FOR_TARGET)' \
441         'DLLTOOL=$$(DLLTOOL_FOR_TARGET)' \
442         'LD=$(COMPILER_LD_FOR_TARGET)' \
443         'LDFLAGS=$$(LDFLAGS_FOR_TARGET)' \
444         'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET)' \
445         'LIBCXXFLAGS=$$(LIBCXXFLAGS_FOR_TARGET)' \
446         'NM=$(COMPILER_NM_FOR_TARGET)' \
447         'OBJDUMP=$$(OBJDUMP_FOR_TARGET)' \
448         'RANLIB=$$(RANLIB_FOR_TARGET)' \
449         'WINDRES=$$(WINDRES_FOR_TARGET)'
450
451 TARGET_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)
452
453 # Flags to pass down to gcc.  gcc builds a library, libgcc.a, so it
454 # unfortunately needs the native compiler and the target ar and
455 # ranlib.
456 # If any variables are added here, they must be added to do-*, below.
457 # The BUILD_* variables are a special case, which are used for the gcc
458 # cross-building scheme.
459 EXTRA_GCC_FLAGS = \
460         'BUILD_PREFIX=$(BUILD_PREFIX)' \
461         'BUILD_PREFIX_1=$(BUILD_PREFIX_1)' \
462         "GCC_FOR_TARGET=$(GCC_FOR_TARGET)" \
463         "`echo 'LANGUAGES=$(LANGUAGES)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
464         "`echo 'STMP_FIXPROTO=$(STMP_FIXPROTO)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
465         "`echo 'LIMITS_H_TEST=$(LIMITS_H_TEST)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
466         "`echo 'LIBGCC2_CFLAGS=$(LIBGCC2_CFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
467         "`echo 'LIBGCC2_DEBUG_CFLAGS=$(LIBGCC2_DEBUG_CFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
468         "`echo 'LIBGCC2_INCLUDES=$(LIBGCC2_INCLUDES)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
469         "`echo 'STAGE1_CFLAGS=$(STAGE1_CFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
470         "`echo 'BOOT_CFLAGS=$(BOOT_CFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
471         "`echo 'BOOT_ADAFLAGS=$(BOOT_ADAFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"
472
473 GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(EXTRA_GCC_FLAGS)
474
475 .PHONY: configure-host
476 configure-host: [+
477   FOR host_modules +] \
478     maybe-configure-[+module+][+
479   ENDFOR host_modules +]
480 .PHONY: configure-target
481 configure-target: [+
482   FOR target_modules +] \
483     maybe-configure-target-[+module+][+
484   ENDFOR target_modules +]
485
486 # The target built for a native non-bootstrap build.
487 .PHONY: all
488 all:
489 @if gcc-bootstrap
490         [ -f stage_final ] || echo stage3 > stage_final
491         @r=`${PWD_COMMAND}`; export r; \
492         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
493         $(MAKE) $(RECURSE_FLAGS_TO_PASS) `cat stage_final`-bubble
494 @endif gcc-bootstrap
495         @: $(MAKE); $(unstage)
496         @r=`${PWD_COMMAND}`; export r; \
497         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
498         if [ -f stage_last ]; then \
499           $(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target; \
500         else \
501           $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-host all-target; \
502         fi
503
504 .PHONY: all-build
505 all-build: [+
506   FOR build_modules +] \
507     maybe-all-build-[+module+][+
508   ENDFOR build_modules +]
509 .PHONY: all-host
510 all-host: [+
511   FOR host_modules +] \
512     maybe-all-[+module+][+
513   ENDFOR host_modules +]
514 .PHONY: all-target
515 all-target: [+
516   FOR target_modules +] \
517     maybe-all-target-[+module+][+
518   ENDFOR target_modules +]
519
520 # Do a target for all the subdirectories.  A ``make do-X'' will do a
521 # ``make X'' in all subdirectories (because, in general, there is a
522 # dependency (below) of X upon do-X, a ``make X'' will also do this,
523 # but it may do additional work as well).
524 [+ FOR recursive_targets +]
525 .PHONY: do-[+make_target+]
526 do-[+make_target+]:
527         @: $(MAKE); $(unstage)
528         @r=`${PWD_COMMAND}`; export r; \
529         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
530         $(MAKE) $(RECURSE_FLAGS_TO_PASS) [+make_target+]-host \
531           [+make_target+]-target
532
533
534 .PHONY: [+make_target+]-host
535 [+make_target+]-host: [+
536   FOR host_modules +] \
537     maybe-[+make_target+]-[+module+][+
538   ENDFOR host_modules +]
539
540 .PHONY: [+make_target+]-target
541 [+make_target+]-target: [+
542   FOR target_modules +] \
543     maybe-[+make_target+]-target-[+module+][+
544   ENDFOR target_modules +]
545 [+ ENDFOR recursive_targets +]
546
547 # Here are the targets which correspond to the do-X targets.
548
549 .PHONY: info installcheck dvi html install-info
550 .PHONY: clean distclean mostlyclean maintainer-clean realclean
551 .PHONY: local-clean local-distclean local-maintainer-clean
552 info: do-info
553 installcheck: do-installcheck
554 dvi: do-dvi
555 html: do-html
556
557 # Make sure makeinfo is built before we do a `make info', if we're
558 # in fact building texinfo.
559 do-info: maybe-all-texinfo
560
561 install-info: do-install-info dir.info
562         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
563         if [ -f dir.info ] ; then \
564           $(INSTALL_DATA) dir.info $(DESTDIR)$(infodir)/dir.info ; \
565         else true ; fi
566
567 local-clean:
568         -rm -f *.a TEMP errs core *.o *~ \#* TAGS *.E *.log
569
570 local-distclean:
571         -rm -f Makefile config.status config.cache mh-frag mt-frag
572         -rm -f maybedep.tmp serdep.tmp
573         -if [ "$(TARGET_SUBDIR)" != "." ]; then \
574           rm -rf $(TARGET_SUBDIR); \
575         else true; fi
576         -rm -rf $(BUILD_SUBDIR)
577         -if [ "$(HOST_SUBDIR)" != "." ]; then \
578           rm -rf $(HOST_SUBDIR); \
579         else true; fi
580         -rm -f texinfo/po/Makefile texinfo/po/Makefile.in texinfo/info/Makefile
581         -rm -f texinfo/doc/Makefile texinfo/po/POTFILES
582         -rmdir texinfo/doc texinfo/info texinfo/intl texinfo/lib 2>/dev/null
583         -rmdir texinfo/makeinfo texinfo/po texinfo/util 2>/dev/null
584         -rmdir fastjar gcc libiberty texinfo zlib 2>/dev/null
585
586 local-maintainer-clean:
587         @echo "This command is intended for maintainers to use;"
588         @echo "it deletes files that may require special tools to rebuild."
589
590 clean: do-clean local-clean
591 mostlyclean: do-mostlyclean local-clean
592 distclean: do-distclean local-clean local-distclean
593 maintainer-clean: local-maintainer-clean do-maintainer-clean local-clean 
594 maintainer-clean: local-distclean
595 realclean: maintainer-clean
596
597 # Extra dependency for clean-target, owing to the mixed nature of gcc.
598 clean-target: clean-target-libgcc
599 clean-target-libgcc:
600         test ! -d gcc || (cd gcc && $(MAKE) $@)
601
602 # Check target.
603
604 .PHONY: check do-check
605 check: do-check
606
607 # Only include modules actually being configured and built.
608 .PHONY: check-host
609 check-host: [+
610   FOR host_modules +] \
611     maybe-check-[+module+][+
612   ENDFOR host_modules +]
613
614 .PHONY: check-target
615 check-target: [+
616   FOR target_modules +] \
617     maybe-check-target-[+module+][+
618   ENDFOR target_modules +]
619
620 do-check:
621         @: $(MAKE); $(unstage)
622         @r=`${PWD_COMMAND}`; export r; \
623         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
624         $(MAKE) $(RECURSE_FLAGS_TO_PASS) check-host check-target
625
626 # Automated reporting of test results.
627
628 warning.log: build.log
629         $(srcdir)/contrib/warn_summary build.log > $@
630
631 mail-report.log:
632         if test x'$(BOOT_CFLAGS)' != x''; then \
633             BOOT_CFLAGS='$(BOOT_CFLAGS)'; export BOOT_CFLAGS; \
634         fi; \
635         $(srcdir)/contrib/test_summary -t >$@
636         chmod +x $@
637         echo If you really want to send e-mail, run ./$@ now
638
639 mail-report-with-warnings.log: warning.log
640         if test x'$(BOOT_CFLAGS)' != x''; then \
641             BOOT_CFLAGS='$(BOOT_CFLAGS)'; export BOOT_CFLAGS; \
642         fi; \
643         $(srcdir)/contrib/test_summary -t -i warning.log >$@
644         chmod +x $@
645         echo If you really want to send e-mail, run ./$@ now
646
647 # Installation targets.
648
649 .PHONY: install uninstall
650 install:
651         @: $(MAKE); $(unstage)
652         @r=`${PWD_COMMAND}`; export r; \
653         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
654         $(MAKE) $(RECURSE_FLAGS_TO_PASS) installdirs install-host install-target
655
656 .PHONY: install-host-nogcc
657 install-host-nogcc: [+
658   FOR host_modules +][+ IF (not (= (get "module") "gcc")) +] \
659     maybe-install-[+module+][+ ENDIF +][+
660   ENDFOR host_modules +]
661
662 .PHONY: install-host
663 install-host: [+
664   FOR host_modules +] \
665     maybe-install-[+module+][+
666   ENDFOR host_modules +]
667
668 .PHONY: install-target
669 install-target: [+
670   FOR target_modules +] \
671     maybe-install-target-[+module+][+
672   ENDFOR target_modules +]
673
674 uninstall:
675         @echo "the uninstall target is not supported in this tree"
676
677 .PHONY: install.all
678 install.all: install-no-fixedincludes
679         @if [ -f ./gcc/Makefile ] ; then \
680                 r=`${PWD_COMMAND}` ; export r ; \
681                 s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
682                 $(HOST_EXPORTS) \
683                 (cd ./gcc && \
684                 $(MAKE) $(FLAGS_TO_PASS) install-headers) ; \
685         else \
686                 true ; \
687         fi
688
689 # install-no-fixedincludes is used because Cygnus can not distribute
690 # the fixed header files.
691 .PHONY: install-no-fixedincludes
692 install-no-fixedincludes: installdirs install-host-nogcc \
693         install-target gcc-no-fixedincludes
694
695 ### other supporting targets
696
697 MAKEDIRS= \
698         $(DESTDIR)$(prefix) \
699         $(DESTDIR)$(exec_prefix)
700 .PHONY: installdirs
701 installdirs: mkinstalldirs
702         $(SHELL) $(srcdir)/mkinstalldirs $(MAKEDIRS)
703
704 dir.info: do-install-info
705         if [ -f $(srcdir)/texinfo/gen-info-dir ] ; then \
706           $(srcdir)/texinfo/gen-info-dir $(DESTDIR)$(infodir) $(srcdir)/texinfo/dir.info-template > dir.info.new ; \
707           mv -f dir.info.new dir.info ; \
708         else true ; \
709         fi
710
711 dist:
712         @echo "Building a full distribution of this tree isn't done"
713         @echo "via 'make dist'.  Check out the etc/ subdirectory" 
714
715 etags tags: TAGS
716
717 # Right now this just builds TAGS in each subdirectory.  emacs19 has the
718 # ability to use several tags files at once, so there is probably no need
719 # to combine them into one big TAGS file (like CVS 1.3 does).  We could
720 # (if we felt like it) have this Makefile write a piece of elisp which
721 # the user could load to tell emacs19 where all the TAGS files we just
722 # built are.
723 TAGS: do-TAGS
724
725 # ------------------------------------
726 # Macros for configure and all targets
727 # ------------------------------------
728
729 [+ DEFINE configure +]
730 .PHONY: configure-[+prefix+][+module+] maybe-configure-[+prefix+][+module+]
731 maybe-configure-[+prefix+][+module+]:
732 @if [+prefix+][+module+]
733 maybe-configure-[+prefix+][+module+]: configure-[+prefix+][+module+]
734 configure-[+prefix+][+module+]:
735         @[+ IF bootstrap +]test -f stage_last && exit 0; \
736         [+ ELSE bootstrap +]: $(MAKE); $(unstage)
737         @[+ ENDIF bootstrap +][+ IF check_multilibs
738         +]r=`${PWD_COMMAND}`; export r; \
739         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
740         echo "Checking multilib configuration for [+module+]..."; \
741         $(SHELL) $(srcdir)/mkinstalldirs [+subdir+]/[+module+] ; \
742         $(CC_FOR_TARGET) --print-multi-lib > [+subdir+]/[+module+]/multilib.tmp 2> /dev/null ; \
743         if test -r [+subdir+]/[+module+]/multilib.out; then \
744           if cmp -s [+subdir+]/[+module+]/multilib.tmp [+subdir+]/[+module+]/multilib.out; then \
745             rm -f [+subdir+]/[+module+]/multilib.tmp; \
746           else \
747             rm -f [+subdir+]/[+module+]/Makefile; \
748             mv [+subdir+]/[+module+]/multilib.tmp [+subdir+]/[+module+]/multilib.out; \
749           fi; \
750         else \
751           mv [+subdir+]/[+module+]/multilib.tmp [+subdir+]/[+module+]/multilib.out; \
752         fi
753         @[+ ENDIF check_multilibs +]test ! -f [+subdir+]/[+module+]/Makefile || exit 0; \
754         $(SHELL) $(srcdir)/mkinstalldirs [+subdir+]/[+module+] ; \
755         r=`${PWD_COMMAND}`; export r; \
756         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
757         [+exports+] \
758         echo Configuring in [+subdir+]/[+module+]; \
759         cd "[+subdir+]/[+module+]" || exit 1; \
760         case $(srcdir) in \
761           /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
762           *) topdir=`echo [+subdir+]/[+module+]/ | \
763                 sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
764         esac; \
765         srcdiroption="--srcdir=$${topdir}/[+module+]"; \
766         libsrcdir="$$s/[+module+]"; \
767         [+ IF no-config-site +]rm -f no-such-file || : ; \
768         CONFIG_SITE=no-such-file [+ ENDIF +]$(SHELL) $${libsrcdir}/configure \
769           [+args+] $${srcdiroption} [+extra_configure_flags+] \
770           || exit 1
771 @endif [+prefix+][+module+]
772
773 [+ IF bootstrap +]
774 [+ FOR bootstrap_stage +]
775 .PHONY: configure-stage[+id+]-[+prefix+][+module+] maybe-configure-stage[+id+]-[+prefix+][+module+]
776 maybe-configure-stage[+id+]-[+prefix+][+module+]:
777 @if [+prefix+][+module+]-bootstrap
778 maybe-configure-stage[+id+]-[+prefix+][+module+]: configure-stage[+id+]-[+prefix+][+module+]
779 configure-stage[+id+]-[+prefix+][+module+]:
780         @[ `cat stage_current` = stage[+id+] ] || $(MAKE) stage[+id+]-start
781         @$(SHELL) $(srcdir)/mkinstalldirs [+subdir+]/[+module+]
782         [+ IF check_multilibs
783         +]@r=`${PWD_COMMAND}`; export r; \
784         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
785         echo "Checking multilib configuration for [+module+]..."; \
786         $(CC_FOR_TARGET) --print-multi-lib > [+subdir+]/[+module+]/multilib.tmp 2> /dev/null ; \
787         if test -r [+subdir+]/[+module+]/multilib.out; then \
788           if cmp -s [+subdir+]/[+module+]/multilib.tmp [+subdir+]/[+module+]/multilib.out; then \
789             rm -f [+subdir+]/[+module+]/multilib.tmp; \
790           else \
791             rm -f [+subdir+]/[+module+]/Makefile; \
792             mv [+subdir+]/[+module+]/multilib.tmp [+subdir+]/[+module+]/multilib.out; \
793           fi; \
794         else \
795           mv [+subdir+]/[+module+]/multilib.tmp [+subdir+]/[+module+]/multilib.out; \
796         fi
797         @[+ ENDIF check_multilibs +]test ! -f [+subdir+]/[+module+]/Makefile || exit 0; \
798         [+exports+][+ IF prev +] \
799         [+poststage1_exports+][+ ENDIF prev +] \
800         echo Configuring stage [+id+] in [+subdir+]/[+module+] ; \
801         $(SHELL) $(srcdir)/mkinstalldirs [+subdir+]/[+module+] ; \
802         cd [+subdir+]/[+module+] || exit 1; \
803         case $(srcdir) in \
804           /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
805           *) topdir=`echo [+subdir+]/[+module+]/ | \
806                 sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
807         esac; \
808         srcdiroption="--srcdir=$${topdir}/[+module+]"; \
809         libsrcdir="$$s/[+module+]"; \
810         $(SHELL) $${libsrcdir}/configure \
811           [+args+] $${srcdiroption} \
812           [+stage_configure_flags+] [+extra_configure_flags+]
813 @endif [+prefix+][+module+]-bootstrap
814 [+ ENDFOR bootstrap_stage +]
815 [+ ENDIF bootstrap +]
816 [+ ENDDEF +]
817
818 [+ DEFINE all +]
819 .PHONY: all-[+prefix+][+module+] maybe-all-[+prefix+][+module+]
820 maybe-all-[+prefix+][+module+]:
821 @if [+prefix+][+module+]
822 TARGET-[+prefix+][+module+]=[+
823   IF target +][+target+][+ ELSE +]all[+ ENDIF target +]
824 maybe-all-[+prefix+][+module+]: all-[+prefix+][+module+]
825 all-[+prefix+][+module+]: configure-[+prefix+][+module+]
826         @[+ IF bootstrap +]test -f stage_last && exit 0; \
827         [+ ELSE bootstrap +]: $(MAKE); $(unstage)
828         @[+ ENDIF bootstrap +]r=`${PWD_COMMAND}`; export r; \
829         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
830         [+exports+] \
831         (cd [+subdir+]/[+module+] && \
832           $(MAKE) [+args+] [+extra_make_flags+] $(TARGET-[+prefix+][+module+]))
833 @endif [+prefix+][+module+]
834
835 [+ IF bootstrap +]
836 [+ FOR bootstrap_stage +]
837 .PHONY: all-stage[+id+]-[+prefix+][+module+] maybe-all-stage[+id+]-[+prefix+][+module+]
838 .PHONY: clean-stage[+id+]-[+prefix+][+module+] maybe-clean-stage[+id+]-[+prefix+][+module+]
839 maybe-all-stage[+id+]-[+prefix+][+module+]:
840 maybe-clean-stage[+id+]-[+prefix+][+module+]:
841 @if [+prefix+][+module+]-bootstrap
842 maybe-all-stage[+id+]-[+prefix+][+module+]: all-stage[+id+]-[+prefix+][+module+]
843 all-stage[+id+]: all-stage[+id+]-[+prefix+][+module+]
844 TARGET-stage[+id+]-[+prefix+][+module+] = $(TARGET-[+prefix+][+module+])
845 all-stage[+id+]-[+prefix+][+module+]: configure-stage[+id+]-[+prefix+][+module+]
846         @[ `cat stage_current` = stage[+id+] ] || $(MAKE) stage[+id+]-start
847         @r=`${PWD_COMMAND}`; export r; \
848         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
849         [+exports+][+ IF prev +] \
850         [+poststage1_exports+][+ ENDIF prev +] \
851         cd [+subdir+]/[+module+] && \
852         $(MAKE) [+args+] [+ IF prev
853                 +][+poststage1_args+][+ ENDIF prev
854                 +] [+stage_make_flags+] [+extra_make_flags+] \
855                 $(TARGET-stage[+id+]-[+prefix+][+module+])
856
857 maybe-clean-stage[+id+]-[+prefix+][+module+]: clean-stage[+id+]-[+prefix+][+module+]
858 clean-stage[+id+]: clean-stage[+id+]-[+prefix+][+module+]
859 clean-stage[+id+]-[+prefix+][+module+]:
860         @[ -f [+subdir+]/[+module+]/Makefile ] || [ -f [+subdir+]/stage[+id+]-[+module+]/Makefile ] \
861           || exit 0 ; \
862         @[ `cat stage_current` = stage[+id+] ] || $(MAKE) stage[+id+]-start
863         cd [+subdir+]/[+module+] && \
864         $(MAKE) [+args+] [+ IF prev +] \
865                 [+poststage1_args+] [+ ENDIF prev +] \
866                 [+stage_make_flags+] [+extra_make_flags+] clean
867 @endif [+prefix+][+module+]-bootstrap
868
869 [+ ENDFOR bootstrap_stage +]
870 [+ ENDIF bootstrap +]
871 [+ ENDDEF +]
872
873 # --------------------------------------
874 # Modules which run on the build machine
875 # --------------------------------------
876 [+ FOR build_modules +]
877 [+ configure prefix="build-" subdir="$(BUILD_SUBDIR)" exports="$(BUILD_EXPORTS)"
878              args="$(BUILD_CONFIGARGS)" no-config-site=true +]
879
880 [+ all prefix="build-" subdir="$(BUILD_SUBDIR)" exports="$(BUILD_EXPORTS)" +]
881 [+ ENDFOR build_module +]
882
883 # --------------------------------------
884 # Modules which run on the host machine
885 # --------------------------------------
886 [+ FOR host_modules +]
887 [+ configure prefix="" subdir="$(HOST_SUBDIR)"
888              exports="$(HOST_EXPORTS)"
889              poststage1_exports="$(POSTSTAGE1_HOST_EXPORTS)"
890              args="$(HOST_CONFIGARGS)" +]
891
892 [+ all prefix="" subdir="$(HOST_SUBDIR)"
893        exports="$(HOST_EXPORTS)"
894        poststage1_exports="$(POSTSTAGE1_HOST_EXPORTS)"
895        args="$(FLAGS_TO_PASS)"
896        poststage1_args="$(POSTSTAGE1_FLAGS_TO_PASS)" +]
897
898 .PHONY: check-[+module+] maybe-check-[+module+]
899 maybe-check-[+module+]:
900 @if [+module+]
901 maybe-check-[+module+]: check-[+module+]
902 [+ IF no_check +]
903 check-[+module+]:
904 [+ ELIF no_check_cross +]
905 # This module is only tested in a native toolchain.
906 check-[+module+]:
907         @: $(MAKE); $(unstage)
908         @if [ '$(host)' = '$(target)' ] ; then \
909           r=`${PWD_COMMAND}`; export r; \
910           s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
911           $(HOST_EXPORTS) \
912           (cd $(HOST_SUBDIR)/[+module+] && \
913             $(MAKE) $(FLAGS_TO_PASS) [+extra_make_flags+] check); \
914         fi
915 [+ ELSE check +]
916 check-[+module+]:
917         @: $(MAKE); $(unstage)
918         @r=`${PWD_COMMAND}`; export r; \
919         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
920         $(HOST_EXPORTS) \
921         (cd $(HOST_SUBDIR)/[+module+] && \
922           $(MAKE) $(FLAGS_TO_PASS) [+extra_make_flags+] check)
923 [+ ENDIF no_check +]
924 @endif [+module+]
925
926 .PHONY: install-[+module+] maybe-install-[+module+]
927 maybe-install-[+module+]:
928 @if [+module+]
929 maybe-install-[+module+]: install-[+module+]
930 [+ IF no_install +]
931 install-[+module+]:
932 [+ ELSE install +]
933 install-[+module+]: installdirs
934         @: $(MAKE); $(unstage)
935         @r=`${PWD_COMMAND}`; export r; \
936         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
937         $(HOST_EXPORTS) \
938         (cd $(HOST_SUBDIR)/[+module+] && \
939           $(MAKE) $(FLAGS_TO_PASS) [+extra_make_flags+] install)
940 [+ ENDIF no_install +]
941 @endif [+module+]
942
943 # Other targets (info, dvi, etc.)
944 [+ FOR recursive_targets +]
945 .PHONY: maybe-[+make_target+]-[+module+] [+make_target+]-[+module+]
946 maybe-[+make_target+]-[+module+]:
947 @if [+module+]
948 maybe-[+make_target+]-[+module+]: [+make_target+]-[+module+]
949 [+ IF (match-value? = "missing" (get "make_target") ) +]
950 # [+module+] doesn't support [+make_target+].
951 [+make_target+]-[+module+]:
952 [+ ELSE +]
953 [+make_target+]-[+module+]: [+
954   FOR depend +]\
955     [+depend+]-[+module+] [+
956   ENDFOR depend +]
957         @[+ IF bootstrap +][+ ELSE +]: $(MAKE); $(unstage)
958         @[+ ENDIF bootstrap +][ -f ./[+module+]/Makefile ] || exit 0; \
959         r=`${PWD_COMMAND}`; export r; \
960         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
961         $(HOST_EXPORTS) \
962         for flag in $(EXTRA_HOST_FLAGS) [+extra_make_flags+]; do \
963           eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
964         done; \
965         echo "Doing [+make_target+] in [+module+]" ; \
966         (cd $(HOST_SUBDIR)/[+module+] && \
967           $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
968                   "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
969                   "RANLIB=$${RANLIB}" \
970                   "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" \
971                   [+make_target+]) \
972           || exit 1
973 [+ ENDIF +]
974 @endif [+module+]
975 [+ ENDFOR recursive_targets +]
976 [+ ENDFOR host_modules +]
977
978 # ---------------------------------------
979 # Modules which run on the target machine
980 # ---------------------------------------
981 [+ FOR target_modules +]
982
983 [+ IF raw_cxx +]
984 [+ configure prefix="target-" subdir="$(TARGET_SUBDIR)"
985              check_multilibs=true
986              exports="$(RAW_CXX_TARGET_EXPORTS)"
987              args="$(TARGET_CONFIGARGS)" no-config-site=true +]
988
989 [+ all prefix="target-" subdir="$(TARGET_SUBDIR)"
990        exports="$(RAW_CXX_TARGET_EXPORTS)"
991        args="$(TARGET_FLAGS_TO_PASS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'" +]
992 [+ ELSE +]
993 [+ configure prefix="target-" subdir="$(TARGET_SUBDIR)"
994              check_multilibs=true
995              exports="$(NORMAL_TARGET_EXPORTS)"
996              args="$(TARGET_CONFIGARGS)" no-config-site=true +]
997
998 [+ all prefix="target-" subdir="$(TARGET_SUBDIR)"
999        exports="$(NORMAL_TARGET_EXPORTS)"
1000        args="$(TARGET_FLAGS_TO_PASS)" +]
1001 [+ ENDIF +]
1002
1003 .PHONY: check-target-[+module+] maybe-check-target-[+module+]
1004 maybe-check-target-[+module+]:
1005 @if target-[+module+]
1006 maybe-check-target-[+module+]: check-target-[+module+]
1007 [+ IF no_check +]
1008 # Dummy target for uncheckable module.
1009 check-target-[+module+]:
1010 [+ ELSE check +]
1011 check-target-[+module+]:
1012         @: $(MAKE); $(unstage)
1013         @r=`${PWD_COMMAND}`; export r; \
1014         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \[+
1015 IF raw_cxx +]
1016         $(RAW_CXX_TARGET_EXPORTS) \[+
1017 ELSE normal_cxx +]
1018         $(NORMAL_TARGET_EXPORTS) \[+
1019 ENDIF raw_cxx +]
1020         (cd $(TARGET_SUBDIR)/[+module+] && \
1021           $(MAKE) $(TARGET_FLAGS_TO_PASS) [+
1022             IF raw_cxx 
1023               +] 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)' [+ 
1024             ENDIF raw_cxx 
1025           +] [+extra_make_flags+] check)
1026 [+ ENDIF no_check +]
1027 @endif target-[+module+]
1028
1029 .PHONY: install-target-[+module+] maybe-install-target-[+module+]
1030 maybe-install-target-[+module+]:
1031 @if target-[+module+]
1032 maybe-install-target-[+module+]: install-target-[+module+]
1033 [+ IF no_install +]
1034 # Dummy target for uninstallable.
1035 install-target-[+module+]:
1036 [+ ELSE install +]
1037 install-target-[+module+]: installdirs
1038         @: $(MAKE); $(unstage)
1039         @r=`${PWD_COMMAND}`; export r; \
1040         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \[+
1041 IF raw_cxx +]
1042         $(RAW_CXX_TARGET_EXPORTS) \[+
1043 ELSE normal_cxx +]
1044         $(NORMAL_TARGET_EXPORTS) \[+
1045 ENDIF raw_cxx +]
1046         (cd $(TARGET_SUBDIR)/[+module+] && \
1047           $(MAKE) $(TARGET_FLAGS_TO_PASS) [+extra_make_flags+] install)
1048 [+ ENDIF no_install +]
1049 @endif target-[+module+]
1050
1051 # Other targets (info, dvi, etc.)
1052 [+ FOR recursive_targets +]
1053 .PHONY: maybe-[+make_target+]-target-[+module+] [+make_target+]-target-[+module+]
1054 maybe-[+make_target+]-target-[+module+]:
1055 @if target-[+module+]
1056 maybe-[+make_target+]-target-[+module+]: [+make_target+]-target-[+module+]
1057 [+ IF (match-value? = "missing" (get "make_target") ) +]
1058 # [+module+] doesn't support [+make_target+].
1059 [+make_target+]-target-[+module+]:
1060 [+ ELSE +]
1061 [+make_target+]-target-[+module+]: [+
1062   FOR depend +]\
1063     [+depend+]-target-[+module+] [+
1064   ENDFOR depend +]
1065         @: $(MAKE); $(unstage)
1066         @[ -f $(TARGET_SUBDIR)/[+module+]/Makefile ] || exit 0 ; \
1067         r=`${PWD_COMMAND}`; export r; \
1068         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \[+
1069 IF raw_cxx +]
1070         $(RAW_CXX_TARGET_EXPORTS) \[+
1071 ELSE normal_cxx +]
1072         $(NORMAL_TARGET_EXPORTS) \[+
1073 ENDIF raw_cxx +]
1074         echo "Doing [+make_target+] in $(TARGET_SUBDIR)/[+module+]" ; \
1075         for flag in $(EXTRA_TARGET_FLAGS); do \
1076           eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
1077         done; \
1078         (cd $(TARGET_SUBDIR)/[+module+] && \
1079           $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
1080                   "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
1081                   "RANLIB=$${RANLIB}" \
1082                   "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" \
1083                   [+extra_make_flags+] [+make_target+]) \
1084           || exit 1
1085 [+ ENDIF +]
1086 @endif target-[+module+]
1087 [+ ENDFOR recursive_targets +]
1088 [+ ENDFOR target_modules +]
1089
1090 # ----------
1091 # GCC module
1092 # ----------
1093
1094 @if gcc-no-bootstrap
1095 # GCC has some more recursive targets, which trigger the old
1096 # (but still current, until the toplevel bootstrap project
1097 # is finished) compiler bootstrapping rules.
1098
1099 GCC_STRAP_TARGETS = bootstrap bootstrap-lean bootstrap2 bootstrap2-lean bootstrap3 bootstrap3-lean bootstrap4 bootstrap4-lean bubblestrap quickstrap cleanstrap restrap
1100 .PHONY: $(GCC_STRAP_TARGETS)
1101 $(GCC_STRAP_TARGETS): all-prebootstrap configure-gcc
1102         @r=`${PWD_COMMAND}`; export r; \
1103         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1104         $(HOST_EXPORTS) \
1105         echo "Bootstrapping the compiler"; \
1106         $(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,:[ :]*,:,g;s,^[ :]*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \
1107         cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) $@
1108         @r=`${PWD_COMMAND}`; export r; \
1109         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1110         case "$@" in \
1111           *bootstrap4-lean ) \
1112             msg="Comparing stage3 and stage4 of the compiler"; \
1113             compare=compare3-lean ;; \
1114           *bootstrap4 ) \
1115             msg="Comparing stage3 and stage4 of the compiler"; \
1116             compare=compare3 ;; \
1117           *-lean ) \
1118             msg="Comparing stage2 and stage3 of the compiler"; \
1119             compare=compare-lean ;; \
1120           * ) \
1121             msg="Comparing stage2 and stage3 of the compiler"; \
1122             compare=compare ;; \
1123         esac; \
1124         $(HOST_EXPORTS) \
1125         echo "$$msg"; \
1126         cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) $$compare
1127         @r=`${PWD_COMMAND}`; export r; \
1128         s=`cd $(srcdir); ${PWD_COMMAND}` ; export s; \
1129         echo "Building runtime libraries"; \
1130         $(MAKE) $(RECURSE_FLAGS_TO_PASS) all
1131
1132 profiledbootstrap: all-prebootstrap configure-gcc
1133         @r=`${PWD_COMMAND}`; export r; \
1134         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1135         $(HOST_EXPORTS) \
1136         $(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,:[ :]*,:,g;s,^[ :]*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \
1137         echo "Bootstrapping training compiler"; \
1138         cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) stageprofile_build
1139         @r=`${PWD_COMMAND}`; export r; \
1140         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1141         $(HOST_EXPORTS) \
1142         echo "Building feedback based compiler"; \
1143         cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) stagefeedback_build
1144         @r=`${PWD_COMMAND}`; export r; \
1145         s=`cd $(srcdir); ${PWD_COMMAND}` ; export s; \
1146         echo "Building runtime libraries"; \
1147         $(MAKE) $(RECURSE_FLAGS_TO_PASS) all
1148
1149 .PHONY: cross
1150 cross: all-build all-gas all-ld
1151         @r=`${PWD_COMMAND}`; export r; \
1152         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1153         $(HOST_EXPORTS) \
1154         echo "Building the C and C++ compiler"; \
1155         cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) LANGUAGES="c c++"
1156         @r=`${PWD_COMMAND}`; export r; \
1157         s=`cd $(srcdir); ${PWD_COMMAND}` ; export s; \
1158         echo "Building runtime libraries"; \
1159         $(MAKE) $(RECURSE_FLAGS_TO_PASS) LANGUAGES="c c++" all
1160 @endif gcc-no-bootstrap
1161
1162 @if gcc
1163 .PHONY: check-gcc-c++
1164 check-gcc-c++:
1165         @if [ -f ./gcc/Makefile ] ; then \
1166           r=`${PWD_COMMAND}`; export r; \
1167           s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1168           $(HOST_EXPORTS) \
1169           (cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) check-c++); \
1170         else \
1171           true; \
1172         fi
1173
1174 .PHONY: check-c++
1175 check-c++: check-target-libstdc++-v3 check-gcc-c++
1176
1177 # Install the gcc headers files, but not the fixed include files,
1178 # which Cygnus is not allowed to distribute.  This rule is very
1179 # dependent on the workings of the gcc Makefile.in.
1180 .PHONY: gcc-no-fixedincludes
1181 gcc-no-fixedincludes:
1182         @if [ -f ./gcc/Makefile ]; then \
1183           rm -rf gcc/tmp-include; \
1184           mv gcc/include gcc/tmp-include 2>/dev/null; \
1185           mkdir gcc/include; \
1186           cp $(srcdir)/gcc/gsyslimits.h gcc/include/syslimits.h; \
1187           touch gcc/stmp-fixinc gcc/include/fixed; \
1188           rm -f gcc/stmp-headers gcc/stmp-int-hdrs; \
1189           r=`${PWD_COMMAND}`; export r; \
1190           s=`cd $(srcdir); ${PWD_COMMAND}` ; export s; \
1191           $(HOST_EXPORTS) \
1192           (cd ./gcc && \
1193            $(MAKE) $(GCC_FLAGS_TO_PASS) install); \
1194           rm -rf gcc/include; \
1195           mv gcc/tmp-include gcc/include 2>/dev/null; \
1196         else true; fi
1197 @endif gcc
1198
1199 # ---------------------
1200 # GCC bootstrap support
1201 # ---------------------
1202
1203 # We track the current stage (the one in 'gcc') in the stage_current file.
1204 # stage_last instead tracks the stage that was built last.  These targets
1205 # are dummy when toplevel bootstrap is not active.
1206
1207 # While making host and target tools, symlinks to the final stage must be
1208 # there, so $(unstage) should be run at various points.  To avoid excessive
1209 # recursive invocations of make, we "inline" them using a variable.  These
1210 # must be referenced as ": $(MAKE) ; $(unstage)" rather than "$(unstage)"
1211 # to avoid warnings from the GNU Make job server.
1212
1213 unstage = :
1214 stage = :
1215
1216 @if gcc-bootstrap
1217 unstage = [ -f stage_current ] || $(MAKE) `cat stage_last`-start
1218 stage = if [ -f stage_current ]; then $(MAKE) `cat stage_current`-end || exit 1; else :; fi
1219 @endif gcc-bootstrap
1220
1221 .PHONY: unstage stage
1222 unstage:
1223         @: $(MAKE); $(unstage)
1224 stage:
1225         @: $(MAKE); $(stage)
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         ADAFLAGS="$(BOOT_ADAFLAGS)" \
1259         LDFLAGS="$(BOOT_LDFLAGS)" \
1260         ADAC="\$$(CC)"
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         set stage[+id+]-[+module+] [+module+] ; \
1284         @CREATE_LINK_TO_DIR@ [+ IF prev +] ; \
1285         set stage[+prev+]-[+module+] prev-[+module+] ; \
1286         @CREATE_LINK_TO_DIR@ [+ ENDIF prev +]
1287 @endif [+ module +][+ ENDIF bootstrap +][+ ENDFOR host_modules +]
1288         @[ -d stage[+id+]-$(TARGET_SUBDIR) ] || \
1289           mkdir stage[+id+]-$(TARGET_SUBDIR); \
1290         set stage[+id+]-$(TARGET_SUBDIR) $(TARGET_SUBDIR) ; \
1291         @CREATE_LINK_TO_DIR@ [+ IF prev +] ; \
1292         set stage[+prev+]-$(TARGET_SUBDIR) prev-$(TARGET_SUBDIR) ; \
1293         @CREATE_LINK_TO_DIR@ [+ ENDIF prev +]
1294
1295 stage[+id+]-end::
1296         @rm -f stage_current[+ FOR host_modules +][+ IF bootstrap +]
1297 @if [+ module +]
1298         @if test -d $(HOST_SUBDIR) ; then \
1299         cd $(HOST_SUBDIR); set [+module+] stage[+id+]-[+module+] ; \
1300         @UNDO_LINK_TO_DIR@ [+ IF prev +] ; \
1301         set prev-[+module+] stage[+prev+]-[+module+] ; \
1302         @UNDO_LINK_TO_DIR@ [+ ENDIF prev +] ; \
1303         fi
1304 @endif [+ module +][+ ENDIF bootstrap +][+ ENDFOR host_modules +]
1305         @if test -d $(TARGET_SUBDIR) ; then \
1306           set $(TARGET_SUBDIR) stage[+id+]-$(TARGET_SUBDIR) ; \
1307           @UNDO_LINK_TO_DIR@ [+ IF prev +] ; \
1308           set prev-$(TARGET_SUBDIR) stage[+prev+]-$(TARGET_SUBDIR) ; \
1309           @UNDO_LINK_TO_DIR@ [+ ENDIF prev +] ; \
1310         fi
1311
1312 # Bubble a bugfix through all the stages up to stage [+id+].  They are
1313 # remade, but not reconfigured.  The next stage (if any) will not be
1314 # reconfigured as well.
1315 .PHONY: stage[+id+]-bubble
1316 stage[+id+]-bubble:: [+ IF prev +]stage[+prev+]-bubble[+ ENDIF +][+IF lean +]
1317         @bootstrap_lean@-rm -rf stage[+lean+]-* ; $(STAMP) stage[+lean+]-lean[+ ENDIF lean +]
1318         @r=`${PWD_COMMAND}`; export r; \
1319         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1320         if test -f stage[+id+]-lean [+
1321           IF prev +]|| test -f stage[+prev+]-lean [+ ENDIF prev +] ; then \
1322           echo Skipping rebuild of stage[+id+] ; \
1323         else \
1324           $(MAKE) stage[+id+]-start; \
1325           $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-stage[+id+]; \
1326         fi[+ IF compare-target +]
1327         $(MAKE) $(RECURSE_FLAGS_TO_PASS) [+compare-target+][+ ENDIF compare-target +]
1328
1329 .PHONY: all-stage[+id+] clean-stage[+id+]
1330 do-clean: clean-stage[+id+]
1331
1332 # FIXME: Will not need to be conditional when toplevel bootstrap is the
1333 # only possibility, but now it conflicts with no-bootstrap rules
1334 @if gcc-bootstrap
1335 [+ IF compare-target +]
1336 [+compare-target+]:
1337         @r=`${PWD_COMMAND}`; export r; \
1338         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1339         if test -f stage[+prev+]-lean; then \
1340           echo Cannot compare object files as stage [+prev+] was deleted. ; \
1341           exit 0 ; \
1342         fi; \
1343         : $(MAKE); $(stage); \
1344         rm -f .bad_compare ; \
1345         cd stage[+id+]-gcc; \
1346         files=`find . -name "*$(objext)" -print` ; \
1347         cd .. ; \
1348         for file in $${files} ; do \
1349           f1=$$r/stage[+prev+]-gcc/$$file; f2=$$r/stage[+id+]-gcc/$$file; \
1350           @do_compare@ > /dev/null 2>&1; \
1351           if test $$? -eq 1; then \
1352             case $$file in \
1353               ./cc*-checksum$(objext) | ./libgcc/* ) \
1354                 echo warning: $$file differs ;; \
1355               *) \
1356                 echo $$file differs >> .bad_compare ;; \
1357             esac ; \
1358           fi ; \
1359         done ; \
1360         if [ -f .bad_compare ]; then \
1361           echo "Bootstrap comparison failure!"; \
1362           cat .bad_compare; \
1363           exit 1; \
1364         else \
1365           true; \
1366         fi ; \
1367         $(STAMP) [+compare-target+][+ IF prev +]
1368         @bootstrap_lean@-rm -rf stage[+prev+]-* ; $(STAMP) stage[+prev+]-lean[+ ENDIF prev +]
1369 [+ ENDIF compare-target +]
1370
1371 [+ IF bootstrap-target +]
1372 .PHONY: [+bootstrap-target+]
1373 [+bootstrap-target+]:
1374         echo stage[+id+] > stage_final
1375         @r=`${PWD_COMMAND}`; export r; \
1376         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1377         $(MAKE) $(RECURSE_FLAGS_TO_PASS) stage[+id+]-bubble
1378         @: $(MAKE); $(unstage)
1379         @r=`${PWD_COMMAND}`; export r; \
1380         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1381         $(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target
1382 [+ ENDIF bootstrap-target +]
1383
1384 # Rules to wipe a stage and all the following ones, also used for cleanstrap
1385 [+ IF prev +]distclean-stage[+prev+]:: distclean-stage[+id+] [+ ENDIF prev +]
1386 .PHONY: distclean-stage[+id+]
1387 distclean-stage[+id+]::
1388         @: $(MAKE); $(stage)
1389         rm -rf stage[+id+]-* [+
1390           IF compare-target +][+compare-target+] [+ ENDIF compare-target +]
1391
1392 [+ IF cleanstrap-target +]
1393 .PHONY: [+cleanstrap-target+]
1394 [+cleanstrap-target+]: distclean [+bootstrap-target+]
1395 [+ ENDIF cleanstrap-target +]
1396 @endif gcc-bootstrap
1397
1398 [+ ENDFOR bootstrap-stage +]
1399
1400 stageprofile-end::
1401         $(MAKE) distclean-stagefeedback
1402
1403 stagefeedback-start::
1404         @r=`${PWD_COMMAND}`; export r; \
1405         s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
1406         for i in prev-*; do \
1407           j=`echo $$i | sed s/^prev-//` ; \
1408           cd $$r/$$i && \
1409           { find . -type d | sort | sed 's,.*,$(SHELL) '"$$s"'/mkinstalldirs "../'$$j'/&",' | $(SHELL) ; } && \
1410           { find . -name '*.*da' | sed 's,.*,$(LN) -f "&" "../'$$j'/&",' | $(SHELL) ; } ; \
1411         done
1412
1413 @if gcc-bootstrap
1414 do-distclean: distclean-stage1
1415 @endif gcc-bootstrap
1416
1417 # --------------------------------------
1418 # Dependencies between different modules
1419 # --------------------------------------
1420
1421 # Generic dependencies for target modules on host stuff, especially gcc
1422 [+ FOR target_modules +][+ IF bootstrap +]
1423 @if gcc-bootstrap[+ FOR bootstrap_stage +]
1424 configure-stage[+id+]-target-[+module+]: maybe-all-stage[+id+]-gcc[+ ENDFOR +]
1425 @endif gcc-bootstrap[+ ENDIF bootstrap +]
1426 configure-target-[+module+]: maybe-all-gcc
1427 [+ ENDFOR target_modules +]
1428
1429 [+ FOR lang_env_dependencies +]
1430 configure-target-[+module+]: maybe-all-target-newlib maybe-all-target-libgloss
1431 [+ IF cxx +]configure-target-[+module+]: maybe-all-target-libstdc++-v3
1432 [+ ENDIF cxx +][+ ENDFOR lang_env_dependencies +]
1433
1434 # There are two types of dependencies here: 'hard' dependencies, where one
1435 # module simply won't build without the other; and 'soft' dependencies, where
1436 # if the depended-on module is missing, the depending module will do without
1437 # or find a substitute somewhere (perhaps installed).  Soft dependencies
1438 # are made here to depend on a 'maybe-' target.  If you're not sure,
1439 # it's safer to use a soft dependency.
1440
1441 [+ ;; These Scheme functions build the bulk of the dependencies.
1442    ;; dep-target builds a string like "maybe-all-MODULE_KIND-gcc",
1443    ;; where "maybe-" is only included if HARD is true, and all-gcc
1444    ;; is taken from VAR-NAME.
1445    (define dep-target (lambda (module-kind var-name hard)
1446       (string-append
1447          (if hard "" "maybe-")
1448          (dep-subtarget var-name)
1449          module-kind
1450          (dep-module var-name)
1451       )))
1452
1453    ;; make-dep builds a dependency from the MODULE and ON AutoGen vars.
1454    (define make-dep (lambda (module-kind on-kind)
1455       (string-append
1456          (dep-target module-kind "module" #t) ": "
1457          (dep-target on-kind "on" (exist? "hard")))))
1458
1459    ;; dep-subtarget extracts everything up to the first dash in the given
1460    ;; AutoGen variable, for example it extracts "all-" out of "all-gcc".
1461    (define dep-subtarget (lambda (var-name)
1462       (substring (get var-name) 0 (+ 1 (string-index (get var-name) #\-)))))
1463
1464    ;; dep-module extracts everything up to the first dash in the given
1465    ;; AutoGen variable, for example it extracts "gcc" out of "all-gcc".
1466    (define dep-module (lambda (var-name)
1467       (substring (get var-name) (+ 1 (string-index (get var-name) #\-)))))
1468
1469    ;; dep-stage builds a string for the prefix of a bootstrap stage.
1470    (define dep-stage (lambda ()
1471       (string-append
1472          "stage"
1473          (get "id")
1474          "-")))
1475
1476    ;; dep-maybe is the same as the AutoGen expression "- hard 'maybe-'"
1477    ;; but is written in Scheme.
1478    (define dep-maybe (lambda ()
1479       (if (exist? "hard") "" "maybe-")))
1480
1481    ;; dep-kind returns "normal" if the dependency is on an "install" target,
1482    ;; or if either module is not bootstrapped.  It returns "bootstrap" for
1483    ;; configure or build dependencies between bootstrapped modules; it returns
1484    ;; "prebootstrap" for configure or build dependencies of bootstrapped
1485    ;; modules on a build module (e.g. all-gcc on all-build-bison).  All this
1486    ;; is only necessary for host modules.
1487    (define dep-kind (lambda ()
1488       (if (and (hash-ref boot-modules (dep-module "module"))
1489                (=* (dep-module "on") "build-"))
1490           "prebootstrap"
1491
1492           (if (or (= (dep-subtarget "on") "install-")
1493                   (not (hash-ref boot-modules (dep-module "module")))
1494                   (not (hash-ref boot-modules (dep-module "on"))))
1495               "normal"
1496               "bootstrap"))))
1497
1498    ;; We now build the hash table that is used by dep-kind.
1499    (define boot-modules (make-hash-table 113))
1500 +]
1501
1502 [+ FOR host_modules +][+
1503    (if (exist? "bootstrap")
1504        (hash-create-handle! boot-modules (get "module") #t))
1505    "" +][+ ENDFOR host_modules +]
1506 [+ FOR target_modules +][+
1507    (if (exist? "bootstrap")
1508        (hash-create-handle! boot-modules (string-append "target-" (get "module")) #t))
1509    "" +][+ ENDFOR target_modules +]
1510
1511 # With all the machinery above in place, it is pretty easy to generate
1512 # dependencies.  Host dependencies are a bit more complex because we have
1513 # to check for bootstrap/prebootstrap dependencies.  To resolve
1514 # prebootstrap dependencies, prebootstrap modules are gathered in
1515 # a hash table.
1516 [+ FOR dependencies +][+ (make-dep "" "") +]
1517 [+ CASE (dep-kind) +]
1518 [+ == "prebootstrap"
1519      +][+ FOR bootstrap_stage +]
1520 [+ (make-dep (dep-stage) "") +][+
1521        ENDFOR bootstrap_stage +]
1522 all-prebootstrap: [+ (dep-target "" "on" (exist? "hard")) +]
1523 [+ == "bootstrap"
1524      +][+ FOR bootstrap_stage +]
1525 [+ (make-dep (dep-stage) (dep-stage)) +][+
1526        ENDFOR bootstrap_stage +]
1527 [+ ESAC +][+
1528 ENDFOR dependencies +]
1529
1530 # Non-toplevel bootstrap rules must depend on several packages, to be built
1531 # before gcc.  Another wart that will go away, hopefully soon.
1532 @if gcc-no-bootstrap
1533 [+ FOR host_modules +][+
1534    IF (and (not (= (get "module") "gcc"))
1535            (hash-ref boot-modules (get "module"))) +]
1536 all-prebootstrap: maybe-all-[+module+][+
1537    ENDIF +][+
1538 ENDFOR host_modules +]
1539 @endif gcc-no-bootstrap
1540
1541 CONFIGURE_GDB_TK = @CONFIGURE_GDB_TK@
1542 GDB_TK = @GDB_TK@
1543 INSTALL_GDB_TK = @INSTALL_GDB_TK@
1544 configure-gdb: $(CONFIGURE_GDB_TK)
1545 all-gdb: $(gdbnlmrequirements) $(GDB_TK)
1546 install-gdb: $(INSTALL_GDB_TK)
1547
1548 # Serialization dependencies.  Host configures don't work well in parallel to
1549 # each other, due to contention over config.cache.  Target configures and 
1550 # build configures are similar.
1551 @serialization_dependencies@
1552
1553 # --------------------------------
1554 # Regenerating top level configury
1555 # --------------------------------
1556
1557 # Rebuilding Makefile.in, using autogen.
1558 AUTOGEN = autogen
1559 $(srcdir)/Makefile.in: @MAINT@ $(srcdir)/Makefile.tpl $(srcdir)/Makefile.def
1560         cd $(srcdir) && $(AUTOGEN) Makefile.def
1561
1562 # Rebuilding Makefile.
1563 Makefile: $(srcdir)/Makefile.in config.status
1564         CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
1565
1566 config.status: configure
1567         CONFIG_SHELL="$(SHELL)" $(SHELL) ./config.status --recheck
1568
1569 # Rebuilding configure.
1570 AUTOCONF = autoconf
1571 $(srcdir)/configure: @MAINT@ $(srcdir)/configure.in $(srcdir)/config/acx.m4
1572         cd $(srcdir) && $(AUTOCONF)
1573
1574 # ------------------------------
1575 # Special directives to GNU Make
1576 # ------------------------------
1577
1578 # Don't pass command-line variables to submakes.
1579 .NOEXPORT:
1580 MAKEOVERRIDES=
1581
1582 # end of Makefile.in