]> git.sesse.net Git - rdpsrv/blob - Xserver/config/makedepend/mkdepend.man
Import X server from vnc-3.3.7.
[rdpsrv] / Xserver / config / makedepend / mkdepend.man
1 .\" $XConsortium: mkdepend.man /main/19 1996/09/28 16:15:44 rws $
2 .\" Copyright (c) 1993, 1994  X Consortium
3 .\" 
4 .\" Permission is hereby granted, free of charge, to any person obtaining a
5 .\" copy of this software and associated documentation files (the "Software"), 
6 .\" to deal in the Software without restriction, including without limitation 
7 .\" the rights to use, copy, modify, merge, publish, distribute, sublicense, 
8 .\" and/or sell copies of the Software, and to permit persons to whom the 
9 .\" Software furnished to do so, subject to the following conditions:
10 .\" 
11 .\" The above copyright notice and this permission notice shall be included in
12 .\" all copies or substantial portions of the Software.
13 .\" 
14 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 .\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 .\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL 
17 .\" THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
18 .\" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 
19 .\" OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
20 .\" SOFTWARE.
21 .\" 
22 .\" Except as contained in this notice, the name of the X Consortium shall not 
23 .\" be used in advertising or otherwise to promote the sale, use or other 
24 .\" dealing in this Software without prior written authorization from the 
25 .\" X Consortium.
26 .TH MAKEDEPEND 1 "Release 6.1" "X Version 11"
27 .UC 4
28 .SH NAME
29 makedepend \- create dependencies in makefiles
30 .SH SYNOPSIS
31 .B makedepend
32 [
33 .BI \-D name\fB=\fPdef
34 ] [
35 .BI \-D name
36 ] [
37 .BI \-I includedir
38 ] [
39 .BI \-Y includedir
40 ] [
41 .B \-a
42 ] [
43 .BI \-f makefile
44 ] [
45 .BI \-o objsuffix
46 ] [
47 .BI \-p objprefix
48 ] [
49 .BI \-s string
50 ] [
51 .BI \-w width
52 ] [
53 .B \-v
54 ] [
55 .B \-m
56 ] [
57 \-\^\-
58 .I otheroptions
59 \-\^\-
60 ]
61 .I sourcefile
62 \&.\|.\|.
63 .br
64 .SH DESCRIPTION
65 The
66 .B makedepend
67 program reads each
68 .I sourcefile
69 in sequence and parses it like a C-preprocessor,
70 processing all
71 .I #include,
72 .I #define,
73 .I #undef,
74 .I #ifdef,
75 .I #ifndef,
76 .I #endif,
77 .I #if,
78 .I #elif
79 and
80 .I #else
81 directives so that it can correctly tell which
82 .I #include,
83 directives would be used in a compilation.
84 Any
85 .I #include,
86 directives can reference files having other
87 .I #include
88 directives, and parsing will occur in these files as well.
89 .PP
90 Every file that a
91 .I sourcefile
92 includes,
93 directly or indirectly,
94 is what
95 .B makedepend
96 calls a \fIdependency.\fP
97 These dependencies are then written to a
98 .I makefile
99 in such a way that
100 .B make(1)
101 will know which object files must be recompiled when a dependency has changed.
102 .PP
103 By default,
104 .B makedepend
105 places its output in the file named
106 .I makefile
107 if it exists, otherwise
108 .I Makefile.
109 An alternate makefile may be specified with the
110 .B \-f
111 option.
112 It first searches the makefile for
113 the line
114 .sp
115     # DO NOT DELETE THIS LINE \-\^\- make depend depends on it.
116 .sp
117 or one provided with the
118 .B \-s
119 option,
120 as a delimiter for the dependency output.
121 If it finds it, it will delete everything
122 following this to the end of the makefile
123 and put the output after this line.
124 If it doesn't find it, the program
125 will append the string to the end of the makefile
126 and place the output following that.
127 For each
128 .I sourcefile
129 appearing on the command line,
130 .B makedepend
131 puts lines in the makefile of the form
132 .sp
133      sourcefile.o:\0dfile .\|.\|.
134 .sp
135 Where \fIsourcefile.o\fP is the name from the command
136 line with its suffix replaced with ``.o'',
137 and \fIdfile\fP is a dependency discovered in a
138 .I #include
139 directive while parsing
140 .I sourcefile
141 or one of the files it included.
142 .SH EXAMPLE
143 Normally,
144 .B makedepend
145 will be used in a makefile target so that typing ``make depend'' will
146 bring the dependencies up to date for the makefile.
147 For example,
148 .nf
149     SRCS\0=\0file1.c\0file2.c\0.\|.\|.
150     CFLAGS\0=\0\-O\0\-DHACK\0\-I\^.\^.\^/foobar\0\-xyz
151     depend:
152             makedepend\0\-\^\-\0$(CFLAGS)\0\-\^\-\0$(SRCS)
153 .fi
154 .SH OPTIONS
155 The program
156 will ignore any option that it does not understand so that you may use
157 the same arguments that you would for
158 .B cc(1).
159 .TP 5
160 .B \-D\fIname\fP=\fIdef\fP \fRor\fP \-D\fIname\fP
161 Define.
162 This places a definition for
163 .I name
164 in
165 .B makedepend's
166 symbol table.
167 Without 
168 .I =def\|
169 the symbol becomes defined as ``1''.
170 .TP 5
171 .B \-I\fIincludedir\fP
172 Include directory.
173 This option tells
174 .B makedepend
175 to prepend
176 .I includedir
177 to its list of directories to search when it encounters
178 a
179 .I #include
180 directive.
181 By default,
182 .B makedepend
183 only searches the standard include directories (usually /usr/include
184 and possibly a compiler-dependent directory).
185 .TP 5
186 .B \-Y\fIincludedir\fP
187 Replace all of the standard include directories with the single specified
188 include directory; you can omit the
189 .I includedir
190 to simply prevent searching the standard include directories.
191 .TP 5
192 .B \-a
193 Append the dependencies to the end of the file instead of replacing them. 
194 .TP 5
195 .B \-f\fImakefile\fP
196 Filename.
197 This allows you to specify an alternate makefile in which
198 .B makedepend
199 can place its output.
200 Specifying ``\-'' as the file name (i.e., \fB\-f\-\fP) sends the
201 output to standard output instead of modifying an existing file.
202 .TP 5
203 .B \-o\fIobjsuffix\fP
204 Object file suffix.
205 Some systems may have object files whose suffix is something other
206 than ``.o''.
207 This option allows you to specify another suffix, such as
208 ``.b'' with
209 .I \-o.b
210 or ``:obj''
211 with
212 .I \-o:obj
213 and so forth.
214 .TP 5
215 .B \-p\fIobjprefix\fP
216 Object file prefix.
217 The prefix is prepended to the name of the object file. This is
218 usually used to designate a different directory for the object file.
219 The default is the empty string.
220 .TP 5
221 .B \-s\fIstring\fP
222 Starting string delimiter.
223 This option permits you to specify
224 a different string for
225 .B makedepend
226 to look for in the makefile.
227 .TP 5
228 .B \-w\fIwidth\fP
229 Line width.
230 Normally,
231 .B makedepend
232 will ensure that every output line that it writes will be no wider than
233 78 characters for the sake of readability.
234 This option enables you to change this width.
235 .TP 5
236 .B \-v
237 Verbose operation.
238 This option causes 
239 .B makedepend
240 to emit the list of files included by each input file on standard output.
241 .TP 5
242 .B \-m
243 Warn about multiple inclusion.
244 This option causes 
245 .B makedepend
246 to produce a warning if any input file includes another file more than
247 once.  In previous versions of 
248 .B makedepend
249 this was the default behavior; the default has been changed to better
250 match the behavior of the C compiler, which does not consider multiple
251 inclusion to be an error.  This option is provided for backward 
252 compatibility, and to aid in debugging problems related to multiple
253 inclusion.
254 .TP 5
255 .B "\-\^\- \fIoptions\fP \-\^\-"
256 If
257 .B makedepend
258 encounters a double hyphen (\-\^\-) in the argument list,
259 then any unrecognized argument following it
260 will be silently ignored; a second double hyphen terminates this
261 special treatment.
262 In this way,
263 .B makedepend
264 can be made to safely ignore esoteric compiler arguments that might
265 normally be found in a CFLAGS
266 .B make
267 macro (see the
268 .B EXAMPLE
269 section above).
270 All options that
271 .B makedepend
272 recognizes and appear between the pair of double hyphens
273 are processed normally.
274 .SH ALGORITHM
275 The approach used in this program enables it to run an order of magnitude
276 faster than any other ``dependency generator'' I have ever seen.
277 Central to this performance are two assumptions:
278 that all files compiled by a single
279 makefile will be compiled with roughly the same
280 .I \-I
281 and
282 .I \-D
283 options;
284 and that most files in a single directory will include largely the
285 same files.
286 .PP
287 Given these assumptions,
288 .B makedepend
289 expects to be called once for each makefile, with
290 all source files that are maintained by the
291 makefile appearing on the command line.
292 It parses each source and include
293 file exactly once, maintaining an internal symbol table
294 for each.
295 Thus, the first file on the command line will take an amount of time
296 proportional to the amount of time that a normal C preprocessor takes.
297 But on subsequent files, if it encounters an include file
298 that it has already parsed, it does not parse it again.
299 .PP
300 For example,
301 imagine you are compiling two files,
302 .I file1.c
303 and
304 .I file2.c,
305 they each include the header file
306 .I header.h,
307 and the file
308 .I header.h
309 in turn includes the files
310 .I def1.h
311 and
312 .I def2.h.
313 When you run the command
314 .sp
315     makedepend\0file1.c\0file2.c
316 .sp
317 .B makedepend
318 will parse
319 .I file1.c
320 and consequently,
321 .I header.h
322 and then
323 .I def1.h
324 and
325 .I def2.h.
326 It then decides that the dependencies for this file are
327 .sp
328     file1.o:\0header.h\0def1.h\0def2.h
329 .sp
330 But when the program parses
331 .I file2.c
332 and discovers that it, too, includes
333 .I header.h,
334 it does not parse the file,
335 but simply adds
336 .I header.h,
337 .I def1.h
338 and
339 .I def2.h
340 to the list of dependencies for
341 .I file2.o.
342 .SH "SEE ALSO"
343 cc(1), make(1)
344 .SH BUGS
345 .B makedepend
346 parses, but does not currently evaluate, the SVR4
347 #predicate(token-list) preprocessor expression;
348 such expressions are simply assumed to be true.
349 This may cause the wrong
350 .I #include
351 directives to be evaluated.
352 .PP
353 Imagine you are parsing two files,
354 say
355 .I file1.c
356 and
357 .I file2.c,
358 each includes the file
359 .I def.h.
360 The list of files that
361 .I def.h
362 includes might truly be different when
363 .I def.h
364 is included by
365 .I file1.c
366 than when it is included by
367 .I file2.c.
368 But once
369 .B makedepend
370 arrives at a list of dependencies for a file,
371 it is cast in concrete.
372 .SH AUTHOR
373 Todd Brunhoff, Tektronix, Inc. and MIT Project Athena