previous | back | home | next
CACD Group
updated 2000.03.30
Author Arpad Buermen

XSpice Extensions

How to build your own .cm library

A .cm library can contain multiple CMs and UDNs. An example directory structure along with the makefiles for Microsoft Visual Studio and Linux/Solaris GCC is provided in the templates/ directory of the Spice Opus tree. Another example are the sources for the .cm files that come with Spice Opus. You can find them in the lib/cmsource directory of the Spice Opus tree. A quick way is to edit the makeops.xxx (xxx=lin, sol or win) and the makedefs file. In the makeops file the compile options and directories are specified. In the top level makedefs file the names of the .cm libraries along with their directories are specified. The top level directory contains multiple sub-directories; one for each .cm file. There is a makedefs file in each of these directories. The sub makedefs files contain the lists of CMs and UDNs and the target library name for each .cm library.

To start the Windows compile, type in the top level directory:

  nmake winclean
  nmake win
Under Linux type:
  make linuxclean
  make linux
Under Solaris type:
  gmake solarisclean
  gmake solaris
This will build all .cm libraries in the top level directory.

And what do I have to do to compile a .cm library manually?

First of all everything you compile must be compiled for use in a multithread dll library.
Create one directory for each CM and put all its file in that directory. Then:

  • Create an interface specifcation file (ifspec.ifs)
  • Create a model desription file (cfunc.mod)
  • Compile the ifspec.ifs file using the cmpp utility (see bin/ directory where the Spice Opus binary is located)
    cmpp -ifs
    This results in a ifspec.c file.
  • Compile the cfunc.mod file using the cmpp utility (see bin/ directory)
    cmpp -mod
    This results in a cfunc.c file.
  • Now compile both .c files using your C compiler. Note that they must be compiled as a multithreaded .dll program. The include files for compilation are in the include/ directory in the Spice Opus tree.
  • Now you have two .obj files that will later be linked with other .obj files to produce the dll (.cm) library.
Create a directory for each UDN and put its .c source file in that directory. Then:
  • Write the functions that describe the UDN and compile the .c file with your C compiler (use multithreaded dll options).
  • Now you have a .obj file that will be linked with other .obj files to produce the library.
To build the library:
  • List all CM directories in the cmpath.lst file.
  • List all UDN directories in the udnpath.lst file.
  • Compile the .lst files using:
    cmpp -lst
    You will get 4 files: cmextern.h, cminfo.c, udnextern.h and udninfo.c
  • Edit the dlinfo.h file and enter the information about your .cm library.
  • Compile the dlmain.c (with multithreaded dll options set). By defining the macro CM_LINUX you specify that this is a Linux/Solaris compile and by defining the macro CM_WINDOWS you specify that this is a Windows compile.
  • Link together all CM and UDN .obj files with the dlmain.obj file to obtain a .dll (.so in Linux). Change the extension to .cm.
To load the library, use the cmload Nutmeg command.

IMPORTANT NOTE!
Spice Opus is available for Linux and Solaris. These two platforms have many things incommon. However the .cm files built on Solaris/i386 are not binary compatible with the Linux/i386 spice3 executable and vice versa. The same goes for Solaris/SPARC.

previous | back | home | next