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