Compiling GNU Pascal (GPC) from Scratch - Tiger Version
Peter N Lewis, Stairways Software

Compiling GNU Pascal (GPC) from Scratch
for Mac OS X Tiger
(or "The Twelve Steps to GPC Bliss")
by Peter N Lewis
Aug 16, 2005

This is a brief overview of how to get GNU Pascal to compile from scratch under Tiger.

Alternatively, you can get the binary distribution from

You will also want to consider installing the
Mac OS X Pascal Interfaces for GNU Pascal, and the Xcode integration Kit.

Special thanks to Adriaan van Os for most of the Pre-Tiger information.


  1. Create a build directory
  2. Install bison version 2.0
  3. Install flex version 2.5.27
  4. Install sed version 4.1.4
  5. Install help2man version 1.35.1
  6. Download gcc version 3.4.3
  7. Download gpc-20050331
  8. Configure gcc/gpc
  9. Patch gcc for Mac OS X
  10. Build gcc
  11. Install gp
  12. Setup some links

STEP 1 - Create a build directory

mkdir gpc-build
cd gpc-build

STEP 2 - Install bison version 2.0

curl -s -S -O
tar zxf bison-2.0.tar.gz
cd bison-2.0
sudo make install
cd ..

STEP 3 - Install flex version 2.5.31

curl -s -S -O
tar zxf flex-2.5.27.tar.gz
cd flex-2.5.27
sudo make install
cd ..

STEP 4 - Install sed version 4.1.4

curl -s -S -O
tar zxf sed-4.1.4.tar.gz
cd sed-4.1.4
sudo make install
cd ..

STEP 5 - Install help2man version 1.35.1

curl -s -S -O
tar zxf help2man-1.35.1.tar.gz
cd help2man-1.35.1
./configure --enable-nls=no
sudo make install
cd ..

STEP 6 - Download gcc version 3.4.3

curl -s -S -O
bunzip2 gcc-core-3.4.3.tar.bz2
tar xf gcc-core-3.4.3.tar

STEP 7 - Download gpc-20050331

curl -s -S -O
bunzip2 gpc-20050331.tar.bz2
tar xf gpc-20050331.tar
mv p gcc-3.4.3/gcc

STEP 8 - Configure gcc/gpc

mkdir build
cd build
../gcc-3.4.3/configure --enable-languages=pascal,c --enable-threads=posix --prefix=/Developer/Pascal/gpc-20050331

STEP 9 - Patch gcc for Mac OS X

gcc 3.4.3 has a problem with Mac OS X 10.4, so apply the patch from
here, execute the patch command, and paste in the following lines:

patch -p0 --ignore-whitespace << EOM
--- ../gcc-3.4.3/gcc/config/darwin.h.sav 2005-05-18 13:56:37.000000000 -0400
+++ ../gcc-3.4.3/gcc/config/darwin.h 2005-05-18 13:57:48.000000000 -0400
@@ -275,7 +275,8 @@
/* Machine dependent libraries. */

#undef LIB_SPEC
-#define LIB_SPEC "%{!static:-lSystem}"
+#define LIB_SPEC "%{!static:-lSystemStubs -lSystem}"

/* We specify crt0.o as -lcrt0.o so that ld will search the library path. */

STEP 10 - Build gcc

make EXTRA_PFLAGS=--longjmp-all-nonlocal-labels STAGE1_CFLAGS='-g -DHAVE_DESIGNATED_INITIALIZERS=0' bootstrap
sudo make install
cd ..

To remake if you make any changes, use:

make EXTRA_PFLAGS=--longjmp-all-nonlocal-labels STAGE1_CFLAGS='-g -DHAVE_DESIGNATED_INITIALIZERS=0' all-gcc

STEP 11 - Install gp

gp does not handle capital letters in unit names, even on case insensitive file systems. The patch resolves that issue.

curl -s -S -O
bunzip2 gp.tar.tar.bz2
cd gp-0.60
patch -p1 --ignore-whitespace << EOM
--- gp-0.60/gp.pas 2005-06-06 04:31:51.000000000 +0800
+++ gp-0.60-mine/gp.pas 2005-06-25 11:21:53.000000000 +0800
@@ -708,7 +710,7 @@
if FileName <> '' then
UnitNameMatch := (Dep.SrcBaseNameExt = FileName) or (Dep.SrcBaseName = FileName)
- UnitNameMatch := Dep.SrcBaseName = InterfaceName
+ UnitNameMatch := LoCaseStr( Dep.SrcBaseName ) = LoCaseStr( InterfaceName );

function NewUsesElement (const InterfaceName, FileName: String; Next: PUnitList) = p: PUnitList;
./configure --prefix=/Developer/Pascal/gpc-20050331
sudo make install
cd ..

STEP 12 - Setup some links

sudo ln -s -f /Developer/Pascal/gpc-20050331/bin/gpc /usr/bin/gpc
sudo ln -s -f /Developer/Pascal/gpc-20050331/bin/gcc /usr/bin/gpcgcc
sudo ln -s -f -h /Developer/Pascal/gpc-20050331/lib/gcc/powerpc-apple-darwin7/3.4.3/ /Developer/Pascal/gpclibs
sudo ln -s -f /Developer/Pascal/gpc-20050331/bin/gpidump /usr/bin/gpidump
sudo ln -s -f /Developer/Pascal/gpc-20050331/bin/binobj /usr/bin/gpcbinobj
sudo ln -s -f /Developer/Pascal/gpc-20050331/bin/gpc-run /usr/bin/gpc-run
sudo ln -s -f /Developer/Pascal/gpc-20050331/bin/gp /usr/bin/gp

Copyright © 2005, Peter N Lewis