@c Copyright (C) 1988-2005 Free Software Foundation, Inc.
@c For copying conditions, see the file gpc.texi.
@c This file is part of the GPC Manual.
@c
@c Authors: J.J. van der Heijden <j.j.vanderheijden@student.utwente.nl>
@c          Peter Gerwinski <peter@gerwinski.de>
@c          Frank Heckenbach <frank@pascal.gnu.de>
@c
@c Last modification: 2005-01-01 (file mostly up to date -- `make bootstrap' missing etc.)

@include macros.texi

@ifclear INSTALLONLY
@node Installation
@chapter How to download, compile and install GNU Pascal.
@cindex installing GNU Pascal
@end ifclear

@ifset INSTALLONLY
@include version.texi
@c Note: The following line gets inserted into the destination file,
@c       it does not apply to this Texinfo file!
This file was generated automatically from install.texi.@*
@sc{DO NOT CHANGE THIS FILE MANUALLY!}

@settitle GNU Pascal Installation Guide
@node Top
@chapter Installing GNU Pascal
@end ifset

@menu
* Download::              Where and what to download
* Binary Distributions::  How to install a binary distribution
* Compiling GPC::         How to compile GPC
* Compilation Notes::     Compilation notes for specific platforms
* Cross-Compilers::       Building and Installing a cross-compiler
* Crossbuilding::         Crossbuilding a compiler
@end menu

@iftex
This chapter covers:

@itemize @bullet
@item Downloading GPC sources or binaries
@item Installation instructions for a GPC binary distribution
@item Compilation of the source distribution on a Unix system
@item Compilation notes for specific platforms
@item Building and installing a cross-compiler
@item Crossbuilding a compiler
@end itemize
@end iftex

@ifset INSTALLONLY
Contents of this file:

@itemize @bullet
@item Downloading GPC sources or binaries
@item Installation instructions for a GPC binary distribution
@item Compilation of the source distribution on a Unix system
@item Compilation notes for specific platforms
@item Building and installing a cross-compiler
@item Crossbuilding a compiler
@item Getting help
@end itemize
@end ifset


@c -------------------------------------------------------------------------


@node Download
@section Where and what to download
@cindex download
@cindex HTTP
@cindex WWW
@cindex web site

You can download the source code of the current GNU Pascal release
from
@smallexample
@uref{http://www.gnu-pascal.de/current/}
@end smallexample
and binaries for some platforms from
@smallexample
@uref{http://www.gnu-pascal.de/binary/}
@end smallexample

The binary archive files are named
@file{gpc-@var{version}.@var{platform}.@var{extension}} -- for example
@samp{gpc-2.1.alpha-unknown-linux-gnu.tar.gz} for GPC version 2.1 on an
Alpha workstation running the Linux kernel with GNU C Library, or
@samp{gpc-20000616.i386-pc-msdosdjgpp} for GPC version 20000616 on
an Intel IA32 compatible PC running DOS with DJGPP.

After you have downloaded the correct archive file for your
platform, please read the installation notes on how to install such
a binary distribution.

If you are running Dos or MS Windows, you will need additional tools
-- see
@ifhtml
@localuref{#WhatElse,``What else to download and where''}
@end ifhtml
@ifnothtml
``What else to download and where''
@end ifnothtml
below.

@subheading Current snapshots

GNU Pascal is subject to steady development. Alpha and beta
snapshots (source only, use at your own risk) can be found at:

@smallexample
@uref{http://www.gnu-pascal.de/alpha/}
@uref{http://www.gnu-pascal.de/beta/}
@end smallexample

@c @cindex CVS
@c @noindent or via anonymous CVS from:
@c
@c @c OK smallexample (for check-doc)
@c @smallexample
@c CVS root:
@c   :pserver:anonymous@@agnes.dida.physik.uni-essen.de:/usr/local/cvsroot
@c Password:
@c   anonymous
@c Command:
@c   checkout gpc
@c @end smallexample
@c
@c If you haven't used CVS yet, here's what to do:
@c
@c Make sure you have the @file{cvs} executable. If not, you can get
@c its source from a GNU mirror or binaries for various platforms
@c (Linux @file{.rpm} or @file{.deb}, CygWin archives, etc.) from the
@c usual places.
@c
@c Execute once the following command:
@c
@c @c OK smallexample (for check-doc)
@c @smallexample
@c @t{cvs -d \}
@c @t{  :pserver:anonymous@@agnes.dida.physik.uni-essen.de:/usr/local/cvsroot login}
@c @end smallexample
@c
@c Create a directory where you want to store the GPC sources.
@c
@c Each time you want to get/update your copy of GPC, change to that
@c directory and execute the following command. The first time, it will
@c take a while to get all the GPC sources. Subsequent invocations will
@c only transmit changes and therefore usually be quite fast.
@c
@c @c OK smallexample (for check-doc)
@c @smallexample
@c @t{cvs -z9 -d \}
@c @t{  :pserver:anonymous@@agnes.dida.physik.uni-essen.de:/usr/local/cvsroot \}
@c @t{  checkout gpc}
@c @end smallexample
@c
@c (You may want to store this last command in a script or as an alias
@c so you can invoke it more easily.)
@c
@c Please read the installation notes on how to compile the source from
@c a distribution or a CVS checkout.

@anch{WhatElse}@c
@subheading What else to download and where

When you are using GNU Pascal on a DOS system, you will need either
the DJGPP or the EMX development environment (see below). On an OS/2
system, you will need EMX. On an MS Windows 95/98/NT system you will
need either the CygWin or the mingw32 ot the MSYS environment.

GNU Pascal uses the compiler back-end from the GNU Compiler
Collection, GNU CC or GCC. If you want to compile GPC, you will need
the source of GCC as well as the source of GPC itself. From the same
place as GPC, please download GCC @file{@value{GCCVersion}}. (It is
also available from any GNU mirror; see
@uref{http://www.gnu.org/software/gcc/}.)

@anch{libs}@c
@subheading Libraries

For some of GPC's units, you will need some standard libraries. In
particular:

@c @group
@multitable {xxxxxxxxxxxxxx}     {xxxxxxxxxxxxxxxxxxx}     {xxxxxxxxxxxxxxxxxxxxxxxxxx}
@item     @b{Unit}        @tab @b{Platform}         @tab @b{Library}
@item     @t{CRT}         @tab @t{Unix/terminal}    @tab @t{ncurses >= 5.0} (1), (2)
@item     @t{CRT}         @tab @t{Unix/X11}         @tab @t{PDCurses} (2)
@item     @t{CRT}         @tab @t{Dos, MS-Windows}  @tab @t{PDCurses} (3)
@item     @t{GMP}         @tab @t{any}              @tab @t{gmp}
@item     @t{RegEx}       @tab @t{any}              @tab @t{rx}
@item     (debugging)     @tab @t{Unix, MS-Windows} @tab @t{ElectricFence} (4)
@end multitable
@c @end group

Notes:

(1) ncurses version 5.0 or newer is strongly recommended because
older versions contain a bug that severely affects CRT programs.

(2) You can install both ncurses and PDCurses on a Unix system, and
choose at compile time whether to generate a terminal or X11 version
of your program.

(3) ncurses also runs under MS-Windows with CygWin (not mingw32,
however), but doesn't appear to behave much differently from
PDCurses on that platform.

(4) ElectricFence is not used by any unit, but can be used for
debugging memory allocation bugs by simply linking it (see the
accompanying documentation).

You can find those libraries on many places on the Net. Also, many
GNU/Linux distributions, DJGPP mirrors and other OS distributions
already contain some of the libraries. In any case, you can find the
sources of the libraries (sometimes together with patches that you
should apply before building if you choose to build from the
sources) and binaries for some platforms in

@smallexample
@uref{http://www.gnu-pascal.de/libs/}
@end smallexample

@ifclear INSTALLONLY
For more information and descriptions of these libraries, see
@ref{Libraries}.
@end ifclear

@anch{DJGPP}@c
@subheading DJGPP

@uref{http://www.delorie.com/djgpp/,DJGPP} is available from any
SimTel mirror in the @file{gnu/djgpp} subdirectory; for addresses
look into @uref{http://www.delorie.com/djgpp/v2faq/,the DJGPP FAQ}.
To use GNU Pascal you need at least

@itemize @minus
@item the C library, @samp{v2/djdev201.zip}, and
@item @samp{binutils} (assembler, etc.), @file{v2gnu/bnu270b.zip}.
@end itemize

We also recommend you to get:

@itemize @minus
@item the @samp{make} utility, @file{v2gnu/mak375b.zip}
@item the GNU debugger, @file{v2gnu/gdb416b.zip}
@item the DJGPP FAQ, @file{v2faq/faq211b.zip}
@item the GRX graphics library, @uref{http://www.gnu.de/software/GRX/}
@item PENG, @uref{http://fjf.gnu.de/peng/}, an integrated
development environment, similar to BP's one, written in GNU Pascal,
or
@item RHIDE, @file{v2app/rhide.zip}, another integrated development
environment, or
@item DevPascal, @uref{http://www.bloodshed.net/devpascal.html}, an
integrated development environment for mingw32.
@end itemize

@anch{EMX}@c
@subheading EMX

EMX is an environment for creating 32-bit applications for DOS and OS/2.
To develop EMX programs with GNU Pascal you need at least

@itemize @minus
@item the EMX runtime package, @file{emxrt.zip},
@item the EMX development system, @file{emxdev*.zip}, and
@item the GNU development tools, @file{gnudev*.zip}.
@end itemize

If your DOS box has DPMI (it does if you are using MS Windows or OS/2)
you will also need RSX, available from the same sites as EMX in the
subdirectory @file{rsxnt}.

The GNU development tools contain the GNU C compiler which is in fact
not needed to use GNU Pascal. However, the C library @emph{is} needed.

@anch{CygWin}@c
@subheading CygWin
@cindex MS Windows 95/98/NT
@cindex Windows 95/98/NT, MS

CygWin is an environment which implements a POSIX layer under MS
Windows, giving it large parts of the functionality of Unix. CygWin
contains development tools such as an assembler, a linker,
etc.@: GPC needs for operation. More information about CygWin can be
found at
@smallexample
@uref{http://cygwin.com}
@end smallexample

@anch{mingw32}@c
@subheading mingw32
@cindex MS Windows 95/98/NT
@cindex Windows 95/98/NT, MS

The Minimalists' GNU Win32 environment, mingw32, allows a large
number of Unix programs -- including GPC and GCC -- to run under MS
Windows 95/98/NT using native MS libraries. mingw32 ressources can
be found at
@smallexample
@uref{http://www.mingw.org}
@end smallexample


@c -------------------------------------------------------------------------


@node Binary Distributions
@section Installation instructions for a GPC binary distribution
@cindex binary distributions, installing
@cindex installing binary distributions

To install a binary distribution, @code{cd} to the root directory and
unpack the archive while preserving the stored directory structure. Under
a Unix compatible system with GNU @code{tar} installed, the following
(performed as @samp{root}) will do the job:

@smallexample
# cd /
# tar xzf @var{archive}.tar.gz
@end smallexample

If you are using a @samp{tar} utility other than GNU @code{tar}, it
might be necessary to do the above in an explicit pipe:

@smallexample
# cd /
# gzip -c -d @var{archive}.tar.gz | tar xf -
@end smallexample

Some binary distributions are now distributed packed with
@samp{bzip2}. You can recognize them by their file name suffix
@file{.bz2} instead of @file{.gz}. For such archives, make sure you
have @samp{bunzip2} installed and then use the following command:

@smallexample
# cd /
# tar xjf @var{archive}.tar.bz2
@end smallexample

Or:

@smallexample
# cd /
# bunzip2 -c -d @var{archive}.tar.bz2 | tar xf -
@end smallexample

If you want to install a GPC binary distribution in another directory
than it was prepared for (for example, if you do not have root access
to the computer and want to install GPC somewhere under your home
directory), you can do the following:

@itemize @minus
@item
Unpack the archive file in a directory of your choice (see above).
@item
@samp{cd} to the ``prefix''
directory of the distribution (for instance @file{usr/local}).
@item
Run the script @code{install-gpc-binary}, available from
@uref{http://www.gnu-pascal.de/binary/}.
@item
Follow the instructions in the script.
@end itemize

To install a ZIP archive under DOS with @samp{PKunzip}, @samp{cd} to
the appropriate directory (usually @samp{\} for EMX, @samp{\DJGPP}
for DJGPP), then call @samp{PKunzip} with the @samp{-d} option:

@smallexample
C:\> cd djgpp
C:\DJGPP> pkunzip -d @var{archive}.zip
@end smallexample

where @file{@var{archive}.zip} is the name of the distribution file.

For DJGPP you must edit your @file{djgpp.env} in the
@file{DJGPP} directory to complete the installation: Please copy
the entries from @samp{[gcc]} to create a new @samp{[gpc]}
section. The result may look as follows:

@smallexample
[gcc]
COMPILER_PATH=%/>;COMPILER_PATH%%DJDIR%/bin
LIBRARY_PATH=%/>;LIBRARY_PATH%%DJDIR%/lib

[gpc]
COMPILER_PATH=%/>;COMPILER_PATH%%DJDIR%/bin
LIBRARY_PATH=%/>;LIBRARY_PATH%%DJDIR%/lib
@end smallexample

If you are using the DJGPP version of GPC but do not have a @file{DJGPP}
directory, please download and install DJGPP
@ifset INSTALLONLY
(see above).
@end ifset
@ifclear INSTALLONLY
(@pxref{Download}).
@end ifclear

Binary distributions include @file{libgcc.a} and @file{specs}, files that
are normally part of GCC. If you have GCC installed, they will be replaced
unless you manually install the archive.


@c -------------------------------------------------------------------------


@node Compiling GPC
@section Compiling GPC
@cindex source distributions, installing
@cindex installing source distributions

The preferred way to distribute GNU software is distribution of
the source code. However, it can be a non-trivial exercise to
build GNU Pascal on some non-Unix systems, so we also provide
ready-to-run binaries for a number of platforms. (See
@ifset INSTALLONLY
above
@end ifset
@ifclear INSTALLONLY
@ref{Binary Distributions}
@end ifclear
for how to install a binary distribution.)

GPC is based on the GNU Compiler Collection, GNU CC or GCC. You will
need the GCC sources to build it. It must be the same version as the
one GPC is implemented with -- @code{@value{GCCVersion}} as of this
writing. Although you need GCC to build the GNU Pascal compiler, you
don't need GCC to compile Pascal programs once GNU Pascal is
installed. (However, using certain libraries will require compiling
C wrappers, so it is a good idea to install the C compiler as well.)

Because GNU Pascal shares its back-end with GCC, it should run on any
system supported by GCC. A full list of platforms supported by GCC can
be found in
@ifset INSTALLONLY
the GCC installation instructions.
@end ifset
@ifclear INSTALLONLY
@ref{Installation, the GCC installation
instructions, Chapter 4, gcc, ``Using and Porting GNU CC''}.
@end ifclear

The GCC source can be obtained from any mirror of the GNU FTP
site, @uref{ftp://ftp.gnu.org/gnu/gcc/}. The ``core''
distribution is sufficient for GPC.

Here is the generic procedure for installing GNU Pascal on a Unix
system. See
@ifset INSTALLONLY
below
@end ifset
@ifclear INSTALLONLY
@ref{Compilation Notes}
@end ifclear
for extra information needed to install GPC on DOS-like platforms.

@enumerate

@item
Checking the prerequisites

Make sure that GNU make is installed and that you use it in the
following steps. When unsure, you can try @samp{make --version}
and/or @samp{gmake --version}. It should tell you that it is GNU
make. If you don't have it, you can obtain it from
@uref{http://www.gnu.org/software/make/}.

(In the following, we will simply speak of @samp{make} when invoking
GNU make; you might need to call @samp{gmake} instead.)

You also need a @file{patch} program. If such a program is not
installed on your system, you can get GNU patch from
@uref{http://www.gnu.org/directory/patch.html}.

For extracting the example programs from the documentation to the
@file{doc/docdemos} directory a non-crippled @samp{sed} is needed.
GNU sed is known to work.

@cindex distribution, minimal
If you have downloaded a ``minimal'' source distribution, most
derived files have to be rebuilt. This is done automatically when
building GPC, but you need additional tools:

@samp{bash}, @samp{bzip2}, @strong{GNU} @samp{sed}, GNU @samp{awk},
GNU @samp{m4}, @samp{bison} (at least version 2.0), @samp{flex}
(version 2.5.27), @samp{autoconf} (version 2.12), @samp{texinfo} (at
least version 4.2), @samp{help2man}.

Make sure that these are installed. The minimal distributions are
compressed with @samp{bzip2} instead of @samp{gzip}, so substitute
it in the instructions below.

If your bison and flex programs are installed under different names,
you may have to set some or all of the following environment
variables before running @samp{configure}:

@smallexample
FLEX=/path/to/flex
LEX=/path/to/flex
BISON=/path/to/bison
YACC=/path/to/bison
INTLBISON=/path/to/bison
@end smallexample

If you want to build the GPC WWW pages you will also need a @TeX{}
distribution (including @samp{pdftex} and @samp{dvips}).

If you run into trouble during the installation process, please check
whether you are using outdated versions of the required utilities and
upgrade if necessary.

The GNU versions of the packages above are available from
@uref{http://www.gnu.org/software/}, in a subdirectory whose name is
the name of the package.

@item
Unpacking the source

From a directory of your choice (e.g.@: @file{/home/fred}), unpack the
GCC and GNU Pascal source distributions. This will create separate
subdirectories for GCC and GPC. Let us assume @file{gcc-2.95.3} and
@file{gpc-20030209} in this example.
@smallexample
% cd /home/fred
% gzip -c -d gcc-core-2.95.3.tar.gz | tar xf -
% gzip -c -d gpc-20030209.tar.gz | tar xf -
@end smallexample

@samp{cd} to the GPC directory and move the contents (a subdirectory
@file{p}) to the subdirectory @file{gcc} of the GCC directory:

@smallexample
% mv /home/fred/gpc-20030209/p /home/fred/gcc-2.95.3/gcc/
@end smallexample

Instead of moving the directory, it is now also possible to make a
symbolic link (if the OS supports symlinks). This is useful if you
want to build GPC with several different GCC versions:

@smallexample
% ln -s /home/fred/gpc-20030209/p /home/fred/gcc-2.95.3/gcc/p
@end smallexample

It is recommended, though not required, to use a separate directory for
building the compiler, rather than compiling in the source directory. In
this example, let us create @file{/home/fred/gpc-build} for this
purpose:

@smallexample
% mkdir /home/fred/gpc-build
@end smallexample

If you use a separate directory, you do not need to write into the GCC
source directory once you have patched the GCC source (see below), and
can build GPC for more than one platform from the same source tree.

In case you are re-using a directory where you have already built GCC
and/or GPC for a different target machine, do @samp{make distclean} to
delete all files that might be invalid. One of the files this deletes is
@file{Makefile}; if @samp{make distclean} complains that @file{Makefile}
does not exist, it probably means that the directory is already suitably
clean.

@item
Configuring and building GCC

GNU Pascal is automatically configured with GCC. Configuration of GCC is
treated in depth in
@ifset INSTALLONLY
the GCC installation instructions.
@end ifset
@ifclear INSTALLONLY
@ref{Installation, the GCC installation
instructions, Chapter 4, gcc, ``Using and Porting GNU CC''}.
@end ifclear
The normal procedure is as follows:

@samp{cd} to the GPC build directory. From there, run the
@samp{configure} script in the GCC source directory:

@smallexample
% cd /home/fred/gpc-build
% /home/fred/gcc-2.95.3/configure --enable-languages=pascal
@end smallexample

This creates all the necessary config files, links and Makefile in the
GCC object directory.

Note 1: The configuration will prompt you for patching the GCC source
for GPC support, so you need write access to that directory. All changes
to GCC are surrounded by @samp{#ifdef GPC @dots{} #endif}, so they
should not interfere when you build a C compiler from this source tree.

Note 2: The @samp{--enable-languages=pascal} option means that we only
want to build the Pascal compiler and not, for instance, the C++
compiler.

Note 3: The standard base directory for installing GCC and GPC is
@file{/usr/local}. If you want to install files to an alternate
directory @var{dir}, specify @samp{--prefix=@var{dir}} when you run
@file{configure}. For installing into a system directory such as
@file{/usr/local} you will, of course, need appropriate permissions
(often root). Therefore, if you want to install GPC on a system
where you don't have those permissions, you must specify a prefix
(e.g., @samp{$HOME/usr}).

@item
Putting other GNU tools in place

Some environments require other GNU tools (such as the GNU assembler or
linker) instead of the standard system tools for GCC to work. (See the
GCC installation instructions for details.) If this is the case for your
system, install the required tools in the GPC build directory under the
names @file{as}, @file{ld}, or whatever is appropriate. This will enable
the compiler to find the proper tools for compilation of the program
@file{enquire} (a part of GCC) and to install the GNU tools to a place
where they are found by GCC but do not interfere with the standard
system tools.

Alternatively, you can do subsequent compilation using a value of the
@code{PATH} environment variable such that the necessary GNU tools come
before the standard system tools.

@item
Compiling GPC

Once you are satisfied with the configuration as determined by
@file{configure}, you can build the compiler:

@smallexample
% make
@end smallexample

Notice that this procedure will build the C compiler (and maybe some
other compilers) too, because that is used to compile the GPC runtime
library.

Optionally, you may supply CFLAGS, LDFLAGS or RTSFLAGS. CFLAGS is used for
compiler and RTS, RTSFLAGS are for RTS only, i.e.:@:
@samp{make CFLAGS="-O2" RTSFLAGS=-Wall}

@strong{Note}: The documentation may fail to build from *.texi
sources if GCC 2.95.x tries to use an older version of
@samp{makeinfo} supplied in GCC package itself. This can be
prevented by supplying explicit instruction to use your system's
@samp{makeinfo}:

@smallexample
% make MAKEINFO=`which makeinfo`
@end smallexample

optionally followed by the rest of arguments.

@item
Completing the installation

When everything has been compiled, you can check the installation
process with:

@smallexample
% make -n install
@end smallexample

To complete the installation, run the command @samp{make install}. You
need write access to the target directories (@file{/usr/local/bin},
@file{/usr/local/lib}, @file{/usr/local/info}, @file{/usr/local/doc},
and @file{/usr/local/man} in this example), so this is usually done as
@samp{root}:

@smallexample
% su -c "make install"
@end smallexample

If you want to install @emph{only} the Pascal compiler (for example if
you already have the correct version of GCC installed), @samp{cd} to the
@samp{gcc} subdirectory of the build directory (e.g.@:
@file{/home/fred/gpc-build/gcc}) and run @samp{make pascal.install}. This
installation process does @strong{not} overwrite existing copies of
@file{libgcc.a} or @file{specs}, should they exist.

However, if you do not have the exactly matching GCC version
installed, you might need some additional files (otherwise GPC will
complain about missing files at runtime). You can install them by
doing @samp{make pascal.install-with-gcc} in the @file{gcc}
subdirectory of the build directory.

There is a (partial) translation of the GPC manual into Croatian
available now. It is not installed by default. If you want to
install it, do a @samp{pascal.install-hr} in the @samp{gcc}
directory. This will install the manpage @file{gpc-hr.1} and the
info documentation @file{gpc-hr.info*}. Other formats like PS, PDF
and HTML can be built manually (it's also easy to add appropriate
make targets for them when needed).

Also from the @samp{gcc} subdirectory you can do some more
``exotic'' builds. For instance, you can build the GPC WWW pages by
typing @samp{make pascal.html} or a binary distribution by typing
@samp{make pascal.bindist}. See the @file{Makefile} in that
directory for more examples.
@end enumerate


@c -------------------------------------------------------------------------


@node Compilation Notes
@section Compilation notes for specific platforms
@cindex Compilation notes for specific platforms
@menu
* MS-DOS with DJGPP::        The DJGPP port of GNU compilers to MS-DOS.
* MS-DOS or OS/2 with EMX::  The EMX port of GNU compilers to MS-DOS and OS/2.
* MS Windows 95/98/NT::      Installation on a Windows 95/98/NT system.
@end menu


@c -------------------------------------------------------------------------


@node MS-DOS with DJGPP
@subsection MS-DOS with DJGPP
@cindex djgpp
@cindex DOS, MS-
@cindex MS-DOS

The only compiler that is capable of compiling the GNU Compiler
Collection (GNU CC or GCC) under MS-DOS is GCC itself. In order to
compile GPC or GCC for MS-DOS with DJGPP you will therefore need
either a working copy of DJGPP installed, or you will have to
cross-build from a non-MS-DOS system.

Building GPC under MS-DOS with DJGPP follows the same scheme as building
GPC under a Unix-like system: Place the @file{p} subdirectory in the
@file{gcc} directory and follow the instructions for compiling GCC. This
requires @samp{bash} and many other tools installed, and you must be
very careful at many places to circumvent the limitations of the DOS
platform.

Our preferred way to build GPC for DJGPP is to cross-build it from a
Unix-like platform -- which is much easier. For instructions, see
@ifset INSTALLONLY
``Cross-compilers'' and ``Crossbuilding'' below.
@end ifset
@ifclear INSTALLONLY
@ref{Cross-Compilers} and @ref{Crossbuilding}.
@end ifclear


@c -------------------------------------------------------------------------


@node MS-DOS or OS/2 with EMX
@subsection MS-DOS or OS/2 with EMX
@cindex EMX
@cindex DOS, MS-
@cindex MS-DOS
@cindex OS/2

EMX is a free 32-bit DOS extender which adds some properties of Unix to
MS-compatible DOS and IBM's OS/2 operating systems.

As of this writing, we are not aware of current versions of GCC for EMX,
and EMX support in GPC has not been maintained. Please contact us if you
know about recent development in EMX and are interested in continuing
EMX support in GPC.


@c -------------------------------------------------------------------------


@node MS Windows 95/98/NT
@subsection MS Windows 95/98/NT
@cindex Windows 95/98/NT, MS
@cindex MS Windows 95/98/NT

There are two ports of the GNU development tools to MS Windows
95/98/NT: CygWin and mingw32.

The CygWin environment implements a POSIX layer under MS Windows,
giving it large parts of the functionality of Unix. Thus, compiling
GCC and GPC under the CygWin environment can be done following the
instructions for compiling it under a Unix-like system
@ifset INSTALLONLY
(see above).
@end ifset
@ifclear INSTALLONLY
(see @ref{Compiling GPC}).
@end ifclear

The Minimalists' GNU Win32 environment, mingw32, uses the native
@file{crtdll.dll} library of MS Windows. It is much smaller than
CygWin, but it is not self-hosting and must be crossbuilt from
another system
@ifset INSTALLONLY
(see below).
@end ifset
@ifclear INSTALLONLY
(see @ref{Crossbuilding}).
@end ifclear


@c -------------------------------------------------------------------------


@node Cross-Compilers
@section Building and Installing a cross-compiler
@cindex cross-compilers

GNU Pascal can function as a cross-compiler for many machines. Information
about GNU tools in a cross-configuration can be found at
@samp{ftp://ftp.cygnus.com/pub/embedded/crossgcc/}.

Since GNU Pascal generates assembler code, you need a cross-assembler
that GNU Pascal can run, in order to produce object files. If you want
to link on other than the target machine, you need a cross-linker as
well. It is straightforward to install the GNU binutils to act as
cross-tools -- see the installation instructions of the GNU binutils for
details.

You also need header files and libraries suitable for the target machine
that you can install on the host machine. Please install them under
@file{@var{prefix}/@var{platform}/include/}, for instance
@file{/usr/local/i386-pc-msdosdjgpp/include/} for a cross-compiler from
a typical Unix-like environment to MS-DOS with DJGPP.

Configuration and compilation of the compiler can then be done using the
scripts @file{cfgpc} and @file{mkgpc} which are included in the source
distribution in the subdirectory @file{p/script}. Please call them with
the @samp{-h} option for instructions.


@c -------------------------------------------------------------------------


@node Crossbuilding
@section Crossbuilding a compiler
@cindex crossbuilding

Using a cross-compiler to build GNU Pascal results in a compiler
binary that runs on the cross-target platform. This is called
``crossbuilding''. A possible reason why anybody would want to do
this, is when the platform on which you want to run the GNU Pascal
compiler is not self-hosting. An example is mingw32.

To crossbuild GNU Pascal, you have to install a cross-compiler for
your target first,
@ifset INSTALLONLY
see above.
@end ifset
@ifclear INSTALLONLY
see @ref{Cross-Compilers}.
@end ifclear

As when building a cross-compiler, configuration and compilation of
the compiler can be done using the scripts @file{cfgpc} and
@file{mkgpc} which are included in the source distribution in the
subdirectory @file{p/script}. Please call them with the @samp{-h}
option for instructions.

@ifset INSTALLONLY
@section Getting help

If you have further questions, please ask them on the GPC mailing
list, @email{gpc@@gnu.de}. To subscribe to the list, write an email
containing ``subscribe gpc'' in the body to
@email{majordomo@@gnu.de}. (The subject will be ignored.)

Have fun with GPC!
@end ifset
