Monday, November 04, 2013

compiling scheme48 0.58 on ubuntu 12.04

Scheme48 0.58 is available here, but as the release notes say, it doesn't build.  Here's how I got it to work on a 64-bit Ubuntu 12.04 system.

Grab Scheme48 0.57, and unpack it.  Edit Makefile.in and add -ldl to the end of the EXTERNAL_LD_FLAGS line.  Run

env CC="gcc -m32" ./configure --prefix=/tmp/s

(We'll install it to /tmp/s since we won't need it after bootstrapping 0.58.)

Edit c/unix/io.c and move the line

static long write_integer(unsigned long n, FILE *port);

from inside the ps_write_integer function out to the top-level (just cut and paste it).

Run make.  You should have a working system; run ./go to test it.  Install it with

for dir in bin lib include; do mkdir /tmp/s/$dir; done
make install

Grab 0.58, and unpack it.  Copy 0.57's c/unix/dynamo.c into 0.58's c/unix/ directory.  Edit Makefile.in and make the same -ldl change as above; do the same with c/unix/io.c.

Configure it with

env CC="gcc -m32" ./configure

Edit the Makefile and find the section of the file that says

LINKER_VM = ./$(VM) $(BIG_HEAP)
LINKER_RUNNABLE = $(LINKER_VM)

Change it to

LINKER_VM = /tmp/s/bin/scheme48 $(BIG_HEAP)
LINKER_RUNNABLE = $(LINKER_VM)

Run make.  It'll fail because it's not happy with build/initial.image.  So, build a new image:

make -k linker
make -k image

You can verify that the new image works by doing

make distclean
env CC="gcc -m32" ./configure
make
./go

I may have missed a step or two in writing this blog post; please let me know if it doesn't work for you.  I also haven't used it for anything just yet, so there may be bugs lurking in the code.

Credits: I knew there was a way to rebuild the image, but the last time I looked into Scheme48's internals for this sort of thing was maybe fifteen years ago.  After fruitlessly scanning the source code and documentation to figure out what to do, I googled and found Margaret Fleck's install guide.  That had the two makefile targets needed for the rebuild.

No comments: