Instalar, Configurar e Usar o compilador de programas GCC. Passcal muito mais robusto e sem mistérios ou segredos.
- Checking the prerequisites
Make sure that GNU make is installed and that you use it in the following steps. When unsure, you can try make –version and/or gmake –version. It should tell you that it is GNU make. If you don’t have it, you can obtain it from http://www.gnu.org/software/make/.
(In the following, we will simply speak of make when invoking GNU make; you might need to call gmake instead.)
You also need a patch program. If such a program is not installed on your system, you can get GNU patch from http://www.gnu.org/directory/patch.html.
For extracting the example programs from the documentation to the doc/docdemos directory a non-crippled sed is needed. GNU sed is known to work.
bash, bzip2, GNU sed, GNU awk, GNU m4, bison (at least version 2.0), flex (version 2.5.27), autoconf (version 2.12), texinfo (at least version 4.2), help2man.
Make sure that these are installed. The minimal distributions are compressed with bzip2 instead of 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 configure:
FLEX=/path/to/flex LEX=/path/to/flex BISON=/path/to/bison YACC=/path/to/bison INTLBISON=/path/to/bison
If you want to build the GPC WWW pages you will also need a TeX distribution (including pdftex and 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 http://www.gnu.org/software/, in a subdirectory whose name is the name of the package.
- Unpacking the source
From a directory of your choice (e.g. /home/fred), unpack the GCC and GNU Pascal source distributions. This will create separate subdirectories for GCC and GPC. Let us assume gcc-2.95.3 and gpc-20030209 in this example.
% cd /home/fred % gzip -c -d gcc-core-2.95.3.tar.gz | tar xf - % gzip -c -d gpc-20030209.tar.gz | tar xf -
cd to the GPC directory and move the contents (a subdirectory p) to the subdirectory gcc of the GCC directory:
% mv /home/fred/gpc-20030209/p /home/fred/gcc-2.95.3/gcc/
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:
% ln -s /home/fred/gpc-20030209/p /home/fred/gcc-2.95.3/gcc/p
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 /home/fred/gpc-build for this purpose:
% mkdir /home/fred/gpc-build
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 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 GCC
GNU Pascal is automatically configured with GCC. Configuration of GCC is treated in depth in the GCC installation instructions (“Using and Porting GNU CC”). The normal procedure is as follows:
cd to the GPC build directory. From there, run the configure script in the GCC source directory:
% cd /home/fred/gpc-build % /home/fred/gcc-2.95.3/configure --enable-languages=pascal
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 #ifdef GPC … #endif, so they should not interfere when you build a C compiler from this source tree.
Note 2: The –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 /usr/local. If you want to install files to an alternate directory dir, specify –prefix=dir when you run configure. For installing into a system directory such as /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., $HOME/usr).
- 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 as, ld, or whatever is appropriate. This will enable the compiler to find the proper tools for compilation of the program 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
PATH environment variable such that the necessary GNU tools come before the standard system tools.
- Compiling GPC
Once you are satisfied with the configuration as determined by configure, you can build the compiler:
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.: make CFLAGS=”-O2″ RTSFLAGS=-Wall
Note: The documentation may fail to build from *.texi sources if GCC 2.95.x tries to use an older version of makeinfo supplied in GCC package itself. This can be prevented by supplying explicit instruction to use your system’s makeinfo:
% make MAKEINFO=`which makeinfo`
optionally followed by the rest of arguments.
- Completing the installation
When everything has been compiled, you can check the installation process with:
% make -n install
To complete the installation, run the command make install. You need write access to the target directories (/usr/local/bin, /usr/local/lib, /usr/local/info, /usr/local/doc, and /usr/local/man in this example), so this is usually done as root:
% su -c "make install"
If you want to install only the Pascal compiler (for example if you already have the correct version of GCC installed), cd to the gcc subdirectory of the build directory (e.g. /home/fred/gpc-build/gcc) and run make pascal.install. This installation process does not overwrite existing copies of libgcc.a or 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 make pascal.install-with-gcc in the 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 pascal.install-hr in the gcc directory. This will install the manpage gpc-hr.1 and the info documentation 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 gcc subdirectory you can do some more “exotic” builds. For instance, you can build the GPC WWW pages by typing make pascal.html or a binary distribution by typing make pascal.bindist. See the Makefile in that directory for more examples.
http://www.konlinux.com.br – fundada em 2002 – Conhecimento é um bem da Humanidade.