Difference between revisions of "Build current FPC and Lazarus for Raspbian"

From Free Pascal wiki
Jump to navigationJump to search
m
m
Line 3: Line 3:
 
Requirements:
 
Requirements:
  
* Raspberry Pi 4 4 GB (less memory models would require swap)
+
* Raspberry Pi 4 Model B, 4 GB (less memory models would require swap)
 
* Latest Raspbian Buster fully updated
 
* Latest Raspbian Buster fully updated
  
Line 13: Line 13:
 
# In this directory, as pi user, run <code>./install.sh</code>
 
# In this directory, as pi user, run <code>./install.sh</code>
 
# At the four prompts, answer <code>Enter, n, n, n</code>: this is, accept suggested directory <code>/home/pi/fpc-3.0.2</code>, no Textmode IDE, no documentation, no demos. Ignore <code>tar</code> warnings. Note the additional files written to <code>/home/pi</code>: <code>.fpc.cfg</code>, <code>.config/fppkg.cfg</code>, <code>.fppkg/config/default</code>. When the build is done, to delete this temporary bootstrap compiler these files and the <code>/home/pi/fpc-3.0.2</code> install directory need to be deleted.
 
# At the four prompts, answer <code>Enter, n, n, n</code>: this is, accept suggested directory <code>/home/pi/fpc-3.0.2</code>, no Textmode IDE, no documentation, no demos. Ignore <code>tar</code> warnings. Note the additional files written to <code>/home/pi</code>: <code>.fpc.cfg</code>, <code>.config/fppkg.cfg</code>, <code>.fppkg/config/default</code>. When the build is done, to delete this temporary bootstrap compiler these files and the <code>/home/pi/fpc-3.0.2</code> install directory need to be deleted.
# Temporarily add FPC install directory to PATH: <code>export PATH=$PATH:$HOME/fpc-3.0.2/bin</code>. If you reboot before completing the build you have to do this step again.
+
# Temporarily add FPC install directory to PATH: <code>export PATH=$PATH:$HOME/fpc-3.0.2/bin</code>. If you have to reboot for any reason before completing the FPC build, you have to do this step again.
 
# Test if all ok: <code>fpc abcd</code>. This invokes the just installed compiler trying to compile a non-existent file (abcd). A multiline message will be shown including the compiler version.
 
# Test if all ok: <code>fpc abcd</code>. This invokes the just installed compiler trying to compile a non-existent file (abcd). A multiline message will be shown including the compiler version.
 
# Non-step note: the following steps are mostly based on [https://wiki.lazarus.freepascal.org/How_to_setup_a_FPC_and_Lazarus_Ubuntu_repository#Creating_the_deb_files_yourself this]
 
# Non-step note: the following steps are mostly based on [https://wiki.lazarus.freepascal.org/How_to_setup_a_FPC_and_Lazarus_Ubuntu_repository#Creating_the_deb_files_yourself this]
Line 23: Line 23:
 
# <code>cd lazarus/tools/install</code>
 
# <code>cd lazarus/tools/install</code>
 
# Edit <code>create_fpc_deb.sh</code>, look for line with the following content: <code>arm)    ppcbin=arm;  FPCArch=arm;;</code>, (currently line 109). Copy and paste this line below itself, so it will appear twice. Edit this copy to read like this: <code>armhf)  ppcbin=arm;  FPCArch=arm;;</code>
 
# Edit <code>create_fpc_deb.sh</code>, look for line with the following content: <code>arm)    ppcbin=arm;  FPCArch=arm;;</code>, (currently line 109). Copy and paste this line below itself, so it will appear twice. Edit this copy to read like this: <code>armhf)  ppcbin=arm;  FPCArch=arm;;</code>
# <code>./create_fpc_deb.sh fpc ~/pascal/fpc/</code>. This will compile the latest compiler with the bootstrap compiler.
+
# <code>./create_fpc_deb.sh fpc ~/pascal/fpc/</code>. This will compile the latest compiler with the bootstrap compiler. It takes about 13 minutes; after the first 10 minutes the CPU starts throttling. A <code>.deb</code> file will be created, in this example it ended up being <code>fpc-laz_3.0.4-190826_armhf.deb</code>; the exact name will be show at the end of the compilation.
 +
# You have completed the FPC build. Reboot the Pi to get rid of the temporary PATH.
 +
# Uninstall the bootstrap FPC: <code>rm -rf ~/.fpc.cfg ~/.config/fppkg.cfg ~/.fppkg ~/fpc-3.0.2</code>
 +
# Install the just created FPC Debian package: <code>sudo dpkg -i ~/pascal/lazarus/tools/install/fpc-laz_3.0.4-190826_armhf.deb</code>

Revision as of 06:55, 27 August 2019

Raspbian Buster (based on Debian 10 Buster) has FPC and Lazarus available in the repositories, but they suffer from the same "design decisions" that don't allow for a nice experience, namely the smooth IDE rebuilding capability based on source packages that is possible with FPC/Lazarus official .deb packages vs the crippled experience with the official Debian/Raspbian packages. One wishes there were official FPC/Lazarus packages for Raspbian as there are for Intel Debian/Ubuntu, which are also frequently updated; not being that the case (at least for now), this page shows the steps for building your own FPC, FPC-source and Lazarus packages for Raspbian. Example shows steps for Lazarus 2.0.4 which includes FPC 3.0.4, most recent at the time of writing. Adjust accordingly.

Requirements:

  • Raspberry Pi 4 Model B, 4 GB (less memory models would require swap)
  • Latest Raspbian Buster fully updated

Steps:

  1. Install subversion: sudo apt install subversion
  2. Get bootstrap FPC compiler. The latest compiler is compiled with the previous version of itself.
  3. Extract compiler. This will create a fpc-3.0.2.arm-linux directory.
  4. In this directory, as pi user, run ./install.sh
  5. At the four prompts, answer Enter, n, n, n: this is, accept suggested directory /home/pi/fpc-3.0.2, no Textmode IDE, no documentation, no demos. Ignore tar warnings. Note the additional files written to /home/pi: .fpc.cfg, .config/fppkg.cfg, .fppkg/config/default. When the build is done, to delete this temporary bootstrap compiler these files and the /home/pi/fpc-3.0.2 install directory need to be deleted.
  6. Temporarily add FPC install directory to PATH: export PATH=$PATH:$HOME/fpc-3.0.2/bin. If you have to reboot for any reason before completing the FPC build, you have to do this step again.
  7. Test if all ok: fpc abcd. This invokes the just installed compiler trying to compile a non-existent file (abcd). A multiline message will be shown including the compiler version.
  8. Non-step note: the following steps are mostly based on this
  9. Install development libraries: sudo apt install libgtk2.0-dev libgpm-dev libncurses-dev
  10. mkdir ~/pascal
  11. cd ~/pascal
  12. svn co https://svn.freepascal.org/svn/fpc/tags/release_3_0_4 fpc, you have to be online for this and the next step to work.
  13. svn co https://svn.freepascal.org/svn/lazarus/tags/lazarus_2_0_4 lazarus
  14. cd lazarus/tools/install
  15. Edit create_fpc_deb.sh, look for line with the following content: arm) ppcbin=arm; FPCArch=arm;;, (currently line 109). Copy and paste this line below itself, so it will appear twice. Edit this copy to read like this: armhf) ppcbin=arm; FPCArch=arm;;
  16. ./create_fpc_deb.sh fpc ~/pascal/fpc/. This will compile the latest compiler with the bootstrap compiler. It takes about 13 minutes; after the first 10 minutes the CPU starts throttling. A .deb file will be created, in this example it ended up being fpc-laz_3.0.4-190826_armhf.deb; the exact name will be show at the end of the compilation.
  17. You have completed the FPC build. Reboot the Pi to get rid of the temporary PATH.
  18. Uninstall the bootstrap FPC: rm -rf ~/.fpc.cfg ~/.config/fppkg.cfg ~/.fppkg ~/fpc-3.0.2
  19. Install the just created FPC Debian package: sudo dpkg -i ~/pascal/lazarus/tools/install/fpc-laz_3.0.4-190826_armhf.deb