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