[Modula2] PR-108142 Many empty directories created in the build directory

Message ID 87h6wzf9ci.fsf@debian
State Accepted
Headers
Series [Modula2] PR-108142 Many empty directories created in the build directory |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Gaius Mulley Jan. 10, 2023, 1:48 a.m. UTC
  PR-108142 Modula-2 configure generates many subdirectories in the top
build directory.  This patch dynamically creates subdirectories under
gcc/m2 if and when required.

Bootstrapped on x86_64 gnu/linux, ok for master?

regards,
Gaius


gcc/m2/ChangeLog:

	* Make-lang.in (GM2_1): Change -B path to m2/stage1.
	($(objdir)/m2/images/gnu.eps): Check and create dest dir
        if necessary.
	(gm2-libs.texi-check): Check and create dir m2/gm2-libs-pim,
	m2/gm2-libs-iso and m2/gm2-libs if necessary.
	($(objdir)/m2/gm2-compiler-boot): Remove.
	($(objdir)/m2/gm2-libs-boot): Remove.
	($(objdir)/m2/gm2-libs-libiberty): Remove.
	($(objdir)/m2/gm2-libiberty): Remove.
	($(objdir)/m2/gm2-gcc): Remove.
	($(objdir)/m2/gm2-compiler): Remove.
	($(objdir)/m2/gm2-libs): Remove.
	($(objdir)/m2/gm2-libs-iso): Remove.
	($(objdir)/m2/gm2-libs-min): Remove.
	($(objdir)/m2/gm2-compiler-paranoid): Remove.
	($(objdir)/m2/gm2-libs-paranoid): Remove.
	($(objdir)/m2/gm2-compiler-verify): Remove.
	($(objdir)/m2/boot-bin): Remove.
	($(objdir)/m2/gm2-libs-pim): Remove.
	($(objdir)/m2/gm2-libs-coroutines): Remove.
	(stage1/m2): Remove.
	(stage2/m2): Remove.
	(stage3/m2): Remove.
	(m2.stageprofile): New rule.
	(m2.stagefeedback): New rule.
	(cc1gm2$(exeext)): Change dependent name.
	(m2/stage2/cc1gm2$(exeext)): Change dependent name.
	Check and create dest dir.
	(m2/stage1/cc1gm2$(exeext)): Check and create dest dir
        if necessary.
	(m2/gm2-gcc/%.o): Ditto.
	(m2/gm2-gcc/rtegraph.o): Ditto.
	(m2/gm2-gcc/$(SRC_PREFIX)%.h): Ditto.
	(m2/gm2-gcc/$(SRC_PREFIX)%.h): Ditto.
	(m2/mc-boot): Ditto.
	(m2/mc-boot-ch): Ditto.
	(m2/gm2-libs-boot): Ditto.
	(m2/gm2-compiler-boot): Ditto.
	(m2/gm2-compiler): Ditto.
	(m2/gm2-libiberty): Ditto.
	(m2/gm2-compiler): Ditto.
	(m2/gm2-libs-iso): Ditto.
	(m2/gm2-libs): Ditto.
	(m2/gm2-libs-min): Ditto.
	(m2/gm2-libs-coroutines): Ditto.
	(m2/boot-bin): Ditto.
	(m2/pge-boot): Ditto.
	(m2/pge-boot): Ditto.
	* Make-maintainer.in (m2/gm2-ppg-boot): Check and create
	dest dir if necessary.
	(m2): Ditto.
	(m2/gm2-ppg-boot): Ditto.
	(m2/gm2-pg-boot): Ditto.
	(m2/gm2-auto): Ditto.
	(m2/gm2-pg-boot): Ditto.
	(m2/gm2-pge-boot): Ditto.
	($(objdir)/plugin): Ditto.
	($(objdir)/m2/mc-boot-ch): Ditto.
	($(objdir)/m2/mc-boot-gen): Ditto.
	(m2/boot-bin): Ditto.
	(m2/mc): Ditto.
	(m2/mc-obj): Ditto.
	($(objdir)/m2/gm2-ppg-boot): Ditto.
	($(objdir)/m2/gm2-pg-boot): Ditto.
	($(objdir)/m2/gm2-pge-boot): Ditto.
	(m2/mc-boot-gen): Ditto.
	(m2/m2obj3): Ditto.
	(m2/gm2-libs-paranoid): Ditto.
	(m2/gm2-compiler-paranoid): Ditto.
	(m2/gm2-libs-paranoid): Ditto.
	(m2/gm2-compiler-paranoid): Ditto.
	(m2/gm2-libs-paranoid): Ditto.
	(m2/gm2-compiler-paranoid): Ditto.
	* config-lang.in (m2/gm2-compiler-boot): Remove mkdir.
	(m2/gm2-libs-boot): Ditto.
	(m2/gm2-ici-boot): Ditto.
	(m2/gm2-libiberty): Ditto.
	(m2/gm2-gcc): Ditto.
	(m2/gm2-compiler): Ditto.
	(m2/gm2-libs): Ditto.
	(m2/gm2-libs-iso): Ditto.
	(m2/gm2-compiler-paranoid): Ditto.
	(m2/gm2-libs-paranoid): Ditto.
	(m2/gm2-compiler-verify): Ditto.
	(m2/boot-bin): Ditto.
	(m2/gm2-libs-pim): Ditto.
	(m2/gm2-libs-coroutines): Ditto.
	(m2/gm2-libs-min): Ditto.
	(m2/pge-boot): Ditto.
	(plugin): Ditto.
	(stage1/m2): Ditto.
	(stage2/m2): Ditto.
	(stage3/m2): Ditto.
	(stage4/m2): Ditto.
	(m2/gm2-auto): Ditto.
	(m2/gm2-pg-boot): Ditto.
	(m2/gm2-pge-boot): Ditto.
	(m2/gm2-ppg-boot): Ditto.
	(m2/mc-boot): Ditto.
	(m2/mc-boot-ch): Ditto.
	(m2/mc-boot-gen): Ditto.

------ o< ------ o< ------ o< ------ o< ------ o< ------ o< ------ o<
  

Comments

Richard Biener Jan. 10, 2023, 10:16 a.m. UTC | #1
On Tue, Jan 10, 2023 at 2:49 AM Gaius Mulley via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
>
> PR-108142 Modula-2 configure generates many subdirectories in the top
> build directory.  This patch dynamically creates subdirectories under
> gcc/m2 if and when required.
>
> Bootstrapped on x86_64 gnu/linux, ok for master?
>
> regards,
> Gaius
>
>
> gcc/m2/ChangeLog:
>
>         * Make-lang.in (GM2_1): Change -B path to m2/stage1.
>         ($(objdir)/m2/images/gnu.eps): Check and create dest dir
>         if necessary.
>         (gm2-libs.texi-check): Check and create dir m2/gm2-libs-pim,
>         m2/gm2-libs-iso and m2/gm2-libs if necessary.
>         ($(objdir)/m2/gm2-compiler-boot): Remove.
>         ($(objdir)/m2/gm2-libs-boot): Remove.
>         ($(objdir)/m2/gm2-libs-libiberty): Remove.
>         ($(objdir)/m2/gm2-libiberty): Remove.
>         ($(objdir)/m2/gm2-gcc): Remove.
>         ($(objdir)/m2/gm2-compiler): Remove.
>         ($(objdir)/m2/gm2-libs): Remove.
>         ($(objdir)/m2/gm2-libs-iso): Remove.
>         ($(objdir)/m2/gm2-libs-min): Remove.
>         ($(objdir)/m2/gm2-compiler-paranoid): Remove.
>         ($(objdir)/m2/gm2-libs-paranoid): Remove.
>         ($(objdir)/m2/gm2-compiler-verify): Remove.
>         ($(objdir)/m2/boot-bin): Remove.
>         ($(objdir)/m2/gm2-libs-pim): Remove.
>         ($(objdir)/m2/gm2-libs-coroutines): Remove.
>         (stage1/m2): Remove.
>         (stage2/m2): Remove.
>         (stage3/m2): Remove.
>         (m2.stageprofile): New rule.
>         (m2.stagefeedback): New rule.
>         (cc1gm2$(exeext)): Change dependent name.
>         (m2/stage2/cc1gm2$(exeext)): Change dependent name.
>         Check and create dest dir.
>         (m2/stage1/cc1gm2$(exeext)): Check and create dest dir
>         if necessary.
>         (m2/gm2-gcc/%.o): Ditto.
>         (m2/gm2-gcc/rtegraph.o): Ditto.
>         (m2/gm2-gcc/$(SRC_PREFIX)%.h): Ditto.
>         (m2/gm2-gcc/$(SRC_PREFIX)%.h): Ditto.
>         (m2/mc-boot): Ditto.
>         (m2/mc-boot-ch): Ditto.
>         (m2/gm2-libs-boot): Ditto.
>         (m2/gm2-compiler-boot): Ditto.
>         (m2/gm2-compiler): Ditto.
>         (m2/gm2-libiberty): Ditto.
>         (m2/gm2-compiler): Ditto.
>         (m2/gm2-libs-iso): Ditto.
>         (m2/gm2-libs): Ditto.
>         (m2/gm2-libs-min): Ditto.
>         (m2/gm2-libs-coroutines): Ditto.
>         (m2/boot-bin): Ditto.
>         (m2/pge-boot): Ditto.
>         (m2/pge-boot): Ditto.
>         * Make-maintainer.in (m2/gm2-ppg-boot): Check and create
>         dest dir if necessary.
>         (m2): Ditto.
>         (m2/gm2-ppg-boot): Ditto.
>         (m2/gm2-pg-boot): Ditto.
>         (m2/gm2-auto): Ditto.
>         (m2/gm2-pg-boot): Ditto.
>         (m2/gm2-pge-boot): Ditto.
>         ($(objdir)/plugin): Ditto.
>         ($(objdir)/m2/mc-boot-ch): Ditto.
>         ($(objdir)/m2/mc-boot-gen): Ditto.
>         (m2/boot-bin): Ditto.
>         (m2/mc): Ditto.
>         (m2/mc-obj): Ditto.
>         ($(objdir)/m2/gm2-ppg-boot): Ditto.
>         ($(objdir)/m2/gm2-pg-boot): Ditto.
>         ($(objdir)/m2/gm2-pge-boot): Ditto.
>         (m2/mc-boot-gen): Ditto.
>         (m2/m2obj3): Ditto.
>         (m2/gm2-libs-paranoid): Ditto.
>         (m2/gm2-compiler-paranoid): Ditto.
>         (m2/gm2-libs-paranoid): Ditto.
>         (m2/gm2-compiler-paranoid): Ditto.
>         (m2/gm2-libs-paranoid): Ditto.
>         (m2/gm2-compiler-paranoid): Ditto.
>         * config-lang.in (m2/gm2-compiler-boot): Remove mkdir.
>         (m2/gm2-libs-boot): Ditto.
>         (m2/gm2-ici-boot): Ditto.
>         (m2/gm2-libiberty): Ditto.
>         (m2/gm2-gcc): Ditto.
>         (m2/gm2-compiler): Ditto.
>         (m2/gm2-libs): Ditto.
>         (m2/gm2-libs-iso): Ditto.
>         (m2/gm2-compiler-paranoid): Ditto.
>         (m2/gm2-libs-paranoid): Ditto.
>         (m2/gm2-compiler-verify): Ditto.
>         (m2/boot-bin): Ditto.
>         (m2/gm2-libs-pim): Ditto.
>         (m2/gm2-libs-coroutines): Ditto.
>         (m2/gm2-libs-min): Ditto.
>         (m2/pge-boot): Ditto.
>         (plugin): Ditto.
>         (stage1/m2): Ditto.
>         (stage2/m2): Ditto.
>         (stage3/m2): Ditto.
>         (stage4/m2): Ditto.
>         (m2/gm2-auto): Ditto.
>         (m2/gm2-pg-boot): Ditto.
>         (m2/gm2-pge-boot): Ditto.
>         (m2/gm2-ppg-boot): Ditto.
>         (m2/mc-boot): Ditto.
>         (m2/mc-boot-ch): Ditto.
>         (m2/mc-boot-gen): Ditto.
>
> ------ o< ------ o< ------ o< ------ o< ------ o< ------ o< ------ o<
> diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
> index 08d0f3b963f..a3751109481 100644
> --- a/gcc/m2/Make-lang.in
> +++ b/gcc/m2/Make-lang.in
> @@ -27,7 +27,7 @@ GM2_CROSS_NAME = `echo gm2|sed '$(program_transform_cross_name)'`
>
>  M2_MAINTAINER = no
>
> -GM2_1 = ./gm2 -B./stage1/m2 -g -fm2-g
> +GM2_1 = ./gm2 -B./m2/stage1 -g -fm2-g
>
>  GM2_FOR_TARGET = $(STAGE_CC_WRAPPER) ./gm2 -B./ -B$(build_tooldir)/bin/ -L$(objdir)/../ld $(TFLAGS)
>
> @@ -71,7 +71,6 @@ m2.srcextra: m2/SYSTEM-pim.texi m2/SYSTEM-iso.texi m2/gm2-libs.texi m2/gm2-ebnf.
>         -cp -p m2/SYSTEM-iso.texi $(srcdir)/m2
>         -cp -p m2/gm2-libs.texi $(srcdir)/m2
>         -cp -p m2/gm2-ebnf.texi $(srcdir)/m2
> -       find . -name '*.texi' -print
>  else
>  m2.srcextra:
>  endif
> @@ -167,7 +166,7 @@ doc/m2.info: $(TEXISRC)
>         else true; fi
>
>  $(objdir)/m2/images/gnu.eps: $(srcdir)/m2/images/gnupng
> -       test -d m2/images || mkdir -p m2/images
> +       -test -d m2/images || $(mkinstalldirs) m2/images
>         cp $(srcdir)/m2/images/gnu.eps $@
>
>  # gm2-libs.texi
> @@ -177,6 +176,9 @@ m2/gm2-libs.texi: gm2-libs.texi-check; @true
>  ifeq ($(HAVE_PYTHON),yes)
>  gm2-libs.texi-check: m2/SYSTEM-pim.texi m2/SYSTEM-iso.texi m2/Builtins.texi \
>                       $(objdir)/m2/gm2-libs-coroutines/SYSTEM.def
> +       test -d m2/gm2-libs-pim || $(mkinstalldirs) m2/gm2-libs-pim
> +       test -d m2/gm2-libs-iso || $(mkinstalldirs) m2/gm2-libs-iso
> +       test -d m2/gm2-libs || $(mkinstalldirs) m2/gm2-libs
>         $(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -t -uLibraries -s$(srcdir)/m2 -b$(objdir)/m2 -o $(objdir)/m2/gm2-libs.texi
>  else
>  gm2-libs.texi-check:
> @@ -293,59 +295,21 @@ Builtins.rst-check:  m2/gm2-libs/Builtins.def
>  endif
>         $(STAMP) Builtins.rst-check
>
> -$(objdir)/m2/gm2-compiler-boot:
> -       test -d $@ || mkdir $@
> -
> -$(objdir)/m2/gm2-libs-boot:
> -       test -d $@ || mkdir $@
> -
> -$(objdir)/m2/gm2-libiberty:
> -       test -d $@ || mkdir $@
> -
> -$(objdir)/m2/gm2-gcc:
> -       test -d $@ || mkdir $@
> -
> -$(objdir)/m2/gm2-compiler:
> -       test -d $@ || mkdir $@
> -
> -$(objdir)/m2/gm2-libs:
> -       test -d $@ || mkdir $@
> -
> -$(objdir)/m2/gm2-libs-iso:
> -       test -d $@ || mkdir $@
> -
> -$(objdir)/m2/gm2-libs-min:
> -       test -d $@ || mkdir $@
> -
> -$(objdir)/m2/gm2-compiler-paranoid:
> -       test -d $@ || mkdir $@
> -
> -$(objdir)/m2/gm2-libs-paranoid:
> -       test -d $@ || mkdir $@
> -
> -$(objdir)/m2/gm2-compiler-verify:
> -       test -d $@ || mkdir $@
> -
> -$(objdir)/m2/boot-bin:
> -       test -d $@ || mkdir $@
> -
> -$(objdir)/m2/gm2-libs-pim:
> -       test -d $@ || mkdir $@
> -
> -$(objdir)/m2/gm2-libs-coroutines:
> -       test -d $@ || mkdir $@
> -
> -stage1/m2:
> -       -test -d $@ || mkdir -p stage1/m2
> -
> -stage2/m2:
> -       -test -d $@ || mkdir -p stage2/m2
> -
> -stage3/m2:
> -       -test -d $@ || mkdir -p stage3/m2
> +# Stage hooks:
> +# The toplevel makefile has already created stage?/m2 at this point.
>
> -stage4/m2:
> -       -test -d $@ || mkdir -p stage4/m2
> +m2.stage1: stage1-start
> +       -mv m2/*$(objext) stage1/m2
> +m2.stage2: stage2-start
> +       -mv m2/*$(objext) stage2/m2
> +m2.stage3: stage3-start
> +       -mv m2/*$(objext) stage3/m2
> +m2.stage4: stage4-start
> +       -mv m2/*$(objext) stage4/m2
> +m2.stageprofile: stageprofile-start
> +       -mv m2/*$(objext) stageprofile/m2
> +m2.stagefeedback: stageprofile-start
> +       -mv m2/*$(objext) stagefeedback/m2
>
>  # No gm2-specific selftests
>  selftest-m2:
> @@ -424,7 +388,7 @@ override PLUGINCFLAGS := $(filter-out -mdynamic-no-pic,$(PLUGINCFLAGS))
>
>  plugin/m2rte$(soext): $(srcdir)/m2/plugin/m2rte.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \
>          insn-attr-common.h insn-flags.h $(generated_files)
> -       test -d plugin || mkdir plugin
> +       -test -d plugin || $(mkinstalldirs) plugin

I wonder if that's possibly racy (that's why you use mkinstalldirs?)?

If that was considered this looks OK

>         $(PLUGINCC) $(PLUGINCFLAGS) -fno-rtti -I. -I$(srcdir) $(INCINTL) -I$(srcdir)/m2 -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/../include -I$(srcdir)/../libcpp/include -Wall $(GMPINC) -Wno-literal-suffix -fPIC -c -o plugin/m2rte.o $(srcdir)/m2/plugin/m2rte.cc
>         $(PLUGINCC) $(PLUGINCFLAGS) $(PLUGINLDFLAGS) $(PLUGINLIBS) $(LIBINTL) -fno-rtti plugin/m2rte.o -shared -o $@
>
> @@ -444,20 +408,6 @@ m2.clean:
>  m2.extraclean:
>  m2.realclean:
>
> -# Stage hooks:
> -
> -m2.stage1: stage1-start
> -       -mv m2/*$(objext) stage1/m2
> -
> -m2.stage2: stage2-start
> -       -mv m2/*$(objext) stage2/m2
> -
> -m2.stage3: stage3-start
> -       -mv m2/*$(objext) stage3/m2
> -
> -m2.stage4: stage4-start
> -       -mv m2/*$(objext) stage4/m2
> -
>  quit: force
>         echo "calling exit"
>         exit 1
> @@ -537,12 +487,13 @@ GM2_LIBS_BOOT     = m2/gm2-compiler-boot/gm2.a \
>                      m2/gm2-libs-boot/libgm2.a \
>                      $(GM2-BOOT-O)
>
> -cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) $(m2.prev)
> +cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) $(m2.prev)
>         cp -p $< $@
>
> -stage2/m2/cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(P) \
> +m2/stage2/cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(P) \
>                              $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS) \
>                              m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext) m2/gm2-libs-boot/M2LINK.o
> +       -test -d m2/stage2 || $(mkinstalldirs) m2/stage2
>         @$(call LINK_PROGRESS,$(INDEX.m2),start)
>         +$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler/m2flex.o \
>                              attribs.o \
> @@ -551,12 +502,13 @@ stage2/m2/cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(
>                                $(BACKENDLIBS) $(LIBSTDCXX) -lm
>         @$(call LINK_PROGRESS,$(INDEX.m2),end)
>
> -stage1/m2/cc1gm2$(exeext): gm2$(exeext) m2/gm2-compiler-boot/m2flex.o \
> +m2/stage1/cc1gm2$(exeext): gm2$(exeext) m2/gm2-compiler-boot/m2flex.o \
>                              $(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) \
>                              $(GM2_LIBS_BOOT) $(MC_LIBS) \
>                              m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext) \
>                              m2/gm2-libs-boot/M2LINK.o \
>                              $(m2.prev)
> +       -test -d m2/stage1 || $(mkinstalldirs) m2/stage1
>         @$(call LINK_PROGRESS,$(INDEX.m2),start)
>         +$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler-boot/m2flex.o \
>                              attribs.o \
> @@ -574,6 +526,7 @@ GCC_HEADER_DEPENDENCIES_FOR_M2 = $(BUILD-BOOT-H) $(TIMEVAR_H) m2/gm2config.h $(C
>          $(generated_files) insn-attr-common.h
>
>  m2/gm2-gcc/%.o: $(srcdir)/m2/gm2-gcc/%.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2)
> +       -test -d m2/gm2-gcc || $(mkinstalldirs) m2/gm2-gcc
>         $(COMPILER) -c -g $(ALL_COMPILERFLAGS) \
>               $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
>
> @@ -581,6 +534,7 @@ m2/gm2-gcc/m2configure.o: $(srcdir)/m2/gm2-gcc/m2configure.cc \
>                 $(SYSTEM_H) $(GCC_H) $(CONFIG_H) \
>                 m2/gm2config.h $(TARGET_H) $(PLUGIN_HEADERS) \
>                 $(generated_files) $(C_TREE_H) insn-attr-common.h
> +       -test -d m2/gm2-gcc || $(mkinstalldirs) m2/gm2-gcc
>         $(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
>           $(DRIVER_DEFINES) \
>                 -DLIBSUBDIR=\"$(libsubdir)\" \
> @@ -601,6 +555,7 @@ m2/m2pp.o : $(srcdir)/m2/m2pp.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2)
>
>  m2/gm2-gcc/rtegraph.o: $(srcdir)/m2/gm2-gcc/rtegraph.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \
>                         gt-m2-rtegraph.h
> +       -test -d m2/gm2-gcc || $(mkinstalldirs) m2/gm2-gcc
>         $(COMPILER) -c -g $(GM2GCC) $(ALL_COMPILERFLAGS) \
>              $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
>
> @@ -609,6 +564,7 @@ c-family/m2pp.o : $(srcdir)/m2/m2pp.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2)
>              $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
>
>  m2/gm2-gcc/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-gcc/%.def $(MCDEPS)
> +       -test -d m2/gm2-gcc || $(mkinstalldirs) m2/gm2-gcc
>         $(MC) -o=$@ $(srcdir)/m2/gm2-gcc/$*.def
>
>  # The following tables define the source files which are translated into C using mc
> @@ -1361,15 +1317,19 @@ m2/boot-bin/mc$(exeext): $(BUILD-MC-BOOT-O) $(BUILD-MC-INTERFACE-O) \
>           mcflex.o m2/gm2-libs-boot/RTcodummy.o -lm
>
>  m2/mc-boot/$(SRC_PREFIX)%.o: m2/mc-boot/$(SRC_PREFIX)%.c
> +       -test -d m2/mc-boot || $(mkinstalldirs) m2/mc-boot
>         $(CXX) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@
>
>  m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/mc-boot-ch || $(mkinstalldirs) m2/mc-boot-ch
>         $(CXX) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
>
>  m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/mc-boot-ch || $(mkinstalldirs) m2/mc-boot-ch
>         $(CXX) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@
>
>  m2/mc-boot/main.o: $(M2LINK) $(srcdir)/m2/init/mcinit
> +       -test -d m2/mc-boot || $(mkinstalldirs) m2/mc-boot
>         unset CC ; $(M2LINK) -s --langc++ --exit --name m2/mc-boot/main.c $(srcdir)/m2/init/mcinit
>         $(CXX) -g -c -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) m2/mc-boot/main.c -o $@
>
> @@ -1380,57 +1340,73 @@ mcflex.c: $(srcdir)/m2/mc/mc.flex
>         flex -t $< > $@
>
>  m2/gm2-libs-boot/%.o: $(srcdir)/m2/gm2-libs-boot/%.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(MC) -o=m2/gm2-libs-boot/$*.c $(srcdir)/m2/gm2-libs-boot/$*.mod
>         $(COMPILER) -c -DIN_GCC $(CFLAGS) $(MCINCLUDES) m2/gm2-libs-boot/$*.c -o $@
>
>  m2/gm2-libs-boot/%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(MC) -o=m2/gm2-libs-boot/$*.c $(srcdir)/m2/gm2-libs/$*.mod
>         $(COMPILER) -c -DIN_GCC $(CFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/$*.c -o $@
>
>  m2/gm2-libs-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS)
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(MC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def
>
>  m2/gm2-libs-boot/RTcodummy.o: $(srcdir)/m2/gm2-libs-ch/RTcodummy.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-boot/RTintdummy.o: $(srcdir)/m2/gm2-libs-ch/RTintdummy.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-boot/wrapc.o: $(srcdir)/m2/gm2-libs-ch/wrapc.c m2/gm2-libs-boot/$(SRC_PREFIX)wrapc.h m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(CXX) -c -DHAVE_CONFIG_H $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-boot/M2LINK.o: $(srcdir)/m2/gm2-libs-ch/M2LINK.c m2/gm2-libs-boot/$(SRC_PREFIX)M2LINK.h m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(CXX) -c -DHAVE_CONFIG_H $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-boot/UnixArgs.o: $(srcdir)/m2/gm2-libs-ch/UnixArgs.cc m2/gm2-libs-boot/$(SRC_PREFIX)UnixArgs.h m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-boot/choosetemp.o: m2/gm2-libs-ch/choosetemp.c m2/gm2-libiberty/Gchoosetemp.h m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-boot/errno.o: $(srcdir)/m2/gm2-libs-ch/errno.c m2/gm2-libs-boot/$(SRC_PREFIX)errno.h m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-boot/dtoa.o: $(srcdir)/m2/gm2-libs-ch/dtoa.cc m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-boot/ldtoa.o: $(srcdir)/m2/gm2-libs-ch/ldtoa.cc m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-boot/termios.o: $(srcdir)/m2/gm2-libs-ch/termios.c $(BUILD-LIBS-BOOT-H) m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-boot/SysExceptions.o: $(srcdir)/m2/gm2-libs-ch/SysExceptions.c \
>                                    m2/gm2-libs-boot/$(SRC_PREFIX)SysExceptions.h m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-boot/SysStorage.o: $(srcdir)/m2/gm2-libs/SysStorage.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(MC) -o=m2/gm2-libs-boot/SysStorage.c $(srcdir)/m2/gm2-libs/SysStorage.mod
>         $(COMPILER) -DIN_GCC -c $(CFLAGS) \
>            -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) \
>            m2/gm2-libs-boot/SysStorage.c -o m2/gm2-libs-boot/SysStorage.o
>
>  m2/gm2-compiler-boot/M2GCCDeclare.o: $(srcdir)/m2/gm2-compiler/M2GCCDeclare.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
>         $(MC) --extended-opaque -o=m2/gm2-compiler-boot/M2GCCDeclare.c $<
>         $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
>              -I. -I$(srcdir)/../include -I$(srcdir) \
> @@ -1438,6 +1414,7 @@ m2/gm2-compiler-boot/M2GCCDeclare.o: $(srcdir)/m2/gm2-compiler/M2GCCDeclare.mod
>              -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/M2GCCDeclare.c -o $@
>
>  m2/gm2-compiler-boot/M2Error.o: $(srcdir)/m2/gm2-compiler/M2Error.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
>         $(MC) --extended-opaque -o=m2/gm2-compiler-boot/M2Error.c $<
>         $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
>              -I. -I$(srcdir)/../include -I$(srcdir) \
> @@ -1445,6 +1422,7 @@ m2/gm2-compiler-boot/M2Error.o: $(srcdir)/m2/gm2-compiler/M2Error.mod $(MCDEPS)
>              -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/M2Error.c -o $@
>
>  m2/gm2-compiler-boot/%.o: $(srcdir)/m2/gm2-compiler/%.mod $(BUILD-BOOT-H) $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
>         $(MC) -o=m2/gm2-compiler-boot/$*.c $(srcdir)/m2/gm2-compiler/$*.mod
>         $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
>              -I. -I$(srcdir)/../include -I$(srcdir) \
> @@ -1452,6 +1430,7 @@ m2/gm2-compiler-boot/%.o: $(srcdir)/m2/gm2-compiler/%.mod $(BUILD-BOOT-H) $(MCDE
>              -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/$*.c -o $@
>
>  m2/gm2-compiler-boot/%.o: m2/gm2-compiler-boot/%.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
>         $(MC) -o=m2/gm2-compiler-boot/$*.c m2/gm2-compiler-boot/$*.mod
>         $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
>              -I. -I$(srcdir)/../include -I$(srcdir) \
> @@ -1459,37 +1438,46 @@ m2/gm2-compiler-boot/%.o: m2/gm2-compiler-boot/%.mod $(MCDEPS) $(BUILD-BOOT-H)
>              -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/$*.c -o $@
>
>  m2/gm2-compiler-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-compiler/%.def $(MCDEPS)
> +       -test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
>         $(MC) -o=$@ $(srcdir)/m2/gm2-compiler/$*.def
>
>  m2/gm2-compiler-boot/m2flex.o: m2/gm2-compiler/m2flex.c $(BUILD-BOOT-H) $(TIMEVAR_H) \
>          $(BUILD-LIBS-BOOT-H)  m2/gm2-compiler-boot/$(SRC_PREFIX)NameKey.h \
>          $(CONFIG_H) m2/gm2config.h $(TARGET_H) $(PLUGIN_HEADERS)
> +       -test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
>         $(COMPILER) -c -g $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
>            $(GM2GCC) $(INCLUDES) -I$(srcdir)/m2 \
>            -Im2 -Im2/gm2-compiler-boot -Im2/gm2-libs-boot $< -o $@
>
>  m2/gm2-compiler/m2flex.c: $(srcdir)/m2/m2.flex $(TIMEVAR_H) insn-attr-common.h
> +       -test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
>         flex -t $< | sed -e 's/ malloc/ xmalloc/' | sed -e 's/ realloc/ xrealloc/' > $@
>
>  m2/gm2-libiberty/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libiberty/%.def $(MCDEPS)
> +       -test -d m2/gm2-libiberty || $(mkinstalldirs) m2/gm2-libiberty
>         $(MC) -o=$@ $(srcdir)/m2/gm2-libiberty/$*.def
>
>  # The rules to build objects in gm2-compiler and gm2-libs directories.
>
>  m2/gm2-compiler/%.o: $(srcdir)/m2/gm2-compiler/%.mod
> +       -test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
>         $(GM2_1) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@
>
>  m2/gm2-compiler/m2flex.o: m2/gm2-compiler/m2flex.c m2/gm2-libs/gm2-libs-host.h $(TIMEVAR_H)
> +       -test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
>         $(COMPILER) -c -g $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
>            $(GM2GCC) -Im2/gm2-compiler-boot -Im2/gm2-libs-boot $< -o $@
>
>  m2/gm2-compiler/%.o: m2/gm2-compiler/%.mod
> +       -test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
>         $(GM2_1) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@
>
>  m2/gm2-libs-iso/%.o: $(srcdir)/m2/gm2-libs-iso/%.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-iso || $(mkinstalldirs) m2/gm2-libs-iso
>         $(CXX) -DBUILD_GM2_LIBS_TARGET -DBUILD_GM2_LIBS -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-iso/%.o: $(srcdir)/m2/gm2-libs-iso/%.mod
> +       -test -d m2/gm2-libs-iso || $(mkinstalldirs) m2/gm2-libs-iso
>         $(GM2_1) $(GM2_ISO_FLAGS) -c -B./ -Im2/gm2-libs-iso:$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs $< -o $@
>
>
> @@ -1497,6 +1485,7 @@ m2/gm2-libs-iso/%.o: $(srcdir)/m2/gm2-libs-iso/%.mod
>  # again using itself.
>
>  m2/gm2-libs/gm2-libs-host.h:
> +       -test -d m2/gm2-libs || $(mkinstalldirs) m2/gm2-libs
>         echo "Configuring to build libraries using native compiler" ; \
>          NEW_SRCDIR=`${srcdir}/m2/tools-src/calcpath ../../ ${srcdir} m2/gm2-libs` ; \
>          export NEW_SRCDIR ; \
> @@ -1528,6 +1517,7 @@ m2/gm2config.h:
>          fi
>
>  $(objdir)/m2/gm2-libs-min/SYSTEM.def: $(GM2_PROG_DEP)
> +       -test -d m2/gm2-libs-min || $(mkinstalldirs) m2/gm2-libs-min
>         $(SHELL) $(srcdir)/m2/tools-src/makeSystem -fpim \
>               $(srcdir)/m2/gm2-libs-min/SYSTEM.def \
>               $(srcdir)/m2/gm2-libs-min/SYSTEM.mod \
> @@ -1535,6 +1525,7 @@ $(objdir)/m2/gm2-libs-min/SYSTEM.def: $(GM2_PROG_DEP)
>               "$(GM2_FOR_TARGET)" $@
>
>  $(objdir)/m2/gm2-libs/SYSTEM.def: $(GM2_PROG_DEP)
> +       -test -d m2/gm2-libs || $(mkinstalldirs) m2/gm2-libs
>         echo "GM2_FOR_TARGET $(GM2_FOR_TARGET)"
>         echo "GCC_FOR_TARGET $(GCC_FOR_TARGET)"
>         $(SHELL) $(srcdir)/m2/tools-src/makeSystem -fpim \
> @@ -1544,6 +1535,7 @@ $(objdir)/m2/gm2-libs/SYSTEM.def: $(GM2_PROG_DEP)
>               "$(GM2_FOR_TARGET)" $@
>
>  $(objdir)/m2/gm2-libs-iso/SYSTEM.def: $(GM2_PROG_DEP)
> +       -test -d m2/gm2-libs-iso || $(mkinstalldirs) m2/gm2-libs-iso
>         $(SHELL) $(srcdir)/m2/tools-src/makeSystem -fiso \
>               $(srcdir)/m2/gm2-libs-iso/SYSTEM.def \
>               $(srcdir)/m2/gm2-libs-iso/SYSTEM.mod \
> @@ -1551,6 +1543,7 @@ $(objdir)/m2/gm2-libs-iso/SYSTEM.def: $(GM2_PROG_DEP)
>               "$(GM2_FOR_TARGET)" $@
>
>  $(objdir)/m2/gm2-libs-coroutines/SYSTEM.def: $(GM2_PROG_DEP)
> +       -test -d m2/gm2-libs-coroutines || $(mkinstalldirs) m2/gm2-libs-coroutines
>         $(SHELL) $(srcdir)/m2/tools-src/makeSystem -fpim \
>               $(srcdir)/m2/gm2-libs-coroutines/SYSTEM.def \
>               $(srcdir)/m2/gm2-libs-coroutines/SYSTEM.mod \
> @@ -1562,11 +1555,13 @@ build-compiler: $(GM2-COMP-MODS:%.mod=m2/gm2-compiler/%.o) \
>                  m2/gm2-compiler/m2flex.o
>
>  m2/gm2-compiler/gm2.a: build-compiler gm2$(exeext)
> +       -test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
>         $(AR_FOR_TARGET) cr $@ $(GM2-COMP-MODS:%.mod=m2/gm2-compiler/%.o) \
>                      $(GM2-AUTO-MODS:%.mod=m2/gm2-compiler/%.o)
>         $(RANLIB) $@
>
>  m2/gm2-libs-boot/libgm2.a: m2/boot-bin/mc$(exeext) $(BUILD-LIBS-BOOT)
> +       -test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
>         $(AR) cr $@ $(GM2-LIBS-BOOT-MODS:%.mod=m2/gm2-libs-boot/%.o) \
>                      $(GM2-LIBS-BOOT-CC:%.cc=m2/gm2-libs-boot/%.o) \
>                      $(GM2-LIBS-BOOT-C:%.c=m2/gm2-libs-boot/%.o)
> @@ -1574,6 +1569,7 @@ m2/gm2-libs-boot/libgm2.a: m2/boot-bin/mc$(exeext) $(BUILD-LIBS-BOOT)
>
>  m2/gm2-compiler-boot/gm2.a: m2/boot-bin/mc$(exeext) m2/boot-bin/mklink$(exeext) \
>                           $(BUILD-LIBS-BOOT) $(BUILD-COMPILER-BOOT)
> +       -test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
>         $(AR) cr $@ $(GM2-COMP-BOOT-MODS:%.mod=m2/gm2-compiler-boot/%.o) \
>                      $(GM2-AUTO-MODS:%.mod=m2/gm2-compiler-boot/%.o)
>         $(RANLIB) $@
> @@ -1581,15 +1577,19 @@ m2/gm2-compiler-boot/gm2.a: m2/boot-bin/mc$(exeext) m2/boot-bin/mklink$(exeext)
>  m2/gm2-compiler-boot/gm2.a: m2/boot-bin/mc$(exeext)
>
>  m2/boot-bin/mklink$(exeext): $(srcdir)/m2/tools-src/mklink.c
> +       -test -d m2/boot-bin || $(mkinstalldirs) m2/boot-bin
>         $(CXX) $(CFLAGS) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) $< -o $@
>
>  m2/gm2-compiler-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-compiler-boot/%.def $(MCDEPS)
> +       -test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
>         $(MC) --quiet -o=$@ $(srcdir)/m2/gm2-compiler-boot/$*.def
>
>  m2/gm2-compiler/%.mod: $(srcdir)/m2/gm2-compiler/%.bnf $(PGE)
> +       -test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
>         $(PGE) -k -l $< -o $@
>
>  m2/gm2-compiler-boot/%.mod: $(srcdir)/m2/gm2-compiler/%.bnf $(PGE)
> +       -test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
>         $(PGE) -k -l $< -o $@
>
>  check-m2: check-gm2
> @@ -1658,9 +1658,11 @@ ifeq ($(M2_MAINTAINER),yes)
>  include m2/Make-maintainer
>  else
>  m2/pge-boot/%.o: m2/pge-boot/%.c m2/gm2-libs/gm2-libs-host.h m2/gm2config.h
> +       -test -d m2/pge-boot ||$(mkinstalldirs) m2/pge-boot
>         $(CXX) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
>
>  m2/pge-boot/%.o: m2/pge-boot/%.cc m2/gm2-libs/gm2-libs-host.h m2/gm2config.h
> +       -test -d m2/pge-boot || $(mkinstalldirs) m2/pge-boot
>         $(CXX) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
>
>  $(PGE): $(BUILD-PGE-O)
> diff --git a/gcc/m2/Make-maintainer.in b/gcc/m2/Make-maintainer.in
> index 2460b979207..b41f5858e17 100644
> --- a/gcc/m2/Make-maintainer.in
> +++ b/gcc/m2/Make-maintainer.in
> @@ -20,7 +20,7 @@
>
>  # QUIAT=@
>  XGCC = ./xgcc -B./
> -GM2_2 = ./gm2 -B./stage2/m2 -g -fm2-g
> +GM2_2 = ./gm2 -B./m2/m2obj2 -g -fm2-g
>
>  # m2/ppg$(exeext)  is the recursive descent parser generator.
>
> @@ -96,21 +96,26 @@ BUILD-PPG-LIBS-H = $(PPG-LIB-DEFS:%.def=m2/gm2-ppg-boot/$(SRC_PREFIX)%.h)
>  BUILD-PPG-H = m2/boot-bin/mc$(exeext) $(BUILD-PPG-LIBS-H)
>
>  m2/gm2-ppg-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS)
> +       -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot
>         $(MCC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def
>
>  m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@
>
>  m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@
>
>  m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot
>         $(MCC) -o=m2/gm2-ppg-boot/$(SRC_PREFIX)$*.c $(srcdir)/m2/gm2-libs/$*.mod
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) \
>                -Im2/gm2-ppg-boot -I$(srcdir)/m2/mc-boot -Im2/gm2-libs-boot \
>                -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)$*.c -o $@
>
>  m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-compiler/%.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot
>         $(MCC) -o=m2/gm2-ppg-boot/$(SRC_PREFIX)$*.c $(srcdir)/m2/gm2-compiler/$*.mod
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) \
>                -Im2/mc-boot -Im2/gm2-compiler-boot -Im2/gm2-libs-boot \
> @@ -119,17 +124,19 @@ m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-compiler/%.mod $(MCDEPS) $(BU
>  m2/ppg$(exeext): m2/boot-bin/mc $(BUILD-PPG-O) $(BUILD-MC-INTERFACE-O) m2/gm2-ppg-boot/main.o \
>                   m2/gm2-libs-boot/RTcodummy.o m2/mc-boot-ch/$(SRC_PREFIX)abort.o \
>                   m2/gm2-libs-boot/M2LINK.o
> +       -test -d m2 || $(mkinstalldirs) m2
>         +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-PPG-O) m2/gm2-ppg-boot/main.o \
>                   m2/gm2-libs-boot/RTcodummy.o m2/mc-boot-ch/$(SRC_PREFIX)abort.o \
>                   m2/gm2-libs-boot/M2LINK.o -lm
>
>  m2/gm2-ppg-boot/main.o: $(M2LINK) $(srcdir)/m2/init/mcinit
> +       -test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot
>         unset CC ; $(M2LINK) -s --langc++ --exit --name mainppginit.c $(srcdir)/m2/init/ppginit
>         mv mainppginit.c m2/gm2-ppg-boot/main.c
>         $(CXX) $(INCLUDES) -g -c -o $@ m2/gm2-ppg-boot/main.c
>
>  m2/gm2-auto:
> -       test -d $@ || mkdir -p $@
> +       -test -d $@ || $(mkinstalldirs) $@
>
>  # m2/pg$(exext) is the 2nd generation parser generator built from ebnf
>  # without error recovery
> @@ -143,15 +150,19 @@ BUILD-PG-O = $(PPG-INTERFACE-C:%.c=m2/gm2-pg-boot/$(SRC_PREFIX)%.o) \
>               $(PG-SRC:%.mod=m2/gm2-pg-boot/$(SRC_PREFIX)%.o)
>
>  m2/gm2-pg-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS)
> +       -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
>         $(MCC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def
>
>  m2/gm2-pg-boot/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@
>
>  m2/gm2-pg-boot/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@
>
>  m2/gm2-pg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
>         $(MCC) -o=m2/gm2-pg-boot/$(SRC_PREFIX)$*.c $(srcdir)/m2/gm2-libs/$*.mod
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -Im2/gm2-pg-boot  -I$(srcdir)/m2/mc-boot \
>                 -I$(srcdir)/m2/mc-boot-ch \
> @@ -159,11 +170,13 @@ m2/gm2-pg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-B
>                -g -c m2/gm2-pg-boot/$(SRC_PREFIX)$*.c -o $@
>
>  m2/gm2-pg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-compiler/%.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
>         $(MCC) -o=m2/gm2-pg-boot/$(SRC_PREFIX)$*.c $(srcdir)/m2/gm2-compiler/$*.mod
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -Im2/mc-boot -Im2/gm2-compiler-boot -Im2/gm2-libs-boot \
>                -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-pg-boot/$(SRC_PREFIX)$*.c -o $@
>
>  m2/gm2-pg-boot/$(SRC_PREFIX)pg.o:  m2/gm2-auto/pg.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
>         $(MCC) -o=m2/gm2-pg-boot/$(SRC_PREFIX)pg.c m2/gm2-auto/pg.mod
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -Im2/mc-boot -Im2/gm2-compiler-boot -Im2/gm2-libs-boot \
>                -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-pg-boot/$(SRC_PREFIX)pg.c -o $@
> @@ -172,20 +185,24 @@ m2/pg$(exeext): m2/boot-bin/mc \
>      $(BUILD-PG-O) $(GM2-PPG-MODS:%.mod=m2/gm2-pg-boot/%.o) \
>      $(BUILD-MC-INTERFACE-O) m2/gm2-pg-boot/main.o m2/gm2-libs-boot/RTcodummy.o \
>      m2/mc-boot-ch/$(SRC_PREFIX)abort.o m2/gm2-libs-boot/M2LINK.o
> +       -test -d m2 || $(mkinstalldirs) m2
>         +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-PG-O) \
>           m2/gm2-pg-boot/main.o m2/gm2-libs-boot/RTcodummy.o \
>           m2/gm2-libs-boot/M2LINK.o \
>           m2/mc-boot-ch/$(SRC_PREFIX)abort.o -lm
>
>  m2/gm2-auto/pginit:
> +       -test -d m2/gm2-auto || $(mkinstalldirs) m2/gm2-auto
>         sed -e 's/ppg/pg/' < $(srcdir)/m2/init/ppginit > $@
>
>  m2/gm2-pg-boot/main.o: m2/gm2-auto/pginit $(M2LINK)
> +       -test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
>         unset CC ; $(M2LINK) -s --langc++ --exit --name mainpginit.c m2/gm2-auto/pginit
>         mv mainpginit.c m2/gm2-pg-boot/main.c
>         $(CXX) $(INCLUDES) -g -c -o $@ m2/gm2-pg-boot/main.c
>
>  m2/pg-e$(exeext): m2/pg$(exeext)
> +       -test -d m2 || $(mkinstalldirs) m2
>         $(CP) m2/pg$(exeext) m2/pg-e$(exeext)
>         $(SHELL) $(srcdir)/m2/tools-src/buildpg $(srcdir)/m2/gm2-compiler/ppg.mod pg -e > m2/gm2-auto/t.bnf
>         ./m2/pg-e$(exeext) -e -l m2/gm2-auto/t.bnf | sed -e 's/t\.bnf/pg\.bnf/' > m2/gm2-auto/t.mod
> @@ -196,6 +213,7 @@ m2/pg-e$(exeext): m2/pg$(exeext)
>         $(RM) m2/gm2-auto/t.bnf m2/gm2-auto/t.mod
>
>  m2/gm2-auto/pg.mod: m2/ppg$(exeext)
> +       -test -d m2/gm2-auto || $(mkinstalldirs) m2/gm2-auto
>         $(SHELL) $(srcdir)/m2/tools-src/buildpg $(srcdir)/m2/gm2-compiler/ppg.mod pg -e > m2/gm2-auto/pg.bnf
>         ./m2/ppg$(exeext) -e -l m2/gm2-auto/pg.bnf > m2/gm2-auto/pg.mod
>
> @@ -210,58 +228,74 @@ BUILD-PGE-O = $(PPG-INTERFACE-C:%.c=m2/gm2-pge-boot/$(SRC_PREFIX)%.o) \
>                $(PGE-SRC:%.mod=m2/gm2-pge-boot/$(SRC_PREFIX)%.o)
>
>  m2/gm2-auto/pge.mod: m2/pg$(exeext)
> +       -test -d m2/gm2-auto || $(mkinstalldirs) m2/gm2-auto
>         $(SHELL) $(srcdir)/m2/tools-src/buildpg $(srcdir)/m2/gm2-compiler/ppg.mod pge > m2/gm2-auto/pge.bnf
>         ./m2/pg$(exeext) -l m2/gm2-auto/pge.bnf -o m2/gm2-auto/pge.mod
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS)
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(MCC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)libc.o: $(srcdir)/m2/mc-boot-ch/Glibc.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs -g -c $< -o $@
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)mcrts.o:  $(srcdir)/m2/mc-boot-ch/Gmcrts.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs -g -c $< -o $@
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)UnixArgs.o:  $(srcdir)/m2/mc-boot-ch/GUnixArgs.cc
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c $< -o $@
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)Selective.o:  $(srcdir)/m2/mc-boot-ch/GSelective.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -Im2/gm2-libs -g -c $< -o $@
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)termios.o:  $(srcdir)/m2/mc-boot-ch/Gtermios.cc m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)SysExceptions.o:  $(srcdir)/m2/mc-boot-ch/GSysExceptions.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)ldtoa.o:  $(srcdir)/m2/mc-boot-ch/Gldtoa.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)dtoa.o:  $(srcdir)/m2/mc-boot-ch/Gdtoa.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)wrapc.o:  $(srcdir)/m2/mc-boot-ch/Gwrapc.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)SYSTEM.o:  $(srcdir)/m2/mc-boot-ch/GSYSTEM.c
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c $< -o $@
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)errno.o:  $(srcdir)/m2/mc-boot-ch/Gerrno.c
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c $< -o $@
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(MCC) -o=m2/gm2-pge-boot/$(SRC_PREFIX)$*.c $(srcdir)/m2/gm2-libs/$*.mod
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -Im2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \
>                -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \
>                $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)$*.c -o $@
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-compiler/%.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(MCC) -o=m2/gm2-pge-boot/$(SRC_PREFIX)$*.c $(srcdir)/m2/gm2-compiler/$*.mod
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -Im2/mc-boot -Im2/gm2-compiler-boot \
>                -Im2/gm2-libs-boot \
>                -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)$*.c -o $@
>
>  m2/gm2-pge-boot/$(SRC_PREFIX)pge.o:  m2/gm2-auto/pge.mod $(MCDEPS) $(BUILD-BOOT-H)
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(MCC) -o=m2/gm2-pge-boot/$(SRC_PREFIX)pge.c m2/gm2-auto/pge.mod
>         $(CXX) -I. -I$(srcdir)/../include -I$(srcdir) \
>                -Im2/mc-boot -Im2/gm2-compiler-boot -Im2/gm2-libs-boot \
> @@ -271,6 +305,7 @@ m2/pge$(exeext): m2/boot-bin/mc \
>      $(BUILD-PGE-O) $(GM2-PPG-MODS:%.mod=m2/gm2-pge-boot/%.o) \
>      $(BUILD-MC-INTERFACE-O) m2/gm2-pge-boot/main.o m2/gm2-libs-boot/RTcodummy.o \
>      m2/mc-boot-ch/$(SRC_PREFIX)abort.o m2/gm2-libs-boot/M2LINK.o
> +       -test -d m2 || $(mkinstalldirs) m2
>         +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-PGE-O) \
>           m2/gm2-pge-boot/main.o m2/gm2-libs-boot/RTcodummy.o \
>           m2/mc-boot-ch/$(SRC_PREFIX)abort.o m2/gm2-libs-boot/M2LINK.o -lm
> @@ -285,27 +320,31 @@ m2/pge$(exeext): m2/boot-bin/mc \
>         $(RM) m2/gm2-auto/t.mod m2/gm2-auto/t1.mod m2/gm2-auto/t2.mod
>
>  m2/gm2-auto/pgeinit:
> +       -test -d m2/gm2-auto || $(mkinstalldirs) m2/gm2-auto
>         sed -e 's/ppg/pge/' < $(srcdir)/m2/init/ppginit > $@
>
>  m2/gm2-pge-boot/main.o: m2/gm2-auto/pgeinit $(M2LINK)
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         unset CC ; $(M2LINK) -s --langc++ --exit --name mainpgeinit.c m2/gm2-auto/pgeinit
>         mv mainpgeinit.c m2/gm2-pge-boot/main.c
>         $(CXX) $(INCLUDES) -g -c -o $@ m2/gm2-pge-boot/main.c
>
>  $(objdir)/m2/gm2-ppg-boot:
> -       test -d $@ || mkdir $@
> +       -test -d $@ || $(mkinstalldirs) $@
>
>  $(objdir)/m2/gm2-pg-boot:
> -       test -d $@ || mkdir $@
> +       -test -d $@ || $(mkinstalldirs) $@
>
>  $(objdir)/m2/gm2-pge-boot:
> -       test -d $@ || mkdir $@
> +       -test -d $@ || $(mkinstalldirs) $@
>
>  m2/gm2-auto/pg.o: m2/gm2-auto/pg.mod $(MCDEPS)
> +       -test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
>         $(MC) --quiet -o=m2/gm2-auto/pg.c m2/gm2-auto/pg.mod
>         $(COMPILER) -c $(CFLAGS) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) m2/gm2-auto/pg.c -o $@
>
>  m2/gm2-auto/pge.o: m2/gm2-auto/pge.mod $(MCDEPS)
> +       -test -d m2/gm2-auto || $(mkinstalldirs) m2/gm2-auto
>         $(MC) --quiet -o=m2/gm2-auto/pge.c m2/gm2-auto/pge.mod
>         $(COMPILER) -c $(CFLAGS) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) m2/gm2-auto/pge.c -o $@
>
> @@ -400,7 +439,7 @@ mc-help:  force
>         @echo "m2/pge          build the parser generator (needed by mc-maintainer)"
>
>  m2/mc-obj:
> -       mkdir $@
> +       $(mkinstalldirs) $@
>
>  mc-verify:  mc-clean mc-bootstrap mc
>         mv mc m2/boot-bin/mc.m2
> @@ -442,7 +481,7 @@ m2/boot-bin/mc-devel$(exeext): m2/mc-obj/mcp1.mod \
>                                 mcflex.c \
>                                 m2/mc-boot-ch/Gabort.o
>         $(RM) -rf mc-obj
> -       mkdir mc-obj
> +       $(mkinstalldirs) mc-obj
>         $(CC) -I$(srcdir)/m2/mc -c -g mcflex.c -o mc-obj/mcflex.o
>         $(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/decl.mod -o mc-obj/decl.o
>         $(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcStream.mod -o mc-obj/mcStream.o
> @@ -484,13 +523,16 @@ m2/boot-bin/mc-opt$(exeext): m2/mc-obj/mcp1.mod \
>                               m2/mc-obj/mcp4.mod \
>                               m2/mc-obj/mcp5.mod \
>                               mcflex.c
> +       -test -d m2/boot-bin || $(mkinstalldirs) m2/boot-bin
>         g++ -I$(srcdir)/m2/mc -c -g mcflex.c
>         $(BOOTGM2) -fsources -fm2-whole-program -g -I$(srcdir)/m2/mc:$(objdir)/m2/mc-obj:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/mc $(srcdir)/m2/mc/top.mod
>
>  m2/mc/decl.o:  $(srcdir)/m2/mc/decl.mod
> +       -test -d m2/mc || $(mkinstalldirs) m2/mc
>         $(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) -o $@ $(srcdir)/m2/mc/decl.mod
>
>  m2/mc-obj/%.mod: $(srcdir)/m2/mc/%.bnf $(PGE)
> +       -test -d m2/mc-obj || $(mkinstalldirs) m2/mc-obj
>         $(PGE) -l $< -o $@
>
>  gm2-bootstrap: mc-devel
> @@ -500,16 +542,16 @@ gm2-bootstrap: mc-devel
>
>
>  $(objdir)/plugin:
> -       test -d $@ || mkdir -p $@
> +       -test -d $@ || $(mkinstalldirs) $@
>
>  $(objdir)/m2/mc-boot:
> -       test -d $@ || mkdir -p $@
> +       -test -d $@ || $(mkinstalldirs) $@
>
>  $(objdir)/m2/mc-boot-ch:
> -       test -d $@ || mkdir -p $@
> +       -test -d $@ || $(mkinstalldirs) $@
>
>  $(objdir)/m2/mc-boot-gen:
> -       test -d $@ || mkdir -p $@
> +       -test -d $@ || $(mkinstalldirs) $@
>
>  mc-autogen: mc-clean mc-devel \
>              $(BUILD-MC-BOOT-H) $(BUILD-MC-BOOT-C) \
> @@ -528,24 +570,31 @@ EXTENDED_OPAQUE =
>  MC_OPTIONS = $(MC_COPYRIGHT) --gcc-config-system --olang=c++
>
>  m2/mc-boot-gen/$(SRC_PREFIX)%.h: $(srcdir)/m2/mc/%.def
> +       -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
>         ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $<
>
>  m2/mc-boot-gen/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def
> +       -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
>         ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $<
>
>  m2/mc-boot-gen/$(SRC_PREFIX)decl.c: $(srcdir)/m2/mc/decl.mod
> +       -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
>         ./mc $(MC_OPTIONS) --extended-opaque -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso --h-file-prefix=$(SRC_PREFIX) -o=$@ $<
>
>  m2/mc-boot-gen/$(SRC_PREFIX)%.c: $(srcdir)/m2/mc/%.mod
> +       -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
>         ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $<
>
>  m2/mc-boot-gen/$(SRC_PREFIX)%.c: $(srcdir)/m2/gm2-libs/%.mod
> +       -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
>         ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $<
>
>  m2/mc-boot-gen/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs-iso/%.def
> +       -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
>         ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $<
>
>  m2/mc-boot-gen/$(SRC_PREFIX)%.c: m2/mc-obj/%.mod
> +       -test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
>         ./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $<
>
>  # mc-bootstrap compiles mc using the C version previously generated by mc-autogen.
> @@ -574,9 +623,11 @@ gm2.maintainer-help: force
>
>  #
>  #  verify the compiler can be built across three generations of cc1gm2 diffing assembly output.
> -#  stage1/m2/cc1gm2 built by translating M2 into C++.
> -#  stage2/m2/cc1gm2 built from stage1/m2/cc1gm2.
> -#  stage3/m2/cc1gm2 built from stage2/m2/cc1gm2.
> +#  m2/stage1/cc1gm2 built by translating all M2 sources into C++.
> +#  m2/m2obj2/cc1gm2 built from m2/stage1/cc1gm2.
> +#  m2/m2obj3/cc1gm2 built from m2/m2obj2/cc1gm2.
> +#
> +#  This test only makes sense if host = target = build
>  #
>
>  # GM2-VERIFY-MODS is a list of modules which have no __DATE__ stamp inside them
> @@ -608,11 +659,12 @@ GM2-VERIFY-AUTO    = P1Build.mod       P2Build.mod     PCBuild.mod     P3Build.m
>  GM2_LIBS_PARANOID = m2/gm2-compiler-paranoid/gm2.a \
>                      m2/gm2-libs-paranoid/libgm2.a                       # build it again using GM2_LIBS
>
> -gm2.paranoid: stage3/m2/cc1gm2$(exeext) gm2.verifyparanoid
> +gm2.paranoid: m2/m2obj3/cc1gm2$(exeext) gm2.verifyparanoid
>
> -stage3/m2/cc1gm2$(exeext): stage2/m2/cc1gm2$(exeext) m2/gm2-compiler-paranoid/m2flex.o \
> +m2/m2obj3/cc1gm2$(exeext): m2/m2obj2/cc1gm2$(exeext) m2/gm2-compiler-paranoid/m2flex.o \
>                              $(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS_PARANOID) \
>                              m2/gm2-gcc/rtegraph.o plugin/m2rte$(exeext).so m2/gm2-libs-boot/M2LINK.o
> +       -test -d m2/m2obj3 || $(mkinstalldirs) m2/m2obj3
>         @$(call LINK_PROGRESS,$(INDEX.m2),start)
>         +$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler-paranoid/m2flex.o \
>                              attribs.o \
> @@ -624,7 +676,7 @@ stage3/m2/cc1gm2$(exeext): stage2/m2/cc1gm2$(exeext) m2/gm2-compiler-paranoid/m2
>
>  # gm2.verifyparanoid diffs the output of all three compilers with the compiler source code
>
> -gm2.verifyparanoid: stage1/m2/cc1gm2$(exeext) stage2/m2/cc1gm2$(exeext) stage3/m2/cc1gm2$(exeext) force
> +gm2.verifyparanoid: m2/stage1/cc1gm2$(exeext) m2/m2obj2/cc1gm2$(exeext) m2/m2obj3/cc1gm2$(exeext) force
>         @echo "verifying the three generations of GNU Modula-2 compilers - it may take some time.."
>         $(QUIAT)for i in $(GM2-VERIFY-MODS) ; do \
>             echo -n "$$i " ; \
> @@ -652,11 +704,11 @@ gm2.verifyparanoid: stage1/m2/cc1gm2$(exeext) stage2/m2/cc1gm2$(exeext) stage3/m
>         $(QUIAT)for i in x $(GM2-VERIFY-AUTO) ; do \
>             if [ -f m2/gm2-auto/$$i ] ; then \
>                echo -n "$$i " ; \
> -              ./gm2 -S $(GM2_FLAGS) -c -B./stage1/m2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/1.s ; \
> +              ./gm2 -S $(GM2_FLAGS) -c -B./m2/stage1 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/1.s ; \
>                echo -n "[1]" ; \
> -              ./gm2 -S $(GM2_FLAGS) -c -B./stage2/m2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/2.s ; \
> +              ./gm2 -S $(GM2_FLAGS) -c -B./m2/m2obj2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/2.s ; \
>                echo -n "[2]" ; \
> -              ./gm2 -S $(GM2_FLAGS) -c -B./stage3/m2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/3.s ; \
> +              ./gm2 -S $(GM2_FLAGS) -c -B./m2/m2obj3 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/3.s ; \
>                echo -n "[3]" ; \
>                if ! diff m2/gm2-compiler-verify/1.s m2/gm2-compiler-verify/2.s > m2/gm2-compiler-verify/1_2.diff 2>&1 ; then \
>                    echo -n " [stage 1 and stage 2 differ]" ; \
> @@ -678,7 +730,7 @@ gm2.verifyparanoid: stage1/m2/cc1gm2$(exeext) stage2/m2/cc1gm2$(exeext) stage3/m
>
>  # gm2.verifystage12 diffs the output of the stage1 and stage2 compilers with the compiler source code
>
> -gm2.verifystage12: force stage1/m2/cc1gm2$(exeext) stage2/m2/cc1gm2$(exeext)
> +gm2.verifystage12: force m2/stage1/cc1gm2$(exeext) m2/m2obj2/cc1gm2$(exeext)
>         @echo "verifying stage1 and stage2 generations of GNU Modula-2 compilers - it may take some time.."
>         $(QUIAT)for i in $(GM2-VERIFY-MODS) ; do \
>             echo -n "$$i " ; \
> @@ -698,9 +750,9 @@ gm2.verifystage12: force stage1/m2/cc1gm2$(exeext) stage2/m2/cc1gm2$(exeext)
>         $(QUIAT)for i in x $(GM2-VERIFY-AUTO) ; do \
>             if [ -f m2/gm2-auto/$$i ] ; then \
>                echo -n "$$i " ; \
> -              ./gm2 -S $(GM2_FLAGS) -c -B./stage1/m2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/1.s ; \
> +              ./gm2 -S $(GM2_FLAGS) -c -B./m2/stage1 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/1.s ; \
>                echo -n "[1]" ; \
> -              ./gm2 -S $(GM2_FLAGS) -c -B./stage2/m2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/2.s ; \
> +              ./gm2 -S $(GM2_FLAGS) -c -B./m2/m2obj2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/2.s ; \
>                echo -n "[2]" ; \
>                if ! diff m2/gm2-compiler-verify/1.s m2/gm2-compiler-verify/2.s > m2/gm2-compiler-verify/1_2.diff 2>&1 ; then \
>                    echo -n " [stage 1 and stage 2 differ]" ; \
> @@ -717,78 +769,99 @@ gm2.verifystage12: force stage1/m2/cc1gm2$(exeext) stage2/m2/cc1gm2$(exeext)
>  # The rules which build objects in the gm2-compiler-paranoid gm2-libs-paranoid directories.
>
>  m2/gm2-libs-paranoid/%.o: m2/gm2-libs-ch/%.c
> +       -test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
>         $(XGCC) -c -g $(GM2_O_S3) $(GM2_O) -I./ -Im2/gm2-libs -Wall $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-paranoid/%.o: $(srcdir)/m2/gm2-libs/%.mod
> +       -test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
>         $(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libiberty $< -o $@
>
>  m2/gm2-compiler-paranoid/%.o: $(srcdir)/m2/gm2-compiler/%.mod
> +       -test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
>         $(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@
>
>  m2/gm2-compiler-paranoid/%.o: m2/gm2-compiler-paranoid/%.mod
> +       -test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
>         $(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@
>
>  m2/gm2-compiler-paranoid/P0SyntaxCheck.o: m2/gm2-compiler-paranoid/P0SyntaxCheck.mod
> +       -test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
>         $(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@
>
>  m2/gm2-compiler-paranoid/P1Build.o: m2/gm2-compiler-paranoid/P1Build.mod
> +       -test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
>         $(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@
>
>  m2/gm2-compiler-paranoid/P2Build.o: m2/gm2-compiler-paranoid/P2Build.mod
> +       -test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
>         $(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@
>
>  m2/gm2-compiler-paranoid/P3Build.o: m2/gm2-compiler-paranoid/P3Build.mod
> +       -test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
>         $(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@
>
>  m2/gm2-compiler-paranoid/PHBuild.o: m2/gm2-compiler-paranoid/PHBuild.mod
> +       -test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
>         $(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@
>
>  m2/gm2-compiler-paranoid/PCBuild.o: m2/gm2-compiler-paranoid/PCBuild.mod
> +       -test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
>         $(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@
>
>  m2/gm2-libs-paranoid/host.o: $(srcdir)/m2/gm2-libs-ch/host.c m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
>         $(CXX) -c $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-paranoid/wrapc.o: $(srcdir)/m2/gm2-libs-ch/wrapc.c m2/gm2-libs-boot/$(SRC_PREFIX)wrapc.h m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
>         $(CXX) -c -DIN_GCC $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-paranoid/UnixArgs.o: $(srcdir)/m2/gm2-libs-ch/UnixArgs.cc \
>                                    m2/gm2-libs-boot/$(SRC_PREFIX)UnixArgs.h
> +       -test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
>         $(CXX) -c -DIN_GCC $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-paranoid/errno.o: $(srcdir)/m2/gm2-libs-ch/errno.c \
>                                     m2/gm2-libs-boot/$(SRC_PREFIX)errno.h
> +       -test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
>         $(CXX) -c -DIN_GCC $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-paranoid/Selective.o: $(srcdir)/m2/gm2-libs-ch/Selective.c \
>                                     m2/gm2-libs-boot/$(SRC_PREFIX)Selective.h
> +       -test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
>         $(COMPILER) -c -DIN_GCC $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-paranoid/choosetemp.o: $(srcdir)/m2/gm2-libs-ch/choosetemp.c \
>                                      m2/gm2-libiberty/$(SRC_PREFIX)choosetemp.h
> +       -test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
>         $(CXX) -c -DIN_GCC $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-paranoid/SysExceptions.o: $(srcdir)/m2/gm2-libs-ch/SysExceptions.c \
>                                    m2/gm2-libs-boot/$(SRC_PREFIX)SysExceptions.h
> +       -test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
>         $(CXX) -c -DIN_GCC $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@
>
>  m2/gm2-compiler-paranoid/m2flex.o: m2/gm2-compiler/m2flex.c $(TIMEVAR_H)
> +       -test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
>         $(COMPILER) -c $(GM2_O_S3) -g $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
>            $(GM2GCC) -Im2/gm2-compiler-boot -Im2/gm2-libs-boot $< -o $@
>
>  m2/gm2-libs-paranoid/dtoa.o: $(srcdir)/m2/gm2-libs-ch/dtoa.cc \
>                                m2/gm2-libs-boot/$(SRC_PREFIX)dtoa.h \
>                                m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
>         $(CXX) -c $(GM2_O_S3) $(CFLAGS) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-paranoid/ldtoa.o: $(srcdir)/m2/gm2-libs-ch/ldtoa.cc \
>                                 m2/gm2-libs-boot/$(SRC_PREFIX)ldtoa.h \
>                                 m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
>         $(CXX) -c $(GM2_O_S3) $(CFLAGS) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@
>
>  m2/gm2-libs-paranoid/termios.o: $(srcdir)/m2/gm2-libs-ch/termios.c \
>                                 m2/gm2-libs-boot/$(SRC_PREFIX)termios.h \
>                                 m2/gm2-libs/gm2-libs-host.h
> +       -test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
>         $(CXX) -c $(GM2_O_S3) $(CFLAGS) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@
>
>
> @@ -818,12 +891,15 @@ m2/gm2-compiler-paranoid/gm2.a: \
>         $(RANLIB) $@
>
>  m2/gm2-compiler-paranoid/M2Version.mod:
> +       -test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
>         $(SHELL) $(srcdir)/m2/tools-src/makeversion -m $(srcdir) m2/gm2-compiler-paranoid
>
>  m2/gm2-compiler-paranoid/M2Version.o: m2/gm2-compiler-paranoid/M2Version.mod
> +       -test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
>         $(GM2_2) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc $< -o $@
>
>  m2/gm2-compiler-paranoid/%.mod: $(srcdir)/m2/gm2-compiler/%.bnf $(PGE)
> +       -test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
>         $(PGE) -k -l $< -o $@
>
>  # Recreate the target independent copies of the documentation which is
> diff --git a/gcc/m2/config-lang.in b/gcc/m2/config-lang.in
> index 68bb525355a..d2afff2f23f 100644
> --- a/gcc/m2/config-lang.in
> +++ b/gcc/m2/config-lang.in
> @@ -52,32 +52,3 @@ gtfiles="\$(srcdir)/m2/gm2-lang.cc \
>  outputs="m2/config-make \
>           m2/Make-maintainer \
>          "
> -
> -mkdir -p m2/gm2-compiler-boot
> -mkdir -p m2/gm2-libs-boot
> -mkdir -p m2/gm2-ici-boot
> -mkdir -p m2/gm2-libiberty
> -mkdir -p m2/gm2-gcc
> -mkdir -p m2/gm2-compiler
> -mkdir -p m2/gm2-libs
> -mkdir -p m2/gm2-libs-iso
> -mkdir -p m2/gm2-compiler-paranoid
> -mkdir -p m2/gm2-libs-paranoid
> -mkdir -p m2/gm2-compiler-verify
> -mkdir -p m2/boot-bin
> -mkdir -p m2/gm2-libs-pim
> -mkdir -p m2/gm2-libs-coroutines
> -mkdir -p m2/gm2-libs-min
> -mkdir -p m2/pge-boot
> -mkdir -p plugin
> -mkdir -p stage1/m2 stage2/m2 stage3/m2 stage4/m2
> -
> -# directories used by Make-maintainer
> -
> -mkdir -p m2/gm2-auto
> -mkdir -p m2/gm2-pg-boot
> -mkdir -p m2/gm2-pge-boot
> -mkdir -p m2/gm2-ppg-boot
> -mkdir -p m2/mc-boot
> -mkdir -p m2/mc-boot-ch
> -mkdir -p m2/mc-boot-gen
  
Jakub Jelinek Jan. 10, 2023, 10:46 a.m. UTC | #2
On Tue, Jan 10, 2023 at 11:16:28AM +0100, Richard Biener via Gcc-patches wrote:
> > @@ -424,7 +388,7 @@ override PLUGINCFLAGS := $(filter-out -mdynamic-no-pic,$(PLUGINCFLAGS))
> >
> >  plugin/m2rte$(soext): $(srcdir)/m2/plugin/m2rte.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \
> >          insn-attr-common.h insn-flags.h $(generated_files)
> > -       test -d plugin || mkdir plugin
> > +       -test -d plugin || $(mkinstalldirs) plugin
> 
> I wonder if that's possibly racy (that's why you use mkinstalldirs?)?

Using $(mkinstalldirs) in the patch is what I've suggested because
previously the patch was using mkdir -p which we almost never use
(I think only some Ada Makefiles).  Above when it is a single directory
mkdir is fine.
	-test -d $(TESTSUITEDIR) || mkdir $(TESTSUITEDIR)
etc. is what is used in gcc/Makefile.in in some spots.
If 2 shells do that test -d plugin || mkdir plugin at the same time,
then yes, both might do mkdir, but that is why we have the - at the start,
the error of doing mkdir twice will be ignored then.

	Jakub
  
Gaius Mulley Jan. 10, 2023, 4:01 p.m. UTC | #3
Jakub Jelinek <jakub@redhat.com> writes:

> On Tue, Jan 10, 2023 at 11:16:28AM +0100, Richard Biener via Gcc-patches wrote:
>> > @@ -424,7 +388,7 @@ override PLUGINCFLAGS := $(filter-out -mdynamic-no-pic,$(PLUGINCFLAGS))
>> >
>> >  plugin/m2rte$(soext): $(srcdir)/m2/plugin/m2rte.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \
>> >          insn-attr-common.h insn-flags.h $(generated_files)
>> > -       test -d plugin || mkdir plugin
>> > +       -test -d plugin || $(mkinstalldirs) plugin
>> 
>> I wonder if that's possibly racy (that's why you use mkinstalldirs?)?
>
> Using $(mkinstalldirs) in the patch is what I've suggested because
> previously the patch was using mkdir -p which we almost never use
> (I think only some Ada Makefiles).  Above when it is a single directory
> mkdir is fine.
> 	-test -d $(TESTSUITEDIR) || mkdir $(TESTSUITEDIR)
> etc. is what is used in gcc/Makefile.in in some spots.
> If 2 shells do that test -d plugin || mkdir plugin at the same time,
> then yes, both might do mkdir, but that is why we have the - at the start,
> the error of doing mkdir twice will be ignored then.

thanks both - will apply the patch and close the PR

regards,
Gaius
  

Patch

diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
index 08d0f3b963f..a3751109481 100644
--- a/gcc/m2/Make-lang.in
+++ b/gcc/m2/Make-lang.in
@@ -27,7 +27,7 @@  GM2_CROSS_NAME = `echo gm2|sed '$(program_transform_cross_name)'`

 M2_MAINTAINER = no

-GM2_1 = ./gm2 -B./stage1/m2 -g -fm2-g
+GM2_1 = ./gm2 -B./m2/stage1 -g -fm2-g

 GM2_FOR_TARGET = $(STAGE_CC_WRAPPER) ./gm2 -B./ -B$(build_tooldir)/bin/ -L$(objdir)/../ld $(TFLAGS)

@@ -71,7 +71,6 @@  m2.srcextra: m2/SYSTEM-pim.texi m2/SYSTEM-iso.texi m2/gm2-libs.texi m2/gm2-ebnf.
 	-cp -p m2/SYSTEM-iso.texi $(srcdir)/m2
 	-cp -p m2/gm2-libs.texi $(srcdir)/m2
 	-cp -p m2/gm2-ebnf.texi $(srcdir)/m2
-	find . -name '*.texi' -print
 else
 m2.srcextra:
 endif
@@ -167,7 +166,7 @@  doc/m2.info: $(TEXISRC)
 	else true; fi

 $(objdir)/m2/images/gnu.eps: $(srcdir)/m2/images/gnupng
-	test -d m2/images || mkdir -p m2/images
+	-test -d m2/images || $(mkinstalldirs) m2/images
 	cp $(srcdir)/m2/images/gnu.eps $@

 # gm2-libs.texi
@@ -177,6 +176,9 @@  m2/gm2-libs.texi: gm2-libs.texi-check; @true
 ifeq ($(HAVE_PYTHON),yes)
 gm2-libs.texi-check: m2/SYSTEM-pim.texi m2/SYSTEM-iso.texi m2/Builtins.texi \
                      $(objdir)/m2/gm2-libs-coroutines/SYSTEM.def
+	test -d m2/gm2-libs-pim || $(mkinstalldirs) m2/gm2-libs-pim
+	test -d m2/gm2-libs-iso || $(mkinstalldirs) m2/gm2-libs-iso
+	test -d m2/gm2-libs || $(mkinstalldirs) m2/gm2-libs
 	$(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -t -uLibraries -s$(srcdir)/m2 -b$(objdir)/m2 -o $(objdir)/m2/gm2-libs.texi
 else
 gm2-libs.texi-check:
@@ -293,59 +295,21 @@  Builtins.rst-check:  m2/gm2-libs/Builtins.def
 endif
 	$(STAMP) Builtins.rst-check

-$(objdir)/m2/gm2-compiler-boot:
-	test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs-boot:
-	test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libiberty:
-	test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-gcc:
-	test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-compiler:
-	test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs:
-	test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs-iso:
-	test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs-min:
-	test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-compiler-paranoid:
-	test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs-paranoid:
-	test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-compiler-verify:
-	test -d $@ || mkdir $@
-
-$(objdir)/m2/boot-bin:
-	test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs-pim:
-	test -d $@ || mkdir $@
-
-$(objdir)/m2/gm2-libs-coroutines:
-	test -d $@ || mkdir $@
-
-stage1/m2:
-	-test -d $@ || mkdir -p stage1/m2
-
-stage2/m2:
-	-test -d $@ || mkdir -p stage2/m2
-
-stage3/m2:
-	-test -d $@ || mkdir -p stage3/m2
+# Stage hooks:
+# The toplevel makefile has already created stage?/m2 at this point.

-stage4/m2:
-	-test -d $@ || mkdir -p stage4/m2
+m2.stage1: stage1-start
+	-mv m2/*$(objext) stage1/m2
+m2.stage2: stage2-start
+	-mv m2/*$(objext) stage2/m2
+m2.stage3: stage3-start
+	-mv m2/*$(objext) stage3/m2
+m2.stage4: stage4-start
+	-mv m2/*$(objext) stage4/m2
+m2.stageprofile: stageprofile-start
+	-mv m2/*$(objext) stageprofile/m2
+m2.stagefeedback: stageprofile-start
+	-mv m2/*$(objext) stagefeedback/m2

 # No gm2-specific selftests
 selftest-m2:
@@ -424,7 +388,7 @@  override PLUGINCFLAGS := $(filter-out -mdynamic-no-pic,$(PLUGINCFLAGS))

 plugin/m2rte$(soext): $(srcdir)/m2/plugin/m2rte.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \
         insn-attr-common.h insn-flags.h $(generated_files)
-	test -d plugin || mkdir plugin
+	-test -d plugin || $(mkinstalldirs) plugin
 	$(PLUGINCC) $(PLUGINCFLAGS) -fno-rtti -I. -I$(srcdir) $(INCINTL) -I$(srcdir)/m2 -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/../include -I$(srcdir)/../libcpp/include -Wall $(GMPINC) -Wno-literal-suffix -fPIC -c -o plugin/m2rte.o $(srcdir)/m2/plugin/m2rte.cc
 	$(PLUGINCC) $(PLUGINCFLAGS) $(PLUGINLDFLAGS) $(PLUGINLIBS) $(LIBINTL) -fno-rtti plugin/m2rte.o -shared -o $@

@@ -444,20 +408,6 @@  m2.clean:
 m2.extraclean:
 m2.realclean:

-# Stage hooks:
-
-m2.stage1: stage1-start
-	-mv m2/*$(objext) stage1/m2
-
-m2.stage2: stage2-start
-	-mv m2/*$(objext) stage2/m2
-
-m2.stage3: stage3-start
-	-mv m2/*$(objext) stage3/m2
-
-m2.stage4: stage4-start
-	-mv m2/*$(objext) stage4/m2
-
 quit: force
 	echo "calling exit"
 	exit 1
@@ -537,12 +487,13 @@  GM2_LIBS_BOOT     = m2/gm2-compiler-boot/gm2.a \
                     m2/gm2-libs-boot/libgm2.a \
                     $(GM2-BOOT-O)

-cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) $(m2.prev)
+cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) $(m2.prev)
 	cp -p $< $@

-stage2/m2/cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(P) \
+m2/stage2/cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(P) \
                             $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS) \
                             m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext) m2/gm2-libs-boot/M2LINK.o
+	-test -d m2/stage2 || $(mkinstalldirs) m2/stage2
 	@$(call LINK_PROGRESS,$(INDEX.m2),start)
 	+$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler/m2flex.o \
                             attribs.o \
@@ -551,12 +502,13 @@  stage2/m2/cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(
                               $(BACKENDLIBS) $(LIBSTDCXX) -lm
 	@$(call LINK_PROGRESS,$(INDEX.m2),end)

-stage1/m2/cc1gm2$(exeext): gm2$(exeext) m2/gm2-compiler-boot/m2flex.o \
+m2/stage1/cc1gm2$(exeext): gm2$(exeext) m2/gm2-compiler-boot/m2flex.o \
                             $(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) \
                             $(GM2_LIBS_BOOT) $(MC_LIBS) \
                             m2/gm2-gcc/rtegraph.o plugin/m2rte$(soext) \
                             m2/gm2-libs-boot/M2LINK.o \
                             $(m2.prev)
+	-test -d m2/stage1 || $(mkinstalldirs) m2/stage1
 	@$(call LINK_PROGRESS,$(INDEX.m2),start)
 	+$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler-boot/m2flex.o \
                             attribs.o \
@@ -574,6 +526,7 @@  GCC_HEADER_DEPENDENCIES_FOR_M2 = $(BUILD-BOOT-H) $(TIMEVAR_H) m2/gm2config.h $(C
         $(generated_files) insn-attr-common.h

 m2/gm2-gcc/%.o: $(srcdir)/m2/gm2-gcc/%.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2)
+	-test -d m2/gm2-gcc || $(mkinstalldirs) m2/gm2-gcc
 	$(COMPILER) -c -g $(ALL_COMPILERFLAGS) \
              $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)

@@ -581,6 +534,7 @@  m2/gm2-gcc/m2configure.o: $(srcdir)/m2/gm2-gcc/m2configure.cc \
                $(SYSTEM_H) $(GCC_H) $(CONFIG_H) \
                m2/gm2config.h $(TARGET_H) $(PLUGIN_HEADERS) \
                $(generated_files) $(C_TREE_H) insn-attr-common.h
+	-test -d m2/gm2-gcc || $(mkinstalldirs) m2/gm2-gcc
 	$(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
          $(DRIVER_DEFINES) \
 		-DLIBSUBDIR=\"$(libsubdir)\" \
@@ -601,6 +555,7 @@  m2/m2pp.o : $(srcdir)/m2/m2pp.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2)

 m2/gm2-gcc/rtegraph.o: $(srcdir)/m2/gm2-gcc/rtegraph.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \
                        gt-m2-rtegraph.h
+	-test -d m2/gm2-gcc || $(mkinstalldirs) m2/gm2-gcc
 	$(COMPILER) -c -g $(GM2GCC) $(ALL_COMPILERFLAGS) \
             $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)

@@ -609,6 +564,7 @@  c-family/m2pp.o : $(srcdir)/m2/m2pp.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2)
             $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)

 m2/gm2-gcc/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-gcc/%.def $(MCDEPS)
+	-test -d m2/gm2-gcc || $(mkinstalldirs) m2/gm2-gcc
 	$(MC) -o=$@ $(srcdir)/m2/gm2-gcc/$*.def

 # The following tables define the source files which are translated into C using mc
@@ -1361,15 +1317,19 @@  m2/boot-bin/mc$(exeext): $(BUILD-MC-BOOT-O) $(BUILD-MC-INTERFACE-O) \
          mcflex.o m2/gm2-libs-boot/RTcodummy.o -lm

 m2/mc-boot/$(SRC_PREFIX)%.o: m2/mc-boot/$(SRC_PREFIX)%.c
+	-test -d m2/mc-boot || $(mkinstalldirs) m2/mc-boot
 	$(CXX) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@

 m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/mc-boot-ch || $(mkinstalldirs) m2/mc-boot-ch
 	$(CXX) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@

 m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/mc-boot-ch || $(mkinstalldirs) m2/mc-boot-ch
 	$(CXX) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@

 m2/mc-boot/main.o: $(M2LINK) $(srcdir)/m2/init/mcinit
+	-test -d m2/mc-boot || $(mkinstalldirs) m2/mc-boot
 	unset CC ; $(M2LINK) -s --langc++ --exit --name m2/mc-boot/main.c $(srcdir)/m2/init/mcinit
 	$(CXX) -g -c -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) m2/mc-boot/main.c -o $@

@@ -1380,57 +1340,73 @@  mcflex.c: $(srcdir)/m2/mc/mc.flex
 	flex -t $< > $@

 m2/gm2-libs-boot/%.o: $(srcdir)/m2/gm2-libs-boot/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(MC) -o=m2/gm2-libs-boot/$*.c $(srcdir)/m2/gm2-libs-boot/$*.mod
 	$(COMPILER) -c -DIN_GCC $(CFLAGS) $(MCINCLUDES) m2/gm2-libs-boot/$*.c -o $@

 m2/gm2-libs-boot/%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(MC) -o=m2/gm2-libs-boot/$*.c $(srcdir)/m2/gm2-libs/$*.mod
 	$(COMPILER) -c -DIN_GCC $(CFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/$*.c -o $@

 m2/gm2-libs-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS)
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(MC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def

 m2/gm2-libs-boot/RTcodummy.o: $(srcdir)/m2/gm2-libs-ch/RTcodummy.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-boot/RTintdummy.o: $(srcdir)/m2/gm2-libs-ch/RTintdummy.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-boot/wrapc.o: $(srcdir)/m2/gm2-libs-ch/wrapc.c m2/gm2-libs-boot/$(SRC_PREFIX)wrapc.h m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(CXX) -c -DHAVE_CONFIG_H $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@

 m2/gm2-libs-boot/M2LINK.o: $(srcdir)/m2/gm2-libs-ch/M2LINK.c m2/gm2-libs-boot/$(SRC_PREFIX)M2LINK.h m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(CXX) -c -DHAVE_CONFIG_H $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@

 m2/gm2-libs-boot/UnixArgs.o: $(srcdir)/m2/gm2-libs-ch/UnixArgs.cc m2/gm2-libs-boot/$(SRC_PREFIX)UnixArgs.h m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-boot/choosetemp.o: m2/gm2-libs-ch/choosetemp.c m2/gm2-libiberty/Gchoosetemp.h m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@

 m2/gm2-libs-boot/errno.o: $(srcdir)/m2/gm2-libs-ch/errno.c m2/gm2-libs-boot/$(SRC_PREFIX)errno.h m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-boot/dtoa.o: $(srcdir)/m2/gm2-libs-ch/dtoa.cc m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-boot/ldtoa.o: $(srcdir)/m2/gm2-libs-ch/ldtoa.cc m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-boot/termios.o: $(srcdir)/m2/gm2-libs-ch/termios.c $(BUILD-LIBS-BOOT-H) m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-boot/SysExceptions.o: $(srcdir)/m2/gm2-libs-ch/SysExceptions.c \
                                   m2/gm2-libs-boot/$(SRC_PREFIX)SysExceptions.h m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-boot/SysStorage.o: $(srcdir)/m2/gm2-libs/SysStorage.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(MC) -o=m2/gm2-libs-boot/SysStorage.c $(srcdir)/m2/gm2-libs/SysStorage.mod
 	$(COMPILER) -DIN_GCC -c $(CFLAGS) \
           -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) \
           m2/gm2-libs-boot/SysStorage.c -o m2/gm2-libs-boot/SysStorage.o

 m2/gm2-compiler-boot/M2GCCDeclare.o: $(srcdir)/m2/gm2-compiler/M2GCCDeclare.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
 	$(MC) --extended-opaque -o=m2/gm2-compiler-boot/M2GCCDeclare.c $<
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
             -I. -I$(srcdir)/../include -I$(srcdir) \
@@ -1438,6 +1414,7 @@  m2/gm2-compiler-boot/M2GCCDeclare.o: $(srcdir)/m2/gm2-compiler/M2GCCDeclare.mod
             -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/M2GCCDeclare.c -o $@

 m2/gm2-compiler-boot/M2Error.o: $(srcdir)/m2/gm2-compiler/M2Error.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
 	$(MC) --extended-opaque -o=m2/gm2-compiler-boot/M2Error.c $<
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
             -I. -I$(srcdir)/../include -I$(srcdir) \
@@ -1445,6 +1422,7 @@  m2/gm2-compiler-boot/M2Error.o: $(srcdir)/m2/gm2-compiler/M2Error.mod $(MCDEPS)
             -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/M2Error.c -o $@

 m2/gm2-compiler-boot/%.o: $(srcdir)/m2/gm2-compiler/%.mod $(BUILD-BOOT-H) $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
 	$(MC) -o=m2/gm2-compiler-boot/$*.c $(srcdir)/m2/gm2-compiler/$*.mod
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
             -I. -I$(srcdir)/../include -I$(srcdir) \
@@ -1452,6 +1430,7 @@  m2/gm2-compiler-boot/%.o: $(srcdir)/m2/gm2-compiler/%.mod $(BUILD-BOOT-H) $(MCDE
             -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/$*.c -o $@

 m2/gm2-compiler-boot/%.o: m2/gm2-compiler-boot/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
 	$(MC) -o=m2/gm2-compiler-boot/$*.c m2/gm2-compiler-boot/$*.mod
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
             -I. -I$(srcdir)/../include -I$(srcdir) \
@@ -1459,37 +1438,46 @@  m2/gm2-compiler-boot/%.o: m2/gm2-compiler-boot/%.mod $(MCDEPS) $(BUILD-BOOT-H)
             -I$(srcdir)/m2/gm2-libiberty $(MCINCLUDES) $(INCLUDES) m2/gm2-compiler-boot/$*.c -o $@

 m2/gm2-compiler-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-compiler/%.def $(MCDEPS)
+	-test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
 	$(MC) -o=$@ $(srcdir)/m2/gm2-compiler/$*.def

 m2/gm2-compiler-boot/m2flex.o: m2/gm2-compiler/m2flex.c $(BUILD-BOOT-H) $(TIMEVAR_H) \
         $(BUILD-LIBS-BOOT-H)  m2/gm2-compiler-boot/$(SRC_PREFIX)NameKey.h \
         $(CONFIG_H) m2/gm2config.h $(TARGET_H) $(PLUGIN_HEADERS)
+	-test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
 	$(COMPILER) -c -g $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
           $(GM2GCC) $(INCLUDES) -I$(srcdir)/m2 \
           -Im2 -Im2/gm2-compiler-boot -Im2/gm2-libs-boot $< -o $@

 m2/gm2-compiler/m2flex.c: $(srcdir)/m2/m2.flex $(TIMEVAR_H) insn-attr-common.h
+	-test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
 	flex -t $< | sed -e 's/ malloc/ xmalloc/' | sed -e 's/ realloc/ xrealloc/' > $@

 m2/gm2-libiberty/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libiberty/%.def $(MCDEPS)
+	-test -d m2/gm2-libiberty || $(mkinstalldirs) m2/gm2-libiberty
 	$(MC) -o=$@ $(srcdir)/m2/gm2-libiberty/$*.def

 # The rules to build objects in gm2-compiler and gm2-libs directories.

 m2/gm2-compiler/%.o: $(srcdir)/m2/gm2-compiler/%.mod
+	-test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
 	$(GM2_1) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@

 m2/gm2-compiler/m2flex.o: m2/gm2-compiler/m2flex.c m2/gm2-libs/gm2-libs-host.h $(TIMEVAR_H)
+	-test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
 	$(COMPILER) -c -g $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
           $(GM2GCC) -Im2/gm2-compiler-boot -Im2/gm2-libs-boot $< -o $@

 m2/gm2-compiler/%.o: m2/gm2-compiler/%.mod
+	-test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
 	$(GM2_1) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@

 m2/gm2-libs-iso/%.o: $(srcdir)/m2/gm2-libs-iso/%.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-iso || $(mkinstalldirs) m2/gm2-libs-iso
 	$(CXX) -DBUILD_GM2_LIBS_TARGET -DBUILD_GM2_LIBS -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-iso/%.o: $(srcdir)/m2/gm2-libs-iso/%.mod
+	-test -d m2/gm2-libs-iso || $(mkinstalldirs) m2/gm2-libs-iso
 	$(GM2_1) $(GM2_ISO_FLAGS) -c -B./ -Im2/gm2-libs-iso:$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs $< -o $@


@@ -1497,6 +1485,7 @@  m2/gm2-libs-iso/%.o: $(srcdir)/m2/gm2-libs-iso/%.mod
 # again using itself.

 m2/gm2-libs/gm2-libs-host.h:
+	-test -d m2/gm2-libs || $(mkinstalldirs) m2/gm2-libs
 	echo "Configuring to build libraries using native compiler" ; \
         NEW_SRCDIR=`${srcdir}/m2/tools-src/calcpath ../../ ${srcdir} m2/gm2-libs` ; \
         export NEW_SRCDIR ; \
@@ -1528,6 +1517,7 @@  m2/gm2config.h:
         fi

 $(objdir)/m2/gm2-libs-min/SYSTEM.def: $(GM2_PROG_DEP)
+	-test -d m2/gm2-libs-min || $(mkinstalldirs) m2/gm2-libs-min
 	$(SHELL) $(srcdir)/m2/tools-src/makeSystem -fpim \
              $(srcdir)/m2/gm2-libs-min/SYSTEM.def \
              $(srcdir)/m2/gm2-libs-min/SYSTEM.mod \
@@ -1535,6 +1525,7 @@  $(objdir)/m2/gm2-libs-min/SYSTEM.def: $(GM2_PROG_DEP)
              "$(GM2_FOR_TARGET)" $@

 $(objdir)/m2/gm2-libs/SYSTEM.def: $(GM2_PROG_DEP)
+	-test -d m2/gm2-libs || $(mkinstalldirs) m2/gm2-libs
 	echo "GM2_FOR_TARGET $(GM2_FOR_TARGET)"
 	echo "GCC_FOR_TARGET $(GCC_FOR_TARGET)"
 	$(SHELL) $(srcdir)/m2/tools-src/makeSystem -fpim \
@@ -1544,6 +1535,7 @@  $(objdir)/m2/gm2-libs/SYSTEM.def: $(GM2_PROG_DEP)
              "$(GM2_FOR_TARGET)" $@

 $(objdir)/m2/gm2-libs-iso/SYSTEM.def: $(GM2_PROG_DEP)
+	-test -d m2/gm2-libs-iso || $(mkinstalldirs) m2/gm2-libs-iso
 	$(SHELL) $(srcdir)/m2/tools-src/makeSystem -fiso \
              $(srcdir)/m2/gm2-libs-iso/SYSTEM.def \
              $(srcdir)/m2/gm2-libs-iso/SYSTEM.mod \
@@ -1551,6 +1543,7 @@  $(objdir)/m2/gm2-libs-iso/SYSTEM.def: $(GM2_PROG_DEP)
              "$(GM2_FOR_TARGET)" $@

 $(objdir)/m2/gm2-libs-coroutines/SYSTEM.def: $(GM2_PROG_DEP)
+	-test -d m2/gm2-libs-coroutines || $(mkinstalldirs) m2/gm2-libs-coroutines
 	$(SHELL) $(srcdir)/m2/tools-src/makeSystem -fpim \
              $(srcdir)/m2/gm2-libs-coroutines/SYSTEM.def \
              $(srcdir)/m2/gm2-libs-coroutines/SYSTEM.mod \
@@ -1562,11 +1555,13 @@  build-compiler: $(GM2-COMP-MODS:%.mod=m2/gm2-compiler/%.o) \
                 m2/gm2-compiler/m2flex.o

 m2/gm2-compiler/gm2.a: build-compiler gm2$(exeext)
+	-test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
 	$(AR_FOR_TARGET) cr $@ $(GM2-COMP-MODS:%.mod=m2/gm2-compiler/%.o) \
                     $(GM2-AUTO-MODS:%.mod=m2/gm2-compiler/%.o)
 	$(RANLIB) $@

 m2/gm2-libs-boot/libgm2.a: m2/boot-bin/mc$(exeext) $(BUILD-LIBS-BOOT)
+	-test -d m2/gm2-libs-boot || $(mkinstalldirs) m2/gm2-libs-boot
 	$(AR) cr $@ $(GM2-LIBS-BOOT-MODS:%.mod=m2/gm2-libs-boot/%.o) \
                     $(GM2-LIBS-BOOT-CC:%.cc=m2/gm2-libs-boot/%.o) \
                     $(GM2-LIBS-BOOT-C:%.c=m2/gm2-libs-boot/%.o)
@@ -1574,6 +1569,7 @@  m2/gm2-libs-boot/libgm2.a: m2/boot-bin/mc$(exeext) $(BUILD-LIBS-BOOT)

 m2/gm2-compiler-boot/gm2.a: m2/boot-bin/mc$(exeext) m2/boot-bin/mklink$(exeext) \
                          $(BUILD-LIBS-BOOT) $(BUILD-COMPILER-BOOT)
+	-test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
 	$(AR) cr $@ $(GM2-COMP-BOOT-MODS:%.mod=m2/gm2-compiler-boot/%.o) \
                     $(GM2-AUTO-MODS:%.mod=m2/gm2-compiler-boot/%.o)
 	$(RANLIB) $@
@@ -1581,15 +1577,19 @@  m2/gm2-compiler-boot/gm2.a: m2/boot-bin/mc$(exeext) m2/boot-bin/mklink$(exeext)
 m2/gm2-compiler-boot/gm2.a: m2/boot-bin/mc$(exeext)

 m2/boot-bin/mklink$(exeext): $(srcdir)/m2/tools-src/mklink.c
+	-test -d m2/boot-bin || $(mkinstalldirs) m2/boot-bin
 	$(CXX) $(CFLAGS) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) $< -o $@

 m2/gm2-compiler-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-compiler-boot/%.def $(MCDEPS)
+	-test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
 	$(MC) --quiet -o=$@ $(srcdir)/m2/gm2-compiler-boot/$*.def

 m2/gm2-compiler/%.mod: $(srcdir)/m2/gm2-compiler/%.bnf $(PGE)
+	-test -d m2/gm2-compiler || $(mkinstalldirs) m2/gm2-compiler
 	$(PGE) -k -l $< -o $@

 m2/gm2-compiler-boot/%.mod: $(srcdir)/m2/gm2-compiler/%.bnf $(PGE)
+	-test -d m2/gm2-compiler-boot || $(mkinstalldirs) m2/gm2-compiler-boot
 	$(PGE) -k -l $< -o $@

 check-m2: check-gm2
@@ -1658,9 +1658,11 @@  ifeq ($(M2_MAINTAINER),yes)
 include m2/Make-maintainer
 else
 m2/pge-boot/%.o: m2/pge-boot/%.c m2/gm2-libs/gm2-libs-host.h m2/gm2config.h
+	-test -d m2/pge-boot ||$(mkinstalldirs) m2/pge-boot
 	$(CXX) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@

 m2/pge-boot/%.o: m2/pge-boot/%.cc m2/gm2-libs/gm2-libs-host.h m2/gm2config.h
+	-test -d m2/pge-boot || $(mkinstalldirs) m2/pge-boot
 	$(CXX) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@

 $(PGE): $(BUILD-PGE-O)
diff --git a/gcc/m2/Make-maintainer.in b/gcc/m2/Make-maintainer.in
index 2460b979207..b41f5858e17 100644
--- a/gcc/m2/Make-maintainer.in
+++ b/gcc/m2/Make-maintainer.in
@@ -20,7 +20,7 @@ 

 # QUIAT=@
 XGCC = ./xgcc -B./
-GM2_2 = ./gm2 -B./stage2/m2 -g -fm2-g
+GM2_2 = ./gm2 -B./m2/m2obj2 -g -fm2-g

 # m2/ppg$(exeext)  is the recursive descent parser generator.

@@ -96,21 +96,26 @@  BUILD-PPG-LIBS-H = $(PPG-LIB-DEFS:%.def=m2/gm2-ppg-boot/$(SRC_PREFIX)%.h)
 BUILD-PPG-H = m2/boot-bin/mc$(exeext) $(BUILD-PPG-LIBS-H)

 m2/gm2-ppg-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS)
+	-test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot
 	$(MCC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def

 m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@

 m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@

 m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot
 	$(MCC) -o=m2/gm2-ppg-boot/$(SRC_PREFIX)$*.c $(srcdir)/m2/gm2-libs/$*.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) \
               -Im2/gm2-ppg-boot -I$(srcdir)/m2/mc-boot -Im2/gm2-libs-boot \
               -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)$*.c -o $@

 m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-compiler/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot
 	$(MCC) -o=m2/gm2-ppg-boot/$(SRC_PREFIX)$*.c $(srcdir)/m2/gm2-compiler/$*.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) \
               -Im2/mc-boot -Im2/gm2-compiler-boot -Im2/gm2-libs-boot \
@@ -119,17 +124,19 @@  m2/gm2-ppg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-compiler/%.mod $(MCDEPS) $(BU
 m2/ppg$(exeext): m2/boot-bin/mc $(BUILD-PPG-O) $(BUILD-MC-INTERFACE-O) m2/gm2-ppg-boot/main.o \
                  m2/gm2-libs-boot/RTcodummy.o m2/mc-boot-ch/$(SRC_PREFIX)abort.o \
                  m2/gm2-libs-boot/M2LINK.o
+	-test -d m2 || $(mkinstalldirs) m2
 	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-PPG-O) m2/gm2-ppg-boot/main.o \
                  m2/gm2-libs-boot/RTcodummy.o m2/mc-boot-ch/$(SRC_PREFIX)abort.o \
                  m2/gm2-libs-boot/M2LINK.o -lm

 m2/gm2-ppg-boot/main.o: $(M2LINK) $(srcdir)/m2/init/mcinit
+	-test -d m2/gm2-ppg-boot || $(mkinstalldirs) m2/gm2-ppg-boot
 	unset CC ; $(M2LINK) -s --langc++ --exit --name mainppginit.c $(srcdir)/m2/init/ppginit
 	mv mainppginit.c m2/gm2-ppg-boot/main.c
 	$(CXX) $(INCLUDES) -g -c -o $@ m2/gm2-ppg-boot/main.c

 m2/gm2-auto:
-	test -d $@ || mkdir -p $@
+	-test -d $@ || $(mkinstalldirs) $@

 # m2/pg$(exext) is the 2nd generation parser generator built from ebnf
 # without error recovery
@@ -143,15 +150,19 @@  BUILD-PG-O = $(PPG-INTERFACE-C:%.c=m2/gm2-pg-boot/$(SRC_PREFIX)%.o) \
              $(PG-SRC:%.mod=m2/gm2-pg-boot/$(SRC_PREFIX)%.o)

 m2/gm2-pg-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS)
+	-test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
 	$(MCC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def

 m2/gm2-pg-boot/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@

 m2/gm2-pg-boot/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@

 m2/gm2-pg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
 	$(MCC) -o=m2/gm2-pg-boot/$(SRC_PREFIX)$*.c $(srcdir)/m2/gm2-libs/$*.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -Im2/gm2-pg-boot	-I$(srcdir)/m2/mc-boot \
                -I$(srcdir)/m2/mc-boot-ch \
@@ -159,11 +170,13 @@  m2/gm2-pg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-B
               -g -c m2/gm2-pg-boot/$(SRC_PREFIX)$*.c -o $@

 m2/gm2-pg-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-compiler/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
 	$(MCC) -o=m2/gm2-pg-boot/$(SRC_PREFIX)$*.c $(srcdir)/m2/gm2-compiler/$*.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -Im2/mc-boot -Im2/gm2-compiler-boot -Im2/gm2-libs-boot \
               -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-pg-boot/$(SRC_PREFIX)$*.c -o $@

 m2/gm2-pg-boot/$(SRC_PREFIX)pg.o:  m2/gm2-auto/pg.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
 	$(MCC) -o=m2/gm2-pg-boot/$(SRC_PREFIX)pg.c m2/gm2-auto/pg.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -Im2/mc-boot -Im2/gm2-compiler-boot -Im2/gm2-libs-boot \
               -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-pg-boot/$(SRC_PREFIX)pg.c -o $@
@@ -172,20 +185,24 @@  m2/pg$(exeext): m2/boot-bin/mc \
     $(BUILD-PG-O) $(GM2-PPG-MODS:%.mod=m2/gm2-pg-boot/%.o) \
     $(BUILD-MC-INTERFACE-O) m2/gm2-pg-boot/main.o m2/gm2-libs-boot/RTcodummy.o \
     m2/mc-boot-ch/$(SRC_PREFIX)abort.o m2/gm2-libs-boot/M2LINK.o
+	-test -d m2 || $(mkinstalldirs) m2
 	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-PG-O) \
          m2/gm2-pg-boot/main.o m2/gm2-libs-boot/RTcodummy.o \
          m2/gm2-libs-boot/M2LINK.o \
          m2/mc-boot-ch/$(SRC_PREFIX)abort.o -lm

 m2/gm2-auto/pginit:
+	-test -d m2/gm2-auto || $(mkinstalldirs) m2/gm2-auto
 	sed -e 's/ppg/pg/' < $(srcdir)/m2/init/ppginit > $@

 m2/gm2-pg-boot/main.o: m2/gm2-auto/pginit $(M2LINK)
+	-test -d m2/gm2-pg-boot || $(mkinstalldirs) m2/gm2-pg-boot
 	unset CC ; $(M2LINK) -s --langc++ --exit --name mainpginit.c m2/gm2-auto/pginit
 	mv mainpginit.c m2/gm2-pg-boot/main.c
 	$(CXX) $(INCLUDES) -g -c -o $@ m2/gm2-pg-boot/main.c

 m2/pg-e$(exeext): m2/pg$(exeext)
+	-test -d m2 || $(mkinstalldirs) m2
 	$(CP) m2/pg$(exeext) m2/pg-e$(exeext)
 	$(SHELL) $(srcdir)/m2/tools-src/buildpg $(srcdir)/m2/gm2-compiler/ppg.mod pg -e > m2/gm2-auto/t.bnf
 	./m2/pg-e$(exeext) -e -l m2/gm2-auto/t.bnf | sed -e 's/t\.bnf/pg\.bnf/' > m2/gm2-auto/t.mod
@@ -196,6 +213,7 @@  m2/pg-e$(exeext): m2/pg$(exeext)
 	$(RM) m2/gm2-auto/t.bnf m2/gm2-auto/t.mod

 m2/gm2-auto/pg.mod: m2/ppg$(exeext)
+	-test -d m2/gm2-auto || $(mkinstalldirs) m2/gm2-auto
 	$(SHELL) $(srcdir)/m2/tools-src/buildpg $(srcdir)/m2/gm2-compiler/ppg.mod pg -e > m2/gm2-auto/pg.bnf
 	./m2/ppg$(exeext) -e -l m2/gm2-auto/pg.bnf > m2/gm2-auto/pg.mod

@@ -210,58 +228,74 @@  BUILD-PGE-O = $(PPG-INTERFACE-C:%.c=m2/gm2-pge-boot/$(SRC_PREFIX)%.o) \
               $(PGE-SRC:%.mod=m2/gm2-pge-boot/$(SRC_PREFIX)%.o)

 m2/gm2-auto/pge.mod: m2/pg$(exeext)
+	-test -d m2/gm2-auto || $(mkinstalldirs) m2/gm2-auto
 	$(SHELL) $(srcdir)/m2/tools-src/buildpg $(srcdir)/m2/gm2-compiler/ppg.mod pge > m2/gm2-auto/pge.bnf
 	./m2/pg$(exeext) -l m2/gm2-auto/pge.bnf -o m2/gm2-auto/pge.mod

 m2/gm2-pge-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS)
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(MCC) -o=$@ $(srcdir)/m2/gm2-libs/$*.def

 m2/gm2-pge-boot/$(SRC_PREFIX)libc.o: $(srcdir)/m2/mc-boot-ch/Glibc.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs -g -c $< -o $@

 m2/gm2-pge-boot/$(SRC_PREFIX)mcrts.o:  $(srcdir)/m2/mc-boot-ch/Gmcrts.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs -g -c $< -o $@

 m2/gm2-pge-boot/$(SRC_PREFIX)UnixArgs.o:  $(srcdir)/m2/mc-boot-ch/GUnixArgs.cc
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c $< -o $@

 m2/gm2-pge-boot/$(SRC_PREFIX)Selective.o:  $(srcdir)/m2/mc-boot-ch/GSelective.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -Im2/gm2-libs -g -c $< -o $@

 m2/gm2-pge-boot/$(SRC_PREFIX)termios.o:  $(srcdir)/m2/mc-boot-ch/Gtermios.cc m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@

 m2/gm2-pge-boot/$(SRC_PREFIX)SysExceptions.o:  $(srcdir)/m2/mc-boot-ch/GSysExceptions.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@

 m2/gm2-pge-boot/$(SRC_PREFIX)ldtoa.o:  $(srcdir)/m2/mc-boot-ch/Gldtoa.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@

 m2/gm2-pge-boot/$(SRC_PREFIX)dtoa.o:  $(srcdir)/m2/mc-boot-ch/Gdtoa.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@

 m2/gm2-pge-boot/$(SRC_PREFIX)wrapc.o:  $(srcdir)/m2/mc-boot-ch/Gwrapc.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs $(INCLUDES) -g -c $< -o $@

 m2/gm2-pge-boot/$(SRC_PREFIX)SYSTEM.o:  $(srcdir)/m2/mc-boot-ch/GSYSTEM.c
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c $< -o $@

 m2/gm2-pge-boot/$(SRC_PREFIX)errno.o:  $(srcdir)/m2/mc-boot-ch/Gerrno.c
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c $< -o $@

 m2/gm2-pge-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(MCC) -o=m2/gm2-pge-boot/$(SRC_PREFIX)$*.c $(srcdir)/m2/gm2-libs/$*.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -Im2/gm2-pge-boot -I$(srcdir)/m2/mc-boot \
               -I$(srcdir)/m2/mc-boot-ch -Im2/gm2-libs-boot \
               $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)$*.c -o $@

 m2/gm2-pge-boot/$(SRC_PREFIX)%.o: $(srcdir)/m2/gm2-compiler/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(MCC) -o=m2/gm2-pge-boot/$(SRC_PREFIX)$*.c $(srcdir)/m2/gm2-compiler/$*.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) -Im2/mc-boot -Im2/gm2-compiler-boot \
               -Im2/gm2-libs-boot \
               -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)$*.c -o $@

 m2/gm2-pge-boot/$(SRC_PREFIX)pge.o:  m2/gm2-auto/pge.mod $(MCDEPS) $(BUILD-BOOT-H)
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(MCC) -o=m2/gm2-pge-boot/$(SRC_PREFIX)pge.c m2/gm2-auto/pge.mod
 	$(CXX) -I. -I$(srcdir)/../include -I$(srcdir) \
               -Im2/mc-boot -Im2/gm2-compiler-boot -Im2/gm2-libs-boot \
@@ -271,6 +305,7 @@  m2/pge$(exeext): m2/boot-bin/mc \
     $(BUILD-PGE-O) $(GM2-PPG-MODS:%.mod=m2/gm2-pge-boot/%.o) \
     $(BUILD-MC-INTERFACE-O) m2/gm2-pge-boot/main.o m2/gm2-libs-boot/RTcodummy.o \
     m2/mc-boot-ch/$(SRC_PREFIX)abort.o m2/gm2-libs-boot/M2LINK.o
+	-test -d m2 || $(mkinstalldirs) m2
 	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-PGE-O) \
          m2/gm2-pge-boot/main.o m2/gm2-libs-boot/RTcodummy.o \
          m2/mc-boot-ch/$(SRC_PREFIX)abort.o m2/gm2-libs-boot/M2LINK.o -lm
@@ -285,27 +320,31 @@  m2/pge$(exeext): m2/boot-bin/mc \
 	$(RM) m2/gm2-auto/t.mod m2/gm2-auto/t1.mod m2/gm2-auto/t2.mod

 m2/gm2-auto/pgeinit:
+	-test -d m2/gm2-auto || $(mkinstalldirs) m2/gm2-auto
 	sed -e 's/ppg/pge/' < $(srcdir)/m2/init/ppginit > $@

 m2/gm2-pge-boot/main.o: m2/gm2-auto/pgeinit $(M2LINK)
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	unset CC ; $(M2LINK) -s --langc++ --exit --name mainpgeinit.c m2/gm2-auto/pgeinit
 	mv mainpgeinit.c m2/gm2-pge-boot/main.c
 	$(CXX) $(INCLUDES) -g -c -o $@ m2/gm2-pge-boot/main.c

 $(objdir)/m2/gm2-ppg-boot:
-	test -d $@ || mkdir $@
+	-test -d $@ || $(mkinstalldirs) $@

 $(objdir)/m2/gm2-pg-boot:
-	test -d $@ || mkdir $@
+	-test -d $@ || $(mkinstalldirs) $@

 $(objdir)/m2/gm2-pge-boot:
-	test -d $@ || mkdir $@
+	-test -d $@ || $(mkinstalldirs) $@

 m2/gm2-auto/pg.o: m2/gm2-auto/pg.mod $(MCDEPS)
+	-test -d m2/gm2-pge-boot || $(mkinstalldirs) m2/gm2-pge-boot
 	$(MC) --quiet -o=m2/gm2-auto/pg.c m2/gm2-auto/pg.mod
 	$(COMPILER) -c $(CFLAGS) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) m2/gm2-auto/pg.c -o $@

 m2/gm2-auto/pge.o: m2/gm2-auto/pge.mod $(MCDEPS)
+	-test -d m2/gm2-auto || $(mkinstalldirs) m2/gm2-auto
 	$(MC) --quiet -o=m2/gm2-auto/pge.c m2/gm2-auto/pge.mod
 	$(COMPILER) -c $(CFLAGS) -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) m2/gm2-auto/pge.c -o $@

@@ -400,7 +439,7 @@  mc-help:  force
 	@echo "m2/pge          build the parser generator (needed by mc-maintainer)"

 m2/mc-obj:
-	mkdir $@
+	$(mkinstalldirs) $@

 mc-verify:  mc-clean mc-bootstrap mc
 	mv mc m2/boot-bin/mc.m2
@@ -442,7 +481,7 @@  m2/boot-bin/mc-devel$(exeext): m2/mc-obj/mcp1.mod \
                                mcflex.c \
                                m2/mc-boot-ch/Gabort.o
 	$(RM) -rf mc-obj
-	mkdir mc-obj
+	$(mkinstalldirs) mc-obj
 	$(CC) -I$(srcdir)/m2/mc -c -g mcflex.c -o mc-obj/mcflex.o
 	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/decl.mod -o mc-obj/decl.o
 	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcStream.mod -o mc-obj/mcStream.o
@@ -484,13 +523,16 @@  m2/boot-bin/mc-opt$(exeext): m2/mc-obj/mcp1.mod \
                              m2/mc-obj/mcp4.mod \
                              m2/mc-obj/mcp5.mod \
                              mcflex.c
+	-test -d m2/boot-bin || $(mkinstalldirs) m2/boot-bin
 	g++ -I$(srcdir)/m2/mc -c -g mcflex.c
 	$(BOOTGM2) -fsources -fm2-whole-program -g -I$(srcdir)/m2/mc:$(objdir)/m2/mc-obj:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/mc $(srcdir)/m2/mc/top.mod

 m2/mc/decl.o:  $(srcdir)/m2/mc/decl.mod
+	-test -d m2/mc || $(mkinstalldirs) m2/mc
 	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) -o $@ $(srcdir)/m2/mc/decl.mod

 m2/mc-obj/%.mod: $(srcdir)/m2/mc/%.bnf $(PGE)
+	-test -d m2/mc-obj || $(mkinstalldirs) m2/mc-obj
 	$(PGE) -l $< -o $@

 gm2-bootstrap: mc-devel
@@ -500,16 +542,16 @@  gm2-bootstrap: mc-devel


 $(objdir)/plugin:
-	test -d $@ || mkdir -p $@
+	-test -d $@ || $(mkinstalldirs) $@

 $(objdir)/m2/mc-boot:
-	test -d $@ || mkdir -p $@
+	-test -d $@ || $(mkinstalldirs) $@

 $(objdir)/m2/mc-boot-ch:
-	test -d $@ || mkdir -p $@
+	-test -d $@ || $(mkinstalldirs) $@

 $(objdir)/m2/mc-boot-gen:
-	test -d $@ || mkdir -p $@
+	-test -d $@ || $(mkinstalldirs) $@

 mc-autogen: mc-clean mc-devel \
             $(BUILD-MC-BOOT-H) $(BUILD-MC-BOOT-C) \
@@ -528,24 +570,31 @@  EXTENDED_OPAQUE =
 MC_OPTIONS = $(MC_COPYRIGHT) --gcc-config-system --olang=c++

 m2/mc-boot-gen/$(SRC_PREFIX)%.h: $(srcdir)/m2/mc/%.def
+	-test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
 	./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $<

 m2/mc-boot-gen/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def
+	-test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
 	./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $<

 m2/mc-boot-gen/$(SRC_PREFIX)decl.c: $(srcdir)/m2/mc/decl.mod
+	-test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
 	./mc $(MC_OPTIONS) --extended-opaque -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso --h-file-prefix=$(SRC_PREFIX) -o=$@ $<

 m2/mc-boot-gen/$(SRC_PREFIX)%.c: $(srcdir)/m2/mc/%.mod
+	-test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
 	./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $<

 m2/mc-boot-gen/$(SRC_PREFIX)%.c: $(srcdir)/m2/gm2-libs/%.mod
+	-test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
 	./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $<

 m2/mc-boot-gen/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs-iso/%.def
+	-test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
 	./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $<

 m2/mc-boot-gen/$(SRC_PREFIX)%.c: m2/mc-obj/%.mod
+	-test -d m2/mc-boot-gen || $(mkinstalldirs) m2/mc-boot-gen
 	./mc $(MC_OPTIONS) -I$(srcdir)/m2/mc:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso $(EXTENDED_OPAQUE) --h-file-prefix=$(SRC_PREFIX) -o=$@ $<

 # mc-bootstrap compiles mc using the C version previously generated by mc-autogen.
@@ -574,9 +623,11 @@  gm2.maintainer-help: force

 #
 #  verify the compiler can be built across three generations of cc1gm2 diffing assembly output.
-#  stage1/m2/cc1gm2 built by translating M2 into C++.
-#  stage2/m2/cc1gm2 built from stage1/m2/cc1gm2.
-#  stage3/m2/cc1gm2 built from stage2/m2/cc1gm2.
+#  m2/stage1/cc1gm2 built by translating all M2 sources into C++.
+#  m2/m2obj2/cc1gm2 built from m2/stage1/cc1gm2.
+#  m2/m2obj3/cc1gm2 built from m2/m2obj2/cc1gm2.
+#
+#  This test only makes sense if host = target = build
 #

 # GM2-VERIFY-MODS is a list of modules which have no __DATE__ stamp inside them
@@ -608,11 +659,12 @@  GM2-VERIFY-AUTO    = P1Build.mod       P2Build.mod     PCBuild.mod     P3Build.m
 GM2_LIBS_PARANOID = m2/gm2-compiler-paranoid/gm2.a \
                     m2/gm2-libs-paranoid/libgm2.a                       # build it again using GM2_LIBS

-gm2.paranoid: stage3/m2/cc1gm2$(exeext) gm2.verifyparanoid
+gm2.paranoid: m2/m2obj3/cc1gm2$(exeext) gm2.verifyparanoid

-stage3/m2/cc1gm2$(exeext): stage2/m2/cc1gm2$(exeext) m2/gm2-compiler-paranoid/m2flex.o \
+m2/m2obj3/cc1gm2$(exeext): m2/m2obj2/cc1gm2$(exeext) m2/gm2-compiler-paranoid/m2flex.o \
                             $(P) $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS_PARANOID) \
                             m2/gm2-gcc/rtegraph.o plugin/m2rte$(exeext).so m2/gm2-libs-boot/M2LINK.o
+	-test -d m2/m2obj3 || $(mkinstalldirs) m2/m2obj3
 	@$(call LINK_PROGRESS,$(INDEX.m2),start)
 	+$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler-paranoid/m2flex.o \
                             attribs.o \
@@ -624,7 +676,7 @@  stage3/m2/cc1gm2$(exeext): stage2/m2/cc1gm2$(exeext) m2/gm2-compiler-paranoid/m2

 # gm2.verifyparanoid diffs the output of all three compilers with the compiler source code

-gm2.verifyparanoid: stage1/m2/cc1gm2$(exeext) stage2/m2/cc1gm2$(exeext) stage3/m2/cc1gm2$(exeext) force
+gm2.verifyparanoid: m2/stage1/cc1gm2$(exeext) m2/m2obj2/cc1gm2$(exeext) m2/m2obj3/cc1gm2$(exeext) force
 	@echo "verifying the three generations of GNU Modula-2 compilers - it may take some time.."
 	$(QUIAT)for i in $(GM2-VERIFY-MODS) ; do \
            echo -n "$$i " ; \
@@ -652,11 +704,11 @@  gm2.verifyparanoid: stage1/m2/cc1gm2$(exeext) stage2/m2/cc1gm2$(exeext) stage3/m
 	$(QUIAT)for i in x $(GM2-VERIFY-AUTO) ; do \
            if [ -f m2/gm2-auto/$$i ] ; then \
               echo -n "$$i " ; \
-              ./gm2 -S $(GM2_FLAGS) -c -B./stage1/m2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/1.s ; \
+              ./gm2 -S $(GM2_FLAGS) -c -B./m2/stage1 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/1.s ; \
               echo -n "[1]" ; \
-              ./gm2 -S $(GM2_FLAGS) -c -B./stage2/m2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/2.s ; \
+              ./gm2 -S $(GM2_FLAGS) -c -B./m2/m2obj2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/2.s ; \
               echo -n "[2]" ; \
-              ./gm2 -S $(GM2_FLAGS) -c -B./stage3/m2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/3.s ; \
+              ./gm2 -S $(GM2_FLAGS) -c -B./m2/m2obj3 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/3.s ; \
               echo -n "[3]" ; \
               if ! diff m2/gm2-compiler-verify/1.s m2/gm2-compiler-verify/2.s > m2/gm2-compiler-verify/1_2.diff 2>&1 ; then \
                   echo -n " [stage 1 and stage 2 differ]" ; \
@@ -678,7 +730,7 @@  gm2.verifyparanoid: stage1/m2/cc1gm2$(exeext) stage2/m2/cc1gm2$(exeext) stage3/m

 # gm2.verifystage12 diffs the output of the stage1 and stage2 compilers with the compiler source code

-gm2.verifystage12: force stage1/m2/cc1gm2$(exeext) stage2/m2/cc1gm2$(exeext)
+gm2.verifystage12: force m2/stage1/cc1gm2$(exeext) m2/m2obj2/cc1gm2$(exeext)
 	@echo "verifying stage1 and stage2 generations of GNU Modula-2 compilers - it may take some time.."
 	$(QUIAT)for i in $(GM2-VERIFY-MODS) ; do \
            echo -n "$$i " ; \
@@ -698,9 +750,9 @@  gm2.verifystage12: force stage1/m2/cc1gm2$(exeext) stage2/m2/cc1gm2$(exeext)
 	$(QUIAT)for i in x $(GM2-VERIFY-AUTO) ; do \
            if [ -f m2/gm2-auto/$$i ] ; then \
               echo -n "$$i " ; \
-              ./gm2 -S $(GM2_FLAGS) -c -B./stage1/m2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/1.s ; \
+              ./gm2 -S $(GM2_FLAGS) -c -B./m2/stage1 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/1.s ; \
               echo -n "[1]" ; \
-              ./gm2 -S $(GM2_FLAGS) -c -B./stage2/m2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/2.s ; \
+              ./gm2 -S $(GM2_FLAGS) -c -B./m2/m2obj2 -I$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-gcc:$(srcdir)/m2/gm2-libiberty m2/gm2-auto/$$i -o m2/gm2-compiler-verify/2.s ; \
               echo -n "[2]" ; \
               if ! diff m2/gm2-compiler-verify/1.s m2/gm2-compiler-verify/2.s > m2/gm2-compiler-verify/1_2.diff 2>&1 ; then \
                   echo -n " [stage 1 and stage 2 differ]" ; \
@@ -717,78 +769,99 @@  gm2.verifystage12: force stage1/m2/cc1gm2$(exeext) stage2/m2/cc1gm2$(exeext)
 # The rules which build objects in the gm2-compiler-paranoid gm2-libs-paranoid directories.

 m2/gm2-libs-paranoid/%.o: m2/gm2-libs-ch/%.c
+	-test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
 	$(XGCC) -c -g $(GM2_O_S3) $(GM2_O) -I./ -Im2/gm2-libs -Wall $(INCLUDES) $< -o $@

 m2/gm2-libs-paranoid/%.o: $(srcdir)/m2/gm2-libs/%.mod
+	-test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
 	$(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libiberty $< -o $@

 m2/gm2-compiler-paranoid/%.o: $(srcdir)/m2/gm2-compiler/%.mod
+	-test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
 	$(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@

 m2/gm2-compiler-paranoid/%.o: m2/gm2-compiler-paranoid/%.mod
+	-test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
 	$(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@

 m2/gm2-compiler-paranoid/P0SyntaxCheck.o: m2/gm2-compiler-paranoid/P0SyntaxCheck.mod
+	-test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
 	$(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@

 m2/gm2-compiler-paranoid/P1Build.o: m2/gm2-compiler-paranoid/P1Build.mod
+	-test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
 	$(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@

 m2/gm2-compiler-paranoid/P2Build.o: m2/gm2-compiler-paranoid/P2Build.mod
+	-test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
 	$(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@

 m2/gm2-compiler-paranoid/P3Build.o: m2/gm2-compiler-paranoid/P3Build.mod
+	-test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
 	$(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@

 m2/gm2-compiler-paranoid/PHBuild.o: m2/gm2-compiler-paranoid/PHBuild.mod
+	-test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
 	$(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@

 m2/gm2-compiler-paranoid/PCBuild.o: m2/gm2-compiler-paranoid/PCBuild.mod
+	-test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
 	$(GM2_2) $(GM2_O_S3) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc -I$(srcdir)/m2/gm2-libiberty $< -o $@

 m2/gm2-libs-paranoid/host.o: $(srcdir)/m2/gm2-libs-ch/host.c m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
 	$(CXX) -c $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-paranoid/wrapc.o: $(srcdir)/m2/gm2-libs-ch/wrapc.c m2/gm2-libs-boot/$(SRC_PREFIX)wrapc.h m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
 	$(CXX) -c -DIN_GCC $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-paranoid/UnixArgs.o: $(srcdir)/m2/gm2-libs-ch/UnixArgs.cc \
                                   m2/gm2-libs-boot/$(SRC_PREFIX)UnixArgs.h
+	-test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
 	$(CXX) -c -DIN_GCC $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-paranoid/errno.o: $(srcdir)/m2/gm2-libs-ch/errno.c \
                                    m2/gm2-libs-boot/$(SRC_PREFIX)errno.h
+	-test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
 	$(CXX) -c -DIN_GCC $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-paranoid/Selective.o: $(srcdir)/m2/gm2-libs-ch/Selective.c \
                                    m2/gm2-libs-boot/$(SRC_PREFIX)Selective.h
+	-test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
 	$(COMPILER) -c -DIN_GCC $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-libs-paranoid/choosetemp.o: $(srcdir)/m2/gm2-libs-ch/choosetemp.c \
                                     m2/gm2-libiberty/$(SRC_PREFIX)choosetemp.h
+	-test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
 	$(CXX) -c -DIN_GCC $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty $(INCLUDES) $< -o $@

 m2/gm2-libs-paranoid/SysExceptions.o: $(srcdir)/m2/gm2-libs-ch/SysExceptions.c \
                                   m2/gm2-libs-boot/$(SRC_PREFIX)SysExceptions.h
+	-test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
 	$(CXX) -c -DIN_GCC $(GM2_O_S3) $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@

 m2/gm2-compiler-paranoid/m2flex.o: m2/gm2-compiler/m2flex.c $(TIMEVAR_H)
+	-test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
 	$(COMPILER) -c $(GM2_O_S3) -g $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
           $(GM2GCC) -Im2/gm2-compiler-boot -Im2/gm2-libs-boot $< -o $@

 m2/gm2-libs-paranoid/dtoa.o: $(srcdir)/m2/gm2-libs-ch/dtoa.cc \
                               m2/gm2-libs-boot/$(SRC_PREFIX)dtoa.h \
                               m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
 	$(CXX) -c $(GM2_O_S3) $(CFLAGS) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@

 m2/gm2-libs-paranoid/ldtoa.o: $(srcdir)/m2/gm2-libs-ch/ldtoa.cc \
                                m2/gm2-libs-boot/$(SRC_PREFIX)ldtoa.h \
                                m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
 	$(CXX) -c $(GM2_O_S3) $(CFLAGS) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@

 m2/gm2-libs-paranoid/termios.o: $(srcdir)/m2/gm2-libs-ch/termios.c \
                                m2/gm2-libs-boot/$(SRC_PREFIX)termios.h \
                                m2/gm2-libs/gm2-libs-host.h
+	-test -d m2/gm2-libs-paranoid || $(mkinstalldirs) m2/gm2-libs-paranoid
 	$(CXX) -c $(GM2_O_S3) $(CFLAGS) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@


@@ -818,12 +891,15 @@  m2/gm2-compiler-paranoid/gm2.a: \
 	$(RANLIB) $@

 m2/gm2-compiler-paranoid/M2Version.mod:
+	-test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
 	$(SHELL) $(srcdir)/m2/tools-src/makeversion -m $(srcdir) m2/gm2-compiler-paranoid

 m2/gm2-compiler-paranoid/M2Version.o: m2/gm2-compiler-paranoid/M2Version.mod
+	-test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
 	$(GM2_2) $(GM2_FLAGS) -c -I$(srcdir)/m2/gm2-compiler -I$(srcdir)/m2/gm2-libs -I$(srcdir)/m2/gm2-gcc $< -o $@

 m2/gm2-compiler-paranoid/%.mod: $(srcdir)/m2/gm2-compiler/%.bnf $(PGE)
+	-test -d m2/gm2-compiler-paranoid || $(mkinstalldirs) m2/gm2-compiler-paranoid
 	$(PGE) -k -l $< -o $@

 # Recreate the target independent copies of the documentation which is
diff --git a/gcc/m2/config-lang.in b/gcc/m2/config-lang.in
index 68bb525355a..d2afff2f23f 100644
--- a/gcc/m2/config-lang.in
+++ b/gcc/m2/config-lang.in
@@ -52,32 +52,3 @@  gtfiles="\$(srcdir)/m2/gm2-lang.cc \
 outputs="m2/config-make \
          m2/Make-maintainer \
         "
-
-mkdir -p m2/gm2-compiler-boot
-mkdir -p m2/gm2-libs-boot
-mkdir -p m2/gm2-ici-boot
-mkdir -p m2/gm2-libiberty
-mkdir -p m2/gm2-gcc
-mkdir -p m2/gm2-compiler
-mkdir -p m2/gm2-libs
-mkdir -p m2/gm2-libs-iso
-mkdir -p m2/gm2-compiler-paranoid
-mkdir -p m2/gm2-libs-paranoid
-mkdir -p m2/gm2-compiler-verify
-mkdir -p m2/boot-bin
-mkdir -p m2/gm2-libs-pim
-mkdir -p m2/gm2-libs-coroutines
-mkdir -p m2/gm2-libs-min
-mkdir -p m2/pge-boot
-mkdir -p plugin
-mkdir -p stage1/m2 stage2/m2 stage3/m2 stage4/m2
-
-# directories used by Make-maintainer
-
-mkdir -p m2/gm2-auto
-mkdir -p m2/gm2-pg-boot
-mkdir -p m2/gm2-pge-boot
-mkdir -p m2/gm2-ppg-boot
-mkdir -p m2/mc-boot
-mkdir -p m2/mc-boot-ch
-mkdir -p m2/mc-boot-gen