+# Other targets (dvi, info, etc.)
+[+ FOR recursive_targets +]
+.PHONY: maybe-[+make_target+]-gcc [+make_target+]-gcc
+maybe-[+make_target+]-gcc:
+@if gcc
+maybe-[+make_target+]-gcc: [+make_target+]-gcc
+[+make_target+]-gcc: [+
+ FOR depend +]\
+ [+depend+]-gcc [+
+ ENDFOR depend +]
+ @[ -f ./gcc/Makefile ] || exit 0; \
+ r=`${PWD_COMMAND}`; export r; \
+ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+ $(SET_LIB_PATH) \
+ for flag in $(EXTRA_GCC_FLAGS); do \
+ eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+ done; \
+ $(GCC_HOST_EXPORTS) \
+ echo "Doing [+make_target+] in gcc" ; \
+ (cd gcc && \
+ $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+ "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+ "RANLIB=$${RANLIB}" \
+ "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" \
+ [+make_target+]) \
+ || exit 1
+@endif gcc
+
+[+ ENDFOR recursive_targets +]
+
+# ---------------------
+# GCC bootstrap support
+# ---------------------
+
+# We track the current stage (the one in 'gcc') in the stage_last file.
+# We name the build directories for the various stages "stage1-gcc",
+# "stage2-gcc","stage3-gcc", etc.
+
+# Since the 'compare' process will fail (on debugging information) if any
+# directory names are different, we need to link the gcc directory for
+# the previous stage to a constant name ('gcc-prev'), and to make the name of
+# the build directories constant as well. For the latter, we use naked names
+# like 'gcc', because the scripts in that directory assume it. We use
+# mv on platforms where symlinks to directories do not work or are not
+# reliable.
+
+# At the end of the bootstrap, a symlink to 'stage3-gcc' named 'gcc' must
+# be kept, so that libraries can find it. Ick!
+
+# It would be best to preinstall gcc into a staging area (and in the
+# future, gather there all prebootstrap packages). This would allow
+# assemblers and linkers can be bootstrapped as well as the compiler
+# (both in a combined tree, or separately). This however requires some
+# change to the gcc driver, again in order to avoid comparison failures.
+
+# Bugs: This is almost certainly not parallel-make safe.
+
+# 'touch' doesn't work right on some platforms.
+STAMP = echo timestamp >
+
+# Only build the C compiler for stage1, because that is the only one that
+# we can guarantee will build with the native compiler, and also it is the
+# only thing useful for building stage2. STAGE1_CFLAGS (via CFLAGS),
+# MAKEINFO and MAKEINFOFLAGS are explicitly passed here to make them
+# overrideable (for a bootstrap build stage1 also builds gcc.info).
+
+STAGE1_CFLAGS=@stage1_cflags@
+STAGE1_LANGUAGES=@stage1_languages@
+
+# We only want to compare .o files, so set this!
+objext = .o
+
+# Real targets act phony if they depend on phony targets; this hack
+# prevents gratuitous rebuilding of stage 1.
+prebootstrap:
+ $(MAKE) all-bootstrap
+ $(STAMP) prebootstrap
+
+# Flags to pass to stage2 and later makes.
+BOOT_CFLAGS= -g -O2
+POSTSTAGE1_FLAGS_TO_PASS = \
+ CFLAGS="$(BOOT_CFLAGS)" \
+ ADAC="\$$(CC)"
+
+# For stage 1:
+# * We force-disable intermodule optimizations, even if
+# --enable-intermodule was passed, since the installed compiler probably
+# can't handle them. Luckily, autoconf always respects
+# the last argument when conflicting --enable arguments are passed.
+# * Likewise, we force-disable coverage flags, since the installed compiler
+# probably has never heard of them.
+# * We build only C (and possibly Ada).
+
+[+ FOR bootstrap-stage +]
+.PHONY: new-stage[+id+]-start new-stage[+id+]-end
+
+new-stage[+id+]-start:
+ [ -f stage_last ] && $(MAKE) new-`cat stage_last`-end || :
+ echo stage[+id+] > stage_last ; \
+ [ -d stage[+id+]-gcc ] || mkdir stage[+id+]-gcc; \
+ set stage[+id+]-gcc gcc ; @CREATE_LINK_TO_DIR@ [+ IF prev +] ; \
+ set stage[+prev+]-gcc prev-gcc ; @CREATE_LINK_TO_DIR@ [+ ENDIF prev +]
+
+new-stage[+id+]-end:
+ rm -f stage_last ; \
+ set gcc stage[+id+]-gcc ; @UNDO_LINK_TO_DIR@ [+ IF prev +] ; \
+ set prev-gcc stage[+prev+]-gcc ; @UNDO_LINK_TO_DIR@ [+ ENDIF prev +]
+
+# Bubble a bugfix through all the stages up to stage [+id+]. They
+# are remade, but not reconfigured. The next stage (if any) will not
+# be reconfigured as well.
+.PHONY: new-stage[+id+]-bubble
+new-stage[+id+]-bubble: [+ IF prev +]new-stage[+prev+]-bubble[+ ENDIF +]
+ @if [ -f all-stage[+id+]-gcc ] ; then \
+ echo Remaking stage [+id+] ; \
+ rm -f all-stage[+id+]-gcc ; \
+ $(MAKE) all-stage[+id+]-gcc [+ IF next +] && \
+ if [ -f configure-stage[+next+]-gcc ] ; then \
+ $(STAMP) configure-stage[+next+]-gcc ; \
+ fi [+ ENDIF next +]; \
+ else \
+ $(MAKE) all-stage[+id+]-gcc ; \
+ fi
+
+configure-stage[+id+]-gcc: [+ IF prev +] all-stage[+prev+]-gcc [+
+ ELSE +] prebootstrap [+ ENDIF prev +]
+ $(MAKE) new-stage[+id+]-start
+ @if [ -f stage[+id+]-gcc/Makefile ] ; then \
+ $(STAMP) configure-stage[+id+]-gcc ; \
+ exit 0; \
+ else \
+ true ; \
+ fi ; \
+ r=`${PWD_COMMAND}`; export r; \
+ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; [+ IF prev +] \
+ $(STAGE_HOST_EXPORTS) [+ ELSE prev +] \
+ $(GCC_HOST_EXPORTS) [+ ENDIF prev +] \
+ echo Configuring stage [+id+] in gcc ; \
+ cd gcc || exit 1; \
+ case $(srcdir) in \
+ \.) \
+ srcdiroption="--srcdir=."; \
+ libsrcdir=".";; \
+ /* | [A-Za-z]:[\\/]*) \
+ srcdiroption="--srcdir=$(srcdir)/gcc"; \
+ libsrcdir="$$s/gcc";; \
+ *) \
+ srcdiroption="--srcdir=../$(srcdir)/gcc"; \
+ libsrcdir="$$s/gcc";; \
+ esac; \
+ $(SHELL) $${libsrcdir}/configure \
+ $(HOST_CONFIGARGS) $${srcdiroption} \
+ [+extra_configure_flags+] && \
+ $(STAMP) ../configure-stage[+id+]-gcc
+
+all-stage[+id+]-gcc: configure-stage[+id+]-gcc
+ $(MAKE) new-stage[+id+]-start
+ @r=`${PWD_COMMAND}`; export r; \
+ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; [+ IF prev +] \
+ $(STAGE_HOST_EXPORTS) [+ ELSE prev +] \
+ $(GCC_HOST_EXPORTS) [+ ENDIF prev +] \
+ cd gcc && \
+ $(MAKE) $(GCC_FLAGS_TO_PASS) [+ IF prev +] \
+ CC="$${CC}" CC_FOR_BUILD="${CC_FOR_BUILD}" \
+ STAGE_PREFIX=$$r/stage[+prev+]-gcc/ [+ ENDIF prev +] \
+ [+extra_make_flags+] && $(STAMP) ../all-stage[+id+]-gcc
+
+[+ IF compare-target +]
+[+compare-target+]: all-stage[+id+]-gcc
+ [ -f stage_last ] && $(MAKE) new-`cat stage_last`-end || :
+ @r=`${PWD_COMMAND}`; export r; \
+ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+ rm -f .bad_compare ; \
+ cd stage[+id+]-gcc; \
+ files=`find . -name "*$(objext)" -print` ; \
+ cd .. ; \
+ for file in $${files} ; do \
+ f1=$$r/stage[+prev+]-gcc/$$file; f2=$$r/stage[+id+]-gcc/$$file; \
+ @do_compare@ > /dev/null 2>&1; \
+ test $$? -eq 1 && echo $$file differs >> .bad_compare || true; \
+ done ; \
+ if [ -f .bad_compare ]; then \
+ echo "Bootstrap comparison failure!"; \
+ cat .bad_compare; \
+ exit 1; \
+ else \
+ true; \
+ fi ; \
+ $(STAMP) [+compare-target+]
+[+ ENDIF compare-target +]
+
+[+ IF bootstrap-target +]
+.PHONY: [+bootstrap-target+]
+[+bootstrap-target+]:
+ $(MAKE) new-stage[+id+]-bubble [+
+ IF compare-target +] [+compare-target+] [+
+ ENDIF compare-target +] \
+ new-stage[+id+]-start all new-stage[+id+]-end
+[+ ENDIF bootstrap-target +]
+
+.PHONY: new-restage[+id+] distclean-stage[+id+]
+
+distclean-stage[+id+]: [+ IF next +] distclean-stage[+next+] [+ ENDIF next +]
+ [ -f stage_last ] && $(MAKE) new-`cat stage_last`-end || :
+ rm -rf configure-stage[+id+]-gcc all-stage[+id+]-gcc stage[+id+]-gcc [+
+ IF compare-target +][+compare-target+] [+ ENDIF compare-target +]
+
+new-restage[+id+]: [+ IF next +] distclean-stage[+next+] [+ ENDIF next +]
+ rm -rf all-stage[+id+]-gcc [+
+ IF compare-target +][+compare-target+] [+ ENDIF compare-target +]
+ $(MAKE) [+
+ IF compare-target +][+compare-target+] [+
+ ELSE +] all-stage[+id+]-gcc [+ ENDIF compare-target +]
+
+[+ IF cleanstrap-target +]
+.PHONY: [+cleanstrap-target+]
+[+cleanstrap-target+]: distclean-stage1 [+bootstrap-target+]
+[+ ENDIF cleanstrap-target +]
+
+[+ ENDFOR bootstrap-stage +]
+