g77 on MacOS X

Before you begin, you need to have Apple's developer tools (Dec2002DevTools) installed. If you just want to use my precompiled gcc-with-g77 package, get an RPM package from here. If you want to build g77 for yourself, follow the instruction below.

g77 Building Procedure (gcc-3.1 based)

gcc3.1 that comes with Apple's standard DevTools does not include "g77". However, its source tree does include one. This makes g77 support much easier than before. All you need to do is to get the source file from the Darwin site and compile it.

$ tar -zxvf gcc3-1175.tar.gz
$ cd gcc3-1175
$ export RC_ARCHS=ppc
$ export RC_CFLAGS='-arch ppc'
$ export RC_OS='macos'
$ export TARGETS=ppc
$ export HOSTS=ppc
$ export SRCROOT=`pwd`
$ vi build_gcc
.....
ENABLE_LANGUAGES="c++,c,objc,objc++,f77"
.....
$ make install >& install.log &

Then build libg2c.a (dynamic)
$ cd obj/ppc
$ mkdir libf2c
$ cd libf2c
$ CFLAGS='-traditional-cpp' $SRCROOT/libf2c/configure --srcdir=$SRCROOT/libf2c --host=ppc --target=ppc
$ make >& make.log &

What follows is only a packaging issue, useless for most people:^)

$ cp -p .libs/libg2c.a libfrtbegin.a ../../../dst/usr/lib/gcc/darwin/3.1/
$ cp g2c.h ../../../dst/usr/include/gcc/darwin/3.1/
$ ln -s gcc/darwin/default/g2c.h ../../../dst/usr/include/.
$ ln -s gcc/darwin/default/libg2c.a ../../../dst/usr/lib/libg2c.a
$ cd ../../cc-ppc-on-ppc/
$ cp g77 ../../dst/usr/bin/g773
$ cp f771 ../../dst/usr/libexec/gcc/darwin/ppc/3.1/
$ cd ../../dst
$ pushd usr/bin
$ ln -s g++3 g++
$ ln -s gcc3 gcc
$ ln -s g773 g77
$ ln -s g++ c++
$ ln -s gcc cc
$ ln -s g77 f77
$ cd ../include
$ pushd gcc/darwin/

$ ln -s 3.1 default
$ popd
$ ln -s gcc/darwin/3.1/g++-v3 .
$ for i in gcc/darwin/default/*.h; do ln -s $i .; done
$ cd ../lib
$ pushd gcc/darwin
$ ln -s 3.1 default
$ popd
$ for i in gcc/darwin/default/lib*.a; do ln -s $i .; done
$ rm libcc_noc++.a libgcc_static.a
$ cd ../libexec
$ pushd gcc/darwin/ppc
$ ln -s 3.1 default
$ popd
$ cd ../..
$ su
# chown -R root:wheel usr

# gnutar -zcvf <somewhere>/gcc-with-g77-1175-1a.tar.gz usr/

g77 Building Procedure (gcc-2.95.2 based)

For backward compatibility, Apple distributes old gcc-2.95.2 based compilers together with the new gcc-3.1 based ones. I also prepared g77 for the old 2.95.2 in case one might need the gcc-2.95.2 based ones.
The building procedure in this case is as before:

Extract libf2c and gcc/f from the standard gcc-2.95.2 and place them in Apple's gcc-7 tree:

$ tar -zxvf gcc-7.tar.gz
$ mv gcc-6 gcc-2.95.2-g77
$ tar -zxvf <somewhere>/gcc-2.95.2-g77.tar.gz
$ mv gcc-2.95.2-g77 gcc-6
$ cd gcc-6

and then apply my private patch and make:

$ patch -p1 -s < <somewhere>/gcc-2.95.2-macosx-10.2.patch
$ export RC_ARCHS=ppc
$ export RC_CFLAGS='-arch ppc'
$ export RC_OS='macos'
$ export TARGETS=ppc
$ export HOSTS=ppc
$ export SRCROOT=`pwd`
$ make install >& install.log &

Then build libg2c.a (dynamic)

$ patch -p1 -s < ../patches/gcc-2.95.2-libg2c.patch
$ cd gcc
$ for i in ../obj/cc-ppc-on-ppc/*.h; do ln -s $i .; done
$ cd ..
$ mkdir obj/ppc/libf2c
$ pushd obj/ppc/libf2c
$ CFLAGS='-traditional-cpp' $SRCROOT/libf2c/configure --srcdir=$SRCROOT/libf2c --host=ppc --target=ppc
$ make >& make.log &

$ cp -pP libg2c.a ../../../dst/usr/lib/gcc/darwin/2.95.2/

$ cp g2c.h ../../../dst/usr/include/gcc/darwin/2.95.2/
$ cd ../../cc-ppc-on-ppc/
$ cp g77 ../../dst/usr/bin/g772
$ cp f771 ../../dst/usr/libexec/gcc/darwin/ppc/2.95.2/
$ su
# cd ../../dst
# chown -R root:wheel usr
# gnutar -zcvf <somewhere>/gcc-with-g77-932.1-1c-bin.tar.gz usr/

Notice that gcc, g++, and g77 will be installed as gcc2, g++2, and g772 in order not to overwrite the standared gcc-3.1 based compiliers.

How to Install a Precompiled Binary Package

A binary package is available as an RPM which can be installed as

# rpm -ivh gcc-with-g77-1175-1a.ppc.rpm
# rpm -ivh gcc2-with-g77-7-1a.ppc.rpm
# rpm -ivh gcc-with-g77-symlinks-1175-1a.ppc.rpm


The last "symlinks" packages makes gcc-3.1 based compilers as default compilers to be referred to as gcc, g++, and g77.
 

REMARKS



Back to Keisuke Fujii's HEP on X Page
keisuke.fujii@kek.jp October 16, 2002