Bootstrapping FPC for a new architecture

Without pre-compiled binaries

On the bootstrapping machine

1. Check out FPC from SVN:

   $ svn co http://svn.freepascal.org/svn/fpc/trunk/

2. Install the gcc cross toolchain for the target architecture:

   $ apt install gcc-m68k-linux-gnu g++-m68k-linux-gnu cpp-m68k-linux-gnu

4. Enter FPC source directory and build a cross-compiler:

   $ BINUTILSPREFIX=m68k-linux-gnu- make crossall crossinstall CPU_TARGET=m68k CROSSOPT="-Cp68020 -Cf68881 -CaDEFAULT" OS_TARGET=linux FPC=/usr/lib/fpc/3.0.0/ppcx64 INSTALL_PREFIX=/home/glaubitz/fpc-m68k/

5. Build the native compiler:

   $ BINUTILSPREFIX=m68k-linux-gnu- make compiler CPU_TARGET=m68k OS_TARGET=linux FPC=/root/fpc-m68k/lib/fpc/3.1.1/ppcross68k CROSSOPT="-Cp68020 -Cf68881 -CaDEFAULT -Fu/root/fpc-m68k/lib/fpc/3.1.1/units/*

Note: The options for CROSSOPT can be obtained by running "ppcross$CPU" after the initial build without parameters:

   ~/trunk# ./compiler/ppcross68k -ic
   68000
   68020
   68040
   68060
   ISAA
   ISAA+
   ISAB
   ISAC
   CFV4E
   ~/trunk# ./compiler/ppcross68k -if 
   SOFT
   LIBGCC
   68881
   COLDFIRE
   ~/trunk# ./compiler/ppcross68k -ia
   DEFAULT
   ~/trunk#

6. Copy target compiler into directory of cross-compiler:

   $ cp -av compiler/ppc68k /home/glaubitz/fpc-m68k/lib/fpc/3.1.1/

7. Tar the target compiler up to transport it to the target machine:

   $ tar czf fpc-m68k.tgz /home/glaubitz/fpc-m68k

On the target machine

1. Check out FPC from SVN:

   $ svn co http://svn.freepascal.org/svn/fpc/trunk/

2. Untar cross-compiled target compiler:

   $ tar xf fpc-m68k.tgz

3. Build FPC with the bootstrapped FPC:

   $ make FPC=/path/to/ppcbinary FPCDIR=/path/to/fpc/root OVERRIDEVERSIONCHECK=1 all

FPC usually being /usr/local/lib/fpc/x.y.z/ppc$CPU and FPCDIR /usr/local/lib/fpc/x.y.z/ when the tarball generated on the bootstrapping host was extracted into /usr/local.

Then skip to Creating the Debian package

With pre-compiled binaries

1. Download the binaries for your architecture from ftp://ftp.freepascal.org/pub/fpc/dist/ (chose the latest version, then your target).

   $ wget --no-check-certificate https://downloads.sourceforge.net/project/freepascal/Linux/3.0.2/fpc-3.0.2.mipsel-linux.tar

2. Extract the tarball

   $ tar xf fpc-3.0.2.mipsel-linux.tar

3. Run install.sh to install fpc into your home directory or /usr/local (the latter requires root privileges)

   $ cd fpc-3.0.2.mipsel-linux
   $ ./install.sh