1MAKEDEPEND(1) General Commands Manual MAKEDEPEND(1)
2
3
4
6 makedepend - create dependencies in makefiles
7
9 makedepend [ -Dname=def ] [ -Dname ] [ -Iincludedir ] [ -Yincludedir ]
10 [ -a ] [ -fmakefile ] [ -include file ] [ -oobjsuffix ] [ -pobjprefix ]
11 [ -sstring ] [ -wwidth ] [ -v ] [ -m ] [ -- otheroptions -- ] source‐
12 file ...
13
15 The makedepend program reads each sourcefile in sequence and parses it
16 like a C-preprocessor, processing all #include, #define, #undef,
17 #ifdef, #ifndef, #endif, #if, #elif and #else directives so that it can
18 correctly tell which #include, directives would be used in a compila‐
19 tion. Any #include, directives can reference files having other
20 #include directives, and parsing will occur in these files as well.
21
22 Every file that a sourcefile includes, directly or indirectly, is what
23 makedepend calls a dependency. These dependencies are then written to
24 a makefile in such a way that make(1) will know which object files must
25 be recompiled when a dependency has changed.
26
27 By default, makedepend places its output in the file named makefile if
28 it exists, otherwise Makefile. An alternate makefile may be specified
29 with the -f option. It first searches the makefile for the line
30
31 # DO NOT DELETE THIS LINE -- make depend depends on it.
32
33 or one provided with the -s option, as a delimiter for the dependency
34 output. If it finds it, it will delete everything following this to
35 the end of the makefile and put the output after this line. If it
36 doesn't find it, the program will append the string to the end of the
37 makefile and place the output following that. For each sourcefile
38 appearing on the command line, makedepend puts lines in the makefile of
39 the form
40
41 sourcefile.o: dfile ...
42
43 Where sourcefile.o is the name from the command line with its suffix
44 replaced with ``.o'', and dfile is a dependency discovered in a
45 #include directive while parsing sourcefile or one of the files it
46 included.
47
49 Normally, makedepend will be used in a makefile target so that typing
50 ``make depend'' will bring the dependencies up to date for the make‐
51 file. For example,
52 SRCS = file1.c file2.c ...
53 CFLAGS = -O -DHACK -I../foobar -xyz
54 depend:
55 makedepend -- $(CFLAGS) -- $(SRCS)
56
58 The program will ignore any option that it does not understand so that
59 you may use the same arguments that you would for cc(1).
60
61 -Dname=def or -Dname
62 Define. This places a definition for name in makedepend's symbol
63 table. Without =def the symbol becomes defined as ``1''.
64
65 -Iincludedir
66 Include directory. This option tells makedepend to prepend
67 includedir to its list of directories to search when it encounters
68 a #include directive. By default, makedepend only searches the
69 standard include directories (usually /usr/include and possibly a
70 compiler-dependent directory).
71
72 -Yincludedir
73 Replace all of the standard include directories with the single
74 specified include directory; you can omit the includedir to simply
75 prevent searching the standard include directories.
76
77 -a Append the dependencies to the end of the file instead of replac‐
78 ing them.
79
80 -fmakefile
81 Filename. This allows you to specify an alternate makefile in
82 which makedepend can place its output. Specifying ``-'' as the
83 file name (i.e., -f-) sends the output to standard output instead
84 of modifying an existing file.
85
86 -include file
87 Process file as input, and include all the resulting output before
88 processing the regular input file. This has the same affect as if
89 the specified file is an include statement that appears before the
90 very first line of the regular input file.
91
92 -oobjsuffix
93 Object file suffix. Some systems may have object files whose suf‐
94 fix is something other than ``.o''. This option allows you to
95 specify another suffix, such as ``.b'' with -o.b or ``:obj'' with
96 -o:obj and so forth.
97
98 -pobjprefix
99 Object file prefix. The prefix is prepended to the name of the
100 object file. This is usually used to designate a different direc‐
101 tory for the object file. The default is the empty string.
102
103 -sstring
104 Starting string delimiter. This option permits you to specify a
105 different string for makedepend to look for in the makefile.
106
107 -wwidth
108 Line width. Normally, makedepend will ensure that every output
109 line that it writes will be no wider than 78 characters for the
110 sake of readability. This option enables you to change this
111 width.
112
113 -v Verbose operation. This option causes makedepend to emit the list
114 of files included by each input file.
115
116 -m Warn about multiple inclusion. This option causes makedepend to
117 produce a warning if any input file includes another file more
118 than once. In previous versions of makedepend this was the
119 default behavior; the default has been changed to better match the
120 behavior of the C compiler, which does not consider multiple
121 inclusion to be an error. This option is provided for backward
122 compatibility, and to aid in debugging problems related to multi‐
123 ple inclusion.
124
125 -- options --
126 If makedepend encounters a double hyphen (--) in the argument
127 list, then any unrecognized argument following it will be silently
128 ignored; a second double hyphen terminates this special treatment.
129 In this way, makedepend can be made to safely ignore esoteric com‐
130 piler arguments that might normally be found in a CFLAGS make
131 macro (see the EXAMPLE section above). All options that makede‐
132 pend recognizes and appear between the pair of double hyphens are
133 processed normally.
134
136 The approach used in this program enables it to run an order of magni‐
137 tude faster than any other ``dependency generator'' I have ever seen.
138 Central to this performance are two assumptions: that all files com‐
139 piled by a single makefile will be compiled with roughly the same -I
140 and -D options; and that most files in a single directory will include
141 largely the same files.
142
143 Given these assumptions, makedepend expects to be called once for each
144 makefile, with all source files that are maintained by the makefile
145 appearing on the command line. It parses each source and include file
146 exactly once, maintaining an internal symbol table for each. Thus, the
147 first file on the command line will take an amount of time proportional
148 to the amount of time that a normal C preprocessor takes. But on sub‐
149 sequent files, if it encounters an include file that it has already
150 parsed, it does not parse it again.
151
152 For example, imagine you are compiling two files, file1.c and file2.c,
153 they each include the header file header.h, and the file header.h in
154 turn includes the files def1.h and def2.h. When you run the command
155
156 makedepend file1.c file2.c
157
158 makedepend will parse file1.c and consequently, header.h and then
159 def1.h and def2.h. It then decides that the dependencies for this file
160 are
161
162 file1.o: header.h def1.h def2.h
163
164 But when the program parses file2.c and discovers that it, too,
165 includes header.h, it does not parse the file, but simply adds
166 header.h, def1.h and def2.h to the list of dependencies for file2.o.
167
169 cc(1), make(1)
170
172 makedepend parses, but does not currently evaluate, the SVR4 #predi‐
173 cate(token-list) preprocessor expression; such expressions are simply
174 assumed to be true. This may cause the wrong #include directives to be
175 evaluated.
176
177 Imagine you are parsing two files, say file1.c and file2.c, each
178 includes the file def.h. The list of files that def.h includes might
179 truly be different when def.h is included by file1.c than when it is
180 included by file2.c. But once makedepend arrives at a list of depen‐
181 dencies for a file, it is cast in concrete.
182
184 Todd Brunhoff, Tektronix, Inc. and MIT Project Athena
185
186
187
1884th Berkeley Distribution makedepend 1.0.4 MAKEDEPEND(1)