NOTE (4/10/03): The instructions here are probably no longer necessary to compile Spim under Mac OS X 10.2.x. The latest Spim release, 6.5, appears to compile fine "out of the box" using the instructions included with it.

Spim can also be installed through the Fink package manager, available here. This is probably easier than building it yourself.

I finally got SPIM to build on Mac OS X with the help of some suggestions posted on Apple's discussion boards (thanks Jeffrey Naset!).

NOTE: You need to have the developer tools installed before this will work (obviously... :-)

Here's what I had to do (although this requires XFree86 to be installed, or at least the xmkmf binary; see below if not):

Get SPIM Source
% wget
% gnutar -zxvf spim.tar.Z
% cd spim-6.3

Add lines to Configure file
(a diff format patch was noted in the forum... here's how to do it by hand, as I did, since I didn't want to mess with figuring out patch):

Starting on line 81 of Configure, add:
else if [ -f /usr/lib/libc.dylib ]; then
# Mac OS X Universe:
echo Looks like a Mac OS X / OpenStep universe exists...
echo Scanning libc.dylib
nm /usr/lib/libc.dylib > library_contents
set flag = -q

Starting on line 164 (after the above modification), add:
if [ `uname` == Darwin ]; then
echo "-traditional-cpp" >> configuration
echo "Using Darwin -traditional-cpp"
# Darwin headers restricted if _POSIX_SOURCE
echo "-U_POSIX_SOURCE" >> configuration

Run Configure:
% ./Configure

Change the following variables in Imakefile:
TRAP_DIR = /usr/local/share/spim
BIN_DIR = /usr/local/bin
MAN_DIR = /usr/local/man

Generate Makefile
% xmkmf

Fix the Makefile
Mac OS X uses cc, not gcc (I tried just setting the $CC environment variable and that didn't work...)
Change the line in Makefile that looks like:
CC = gcc -fpcc-struct-return
CC = cc -fpcc-struct-return

Make it... finally
% make
% make xspim
% sudo make install

What just got installed installed:
/usr/local/bin/spim (command line SPIM binary)
/usr/local/bin/xspim (X11 graphical binary)
/usr/local/share/spim/trap.handler (shared trap handling code)

If you want the manpages installed (for help):
% sudo cp /usr/local/man/man1/spim.1
% sudo cp /usr/local/man/man6/xspim.6

Some final notes:
The installed spim and xspim binaries seem to work (with my limited testing)... and make test passed too.

NOTE: There is a way to do this without XFree86 (or xmkmf) being installed... I haven't had time to test it though.
From the readme:
If you do not have X-windows or the program xmkmf, edit the makefile in Makefile.std or Makefile.cygwin and type:

% make -f Makefile.std test
% make -f Makefile.std xspim

Translation: Above, where you edit Imakefile, edit Makefile.std instead, skip the part about xmkmf, and change the CC variable in Makefile.std as well. Then do the make commands I gave, but use the -f option and specify Makefile.std as the readme shows. If XFree86 isn't installed, making xspim won't work.

My Homepage