1IMAKE(1) General Commands Manual IMAKE(1)
2
3
4
6 imake - C preprocessor interface to the make utility
7
9 imake [ -Ddefine ] [ -Idir ] [ -Udefine ] [ -Ttemplate ] [ -f filename
10 ] [ -C filename ] [ -s filename ] [ -e ] [ -v ]
11
13 Imake is used to generate Makefiles from a template, a set of cpp macro
14 functions, and a per-directory input file called an Imakefile. This
15 allows machine dependencies (such as compiler options, alternate com‐
16 mand names, and special make rules) to be kept separate from the
17 descriptions of the various items to be built.
18
20 The following command line options may be passed to imake:
21
22 -Ddefine
23 This option is passed directly to cpp. It is typically used to
24 set directory-specific variables. For example, the X Window
25 System used this flag to set TOPDIR to the name of the direc‐
26 tory containing the top of the core distribution and CURDIR to
27 the name of the current directory, relative to the top.
28
29 -Idirectory
30 This option is passed directly to cpp. It is typically used to
31 indicate the directory in which the imake template and configu‐
32 ration files may be found.
33
34 -Udefine
35 This option is passed directly to cpp. It is typically used to
36 unset variables when debugging imake configuration files.
37
38 -Ttemplate
39 This option specifies the name of the master template file
40 (which is usually located in the directory specified with -I)
41 used by cpp. The default is Imake.tmpl.
42
43 -f filename
44 This option specifies the name of the per-directory input file.
45 The default is Imakefile.
46
47 -C filename
48 This option specifies the name of the .c file that is con‐
49 structed in the current directory. The default is Imakefile.c.
50
51 -s filename
52 This option specifies the name of the make description file to
53 be generated but make should not be invoked. If the filename
54 is a dash (-), the output is written to stdout. The default is
55 to generate, but not execute, a Makefile.
56
57 -e This option indicates the imake should execute the generated
58 Makefile. The default is to leave this to the user.
59
60 -v This option indicates that imake should print the cpp command
61 line that it is using to generate the Makefile.
62
64 Imake invokes cpp with any -I or -D flags passed on the command line
65 and passes the name of a file containing the following 3 lines:
66
67 #define IMAKE_TEMPLATE "Imake.tmpl"
68 #define INCLUDE_IMAKEFILE <Imakefile>
69 #include IMAKE_TEMPLATE
70
71 where Imake.tmpl and Imakefile may be overridden by the -T and -f com‐
72 mand options, respectively.
73
74 The IMAKE_TEMPLATE typically reads in a file containing machine-depen‐
75 dent parameters (specified as cpp symbols), a site-specific parameters
76 file, a file defining variables, a file containing cpp macro functions
77 for generating make rules, and finally the Imakefile (specified by
78 INCLUDE_IMAKEFILE) in the current directory. The Imakefile uses the
79 macro functions to indicate what targets should be built; imake takes
80 care of generating the appropriate rules.
81
82 Imake configuration files contain two types of variables, imake vari‐
83 ables and make variables. The imake variables are interpreted by cpp
84 when imake is run. By convention they are mixed case. The make vari‐
85 ables are written into the Makefile for later interpretation by make.
86 By convention make variables are upper case.
87
88 The rules file (usually named Imake.rules in the configuration direc‐
89 tory) contains a variety of cpp macro functions that are configured
90 according to the current platform. Imake replaces any occurrences of
91 the string ``@@'' with a newline to allow macros that generate more
92 than one line of make rules. For example, the macro
93
94 #define program_target(program, objlist) @@\
95 program: objlist @@\
96 $(CC) -o $@ objlist $(LDFLAGS)
97
98 when called with program_target(foo, foo1.o foo2.o) will expand to
99
100 foo: foo1.o foo2.o
101 $(CC) -o $@ foo1.o foo2.o $(LDFLAGS)
102
103
104 Imake also replaces any occurrences of the word ``XCOMM'' with the
105 character ``#'' to permit placing comments in the Makefile without
106 causing ``invalid directive'' errors from the preprocessor.
107
108 Some complex imake macros require generated make variables local to
109 each invocation of the macro, often because their value depends on
110 parameters passed to the macro. Such variables can be created by using
111 an imake variable of the form XVARdefn, where n is a single digit. A
112 unique make variable will be substituted. Later occurrences of the
113 variable XVARusen will be replaced by the variable created by the cor‐
114 responding XVARdefn.
115
116 On systems whose cpp reduces multiple tabs and spaces to a single
117 space, imake attempts to put back any necessary tabs (make is very
118 picky about the difference between tabs and spaces). For this reason,
119 colons (:) in command lines must be preceded by a backslash (\).
120
122 The X Window System used imake extensively up through the X11R6.9
123 release, for both full builds within the source tree and external soft‐
124 ware. X has since moved to GNU autoconf and automake for its build
125 system in X11R7.0 and later releases, but still maintains imake for
126 building existing external software programs that have not yet con‐
127 verted.
128
129 As mentioned above, two special variables, TOPDIR and CURDIR, are set
130 to make referencing files using relative path names easier. For exam‐
131 ple, the following command is generated automatically to build the
132 Makefile in the directory lib/X/ (relative to the top of the sources):
133
134 % ../.././config/imake -I../.././config \
135 -DTOPDIR=../../. -DCURDIR=./lib/X
136
137 When building X programs outside the source tree, a special symbol Use‐
138 Installed is defined and TOPDIR and CURDIR are omitted. If the config‐
139 uration files have been properly installed, the script xmkmf(1) may be
140 used.
141
143 Here is a summary of the files read by imake as used by X. The inden‐
144 tation shows what files include what other files.
145
146 Imake.tmpl generic variables
147 site.def site-specific, BeforeVendorCF defined
148 *.cf machine-specific
149 *Lib.rules shared library rules
150 site.def site-specific, AfterVendorCF defined
151 Imake.rules rules
152 Project.tmpl X-specific variables
153 *Lib.tmpl shared library variables
154 Imakefile
155 Library.tmpl library rules
156 Server.tmpl server rules
157 Threads.tmpl multi-threaded rules
158
159 Note that site.def gets included twice, once before the *.cf file and
160 once after. Although most site customizations should be specified
161 after the *.cf file, some, such as the choice of compiler, need to be
162 specified before, because other variable settings may depend on them.
163
164 The first time site.def is included, the variable BeforeVendorCF is
165 defined, and the second time, the variable AfterVendorCF is defined.
166 All code in site.def should be inside an #ifdef for one of these sym‐
167 bols.
168
170 Imakefile.c temporary input file for cpp
171 /tmp/Imf.XXXXXX temporary Makefile for -s
172 /tmp/IIf.XXXXXX temporary Imakefile if specified Imake‐
173 file uses # comments
174 /usr/bin/cpp default C preprocessor
175
177 make(1), xmkmf(1)
178 Paul DuBois, imake-Related Software and Documentation,
179 http://www.snake.net/software/imake-stuff/
180 Paul DuBois, Software Portability with imake, Second Edition, O'Reilly
181 & Associates, 1996.
182 S. I. Feldman, Make — A Program for Maintaining Computer Programs
183
185 The following environment variables may be set, however their use is
186 not recommended as they introduce dependencies that are not readily
187 apparent when imake is run:
188
189 IMAKEINCLUDE
190 If defined, this specifies a ``-I'' include argument to pass to
191 the C preprocessor. E.g., ``-I/usr/X11/config''.
192
193 IMAKECPP
194 If defined, this should be a valid path to a preprocessor program.
195 E.g., ``/usr/local/cpp''. By default, imake will use cc -E or
196 /usr/bin/cpp, depending on the OS specific configuration.
197
198 IMAKEMAKE
199 If defined, this should be a valid path to a make program, such as
200 ``/usr/local/make''. By default, imake will use whatever make
201 program is found using execvp(3). This variable is only used if
202 the ``-e'' option is specified.
203
205 Todd Brunhoff, Tektronix and MIT Project Athena; Jim Fulton, MIT X Con‐
206 sortium
207
208
209
210X Version 11 imake 1.0.5 IMAKE(1)