]>
Commit | Line | Data |
---|---|---|
d1b2a10e | 1 | .TH IMAKE 1 "Jan 6, 1987" |
2 | .UC 4 | |
3 | .SH NAME | |
4 | imake \- C preprocessor interface to the make utility | |
5 | .SH SYNOPSIS | |
6 | .B imake | |
7 | [ | |
8 | .B \-Ddefine | |
9 | ] [ | |
10 | .B \-Idirectory | |
11 | ] [ | |
12 | .B \-T | |
13 | ] [ | |
14 | .B \-f | |
15 | .I imakefile | |
16 | ] [ | |
17 | .B \-s | |
18 | [ | |
19 | .I makefile | |
20 | ]] [ | |
21 | .B \-v | |
22 | ] [ make options or arguments ] | |
23 | .SH DESCRIPTION | |
24 | .I Imake | |
25 | takes a template and an Imakefile and runs the C preprocessor on it producing a | |
26 | temporary makefile in /usr/tmp. It then runs | |
27 | .I make | |
28 | on this pre-processed makefile. | |
29 | See IMPLEMENTATION DETAIL below. | |
30 | .PP | |
31 | By default, | |
32 | .I Imake | |
33 | looks first for the file named | |
34 | .I Imakefile | |
35 | and if that fails, looks for the file named | |
36 | .I imakefile, | |
37 | both in the current working directory. | |
38 | .SH OPTIONS | |
39 | .TP 5 | |
40 | .B \-Ddefine | |
41 | Define. | |
42 | This argument is passed on to the preprocessor, cpp. | |
43 | This can also be accomplished with the environment variable, | |
44 | IMAKEINCLUDE. | |
45 | .TP 5 | |
46 | .B \-Idirectory | |
47 | Include directory. | |
48 | This argument is passed on to the preprocessor, cpp. | |
49 | This can also be accomplished with the environment variable, | |
50 | IMAKEINCLUDE. | |
51 | .TP 5 | |
52 | .B \-T template | |
53 | Template file. | |
54 | Specifies the template file to be initially included by cpp, | |
55 | instead of the default file | |
56 | .I Imake.template. | |
57 | .TP 5 | |
58 | .B \-f imakefile | |
59 | File. | |
60 | Specifies an alternate imakefile for | |
61 | .I imake to use. | |
62 | .TP 5 | |
63 | .B \-s [ filename ] | |
64 | Show. | |
65 | .I Imake | |
66 | will preprocess the imakefile, | |
67 | and direct it to the standard output. | |
68 | The | |
69 | .I make | |
70 | program will not be invoked. | |
71 | If the filename argument is present | |
72 | the output will be directed instead to the named file. | |
73 | Typically, this is | |
74 | .I \-s Makefile. | |
75 | .TP 5 | |
76 | .B \-v | |
77 | Verbose. | |
78 | .I Imake | |
79 | will display the command line it uses to invoke the C preprocessor before | |
80 | actually doing so. | |
81 | .SH "ENVIRONMENT VARIABLES" | |
82 | Imake consults its environment for three variables: | |
83 | .TP 5 | |
84 | .B IMAKEINCLUDE | |
85 | If defined, this should be a valid include argument for the | |
86 | C preprocessor. E.g. ``-I/usr/include/local''. | |
87 | Actually, any valid | |
88 | .I cpp | |
89 | argument will work here. | |
90 | .TP 5 | |
91 | .B IMAKECPP | |
92 | If defined, this should be a valid path to a preprocessor program. | |
93 | E.g. ``/usr/local/cpp''. | |
94 | By default, | |
95 | .I imake | |
96 | will use /lib/cpp. | |
97 | .TP 5 | |
98 | .B IMAKEMAKE | |
99 | If defined, this should be a valid path to a make program. | |
100 | E.g. ``/usr/local/make''. | |
101 | By default, | |
102 | .I imake | |
103 | will use whatever | |
104 | .I make | |
105 | program is found using | |
106 | .I execvp(3). | |
107 | .SH IMPLEMENTATION DETAIL | |
108 | .I Imake | |
109 | first determins the name of the imakefile from the command line \-f | |
110 | flag or from the content of the current directory, depending | |
111 | on whether Imakefile or imakefile exist. | |
112 | We shall call this \fI<imakefile>\fP. | |
113 | It also determines the name of the template | |
114 | from the command line \-T flag or the default, Imake.template. | |
115 | Call this \fI<template>\fP. | |
116 | .PP | |
117 | The program then examines the imakefile looking for any lines | |
118 | that begin with a '#' character. If it finds one, | |
119 | it checks to see if it is a valid C preprocessor directive | |
120 | from the set | |
121 | .I #include, | |
122 | .I #define, | |
123 | .I #undef, | |
124 | .I #ifdef, | |
125 | .I #else, | |
126 | .I #endif | |
127 | or | |
128 | .I #if. | |
129 | If it is, | |
130 | .I imake | |
131 | leaves it unchanged. | |
132 | If not, | |
133 | it pads the beginning of the line with a null C comment ``/**/'' | |
134 | so that the line will by untouched by the preprocessor. | |
135 | This is usefull for preserving the use of | |
136 | .I make | |
137 | style ``#'' comments. | |
138 | If any lines needed to be changed, | |
139 | a temporary file named /tmp/tmp-imake.* will receive the "padded" | |
140 | imakefile. | |
141 | Call this file, whether it needed to be changed or not, | |
142 | \fI<input-imakefile>\fP. | |
143 | .PP | |
144 | Then the program | |
145 | starts up the C preprocessor with the command line | |
146 | .RS 5 | |
147 | .sp 1 | |
148 | /lib/cpp -I. -I/usr/lib/local/imake.includes -Uunix | |
149 | .sp 1 | |
150 | .RE | |
151 | perhaps prepending the argument list with the IMAKEINCLUDE | |
152 | environment variable, | |
153 | the \fI\-I\fP, and the \fI\-D\fP command line arguments; | |
154 | or changing the preprocessor program to the IMAKECPP environment variable. | |
155 | Standard input is from the | |
156 | .I imake | |
157 | program and standard output is directed to a temporary file in | |
158 | /usr/tmp/tmp-make.*; | |
159 | unless there was an argument to the \-s flag, in which case | |
160 | output is directed there. | |
161 | Call this file \fI<makefile>\fP. | |
162 | The first three lines provided as input to the preprocessor | |
163 | will be | |
164 | .RS 5 | |
165 | .sp 1 | |
166 | #define IMAKE_TEMPLATE "\fI<template>\fP" | |
167 | .br | |
168 | #define INCLUDE_IMAKEFILE "\fI<input-imakefile>\fP" | |
169 | .br | |
170 | #include IMAKE_TEMPLATE | |
171 | .sp 1 | |
172 | .RE | |
173 | .PP | |
174 | Note that this implies that the template must have, at a bare minimum, | |
175 | the line | |
176 | .RS 5 | |
177 | .sp 1 | |
178 | #include INCLUDE_IMAKEFILE | |
179 | .sp 1 | |
180 | .RE | |
181 | .PP | |
182 | Next, | |
183 | .I imake | |
184 | reads the entire output of the preprocessor into memory, | |
185 | stripping off any double '@' signs encountered in the input. | |
186 | This is very useful for writing cpp multi-line macros that | |
187 | won't be coalesced into a single line the way | |
188 | .I cpp | |
189 | normally does. | |
190 | In addition, trailing white space on any line is thrown away to keep | |
191 | .I make | |
192 | from getting upset; | |
193 | and most blank lines are thrown | |
194 | away. | |
195 | For example, the macro | |
196 | .ta .8i 1.6i 5i | |
197 | .nf | |
198 | ||
199 | #define program_target(program, objlist) @@\e | |
200 | program: objlist @@\e | |
201 | $(CC) -o $@ objlist $(LDFLAGS) | |
202 | ||
203 | .fi | |
204 | when called with | |
205 | .I "program_target(foo, foo1.o foo2.o)" | |
206 | will expand to | |
207 | .nf | |
208 | ||
209 | foo: foo1.o foo2.o | |
210 | $(CC) -o $@ foo1.o foo2.o $(LDFLAGS) | |
211 | ||
212 | .fi | |
213 | .DT | |
214 | .PP | |
215 | Finally, | |
216 | if the | |
217 | .B -s | |
218 | option has not been specified, | |
219 | .I imake | |
220 | calls the program | |
221 | .RS 5 | |
222 | .sp 1 | |
223 | make MAKE=\fI<program>\fP MAKEFILE=\fI<imakefile>\fP -f \fI<makefile>\fP makeargs | |
224 | .sp 1 | |
225 | .RE | |
226 | where ``makeargs'' is replaced with any arguments found on the command line. | |
227 | .SH FILES | |
228 | .ta 3i | |
229 | /usr/tmp/tmp-imake.\fInnnnnn\fP temporary input file for cpp | |
230 | .br | |
231 | /usr/tmp/tmp-make.\fInnnnnn\fP temporary input file for make | |
232 | .br | |
233 | /lib/cpp default C preprocessor | |
234 | .br | |
235 | /usr/lib/local/imake.includes default directory for include files. | |
236 | .DT | |
237 | .SH "SEE ALSO" | |
238 | make(1) | |
239 | .br | |
240 | S. I. Feldman | |
241 | .I | |
242 | Make \- A Program for Maintaining Computer Programs | |
243 | .SH "AUTHOR" | |
244 | Todd Brunhoff; Tektronix, inc. and Project Athena, MIT. | |
245 | .SH "BUGS" | |
246 | The C-preprocessor, Cpp, | |
247 | on a Sun compresses all tabs in a macro expansion to a single | |
248 | space. It also replaces an escaped newline with a space instead of | |
249 | deleting it. There is a kludge in the code to try to get around this | |
250 | but it depends on the fact that all targets have a ':' somewhere in | |
251 | the line and all actions for a target do not have a ':'. | |
252 | .PP | |
253 | You can use \fImake\fP-style '#' comments in the Imakefile, but | |
254 | not in the template or any other included files. If you want | |
255 | them, you must preceed them with a C null comment, /**/. |