Difference between revisions of "Building from Source"

From Ultibo.org
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
=== Building the Ultibo RTL ===
 
=== Building the Ultibo RTL ===
 
----
 
----
 +
 +
<span style="color: red">'''Note: Most of the steps described below are now handled automatically by the Ultibo RTL Builder, simply select Build Ultibo RTL ... from the Tools menu in Lazarus and follow the instructions.'''
  
 
Ultibo core is actively being developed with new features and bug fixes added regularly. New releases of the installer download will be made available regularly but not as frequently as changes to the Ultibo core source itself, being open source also means that you have the opportunity to modify the source and experiment with ideas and changes (you might even choose to contribute some of those changes).
 
Ultibo core is actively being developed with new features and bug fixes added regularly. New releases of the installer download will be made available regularly but not as frequently as changes to the Ultibo core source itself, being open source also means that you have the opportunity to modify the source and experiment with ideas and changes (you might even choose to contribute some of those changes).
Line 8: Line 10:
 
The latest version of the Ultibo core source is always available on GitHub in the [https://github.com/ultibohub/Core Ultibo Core] repository and can be downloaded as a zip file, or if you are comfortable with using git you can clone your own copy of it.  
 
The latest version of the Ultibo core source is always available on GitHub in the [https://github.com/ultibohub/Core Ultibo Core] repository and can be downloaded as a zip file, or if you are comfortable with using git you can clone your own copy of it.  
  
The folder structure of the repository is exactly the same as what is used by the Ultibo core installation so you can simply unzip the downloaded file and copy it over the top of what was installed. The repository starts at the <code>source</code> folder, if you look at your installation you will find the same folder at <code>C:\Ultibo\Core\fpc\3.1.1</code> so all you need to do is copy the contents of the zip to this folder and it will overwrite the current version with the new one.
+
The folder structure of the repository is exactly the same as what is used by the Ultibo core installation so you can simply unzip the downloaded file and copy it over the top of what was installed. The repository starts at the <code>source</code> folder, if you look at your installation you will find the same folder at <code>C:\Ultibo\Core\fpc\3.2.2</code> so all you need to do is copy the contents of the zip to this folder and it will overwrite the current version with the new one.
  
  
Line 33: Line 35:
 
----
 
----
  
The version of Free Pascal (FPC) included with Ultibo core has been modified to add the Ultibo target (-Tultibo) and to enable linking of the executable produced into a form that is suitable for use on Raspberry Pi. The complete source of the modified FPC can be found on GitHub in the [https://github.com/ultibohub/FPC Ultibo FPC] repository and can be downloaded (zip or clone) and overlayed onto the Ultibo core installation to allow rebuilding of FPC.
+
The version of Free Pascal (FPC) included with Ultibo core has been modified to add the Ultibo target (-Tultibo) and to enable linking of the executable produced into a form that is suitable for use on Raspberry Pi. The complete source of the modified FPC can be found on GitHub in the [https://github.com/ultibohub/FreePascal Ultibo FreePascal] repository and can be downloaded (zip or clone) and overlayed onto the Ultibo core installation to allow rebuilding of FPC.
  
 
These instructions only relate to building the ARM cross compiler and use the native compiler installed with Ultibo core to perform the build, you can find instructions in the Free Pascal Wiki for building a native compiler for your platform if required.
 
These instructions only relate to building the ARM cross compiler and use the native compiler installed with Ultibo core to perform the build, you can find instructions in the Free Pascal Wiki for building a native compiler for your platform if required.
Line 39: Line 41:
 
Once you have the sources installed, open a command prompt and change to the directory where the FPC sources for Ultibo core are installed:
 
Once you have the sources installed, open a command prompt and change to the directory where the FPC sources for Ultibo core are installed:
  
  cd C:\Ultibo\Core\fpc\3.1.1\source
+
  cd C:\Ultibo\Core\fpc\3.2.2\source
  
 
Set the path to include the Free Pascal compiler version used by Ultibo core:
 
Set the path to include the Free Pascal compiler version used by Ultibo core:
  
  set path=C:\Ultibo\Core\fpc\3.1.1\bin\i386-Win32
+
  set path=C:\Ultibo\Core\fpc\3.2.2\bin\i386-Win32
  
 
Delete any instances of fpmake.exe otherwise make will fail with an error (they will be recreated as part of the build):
 
Delete any instances of fpmake.exe otherwise make will fail with an error (they will be recreated as part of the build):
Line 51: Line 53:
 
Do a make distclean to remove files leftover after previous builds:
 
Do a make distclean to remove files leftover after previous builds:
  
  make distclean OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a BINUTILSPREFIX=arm-ultibo- CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -OoFASTMATH" FPC=C:/Ultibo/Core/fpc/3.1.1/bin/i386-win32/ppc386.exe
+
  make distclean OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a BINUTILSPREFIX=arm-ultibo- FPCOPT="-dFPC_ARMHF" CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -CaEABIHF -OoFASTMATH" FPC=C:/Ultibo/Core/fpc/3.2.2/bin/i386-win32/ppc386.exe
  
 
Check for any errors and run make all to build the compiler, rtl and packages:
 
Check for any errors and run make all to build the compiler, rtl and packages:
  
  make all OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a BINUTILSPREFIX=arm-ultibo- CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -OoFASTMATH" FPC=C:/Ultibo/Core/fpc/3.1.1/bin/i386-win32/ppc386.exe
+
  make all OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a BINUTILSPREFIX=arm-ultibo- FPCOPT="-dFPC_ARMHF" CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -CaEABIHF -OoFASTMATH" FPC=C:/Ultibo/Core/fpc/3.2.2/bin/i386-win32/ppc386.exe
  
 
If that was successful, run make crossinstall to install the new cross compiler, rtl and packages
 
If that was successful, run make crossinstall to install the new cross compiler, rtl and packages
  
  make crossinstall BINUTILSPREFIX=arm-ultibo- CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -OoFASTMATH" OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a FPC=C:/Ultibo/Core/fpc/3.1.1/bin/i386-win32/ppc386.exe INSTALL_BASEDIR=C:/Ultibo/Core/fpc/3.1.1
+
  make crossinstall BINUTILSPREFIX=arm-ultibo- FPCOPT="-dFPC_ARMHF" CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -CaEABIHF -OoFASTMATH" OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a FPC=C:/Ultibo/Core/fpc/3.2.2/bin/i386-win32/ppc386.exe INSTALL_BASEDIR=C:/Ultibo/Core/fpc/3.2.2
  
The cross install will place all of the rtl and package files in the folder C:\Ultibo\Core\fpc\3.1.1\units\arm-ultibo but since these build instructions specify ARMV7A they will not be usable for Raspberry Pi A, B, A+, B+ and Zero. To resolve this delete the entire arm-ultibo folder in C:\Ultibo\Core\fpc\3.1.1\units and follow the instructions above to rebuild the Ultibo RTL for both ARMv6 and ARMv7.
+
The cross install will place all of the rtl and package files in the folder C:\Ultibo\Core\fpc\3.2.2\units\arm-ultibo but since these build instructions specify ARMV7A they will not be usable for Raspberry Pi A, B, A+, B+ and Zero. To resolve this delete the entire arm-ultibo folder in C:\Ultibo\Core\fpc\3.2.2\units and follow the instructions above to rebuild the Ultibo RTL for both ARMv6 and ARMv7.
  
 
=== Building Lazarus ===
 
=== Building Lazarus ===
Line 68: Line 70:
 
Building or rebuilding Lazarus follows almost exactly the instructions provided with the official sources. The changes made to Lazarus for the Ultibo edition relate mostly to adding and removing menu items and options that are not relevant to embedded development, some of the makefiles have also been modified to remove components and reduce the size of what is distributed.
 
Building or rebuilding Lazarus follows almost exactly the instructions provided with the official sources. The changes made to Lazarus for the Ultibo edition relate mostly to adding and removing menu items and options that are not relevant to embedded development, some of the makefiles have also been modified to remove components and reduce the size of what is distributed.
  
You will need to add the modified Lazarus sources to your installation before you can build Lazarus, these can be downloaded from the [https://github.com/ultibohub/Lazarus Ultibo Lazarus] repository on GitHub. Either download the zip or clone the repository depending on your preference and then overlay the downloaded sources onto your Ultibo core installation.
+
You will need to add the modified Lazarus sources to your installation before you can build Lazarus, these can be downloaded from the [https://github.com/ultibohub/LazarusIDE Ultibo LazarusIDE] repository on GitHub. Either download the zip or clone the repository depending on your preference and then overlay the downloaded sources onto your Ultibo core installation.
  
 
Once you have the sources installed, open a command prompt and change to the directory where Ultibo core is installed:
 
Once you have the sources installed, open a command prompt and change to the directory where Ultibo core is installed:
Line 76: Line 78:
 
Set the path to include the Free Pascal compiler version used by Ultibo core:
 
Set the path to include the Free Pascal compiler version used by Ultibo core:
  
  set path=C:\Ultibo\Core\fpc\3.1.1\bin\i386-Win32
+
  set path=C:\Ultibo\Core\fpc\3.2.2\bin\i386-Win32
  
 
Use make to build Lazarus and all the required components:
 
Use make to build Lazarus and all the required components:

Latest revision as of 05:58, 23 May 2022

Building the Ultibo RTL


Note: Most of the steps described below are now handled automatically by the Ultibo RTL Builder, simply select Build Ultibo RTL ... from the Tools menu in Lazarus and follow the instructions.

Ultibo core is actively being developed with new features and bug fixes added regularly. New releases of the installer download will be made available regularly but not as frequently as changes to the Ultibo core source itself, being open source also means that you have the opportunity to modify the source and experiment with ideas and changes (you might even choose to contribute some of those changes).

To take advantage of fixes and enhancements in the Ultibo core source without waiting for a new release of the installer you will need to rebuild the Ultibo run time library (RTL).

The latest version of the Ultibo core source is always available on GitHub in the Ultibo Core repository and can be downloaded as a zip file, or if you are comfortable with using git you can clone your own copy of it.

The folder structure of the repository is exactly the same as what is used by the Ultibo core installation so you can simply unzip the downloaded file and copy it over the top of what was installed. The repository starts at the source folder, if you look at your installation you will find the same folder at C:\Ultibo\Core\fpc\3.2.2 so all you need to do is copy the contents of the zip to this folder and it will overwrite the current version with the new one.


To make the process of building the RTL as quick and easy as possible we have included a tool to take care of the process for you, in Lazarus go to Build Ultibo RTL ... in the Tools menu to start the Ultibo RTL Builder tool.

BuildFromSource-BuildRTL.png


You can choose to build either the ARMv6 or ARMv7 versions of the RTL or both, simply click the Build button to start the process.

BuildFromSource-RTLBuilder.png


When the build process has completed you will see a message at the bottom of the RTL Builder window indicating the result, if errors are shown check the message for more information.

BuildFromSource-RTLBuilder-Completed.png


After completing the process, all applications compiled in Lazarus will use the latest version of the RTL and include any new features or fixes provided.

Note: It may be best to restart Lazarus after rebuilding the RTL to ensure it uses only the latest versions

Building Free Pascal


The version of Free Pascal (FPC) included with Ultibo core has been modified to add the Ultibo target (-Tultibo) and to enable linking of the executable produced into a form that is suitable for use on Raspberry Pi. The complete source of the modified FPC can be found on GitHub in the Ultibo FreePascal repository and can be downloaded (zip or clone) and overlayed onto the Ultibo core installation to allow rebuilding of FPC.

These instructions only relate to building the ARM cross compiler and use the native compiler installed with Ultibo core to perform the build, you can find instructions in the Free Pascal Wiki for building a native compiler for your platform if required.

Once you have the sources installed, open a command prompt and change to the directory where the FPC sources for Ultibo core are installed:

cd C:\Ultibo\Core\fpc\3.2.2\source

Set the path to include the Free Pascal compiler version used by Ultibo core:

set path=C:\Ultibo\Core\fpc\3.2.2\bin\i386-Win32

Delete any instances of fpmake.exe otherwise make will fail with an error (they will be recreated as part of the build):

del fpmake.exe /s

Do a make distclean to remove files leftover after previous builds:

make distclean OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a BINUTILSPREFIX=arm-ultibo- FPCOPT="-dFPC_ARMHF" CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -CaEABIHF -OoFASTMATH" FPC=C:/Ultibo/Core/fpc/3.2.2/bin/i386-win32/ppc386.exe

Check for any errors and run make all to build the compiler, rtl and packages:

make all OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a BINUTILSPREFIX=arm-ultibo- FPCOPT="-dFPC_ARMHF" CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -CaEABIHF -OoFASTMATH" FPC=C:/Ultibo/Core/fpc/3.2.2/bin/i386-win32/ppc386.exe

If that was successful, run make crossinstall to install the new cross compiler, rtl and packages

make crossinstall BINUTILSPREFIX=arm-ultibo- FPCOPT="-dFPC_ARMHF" CROSSOPT="-CpARMV7A -CfVFPV3 -CIARM -CaEABIHF -OoFASTMATH" OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a FPC=C:/Ultibo/Core/fpc/3.2.2/bin/i386-win32/ppc386.exe INSTALL_BASEDIR=C:/Ultibo/Core/fpc/3.2.2

The cross install will place all of the rtl and package files in the folder C:\Ultibo\Core\fpc\3.2.2\units\arm-ultibo but since these build instructions specify ARMV7A they will not be usable for Raspberry Pi A, B, A+, B+ and Zero. To resolve this delete the entire arm-ultibo folder in C:\Ultibo\Core\fpc\3.2.2\units and follow the instructions above to rebuild the Ultibo RTL for both ARMv6 and ARMv7.

Building Lazarus


Building or rebuilding Lazarus follows almost exactly the instructions provided with the official sources. The changes made to Lazarus for the Ultibo edition relate mostly to adding and removing menu items and options that are not relevant to embedded development, some of the makefiles have also been modified to remove components and reduce the size of what is distributed.

You will need to add the modified Lazarus sources to your installation before you can build Lazarus, these can be downloaded from the Ultibo LazarusIDE repository on GitHub. Either download the zip or clone the repository depending on your preference and then overlay the downloaded sources onto your Ultibo core installation.

Once you have the sources installed, open a command prompt and change to the directory where Ultibo core is installed:

cd C:\Ultibo\Core

Set the path to include the Free Pascal compiler version used by Ultibo core:

set path=C:\Ultibo\Core\fpc\3.2.2\bin\i386-Win32

Use make to build Lazarus and all the required components:

make clean all

Make will report any errors, otherwise once the build is completed the newly compiled version of Lazarus will be ready to use.

Additional Information


The information on this page is specific to building FPC and Lazarus on Windows but should be able to be modified to suit other platforms such as Linux or Mac OS X. The links below provide more detailed information on building and installing FPC and Lazarus for users with advanced requirements.

  • Building Lazarus - Detailed information and examples for building and installing Lazarus and FPC on a variety of platforms.
  • Build FAQ - The official Free Pascal build FAQ with full details on how to build FPC for many platforms.
  • Cross Compiling - A guide to building FPC cross compilers for multiple platform combinations.