Subject: Re: How to make SIOD?
From: rpw3@rpw3.org (Rob Warnock)
Date: Sun, 18 May 2008 00:36:20 -0500
Newsgroups: comp.lang.scheme
Message-ID: <X_OdnXSGfYrJXbLVnZ2dnUVZ_vWdnZ2d@speakeasy.net>
O.k., so now you've suckered me into an afternoon of technoarchaelogy
both out on the Intarweb and on my own machines...  ;-}  ;-}
...but I may have some info for you.

Pascal Costanza  <pc@p-cos.net> wrote:
+---------------
| Rob Warnock wrote:
| > Pascal Costanza  <pc@p-cos.net> wrote:
| > +---------------
| > | I have tried to make SIOD on Mac OS X 10.5 and on Linux with a 2.6 
| > | kernel, but failed on both platforms.
...
| > ... (1) What the observed problem was?
| > (2) What version of SIOD you're using? (3) Where you got it?
| > (4) Are you on a 32-bit or 64-bit platform?
| 
| (2 & 3) I downloaded SIOD from 
| http://people.delphiforums.com/gjc/siod.html - so version 3.6.
+---------------

Well maybe and maybe not.  ;-}  Did you grab the tarball from here?

    http://people.delphiforums.com/gjc/siod.tgz

or from here?

    http://www.codeplex.com/siod/SourceControl/DownloadSourceCode.aspx?changeSetId=11049

If the former ["siod.tgz"], then what you really got was the last
3.5 variant [circa 2001] before George Carrette moved the source tree
over to CodePlex and started focussing full-time on the Windows port.

[Note: Despite the comment in CodePlex Change Set 1720 about
"This will be release 3.5.1", I see no evidence that an actual
"release 3.5.1" ever happened. In fact, the internal evidence from
Change Set 1720/winsiod/siod.wxs is that CS 1720 was Version="3.6.1.0".]

If the latter [CodePlex Change Set 11049], then you indeed got
version 3.6.3.0, in which case you potentially have a *lot* of
work ahead of you to put back various bits of non-Windows code
that may have been ripped out, and you may need to rip out bits
of Windows code that have been added. [See below for a possibly
gentler-slope way to get there from here...]

+---------------
| (4) I am on Mac OS X 10.5.2, Intel Mac with a 64 bit processor.
+---------------

I have various flavors of SIOD "3.5" running on both FreeBSD 4.10 32-bit
and FreeBSD 6.2 64-bit [and now Linux! -- see below]. The FreeBSD 6.2
I installed just today with a straightforward "portinstall lang/siod".
Despite a bunch of compiler warnings, the install was totally clean;
no manual intervention was needed. Though note that while the FreeBSD
Makefile for the SIOD port *claims* that it's installing "3.4":

    --->  Installing 'siod-3.4' from a port (lang/siod)
    --->  Building '/usr/ports/lang/siod'
    ===>  Cleaning for siod-3.4

the resulting binary thinks it's really 3.5 [and *is*!!]:  ;-}

    $ siod
    Welcome to SIOD, Scheme In One Defun, Version 3.5 5-MAY-97
    (C) Copyright 1988-1994 Paradigm Associates Inc.
    10 heaps. size = 100000 cells, 2400000 bytes. 2048 inums. GC is mark and sweep
    > 

Given that you're trying to build for a Mac-OS/X and/or Linux, then
probably the easiest thing to do [and it's not really going to be all
*that* "easy", but you should be able to handle it] is to go grab a
current copy of the FreeBSD "port" for SIOD (Makefile, etc.) from here:

    http://www.freebsd.org/cgi/cvsweb.cgi/ports/lang/siod/

At a minimum you will need the three "files/patch-a{a,b,c}" files
[and you mgiht want to grab the "Makefile", just for reference,
but you *won't* actually need it]. Then go grab the base source
tarball that matches that "port":

    ftp://ftp.freebsd.org/pub/FreeBSD/ports/local-distfiles/jkoshy/siod.tgz

That's dated 2000-04-03, and as far as I can tell by comparing several
other random snaps of SIOD that I have lying around, it was snapped
from Carrette's "siod.tgz" on that same day, though except for the
FreeBSD-specific changes it differs only in the minutest details from
a 1997-05-16 version. [For comparison, the current "latest" version at
<http://people.delphiforums.com/gjc/siod.tgz> seems to have no changes
since 2001-10-12.]

So given all that, here's a build procedure that works -- I just now
tried it! -- for both FreeBSD 4.10 32-bit and FreeBSD 6.2 64-bit
[and, mutatis mutandis, for Linux!]. Take the above-referenced
2000-04-03 "jkoshy/siod.tgz" tarball and unpack it into a fresh
directory somewhere, then apply the three patch files from the
"ports" collection mentioned above. Then further tweak the "makefile"
you'll find in that directory [*not* the "Makefile" from the "ports"
tree!] by finding the "freebsd:" target in it and adding these words
inside the quoted string that defines the "LD_EXE_FLAGS" variable:

    -Xlinker -rpath -Xlinker $(PWD)

That is:

    $ diff makefile.bak makefile
    311c311
    <       LD_EXE_FLAGS="-rdynamic -Xlinker -rpath -Xlinker $(LIBDIR) -Xlinker -rpath -Xlinker $(LIBSIODDIR)" \
    ---
    >       LD_EXE_FLAGS="-rdynamic -Xlinker -rpath -Xlinker $(LIBDIR) -Xlinker -rpath -Xlinker $(LIBSIODDIR) -Xlinker -rpath -Xlinker $(PWD)" \
    $ 
    $ # Adding this bit here: \_____________________________/

That will allow you to run your newly-built SIOD from your private
build directory.  Then simply say:

    $ make freebsd
    ...[lots of noise, compiler complaints, etc.]...
    ld -o regex.so -shared regex.o   libsiod.so -lcrypt -lm
    ./siod -v01,-m2 csiod.smd csiod.smd  :o=csiod :i=/bin/siod :p=read
    ...[and another dozen of the like]...
    ./siod -v01,-m2 csiod.smd :o=proxy-server :i=/bin/siod proxy-server.smd
    Build done.
    $ 

Now you can try it:

    $ ./siod
    Welcome to SIOD, Scheme In One Defun, Version 3.5 5-MAY-97
    (C) Copyright 1988-1994 Paradigm Associates Inc.
    10 heaps. size = 100000 cells, 2400000 bytes. 2048 inums. GC is mark and sweep
    > (define (fact n) (if (< n 2) 1 (* n (fact (- n 1)))))
    Evaluation took 0 seconds (0 in gc) 6 cons work, 0 real.
    #<CLOSURE (n) (if (< n 2) 1 (* n (fact (- n 1))))>
    > (fact 20)
    Evaluation took 0 seconds (0 in gc) 74 cons work, 0 real.
    2432902008176640000
    > 

As I said, I just did the above this successfully on both FreeBSD
4.10 32-bit and FreeBSD 6.2 64-bit.

+---------------
| If I say 'make linux', I get that:
| 
| [lots of warnings, and finally:]
| 
| slibu.c: In function �init_slibu�:
| slibu.c:2178: warning: unused variable �j�
| make[1]: *** [slibu.o] Error 1
| make: *** [linux] Error 2
+---------------

Hmmm... That's odd. When I tried it it compiled all right
[modulo the usual *loud* complaints] but then failed when I
tried to run it as follows:

    $ uname -rs
    Linux 2.4.21-40.EL
    $ make linux
    ...[usual chatter & complaints]...
    ./siod -v01,-m2 csiod.smd :o=proxy-server :i=/bin/siod proxy-server.smd
    Build done.
    $ ./siod
    ./siod: error while loading shared libraries: libsiod.so: cannot open shared object file: No such file or directory
    $ 

But applying the same patch to the "LD_EXE_FLAGS" line in the
"linux:" target fixed that. [NOTA BENE: Be sure to do a "make clean"
before trying another "make linux", or your "make linux" will fail.]

    $ vi makefile
    ...[tweak]...
    $ make clean
    ...[lots of chatter & complaints]...
    $ make linux
    ...[usual chatter & complaints]...
    ./siod -v01,-m2 csiod.smd :o=proxy-server :i=/bin/siod proxy-server.smd
    Build done.
    make[1]: Leaving directory `/home/rpw3/tmp.siod'
    -bash-2.05b$ ./siod
    Welcome to SIOD, Scheme In One Defun, Version 3.5 5-MAY-97
    (C) Copyright 1988-1994 Paradigm Associates Inc.
    10 heaps. size = 100000 cells, 1200000 bytes. 2048 inums. GC is mark and sweep
    > (define (fact n) (if (< n 2) 1 (* n (fact (- n 1)))))
    Evaluation took 0 seconds (0 in gc) 6 cons work, 1.30284e-05 real.
    #<CLOSURE (n) (if (< n 2) 1 (* n (fact (- n 1))))>
    > (fact 20)
    Evaluation took 0 seconds (0 in gc) 74 cons work, 4.10286e-05 real.
    2.4329e+18
    > 

Works!! [Hmmm... Looks like the Linux version doesn't have bignum support!]

Once you've got that much running on at least *one* platform,
you should then be able to cherry-pick whichever of the source code
changes you want from either the Unix/Linux 3.5 distribution at
<http://people.delphiforums.com/gjc/siod.tgz> [*very* few changes]
or -- if you're really enthusiastic ;-}  -- from the 3.6.3 WINSIOD
tree at <http://www.codeplex.com/siod/>.  Good luck!


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607