MMG(1)

NAME
mmg - MuPAD module generator

SYNOPSIS

mmg [ -a attrib ] [ -c ] [ -check ] [ -gcc ] [ -generic ]
[ -j jump ] [ -l ] [ -n ] [ -pseudo ] [ -skip ] [ -sys ]
[ -V vers ] [ -v ] [ -CC cc ] [ -LD ld ] [ -oc ccopt ]
[ -ol ldopt ] [ -Ddef ] [ -Ipath ] [ -Lpath ] [ -llib ]
sourcefile mmg is the module generator for MuPAD. It translates MuPAD module-sources written in C programming language (with some additional special commands for mmg) into valid MuPAD modules.

In addition to its options, mmg accepts one sourcefile name with or without the suffix '.c'. Depending on the options, the source is translated by generating the files 'MMG*.c' and '*.o', where '*' is replaced by the string sourcefile. Then the MuPAD module is created and named after its source file extended with the suffix '.mdm'. All output-files are placed in the current directory.

In general, mmg calls the C-compiler acc/cc(1) (or the GNU C-compiler gcc(1)) and the link editor ld(1) to create modules. The format of both calls can optionally be overwritten by the user.

OPTIONS

-a attrib
    Set MuPAD module attributes to determine a special behaviour of this module:
    static - MuPAD never unloads this module
    unload - MuPAD unloads this module as fast
    as possible

-c  Suppress compiling and linking. Only produce the file 'MMG*.c' which contains the information for module management.

-check
    Combination of '-j link' and '-l'. mmg checks the correctness of MuPAD-kernel function-calls. The value 'link' enables the C-compiler to make a full analysis by using the MuPAD function prototypes.

-gcc
    Use the GNU gcc(1) instead of acc/cc(1).

-generic
    Produce a module for the generic MuPAD kernel.

-j jump
    Method of address evaluation for MuPAD-kernel variables and functions:
    slow - via function call (default)
    fast - via address table
    link - via dynamic link editor

-l  Suppress linking. Only produce output file 'MMG*.o' which still has to be converted to a loadable MuPAD module. In combination with the option '-j link' it can be used to check the syntax and the static semantics of module sources.

-n  No operation. Suppress execution of analysis, compiling and linking. In combination with the option '-v' it can be used to check the calling sequence of the compiler and linker.

-pseudo
    Generate C code for pseudo modules. This code may be compiled and statically linked to the MuPAD kernel. It is used for systems that do not support real dynamic modules. The name of the output file is 'p<module>.c'.

-sys
    Prints out the system's name. MuPAD uses this name to find its system dependend binaries. Also refer to the MuPAD script sysinfo.

-skip
    Skip the generation of C code for module management. If it has not been generated by mmg before, the user himself has to guarantee the correct handling of this module. This option is activated automatically if the input file has the reserved name "MMGout.c".

-V vers
    Set the information string of the module to vers.

-v  Verbose. Normally mmg does its work silently. With this option mmg displays each step of module generation.

-CC cc
    Specifies format of C-compiler call. This over- writes the default value, the option '-gcc' and the value given in the environment variable MMG_CC. The string cc may contain the following reserved symbols which will be substituted by mmg as described below:
    %S = name of source file (in general MMG*.c)
    %O = name of object file (in general MMG*.o)
    %M = name of module file
    %E = name of module entry-point
    %C = sequence of compiler options
    %L = sequence of linker options This is an example for using the C-compiler 'gcc' on a FreeBSD system:
    -CC "gcc -fPIC -c %S -o %O %C"

-LD ld
    Specifies format of linker call. This overwrites the default value and the value given in the environment variable MMG_LD. Refer to option '-CC' to get more information about the format of the string ld. This is an example for using the linker 'ld' on a FreeBSD system:
    -LD "ld -Bshareable %O -o %M %L"

-oc ccopt
    The option string ccopt (=%C) is passed to the C-compiler. See also '-D' and '-I'.

-ol ldopt
    The option string ldopt (=%L) is passed to the linker. See also '-l' and '-L'.

-Ddef
    Define the symbol def to the C preprocessor cpp(1). Shortcut for '-oc -Ddef'.

-Ipath
    Add path to the list of directories in which to search for include-files. Shortcut for '-oc -Ipath'.

-Lpath
    Add the path to the list of directories in which to search for libraries. Shortcut for '-ol -Lpath'.

-llib
    This option is an abbreviation for the library name 'liblib.?' where lib is a string. Shortcut for '-ol -llib'.

ENVIRONMENT

MMG_CC
    Specifies format of C-compiler call. Refer to option '-CC' to get more information about its format.

MMG_LD
    Specifies format of linker call. Refer to option '-LD' to get more information about its format.

PATH
    The mmg command requires the insertion of the names of directories which contain acc/cc(1), ld(1) and (if you want to use it) gcc(1) in your path list.

NOTE
    If you have to use LD_LIBRARY_PATH be sure to put the path of your C compiler at the head of the path list.

FILES
MDM_mod.h
    basics of MuPAD module management
MMGfile.c
    completed source, incl. module management
file.o
    module object, not linked
file.mdm
    loadable MuPAD module (dependent on system)

SEE ALSO
acc(1), cc(1), gcc(1), ld(1)

DIAGNOSTICS
The diagnostics produced by mmg are intended to be self-explanatory. Occasional obscure messages may be produced by the preprocessor, compiler, assembler, or loader.

NOTES
mmg generates additional C source code for module management which includes the user's source file. If there is any misbehaviour, check your source for names that are also used in the file `MMG*.c'. Never define any names with the prefix 'MF_' or 'MDM_'. "MMGout.c" is a reserved name for mmg and must not be used to name any user's module sources. If the module generator gets it as sourcefile name the generation of module management code will be skipped. If this file has not been created by mmg before, the user himself has to guarantee the correct handling of this module. All module sources have to be written in ANSI-C programming language.

EXAMPLES
The following source code is a small example of a MuPAD module definition. It is a complete source of a module with the public module-function 'dummy' which simply returns the MuPAD string (DOM_STRING) "dummy":
     /*** Begin of source: 'test.c' ***/

     MODUL_FUNC ( dummy )
     {
          return( MTR_new_cat_string(MMMCglobal,"dummy") );
     }

     /*** End of source: 'test.c' ***/ Now mmg is called to create the Version "andi's example" of the MuPAD module `test'. The module file has the suffix '.mdm' and is placed in the current directory.
     mmg -v -V "andi's example" test The module generator has two reserved names for module functions. The first of them is the function infomod which returns information about the current MuPAD module. It is normally generated by mmg but it can also be defined by the user. The second function is initmod that may be defined (optionally) by the user and will be called by the MuPAD function loadmod to initialize the module after it has been loaded.

SYSTEMS
By now, mmg is available on the following operating systems:

IBM(RS6000):
    AIX-3.x
IBM(AT):
    Linux 0.99p15 (for use with dld-3.2.3)
IBM(AT):
    NetBSD/FreeBSD 1.0
SGI(Indigo):
    IRIX-5.x
Sun(SPARC):
    SunOS-4.x, SunOS-5.x (Solaris)
HP: HP-UX Rel. 9.0

BUGS
The total length of mmg parameter strings is limited to 2000 characters. The number of module functions in one module is limited to 512. Linux: Don't rename MuPAD modules (moving is allowed) because the name of the module entry-point must match the module name.