man-pages/man1/makedepend.1.html
2021-03-31 01:06:50 +01:00

521 lines
10 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of MAKEDEPEND</TITLE>
</HEAD><BODY>
<H1>MAKEDEPEND</H1>
Section: User Commands (1)<BR>Updated: makedepend 1.0.5<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
makedepend - create dependencies in makefiles
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>makedepend</B>
[
<B>-D</B><I>name</I><B>=</B>def
] [
<B>-D</B><I>name</I>
] [
<B>-I</B><I>includedir</I>
] [
<B>-Y</B><I>includedir</I>
] [
<B>-a</B>
] [
<B>-f</B><I>makefile</I>
] [
<B>-include</B><I>&nbsp;file</I>
] [
<B>-o</B><I>objsuffix</I>
] [
<B>-p</B><I>objprefix</I>
] [
<B>-s</B><I>string</I>
] [
<B>-w</B><I>width</I>
] [
<B>-v</B>
] [
<B>-m</B>
] [
--
<I>otheroptions</I>
--
]
<I>sourcefile</I>
...
<BR>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The
<B>makedepend</B>
program reads each
<I>sourcefile</I>
in sequence and parses it like a C-preprocessor,
processing all
<I>#include,</I>
<I>#define,</I>
<I>#undef,</I>
<I>#ifdef,</I>
<I>#ifndef,</I>
<I>#endif,</I>
<I>#if,</I>
<I>#elif</I>
and
<I>#else</I>
directives so that it can correctly tell which
<I>#include,</I>
directives would be used in a compilation.
Any
<I>#include,</I>
directives can reference files having other
<I>#include</I>
directives, and parsing will occur in these files as well.
<P>
Every file that a
<I>sourcefile</I>
includes,
directly or indirectly,
is what
<B>makedepend</B>
calls a <I>dependency.</I>
These dependencies are then written to a
<I>makefile</I>
in such a way that
<B><A HREF="/cgi-bin/man/man2html?1+make">make</A>(1)</B>
will know which object files must be recompiled when a dependency has changed.
<P>
By default,
<B>makedepend</B>
places its output in the file named
<I>makefile</I>
if it exists, otherwise
<I>Makefile.</I>
An alternate makefile may be specified with the
<B>-f</B>
option.
It first searches the makefile for
the line
<P>
# DO NOT DELETE THIS LINE -- make depend depends on it.
<P>
or one provided with the
<B>-s</B>
option,
as a delimiter for the dependency output.
If it finds it, it will delete everything
following this to the end of the makefile
and put the output after this line.
If it doesn't find it, the program
will append the string to the end of the makefile
and place the output following that.
For each
<I>sourcefile</I>
appearing on the command line,
<B>makedepend</B>
puts lines in the makefile of the form
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sourcefile.o:&nbsp;dfile&nbsp;...
<P>
Where <I>sourcefile.o</I> is the name from the command
line with its suffix replaced with ``.o'',
and <I>dfile</I> is a dependency discovered in a
<I>#include</I>
directive while parsing
<I>sourcefile</I>
or one of the files it included.
<A NAME="lbAE">&nbsp;</A>
<H2>EXAMPLE</H2>
Normally,
<B>makedepend</B>
will be used in a makefile target so that typing ``make depend'' will
bring the dependencies up to date for the makefile.
For example,
<PRE>
SRCS&nbsp;=&nbsp;file1.c&nbsp;file2.c&nbsp;...
CFLAGS&nbsp;=&nbsp;-O&nbsp;-DHACK&nbsp;-I../foobar&nbsp;-xyz
depend:
makedepend&nbsp;--&nbsp;$(CFLAGS)&nbsp;--&nbsp;$(SRCS)
</PRE>
<A NAME="lbAF">&nbsp;</A>
<H2>OPTIONS</H2>
The program
will ignore any option that it does not understand so that you may use
the same arguments that you would for
<B><A HREF="/cgi-bin/man/man2html?1+cc">cc</A>(1).</B>
<DL COMPACT>
<DT id="1"><B>-D</B><I>name</I>=<I>def</I> or -D<I>name</I>
<DD>
Define.
This places a definition for
<I>name</I>
in
<B>makedepend's</B>
symbol table.
Without
<I>=def</I>
the symbol becomes defined as ``1''.
<DT id="2"><B>-I</B><I>includedir</I>
<DD>
Include directory.
This option tells
<B>makedepend</B>
to prepend
<I>includedir</I>
to its list of directories to search when it encounters
a
<I>#include</I>
directive.
By default,
<B>makedepend</B>
only searches the standard include directories (usually /usr/include
and possibly a compiler-dependent directory).
<DT id="3"><B>-Y</B><I>includedir</I>
<DD>
Replace all of the standard include directories with the single specified
include directory; you can omit the
<I>includedir</I>
to simply prevent searching the standard include directories.
<DT id="4"><B>-a</B>
<DD>
Append the dependencies to the end of the file instead of replacing them.
<DT id="5"><B>-f</B><I>makefile</I>
<DD>
Filename.
This allows you to specify an alternate makefile in which
<B>makedepend</B>
can place its output.
Specifying ``-'' as the file name (i.e., <B>-f-</B>) sends the
output to standard output instead of modifying an existing file.
<DT id="6"><B>-include </B><I>file</I>
<DD>
Process file as input, and include all the resulting output
before processing the regular input file. This has the same
affect as if the specified file is an include statement that
appears before the very first line of the regular input file.
<DT id="7"><B>-o</B><I>objsuffix</I>
<DD>
Object file suffix.
Some systems may have object files whose suffix is something other
than ``.o''.
This option allows you to specify another suffix, such as
``.b'' with
<I>-o.b</I>
or ``:obj''
with
<I>-o:obj</I>
and so forth.
<DT id="8"><B>-p</B><I>objprefix</I>
<DD>
Object file prefix.
The prefix is prepended to the name of the object file. This is
usually used to designate a different directory for the object file.
The default is the empty string.
<DT id="9"><B>-s</B><I>string</I>
<DD>
Starting string delimiter.
This option permits you to specify
a different string for
<B>makedepend</B>
to look for in the makefile.
<DT id="10"><B>-w</B><I>width</I>
<DD>
Line width.
Normally,
<B>makedepend</B>
will ensure that every output line that it writes will be no wider than
78 characters for the sake of readability.
This option enables you to change this width.
<DT id="11"><B>-v</B>
<DD>
Verbose operation.
This option causes
<B>makedepend</B>
to emit the list of files included by each input file.
<DT id="12"><B>-m</B>
<DD>
Warn about multiple inclusion.
This option causes
<B>makedepend</B>
to produce a warning if any input file includes another file more than
once. In previous versions of
<B>makedepend</B>
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.
<DT id="13"><B>-- </B><I>options</I> --
<DD>
If
<B>makedepend</B>
encounters a double hyphen (--) in the argument list,
then any unrecognized argument following it
will be silently ignored; a second double hyphen terminates this
special treatment.
In this way,
<B>makedepend</B>
can be made to safely ignore esoteric compiler arguments that might
normally be found in a CFLAGS
<B>make</B>
macro (see the
<B>EXAMPLE</B>
section above).
All options that
<B>makedepend</B>
recognizes and appear between the pair of double hyphens
are processed normally.
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>ALGORITHM</H2>
The approach used in this program enables it to run an order of magnitude
faster than any other ``dependency generator'' I have ever seen.
Central to this performance are two assumptions:
that all files compiled by a single
makefile will be compiled with roughly the same
<I>-I</I>
and
<I>-D</I>
options;
and that most files in a single directory will include largely the
same files.
<P>
Given these assumptions,
<B>makedepend</B>
expects to be called once for each makefile, with
all source files that are maintained by the
makefile appearing on the command line.
It parses each source and include
file exactly once, maintaining 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.
But on subsequent files, if it encounters an include file
that it has already parsed, it does not parse it again.
<P>
For example,
imagine you are compiling two files,
<I>file1.c</I>
and
<I>file2.c,</I>
they each include the header file
<I>header.h,</I>
and the file
<I>header.h</I>
in turn includes the files
<I>def1.h</I>
and
<I>def2.h.</I>
When you run the command
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;makedepend&nbsp;file1.c&nbsp;file2.c
<P>
<B>makedepend</B>
will parse
<I>file1.c</I>
and consequently,
<I>header.h</I>
and then
<I>def1.h</I>
and
<I>def2.h.</I>
It then decides that the dependencies for this file are
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;file1.o:&nbsp;header.h&nbsp;def1.h&nbsp;def2.h
<P>
But when the program parses
<I>file2.c</I>
and discovers that it, too, includes
<I>header.h,</I>
it does not parse the file,
but simply adds
<I>header.h,</I>
<I>def1.h</I>
and
<I>def2.h</I>
to the list of dependencies for
<I>file2.o.</I>
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
<A HREF="/cgi-bin/man/man2html?1+cc">cc</A>(1), <A HREF="/cgi-bin/man/man2html?1+make">make</A>(1)
<A NAME="lbAI">&nbsp;</A>
<H2>BUGS</H2>
<B>makedepend</B>
parses, but does not currently evaluate, the SVR4 #predicate(token-list)
preprocessor expression; such expressions are simply assumed to be true.
This may cause the wrong
<I>#include</I>
directives to be evaluated.
<P>
Imagine you are parsing two files,
say
<I>file1.c</I>
and
<I>file2.c,</I>
each includes the file
<I>def.h.</I>
The list of files that
<I>def.h</I>
includes might truly be different when
<I>def.h</I>
is included by
<I>file1.c</I>
than when it is included by
<I>file2.c.</I>
But once
<B>makedepend</B>
arrives at a list of dependencies for a file,
it is cast in concrete.
<A NAME="lbAJ">&nbsp;</A>
<H2>AUTHOR</H2>
Todd Brunhoff, Tektronix, Inc. and MIT Project Athena
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="14"><A HREF="#lbAB">NAME</A><DD>
<DT id="15"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="16"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="17"><A HREF="#lbAE">EXAMPLE</A><DD>
<DT id="18"><A HREF="#lbAF">OPTIONS</A><DD>
<DT id="19"><A HREF="#lbAG">ALGORITHM</A><DD>
<DT id="20"><A HREF="#lbAH">SEE ALSO</A><DD>
<DT id="21"><A HREF="#lbAI">BUGS</A><DD>
<DT id="22"><A HREF="#lbAJ">AUTHOR</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:18 GMT, March 31, 2021
</BODY>
</HTML>