Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | .\" $Xorg: mkdepend.man,v 1.5 2001/02/09 02:03:16 xorgcvs Exp $ |
michael@0 | 2 | .\" Copyright (c) 1993, 1994, 1998 The Open Group |
michael@0 | 3 | .\" |
michael@0 | 4 | .\" Permission to use, copy, modify, distribute, and sell this software and its |
michael@0 | 5 | .\" documentation for any purpose is hereby granted without fee, provided that |
michael@0 | 6 | .\" the above copyright notice appear in all copies and that both that |
michael@0 | 7 | .\" copyright notice and this permission notice appear in supporting |
michael@0 | 8 | .\" documentation. |
michael@0 | 9 | .\" |
michael@0 | 10 | .\" The above copyright notice and this permission notice shall be included in |
michael@0 | 11 | .\" all copies or substantial portions of the Software. |
michael@0 | 12 | .\" |
michael@0 | 13 | .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
michael@0 | 14 | .\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
michael@0 | 15 | .\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
michael@0 | 16 | .\" THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
michael@0 | 17 | .\" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF |
michael@0 | 18 | .\" OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
michael@0 | 19 | .\" SOFTWARE. |
michael@0 | 20 | .\" |
michael@0 | 21 | .\" Except as contained in this notice, the name of The Open Group shall not |
michael@0 | 22 | .\" be used in advertising or otherwise to promote the sale, use or other |
michael@0 | 23 | .\" dealing in this Software without prior written authorization from The |
michael@0 | 24 | .\" Open Group. |
michael@0 | 25 | .\" |
michael@0 | 26 | .\" $XFree86: xc/config/makedepend/mkdepend.man,v 1.7 2002/12/14 02:39:45 dawes Exp $ |
michael@0 | 27 | .\" |
michael@0 | 28 | .TH MAKEDEPEND 1 __xorgversion__ |
michael@0 | 29 | .UC 4 |
michael@0 | 30 | .SH NAME |
michael@0 | 31 | makedepend \- create dependencies in makefiles |
michael@0 | 32 | .SH SYNOPSIS |
michael@0 | 33 | .B makedepend |
michael@0 | 34 | [ |
michael@0 | 35 | .BI \-D name\fB=\fPdef |
michael@0 | 36 | ] [ |
michael@0 | 37 | .BI \-D name |
michael@0 | 38 | ] [ |
michael@0 | 39 | .BI \-I includedir |
michael@0 | 40 | ] [ |
michael@0 | 41 | .BI \-Y includedir |
michael@0 | 42 | ] [ |
michael@0 | 43 | .B \-a |
michael@0 | 44 | ] [ |
michael@0 | 45 | .BI \-f makefile |
michael@0 | 46 | ] [ |
michael@0 | 47 | .BI \-include \ file |
michael@0 | 48 | ] [ |
michael@0 | 49 | .BI \-o objsuffix |
michael@0 | 50 | ] [ |
michael@0 | 51 | .BI \-p objprefix |
michael@0 | 52 | ] [ |
michael@0 | 53 | .BI \-s string |
michael@0 | 54 | ] [ |
michael@0 | 55 | .BI \-w width |
michael@0 | 56 | ] [ |
michael@0 | 57 | .B \-v |
michael@0 | 58 | ] [ |
michael@0 | 59 | .B \-m |
michael@0 | 60 | ] [ |
michael@0 | 61 | \-\^\- |
michael@0 | 62 | .I otheroptions |
michael@0 | 63 | \-\^\- |
michael@0 | 64 | ] |
michael@0 | 65 | .I sourcefile |
michael@0 | 66 | \&.\|.\|. |
michael@0 | 67 | .br |
michael@0 | 68 | .SH DESCRIPTION |
michael@0 | 69 | The |
michael@0 | 70 | .B makedepend |
michael@0 | 71 | program reads each |
michael@0 | 72 | .I sourcefile |
michael@0 | 73 | in sequence and parses it like a C-preprocessor, |
michael@0 | 74 | processing all |
michael@0 | 75 | .I #include, |
michael@0 | 76 | .I #define, |
michael@0 | 77 | .I #undef, |
michael@0 | 78 | .I #ifdef, |
michael@0 | 79 | .I #ifndef, |
michael@0 | 80 | .I #endif, |
michael@0 | 81 | .I #if, |
michael@0 | 82 | .I #elif |
michael@0 | 83 | and |
michael@0 | 84 | .I #else |
michael@0 | 85 | directives so that it can correctly tell which |
michael@0 | 86 | .I #include, |
michael@0 | 87 | directives would be used in a compilation. |
michael@0 | 88 | Any |
michael@0 | 89 | .I #include, |
michael@0 | 90 | directives can reference files having other |
michael@0 | 91 | .I #include |
michael@0 | 92 | directives, and parsing will occur in these files as well. |
michael@0 | 93 | .PP |
michael@0 | 94 | Every file that a |
michael@0 | 95 | .I sourcefile |
michael@0 | 96 | includes, |
michael@0 | 97 | directly or indirectly, |
michael@0 | 98 | is what |
michael@0 | 99 | .B makedepend |
michael@0 | 100 | calls a \fIdependency.\fP |
michael@0 | 101 | These dependencies are then written to a |
michael@0 | 102 | .I makefile |
michael@0 | 103 | in such a way that |
michael@0 | 104 | .B make(1) |
michael@0 | 105 | will know which object files must be recompiled when a dependency has changed. |
michael@0 | 106 | .PP |
michael@0 | 107 | By default, |
michael@0 | 108 | .B makedepend |
michael@0 | 109 | places its output in the file named |
michael@0 | 110 | .I makefile |
michael@0 | 111 | if it exists, otherwise |
michael@0 | 112 | .I Makefile. |
michael@0 | 113 | An alternate makefile may be specified with the |
michael@0 | 114 | .B \-f |
michael@0 | 115 | option. |
michael@0 | 116 | It first searches the makefile for |
michael@0 | 117 | the line |
michael@0 | 118 | .sp |
michael@0 | 119 | \& # DO NOT DELETE THIS LINE \-\^\- make depend depends on it. |
michael@0 | 120 | .sp |
michael@0 | 121 | or one provided with the |
michael@0 | 122 | .B \-s |
michael@0 | 123 | option, |
michael@0 | 124 | as a delimiter for the dependency output. |
michael@0 | 125 | If it finds it, it will delete everything |
michael@0 | 126 | following this to the end of the makefile |
michael@0 | 127 | and put the output after this line. |
michael@0 | 128 | If it doesn't find it, the program |
michael@0 | 129 | will append the string to the end of the makefile |
michael@0 | 130 | and place the output following that. |
michael@0 | 131 | For each |
michael@0 | 132 | .I sourcefile |
michael@0 | 133 | appearing on the command line, |
michael@0 | 134 | .B makedepend |
michael@0 | 135 | puts lines in the makefile of the form |
michael@0 | 136 | .sp |
michael@0 | 137 | sourcefile.o:\0dfile .\|.\|. |
michael@0 | 138 | .sp |
michael@0 | 139 | Where \fIsourcefile.o\fP is the name from the command |
michael@0 | 140 | line with its suffix replaced with ``.o'', |
michael@0 | 141 | and \fIdfile\fP is a dependency discovered in a |
michael@0 | 142 | .I #include |
michael@0 | 143 | directive while parsing |
michael@0 | 144 | .I sourcefile |
michael@0 | 145 | or one of the files it included. |
michael@0 | 146 | .SH EXAMPLE |
michael@0 | 147 | Normally, |
michael@0 | 148 | .B makedepend |
michael@0 | 149 | will be used in a makefile target so that typing ``make depend'' will |
michael@0 | 150 | bring the dependencies up to date for the makefile. |
michael@0 | 151 | For example, |
michael@0 | 152 | .nf |
michael@0 | 153 | SRCS\0=\0file1.c\0file2.c\0.\|.\|. |
michael@0 | 154 | CFLAGS\0=\0\-O\0\-DHACK\0\-I\^.\^.\^/foobar\0\-xyz |
michael@0 | 155 | depend: |
michael@0 | 156 | makedepend\0\-\^\-\0$(CFLAGS)\0\-\^\-\0$(SRCS) |
michael@0 | 157 | .fi |
michael@0 | 158 | .SH OPTIONS |
michael@0 | 159 | The program |
michael@0 | 160 | will ignore any option that it does not understand so that you may use |
michael@0 | 161 | the same arguments that you would for |
michael@0 | 162 | .B cc(1). |
michael@0 | 163 | .TP 5 |
michael@0 | 164 | .B \-D\fIname\fP=\fIdef\fP \fRor\fP \-D\fIname\fP |
michael@0 | 165 | Define. |
michael@0 | 166 | This places a definition for |
michael@0 | 167 | .I name |
michael@0 | 168 | in |
michael@0 | 169 | .B makedepend's |
michael@0 | 170 | symbol table. |
michael@0 | 171 | Without |
michael@0 | 172 | .I =def\| |
michael@0 | 173 | the symbol becomes defined as ``1''. |
michael@0 | 174 | .TP 5 |
michael@0 | 175 | .B \-I\fIincludedir\fP |
michael@0 | 176 | Include directory. |
michael@0 | 177 | This option tells |
michael@0 | 178 | .B makedepend |
michael@0 | 179 | to prepend |
michael@0 | 180 | .I includedir |
michael@0 | 181 | to its list of directories to search when it encounters |
michael@0 | 182 | a |
michael@0 | 183 | .I #include |
michael@0 | 184 | directive. |
michael@0 | 185 | By default, |
michael@0 | 186 | .B makedepend |
michael@0 | 187 | only searches the standard include directories (usually /usr/include |
michael@0 | 188 | and possibly a compiler-dependent directory). |
michael@0 | 189 | .TP 5 |
michael@0 | 190 | .B \-Y\fIincludedir\fP |
michael@0 | 191 | Replace all of the standard include directories with the single specified |
michael@0 | 192 | include directory; you can omit the |
michael@0 | 193 | .I includedir |
michael@0 | 194 | to simply prevent searching the standard include directories. |
michael@0 | 195 | .TP 5 |
michael@0 | 196 | .B \-a |
michael@0 | 197 | Append the dependencies to the end of the file instead of replacing them. |
michael@0 | 198 | .TP 5 |
michael@0 | 199 | .B \-f\fImakefile\fP |
michael@0 | 200 | Filename. |
michael@0 | 201 | This allows you to specify an alternate makefile in which |
michael@0 | 202 | .B makedepend |
michael@0 | 203 | can place its output. |
michael@0 | 204 | Specifying ``\-'' as the file name (i.e., \fB\-f\-\fP) sends the |
michael@0 | 205 | output to standard output instead of modifying an existing file. |
michael@0 | 206 | .TP 5 |
michael@0 | 207 | .B \-include \fIfile\fP |
michael@0 | 208 | Process file as input, and include all the resulting output |
michael@0 | 209 | before processing the regular input file. This has the same |
michael@0 | 210 | affect as if the specified file is an include statement that |
michael@0 | 211 | appears before the very first line of the regular input file. |
michael@0 | 212 | .TP 5 |
michael@0 | 213 | .B \-o\fIobjsuffix\fP |
michael@0 | 214 | Object file suffix. |
michael@0 | 215 | Some systems may have object files whose suffix is something other |
michael@0 | 216 | than ``.o''. |
michael@0 | 217 | This option allows you to specify another suffix, such as |
michael@0 | 218 | ``.b'' with |
michael@0 | 219 | .I \-o.b |
michael@0 | 220 | or ``:obj'' |
michael@0 | 221 | with |
michael@0 | 222 | .I \-o:obj |
michael@0 | 223 | and so forth. |
michael@0 | 224 | .TP 5 |
michael@0 | 225 | .B \-p\fIobjprefix\fP |
michael@0 | 226 | Object file prefix. |
michael@0 | 227 | The prefix is prepended to the name of the object file. This is |
michael@0 | 228 | usually used to designate a different directory for the object file. |
michael@0 | 229 | The default is the empty string. |
michael@0 | 230 | .TP 5 |
michael@0 | 231 | .B \-s\fIstring\fP |
michael@0 | 232 | Starting string delimiter. |
michael@0 | 233 | This option permits you to specify |
michael@0 | 234 | a different string for |
michael@0 | 235 | .B makedepend |
michael@0 | 236 | to look for in the makefile. |
michael@0 | 237 | .TP 5 |
michael@0 | 238 | .B \-w\fIwidth\fP |
michael@0 | 239 | Line width. |
michael@0 | 240 | Normally, |
michael@0 | 241 | .B makedepend |
michael@0 | 242 | will ensure that every output line that it writes will be no wider than |
michael@0 | 243 | 78 characters for the sake of readability. |
michael@0 | 244 | This option enables you to change this width. |
michael@0 | 245 | .TP 5 |
michael@0 | 246 | .B \-v |
michael@0 | 247 | Verbose operation. |
michael@0 | 248 | This option causes |
michael@0 | 249 | .B makedepend |
michael@0 | 250 | to emit the list of files included by each input file. |
michael@0 | 251 | .TP 5 |
michael@0 | 252 | .B \-m |
michael@0 | 253 | Warn about multiple inclusion. |
michael@0 | 254 | This option causes |
michael@0 | 255 | .B makedepend |
michael@0 | 256 | to produce a warning if any input file includes another file more than |
michael@0 | 257 | once. In previous versions of |
michael@0 | 258 | .B makedepend |
michael@0 | 259 | this was the default behavior; the default has been changed to better |
michael@0 | 260 | match the behavior of the C compiler, which does not consider multiple |
michael@0 | 261 | inclusion to be an error. This option is provided for backward |
michael@0 | 262 | compatibility, and to aid in debugging problems related to multiple |
michael@0 | 263 | inclusion. |
michael@0 | 264 | .TP 5 |
michael@0 | 265 | .B "\-\^\- \fIoptions\fP \-\^\-" |
michael@0 | 266 | If |
michael@0 | 267 | .B makedepend |
michael@0 | 268 | encounters a double hyphen (\-\^\-) in the argument list, |
michael@0 | 269 | then any unrecognized argument following it |
michael@0 | 270 | will be silently ignored; a second double hyphen terminates this |
michael@0 | 271 | special treatment. |
michael@0 | 272 | In this way, |
michael@0 | 273 | .B makedepend |
michael@0 | 274 | can be made to safely ignore esoteric compiler arguments that might |
michael@0 | 275 | normally be found in a CFLAGS |
michael@0 | 276 | .B make |
michael@0 | 277 | macro (see the |
michael@0 | 278 | .B EXAMPLE |
michael@0 | 279 | section above). |
michael@0 | 280 | All options that |
michael@0 | 281 | .B makedepend |
michael@0 | 282 | recognizes and appear between the pair of double hyphens |
michael@0 | 283 | are processed normally. |
michael@0 | 284 | .SH ALGORITHM |
michael@0 | 285 | The approach used in this program enables it to run an order of magnitude |
michael@0 | 286 | faster than any other ``dependency generator'' I have ever seen. |
michael@0 | 287 | Central to this performance are two assumptions: |
michael@0 | 288 | that all files compiled by a single |
michael@0 | 289 | makefile will be compiled with roughly the same |
michael@0 | 290 | .I \-I |
michael@0 | 291 | and |
michael@0 | 292 | .I \-D |
michael@0 | 293 | options; |
michael@0 | 294 | and that most files in a single directory will include largely the |
michael@0 | 295 | same files. |
michael@0 | 296 | .PP |
michael@0 | 297 | Given these assumptions, |
michael@0 | 298 | .B makedepend |
michael@0 | 299 | expects to be called once for each makefile, with |
michael@0 | 300 | all source files that are maintained by the |
michael@0 | 301 | makefile appearing on the command line. |
michael@0 | 302 | It parses each source and include |
michael@0 | 303 | file exactly once, maintaining an internal symbol table |
michael@0 | 304 | for each. |
michael@0 | 305 | Thus, the first file on the command line will take an amount of time |
michael@0 | 306 | proportional to the amount of time that a normal C preprocessor takes. |
michael@0 | 307 | But on subsequent files, if it encounters an include file |
michael@0 | 308 | that it has already parsed, it does not parse it again. |
michael@0 | 309 | .PP |
michael@0 | 310 | For example, |
michael@0 | 311 | imagine you are compiling two files, |
michael@0 | 312 | .I file1.c |
michael@0 | 313 | and |
michael@0 | 314 | .I file2.c, |
michael@0 | 315 | they each include the header file |
michael@0 | 316 | .I header.h, |
michael@0 | 317 | and the file |
michael@0 | 318 | .I header.h |
michael@0 | 319 | in turn includes the files |
michael@0 | 320 | .I def1.h |
michael@0 | 321 | and |
michael@0 | 322 | .I def2.h. |
michael@0 | 323 | When you run the command |
michael@0 | 324 | .sp |
michael@0 | 325 | makedepend\0file1.c\0file2.c |
michael@0 | 326 | .sp |
michael@0 | 327 | .B makedepend |
michael@0 | 328 | will parse |
michael@0 | 329 | .I file1.c |
michael@0 | 330 | and consequently, |
michael@0 | 331 | .I header.h |
michael@0 | 332 | and then |
michael@0 | 333 | .I def1.h |
michael@0 | 334 | and |
michael@0 | 335 | .I def2.h. |
michael@0 | 336 | It then decides that the dependencies for this file are |
michael@0 | 337 | .sp |
michael@0 | 338 | file1.o:\0header.h\0def1.h\0def2.h |
michael@0 | 339 | .sp |
michael@0 | 340 | But when the program parses |
michael@0 | 341 | .I file2.c |
michael@0 | 342 | and discovers that it, too, includes |
michael@0 | 343 | .I header.h, |
michael@0 | 344 | it does not parse the file, |
michael@0 | 345 | but simply adds |
michael@0 | 346 | .I header.h, |
michael@0 | 347 | .I def1.h |
michael@0 | 348 | and |
michael@0 | 349 | .I def2.h |
michael@0 | 350 | to the list of dependencies for |
michael@0 | 351 | .I file2.o. |
michael@0 | 352 | .SH "SEE ALSO" |
michael@0 | 353 | cc(1), make(1) |
michael@0 | 354 | .SH BUGS |
michael@0 | 355 | .B makedepend |
michael@0 | 356 | parses, but does not currently evaluate, the SVR4 #predicate(token-list) |
michael@0 | 357 | preprocessor expression; such expressions are simply assumed to be true. |
michael@0 | 358 | This may cause the wrong |
michael@0 | 359 | .I #include |
michael@0 | 360 | directives to be evaluated. |
michael@0 | 361 | .PP |
michael@0 | 362 | Imagine you are parsing two files, |
michael@0 | 363 | say |
michael@0 | 364 | .I file1.c |
michael@0 | 365 | and |
michael@0 | 366 | .I file2.c, |
michael@0 | 367 | each includes the file |
michael@0 | 368 | .I def.h. |
michael@0 | 369 | The list of files that |
michael@0 | 370 | .I def.h |
michael@0 | 371 | includes might truly be different when |
michael@0 | 372 | .I def.h |
michael@0 | 373 | is included by |
michael@0 | 374 | .I file1.c |
michael@0 | 375 | than when it is included by |
michael@0 | 376 | .I file2.c. |
michael@0 | 377 | But once |
michael@0 | 378 | .B makedepend |
michael@0 | 379 | arrives at a list of dependencies for a file, |
michael@0 | 380 | it is cast in concrete. |
michael@0 | 381 | .SH AUTHOR |
michael@0 | 382 | Todd Brunhoff, Tektronix, Inc. and MIT Project Athena |