F.3 Compiling using make

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 cycle

This will work only if the makefile is installed correctly and if the needed tools are present in the PATH. Which tools must be installed can be found in appendix E.

The above instructions will do the following:

  1. Using the current compiler, the RTL is compiled in the correct directory, which is determined by the OS. e.g. under linux, the RTL is compiled in directory rtl/linux.
  2. The compiler is compiled using the newly compiled RTL. If successful, the newly compiled compiler executable is copied to a temporary executable.
  3. Using the temporary executable from the previous step, the RTL is re-compiled.
  4. Using the temporary executable and the newly compiled RTL from the last step, the compiler is compiled again.

The last two steps are repeated 3 times, until three passes have been made or until the generated compiler binary is equal to the binary it was compiled with. This process ensures that the compiler binary is correct.

Compiling for another target: When compiling the compiler for another target, it is necessary to 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=go32v2

This will compile the go32v2 RTL, and compile a go32v2 compiler.

When compiling a new compiler and the compiler should be compiled using an existing compiled RTL, the all target must be used, and another RTL directory than the default (which is the ../rtl/$(OS_TARGET) directory) must be indicated. For instance, assuming that the compiled RTL units are in /pp/rtl/units/i386-linux, typing

cd compiler  
make clean  
make all UNITDIR=/pp/rtl/units/i386-linux

should use the RTL from the /pp/rtl/units/i386-linux directory.

This will then compile the compiler using the RTL units in /pp/rtl/units/i386-linux. After this has been done, the ’make cycle’ can be used, starting with this compiler:

make cycle PP=./ppc386

This 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. Additional options (e.g. optimization options) can be specified by passing them in OPT.