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