Go to the previous, next section.

# Using Imake with ILU

ILU uses the `imake` system from the X Window System distribution. `imake` provides a parameterized way of constructing ``Makefile'`s automatically from ``Imakefile'`s. The ``Imakefile'`s contain macros which are expanded to regular ``Makefile'` rules when the program `imake` is run.

## Creating ``Makefile'`s from ``Imakefile'`s

The program `ilumkmf` is supplied with the ILU system. When run, it will use the ``Imakefile'` in your current working directory as input, and produce the corresponding ``Makefile'`, again in the current working directory:

    % cd myilu
    % ls
    Imakefile foo.isl fooProg.cc
    % ilumkmf
    % ls
    Imakefile Makefile foo.isl fooProg.cc
    %

## ANSI C Usage

A typical ``Imakefile'` for an ANSI C ILU application would look like:

    NormalObjectRule()  /* this rule defines the .c -> .o step */

    InterfaceTarget(foo.isl)
    ILUCTarget(foo.h foo-surrogate.c foo-common.c foo-true.c, foo.isl)

    DepObjectTarget(programComponent1.o, foo.h somethingElse.h)
    ObjectTarget(programComponent2.o)

    CProgramTarget(program, programComponent1.o programComponent2.o foo-surrogate.o foo-common.o,,)

### ANSI C ILU `imake` Macros

The variable `LOCAL_INCLUDES` is a list of include file locations to be included when compiling.

The variable `ANSI_C_COMMAND` defines the particular command invoked for compiling ANSI C on your system. If you wish to use a different ANSI C compiler, override the default command by redefining this value in your ``Imakefile'`. Note that it may also be necessary to build a version of the ILU ANSI C library, ``ILUHOME/lib/libilu-c.a'`, to use with this compiler.

`NormalObjectRule()` defines a number of suffix rules, in particular the one to go from ``.c'` files to ``.o'` files in your environment.

`InterfaceTarget(ISL-file)` defines a number of rules about the ``.isl'` file ISL-file. You should have one of these in your ``Imakefile'` for every interface you use.

`ILUCTarget(generated-files, ISL-file)` defines which ANSI C files are generated from the ``isl'` file and may therefore by re-generated at will, and when the ``.isl'` file changes. Generally, for an interface called `foo`, the generated files will be ``foo-surrogate.c'`, ``foo-true.c'`, ``foo-common.c'`, and ``foo.h'`.

`ObjectTarget(object-file)` simply states that the specified object-file should be built.

`DepObjectTarget(object-file, dependencies)` says that the specified object-file should be built, and that it depends on the files specified in dependencies, which is a list of file names separated by spaces. Whenever something in the dependencies list changes, the object-file will be re-built.

`CProgramTarget(program-name, objects, dep-libraries, non-dep-libraries)` defines a program called program-name that is dependent on the object files defined in objects, and the libraries specified in dep-libraries, so that it will be re-built if anything changes in those two groups. It will also be linked with libraries specified in non-dep-libraries, but will not be re-built if they change. Note that the ILU ANSI C libraries are not automatically included by this command, but may be specified as part of the program by specifying them as part of either `dep-libraries` or `non-dep-libraries`.

`ILUCProgramTarget(program-name, objects, dep-libraries, non-dep-libraries)` defines a program called program-name that is dependent on the object files defined in objects, and the libraries specified in dep-libraries, and the normal ILU ANSI C libraries, so that it will be re-built if anything changes in those three groups, all of which will be linked into the program program-name. It will also be linked with libraries specified in non-dep-libraries, but will not be re-built if they change. This differs from `CProgramTarget` in that the ILU libraries are automatically included.

## C++ Usage

A typical ``Imakefile'` for a C++ application and ILU would look like:

    LOCALINCLUDES = -I$(ILUHOME)/include
    ILULIBS = $(ILUHOME)/lib/libilu-c++.a $(ILUHOME)/lib/libilu.a

    NormalObjectRule()  /* this rule defines the .cc -> .o step */

    InterfaceTarget(foo.isl)
    ILUCPlusPlusTarget(foo.H foo.cc foo-server-stubs.cc, foo.isl)

    DepObjectTarget(programComponent1.o, foo.H somethingElse.H)
    ObjectTarget(programComponent2.o)

    CPlusPlusProgramTarget(program, programComponent1.o programComponent2.o foo.o, $(ILULIBS),)

### C++ ILU `imake` Macros

The variable `LOCAL_INCLUDES` is a list of include file locations to be included when compiling. `-I$(ILUHOME)/include` should always be on this list for compiling ILU applications.

The variable `CPLUSPLUS_COMMAND` defines the particular command invoked for compiling C++ on your system. If you wish to use a different C++, override the default command by redefining this value. Note that it will also be necessary to build a version of ILU C++ library, ``ILUHOME/lib/libilu-c++.a'`, to use with this compiler.

`NormalObjectRule()` defines a number of suffix rules, in particular the one to go from ``.cc'` files to ``.o'` files in your environment.

`InterfaceTarget(ISL-file)` defines a number of rules about the ``.isl'` file ISL-file. You should have one of these in your ``Imakefile'` for every interface you use.

`ILUCPlusPlusTarget(generated-files, ISL-file)` defines which C++ files are generated from the ``isl'` file and may therefore by re-generated at will, and when the ``.isl'` file changes. Generally, for an interface called `foo`, the generated files will be ``foo.cc'`, ``foo.H'`, and ``foo-server-stubs.cc'`.

`ObjectTarget(object-file)` simply states that the specified object-file should be built.

`DepObjectTarget(object-file, dependencies)` says that the specified object-file should be built, and that it depends on the files specified in dependencies, which is a list of file names separated by spaces. Whenever something in the dependencies list changes, the object-file will be re-built.

`CPlusPlusProgramTarget(program-name, objects, dep-libraries, non-dep-libraries)` defines a program called program-name that is dependent on the object files defined in objects, and the libraries specified in dep-libraries, so that it will be re-built if anything changes in those two groups. It will also be linked with libraries specified in non-dep-libraries, but will not be re-built if they change. Note that the ILU ANSI C libraries are not automatically included by this command, but may be specified as part of the program by specifying them as part of either `dep-libraries` or `non-dep-libraries`.

`ILUCPlusPlusProgramTarget(program-name, objects, dep-libraries, non-dep-libraries)` defines a program called program-name that is dependent on the object files defined in objects, and the libraries specified in dep-libraries, and the normal ILU ANSI C libraries, so that it will be re-built if anything changes in those three groups, all of which will be linked into the program program-name. It will also be linked with libraries specified in non-dep-libraries, but will not be re-built if they change. This differs from `CProgramTarget` in that the ILU libraries are automatically included.

## Modula-3 Usage

A typical ``Imakefile'` for a Modula-3 application and ILU would look like:

    LOCALM3FLAGS = -D$(ILUHOME)/include -L$(ILUHOME)/lib

    InterfaceTarget(foo.isl)
    ILUM3Target(IluM3Files(foo), foo.isl)
    M3LibraryTarget(libfoo.a, IluM3Files(foo), -lilu-m3)
    M3ProgramTarget(FooM3Server, FooM3Server.m3 libfoo.a, -lilu-m3 -lilu)
    M3ProgramTarget(FooM3Client, FooM3Client.m3 libfoo.a, -lilu-m3 -lilu)

### Modula-3 ILU `imake` Macros

The variable `LOCALM3FLAGS` is a list of extra arguments to be passed to the `m3` command when compiling. `-D$(ILUHOME)/include` and `-L$(ILUHOME)/lib` should always be on this list for compiling ILU applications.

The variable `M3_COMMAND` defines the particular command invoked for compiling Modula-3 on your system. If you wish to use a different Modula-3, override the default command by redefining this value. Note that it will also be necessary to build a version of ILU Modula-3 library, ``ILUHOME/lib/libilu-m3.a'`, to use with this compiler.

`IluM3Files(base)` expands to the series of filenames generated by the Modula-3 stubber from ``base.isl'`: ``base.i3 base_x.i3 base_y.m3 base_c.m3 base_s.m3'`.

`ILUM3Target(generated-files, ISL-file)` declares that files generated-files are generated from the ``isl'` file and may therefore by re-generated at will, and should be when the ``.isl'` file changes.

`M3LibraryTarget(library-name, parts, non-dep-libraries)` defines a library called library-name that is built from parts and non-dep-libraries; it will be re-built if anything among the parts changes. The library-name should be the name of the ``.a'` file, including the ".a".

`M3ProgramTarget(program-name, parts, non-dep-libraries)` defines a program called program-name that is built from parts and non-dep-libraries; it will be re-built if anything among the parts changes.

Go to the previous, next section.