2002-03-26 01:52:52 +03:00
|
|
|
.\" $Xorg: mkdepend.man,v 1.5 2001/02/09 02:03:16 xorgcvs Exp $
|
|
|
|
.\" Copyright (c) 1993, 1994, 1998 The Open Group
|
1998-03-28 05:44:41 +03:00
|
|
|
.\"
|
2002-03-26 01:52:52 +03:00
|
|
|
.\" Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
.\" documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
.\" the above copyright notice appear in all copies and that both that
|
|
|
|
.\" copyright notice and this permission notice appear in supporting
|
|
|
|
.\" documentation.
|
1998-03-28 05:44:41 +03:00
|
|
|
.\"
|
|
|
|
.\" The above copyright notice and this permission notice shall be included in
|
|
|
|
.\" all copies or substantial portions of the Software.
|
|
|
|
.\"
|
|
|
|
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
2002-03-26 01:52:52 +03:00
|
|
|
.\" THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
1998-03-28 05:44:41 +03:00
|
|
|
.\" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
|
|
|
.\" OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
.\" SOFTWARE.
|
|
|
|
.\"
|
2002-03-26 01:52:52 +03:00
|
|
|
.\" Except as contained in this notice, the name of The Open Group shall not
|
1998-03-28 05:44:41 +03:00
|
|
|
.\" be used in advertising or otherwise to promote the sale, use or other
|
2002-03-26 01:52:52 +03:00
|
|
|
.\" dealing in this Software without prior written authorization from The
|
|
|
|
.\" Open Group.
|
2003-10-01 23:16:15 +04:00
|
|
|
.\"
|
|
|
|
.\" $XFree86: xc/config/makedepend/mkdepend.man,v 1.7 2002/12/14 02:39:45 dawes Exp $
|
|
|
|
.\"
|
|
|
|
.TH MAKEDEPEND 1 __xorgversion__
|
1998-03-28 05:44:41 +03:00
|
|
|
.UC 4
|
|
|
|
.SH NAME
|
|
|
|
makedepend \- create dependencies in makefiles
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B makedepend
|
|
|
|
[
|
2002-03-26 01:52:52 +03:00
|
|
|
.BI \-D name\fB=\fPdef
|
1998-03-28 05:44:41 +03:00
|
|
|
] [
|
2002-03-26 01:52:52 +03:00
|
|
|
.BI \-D name
|
1998-03-28 05:44:41 +03:00
|
|
|
] [
|
2002-03-26 01:52:52 +03:00
|
|
|
.BI \-I includedir
|
1998-03-28 05:44:41 +03:00
|
|
|
] [
|
2002-03-26 01:52:52 +03:00
|
|
|
.BI \-Y includedir
|
1998-03-28 05:44:41 +03:00
|
|
|
] [
|
|
|
|
.B \-a
|
|
|
|
] [
|
2002-03-26 01:52:52 +03:00
|
|
|
.BI \-f makefile
|
1998-03-28 05:44:41 +03:00
|
|
|
] [
|
2003-10-01 23:16:15 +04:00
|
|
|
.BI \-include \ file
|
|
|
|
] [
|
2002-03-26 01:52:52 +03:00
|
|
|
.BI \-o objsuffix
|
1998-03-28 05:44:41 +03:00
|
|
|
] [
|
2002-03-26 01:52:52 +03:00
|
|
|
.BI \-p objprefix
|
1998-03-28 05:44:41 +03:00
|
|
|
] [
|
2002-03-26 01:52:52 +03:00
|
|
|
.BI \-s string
|
1998-03-28 05:44:41 +03:00
|
|
|
] [
|
2002-03-26 01:52:52 +03:00
|
|
|
.BI \-w width
|
1998-03-28 05:44:41 +03:00
|
|
|
] [
|
|
|
|
.B \-v
|
|
|
|
] [
|
|
|
|
.B \-m
|
|
|
|
] [
|
|
|
|
\-\^\-
|
2002-03-26 01:52:52 +03:00
|
|
|
.I otheroptions
|
1998-03-28 05:44:41 +03:00
|
|
|
\-\^\-
|
|
|
|
]
|
2002-03-26 01:52:52 +03:00
|
|
|
.I sourcefile
|
|
|
|
\&.\|.\|.
|
1998-03-28 05:44:41 +03:00
|
|
|
.br
|
|
|
|
.SH DESCRIPTION
|
2002-03-26 01:52:52 +03:00
|
|
|
The
|
|
|
|
.B makedepend
|
|
|
|
program reads each
|
1998-03-28 05:44:41 +03:00
|
|
|
.I sourcefile
|
|
|
|
in sequence and parses it like a C-preprocessor,
|
|
|
|
processing all
|
|
|
|
.I #include,
|
|
|
|
.I #define,
|
|
|
|
.I #undef,
|
|
|
|
.I #ifdef,
|
|
|
|
.I #ifndef,
|
|
|
|
.I #endif,
|
2002-03-26 01:52:52 +03:00
|
|
|
.I #if,
|
|
|
|
.I #elif
|
1998-03-28 05:44:41 +03:00
|
|
|
and
|
|
|
|
.I #else
|
|
|
|
directives so that it can correctly tell which
|
|
|
|
.I #include,
|
|
|
|
directives would be used in a compilation.
|
|
|
|
Any
|
|
|
|
.I #include,
|
|
|
|
directives can reference files having other
|
|
|
|
.I #include
|
|
|
|
directives, and parsing will occur in these files as well.
|
|
|
|
.PP
|
|
|
|
Every file that a
|
|
|
|
.I sourcefile
|
|
|
|
includes,
|
|
|
|
directly or indirectly,
|
|
|
|
is what
|
|
|
|
.B makedepend
|
2002-03-26 01:52:52 +03:00
|
|
|
calls a \fIdependency.\fP
|
1998-03-28 05:44:41 +03:00
|
|
|
These dependencies are then written to a
|
|
|
|
.I makefile
|
|
|
|
in such a way that
|
|
|
|
.B make(1)
|
|
|
|
will know which object files must be recompiled when a dependency has changed.
|
|
|
|
.PP
|
|
|
|
By default,
|
|
|
|
.B makedepend
|
|
|
|
places its output in the file named
|
|
|
|
.I makefile
|
|
|
|
if it exists, otherwise
|
|
|
|
.I Makefile.
|
|
|
|
An alternate makefile may be specified with the
|
|
|
|
.B \-f
|
|
|
|
option.
|
|
|
|
It first searches the makefile for
|
|
|
|
the line
|
|
|
|
.sp
|
2003-10-01 23:16:15 +04:00
|
|
|
\& # DO NOT DELETE THIS LINE \-\^\- make depend depends on it.
|
1998-03-28 05:44:41 +03:00
|
|
|
.sp
|
|
|
|
or one provided with the
|
|
|
|
.B \-s
|
|
|
|
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
|
|
|
|
appearing on the command line,
|
|
|
|
.B makedepend
|
|
|
|
puts lines in the makefile of the form
|
|
|
|
.sp
|
|
|
|
sourcefile.o:\0dfile .\|.\|.
|
|
|
|
.sp
|
2002-03-26 01:52:52 +03:00
|
|
|
Where \fIsourcefile.o\fP is the name from the command
|
|
|
|
line with its suffix replaced with ``.o'',
|
|
|
|
and \fIdfile\fP is a dependency discovered in a
|
1998-03-28 05:44:41 +03:00
|
|
|
.I #include
|
|
|
|
directive while parsing
|
|
|
|
.I sourcefile
|
|
|
|
or one of the files it included.
|
|
|
|
.SH EXAMPLE
|
|
|
|
Normally,
|
|
|
|
.B makedepend
|
2002-03-26 01:52:52 +03:00
|
|
|
will be used in a makefile target so that typing ``make depend'' will
|
1998-03-28 05:44:41 +03:00
|
|
|
bring the dependencies up to date for the makefile.
|
|
|
|
For example,
|
|
|
|
.nf
|
|
|
|
SRCS\0=\0file1.c\0file2.c\0.\|.\|.
|
|
|
|
CFLAGS\0=\0\-O\0\-DHACK\0\-I\^.\^.\^/foobar\0\-xyz
|
|
|
|
depend:
|
|
|
|
makedepend\0\-\^\-\0$(CFLAGS)\0\-\^\-\0$(SRCS)
|
|
|
|
.fi
|
|
|
|
.SH OPTIONS
|
2002-03-26 01:52:52 +03:00
|
|
|
The program
|
1998-03-28 05:44:41 +03:00
|
|
|
will ignore any option that it does not understand so that you may use
|
|
|
|
the same arguments that you would for
|
|
|
|
.B cc(1).
|
|
|
|
.TP 5
|
2002-03-26 01:52:52 +03:00
|
|
|
.B \-D\fIname\fP=\fIdef\fP \fRor\fP \-D\fIname\fP
|
1998-03-28 05:44:41 +03:00
|
|
|
Define.
|
|
|
|
This places a definition for
|
|
|
|
.I name
|
|
|
|
in
|
|
|
|
.B makedepend's
|
|
|
|
symbol table.
|
|
|
|
Without
|
2002-03-26 01:52:52 +03:00
|
|
|
.I =def\|
|
|
|
|
the symbol becomes defined as ``1''.
|
1998-03-28 05:44:41 +03:00
|
|
|
.TP 5
|
2002-03-26 01:52:52 +03:00
|
|
|
.B \-I\fIincludedir\fP
|
1998-03-28 05:44:41 +03:00
|
|
|
Include directory.
|
|
|
|
This option tells
|
|
|
|
.B makedepend
|
|
|
|
to prepend
|
|
|
|
.I includedir
|
|
|
|
to its list of directories to search when it encounters
|
|
|
|
a
|
|
|
|
.I #include
|
|
|
|
directive.
|
|
|
|
By default,
|
|
|
|
.B makedepend
|
|
|
|
only searches the standard include directories (usually /usr/include
|
|
|
|
and possibly a compiler-dependent directory).
|
|
|
|
.TP 5
|
2002-03-26 01:52:52 +03:00
|
|
|
.B \-Y\fIincludedir\fP
|
1998-03-28 05:44:41 +03:00
|
|
|
Replace all of the standard include directories with the single specified
|
|
|
|
include directory; you can omit the
|
|
|
|
.I includedir
|
|
|
|
to simply prevent searching the standard include directories.
|
|
|
|
.TP 5
|
|
|
|
.B \-a
|
|
|
|
Append the dependencies to the end of the file instead of replacing them.
|
|
|
|
.TP 5
|
2002-03-26 01:52:52 +03:00
|
|
|
.B \-f\fImakefile\fP
|
1998-03-28 05:44:41 +03:00
|
|
|
Filename.
|
|
|
|
This allows you to specify an alternate makefile in which
|
|
|
|
.B makedepend
|
|
|
|
can place its output.
|
2002-03-26 01:52:52 +03:00
|
|
|
Specifying ``\-'' as the file name (i.e., \fB\-f\-\fP) sends the
|
|
|
|
output to standard output instead of modifying an existing file.
|
1998-03-28 05:44:41 +03:00
|
|
|
.TP 5
|
2003-10-01 23:16:15 +04:00
|
|
|
.B \-include \fIfile\fP
|
|
|
|
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.
|
|
|
|
.TP 5
|
2002-03-26 01:52:52 +03:00
|
|
|
.B \-o\fIobjsuffix\fP
|
1998-03-28 05:44:41 +03:00
|
|
|
Object file suffix.
|
|
|
|
Some systems may have object files whose suffix is something other
|
2002-03-26 01:52:52 +03:00
|
|
|
than ``.o''.
|
1998-03-28 05:44:41 +03:00
|
|
|
This option allows you to specify another suffix, such as
|
2002-03-26 01:52:52 +03:00
|
|
|
``.b'' with
|
|
|
|
.I \-o.b
|
|
|
|
or ``:obj''
|
1998-03-28 05:44:41 +03:00
|
|
|
with
|
2002-03-26 01:52:52 +03:00
|
|
|
.I \-o:obj
|
1998-03-28 05:44:41 +03:00
|
|
|
and so forth.
|
|
|
|
.TP 5
|
2002-03-26 01:52:52 +03:00
|
|
|
.B \-p\fIobjprefix\fP
|
1998-03-28 05:44:41 +03:00
|
|
|
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.
|
|
|
|
.TP 5
|
2002-03-26 01:52:52 +03:00
|
|
|
.B \-s\fIstring\fP
|
1998-03-28 05:44:41 +03:00
|
|
|
Starting string delimiter.
|
|
|
|
This option permits you to specify
|
|
|
|
a different string for
|
|
|
|
.B makedepend
|
|
|
|
to look for in the makefile.
|
|
|
|
.TP 5
|
2002-03-26 01:52:52 +03:00
|
|
|
.B \-w\fIwidth\fP
|
1998-03-28 05:44:41 +03:00
|
|
|
Line width.
|
|
|
|
Normally,
|
|
|
|
.B makedepend
|
|
|
|
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.
|
|
|
|
.TP 5
|
|
|
|
.B \-v
|
|
|
|
Verbose operation.
|
|
|
|
This option causes
|
|
|
|
.B makedepend
|
2002-03-26 01:52:52 +03:00
|
|
|
to emit the list of files included by each input file.
|
1998-03-28 05:44:41 +03:00
|
|
|
.TP 5
|
|
|
|
.B \-m
|
|
|
|
Warn about multiple inclusion.
|
|
|
|
This option causes
|
|
|
|
.B makedepend
|
|
|
|
to produce a warning if any input file includes another file more than
|
|
|
|
once. In previous versions of
|
|
|
|
.B 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.
|
|
|
|
.TP 5
|
2002-03-26 01:52:52 +03:00
|
|
|
.B "\-\^\- \fIoptions\fP \-\^\-"
|
1998-03-28 05:44:41 +03:00
|
|
|
If
|
|
|
|
.B makedepend
|
|
|
|
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
|
|
|
|
can be made to safely ignore esoteric compiler arguments that might
|
|
|
|
normally be found in a CFLAGS
|
|
|
|
.B make
|
|
|
|
macro (see the
|
|
|
|
.B EXAMPLE
|
|
|
|
section above).
|
|
|
|
All options that
|
|
|
|
.B makedepend
|
|
|
|
recognizes and appear between the pair of double hyphens
|
|
|
|
are processed normally.
|
|
|
|
.SH ALGORITHM
|
|
|
|
The approach used in this program enables it to run an order of magnitude
|
2002-03-26 01:52:52 +03:00
|
|
|
faster than any other ``dependency generator'' I have ever seen.
|
1998-03-28 05:44:41 +03:00
|
|
|
Central to this performance are two assumptions:
|
|
|
|
that all files compiled by a single
|
|
|
|
makefile will be compiled with roughly the same
|
2002-03-26 01:52:52 +03:00
|
|
|
.I \-I
|
1998-03-28 05:44:41 +03:00
|
|
|
and
|
2002-03-26 01:52:52 +03:00
|
|
|
.I \-D
|
1998-03-28 05:44:41 +03:00
|
|
|
options;
|
|
|
|
and that most files in a single directory will include largely the
|
|
|
|
same files.
|
|
|
|
.PP
|
|
|
|
Given these assumptions,
|
|
|
|
.B makedepend
|
|
|
|
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.
|
2002-03-26 01:52:52 +03:00
|
|
|
But on subsequent files, if it encounters an include file
|
1998-03-28 05:44:41 +03:00
|
|
|
that it has already parsed, it does not parse it again.
|
|
|
|
.PP
|
|
|
|
For example,
|
|
|
|
imagine you are compiling two files,
|
|
|
|
.I file1.c
|
|
|
|
and
|
|
|
|
.I file2.c,
|
|
|
|
they each include the header file
|
|
|
|
.I header.h,
|
|
|
|
and the file
|
|
|
|
.I header.h
|
|
|
|
in turn includes the files
|
|
|
|
.I def1.h
|
|
|
|
and
|
|
|
|
.I def2.h.
|
|
|
|
When you run the command
|
|
|
|
.sp
|
|
|
|
makedepend\0file1.c\0file2.c
|
|
|
|
.sp
|
|
|
|
.B makedepend
|
|
|
|
will parse
|
|
|
|
.I file1.c
|
|
|
|
and consequently,
|
|
|
|
.I header.h
|
|
|
|
and then
|
|
|
|
.I def1.h
|
|
|
|
and
|
|
|
|
.I def2.h.
|
|
|
|
It then decides that the dependencies for this file are
|
|
|
|
.sp
|
|
|
|
file1.o:\0header.h\0def1.h\0def2.h
|
|
|
|
.sp
|
|
|
|
But when the program parses
|
|
|
|
.I file2.c
|
|
|
|
and discovers that it, too, includes
|
|
|
|
.I header.h,
|
|
|
|
it does not parse the file,
|
|
|
|
but simply adds
|
|
|
|
.I header.h,
|
|
|
|
.I def1.h
|
|
|
|
and
|
|
|
|
.I def2.h
|
|
|
|
to the list of dependencies for
|
|
|
|
.I file2.o.
|
|
|
|
.SH "SEE ALSO"
|
|
|
|
cc(1), make(1)
|
|
|
|
.SH BUGS
|
|
|
|
.B makedepend
|
2003-10-01 23:16:15 +04:00
|
|
|
parses, but does not currently evaluate, the SVR4 #predicate(token-list)
|
|
|
|
preprocessor expression; such expressions are simply assumed to be true.
|
1998-03-28 05:44:41 +03:00
|
|
|
This may cause the wrong
|
|
|
|
.I #include
|
|
|
|
directives to be evaluated.
|
|
|
|
.PP
|
|
|
|
Imagine you are parsing two files,
|
|
|
|
say
|
|
|
|
.I file1.c
|
|
|
|
and
|
|
|
|
.I file2.c,
|
|
|
|
each includes the file
|
|
|
|
.I def.h.
|
|
|
|
The list of files that
|
|
|
|
.I def.h
|
|
|
|
includes might truly be different when
|
|
|
|
.I def.h
|
|
|
|
is included by
|
|
|
|
.I file1.c
|
|
|
|
than when it is included by
|
|
|
|
.I file2.c.
|
|
|
|
But once
|
|
|
|
.B makedepend
|
|
|
|
arrives at a list of dependencies for a file,
|
|
|
|
it is cast in concrete.
|
|
|
|
.SH AUTHOR
|
|
|
|
Todd Brunhoff, Tektronix, Inc. and MIT Project Athena
|