From 33e3141db12836305e2f3cf54ec7958a05e5ac37 Mon Sep 17 00:00:00 2001
From: bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Sat, 24 Apr 2004 06:42:54 +0000
Subject: [PATCH] 2004-04-23  Paolo Bonzini  <bonzini@gnu.org>

	* Makefile.tpl (all-stage1-gcc, all-stage2-gcc, all-stage3-gcc):
	Always relocate gcc and prev-gcc to the original names, even
	if the build fails.
	(new-cleanstrap, new-restage1, new-restage2, new-restage3):
	New targets.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@81130 138bc75d-0d04-0410-961f-82ee72b054a4
---
 ChangeLog    |  8 ++++++++
 Makefile.in  | 41 ++++++++++++++++++++++++++++++++++-------
 Makefile.tpl | 40 +++++++++++++++++++++++++++++++++-------
 3 files changed, 75 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6000a4328e45..5101b2a3a240 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-04-23  Paolo Bonzini  <bonzini@gnu.org>
+
+	* Makefile.tpl (all-stage1-gcc, all-stage2-gcc, all-stage3-gcc):
+	Always relocate gcc and prev-gcc to the original names, even
+	if the build fails.
+	(new-cleanstrap, new-restage1, new-restage2, new-restage3):
+	New targets.
+
 2004-04-23  Laurent GUERBY <laurent@guerby.net>
 
 	* MAINTAINERS: Update my email address.
diff --git a/Makefile.in b/Makefile.in
index 354b7d9f7275..55ec68c5c587 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -24112,11 +24112,11 @@ all-stage1-gcc: configure-stage1-gcc prebootstrap
 	mv stage1-gcc gcc ; \
 	cd gcc && \
 	$(MAKE) $(GCC_FLAGS_TO_PASS) \
-		CFLAGS="$(STAGE1_CFLAGS)" \
-		|| exit 1 ; \
+		CFLAGS="$(STAGE1_CFLAGS)" && $(STAMP) ../all-stage1-gcc ; \
+	result=$$? ; \
 	cd .. ; \
 	mv gcc stage1-gcc ; \
-	$(STAMP) all-stage1-gcc
+	exit $$result
 
 # TODO: Deal with STAGE_PREFIX (which is only for ada, incidentally)
 # Possibly pass --enable-werror-always (depending on --enable-werror);
@@ -24188,11 +24188,12 @@ all-stage2-gcc: all-stage1-gcc configure-stage2-gcc
 		CC="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/" \
 		CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/" \
 		STAGE_PREFIX=$$r/prev-gcc/ \
-		$(POSTSTAGE1_FLAGS_TO_PASS) || exit 1 ; \
+		$(POSTSTAGE1_FLAGS_TO_PASS) && $(STAMP) ../all-stage2-gcc ; \
+	result=$$? ; \
 	cd .. ; \
 	mv prev-gcc stage1-gcc ; \
 	mv gcc stage2-gcc ; \
-	$(STAMP) all-stage2-gcc
+	exit $$result
 
 configure-stage3-gcc: all-stage2-gcc
 	echo configure-stage3-gcc > stage_last ; \
@@ -24255,11 +24256,12 @@ all-stage3-gcc: all-stage2-gcc configure-stage3-gcc
 		CC="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/" \
 		CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/" \
 		STAGE_PREFIX=$$r/prev-gcc/ \
-		$(POSTSTAGE1_FLAGS_TO_PASS) || exit 1 ; \
+		$(POSTSTAGE1_FLAGS_TO_PASS) && $(STAMP) ../all-stage3-gcc \
+	result=$$? ; \
 	cd .. ; \
 	mv prev-gcc stage2-gcc ; \
 	mv gcc stage3-gcc ; \
-	$(STAMP) all-stage3-gcc
+	exit $$result
 
 # We only want to compare .o files, so set this!
 objext = .o
@@ -24294,6 +24296,31 @@ new-bootstrap: compare
 	$(MAKE) all ; \
 	mv gcc stage3-gcc
 
+new-cleanstrap:
+	rm -rf configure-stage1-gcc all-stage1-gcc stage1-gcc \
+	  configure-stage2-gcc all-stage2-gcc stage2-gcc \
+	  configure-stage3-gcc all-stage3-gcc stage3-gcc \
+	  compare
+	$(MAKE) new-bootstrap
+
+new-restage1:
+	rm -rf configure-stage1-gcc all-stage1-gcc stage1-gcc/Makefile \
+	  configure-stage2-gcc all-stage2-gcc stage2-gcc \
+	  configure-stage3-gcc all-stage3-gcc stage3-gcc \
+	  compare
+	$(MAKE) all-stage1-gcc
+
+new-restage2: all-stage1-gcc
+	rm -rf configure-stage2-gcc all-stage2-gcc stage2-gcc/Makefile \
+	  configure-stage3-gcc all-stage3-gcc stage3-gcc \
+	  compare
+	$(MAKE) all-stage2-gcc
+
+new-restage3: all-stage2-gcc
+	rm -rf configure-stage3-gcc all-stage3-gcc stage3-gcc/Makefile \
+	  compare
+	$(MAKE) compare
+
 # --------------------------------------
 # Dependencies between different modules
 # --------------------------------------
diff --git a/Makefile.tpl b/Makefile.tpl
index 7ae10deab3b4..d38061616883 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -1377,11 +1377,11 @@ all-stage1-gcc: configure-stage1-gcc prebootstrap
 	mv stage1-gcc gcc ; \
 	cd gcc && \
 	$(MAKE) $(GCC_FLAGS_TO_PASS) \
-		CFLAGS="$(STAGE1_CFLAGS)" \
-		|| exit 1 ; \
+		CFLAGS="$(STAGE1_CFLAGS)" && $(STAMP) ../all-stage1-gcc ; \
+	result=$$? ; \
 	cd .. ; \
 	mv gcc stage1-gcc ; \
-	$(STAMP) all-stage1-gcc
+	exit $$result
 
 # TODO: Deal with STAGE_PREFIX (which is only for ada, incidentally)
 # Possibly pass --enable-werror-always (depending on --enable-werror);
@@ -1453,11 +1453,12 @@ all-stage2-gcc: all-stage1-gcc configure-stage2-gcc
 		CC="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/" \
 		CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/" \
 		STAGE_PREFIX=$$r/prev-gcc/ \
-		$(POSTSTAGE1_FLAGS_TO_PASS) || exit 1 ; \
+		$(POSTSTAGE1_FLAGS_TO_PASS) && $(STAMP) ../all-stage2-gcc ; \
+	result=$$? ; \
 	cd .. ; \
 	mv prev-gcc stage1-gcc ; \
 	mv gcc stage2-gcc ; \
-	$(STAMP) all-stage2-gcc
+	exit $$result
 
 configure-stage3-gcc: all-stage2-gcc
 	echo configure-stage3-gcc > stage_last ; \
@@ -1520,11 +1521,12 @@ all-stage3-gcc: all-stage2-gcc configure-stage3-gcc
 		CC="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/" \
 		CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/" \
 		STAGE_PREFIX=$$r/prev-gcc/ \
-		$(POSTSTAGE1_FLAGS_TO_PASS) || exit 1 ; \
+		$(POSTSTAGE1_FLAGS_TO_PASS) && $(STAMP) ../all-stage3-gcc \
+	result=$$? ; \
 	cd .. ; \
 	mv prev-gcc stage2-gcc ; \
 	mv gcc stage3-gcc ; \
-	$(STAMP) all-stage3-gcc
+	exit $$result
 
 # We only want to compare .o files, so set this!
 objext = .o
@@ -1559,6 +1561,30 @@ new-bootstrap: compare
 	$(MAKE) all ; \
 	mv gcc stage3-gcc
 
+new-cleanstrap:
+	rm -rf configure-stage1-gcc all-stage1-gcc stage1-gcc \
+	  configure-stage2-gcc all-stage2-gcc stage2-gcc \
+	  configure-stage3-gcc all-stage3-gcc stage3-gcc \
+	  compare
+	$(MAKE) new-bootstrap
+
+new-restage1:
+	rm -rf all-stage1-gcc \
+	  configure-stage2-gcc all-stage2-gcc stage2-gcc \
+	  configure-stage3-gcc all-stage3-gcc stage3-gcc \
+	  compare
+	$(MAKE) all-stage1-gcc
+
+new-restage2: all-stage1-gcc
+	rm -rf all-stage2-gcc \
+	  configure-stage3-gcc all-stage3-gcc stage3-gcc \
+	  compare
+	$(MAKE) all-stage2-gcc
+
+new-restage3: all-stage2-gcc
+	rm -rf all-stage3-gcc compare
+	$(MAKE) compare
+
 # --------------------------------------
 # Dependencies between different modules
 # --------------------------------------
-- 
GitLab