Previous: vimake Up: vimake Next: Valid vimake Commands

Creating and Using a VICAR Imakefile

Since vimake is based on the C preprocessor, every line in an imakefile will be a C preprocessor command. Most lines will be ``#define'', with some comments and ``#if'' statements on occasion. Comments are allowed, in the standard C style (enclosed in /* ... */).

It may be easier to start with an example. Here is the imakefile for the program gen:

#define PROGRAM gen

#define MODULE_LIST gen.c

#define MAIN_LANG_C #define USES_C

#define R2LIB

#define LIB_RTL #define LIB_TAE

The first two lines define macros with values. PROGRAM specifies that this is an application program, rather than a subroutine. It also specifies the name of the application. MODULE_LIST tells vimake what source code modules make up the application.

The rest of the lines simply define switches; there are no values associated with them. MAIN_LANG_C tells vimake that the main program is written in C (or ANSI C). USES_C says that some (non-ANSI) C is used in the application (that may sound redundant but is needed when there is more than one module with mixed languages). R2LIB says that this application goes in R2LIB. The LIB_RTL and LIB_TAE switches indicate which libraries to link with, in this case the RTL and TAE libraries.

Due to the internals of how vimake operates, there is unfortunately no real error checking. You have to be sure to spell the macros correctly, or they will simply be ignored. This may cause surprising results. If vimake is not operating the way you expect, first check to make sure that all the preprocessor macros are spelled correctly.

vimake can also handle some machine dependencies. All the macros defined in xvmaininc.h are available for use in #if statements. This is typically used to compile a VMS-specific module only under VMS, and its Unix-specific counterpart only under Unix. See Section , Machine Dependencies, in the Porting C section, for details on what preprocessor macros are available from xvmaininc.h.

To use an imakefile, simply type the command vimake followed by the name of the imakefile. Note that imakefiles must have a ``.imake'' extension, but you should not give the extension on the vimake command. The command is the same under both VMS and Unix.

vimake gen

If you are running VMS, a file called ``gen.bld'' will be created (although it is a DCL COM file, a ``.com'' extension would confuse it with the packed application file). This file can be executed to compile and link the program:

$ @gen.bld

There are many options you can give on the command line to control the build, which are described in Section , Using the Generated VMS Build File.

If you are running Unix, a file called ``gen.make'' will be created when you run vimake. This file can be submitted to make to compile and link the program:

% make -f gen.make

There are many different build targets you can give to control the build process, which are described in Section , Using the Generated Unix Makefile.

The imakefile is actually composed of several parts. These parts are described below, with some examples. Although they can be in any order, the parts should generally follow the order listed below for consistency. For a complete list of valid #define's, see the next section.

Here are some more examples of VICAR imakefiles. A simple C program, gen, was listed previously. Here is a simple Fortran program:

#define PROGRAM copy

#define MODULE_LIST copy.f


#define R2LIB

#define LIB_RTL #define LIB_TAE

The following is an example subroutine that uses several different languages and has VMS-specific code. It illustrates how existing VMS macro code can be retained for efficiency while still having portable C code for other machines. Although the subroutine has not yet been ported, the example shows what the imakefile could look like when it does get ported.

#define SUBROUTINE amosids

#if VMS_OS #define MODULE_LIST amosids.f camosids.c amosufo_vms.mar #define CLEAN_OTHER_LIST amosufo_unix.c #else #define MODULE_LIST amosids.f camosids.c amosufo_unix.c #define CLEAN_OTHER_LIST amosufo_vms.mar #endif

#define P2_SUBLIB

#define USES_C #define USES_FORTRAN #if VMS_OS #define USES_MACRO #endif

The last example is for a more complex program, that has lots of modules, mixed languages, and uses several subroutine libraries. Again, the program has not yet been ported, but this is what the imakefile could look like.

/* C-style comments are okay if you really feel the need */

#define PROGRAM mgncorr

#define MODULE_LIST mgncorr.f mgncorr_fort.f mgncorr_support.c mgncorr_correl.f mgncorr_interact.c mgncorr_graphics.c mgncorr_vdt.c mgncorr_logs.c


#define R2LIB

#define LIB_P2SUB #define LIB_VRDI #define LIB_MATH77 #define LIB_RTL #define LIB_TAE