public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 09/10] Use prologue and epilogue Makefile fragments
Date: Thu,  8 Apr 2021 14:33:11 -0600	[thread overview]
Message-ID: <20210408203312.2938165-10-tom@tromey.com> (raw)
In-Reply-To: <20210408203312.2938165-1-tom@tromey.com>

I looked at converting the sim Makefiles to use new-style
config.status invocations, and found that this wasn't really possible
due to the unusual way that the sim constructed Makefile.  This was
done via a sequence of several config.status outputs, with the
intermediate results being removed.

This patch changes the sim to use the GNU make "include" feature
instead.  Variable substitutions are done in a prologue, and each
sim's Makefile is created in the most straightforward way.

2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/arm/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/avr/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/bfin/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/bpf/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/common/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Make-common.in: Remove.
	* epilogue.mk: New file, from Make-common.in.
	(prologue.mk): New target.
	(Makefile, config.status, stamp-h): Use new style.
	(.gdbinit): Likewise; uncomment dependencies.
	* prologue.mk.in: New file, from Make-common.in.

sim/cr16/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/cris/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/d10v/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/erc32/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/example-synacor/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/frv/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/ft32/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/h8300/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/iq2000/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/lm32/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/m32c/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/m32r/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/m68hc11/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/mcore/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/microblaze/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/mips/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/mn10300/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/moxie/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/msp430/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/or1k/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/pru/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/riscv/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/rl78/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/rx/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/sh/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.

sim/v850/ChangeLog
2021-04-08  Tom Tromey  <tom@tromey.com>

	* Makefile.in: Include prologue and epilogue.
	* configure: Rebuild.
---
 sim/aarch64/ChangeLog                      |   5 +
 sim/aarch64/Makefile.in                    |   4 +-
 sim/aarch64/configure                      |  20 +-
 sim/arm/ChangeLog                          |   5 +
 sim/arm/Makefile.in                        |   4 +-
 sim/arm/configure                          |  20 +-
 sim/avr/ChangeLog                          |   5 +
 sim/avr/Makefile.in                        |   4 +-
 sim/avr/configure                          |  20 +-
 sim/bfin/ChangeLog                         |   5 +
 sim/bfin/Makefile.in                       |   4 +-
 sim/bfin/configure                         |  20 +-
 sim/bpf/ChangeLog                          |   5 +
 sim/bpf/Makefile.in                        |   4 +-
 sim/bpf/configure                          |  20 +-
 sim/common/ChangeLog                       |   9 +
 sim/common/{Make-common.in => epilogue.mk} | 229 +--------------------
 sim/common/prologue.mk.in                  | 205 ++++++++++++++++++
 sim/cr16/ChangeLog                         |   5 +
 sim/cr16/Makefile.in                       |   4 +-
 sim/cr16/configure                         |  20 +-
 sim/cris/ChangeLog                         |   5 +
 sim/cris/Makefile.in                       |   4 +-
 sim/cris/configure                         |  20 +-
 sim/d10v/ChangeLog                         |   5 +
 sim/d10v/Makefile.in                       |   4 +-
 sim/d10v/configure                         |  20 +-
 sim/erc32/ChangeLog                        |   5 +
 sim/erc32/Makefile.in                      |   4 +-
 sim/erc32/configure                        |  20 +-
 sim/example-synacor/ChangeLog              |   5 +
 sim/example-synacor/Makefile.in            |   4 +-
 sim/example-synacor/configure              |  20 +-
 sim/frv/ChangeLog                          |   5 +
 sim/frv/Makefile.in                        |   4 +-
 sim/frv/configure                          |  20 +-
 sim/ft32/ChangeLog                         |   5 +
 sim/ft32/Makefile.in                       |   5 +-
 sim/ft32/configure                         |  20 +-
 sim/h8300/ChangeLog                        |   5 +
 sim/h8300/Makefile.in                      |   4 +-
 sim/h8300/configure                        |  20 +-
 sim/iq2000/ChangeLog                       |   5 +
 sim/iq2000/Makefile.in                     |   4 +-
 sim/iq2000/configure                       |  20 +-
 sim/lm32/ChangeLog                         |   5 +
 sim/lm32/Makefile.in                       |   4 +-
 sim/lm32/configure                         |  20 +-
 sim/m32c/ChangeLog                         |   5 +
 sim/m32c/Makefile.in                       |   4 +-
 sim/m32c/configure                         |  20 +-
 sim/m32r/ChangeLog                         |   5 +
 sim/m32r/Makefile.in                       |   4 +-
 sim/m32r/configure                         |  20 +-
 sim/m4/sim_ac_output.m4                    |  14 +-
 sim/m68hc11/ChangeLog                      |   5 +
 sim/m68hc11/Makefile.in                    |   4 +-
 sim/m68hc11/configure                      |  20 +-
 sim/mcore/ChangeLog                        |   5 +
 sim/mcore/Makefile.in                      |   4 +-
 sim/mcore/configure                        |  20 +-
 sim/microblaze/ChangeLog                   |   5 +
 sim/microblaze/Makefile.in                 |   4 +-
 sim/microblaze/configure                   |  20 +-
 sim/mips/ChangeLog                         |   5 +
 sim/mips/Makefile.in                       |   4 +-
 sim/mips/configure                         |  20 +-
 sim/mn10300/ChangeLog                      |   5 +
 sim/mn10300/Makefile.in                    |   4 +-
 sim/mn10300/configure                      |  20 +-
 sim/moxie/ChangeLog                        |   5 +
 sim/moxie/Makefile.in                      |   4 +-
 sim/moxie/configure                        |  20 +-
 sim/msp430/ChangeLog                       |   5 +
 sim/msp430/Makefile.in                     |   4 +-
 sim/msp430/configure                       |  20 +-
 sim/or1k/ChangeLog                         |   5 +
 sim/or1k/Makefile.in                       |   4 +-
 sim/or1k/configure                         |  20 +-
 sim/pru/ChangeLog                          |   5 +
 sim/pru/Makefile.in                        |   5 +-
 sim/pru/configure                          |  20 +-
 sim/riscv/ChangeLog                        |   5 +
 sim/riscv/Makefile.in                      |   5 +-
 sim/riscv/configure                        |  20 +-
 sim/rl78/ChangeLog                         |   5 +
 sim/rl78/Makefile.in                       |   4 +-
 sim/rl78/configure                         |  20 +-
 sim/rx/ChangeLog                           |   5 +
 sim/rx/Makefile.in                         |   4 +-
 sim/rx/configure                           |  20 +-
 sim/sh/ChangeLog                           |   5 +
 sim/sh/Makefile.in                         |   4 +-
 sim/sh/configure                           |  20 +-
 sim/v850/ChangeLog                         |   5 +
 sim/v850/Makefile.in                       |   4 +-
 sim/v850/configure                         |  20 +-
 97 files changed, 570 insertions(+), 789 deletions(-)
 rename sim/common/{Make-common.in => epilogue.mk} (67%)
 create mode 100644 sim/common/prologue.mk.in

diff --git a/sim/aarch64/Makefile.in b/sim/aarch64/Makefile.in
index 4f337003738..0207ac8296b 100644
--- a/sim/aarch64/Makefile.in
+++ b/sim/aarch64/Makefile.in
@@ -19,7 +19,7 @@
 ### You should have received a copy of the GNU General Public License
 ### along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_EXTRA_LIBS = -lm
 
@@ -31,5 +31,5 @@ SIM_OBJS = \
 	memory.o \
 	sim-resume.o \
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
diff --git a/sim/aarch64/configure b/sim/aarch64/configure
index 70c5488a2de..f0883930d3d 100755
--- a/sim/aarch64/configure
+++ b/sim/aarch64/configure
@@ -12027,13 +12027,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13021,10 +13019,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14220,15 +14217,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/arm/Makefile.in b/sim/arm/Makefile.in
index 29166952ce1..f88a6764dad 100644
--- a/sim/arm/Makefile.in
+++ b/sim/arm/Makefile.in
@@ -15,7 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_EXTRA_CFLAGS = -DMODET
 SIM_EXTRA_LIBS = -lm
@@ -27,7 +27,7 @@ SIM_OBJS = \
 	armvirt.o thumbemu.o \
 	armcopro.o maverick.o iwmmxt.o
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 armemu26.o: armemu.c
 	$(COMPILE) $(srcdir)/armemu.c
diff --git a/sim/arm/configure b/sim/arm/configure
index a73ba1597a8..67168b49e5e 100755
--- a/sim/arm/configure
+++ b/sim/arm/configure
@@ -12023,13 +12023,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13017,10 +13015,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14216,15 +14213,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/avr/Makefile.in b/sim/avr/Makefile.in
index 92d0d88e3f0..525e156fb62 100644
--- a/sim/avr/Makefile.in
+++ b/sim/avr/Makefile.in
@@ -14,11 +14,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_OBJS = \
 	interp.o \
 	$(SIM_NEW_COMMON_OBJS) \
 	sim-resume.o
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
diff --git a/sim/avr/configure b/sim/avr/configure
index f492aa553b0..9edf4362082 100755
--- a/sim/avr/configure
+++ b/sim/avr/configure
@@ -12023,13 +12023,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13017,10 +13015,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14216,15 +14213,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/bfin/Makefile.in b/sim/bfin/Makefile.in
index a5c16764682..437699392b4 100644
--- a/sim/bfin/Makefile.in
+++ b/sim/bfin/Makefile.in
@@ -18,7 +18,7 @@
 # This selects the bfin newlib/libgloss syscall definitions.
 NL_TARGET = -DNL_TARGET_bfin
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_OBJS = \
 	$(SIM_NEW_COMMON_OBJS) \
@@ -32,7 +32,7 @@ SIM_OBJS = \
 SIM_EXTRA_CFLAGS = @SDL_CFLAGS@
 SIM_EXTRA_LIBS = @SDL_LIBS@ -lm
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 $(srcdir)/linux-fixed-code.h: @MAINTAINER_MODE_TRUE@ $(srcdir)/linux-fixed-code.s Makefile.in
 	$(AS_FOR_TARGET) $(srcdir)/linux-fixed-code.s -o linux-fixed-code.o
diff --git a/sim/bfin/configure b/sim/bfin/configure
index 49f1c8ba9dd..bb5dc6d1840 100755
--- a/sim/bfin/configure
+++ b/sim/bfin/configure
@@ -12498,13 +12498,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13492,10 +13490,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14691,15 +14688,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/bpf/Makefile.in b/sim/bpf/Makefile.in
index b29b3c02dc0..a52a0354a0e 100644
--- a/sim/bpf/Makefile.in
+++ b/sim/bpf/Makefile.in
@@ -16,7 +16,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 CGEN_STD_OBJS = cgen-run.o cgen-scache.o cgen-trace.o cgen-utils.o
 BPF_GEN_OBJS = arch.o cpu.o \
@@ -40,7 +40,7 @@ SIM_EXTRA_DEPS = \
 
 SIM_EXTRA_CLEAN = bpf-clean
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 # cgen support, enable with --enable-cgen-maint
 CGEN_MAINT = ; @true
diff --git a/sim/bpf/configure b/sim/bpf/configure
index 76524c23c09..4a8109f1bb6 100755
--- a/sim/bpf/configure
+++ b/sim/bpf/configure
@@ -12160,13 +12160,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13154,10 +13152,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14353,15 +14350,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/common/Make-common.in b/sim/common/epilogue.mk
similarity index 67%
rename from sim/common/Make-common.in
rename to sim/common/epilogue.mk
index d76b3a681f6..a3806cfb993 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/epilogue.mk
@@ -15,213 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# This Makefile fragment consists of two separate parts.
-# They are merged into the final Makefile at points denoted by
-# "## COMMON_PRE_CONFIG_FRAG" and "## COMMON_POST_CONFIG_FRAG".
-#
-# The target Makefile should look like:
-#
-#># Copyright blah blah
-#>
-#>## COMMON_PRE_CONFIG_FRAG
-#>
-#># Any overrides necessary for the SIM_FOO config vars.
-#>SIM_FOO = ...
-#>
-#>## COMMON_POST_CONFIG_FRAG
-#>
-#># Rules to build target specific .o's.
-
-## COMMON_PRE_CONFIG_FRAG
-
-VPATH = @srcdir@:$(srccom)
-srcdir = @srcdir@
-srccom = $(srcdir)/../common
-srcroot = $(srcdir)/../..
-srcsim = $(srcdir)/..
-
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-host_alias = @host_alias@
-target_alias = @target_alias@
-program_transform_name = @program_transform_name@
-bindir = @bindir@
-
-libdir = @libdir@
-tooldir = $(libdir)/$(target_alias)
-
-datadir = @datadir@
-datarootdir = @datarootdir@
-mandir = @mandir@
-man1dir = $(mandir)/man1
-infodir = @infodir@
-includedir = @includedir@
-
-lt_cv_dlopen_libs = @lt_cv_dlopen_libs@
-# This can be referenced by the gettext configuration code.
-top_builddir = ..
-
-EXEEXT = @EXEEXT@
-SHELL = @SHELL@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
-
-CC = @CC@
-C_DIALECT = @C_DIALECT@
-CC_FOR_BUILD = @CC_FOR_BUILD@
-CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
-CFLAGS = @CFLAGS@
-CPPFLAGS = @CPPFLAGS@
-CXXFLAGS = @CXXFLAGS@
-LDFLAGS = @LDFLAGS@
-
-SIM_ALIGNMENT = @sim_alignment@
-SIM_BITSIZE = @sim_bitsize@
-SIM_DEFAULT_MODEL = @sim_default_model@
-SIM_ENDIAN = @sim_endian@
-SIM_FLOAT = @sim_float@
-SIM_HW_CFLAGS = @sim_hw_cflags@
-SIM_HW_OBJS = @sim_hw_objs@
-SIM_HW = @sim_hw@
-SIM_INLINE = @sim_inline@
-SIM_RESERVED_BITS = @sim_reserved_bits@
-SIM_SCACHE = @sim_scache@
-WARN_CFLAGS = @WARN_CFLAGS@
-WERROR_CFLAGS = @WERROR_CFLAGS@
-SIM_WARN_CFLAGS = $(WARN_CFLAGS)
-SIM_WERROR_CFLAGS = $(WERROR_CFLAGS)
-
-AR = @AR@
-AR_FLAGS = rc
-RANLIB = @RANLIB@
-MAKEINFO = makeinfo
-
-# Dependency tracking information.
-DEPMODE = @CCDEPMODE@
-DEPDIR = @DEPDIR@
-depcomp = $(SHELL) $(srcroot)/depcomp
-
-DEFS = @DEFS@
-LIBS = @LIBS@
-INCINTL = @INCINTL@
-zlibdir = @zlibdir@
-@PLUGINS_TRUE@LIBDL = @lt_cv_dlopen_libs@
-LIBINTL = @LIBINTL@
-LIBINTL_DEP = @LIBINTL_DEP@
-CGENDIR = @cgendir@
-
-# Note that these are overridden by GNU make-specific code below if
-# GNU make is used.  The overrides implement dependency tracking.
-COMPILE.pre = $(CC) $(C_DIALECT)
-COMPILE.post = -c -o $@
-COMPILE = $(COMPILE.pre) $(ALL_CFLAGS) $(COMPILE.post)
-POSTCOMPILE = @true
-
-# igen leaks memory, and therefore makes AddressSanitizer unhappy.  Disable
-# leak detection while running it.
-IGEN = ASAN_OPTIONS=detect_leaks=0 ../igen/igen
-
-# Each simulator's Makefile.in defines one or more of these variables
-# to override our settings as necessary.  There is no need to define these
-# in the simulator's Makefile.in if one is using the default value.  In fact
-# it's preferable not to.
-
-# List of object files, less common parts.
-SIM_OBJS =
-# List of extra dependencies.
-# Generally this consists of simulator specific files included by sim-main.h.
-SIM_EXTRA_DEPS =
-# List of flags to always pass to $(CC).
-SIM_EXTRA_CFLAGS =
-# List of extra libraries to link with.
-SIM_EXTRA_LIBS =
-# List of main object files for `run'.
-SIM_RUN_OBJS = nrun.o
-# Dependency of `install' to install any extra files.
-SIM_EXTRA_INSTALL =
-# Dependency of `clean' to clean any extra files.
-SIM_EXTRA_CLEAN =
-# Likewise `distclean'
-SIM_EXTRA_DISTCLEAN =
-
-# Every time a new general purpose source file was added every target's
-# Makefile.in needed to be updated to include the file in SIM_OBJS.
-# This doesn't scale.
-# This variable specifies all the generic stuff common to the newer simulators.
-# Things like sim-reason.o can't go here as the cpu may provide its own
-# (though hopefully in time that won't be so).  Things like sim-bits.o can go
-# here.  Some files are used by all simulators (e.g. callback.o).
-# Those files are specified in LIB_OBJS below.
-
-SIM_COMMON_HW_OBJS = \
-	hw-alloc.o \
-	hw-base.o \
-	hw-device.o \
-	hw-events.o \
-	hw-handles.o \
-	hw-instances.o \
-	hw-ports.o \
-	hw-properties.o \
-	hw-tree.o \
-	sim-hw.o \
-
-SIM_NEW_COMMON_OBJS = \
-	sim-arange.o \
-	sim-bits.o \
-	sim-close.o \
-	sim-command.o \
-	sim-config.o \
-	sim-core.o \
-	sim-cpu.o \
-	sim-endian.o \
-	sim-engine.o \
-	sim-events.o \
-	sim-fpu.o \
-	sim-hload.o \
-	sim-hrw.o \
-	sim-io.o \
-	sim-info.o \
-	sim-load.o \
-	sim-memopt.o \
-	sim-model.o \
-	sim-module.o \
-	sim-options.o \
-	sim-profile.o \
-	sim-reason.o \
-	sim-reg.o \
-	sim-signal.o \
-	sim-stop.o \
-	sim-syscall.o \
-	sim-trace.o \
-	sim-utils.o \
-	sim-watch.o \
-	\
-	$(SIM_HW_OBJS) \
-
-# cgen-sim.h and the headers it includes
-CGEN_SIM_DEPS = \
-	$(srccom)/cgen-sim.h \
-	$(srccom)/cgen-defs.h \
-	$(srccom)/cgen-scache.h \
-	$(srccom)/cgen-fpu.h \
-	$(srccom)/cgen-par.h \
-	$(srccom)/cgen-cpu.h \
-	$(srccom)/cgen-trace.h \
-	cpuall.h
-
-# Add this to SIM_EXTRA_DEPS.
-CGEN_INCLUDE_DEPS = \
-	$(CGEN_SIM_DEPS) \
-	$(srccom)/cgen-engine.h \
-	$(srccom)/cgen-types.h \
-	$(srcdir)/../../include/opcode/cgen.h
-
-## End COMMON_PRE_CONFIG_FRAG
-
-## COMMON_POST_CONFIG_FRAG
+# Epilogue fragment.
 
 CONFIG_CFLAGS = \
 	$(DEFS) \
@@ -445,7 +239,7 @@ endif
 
 # FIXME This is one very simple-minded way of generating the file hw-config.h
 hw-config.h: stamp-hw ; @true
-stamp-hw: Makefile.in $(srccom)/Make-common.in config.status Makefile
+stamp-hw: Makefile.in $(srccom)/prologue.mk.in config.status Makefile
 	rm -f tmp-hw.h
 	echo "/* generated by Makefile */" > tmp-hw.h
 	sim_hw="$(SIM_HW)"; \
@@ -517,9 +311,7 @@ mostlyclean clean: $(SIM_EXTRA_CLEAN)
 	rm -f run$(EXEEXT) libsim.a
 	rm -f hw-config.h stamp-hw
 	rm -f gentmap targ-map.c targ-vals.h stamp-tvals
-	if [ ! -f Make-common.in ] ; then \
-		rm -f $(BUILT_SRC_FROM_COMMON) ; \
-	fi
+	rm -f $(BUILT_SRC_FROM_COMMON)
 	rm -f tmp-mloop.hin tmp-mloop.h tmp-mloop.cin tmp-mloop.c
 
 distclean maintainer-clean realclean: clean $(SIM_EXTRA_DISTCLEAN)
@@ -534,18 +326,21 @@ distclean maintainer-clean realclean: clean $(SIM_EXTRA_DISTCLEAN)
 # Dummy target to force execution of dependent targets.
 force:
 
-Makefile: Makefile.in $(srccom)/Make-common.in config.status
-	CONFIG_HEADERS= $(SHELL) ./config.status
+Makefile: Makefile.in config.status
+	$(SHELL) ./config.status $@
+
+prologue.mk: prologue.mk.in config.status
+	$(SHELL) ./config.status $@
 
 config.status: configure
 	$(SHELL) ./config.status --recheck
 
 config.h: stamp-h ; @true
 stamp-h: config.in config.status
-	CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
+	$(SHELL) ./config.status $@
 
-.gdbinit: # config.status $(srccom)/gdbinit.in
-	CONFIG_FILES=$@:../common/gdbinit.in CONFIG_HEADERS= $(SHELL) ./config.status
+.gdbinit: config.status $(srccom)/gdbinit.in
+	$(SHELL) ./config.status $@
 
 
 # CGEN support
@@ -613,5 +408,3 @@ cgen-desc: force
 		$(CGEN) $(CGENDIR) "$(CGENFLAGS)" \
 		$(arch) "$(FLAGS)" $(cpu) "$(isa)" $(mach) "$(SUFFIX)" \
 		$(archfile) ignored $(opcfile)
-
-## End COMMON_POST_CONFIG_FRAG
diff --git a/sim/common/prologue.mk.in b/sim/common/prologue.mk.in
new file mode 100644
index 00000000000..7a62d053164
--- /dev/null
+++ b/sim/common/prologue.mk.in
@@ -0,0 +1,205 @@
+# Makefile fragment for common parts of all simulators.
+# Copyright 1997-2021 Free Software Foundation, Inc.
+# Contributed by Cygnus Support.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# This Makefile fragment holds variable definitions, and is processed
+# by configure to substitute values.
+
+VPATH = @srcdir@:$(srccom)
+srcdir = @srcdir@
+srccom = $(srcdir)/../common
+srcroot = $(srcdir)/../..
+srcsim = $(srcdir)/..
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+host_alias = @host_alias@
+target_alias = @target_alias@
+program_transform_name = @program_transform_name@
+bindir = @bindir@
+
+libdir = @libdir@
+tooldir = $(libdir)/$(target_alias)
+
+datadir = @datadir@
+datarootdir = @datarootdir@
+mandir = @mandir@
+man1dir = $(mandir)/man1
+infodir = @infodir@
+includedir = @includedir@
+
+lt_cv_dlopen_libs = @lt_cv_dlopen_libs@
+# This can be referenced by the gettext configuration code.
+top_builddir = ..
+
+EXEEXT = @EXEEXT@
+SHELL = @SHELL@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+CC = @CC@
+C_DIALECT = @C_DIALECT@
+CC_FOR_BUILD = @CC_FOR_BUILD@
+CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
+CXXFLAGS = @CXXFLAGS@
+LDFLAGS = @LDFLAGS@
+
+SIM_ALIGNMENT = @sim_alignment@
+SIM_BITSIZE = @sim_bitsize@
+SIM_DEFAULT_MODEL = @sim_default_model@
+SIM_ENDIAN = @sim_endian@
+SIM_FLOAT = @sim_float@
+SIM_HW_CFLAGS = @sim_hw_cflags@
+SIM_HW_OBJS = @sim_hw_objs@
+SIM_HW = @sim_hw@
+SIM_INLINE = @sim_inline@
+SIM_RESERVED_BITS = @sim_reserved_bits@
+SIM_SCACHE = @sim_scache@
+WARN_CFLAGS = @WARN_CFLAGS@
+WERROR_CFLAGS = @WERROR_CFLAGS@
+SIM_WARN_CFLAGS = $(WARN_CFLAGS)
+SIM_WERROR_CFLAGS = $(WERROR_CFLAGS)
+
+AR = @AR@
+AR_FLAGS = rc
+RANLIB = @RANLIB@
+MAKEINFO = makeinfo
+
+# Dependency tracking information.
+DEPMODE = @CCDEPMODE@
+DEPDIR = @DEPDIR@
+depcomp = $(SHELL) $(srcroot)/depcomp
+
+DEFS = @DEFS@
+LIBS = @LIBS@
+INCINTL = @INCINTL@
+zlibdir = @zlibdir@
+@PLUGINS_TRUE@LIBDL = @lt_cv_dlopen_libs@
+LIBINTL = @LIBINTL@
+LIBINTL_DEP = @LIBINTL_DEP@
+CGENDIR = @cgendir@
+
+# Note that these are overridden by GNU make-specific code below if
+# GNU make is used.  The overrides implement dependency tracking.
+COMPILE.pre = $(CC) $(C_DIALECT)
+COMPILE.post = -c -o $@
+COMPILE = $(COMPILE.pre) $(ALL_CFLAGS) $(COMPILE.post)
+POSTCOMPILE = @true
+
+# igen leaks memory, and therefore makes AddressSanitizer unhappy.  Disable
+# leak detection while running it.
+IGEN = ASAN_OPTIONS=detect_leaks=0 ../igen/igen
+
+# Each simulator's Makefile.in defines one or more of these variables
+# to override our settings as necessary.  There is no need to define these
+# in the simulator's Makefile.in if one is using the default value.  In fact
+# it's preferable not to.
+
+# List of object files, less common parts.
+SIM_OBJS =
+# List of extra dependencies.
+# Generally this consists of simulator specific files included by sim-main.h.
+SIM_EXTRA_DEPS =
+# List of flags to always pass to $(CC).
+SIM_EXTRA_CFLAGS =
+# List of extra libraries to link with.
+SIM_EXTRA_LIBS =
+# List of main object files for `run'.
+SIM_RUN_OBJS = nrun.o
+# Dependency of `install' to install any extra files.
+SIM_EXTRA_INSTALL =
+# Dependency of `clean' to clean any extra files.
+SIM_EXTRA_CLEAN =
+# Likewise `distclean'
+SIM_EXTRA_DISTCLEAN =
+
+# Every time a new general purpose source file was added every target's
+# Makefile.in needed to be updated to include the file in SIM_OBJS.
+# This doesn't scale.
+# This variable specifies all the generic stuff common to the newer simulators.
+# Things like sim-reason.o can't go here as the cpu may provide its own
+# (though hopefully in time that won't be so).  Things like sim-bits.o can go
+# here.  Some files are used by all simulators (e.g. callback.o).
+# Those files are specified in LIB_OBJS below.
+
+SIM_COMMON_HW_OBJS = \
+	hw-alloc.o \
+	hw-base.o \
+	hw-device.o \
+	hw-events.o \
+	hw-handles.o \
+	hw-instances.o \
+	hw-ports.o \
+	hw-properties.o \
+	hw-tree.o \
+	sim-hw.o \
+
+SIM_NEW_COMMON_OBJS = \
+	sim-arange.o \
+	sim-bits.o \
+	sim-close.o \
+	sim-command.o \
+	sim-config.o \
+	sim-core.o \
+	sim-cpu.o \
+	sim-endian.o \
+	sim-engine.o \
+	sim-events.o \
+	sim-fpu.o \
+	sim-hload.o \
+	sim-hrw.o \
+	sim-io.o \
+	sim-info.o \
+	sim-load.o \
+	sim-memopt.o \
+	sim-model.o \
+	sim-module.o \
+	sim-options.o \
+	sim-profile.o \
+	sim-reason.o \
+	sim-reg.o \
+	sim-signal.o \
+	sim-stop.o \
+	sim-syscall.o \
+	sim-trace.o \
+	sim-utils.o \
+	sim-watch.o \
+	\
+	$(SIM_HW_OBJS) \
+
+# cgen-sim.h and the headers it includes
+CGEN_SIM_DEPS = \
+	$(srccom)/cgen-sim.h \
+	$(srccom)/cgen-defs.h \
+	$(srccom)/cgen-scache.h \
+	$(srccom)/cgen-fpu.h \
+	$(srccom)/cgen-par.h \
+	$(srccom)/cgen-cpu.h \
+	$(srccom)/cgen-trace.h \
+	cpuall.h
+
+# Add this to SIM_EXTRA_DEPS.
+CGEN_INCLUDE_DEPS = \
+	$(CGEN_SIM_DEPS) \
+	$(srccom)/cgen-engine.h \
+	$(srccom)/cgen-types.h \
+	$(srcdir)/../../include/opcode/cgen.h
diff --git a/sim/cr16/Makefile.in b/sim/cr16/Makefile.in
index 8cfe3ea3b26..965a4808bf8 100644
--- a/sim/cr16/Makefile.in
+++ b/sim/cr16/Makefile.in
@@ -15,7 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_OBJS = \
 	$(SIM_NEW_COMMON_OBJS) \
@@ -33,7 +33,7 @@ INCLUDE = cr16_sim.h $(srcroot)/include/gdb/callback.h targ-vals.h \
 # This selects the cr16 newlib/libgloss syscall definitions.
 NL_TARGET = -DNL_TARGET_cr16
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 simops.h: gencode
 	./gencode -h >$@
diff --git a/sim/cr16/configure b/sim/cr16/configure
index 793aff7353d..4fd0a66d9bd 100755
--- a/sim/cr16/configure
+++ b/sim/cr16/configure
@@ -12020,13 +12020,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13014,10 +13012,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14213,15 +14210,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/cris/Makefile.in b/sim/cris/Makefile.in
index 5879cffe80b..2372cc43d00 100644
--- a/sim/cris/Makefile.in
+++ b/sim/cris/Makefile.in
@@ -17,7 +17,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 CRISV10F_OBJS = crisv10f.o cpuv10.o decodev10.o modelv10.o mloopv10f.o
 CRISV32F_OBJS = crisv32f.o cpuv32.o decodev32.o modelv32.o mloopv32f.o
@@ -43,7 +43,7 @@ SIM_EXTRA_CLEAN = cris-clean
 # This selects the cris newlib/libgloss syscall definitions.
 NL_TARGET = -DNL_TARGET_cris
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 arch = cris
 
diff --git a/sim/cris/configure b/sim/cris/configure
index 56740dabd5d..2fc847262ab 100755
--- a/sim/cris/configure
+++ b/sim/cris/configure
@@ -12226,13 +12226,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13220,10 +13218,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14419,15 +14416,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/d10v/Makefile.in b/sim/d10v/Makefile.in
index 13b902dec5d..00e438de64e 100644
--- a/sim/d10v/Makefile.in
+++ b/sim/d10v/Makefile.in
@@ -15,7 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_OBJS = \
 	interp.o \
@@ -34,7 +34,7 @@ INCLUDE = d10v_sim.h $(srcroot)/include/gdb/callback.h targ-vals.h endian.c \
 # This selects the d10v newlib/libgloss syscall definitions.
 NL_TARGET = -DNL_TARGET_d10v
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 simops.h: gencode
 	./gencode -h >$@
diff --git a/sim/d10v/configure b/sim/d10v/configure
index 84f33c45134..678560066bd 100755
--- a/sim/d10v/configure
+++ b/sim/d10v/configure
@@ -12020,13 +12020,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13014,10 +13012,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14213,15 +14210,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/erc32/Makefile.in b/sim/erc32/Makefile.in
index 0006922904b..4c95c8acea3 100644
--- a/sim/erc32/Makefile.in
+++ b/sim/erc32/Makefile.in
@@ -16,7 +16,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 TERMCAP_LIB = @TERMCAP@
 READLINE_LIB = @READLINE@
@@ -32,7 +32,7 @@ SIM_EXTRA_CLEAN = clean-sis
 # behaviour of UART interrupt routines ...
 SIM_EXTRA_CFLAGS = -DFAST_UART -I$(srcroot)
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 # `sis' doesn't need interf.o.
 SIS_OFILES = exec.o erc32.o func.o help.o float.o
diff --git a/sim/erc32/configure b/sim/erc32/configure
index 8729505a5f1..585f20a9e7b 100755
--- a/sim/erc32/configure
+++ b/sim/erc32/configure
@@ -12061,13 +12061,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13055,10 +13053,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14254,15 +14251,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/example-synacor/Makefile.in b/sim/example-synacor/Makefile.in
index edd77ac801e..370ce958133 100644
--- a/sim/example-synacor/Makefile.in
+++ b/sim/example-synacor/Makefile.in
@@ -15,7 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_OBJS = \
 	$(SIM_NEW_COMMON_OBJS) \
@@ -23,4 +23,4 @@ SIM_OBJS = \
 	interp.o \
 	sim-main.o
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
diff --git a/sim/example-synacor/configure b/sim/example-synacor/configure
index 8e8bdcdbb2d..ed8d85186b1 100755
--- a/sim/example-synacor/configure
+++ b/sim/example-synacor/configure
@@ -12023,13 +12023,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13017,10 +13015,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14216,15 +14213,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/frv/Makefile.in b/sim/frv/Makefile.in
index 0d40a568fdd..e49af930f6d 100644
--- a/sim/frv/Makefile.in
+++ b/sim/frv/Makefile.in
@@ -15,7 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 FRV_OBJS = frv.o cpu.o decode.o sem.o model.o mloop.o cgen-par.o
 
@@ -43,7 +43,7 @@ SIM_EXTRA_CLEAN = frv-clean
 # This selects the frv newlib/libgloss syscall definitions.
 NL_TARGET = -DNL_TARGET_frv
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 arch = frv
 
diff --git a/sim/frv/configure b/sim/frv/configure
index b55e7ead7cc..e832ca58eb0 100755
--- a/sim/frv/configure
+++ b/sim/frv/configure
@@ -12231,13 +12231,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13225,10 +13223,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14424,15 +14421,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/ft32/Makefile.in b/sim/ft32/Makefile.in
index 0a90c0fe1dd..74895fe4d44 100644
--- a/sim/ft32/Makefile.in
+++ b/sim/ft32/Makefile.in
@@ -15,12 +15,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
-
+include prologue.mk
 
 SIM_OBJS = \
 	$(SIM_NEW_COMMON_OBJS) \
 	interp.o	\
 	sim-resume.o
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
diff --git a/sim/ft32/configure b/sim/ft32/configure
index 5dc69fd8d73..ecabbc0d389 100755
--- a/sim/ft32/configure
+++ b/sim/ft32/configure
@@ -12023,13 +12023,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13017,10 +13015,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14216,15 +14213,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/h8300/Makefile.in b/sim/h8300/Makefile.in
index 451c584cd6f..8cd718098d1 100644
--- a/sim/h8300/Makefile.in
+++ b/sim/h8300/Makefile.in
@@ -15,10 +15,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_OBJS = compile.o \
 	$(SIM_NEW_COMMON_OBJS) \
 	sim-resume.o
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
diff --git a/sim/h8300/configure b/sim/h8300/configure
index 0d022c6a801..03cac86a569 100755
--- a/sim/h8300/configure
+++ b/sim/h8300/configure
@@ -12033,13 +12033,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13027,10 +13025,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14226,15 +14223,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/iq2000/Makefile.in b/sim/iq2000/Makefile.in
index 18d0715ec59..000082a24e2 100644
--- a/sim/iq2000/Makefile.in
+++ b/sim/iq2000/Makefile.in
@@ -15,7 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 IQ2000_OBJS = iq2000.o cpu.o decode.o sem.o model.o mloop.o
 
@@ -37,7 +37,7 @@ ALL_CPU_CFLAGS = -DHAVE_CPU_IQ2000BF -DHAVE_CPU_IQ10BF
 
 SIM_EXTRA_CLEAN = iq2000-clean
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 arch = iq2000
 
diff --git a/sim/iq2000/configure b/sim/iq2000/configure
index 2207210db52..a99f4a584b3 100755
--- a/sim/iq2000/configure
+++ b/sim/iq2000/configure
@@ -12210,13 +12210,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13204,10 +13202,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14403,15 +14400,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/lm32/Makefile.in b/sim/lm32/Makefile.in
index 834c41150a1..dcb7f901b85 100644
--- a/sim/lm32/Makefile.in
+++ b/sim/lm32/Makefile.in
@@ -1,7 +1,7 @@
 # Makefile for Lattice Mico32 simulator.
 # Contributed by Jon Beniston <jon@beniston.com>
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 # List of object files, less common parts.
 SIM_OBJS = \
@@ -24,7 +24,7 @@ SIM_EXTRA_CLEAN = lm32-clean
 # This selects the lm32 newlib/libgloss syscall definitions.
 NL_TARGET = -DNL_TARGET_lm32
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 arch = lm32 
 
diff --git a/sim/lm32/configure b/sim/lm32/configure
index 08f0eba9836..5c2a85fed18 100755
--- a/sim/lm32/configure
+++ b/sim/lm32/configure
@@ -12209,13 +12209,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13203,10 +13201,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14402,15 +14399,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/m32c/Makefile.in b/sim/m32c/Makefile.in
index 05aa75309fa..89fefd5e159 100644
--- a/sim/m32c/Makefile.in
+++ b/sim/m32c/Makefile.in
@@ -18,7 +18,7 @@
 ### You should have received a copy of the GNU General Public License
 ### along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_EXTRA_CFLAGS = -Wall -DTIMER_A
 
@@ -40,7 +40,7 @@ SIM_OBJS = \
 	trace.o \
 	$(ENDLIST)
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 arch = m32c
 
diff --git a/sim/m32c/configure b/sim/m32c/configure
index 349101584e0..23c0f44eff3 100755
--- a/sim/m32c/configure
+++ b/sim/m32c/configure
@@ -11936,13 +11936,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -12930,10 +12928,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14129,15 +14126,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/m32r/Makefile.in b/sim/m32r/Makefile.in
index 9b24995860d..6fa8b9a6cb6 100644
--- a/sim/m32r/Makefile.in
+++ b/sim/m32r/Makefile.in
@@ -17,7 +17,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 M32R_OBJS = m32r.o cpu.o decode.o sem.o model.o mloop.o
 M32RX_OBJS = m32rx.o cpux.o decodex.o modelx.o mloopx.o
@@ -46,7 +46,7 @@ SIM_EXTRA_CLEAN = m32r-clean
 # This selects the m32r newlib/libgloss syscall definitions.
 NL_TARGET = -DNL_TARGET_m32r
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 arch = m32r
 
diff --git a/sim/m32r/configure b/sim/m32r/configure
index 60a0d8eab38..16c98a30eab 100755
--- a/sim/m32r/configure
+++ b/sim/m32r/configure
@@ -12225,13 +12225,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13219,10 +13217,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14418,15 +14415,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/m4/sim_ac_output.m4 b/sim/m4/sim_ac_output.m4
index 9ec566d8acd..5585a8597d5 100644
--- a/sim/m4/sim_ac_output.m4
+++ b/sim/m4/sim_ac_output.m4
@@ -29,19 +29,9 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 AC_SUBST(cgen_breaks)
-AC_CONFIG_FILES(Makefile.sim:Makefile.in)
-AC_CONFIG_FILES(Make-common.sim:../common/Make-common.in)
+AC_CONFIG_FILES(prologue.mk:../common/prologue.mk.in)
 AC_CONFIG_FILES(.gdbinit:../common/gdbinit.in)
-AC_CONFIG_COMMANDS([Makefile],
-[echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
-])
+AC_CONFIG_FILES([Makefile])
 AC_CONFIG_COMMANDS([stamp-h], [echo > stamp-h])
 
 dnl These are unfortunate.  They are conditionally called by other sim macros
diff --git a/sim/m68hc11/Makefile.in b/sim/m68hc11/Makefile.in
index 8a044914ed6..5f857c49ed3 100644
--- a/sim/m68hc11/Makefile.in
+++ b/sim/m68hc11/Makefile.in
@@ -15,7 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 M68HC11_OBJS = interp.o m68hc11int.o m68hc12int.o \
 		emulos.o interrupts.o m68hc11_sim.o
@@ -37,7 +37,7 @@ SIM_EXTRA_CFLAGS = -DWITH_TARGET_WORD_BITSIZE=32 \
 SIM_EXTRA_CLEAN = clean-extra
 
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 m68hc11int.c: gencode
 	./gencode -m6811 > $@
diff --git a/sim/m68hc11/configure b/sim/m68hc11/configure
index 398dd283617..6dfe9307c3e 100755
--- a/sim/m68hc11/configure
+++ b/sim/m68hc11/configure
@@ -12130,13 +12130,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13124,10 +13122,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14323,15 +14320,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/mcore/Makefile.in b/sim/mcore/Makefile.in
index 45cf634d06a..d2f9d5058d0 100644
--- a/sim/mcore/Makefile.in
+++ b/sim/mcore/Makefile.in
@@ -18,11 +18,11 @@
 # This selects the bfin newlib/libgloss syscall definitions.
 NL_TARGET = -DNL_TARGET_mcore
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_OBJS = \
 	interp.o \
 	$(SIM_NEW_COMMON_OBJS) \
 	sim-resume.o
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
diff --git a/sim/mcore/configure b/sim/mcore/configure
index 84f33c45134..678560066bd 100755
--- a/sim/mcore/configure
+++ b/sim/mcore/configure
@@ -12020,13 +12020,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13014,10 +13012,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14213,15 +14210,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/microblaze/Makefile.in b/sim/microblaze/Makefile.in
index 8f625839723..4183e3155df 100644
--- a/sim/microblaze/Makefile.in
+++ b/sim/microblaze/Makefile.in
@@ -15,11 +15,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_OBJS = \
 	interp.o \
 	$(SIM_NEW_COMMON_OBJS) \
 	sim-resume.o
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
diff --git a/sim/microblaze/configure b/sim/microblaze/configure
index a73ba1597a8..67168b49e5e 100755
--- a/sim/microblaze/configure
+++ b/sim/microblaze/configure
@@ -12023,13 +12023,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13017,10 +13015,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14216,15 +14213,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/mips/Makefile.in b/sim/mips/Makefile.in
index c150224041f..4ef7fb016b2 100644
--- a/sim/mips/Makefile.in
+++ b/sim/mips/Makefile.in
@@ -3,7 +3,7 @@
 
 SHELL = @SHELL@
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 srcdir=@srcdir@
 srcroot=$(srcdir)/../../
@@ -84,7 +84,7 @@ all: $(SIM_@sim_gen@_ALL)
 SIM_EXTRA_LIBS = $(MIPS_EXTRA_LIBS)
 
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 IGEN_TRACE= # -G omit-line-numbers # -G trace-rule-selection -G trace-rule-rejection -G trace-entries # -G trace-all
 IGEN_INSN=$(srcdir)/mips.igen
diff --git a/sim/mips/configure b/sim/mips/configure
index 92d41ece133..c92e174e610 100755
--- a/sim/mips/configure
+++ b/sim/mips/configure
@@ -12949,13 +12949,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13943,10 +13941,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -15142,15 +15139,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/mn10300/Makefile.in b/sim/mn10300/Makefile.in
index 4b715cb46d6..eac566fd326 100644
--- a/sim/mn10300/Makefile.in
+++ b/sim/mn10300/Makefile.in
@@ -15,7 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 MN10300_OBJS = \
 	itable.o semantics.o idecode.o icache.o engine.o irun.o support.o \
@@ -35,7 +35,7 @@ NL_TARGET = -DNL_TARGET_mn10300
 # List of extra flags to always pass to $(CC).
 SIM_EXTRA_CFLAGS = -DPOLL_QUIT_INTERVAL=0x20
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 BUILT_SRC_FROM_IGEN = \
 	icache.h \
diff --git a/sim/mn10300/configure b/sim/mn10300/configure
index b5a2b6a712a..25b06e4c859 100755
--- a/sim/mn10300/configure
+++ b/sim/mn10300/configure
@@ -12236,13 +12236,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13230,10 +13228,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14429,15 +14426,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/moxie/Makefile.in b/sim/moxie/Makefile.in
index ee513867290..7b53ffc9f04 100644
--- a/sim/moxie/Makefile.in
+++ b/sim/moxie/Makefile.in
@@ -15,7 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 dtbdir = @datadir@/gdb/dtb
 
@@ -28,7 +28,7 @@ SIM_EXTRA_LIBS = -lm -lz
 SIM_EXTRA_INSTALL = install-dtb
 SIM_EXTRA_CFLAGS = -DDTB="\"$(dtbdir)/moxie-gdb.dtb\""
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 all: moxie-gdb.dtb
 
diff --git a/sim/moxie/configure b/sim/moxie/configure
index 6bf47d4d8a4..fddee7f12ef 100755
--- a/sim/moxie/configure
+++ b/sim/moxie/configure
@@ -12117,13 +12117,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13111,10 +13109,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14310,15 +14307,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/msp430/Makefile.in b/sim/msp430/Makefile.in
index 113f28d3c90..45b7cb94401 100644
--- a/sim/msp430/Makefile.in
+++ b/sim/msp430/Makefile.in
@@ -16,7 +16,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 # These variables are given default values in COMMON_PRE_CONFIG_FRAG.
 # We override the ones we need to here.
@@ -44,7 +44,7 @@ SIM_EXTRA_CLEAN =
 # This selects the MSP430 newlib/libgloss syscall definitions.
 NL_TARGET = -DNL_TARGET_msp430
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 # Rules need to build $(SIM_OBJS), plus whatever else the target wants.
 
diff --git a/sim/msp430/configure b/sim/msp430/configure
index 14abf9a6ef9..5d4ab8a2fc3 100755
--- a/sim/msp430/configure
+++ b/sim/msp430/configure
@@ -12036,13 +12036,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13030,10 +13028,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14229,15 +14226,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/or1k/Makefile.in b/sim/or1k/Makefile.in
index 649486fd4e1..c5ca8e9d385 100644
--- a/sim/or1k/Makefile.in
+++ b/sim/or1k/Makefile.in
@@ -16,7 +16,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 OR1K_OBJS = \
 	or1k.o \
@@ -55,7 +55,7 @@ SIM_EXTRA_LIBS = -lm
 
 SIM_EXTRA_CLEAN = or1k-clean
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 arch = or1k
 
diff --git a/sim/or1k/configure b/sim/or1k/configure
index d65e7140e3d..4b4895d413d 100755
--- a/sim/or1k/configure
+++ b/sim/or1k/configure
@@ -12182,13 +12182,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13176,10 +13174,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14375,15 +14372,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/pru/Makefile.in b/sim/pru/Makefile.in
index 7dd79b4bba6..af173e2dd13 100644
--- a/sim/pru/Makefile.in
+++ b/sim/pru/Makefile.in
@@ -17,7 +17,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_OBJS = \
 	$(SIM_NEW_COMMON_OBJS) \
@@ -26,4 +26,5 @@ SIM_OBJS = \
 
 NL_TARGET = -DNL_TARGET_pru
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
+
diff --git a/sim/pru/configure b/sim/pru/configure
index f492aa553b0..9edf4362082 100755
--- a/sim/pru/configure
+++ b/sim/pru/configure
@@ -12023,13 +12023,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13017,10 +13015,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14216,15 +14213,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/riscv/Makefile.in b/sim/riscv/Makefile.in
index 17cb288eba3..ffc1ed95f23 100644
--- a/sim/riscv/Makefile.in
+++ b/sim/riscv/Makefile.in
@@ -18,7 +18,7 @@
 # This selects the newlib/libgloss syscall definitions.
 NL_TARGET = -DNL_TARGET_riscv
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_OBJS = \
 	$(SIM_NEW_COMMON_OBJS) \
@@ -27,4 +27,5 @@ SIM_OBJS = \
 	machs.o \
 	sim-main.o
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
+
diff --git a/sim/riscv/configure b/sim/riscv/configure
index 4b4fc6b8db2..ad35e6347e4 100755
--- a/sim/riscv/configure
+++ b/sim/riscv/configure
@@ -12139,13 +12139,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13133,10 +13131,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14332,15 +14329,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/rl78/Makefile.in b/sim/rl78/Makefile.in
index 675f87be9b9..3c3e20b8bc0 100644
--- a/sim/rl78/Makefile.in
+++ b/sim/rl78/Makefile.in
@@ -18,7 +18,7 @@
 ### You should have received a copy of the GNU General Public License
 ### along with the GNU simulators; if not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_EXTRA_CFLAGS = -Wall
 
@@ -33,7 +33,7 @@ SIM_OBJS = \
 	gdb-if.o \
 	trace.o
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 arch = rl78
 
diff --git a/sim/rl78/configure b/sim/rl78/configure
index e00d20404f3..4ba20b2da8f 100755
--- a/sim/rl78/configure
+++ b/sim/rl78/configure
@@ -11934,13 +11934,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -12928,10 +12926,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14127,15 +14124,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/rx/Makefile.in b/sim/rx/Makefile.in
index 4008aac2619..a8a60375d64 100644
--- a/sim/rx/Makefile.in
+++ b/sim/rx/Makefile.in
@@ -18,7 +18,7 @@
 ### You should have received a copy of the GNU General Public License
 ### along with the GNU simulators; if not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_EXTRA_CFLAGS = -Wall
 
@@ -39,6 +39,6 @@ SIM_OBJS = \
 	err.o \
 	$(ENDLIST)
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 arch = rx
diff --git a/sim/rx/configure b/sim/rx/configure
index 4ad5c706464..b2c1b61046b 100755
--- a/sim/rx/configure
+++ b/sim/rx/configure
@@ -11979,13 +11979,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -12973,10 +12971,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14172,15 +14169,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/sh/Makefile.in b/sim/sh/Makefile.in
index 3910c4f5614..6ac952a7138 100644
--- a/sim/sh/Makefile.in
+++ b/sim/sh/Makefile.in
@@ -15,7 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_OBJS = \
 	interp.o \
@@ -25,7 +25,7 @@ SIM_EXTRA_LIBS = -lm
 SIM_EXTRA_CLEAN = sh-clean
 SIM_EXTRA_DEPS = table.c code.c ppi.c
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 code.c: gencode
 	./gencode -x >code.c
diff --git a/sim/sh/configure b/sim/sh/configure
index 84f33c45134..678560066bd 100755
--- a/sim/sh/configure
+++ b/sim/sh/configure
@@ -12020,13 +12020,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13014,10 +13012,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14213,15 +14210,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
diff --git a/sim/v850/Makefile.in b/sim/v850/Makefile.in
index 3e1b4054174..24fc3c5b5bd 100644
--- a/sim/v850/Makefile.in
+++ b/sim/v850/Makefile.in
@@ -17,7 +17,7 @@
 
 SHELL = @SHELL@
 
-## COMMON_PRE_CONFIG_FRAG
+include prologue.mk
 
 SIM_OBJS = \
 	$(SIM_NEW_COMMON_OBJS) \
@@ -37,7 +37,7 @@ SIM_EXTRA_CLEAN = clean-extra
 
 NL_TARGET = -DNL_TARGET_v850
 
-## COMMON_POST_CONFIG_FRAG
+include $(srccom)/epilogue.mk
 
 BUILT_SRC_FROM_IGEN = \
 	icache.h \
diff --git a/sim/v850/configure b/sim/v850/configure
index 9176b7ff64c..8663d3d6a76 100755
--- a/sim/v850/configure
+++ b/sim/v850/configure
@@ -12129,13 +12129,11 @@ if grep CGEN_MAINT $srcdir/Makefile.in >/dev/null; then
 cgen_breaks="break cgen_rtx_error";
 fi
 
-ac_config_files="$ac_config_files Makefile.sim:Makefile.in"
-
-ac_config_files="$ac_config_files Make-common.sim:../common/Make-common.in"
+ac_config_files="$ac_config_files prologue.mk:../common/prologue.mk.in"
 
 ac_config_files="$ac_config_files .gdbinit:../common/gdbinit.in"
 
-ac_config_commands="$ac_config_commands Makefile"
+ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands stamp-h"
 
@@ -13123,10 +13121,9 @@ do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
     "depdir") CONFIG_COMMANDS="$CONFIG_COMMANDS depdir" ;;
     "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
-    "Makefile.sim") CONFIG_FILES="$CONFIG_FILES Makefile.sim:Makefile.in" ;;
-    "Make-common.sim") CONFIG_FILES="$CONFIG_FILES Make-common.sim:../common/Make-common.in" ;;
+    "prologue.mk") CONFIG_FILES="$CONFIG_FILES prologue.mk:../common/prologue.mk.in" ;;
     ".gdbinit") CONFIG_FILES="$CONFIG_FILES .gdbinit:../common/gdbinit.in" ;;
-    "Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "stamp-h") CONFIG_COMMANDS="$CONFIG_COMMANDS stamp-h" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -14322,15 +14319,6 @@ _LT_EOF
     (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
   chmod +x "$ofile"
 
- ;;
-    "Makefile":C) echo "Merging Makefile.sim+Make-common.sim into Makefile ..."
- rm -f Makesim1.tmp Makesim2.tmp Makefile
- sed -n -e '/^## COMMON_PRE_/,/^## End COMMON_PRE_/ p' <Make-common.sim >Makesim1.tmp
- sed -n -e '/^## COMMON_POST_/,/^## End COMMON_POST_/ p' <Make-common.sim >Makesim2.tmp
- sed -e '/^## COMMON_PRE_/ r Makesim1.tmp' \
-	-e '/^## COMMON_POST_/ r Makesim2.tmp' \
-	<Makefile.sim >Makefile
- rm -f Makefile.sim Make-common.sim Makesim1.tmp Makesim2.tmp
  ;;
     "stamp-h":C) echo > stamp-h ;;
 
-- 
2.26.2


  parent reply	other threads:[~2021-04-08 20:43 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08 20:33 [PATCH 00/10] sim build improvements Tom Tromey
2021-04-08 20:33 ` [PATCH 01/10] Make mostlyclean an alias for clean Tom Tromey
2021-04-09  0:25   ` Mike Frysinger
2021-04-08 20:33 ` [PATCH 02/10] Introduce stamp file for hw-config.h Tom Tromey
2021-04-09  0:25   ` Mike Frysinger
2021-04-08 20:33 ` [PATCH 03/10] Add stamp files for generated files in sim/ppc Tom Tromey
2021-04-09  0:25   ` Mike Frysinger
2021-04-08 20:33 ` [PATCH 04/10] Require GNU make Tom Tromey
2021-04-09  0:31   ` Mike Frysinger
2021-04-09 17:18     ` Tom Tromey
2021-04-09 22:45       ` Mike Frysinger
2021-04-21 23:14         ` Tom Tromey
2021-04-22  3:17           ` Mike Frysinger
2021-04-22 14:14             ` Tom Tromey
2021-04-08 20:33 ` [PATCH 05/10] Remove and modernize dependencies in sim Tom Tromey
2021-04-11 17:50   ` Mike Frysinger
2021-04-22 14:15     ` Tom Tromey
2021-04-23  0:44       ` Mike Frysinger
2021-04-08 20:33 ` [PATCH 06/10] Remove INCLUDE variable from some sim Makefiles Tom Tromey
2021-04-09  0:27   ` Mike Frysinger
2021-04-08 20:33 ` [PATCH 07/10] Remove LIBS from two " Tom Tromey
2021-04-09  0:27   ` Mike Frysinger
2021-04-08 20:33 ` [PATCH 08/10] Define autoconf substitution variables early in Make-common.in Tom Tromey
2021-04-09  0:44   ` Mike Frysinger
2021-04-08 20:33 ` Tom Tromey [this message]
2021-04-08 20:33 ` [PATCH 10/10] Do not check for sys/time.h or sys/times.h Tom Tromey
2021-04-09  0:35   ` Mike Frysinger
2021-04-09 17:18     ` Tom Tromey
2021-04-09  0:26 ` [PATCH 00/10] sim build improvements Mike Frysinger
2021-04-09 17:14   ` Tom Tromey
2021-04-09 22:27     ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210408203312.2938165-10-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).