mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-29 04:11:06 +02:00
update_cross_fpc.sh now installs a complete cross fpc+binutils set
git-svn-id: trunk@7666 -
This commit is contained in:
parent
8925ef5f51
commit
8d519f5cda
@ -14,15 +14,68 @@ Abstract:
|
||||
crosscompiling to other targets. Once you have these cross files you can
|
||||
switch easily in the Lazarus IDE between any of the target platforms.
|
||||
|
||||
It is important that the FPC units have the same date/version for all
|
||||
platforms, because you will use only one compiler. That means:
|
||||
Whenever you update your FPC, you must update all other cross fpc units too.
|
||||
IMPORTANT: The FPC units must have the same date/version for all platforms,
|
||||
because you will use only one compiler. That means:
|
||||
Whenever you update your FPC, you must update all other cross fpc units too.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
A.1
|
||||
|
||||
Requirements:
|
||||
An installed and working fpc. Preferrably the latest stable release.
|
||||
A good internet connection or manually downloaded FPC sources and binutils.
|
||||
|
||||
The following steps don't need the root user. They can be done as normal user.
|
||||
|
||||
There is a script in tools/install/cross_unix/update_cross_fpc.sh, that will
|
||||
do the below steps. It downloads bintuils, fpc and builds the cross targets.
|
||||
There are some scripts in <lazarusdir>/tools/install/cross_unix/.
|
||||
The script "update_cross_fpc.sh" compiles and setups everything in the home
|
||||
directory of the current user. Therefore it does not need a root account.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
Quick start:
|
||||
If you have a good internet connection, then you can just type
|
||||
|
||||
[]$ cd <lazarusdir>/tools/install/cross_unix/
|
||||
[]$ ./update_cross_fpc.sh all
|
||||
|
||||
This will download the needed sources, compile them for your platform plus
|
||||
i386-win32 and installs them for the current user.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
What needs to be downloaded:
|
||||
|
||||
For cross compilation you need a cross compiler, cross linker, cross assembler,
|
||||
... . FPC is already a cross compiler for all supported targets. The rest is
|
||||
provided by the binutils, which will be compiled for every needed target system.
|
||||
|
||||
The script needs the binutils sources and the FPC sources. By default it will do
|
||||
|
||||
[]$ mkdir -p ~/freepascal/download
|
||||
[]$ cd ~/freepascal/download
|
||||
[]$ wget http://ftp.gnu.org/gnu/binutils/binutils-2.16.tar.gz
|
||||
|
||||
If you don't have a good internet connection, you can download it manually.
|
||||
|
||||
And by default the script will download the FPC SVN source tree via
|
||||
|
||||
[]$ svn co http://svn.freepascal.org/svn/fpc/branches/fixes_2_0 ~/freepascal/fpc
|
||||
[]$ svn co http://svn.freepascal.org/svn/fpcbuild/branches/fixes_2_0/install ~/freepascal/install
|
||||
|
||||
This requires an installed 'svn' package.
|
||||
|
||||
If you don't have a good internet connection, you can download them manually
|
||||
from http://www.freepascal.org/develop.html#sourcesv20. Unpack the fpc sources
|
||||
to ~/freepascal/fpc, that means there should be a directory
|
||||
~/freepascal/fpc/compiler/.
|
||||
TODO: write, where you can get the fpc 'install' directory sources.
|
||||
|
||||
|
||||
================================================================================
|
||||
|
||||
What the lazarus scripts do / Doing it by hand:
|
||||
|
||||
|
||||
1. Download the fpc sources
|
||||
@ -158,6 +211,7 @@ do the below steps. It downloads bintuils, fpc and builds the cross targets.
|
||||
|
||||
================================================================================
|
||||
|
||||
Obsolete:
|
||||
|
||||
B.
|
||||
For fpc 1.0.x:
|
||||
@ -239,11 +293,12 @@ Or if you did not link the four files (asw, ldw, ...) to /usr/bin:
|
||||
'ppc386 -FD/your/directory -Twin32 pascalfile.pas'
|
||||
|
||||
|
||||
================================================================================
|
||||
|
||||
4. Cross compiling the LCL
|
||||
4.1 Command line: cd lazarus/lcl; make OS_TARGET=win32
|
||||
4.2 In the IDE: Set LCL to Clean+Build, set LCL interface to win32 and
|
||||
set 'Target OS' to win32. Then 'build lazarus'. The win32 interface is not
|
||||
complete enough for the IDE, but many of the components already work.
|
||||
set 'Target OS' to win32. Then 'build lazarus'.
|
||||
|
||||
|
||||
5. Cross compiling a project
|
||||
|
@ -7657,9 +7657,9 @@ end;
|
||||
{ TPickListCellEditor }
|
||||
procedure TPickListCellEditor.WndProc(var TheMessage: TLMessage);
|
||||
begin
|
||||
{$IfDef GridTraceMsg}
|
||||
TransMsg('PicklistEditor: ', TheMessage);
|
||||
{$Endif}
|
||||
{$IfDef GridTraceMsg}
|
||||
TransMsg('PicklistEditor: ', TheMessage);
|
||||
{$Endif}
|
||||
if TheMessage.msg=LM_KILLFOCUS then begin
|
||||
// MWE: ???
|
||||
// TODO: why are only the lower bytes of a handle checked ???
|
||||
|
@ -16,13 +16,91 @@ BinutilsDownloadPath=http://ftp.gnu.org/gnu/binutils/
|
||||
# the FPC targets
|
||||
Targets="i386-win32";
|
||||
|
||||
# steps
|
||||
# where to install the fpc+binutils executables
|
||||
# Only used if called with 'install'. This directory must be in $PATH.
|
||||
InstallBin=~/bin/
|
||||
|
||||
# what intel platform do you want/need to build for?
|
||||
MyIntel=i686
|
||||
|
||||
#===============================================================================
|
||||
# parse command line parameters
|
||||
DownloadBinutils=no
|
||||
DownloadFPC=no
|
||||
BuildBinutils=no
|
||||
BuildCrossFPC=no
|
||||
BuildNormalFPC=no
|
||||
CreateFPCCfg=yes
|
||||
CreateFPCCfg=no
|
||||
InstallAsDefault=no # install ~/fpc.cfg, binaries to ~/bin
|
||||
|
||||
Params=$@
|
||||
for p in $Params; do
|
||||
case "$p" in
|
||||
all)
|
||||
DownloadBinutils=yes
|
||||
DownloadFPC=yes
|
||||
BuildBinutils=yes
|
||||
BuildCrossFPC=yes
|
||||
BuildNormalFPC=yes
|
||||
CreateFPCCfg=yes
|
||||
;;
|
||||
downloadbinutils)
|
||||
DownloadBinutils=yes
|
||||
;;
|
||||
downloadfpc)
|
||||
DownloadFPC=yes
|
||||
;;
|
||||
buildbinutils)
|
||||
BuildBinutils=yes
|
||||
;;
|
||||
buildnormalfpc)
|
||||
BuildNormalFPC=yes
|
||||
;;
|
||||
buildcrossfpc)
|
||||
BuildCrossFPC=yes
|
||||
;;
|
||||
createfpccfg)
|
||||
CreateFPCCfg=yes
|
||||
;;
|
||||
install)
|
||||
InstallAsDefault=yes
|
||||
;;
|
||||
installbin=*)
|
||||
InstallBin=$(echo $p | sed -e 's#^installbin=##')
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $p"
|
||||
echo
|
||||
echo "Usage:"
|
||||
echo " $0 [all] [downloadbinutils] [downloadfpc] [buildbinutils] [buildnormalfpc] [buildcrossfpc] [createfpccfg]"
|
||||
exit -1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#===============================================================================
|
||||
|
||||
# expand paths
|
||||
BuildRoot=$(echo $BuildRoot)
|
||||
InstallBin=$(echo $InstallBin)
|
||||
|
||||
# the 'bin' directory - where to put the fpc+binutils executables
|
||||
# On InstallAsDefault=yes they will be copied to $HomeBin
|
||||
BinDir=$BuildRoot/bin/
|
||||
|
||||
# check install path
|
||||
if [ $InstallAsDefault = "yes" ]; then
|
||||
# check if the $InstallBin is in $PATH
|
||||
TrimmedPath=$(echo $InstallBin | sed -e 's#/$##g' -e 's#//#/#')
|
||||
if [ -z $(echo $PATH | egrep "(^|:)$TrimmedPath(:|$)") ]; then
|
||||
echo "ERROR: $InstallBin not in \$PATH."
|
||||
echo "This script installs FPC and binutils executables to a directory"
|
||||
echo "that is in your search PATH before your installed FPC."
|
||||
echo "Either prepend it to \$PATH or define another with installbin=<path>"
|
||||
fi
|
||||
|
||||
BinDir=$InstallBin
|
||||
fi
|
||||
|
||||
#===============================================================================
|
||||
# calculate targets
|
||||
@ -69,6 +147,7 @@ if [ $DownloadBinutils = "yes" ]; then
|
||||
if [ ! -f $BinutilsTGZ ]; then
|
||||
mkdir -p $DownloadDir
|
||||
cd $DownloadDir
|
||||
echo "Downloading $BinutilsDownloadPath/$BinutilsFilename ..."
|
||||
wget $BinutilsDownloadPath/$BinutilsFilename
|
||||
fi
|
||||
fi
|
||||
@ -80,24 +159,26 @@ if [ $DownloadFPC = "yes" ]; then
|
||||
cd $BuildRoot
|
||||
if [ -f fpc ]; then
|
||||
cd fpc
|
||||
echo "SVN update for FPC ..."
|
||||
svn cleanup
|
||||
svn up
|
||||
else
|
||||
echo "SVN checkout for FPC ..."
|
||||
svn co http://svn.freepascal.org/svn/fpc/branches/fixes_2_0 fpc
|
||||
fi
|
||||
if [ -f install ]; then
|
||||
cd install
|
||||
echo "SVN update for FPC install ..."
|
||||
svn cleanup
|
||||
svn up
|
||||
else
|
||||
echo "SVN checkout for FPC install ..."
|
||||
svn co http://svn.freepascal.org/svn/fpcbuild/branches/fixes_2_0/install install
|
||||
fi
|
||||
fi
|
||||
|
||||
#===============================================================================
|
||||
# setup some variables
|
||||
BinDir=$BuildRoot/bin/
|
||||
|
||||
# retrieve the version information
|
||||
VersionFile="$BuildRoot/fpc/compiler/version.pas"
|
||||
CompilerVersion=`cat $VersionFile | grep ' *version_nr *=.*;' | sed -e 's/[^0-9]//g'`
|
||||
@ -128,7 +209,31 @@ if [ $BuildBinutils = "yes" ]; then
|
||||
|
||||
# build the cross binutils
|
||||
echo "HINT: when something goes wrong see the log files in $BuildRoot/bintuils/logs/"
|
||||
rm -rf $BuildRoot/binutils
|
||||
sh buildcrossbinutils.sh
|
||||
|
||||
# link binaries into the bin directory, so that FPC can find them
|
||||
mkdir -p $BinDir
|
||||
for Target in $Targets; do
|
||||
TargetCPU=$(echo $Target | sed -e 's#^\(.*\)-.*$#\1#')
|
||||
TargetOS=$(echo $Target | sed -e 's#^.*-\(.*\)$#\1#')
|
||||
BinUtilsCPU=$TargetCPU
|
||||
BinUtilsOS=$TargetOS
|
||||
|
||||
if [ $TargetOS = "win32" ]; then
|
||||
BinUtilsOS="mingw32"
|
||||
BinUtilsCPU=$MyIntel
|
||||
fi
|
||||
|
||||
BinUtilsDir=$BuildRoot/binutils/cross/bin/
|
||||
BinUtilsPrefix="$BinUtilsCPU-$BinUtilsOS-"
|
||||
|
||||
cd ${BinUtilsDir}
|
||||
for binutility in $(ls -B ${BinUtilsPrefix}*); do
|
||||
link=$(echo $binutility | sed -e "s#$BinUtilsPrefix#${TargetCPU}-${TargetOS}-#")
|
||||
ln -sf ${BinUtilsDir}${binutility} ${BinDir}${link}
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
#===============================================================================
|
||||
@ -183,14 +288,15 @@ if [ $BuildNormalFPC = "yes" ]; then
|
||||
mkdir -p ${LOGDIR}
|
||||
|
||||
cd $BuildRoot/fpc
|
||||
echo "building non cross fpc for target $CPU-$OS in $BuildRoot/bintuils/cross/destination/"
|
||||
echo "see logs in $BuildRoot/bintuils/cross/logs/"
|
||||
echo "building non cross fpc for target $CPU-$OS in $DESTDIR"
|
||||
echo "see logs in $LOGDIR"
|
||||
${MAKE} clean all > ${LOGDIR}snapbuild-${CPU}-${OS} 2>&1
|
||||
${MAKE} install INSTALL_PREFIX=${DESTDIR} LIBDIR=${BASELIBDIR}/${CPU}-${OS} OPT="-Xd -Xt -gl" > ${LOGDIR}snapinstalllog-${CPU}-${OS} 2>&1
|
||||
|
||||
# save samplecfg
|
||||
# save samplecfg, ppc386
|
||||
mkdir -p $BinDir
|
||||
cp ${DESTDIR}lib/fpc/$CompilerVersionStr/samplecfg $BinDir
|
||||
cp ${DESTDIR}lib/fpc/$CompilerVersionStr/ppc* $BinDir
|
||||
fi
|
||||
|
||||
#===============================================================================
|
||||
@ -198,7 +304,33 @@ fi
|
||||
if [ $CreateFPCCfg = "yes" ]; then
|
||||
echo "building ~/fpc.cfg ..."
|
||||
|
||||
$BuildRoot/bin/samplecfg $BuildRoot/binutils/cross/destination/lib/fpc/$CompilerVersionStr/ ~/freepascal
|
||||
DestDir=~/freepascal
|
||||
$BuildRoot/bin/samplecfg $BuildRoot/binutils/cross/destination/lib/fpc/$CompilerVersionStr/ $DestDir
|
||||
FPCCfg=$DestDir/fpc.cfg
|
||||
|
||||
# add -FD and -XP entry for cross compiling
|
||||
echo "# set binutils paths for crosscompiling" >> $FPCCfg
|
||||
echo "#IFDEF FPC_CROSSCOMPILING" >> $FPCCfg
|
||||
echo " -FD${BinDir}" >> $FPCCfg
|
||||
echo ' -XP$fpctarget-' >> $FPCCfg
|
||||
echo "#ENDIF" >> $FPCCfg
|
||||
|
||||
# test the fpc.cfg
|
||||
echo "Testing compiling test.pas ..."
|
||||
TestPas="$BuildRoot/test.pas"
|
||||
echo "program Test;" > $TestPas
|
||||
echo "{$mode objfpc}{$H+}" >> $TestPas
|
||||
echo "uses Classes, SysUtils;" >> $TestPas
|
||||
echo "begin" >> $TestPas
|
||||
echo " writeln('Test');" >> $TestPas
|
||||
echo "end." >> $TestPas
|
||||
cd $BuildRoot
|
||||
$BinDir/ppc386 test.pas
|
||||
|
||||
if [ $InstallAsDefault = "yes" ]; then
|
||||
echo "Installing ~/fpc.cfg ..."
|
||||
cp $BuildRoot/fpc.cfg ~/fpc.cfg
|
||||
fi
|
||||
fi
|
||||
|
||||
# end.
|
||||
|
Loading…
Reference in New Issue
Block a user