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