Blame config/makedepend/mkdepend.man

Packit b099d7
.\" $XConsortium: mkdepend.man /main/19 1996/09/28 16:15:44 rws $
Packit b099d7
.\" Copyright (c) 1993, 1994  X Consortium
Packit b099d7
.\" 
Packit b099d7
.\" Permission is hereby granted, free of charge, to any person obtaining a
Packit b099d7
.\" copy of this software and associated documentation files (the "Software"), 
Packit b099d7
.\" to deal in the Software without restriction, including without limitation 
Packit b099d7
.\" the rights to use, copy, modify, merge, publish, distribute, sublicense, 
Packit b099d7
.\" and/or sell copies of the Software, and to permit persons to whom the 
Packit b099d7
.\" Software furnished to do so, subject to the following conditions:
Packit b099d7
.\" 
Packit b099d7
.\" The above copyright notice and this permission notice shall be included in
Packit b099d7
.\" all copies or substantial portions of the Software.
Packit b099d7
.\" 
Packit b099d7
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Packit b099d7
.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Packit b099d7
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL 
Packit b099d7
.\" THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
Packit b099d7
.\" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 
Packit b099d7
.\" OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
Packit b099d7
.\" SOFTWARE.
Packit b099d7
.\" 
Packit b099d7
.\" Except as contained in this notice, the name of the X Consortium shall not 
Packit b099d7
.\" be used in advertising or otherwise to promote the sale, use or other 
Packit b099d7
.\" dealing in this Software without prior written authorization from the 
Packit b099d7
.\" X Consortium.
Packit b099d7
.TH MAKEDEPEND 1 "Release 6.1" "X Version 11"
Packit b099d7
.UC 4
Packit b099d7
.SH NAME
Packit b099d7
makedepend \- create dependencies in makefiles
Packit b099d7
.SH SYNOPSIS
Packit b099d7
.B makedepend
Packit b099d7
[
Packit b099d7
.BI \-D name\fB=\fPdef
Packit b099d7
] [
Packit b099d7
.BI \-D name
Packit b099d7
] [
Packit b099d7
.BI \-I includedir
Packit b099d7
] [
Packit b099d7
.BI \-Y includedir
Packit b099d7
] [
Packit b099d7
.B \-a
Packit b099d7
] [
Packit b099d7
.BI \-f makefile
Packit b099d7
] [
Packit b099d7
.BI \-o objsuffix
Packit b099d7
] [
Packit b099d7
.BI \-p objprefix
Packit b099d7
] [
Packit b099d7
.BI \-s string
Packit b099d7
] [
Packit b099d7
.BI \-w width
Packit b099d7
] [
Packit b099d7
.B \-v
Packit b099d7
] [
Packit b099d7
.B \-m
Packit b099d7
] [
Packit b099d7
\-\^\-
Packit b099d7
.I otheroptions
Packit b099d7
\-\^\-
Packit b099d7
]
Packit b099d7
.I sourcefile
Packit b099d7
\&.\|.\|.
Packit b099d7
.br
Packit b099d7
.SH DESCRIPTION
Packit b099d7
The
Packit b099d7
.B makedepend
Packit b099d7
program reads each
Packit b099d7
.I sourcefile
Packit b099d7
in sequence and parses it like a C-preprocessor,
Packit b099d7
processing all
Packit b099d7
.I #include,
Packit b099d7
.I #define,
Packit b099d7
.I #undef,
Packit b099d7
.I #ifdef,
Packit b099d7
.I #ifndef,
Packit b099d7
.I #endif,
Packit b099d7
.I #if,
Packit b099d7
.I #elif
Packit b099d7
and
Packit b099d7
.I #else
Packit b099d7
directives so that it can correctly tell which
Packit b099d7
.I #include,
Packit b099d7
directives would be used in a compilation.
Packit b099d7
Any
Packit b099d7
.I #include,
Packit b099d7
directives can reference files having other
Packit b099d7
.I #include
Packit b099d7
directives, and parsing will occur in these files as well.
Packit b099d7
.PP
Packit b099d7
Every file that a
Packit b099d7
.I sourcefile
Packit b099d7
includes,
Packit b099d7
directly or indirectly,
Packit b099d7
is what
Packit b099d7
.B makedepend
Packit b099d7
calls a \fIdependency.\fP
Packit b099d7
These dependencies are then written to a
Packit b099d7
.I makefile
Packit b099d7
in such a way that
Packit b099d7
.B make(1)
Packit b099d7
will know which object files must be recompiled when a dependency has changed.
Packit b099d7
.PP
Packit b099d7
By default,
Packit b099d7
.B makedepend
Packit b099d7
places its output in the file named
Packit b099d7
.I makefile
Packit b099d7
if it exists, otherwise
Packit b099d7
.I Makefile.
Packit b099d7
An alternate makefile may be specified with the
Packit b099d7
.B \-f
Packit b099d7
option.
Packit b099d7
It first searches the makefile for
Packit b099d7
the line
Packit b099d7
.sp
Packit b099d7
    # DO NOT DELETE THIS LINE \-\^\- make depend depends on it.
Packit b099d7
.sp
Packit b099d7
or one provided with the
Packit b099d7
.B \-s
Packit b099d7
option,
Packit b099d7
as a delimiter for the dependency output.
Packit b099d7
If it finds it, it will delete everything
Packit b099d7
following this to the end of the makefile
Packit b099d7
and put the output after this line.
Packit b099d7
If it doesn't find it, the program
Packit b099d7
will append the string to the end of the makefile
Packit b099d7
and place the output following that.
Packit b099d7
For each
Packit b099d7
.I sourcefile
Packit b099d7
appearing on the command line,
Packit b099d7
.B makedepend
Packit b099d7
puts lines in the makefile of the form
Packit b099d7
.sp
Packit b099d7
     sourcefile.o:\0dfile .\|.\|.
Packit b099d7
.sp
Packit b099d7
Where \fIsourcefile.o\fP is the name from the command
Packit b099d7
line with its suffix replaced with ``.o'',
Packit b099d7
and \fIdfile\fP is a dependency discovered in a
Packit b099d7
.I #include
Packit b099d7
directive while parsing
Packit b099d7
.I sourcefile
Packit b099d7
or one of the files it included.
Packit b099d7
.SH EXAMPLE
Packit b099d7
Normally,
Packit b099d7
.B makedepend
Packit b099d7
will be used in a makefile target so that typing ``make depend'' will
Packit b099d7
bring the dependencies up to date for the makefile.
Packit b099d7
For example,
Packit b099d7
.nf
Packit b099d7
    SRCS\0=\0file1.c\0file2.c\0.\|.\|.
Packit b099d7
    CFLAGS\0=\0\-O\0\-DHACK\0\-I\^.\^.\^/foobar\0\-xyz
Packit b099d7
    depend:
Packit b099d7
            makedepend\0\-\^\-\0$(CFLAGS)\0\-\^\-\0$(SRCS)
Packit b099d7
.fi
Packit b099d7
.SH OPTIONS
Packit b099d7
The program
Packit b099d7
will ignore any option that it does not understand so that you may use
Packit b099d7
the same arguments that you would for
Packit b099d7
.B cc(1).
Packit b099d7
.TP 5
Packit b099d7
.B \-D\fIname\fP=\fIdef\fP \fRor\fP \-D\fIname\fP
Packit b099d7
Define.
Packit b099d7
This places a definition for
Packit b099d7
.I name
Packit b099d7
in
Packit b099d7
.B makedepend's
Packit b099d7
symbol table.
Packit b099d7
Without 
Packit b099d7
.I =def\|
Packit b099d7
the symbol becomes defined as ``1''.
Packit b099d7
.TP 5
Packit b099d7
.B \-I\fIincludedir\fP
Packit b099d7
Include directory.
Packit b099d7
This option tells
Packit b099d7
.B makedepend
Packit b099d7
to prepend
Packit b099d7
.I includedir
Packit b099d7
to its list of directories to search when it encounters
Packit b099d7
a
Packit b099d7
.I #include
Packit b099d7
directive.
Packit b099d7
By default,
Packit b099d7
.B makedepend
Packit b099d7
only searches the standard include directories (usually /usr/include
Packit b099d7
and possibly a compiler-dependent directory).
Packit b099d7
.TP 5
Packit b099d7
.B \-Y\fIincludedir\fP
Packit b099d7
Replace all of the standard include directories with the single specified
Packit b099d7
include directory; you can omit the
Packit b099d7
.I includedir
Packit b099d7
to simply prevent searching the standard include directories.
Packit b099d7
.TP 5
Packit b099d7
.B \-a
Packit b099d7
Append the dependencies to the end of the file instead of replacing them. 
Packit b099d7
.TP 5
Packit b099d7
.B \-f\fImakefile\fP
Packit b099d7
Filename.
Packit b099d7
This allows you to specify an alternate makefile in which
Packit b099d7
.B makedepend
Packit b099d7
can place its output.
Packit b099d7
Specifying ``\-'' as the file name (i.e., \fB\-f\-\fP) sends the
Packit b099d7
output to standard output instead of modifying an existing file.
Packit b099d7
.TP 5
Packit b099d7
.B \-o\fIobjsuffix\fP
Packit b099d7
Object file suffix.
Packit b099d7
Some systems may have object files whose suffix is something other
Packit b099d7
than ``.o''.
Packit b099d7
This option allows you to specify another suffix, such as
Packit b099d7
``.b'' with
Packit b099d7
.I \-o.b
Packit b099d7
or ``:obj''
Packit b099d7
with
Packit b099d7
.I \-o:obj
Packit b099d7
and so forth.
Packit b099d7
.TP 5
Packit b099d7
.B \-p\fIobjprefix\fP
Packit b099d7
Object file prefix.
Packit b099d7
The prefix is prepended to the name of the object file. This is
Packit b099d7
usually used to designate a different directory for the object file.
Packit b099d7
The default is the empty string.
Packit b099d7
.TP 5
Packit b099d7
.B \-s\fIstring\fP
Packit b099d7
Starting string delimiter.
Packit b099d7
This option permits you to specify
Packit b099d7
a different string for
Packit b099d7
.B makedepend
Packit b099d7
to look for in the makefile.
Packit b099d7
.TP 5
Packit b099d7
.B \-w\fIwidth\fP
Packit b099d7
Line width.
Packit b099d7
Normally,
Packit b099d7
.B makedepend
Packit b099d7
will ensure that every output line that it writes will be no wider than
Packit b099d7
78 characters for the sake of readability.
Packit b099d7
This option enables you to change this width.
Packit b099d7
.TP 5
Packit b099d7
.B \-v
Packit b099d7
Verbose operation.
Packit b099d7
This option causes 
Packit b099d7
.B makedepend
Packit b099d7
to emit the list of files included by each input file on standard output.
Packit b099d7
.TP 5
Packit b099d7
.B \-m
Packit b099d7
Warn about multiple inclusion.
Packit b099d7
This option causes 
Packit b099d7
.B makedepend
Packit b099d7
to produce a warning if any input file includes another file more than
Packit b099d7
once.  In previous versions of 
Packit b099d7
.B makedepend
Packit b099d7
this was the default behavior; the default has been changed to better
Packit b099d7
match the behavior of the C compiler, which does not consider multiple
Packit b099d7
inclusion to be an error.  This option is provided for backward 
Packit b099d7
compatibility, and to aid in debugging problems related to multiple
Packit b099d7
inclusion.
Packit b099d7
.TP 5
Packit b099d7
.B "\-\^\- \fIoptions\fP \-\^\-"
Packit b099d7
If
Packit b099d7
.B makedepend
Packit b099d7
encounters a double hyphen (\-\^\-) in the argument list,
Packit b099d7
then any unrecognized argument following it
Packit b099d7
will be silently ignored; a second double hyphen terminates this
Packit b099d7
special treatment.
Packit b099d7
In this way,
Packit b099d7
.B makedepend
Packit b099d7
can be made to safely ignore esoteric compiler arguments that might
Packit b099d7
normally be found in a CFLAGS
Packit b099d7
.B make
Packit b099d7
macro (see the
Packit b099d7
.B EXAMPLE
Packit b099d7
section above).
Packit b099d7
All options that
Packit b099d7
.B makedepend
Packit b099d7
recognizes and appear between the pair of double hyphens
Packit b099d7
are processed normally.
Packit b099d7
.SH ALGORITHM
Packit b099d7
The approach used in this program enables it to run an order of magnitude
Packit b099d7
faster than any other ``dependency generator'' I have ever seen.
Packit b099d7
Central to this performance are two assumptions:
Packit b099d7
that all files compiled by a single
Packit b099d7
makefile will be compiled with roughly the same
Packit b099d7
.I \-I
Packit b099d7
and
Packit b099d7
.I \-D
Packit b099d7
options;
Packit b099d7
and that most files in a single directory will include largely the
Packit b099d7
same files.
Packit b099d7
.PP
Packit b099d7
Given these assumptions,
Packit b099d7
.B makedepend
Packit b099d7
expects to be called once for each makefile, with
Packit b099d7
all source files that are maintained by the
Packit b099d7
makefile appearing on the command line.
Packit b099d7
It parses each source and include
Packit b099d7
file exactly once, maintaining an internal symbol table
Packit b099d7
for each.
Packit b099d7
Thus, the first file on the command line will take an amount of time
Packit b099d7
proportional to the amount of time that a normal C preprocessor takes.
Packit b099d7
But on subsequent files, if it encounters an include file
Packit b099d7
that it has already parsed, it does not parse it again.
Packit b099d7
.PP
Packit b099d7
For example,
Packit b099d7
imagine you are compiling two files,
Packit b099d7
.I file1.c
Packit b099d7
and
Packit b099d7
.I file2.c,
Packit b099d7
they each include the header file
Packit b099d7
.I header.h,
Packit b099d7
and the file
Packit b099d7
.I header.h
Packit b099d7
in turn includes the files
Packit b099d7
.I def1.h
Packit b099d7
and
Packit b099d7
.I def2.h.
Packit b099d7
When you run the command
Packit b099d7
.sp
Packit b099d7
    makedepend\0file1.c\0file2.c
Packit b099d7
.sp
Packit b099d7
.B makedepend
Packit b099d7
will parse
Packit b099d7
.I file1.c
Packit b099d7
and consequently,
Packit b099d7
.I header.h
Packit b099d7
and then
Packit b099d7
.I def1.h
Packit b099d7
and
Packit b099d7
.I def2.h.
Packit b099d7
It then decides that the dependencies for this file are
Packit b099d7
.sp
Packit b099d7
    file1.o:\0header.h\0def1.h\0def2.h
Packit b099d7
.sp
Packit b099d7
But when the program parses
Packit b099d7
.I file2.c
Packit b099d7
and discovers that it, too, includes
Packit b099d7
.I header.h,
Packit b099d7
it does not parse the file,
Packit b099d7
but simply adds
Packit b099d7
.I header.h,
Packit b099d7
.I def1.h
Packit b099d7
and
Packit b099d7
.I def2.h
Packit b099d7
to the list of dependencies for
Packit b099d7
.I file2.o.
Packit b099d7
.SH "SEE ALSO"
Packit b099d7
cc(1), make(1)
Packit b099d7
.SH BUGS
Packit b099d7
.B makedepend
Packit b099d7
parses, but does not currently evaluate, the SVR4
Packit b099d7
#predicate(token-list) preprocessor expression;
Packit b099d7
such expressions are simply assumed to be true.
Packit b099d7
This may cause the wrong
Packit b099d7
.I #include
Packit b099d7
directives to be evaluated.
Packit b099d7
.PP
Packit b099d7
Imagine you are parsing two files,
Packit b099d7
say
Packit b099d7
.I file1.c
Packit b099d7
and
Packit b099d7
.I file2.c,
Packit b099d7
each includes the file
Packit b099d7
.I def.h.
Packit b099d7
The list of files that
Packit b099d7
.I def.h
Packit b099d7
includes might truly be different when
Packit b099d7
.I def.h
Packit b099d7
is included by
Packit b099d7
.I file1.c
Packit b099d7
than when it is included by
Packit b099d7
.I file2.c.
Packit b099d7
But once
Packit b099d7
.B makedepend
Packit b099d7
arrives at a list of dependencies for a file,
Packit b099d7
it is cast in concrete.
Packit b099d7
.SH AUTHOR
Packit b099d7
Todd Brunhoff, Tektronix, Inc. and MIT Project Athena