Info file: ffi.info,    -*-Text-*-
produced on 30 Jul 1993 by texinfo-format-buffer
from file `ffi.texinfo'
using `texinfmt.el' version 2.26 of 15 September 1992.



File: ffi.info, Node: Top, Next: (dir), Prev: (dir), Up: (dir)


Using the Foreign Function call Interface
=========================================

  1. Mkdir a new directory for this stuff.

  2. Copy into this directory any C or Fortran source or objects (.o's)
     that you'll need to link with.

  3. In that directory, create a file called "ffi", containing the
     description of the funtions you need to call.

  4. Load "/scheme/etc/genprim.scm" into a running scheme somewhere, and
     invoke (genprim "ffi").

  5. This will generate files called ffi.c and ffi.scm.  Edit these if
     necessary, to add additional scheme or C functions, etc.

  6. Run /scheme/etc/make-ucode-dir, which is a script that will create
     a subdir called 'ucode', and set things up in there so that you can
     compile and link your own version of the microcode.

  7. Look at the ymake.lcl file created in the current directory by
     make-ucode-dir.  Edit FFI_SOURCES and FFI_OBJECTS to add any C or
     Fortran source you copied over in step #2.

  8. Cd to the ucode subdir.  Do 'make xmkfile' followed by 'make -f
     xmkfile scmffi'.  This should compile and link everything.

  9. Run the new microcode by invoking './scmffi'.  When it comes up,
     (load "ffi.scm")

 10. Miller Time.



Notes:
======


   * You probably don't want to run make-ucode-dir more than once,
     unless you rm -rf the ucode subdir.  It makes links in the ucode
     subdir for anything already in the parent dir.  This separates what
     is "yours" from the standard microcode sources.

   * You need to load /scheme/etc/dp.scm (in ffi.scm, say) if you are
     going to be working with vectors of double-floats (e.g. real*8's in
     Fortrash).

   * Ymake.lcl has things preconfigured for a vanilla setup. You may
     want to hack FFI_LIBS as well, or LDFLAGS in the xmkfile.  Anything
     you do to the xmkfile will get blown away if you re-make it ...

   * A working example of all this is in /sw/nick/ffi/example.


