home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
prog
/
utils
/
gambit_c.lha
/
Gambit_Comp
/
build.doc
next >
Wrap
Text File
|
1992-11-21
|
3KB
|
80 lines
FILE: "build.doc"
IMPLEMENTS: Description of how to build a stand-alone program (gsi).
AUTHOR: Ken Dickey
DATE: 1992 August 2
LAST UPDATED: 1992 November 1
NOTES: Lattice/SAS C version 5.04; Amiga 2000 w GVP 68030/882.
You really should have a hard disk and at least 3MB of RAM.
There are 2 versions of gsi which can be built. The way that uses the
least space loads the runtime from disk (assumed from directory
"Gambit:runtime"). Another way--which is here as gsi--bundles Scheme
binaries with the C code. This takes up some extra space, but
requires that only 1 file--gsi--be present. I will first describe the
large version, then the small one. Note that the make utility I got
with my original Lattice never worked, so I have written a few simple
scripts instead.
In either case there are 3 steps to building gsi [0 is already done]:
[0] Compile the Scheme runtime files into object files.
[1] Convert the Scheme object files for the interpreter runtime
into C object format.
[2] Compile the loader (C) sources.
[3] Link the C objects together into an executable.
LARGE
In addition to compiling the loader C files, you will need to convert
compiled scheme ".O" files to C ".obj" files using "gcv". Just execute
"gcv foo" to create "foo.obj" from "foo.O". Use "glk" and the file
names beyond the runtime which may be required. "glk gsi" creates a
"link_me.c" file--this has already been done for gsi.
You can then use the "link-full" or the "link-full.emu" script to link
together gsi. The script for this is "loader/compile-runtime.68020".
Actually, you can link together a stand-alone compiler (gsc), but this
adds about 800K to the binary, so I just load the compiled compiler
files from disk (see "compiler.doc").
Example:
>> cd Gambit:objects/interpreter
>> gcv _runtime ; creates _runtime.obj from _runtime.O
>> gcv _standard
;; and so on for each for each .O file
>> copy #?.obj //sources/loader ; copy to loader dir for link
>> cd //sources/loader
>> execute compile-runtime.68020 ; compile the loader files
>> execute link-full ; link gsi from the C and Scheme objects
>> gsi ; check it out ...
>> copy gsi C:gsi ; put it in your C: directory
SMALL
The loader is built with either the "compile.68020+FPU" or the
"compile.68000+emul" script. The small system is liked with
"short_link.o" which causes the runtime to be read in from disk.
Use "link-short" or "link-short.emu" to do the link.
LINKING IN C FILES
You can link in C files as long as they obey the Gambit runtime
conventions. C storage should never be referenced by other than a
vector opaque to the garbage collector (see "sources/interpreter/gsi.scm"
for unscanned-vector implementation and "loader/gambit.h" for
representation usage). Scheme objects may be moved by the collector
and so references to them from C should not be retained between calls.
Other than that, look at "loader/emu.c" and "loader/ext.c" and
"loader/ext_amiga" for a simple example. As you can see calling C
from Scheme is pretty darn simple.
.
;; --- E O F ---