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