Go to the first, previous, next, last section, table of contents.
This chapter covers:
- Compilation of the source distribution on a UNIX system
- Configuration dependent compilation notes
- Building and installing a cross-compiler
- Installation instructions for a GPC binary distribution
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 section Installation instructions for a GPC binary distribution how to install a binary distribution.
GPC is based on GNU CC; you will need the GCC sources to build it. It must be
the same version as the one GPC is implemented with. Although you need GCC to
build the GNU Pascal compiler, you don't need GCC to compile Pascal programs
once GNU Pascal is installed. Because GNU Pascal shares its backend with
GNU CC, it should run on any system supported by GNU CC. A full list of
platforms supported by GNU CC can be found in chapter 4 of the GCC manual,
"Using and Porting GNU CC"
Here is the generic procedure for installing GNU Pascal on a Unix system.
See section Configuration dependent compilation notes for extra information needed to install GPC on certain platforms.
- Unpack the source distributions.
Sources for GNU CC and GNU Pascal must be unpacked in separate directories.
Do not move GNU Pascal files into the GNU C source directory.
It is possible, though not required, to build the compiler(s) in a directory
other than the one containing the sources. In either case, you need a
`make' that understands the VPATH variable. GNU make does, although at
least GNU make version 3.71 has a bug in the way it treats VPATH.
GNU make version 3.74 is known to work.
If you have built GNU Pascal previously in the same directory for a
different target machine, do `make distclean' to delete all files
that might be invalid. One of the files this deletes is
`Makefile'; if `make distclean' complains that `Makefile'
does not exist, it probably means that the directory is already suitably
clean.
- Configuring and building GNU CC
GNU Pascal shares its configuration with GNU CC. The configuration options you
select for GCC, apply for GNU Pascal too. Configuration of GNU CC is treated in
depth in Chapter 4 of "Using and Porting GNU CC"
Chdir to the GCC object directory. Usually,
% ../gcc-2.7.2.1/configure --prefix=/usr
will do the job. This creates all the necessary config files, links and
Makefile in the GCC object directory.
-
The standard directory for installing GNU CC and GNU Pascal is
`/usr/local/lib'. If you want to install its files somewhere else,
specify `--prefix=dir' when you run `configure'.
Here dir is a directory name to use instead of `/usr/local' for
all purposes with one exception: the directory `/usr/local/include'
is searched for header files no matter where you install the compiler.
To override this name, use the
--local-prefix
option below.
-
Specify `--local-prefix=dir' if you want the compiler to
search directory `dir/include' for locally installed header
files instead of `/usr/local/include'.
You should specify `--local-prefix' only if your site has
a different convention (not `/usr/local') for where to put
site-specific files.
Do not specify `/usr' as the `--local-prefix'! The
directory you use for `--local-prefix' must not contain
any of the system's standard header files. If it did contain them,
certain programs would be miscompiled (including GNU Emacs, on certain
targets), because this would override and nullify the header file
corrections made by the
fixincludes
script.
-
Make sure the Bison parser generator is installed. (This is
unnecessary if the Bison output files `c-parse.c' and
`cexp.c' are more recent than `c-parse.y' and `cexp.y'
and you do not plan to change the `.y' files.)
Bison versions older than Sept 8, 1988 will produce incorrect output
for `c-parse.c'.
-
If you have chosen a configuration for GNU Pascal which requires other GNU
tools (such as GAS or the GNU linker) instead of the standard system
tools, install the required tools in the build directory under the names
`as', `ld' or whatever is appropriate. This will enable the
compiler to find the proper tools for compilation of the program
`enquire'.
Alternatively, you can do subsequent compilation using a value of the
PATH
environment variable such that the necessary GNU tools come
before the standard system tools.
-
Build the C compiler:
% make LANGUAGES=c
(Just `make' would also build the C++ and Objective C compilers).
You do not need to install the compiler you just built, but leave the
objects in place, since GPC will directly load most of the GCC object files.
- Configuring and building GNU Pascal for your system.
Normally, you just `cd' to the directory containing the source code and
type `./configure'. If you're using `csh' on an old version of
System V, you might need to type `sh configure' instead to prevent
`csh' from trying to execute `configure' itself (under AIX, you
may need to use ksh instead of sh).
To compile the GNU Pascal in a different directory from the one
containing the source code, `cd' to the directory where you want the
object files and executables to go and run the `configure' script.
`configure' automatically checks for the source code in the directory
that `configure' is in. If for some reason `configure' is not able
to find the source directory, rerun `configure' with the option
`--srcdir=dir', where dir is the directory that contains
the source code.
Note that the gpc `configure' script does not accept most of the
switches usually given to a `configure' script because it extracts
this information from the GCC configuration files.
Run `configure --help' to see the options supported by `configure'.
Running `configure' takes a while. While it is running, it
prints some messages that tell what it is doing. If you don't want to
see any messages, run `configure' with its standard output redirected
to /dev/null; for example, `./configure >/dev/null'.
If `configure' is unable to locate GNU CC sources or object code, it
will print an error message and exit. In that case, run `configure'
again with `--with-gccsrc=dir' and / or
`--with-gccbin=dir' arguments.
When it is finished, `configure' prints a short summary of the
information it has collected.
--------------------------------------------------------------------------
Configuration summary:
Building a native i386-freebsd2.1.0 compiler
GPC sources in: .
GCC sources in: ../gcc-2.7.2.1
GCC object code in: ../gcc-2.7.2.1
GCC version: 2.7.2.1
Compiler for GPC: gcc
Compiler for libgpc.a: gcc
Compiler flags: -g -O
Installation path: /usr/bin, /usr/lib/gcc-lib/i386-freebsd2.1.0/2.7.2.1
--------------------------------------------------------------------------
Now, type `make' to build the compiler and runtime system.
- Building the compiler.
Once you are satisfied with the configuration as determined
by `configure', you can build the compiler:
% make
Optionally, you may supply CFLAGS, LDFLAGS or RTSFLAGS. CFLAGS is used for
compiler and RTS, RTSFLAGS are for RTS only, i.e.:
`make CFLAGS="-O2" RTSFLAGS=-Wall'
-
When everything compiles, you can verify what the
make -n install
command does, and if you are satisfied run it without the -n
option
to install the compiler (gpc1), front end (gpc), run time system (libgpc.a)
to the same place where gcc was installed.
It is sort of stupid to have a separate incarnation of `gcc.c'; the
difference now is that `gpc' also searches from library `libgpc.a'
and `-lm'. In addition `gcc.c' specifies the interface to the
Pascal compiler (gpc1). This command will vanish when `gcc' knows how to
compile Pascal programs.
Go to the first, previous, next, last section, table of contents.