COHERENT manpages
This page displays the COHERENT manpage for makedepend [Generate list of dependencies for a makefile].
List of available manpages
Index
makedepend -- X Utility
Generate list of dependencies for a makefile
makedepend [-Dname=def] [-Dname] [-Iincludedir] [-Yincludedir] [-a] [-
fmakefile] [-oobjsuffix] [-pobjprefix] [-sstring] [-wwidth] [-v] [-m] [--
otheroption ...--] sourcefile ...
makedepend reads each sourcefile, and parses it as the C preprocessor does.
It processes every #include, #define, #undef, #ifdef, #ifndef, #endif, #if,
and #else directives so that it can correctly tell which #include
directives should be used in a compilation. Any #include directive can
reference a file that has other #include directives, and makedepend parses
these files as well.
Every file that a sourcefile includes, directly or indirectly, is what
makedepend calls a dependency. It writes these dependencies into a makefile
in such a way that make will know which object files must be recompiled
when a dependency has changed.
By default, makedepend writes its output into a file named makefile, if it
exists; otherwise, it writes its output into Makefile. You can specify an
alternate makefile with the option -f. makedepend first searches the
makefile for the line
# DO NOT DELETE THIS LINE -- make depend depends on it.
or one provided with the option -s as a delimiter for the dependency
output. If it finds the line, it deletes everything after after this line
to the end of the makefile, and writes its output after this line. If
makedepend does not find this line, it appends the string to the end of the
makefile and writes the output after that. For each sourcefile, makedepend
writes into the makefile a line of the form
sourcefile.o: dfile ...
where sourcefile.o is the name of the sourcefile with its suffix replaced
.o, and dfile is a dependency that makedepend discovered in a #include
directive as it parsed sourcefile or one of the files it includes.
Command-line Options
makedepend ignores any option it does not understand, so you can use the
same arguments that you would for cc. It does recognize the following
command-line options:
-Dsymbol[=def]
Define symbol within makedepend's internal symbol table. Without
=def, makedepend defines it as 1.
-Iincludedir
Tell makedepend to prefix includedir onto the list of directories to
search when it encounters a #include directive. By default,
makedepend only searches only /usr/include.
-Y[includedir]
Search includedir for header files instead of all of the standard
header-file directories. If you omit to name an includedir, this
option prevents searching of the standard header-file directories.
-a Append the dependencies to the end of the file instead of replacing
them.
-ffile
Write output into file instead of into makefile.
-oobjsuffix
Append objectsuffix to a filename instead of the default .o.
-pobjprefix
Prefix the name of each object file with objprefix. This usually is
used to designate a different directory for the object file. The
default is the empty string.
-sstring
Use string as the starting-string delimiter within a makefile.
-wwidth
Set the width of a line of output to width. By default, makedepend
limits a line of output to 78 characters.
-v Verbose: tell makedepend to write onto the standard output the list of
files that each input file includes.
-m Warn about multiple inclusion. This option tells makedepend to warn
if any input file includes another file more than once. In previous
versions of makedepend, this was the default behavior; the default has
been changed to better match the behavior of the C compiler, which
does not consider multiple inclusion to be an error. This option is
provided for backward compatibility, and to aid in debugging problems
related to multiple inclusion.
-- option ... --
makedepend ignores every option that it does not recognize and that is
bracked by two hyphens `--'. In this way, you can safely tell
makedepend to ignore esoteric compiler arguments that might normally
be found in a CFLAGS macro. makedepend processes normally all options
between the pair of double hyphens that recognizes.
Algorithm
To speed its performance, makedepend makes two assumptions about the
programs whose dependency it is mapping: first, that all files compiled by
a single makefile will be compiled with roughly the same -I and -D options;
and second, that most files in a directory include largely the same files.
Given these assumptions, makedepend expects to be called once for each
makefile, with all source files that that makefile maintains appearing on
its command line.
makedepend parses each source and header file exactly once, and maintains
an internal symbol table for each. Thus, the first file on the command
line will take an amount of time proportional to the amount of time that a
normal C preprocessor takes. However, on subsequent files, if makedepend
encounters a header file that it has already parsed, it does not parse it
again.
For example, imagine you are compiling two files, file1.c and file2.c.
Assume, further, that each includes the header file header.h, and header.h
in turn includes the files def1.h and def2.h. When you run the command
makedepend file1.c file2.c
makedepend parses file1.c and, therefore, header.h followed by def1.h and
def2.h. It then decides that the dependencies for this file are
file1.o: header.h def1.h def2.h
When makedepend parses file2.c and discovers that it, too, includes
header.h, it does not re-parse that file, but simply adds header.h, def1.h,
and def2.h to the list of dependencies for file2.o.
Example
makedepend normally is used within a makefile target, so that typing the
command
make depend
brings the dependencies up to date for the makefile. For example,
SRCS = file1.c file2.c ...
CFLAGS = -O -DHACK -I../foobar -xyz
depend:
makedepend -- $(CFLAGS) -- $(SRCS)
See Also
cc,
commands,
make
X Windows Manual: imake
Notes
makedepend was written by Todd Brunhoff of Tektronix, Inc., and MIT Project
Athena.






