| 1 | .\" Copyright (c) 1990, 1993 | 
|---|
| 2 | .\"     The Regents of the University of California.  All rights reserved. | 
|---|
| 3 | .\" | 
|---|
| 4 | .\" Redistribution and use in source and binary forms, with or without | 
|---|
| 5 | .\" modification, are permitted provided that the following conditions | 
|---|
| 6 | .\" are met: | 
|---|
| 7 | .\" 1. Redistributions of source code must retain the above copyright | 
|---|
| 8 | .\"    notice, this list of conditions and the following disclaimer. | 
|---|
| 9 | .\" 2. Redistributions in binary form must reproduce the above copyright | 
|---|
| 10 | .\"    notice, this list of conditions and the following disclaimer in the | 
|---|
| 11 | .\"    documentation and/or other materials provided with the distribution. | 
|---|
| 12 | .\" 3. All advertising materials mentioning features or use of this software | 
|---|
| 13 | .\"    must display the following acknowledgement: | 
|---|
| 14 | .\"     This product includes software developed by the University of | 
|---|
| 15 | .\"     California, Berkeley and its contributors. | 
|---|
| 16 | .\" 4. Neither the name of the University nor the names of its contributors | 
|---|
| 17 | .\"    may be used to endorse or promote products derived from this software | 
|---|
| 18 | .\"    without specific prior written permission. | 
|---|
| 19 | .\" | 
|---|
| 20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 
|---|
| 21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
|---|
| 22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 
|---|
| 23 | .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 
|---|
| 24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
|---|
| 25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
|---|
| 26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
|---|
| 27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 
|---|
| 28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 
|---|
| 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 
|---|
| 30 | .\" SUCH DAMAGE. | 
|---|
| 31 | .\" | 
|---|
| 32 | .\"     from: @(#)make.1        8.4 (Berkeley) 3/19/94 | 
|---|
| 33 | .\" $FreeBSD: src/usr.bin/make/make.1,v 1.29.2.14 2002/09/09 19:06:16 archie Exp $ | 
|---|
| 34 | .\" | 
|---|
| 35 | .Dd March 19, 1994 | 
|---|
| 36 | .Dt MAKE 1 | 
|---|
| 37 | .Os | 
|---|
| 38 | .Sh NAME | 
|---|
| 39 | .Nm make | 
|---|
| 40 | .Nd maintain program dependencies | 
|---|
| 41 | .Sh SYNOPSIS | 
|---|
| 42 | .Nm | 
|---|
| 43 | .Op Fl BPSXeiknqrstv | 
|---|
| 44 | .Op Fl D Ar variable | 
|---|
| 45 | .Op Fl d Ar flags | 
|---|
| 46 | .Op Fl E Ar variable | 
|---|
| 47 | .Op Fl f Ar makefile | 
|---|
| 48 | .Op Fl I Ar directory | 
|---|
| 49 | .Bk -words | 
|---|
| 50 | .Op Fl j Ar max_jobs | 
|---|
| 51 | .Op Fl m Ar directory | 
|---|
| 52 | .Ek | 
|---|
| 53 | .Op Fl V Ar variable | 
|---|
| 54 | .Op Ar variable Ns No = Ns Ar value | 
|---|
| 55 | .Op Ar target ... | 
|---|
| 56 | .Sh DESCRIPTION | 
|---|
| 57 | The | 
|---|
| 58 | .Nm | 
|---|
| 59 | utility is a program designed to simplify the maintenance of other programs. | 
|---|
| 60 | Its input is a list of specifications | 
|---|
| 61 | describing dependency relationships between the generation of | 
|---|
| 62 | files and programs. | 
|---|
| 63 | The first of | 
|---|
| 64 | .Ql Pa makefile | 
|---|
| 65 | and | 
|---|
| 66 | .Ql Pa Makefile | 
|---|
| 67 | that can be found in either the current directory or a special object directory | 
|---|
| 68 | (see | 
|---|
| 69 | .Ql Va .OBJDIR ) | 
|---|
| 70 | will be read for this list of specifications. | 
|---|
| 71 | If the file | 
|---|
| 72 | .Ql Pa .depend | 
|---|
| 73 | can be found, it is also read (see | 
|---|
| 74 | .Xr mkdep 1 ) . | 
|---|
| 75 | .Pp | 
|---|
| 76 | This manual page is intended as a reference document only. | 
|---|
| 77 | For a more thorough introduction to | 
|---|
| 78 | .Nm | 
|---|
| 79 | and makefiles, please refer to | 
|---|
| 80 | .%T "Make \- A Tutorial" . | 
|---|
| 81 | .Pp | 
|---|
| 82 | The options are as follows: | 
|---|
| 83 | .Bl -tag -width Ds | 
|---|
| 84 | .It Fl B | 
|---|
| 85 | Try to be backwards compatible by executing a single shell per command and | 
|---|
| 86 | by executing the commands to make the sources of a dependency line in sequence. | 
|---|
| 87 | This is turned on by default unless | 
|---|
| 88 | .Fl j | 
|---|
| 89 | is used. | 
|---|
| 90 | .It Fl D Ar variable | 
|---|
| 91 | Define | 
|---|
| 92 | .Ar variable | 
|---|
| 93 | to be 1, in the global context. | 
|---|
| 94 | .It Fl d Ar flags | 
|---|
| 95 | Turn on debugging, and specify which portions of | 
|---|
| 96 | .Nm | 
|---|
| 97 | are to print debugging information. | 
|---|
| 98 | Argument | 
|---|
| 99 | .Ar flags | 
|---|
| 100 | is one or more of the following: | 
|---|
| 101 | .Bl -tag -width Ds | 
|---|
| 102 | .It Ar A | 
|---|
| 103 | Print all possible debugging information; | 
|---|
| 104 | equivalent to specifying all of the debugging flags. | 
|---|
| 105 | .It Ar a | 
|---|
| 106 | Print debugging information about archive searching and caching. | 
|---|
| 107 | .It Ar c | 
|---|
| 108 | Print debugging information about conditional evaluation. | 
|---|
| 109 | .It Ar d | 
|---|
| 110 | Print debugging information about directory searching and caching. | 
|---|
| 111 | .It Ar f | 
|---|
| 112 | Print debugging information about the execution of for loops. | 
|---|
| 113 | Currently a | 
|---|
| 114 | no-op. | 
|---|
| 115 | .It Ar "g1" | 
|---|
| 116 | Print the input graph before making anything. | 
|---|
| 117 | .It Ar "g2" | 
|---|
| 118 | Print the input graph after making everything, or before exiting | 
|---|
| 119 | on error. | 
|---|
| 120 | .It Ar j | 
|---|
| 121 | Print debugging information about running multiple shells. | 
|---|
| 122 | .It Ar l | 
|---|
| 123 | Print commands in Makefiles regardless of whether or not they are prefixed | 
|---|
| 124 | by @ or other "quiet" flags. | 
|---|
| 125 | Also known as "loud" behavior. | 
|---|
| 126 | .It Ar m | 
|---|
| 127 | Print debugging information about making targets, including modification | 
|---|
| 128 | dates. | 
|---|
| 129 | .It Ar s | 
|---|
| 130 | Print debugging information about suffix-transformation rules. | 
|---|
| 131 | .It Ar t | 
|---|
| 132 | Print debugging information about target list maintenance. | 
|---|
| 133 | .It Ar v | 
|---|
| 134 | Print debugging information about variable assignment. | 
|---|
| 135 | .El | 
|---|
| 136 | .It Fl E Ar variable | 
|---|
| 137 | Specify a variable whose environment value (if any) will override | 
|---|
| 138 | macro assignments within makefiles. | 
|---|
| 139 | .It Fl e | 
|---|
| 140 | Specify that environment values override macro assignments within | 
|---|
| 141 | makefiles for all variables. | 
|---|
| 142 | .It Fl f Ar makefile | 
|---|
| 143 | Specify a makefile to read instead of the default | 
|---|
| 144 | .Ql Pa makefile | 
|---|
| 145 | and | 
|---|
| 146 | .Ql Pa Makefile . | 
|---|
| 147 | If | 
|---|
| 148 | .Ar makefile | 
|---|
| 149 | is | 
|---|
| 150 | .Ql \- , | 
|---|
| 151 | standard input is read. | 
|---|
| 152 | Multiple makefiles may be specified, and are read in the order specified. | 
|---|
| 153 | .It Fl I Ar directory | 
|---|
| 154 | Specify a directory in which to search for makefiles and included makefiles. | 
|---|
| 155 | The system makefile directory (or directories, see the | 
|---|
| 156 | .Fl m | 
|---|
| 157 | option) is automatically included as part of this list. | 
|---|
| 158 | .It Fl i | 
|---|
| 159 | Ignore non-zero exit of shell commands in the makefile. | 
|---|
| 160 | Equivalent to specifying | 
|---|
| 161 | .Ql \- | 
|---|
| 162 | before each command line in the makefile. | 
|---|
| 163 | .It Fl j Ar max_jobs | 
|---|
| 164 | Specify the maximum number of jobs that | 
|---|
| 165 | .Nm | 
|---|
| 166 | may have running at any one time. | 
|---|
| 167 | Turns compatibility mode off, unless the | 
|---|
| 168 | .Ar B | 
|---|
| 169 | flag is also specified. | 
|---|
| 170 | .It Fl k | 
|---|
| 171 | Continue processing after errors are encountered, but only on those targets | 
|---|
| 172 | that do not depend on the target whose creation caused the error. | 
|---|
| 173 | .It Fl m Ar directory | 
|---|
| 174 | Specify a directory in which to search for sys.mk and makefiles included | 
|---|
| 175 | via the <...> style. | 
|---|
| 176 | Multiple directories can be added to form a search path. | 
|---|
| 177 | This path will override the default system include path: | 
|---|
| 178 | .Pa /usr/share/mk . | 
|---|
| 179 | Furthermore, the system include path will be appended to the search path used | 
|---|
| 180 | for "..."-style inclusions (see the | 
|---|
| 181 | .Fl I | 
|---|
| 182 | option). | 
|---|
| 183 | .It Fl n | 
|---|
| 184 | Display the commands that would have been executed, but do not actually | 
|---|
| 185 | execute them. | 
|---|
| 186 | .It Fl P | 
|---|
| 187 | Collate the output of a given job and display it only when the job finishes, | 
|---|
| 188 | instead of mixing the output of parallel jobs together. | 
|---|
| 189 | This option has no effect unless | 
|---|
| 190 | .Fl j | 
|---|
| 191 | is used too. | 
|---|
| 192 | .It Fl q | 
|---|
| 193 | Do not execute any commands, but exit 0 if the specified targets are | 
|---|
| 194 | up-to-date and 1, otherwise. | 
|---|
| 195 | .It Fl r | 
|---|
| 196 | Do not use the built-in rules specified in the system makefile. | 
|---|
| 197 | .It Fl S | 
|---|
| 198 | Stop processing when an error is encountered. | 
|---|
| 199 | Default behaviour. | 
|---|
| 200 | This is needed to negate the | 
|---|
| 201 | .Fl k | 
|---|
| 202 | option during recursive builds. | 
|---|
| 203 | .It Fl s | 
|---|
| 204 | Do not echo any commands as they are executed. | 
|---|
| 205 | Equivalent to specifying | 
|---|
| 206 | .Ql Ic @ | 
|---|
| 207 | before each command line in the makefile. | 
|---|
| 208 | .It Fl t | 
|---|
| 209 | Rather than re-building a target as specified in the makefile, create it | 
|---|
| 210 | or update its modification time to make it appear up-to-date. | 
|---|
| 211 | .It Fl V Ar variable | 
|---|
| 212 | Print | 
|---|
| 213 | .Nm Ns 's | 
|---|
| 214 | idea of the value of | 
|---|
| 215 | .Ar variable , | 
|---|
| 216 | in the global context. | 
|---|
| 217 | Do not build any targets. | 
|---|
| 218 | Multiple instances of this option may be specified; | 
|---|
| 219 | the variables will be printed one per line, | 
|---|
| 220 | with a blank line for each null or undefined variable. | 
|---|
| 221 | .It Fl v | 
|---|
| 222 | Be extra verbose. | 
|---|
| 223 | For multi-job makes, this will cause file banners to be generated. | 
|---|
| 224 | .It Fl X | 
|---|
| 225 | When using the | 
|---|
| 226 | .Fl V | 
|---|
| 227 | option to print the values of variables, | 
|---|
| 228 | do not recursively expand the values. | 
|---|
| 229 | .It Ar variable Ns No = Ns Ar value | 
|---|
| 230 | Set the value of the variable | 
|---|
| 231 | .Ar variable | 
|---|
| 232 | to | 
|---|
| 233 | .Ar value . | 
|---|
| 234 | .El | 
|---|
| 235 | .Pp | 
|---|
| 236 | There are seven different types of lines in a makefile: file dependency | 
|---|
| 237 | specifications, shell commands, variable assignments, include statements, | 
|---|
| 238 | conditional directives, for loops, and comments. | 
|---|
| 239 | .Pp | 
|---|
| 240 | In general, lines may be continued from one line to the next by ending | 
|---|
| 241 | them with a backslash | 
|---|
| 242 | .Pq Ql \e . | 
|---|
| 243 | The trailing newline character and initial whitespace on the following | 
|---|
| 244 | line are compressed into a single space. | 
|---|
| 245 | .Sh FILE DEPENDENCY SPECIFICATIONS | 
|---|
| 246 | Dependency lines consist of one or more targets, an operator, and zero | 
|---|
| 247 | or more sources. | 
|---|
| 248 | This creates a relationship where the targets | 
|---|
| 249 | .Dq depend | 
|---|
| 250 | on the sources | 
|---|
| 251 | and are usually created from them. | 
|---|
| 252 | The exact relationship between the target and the source is determined | 
|---|
| 253 | by the operator that separates them. | 
|---|
| 254 | The three operators are as follows: | 
|---|
| 255 | .Bl -tag -width flag | 
|---|
| 256 | .It Ic \&: | 
|---|
| 257 | A target is considered out-of-date if its modification time is less than | 
|---|
| 258 | those of any of its sources. | 
|---|
| 259 | Sources for a target accumulate over dependency lines when this operator | 
|---|
| 260 | is used. | 
|---|
| 261 | The target is removed if | 
|---|
| 262 | .Nm | 
|---|
| 263 | is interrupted. | 
|---|
| 264 | .It Ic \&! | 
|---|
| 265 | Targets are always re-created, but not until all sources have been | 
|---|
| 266 | examined and re-created as necessary. | 
|---|
| 267 | Sources for a target accumulate over dependency lines when this operator | 
|---|
| 268 | is used. | 
|---|
| 269 | The target is removed if | 
|---|
| 270 | .Nm | 
|---|
| 271 | is interrupted. | 
|---|
| 272 | .It Ic \&:: | 
|---|
| 273 | If no sources are specified, the target is always re-created. | 
|---|
| 274 | Otherwise, a target is considered out-of-date if any of its sources has | 
|---|
| 275 | been modified more recently than the target. | 
|---|
| 276 | Sources for a target do not accumulate over dependency lines when this | 
|---|
| 277 | operator is used. | 
|---|
| 278 | The target will not be removed if | 
|---|
| 279 | .Nm | 
|---|
| 280 | is interrupted. | 
|---|
| 281 | .El | 
|---|
| 282 | .Pp | 
|---|
| 283 | Targets and sources may contain the shell wildcard expressions | 
|---|
| 284 | .Ql \&? , | 
|---|
| 285 | .Ql * , | 
|---|
| 286 | .Ql [] | 
|---|
| 287 | and | 
|---|
| 288 | .Ql {} . | 
|---|
| 289 | The expressions | 
|---|
| 290 | .Ql \&? , | 
|---|
| 291 | .Ql * | 
|---|
| 292 | and | 
|---|
| 293 | .Ql [] | 
|---|
| 294 | may only be used as part of the final | 
|---|
| 295 | component of the target or source, and must be used to describe existing | 
|---|
| 296 | files. | 
|---|
| 297 | The expression | 
|---|
| 298 | .Ql {} | 
|---|
| 299 | need not necessarily be used to describe existing files. | 
|---|
| 300 | Expansion is in directory order, not alphabetically as done in the shell. | 
|---|
| 301 | .Sh SHELL COMMANDS | 
|---|
| 302 | Each target may have associated with it a series of shell commands, normally | 
|---|
| 303 | used to create the target. | 
|---|
| 304 | Each of the commands in this script | 
|---|
| 305 | .Em must | 
|---|
| 306 | be preceded by a tab. | 
|---|
| 307 | While any target may appear on a dependency line, only one of these | 
|---|
| 308 | dependencies may be followed by a creation script, unless the | 
|---|
| 309 | .Ql Ic :: | 
|---|
| 310 | operator is used. | 
|---|
| 311 | .Pp | 
|---|
| 312 | If the first or first two characters of the command line are | 
|---|
| 313 | .Ql Ic @ | 
|---|
| 314 | and/or | 
|---|
| 315 | .Ql Ic \- , | 
|---|
| 316 | the command is treated specially. | 
|---|
| 317 | A | 
|---|
| 318 | .Ql Ic @ | 
|---|
| 319 | causes the command not to be echoed before it is executed. | 
|---|
| 320 | A | 
|---|
| 321 | .Ql Ic \- | 
|---|
| 322 | causes any non-zero exit status of the command line to be ignored. | 
|---|
| 323 | .Sh VARIABLE ASSIGNMENTS | 
|---|
| 324 | Variables in | 
|---|
| 325 | .Nm | 
|---|
| 326 | are much like variables in the shell, and, by tradition, | 
|---|
| 327 | consist of all upper-case letters. | 
|---|
| 328 | The five operators that can be used to assign values to variables are as | 
|---|
| 329 | follows: | 
|---|
| 330 | .Bl -tag -width Ds | 
|---|
| 331 | .It Ic \&= | 
|---|
| 332 | Assign the value to the variable. | 
|---|
| 333 | Any previous value is overridden. | 
|---|
| 334 | .It Ic \&+= | 
|---|
| 335 | Append the value to the current value of the variable. | 
|---|
| 336 | .It Ic \&?= | 
|---|
| 337 | Assign the value to the variable if it is not already defined. | 
|---|
| 338 | .It Ic \&:= | 
|---|
| 339 | Assign with expansion, i.e. expand the value before assigning it | 
|---|
| 340 | to the variable. | 
|---|
| 341 | Normally, expansion is not done until the variable is referenced. | 
|---|
| 342 | .It Ic \&!= | 
|---|
| 343 | Expand the value and pass it to the shell for execution and assign | 
|---|
| 344 | the result to the variable. | 
|---|
| 345 | Any newlines in the result are replaced with spaces. | 
|---|
| 346 | .El | 
|---|
| 347 | .Pp | 
|---|
| 348 | Any whitespace before the assigned | 
|---|
| 349 | .Ar value | 
|---|
| 350 | is removed; if the value is being appended, a single space is inserted | 
|---|
| 351 | between the previous contents of the variable and the appended value. | 
|---|
| 352 | .Pp | 
|---|
| 353 | Variables are expanded by surrounding the variable name with either | 
|---|
| 354 | curly braces | 
|---|
| 355 | .Pq Ql {} | 
|---|
| 356 | or parentheses | 
|---|
| 357 | .Pq Ql () | 
|---|
| 358 | and preceding it with | 
|---|
| 359 | a dollar sign | 
|---|
| 360 | .Pq Ql \&$ . | 
|---|
| 361 | If the variable name contains only a single letter, the surrounding | 
|---|
| 362 | braces or parentheses are not required. | 
|---|
| 363 | This shorter form is not recommended. | 
|---|
| 364 | .Pp | 
|---|
| 365 | Variable substitution occurs at two distinct times, depending on where | 
|---|
| 366 | the variable is being used. | 
|---|
| 367 | Variables in dependency lines are expanded as the line is read. | 
|---|
| 368 | Variables in shell commands are expanded when the shell command is | 
|---|
| 369 | executed. | 
|---|
| 370 | .Pp | 
|---|
| 371 | The four different classes of variables (in order of increasing precedence) | 
|---|
| 372 | are: | 
|---|
| 373 | .Bl -tag -width Ds | 
|---|
| 374 | .It Environment variables | 
|---|
| 375 | Variables defined as part of | 
|---|
| 376 | .Nm Ns 's | 
|---|
| 377 | environment. | 
|---|
| 378 | .It Global variables | 
|---|
| 379 | Variables defined in the makefile or in included makefiles. | 
|---|
| 380 | .It Command line variables | 
|---|
| 381 | Variables defined as part of the command line. | 
|---|
| 382 | .It Local variables | 
|---|
| 383 | Variables that are defined specific to a certain target. | 
|---|
| 384 | The seven local variables are as follows: | 
|---|
| 385 | .Bl -tag -width ".ARCHIVE" | 
|---|
| 386 | .It Va .ALLSRC | 
|---|
| 387 | The list of all sources for this target; also known as | 
|---|
| 388 | .Ql Va \&> . | 
|---|
| 389 | .It Va .ARCHIVE | 
|---|
| 390 | The name of the archive file; also known as | 
|---|
| 391 | .Ql Va \&! . | 
|---|
| 392 | .It Va .IMPSRC | 
|---|
| 393 | The name/path of the source from which the target is to be transformed | 
|---|
| 394 | (the | 
|---|
| 395 | .Dq implied | 
|---|
| 396 | source); also known as | 
|---|
| 397 | .Ql Va \&< . | 
|---|
| 398 | .It Va .MEMBER | 
|---|
| 399 | The name of the archive member; also known as | 
|---|
| 400 | .Ql Va \&% . | 
|---|
| 401 | .It Va .OODATE | 
|---|
| 402 | The list of sources for this target that were deemed out-of-date; also | 
|---|
| 403 | known as | 
|---|
| 404 | .Ql Va \&? . | 
|---|
| 405 | .It Va .PREFIX | 
|---|
| 406 | The file prefix of the file, containing only the file portion, no suffix | 
|---|
| 407 | or preceding directory components; also known as | 
|---|
| 408 | .Ql Va * . | 
|---|
| 409 | .It Va .TARGET | 
|---|
| 410 | The name of the target; also known as | 
|---|
| 411 | .Ql Va @ . | 
|---|
| 412 | .El | 
|---|
| 413 | .Pp | 
|---|
| 414 | The shorter forms | 
|---|
| 415 | .Ql Va @ , | 
|---|
| 416 | .Ql Va \&! , | 
|---|
| 417 | .Ql Va \&< , | 
|---|
| 418 | .Ql Va \&% , | 
|---|
| 419 | .Ql Va \&? , | 
|---|
| 420 | .Ql Va \&> , | 
|---|
| 421 | and | 
|---|
| 422 | .Ql Va * | 
|---|
| 423 | are permitted for backward | 
|---|
| 424 | compatibility and are not recommended. | 
|---|
| 425 | The six variables | 
|---|
| 426 | .Ql Va "@F" , | 
|---|
| 427 | .Ql Va "@D" , | 
|---|
| 428 | .Ql Va "<F" , | 
|---|
| 429 | .Ql Va "<D" , | 
|---|
| 430 | .Ql Va "*F" , | 
|---|
| 431 | and | 
|---|
| 432 | .Ql Va "*D" | 
|---|
| 433 | are | 
|---|
| 434 | permitted for compatibility with | 
|---|
| 435 | .At V | 
|---|
| 436 | makefiles and are not recommended. | 
|---|
| 437 | .Pp | 
|---|
| 438 | Four of the local variables may be used in sources on dependency lines | 
|---|
| 439 | because they expand to the proper value for each target on the line. | 
|---|
| 440 | These variables are | 
|---|
| 441 | .Ql Va .TARGET , | 
|---|
| 442 | .Ql Va .PREFIX , | 
|---|
| 443 | .Ql Va .ARCHIVE , | 
|---|
| 444 | and | 
|---|
| 445 | .Ql Va .MEMBER . | 
|---|
| 446 | .El | 
|---|
| 447 | .Pp | 
|---|
| 448 | In addition, | 
|---|
| 449 | .Nm | 
|---|
| 450 | sets or knows about the following internal variables or environment | 
|---|
| 451 | variables: | 
|---|
| 452 | .Bl -tag -width MAKEFLAGS | 
|---|
| 453 | .It Va \&$ | 
|---|
| 454 | A single dollar sign | 
|---|
| 455 | .Ql \&$ , | 
|---|
| 456 | i.e.\& | 
|---|
| 457 | .Ql \&$$ | 
|---|
| 458 | expands to a single dollar | 
|---|
| 459 | sign. | 
|---|
| 460 | .It Va MAKE | 
|---|
| 461 | The name that | 
|---|
| 462 | .Nm | 
|---|
| 463 | was executed with | 
|---|
| 464 | .Pq Va argv Ns Op 0 . | 
|---|
| 465 | .It Va .CURDIR | 
|---|
| 466 | A path to the directory where | 
|---|
| 467 | .Nm | 
|---|
| 468 | was executed. | 
|---|
| 469 | The | 
|---|
| 470 | .Nm | 
|---|
| 471 | utility sets | 
|---|
| 472 | .Va .CURDIR | 
|---|
| 473 | to the canonical path given by | 
|---|
| 474 | .Xr getcwd 3 . | 
|---|
| 475 | .It Va .OBJDIR | 
|---|
| 476 | A path to the directory where the targets are built. | 
|---|
| 477 | At startup, | 
|---|
| 478 | .Nm | 
|---|
| 479 | searches for an alternate directory to place target files. | 
|---|
| 480 | It will attempt to change into this special directory | 
|---|
| 481 | and will search this directory for makefiles | 
|---|
| 482 | not found in the current directory. | 
|---|
| 483 | The following directories are tried in order: | 
|---|
| 484 | .Pp | 
|---|
| 485 | .Bl -enum -compact | 
|---|
| 486 | .It | 
|---|
| 487 | ${MAKEOBJDIRPREFIX}/`pwd` | 
|---|
| 488 | .It | 
|---|
| 489 | ${MAKEOBJDIR} | 
|---|
| 490 | .It | 
|---|
| 491 | obj.${MACHINE} | 
|---|
| 492 | .It | 
|---|
| 493 | obj | 
|---|
| 494 | .It | 
|---|
| 495 | /usr/obj/`pwd` | 
|---|
| 496 | .El | 
|---|
| 497 | .Pp | 
|---|
| 498 | The first directory that | 
|---|
| 499 | .Nm | 
|---|
| 500 | successfully changes into is used. | 
|---|
| 501 | If either | 
|---|
| 502 | .Ev MAKEOBJDIRPREFIX | 
|---|
| 503 | or | 
|---|
| 504 | .Ev MAKEOBJDIR | 
|---|
| 505 | is set in the environment but | 
|---|
| 506 | .Nm | 
|---|
| 507 | is unable to change into the corresponding directory, | 
|---|
| 508 | then the current directory is used | 
|---|
| 509 | without checking the remainder of the list. | 
|---|
| 510 | If they are undefined and | 
|---|
| 511 | .Nm | 
|---|
| 512 | is unable to change into any of the remaining three directories, | 
|---|
| 513 | then the current directory is used. | 
|---|
| 514 | .It Va .MAKEFLAGS | 
|---|
| 515 | The environment variable | 
|---|
| 516 | .Ev MAKEFLAGS | 
|---|
| 517 | may contain anything that | 
|---|
| 518 | may be specified on | 
|---|
| 519 | .Nm Ns 's | 
|---|
| 520 | command line. | 
|---|
| 521 | Its contents are stored in | 
|---|
| 522 | .Nm Ns 's | 
|---|
| 523 | .Va .MAKEFLAGS | 
|---|
| 524 | variable. | 
|---|
| 525 | Anything specified on | 
|---|
| 526 | .Nm Ns 's | 
|---|
| 527 | command line is appended to the | 
|---|
| 528 | .Va .MAKEFLAGS | 
|---|
| 529 | variable which is then | 
|---|
| 530 | entered into the environment as | 
|---|
| 531 | .Ev MAKEFLAGS | 
|---|
| 532 | for all programs which | 
|---|
| 533 | .Nm | 
|---|
| 534 | executes. | 
|---|
| 535 | .It Va MFLAGS | 
|---|
| 536 | A synonym for | 
|---|
| 537 | .Va .MAKEFLAGS | 
|---|
| 538 | provided for backward compatibility. | 
|---|
| 539 | .It Ev PWD | 
|---|
| 540 | Alternate path to the current directory. | 
|---|
| 541 | Supported if built with WANT_ENV_PWD defined. | 
|---|
| 542 | .Nm | 
|---|
| 543 | normally sets | 
|---|
| 544 | .Ql Va .CURDIR | 
|---|
| 545 | to the canonical path given by | 
|---|
| 546 | .Xr getcwd 3 . | 
|---|
| 547 | However, if the environment variable | 
|---|
| 548 | .Ev PWD | 
|---|
| 549 | is set and gives a path to the current directory, then | 
|---|
| 550 | .Nm | 
|---|
| 551 | sets | 
|---|
| 552 | .Ql Va .CURDIR | 
|---|
| 553 | to the value of | 
|---|
| 554 | .Ev PWD | 
|---|
| 555 | instead. | 
|---|
| 556 | .Ev PWD | 
|---|
| 557 | is always set to the value of | 
|---|
| 558 | .Ql Va .OBJDIR | 
|---|
| 559 | for all programs which | 
|---|
| 560 | .Nm | 
|---|
| 561 | executes. | 
|---|
| 562 | .It Va .TARGETS | 
|---|
| 563 | List of targets | 
|---|
| 564 | .Nm | 
|---|
| 565 | is currently building. | 
|---|
| 566 | .It Va .INCLUDES | 
|---|
| 567 | See | 
|---|
| 568 | .Ic .INCLUDES | 
|---|
| 569 | special target. | 
|---|
| 570 | .It Va .LIBS | 
|---|
| 571 | See | 
|---|
| 572 | .Ic .LIBS | 
|---|
| 573 | special target. | 
|---|
| 574 | .It Va MACHINE | 
|---|
| 575 | Name of the machine architecture | 
|---|
| 576 | .Nm | 
|---|
| 577 | is running on, obtained from the | 
|---|
| 578 | .Ev MACHINE | 
|---|
| 579 | environment variable, or through | 
|---|
| 580 | .Xr uname 3 | 
|---|
| 581 | if not defined. | 
|---|
| 582 | .It Va MACHINE_ARCH | 
|---|
| 583 | Name of the machine architecture | 
|---|
| 584 | .Nm | 
|---|
| 585 | was compiled for, defined at compilation time. | 
|---|
| 586 | .It Va VPATH | 
|---|
| 587 | Makefiles may assign a colon-delimited list of directories to | 
|---|
| 588 | .Va VPATH . | 
|---|
| 589 | These directories will be searched for source files by | 
|---|
| 590 | .Nm | 
|---|
| 591 | after | 
|---|
| 592 | .Nm | 
|---|
| 593 | has finished parsing all input makefiles. | 
|---|
| 594 | .El | 
|---|
| 595 | .Pp | 
|---|
| 596 | Variable expansion may be modified to select or modify each word of the | 
|---|
| 597 | variable (where a | 
|---|
| 598 | .Dq word | 
|---|
| 599 | is whitespace-delimited sequence of characters). | 
|---|
| 600 | The general format of a variable expansion is as follows: | 
|---|
| 601 | .Pp | 
|---|
| 602 | .Dl {variable[:modifier[:...]]} | 
|---|
| 603 | .Pp | 
|---|
| 604 | Each modifier begins with a colon and one of the following | 
|---|
| 605 | special characters. | 
|---|
| 606 | The colon may be escaped with a backslash | 
|---|
| 607 | .Pq Ql \e . | 
|---|
| 608 | .Bl -tag -width Cm | 
|---|
| 609 | .Sm off | 
|---|
| 610 | .It Cm C No \&/ Ar pattern Xo | 
|---|
| 611 | .No \&/ Ar replacement | 
|---|
| 612 | .No \&/ Op Cm 1g | 
|---|
| 613 | .Xc | 
|---|
| 614 | .Sm on | 
|---|
| 615 | The | 
|---|
| 616 | .Cm C | 
|---|
| 617 | modifier is just like the | 
|---|
| 618 | .Cm S | 
|---|
| 619 | modifier except that the old and new strings, instead of being | 
|---|
| 620 | simple strings, are an extended regular expression (see | 
|---|
| 621 | .Xr re_format 7 ) | 
|---|
| 622 | and an | 
|---|
| 623 | .Xr ed 1 Ns \-style | 
|---|
| 624 | replacement string. | 
|---|
| 625 | Normally, the first occurrence of the pattern in | 
|---|
| 626 | each word of the value is changed. | 
|---|
| 627 | The | 
|---|
| 628 | .Ql 1 | 
|---|
| 629 | modifier causes the substitution to apply to at most one word; the | 
|---|
| 630 | .Ql g | 
|---|
| 631 | modifier causes the substitution to apply to as many instances of the | 
|---|
| 632 | search pattern as occur in the word or words it is found in. | 
|---|
| 633 | Note that | 
|---|
| 634 | .Ql 1 | 
|---|
| 635 | and | 
|---|
| 636 | .Ql g | 
|---|
| 637 | are orthogonal; the former specifies whether multiple words are | 
|---|
| 638 | potentially affected, the latter whether multiple substitutions can | 
|---|
| 639 | potentially occur within each affected word. | 
|---|
| 640 | .It Cm E | 
|---|
| 641 | Replaces each word in the variable with its suffix. | 
|---|
| 642 | .It Cm H | 
|---|
| 643 | Replaces each word in the variable with everything but the last component. | 
|---|
| 644 | .It Cm L | 
|---|
| 645 | Converts variable to lower-case letters. | 
|---|
| 646 | .It Cm M Ns Ar pattern | 
|---|
| 647 | Select only those words that match the rest of the modifier. | 
|---|
| 648 | The standard shell wildcard characters | 
|---|
| 649 | .Pf ( Ql * , | 
|---|
| 650 | .Ql \&? , | 
|---|
| 651 | and | 
|---|
| 652 | .Ql Op ) | 
|---|
| 653 | may | 
|---|
| 654 | be used. | 
|---|
| 655 | The wildcard characters may be escaped with a backslash | 
|---|
| 656 | .Pq Ql \e . | 
|---|
| 657 | .It Cm N Ns Ar pattern | 
|---|
| 658 | This is identical to | 
|---|
| 659 | .Cm M , | 
|---|
| 660 | but selects all words which do not match | 
|---|
| 661 | the rest of the modifier. | 
|---|
| 662 | .It Cm Q | 
|---|
| 663 | Quotes every shell meta-character in the variable, so that it can be passed | 
|---|
| 664 | safely through recursive invocations of | 
|---|
| 665 | .Nm . | 
|---|
| 666 | .It Cm R | 
|---|
| 667 | Replaces each word in the variable with everything but its suffix. | 
|---|
| 668 | .Sm off | 
|---|
| 669 | .It Cm S No \&/ Ar old_string Xo | 
|---|
| 670 | .No \&/ Ar new_string | 
|---|
| 671 | .No \&/ Op Cm g | 
|---|
| 672 | .Xc | 
|---|
| 673 | .Sm on | 
|---|
| 674 | Modify the first occurrence of | 
|---|
| 675 | .Ar old_string | 
|---|
| 676 | in each word of the variable's value, replacing it with | 
|---|
| 677 | .Ar new_string . | 
|---|
| 678 | If a | 
|---|
| 679 | .Ql g | 
|---|
| 680 | is appended to the last slash of the pattern, all occurrences | 
|---|
| 681 | in each word are replaced. | 
|---|
| 682 | If | 
|---|
| 683 | .Ar old_string | 
|---|
| 684 | begins with a caret | 
|---|
| 685 | .Pq Ql ^ , | 
|---|
| 686 | .Ar old_string | 
|---|
| 687 | is anchored at the beginning of each word. | 
|---|
| 688 | If | 
|---|
| 689 | .Ar old_string | 
|---|
| 690 | ends with a dollar sign | 
|---|
| 691 | .Pq Ql \&$ , | 
|---|
| 692 | it is anchored at the end of each word. | 
|---|
| 693 | Inside | 
|---|
| 694 | .Ar new_string , | 
|---|
| 695 | an ampersand | 
|---|
| 696 | .Pq Ql & | 
|---|
| 697 | is replaced by | 
|---|
| 698 | .Ar old_string . | 
|---|
| 699 | Any character may be used as a delimiter for the parts of the modifier | 
|---|
| 700 | string. | 
|---|
| 701 | The anchoring, ampersand, and delimiter characters may be escaped with a | 
|---|
| 702 | backslash | 
|---|
| 703 | .Pq Ql \e . | 
|---|
| 704 | .Pp | 
|---|
| 705 | Variable expansion occurs in the normal fashion inside both | 
|---|
| 706 | .Ar old_string | 
|---|
| 707 | and | 
|---|
| 708 | .Ar new_string | 
|---|
| 709 | with the single exception that a backslash is used to prevent the expansion | 
|---|
| 710 | of a dollar sign | 
|---|
| 711 | .Pq Ql \&$ , | 
|---|
| 712 | not a preceding dollar sign as is usual. | 
|---|
| 713 | .It Cm T | 
|---|
| 714 | Replaces each word in the variable with its last component. | 
|---|
| 715 | .It Ar old_string=new_string | 
|---|
| 716 | This is the | 
|---|
| 717 | .At V | 
|---|
| 718 | style variable substitution. | 
|---|
| 719 | It must be the last modifier specified. | 
|---|
| 720 | If | 
|---|
| 721 | .Ar old_string | 
|---|
| 722 | or | 
|---|
| 723 | .Ar new_string | 
|---|
| 724 | do not contain the pattern matching character | 
|---|
| 725 | .Ar % | 
|---|
| 726 | then it is assumed that they are | 
|---|
| 727 | anchored at the end of each word, so only suffixes or entire | 
|---|
| 728 | words may be replaced. | 
|---|
| 729 | Otherwise | 
|---|
| 730 | .Ar % | 
|---|
| 731 | is the substring of | 
|---|
| 732 | .Ar old_string | 
|---|
| 733 | to be replaced in | 
|---|
| 734 | .Ar new_string | 
|---|
| 735 | .It Cm U | 
|---|
| 736 | Converts variable to upper-case letters. | 
|---|
| 737 | .El | 
|---|
| 738 | .Sh DIRECTIVES, CONDITIONALS, AND FOR LOOPS | 
|---|
| 739 | Directives, conditionals, and for loops reminiscent | 
|---|
| 740 | of the C programming language are provided in | 
|---|
| 741 | .Nm . | 
|---|
| 742 | All such structures are identified by a line beginning with a single | 
|---|
| 743 | dot | 
|---|
| 744 | .Pq Ql \&. | 
|---|
| 745 | character. | 
|---|
| 746 | The following directives are supported: | 
|---|
| 747 | .Bl -tag -width Ds | 
|---|
| 748 | .It Ic \&.include Ar <file> | 
|---|
| 749 | .It Ic \&.include Ar \*qfile\*q | 
|---|
| 750 | Include the specified makefile. | 
|---|
| 751 | Variables between the angle brackets | 
|---|
| 752 | or double quotes are expanded to form the file name. | 
|---|
| 753 | If angle brackets | 
|---|
| 754 | are used, the included makefile is expected to be in the system | 
|---|
| 755 | makefile directory. | 
|---|
| 756 | If double quotes are used, the including | 
|---|
| 757 | makefile's directory and any directories specified using the | 
|---|
| 758 | .Fl I | 
|---|
| 759 | option are searched before the system | 
|---|
| 760 | makefile directory. | 
|---|
| 761 | .It Ic \&.undef Ar variable | 
|---|
| 762 | Un-define the specified global variable. | 
|---|
| 763 | Only global variables may be un-defined. | 
|---|
| 764 | .It Ic \&.error Ar message | 
|---|
| 765 | Terminate processing of the makefile immediately. | 
|---|
| 766 | The filename of the | 
|---|
| 767 | makefile, the line on which the error was encountered and the specified | 
|---|
| 768 | message are printed to standard output and | 
|---|
| 769 | .Nm | 
|---|
| 770 | terminates with exit code 1. | 
|---|
| 771 | Variables in the message are expanded. | 
|---|
| 772 | .El | 
|---|
| 773 | .Pp | 
|---|
| 774 | Conditionals are used to determine which parts of the Makefile | 
|---|
| 775 | to process. | 
|---|
| 776 | They are used similarly to the conditionals supported | 
|---|
| 777 | by the C pre-processor. | 
|---|
| 778 | The following conditionals are supported: | 
|---|
| 779 | .Bl -tag -width Ds | 
|---|
| 780 | .It Xo | 
|---|
| 781 | .Ic \&.if | 
|---|
| 782 | .Oo \&! Oc Ns Ar expression | 
|---|
| 783 | .Op Ar operator expression ... | 
|---|
| 784 | .Xc | 
|---|
| 785 | Test the value of an expression. | 
|---|
| 786 | .It Xo | 
|---|
| 787 | .Ic .ifdef | 
|---|
| 788 | .Oo \&! Oc Ns Ar variable | 
|---|
| 789 | .Op Ar operator variable ... | 
|---|
| 790 | .Xc | 
|---|
| 791 | Test the value of a variable. | 
|---|
| 792 | .It Xo | 
|---|
| 793 | .Ic .ifndef | 
|---|
| 794 | .Oo \&! Oc Ns Ar variable | 
|---|
| 795 | .Op Ar operator variable ... | 
|---|
| 796 | .Xc | 
|---|
| 797 | Test the value of a variable. | 
|---|
| 798 | .It Xo | 
|---|
| 799 | .Ic .ifmake | 
|---|
| 800 | .Oo \&! Oc Ns Ar target | 
|---|
| 801 | .Op Ar operator target ... | 
|---|
| 802 | .Xc | 
|---|
| 803 | Test the target being built. | 
|---|
| 804 | .It Xo | 
|---|
| 805 | .Ic .ifnmake | 
|---|
| 806 | .Oo \&! Oc Ns Ar target | 
|---|
| 807 | .Op Ar operator target ... | 
|---|
| 808 | .Xc | 
|---|
| 809 | Test the target being built. | 
|---|
| 810 | .It Ic .else | 
|---|
| 811 | Reverse the sense of the last conditional. | 
|---|
| 812 | .It Xo | 
|---|
| 813 | .Ic .elif | 
|---|
| 814 | .Oo \&! Oc Ns Ar expression | 
|---|
| 815 | .Op Ar operator expression ... | 
|---|
| 816 | .Xc | 
|---|
| 817 | A combination of | 
|---|
| 818 | .Ql Ic .else | 
|---|
| 819 | followed by | 
|---|
| 820 | .Ql Ic .if . | 
|---|
| 821 | .It Xo | 
|---|
| 822 | .Ic .elifdef | 
|---|
| 823 | .Oo \&! Oc Ns Ar variable | 
|---|
| 824 | .Op Ar operator variable ... | 
|---|
| 825 | .Xc | 
|---|
| 826 | A combination of | 
|---|
| 827 | .Ql Ic .else | 
|---|
| 828 | followed by | 
|---|
| 829 | .Ql Ic .ifdef . | 
|---|
| 830 | .It Xo | 
|---|
| 831 | .Ic .elifndef | 
|---|
| 832 | .Oo \&! Oc Ns Ar variable | 
|---|
| 833 | .Op Ar operator variable ... | 
|---|
| 834 | .Xc | 
|---|
| 835 | A combination of | 
|---|
| 836 | .Ql Ic .else | 
|---|
| 837 | followed by | 
|---|
| 838 | .Ql Ic .ifndef . | 
|---|
| 839 | .It Xo | 
|---|
| 840 | .Ic .elifmake | 
|---|
| 841 | .Oo \&! Oc Ns Ar target | 
|---|
| 842 | .Op Ar operator target ... | 
|---|
| 843 | .Xc | 
|---|
| 844 | A combination of | 
|---|
| 845 | .Ql Ic .else | 
|---|
| 846 | followed by | 
|---|
| 847 | .Ql Ic .ifmake . | 
|---|
| 848 | .It Xo | 
|---|
| 849 | .Ic .elifnmake | 
|---|
| 850 | .Oo \&! Oc Ns Ar target | 
|---|
| 851 | .Op Ar operator target ... | 
|---|
| 852 | .Xc | 
|---|
| 853 | A combination of | 
|---|
| 854 | .Ql Ic .else | 
|---|
| 855 | followed by | 
|---|
| 856 | .Ql Ic .ifnmake . | 
|---|
| 857 | .It Ic .endif | 
|---|
| 858 | End the body of the conditional. | 
|---|
| 859 | .El | 
|---|
| 860 | .Pp | 
|---|
| 861 | The | 
|---|
| 862 | .Ar operator | 
|---|
| 863 | may be any one of the following: | 
|---|
| 864 | .Bl -tag -width "Cm XX" | 
|---|
| 865 | .It Cm \&|\&| | 
|---|
| 866 | logical OR | 
|---|
| 867 | .It Cm \&&& | 
|---|
| 868 | Logical | 
|---|
| 869 | .Tn AND ; | 
|---|
| 870 | of higher precedence than | 
|---|
| 871 | .Ql Ic || . | 
|---|
| 872 | .El | 
|---|
| 873 | .Pp | 
|---|
| 874 | As in C, | 
|---|
| 875 | .Nm | 
|---|
| 876 | will only evaluate a conditional as far as is necessary to determine | 
|---|
| 877 | its value. | 
|---|
| 878 | Parentheses may be used to change the order of evaluation. | 
|---|
| 879 | The boolean operator | 
|---|
| 880 | .Ql Ic !\& | 
|---|
| 881 | may be used to logically negate an entire | 
|---|
| 882 | conditional. | 
|---|
| 883 | It is of higher precedence than | 
|---|
| 884 | .Ql Ic \&&& . | 
|---|
| 885 | .Pp | 
|---|
| 886 | The value of | 
|---|
| 887 | .Ar expression | 
|---|
| 888 | may be any of the following: | 
|---|
| 889 | .Bl -tag -width Ic | 
|---|
| 890 | .It Ic defined | 
|---|
| 891 | Takes a variable name as an argument and evaluates to true if the variable | 
|---|
| 892 | has been defined. | 
|---|
| 893 | .It Ic make | 
|---|
| 894 | Takes a target name as an argument and evaluates to true if the target | 
|---|
| 895 | was specified as part of | 
|---|
| 896 | .Nm Ns 's | 
|---|
| 897 | command line or was declared the default target (either implicitly or | 
|---|
| 898 | explicitly, see | 
|---|
| 899 | .Va .MAIN ) | 
|---|
| 900 | before the line containing the conditional. | 
|---|
| 901 | .It Ic empty | 
|---|
| 902 | Takes a variable, with possible modifiers, and evaluates to true if | 
|---|
| 903 | the expansion of the variable would result in an empty string. | 
|---|
| 904 | .It Ic exists | 
|---|
| 905 | Takes a file name as an argument and evaluates to true if the file exists. | 
|---|
| 906 | The file is searched for on the system search path (see | 
|---|
| 907 | .Va .PATH ) . | 
|---|
| 908 | .It Ic target | 
|---|
| 909 | Takes a target name as an argument and evaluates to true if the target | 
|---|
| 910 | has been defined. | 
|---|
| 911 | .El | 
|---|
| 912 | .Pp | 
|---|
| 913 | An | 
|---|
| 914 | .Ar expression | 
|---|
| 915 | may also be an arithmetic or string comparison. | 
|---|
| 916 | Variable expansion is | 
|---|
| 917 | performed on both sides of the comparison, after which the integral | 
|---|
| 918 | values are compared. | 
|---|
| 919 | A value is interpreted as hexadecimal if it is | 
|---|
| 920 | preceded by 0x, otherwise it is decimal; octal numbers are not supported. | 
|---|
| 921 | The standard C relational operators are all supported. | 
|---|
| 922 | If after | 
|---|
| 923 | variable expansion, either the left or right hand side of a | 
|---|
| 924 | .Ql Ic == | 
|---|
| 925 | or | 
|---|
| 926 | .Ql Ic "!=" | 
|---|
| 927 | operator is not an integral value, then | 
|---|
| 928 | string comparison is performed between the expanded | 
|---|
| 929 | variables. | 
|---|
| 930 | If no relational operator is given, it is assumed that the expanded | 
|---|
| 931 | variable is being compared against 0. | 
|---|
| 932 | .Pp | 
|---|
| 933 | When | 
|---|
| 934 | .Nm | 
|---|
| 935 | is evaluating one of these conditional expressions, and it encounters | 
|---|
| 936 | a word it doesn't recognize, either the | 
|---|
| 937 | .Dq make | 
|---|
| 938 | or | 
|---|
| 939 | .Dq defined | 
|---|
| 940 | expression is applied to it, depending on the form of the conditional. | 
|---|
| 941 | If the form is | 
|---|
| 942 | .Ql Ic .ifdef | 
|---|
| 943 | or | 
|---|
| 944 | .Ql Ic .ifndef , | 
|---|
| 945 | the | 
|---|
| 946 | .Dq defined | 
|---|
| 947 | expression is applied. | 
|---|
| 948 | Similarly, if the form is | 
|---|
| 949 | .Ql Ic .ifmake | 
|---|
| 950 | or | 
|---|
| 951 | .Ql Ic .ifnmake , | 
|---|
| 952 | the | 
|---|
| 953 | .Dq make | 
|---|
| 954 | expression is applied. | 
|---|
| 955 | .Pp | 
|---|
| 956 | If the conditional evaluates to true the parsing of the makefile continues | 
|---|
| 957 | as before. | 
|---|
| 958 | If it evaluates to false, the following lines are skipped. | 
|---|
| 959 | In both cases this continues until a | 
|---|
| 960 | .Ql Ic .else | 
|---|
| 961 | or | 
|---|
| 962 | .Ql Ic .endif | 
|---|
| 963 | is found. | 
|---|
| 964 | .Pp | 
|---|
| 965 | For loops are typically used to apply a set of rules to a list of files. | 
|---|
| 966 | The syntax of a for loop is: | 
|---|
| 967 | .Pp | 
|---|
| 968 | .Bl -tag -width indent -compact | 
|---|
| 969 | .It Ic .for Ar variable Ic in Ar expression | 
|---|
| 970 | .It <make-rules> | 
|---|
| 971 | .It Ic \&.endfor | 
|---|
| 972 | .El | 
|---|
| 973 | .Pp | 
|---|
| 974 | After the for | 
|---|
| 975 | .Ar expression | 
|---|
| 976 | is evaluated, it is split into words. | 
|---|
| 977 | The | 
|---|
| 978 | iteration | 
|---|
| 979 | .Ar variable | 
|---|
| 980 | is successively set to each word, and substituted in the | 
|---|
| 981 | .Ic make-rules | 
|---|
| 982 | inside the body of the for loop. | 
|---|
| 983 | .Sh COMMENTS | 
|---|
| 984 | Comments begin with a hash | 
|---|
| 985 | .Pq Ql \&# | 
|---|
| 986 | character, anywhere but in a shell | 
|---|
| 987 | command line, and continue to the end of the line. | 
|---|
| 988 | .Sh SPECIAL SOURCES | 
|---|
| 989 | .Bl -tag -width Ic | 
|---|
| 990 | .It Ic .IGNORE | 
|---|
| 991 | Ignore any errors from the commands associated with this target, exactly | 
|---|
| 992 | as if they all were preceded by a dash | 
|---|
| 993 | .Pq Ql \- . | 
|---|
| 994 | .It Ic .MAKE | 
|---|
| 995 | Execute the commands associated with this target even if the | 
|---|
| 996 | .Fl n | 
|---|
| 997 | or | 
|---|
| 998 | .Fl t | 
|---|
| 999 | options were specified. | 
|---|
| 1000 | Normally used to mark recursive | 
|---|
| 1001 | .Nm Ns 's . | 
|---|
| 1002 | .It Ic .NOTMAIN | 
|---|
| 1003 | Normally | 
|---|
| 1004 | .Nm | 
|---|
| 1005 | selects the first target it encounters as the default target to be built | 
|---|
| 1006 | if no target was specified. | 
|---|
| 1007 | This source prevents this target from being selected. | 
|---|
| 1008 | .It Ic .OPTIONAL | 
|---|
| 1009 | If a target is marked with this attribute and | 
|---|
| 1010 | .Nm | 
|---|
| 1011 | can't figure out how to create it, it will ignore this fact and assume | 
|---|
| 1012 | the file isn't needed or already exists. | 
|---|
| 1013 | .It Ic .PRECIOUS | 
|---|
| 1014 | When | 
|---|
| 1015 | .Nm | 
|---|
| 1016 | is interrupted, it removes any partially made targets. | 
|---|
| 1017 | This source prevents the target from being removed. | 
|---|
| 1018 | .It Ic .SILENT | 
|---|
| 1019 | Do not echo any of the commands associated with this target, exactly | 
|---|
| 1020 | as if they all were preceded by an at sign | 
|---|
| 1021 | .Pq Ql @ . | 
|---|
| 1022 | .It Ic .USE | 
|---|
| 1023 | Turn the target into | 
|---|
| 1024 | .Nm Ns 's | 
|---|
| 1025 | version of a macro. | 
|---|
| 1026 | When the target is used as a source for another target, the other target | 
|---|
| 1027 | acquires the commands, sources, and attributes (except for | 
|---|
| 1028 | .Ic .USE ) | 
|---|
| 1029 | of the | 
|---|
| 1030 | source. | 
|---|
| 1031 | If the target already has commands, the | 
|---|
| 1032 | .Ic .USE | 
|---|
| 1033 | target's commands are appended | 
|---|
| 1034 | to them. | 
|---|
| 1035 | .It Ic .WAIT | 
|---|
| 1036 | If special | 
|---|
| 1037 | .Ic .WAIT | 
|---|
| 1038 | source is appears in a dependency line, the sources that precede it are | 
|---|
| 1039 | made before the sources that succeed it in the line. | 
|---|
| 1040 | Loops are not being | 
|---|
| 1041 | detected and targets that form loops will be silently ignored. | 
|---|
| 1042 | .El | 
|---|
| 1043 | .Sh "SPECIAL TARGETS" | 
|---|
| 1044 | Special targets may not be included with other targets, i.e. they must be | 
|---|
| 1045 | the only target specified. | 
|---|
| 1046 | .Bl -tag -width Ic | 
|---|
| 1047 | .It Ic .BEGIN | 
|---|
| 1048 | Any command lines attached to this target are executed before anything | 
|---|
| 1049 | else is done. | 
|---|
| 1050 | .It Ic .DEFAULT | 
|---|
| 1051 | This is sort of a | 
|---|
| 1052 | .Ic .USE | 
|---|
| 1053 | rule for any target (that was used only as a | 
|---|
| 1054 | source) that | 
|---|
| 1055 | .Nm | 
|---|
| 1056 | can't figure out any other way to create. | 
|---|
| 1057 | Only the shell script is used. | 
|---|
| 1058 | The | 
|---|
| 1059 | .Ic .IMPSRC | 
|---|
| 1060 | variable of a target that inherits | 
|---|
| 1061 | .Ic .DEFAULT Ns 's | 
|---|
| 1062 | commands is set | 
|---|
| 1063 | to the target's own name. | 
|---|
| 1064 | .It Ic .END | 
|---|
| 1065 | Any command lines attached to this target are executed after everything | 
|---|
| 1066 | else is done. | 
|---|
| 1067 | .It Ic .IGNORE | 
|---|
| 1068 | Mark each of the sources with the | 
|---|
| 1069 | .Ic .IGNORE | 
|---|
| 1070 | attribute. | 
|---|
| 1071 | If no sources are specified, this is the equivalent of specifying the | 
|---|
| 1072 | .Fl i | 
|---|
| 1073 | option. | 
|---|
| 1074 | .It Ic .INCLUDES | 
|---|
| 1075 | A list of suffixes that indicate files that can be included in a source | 
|---|
| 1076 | file. | 
|---|
| 1077 | The suffix must have already been declared with | 
|---|
| 1078 | .Ic .SUFFIXES ; | 
|---|
| 1079 | any suffix so declared will have the directories on its search path (see | 
|---|
| 1080 | .Ic .PATH ) | 
|---|
| 1081 | placed in the | 
|---|
| 1082 | .Va .INCLUDES | 
|---|
| 1083 | special variable, each preceded by a | 
|---|
| 1084 | .Fl I | 
|---|
| 1085 | flag. | 
|---|
| 1086 | .It Ic .INTERRUPT | 
|---|
| 1087 | If | 
|---|
| 1088 | .Nm | 
|---|
| 1089 | is interrupted, the commands for this target will be executed. | 
|---|
| 1090 | .It Ic .LIBS | 
|---|
| 1091 | This does for libraries what | 
|---|
| 1092 | .Ic .INCLUDES | 
|---|
| 1093 | does for include files, except that the flag used is | 
|---|
| 1094 | .Fl L . | 
|---|
| 1095 | .It Ic .MAIN | 
|---|
| 1096 | If no target is specified when | 
|---|
| 1097 | .Nm | 
|---|
| 1098 | is invoked, this target will be built. | 
|---|
| 1099 | This is always set, either | 
|---|
| 1100 | explicitly, or implicitly when | 
|---|
| 1101 | .Nm | 
|---|
| 1102 | selects the default target, to give the user a way to refer to the default | 
|---|
| 1103 | target on the command line. | 
|---|
| 1104 | .It Ic .MAKEFLAGS | 
|---|
| 1105 | This target provides a way to specify flags for | 
|---|
| 1106 | .Nm | 
|---|
| 1107 | when the makefile is used. | 
|---|
| 1108 | The flags are as if typed to the shell, though the | 
|---|
| 1109 | .Fl f | 
|---|
| 1110 | option will have | 
|---|
| 1111 | no effect. | 
|---|
| 1112 | .\" XXX: NOT YET!!!! | 
|---|
| 1113 | .\" .It Ic .NOTPARALLEL | 
|---|
| 1114 | .\" The named targets are executed in non parallel mode. If no targets are | 
|---|
| 1115 | .\" specified, then all targets are executed in non parallel mode. | 
|---|
| 1116 | .It Ic .NOTPARALLEL | 
|---|
| 1117 | Disable parallel mode. | 
|---|
| 1118 | .It Ic .NO_PARALLEL | 
|---|
| 1119 | Same as above, for compatibility with other pmake variants. | 
|---|
| 1120 | .It Ic .ORDER | 
|---|
| 1121 | The named targets are made in sequence. | 
|---|
| 1122 | .\" XXX: NOT YET!!!! | 
|---|
| 1123 | .\" .It Ic .PARALLEL | 
|---|
| 1124 | .\" The named targets are executed in parallel mode. If no targets are | 
|---|
| 1125 | .\" specified, then all targets are executed in parallel mode. | 
|---|
| 1126 | .It Ic .PATH | 
|---|
| 1127 | The sources are directories which are to be searched for files not | 
|---|
| 1128 | found in the current directory. | 
|---|
| 1129 | If no sources are specified, any previously specified directories are | 
|---|
| 1130 | deleted. | 
|---|
| 1131 | Where possible, use of | 
|---|
| 1132 | .Ic .PATH | 
|---|
| 1133 | is preferred over use of the | 
|---|
| 1134 | .Va VPATH | 
|---|
| 1135 | variable. | 
|---|
| 1136 | .It Ic .PATH\fIsuffix\fR | 
|---|
| 1137 | The sources are directories which are to be searched for suffixed files | 
|---|
| 1138 | not found in the current directory. | 
|---|
| 1139 | The | 
|---|
| 1140 | .Nm | 
|---|
| 1141 | utility | 
|---|
| 1142 | first searches the suffixed search path, before reverting to the default | 
|---|
| 1143 | path if the file is not found there. | 
|---|
| 1144 | This form is required for | 
|---|
| 1145 | .Ic .LIBS | 
|---|
| 1146 | and | 
|---|
| 1147 | .Ic .INCLUDES | 
|---|
| 1148 | to work. | 
|---|
| 1149 | .It Ic .PHONY | 
|---|
| 1150 | Apply the | 
|---|
| 1151 | .Ic .PHONY | 
|---|
| 1152 | attribute to any specified sources. | 
|---|
| 1153 | Targets with this attribute are always | 
|---|
| 1154 | considered to be out of date. | 
|---|
| 1155 | .It Ic .PRECIOUS | 
|---|
| 1156 | Apply the | 
|---|
| 1157 | .Ic .PRECIOUS | 
|---|
| 1158 | attribute to any specified sources. | 
|---|
| 1159 | If no sources are specified, the | 
|---|
| 1160 | .Ic .PRECIOUS | 
|---|
| 1161 | attribute is applied to every | 
|---|
| 1162 | target in the file. | 
|---|
| 1163 | .It Ic .SILENT | 
|---|
| 1164 | Apply the | 
|---|
| 1165 | .Ic .SILENT | 
|---|
| 1166 | attribute to any specified sources. | 
|---|
| 1167 | If no sources are specified, the | 
|---|
| 1168 | .Ic .SILENT | 
|---|
| 1169 | attribute is applied to every | 
|---|
| 1170 | command in the file. | 
|---|
| 1171 | .It Ic .SUFFIXES | 
|---|
| 1172 | Each source specifies a suffix to | 
|---|
| 1173 | .Nm . | 
|---|
| 1174 | If no sources are specified, any previous specified suffices are deleted. | 
|---|
| 1175 | .El | 
|---|
| 1176 | .Sh COMPATIBILITY | 
|---|
| 1177 | Older versions of | 
|---|
| 1178 | .Nm | 
|---|
| 1179 | used | 
|---|
| 1180 | .Ev MAKE | 
|---|
| 1181 | instead of | 
|---|
| 1182 | .Ev MAKEFLAGS . | 
|---|
| 1183 | This was removed for POSIX compatibility. | 
|---|
| 1184 | The internal variable | 
|---|
| 1185 | .Va MAKE | 
|---|
| 1186 | is set to the same value as | 
|---|
| 1187 | .Va .MAKE ; | 
|---|
| 1188 | support for this may be removed in the future. | 
|---|
| 1189 | .Pp | 
|---|
| 1190 | Most of the more esoteric features of | 
|---|
| 1191 | .Nm | 
|---|
| 1192 | should probably be avoided for greater compatibility. | 
|---|
| 1193 | .Sh ENVIRONMENT | 
|---|
| 1194 | The | 
|---|
| 1195 | .Nm | 
|---|
| 1196 | utility uses the following environment variables, if they exist: | 
|---|
| 1197 | .Ev MACHINE , | 
|---|
| 1198 | .Ev MAKE , | 
|---|
| 1199 | .Ev MAKEFLAGS , | 
|---|
| 1200 | .Ev MAKEOBJDIR , | 
|---|
| 1201 | .Ev MAKEOBJDIRPREFIX , | 
|---|
| 1202 | and | 
|---|
| 1203 | .Ev PWD . | 
|---|
| 1204 | .Sh FILES | 
|---|
| 1205 | .Bl -tag -width /usr/share/doc/psd/12.make -compact | 
|---|
| 1206 | .It Pa .depend | 
|---|
| 1207 | list of dependencies | 
|---|
| 1208 | .It Pa Makefile | 
|---|
| 1209 | list of dependencies | 
|---|
| 1210 | .It Pa makefile | 
|---|
| 1211 | list of dependencies | 
|---|
| 1212 | .It obj | 
|---|
| 1213 | object directory | 
|---|
| 1214 | .It Pa sys.mk | 
|---|
| 1215 | system makefile (processed before any other file, including | 
|---|
| 1216 | .Pa makefile | 
|---|
| 1217 | and | 
|---|
| 1218 | .Pa Makefile ) | 
|---|
| 1219 | .It Pa /usr/share/mk | 
|---|
| 1220 | system makefile directory | 
|---|
| 1221 | .It /usr/share/doc/psd/12.make | 
|---|
| 1222 | PMake tutorial | 
|---|
| 1223 | .It Pa /usr/obj | 
|---|
| 1224 | default | 
|---|
| 1225 | .Ev MAKEOBJDIRPREFIX | 
|---|
| 1226 | directory. | 
|---|
| 1227 | .El | 
|---|
| 1228 | .Sh BUGS | 
|---|
| 1229 | The determination of | 
|---|
| 1230 | .Va .OBJDIR | 
|---|
| 1231 | is contorted to the point of absurdity. | 
|---|
| 1232 | .Pp | 
|---|
| 1233 | In the presence of several | 
|---|
| 1234 | .Ic .MAIN | 
|---|
| 1235 | special targets, | 
|---|
| 1236 | .Nm | 
|---|
| 1237 | silently ignores all but the first. | 
|---|
| 1238 | .Pp | 
|---|
| 1239 | .Va .TARGETS | 
|---|
| 1240 | is not set to the default target when | 
|---|
| 1241 | .Nm | 
|---|
| 1242 | is invoked without a target name and no | 
|---|
| 1243 | .Ic .MAIN | 
|---|
| 1244 | special target exists. | 
|---|
| 1245 | .Pp | 
|---|
| 1246 | The evaluation of | 
|---|
| 1247 | .Ar expression | 
|---|
| 1248 | in a test is very simple-minded. | 
|---|
| 1249 | Currently, the only form that works is | 
|---|
| 1250 | .Ql .if ${VAR} op something | 
|---|
| 1251 | For instance, you should write tests as | 
|---|
| 1252 | .Ql .if ${VAR} = "string" | 
|---|
| 1253 | not the other way around, which doesn't work. | 
|---|
| 1254 | .Pp | 
|---|
| 1255 | For loops are expanded before tests, so a fragment such as: | 
|---|
| 1256 | .Bd -literal | 
|---|
| 1257 | \&.for TMACHINE in ${SHARED_ARCHS} | 
|---|
| 1258 | \&.if ${TMACHINE} = ${MACHINE} | 
|---|
| 1259 | ... | 
|---|
| 1260 | \&.endif | 
|---|
| 1261 | \&.endfor | 
|---|
| 1262 | .Ed | 
|---|
| 1263 | won't work, and should be rewritten the other way around. | 
|---|
| 1264 | .Sh SEE ALSO | 
|---|
| 1265 | .Xr mkdep 1 , | 
|---|
| 1266 | .Xr make.conf 5 | 
|---|
| 1267 | .Rs | 
|---|
| 1268 | .%T "PMake - A Tutorial" | 
|---|
| 1269 | .Re | 
|---|
| 1270 | in | 
|---|
| 1271 | .Pa /usr/share/doc/psd/12.make | 
|---|
| 1272 | .Sh HISTORY | 
|---|
| 1273 | A | 
|---|
| 1274 | .Nm | 
|---|
| 1275 | command appeared in | 
|---|
| 1276 | .At v7 . | 
|---|