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 here.
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.
Steps-at-a-Glance
cd
mkdir gpc-build
cd gpc-build
STEP 2 - Install bison version 2.0
curl -s -S -O http://ftp.gnu.org/gnu/bison/bison-2.0.tar.gz
tar zxf bison-2.0.tar.gz
cd bison-2.0
./configure
make
sudo make install
cd ..
STEP 3 - Install flex version 2.5.31
curl -s -S -O http://easynews.dl.sourceforge.net/sourceforge/lex/flex-2.5.27.tar.gz
tar zxf flex-2.5.27.tar.gz
cd flex-2.5.27
./configure
make
sudo make install
cd ..
STEP 4 - Install sed version 4.1.4
curl -s -S -O http://ftp.gnu.org/gnu/sed/sed-4.1.4.tar.gz
tar zxf sed-4.1.4.tar.gz
cd sed-4.1.4
./configure
make
sudo make install
cd ..
STEP 5 - Install help2man version 1.35.1
curl -s -S -O ftp://ftp.gnu.org/gnu/help2man/help2man-1.35.1.tar.gz
tar zxf help2man-1.35.1.tar.gz
cd help2man-1.35.1
./configure --enable-nls=no
make
sudo make install
cd ..
STEP 6 - Download gcc version 3.4.3
curl -s -S -O ftp://ftp.gnu.org/gnu/gcc/gcc-3.4.3/gcc-core-3.4.3.tar.bz2
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 http://www.g-n-u.de/gpc/gpc-20050331.tar.bz2
bunzip2 gpc-20050331.tar.bz2
tar xf gpc-20050331.tar
mv p gcc-3.4.3/gcc
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. */
EOM
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 http://fjf.gnu.de/misc/gp.tar.bz2
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)
else
- UnitNameMatch := Dep.SrcBaseName = InterfaceName
+ UnitNameMatch := LoCaseStr( Dep.SrcBaseName ) = LoCaseStr( InterfaceName );
end;
function NewUsesElement (const InterfaceName, FileName: String; Next: PUnitList) = p: PUnitList;
EOM
./configure --prefix=/Developer/Pascal/gpc-20050331
make
sudo make install
cd ..
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