The Free Pascal team releases at intervals a completely prepared package, with compiler and units all ready to use, the so-called releases. After a release, work on the compiler continues, bugs are fixed and features are added. The Free Pascal team doesn't make a new release whenever they change something in the compiler, instead the sources are available for anyone to use and compile. Compiled versions of RTL and compiler are also made daily, and put on the web.
There are, nevertheless, circumstances when you'll want to compile the compiler yourself. For instance if you made changes to compiler code, or when you download the compiler via CVS.
There are essentially 2 ways of recompiling the compiler: by hand, or using the makefiles. Each of these methods will be discussed.
To compile the compiler easily, it is best to keep the following directory structure (a base directory of /pp/src is supposed, but that may be different):
/pp/src/Makefile /makefile.fpc /rtl/linux /inc /i386 /... /compilerIf you want to use the makefiles, you must use the above directory tree.
The compiler and rtl source are zipped in such a way that if you unzip both files in the same directory (/pp/src in the above) the above directory tree results.
The makefile.fpc and Makefile come from the base.zip file on the ftp site. If you compile manually, you don't need them.
There are 2 ways to start compiling the compiler and RTL. Both ways must be used, depending on the situation. Usually, the RTL must be compiled first, before compiling the compiler, after which the compiler is compiled using the current compiler. In some special cases the compiler must be compiled first, with a previously compiled RTL.
How to decide which should be compiled first? In general, the answer is that you should compile the RTL first. There are 2 exceptions to this rule:
When compiling with make it is necessary to have the above directory structure. Compiling the compiler is achieved with the target cycle.
Under normal circumstances, recompiling the compiler is limited to the following instructions (assuming you start in directory /pp/src):
cd compiler make cycleThis will work only if the makefile.fpc is installed correctly and if the needed tools are present in the PATH. Which tools must be installed can be found in appendix .
The above instructions will do the following:
Compiling for another target: When you want to compile the compiler for another target, you must specify the OS_TARGET makefile variable. It can be set to the following values: win32, go32v2, os2 and linux. As an example, cross-compilation for the go32v2 target from the win32 target is chosen:
cd compiler make cycle OS_TARGET=go32v2This will compile the go32v2 RTL, and compile a go32v2 compiler.
If you want to compile a new compiler, but you want the compiler to be compiled first using an existing compiled RTL, you should specify the all target, and specify another RTL directory than the default (which is the ../rtl/$(OS_TARGET) directory). For instance, assuming that the compiled RTL units are in /pp/rtl, you could type
cd compiler make clean make all UNITDIR=/pp/rtl
This will then compile the compiler using the RTL units in /pp/rtl. After this has been done, you can do the 'make cycle', starting with this compiler:
make cycle PP=./ppc386This will do the make cycle from above, but will start with the compiler that was generated by the make all instruction.
In all cases, many options can be passed to make to influence the compile process. In general, the makefiles add any needed compiler options to the command-line, so that the RTL and compiler can be compiled. You can specify additional options (e.g. optimization options) by passing them in OPT.
Compiling by hand is difficult and tedious, but can be done. We'll treat the compilation of RTL and compiler separately.
ppc386 -Tlinux -b- -Fi../inc -Fi../i386 -FE. -di386 -Us -Sg syslinux.pp ppc386 -Tlinux -b- -Fi../inc -Fi../i386 -FE. -di386 ../inc/strings.pp ppc386 -Tlinux -b- -Fi../inc -Fi../i386 -FE. -di386 dos.pp ppc386 -Tlinux -b- -Fi../inc -Fi../i386 -FE. -di386 ../inc/objects.ppThese are the minimum command-line options, needed to compile the RTL.
For another processor, you should change the i386 into the appropriate processor. For another operating system (target) you should change the syslinux in the appropriate system unit file, and you should change the target OS setting (-T).
Depending on the target OS there are other units that you may wish to compile, but which are not strictly needed to recompile the compiler. The following units are available for all plaforms:
Compiling the compiler can be done with one statement. It's always best to remove all units from the compiler directory first, so something like
rm *.ppu *.oon LINUX, and on DOS
del *.ppu del *.oAfter this, the compiler can be compiled with the following command-line:
ppc386 -Tlinux -Fu../rtl/linux -di386 -dGDB pp.pasSo, the minimum options are:
ppc386 -di386 -Sg pp.pas
You can define some other command-line options, but the above are the minimum. A list of recognised options can be found in table (FPCdefines) .
Define | does what |
USE_RHIDE | Generates errors and warnings in a format recognized |
by RHIDE. | |
TP | Needed to compile the compiler with Turbo or Borland Pascal. |
Delphi | Needed to compile the compiler with Delphi from Borland. |
GDB | Support of the GNU Debugger. |
I386 | Generate a compiler for the Intel i386+ processor family. |
M68K | Generate a compiler for the M68000 processor family. |
USEOVERLAY | Compiles a TP version which uses overlays. |
EXTDEBUG | Some extra debug code is executed. |
SUPPORT_MMX | only i386: enables the compiler switch MMX which |
allows the compiler to generate MMX instructions. | |
EXTERN_MSG | Don't compile the msgfiles in the compiler, always use |
external messagefiles (default for TP). | |
NOAG386INT | no Intel Assembler output. |
NOAG386NSM | no NASM output. |
NOAG386BIN | leaves out the binary writer. |