IMAKE(1) IMAKE(1)
NAME
imake - C preprocessor interface to the make utility
SYNOPSIS
imake [-Ddefine] [-Idirectory] [-T template] [-f
imakefile]
[-s [makefile]] [-v] [make_options_or_arguments]
DESCRIPTION
imake takes a template and an imakefile and runs the C
preprocessor on it producing a temporary makefile in
/usr/tmp. It then runs make on this preprocessed
makefile. See Implementation Detail.
By default, imake looks first for the file named
imakefile and, if that fails, looks for the file named
imakefile, both in the current working directory.
OPTIONS
-Ddefine
The define argument is passed on to the preprocessor,
cpp. This can also be accomplished with the
environment variable IMAKEINCLUDE.
-Idirectory
The directory argument, which specifies where imake
should look for the included files, is passed on to
the preprocessor, cpp. This can also be accomplished
with the environment variable IMAKEINCLUDE. The
default directory is /usr/include/X11/imake.includes.
-T template
Specifies the template file to be initially included
by cpp, instead of the default file, imake.tmpl.
-f imakefile
Specifies an alternate imakefile for imake to use
instead of the default imakefile.
-s [filename]
Shows the resulting makefile. imake will preprocess
the imakefile, and direct it to the standard output.
The make program will not be invoked. If the
filename argument is present the output will be
directed instead to the named file. Typically, this
is -s Makefile.
-v
Verbose mode. imake will display the command line it
uses to invoke the C preprocessor before actually
doing so.
- 1 -
IMAKE(1) IMAKE(1)
ENVIRONMENT VARIABLES
imake consults its environment for three variables:
IMAKEINCLUDE
If defined, this should be a valid include argument
for the C preprocessor, e.g., -I/usr/include/local.
Actually, any valid cpp argument will work.
IMAKECPP
If defined, this should be a valid path to a
preprocessor program, e.g., /usr/local/cpp. By
default, imake will use /lib/cpp.
IMAKEMAKE
If defined, this should be a valid path to a make
program, e.g., /usr/local/make. By default, imake
will use whatever make program is found using
execvp(3).
IMPLEMENTATION DETAIL
imake first determines the name of the imakefile from
the command line -f flag or from the content of the
current directory, depending on whether Imakefile or
imakefile exists. We shall call this imakefile. It
also determines the name of the template from the
command line -T flag or the default, Imake.tmpl. Call
this template.
The program then examines the imakefile looking for any
lines that begin with a # character. If it finds one,
it checks whether it is a valid C preprocessor
directive from the set #include, #define, #undef,
#ifdef, #else, #endif, or #if. If it is, imake leaves
it unchanged. If not, it pads the beginning of the
line with a NULL C comment, /**/, so that the line will
by untouched by the preprocessor. This is useful for
preserving the use of make-style # comments. If any
lines needed to be changed, a temporary file named
/tmp/Imake.* will receive the padded imakefile. Call
this file, whether it needed to be changed or not,
input-imakefile.
Then the program starts up the C preprocessor with the
command line:
/lib/cpp -I. -I/usr/include/X11/imake.includes -Uunix
It may prepend the argument list with the IMAKEINCLUDE
environment variable, the -I, and the -D command line
arguments, or it may change the preprocessor program to
the IMAKECPP environment variable. Standard input is
from the imake program, and standard output is directed
- 2 -
IMAKE(1) IMAKE(1)
to a temporary file in /usr/tmp/Make.* unless there was
an argument to the -s flag, in which case output is
directed there. Call this file makefile.
The first three lines provided as input to the
preprocessor will be:
#define IMAKE_TEMPLATE "<template>"
#define INCLUDE_IMAKEFILE "<input-
imakefile>"
#include IMAKE_TEMPLATE
Note that this implies that the template must have, as
the minimum, the line:
#include INCLUDE_IMAKEFILE
Next, imake reads the entire output of the preprocessor
into memory, stripping off any double at signs (@@)
encountered in the input. This is very useful for
writing multiline cpp macros that would not be
coalesced into a single line as they would with cpp.
In addition, trailing white space on any line is thrown
away to keep make from failing, and most blank lines
are thrown away. For example, the following macro:
#define program_target(program, objlist)@@\
program: objlist @@\
$(CC) -o $@ objlist $(LDFLAGS)
when called with program_target(foo, foo1.o foo2.o)
will expand to:
foo: foo1.o foo2.o
$(CC) -o $@ foo1.o foo2.o $(LDFLAGS)
Finally, if the -s option has not been specified, imake
calls the program:
make MAKE=<program> MAKEFILE=<imakefile> \
-f <makefile> makeargs
where makeargs is replaced with any arguments on the
command line.
FILES
/usr/tmp/Imake.nnnnnn temporary input file for cpp
/usr/tmp/Make.nnnnnn temporary input file for make
/lib/cpp default C preprocessor
/usr/include/X11/imake.includesdefault directory for
include files
- 3 -
IMAKE(1) IMAKE(1)
SEE ALSO
make(1)
- 4 -
IMAKE(1) IMAKE(1)
BUGS
The C preprocessor cpp compresses all tabs in a macro
expansion to a single space. It also replaces an
escaped newline with a space, instead of deleting it.
The code can account for this, but only if each target
has a colon (:) somewhere in the line and none of the
actions has a colon (:).
You can use make-style # comments in the imakefile but
not in the template or any other included files. If
you want them, you must precede them with a NULL C
comment, /**/.
AUTHOR
Todd Brunhoff; Tektronix, Inc. and Project Athena, MIT
- 5 -