Blame | Last modification | View Log | RSS feed
.\" $XConsortium: mkdepend.man /main/18 1995/12/15 14:00:41 gildea $.\" Copyright (c) 1993, 1994 X Consortium.\".\" Permission is hereby granted, free of charge, to any person obtaining a.\" copy of this software and associated documentation files (the "Software"),.\" to deal in the Software without restriction, including without limitation.\" the rights to use, copy, modify, merge, publish, distribute, sublicense,.\" and/or sell copies of the Software, and to permit persons to whom the.\" Software furnished to do so, subject to the following conditions:.\".\" 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.\" THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,.\" 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..\".\" Except as contained in this notice, the name of the X Consortium shall not.\" be used in advertising or otherwise to promote the sale, use or other.\" dealing in this Software without prior written authorization from the.\" X Consortium..TH MAKEDEPEND 1 "Release 6.1" "X Version 11".UC 4.SH NAMEmakedepend \- create dependencies in makefiles.SH SYNOPSIS.B makedepend[.BI \-D name\fB=\fPdef] [.BI \-D name] [.BI \-I includedir] [.BI \-Y includedir] [.B \-a] [.BI \-f makefile] [.BI \-o objsuffix] [.BI \-p objprefix] [.BI \-s string] [.BI \-w width] [.B \-v] [.B \-m] [\-\^\-.I otheroptions\-\^\-].I sourcefile\&.\|.\|..br.SH DESCRIPTIONThe.B makedependprogram reads each.I sourcefilein sequence and parses it like a C-preprocessor,processing all.I #include,.I #define,.I #undef,.I #ifdef,.I #ifndef,.I #endif,.I #if,.I #elifand.I #elsedirectives 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 #includedirectives, and parsing will occur in these files as well..PPEvery file that a.I sourcefileincludes,directly or indirectly,is what.B makedependcalls a \fIdependency.\fPThese dependencies are then written to a.I makefilein such a way that.B make(1)will know which object files must be recompiled when a dependency has changed..PPBy default,.B makedependplaces its output in the file named.I makefileif it exists, otherwise.I Makefile.An alternate makefile may be specified with the.B \-foption.It first searches the makefile forthe line.sp# DO NOT DELETE THIS LINE \-\^\- make depend depends on it..spor one provided with the.B \-soption,as a delimiter for the dependency output.If it finds it, it will delete everythingfollowing this to the end of the makefileand put the output after this line.If it doesn't find it, the programwill append the string to the end of the makefileand place the output following that.For each.I sourcefileappearing on the command line,.B makedependputs lines in the makefile of the form.spsourcefile.o:\0dfile .\|.\|..spWhere \fIsourcefile.o\fP is the name from the commandline with its suffix replaced with ``.o'',and \fIdfile\fP is a dependency discovered in a.I #includedirective while parsing.I sourcefileor one of the files it included..SH EXAMPLENormally,.B makedependwill be used in a makefile target so that typing ``make depend'' willbring the dependencies up to date for the makefile.For example,.nfSRCS\0=\0file1.c\0file2.c\0.\|.\|.CFLAGS\0=\0\-O\0\-DHACK\0\-I\^.\^.\^/foobar\0\-xyzdepend:makedepend\0\-\^\-\0$(CFLAGS)\0\-\^\-\0$(SRCS).fi.SH OPTIONSThe programwill ignore any option that it does not understand so that you may usethe same arguments that you would for.B cc(1)..TP 5.B \-D\fIname\fP=\fIdef\fP \fRor\fP \-D\fIname\fPDefine.This places a definition for.I namein.B makedepend'ssymbol table.Without.I =def\|the symbol becomes defined as ``1''..TP 5.B \-I\fIincludedir\fPInclude directory.This option tells.B makedependto prepend.I includedirto its list of directories to search when it encountersa.I #includedirective.By default,.B makedependonly searches the standard include directories (usually /usr/includeand possibly a compiler-dependent directory)..TP 5.B \-Y\fIincludedir\fPReplace all of the standard include directories with the single specifiedinclude directory; you can omit the.I includedirto simply prevent searching the standard include directories..TP 5.B \-aAppend the dependencies to the end of the file instead of replacing them..TP 5.B \-f\fImakefile\fPFilename.This allows you to specify an alternate makefile in which.B makedependcan place its output.Specifying ``\-'' as the file name (i.e., \fB\-f\-\fP) sends theoutput to standard output instead of modifying an existing file..TP 5.B \-o\fIobjsuffix\fPObject file suffix.Some systems may have object files whose suffix is something otherthan ``.o''.This option allows you to specify another suffix, such as``.b'' with.I \-o.bor ``:obj''with.I \-o:objand so forth..TP 5.B \-p\fIobjprefix\fPObject file prefix.The prefix is prepended to the name of the object file. This isusually used to designate a different directory for the object file.The default is the empty string..TP 5.B \-s\fIstring\fPStarting string delimiter.This option permits you to specifya different string for.B makedependto look for in the makefile..TP 5.B \-w\fIwidth\fPLine width.Normally,.B makedependwill ensure that every output line that it writes will be no wider than78 characters for the sake of readability.This option enables you to change this width..TP 5.B \-vVerbose operation.This option causes.B makedependto emit the list of files included by each input file on standard output..TP 5.B \-mWarn about multiple inclusion.This option causes.B makedependto produce a warning if any input file includes another file more thanonce. In previous versions of.B makedependthis was the default behavior; the default has been changed to bettermatch the behavior of the C compiler, which does not consider multipleinclusion to be an error. This option is provided for backwardcompatibility, and to aid in debugging problems related to multipleinclusion..TP 5.B "\-\^\- \fIoptions\fP \-\^\-"If.B makedependencounters a double hyphen (\-\^\-) in the argument list,then any unrecognized argument following itwill be silently ignored; a second double hyphen terminates thisspecial treatment.In this way,.B makedependcan be made to safely ignore esoteric compiler arguments that mightnormally be found in a CFLAGS.B makemacro (see the.B EXAMPLEsection above).All options that.B makedependrecognizes and appear between the pair of double hyphensare processed normally..SH ALGORITHMThe approach used in this program enables it to run an order of magnitudefaster than any other ``dependency generator'' I have ever seen.Central to this performance are two assumptions:that all files compiled by a singlemakefile will be compiled with roughly the same.I \-Iand.I \-Doptions;and that most files in a single directory will include largely thesame files..PPGiven these assumptions,.B makedependexpects to be called once for each makefile, withall source files that are maintained by themakefile appearing on the command line.It parses each source and includefile exactly once, maintaining an internal symbol tablefor each.Thus, the first file on the command line will take an amount of timeproportional to the amount of time that a normal C preprocessor takes.But on subsequent files, if it encounters an include filethat it has already parsed, it does not parse it again..PPFor example,imagine you are compiling two files,.I file1.cand.I file2.c,they each include the header file.I header.h,and the file.I header.hin turn includes the files.I def1.hand.I def2.h.When you run the command.spmakedepend\0file1.c\0file2.c.sp.B makedependwill parse.I file1.cand consequently,.I header.hand then.I def1.hand.I def2.h.It then decides that the dependencies for this file are.spfile1.o:\0header.h\0def1.h\0def2.h.spBut when the program parses.I file2.cand discovers that it, too, includes.I header.h,it does not parse the file,but simply adds.I header.h,.I def1.hand.I def2.hto the list of dependencies for.I file2.o..SH "SEE ALSO"cc(1), make(1).SH BUGS.B makedependparses, 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 #includedirectives to be evaluated..PPImagine you are parsing two files,say.I file1.cand.I file2.c,each includes the file.I def.h.The list of files that.I def.hincludes might truly be different when.I def.his included by.I file1.cthan when it is included by.I file2.c.But once.B makedependarrives at a list of dependencies for a file,it is cast in concrete..SH AUTHORTodd Brunhoff, Tektronix, Inc. and MIT Project Athena