[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Commands Reference, Volume 3

imake Command


C preprocessor interface to the make command.


imake [ -DDefine ] [ -IDirectory ] [ -TTemplate ] [ -f FileName ] [ -C FileName ] [ -s FileName ] [ -e ] [ -v ]


The imake command generates Makefiles from a template, a set of cpp macro functions, and a per-directory input file called Imakefile. This command keeps machine dependencies (such as compiler options, alternate command names, and special make command rules) separate from the descriptions of the items to build.

imake invokes cpp with any -I or -D flags passed on the command line and passes to it the following three lines:

#define IMAKE_TEMPLATE "Imake.tmpl"
#define INCLUDE_MAKEFILE "Imakefile"

Override Imake.tmpl and Imakefile by using the -T and -f flags, respectively.

The IMAKE_TEMPLATE typically reads the following files:

The Imakefile file uses the macro functions to indicate what targets to build and the imake command generates the appropriate rules.

Imake configuration files contain two types of variables, imake variables and make variables. The imake variables are interpreted by cpp when the imake command is run. By convention, they are not case-sensitive. The make variables are written into the Makefile for later interpretation by the make command. By convention, make variables are uppercase.

The rules file (usually named Imake.rules in the configuration directory) contains a variety of cpp macro functions that are configured according to the current platform. The imake command replaces any occurrences of the string ``@@'' with a newline ( carriage return ) to support macros that generate more than one line of make rules. For example, the 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)

On systems whose cpp reduces multiple tabs and spaces to a single space, the imake command attempts to put back any necessary tabs (the make command distinguishes between tabs and spaces). For this reason, precede all colons (:) in command lines by a backslash (\).

Use with AIXwindows

AIXwindows uses the imake command extensively for both full builds within the source tree and builds of external software. Two special variables, TOPDIR and CURDIR, are set to make referencing files using relative path names easier. For example, the following command is generated automatically to build the Makefile in the lib/X directory (relative to the top of the sources):

%  ../.././config/imake  -I../.././config  \
             -DTOPDIR=../../.  -DCURDIR=./lib/X

To build AIXwindows programs outside the source tree, a special symbol, UseInstalled, is defined and the TOPDIR and CURDIR variables are omitted. If the configuration files are properly installed, you can use the xmkmf command.

The imake command reads the following files as used by AIXwindows.

Note: The indented format indicates files that include other files.

Imake.tmpl                  generic variables
   site.def                 site-specific, BeforeVendorCF defined
         *.cf               machine-specific
             *Lib.rules     shared library
   site.def                 site-specific, AfterVendorCF defined
   Imake.rules              rules
   Project.tmpl             X-specific variables
         *Lib.tmpl          shared library variables
   Library.tmpl             library rules
   Server.tmpl              server rules
   Threads.tmpl              multi-thread rules
Note: The site.def file is included twice, both before and after the *.cf file. Although most site customizations are specified after the *.cf file, some, such as the choice of compiler, need to be specified before, because other variable settings may depend on them.

The first time the site.def file is included, the BeforeVendorCF variable is defined, and the second time, the AfterVendorCF variable is defined. All code in the site.def file should be placed inside a #ifdef macro for one of these symbols.


-DDefine Passed directly to cpp to set directory-specific variables. For example, X-windows uses this flag to set the TOPDIR variable to the name of the directory containing the top of the core distribution, and the CURDIR variable to the name of the current directory, relative to the top.
-e Indicates that the imake command should execute the generated Makefile. The default is to leave this to the user.
-f FileName Specifies the name of the per-directory input file. The default is the Imakefile file.
-IDirectory (Uppercase i) Passed directly to cpp to indicate the directory in which the imake template and configuration files are located.
-C FileName Specifies the name of the .c file that is constructed in the current directory. The default is Imakefile.c.
-s FileName Specifies the name of the make description file to be generated, without invoking the make command. If the FileName variable is a - (dash), the output is written to stdout. The default is to generate, but not execute, a Makefile.
-TTemplate Specifies the name of the master template file ( which is usually located in the directory specified with -I ) used by the cpp command. The default is the Imake.tmpl.
-v Indicates that imake should print the cpp command line that it is using to generate the Makefile.

Environment Variables

Note: The following environment variables may be set, but their use is not recommended because they introduce dependencies that are not readily apparent when the imake command is run.
IMAKEINCLUDE If defined, specifies an include argument for the C preprocessor. For example:

IMAKECPP If defined, specifies a valid path to a preprocessor program. For example:


The default is the /lib/cpp program.

IMAKEMAKE Specifies a valid path to a make program such as /usr/local/make. By default, imake uses whatever make program is found using the execvp subroutine. This variable is only used if the -e flag is specified.


imake -I/usr/lib/X11/config -DTOPDIR=/usr/lpp/X11/Xamples


/usr/tmp/tmp-imake.nnnnnn Specifies the temporary input file for the cpp preprocessor.
/usr/tmp/tmp-make.nnnnnn Specifies the temporary input file for make.
/lib/cpp The default C preprocessor.

Related Information

The make command, xmkmf command.

[ Previous | Next | Contents | Glossary | Home | Search ]