objectivepascal

From Lazarus wiki
Jump to navigationJump to search

Downloading Sources

Before building any compilers you must download the FPC sources from SVN using the command svn co or svn up if you're updating existing sources you download previously. This page uses the standard location of /Developer/ObjectivePascal/fpc for all the FPC sources and you may need to create the /Developer/ObjectivePascal directory before going any further. For example:

svn co http://svn.freepascal.org/svn/fpc/trunk /Developer/ObjectivePascal/fpc

Building the compiler for Cocoa development

1) Download the latest version of FPC and Xcode developer tools then install. The examples below assumes the latest version is 2.4.2 but you may need to change this to which ever version is current at the time of installing.

1) Download the latest version of the sources (see Downloading Sources)

2) Build the Intel compiler to /usr/local/lib/fpc/2.5.1/ppc386

cd /Developer/ObjectivePascal/fpc
sudo make distclean -j 3
sudo make FPC=/usr/local/lib/fpc/2.4.2/ppc386 OPT="-ap" distclean all -j 2
sudo make FPC=`pwd`/compiler/ppc386 install

3) Build the PPC cross-compiler to /usr/local/lib/fpc/2.5.1/ppcppc. If you don't wish to build universal binaries or PPC-only binaries you can skip this step.

cd /Developer/ObjectivePascal/fpc
sudo make distclean -j 3
sudo make FPC=/usr/local/lib/fpc/2.4.2/ppc386 OPT="-ap" distclean CPU_TARGET=powerpc all -j 2
sudo make FPC=`pwd`/compiler/ppcppc CROSSINSTALL=1 install
sudo mv /usr/local/lib/fpc/2.5.1/ppcrossppc /usr/local/lib/fpc/2.5.1/ppcppc

Cocoa Headers

The most recent version of the translated Cocoa headers (which are guaranteed to compile with that version) are location in the FPC distribution at /Developer/ObjectivePascal/fpc/packages/cocoaint/src. If you need newer headers you will need to parse them manually using the framework parser located at /Developer/ObjectivePascal/fpc/packages/cocoaint/utils/parser.php.

Building the compiler for iOS development

Follow the steps below to install the ARM compiler and 386 compiler for iOS simulator. The commands below utilize the standard location of /Developer/ObjectivePascal/fpc which contains all FPC sources related to Objective Pascal development.

1) Download the latest version of FPC and Xcode developer tools (with iOS SDK) then install. Please note you must start with a standard (unchanged) installation of Xcode developer tools and iOS SDK.

If you installed Xcode into another location than the default location /Developer you will need to change the paths below and in any other scripts you may run. Make sure if you installed into another location the path does not contain spaces.

2) Download the latest version of the sources (see Downloading Sources)

3) Generate the iPhone headers. The SDK used to build the sources may not be the latest version of the SDK you installed from Xcode. Check the SDK version used in the script make-ios-headers.sh before trying this step.

cd /Developer/ObjectivePascal/fpc/packages/cocoaint/utils
./make-ios-headers.sh

The headers will be parsed and saved into /Developer/ObjectivePascal/fpc/packages/cocoaint/utils/uikit-skel/src

4) Build the ARM cross-compiler.

  • In the examples below the iPhoneOS4.2.sdk SDK is used but you should change this to the SDK version which you installed from Xcode.
  • If you are using Xcode 3.2.6+ or Xcode 4+, currently you first have to apply a patch to the FPC sources as explained at http://bugs.freepascal.org/view.php?id=19196
  • copy /Developer/FreePascalCompiler/2.4.2/Source/rtl/darwin/arm/sig_cpu.inc to /Developer/ObjectivePascal/fpc/rtl/darwin/arm (that file was generated when you installed the FPC iPhone SDK integration kit)
cd /Developer/ObjectivePascal/fpc
export IPHONEPLATFORMBASEDIR=/Developer/Platforms/iPhoneOS.platform/Developer
make FPC=/usr/local/lib/fpc/2.4.2/ppc386 CPU_TARGET=arm CROSSOPT="-FD${IPHONEPLATFORMBASEDIR}/usr/bin -XR${IPHONEPLATFORMBASEDIR}/SDKs/iPhoneOS4.2.sdk/ -ap -Cfvfpv2" all
sudo make FPC=`pwd`/compiler/ppcrossarm OPT="-ap" CPU_TARGET=arm CROSSOPT="-FD${IPHONEPLATFORMBASEDIR}/usr/bin -XR${IPHONEPLATFORMBASEDIR}/SDKs/iPhoneOS4.2.sdk/ -ap" install CROSSINSTALL=1
sudo ln -sf ../lib/fpc/2.5.1/ppcrossarm /usr/local/bin/ppcarm

5) Build the 386 compiler for iOS Simulator.

cd /Developer/ObjectivePascal/fpc
make FPC=/usr/local/lib/fpc/2.4.2/ppc386 OS_TARGET=iphonesim all
sudo make FPC=/usr/local/lib/fpc/2.4.2/ppc386 OS_TARGET=iphonesim install CROSSINSTALL=1

Compiling iOS sources

These are example commands you can use to compile iOS programs from the command line. Change the path of the iOS SDK to the version which you generated the headers for.

  • Compile for iOS simulator
/usr/local/lib/fpc/2.5.1/ppcross386 -XX -Tiphonesim -Fu/Developer/ObjectivePascal/fpc/packages/cocoaint/utils/uikit-skel/src -XR/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk program.pas
  • Compile for iOS device
/usr/local/lib/fpc/2.5.1/ppcrossarm -XX -Cfvfpv2 -Fu/Developer/ObjectivePascal/fpc/packages/cocoaint/utils/uikit-skel/src -FD/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin -XR/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk program.pas