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