Recent

Author Topic: My script to build FPC 3.2.x under Linux  (Read 636 times)

Roland57

  • Hero Member
  • *****
  • Posts: 613
    • msegui.net
My script to build FPC 3.2.x under Linux
« on: June 29, 2026, 06:46:42 am »
Hello everybody.

I made a script to build FPC 3.2.x under Linux. I paste it here, in case someone would find it useful or would have improvements to suggest.

I chose to build the fixes_3_2 branch of GitLab repository. I use the compiler available with my distribution (Mageia), that is FPC 3.2.2.

Code: Bash  [Select][+][-]
  1. # build-fpc.sh
  2.  
  3. BRANCH=fixes_3_2
  4. URL=https://gitlab.com/freepascal.org/fpc/source.git
  5.  
  6. RELDIR=apps/fpc
  7. DIR=$HOME/$RELDIR
  8.  
  9. git clone --single-branch --depth 1 --branch $BRANCH $URL $DIR
  10.  
  11. cd $DIR
  12.  
  13. make all
  14.  
  15. utils/fpcmkcfg/bin/x86_64-linux/fpcmkcfg -d basepath=$DIR > $DIR/compiler/ppcx64.cfg
  16.  
  17. SCRIPT=$HOME/.local/bin/fpc32
  18.  
  19. cat > $SCRIPT << EOF
  20. FPC=\$HOME/$RELDIR/compiler/ppcx64
  21. \$FPC -n @\$FPC.cfg \$*
  22. EOF
  23.  
  24. chmod +x $SCRIPT
  25.  
  26. fpc32 -iW

The script works:

$ sh build-fpc.sh
...
3.2.3


But when I try to compile a simple program, I get this error:

$ fpc32 hello.pas
Free Pascal Compiler version 3.2.3 [2026/06/15] for x86_64
Copyright (c) 1993-2026 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling hello.pas
Fatal: Can't find unit system used by Program
Fatal: Compilation aborted


I have to do the following correction in configuration file (ppcx64.cfg):

# searchpath for units and other system dependent things
#-Fu/home/roland/apps/fpc/units/$fpctarget
#-Fu/home/roland/apps/fpc/units/$fpctarget/*
#-Fu/home/roland/apps/fpc/units/$fpctarget/rtl
-Fu/home/roland/apps/fpc/rtl/units/$fpctarget
-Fu/home/roland/apps/fpc/rtl/units/$fpctarget/*
-Fu/home/roland/apps/fpc/rtl/units/$fpctarget/rtl


After that, I can compile my simple program.

$ fpc32 hello.pas
Free Pascal Compiler version 3.2.3 [2026/06/15] for x86_64
Copyright (c) 1993-2026 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling hello.pas
Linking hello
28 lines compiled, 0.2 sec
My projects are on Codeberg.

Roland57

  • Hero Member
  • *****
  • Posts: 613
    • msegui.net
Re: My script to build FPC 3.2.x under Linux
« Reply #1 on: June 30, 2026, 10:36:23 am »
So I appended this line to my script:

Code: Bash  [Select][+][-]
  1. sed -i 's|fpc/units|fpc/rtl/units|g' $DIR/compiler/ppcx64.cfg

But now, if I want to use, for example, the RegExpr unit, it is not found. So I had to append this in the configuration file:

-Fu/home/roland/apps/fpc/packages/regexpr/units/$fpctarget

This also seems to work:

-Fu/home/roland/apps/fpc/packages/*/units/$fpctarget

I guess I shouldn't have to edit manually the configuration file.  :-\

I attach the current version of my script.
« Last Edit: June 30, 2026, 10:38:27 am by Roland57 »
My projects are on Codeberg.

Fred vS

  • Hero Member
  • *****
  • Posts: 3952
    • StrumPract is the musicians best friend
Re: My script to build FPC 3.2.x under Linux
« Reply #2 on: June 30, 2026, 03:27:37 pm »

I guess I shouldn't have to edit manually the configuration file.  :-\


Perhaps it's time for fpcmkcfg to receive a major update...  :-X
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12942
  • FPC developer.
Re: My script to build FPC 3.2.x under Linux
« Reply #3 on: June 30, 2026, 04:01:42 pm »
Roland57 doesn't install, so he manually crafts paths into the source repositories units dirs. 

This is not supported, the normal procedure is to "make install" the units.

Roland57

  • Hero Member
  • *****
  • Posts: 613
    • msegui.net
Re: My script to build FPC 3.2.x under Linux
« Reply #4 on: June 30, 2026, 06:28:20 pm »
This is not supported, the normal procedure is to "make install" the units.

I see. Thank you for the explanation.
My projects are on Codeberg.

dbannon

  • Hero Member
  • *****
  • Posts: 3842
    • tomboy-ng, a rewrite of the classic Tomboy
Re: My script to build FPC 3.2.x under Linux
« Reply #5 on: July 01, 2026, 09:47:10 am »
https://github.com/davidbannon/FPC_Laz_Install/blob/main/compile_fpc.bash

and, a companion script that installs the pre-made binaries AND sets up paths etc,

https://github.com/davidbannon/FPC_Laz_Install/blob/main/fpc-tar.bash

Its called 'tar' because it works with tar-balls of precompiled binaries from same github site.

Davo
Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Roland57

  • Hero Member
  • *****
  • Posts: 613
    • msegui.net
Re: My script to build FPC 3.2.x under Linux
« Reply #6 on: July 01, 2026, 08:13:07 pm »
@dbannon

Interesting, thank you.
My projects are on Codeberg.

 

TinyPortal © 2005-2018