GAP under Macintosh OS X

Alexander Hulpke
The following are some remarks and hints about running GAP under OS X. I will not assume that you use the MacOS version (that will run in the `Classic' environment) but that you want to run it as a Unix program, befitting the Unix basis of the operating system.

I will assume that you are using the ``Tiger'' (10.4) version of OS X with XCode 2 (i.e. gcc 4). (See below for notes on older versions) Similar steps might work under older versions, though this is beyond the scope of this document.

Tools needed

Unless you are content with getting my precompiled binaries (and these precompiled binaries run) you will have to compile GAP yourself. For this you need to install a couple of tools that are provided by Apple for free, but are not installed by default.

All required packages (apart from GAP itself, of course) is available on the Xcode CD (at the time of writing this the most recent version was 2.1). If you bought a boxed version of the operating system this CD was included. Otherwise you can get a copy at your local Apple store or you can download it for free.

To download Xcode go to developer.apple.com. If this is your first visit, you will have to register (the free online membership that only gives you download access is sufficient). Then go to Download Software -> Developer Tools and download the most recent version of Xcode Tools.

From the Xcode CD, install the Developer.mpkg package. (The package downloads in multiple chunks. Unpack the first one, run it, it will unpack the other ones.) Go through the spiel of the installer which might take half an hour depending on your machine.

If you also want to compile XGAP, you need to install X11, as well as the X11 SDK (Software Development Kit). You find X11 itself on the third installer disk for ``Panther'' (just insert the CD and follow the prompts, you will have to select X11 yourself). The SDK is a separate package in the Packages directory of the Xcode CD.
(The naming Xcode 2.1 and X11 is misleadingly similar, but this are really two different programs.)
You may also want to read this webpage by Apple about X11 under OS X.

Compiling and Running GAP

You run and compile GAP Unix-like in a terminal window. You can open this via the Terminal application, which can be found in Applications/Utilities. Go (via cd) to the directory you want to install GAP and then follow the general Unix installation instructions. The cycle
./configure
make
should produce a workable binary. Depending on your processor, however you will be able to get a notable performance increase by replacing the make call by one that specifies extra optimization flags. (You will find a description of all of these in the `gcc' manual, for example at developer.apple.com/documentation.) Extra optimization might give you as speed gain of about 20%.
On a reasonably recent G4 machine with a processor in the 7450 family (see the web page at everymac.com) one can use: compilation with
make CFLAGS="-fast -mtune=7450 -mcpu=7450"
On a G5, using gcc 4 the -fast option alone seems to be sufficient. (I do not have a G5 at hand, please let me know if you encounter problems.)
make CFLAGS="-fast -mpowerpc64"
If you have an older G4 processor, a G3, or an older version of the compiler, you might need to specify options separately, as there seem to be some compiler problems.
In general, try
make COPTS="-O3 -funroll-loops -fstrict-aliasing -fsched-interblock
-falign-loops=16 -falign-jumps=16 -falign-functions=16
-falign-jumps-max-skip=15 -falign-loops-max-skip=15 -malign-natural
-ffast-math -mdynamic-no-pic -mpowerpc-gpopt -force_cpusubtype_ALL
-fstrict-aliasing"
On a newer G4, you can again add the options -mtune=7450 -mcpu=7450.
On a G5 the following options seem to work (so far no full test with all options has been done):
   
make COPTS="-O3 -mtune=G5 -mcpu=G5 -mpowerpc64"
Compilation of XGAP is straightforward once the X11 SDK is installed. (It is not worth to worry about optimization tricks here, as the XGAP program is only a wrapper to GAP.

To run XGAP, you will have to start the application X11 (which provides a X-windows server running under the ``Aqua'' window system of the Macintosh) first. This application sitz in the Utilities folder in the Applications folder.

Precompiled binaries

If you cannot install the developer tools (for example because you do not have administrator access), I have put here binaries which I compiled on my (G4 powerbook under OS X 10.3) machine. they might or might not run on other machines or other versions of the operating system.

GAP 4.4.4 binary
Download the archive, extract in the bin directory of your GAP installation. You will have to edit the file gap.sh that starts GAP to amend paths (replace /Users/ahulpke/gap4 by your path).
XGAP binary
Download the archive, extract in the pkg/xgap/bin directory of your GAP installation. You will have to edit the file xgap.sh that starts XGAP to amend paths (replace /Users/ahulpke/gap4 by your path).
I will update these files from time to time but this sometimes might lag behind the GAP releases.