Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
333 dpurdie 1
MAKEDEPEND(1)           Release 6.1 - X Version 11              MAKEDEPEND(1)
2
 
3
    NAME
4
        makedepend - create dependencies in makefiles
5
 
6
    SYNOPSIS
7
        makedepend [-D name[=def]] [-I includedir] [-Y includedir]
8
          [-a] [-f makefile] [-o objsuffix] [-p objprefix] [-s string]
9
            [-w width] [-v] [-m] [-- otheroptions --] sourcefile ...
10
 
11
    DESCRIPTION
12
        The makedepend program reads each 'sourcefile' in sequence
13
        and parses it like a C-preprocessor, processing all #include,
14
        #define, #undef, #ifdef, #ifndef, #endif, #if, #elif and
15
        #else directives so that it can correctly tell which #include,
16
        directives would be used in a compilation. Any #include,
17
        directives can reference files having other #include
18
        directives, and parsing will occur in these files as well.
19
 
20
        Every file that a 'sourcefile' includes, directly or indirectly,
21
        is what makedepend calls a 'dependency'.  These dependencies
22
        are then written to a "makefile" in such a way that make(1)
23
        will know which object files must be recompiled when a
24
        dependency has changed.
25
 
26
        By default, 'makedepend' places its output in the file named
27
        "makefile" if it exists, otherwise "Makefile".  An alternate
28
        makefile may be specified with the '-f' option.  It first
29
        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
34
        dependency output.  If it finds it, it will delete everything
35
        following this to the end of the makefile and put the output
36
        after this line.  If it doesn't find it, the program will
37
        append the string to the end of the makefile and place the
38
        output following that.  For each 'sourcefile' appearing on
39
        the command line, "makedepend" puts lines in the makefile
40
        of the form
41
 
42
            sourcefile.o:   file ...
43
 
44
        Where "sourcefile.o" is the name from the command line with
45
        its suffix replaced with `.o', and 'file' is a dependency
46
        discovered in a #include directive while parsing 'sourcefile'
47
        or one of the files it included.
48
 
49
    EXAMPLE
50
        Normally, "makedepend" will be used in a makefile target so
51
        that typing ``make depend'' will bring the dependencies up
52
        to date for the makefile.
53
 
54
            For example,
55
                SRCS    = file1.c    file2.c ...
56
                CFLAGS  = -O -DHACK -I../foobar-xyz
57
 
58
            depend:
59
                makedepend $(CFLAGS) $(SRCS)
60
 
61
    OPTIONS
62
        The program will ignore any option that it does not
63
        understand so that you may use the same arguments that you
64
        would for cc(1).
65
 
66
        -DIname=def or -DIname  Define.
67
 
68
                This places a definition for 'name' in makedepend's
69
                symbol table. Without =def the symbol becomes
70
                defined as `1'.
71
 
72
        -Iincludedir            Include directory.
73
 
74
                This option tells makedepend to prepend 'includedir'
75
                to its list of directories to search when it
76
                encounters #include directive.  By default, 
77
                makedepend only searches the standard include
78
                directories (usually /usr/include and possibly a
79
                compiler-dependent directory).
80
 
81
        -Yincludedir
82
                Replace all of the standard include directories with
83
                the single specified include directory; you can omit
84
                the 'includedir' to simply prevent searching the
85
                standard include directories.  Otherwise the system
86
                default include is referenced.
87
 
88
        -a
89
                Append the dependencies to the end of the file
90
                instead of replacing them.
91
 
92
        -fmakefile              Filename.
93
 
94
                This allows you to specify an alternate makefile in
95
                which makedepend can place its output.  Specifying
96
                `-' as the file name (i.e., -f-) sends the output
97
                to standard output instead of modifying an existing
98
                file.
99
 
100
        -oobjsuffix             Object file suffix.
101
 
102
                Some systems may have object files whose suffix is
103
                something other than `.o'.  This option allows you
104
                to specify another suffix, such as `.b' with 
105
                -o.b or `:obj' with -o:obj and so forth.
106
 
107
        -pobjprefix             Object file prefix.
108
 
109
                The prefix is prepended to the name of the object
110
                file. This is usually used to designate a different
111
                directory for the object file.  The default is the
112
                empty string.
113
 
114
        -sstring                Starting string delimiter.
115
 
116
                This option permits you to specify a different string
117
                for makedepend to look for in the makefile.
118
 
119
        -wwidth                 Line width.
120
 
121
                Normally, makedepend will ensure that every output
122
                line that it writes will be no wider than 78
123
                characters for the sake of readability.  This option
124
                enables you to change this width.
125
 
126
        -v                      Verbose operation.
127
 
128
                This option causes makedepend to emit the list of
129
                files included by each input file on standard output.
130
 
131
        -m                      Warn about multiple inclusion.
132
 
133
                This option causes makedepend to produce a warning
134
		if any input file includes another file more than 
135
		once. In previous versions of makedepend this was 
136
		the default behavior; the default has been changed 
137
		to better match the behavior of the C compiler, 
138
		which does not consider multiple inclusion to be 
139
		an error. This option is provided for backward 
140
		compatibility, and to aid in debugging problems 
141
		related to multiple inclusion.
142
 
143
        -M  [ -MG ]             GCC support
144
 
145
                `-M' tell the preprocessor to output dependencies.
146
 
147
                `-MG' says to treat missing header files as generated
148
                files and assume they live in the same directory as the
149
                source file.  It must be specified in addition to `-M'.
150
 
151
        -MM  [ -MG ]            GCC support
152
 
153
                Like `-M' but the output mentions only the user header
154
                files  included with `#include file"'.  System  header
155
                files included with `#include <file>' are omitted.
156
 
157
        --options --
158
 
159
                If makedepend encounters a double hyphen (--) in the
160
                argument list, then any unrecognized argument
161
                following it will be silently ignored; a second
162
                double hyphen terminates this special treatment.
163
                In this way, makedepend can be made to safely ignore
164
                esoteric compiler arguments that might normally be
165
                found in a CFLAGS make macro (see the EXAMPLE
166
                section above).  All options that makedepend
167
                recognizes and appear between the pair of double
168
                hyphens are processed normally.
169
 
170
    ALGORITHM
171
        The approach used in this program enables it to run an 
172
	order of magnitude faster than any other `dependency 
173
	generator' I have ever seen.  Central to this performance 
174
	are two assumptions: that all files compiled by a single 
175
	makefile will be compiled with roughly the same -I and -D 
176
	options; and that most files in a single directory will 
177
	include largely the same files.
178
 
179
        Given these assumptions, makedepend expects to be called
180
        once for each makefile, with all source files that are
181
        maintained by the makefile appearing on the command line.
182
        It parses each source and include file exactly once,
183
        maintaining an internal symbol table for each. Thus, the
184
        first file on the command line will take an amount of time
185
        proportional to the amount of time that a normal C
186
        preprocessor takes.  But on subsequent files, if it
187
        encounters an include file that it has already parsed,
188
        it does not parse it again.
189
 
190
        For example, imagine you are compiling two files,
191
        file1.c and file2.c, they each include the header file
192
        header.h, and the file header.h in turn includes the files
193
        def1.h and def2.h.  When you run the command
194
 
195
                makedepend  file1.c file2.c
196
 
197
        makedepend will parse file1.c and consequently, header.h
198
        and then def1.h and def2.h.  It then decides that the
199
        dependencies for this file are
200
 
201
                file1.o:    header.h    def1.h  def2.h
202
 
203
        But when the program parses file2.c and discovers that it,
204
        too, includes header.h, it does not parse the file, but
205
        simply adds header.h, def1.h and def2.h to the list of
206
        dependencies for file2.o.
207
 
208
    SEE ALSO
209
        cc(1), make(1)
210
 
211
    BUGS
212
        makedepend parses, but does not currently evaluate, the
213
        SVR4 #predicate(token-list) preprocessor expression;
214
        such expressions are simply assumed to be true. This may
215
        cause the wrong #include directives to be evaluated.
216
 
217
        Imagine you are parsing two files, say file1.c and file2.c,
218
        each includes the file def.h.  The list of files that
219
        def.h includes might truly be different when def.h is
220
        included by file1.c than when it is included by file2.c.
221
        But once makedepend arrives at a list of dependencies for
222
        a file, it is cast in concrete.
223
 
224
    AUTHOR
225
        Todd Brunhoff, Tektronix, Inc. and MIT Project Athena