This directory contains a simple example of creating a module in
RScheme.  All you need to do is cd to this directory and run

  rsc -p sample.mcf

to create the module in byte compiled format, and

  rsc -p -ccode sample.mcf

to generate C code instead.

The .mcf definition is set up to generate all it's files in the
"sample" subdirectory.  That makes it easier to clean up, but note
that at the moment, the subdirectory *must* have the same name as the
module because that determines the name for any .so library.  This is
a bug in the current version of RScheme.  (FIXME: This may have been
fixed.  Check and modify documentation accordingly.)

If you generate C code, you can build the necessary shared library
with

  (cd sample && make)

This will build sample.o, which is only useful for static linking.  If
you want to be able to use your new module immediately, you want to do
this instead:

  (cd sample && make libsample.so)

Once libsample.so is built, to use it, you must first either put the
resulting .mif, .mx, .so, and .doc files into ~/lib/rs/modules or set
RS_MODULE_PATH to include whatever directory you do put the files in.

Given our current example, you could just do this:

  RS_MODULE_PATH=`pwd`/sample rs +sample

and you're in business.  Alternately, you can load the module with the
command ",(use sample)" from an RScheme prompt rather than with the
"+sample" command line argument.

Here's an example of what you can expect to see:

$ rsc -p -ccode sample.mcf 
processing: sample.mcf
adding dependent module primops (to front)
adding dependent module *scheme* (to front)
adding dependent module low-scheme (to front)
adding dependent module objsys (to front)
adding dependent module iolib (to front)
adding dependent module mathlib (to front)
adding dependent module tables (to front)
adding dependent module high-scheme (to front)
adding dependent module paths (to front)
adding dependent module mlink (to front)
adding dependent module start (to front)
adding dependent module corelib (to front)
Participating scheme file: sample
building C support files...
  corelib: detaching 3 imported bindings
  start: detaching 0 imported bindings
  mlink: detaching 0 imported bindings
  paths: detaching 0 imported bindings
  high-scheme: detaching 0 imported bindings
  tables: detaching 0 imported bindings
  mathlib: detaching 8 imported bindings
  iolib: detaching 0 imported bindings
  objsys: detaching 0 imported bindings
  low-scheme: detaching 0 imported bindings
  *scheme*: detaching 4 imported bindings
  primops: detaching 4 imported bindings
stripped local environment table: 15 / 31 bindings
saving mif: sample/sample.mif
saving documentation...

$ (cd sample && make libsample.so)
gcc -c  -g -O2 -O2 -DNDEBUG -DINLINES -DGC_MACROS -Wall -Wno-unused  -I. -I- -I/usr/lib/rscheme/include -fPIC -o sample_l.so sample_l.c
gcc -c  -g -O2 -O2 -DNDEBUG -DINLINES -DGC_MACROS -Wall -Wno-unused  -I. -I- -I/usr/lib/rscheme/include -fPIC -o sample1.so sample1.c
gcc -shared sample_l.so sample1.so -o libsample.so 

$ RS_MODULE_PATH=`pwd`/sample rs +sample
RScheme (v0.7.3.1-b32u, 1999-02-21)
Copyright (C) 1995-1999 Donovan Kolbly <d.kolbly@rscheme.org>
RScheme comes with ABSOLUTELY NO WARRANTY.
type ",warranty" for details; type ",help" for some help
loading C unit sample: /home/rlb/debdevel/rscheme/0.7.3/module-example/sample/libsample.so

$ RS_MODULE_PATH=`pwd`/sample rs +sample
RScheme (v0.7.3.1-b32u, 1999-02-21)
Copyright (C) 1995-1999 Donovan Kolbly <d.kolbly@rscheme.org>
RScheme comes with ABSOLUTELY NO WARRANTY.
type ",warranty" for details; type ",help" for some help
loading C unit sample: /home/rlb/debdevel/rscheme/0.7.3/module-example/sample/libsample.so
top[0]=>(define my-point (make <point> x: 10.0 y: 20.0))
value := my-point
top[1]=>my-point
value := #[<point> @0840_5aab]
top[2]=>
