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