[v5,1a/19] modula2 front end: (long unedited patches).

Message ID 87sfhict3i.fsf@debian
State Accepted
Headers
Series [v5,1a/19] modula2 front end: (long unedited patches). |

Checks

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

Commit Message

Gaius Mulley Dec. 14, 2022, 8 a.m. UTC
  This patch set adds a re-exp ACX_CHECK_PROG_VER to detect python3.
HAVE_PYTHON is then checked in gcc/m2/Make-lang.in to generate library
chapters if python3 is available.  If python3 is unavailable then the
chapters are copied from a target-independent version.

Bugfixed --enable-generated-files-in-srcdir.

Python3 modules section added to install.texi.

Also included are the target-independent versions of the
documentation.  The only difference is in the SYSTEM module which if
generated when HAVE_PYTHON is "yes" will enumerate all fundamental
data types supported by the target and compiler.

For completness (1a and 1b) contain the entire patchset

regards,
Gaius


------8<----------8<----------8<----------8<----------8<----------8<----
  

Patch

diff -ruw gcc-git-master/gcc/configure.ac gcc-git-devel-modula2/gcc/configure.ac
--- gcc-git-master/gcc/configure.ac	2022-12-14 06:54:50.040826539 +0000
+++ gcc-git-devel-modula2/gcc/configure.ac	2022-12-14 06:54:59.564964362 +0000
@@ -1263,6 +1263,20 @@ 
 # Bison?
 AC_CHECK_PROGS([BISON], bison, [$MISSING bison])
 
+# Python3?
+ACX_CHECK_PROG_VER(PYTHON, python3, --version,
+  [Python.* \([0-9][0-9.]*\)],
+  [3.[4-9]*|3.[1-9][0-9]*|[4-9].*|[1-9][0-9]*])
+if test $gcc_cv_prog_python3_modern = no; then
+  AC_MSG_WARN([
+*** Python3 is missing.
+*** Documentation for modula-2 will not include the target SYSTEM module.])
+  HAVE_PYTHON=no
+else
+  HAVE_PYTHON=yes
+fi
+AC_SUBST(HAVE_PYTHON)
+
 # Binutils are not build modules, unlike bison/flex/makeinfo.  So we
 # check for build == host before using them.
 
@@ -7651,4 +7665,3 @@ 
 ], 
 [subdirs='$subdirs'])
 AC_OUTPUT
-
diff -ruw gcc-git-master/gcc/doc/install.texi gcc-git-devel-modula2/gcc/doc/install.texi
--- gcc-git-master/gcc/doc/install.texi	2022-12-14 06:54:50.132827871 +0000
+++ gcc-git-devel-modula2/gcc/doc/install.texi	2022-12-14 06:54:59.604964941 +0000
@@ -308,6 +308,13 @@ 
 and works if @option{--enable-libphobos} is used.  Specifics are
 documented for affected targets.
 
+@item @anchor{GM2-prerequisite}GM2
+
+Python3 is required if you want to build the complete Modula-2
+documentation including the target @code{SYSTEM} definition module.
+If Python3 is unavailable Modula-2 documentation will include a target
+independent version of the SYSTEM modules.
+
 @item A ``working'' POSIX compatible shell, or GNU bash
 
 Necessary when running @command{configure} because some
@@ -436,6 +443,34 @@ 
 The library is searched in your default library patch search.
 Alternatively, the @option{--with-zstd} configure option should be used.
 
+@item Python3 modules
+
+The complete list of Python3 modules broken down by GCC subcomponent
+is shown below:
+
+@table @asis
+@item internal debugging in gdbhooks
+@code{gdb}, @code{gdb.printing}, @code{gdb.types},
+@code{os.path}, @code{re}, @code{sys} and @code{tempfile},
+
+@item g++ testsuite
+@code{gcov}, @code{gzip}, @code{json}, @code{os} and @code{pytest}.
+
+@item c++ cxx api generation
+@code{csv}, @code{os}, @code{sys} and @code{time}.
+
+@item modula-2 documentation
+@code{argparse}, @code{os}, @code{pathlib}, @code{shutil} and
+@code{sys}.
+
+@item git developer tools
+@code{os} and @code{sys}.
+
+@item ada documentation
+@code{latex_elements}, @code{os}, @code{pygments}, @code{re},
+@code{sys} and @code{time}.
+@end table
+
 @end table
 
 @heading Tools/packages necessary for modifying GCC
@@ -3144,10 +3179,10 @@ 
 In order to run sets of tests selectively, there are targets
 @samp{make check-gcc} and language specific @samp{make check-c},
 @samp{make check-c++}, @samp{make check-d} @samp{make check-fortran},
-@samp{make check-ada}, @samp{make check-objc}, @samp{make check-obj-c++},
-@samp{make check-lto}
-in the @file{gcc} subdirectory of the object directory.  You can also
-just run @samp{make check} in a subdirectory of the object directory.
+@samp{make check-ada}, @samp{make check-m2}, @samp{make check-objc},
+@samp{make check-obj-c++}, @samp{make check-lto} in the @file{gcc}
+subdirectory of the object directory.  You can also just run
+@samp{make check} in a subdirectory of the object directory.
 
 
 A more selective way to just run all @command{gcc} execute tests in the
diff -ruw /dev/null gcc-git-devel-modula2/gcc/doc/gm2.texi
--- /dev/null	2022-08-24 16:22:16.888000070 +0100
+++ gcc-git-devel-modula2/gcc/doc/gm2.texi	2022-12-14 06:54:59.604964941 +0000
@@ -0,0 +1,2838 @@ 
+\input texinfo
+@c -*-texinfo-*-
+@c Copyright (C) 2001-2022 Free Software Foundation, Inc.
+@c This is part of the GM2 manual.
+
+@c User level documentation for GNU Modula-2
+@c
+@c header
+
+@setfilename gm2.info
+@settitle The GNU Modula-2 Compiler
+
+@set version-python  3.5
+
+@include gcc-common.texi
+
+@c Copyright years for this manual.
+@set copyrights-gm2 1999-2022
+
+@copying
+@c man begin COPYRIGHT
+Copyright @copyright{} @value{copyrights-gm2} Free Software Foundation, Inc.
+
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.3 or
+any later version published by the Free Software Foundation; with no
+Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+A copy of the license is included in the
+@c man end
+section entitled ``GNU Free Documentation License''.
+@ignore
+@c man begin COPYRIGHT
+man page gfdl(7).
+@c man end
+@end ignore
+@end copying
+
+@ifinfo
+@format
+@dircategory Software development
+@direntry
+* gm2: (gm2).               A GCC-based compiler for the Modula-2 language
+@end direntry
+@end format
+
+@insertcopying
+@end ifinfo
+
+@titlepage
+@title The GNU Modula-2 Compiler
+@versionsubtitle
+@author Gaius Mulley
+
+@page
+@vskip 0pt plus 1filll
+Published by the Free Software Foundation @*
+51 Franklin Street, Fifth Floor@*
+Boston, MA 02110-1301, USA@*
+@sp 1
+@insertcopying
+@end titlepage
+@contents
+@page
+
+@c `Top' Node and Master Menu
+
+@node Top, Overview, (dir), (dir)
+@top Introduction
+
+@menu
+* Overview::         What is GNU Modula-2.
+* Using::            Using GNU Modula-2.
+* License::          License of GNU Modula-2
+* Copying::          GNU Public License V3.
+* Contributing::     Contributing to GNU Modula-2
+* Internals::        GNU Modula-2 internals.
+* EBNF::             EBNF of GNU Modula-2
+* Libraries::        PIM and ISO library definitions.
+* Indices::          Document and function indices.
+@end menu
+
+@node Overview, Using, Top, Top
+@chapter Overview of GNU Modula-2
+
+@menu
+* What is GNU Modula-2::  Brief description of GNU Modula-2.
+* Why use GNU Modula-2::  Advantages of GNU Modula-2.
+* Development::           How to get source code using git.
+* Features::              GNU Modula-2 Features
+@end menu
+
+@node What is GNU Modula-2, Why use GNU Modula-2, , Using
+@section What is GNU Modula-2
+
+GNU Modula-2 is a @uref{http://gcc.gnu.org/frontends.html, front end}
+for the GNU Compiler Collection (@uref{http://gcc.gnu.org/, GCC}).
+The GNU Modula-2 compiler is compliant with the PIM2, PIM3, PIM4 and
+ISO dialects.  Also implemented are a complete set of free ISO
+libraries and PIM libraries.
+
+@footnote{The four Modula-2 dialects supported are defined in the following
+references:
+
+PIM2: 'Programming in Modula-2', 2nd Edition, Springer Verlag, 1982,
+1983 by Niklaus Wirth (PIM2).
+
+PIM3: 'Programming in Modula-2', 3rd Corrected Edition, Springer Verlag,
+1985 (PIM3).
+
+PIM4: 'Programming in Modula-2', 4th Edition, Springer Verlag, 1988
+(@uref{http://freepages.modula2.org/report4/modula-2.html, PIM4}).
+
+ISO: the ISO Modula-2 language as defined in 'ISO/IEC Information
+technology - programming languages - part 1: Modula-2 Language,
+ISO/IEC 10514-1 (1996)'
+}
+
+@node Why use GNU Modula-2, Release map, What is GNU Modula-2, Using
+@section Why use GNU Modula-2
+
+There are a number of advantages of using GNU Modula-2 rather than
+translate an existing project into another language.
+
+The first advantage is of maintainability of the original sources
+and the ability to debug the original project source code using a
+combination of gm2 and gdb.
+
+The second advantage is that gcc runs on many processors and
+platforms.  gm2 builds and runs on powerpc64le, amd64, i386, aarch64
+to name but a few processors.
+
+gm2 can produce swig interface headers to allow access from Python and
+other scripting languages.  It can also be used with C/C++ and
+generate shared libraries.
+
+The compiler provides semantic analysis and run time checking (full ISO
+Modula-2 checking is implemented) and there is a plugin which can,
+under certain conditions, detect run time errors at compile time.
+
+The compiler supports PIM2, PIM3, PIM4 and ISO dialects of Modula-2,
+work is underway to implement M2R10.  Many of the GCC builtins are
+available and access to assembly programming is achieved using the
+same syntax as that used by GCC.
+
+The gm2 driver allows third party libraries to be installed alongside
+gm2 libraries.  For example if the user specifies library @code{foo}
+using @code{-flibs=foo} the driver will check the standard GCC install
+directory for a sub directory @code{foo} containing the library
+contents.  The library module search path is altered accordingly
+for compile and link.
+
+@node Release map, Development, Why use GNU Modula-2, Using
+@section Release map
+
+GNU Modula-2 is now part of GCC and therefore will adopt the GCC
+release schedule.  It is intended that GNU Modula-2 implement more of
+the GCC builtins (vararg access) and GCC features.
+
+There is an intention to implement the ISO generics and the M2R10
+dialect of Modula-2.  It will also implement all language changes.  If
+you wish to see something different please email
+@email{gm2@@nongnu.org} with your ideas.
+
+@node Development, Features, Release map, Using
+@section How to get source code using git
+
+GNU Modula-2 is now in the @url{https://gcc.gnu.org/git.html, GCC git
+tree}.
+
+@node Features, Documentation, Development, Using
+@section GNU Modula-2 Features
+
+@itemize @bullet
+
+@item
+the compiler currently complies with Programming in Modula-2 Edition
+2, 3, 4 and ISO Modula-2.  Users can switch on specific language
+features by using: @samp{-fpim}, @samp{-fpim2}, @samp{-fpim3},
+@samp{-fpim4} or @samp{-fiso}.
+
+@item
+the option @samp{-fswig} will automatically create a swig interface
+file which corresponds to the definition module of the file being
+compiled.
+
+@item
+exception handling is compatible with C++ and swig.  Modula-2 code can
+be used with C or C++ code.
+
+@item
+Python can call GNU Modula-2 modules via swig.
+
+@item
+shared libraries can be built.
+
+@item
+fixed sized types are now available from @samp{SYSTEM}.
+
+@c @item
+@c support for dynamic @code{ARRAY}s has been added into @samp{gdb}.
+
+@item
+variables can be declared at addresses.
+
+@item
+much better dwarf-2 debugging support and when used with
+@samp{gdb} the programmer can display @code{RECORD}s,
+@code{ARRAY}s, @code{SET}s, subranges and constant char literals
+in Modula-2 syntax.
+
+@item
+supports sets of any ordinal size (memory permitting).
+
+@item
+easy interface to C, and varargs can be passed to C routines.
+
+@item
+many Logitech libraries have been implemented and can be accessed via:
+@samp{-flibs=m2log,m2pim,m2iso}.
+
+@item
+coroutines have been implemented in the PIM style and these are
+accessible from SYSTEM.  A number of supporting libraries (executive
+and file descriptor mapping to interrupt vector libraries are
+available through the @samp{-flibs=m2iso,m2pim} switch).
+
+@item
+can be built as a cross compiler (for embedded microprocessors
+such as the AVR and the ARM).
+
+@end itemize
+
+@node Documentation, Regression tests, Features, Using
+@section Documentation
+
+The GNU Modula-2 documentation is available on line
+@url{https://www.nongnu.org/gm2/homepage.html,at the gm2 homepage}
+or in the pdf, info, html file format.
+
+@node Regression tests, Limitations, Documentation, Using
+@section Regression tests for gm2 in the repository
+
+The regression testsuite can be run from the gcc build directory:
+
+@example
+$ cd build-gcc
+$ make check -j 24
+@end example
+
+which runs the complete testsuite for all compilers using 24 parallel
+invocations of the compiler.  Individual language testsuites can be
+run by specifying the language, for example the Modula-2 testsuite can
+be run using:
+
+@example
+$ cd build-gcc
+$ make check-m2 -j 24
+@end example
+
+Finally the results of the testsuite can be emailed to the
+@url{https://gcc.gnu.org/lists.html, gcc-testresults} list using the
+@file{test_summary} script found in the gcc source tree:
+
+@example
+$ @samp{directory to the sources}/contrib/test_summary
+@end example
+
+@node Limitations, Objectives, Regression tests, Using
+@section Limitations
+
+Logitech compatibility library is incomplete.  The principle modules
+for this platform exist however for a comprehensive list of completed
+modules please check the documentation
+@url{gm2.html}.
+
+@node Objectives, FAQ, , Using
+@section Objectives
+
+@itemize @bullet
+
+@item
+The intention of GNU Modula-2 is to provide a production Modula-2
+front end to GCC.
+
+@item
+It should support all Niklaus Wirth PIM Dialects [234] and also ISO
+Modula-2 including a re-implementation of all the ISO modules.
+
+@item
+There should be an easy interface to C.
+
+@item
+Exploit the features of GCC.
+
+@item
+Listen to the requests of the users.
+@end itemize
+
+@node FAQ, Community, Objectives, Using
+@section FAQ
+
+@subsection Why use the C++ exception mechanism in GCC, rather than a bespoke Modula-2 mechanism?
+
+The C++ mechanism is tried and tested, it also provides GNU Modula-2
+with the ability to link with C++ modules and via swig it can raise
+Python exceptions.
+
+@node Community, Other languages, FAQ, Using
+@section Community
+
+You can subscribe to the GNU Modula-2 mailing by sending an
+email to:
+@email{gm2-subscribe@@nongnu.org}
+or by
+@url{http://lists.nongnu.org/mailman/listinfo/gm2}.
+The mailing list contents can be viewed
+@url{http://lists.gnu.org/archive/html/gm2}.
+
+@node Other languages, , Community, Using
+@section Other languages for GCC
+
+These exist and can be found on the frontends web page on the
+@uref{http://gcc.gnu.org/frontends.html, gcc web site}.
+
+@node Using, , Community, Top
+@chapter Using GNU Modula-2
+
+@menu
+* Example usage::         Example compile and link.
+* Compiler options::      GNU Modula-2 compiler options.
+* Linking::               Linking options in more detail.
+* Elementary data types:: Data types supported by GNU Modula-2.
+* Standard procedures::   Permanently accessible base procedures.
+* Dialect::               GNU Modula-2 supported dialects.
+* Exceptions::            Exception implementation
+* Semantic checking::     How to detect run time problems at compile time.
+* Extensions::            GNU Modula-2 language extensions.
+* Type compatibility::    Data type compatibility.
+* Unbounded by reference::Explanation of a language optimization.
+* Building a shared library:: How to build a shared library.
+* Interface for Python::  How to produce swig interface files.
+* Producing a Python module::  How to produce a Python module.
+* Interface to C::        Interfacing GNU Modula-2 to C.
+* Assembly language::     Interface to assembly language.
+* Alignment::             Data type alignment.
+* Packed::                Packing data types.
+* Built-ins::             Accessing GNU Modula-2 Built-ins.
+* The PIM system module:: SYSTEM data types and procedures.
+* The ISO system module:: SYSTEM data types, procedures and run time.
+* Other languages::       Other languages for GCC.
+* What is GNU Modula-2::  Brief description of GNU Modula-2.
+* Why use GNU Modula-2::  Advantages of GNU Modula-2.
+@ifnothtml
+@c omit these nodes if generating gm2 webpage as these are hand written.
+* Release map:: Release map.
+* Development:: Development.
+* Features:: Features of the implementation.
+* Documentation:: Placeholder for how to access the documentation online.
+* Regression tests:: How to run the testsuite.
+* Limitations:: Current limitations.
+* Objectives:: Objectives of the implementation.
+* FAQ:: Frequently asked questions.
+* Community:: How to join the community.
+@end ifnothtml
+@end menu
+
+This document contains the user and design issues relevant to the
+Modula-2 front end to gcc.
+
+@node Example usage, Compiler options, Using, Using
+@section Example compile and link
+
+@ignore
+@c man begin SYNOPSIS gm2
+gm2 [@option{-c}|@option{-S}] [@option{-g}] [@option{-pg}]
+    [@option{-O}@var{level}] [@option{-W}@var{warn}@dots{}]
+    [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
+    [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}]
+    [@option{-o} @var{outfile}] [@@@var{file}] @var{infile}@dots{}
+
+Only the most useful options are listed here; see below for the
+remainder.
+@c man end
+@c man begin SEEALSO
+gpl(7), gfdl(7), fsf-funding(7), gcc(1)
+and the Info entries for @file{gm2} and @file{gcc}.
+@c man end
+@end ignore
+
+@c man begin DESCRIPTION gm2
+
+The @command{gm2} command is the GNU compiler for the Modula-2 language and
+supports many of the same options as @command{gcc}.  @xref{Option Summary, ,
+Option Summary, gcc, Using the GNU Compiler Collection (GCC)}.
+This manual only documents the options specific to @command{gm2}.
+
+@c man end
+
+This section describes how to compile and link a simple hello world
+program.  It provides a few examples of using the different options
+mentioned in @pxref{Compiler options, , ,gm2}.  Assuming that you have
+a file called @file{hello.mod} in your current directory which
+contains:
+
+@example
+MODULE hello ;
+
+FROM StrIO IMPORT WriteString, WriteLn ;
+
+BEGIN
+   WriteString ('hello world') ; WriteLn
+END hello.
+@end example
+
+You can compile and link it by: @samp{gm2 -g hello.mod}.
+The result will be an @samp{a.out} file created in your directory.
+
+You can split this command into two steps if you prefer.  The compile
+step can be achieved by: @samp{gm2 -g -c -fscaffold-main hello.mod}
+and the link via: @samp{gm2 -g hello.o}.
+
+@footnote{To see all the compile actions taken by @samp{gm2} users can also
+add the @samp{-v} flag at the command line, for example:
+
+@samp{gm2 -v -g -I. hello.mod}
+
+This displays the sub processes initiated by @samp{gm2} which can be useful
+when trouble shooting.}
+
+@node Compiler options, Elementary data types, Example usage, Using
+@section Compiler options
+
+This section describes the compiler options specific to GNU Modula-2
+for generic flags details @xref{Invoking GCC, , ,gcc}.
+
+@c man begin OPTIONS
+
+For any given input file, the file name suffix determines what kind of
+compilation is done.  The following kinds of input file names are supported:
+
+@table @gcctabopt
+@item @var{file}.mod
+Modula-2 implementation or program source files.  See the
+@samp{-fmod=} option if you wish to compile a project which uses a
+different source file extension.
+@item @var{file}.def
+Modula-2 definition module source files.  Definition modules are not
+compiled separately, in GNU Modula-2 definition modules are parsed as
+required when program or implementation modules are compiled.  See the
+@samp{-fdef=} option if you wish to compile a project which uses a
+different source file extension.
+@end table
+
+You can specify more than one input file on the @command{gm2} command line,
+
+@table @code
+
+@item -g
+create debugging information so that debuggers such as @file{gdb}
+can inspect and control executable.
+
+@item -I
+used to specify the search path for definition and implementation
+modules.  An example is:  @code{gm2 -g -c -I.:../../libs foo.mod}.
+If this option is not specified then the default path is added
+which consists of the current directory followed by the appropriate
+language dialect library directories.
+
+@c ordered list of options from here.
+
+@item -fauto-init
+turns on auto initialization of pointers to NIL.  Whenever a block is
+created all pointers declared within this scope will have their
+addresses assigned to NIL.
+
+@item -fbounds
+turns on run time subrange, array index and indirection via @code{NIL}
+pointer checking.
+
+@item -fcase
+turns on compile time checking to check whether a @code{CASE}
+statement requires an @code{ELSE} clause when on was not specified.
+
+@item -fcpp
+preprocess the source with @samp{cpp -lang-asm -traditional-cpp}
+For further details about these options @xref{Invocation, , ,cpp}.
+If @samp{-fcpp} is supplied then all definition modules and
+implementation modules which are parsed will be prepossessed by
+@samp{cpp}.
+
+@c fcpp-end
+@c Modula-2
+@c passed to the preprocessor if -fcpp is used (internal switch)
+
+@c fcpp-begin
+@c Modula-2
+@c passed to the preprocessor if -fcpp is used (internal switch)
+
+@item -fdebug-builtins
+call a real function, rather than the builtin equivalent.  This can
+be useful for debugging parameter values to a builtin function as
+it allows users to single step code into a real function.
+
+@c fd
+@c Modula-2
+@c turn on internal debugging of the compiler (internal switch)
+
+@c fdebug-trace-quad
+@c Modula-2
+@c turn on quadruple tracing (internal switch)
+
+@c fdebug-trace-api
+@c Modula-2
+@c turn on the Modula-2 api tracing (internal switch)
+
+@c fdebug-function-line-numbers
+@c Modula-2
+@c turn on the Modula-2 function line number generation (internal switch)
+
+@item -fdef=
+recognize the specified suffix as a definition module filename.
+The default implementation and module filename suffix is @file{.def}.
+If this option is used GNU Modula-2 will still fall back to this
+default if a requested definition module is not found.
+
+@item -fdump-system-exports
+display all inbuilt system items.
+This is an internal command line option.
+
+@item -fexceptions
+turn on exception handling code.  By default this option is on.
+Exception handling can be disabled by @samp{-fno-exceptions}
+and no references are made to the run time exception libraries.
+
+@item -fextended-opaque
+allows opaque types to be implemented as any type.  This is a GNU
+Modula-2 extension and it requires that the implementation module
+defining the opaque type is available so that it can be resolved when
+compiling the module which imports the opaque type.
+
+@item -ffloatvalue
+turns on run time checking to check whether a floating point number is
+about to exceed range.
+
+@item -fgen-module-list=@file{filename}
+attempt to find all modules when linking and generate a module list.
+If the @file{filename} is @samp{-} then the contents are not written
+and only used to force the linking of all module ctors.
+This option cannot be used if @samp{-fuse-list=} is enabled.
+
+@item -findex
+generate code to check whether array index values are out of bounds.
+Array index checking can be disabled via @samp{-fno-index}.
+
+@item -fiso
+turn on ISO standard features.  Currently this enables the ISO
+@code{SYSTEM} module and alters the default library search path so
+that the ISO libraries are searched before the PIM libraries.  It also
+effects the behavior of @code{DIV} and @code{MOD} operators.
+@xref{Dialect, , ,gm2}.
+
+@item -flibs=
+modifies the default library search path.  The libraries supplied are:
+m2pim, m2iso, m2min, m2log and m2cor.  These map onto the
+Programming in Modula-2 base libraries, ISO standard libraries, minimal
+library support, Logitech compatible library and Programming in
+Modula-2 with coroutines.
+Multiple libraries can be specified and are comma separated with precedence
+going to the first in the list.  It is not necessary to use -flibs=m2pim or
+-flibs=m2iso if you also specify -fpim, -fpim2, -fpim3, -fpim4 or
+-fiso.  Unless you are using -flibs=m2min you should include m2pim as
+the they provide the base modules which all other dialects utilize.
+The option @samp{-fno-libs=-} disables the @samp{gm2} driver from
+modifying the search and library paths.
+
+@c flocation=
+@c Modula-2 Joined
+@c set all location values to a specific value (internal switch)
+
+@item -fm2-g
+improve the debugging experience for new programmers at the expense
+of generating @code{nop} instructions if necessary to ensure single
+stepping precision over all code related keywords.  An example
+of this is in termination of a list of nested @code{IF} statements
+where multiple @code{END} keywords are mapped onto a sequence of
+@code{nop} instructions.
+
+@item -fm2-lower-case
+render keywords in error messages using lower case.
+
+@item -fm2-plugin
+insert plugin to identify run time errors at compile time (default on).
+
+@item -fm2-statistics
+generates quadruple information: number of quadruples generated,
+number of quadruples remaining after optimization and number of source
+lines compiled.
+
+@item -fm2-strict-type
+experimental flag to turn on the new strict type checker.
+
+@item -fm2-whole-program
+compile all implementation modules and program module at once.  Notice
+that you need to take care if you are compiling different dialect
+modules (particularly with the negative operands to modulus).  But
+this option, when coupled together with @code{-O3}, can deliver huge
+performance improvements.
+
+@item -fmod=
+recognize the specified suffix as implementation and module filenames.
+The default implementation and module filename suffix is @file{.mod}.
+If this option is used GNU Modula-2 will still fall back to this
+default if it needs to read an implementation module and the specified
+suffixed filename does not exist.
+
+@item -fnil
+generate code to detect accessing data through a @code{NIL} value
+pointer.  Dereferencing checking through a @code{NIL} pointer can be
+disabled by @samp{-fno-nil}.
+
+@item -fpim
+turn on PIM standard features.  Currently this enables the PIM
+@code{SYSTEM} module and determines which identifiers are pervasive
+(declared in the base module).  If no other @samp{-fpim[234]} switch is
+used then division and modulus operators behave as defined in PIM4.
+@xref{Dialect, , ,gm2}.
+
+@item -fpim2
+turn on PIM-2 standard features.  Currently this removes @code{SIZE}
+from being a pervasive identifier (declared in the base module).  It
+places @code{SIZE} in the @code{SYSTEM} module.  It also effects the
+behavior of @code{DIV} and @code{MOD} operators.
+@xref{Dialect, , ,gm2}.
+
+@item -fpim3
+turn on PIM-3 standard features.  Currently this only effects the
+behavior of @code{DIV} and @code{MOD} operators.
+@xref{Dialect, , ,gm2}.
+
+@item -fpim4
+turn on PIM-4 standard features.  Currently this only effects the
+behavior of @code{DIV} and @code{MOD} operators.
+@xref{Dialect, , ,gm2}.
+
+@item -fpositive-mod-floor-div
+forces the @code{DIV} and @code{MOD} operators to behave as defined by PIM4.
+All modulus results are positive and the results from the division are
+rounded to the floor.
+@xref{Dialect, , ,gm2}.
+
+@item -fpthread
+link against the pthread library.  By default this option is on.  It
+can be disabled by @samp{-fno-pthread}.  GNU Modula-2 uses the GCC
+pthread libraries to implement coroutines (see the SYSTEM
+implementation module).
+
+@c -fq
+@c -Modula-2
+@c -internal compiler debugging information, dump the list of quadruples
+
+@item -frange
+generate code to check the assignment range, return value range
+set range and constructor range.  Range checking can be disabled
+via @samp{-fno-range}.
+
+@item -freturn
+generate code to check that functions always exit with a @code{RETURN}
+and do not fall out at the end.  Return checking can be disabled
+via @samp{-fno-return}.
+
+@item -fruntime-modules=
+specify, using a comma separated list, the run time modules and their
+order.  These modules will initialized first before any other modules
+in the application dependency.  By default the run time modules list is
+set to @code{Storage,SYSTEM,M2RTS,RTExceptions,IOLink}.  Note that
+these modules will only be linked into your executable if they are
+required.  So adding a long list of dependent modules will not effect
+the size of the executable it merely states the initialization order
+should they be required.
+
+@item -fscaffold-dynamic
+the option ensures that @samp{gm2} will generate a dynamic scaffold
+infrastructure when compiling implementation and program modules.
+By default this option is on.  Use @samp{-fno-scaffold-dynamic}
+to turn it off or select @samp{-fno-scaffold-static}.
+
+@item -fscaffold-c
+generate a C source scaffold for the current module being compiled.
+
+@item -fscaffold-c++
+generate a C++ source scaffold for the current module being compiled.
+
+@item -fscaffold-main
+force the generation of the @samp{main} function.  This is not
+necessary if the @samp{-c} is omitted.
+
+@item -fscaffold-static
+the option ensures that @samp{gm2} will generate a static scaffold
+within the program module.  The static scaffold consists of sequences
+of calls to all dependent module initialization and finalization
+procedures.  The static scaffold is useful for debugging and single
+stepping the initialization blocks of implementation modules.
+
+@item -fshared
+generate a shared library from the module.
+
+@item -fsoft-check-all
+turns on all run time checks.  This is the same as invoking
+GNU Modula-2 using the command options
+@code{-fnil} @code{-frange} @code{-findex}
+@code{-fwholevalue}
+@code{-fwholediv} @code{-fcase} @code{-freturn}.
+
+@item -fsources
+displays the path to the source of each module.  This option
+can be used at compile time to check the correct definition module
+is being used.
+
+@item -fswig
+generate a swig interface file.
+
+@item -funbounded-by-reference
+enable optimization of unbounded parameters by attempting to pass non
+@code{VAR} unbounded parameters by reference.  This optimization
+avoids the implicit copy inside the callee procedure.  GNU Modula-2
+will only allow unbounded parameters to be passed by reference if,
+inside the callee procedure, they are not written to, no address is
+calculated on the array and it is not passed as a @code{VAR}
+parameter.  Note that it is possible to write code to break this
+optimization, therefore this option should be used carefully.
+For example it would be possible to take the address of an array, pass
+the address and the array to a procedure, read from the array in
+the procedure and write to the location using the address parameter.
+
+Due to the dangerous nature of this option it is not enabled
+when the @samp{-O} option is specified.
+
+@item -fuse-list=@file{filename}
+if @samp{-fscaffold-static} is enabled then use the file
+@file{filename} for the initialization order of modules.  Whereas if
+@samp{-fscaffold-dynamic} is enabled then use this file to force
+linking of all module ctors.
+This option cannot be used if @samp{-fgen-module-list=} is enabled.
+
+@item -fwholediv
+generate code to detect whole number division by zero or modulus by
+zero.
+
+@item -fwholevalue
+generate code to detect whole number overflow and underflow.
+
+@c the following warning options are complete but need to be
+@c regression tested against all other front ends
+@c to ensure the options do not conflict.
+
+@c @item -Wall
+@c turn on all Modula-2 warnings.
+
+@c @item -Wpedantic
+@c forces the compiler to reject nested @code{WITH} statements
+@c referencing the same record type.  Does not allow multiple imports of
+@c the same item from a module.  It also checks that: procedure variables
+@c are written to before being read; variables are not only written to
+@c but read from; variables are declared and used.  If the compiler
+@c encounters a variable being read before written it will terminate with
+@c a message.  It will check that @code{FOR} loop indices are not used
+@c outside the end of this loop without being reset.
+
+@c @item -Wpedantic-cast
+@c warns if the ISO system function is used and if the size of
+@c the variable is different from that of the type.  This is legal
+@c in ISO Modula-2, however it can be dangerous.  Some users may prefer
+@c to use @code{VAL} instead in these situations and use @code{CAST}
+@c exclusively for changes in type on objects which have the same size.
+
+@c @item -Wpedantic-param-names
+@c procedure parameter names are checked in the definition module
+@c against their implementation module counterpart.  This is not
+@c necessary in ISO or PIM versions of Modula-2.
+
+@c @item -Wstyle
+@c checks for poor programming style.  This option is aimed at new users of
+@c Modula-2 in that it checks for situations which might cause confusion
+@c and thus mistakes.  It checks whether variables of the same name are
+@c declared in different scopes and whether variables look like keywords.
+@c Experienced users might find this option too aggressive.
+
+@c @item -Wunused-variable
+@c warns if a variable has been declared and it not used.
+
+@c @item -Wunused-parameter
+@c warns if a parameter has been declared and it not used.
+
+@c @item -Wverbose-unbounded
+@c inform the user which non @code{VAR} unbounded parameters will be
+@c passed by reference.  This only produces output if the option
+@c @samp{-funbounded-by-reference} is also supplied on the command line.
+
+@end table
+
+@c man end
+
+@node Elementary data types, Standard procedures, Compiler options, Using
+@section Elementary data types
+
+This section describes the elementary data types supported by GNU
+Modula-2.  It also describes the relationship between these data types
+and the equivalent C data types.
+
+The following data types are supported: @code{INTEGER},
+@code{LONGINT}, @code{SHORTINT}, @code{CARDINAL}, @code{LONGCARD},
+@code{SHORTCARD}, @code{BOOLEAN}, @code{REAL}, @code{LONGREAL},
+@code{SHORTREAL}, @code{COMPLEX}, @code{LONGCOMPLEX},
+@code{SHORTCOMPLEX} and @code{CHAR}.
+
+An equivalence table is given below:
+
+@example
+GNU Modula-2              GNU C
+======================================
+INTEGER                   int
+LONGINT                   long long int
+SHORTINT                  short int
+CARDINAL                  unsigned int
+LONGCARD                  long long unsigned int
+SHORTCARD                 short unsigned int
+BOOLEAN                   int
+REAL                      double
+LONGREAL                  long double
+SHORTREAL                 float
+CHAR                      char
+SHORTCOMPLEX              complex float
+COMPLEX                   complex double
+LONGCOMPLEX               complex long double
+@end example
+
+Note that GNU Modula-2 also supports fixed sized data types which are
+exported from the @code{SYSTEM} module.
+@xref{The PIM system module, , ,gm2}.
+@xref{The ISO system module, , ,gm2}.
+
+@node Standard procedures, Dialect, Elementary data types, Using
+@section Permanently accessible base procedures.
+
+This section describes the procedures and functions which are
+always visible.
+
+@subsection Standard procedures and functions common to PIM and ISO
+
+The following procedures are implemented and conform with Programming
+in Modula-2 and ISO Modula-2: @code{NEW}, @code{DISPOSE}, @code{INC},
+@code{DEC}, @code{INCL}, @code{EXCL} and @code{HALT}.  The standard
+functions are: @code{ABS}, @code{CAP}, @code{CHR}, @code{FLOAT},
+@code{HIGH}, @code{LFLOAT}, @code{LTRUNC}, @code{MIN}, @code{MAX},
+@code{ODD}, @code{SFLOAT}, @code{STRUNC} @code{TRUNC} and
+@code{VAL}.  All these functions and procedures (except @code{HALT},
+@code{NEW}, @code{DISPOSE} and, under non constant conditions,
+@code{LENGTH}) generate in-line code for efficiency.
+
+@example
+
+(*
+   ABS - returns the positive value of i.
+*)
+
+@findex ABS
+PROCEDURE ABS (i: <any signed type>) : <any signed type> ;
+
+@end example
+
+@example
+
+(*
+   CAP - returns the capital of character ch providing
+         ch lies within the range 'a'..'z'.  Otherwise ch
+         is returned unaltered.
+*)
+
+@findex CAP
+PROCEDURE CAP (ch: CHAR) : CHAR ;
+
+@end example
+
+@example
+
+(*
+   CHR - converts a value of a <whole number type> into a CHAR.
+         CHR(x) is shorthand for VAL(CHAR, x).
+*)
+
+@findex CHR
+PROCEDURE CHR (x: <whole number type>) : CHAR ;
+
+@end example
+
+@example
+
+(*
+   DISPOSE - the procedure DISPOSE is replaced by:
+             DEALLOCATE(p, TSIZE(p^)) ;
+             The user is expected to import the procedure DEALLOCATE
+             (normally found in the module, Storage.)
+
+             In:  a variable p: of any pointer type which has been
+                  initialized by a call to NEW.
+             Out: the area of memory
+                  holding p^ is returned to the system.
+                  Note that the underlying procedure DEALLOCATE
+                  procedure in module Storage will assign p to NIL.
+*)
+
+@findex DISPOSE
+PROCEDURE DISPOSE (VAR p:<any pointer type>) ;
+@end example
+
+@example
+
+(*
+   DEC - can either take one or two parameters.  If supplied
+         with one parameter then on the completion of the call to
+         DEC, v will have its predecessor value.  If two
+         parameters are supplied then the value v will have its
+         n'th predecessor.  For these reasons the value of n
+         must be >=0.
+*)
+
+@findex DEC
+PROCEDURE DEC (VAR v: <any base type>; [n: <any base type> = 1]) ;
+@end example
+
+@example
+
+(*
+   EXCL - excludes bit element e from a set type s.
+*)
+
+@findex EXCL
+PROCEDURE EXCL (VAR s: <any set type>; e: <element of set type s>) ;
+@end example
+
+@example
+
+(*
+   FLOAT - will return a REAL number whose value is the same as o.
+*)
+
+@findex FLOAT
+PROCEDURE FLOAT (o: <any whole number type>) : REAL ;
+@end example
+
+@example
+
+(*
+   FLOATS - will return a SHORTREAL number whose value is the same as o.
+*)
+
+@findex FLOATS
+PROCEDURE FLOATS (o: <any whole number type>) : REAL ;
+@end example
+
+@example
+
+(*
+   FLOATL - will return a LONGREAL number whose value is the same as o.
+*)
+
+@findex FLOATL
+PROCEDURE FLOATL (o: <any whole number type>) : REAL ;
+@end example
+
+@example
+
+(*
+   HALT - will call the HALT procedure inside the module M2RTS.
+          Users can replace M2RTS.
+*)
+
+@findex HALT
+PROCEDURE HALT ;
+@end example
+
+@example
+
+(*
+   HIGH - returns the last accessible index of an parameter declared as
+          ARRAY OF CHAR.  Thus
+
+          PROCEDURE foo (a: ARRAY OF CHAR) ;
+          VAR
+             c: CARDINAL ;
+          BEGIN
+             c := HIGH(a)
+          END foo ;
+
+          BEGIN
+             foo('hello')
+          END
+
+          will cause the local variable c to contain the value 4
+*)
+
+@findex HIGH
+PROCEDURE HIGH (a: ARRAY OF CHAR) : CARDINAL ;
+@end example
+
+@example
+
+(*
+   INC - can either take one or two parameters.  If supplied
+         with one parameter then on the completion of the call to
+         INC, v will have its successor value.  If two
+         parameters are supplied then the value v will have its
+         n'th successor.  For these reasons the value of n
+         must be >=0.
+*)
+
+@findex INC
+PROCEDURE INC (VAR v: <any base type>; [n: <any base type> = 1]) ;
+@end example
+
+@example
+
+(*
+   INCL - includes bit element e to a set type s.
+*)
+
+@findex INCL
+PROCEDURE INCL (VAR s: <any set type>; e: <element of set type s>) ;
+@end example
+
+@example
+
+(*
+   LFLOAT - will return a LONGREAL number whose value is the same as o.
+*)
+
+@findex LFLOAT
+PROCEDURE LFLOAT (o: <any whole number type>) : LONGREAL ;
+@end example
+
+@example
+
+(*
+   LTRUNC - will return a LONG<type> number whose value is the
+            same as o.  PIM2, PIM3 and ISO Modula-2 will return
+            a LONGCARD whereas PIM4 returns LONGINT.
+*)
+
+@findex LTRUNC
+PROCEDURE LTRUNC (o: <any floating point type>) : LONG<type> ;
+@end example
+
+@example
+
+(*
+   MIN - returns the lowest legal value of an ordinal type.
+*)
+
+@findex MIN
+PROCEDURE MIN (t: <ordinal type>) : <ordinal type> ;
+
+@end example
+
+@example
+
+(*
+   MAX - returns the largest legal value of an ordinal type.
+*)
+
+@findex MAX
+PROCEDURE MAX (t: <ordinal type>) : <ordinal type> ;
+
+@end example
+
+@example
+
+(*
+   NEW - the procedure NEW is replaced by:
+         ALLOCATE(p, TSIZE(p^)) ;
+         The user is expected to import the procedure ALLOCATE
+         (normally found in the module, Storage.)
+
+         In:  a variable p: of any pointer type.
+         Out: variable p is set to some allocated memory
+              which is large enough to hold all the contents of p^.
+*)
+
+@findex NEW
+PROCEDURE NEW (VAR p:<any pointer type>) ;
+@end example
+
+@example
+
+(*
+   ODD - returns TRUE if the value is not divisible by 2.
+*)
+
+@findex ODD
+PROCEDURE ODD (x: <whole number type>) : BOOLEAN ;
+
+@end example
+
+@example
+
+(*
+   SFLOAT - will return a SHORTREAL number whose value is the same
+            as o.
+*)
+
+@findex SFLOAT
+PROCEDURE SFLOAT (o: <any whole number type>) : SHORTREAL ;
+@end example
+
+@example
+
+(*
+   STRUNC - will return a SHORT<type> number whose value is the same
+            as o.  PIM2, PIM3 and ISO Modula-2 will return a
+            SHORTCARD whereas PIM4 returns SHORTINT.
+*)
+
+@findex STRUNC
+PROCEDURE STRUNC (o: <any floating point type>) : SHORT<type> ;
+@end example
+
+@example
+
+(*
+   TRUNC - will return a <type> number whose value is the same as o.
+           PIM2, PIM3 and ISO Modula-2 will return a CARDINAL
+           whereas PIM4 returns INTEGER.
+*)
+
+@findex TRUNC
+PROCEDURE TRUNC (o: <any floating point type>) : <type> ;
+@end example
+
+@example
+
+(*
+   TRUNCS - will return a <type> number whose value is the same
+            as o.  PIM2, PIM3 and ISO Modula-2 will return a
+            SHORTCARD whereas PIM4 returns SHORTINT.
+*)
+
+@findex TRUNCS
+PROCEDURE TRUNCS (o: <any floating point type>) : <type> ;
+@end example
+
+@example
+
+(*
+   TRUNCL - will return a <type> number whose value is the same
+            as o.  PIM2, PIM3 and ISO Modula-2 will return a
+            LONGCARD whereas PIM4 returns LONGINT.
+*)
+
+@findex TRUNCL
+PROCEDURE TRUNCL (o: <any floating point type>) : <type> ;
+@end example
+
+@example
+
+(*
+   VAL - converts data i of <any simple data type 2> to
+         <any simple data type 1> and returns this value.
+         No range checking is performed during this conversion.
+*)
+
+@findex VAL
+PROCEDURE VAL (<any simple data type 1>,
+               i: <any simple data type 2>) : <any simple data type 1> ;
+
+@end example
+
+@subsection ISO specific standard procedures and functions
+
+The standard function @code{LENGTH} is specific to ISO Modula-2 and
+is defined as:
+
+@example
+
+(*
+   IM - returns the imaginary component of a complex type.
+        The return value will the same type as the imaginary field
+        within the complex type.
+*)
+
+@findex IM
+PROCEDURE IM (c: <any complex type>) : <floating point type> ;
+@end example
+
+@example
+
+(*
+   INT - returns an INTEGER value which has the same value as v.
+         This function is equivalent to: VAL(INTEGER, v).
+*)
+
+@findex INT
+PROCEDURE INT (v: <any ordinal type>) : INTEGER ;
+@end example
+
+@example
+
+(*
+   LENGTH - returns the length of string a.
+*)
+
+@findex LENGTH
+PROCEDURE LENGTH (a: ARRAY OF CHAR) : CARDINAL ;
+@end example
+
+This function is evaluated at compile time, providing that string
+@code{a} is a constant.  If @code{a} cannot be evaluated then a call is
+made to @code{M2RTS.Length}.
+
+@example
+
+(*
+   ODD - returns a BOOLEAN indicating whether the whole number
+         value, v, is odd.
+*)
+
+@findex ODD
+PROCEDURE ODD (v: <any whole number type>) : BOOLEAN ;
+@end example
+
+@example
+
+(*
+   RE - returns the real component of a complex type.
+        The return value will the same type as the real field
+        within the complex type.
+*)
+
+@findex RE
+PROCEDURE RE (c: <any complex type>) : <floating point type> ;
+@end example
+
+@node Dialect, Exceptions, Standard procedures, Using
+@section GNU Modula-2 supported dialects
+
+This section describes the dialects understood by GNU Modula-2.
+It also describes the differences between the dialects and
+any command line switches which determine dialect behaviour.
+
+The GNU Modula-2 compiler is compliant with four dialects of Modula-2.
+The language as defined in 'Programming in Modula-2' 2nd Edition,
+Springer Verlag, 1982, 1983 by Niklaus Wirth (PIM2), 'Programming in
+Modula-2', 3rd Corrected Edition, Springer Verlag, 1985 (PIM3) and
+'Programming in Modula-2', 4th Edition, Springer Verlag, 1988 (PIM4)
+@uref{http://freepages.modula2.org/report4/modula-2.html} and the ISO
+Modula-2 language as defined in ISO/IEC Information technology -
+programming languages - part 1: Modula-2 Language, ISO/IEC 10514-1
+(1996) (ISO).
+
+The command line switches @samp{-fpim2}, @samp{-fpim3}, @samp{-fpim4}
+and @samp{-fiso} can be used to force mutually exclusive
+features.  However by default the compiler will not aggressively fail
+if a non mutually exclusive feature is used from another dialect.  For
+example it is possible to specify @samp{-fpim2} and still utilize
+@samp{DEFINITION} @samp{MODULES} which have no export list.
+
+Some dialect differences will force a compile time error, for example
+in PIM2 the user must @code{IMPORT} @code{SIZE} from the module
+@code{SYSTEM}, whereas in PIM3 and PIM4 @code{SIZE} is a pervasive
+function.  Thus compiling PIM4 source code with the @samp{-fpim2}
+switch will cause a compile time error.  This can be fixed quickly
+with an additional @code{IMPORT} or alternatively by compiling with
+the @samp{-fpim4} switch.
+
+However there are some very important differences between the dialects
+which are mutually exclusive and therefore it is vital that users
+choose the dialects with care when these language features are used.
+
+@subsection Integer division, remainder and modulus
+
+The most dangerous set of mutually exclusive features found in the
+four dialects supported by GNU Modula-2 are the @code{INTEGER}
+division, remainder and modulus arithmetic operators.  It is important
+to note that the same source code can be compiled to give different
+run time results depending upon these switches!  The reference manual
+for the various dialects of Modula-2 are quite clear about this
+behavior and sadly there are three distinct definitions.
+
+The table below illustrates the problem when a negative operand is
+used.
+
+@example
+                  Pim2/3          Pim4                ISO
+               -----------    -----------    ----------------------
+lval    rval   DIV     MOD    DIV     MOD    DIV    MOD    /    REM
+ 31      10      3       1      3       1      3      1     3     1
+-31      10     -3      -1     -4       9     -4      9    -3    -1
+ 31     -10     -3       1     -3       1     Exception    -3     1
+-31     -10      3      -1      4       9     Exception     3    -1
+@end example
+
+See also P24 of PIM2, P27 of PIM3, P29 of PIM4 and P201 of the ISO
+Standard.  At present all dialect division, remainder and modulus are
+implemented as above, apart from the exception calling in the ISO
+dialect.  Instead of exception handling the results are the same as the
+PIM4 dialect.  This is a temporary implementation situation.
+
+@node Exceptions, Semantic checking, Dialect, Using
+@section Exception implementation
+
+This section describes how exceptions are implemented in GNU Modula-2
+and how command line switches affect their behavior.  The option
+@samp{-fsoft-check-all} enables all software checking of nil
+dereferences, division by zero etc.  Additional code is produced to
+check these conditions and exception handlers are invoked if the
+conditions prevail.
+
+Without @samp{-fsoft-check-all} these exceptions will be caught by
+hardware (assuming the hardware support exists) and a signal handler
+is invoked.  The signal handler will in turn @code{THROW} an exception
+which will be caught by the appropriate Modula-2 handler.  However the
+action of throwing an exception from within a signal handler is
+implementation defined (according to the C++ documentation).  For
+example on the x86_64 architecture this works whereas on the i686
+architecture it does not.  Therefore to ensure portability it is
+recommended to use @samp{-fsoft-check-all}.
+
+@footnote{@samp{-fsoft-check-all} can be effectively combined with
+@samp{-O2} to semantically analyze source code for possible run time
+errors at compile time.}
+
+@node Semantic checking, Extensions, Exceptions, Using
+@section How to detect run time problems at compile time
+
+Consider the following program:
+
+@example
+MODULE assignvalue ;  (*!m2iso+gm2*)
+
+PROCEDURE bad () : INTEGER ;
+VAR
+   i: INTEGER ;
+BEGIN
+   i := -1 ;
+   RETURN i
+END bad ;
+
+VAR
+   foo: CARDINAL ;
+BEGIN
+   (* The m2rte plugin will detect this as an error, post
+      optimization.  *)
+   foo := bad ()
+END assignvalue.
+@end example
+
+here we see that the programmer has overlooked that the return value
+from @samp{bad} will cause an overflow to @samp{foo}.  If we compile
+the code with the following options:
+
+@example
+$ gm2 -g -fsoft-check-all -O2 -c assignvalue.mod
+assignvalue.mod:16:0:inevitable that this error will occur at run time,
+assignment will result in an overflow
+@end example
+
+The gm2 semantic plugin is automatically run and will generate a
+warning message for every exception call which is known as reachable.
+It is highly advised to run the optimizer (@samp{-O2} or @samp{-O3})
+with @samp{-fsoft-check-all} so that the compiler is able to run the
+optimizer and perform variable and flow analysis before the semantic
+plugin is invoked.
+
+@node Extensions, Type compatibility, Semantic checking, Using
+@section GNU Modula-2 language extensions
+
+This section introduces the GNU Modula-2 language extensions.
+The GNU Modula-2 compiler allows abstract data types to be any type,
+not just restricted to a pointer type providing the
+@samp{-fextended-opaque} option is supplied
+@xref{Compiler options, , ,gm2}.
+
+Declarations can be made in any order, whether they are
+types, constants, procedures, nested modules or variables.
+@c (@xref{Passes, , ,}.)
+
+GNU Modula-2 also allows programmers to interface to @code{C} and
+assembly language.
+
+GNU Modula-2 provides support for the special tokens @code{__LINE__},
+@code{__FILE__}, @code{__FUNCTION__} and @code{__DATE__}.  Support for
+these tokens will occur even if the @samp{-fcpp} option is not
+supplied.  A table of these identifiers and their data type and values
+is given below:
+
+@example
+Scope       GNU Modula-2 token      Data type and example value
+
+anywhere    __LINE__                Constant Literal compatible
+                                    with CARDINAL, INTEGER and WORD.
+                                    Example 1234
+
+anywhere    __FILE__                Constant string compatible
+                                    with parameter ARRAY OF CHAR or
+                                    an ARRAY whose SIZE is >= string
+                                    length.  Example
+                                    "hello.mod"
+
+procedure   __FUNCTION__            Constant string compatible
+                                    with parameter ARRAY OF CHAR or
+                                    an ARRAY whose SIZE is >= string
+                                    length.  Example
+                                    "calc"
+
+module      __FUNCTION__            Example
+                                    "module hello initialization"
+
+anywhere    __DATE__                Constant string compatible
+                                    with parameter ARRAY OF CHAR or
+                                    an ARRAY whose SIZE is >= string
+                                    length.  Example
+                                    "Thu Apr 29 10:07:16 BST 2004"
+
+anywhere   __COLUMN__               Gives a constant literal number
+                                    determining the left hand column
+                                    where the first _ appears in
+                                    __COLUMN__.  The left most column
+                                    is 1.
+
+@end example
+
+The preprocessor @samp{cpp} can be invoked via the @samp{-fcpp}
+command line option.  This in turn invokes @samp{cpp} with the
+following arguments @samp{-traditional -lang-asm}.  These options
+preserve comments and all quotations.  @samp{gm2} treats a @samp{#}
+character in the first column as a preprocessor directive.
+
+For example here is a module which calls @code{FatalError}
+via the macro @code{ERROR}.
+
+@example
+MODULE cpp ;
+
+FROM SYSTEM IMPORT ADR, SIZE ;
+FROM libc IMPORT exit, printf, malloc ;
+
+PROCEDURE FatalError (a, file: ARRAY OF CHAR;
+                         line: CARDINAL;
+                         func: ARRAY OF CHAR) ;
+BEGIN
+   printf ("%s:%d:fatal error, %s, in %s\n",
+            ADR (file), line, ADR (a), ADR (func)) ;
+   exit (1)
+END FatalError ;
+
+#define ERROR(X)  FatalError(X, __FILE__, __LINE__, __FUNCTION__)
+
+VAR
+   pc: POINTER TO CARDINAL;
+BEGIN
+   pc := malloc (SIZE (CARDINAL)) ;
+   IF pc = NIL
+   THEN
+      ERROR ('out of memory')
+   END
+END cpp.
+@end example
+
+Another use for the C preprocessor in Modula-2 might be to turn on
+debugging code.  For example the library module
+@file{FormatStrings.mod} uses procedures from @file{DynamicStrings.mod}
+and to track down memory leaks it was useful to track the source file
+and line where each string was created.  Here is a section of
+@file{FormatStrings.mod} which shows how the debugging code was
+enabled and disabled by adding @code{-fcpp} to the command line.
+
+@example
+FROM DynamicStrings IMPORT String, InitString, InitStringChar, Mark,
+                           ConCat, Slice, Index, char,
+                           Assign, Length, Mult, Dup, ConCatChar,
+                           PushAllocation, PopAllocationExemption,
+                           InitStringDB, InitStringCharStarDB,
+                           InitStringCharDB, MultDB, DupDB, SliceDB ;
+
+(*
+#define InitString(X) InitStringDB(X, __FILE__, __LINE__)
+#define InitStringCharStar(X) InitStringCharStarDB(X, __FILE__, \
+                                                   __LINE__)
+#define InitStringChar(X) InitStringCharDB(X, __FILE__, __LINE__)
+#define Mult(X,Y) MultDB(X, Y, __FILE__, __LINE__)
+#define Dup(X) DupDB(X, __FILE__, __LINE__)
+#define Slice(X,Y,Z) SliceDB(X, Y, Z, __FILE__, __LINE__)
+*)
+
+PROCEDURE doDSdbEnter ;
+BEGIN
+   PushAllocation
+END doDSdbEnter ;
+
+PROCEDURE doDSdbExit (s: String) ;
+BEGIN
+   s := PopAllocationExemption (TRUE, s)
+END doDSdbExit ;
+
+PROCEDURE DSdbEnter ;
+BEGIN
+END DSdbEnter ;
+
+PROCEDURE DSdbExit (s: String) ;
+BEGIN
+END DSdbExit ;
+
+(*
+#define DBsbEnter doDBsbEnter
+#define DBsbExit  doDBsbExit
+*)
+
+PROCEDURE Sprintf1 (s: String; w: ARRAY OF BYTE) : String ;
+BEGIN
+   DSdbEnter ;
+   s := FormatString (HandleEscape (s), w) ;
+   DSdbExit (s) ;
+   RETURN s
+END Sprintf1 ;
+@end example
+
+It is worth noting that the overhead of this code once @code{-fcpp} is
+not present and -O2 is used will be zero since the local empty
+procedures @code{DSdbEnter} and @code{DSdbExit} will be thrown away by
+the optimization passes of the GCC backend.
+
+@subsection Optional procedure parameter
+
+GNU Modula-2 allows the last parameter to a procedure or function
+parameter to be optional.  For example in the ISO library
+@file{COROUTINES.def} the procedure @code{NEWCOROUTINE} is defined as
+having an optional fifth argument (@code{initProtection}) which, if
+absent, is automatically replaced by @code{NIL}.
+
+@example
+@findex NEWCOROUTINE
+PROCEDURE NEWCOROUTINE (procBody: PROC; workspace: SYSTEM.ADDRESS;
+                        size: CARDINAL; VAR cr: COROUTINE;
+                        [initProtection: PROTECTION = NIL]);
+
+  (* Creates a new coroutine whose body is given by procBody,
+     and returns the identity of the coroutine in cr.
+     workspace is a pointer to the work space allocated to
+     the coroutine; size specifies the size of this workspace
+     in terms of SYSTEM.LOC.
+
+     The optional fifth argument may contain a single parameter
+     which specifies the initial protection level of the coroutine.
+  *)
+@end example
+
+The implementation module @file{COROUTINES.mod} implements this
+procedure using the following syntax:
+
+@example
+PROCEDURE NEWCOROUTINE (procBody: PROC; workspace: SYSTEM.ADDRESS;
+                        size: CARDINAL; VAR cr: COROUTINE;
+                        [initProtection: PROTECTION]);
+BEGIN
+
+END NEWCOROUTINE ;
+@end example
+
+Note that it is illegal for this declaration to contain an initializer
+value for @code{initProtection}.  However it is necessary to surround
+this parameter with the brackets @code{[} and @code{]}.  This serves to
+remind the programmer that the last parameter was declared as optional
+in the definition module.
+
+Local procedures can be declared to have an optional final parameter
+in which case the initializer is mandatory in the implementation or
+program module.
+
+GNU Modula-2 also provides additional fixed sized data types which
+are all exported from the @code{SYSTEM} module.
+@xref{The PIM system module, , ,gm2}.
+@xref{The ISO system module, , ,gm2}.
+
+@node Type compatibility, Unbounded by reference, Extensions, Using
+@section Type compatibility
+
+This section discuss the issues surrounding assignment, expression
+and parameter compatibility, their effect of the additional
+fixed sized datatypes and also their effect of run time checking.
+The data types supported by the compiler are:
+
+@example
+GNU Modula-2              scope      switches
+=============================================
+INTEGER                   pervasive
+LONGINT                   pervasive
+SHORTINT                  pervasive
+CARDINAL                  pervasive
+LONGCARD                  pervasive
+SHORTCARD                 pervasive
+BOOLEAN                   pervasive
+BITSET                    pervasive
+REAL                      pervasive
+LONGREAL                  pervasive
+SHORTREAL                 pervasive
+CHAR                      pervasive
+SHORTCOMPLEX              pervasive
+COMPLEX                   pervasive
+LONGCOMPLEX               pervasive
+
+LOC                       SYSTEM     -fiso
+BYTE                      SYSTEM
+WORD                      SYSTEM
+ADDRESS                   SYSTEM
+
+The following extensions are supported for
+most architectures (please check SYSTEM.def).
+=============================================
+INTEGER8                  SYSTEM
+INTEGER16                 SYSTEM
+INTEGER32                 SYSTEM
+INTEGER64                 SYSTEM
+CARDINAL8                 SYSTEM
+CARDINAL16                SYSTEM
+CARDINAL32                SYSTEM
+CARDINAL64                SYSTEM
+BITSET8                   SYSTEM
+BITSET16                  SYSTEM
+BITSET32                  SYSTEM
+WORD16                    SYSTEM
+WORD32                    SYSTEM
+WORD64                    SYSTEM
+REAL32                    SYSTEM
+REAL64                    SYSTEM
+REAL96                    SYSTEM
+REAL128                   SYSTEM
+COMPLEX32                 SYSTEM
+COMPLEX64                 SYSTEM
+COMPLEX96                 SYSTEM
+COMPLEX128                SYSTEM
+@end example
+
+The Modula-2 language categorizes compatibility between entities of
+possibly differing types into three sub components: expressions,
+assignments, and parameters.  Parameter compatibility is further
+divided into two sections for pass by reference and pass by value
+compatibility.
+
+For more detail on the Modula-2 type compatibility see the Modula-2
+ISO standard BS ISO/IEC 10514-1:1996 page 121-125.  For detail on the
+PIM type compatibility see Programming in Modula-2 Edition 4 page 29,
+(Elementary Data Types).
+
+@subsection Expression compatibility
+
+Modula-2 restricts the types of expressions to the same type.
+Expression compatibility is a symmetric relation.
+
+For example two sub expressions of @code{INTEGER} and @code{CARDINAL}
+are not expression compatible
+(@uref{http://freepages.modula2.org/report4/modula-2.html} and ISO
+Modula-2).
+
+In GNU Modula-2 this rule is also extended across all fixed sized data
+types (imported from SYSTEM).
+
+@subsection Assignment compatibility
+
+This section discusses the assignment issues surrounding assignment
+compatibility of elementary types (@code{INTEGER}, @code{CARDINAL},
+@code{REAL} and @code{CHAR} for example).  The information here is
+found in more detail in the Modula-2 ISO standard BS ISO/IEC
+10514-1:1996 page 122.
+
+Assignment compatibility exists between the same sized elementary
+types.
+
+Same type family of different sizes are
+also compatible as long as the @code{MAX(}type@code{)} and
+@code{MIN(}type@code{)} is known.  So for example this includes the
+@code{INTEGER} family, @code{CARDINAL} family and the @code{REAL}
+family.
+
+The reason for this is that when the assignment is performed
+the compiler will check to see that the expression (on the right of
+the @code{:=}) lies within the range of the designator type (on the
+left hand side of the @code{:=}).  Thus these ordinal types can be
+assignment compatible.  However it does mean that @code{WORD32} is not
+compatible with @code{WORD16} as @code{WORD32} does not have a minimum
+or maximum value and therefore cannot be checked.  The compiler does
+not know which of the two bytes from @code{WORD32} should be copied
+into @code{WORD16} and which two should be ignored.  Currently the
+types @code{BITSET8}, @code{BITSET16} and @code{BITSET32} are
+assignment incompatible.  However this restriction maybe lifted when
+further run time checking is achieved.
+
+Modula-2 does allow @code{INTEGER} to be assignment compatible with
+@code{WORD} as they are the same size.  Likewise GNU Modula-2 allows
+@code{INTEGER16} to be compatible with @code{WORD16} and the same for
+the other fixed sized types and their sized equivalent in either
+@code{WORD}n, @code{BYTE} or @code{LOC} types.  However it prohibits
+assignment between @code{WORD} and @code{WORD32} even though on many
+systems these sizes will be the same.  The reasoning behind this rule
+is that the extended fixed sized types are meant to be used by
+applications requiring fixed sized data types and it is more portable
+to forbid the blurring of the boundaries between fixed sized and
+machine dependent sized types.
+
+Intermediate code run time checking is always generated by the front
+end.  However this intermediate code is only translated into actual
+code if the appropriate command line switches are specified.  This
+allows the compiler to perform limited range checking at compile time.
+In the future it will allow the extensive GCC optimizations to
+propagate constant values through to the range checks which if they
+are found to exceed the type range will result in a compile time
+error message.
+
+@subsection Parameter compatibility
+
+Parameter compatibility is divided into two areas, pass by value and
+pass by reference (@code{VAR}).  In the case of pass by value the
+rules are exactly the same as assignment.  However in the second case,
+pass by reference, the actual parameter and formal parameter must be
+the same size and family.  Furthermore @code{INTEGER} and
+@code{CARDINAL}s are not treated as compatible in the pass by
+reference case.
+
+The types @code{BYTE}, @code{LOC}, @code{WORD} and @code{WORD}n
+derivatives are assignment and parameter compatible with any data type
+of the same size.
+
+@node Unbounded by reference, Building a shared library, Type compatibility, Using
+@section Unbounded by reference
+
+This section documents a GNU Modula-2 compiler switch which implements
+a language optimization surrounding the implementation of unbounded
+arrays.  In GNU Modula-2 the unbounded array is implemented by
+utilizing an internal structure @code{struct @{dataType *address,
+unsigned int high@}}.  So given the Modula-2 procedure declaration:
+
+@example
+PROCEDURE foo (VAR a: ARRAY OF dataType) ;
+BEGIN
+   IF a[2]= (* etc *)
+END foo ;
+@end example
+
+it is translated into GCC @code{tree}s, which can be represented
+in their C form thus:
+
+@example
+void foo (struct @{dataType *address, unsigned int high@} a)
+@{
+   if (a.address[2] == /* etc */
+@}
+@end example
+
+Whereas if the procedure @code{foo} was declared as:
+
+@example
+PROCEDURE foo (a: ARRAY OF dataType) ;
+BEGIN
+   IF a[2]= (* etc *)
+END foo ;
+@end example
+
+then it is implemented by being translated into the following
+GCC @code{tree}s, which can be represented in their C form thus:
+
+@example
+void foo (struct @{dataType *address, unsigned int high@} a)
+@{
+   dataType *copyContents = (dataType *)alloca (a.high+1);
+   memcpy(copyContents, a.address, a.high+1);
+   a.address = copyContents;
+
+   if (a.address[2] == /* etc */
+@}
+@end example
+
+This implementation works, but it makes a copy of each non VAR
+unbounded array when a procedure is entered.  If the unbounded array
+is not changed during procedure @code{foo} then this implementation
+will be very inefficient.  In effect Modula-2 lacks the @code{REF}
+keyword of Ada.  Consequently the programmer maybe tempted to
+sacrifice semantic clarity for greater efficiency by declaring the
+parameter using the @code{VAR} keyword in place of @code{REF}.
+
+The @code{-funbounded-by-reference} switch instructs the compiler to
+check and see if the programmer is modifying the content of any
+unbounded array.  If it is modified then a copy will be made upon
+entry into the procedure.  Conversely if the content is only read and
+never modified then this non @code{VAR} unbounded array is a candidate
+for being passed by reference.  It is only a candidate as it is still
+possible that passing this parameter by reference could alter the
+meaning of the source code.  For example consider the following case:
+
+@example
+PROCEDURE StrConCat (VAR a: ARRAY OF CHAR; b, c: ARRAY OF CHAR) ;
+BEGIN
+   (* code which performs string a := b + c *)
+END StrConCat ;
+
+PROCEDURE foo ;
+VAR
+   a: ARRAY [0..3] OF CHAR ;
+BEGIN
+   a := 'q' ;
+   StrConCat(a, a, a)
+END foo ;
+@end example
+
+In the code above we see that the same parameter, @code{a}, is being
+passed three times to @code{StrConCat}.  Clearly even though parameters
+@code{b} and @code{c} are never modified it would be incorrect to
+implement them as pass by reference.  Therefore the compiler checks to
+see if any non @code{VAR} parameter is type compatible with any
+@code{VAR} parameter and if so it generates run time procedure entry
+checks to determine whether the contents of parameters @code{b} or
+@code{c} matches the contents of @code{a}.  If a match is detected
+then a copy is made and the @code{address} in the unbounded
+@code{struct}ure is modified.
+
+The compiler will check the address range of each candidate against
+the address range of any @code{VAR} parameter, providing they are type
+compatible.  For example consider:
+
+@example
+PROCEDURE foo (a: ARRAY OF BYTE; VAR f: REAL) ;
+BEGIN
+   f := 3.14 ;
+   IF a[0]=BYTE(0)
+   THEN
+      (* etc *)
+   END
+END foo ;
+
+PROCEDURE bar ;
+BEGIN
+   r := 2.0 ;
+   foo(r, r)
+END bar ;
+@end example
+
+Here we see that although parameter, @code{a}, is a candidate for the
+passing by reference, it would be incorrect to use this
+transformation.  Thus the compiler detects that parameters, @code{a}
+and @code{f} are type compatible and will produce run time checking
+code to test whether the address range of their respective contents
+intersect.
+
+@node Linking, Building a shared library, Unbounded by reference, Using
+
+This section describes the linking related options.  There are three
+linking strategies available which are dynamic scaffold, static
+scaffold and user defined.  The dynamic scaffold is enabled by default
+and each module will register itself to the run time @samp{M2RTS} via
+a constructor.  The static scaffold mechanism will invoke each modules
+@samp{_init} and @samp{_finish} function in turn via a sequence of
+calls from within @samp{main}.  Lastly the user defined strategy
+can be implemented by turning off the dynamic and static options via
+@samp{-fno-scaffold-dynamic} and @samp{-fno-scaffold-static}.
+
+In the simple test below:
+
+@example
+$ gm2 hello.mod
+@end example
+
+the driver will add the options @samp{-fscaffold-dynamic} and
+@samp{-fgen-module-list=-} which generate a list of application
+modules and also creates the @samp{main} function with calls to
+@samp{M2RTS}.  It can be useful to add the option @samp{-fsources}
+which displays the source files as they are parsed and summarizes
+whether the source file is required for compilation or linking.
+
+If you wish to split the above command line into a compile and link
+then you could use these steps:
+
+@example
+$ gm2 -c -fscaffold-main hello.mod
+$ gm2 hello.o
+@end example
+
+The @samp{-fscaffold-main} informs the compiler to generate the
+@samp{main} function and scaffold.  You can enable the environment
+variable @samp{GCC_M2LINK_RTFLAG} to trace the construction and
+destruction of the application.  The values for
+@samp{GCC_M2LINK_RTFLAG} are shown in the table below:
+
+@example
+value   | meaning
+=================
+all     | turn on all flags below
+module  | trace modules as they register themselves
+pre     | generate module list prior to dependency resolution
+dep     | trace module dependency resolution
+post    | generate module list after dependency resolution
+force   | generate a module list after dependency and forced
+        | ordering is complete
+@end example
+
+The values can be combined using a comma separated list.
+
+One of the advantages of the dynamic scaffold is that the driver
+behaves in a similar way to the other front end drivers.
+For example consider a small project consisting of 4 definition
+implementation modules (@samp{a.def}, @samp{a.mod}, @samp{b.def},
+@samp{b.mod}, @samp{c.def}, @samp{c.mod}, @samp{d.def}, @samp{d.mod})
+and a program module @samp{program.mod}.
+
+To link this project we could:
+
+@example
+$ gm2 -g -c a.mod
+$ gm2 -g -c b.mod
+$ gm2 -g -c c.mod
+$ gm2 -g -c d.mod
+$ gm2 -g program.mod a.o b.o c.o d.o
+@end example
+
+The module initialization sequence is defined by the ISO standard to
+follow the import graph traversal.  The initialization order is the
+order in which the corresponding separate modules finish the
+processing of their import lists.
+
+However, if required, you can override this using
+@samp{-fruntime-modules=a,b,c,d} for example which forces the
+initialization sequence to @samp{a}, @samp{b}, @samp{c} and @samp{d}.
+
+@node Building a shared library, Interface for Python, Unbounded by reference, Using
+@section Building a shared library
+
+This section describes building a tiny shared library implemented in
+Modula-2 and built with @file{libtool}.  Suppose a project consists of
+two definition modules and two implementation modules and a program
+module @file{a.def}, @file{a.mod}, @file{b.def}, @file{b.mod} and
+@file{c.mod}.  The first step is to compile the modules using position
+independent code.  This can be achieved by the following three
+commands:
+
+@example
+libtool --tag=CC --mode=compile gm2 -g -c a.mod -o a.lo
+libtool --tag=CC --mode=compile gm2 -g -c b.mod -o b.lo
+libtool --tag=CC --mode=compile gm2 -g -c c.mod -o c.lo
+@end example
+
+The second step is to generate the shared library initialization and
+finalization routines.  We can do this by asking gm2 to generate a
+list of dependent modules and then use this to generate the scaffold.
+We also must compile the scaffold.
+
+@example
+gm2 -c -g -fmakelist c.mod
+gm2 -c -g -fmakeinit -fshared c.mod
+libtool --tag=CC --mode=compile g++ -g -c c_m2.cpp -o c_m2.lo
+@end example
+
+The third step is to link all these @file{.lo} files.
+
+@example
+libtool --mode=link gcc -g c_m2.lo a.lo b.lo c.lo \
+        -L$(prefix)/lib64 \
+        -rpath `pwd` -lgm2 -lstdc++ -lm -o libabc.la
+@end example
+
+At this point the shared library @file{libabc.so} will have been
+created inside the directory @file{.libs}.
+
+@node Interface for Python, Producing a Python module, Building a shared library, Using
+@section How to produce swig interface files
+
+This section describes how Modula-2 implementation modules can be
+called from Python (and other scripting languages such as TCL and
+Perl).  GNU Modula-2 can be instructed to create a swig interface when
+it is compiling an implementation module.  Swig then uses the
+interface file to generate all the necessary wrapping to that the
+desired scripting language may access the implementation module.
+
+Here is an example of how you might call upon the services of the
+Modula-2 library module @code{NumberIO} from Python3.
+
+The following commands can be used to generate the Python3 module:
+
+@example
+export src=@samp{directory to the sources}
+export prefix=@samp{directory to where the compiler is installed}
+gm2 -I$@{src@} -c -g -fswig $@{src@}/../../../gm2-libs/NumberIO.mod
+gm2 -I$@{src@} -c -g -fmakelist $@{src@}/../../../gm2-libs/NumberIO.mod
+
+gm2 -I$@{src@} -c -g -fmakeinit -fshared \
+   $@{src@}/../../../gm2-libs/NumberIO.mod
+
+swig -c++ -python3 NumberIO.i
+
+libtool --mode=compile g++ -g -c -I$@{src@} NumberIO_m2.cpp \
+  -o NumberIO_m2.lo
+
+libtool --tag=CC --mode=compile gm2 -g -c \
+  -I$@{src@}../../../gm2-libs \
+  $@{src@}/../../../gm2-libs/NumberIO.mod -o NumberIO.lo
+
+libtool --tag=CC --mode=compile g++ -g -c NumberIO_wrap.cxx \
+  -I/usr/include/python3 -o NumberIO_wrap.lo
+
+libtool --mode=link gcc -g NumberIO_m2.lo NumberIO_wrap.lo \
+   -L$@{prefix@}/lib64 \
+   -rpath `pwd` -lgm2 -lstdc++ -lm -o libNumberIO.la
+
+cp .libs/libNumberIO.so _NumberIO.so
+@end example
+
+The first four commands, generate the swig interface file
+@file{NumberIO.i} and python wrap files @file{NumberIO_wrap.cxx} and
+@file{NumberIO.py}.  The next three @file{libtool} commnads compile
+the C++ and Modula-2 source code into @file{.lo} objects.  The last
+@file{libtool} command links all the @file{.lo} files into a
+@file{.la} file and includes all shared library dependencies.
+
+Now it is possible to run the following Python script
+(called @file{testnum.py}):
+
+@example
+import NumberIO
+
+print ("1234 x 2 =", NumberIO.NumberIO_StrToInt("1234")*2)
+@end example
+
+like this:
+
+@example
+$ python3 testnum.py
+1234 x 2 = 2468
+@end example
+
+@xref{Producing a Python module, , ,gm2} for another example which
+uses the @code{UNQUALIFIED} keyword to reduce the module name clutter
+from the viewport of Python3.
+
+@subsection Limitations of automatic generated of Swig files
+
+This section discusses the limitations of automatically generating
+swig files.  From the previous example we see that the module
+@code{NumberIO} had a swig interface file @file{NumberIO.i}
+automatically generated by the compiler.  If we consider three of the
+procedure definitions in @file{NumberIO.def} we can see the
+success and limitations of the automatic interface generation.
+
+@example
+PROCEDURE StrToHex (a: ARRAY OF CHAR; VAR x: CARDINAL) ;
+PROCEDURE StrToInt (a: ARRAY OF CHAR; VAR x: INTEGER) ;
+PROCEDURE ReadInt (VAR x: CARDINAL) ;
+@end example
+
+Below are the swig interface prototypes:
+
+@example
+extern void NumberIO_StrToHex (char *_m2_address_a,
+                               int _m2_high_a, unsigned int *OUTPUT);
+/*  parameters: x is known to be an OUTPUT */
+extern void NumberIO_StrToInt (char *_m2_address_a,
+                               int _m2_high_a, int *OUTPUT);
+/*  parameters: x is guessed to be an OUTPUT */
+extern void NumberIO_ReadInt (int *x);
+/*  parameters: x is unknown */
+@end example
+
+In the case of @code{StrToHex} it can be seen that the compiler
+detects that the last parameter is an output.  It explicitly tells
+swig this by using the parameter name @code{OUTPUT} and in the
+following comment it informs the user that it knows this to be an
+output parameter.  In the second procedure @code{StrToInt} it marks
+the final parameter as an output, but it tells the user that this is
+only a guess.  Finally in @code{ReadInt} it informs the user that
+it does not know whether the parameter, @code{x}, is an output, input
+or an inout parameter.
+
+The compiler decides whether to mark a parameter as either:
+@code{INPUT}, @code{OUTPUT} or @code{INOUT} if it is read before
+written or visa versa in the first basic block.  At this point
+it will write output that the parameter is known.  If it is not
+read or written in the first basic block then subsequent basic blocks
+are searched and the result is commented as a guess.  Finally if
+no read or write occurs then the parameter is commented as unknown.
+However, clearly it is possible to fool this mechanism.  Nevertheless
+automatic generation of implementation module into swig interface files
+was thought sufficiently useful despite these limitations.
+
+In conclusion it would be wise to check all parameters in any
+automatically generated swig interface file.  Furthermore you can
+force the automatic mechanism to generate correct interface files by
+reading or writing to the @code{VAR} parameter in the first basic
+block of a procedure.
+
+@node Producing a Python module, Interface to C, Interface for Python, Using
+@section How to produce a Python module
+
+This section describes how it is possible to produce a Python module
+from Modula-2 code.  There are a number of advantages to this
+approach, it ensures your code reaches a wider audience, maybe it is
+easier to initialize your application in Python.
+
+The example application here is a pedagogical two dimensional gravity
+next event simulation.  The Python module needs to have a clear API
+which should be placed in a single definition module.  Furthermore the
+API should only use fundamental pervasive data types and strings.
+Below the API is contained in the file @file{twoDsim.def}:
+
+@example
+DEFINITION MODULE twoDsim ;
+
+EXPORT UNQUALIFIED gravity, box, poly3, poly5, poly6, mass,
+                   fix, circle, pivot, velocity, accel, fps,
+                   replayRate, simulateFor ;
+(*
+   gravity - turn on gravity at: g m^2
+*)
+
+PROCEDURE gravity (g: REAL) ;
+
+
+(*
+   box - place a box in the world at (x0,y0),(x0+i,y0+j)
+*)
+
+PROCEDURE box (x0, y0, i, j: REAL) : CARDINAL ;
+
+
+(*
+   poly3 - place a triangle in the world at:
+           (x0,y0),(x1,y1),(x2,y2)
+*)
+
+PROCEDURE poly3 (x0, y0, x1, y1, x2, y2: REAL) : CARDINAL ;
+
+
+(*
+   poly5 - place a pentagon in the world at:
+           (x0,y0),(x1,y1),(x2,y2),(x3,y3),(x4,y4)
+*)
+
+PROCEDURE poly5 (x0, y0, x1, y1,
+                 x2, y2, x3, y3, x4, y4: REAL) : CARDINAL ;
+
+
+(*
+   poly6 - place a hexagon in the world at:
+           (x0,y0),(x1,y1),(x2,y2),(x3,y3),(x4,y4),(x5,y5)
+*)
+
+PROCEDURE poly6 (x0, y0, x1, y1,
+                 x2, y2, x3, y3,
+                 x4, y4, x5, y5: REAL) : CARDINAL ;
+
+
+(*
+   mass - specify the mass of an object and return the, id.
+*)
+
+PROCEDURE mass (id: CARDINAL; m: REAL) : CARDINAL ;
+
+
+(*
+   fix - fix the object to the world.
+*)
+
+PROCEDURE fix (id: CARDINAL) : CARDINAL ;
+
+
+(*
+   circle - adds a circle to the world.  Center
+            defined by: x0, y0 radius, r.
+*)
+
+PROCEDURE circle (x0, y0, r: REAL) : CARDINAL ;
+
+
+(*
+   velocity - give an object, id, a velocity, vx, vy.
+*)
+
+PROCEDURE velocity (id: CARDINAL; vx, vy: REAL) : CARDINAL ;
+
+
+(*
+   accel - give an object, id, an acceleration, ax, ay.
+*)
+
+PROCEDURE accel (id: CARDINAL; ax, ay: REAL) : CARDINAL ;
+
+
+(*
+   fps - set frames per second.
+*)
+
+PROCEDURE fps (f: REAL) ;
+
+
+(*
+   replayRate - set frames per second during replay.
+*)
+
+PROCEDURE replayRate (f: REAL) ;
+
+
+(*
+   simulateFor - render for, t, seconds.
+*)
+
+PROCEDURE simulateFor (t: REAL) ;
+
+
+END twoDsim.
+@end example
+
+The keyword @code{UNQUALIFIED} can be used to ensure that the
+compiler will provide externally accessible functions
+@code{gravity}, @code{box}, @code{poly3}, @code{poly5}, @code{poly6},
+@code{mass}, @code{fix}, @code{circle}, @code{pivot}, @code{velocity},
+@code{accel}, @code{fps}, @code{replayRate}, @code{simulateFor}
+rather than name mangled alternatives.
+Hence in our Python3 application we could write:
+
+@example
+#!/usr/bin/env python3
+
+from twoDsim import *
+
+b = box (0.0, 0.0, 1.0, 1.0)
+b = fix (b)
+c1 = circle (0.7, 0.7, 0.05)
+c1 = mass (c1, 0.01)
+c2 = circle (0.7, 0.1, 0.05)
+c2 = mass (c2, 0.01)
+c2 = fix (c2)
+gravity (-9.81)
+fps (24.0*4.0)
+replayRate (24.0)
+print ("creating frames")
+try:
+    simulateFor (1.0)
+    print ("all done")
+except:
+    print ("exception raised")
+@end example
+
+which accesses the various functions defined and implemented by the
+module @code{twoDsim}.  The Modula-2 source code is compiled via:
+
+@example
+$ gm2 -g -fiso -c -fswig twoDsim.mod
+$ gm2 -g -fiso -c -fmakelist twoDsim.mod
+$ gm2 -g -fiso -c -fmakeinit twoDsim.mod
+@end example
+
+The first command both compiles the source file creating
+@file{twoDsim.o} and produces a swig interface file @file{swig.i}.  We
+now use @code{swig} and @code{g++} to produce and compile the
+interface wrappers:
+
+@example
+$ libtool --mode=compile g++ -g -c twoDsim_m2.cpp -o twoDsim_m2.lo
+$ swig -c++ -python3 twoDsim.i
+$ libtool --mode=compile g++ -c -fPIC twoDsim_wrap.cxx \
+   -I/usr/include/python3 -o twoDsim_wrap.lo
+$ libtool --mode=compile gm2 -g -fPIC -fiso -c deviceGnuPic.mod
+$ libtool --mode=compile gm2 -g -fPIC -fiso -c roots.mod
+$ libtool --mode=compile gm2 -g -fPIC -fiso -c -fswig \
+   twoDsim.mod -o twoDsim.lo
+@end example
+
+Finally the application is linked into a shared library:
+
+@example
+$ libtool --mode=link gcc -g twoDsim_m2.lo twoDsim_wrap.lo \
+  roots.lo deviceGnuPic.lo \
+   -L$@{prefix@}/lib64 \
+   -rpath `pwd` -lgm2 -lstdc++ -lm -o libtwoDsim.la
+cp .libs/libtwoDsim.so _twoDsim.so
+@end example
+
+The library name must start with @code{_} to comply with the Python3
+module naming scheme.
+
+@node Interface to C, Assembly language, Producing a Python module, Using
+@section Interfacing GNU Modula-2 to C
+
+The GNU Modula-2 compiler tries to use the C calling convention
+wherever possible however some parameters have no C equivalent and
+thus a language specific method is used.  For example unbounded arrays
+are passed as a @code{struct @{void *address, unsigned int high@}} and
+the contents of these arrays are copied by callee functions when they
+are declared as non @code{VAR} parameters.  The @code{VAR} equivalent
+unbounded array parameters need no copy, but still use the
+@code{struct} representation.
+
+The recommended method of interfacing GNU Modula-2 to C is by telling
+the definition module that the implementation is in the C language.
+This is achieved by using the tokens @code{DEFINITION MODULE FOR "C"}.
+Here is an example @file{libprintf.def}.
+
+@example
+DEFINITION MODULE FOR "C" libprintf ;
+
+EXPORT UNQUALIFIED printf ;
+
+PROCEDURE printf (a: ARRAY OF CHAR; ...) : [ INTEGER ] ;
+
+END libprintf.
+@end example
+
+the @code{UNQUALIFIED} keyword in the definition module informs
+GNU Modula-2 not to prefix the module name to exported references
+in the object file.
+
+The @code{printf} declaration states that the first parameter
+semantically matches @code{ARRAY OF CHAR} but since the module is for
+the C language it will be mapped onto @code{char *}.  The token
+@code{...} indicates a variable number of arguments (varargs) and all
+parameters passed here are mapped onto their C equivalents.  Arrays and
+constant strings are passed as pointers.  Lastly @code{[ INTEGER ]}
+states that the caller can ignore the function return result if desired.
+
+The hello world program can be rewritten as:
+
+@example
+MODULE hello ;
+
+FROM libprintf IMPORT printf ;
+
+BEGIN
+   printf ("hello world\n")
+END hello.
+@end example
+
+and it can be compiled by:
+
+@samp{gm2 -g hello.mod -lc}
+
+In reality the @samp{-lc} is redundant as libc is always included in the
+linking process.  It is shown here to emphasize that the C library or
+object file containing @code{printf} must be present.  The search path
+for modules can be changed by using @samp{-I}.
+
+If a procedure function is declared using varargs then some parameter
+values are converted.  The table below summarizes the default conversions
+and default types used.
+
+@example
+Actual Parameter       |  Default conversion  |   Type of actual
+                       |                      |   value passed
+===============================================================
+123                    |  none                |   long long int
+"hello world"          |  none                |   const char *
+a: ARRAY OF CHAR       |  ADR (a)             |   char *
+a: ARRAY [0..5] OF CHAR|  ADR (a)             |   char *
+3.14                   |  none                |   long double
+@end example
+
+If you wish to pass @code{int} values then you should explicitly
+convert the constants using one of the conversion mechanisms.
+For example:  @code{INTEGER(10)} or @code{VAL(INTEGER, 10)} or
+@code{CAST(INTEGER, 10)}.
+
+@node Assembly language, Alignment, Interface to C, Using
+@section Interface to assembly language
+
+The interface for GNU Modula-2 to assembly language is almost
+identical to GNU C.  The only alterations are that the keywords
+@code{asm} and @code{volatile} are in capitals, following the Modula-2
+convention.
+
+A simple, but highly non optimal, example is given below.  Here we want
+to add the two @code{CARDINAL}s @code{foo} and @code{bar} together and
+return the result.  The target processor is assumed to be executing
+the x86_64 instruction set.
+
+@example
+PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
+VAR
+   myout: CARDINAL ;
+BEGIN
+   ASM VOLATILE ("movq %1,%%rax; addq %2,%%rax; movq %%rax,%0"
+      : "=rm" (myout)            (* outputs *)
+      : "rm" (foo), "rm" (bar)   (* inputs  *)
+      : "rax") ;                 (* we trash *)
+   RETURN( myout )
+END Example ;
+@end example
+
+For a full description of this interface we refer the reader to the GNU C manual.
+
+@xref{Extended Asm, ,Extensions to the C Language Family,gcc}.
+
+The same example can be written using the newer extensions of naming
+the operands rather than using numbered arguments.
+
+@example
+PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
+VAR
+   myout: CARDINAL ;
+BEGIN
+   ASM VOLATILE (
+    "movq %[left],%%rax; addq %[right],%%rax; movq %%rax,%[output]"
+      : [output] "=rm" (myout)                  (* outputs *)
+      : [left] "rm" (foo), [right] "rm" (bar)   (* inputs  *)
+      : "rax") ;                                (* we trash *)
+   RETURN( myout )
+END Example ;
+@end example
+
+Both examples generate exactly the same code.  It is worth noting that
+the specifier ``rm'' indicates that the operand can be either a
+register or memory.  Of course you must choose an instruction which
+can take either, but this allows the compiler to take make more
+efficient choices depending upon the optimization level given to the
+compiler.
+
+@node Alignment, Packed, Assembly language, Using
+@section Data type alignment
+
+GNU Modula-2 allows you to specify alignment for types and variables.
+The syntax for alignment is to use the ISO pragma directives @code{<*}
+@code{bytealignment (} expression @code{)} and @code{*>}.  These directives
+can be used after type and variable declarations.
+
+The ebnf of the alignment production is:
+
+@example
+Alignment := [ ByteAlignment ] =:
+ByteAlignment := '<*' AttributeExpression '*>' =:
+AlignmentExpression := "(" ConstExpression ")" =:
+@end example
+
+The @code{Alignment} ebnf statement may be used during construction of
+types, records, record fields, arrays, pointers and variables.  Below
+is an example of aligning a type so that the variable @code{bar} is
+aligned on a 1024 address.
+
+@example
+MODULE align ;
+
+TYPE
+   foo = INTEGER <* bytealignment(1024) *> ;
+
+VAR
+   z  : INTEGER ;
+   bar: foo ;
+BEGIN
+END align.
+@end example
+
+The next example aligns a variable on a 1024 byte boundary.
+
+@example
+MODULE align2 ;
+
+VAR
+   x  : CHAR ;
+   z  : ARRAY [0..255] OF INTEGER <* bytealignment(1024) *> ;
+BEGIN
+END align2.
+@end example
+
+Here the example aligns a pointer on a 1024 byte boundary.
+
+@example
+MODULE align4 ;
+
+FROM SYSTEM IMPORT ADR ;
+FROM libc IMPORT exit ;
+
+VAR
+   x  : CHAR ;
+   z  : POINTER TO INTEGER <* bytealignment(1024) *> ;
+BEGIN
+   IF ADR(z) MOD 1024=0
+   THEN
+      exit(0)
+   ELSE
+      exit(1)
+   END
+END align4.
+@end example
+
+In example @code{align5} record field @code{y} is aligned on a 1024
+byte boundary.
+
+@example
+MODULE align5 ;
+
+FROM SYSTEM IMPORT ADR ;
+FROM libc IMPORT exit ;
+
+TYPE
+   rec = RECORD
+            x: CHAR ;
+            y: CHAR <* bytealignment(1024) *> ;
+         END ;
+VAR
+   r: rec ;
+BEGIN
+   IF ADR(r.y) MOD 1024=0
+   THEN
+      exit(0)
+   ELSE
+      exit(1)
+   END
+END align5.
+@end example
+
+In the example below module @code{align6} declares @code{foo} as an
+array of 256 @code{INTEGER}s.  The array @code{foo} is aligned on a
+1024 byte boundary.
+
+@example
+MODULE align6 ;
+
+FROM SYSTEM IMPORT ADR ;
+FROM libc IMPORT exit ;
+
+TYPE
+   foo = ARRAY [0..255] OF INTEGER <* bytealignment(1024) *> ;
+
+VAR
+   x  : CHAR ;
+   z  : foo ;
+BEGIN
+   IF ADR(z) MOD 1024=0
+   THEN
+      exit(0)
+   ELSE
+      exit(1)
+   END
+END align6.
+@end example
+
+@node Packed, Built-ins, Alignment, Using
+@section Packing data types
+
+The pragma @code{<* bytealignment(0) *>} can be used to specify that
+the fields within a @code{RECORD} are to be packed.  Currently this
+only applies to fields which are declared as subranges, ordinal types
+and enumerated types.  Here is an example of how two subranges might
+be packed into a byte.
+
+@example
+TYPE
+   bits3c =  [0..7] ;
+   bits3i = [-4..3] ;
+
+   byte = RECORD
+              <* bytealignment(0) *>
+              x: bits3c ;
+              <* bitsunused(2) *>
+              y: bits3i ;
+          END ;
+@end example
+
+Notice that the user has specified that in between fields @code{x} and
+@code{y} there are two bits unused.
+
+Now the user wishes to create a record with byte numbers zero and one
+occupied and then an @code{INTEGER32} field which is four byte
+aligned.  In this case byte numbers two and three will be unused.  The
+pragma @code{bytealignment} can be issued at the start of the record
+indicating the default alignment for the whole record and this can be
+overridden by individual fields if necessary.
+
+@example
+   rec = RECORD
+            <* bytealignment (1) *> ;
+            a, b: byte ;
+            x: INTEGER32 <* bytealignment(4) *> ;
+         END ;
+@end example
+
+In the following example the user has specified that a record has two
+fields @code{p} and @code{q} but that there are three bytes unused between
+these fields.
+
+@example
+   header = RECORD
+               <* bytealignment(1) *>
+               p: byte ;
+               <* bytesunused(3) *>
+               q: byte ;
+            END ;
+@end example
+
+The pragma @code{<* bytesunused(x) *>} can only be used if the current
+field is on a byte boundary.  There is also a @code{SYSTEM} pseudo
+procedure function @code{TBITSIZE(T)} which returns the minimum number of
+bits necessary to represent type @code{T}.
+
+Another example of packing record bit fields is given below:
+
+@example
+MODULE align21 ;
+
+FROM libc IMPORT exit ;
+
+TYPE
+   colour = (red, blue, green, purple, white, black) ;
+
+   soc = PACKEDSET OF colour ;
+
+   rec = RECORD
+            <* bytealignment(0) *>
+            x: soc ;
+            y: [-1..1] ;
+         END ;
+
+VAR
+   r: rec ;
+   v: CARDINAL ;
+BEGIN
+   v := SIZE(r) ;
+   IF SIZE(r)#1
+   THEN
+      exit(1)
+   END ;
+   r.x := soc@{blue@} ;
+   IF r.x#soc@{blue@}
+   THEN
+      exit(2)
+   END
+END align21.
+@end example
+
+Here we see that the total size of this record is one byte and consists
+of a six bit set type followed by a 2 bit integer subrange.
+
+@node Built-ins, The PIM system module, Packed, Using
+@section Accessing GNU Modula-2 Built-ins
+
+This section describes the built-in constants and functions defined in
+GNU Modula-2.  The following compiler constants can be accessed using
+the @code{__ATTRIBUTE__} @code{__BUILTIN__} keywords.  These are not
+part of the Modula-2 language and they may differ depending upon the
+target architecture but they provide a method whereby common
+libraries can interface to a different underlying architecture.
+
+The built-in constants are: @code{BITS_PER_UNIT}, @code{BITS_PER_WORD},
+@code{BITS_PER_CHAR} and @code{UNITS_PER_WORD}.  They are integrated into
+GNU Modula-2 by an extension to the @code{ConstFactor} rule:
+
+@example
+ConstFactor := ConstQualidentOrSet | Number | ConstString |
+               "(" ConstExpression ")" | "NOT" ConstFactor |
+               ConstAttribute =:
+
+ConstAttribute := "__ATTRIBUTE__" "__BUILTIN__" "(" "(" Ident ")" ")" =:
+@end example
+
+Here is an example taken from the ISO library @code{SYSTEM.def}:
+
+@example
+CONST
+   BITSPERLOC    = __ATTRIBUTE__ __BUILTIN__ ((BITS_PER_UNIT)) ;
+   LOCSPERWORD   = __ATTRIBUTE__ __BUILTIN__ ((UNITS_PER_WORD)) ;
+@end example
+
+Built-in functions are transparent to the end user.  All built-in
+functions are declared in @code{DEFINITION MODULE}s and are imported
+as and when required.  Built-in functions are declared in definition
+modules by using the @code{__BUILTIN__} keyword.  Here is a section of
+the ISO library @code{LongMath.def} which demonstrates this feature.
+
+@example
+PROCEDURE __BUILTIN__ sqrt (x: LONGREAL): LONGREAL;
+  (* Returns the square root of x *)
+@end example
+
+This indicates that the function @code{sqrt} will be implemented using
+the gcc built-in maths library.  If gcc cannot utilize the built-in
+function (for example if the programmer requested the address of
+@code{sqrt}) then code is generated to call the alternative function
+implemented in the @code{IMPLEMENTATION} @code{MODULE}.
+
+Sometimes a function exported from the @code{DEFINITION} @code{MODULE}
+will have a different name from the built-in function within gcc.  In
+such cases the mapping between the GNU Modula-2 function name and the
+gcc name is expressed using the keywords @code{__ATTRIBUTE__}
+@code{__BUILTIN__} @code{((Ident))}.  For example the function
+@code{sqrt} in @code{LongMath.def} maps onto the gcc built-in function
+@code{sqrtl} and this is expressed as:
+
+@example
+PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((sqrtl)) sqrt
+                                    (x: LONGREAL) : LONGREAL;
+  (* Returns the positive square root of x *)
+@end example
+
+The following module @code{Builtins.def} enumerates the list of
+built-in functions which can be accessed in GNU Modula-2.  It also
+serves to define the parameter and return value for each function:
+
+@include m2/Builtins.texi
+
+Although this module exists and will result in the generation of
+in-line code if optimization flags are passed to GNU Modula-2, users
+are advised to utilize the same functions from more generic libraries.
+The built-in mechanism will be applied to these generic
+libraries where appropriate.  Note for the mathematical routines to
+be in-lined you need to specify the @samp{-ffast-math -O} options.
+
+@node The PIM system module, The ISO system module, Built-ins, Using
+@section The PIM system module
+
+@include m2/SYSTEM-pim.texi
+
+The different dialects of Modula-2 PIM-[234] and ISO Modula-2 declare
+the function @code{SIZE} in different places.  PIM-[34] and ISO
+Modula-2 declare @code{SIZE} as a pervasive function (declared in the
+base module).  PIM-2 defined @code{SIZE} in the @code{SYSTEM} module
+(as shown above).
+
+GNU Modula-2 allows users to specify the dialect of Modula-2 by using
+the @code{-fiso} and @code{-fpim2} command line switches.
+
+The data types @code{CSIZE_T} and @code{CSSIZE_T} are also exported from
+the @code{SYSTEM} module.  The type @code{CSIZE_T} is unsigned and is
+mapped onto the target C data type @code{size_t} whereas the type
+@code{CSSIZE_T} is mapped onto the signed C data type @code{ssize_t}.
+
+It is anticipated that these should only be used to provide cross
+platform definition modules for C libraries.
+
+There are also a variety of fixed sized @code{INTEGER} and
+@code{CARDINAL} types.  The variety of the fixed sized types will
+depend upon the target architecture.
+
+@node The ISO system module, , The PIM system module, Using
+@section The ISO system module
+
+@include m2/SYSTEM-iso.texi
+
+The data types @code{CSIZE_T} and @code{CSSIZE_T} are also exported from
+the @code{SYSTEM} module.  The type @code{CSIZE_T} is unsigned and is
+mapped onto the target C data type @code{size_t} whereas the type
+@code{CSSIZE_T} is mapped onto the signed C data type @code{ssize_t}.
+
+It is anticipated that these should only be used to provide cross
+platform definition modules for C libraries.
+
+There are also a variety of fixed sized @code{INTEGER} and
+@code{CARDINAL} types.  The variety of the fixed sized types will
+depend upon the target architecture.
+
+@node License, Copying, The ISO system module, Top
+@section License of GNU Modula-2
+
+GNU Modula-2 is free software, the compiler is held under the GPL v3
+@uref{http://www.gnu.org/licenses/gpl.txt},
+its libraries (pim, iso and Logitech compatible) are under the
+GPL v3 with the GCC run time library exception clause.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.
+
+More information on how these licenses work is available
+@uref{http://www.gnu.org/licenses/licenses.html} on the GNU web site.
+
+@c Copying node is inside the gpl_v3.texi
+@include gpl_v3.texi
+
+@node Contributing, Internals, Copying, Top
+@section Contributing to GNU Modula-2
+
+Please do and please read the GNU Emacs info under
+
+@example
+* Standards: (standards).       GNU coding standards.
+* Intellectual Property::       Keeping Free Software Free
+* Reading Non-Free Code::       Referring to Proprietary Programs
+* Contributions::               Accepting Contributions
+@end example
+
+You might consider joining the GM2 Mailing list before you start
+coding.  The mailing list may be subscribed via a web interface
+@uref{http://lists.nongnu.org/mailman/listinfo/gm2} or via email
+@email{gm2-subscribe@@nongnu.org}.
+
+Many thanks and enjoy your coding!
+
+@node Internals, EBNF, Contributing, Top
+
+This section is still being written.
+@c @include gm2-internals.texi
+
+@node EBNF, Libraries, Internals, Top
+@chapter EBNF of GNU Modula-2
+
+This chapter contains the EBNF of GNU Modula-2.  This grammar currently
+supports both PIM and ISO dialects.  The rules here are automatically
+extracted from the crammer files in GNU Modula-2 and serve to document
+the syntax of the extensions described earlier and how they fit in
+with the base language.
+
+Note that the first six productions are built into the lexical analysis
+phase.
+
+@include m2/gm2-ebnf.texi
+
+@node Libraries, Indices, EBNF, Top
+@chapter PIM and ISO library definitions
+
+This chapter contains M2F, PIM and ISO libraries.
+
+@include m2/gm2-libs.texi
+
+@node Indices, , Libraries, Top
+@section Indices
+
+@ifhtml
+@menu
+* Contents::    Section and subsections.
+* Functions::   Function, constants, types, ebnf indices.
+@end menu
+
+@node Contents, Functions, ,
+@section Section and subsections
+@printindex cp
+
+@node Functions, , Contents,
+@section Function, constants, types, ebnf indices.
+@end ifhtml
+
+@printindex fn
+
+@summarycontents
+@contents
+@bye
diff -ruw /dev/null gcc-git-devel-modula2/gcc/m2/tools-src/def2doc.py
--- /dev/null	2022-08-24 16:22:16.888000070 +0100
+++ gcc-git-devel-modula2/gcc/m2/tools-src/def2doc.py	2022-12-14 06:54:59.688966155 +0000
@@ -0,0 +1,539 @@ 
+#!/usr/bin/env python3
+
+# def2doc.py creates texi library documentation for all exported procedures.
+# Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
+
+# Copyright (C) 2000-2022 Free Software Foundation, Inc.
+# This file is part of GNU Modula-2.
+#
+# GNU Modula-2 is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Modula-2 is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Modula-2; see the file COPYING.  If not, write to the
+# Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+
+import argparse
+import os
+import sys
+
+Base_Libs = ['gm2-libs', 'Base libraries', 'Basic M2F compatible libraries']
+
+PIM_Log_Desc = 'PIM and Logitech 3.0 compatible libraries'
+PIM_Log = ['gm2-libs-pim', 'PIM and Logitech 3.0 Compatible', PIM_Log_Desc]
+PIM_Cor_Desc = 'PIM compatible process support'
+PIM_Cor = ['gm2-libs-coroutines', 'PIM coroutine support', PIM_Cor_Desc]
+ISO_Libs = ['gm2-libs-iso', 'M2 ISO Libraries', 'ISO defined libraries']
+
+library_classifications = [Base_Libs, PIM_Log, PIM_Cor, ISO_Libs]
+
+# state_states
+state_none, state_var, state_type, state_const = range(4)
+# block states
+block_none, block_code, block_text, block_index = range(4)
+
+
+class state:
+    def __init__(self):
+        self._state_state = state_none
+        self._block = block_none
+
+    def get_state(self):
+        return self._state_state
+
+    def set_state(self, value):
+        self._state_state = value
+
+    def is_const(self):
+        return self._state_state == state_const
+
+    def is_type(self):
+        return self._state_state == state_type
+
+    def is_var(self):
+        return self._state_state == state_var
+
+    def get_block(self):
+        return self._block
+
+    def _change_block(self, new_block):
+        if self._block != new_block:
+            self._block = new_block
+            self._emit_block_desc()
+
+    def _emit_block_desc(self):
+        if self._block == block_code:
+            output.write('.. code-block:: modula2\n')
+        elif self._block == block_index:
+            output.write('.. index::\n')
+
+    def to_code(self):
+        self._change_block(block_code)
+
+    def to_index(self):
+        self._change_block(block_index)
+
+
+def init_state():
+    global state_obj
+    state_obj = state()
+
+
+def emit_node(name, nxt, previous, up):
+    if args.texinfo:
+        output.write('@node ' + name + ', ' + nxt + ', ')
+        output.write(previous + ', ' + up + '\n')
+    elif args.sphinx:
+        output.write('@c @node ' + name + ', ' + nxt + ', ')
+        output.write(previous + ', ' + up + '\n')
+
+
+def emit_section(name):
+    if args.texinfo:
+        output.write('@section ' + name + '\n')
+    elif args.sphinx:
+        output.write(name + '\n')
+        output.write('=' * len(name) + '\n')
+
+
+def emit_sub_section(name):
+    if args.texinfo:
+        output.write('@subsection ' + name + '\n')
+    elif args.sphinx:
+        output.write(name + '\n')
+        output.write('-' * len(name) + '\n')
+
+
+def display_library_class():
+    # display_library_class displays a node for a library directory and invokes
+    # a routine to summarize each module.
+    global args
+    previous = ''
+    nxt = library_classifications[1][1]
+    i = 0
+    lib = library_classifications[i]
+    while True:
+        emit_node(lib[1], nxt, previous, args.up)
+        emit_section(lib[1])
+        output.write('\n')
+        display_modules(lib[1], lib[0], args.builddir, args.sourcedir)
+        output.write('\n')
+        output.write('@c ' + '-' * 60 + '\n')
+        previous = lib[1]
+        i += 1
+        if i == len(library_classifications):
+            break
+        lib = library_classifications[i]
+        if i+1 == len(library_classifications):
+            nxt = ''
+        else:
+            nxt = library_classifications[i+1][1]
+
+
+def display_menu():
+    # display_menu displays the top level menu for library documentation.
+    output.write('@menu\n')
+    for lib in library_classifications:
+        output.write('* ' + lib[1] + '::' + lib[2] + '\n')
+    output.write('@end menu\n')
+    output.write('\n')
+    output.write('@c ' + '=' * 60 + '\n')
+    output.write('\n')
+
+
+def remote_initial_comments(file, line):
+    # remote_initial_comments removes any (* *) at the top
+    # of the definition module.
+    while (line.find('*)') == -1):
+        line = file.readline()
+
+
+def removeable_field(line):
+    # removeable_field - returns True if a comment field should be removed
+    # from the definition module.
+    field_list = ['Author', 'Last edit', 'LastEdit', 'Last update',
+                  'Date', 'Title', 'Revision']
+    for field in field_list:
+        if (line.find(field) != -1) and (line.find(':') != -1):
+            return True
+    ignore_list = ['System', 'SYSTEM']
+    for ignore_field in ignore_list:
+        if line.find(ignore_field) != -1:
+            if line.find(':') != -1:
+                if line.find('Description:') == -1:
+                    return True
+    return False
+
+
+def remove_fields(file, line):
+    # remove_fields removes Author/Date/Last edit/SYSTEM/Revision
+    # fields from a comment within the start of a definition module.
+    while (line.find('*)') == -1):
+        if not removeable_field(line):
+            line = line.rstrip().replace('{', '@{').replace('}', '@}')
+            output.write(line + '\n')
+        line = file.readline()
+    output.write(line.rstrip() + '\n')
+
+
+def emit_index(entry, tag):
+    global state_obj
+    if args.texinfo:
+        if tag == '':
+            output.write('@findex ' + entry.rstrip() + '\n')
+        else:
+            output.write('@findex ' + entry.rstrip() + ' ' + tag + '\n')
+    elif args.sphinx:
+        if tag == '':
+            state_obj.to_index()
+            output.write(' ' * 3 + entry.rstrip() + '\n')
+        else:
+            state_obj.to_index()
+            output.write(' ' * 3 + 'pair: ' + entry.rstrip() + '; ' + tag + '\n')
+
+
+def check_index(line):
+    # check_index - create an index entry for a PROCEDURE, TYPE, CONST or VAR.
+    global state_obj
+
+    words = line.split()
+    procedure = ''
+    if (len(words) > 1) and (words[0] == 'PROCEDURE'):
+        state_obj.set_state(state_none)
+        if (words[1] == '__BUILTIN__') and (len(words) > 2):
+            procedure = words[2]
+        else:
+            procedure = words[1]
+    if (len(line) > 1) and (line[0:2] == '(*'):
+        state_obj.set_state(state_none)
+    elif line == 'VAR':
+        state_obj.set_state(state_var)
+        return
+    elif line == 'TYPE':
+        state_obj.set_state(state_type)
+        return
+    elif line == 'CONST':
+        state_obj.set_state(state_const)
+    if state_obj.is_var():
+        words = line.split(',')
+        for word in words:
+            word = word.lstrip()
+            if word != '':
+                if word.find(':') == -1:
+                    emit_index(word, '(var)')
+                elif len(word) > 0:
+                    var = word.split(':')
+                    if len(var) > 0:
+                        emit_index(var[0], '(var)')
+    if state_obj.is_type():
+        words = line.lstrip()
+        if words.find('=') != -1:
+            word = words.split('=')
+            if (len(word[0]) > 0) and (word[0][0] != '_'):
+                emit_index(word[0].rstrip(), '(type)')
+        else:
+            word = words.split()
+            if (len(word) > 1) and (word[1] == ';'):
+                # hidden type
+                if (len(word[0]) > 0) and (word[0][0] != '_'):
+                    emit_index(word[0].rstrip(), '(type)')
+    if state_obj.is_const():
+        words = line.split(';')
+        for word in words:
+            word = word.lstrip()
+            if word != '':
+                if word.find('=') != -1:
+                    var = word.split('=')
+                    if len(var) > 0:
+                        emit_index(var[0], '(const)')
+    if procedure != '':
+        name = procedure.split('(')
+        if name[0] != '':
+            proc = name[0]
+            if proc[-1] == ';':
+                proc = proc[:-1]
+            if proc != '':
+                emit_index(proc, '')
+
+def demangle_system_datatype(line, indent):
+    # The spaces in front align in the export qualified list.
+    indent += len ('EXPORT QUALIFIED ')
+    line = line.replace('@SYSTEM_DATATYPES@',
+                        '\n' + indent * ' ' + 'Target specific data types.')
+    line = line.replace('@SYSTEM_TYPES@',
+                        '(* Target specific data types.  *)')
+    return line
+
+
+def emit_texinfo_content(f, line):
+    global state_obj
+    output.write(line.rstrip() + '\n')
+    line = f.readline()
+    if len(line.rstrip()) == 0:
+        output.write('\n')
+        line = f.readline()
+        if (line.find('(*') != -1):
+            remove_fields(f, line)
+        else:
+            output.write(line.rstrip() + '\n')
+    else:
+        output.write(line.rstrip() + '\n')
+    line = f.readline()
+    while line:
+        line = line.rstrip()
+        check_index(line)
+        line = line.replace('{', '@{').replace('}', '@}')
+        line = demangle_system_datatype(line, 0)
+        output.write(line + '\n')
+        line = f.readline()
+    return f
+
+
+def emit_sphinx_content(f, line):
+    global state_obj
+    state_obj.to_code()
+    indentation = 4
+    indent = ' ' * indentation
+    output.write(indent + line.rstrip() + '\n')
+    line = f.readline()
+    if len(line.rstrip()) == 0:
+        output.write('\n')
+        line = f.readline()
+        if (line.find('(*') != -1):
+            remove_fields(f, line)
+        else:
+            output.write(indent + line.rstrip() + '\n')
+    else:
+        output.write(indent + line.rstrip() + '\n')
+    line = f.readline()
+    while line:
+        line = line.rstrip()
+        check_index(line)
+        state_obj.to_code()
+        line = demangle_system_datatype(line, indentation)
+        output.write(indent + line + '\n')
+        line = f.readline()
+    return f
+
+
+def emit_example_content(f, line):
+    if args.texinfo:
+        return emit_texinfo_content(f, line)
+    elif args.sphinx:
+        return emit_sphinx_content(f, line)
+
+
+def emit_example_begin():
+    if args.texinfo:
+        output.write('@example\n')
+
+
+def emit_example_end():
+    if args.texinfo:
+        output.write('@end example\n')
+
+
+def emit_page(need_page):
+    if need_page and args.texinfo:
+        output.write('@page\n')
+
+
+def parse_definition(dir_, source, build, file, need_page):
+    # parse_definition reads a definition module and creates
+    # indices for procedures, constants, variables and types.
+    output.write('\n')
+    with open(find_file(dir_, build, source, file), 'r') as f:
+        init_state()
+        line = f.readline()
+        while (line.find('(*') != -1):
+            remote_initial_comments(f, line)
+            line = f.readline()
+        while (line.find('DEFINITION') == -1):
+            line = f.readline()
+        emit_example_begin()
+        f = emit_example_content(f, line)
+        emit_example_end()
+        emit_page(need_page)
+
+
+def parse_modules(up, dir_, build, source, list_of_modules):
+    previous = ''
+    i = 0
+    if len(list_of_modules) > 1:
+        nxt = dir_ + '/' + list_of_modules[1][:-4]
+    else:
+        nxt = ''
+    while i < len(list_of_modules):
+        emit_node(dir_ + '/' + list_of_modules[i][:-4], nxt, previous, up)
+        emit_sub_section(dir_ + '/' + list_of_modules[i][:-4])
+        parse_definition(dir_, source, build, list_of_modules[i], True)
+        output.write('\n')
+        previous = dir_ + '/' + list_of_modules[i][:-4]
+        i = i + 1
+        if i+1 < len(list_of_modules):
+            nxt = dir_ + '/' + list_of_modules[i+1][:-4]
+        else:
+            nxt = ''
+
+
+def do_cat(name):
+    # do_cat displays the contents of file, name, to stdout
+    with open(name, 'r') as file:
+        line = file.readline()
+        while line:
+            output.write(line.rstrip() + '\n')
+            line = file.readline()
+
+
+def module_menu(dir_, build, source):
+    # module_menu generates a simple menu for all definition modules
+    # in dir
+    output.write('@menu\n')
+    list_of_files = []
+    if os.path.exists(os.path.join(source, dir_)):
+        list_of_files += os.listdir(os.path.join(source, dir_))
+    if os.path.exists(os.path.join(source, dir_)):
+        list_of_files += os.listdir(os.path.join(build, dir_))
+    list_of_files = list(dict.fromkeys(list_of_files).keys())
+    list_of_files.sort()
+    for file in list_of_files:
+        if found_file(dir_, build, source, file):
+            if (len(file) > 4) and (file[-4:] == '.def'):
+                output.write('* ' + dir_ + '/' + file[:-4] + '::' + file + '\n')
+    output.write('@end menu\n')
+    output.write('\n')
+
+
+def check_directory(dir_, build, source):
+    # check_directory - returns True if dir exists in either build or source.
+    if os.path.isdir(build) and os.path.exists(os.path.join(build, dir_)):
+        return True
+    elif os.path.isdir(source) and os.path.exists(os.path.join(source, dir_)):
+        return True
+    else:
+        return False
+
+
+def found_file(dir_, build, source, file):
+    # found_file return True if file is found in build/dir/file or
+    # source/dir/file.
+    name = os.path.join(os.path.join(build, dir_), file)
+    if os.path.exists(name):
+        return True
+    name = os.path.join(os.path.join(source, dir_), file)
+    if os.path.exists(name):
+        return True
+    return False
+
+
+def find_file(dir_, build, source, file):
+    # find_file return the path to file searching in build/dir/file
+    # first then source/dir/file.
+    name1 = os.path.join(os.path.join(build, dir_), file)
+    if os.path.exists(name1):
+        return name1
+    name2 = os.path.join(os.path.join(source, dir_), file)
+    if os.path.exists(name2):
+        return name2
+    sys.stderr.write('file cannot be found in either ' + name1)
+    sys.stderr.write(' or ' + name2 + '\n')
+    os.sys.exit(1)
+
+
+def display_modules(up, dir_, build, source):
+    # display_modules walks though the files in dir and parses
+    # definition modules and includes README.texi
+    if check_directory(dir_, build, source):
+        if args.texinfo:
+            ext = '.texi'
+        elif args.sphinx:
+            ext = '.rst'
+        else:
+            ext = ''
+        if found_file(dir_, build, source, 'README' + ext):
+            do_cat(find_file(dir_, build, source, 'README' + ext))
+        module_menu(dir_, build, source)
+        list_of_files = []
+        if os.path.exists(os.path.join(source, dir_)):
+            list_of_files += os.listdir(os.path.join(source, dir_))
+        if os.path.exists(os.path.join(source, dir_)):
+            list_of_files += os.listdir(os.path.join(build, dir_))
+        list_of_files = list(dict.fromkeys(list_of_files).keys())
+        list_of_files.sort()
+        list_of_modules = []
+        for file in list_of_files:
+            if found_file(dir_, build, source, file):
+                if (len(file) > 4) and (file[-4:] == '.def'):
+                    list_of_modules += [file]
+        list_of_modules.sort()
+        parse_modules(up, dir_, build, source, list_of_modules)
+    else:
+        line = 'directory ' + dir_ + ' not found in either '
+        line += build + ' or ' + source
+        sys.stderr.write(line + '\n')
+
+
+def display_copyright():
+    output.write('@c Copyright (C) 2000-2022 Free Software Foundation, Inc.\n')
+    output.write('@c This file is part of GNU Modula-2.\n')
+    output.write("""
+@c Permission is granted to copy, distribute and/or modify this document
+@c under the terms of the GNU Free Documentation License, Version 1.2 or
+@c any later version published by the Free Software Foundation.
+""")
+
+
+def collect_args():
+    parser = argparse.ArgumentParser()
+    parser.add_argument('-v', '--verbose', help='generate progress messages',
+                        action='store_true')
+    parser.add_argument('-b', '--builddir', help='set the build directory',
+                        default='.', action='store')
+    parser.add_argument('-f', '--inputfile', help='set the input file',
+                        default=None, action='store')
+    parser.add_argument('-o', '--outputfile', help='set the output file',
+                        default=None, action='store')
+    parser.add_argument('-s', '--sourcedir', help='set the source directory',
+                        default='.', action='store')
+    parser.add_argument('-t', '--texinfo',
+                        help='generate texinfo documentation',
+                        default=False, action='store_true')
+    parser.add_argument('-u', '--up', help='set the up node',
+                        default='', action='store')
+    parser.add_argument('-x', '--sphinx', help='generate sphinx documentation',
+                        default=False, action='store_true')
+    args = parser.parse_args()
+    return args
+
+
+def handle_file():
+    if args.inputfile is None:
+        display_copyright()
+        display_menu()
+        display_library_class()
+    else:
+        parse_definition('.', args.sourcedir, args.builddir,
+                         args.inputfile, False)
+
+
+def main():
+    global args, output
+    args = collect_args()
+    if args.outputfile is None:
+        output = sys.stdout
+        handle_file()
+    else:
+        with open(args.outputfile, 'w') as output:
+            handle_file()
+
+
+main()
diff -ruw /dev/null gcc-git-devel-modula2/gcc/m2/Make-lang.in
--- /dev/null	2022-08-24 16:22:16.888000070 +0100
+++ gcc-git-devel-modula2/gcc/m2/Make-lang.in	2022-12-14 06:54:59.636965403 +0000
@@ -0,0 +1,1653 @@ 
+# Top level -*- makefile -*- fragment for GNU M2.
+
+# Copyright (C) 2000-2022 Free Software Foundation, Inc.
+
+#This file is part of GCC.
+
+#GCC is free software; you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation; either version 3, or (at your option)
+#any later version.
+
+#GCC is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#GNU General Public License for more details.
+
+#You should have received a copy of the GNU General Public License
+#along with GCC; see the file COPYING3.  If not see
+#<http://www.gnu.org/licenses/>.
+
+# Actual names to use when installing a native compiler.
+GM2_INSTALL_NAME = $(shell echo gm2|sed '$(program_transform_name)')
+GM2_TARGET_INSTALL_NAME = $(target_noncanonical)-$(shell echo gm2|sed '$(program_transform_name)')
+
+# Actual names to use when installing a cross-compiler.
+GM2_CROSS_NAME = `echo gm2|sed '$(program_transform_cross_name)'`
+
+M2_MAINTAINER = no
+
+GM2_1 = ./gm2 -B./stage1/m2 -g -fm2-g
+
+GM2_FOR_TARGET = $(STAGE_CC_WRAPPER) ./gm2 -B./ -B$(build_tooldir)/bin/ -L$(objdir)/../ld $(TFLAGS)
+
+TEXISRC = $(objdir)/m2/images/gnu.eps \
+          $(srcdir)/doc/gm2.texi \
+          m2/gm2-libs.texi \
+          m2/gm2-ebnf.texi \
+          m2/SYSTEM-pim.texi \
+          m2/SYSTEM-iso.texi \
+          m2/Builtins.texi
+
+RSTSRC = $(objdir)/m2/images/gnu.eps \
+          $(srcdir)/doc/gm2.texi \
+          m2/gm2-libs.rst \
+          m2/gm2-ebnf.rst \
+          m2/SYSTEM-pim.rst \
+          m2/SYSTEM-iso.rst \
+          m2/Builtins.rst
+
+# Define the names for selecting modula-2 in LANGUAGES.
+m2 modula-2 modula2: gm2$(exeext) xgcc$(exeext) cc1gm2$(exeext) \
+                 $(GCC_PASSES) $(GCC_PARTS)
+m2.serial = cc1gm2$(exeext)
+
+m2.srcinfo: doc/m2.info
+	-cp -p $^ $(srcdir)/doc
+
+ifeq ($(HAVE_PYTHON),yes)
+m2.srcextra: m2/SYSTEM-pim.texi m2/SYSTEM-iso.texi m2/gm2-libs.texi m2/gm2-ebnf.texi
+	-cp -p m2/SYSTEM-pim.texi $(srcdir)/m2
+	-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
+
+m2.srcman: doc/gm2.1
+	-cp -p $^ $(srcdir)/doc
+
+# Tell GNU make to ignore these if they exist.
+.PHONY: m2 modula-2 modula2
+
+GM2_PROG_DEP=gm2$(exeext) xgcc$(exeext) cc1gm2$(exeext)
+
+include m2/config-make
+
+LIBSTDCXX=../$(TARGET_SUBDIR)/libstdc++-v3/src/.libs/libstdc++.a
+
+PGE=m2/pge$(exeext)
+
+SRC_PREFIX=G
+
+m2/gm2spec.o: $(srcdir)/m2/gm2spec.cc $(SYSTEM_H) $(GCC_H) $(CONFIG_H) \
+               m2/gm2config.h $(TARGET_H) $(PLUGIN_HEADERS) \
+               $(generated_files) $(C_TREE_H) insn-attr-common.h
+	(SHLIB_LINK='$(SHLIB_LINK)' \
+	SHLIB_MULTILIB='$(SHLIB_MULTILIB)'; \
+	$(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
+         $(DRIVER_DEFINES) \
+		-DLIBSUBDIR=\"$(libsubdir)\" \
+                -DPREFIX=\"$(prefix)\" \
+                -c $(srcdir)/m2/gm2spec.cc $(OUTPUT_OPTION))
+
+# Create the compiler driver for M2.
+CFLAGS-m2/m2/gm2spec.o += $(DRIVER_DEFINES)
+
+GM2_OBJS = $(GCC_OBJS) prefix.o intl.o m2/gm2spec.o
+
+# Create the compiler driver for gm2.
+gm2$(exeext): $(GM2_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS) \
+    m2/gm2config.h
+	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
+	  $(GM2_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
+	  $(EXTRA_GCC_LIBS) $(LIBS)
+
+# Create a version of the gm2 driver which calls the cross-compiler.
+gm2-cross$(exeext): gm2$(exeext)
+	-rm -f gm2-cross$(exeext)
+	cp gm2$(exeext) gm2-cross$(exeext)
+
+po-generated:
+
+# Build hooks:
+
+m2.all.cross: gm2-cross$(exeext) plugin/m2rte$(exeext).so
+
+m2.start.encap: gm2$(exeext) plugin/m2rte$(exeext).so
+m2.rest.encap:
+
+
+m2.info: doc/m2.info
+
+m2.man: doc/m2.1
+
+m2.install-man: $(DESTDIR)$(man1dir)/$(GM2_INSTALL_NAME)$(man1ext)
+
+$(DESTDIR)$(man1dir)/$(GM2_INSTALL_NAME)$(man1ext): doc/m2.1 installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+	-chmod a-x $@
+
+m2.dvi: $(TEXISRC)
+	$(TEXI2DVI) -I $(objdir)/m2 -I $(srcdir)/doc/include $(srcdir)/doc/gm2.texi -o $@
+
+m2.ps: m2.dvi
+	dvips -o $@ $<
+
+m2.pdf: m2.ps
+	gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=$@ $<
+
+.INTERMEDIATE: m2.pod
+
+m2.pod: doc/gm2.texi $(TEXISRC)
+	-$(TEXI2POD) -I $(objdir)/m2 -D m2 < $< > $@
+
+doc/m2.info: $(TEXISRC)
+	if test "x$(BUILD_INFO)" = xinfo; then \
+	  rm -f doc/m2.info*; \
+          $(MAKEINFO) -I$(objdir)/m2 -I$(srcdir)/doc/include \
+                      -o $@ $(srcdir)/doc/gm2.texi ; \
+	else true; fi
+
+$(objdir)/m2/images/gnu.eps: $(srcdir)/m2/images/gnupng
+	test -d m2/images || mkdir -p m2/images
+	cp $(srcdir)/m2/images/gnu.eps $@
+
+# gm2-libs.texi
+
+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
+	$(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:
+	cp $(srcdir)/m2/target-independent/gm2-libs.texi $(objdir)/m2/gm2-libs.texi
+endif
+	$(STAMP) gm2-libs.texi-check
+
+# gm2-libs.rst
+
+m2/gm2-libs.rst: gm2-libs.rst-check; @true
+
+ifeq ($(HAVE_PYTHON),yes)
+gm2-libs.rst-check: m2/SYSTEM-pim.texi m2/SYSTEM-iso.texi m2/Builtins.texi \
+                     $(objdir)/m2/gm2-libs-coroutines/SYSTEM.def
+	$(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -x -uLibraries -s$(srcdir)/m2 -b$(objdir)/m2 -o $(objdir)/m2/gm2-libs.rst
+else
+gm2-libs.rst-check:
+	cp $(srcdir)/m2/target-independent/gm2-libs.rst $(objdir)/m2/gm2-libs.rst
+endif
+	$(STAMP) gm2-libs.rst-check
+
+# gm2-ebnf.texi
+
+m2/gm2-ebnf.texi: gm2-ebnf.texi-check; @true
+
+gm2-ebnf.texi-check: $(PGE) $(srcdir)/m2/gm2-compiler/P0SyntaxCheck.bnf
+	$(PGE) -c -p -t -f $(srcdir)/m2/gm2-compiler/P0SyntaxCheck.bnf -o m2/gm2-ebnf.texi
+	$(STAMP) gm2-ebnf.texi-check
+
+# gm2-ebnf.rst
+
+m2/gm2-ebnf.rst: gm2-ebnf.rst-check; @true
+
+gm2-ebnf.rst-check: $(PGE) $(srcdir)/m2/gm2-compiler/P0SyntaxCheck.bnf
+	$(PGE) -c -p -t -f $(srcdir)/m2/gm2-compiler/P0SyntaxCheck.bnf -o m2/gm2-ebnf.rst
+	$(STAMP) gm2-ebnf.rst-check
+
+# SYSTEM-pim.texi
+
+m2/SYSTEM-pim.texi: SYSTEM-pim-texi-check; @true
+
+ifeq ($(HAVE_PYTHON),yes)
+SYSTEM-pim-texi-check: $(objdir)/m2/gm2-libs/SYSTEM.def
+	$(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -t -b$(objdir)/m2 -f$(objdir)/m2/gm2-libs/SYSTEM.def -o $(objdir)/m2/SYSTEM-pim.texi
+else
+SYSTEM-pim-texi-check: $(objdir)/m2/gm2-libs/SYSTEM.def
+	cp $(srcdir)/m2/target-independent/SYSTEM-pim.texi $(objdir)/m2/SYSTEM-pim.texi
+endif
+	$(STAMP) SYSTEM-pim-texi-check
+
+# SYSTEM-pim.rst
+
+m2/SYSTEM-pim.rst: SYSTEM-pim-rst-check; @true
+
+ifeq ($(HAVE_PYTHON),yes)
+SYSTEM-pim-rst-check: $(objdir)/m2/gm2-libs/SYSTEM.def
+	$(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -x -b$(objdir)/m2 -f$(objdir)/m2/gm2-libs/SYSTEM.def -o $(objdir)/m2/SYSTEM-pim.rst
+else
+SYSTEM-pim-rst-check: $(objdir)/m2/gm2-libs/SYSTEM.def
+	cp $(srcdir)/m2/target-independent/SYSTEM-pim.rst $(objdir)/m2/SYSTEM-pim.rst
+endif
+	$(STAMP) SYSTEM-pim-rst-check
+
+# SYSTEM-pim.texi
+
+m2/SYSTEM-iso.texi:  SYSTEM-iso.texi-check; @true
+
+ifeq ($(HAVE_PYTHON),yes)
+SYSTEM-iso.texi-check:  $(objdir)/m2/gm2-libs-iso/SYSTEM.def
+	$(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -t -b$(objdir)/m2 -f$(objdir)/m2/gm2-libs-iso/SYSTEM.def -o $(objdir)/m2/SYSTEM-iso.texi
+else
+SYSTEM-iso.texi-check:  $(objdir)/m2/gm2-libs-iso/SYSTEM.def
+	cp $(srcdir)/m2/target-independent/SYSTEM-iso.texi $(objdir)/m2/SYSTEM-iso.texi
+endif
+	$(STAMP) SYSTEM-iso.texi-check
+
+# SYSTEM-pim.rst
+
+m2/SYSTEM-iso.rst:  SYSTEM-iso.rst-check; @true
+
+ifeq ($(HAVE_PYTHON),yes)
+SYSTEM-iso.rst-check:  $(objdir)/m2/gm2-libs-iso/SYSTEM.def
+	$(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -x -b$(objdir)/m2 -f$(objdir)/m2/gm2-libs-iso/SYSTEM.def -o $(objdir)/m2/SYSTEM-iso.rst
+else
+SYSTEM-iso.rst-check:  $(objdir)/m2/gm2-libs-iso/SYSTEM.def
+	cp $(srcdir)/m2/target-independent/SYSTEM-iso.rst $(objdir)/m2/SYSTEM-iso.rst
+endif
+	$(STAMP) SYSTEM-iso.rst-check
+
+
+# m2/Builtins.texi
+
+m2/Builtins.texi:  Builtins.texi-check; @true
+
+ifeq ($(HAVE_PYTHON),yes)
+Builtins.texi-check:  m2/gm2-libs/Builtins.def
+	$(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -t -b./ -f$(srcdir)/m2/gm2-libs/Builtins.def -o $(objdir)/m2/Builtins.texi
+else
+Builtins.texi-check:  m2/gm2-libs/Builtins.def
+	cp $(srcdir)/m2/target-independent/Builtins.texi $(objdir)/m2/Builtins.texi
+endif
+	$(STAMP) Builtins.texi-check
+
+# m2/Builtins.rst
+
+m2/Builtins.rst:  Builtins.rst-check; @true
+
+ifeq ($(HAVE_PYTHON),yes)
+Builtins.rst-check:  m2/gm2-libs/Builtins.def
+	$(PYTHON) $(srcdir)/m2/tools-src/def2doc.py -x -b./ -f$(srcdir)/m2/gm2-libs/Builtins.def -o $(objdir)/m2/Builtins.rst
+else
+Builtins.rst-check:  m2/gm2-libs/Builtins.def
+	cp $(srcdir)/m2/target-independent/Builtins.rst $(objdir)/m2/Builtins.rst
+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
+
+stage4/m2:
+	-test -d $@ || mkdir -p stage4/m2
+
+# No gm2-specific selftests
+selftest-m2:
+
+# Install hooks:
+# cc1gm2 is installed elsewhere as part of $(COMPILERS).
+# $(COMPILERS) is defined in `config-lang.in'
+
+m2.install-common: installdirs
+	-rm -f $(DESTDIR)$(bindir)/$(GM2_INSTALL_NAME)$(exeext)
+	$(INSTALL_PROGRAM) gm2$(exeext) $(DESTDIR)$(bindir)/$(GM2_INSTALL_NAME)$(exeext)
+	-if test -f cc1gm2$(exeext); then \
+	  if test -f gm2-cross$(exeext); then \
+	    :; \
+	  else \
+	    rm -f $(DESTDIR)$(bindir)/$(GM2_TARGET_INSTALL_NAME)$(exeext); \
+	    ( cd $(DESTDIR)$(bindir) && \
+	      $(LN) $(GM2_INSTALL_NAME)$(exeext) $(GM2_TARGET_INSTALL_NAME)$(exeext) ); \
+	  fi; \
+	fi
+	-for tool in cc1gm2$(exeext); do \
+             if [ -f $$tool ]; then \
+               rm -f $(DESTDIR)$(libexecsubdir)/$$tool; \
+               $(INSTALL_PROGRAM) $$tool $(DESTDIR)$(libexecsubdir)/$$tool; \
+               chmod a+x $(DESTDIR)$(libexecsubdir)/$$tool; \
+             else \
+               echo "cannot find $$tool" ; \
+             fi ; \
+         done
+
+m2.install-info: installdirs
+	if [ -d gm2$(exeext) ] ; then \
+	  if [ -f $(objdir)/doc/gm2.info ]; then \
+	    rm -f $(DESTDIR)$(infodir)/gm2.info*; \
+	    for f in $(objdir)/doc/gm2.info*; do \
+	      realfile=`echo $$f | sed -e 's|.*/\([^/]*\)$$|\1|'`; \
+              rm -f $(DESTDIR)$(infodir)/`basename $$realfile`; \
+	      $(INSTALL_DATA) $$f $(DESTDIR)$(infodir)/`basename $$realfile`; \
+	    done; \
+	    chmod a-x $(DESTDIR)$(infodir)/gm2.info*; \
+	  else true; fi; \
+	else true; fi
+	-if [ -f gm2$(exeext) ] && [ -f $(DESTDIR)$(infodir)/gm2.info ]; then \
+	  if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
+	    install-info --dir-file=$(infodir)/dir $(DESTDIR)$(infodir)/gm2.info; \
+	  else true; fi; \
+	else true; fi
+
+m2.install-normal: m2.install-common m2.install-info m2.install-man
+
+# This target will install GM2 into an existing GCC installation,
+# without overwriting existing files.
+# The semicolon is to prevent the install.sh -> install default rule
+# from doing anything.  Having it run true helps avoid problems and
+# noise from versions of make which don't like to have null commands.
+m2.install: m2.install-normal; @true
+
+gm2.install-with-gcc: $(INSTALL_HEADERS) gm2.install $(INSTALL_LIBGCC)
+	for file in $(GCC_PASSES); do \
+          if [ x"$$file" != x"xgcc$(exeext)" ]; then \
+            rm -f $(DESTDIR)$(libsubdir)/$$file; \
+            $(INSTALL_PROGRAM) $$file $(DESTDIR)$(libsubdir)/$$file || exit 1; \
+          fi; \
+        done; exit 0
+
+m2.uninstall:
+	-rm -rf $(bindir)/$(GM2_INSTALL_NAME)
+	-rm -rf $(bindir)/$(GM2_CROSS_NAME)
+
+m2.install-plugin: installdirs
+	$(mkinstalldirs) $(DESTDIR)$(plugin_resourcesdir)
+	$(INSTALL_PROGRAM) plugin/m2rte$(exeext).so $(DESTDIR)$(plugin_resourcesdir)/m2rte$(exeext).so
+	chmod a+x $(DESTDIR)$(plugin_resourcesdir)/m2rte$(exeext).so
+
+plugin/m2rte$(exeext).so: $(srcdir)/m2/plugin/m2rte.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \
+        insn-attr-common.h insn-flags.h $(generated_files)
+	test -d plugin || mkdir plugin
+	$(PLUGINCC) $(PLUGINCFLAGS) -fno-rtti -I. -I$(srcdir) -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) $(PLUGINLIBS) -fno-rtti plugin/m2rte.o -shared -o $@
+
+
+# Clean hooks:
+# A lot of the ancillary files are deleted by the main makefile.
+# We just have to delete files specific to us.
+
+m2.mostlyclean:
+	-rm -f m2/*.o
+
+m2.clean:
+	-rm -f m2/*.o
+	-rm -f m2/gm2-libs/config.*
+	-rm m2/gm2-libs/gm2-libs-host.h m2/gm2config.h
+
+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
+
+# Rules to build the compiler, pge and mc.
+
+# MC_COPYRIGHT=--gpl-header --project="GNU Modula-2"
+MC_COPYRIGHT=
+
+MC_ARGS= --olang=c++ \
+ --h-file-prefix=$(SRC_PREFIX) \
+ -I$(srcdir)/m2/gm2-libs \
+ -I$(srcdir)/m2/gm2-compiler \
+ -I$(srcdir)/m2/gm2-libiberty \
+ -I$(srcdir)/m2/gm2-gcc \
+ --quiet \
+ $(MC_COPYRIGHT) \
+ --gcc-config-system
+
+MCDEPS=m2/boot-bin/mc$(exeext)
+
+MC=m2/boot-bin/mc$(exeext) $(MC_ARGS)
+
+MC_LIBS=m2/mc-boot-ch/Glibc.o m2/mc-boot-ch/Gmcrts.o
+
+M2LINK=m2/boot-bin/mklink$(exeext)
+GM2_O=
+GM2_O_S3=-O
+GM2_OS=-Os
+GM2_G=-g -fm2-g
+GM2_CPP=
+# GM2_DEBUG_STRMEM=-fcpp
+GM2_DEBUG_STRMEM=
+GM2_FLAGS=-Wunused-variable -fsoft-check-all $(GM2_G) $(GM2_O) \
+ -funbounded-by-reference -fpim -fextended-opaque \
+ -Wpedantic-cast -Wpedantic-param-names -ffunction-sections \
+ -fdata-sections $(GM2_CPP) # -fauto-init
+GM2_ISO_FLAGS=-fsoft-check-all $(GM2_G) $(GM2_O) \
+ -funbounded-by-reference -fiso -fextended-opaque \
+ -Wpedantic-cast -Wpedantic-param-names -ffunction-sections \
+ -fdata-sections $(GM2_CPP)
+GM2_MIN_FLAGS=$(GM2_G) $(GM2_OS) \
+ -funbounded-by-reference -fextended-opaque \
+ -Wpedantic-cast -Wpedantic-param-names -fno-exceptions \
+ -ffunction-sections -fdata-sections $(GM2_CPP)
+
+O2=-O2 -g
+SO_O2=-O2 -g -fPIC
+SO=-O0 -g -fPIC
+
+# Language-specific object files for the gm2 compiler.
+
+GM2_C_OBJS        = m2/gm2-lang.o \
+                    m2/stor-layout.o \
+                    m2/m2pp.o \
+                    m2/gm2-gcc/m2assert.o \
+                    m2/gm2-gcc/m2block.o \
+                    m2/gm2-gcc/m2builtins.o \
+                    m2/gm2-gcc/m2except.o \
+                    m2/gm2-gcc/m2color.o \
+                    m2/gm2-gcc/m2configure.o \
+                    m2/gm2-gcc/m2convert.o \
+                    m2/gm2-gcc/m2decl.o \
+                    m2/gm2-gcc/m2expr.o \
+                    m2/gm2-gcc/m2linemap.o \
+                    m2/gm2-gcc/m2statement.o \
+                    m2/gm2-gcc/m2type.o \
+                    m2/gm2-gcc/m2tree.o \
+                    m2/gm2-gcc/m2treelib.o \
+                    m2/gm2-gcc/m2top.o \
+                    m2/gm2-gcc/m2misc.o \
+                    m2/gm2-gcc/init.o
+GM2_LIBS          = m2/gm2-compiler/gm2.a \
+                    ../$(target_subdir)/libgm2/libm2pim/.libs/libm2pim.a m2/gm2-libs-boot/choosetemp.o
+
+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)
+	cp -p $< $@
+
+stage2/m2/cc1gm2$(exeext): stage1/m2/cc1gm2$(exeext) m2/gm2-compiler/m2flex.o $(P) \
+                            $(GM2_C_OBJS) $(BACKEND) $(LIBDEPS) $(GM2_LIBS) \
+                            m2/gm2-gcc/rtegraph.o plugin/m2rte$(exeext).so m2/gm2-libs-boot/M2LINK.o
+	@$(call LINK_PROGRESS,$(INDEX.m2),start)
+	+$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler/m2flex.o \
+                            attribs.o \
+                              $(GM2_LIBS) \
+                              $(BACKEND) $(LIBS) m2/gm2-gcc/rtegraph.o m2/gm2-libs-boot/M2LINK.o \
+                              $(BACKENDLIBS) $(LIBSTDCXX) -lm
+	@$(call LINK_PROGRESS,$(INDEX.m2),end)
+
+stage1/m2/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$(exeext).so \
+                            m2/gm2-libs-boot/M2LINK.o \
+                            $(m2.prev)
+	@$(call LINK_PROGRESS,$(INDEX.m2),start)
+	+$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler-boot/m2flex.o \
+                            attribs.o \
+                             $(GM2_LIBS_BOOT) $(MC_LIBS) \
+                             m2/gm2-gcc/rtegraph.o m2/gm2-libs-boot/M2LINK.o \
+                             $(BACKEND) $(LIBS) $(BACKENDLIBS)
+	@$(call LINK_PROGRESS,$(INDEX.m2),end)
+
+# Compiling object files from source files.
+
+GCC_HEADER_DEPENDENCIES_FOR_M2 = $(BUILD-BOOT-H) $(TIMEVAR_H) m2/gm2config.h $(CONFIG_H) \
+        $(TREE_H) $(RTL_H) $(TARGET_H) $(PLUGIN_HEADERS) \
+        $(BCONFIG_H) $(CORETYPES_H) $(SYSTEM_H) \
+        $(srcdir)/flags.h gtype-m2.h \
+        $(generated_files) insn-attr-common.h
+
+m2/gm2-gcc/%.o: $(srcdir)/m2/gm2-gcc/%.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2)
+	$(COMPILER) -c -g $(ALL_COMPILERFLAGS) \
+             $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
+
+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
+	$(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
+         $(DRIVER_DEFINES) \
+		-DLIBSUBDIR=\"$(libsubdir)\" \
+                -DPREFIX=\"$(prefix)\" \
+                -c $(srcdir)/m2/gm2-gcc/m2configure.cc $(OUTPUT_OPTION)
+
+m2/gm2-lang.o: $(srcdir)/m2/gm2-lang.cc gt-m2-gm2-lang.h $(GCC_HEADER_DEPENDENCIES_FOR_M2)
+	$(COMPILER) -c -g -I$(GM2GCC) $(ALL_COMPILERFLAGS) \
+            $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
+
+m2/stor-layout.o: $(srcdir)/stor-layout.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2)
+	$(COMPILER) -c -DSET_WORD_SIZE=INT_TYPE_SIZE $(ALL_COMPILERFLAGS) \
+            $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
+
+m2/m2pp.o : $(srcdir)/m2/m2pp.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2)
+	$(COMPILER) -c -g -DGM2 $(ALL_COMPILERFLAGS) \
+            $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
+
+m2/gm2-gcc/rtegraph.o: $(srcdir)/m2/gm2-gcc/rtegraph.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2) \
+                       gt-m2-rtegraph.h
+	$(COMPILER) -c -g -I$(GM2GCC) $(ALL_COMPILERFLAGS) \
+            $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
+
+c-family/m2pp.o : $(srcdir)/m2/m2pp.cc $(GCC_HEADER_DEPENDENCIES_FOR_M2)
+	$(COMPILER) -c -g $(ALL_COMPILERFLAGS) \
+            $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
+
+m2/gm2-gcc/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-gcc/%.def $(MCDEPS)
+	$(MC) -o=$@ $(srcdir)/m2/gm2-gcc/$*.def
+
+# The following tables define the source files which are translated into C using mc
+# and defines the system interface C files.
+
+# Core library definition modules found in gm2-libs.
+
+GM2-LIBS-BOOT-DEFS = \
+   ASCII.def \
+   Args.def \
+   Assertion.def \
+   Break.def \
+   CmdArgs.def \
+   Debug.def \
+   DynamicStrings.def \
+   Environment.def \
+   FIO.def \
+   FormatStrings.def \
+   FpuIO.def \
+   IO.def \
+   Indexing.def \
+   M2Dependent.def \
+   M2EXCEPTION.def \
+   M2LINK.def \
+   M2RTS.def \
+   NumberIO.def \
+   PushBackInput.def \
+   RTExceptions.def \
+   SArgs.def \
+   SEnvironment.def \
+   SFIO.def \
+   SYSTEM.def \
+   Scan.def \
+   StdIO.def \
+   Storage.def \
+   StrCase.def \
+   StrIO.def \
+   StrLib.def \
+   StringConvert.def \
+   SysExceptions.def \
+   SysStorage.def \
+   TimeString.def \
+   UnixArgs.def \
+   dtoa.def \
+   errno.def \
+   ldtoa.def \
+   libc.def \
+   libm.def \
+   termios.def \
+   wrapc.def \
+
+# Core library implementation modules found in gm2-libs.
+
+GM2-LIBS-BOOT-MODS = \
+   ASCII.mod \
+   Args.mod \
+   Assertion.mod \
+   Break.mod \
+   CmdArgs.mod \
+   Debug.mod \
+   DynamicStrings.mod \
+   Environment.mod \
+   FIO.mod \
+   FormatStrings.mod \
+   FpuIO.mod \
+   IO.mod \
+   Indexing.mod \
+   M2Dependent.mod \
+   M2EXCEPTION.mod \
+   M2RTS.mod \
+   NumberIO.mod \
+   PushBackInput.mod \
+   RTExceptions.mod \
+   SArgs.mod \
+   SEnvironment.mod \
+   SFIO.mod \
+   Scan.mod \
+   Storage.mod \
+   StrCase.mod \
+   StrIO.mod \
+   StrLib.mod \
+   StringConvert.mod \
+   SysStorage.mod \
+   TimeString.mod \
+
+# Hand translated C files and C files for definition module for "C" modules
+# found in gm2-libs-ch.
+
+GM2-LIBS-BOOT-C = \
+   StdIO.c \
+   SysExceptions.c \
+   choosetemp.c \
+   errno.c \
+   termios.c \
+   wrapc.c \
+
+# C++ implemented modules found in gm2-libs-ch.
+
+GM2-LIBS-BOOT-CC = \
+   UnixArgs.cc \
+   dtoa.cc \
+   ldtoa.cc
+
+# Definition modules for the front end found in gm2-compiler.
+
+GM2-COMP-BOOT-DEFS = \
+   FifoQueue.def \
+   Lists.def \
+   M2ALU.def \
+   M2AsmUtil.def \
+   M2Base.def \
+   M2BasicBlock.def \
+   M2Batch.def \
+   M2Bitset.def \
+   M2CaseList.def \
+   M2Check.def \
+   M2Code.def \
+   M2ColorString.def \
+   M2Comp.def \
+   M2Const.def \
+   M2Debug.def \
+   M2DebugStack.def \
+   M2Defaults.def \
+   M2DriverOptions.def \
+   M2Emit.def \
+   M2Error.def \
+   M2EvalSym.def \
+   M2FileName.def \
+   M2GCCDeclare.def \
+   M2GenGCC.def \
+   M2Graph.def \
+   M2LexBuf.def \
+   M2MetaError.def \
+   M2Optimize.def \
+   M2Options.def \
+   M2Pass.def \
+   M2Preprocess.def \
+   M2Printf.def \
+   M2Quads.def \
+   M2Quiet.def \
+   M2Range.def \
+   M2Reserved.def \
+   M2SSA.def \
+   M2Scaffold.def \
+   M2Scope.def \
+   M2Search.def \
+   M2Size.def \
+   M2StackAddress.def \
+   M2StackWord.def \
+   M2Students.def \
+   M2Swig.def \
+   M2System.def \
+   NameKey.def \
+   ObjectFiles.def \
+   Output.def \
+   P0SymBuild.def \
+   P0SyntaxCheck.def \
+   P1Build.def \
+   P1SymBuild.def \
+   P2Build.def \
+   P2SymBuild.def \
+   P3Build.def \
+   P3SymBuild.def \
+   PCBuild.def \
+   PCSymBuild.def \
+   PHBuild.def \
+   Sets.def \
+   SymbolConversion.def \
+   SymbolKey.def \
+   SymbolTable.def \
+   bnflex.def \
+   m2flex.def \
+
+# Implementation modules for the front end found in gm2-compiler.
+
+GM2-COMP-BOOT-MODS = \
+   FifoQueue.mod \
+   Lists.mod \
+   Lists.mod \
+   M2ALU.mod \
+   M2AsmUtil.mod \
+   M2Base.mod \
+   M2BasicBlock.mod \
+   M2Batch.mod \
+   M2Bitset.mod \
+   M2CaseList.mod \
+   M2Check.mod \
+   M2Code.mod \
+   M2ColorString.mod \
+   M2Comp.mod \
+   M2Const.mod \
+   M2Debug.mod \
+   M2DebugStack.mod \
+   M2Defaults.mod \
+   M2DriverOptions.mod \
+   M2Emit.mod \
+   M2Error.mod \
+   M2FileName.mod \
+   M2GCCDeclare.mod \
+   M2GenGCC.mod \
+   M2Graph.mod \
+   M2LexBuf.mod \
+   M2MetaError.mod \
+   M2Optimize.mod \
+   M2Options.mod \
+   M2Pass.mod \
+   M2Preprocess.mod \
+   M2Printf.mod \
+   M2Quads.mod \
+   M2Quiet.mod \
+   M2Range.mod \
+   M2Reserved.mod \
+   M2SSA.mod \
+   M2Scaffold.mod \
+   M2Scope.mod \
+   M2Search.mod \
+   M2Size.mod \
+   M2StackAddress.mod \
+   M2StackWord.mod \
+   M2Students.mod \
+   M2Swig.mod \
+   M2System.mod \
+   NameKey.mod \
+   NameKey.mod \
+   ObjectFiles.mod \
+   Output.mod \
+   P0SymBuild.mod \
+   P1SymBuild.mod \
+   P2SymBuild.mod \
+   P3SymBuild.mod \
+   PCSymBuild.mod \
+   Sets.mod \
+   SymbolConversion.mod \
+   SymbolKey.mod \
+   SymbolKey.mod \
+   SymbolTable.mod \
+   bnflex.mod \
+
+# The interface between the modula-2 front end and gimple/trees found in directory gm2-gcc.
+
+GM2-GCC-DEFS = \
+   m2block.def \
+   m2builtins.def \
+   m2color.def \
+   m2configure.def \
+   m2convert.def \
+   m2decl.def \
+   m2except.def \
+   m2except.def \
+   m2expr.def \
+   m2linemap.def \
+   m2misc.def \
+   m2statement.def \
+   m2top.def \
+   m2tree.def \
+   m2treelib.def \
+   m2type.def \
+
+# The following lists define the source files used to build gm2 using Modula-2
+# sources directly.
+#
+# cc1gm2$(exeext) uses these definition modules from the core libraries.
+
+GM2-LIBS-DEFS = \
+   ASCII.def \
+   Args.def \
+   Assertion.def \
+   Break.def \
+   Builtins.def \
+   COROUTINES.def \
+   CmdArgs.def \
+   Debug.def \
+   DynamicStrings.def \
+   Environment.def \
+   FIO.def \
+   FormatStrings.def \
+   FpuIO.def \
+   GetOpt.def \
+   IO.def \
+   Indexing.def \
+   LMathLib0.def \
+   LegacyReal.def \
+   M2Dependent.def \
+   M2EXCEPTION.def \
+   M2LINK.def \
+   M2RTS.def \
+   MathLib0.def \
+   MemUtils.def \
+   NumberIO.def \
+   PushBackInput.def \
+   RTExceptions.def \
+   RTint.def \
+   SArgs.def \
+   SEnvironment.def \
+   SFIO.def \
+   SMathLib0.def \
+   SYSTEM.def \
+   Scan.def \
+   StdIO.def \
+   Storage.def \
+   StrCase.def \
+   StrIO.def \
+   StrLib.def \
+   StringConvert.def \
+   SysStorage.def \
+   TimeString.def \
+   UnixArgs.def \
+   cbuiltin.def \
+   dtoa.def \
+   ldtoa.def \
+   libc.def \
+   termios.def \
+   wrapc.def \
+
+# cc1gm2$(exeext) uses these implementation modules from the core libraries.
+
+GM2-LIBS-MODS = \
+   ASCII.mod \
+   Args.mod \
+   Assertion.mod \
+   Break.mod \
+   Builtins.mod \
+   COROUTINES.mod \
+   CmdArgs.mod \
+   Debug.mod \
+   DynamicStrings.mod \
+   Environment.mod \
+   FIO.mod \
+   FormatStrings.mod \
+   FpuIO.mod \
+   GetOpt.mod \
+   IO.mod \
+   Indexing.mod \
+   LMathLib0.mod \
+   LegacyReal.mod \
+   M2Dependent.mod \
+   M2EXCEPTION.mod \
+   M2RTS.mod \
+   MathLib0.mod \
+   MemUtils.mod \
+   NumberIO.mod \
+   PushBackInput.mod \
+   RTExceptions.mod \
+   RTint.mod \
+   SArgs.mod \
+   SEnvironment.mod \
+   SFIO.mod \
+   SMathLib0.mod \
+   SYSTEM.mod \
+   Scan.mod \
+   StdIO.mod \
+   Storage.mod \
+   StrCase.mod \
+   StrIO.mod \
+   StrLib.mod \
+   StringConvert.mod \
+   SysStorage.mod \
+   TimeString.mod \
+
+# cc1gm2$(exeext) uses these C modules from the core libraries.
+
+GM2-LIBS-C = \
+   Selective.c \
+   SysExceptions.c \
+   cgetopt.c \
+   choosetemp.c \
+   errno.c \
+   host.c \
+   termios.c \
+   wrapc.c \
+
+# cc1gm2$(exeext) uses these C++ modules from the core libraries.
+
+GM2-LIBS-CC = \
+   UnixArgs.cc \
+   dtoa.cc \
+   ldtoa.cc \
+
+# cc1gm2$(exeext) uses these definition modules found in the gm2-compiler directory.
+
+GM2-COMP-DEFS = \
+   FifoQueue.def \
+   Lists.def \
+   M2ALU.def \
+   M2AsmUtil.def   \
+   M2Base.def \
+   M2BasicBlock.def \
+   M2Batch.def \
+   M2Bitset.def \
+   M2CaseList.def \
+   M2Check.def \
+   M2Code.def \
+   M2ColorString.def \
+   M2Comp.def \
+   M2Const.def \
+   M2Debug.def \
+   M2DebugStack.def \
+   M2Defaults.def \
+   M2DriverOptions.def \
+   M2Emit.def \
+   M2Error.def \
+   M2FileName.def \
+   M2GCCDeclare.def \
+   M2GenGCC.def \
+   M2Graph.def \
+   M2LexBuf.def \
+   M2MetaError.def \
+   M2Optimize.def \
+   M2Options.def \
+   M2Pass.def \
+   M2Preprocess.def \
+   M2Printf.def \
+   M2Quads.def     \
+   M2Quiet.def \
+   M2Range.def \
+   M2Reserved.def \
+   M2SSA.def \
+   M2Scaffold.def \
+   M2Scope.def \
+   M2Search.def \
+   M2Size.def \
+   M2StackAddress.def \
+   M2StackWord.def \
+   M2Students.def \
+   M2Swig.def \
+   M2System.def \
+   NameKey.def \
+   ObjectFiles.def \
+   P0SymBuild.def \
+   P0SyntaxCheck.def \
+   P1Build.def \
+   P1SymBuild.def \
+   P2Build.def \
+   P2SymBuild.def \
+   P3Build.def \
+   P3SymBuild.def \
+   PCBuild.def \
+   PCSymBuild.def \
+   PHBuild.def \
+   Sets.def \
+   SymbolConversion.def \
+   SymbolKey.def \
+   SymbolTable.def \
+   bnflex.def \
+
+# cc1gm2$(exeext) uses these implementation modules found in the gm2-compiler directory.
+
+GM2-COMP-MODS = \
+   FifoQueue.mod \
+   Lists.mod \
+   M2ALU.mod \
+   M2AsmUtil.mod \
+   M2Base.mod \
+   M2BasicBlock.mod \
+   M2Batch.mod \
+   M2Bitset.mod \
+   M2CaseList.mod \
+   M2Check.mod \
+   M2Code.mod \
+   M2ColorString.mod \
+   M2Comp.mod \
+   M2Const.mod \
+   M2Debug.mod \
+   M2DebugStack.mod \
+   M2Defaults.mod \
+   M2DriverOptions.mod \
+   M2Emit.mod \
+   M2Error.mod \
+   M2FileName.mod \
+   M2GCCDeclare.mod \
+   M2GenGCC.mod \
+   M2Graph.mod \
+   M2LexBuf.mod \
+   M2MetaError.mod \
+   M2Optimize.mod \
+   M2Options.mod \
+   M2Pass.mod \
+   M2Preprocess.mod \
+   M2Printf.mod \
+   M2Quads.mod \
+   M2Quiet.mod \
+   M2Range.mod \
+   M2Reserved.mod \
+   M2SSA.mod \
+   M2Scaffold.mod \
+   M2Scope.mod \
+   M2Search.mod \
+   M2Size.mod \
+   M2StackAddress.mod \
+   M2StackWord.mod \
+   M2Students.mod \
+   M2Swig.mod \
+   M2System.mod \
+   NameKey.mod \
+   ObjectFiles.mod \
+   Output.mod \
+   P0SymBuild.mod \
+   P1SymBuild.mod \
+   P2SymBuild.mod  \
+   P3SymBuild.mod  \
+   PCSymBuild.mod \
+   Sets.mod \
+   SymbolConversion.mod \
+   SymbolKey.mod \
+   SymbolTable.mod \
+   bnflex.mod \
+
+# Implementation modules created by the parser generator pge from .bnf files.
+
+GM2-AUTO-MODS = \
+   P2Build.mod \
+   P3Build.mod \
+   PHBuild.mod \
+   PCBuild.mod \
+   P1Build.mod \
+   P0SyntaxCheck.mod \
+
+# LIBIBERTY interface definition modules
+
+GM2-LIBIBERTY-DEFS = \
+   choosetemp.def \
+   pexecute.def
+
+BUILD-LIBS-BOOT-H = $(GM2-LIBS-BOOT-DEFS:%.def=m2/gm2-libs-boot/$(SRC_PREFIX)%.h)
+
+BUILD-LIBS-BOOT = $(BUILD-LIBS-BOOT-H) \
+                  $(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)
+
+BUILD-COMPILER-BOOT-H = $(GM2-COMP-BOOT-DEFS:%.def=m2/gm2-compiler-boot/$(SRC_PREFIX)%.h) \
+                        $(GM2-LIBIBERTY-DEFS:%.def=m2/gm2-libiberty/$(SRC_PREFIX)%.h) \
+                        $(GM2-GCC-DEFS:%.def=m2/gm2-gcc/$(SRC_PREFIX)%.h)
+
+BUILD-COMPILER-BOOT = $(BUILD-COMPILER-BOOT-H) \
+                      $(GM2-COMP-BOOT-DEFS:%.def=m2/gm2-compiler-boot/$(SRC_PREFIX)%.h) \
+                      $(GM2-AUTO-MODS:%.mod=m2/gm2-compiler-boot/%.o) \
+                      $(GM2-COMP-BOOT-MODS:%.mod=m2/gm2-compiler-boot/%.o) \
+                      m2/gm2-compiler-boot/m2flex.o
+
+BUILD-BOOT-H = m2/boot-bin/mc$(exeext) \
+               $(BUILD-LIBS-BOOT-H) $(BUILD-COMPILER-BOOT-H) $(TARGET_H) $(PLUGIN_HEADERS)
+
+# Core library definition modules used by the modula-2 to C++ translator.
+
+MC-LIB-DEFS = \
+   ASCII.def \
+   Args.def \
+   Assertion.def \
+   Break.def  \
+   COROUTINES.def \
+   CmdArgs.def \
+   Debug.def \
+   DynamicStrings.def \
+   Environment.def \
+   FIO.def \
+   FormatStrings.def \
+   FpuIO.def \
+   IO.def \
+   M2Dependent.def \
+   M2EXCEPTION.def \
+   M2LINK.def \
+   M2RTS.def \
+   MemUtils.def \
+   NumberIO.def \
+   PushBackInput.def \
+   RTExceptions.def \
+   RTco.def \
+   RTint.def \
+   SArgs.def \
+   SFIO.def \
+   SYSTEM.def \
+   Selective.def \
+   StdIO.def \
+   Storage.def \
+   StrCase.def \
+   StrIO.def \
+   StrLib.def \
+   StringConvert.def \
+   SysExceptions.def \
+   SysStorage.def \
+   TimeString.def \
+   UnixArgs.def \
+   dtoa.def \
+   errno.def \
+   ldtoa.def \
+   libc.def \
+   libm.def \
+   termios.def \
+   wrapc.def \
+
+# Core library implementation modules used by the modula-2 to C++ translator.
+
+MC-LIB-MODS = \
+   ASCII.mod \
+   Args.mod \
+   Assertion.mod \
+   Break.mod  \
+   CmdArgs.mod \
+   Debug.mod \
+   DynamicStrings.mod \
+   Environment.mod \
+   FIO.mod \
+   FormatStrings.mod \
+   FpuIO.mod \
+   IO.mod \
+   M2Dependent.mod \
+   M2EXCEPTION.mod \
+   M2RTS.mod \
+   MemUtils.mod \
+   NumberIO.mod \
+   PushBackInput.mod \
+   RTExceptions.mod \
+   RTint.mod \
+   SArgs.mod \
+   SFIO.mod \
+   StdIO.mod \
+   Storage.mod \
+   StrCase.mod \
+   StrIO.mod \
+   StrLib.mod \
+   StringConvert.mod \
+   SysStorage.mod \
+   TimeString.mod \
+
+MC-LIB-BOOT-C = $(MC-LIB-MODS:%.mod=%.c)
+
+# Definition modules for the modula-2 to C++ translator found in mc.
+
+MC-DEFS = \
+   Indexing.def \
+   alists.def \
+   decl.def \
+   keyc.def \
+   lists.def \
+   mcComment.def \
+   mcComp.def \
+   mcDebug.def \
+   mcError.def \
+   mcFileName.def \
+   mcLexBuf.def \
+   mcMetaError.def \
+   mcOptions.def \
+   mcPreprocess.def \
+   mcPretty.def \
+   mcPrintf.def \
+   mcQuiet.def \
+   mcReserved.def \
+   mcSearch.def \
+   mcStack.def \
+   mcStream.def \
+   mcflex.def \
+   mcp1.def \
+   mcp2.def \
+   mcp3.def \
+   mcp4.def \
+   mcp5.def  \
+   nameKey.def \
+   symbolKey.def \
+   varargs.def \
+   wlists.def \
+
+# Implementation modules for the modula-2 to C++ translator found in mc.
+
+MC-MODS = \
+   Indexing.mod \
+   alists.mod \
+   decl.mod \
+   keyc.mod \
+   lists.mod \
+   mcComment.mod \
+   mcComp.mod \
+   mcDebug.mod \
+   mcError.mod \
+   mcFileName.mod \
+   mcLexBuf.mod \
+   mcMetaError.mod \
+   mcOptions.mod \
+   mcPreprocess.mod \
+   mcPretty.mod \
+   mcPrintf.mod \
+   mcQuiet.mod \
+   mcReserved.mod \
+   mcSearch.mod \
+   mcStack.mod \
+   mcStream.mod \
+   nameKey.mod \
+   symbolKey.mod \
+   top.mod \
+   varargs.mod \
+   wlists.mod \
+
+# Parser files generated by pge from .bnf files.
+
+MC-AUTO-MODS = \
+   mcp1.mod \
+   mcp2.mod \
+   mcp3.mod \
+   mcp4.mod \
+   mcp5.mod
+
+MC-BOOT-C = $(MC-MODS:%.mod=%.c) $(MC-AUTO-MODS:%.mod=%.c)
+
+# C interface files for mc.
+
+MC-INTERFACE-C = \
+   M2LINK.c \
+   SYSTEM.c \
+   Selective.c \
+   SysExceptions.c \
+   abort.c \
+   errno.c \
+   libc.c \
+   mcrts.c \
+   termios.c \
+   wrapc.c \
+
+# C++ interface files for mc.
+
+MC-INTERFACE-CC = \
+   UnixArgs.cc \
+   dtoa.cc \
+   ldtoa.cc \
+
+BUILD-MC-BOOT-H =  $(MC-LIB-DEFS:%.def=m2/mc-boot-gen/$(SRC_PREFIX)%.h) \
+                   $(MC-DEFS:%.def=m2/mc-boot-gen/$(SRC_PREFIX)%.h)
+
+BUILD-MC-BOOT-C =  $(MC-LIB-MODS:%.mod=m2/mc-boot-gen/$(SRC_PREFIX)%.c) \
+                   $(MC-MODS:%.mod=m2/mc-boot-gen/$(SRC_PREFIX)%.c)
+
+BUILD-MC-BOOT-AUTO-C = $(MC-AUTO-MODS:%.mod=m2/mc-boot-gen/$(SRC_PREFIX)%.c)
+
+BUILD-MC-BOOT-O =  $(MC-LIB-BOOT-C:%.c=m2/mc-boot/$(SRC_PREFIX)%.o) \
+                   $(MC-BOOT-C:%.c=m2/mc-boot/$(SRC_PREFIX)%.o)
+
+BUILD-MC-INTERFACE-O = $(MC-INTERFACE-C:%.c=m2/mc-boot-ch/$(SRC_PREFIX)%.o) \
+                       $(MC-INTERFACE-CC:%.cc=m2/mc-boot-ch/$(SRC_PREFIX)%.o)
+
+GM2GCC = -I$(srcdir)/m2 -Im2 -I$(srcdir)/m2/gm2-gcc -Im2/gm2-gcc
+
+MCINCLUDES= -I$(srcdir)/m2/mc-boot-ch
+LOCAL_INCLUDES = -I. -I$(srcdir)/../include -I$(srcdir)
+
+GCC_COLOR=m2/gm2-gcc/m2color.o diagnostic-color.o
+
+m2/boot-bin/mc$(exeext): $(BUILD-MC-BOOT-O) $(BUILD-MC-INTERFACE-O) \
+        m2/mc-boot/main.o mcflex.o m2/gm2-libs-boot/RTcodummy.o
+	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-MC-BOOT-O) \
+         $(BUILD-MC-INTERFACE-O) m2/mc-boot/main.o \
+         mcflex.o m2/gm2-libs-boot/RTcodummy.o -lm
+
+m2/mc-boot/$(SRC_PREFIX)%.o: m2/mc-boot/$(SRC_PREFIX)%.c
+	$(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
+	$(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
+	$(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
+	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 $@
+
+mcflex.o: mcflex.c
+	$(CC) -I$(srcdir)/m2/mc -g -c $< -o $@   # remember that mcReserved.h is copied into m2/mc
+
+mcflex.c: $(srcdir)/m2/mc/mc.flex
+	flex -t $< > $@
+
+m2/gm2-libs-boot/%.o: $(srcdir)/m2/gm2-libs-boot/%.mod $(MCDEPS) $(BUILD-BOOT-H)
+	$(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)
+	$(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)
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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)
+	$(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)
+	$(MC) --extended-opaque -o=m2/gm2-compiler-boot/M2GCCDeclare.c $<
+	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
+            -I. -I$(srcdir)/../include -I$(srcdir) \
+            -I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot \
+            -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)
+	$(MC) --extended-opaque -o=m2/gm2-compiler-boot/M2Error.c $<
+	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) \
+            -I. -I$(srcdir)/../include -I$(srcdir) \
+            -I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot \
+            -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)
+	$(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) \
+            -I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot -Im2/gm2-libiberty \
+            -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)
+	$(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) \
+            -I. -Im2/gm2-libs-boot -Im2/gm2-compiler-boot \
+            -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)
+	$(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)
+	$(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
+	flex -t $< | sed -e 's/ malloc/ xmalloc/' | sed -e 's/ realloc/ xrealloc/' > $@
+
+m2/gm2-libiberty/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libiberty/%.def $(MCDEPS)
+	$(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
+	$(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)
+	$(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
+	$(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
+	$(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
+	$(GM2_1) $(GM2_ISO_FLAGS) -c -B./ -Im2/gm2-libs-iso:$(srcdir)/m2/gm2-libs-iso -I$(srcdir)/m2/gm2-libs $< -o $@
+
+
+# We build the cc1gm2$(exeext) from the boot stage and then proceed to build it
+# again using itself.
+
+m2/gm2-libs/gm2-libs-host.h:
+	echo "Configuring to build libraries using native compiler" ; \
+        NEW_SRCDIR=`${srcdir}/m2/tools-src/calcpath ../../ ${srcdir} m2/gm2-libs` ; \
+        export NEW_SRCDIR ; \
+        cd m2/gm2-libs ; \
+        $(SHELL) -c '$${NEW_SRCDIR}/config-host \
+               --srcdir=$${NEW_SRCDIR} \
+               --target=$(target) \
+               --program-suffix=$(exeext)'
+
+# Autoconf inserts -DCROSS_DIRECTORY_STRUCTURE if we are building a
+# cross compiler and the ../Makefile.in above appends this to INTERNAL_CFLAGS.
+
+m2/gm2config.h:
+	NEW_SRCDIR=`${srcdir}/m2/tools-src/calcpath ../ ${srcdir} m2` ; \
+        export NEW_SRCDIR ; \
+	cd m2 ; \
+	if echo $(INTERNAL_CFLAGS) | grep \\-DCROSS_DIRECTORY_STRUCTURE; then \
+            AR=$(echo $(AR_FOR_TARGET) | sed -e "s/^ //") ; \
+            export AR ; \
+            RANLIB=$(echo $(RANLIB_FOR_TARGET) | sed -e "s/^ //") ; \
+            export RANLIB ; \
+            $(SHELL) -c '$${NEW_SRCDIR}/configure --srcdir=$${NEW_SRCDIR} \
+                --target=$(target) --program-suffix=$(exeext) \
+                --includedir=$(SYSTEM_HEADER_DIR) --libdir=$(libdir) \
+                --libexecdir=$(libexecdir)' ; \
+        else \
+            $(SHELL) -c '$${NEW_SRCDIR}/configure --srcdir=$(NEW_SRCDIR) \
+                --target=$(target) --program-suffix=$(exeext)' ; \
+        fi
+
+$(objdir)/m2/gm2-libs-min/SYSTEM.def: $(GM2_PROG_DEP)
+	$(SHELL) $(srcdir)/m2/tools-src/makeSystem -fpim \
+             $(srcdir)/m2/gm2-libs-min/SYSTEM.def \
+             $(srcdir)/m2/gm2-libs-min/SYSTEM.mod \
+             -I$(srcdir)/m2/gm2-libs-min:$(srcdir)/m2/gm2-libs \
+             "$(GM2_FOR_TARGET)" $@
+
+$(objdir)/m2/gm2-libs/SYSTEM.def: $(GM2_PROG_DEP)
+	echo "GM2_FOR_TARGET $(GM2_FOR_TARGET)"
+	echo "GCC_FOR_TARGET $(GCC_FOR_TARGET)"
+	$(SHELL) $(srcdir)/m2/tools-src/makeSystem -fpim \
+             $(srcdir)/m2/gm2-libs/SYSTEM.def \
+             $(srcdir)/m2/gm2-libs/SYSTEM.mod \
+             -I$(srcdir)/m2/gm2-libs \
+             "$(GM2_FOR_TARGET)" $@
+
+$(objdir)/m2/gm2-libs-iso/SYSTEM.def: $(GM2_PROG_DEP)
+	$(SHELL) $(srcdir)/m2/tools-src/makeSystem -fiso \
+             $(srcdir)/m2/gm2-libs-iso/SYSTEM.def \
+             $(srcdir)/m2/gm2-libs-iso/SYSTEM.mod \
+             -I$(srcdir)/m2/gm2-libs-iso:$(srcdir)/m2/gm2-libs \
+             "$(GM2_FOR_TARGET)" $@
+
+$(objdir)/m2/gm2-libs-coroutines/SYSTEM.def: $(GM2_PROG_DEP)
+	$(SHELL) $(srcdir)/m2/tools-src/makeSystem -fpim \
+             $(srcdir)/m2/gm2-libs-coroutines/SYSTEM.def \
+             $(srcdir)/m2/gm2-libs-coroutines/SYSTEM.mod \
+             -I$(srcdir)/m2/gm2-libs-coroutines:$(srcdir)/m2/gm2-libs-iso:$(srcdir)/m2/gm2-libs \
+             "$(GM2_FOR_TARGET)" $@
+
+build-compiler: $(GM2-COMP-MODS:%.mod=m2/gm2-compiler/%.o) \
+                $(GM2-AUTO-MODS:%.mod=m2/gm2-compiler/%.o) \
+                m2/gm2-compiler/m2flex.o
+
+m2/gm2-compiler/gm2.a: build-compiler gm2$(exeext)
+	$(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)
+	$(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)
+	$(RANLIB) $@
+
+m2/gm2-compiler-boot/gm2.a: m2/boot-bin/mc$(exeext) m2/boot-bin/mklink$(exeext) \
+                         $(BUILD-LIBS-BOOT) $(BUILD-COMPILER-BOOT)
+	$(AR) cr $@ $(GM2-COMP-BOOT-MODS:%.mod=m2/gm2-compiler-boot/%.o) \
+                    $(GM2-AUTO-MODS:%.mod=m2/gm2-compiler-boot/%.o)
+	$(RANLIB) $@
+
+m2/gm2-compiler-boot/gm2.a: m2/boot-bin/mc$(exeext)
+
+m2/boot-bin/mklink$(exeext): $(srcdir)/m2/tools-src/mklink.c
+	$(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)
+	$(MC) --quiet -o=$@ $(srcdir)/m2/gm2-compiler-boot/$*.def
+
+m2/gm2-compiler/%.mod: $(srcdir)/m2/gm2-compiler/%.bnf $(PGE)
+	$(PGE) -k -l $< -o $@
+
+m2/gm2-compiler-boot/%.mod: $(srcdir)/m2/gm2-compiler/%.bnf $(PGE)
+	$(PGE) -k -l $< -o $@
+
+check-m2: check-gm2
+check_m2: check-gm2
+check_gm2: check-gm2
+check-modula2: check-gm2
+check_modula2: check-gm2
+check-modula-2: check-gm2
+check_modula-2: check-gm2
+check_modula_2: check-gm2
+
+lang_checks += check-gm2
+lang_checks_parallelized += check-gm2
+# For description see the check_$lang_parallelize comment in gcc/Makefile.in.
+check_gm2_parallelize = 10000
+
+check-gm2-local: $(GM2TESTSUITEDIR)/site.exp
+	-(rootme=`${PWD_COMMAND}`; export rootme; \
+	srcdir=`cd ${srcdir}; ${PWD_COMMAND}` ; export srcdir ; \
+	cd $(TESTSUITEDIR); \
+	EXPECT=${EXPECT} ; export EXPECT ; \
+	if [ -f $${rootme}/../expect/expect ] ; then  \
+	   TCL_LIBRARY=`cd .. ; cd ${srcdir}/../tcl/library ; ${PWD_COMMAND}` ; \
+	    export TCL_LIBRARY ; fi ; \
+	$(RUNTEST) --tool gm2 --directory testsuite/m2/pim/pass)
+
+BUILD-PGE-O = \
+   m2/pge-boot/GArgs.o \
+   m2/pge-boot/GASCII.o \
+   m2/pge-boot/GAssertion.o \
+   m2/pge-boot/Gbnflex.o \
+   m2/pge-boot/GDebug.o \
+   m2/pge-boot/GDynamicStrings.o \
+   m2/pge-boot/GFIO.o \
+   m2/pge-boot/GIndexing.o \
+   m2/pge-boot/GIO.o \
+   m2/pge-boot/GLists.o \
+   m2/pge-boot/GM2Dependent.o \
+   m2/pge-boot/GM2EXCEPTION.o \
+   m2/pge-boot/GM2RTS.o \
+   m2/pge-boot/GNameKey.o \
+   m2/pge-boot/GNumberIO.o \
+   m2/pge-boot/GOutput.o \
+   m2/pge-boot/Gpge.o \
+   m2/pge-boot/GPushBackInput.o \
+   m2/pge-boot/GRTExceptions.o \
+   m2/pge-boot/GSFIO.o \
+   m2/pge-boot/GStdIO.o \
+   m2/pge-boot/GStorage.o \
+   m2/pge-boot/GStrCase.o \
+   m2/pge-boot/GStrIO.o \
+   m2/pge-boot/GStrLib.o \
+   m2/pge-boot/GSymbolKey.o \
+   m2/pge-boot/GSysStorage.o \
+   m2/pge-boot/Glibc.o \
+   m2/pge-boot/Gerrno.o \
+   m2/pge-boot/GUnixArgs.o \
+   m2/pge-boot/GM2LINK.o \
+   m2/pge-boot/Gtermios.o \
+   m2/pge-boot/GSysExceptions.o \
+   m2/pge-boot/Gabort.o \
+   m2/pge-boot/Gmcrts.o \
+   m2/pge-boot/main.o
+
+ifeq ($(M2_MAINTAINER),yes)
+include m2/Make-maintainer
+else
+m2/pge-boot/%.o: m2/pge-boot/%.c m2/gm2-libs/gm2-libs-host.h
+	$(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
+	$(CXX) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@
+
+$(PGE): $(BUILD-PGE-O)
+	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-PGE-O) -lm
+
+endif
diff -ruw /dev/null gcc-git-devel-modula2/gcc/m2/Make-maintainer.in
--- /dev/null	2022-08-24 16:22:16.888000070 +0100
+++ gcc-git-devel-modula2/gcc/m2/Make-maintainer.in	2022-12-14 06:54:59.636965403 +0000
@@ -0,0 +1,856 @@ 
+# Make-maintainer.in build support tools for GNU M2.
+
+# Copyright (C) 2022 Free Software Foundation, Inc.
+
+#This file is part of GCC.
+
+#GCC is free software; you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation; either version 3, or (at your option)
+#any later version.
+
+#GCC is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#GNU General Public License for more details.
+
+#You should have received a copy of the GNU General Public License
+#along with GCC; see the file COPYING3.  If not see
+#<http://www.gnu.org/licenses/>.
+
+# QUIAT=@
+XGCC = ./xgcc -B./
+GM2_2 = ./gm2 -B./stage2/m2 -g -fm2-g
+
+# m2/ppg$(exeext)  is the recursive descent parser generator.
+
+PPG-INTERFACE-C = libc.c mcrts.c Selective.c termios.c \
+                  SysExceptions.c wrapc.c \
+                  SYSTEM.c errno.c
+
+PPG-INTERFACE-CC = UnixArgs.cc ldtoa.cc dtoa.cc
+
+# Implementation modules found in the gm2-compiler directory.
+
+PPG-MODS         = SymbolKey.mod   NameKey.mod  Lists.mod  bnflex.mod  Output.mod
+
+# Core library definition modules used by ppg found in the gm2-libs directory.
+
+PPG-LIB-DEFS     = Args.def Assertion.def ASCII.def Debug.def \
+                   DynamicStrings.def FIO.def Indexing.def IO.def \
+                   NumberIO.def PushBackInput.def \
+                   M2Dependent.def \
+                   M2EXCEPTION.def M2LINK.def M2RTS.def \
+                   RTExceptions.def \
+                   StdIO.def SFIO.def StrIO.def StrLib.def \
+                   Storage.def StrCase.def SysStorage.def
+
+# Core library implementation modules used by ppg found in the gm2-libs directory.
+
+PPG-LIB-MODS     = ASCII.mod \
+                   Args.mod \
+                   Assertion.mod \
+                   Debug.mod \
+                   DynamicStrings.mod \
+                   FIO.mod \
+                   IO.mod \
+                   Indexing.mod \
+                   M2Dependent.mod \
+                   M2EXCEPTION.mod \
+                   M2RTS.mod \
+                   NumberIO.mod \
+                   PushBackInput.mod \
+                   RTExceptions.mod \
+                   SFIO.mod \
+                   StdIO.mod \
+                   Storage.mod \
+                   StrCase.mod \
+                   StrIO.mod \
+                   StrLib.mod \
+                   SysStorage.mod
+
+# Program module ppg.mod from which pge.mod is created.  ppg.mod is
+# where changes should be made and then you should run pge-maintainer
+# to recreate the C++ version of pge.
+
+PPG-SRC          = ppg.mod
+
+BUILD-PPG-O = $(PPG-INTERFACE-C:%.c=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) \
+              $(PPG-INTERFACE-CC:%.cc=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) \
+              $(PPG-MODS:%.mod=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) \
+              $(PPG-LIB-MODS:%.mod=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o) \
+              $(PPG-SRC:%.mod=m2/gm2-ppg-boot/$(SRC_PREFIX)%.o)
+
+MCC_ARGS= --olang=c++ \
+ --quiet \
+ --h-file-prefix=$(SRC_PREFIX) \
+ -I$(srcdir)/m2/gm2-libs \
+ -I$(srcdir)/m2/gm2-compiler \
+ -I$(srcdir)/m2/gm2-libiberty \
+ -I$(srcdir)/m2/gm2-gcc
+
+MCC=m2/boot-bin/mc$(exeext) $(MCC_ARGS)
+
+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)
+	$(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
+	$(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
+	$(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)
+	$(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)
+	$(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 \
+              -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-ppg-boot/$(SRC_PREFIX)$*.c -o $@
+
+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
+	+$(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
+	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 $@
+
+# m2/pg$(exext) is the 2nd generation parser generator built from ebnf
+# without error recovery
+
+PG-SRC = pg.mod
+
+BUILD-PG-O = $(PPG-INTERFACE-C:%.c=m2/gm2-pg-boot/$(SRC_PREFIX)%.o) \
+             $(PPG-INTERFACE-CC:%.cc=m2/gm2-pg-boot/$(SRC_PREFIX)%.o) \
+             $(PPG-MODS:%.mod=m2/gm2-pg-boot/$(SRC_PREFIX)%.o) \
+             $(PPG-LIB-MODS:%.mod=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)
+	$(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
+	$(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
+	$(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)
+	$(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 \
+               -Im2/gm2-libs-boot $(INCLUDES) \
+              -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)
+	$(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)
+	$(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 $@
+
+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
+	+$(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:
+	sed -e 's/ppg/pg/' < $(srcdir)/m2/init/ppginit > $@
+
+m2/gm2-pg-boot/main.o: m2/gm2-auto/pginit $(M2LINK)
+	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)
+	$(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
+	$(QUIAT)if ! diff m2/gm2-auto/t.mod m2/gm2-auto/pg.mod > /dev/null ; then \
+           echo "pg failed during self build" ; \
+           exit 1 ; \
+        fi
+	$(RM) m2/gm2-auto/t.bnf m2/gm2-auto/t.mod
+
+m2/gm2-auto/pg.mod: m2/ppg$(exeext)
+	$(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
+
+# pge is the recursive descent parser with first/followset error recovery.
+
+PGE-SRC = pge.mod
+
+BUILD-PGE-O = $(PPG-INTERFACE-C:%.c=m2/gm2-pge-boot/$(SRC_PREFIX)%.o) \
+              $(PPG-INTERFACE-CC:%.cc=m2/gm2-pge-boot/$(SRC_PREFIX)%.o) \
+              $(PPG-MODS:%.mod=m2/gm2-pge-boot/$(SRC_PREFIX)%.o) \
+              $(PPG-LIB-MODS:%.mod=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)
+	$(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)
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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)
+	$(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)
+	$(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)
+	$(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 \
+              -I$(srcdir)/m2/mc-boot-ch $(INCLUDES) -g -c m2/gm2-pge-boot/$(SRC_PREFIX)pge.c -o $@
+
+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
+	+$(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
+	$(SHELL) $(srcdir)/m2/tools-src/buildpg $(srcdir)/m2/gm2-compiler/ppg.mod t > m2/gm2-auto/t.bnf
+	./m2/pge$(exeext) m2/gm2-auto/t.bnf -o m2/gm2-auto/t1.mod
+	./m2/pg$(exeext) m2/gm2-auto/t.bnf -o m2/gm2-auto/t2.mod
+	$(QUIAT)if ! diff m2/gm2-auto/t1.mod m2/gm2-auto/t2.mod > /dev/null ; then \
+           echo "failure: pg (with error recovery) failed" ; \
+           $(RM) m2/pge$(exeext) ; \
+           exit 1 ; \
+        fi
+	$(RM) m2/gm2-auto/t.mod m2/gm2-auto/t1.mod m2/gm2-auto/t2.mod
+
+m2/gm2-auto/pgeinit:
+	sed -e 's/ppg/pge/' < $(srcdir)/m2/init/ppginit > $@
+
+m2/gm2-pge-boot/main.o: m2/gm2-auto/pgeinit $(M2LINK)
+	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 $@
+
+$(objdir)/m2/gm2-pg-boot:
+	test -d $@ || mkdir $@
+
+$(objdir)/m2/gm2-pge-boot:
+	test -d $@ || mkdir $@
+
+m2/gm2-auto/pg.o: m2/gm2-auto/pg.mod $(MCDEPS)
+	$(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)
+	$(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 $@
+
+pge-help: force
+	@echo "The pge maintainer commands are:"
+	@echo " "
+	@echo " make pge-maintainer"
+	@echo " make pge-verify"
+	@echo " make pge-push       # copy pge C++ sources (app and libs) into srcdir/m2/pge-boot"
+	@echo " make pge-libs-push  # copy C++ libraries which pge uses into srcdir/m2/pge-boot"
+	@echo " make pge-app-push   # copy pge C++ application modules into srcdir/m2/pge-boot"
+	@echo " make pge-clean"
+
+pge-maintainer: $(PGE)
+
+# Copy the C++ sources for ppe.mod into $(srcdir)/pge-boot.
+
+pge-push: pge-libs-push pge-app-push
+
+pge-libs-push: force
+	for i in $(cat $(srcdir)/m2/init/ppginit) ; do \
+	    if [ -f $(srcdir)/m2/gm2-libs-ch/${i}.h ] ; then \
+                cp $(srcdir)/m2/gm2-libs-ch/${i}.h $(srcdir) ; \
+            else \
+                echo "not found ${i}" ; \
+            fi ; \
+	    if [ -f $(srcdir)/m2/gm2-libs-ch/${i}.c* ] ; then \
+                cp $(srcdir)/m2/gm2-libs-ch/${i}.c* $(srcdir) ; \
+	    elif [ -f $(srcdir)/m2/gm2-pge-libs/${i}.c* ] ; then \
+                cp $(srcdir)/m2/gm2-pge-libs/${i}.c* $(srcdir) ; \
+            else \
+                echo "not found ${i}" ; \
+            fi ; \
+        done
+
+pge-app-push: force
+	cp m2/gm2-pge-boot/*.c $(srcdir)/m2/pge-boot
+
+# Perform sanity checks.
+
+pge-verify: force
+
+# Remove pge build files.
+
+pge-clean: force
+	$(RM) -f m2/gm2-pg-boot/* m2/gm2-ppg-boot/* m2/gm2-pge-boot/*
+
+
+# The rest of the Make-lang.in handles the bootstrap tool (maintained
+# mode) and also provides testing between the bootstrapped and the
+# non-bootstrapped compilers.
+
+# Rules for mc
+
+# The default rule used generate mc, eventually it will be replaced by mc-bootstrap.
+
+BOOTGM2=gm2
+
+MCOPTIONS=-g -c -fsources -fsoft-check-all -fm2-g # -fauto-init
+MCLINK=-g     # use -g -fmodules -c if you are debugging and wish to see missing modules.
+
+# This is only needed in maintainer mode by 'make mc-maintainer' when regenerating the C
+# version of mc.  We need a working Modula-2 compiler to run mc-maintainer.
+
+GM2SYS=${HOME}/opt/lib/gcc/x86_64-pc-linux-gnu/12.0.0/m2/m2pim
+GM2PATH=$(srcdir)/m2/mc:$(GM2SYS):$(srcdir)/m2:m2/gm2-auto:$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-libs-iso
+
+mc: mc-clean mc-devel
+
+mc-push: force
+	cp -p m2/mc-boot-gen/*.c $(srcdir)/m2/mc-boot/
+	cp -p m2/mc-boot-gen/*.h $(srcdir)/m2/mc-boot/
+
+mc-clean: force m2/mc-obj
+	$(RM) m2/mc-boot-gen/*.[ch] m2/boot-bin/* m2/mc-boot/* m2/mc-boot-ch/*
+
+mc-maintainer: mc-clean mc-autogen mc-push mc-clean mc-bootstrap
+
+mc-clean-libs: force
+	$(RM) m2/gm2-libs-boot/*
+
+mc-continue:  mc-clean mc-bootstrap mc-clean-libs mc-fresh $(BUILD-MC-INTERFACE-O) $(BUILD-LIBS-BOOT) $(BUILD-COMPILER-BOOT)
+
+mc-fresh: force
+	$(RM) m2/gm2-auto/* m2/gm2-compiler-boot/* m2/gm2-libs-boot/*
+
+mc-help:  force
+	@echo "mc-maintainer   produces a new mc C version in the source tree (takes longer)"
+	@echo "mc-continue     builds the mc from the C version and attempts to build gm2 libraries and gm2 compiler"
+	@echo "mc-verify       builds mc from Modula-2 sources and mc from C sources and run both on all sources diffing the output"
+	@echo "mc              builds mc from Modula-2 sources, quickly"
+	@echo "m2/pge          build the parser generator (needed by mc-maintainer)"
+
+m2/mc-obj:
+	mkdir $@
+
+mc-verify:  mc-clean mc-bootstrap mc
+	mv mc m2/boot-bin/mc.m2
+	@echo "verifying the two generations of mc"
+	for i in $(GM2-VERIFY-MODS) ; do \
+           echo -n "$$i " ; \
+           m2/boot-bin/mc $(MC_ARGS) -o=mcout.c $(srcdir)/m2/gm2-compiler/$$i > /dev/null ; \
+           echo -n "[1]" ; \
+           m2/boot-bin/mc.m2 $(MC_ARGS) -o=mcout.m2 $(srcdir)/m2/gm2-compiler/$$i > /dev/null ; \
+           echo -n "[2]" ; \
+           $(RM) $$i.mc-diff ; \
+           if [ -f mcout.c -a -f mcout.m2 ] ; then \
+              if diff mcout.c mcout.m2 > /dev/null ; then \
+                 echo "[passed]" ; \
+              else \
+                 echo "[*** failed ***]" ; \
+                 diff mcout.c mcout.m2 > $$i.mc-diff ; \
+              fi \
+           fi ; \
+	   $(RM) mcout.c mcout.m2 ; \
+        done
+
+mc-stage2:  force
+	m2/boot-bin/mc$(exeext) -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/GmcStream.c $(srcdir)/m2/mc/mcStream.mod
+	m2/boot-bin/mc$(exeext) -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/Gdecl.c $(srcdir)/m2/mc/decl.mod
+	if diff m2/mc-boot-gen/Gdecl.c $(srcdir)/m2/mc-boot/Gdecl.c ; then echo "passed" ; else echo "failed" ; fi
+
+
+
+#  mc-devel - compiles mc using gm2
+
+mc-devel: m2/boot-bin/mc-devel$(exeext)
+
+m2/boot-bin/mc-devel$(exeext): m2/mc-obj/mcp1.mod \
+                               m2/mc-obj/mcp2.mod \
+                               m2/mc-obj/mcp3.mod \
+                               m2/mc-obj/mcp4.mod \
+                               m2/mc-obj/mcp5.mod \
+                               mcflex.c \
+                               m2/mc-boot-ch/Gabort.o
+	$(RM) -rf mc-obj
+	mkdir 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
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcPretty.mod -o mc-obj/mcPretty.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcStack.mod -o mc-obj/mcStack.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/varargs.mod -o mc-obj/varargs.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcMetaError.mod -o mc-obj/mcMetaError.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcOptions.mod -o mc-obj/mcOptions.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcComp.mod -o mc-obj/mcComp.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) m2/mc-obj/mcp1.mod -o mc-obj/mcp1.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) m2/mc-obj/mcp2.mod -o mc-obj/mcp2.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) m2/mc-obj/mcp3.mod -o mc-obj/mcp3.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) m2/mc-obj/mcp4.mod -o mc-obj/mcp4.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) m2/mc-obj/mcp5.mod -o mc-obj/mcp5.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/wlists.mod -o mc-obj/wlists.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/alists.mod -o mc-obj/alists.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/symbolKey.mod -o mc-obj/symbolKey.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcReserved.mod -o mc-obj/mcReserved.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/nameKey.mod -o mc-obj/nameKey.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcSearch.mod -o mc-obj/mcSearch.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcFileName.mod -o mc-obj/mcFileName.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcLexBuf.mod -o mc-obj/mcLexBuf.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcQuiet.mod -o mc-obj/mcQuiet.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcError.mod -o mc-obj/mcError.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcDebug.mod -o mc-obj/mcDebug.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcPrintf.mod -o mc-obj/mcPrintf.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/Indexing.mod -o mc-obj/Indexing.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcPreprocess.mod -o mc-obj/mcPreprocess.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/keyc.mod -o mc-obj/keyc.o
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) $(srcdir)/m2/mc/mcComment.mod -o mc-obj/mcComment.o
+	$(BOOTGM2) $(MCLINK) -I. -fscaffold-main -I$(GM2PATH) \
+            -fuse-list=$(srcdir)/m2/init/mcinit $(srcdir)/m2/mc/top.mod -o mc \
+            m2/gm2-libs-boot/RTcodummy.o \
+            m2/gm2-libs-boot/dtoa.o m2/gm2-libs-boot/ldtoa.o mc-obj/*o m2/mc-boot-ch/Gabort.o
+
+m2/boot-bin/mc-opt$(exeext): m2/mc-obj/mcp1.mod \
+                             m2/mc-obj/mcp2.mod \
+                             m2/mc-obj/mcp3.mod \
+                             m2/mc-obj/mcp4.mod \
+                             m2/mc-obj/mcp5.mod \
+                             mcflex.c
+	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
+	$(BOOTGM2) $(MCOPTIONS) -I$(GM2PATH) -o $@ $(srcdir)/m2/mc/decl.mod
+
+m2/mc-obj/%.mod: $(srcdir)/m2/mc/%.bnf $(PGE)
+	$(PGE) -l $< -o $@
+
+gm2-bootstrap: mc-devel
+	for i in $(srcdir)/m2/gm2-libs/*.def ; do echo $$i ; ./mc --gcc-config-system -I$(srcdir)/m2/gm2-libs $$i ; done
+	for i in $(srcdir)/m2/gm2-compiler/*.def ; do echo $$i ; ./mc --gcc-config-system -I$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-gcc $$i ; done
+	for i in $(srcdir)/m2/gm2-libs/*.mod ; do echo $$i ; ./mc --gcc-config-system -I$(srcdir)/m2/gm2-libs:$(srcdir)/m2/gm2-compiler:$(srcdir)/m2/gm2-gcc $$i ; done
+
+
+$(objdir)/plugin:
+	test -d $@ || mkdir -p $@
+
+$(objdir)/m2/mc-boot:
+	test -d $@ || mkdir -p $@
+
+$(objdir)/m2/mc-boot-ch:
+	test -d $@ || mkdir -p $@
+
+$(objdir)/m2/mc-boot-gen:
+	test -d $@ || mkdir -p $@
+
+mc-autogen: mc-clean mc-devel \
+            $(BUILD-MC-BOOT-H) $(BUILD-MC-BOOT-C) \
+            $(BUILD-MC-BOOT-AUTO-C)
+	for i in m2/mc-boot-gen/*.c ; do \
+           echo $(CXX) -g -c -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/mc-boot-gen/ $$i -o m2/mc-boot-gen/`basename $$i .c`.o ; \
+                $(CXX) -g -c -I. -I$(srcdir)/../include -I$(srcdir) -I$(srcdir)/m2/mc-boot-ch -Im2/mc-boot-gen/ $$i -o m2/mc-boot-gen/`basename $$i .c`.o ; done
+	@echo -n "built "
+	@cd m2/mc-boot-gen ; ls *.o | wc -l
+	@echo -n "out of "
+	@cd m2/mc-boot-gen ; ls *.c | wc -l
+	@echo "modules"
+
+# EXTENDED_OPAQUE = --extended-opaque
+EXTENDED_OPAQUE =
+MC_OPTIONS = $(MC_COPYRIGHT) --gcc-config-system --olang=c++
+
+m2/mc-boot-gen/$(SRC_PREFIX)%.h: $(srcdir)/m2/mc/%.def
+	./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
+	./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
+	./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
+	./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
+	./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
+	./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
+	./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.
+# These autogenerated files will be checked into git by the maintainer.
+
+mc-bootstrap: mc-clean m2/boot-bin/mc$(exeext)
+
+gm2.maintainer-reconfigure: force
+	autoconf $(srcdir)/m2/gm2-libs/config-host.in > $(srcdir)/m2/gm2-libs/config-host
+	( cd $(srcdir)/m2/gm2-libs ; autoheader config-host.in )
+	( cd $(srcdir)/m2 ; autoconf configure.in > configure )
+
+gm2.maintainer-clean: force
+	-rm -f $(srcdir)/m2/gm2-auto/*
+	-rm -f $(srcdir)/m2/gm2-libs.texi
+	-rm -f $(srcdir)/m2/gm2-ebnf.texi
+	-rm -f $(srcdir)/m2/images/gnu.eps
+
+gm2.maintainer-help: force
+	@echo "make knows about:"
+	@echo " "
+	@echo "make gm2.maintainer-help           this command"
+	@echo "make gm2.maintainer-reconfigure    rebuild the configure scripts"
+	@echo "make gm2.maintainer-clean          clean pre-built images and texi files"
+
+
+#
+#  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.
+#
+
+# GM2-VERIFY-MODS is a list of modules which have no __DATE__ stamp inside them
+#                 and thus they can be built by the different versions of gm2.
+#                 This list is used for testing only.
+
+GM2-VERIFY-MODS    = FifoQueue.mod     M2AsmUtil.mod                   M2Optimize.mod  \
+                     M2StackWord.mod                   M2Pass.mod      M2Batch.mod     \
+                     M2Quads.mod       M2Comp.mod      M2Reserved.mod  \
+                     M2Debug.mod       M2Defaults.mod  NameKey.mod     \
+                     M2FileName.mod    P0SymBuild.mod  P1SymBuild.mod  P2SymBuild.mod  \
+                     P3SymBuild.mod  \
+                     SymbolKey.mod     SymbolTable.mod                 M2Error.mod     \
+                     M2StackAddress.mod \
+                     M2Students.mod  \
+                     M2BasicBlock.mod  M2Code.mod      M2GenGCC.mod    M2GCCDeclare.mod\
+                     M2ALU.mod         M2System.mod    M2Base.mod      Lists.mod       \
+                     M2Search.mod      bnflex.mod      ppg.mod         Output.mod      \
+                     SymbolConversion.mod \
+                     M2Preprocess.mod  M2Printf.mod    M2LexBuf.mod    M2Quiet.mod     \
+                     M2Bitset.mod      M2Size.mod      CLexBuf.mod     M2Scope.mod     \
+                     M2Range.mod       M2Swig.mod      M2MetaError.mod Sets.mod        \
+                     M2CaseList.mod    PCSymBuild.mod  M2Const.mod     \
+                     M2DebugStack.mod  ObjectFiles.mod M2ColorString.mod M2Emit.mod
+
+GM2-VERIFY-AUTO    = P1Build.mod       P2Build.mod     PCBuild.mod     P3Build.mod     \
+                     PHBuild.mod       pg.mod          P0SyntaxCheck.mod
+
+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
+
+stage3/m2/cc1gm2$(exeext): stage2/m2/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
+	@$(call LINK_PROGRESS,$(INDEX.m2),start)
+	+$(LLINKER) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GM2_C_OBJS) m2/gm2-compiler-paranoid/m2flex.o \
+                            attribs.o \
+                              $(GM2_LIBS_PARANOID) \
+                              $(BACKEND) $(LIBS) m2/gm2-gcc/rtegraph.o m2/gm2-libs-boot/M2LINK.o \
+                              $(BACKENDLIBS) $(LIBSTDCXX) -lm
+	@$(call LINK_PROGRESS,$(INDEX.m2),end)
+
+
+# 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
+	@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 " ; \
+           ./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 $(srcdir)/m2/gm2-compiler/$$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 $(srcdir)/m2/gm2-compiler/$$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 $(srcdir)/m2/gm2-compiler/$$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]" ; \
+               cp m2/gm2-compiler-verify/1.s m2/gm2-compiler-verify/t.s | as -ahl m2/gm2-compiler-verify/t.s > m2/gm2-compiler-verify/$$i.1.lst ; \
+               cp m2/gm2-compiler-verify/2.s m2/gm2-compiler-verify/t.s | as -ahl m2/gm2-compiler-verify/t.s > m2/gm2-compiler-verify/$$i.2.lst ; \
+               echo " " ; \
+               exit 1 ; \
+           fi ; \
+           if ! diff m2/gm2-compiler-verify/2.s m2/gm2-compiler-verify/3.s > m2/gm2-compiler-verify/2_3.diff 2>&1 ; then \
+               echo -n " [stage 2 and stage 3 differ]" ; \
+               cp m2/gm2-compiler-verify/2.s m2/gm2-compiler-verify/t.s | as -ahl m2/gm2-compiler-verify/t.s > m2/gm2-compiler-verify/$$i.2.lst ; \
+               cp m2/gm2-compiler-verify/3.s m2/gm2-compiler-verify/t.s | as -ahl m2/gm2-compiler-verify/t.s > m2/gm2-compiler-verify/$$i.3.lst ; \
+           fi ; \
+           echo " " ; \
+        done
+	$(QUIAT)echo "now verifying automatically built modules"
+	$(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 ; \
+              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 ; \
+              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 ; \
+              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]" ; \
+                  cp m2/gm2-compiler-verify/1.s m2/gm2-compiler-verify/t.s | as -ahl m2/gm2-compiler-verify/t.s > m2/gm2-compiler-verify/$$i.1.lst ; \
+                  cp m2/gm2-compiler-verify/2.s m2/gm2-compiler-verify/t.s | as -ahl m2/gm2-compiler-verify/t.s > m2/gm2-compiler-verify/$$i.2.lst ; \
+                  echo " " ; \
+                  exit 1 ; \
+              fi ; \
+              if ! diff m2/gm2-compiler-verify/2.s m2/gm2-compiler-verify/3.s > m2/gm2-compiler-verify/2_3.diff 2>&1 ; then \
+                  echo -n " [stage 2 and stage 3 differ]" ; \
+                  cp m2/gm2-compiler-verify/2.s m2/gm2-compiler-verify/t.s | as -ahl m2/gm2-compiler-verify/t.s > m2/gm2-compiler-verify/$$i.2.lst ; \
+                  cp m2/gm2-compiler-verify/3.s m2/gm2-compiler-verify/t.s | as -ahl m2/gm2-compiler-verify/t.s > m2/gm2-compiler-verify/$$i.3.lst ; \
+              fi ; \
+              echo " " ; \
+           fi ; \
+        done ; \
+	$(RM) -f m2/gm2-compiler-verify/1.s m2/gm2-compiler-verify/2.s m2/gm2-compiler-verify/3.s m2/gm2-compiler-verify/2_3.diff m2/gm2-compiler-verify/1_2.diff
+
+
+# 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)
+	@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 " ; \
+           ./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 $(srcdir)/m2/gm2-compiler/$$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 $(srcdir)/m2/gm2-compiler/$$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]" ; \
+               cp m2/gm2-compiler-verify/1.s m2/gm2-compiler-verify/t.s | as -ahl m2/gm2-compiler-verify/t.s > m2/gm2-compiler-verify/$$i.1.lst ; \
+               cp m2/gm2-compiler-verify/2.s m2/gm2-compiler-verify/t.s | as -ahl m2/gm2-compiler-verify/t.s > m2/gm2-compiler-verify/$$i.2.lst ; \
+               echo " " ; \
+           fi ; \
+           echo " " ; \
+        done
+	$(QUIAT)echo "now verifying automatically built modules"
+	$(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 ; \
+              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 ; \
+              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]" ; \
+                  cp m2/gm2-compiler-verify/1.s m2/gm2-compiler-verify/t.s | as -ahl m2/gm2-compiler-verify/t.s > m2/gm2-compiler-verify/$$i.1.lst ; \
+                  cp m2/gm2-compiler-verify/2.s m2/gm2-compiler-verify/t.s | as -ahl m2/gm2-compiler-verify/t.s > m2/gm2-compiler-verify/$$i.2.lst ; \
+                  echo " " ; \
+              fi ; \
+              echo " " ; \
+           fi ; \
+        done ; \
+	$(RM) -f m2/gm2-compiler-verify/1.s m2/gm2-compiler-verify/2.s m2/gm2-compiler-verify/3.s m2/gm2-compiler-verify/2_3.diff m2/gm2-compiler-verify/1_2.diff
+
+
+# The rules which build objects in the gm2-compiler-paranoid gm2-libs-paranoid directories.
+
+m2/gm2-libs-paranoid/%.o: m2/gm2-libs-ch/%.c
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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
+	$(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)
+	$(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
+	$(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
+	$(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
+	$(CXX) -c $(GM2_O_S3) $(CFLAGS) -I$(srcdir)/m2 -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@
+
+
+# The rules which build the paranoid version of gm2.
+
+BUILD-LIBS-PARANOID-H = $(GM2-LIBS-BOOT-DEFS:%.def=m2/gm2-libs-boot/$(SRC_PREFIX)%.h)
+
+BUILD-LIBS-PARANOID = $(BUILD-LIBS-PARANOID-H) \
+                      $(GM2-LIBS-MODS:%.mod=m2/gm2-libs-paranoid/%.o) \
+                      $(GM2-LIBS-CC:%.cc=m2/gm2-libs-paranoid/%.o) \
+                      $(GM2-LIBS-C:%.c=m2/gm2-libs-paranoid/%.o)
+
+m2/gm2-libs-paranoid/libgm2.a: m2/boot-bin/mc$(exeext) $(BUILD-LIBS-PARANOID)
+	$(AR) cr $@ $(GM2-LIBS-MODS:%.mod=m2/gm2-libs-paranoid/%.o) \
+                    $(GM2-LIBS-CC:%.cc=m2/gm2-libs-paranoid/%.o) \
+                    $(GM2-LIBS-C:%.c=m2/gm2-libs-paranoid/%.o)
+	$(RANLIB) $@
+
+m2/gm2-compiler-paranoid/gm2.a: \
+                             $(GM2-COMP-MODS:%.mod=m2/gm2-compiler-paranoid/%.o) \
+                             $(GM2-AUTO-MODS:%.mod=m2/gm2-compiler-paranoid/%.o) \
+                             m2/gm2-compiler-paranoid/M2Version.o \
+                             m2/gm2-compiler-paranoid/m2flex.o
+	$(AR) cr $@ $(GM2-COMP-MODS:%.mod=m2/gm2-compiler-paranoid/%.o) \
+                    $(GM2-AUTO-MODS:%.mod=m2/gm2-compiler-paranoid/%.o) \
+                    m2/gm2-compiler-paranoid/M2Version.o
+	$(RANLIB) $@
+
+m2/gm2-compiler-paranoid/M2Version.mod:
+	$(SHELL) $(srcdir)/m2/tools-src/makeversion -m $(srcdir) m2/gm2-compiler-paranoid
+
+m2/gm2-compiler-paranoid/M2Version.o: m2/gm2-compiler-paranoid/M2Version.mod
+	$(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)
+	$(PGE) -k -l $< -o $@
+
+# Recreate the target independent copies of the documentation which is
+# used during the build if Python3 is unavailable.
+
+# m2-target-independent-doc-rst should be enabled once
+# tools-src/def2doc.py is completed (module hyperlinks need rst
+# treatment).
+
+m2-target-independent-doc: m2-target-independent-doc-texi # m2-target-independent-doc-rst
+
+m2-target-independent-doc-texi: force
+ifeq ($(HAVE_PYTHON),yes)
+	python3 $(srcdir)/m2/tools-src/def2doc.py -t -b$(srcdir)/m2 -f$(srcdir)/m2/gm2-libs-iso/SYSTEM.def -o $(srcdir)/m2/target-independent/SYSTEM-iso.texi
+	python3 $(srcdir)/m2/tools-src/def2doc.py -t -b$(srcdir)/m2 -f$(srcdir)/m2/gm2-libs/SYSTEM.def -o $(srcdir)/m2/target-independent/SYSTEM-pim.texi
+	python3 $(srcdir)/m2/tools-src/def2doc.py -t -b$(srcdir)/m2 -f$(srcdir)/m2/gm2-libs/Builtins.def -o $(srcdir)/m2/target-independent/Builtins.texi
+	python3 $(srcdir)/m2/tools-src/def2doc.py -t -uLibraries -s$(srcdir)/m2 -b$(srcdir)/m2 -o $(srcdir)/m2/target-independent/gm2-libs.texi
+else
+	echo "m2-target-independent-doc-texi will only work if Python3 was detected during configure"
+endif
+
+m2-target-independent-doc-rst: force
+ifeq ($(HAVE_PYTHON),yes)
+	python3 $(srcdir)/m2/tools-src/def2doc.py -x -b$(srcdir)/m2 -f$(srcdir)/m2/gm2-libs-iso/SYSTEM.def -o $(srcdir)/m2/target-independent/SYSTEM-iso.rst
+	python3 $(srcdir)/m2/tools-src/def2doc.py -x -b$(srcdir)/m2 -f$(srcdir)/m2/gm2-libs/SYSTEM.def -o $(srcdir)/m2/target-independent/SYSTEM-pim.rst
+	python3 $(srcdir)/m2/tools-src/def2doc.py -x -b$(srcdir)/m2 -f$(srcdir)/m2/gm2-libs/Builtins.def -o $(srcdir)/m2/target-independent/Builtins.rst
+	python3 $(srcdir)/m2/tools-src/def2doc.py -x -uLibraries -s$(srcdir)/m2 -b$(srcdir)/m2 -o $(srcdir)/m2/target-independent/gm2-libs.rst
+else
+	echo "m2-target-independent-doc-rst will only work if Python3 was detected during configure"
+endif
diff -ruw /dev/null gcc-git-devel-modula2/gcc/m2/target-independent/SYSTEM-iso.texi
--- /dev/null	2022-08-24 16:22:16.888000070 +0100
+++ gcc-git-devel-modula2/gcc/m2/target-independent/SYSTEM-iso.texi	2022-12-14 06:54:59.688966155 +0000
@@ -0,0 +1,237 @@ 
+
+@example
+DEFINITION MODULE SYSTEM;
+
+  (* Gives access to system programming facilities that are probably
+     non portable. *)
+
+  (* The constants and types define underlying properties of storage *)
+
+EXPORT QUALIFIED BITSPERLOC, LOCSPERWORD,
+                 LOC, BYTE, WORD, ADDRESS, CSIZE_T, CSSIZE_T, (* 
+                 Target specific data types.  *)
+                 ADDADR, SUBADR, DIFADR, MAKEADR, ADR, ROTATE,
+                 SHIFT, CAST, TSIZE,
+
+                 (* Internal GM2 compiler functions *)
+                 ShiftVal, ShiftLeft, ShiftRight,
+                 RotateVal, RotateLeft, RotateRight,
+                 THROW, TBITSIZE ;
+
+CONST
+                  (* <implementation-defined constant> ; *)
+@findex BITSPERLOC (const)
+  BITSPERLOC    = __ATTRIBUTE__ __BUILTIN__ ((BITS_PER_UNIT)) ;
+                  (* <implementation-defined constant> ; *)
+@findex LOCSPERWORD (const)
+  LOCSPERWORD   = __ATTRIBUTE__ __BUILTIN__ ((UNITS_PER_WORD)) ;
+                  (* <implementation-defined constant> ; *)
+@findex LOCSPERBYTE (const)
+  LOCSPERBYTE = 8 DIV BITSPERLOC ;
+
+(*
+   all the objects below are declared internally to gm2
+   ====================================================
+
+TYPE
+   (* Target specific data types.  *)
+
+TYPE
+  LOC; (* A system basic type. Values are the uninterpreted
+          contents of the smallest addressable unit of storage *)
+@findex ADDRESS (type)
+  ADDRESS = POINTER TO LOC;
+@findex WORD (type)
+  WORD = ARRAY [0 .. LOCSPERWORD-1] OF LOC;
+
+  (* BYTE and LOCSPERBYTE are provided if appropriate for machine *)
+
+TYPE
+@findex BYTE (type)
+  BYTE = ARRAY [0 .. LOCSPERBYTE-1] OF LOC;
+
+@findex ADDADR
+PROCEDURE ADDADR (addr: ADDRESS; offset: CARDINAL): ADDRESS;
+  (* Returns address given by (addr + offset), or may raise
+     an exception if this address is not valid.
+  *)
+
+@findex SUBADR
+PROCEDURE SUBADR (addr: ADDRESS; offset: CARDINAL): ADDRESS;
+  (* Returns address given by (addr - offset), or may raise an
+     exception if this address is not valid.
+  *)
+
+@findex DIFADR
+PROCEDURE DIFADR (addr1, addr2: ADDRESS): INTEGER;
+  (* Returns the difference between addresses (addr1 - addr2),
+     or may raise an exception if the arguments are invalid
+     or address space is non-contiguous.
+  *)
+
+@findex MAKEADR
+PROCEDURE MAKEADR (high: <some type>; ...): ADDRESS;
+  (* Returns an address constructed from a list of values whose
+     types are implementation-defined, or may raise an
+     exception if this address is not valid.
+
+     In GNU Modula-2, MAKEADR can take any number of arguments
+     which are mapped onto the type ADDRESS. The first parameter
+     maps onto the high address bits and subsequent parameters map
+     onto lower address bits. For example:
+
+     a := MAKEADR(BYTE(0FEH), BYTE(0DCH), BYTE(0BAH), BYTE(098H),
+                  BYTE(076H), BYTE(054H), BYTE(032H), BYTE(010H)) ;
+
+     then the value of, a, on a 64 bit machine is: 0FEDCBA9876543210H
+
+     The parameters do not have to be the same type, but constants
+     _must_ be typed.
+  *)
+
+@findex ADR
+PROCEDURE ADR (VAR v: <anytype>): ADDRESS;
+  (* Returns the address of variable v. *)
+
+@findex ROTATE
+PROCEDURE ROTATE (val: <a packedset type>;
+                  num: INTEGER): <type of first parameter>;
+  (* Returns a bit sequence obtained from val by rotating up/right
+     or down/right by the absolute value of num.  The direction is
+     down/right if the sign of num is negative, otherwise the direction
+     is up/left.
+  *)
+
+@findex SHIFT
+PROCEDURE SHIFT (val: <a packedset type>;
+                 num: INTEGER): <type of first parameter>;
+  (* Returns a bit sequence obtained from val by shifting up/left
+     or down/right by the absolute value of num, introducing
+     zeros as necessary.  The direction is down/right if the sign of
+     num is negative, otherwise the direction is up/left.
+  *)
+
+@findex CAST
+PROCEDURE CAST (<targettype>; val: <anytype>): <targettype>;
+  (* CAST is a type transfer function.  Given the expression
+     denoted by val, it returns a value of the type <targettype>.
+     An invalid value for the target value or a
+     physical address alignment problem may raise an exception.
+  *)
+
+@findex TSIZE
+PROCEDURE TSIZE (<type>; ... ): CARDINAL;
+  (* Returns the number of LOCS used to store a value of the
+     specified <type>.   The extra parameters, if present,
+     are used to distinguish variants in a variant record.
+  *)
+
+@findex THROW
+PROCEDURE THROW (i: INTEGER) ;
+  (*
+     THROW is a GNU extension and was not part of the PIM or ISO
+     standards.  It throws an exception which will be caught by the
+     EXCEPT block (assuming it exists).  This is a compiler builtin
+     function which interfaces to the GCC exception handling runtime
+     system.
+     GCC uses the term throw, hence the naming distinction between
+     the GCC builtin and the Modula-2 runtime library procedure Raise.
+     The later library procedure Raise will call SYSTEM.THROW after
+     performing various housekeeping activities.
+  *)
+
+@findex TBITSIZE
+PROCEDURE TBITSIZE (<type>) : CARDINAL ;
+  (* Returns the minimum number of bits necessary to represent
+     <type>.  This procedure function is only useful for determining
+     the number of bits used for any type field within a packed RECORD.
+     It is not particularly useful elsewhere since <type> might be
+     optimized for speed, for example a BOOLEAN could occupy a WORD.
+  *)
+*)
+
+
+(* The following procedures are invoked by GNU Modula-2 to
+   shift non word set types. They are not part of ISO Modula-2
+   but are used to implement the SHIFT procedure defined above. *)
+
+(*
+   ShiftVal - is a runtime procedure whose job is to implement
+              the SHIFT procedure of ISO SYSTEM. GNU Modula-2 will
+              inline a SHIFT of a single WORD sized set and will only
+              call this routine for larger sets.
+*)
+
+@findex ShiftVal
+PROCEDURE ShiftVal (VAR s, d: ARRAY OF BITSET;
+                    SetSizeInBits: CARDINAL;
+                    ShiftCount: INTEGER) ;
+
+
+(*
+   ShiftLeft - performs the shift left for a multi word set.
+               This procedure might be called by the back end of
+               GNU Modula-2 depending whether amount is known at
+               compile time.
+*)
+
+@findex ShiftLeft
+PROCEDURE ShiftLeft (VAR s, d: ARRAY OF BITSET;
+                     SetSizeInBits: CARDINAL;
+                     ShiftCount: CARDINAL) ;
+
+(*
+   ShiftRight - performs the shift left for a multi word set.
+                This procedure might be called by the back end of
+                GNU Modula-2 depending whether amount is known at
+                compile time.
+*)
+
+@findex ShiftRight
+PROCEDURE ShiftRight (VAR s, d: ARRAY OF BITSET;
+                     SetSizeInBits: CARDINAL;
+                     ShiftCount: CARDINAL) ;
+
+
+(*
+   RotateVal - is a runtime procedure whose job is to implement
+               the ROTATE procedure of ISO SYSTEM. GNU Modula-2 will
+               inline a ROTATE of a single WORD (or less)
+               sized set and will only call this routine for larger
+               sets.
+*)
+
+@findex RotateVal
+PROCEDURE RotateVal (VAR s, d: ARRAY OF BITSET;
+                     SetSizeInBits: CARDINAL;
+                     RotateCount: INTEGER) ;
+
+
+(*
+   RotateLeft - performs the rotate left for a multi word set.
+                This procedure might be called by the back end of
+                GNU Modula-2 depending whether amount is known at
+                compile time.
+*)
+
+@findex RotateLeft
+PROCEDURE RotateLeft (VAR s, d: ARRAY OF BITSET;
+                      SetSizeInBits: CARDINAL;
+                      RotateCount: CARDINAL) ;
+
+
+(*
+   RotateRight - performs the rotate right for a multi word set.
+                 This procedure might be called by the back end of
+                 GNU Modula-2 depending whether amount is known at
+                 compile time.
+*)
+
+@findex RotateRight
+PROCEDURE RotateRight (VAR s, d: ARRAY OF BITSET;
+                       SetSizeInBits: CARDINAL;
+                       RotateCount: CARDINAL) ;
+
+
+END SYSTEM.
+@end example