]> andersk Git - moira.git/blame - util/makedepend/mkdepend.man
Fix another freeing-memory-we-didn't-malloc bug in AddMachine. This
[moira.git] / util / makedepend / mkdepend.man
CommitLineData
d1b2a10e 1.TH MAKEDEPEND 1 "26 October 1988" "X Version 11"
2.UC 4
3.SH NAME
4makedepend \- create dependencies in makefiles
5.SH SYNOPSIS
6.B makedepend
7[
8.B \-Dname=def
9] [
10.B \-Dname
11] [
12.B \-Iincludedir
13] [
14.B \-fmakefile
15] [
16.B \-oobjsuffix
17] [
18.B \-sstring
19] [
20.B \-wwidth
21] [
22\-\ \-
23.B otheroptions
24\-\ \-
25]
26sourcefile ...
27.br
28.SH DESCRIPTION
29.B Makedepend
30reads each
31.I sourcefile
32in sequence and parses it like a C-preprocessor,
33processing all
34.I #include,
35.I #define,
36.I #undef,
37.I #ifdef,
38.I #ifndef,
39.I #endif,
40.I #if
41and
42.I #else
43directives so that it can correctly tell which
44.I #include,
45directives would be used in a compilation.
46Any
47.I #include,
48directives can reference files having other
49.I #include
50directives, and parsing will occur in these files as well.
51.PP
52Every file that a
53.I sourcefile
54includes,
55directly or indirectly,
56is what
57.B makedepend
58calls a "dependency".
59These dependencies are then written to a
60.I makefile
61in such a way that
62.B make(1)
63will know which object files must be recompiled when a dependency has changed.
64.PP
65By default,
66.B makedepend
67places its output in the file named
68.I makefile
69if it exists, otherwise
70.I Makefile.
71An alternate makefile may be specified with the
72.I -f
73option.
74It first searches the makefile for
75the line
76.sp
77 # DO NOT DELETE THIS LINE -- make depend depends on it.
78.sp
79or one provided with the
80.I -s
81option,
82as a delimiter for the dependency output.
83If it finds it, it will delete everything
84following this to the end of the makefile
85and put the output after this line.
86If it doesn't find it, the program
87will append the string to the end of the makefile
88and place the output following that.
89For each
90.I sourcefile
91appearing on the command line,
92.B makedepend
93puts lines in the makefile of the form
94.sp
95 sourcefile.o: dfile ...
96.sp
97Where "sourcefile.o" is the name from the command
98line with its suffix replaced with ".o",
99and "dfile" is a dependency discovered in a
100.I #include
101directive while parsing
102.I sourcefile
103or one of the files it included.
104.SH EXAMPLE
105Normally,
106.B makedepend
107will be used in a makefile target so that typing "make depend" will
108bring the dependencies up to date for the makefile.
109For example,
110.nf
111 SRCS = file1.c file2.c ...
112 CFLAGS = -O -DHACK -I../foobar -xyz
113 depend:
114 makedepend -- $(CFLAGS) -- $(SRCS)
115.fi
116.SH OPTIONS
117.B Makedepend
118will ignore any option that it does not understand so that you may use
119the same arguments that you would for
120.B cc(1).
121.TP 5
122.B \-Dname=def or \-Dname
123Define.
124This places a definition for
125.I name
126in
127.B makedepend's
128symbol table.
129Without
130.I =def
131the symbol becomes defined as "1".
132.TP 5
133.B \-Iincludedir
134Include directory.
135This option tells
136.B makedepend
137to prepend
138.I includedir
139to its list of directories to search when it encounters
140a
141.I #include
142directive.
143By default,
144.B makedepend
145only searches /usr/include.
146.TP 5
147.B \-fmakefile
148Filename.
149This allows you to specify an alternate makefile in which
150.B makedepend
151can place its output.
152.TP 5
153.B \-oobjsuffix
154Object file suffix.
155Some systems may have object files whose suffix is something other
156than ".o".
157This option allows you to specify another suffix, such as
158".b" with
159.I -o.b
160or ":obj"
161with
162.I -o:obj
163and so forth.
164.TP 5
165.B \-sstring
166Starting string delimiter.
167This option permits you to specify
168a different string for
169.B makedepend
170to look for in the makefile.
171.TP 5
172.B \-wwidth
173Line width.
174Normally,
175.B makedepend
176will ensure that every output line that it writes will be no wider than
17778 characters for the sake of readability.
178This option enables you to change this width.
179.TP 5
180.B "\-\ \- options \-\ \-"
181If
182.B makedepend
183encounters a double hyphen (\-\ \-) in the argument list,
184then any unrecognized argument following it
185will be silently ignored; a second double hyphen terminates this
186special treatment.
187In this way,
188.B makedepend
189can be made to safely ignore esoteric compiler arguments that might
190normally be found in a CFLAGS
191.B make
192macro (see the
193.B EXAMPLE
194section above).
195All options that
196.B makedepend
197recognizes and appear between the pair of double hyphens
198are processed normally.
199.SH ALGORITHM
200The approach used in this program enables it to run an order of magnitude
201faster than any other "dependency generator" I have ever seen.
202Central to this performance are two assumptions:
203that all files compiled by a single
204makefile will be compiled with roughly the same
205.I -I
206and
207.I -D
208options;
209and that most files in a single directory will include largely the
210same files.
211.PP
212Given these assumptions,
213.B makedepend
214expects to be called once for each makefile, with
215all source files that are maintained by the
216makefile appearing on the command line.
217It parses each source and include
218file exactly once, maintaining an internal symbol table
219for each.
220Thus, the first file on the command line will take an amount of time
221proportional to the amount of time that a normal C preprocessor takes.
222But on subsequent files, if it encounter's an include file
223that it has already parsed, it does not parse it again.
224.PP
225For example,
226imagine you are compiling two files,
227.I file1.c
228and
229.I file2.c,
230they each include the header file
231.I header.h,
232and the file
233.I header.h
234in turn includes the files
235.I def1.h
236and
237.I def2.h.
238When you run the command
239.sp
240 makedepend file1.c file2.c
241.sp
242.B makedepend
243will parse
244.I file1.c
245and consequently,
246.I header.h
247and then
248.I def1.h
249and
250.I def2.h.
251It then decides that the dependencies for this file are
252.sp
253 file1.o: header.h def1.h def2.h
254.sp
255But when the program parses
256.I file2.c
257and discovers that it, too, includes
258.I header.h,
259it does not parse the file,
260but simply adds
261.I header.h,
262.I def1.h
263and
264.I def2.h
265to the list of dependencies for
266.I file2.o.
267.SH "SEE ALSO"
268cc(1), make(1)
269.SH BUGS
270If you do not have the source for cpp, the Berkeley Unix C preprocessor,
271then
272.B makedepend
273will be compiled in such a way that all
274.I #if
275directives will evaluate to "true" regardless of their actual value.
276This may cause the wrong
277.I #include
278directives to be evaluated.
279.B Makedepend
280should simply have its own parser written for
281.I #if
282expressions.
283.PP
284Imagine you are parsing two files,
285say
286.I file1.c
287and
288.I file2.c,
289each includes the file
290.I def.h.
291The list of files that
292.I def.h
293includes might truly be different when
294.I def.h
295is included by
296.I file1.c
297than when it is included by
298.I file2.c.
299But once
300.B makedepend
301arrives at a list of dependencies for a file,
302it is cast in concrete.
303.SH AUTHOR
304Todd Brunhoff, Tektronix, Inc. and MIT Project Athena
This page took 0.08667 seconds and 5 git commands to generate.