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 de‐
17 scriptions 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 construc‐
49 ted 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 IN‐
78 CLUDE_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 ac‐
90 cording to the current platform. Imake replaces any occurrences of the
91 string ``@@'' with a newline to allow macros that generate more than
92 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
99 when called with program_target(foo, foo1.o foo2.o) will expand to
100
101 foo: foo1.o foo2.o
102 $(CC) -o $@ foo1.o foo2.o $(LDFLAGS)
103
104
105 Imake also replaces any occurrences of the word ``XCOMM'' with the
106 character ``#'' to permit placing comments in the Makefile without
107 causing ``invalid directive'' errors from the preprocessor.
108
109 Some complex imake macros require generated make variables local to
110 each invocation of the macro, often because their value depends on pa‐
111 rameters passed to the macro. Such variables can be created by using
112 an imake variable of the form XVARdefn, where n is a single digit. A
113 unique make variable will be substituted. Later occurrences of the
114 variable XVARusen will be replaced by the variable created by the cor‐
115 responding XVARdefn.
116
117 On systems whose cpp reduces multiple tabs and spaces to a single
118 space, imake attempts to put back any necessary tabs (make is very
119 picky about the difference between tabs and spaces). For this reason,
120 colons (:) in command lines must be preceded by a backslash (\).
121
123 The X Window System used imake extensively up through the X11R6.9 re‐
124 lease, for both full builds within the source tree and external soft‐
125 ware. X has since moved to GNU autoconf and automake for its build
126 system in X11R7.0 and later releases, but still maintains imake for
127 building existing external software programs that have not yet con‐
128 verted.
129
130 As mentioned above, two special variables, TOPDIR and CURDIR, are set
131 to make referencing files using relative path names easier. For exam‐
132 ple, the following command is generated automatically to build the
133 Makefile in the directory lib/X/ (relative to the top of the sources):
134
135 % ../.././config/imake -I../.././config \
136 -DTOPDIR=../../. -DCURDIR=./lib/X
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 Imake.tmpl generic variables
146 site.def site-specific, BeforeVendorCF defined
147 *.cf machine-specific
148 *Lib.rules shared library rules
149 site.def site-specific, AfterVendorCF defined
150 Imake.rules rules
151 Project.tmpl X-specific variables
152 *Lib.tmpl shared library variables
153 Imakefile
154 Library.tmpl library rules
155 Server.tmpl server rules
156 Threads.tmpl multi-threaded rules
157
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 af‐
161 ter 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 de‐
165 fined, and the second time, the variable AfterVendorCF is defined. All
166 code in site.def should be inside an #ifdef for one of these symbols.
167
169 Imakefile.c
170 temporary input file for cpp
171
172 /tmp/Imf.XXXXXX
173 temporary Makefile for -s
174
175 /tmp/IIf.XXXXXX
176 temporary Imakefile if specified Imakefile uses # comments
177
178 /usr/bin/cpp
179 default C preprocessor
180
182 make(1), xmkmf(1)
183
184 Paul DuBois
185 imake-Related Software and Documentation,
186 http://www.snake.net/software/imake-stuff/
187
188 Paul DuBois
189 Software Portability with imake, Second Edition, O'Reilly & As‐
190 sociates, 1996.
191
192 S. I. Feldman,
193 Make — A Program for Maintaining Computer Programs
194
196 The following environment variables may be set, however their use is
197 not recommended as they introduce dependencies that are not readily ap‐
198 parent when imake is run:
199
200 IMAKEINCLUDE
201 If defined, this specifies a ``-I'' include argument to pass to
202 the C preprocessor. E.g., ``-I/usr/X11/config''.
203
204 IMAKECPP
205 If defined, this should be a valid path to a preprocessor program.
206 E.g., ``/usr/local/cpp''. By default, imake will use cc -E or
207 /usr/bin/cpp, depending on the OS specific configuration.
208
209 IMAKEMAKE
210 If defined, this should be a valid path to a make program, such as
211 ``/usr/local/make''. By default, imake will use whatever make
212 program is found using execvp(3). This variable is only used if
213 the ``-e'' option is specified.
214
216 Todd Brunhoff, Tektronix and MIT Project Athena; Jim Fulton, MIT X Con‐
217 sortium
218
219
220
221X Version 11 imake 1.0.9 IMAKE(1)