jcs's openbsd hax
openbsd
at jcs 1736 lines 43 kB view raw
1.\" $OpenBSD: make.1,v 1.142 2025/11/27 09:08:49 tb Exp $ 2.\" $NetBSD: make.1,v 1.18 1997/03/10 21:19:53 christos Exp $ 3.\" 4.\" Copyright (c) 1990, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 32.\" 33.Dd $Mdocdate: November 27 2025 $ 34.Dt MAKE 1 35.Os 36.Sh NAME 37.Nm make 38.Nd maintain program dependencies 39.Sh SYNOPSIS 40.Nm make 41.Op Fl BeiknpqrSst 42.Op Fl C Ar directory 43.Op Fl D Ar variable 44.Op Fl d Ar flags 45.Op Fl f Ar mk 46.Op Fl I Ar directory 47.Op Fl j Ar max_jobs 48.Op Fl m Ar directory 49.Op Fl V Ar variable 50.Op Ar NAME Ns = Ns Ar value ... 51.Bk -words 52.Op Ar target ... 53.Ek 54.Sh DESCRIPTION 55.Nm 56is a program designed to simplify the maintenance of other programs. 57Its input is a 58.Em makefile : 59a list of specifications (target rules) describing build 60relationships between programs and other files. 61By default, the file 62.Pa makefile 63is used; 64if no such file is found, it tries 65.Pa Makefile . 66If neither of these exist, 67.Nm 68can still rely on a set of built-in system rules. 69.Pp 70If the file 71.Sq Pa .depend 72exists, it will also be read after the main 73.Ar makefile 74(see 75.Xr mkdep 1 ) . 76.Pp 77The handling of 78.Sq Pa .depend 79is a 80.Bx 81extension. 82.Pp 83If a list of 84.Ar target ... 85is specified, 86.Nm 87will build those targets. 88Otherwise a default target will be built: 89either a target explicitly marked with 90.Ic .MAIN 91or the first target encountered in the 92.Em makefile . 93.Pp 94Standard options are as follows: 95.Bl -tag -width Ds 96.It Fl e 97Environment variables override macro assignments within 98makefiles. 99.It Fl f Ar mk 100Read file 101.Ar mk 102instead of the default makefile. 103If 104.Ar mk 105is 106.Ql \- , 107standard input is used. 108Multiple makefiles may be specified, and are read in the order specified. 109.It Fl i 110Ignore non-zero exit of shell commands in the makefile. 111Equivalent to specifying 112.Ql \- 113before each command line in the makefile. 114.It Fl k 115Continue processing after errors are encountered, but only on those targets 116that do not depend on the target whose creation caused the error. 117.It Fl n 118Display the commands that would have been executed, but do not actually 119execute them. 120.It Fl p 121Print a dump of the target rules and variables on stdout. 122Do not build anything. 123.It Fl q 124Do not execute any commands, but exit with status 0 if the specified targets 125are up to date, and 1 otherwise. 126.It Fl r 127Do not use the built-in rules specified in the system makefile, 128.Pa <sys.mk> . 129.It Fl S 130Stop processing when an error is encountered. 131This is the default behavior. 132This is needed to negate the 133.Fl k 134option during recursive builds. 135.It Fl s 136Do not echo commands as they are executed. 137Equivalent to specifying 138.Sq Ic @ 139before each command line in the makefile. 140.It Fl t 141Rather than re-building a target as specified in the makefile, create it 142or update its modification time to make it appear up to date, a bit like 143.Xr touch 1 . 144.It Ar NAME Ns = Ns Ar value 145Set the value of the variable 146.Ar NAME 147to 148.Ar value . 149.El 150.Pp 151Extended options are as follows: 152.Bl -tag -width Ds 153.It Fl B 154Try to be backwards compatible by executing the commands to make 155the prerequisites in a target rule in sequence. 156This is the default, in the absence of 157.Fl j Ar max_jobs . 158.It Fl C Ar directory 159Enter 160.Ar directory 161before doing anything. 162.It Fl D Ar variable 163Define 164.Ar variable 165to be 1. 166.It Fl d Ar flags 167Turn on debugging, and specify which portions of 168.Nm 169are to print debugging information. 170.Ar flags 171is one or more of the following: 172.Bl -tag -width Ds 173.It Ar A 174Print all possible debugging information; 175equivalent to specifying all of the debugging flags. 176.It Ar a 177Print debugging information about archive searching and caching. 178.It Ar c 179Print debugging information about conditional evaluation. 180.It Ar d 181Print debugging information about directory searching and caching. 182.It Ar D 183Print warning messages about multiply defined command lists. 184.It Ar e 185Print debugging information about expensive command heuristics. 186.It Ar f 187Print debugging information about the expansion of for loops. 188.It Ar "g1" 189Print the input graph before making anything. 190.It Ar "g2" 191Print the input graph after making everything, or before exiting 192on error. 193.It Ar h 194Print information about jobs being held back because of sibling/target 195groups races. 196.It Ar j 197Print debugging information about forking processes to run commands. 198.It Ar k 199Print debugging information about manually killing processes. 200.It Ar l 201Print commands in Makefile targets regardless of whether or not they are 202prefixed by @. 203Also known as loud behavior. 204.It Ar m 205Print debugging information about making targets, including modification 206dates. 207.It Ar n 208Print debugging information about target names equivalence computations. 209.It Ar p 210Help finding concurrency issues for parallel make by adding some 211randomization. 212If 213.Va RANDOM_ORDER 214is defined, 215targets will be shuffled before being built. 216If 217.Va RANDOM_DELAY 218is defined, 219.Nm 220will wait between 0 and ${RANDOM_DELAY} seconds before starting a command. 221A given random seed can be forced by setting 222.Va RANDOM_SEED , 223but this does not guarantee reproducibility. 224.It Ar q 225.Sq quick death 226option: after a fatal error, instead of waiting for other jobs to die, 227kill them right away. 228.It Ar s 229Print debugging information about inference (suffix) transformation rules. 230.It Ar t 231Print debugging information about target list maintenance. 232.It Ar T 233Print debugging information about target group determination. 234.It Ar v 235Print debugging information about variable assignment. 236.El 237.It Fl I Ar directory 238Specify a directory in which to search for makefiles and 239for "..."-style inclusions. 240Multiple directories can be added to form a search path. 241Furthermore, the system include path (see the 242.Fl m 243option) will be used after this search path. 244.It Fl j Ar max_jobs 245Specify the maximum number of jobs that 246.Nm 247may have running at any one time. 248See the discussion about recursive invocations under 249.Sx BUGS . 250.It Fl m Ar directory 251Specify a directory in which to search for system include files: 252.Pa sys.mk 253and <...>-style inclusions. 254Multiple directories can be added to form the system search path. 255Using 256.Fl m 257will override the default system include directory 258.Pa /usr/share/mk . 259.It Fl V Ar variable 260Print 261.Nm make Ns 's 262idea of the value of 263.Ar variable . 264Do not build any targets. 265Multiple instances of this option may be specified; 266the variables will be printed one per line, 267with a blank line for each null or undefined variable. 268.El 269.Pp 270There are seven different types of lines in a makefile: dependency 271lines, shell commands, variable assignments, include statements, 272conditional directives, for loops, and comments. 273Of these, include statements, conditional directives and for loops are 274extensions. 275.Pp 276A complete target rule is composed of a dependency line, 277followed by a list of shell commands. 278.Pp 279In general, lines may be continued from one line to the next by ending 280them with a backslash 281.Pq Ql \e . 282The trailing newline character and initial whitespace on the following 283line are compressed into a single space. 284.Sh DEPENDENCY LINES 285Dependency lines consist of one or more targets, an operator, and zero 286or more prerequisites: 287.Bd -ragged -offset indent 288.Ar target ... : Ns Op Ar prerequisite ... 289.Ed 290.Pp 291This creates a relationship where the targets 292.Dq depend 293on the prerequisites and are usually built from them. 294The exact relationship between targets and prerequisites is determined 295by the operator that separates them. 296.Pp 297It is an error to use different dependency operators for the same target. 298.Pp 299The operators are as follows: 300.Bl -tag -width flag 301.It Ic \&: 302A target is considered out of date if any of its prerequisites has 303been modified more recently than the target (that is, its modification time 304is less than that of any of its prerequisites). 305Thus, targets with no prerequisites are always out of date. 306.Pp 307.Nm 308will then execute the list of shell commands associated with that target. 309.Pp 310Additional prerequisites may be specified over additional dependency lines: 311.Nm 312will consider all prerequisites for determining out-of-date status. 313The target is removed if 314.Nm 315is interrupted. 316.It Ic \&! 317.Nm 318first examines all prerequisites and re-creates them as necessary. 319.Pp 320It will then always execute the list of shell commands associated with 321that target (as if the target always was out of date). 322.Pp 323Like 324.Ic \&: , 325additional prerequisites may be specified over additional dependency lines, 326and the target is still removed if 327.Nm 328is interrupted. 329.It Ic \&:: 330Each dependency line for a target is considered independently. 331A target is considered out of date for this target rule if any of its 332prerequisites in this dependency has been modified more recently than 333the target. 334.Pp 335.Nm 336will then execute the list of shell commands associated with that target. 337Target rules that specify no prerequisites are always executed. 338.Pp 339The target will not be removed if 340.Nm 341is interrupted. 342.El 343.Pp 344The 345.Ic \&: 346operator is the only standard operator. 347The 348.Ic \&:: 349operator is a fairly standard extension, 350popularized by 351.Sy imake . 352The 353.Ic !\& 354operator is a 355.Bx 356extension. 357.Pp 358As an extension, targets and prerequisites may contain the shell wildcard 359expressions 360.Ql \&? , 361.Ql * , 362.Ql [] 363and 364.Ql {} . 365The expressions 366.Ql \&? , 367.Ql * 368and 369.Ql [] 370may only be used as part of the final 371component of the target or prerequisite, and must be used to describe existing 372files. 373The expression 374.Ql {} 375need not necessarily be used to describe existing files. 376Expansion is in directory order, not alphabetically as done in the shell. 377.Pp 378For maximum portability, target names should only consist of periods, 379underscores, digits and alphabetic characters. 380.Pp 381The use of several targets can be a shorthand for duplicate rules. 382Specifically, 383.Bd -literal -offset indent 384target1 target2: reqa reqa 385 cmd1 386 cmd2 387.Ed 388.Pp 389may be replaced with 390.Bd -literal -offset indent 391target1: reqa reqa 392 cmd1 393 cmd2 394target2: reqa reqa 395 cmd1 396 cmd2 397.Ed 398.Pp 399in general. 400But 401.Nm 402is aware of parallel issues, and will not build those targets concurrently, 403if not appropriate. 404.Sh SHELL COMMANDS 405Each target may have associated with it a series of shell commands, normally 406used to build the target. 407While several dependency lines may name the same target, only one of 408these dependency lines should be followed by shell commands, and thus 409define a complete target rule (unless the 410.Sq Ic :: 411operator is used). 412Each of the shell commands in the target rule 413.Em must 414be preceded by a tab. 415.Pp 416If a command line begins with a combination of the characters, 417.Sq Ic @ , 418.Sq Ic \- 419and/or 420.Sq Ic + , 421the command is treated specially: 422.Bl -tag -width `@' 423.It Sq Ic @ 424causes the command not to be echoed before it is executed. 425.It Sq Ic \- 426causes any non-zero exit status of the command line to be ignored. 427.It Sq Ic + 428causes the command to be executed even if 429.Fl n 430has been specified. 431(This can be useful to debug recursive Makefiles.) 432.El 433.Pp 434Commands are executed using 435.Pa /bin/sh 436in 437.Qq set -e 438mode, unless 439.Sq Ic \- 440is specified. 441.Pp 442As an optimization, 443.Nm 444may execute very simple commands without going through an extra shell 445process, as long as this does not change observable behavior. 446.Sh INFERENCE RULES 447.Nm 448also maintains a list of valid suffixes through the use of the 449.Ic .SUFFIXES 450special target. 451.Pp 452These suffixes can be used to write generic transformation rules called 453inference rules. 454.Pp 455If a target has the form 456.Sq \&.s1.s2 , 457where .s1 and .s2 are currently valid suffixes, then it defines a 458transformation from *.s1 to *.s2 (double suffix inference). 459If a target has the form 460.Sq \&.s1 , 461where .s1 is a currently valid suffix, then it defines a 462transformation from *.s1 to * (single suffix inference). 463.Pp 464A complete inference rule is a dependency line with such a target, the 465normal dependency operator, no prerequisites and a list of shell commands. 466.Pp 467When 468.Nm 469requires a target for which it has no complete target rule, it will try 470to apply a single active inference rule to create the target. 471.Pp 472For instance, with the following Makefile, describing a C program compiled 473from sources a.c and b.c, with header file a.h: 474.Bd -literal -offset indent 475\&.SUFFIXES: .c .o 476\&.c.o: 477 ${CC} ${CFLAGS} -c $< 478 479prog: a.o b.o 480 ${CC} ${CFLAGS} -o $@ a.o b.o 481 482a.o b.o: a.h 483 484b.o: b.c 485 ${CC} -DFOO ${CFLAGS} -o $@ $< 486.Ed 487.Pp 488Consider b.o: 489there is a complete target rule re-creating it from b.c, so 490it will be compiled using ${CC} -DFOO. 491.Pp 492Consider a.o: 493there is no explicit target rule, so 494.Nm 495will consider valid transforms. 496Fortunately, there is an inference rule that can create a.o from a.c, 497so it will be compiled using ${CC}. 498.Pp 499Note that extra prerequisites are still taken into account, so both a.o 500and b.o depend on a.h for re-creation. 501.Pp 502Valid suffixes accumulate over 503.Ic .SUFFIXES 504lines. 505An empty 506.Ic .SUFFIXES 507can be used to reset the currently valid list of suffixes, 508but inference rules already read are still known by 509.Nm , 510and they are marked as inactive. 511Redefining the corresponding suffix (or suffixes) will reactivate the rule. 512.Pp 513In case of duplicate inference rules with the same suffix combination, 514the new rule overrides the old one. 515.Pp 516For maximal portability, suffixes should start with a dot. 517.Sh VARIABLE ASSIGNMENTS 518Variables in 519.Nm 520are much like variables in the shell and, by tradition, 521consist of all upper-case letters. 522They are also called 523.Sq macros 524in various texts. 525For portability, only periods, underscores, digits and letters should be 526used for variable names. 527The following operators can be used to assign values to variables: 528.Bl -tag -width Ds 529.It Ic \&= 530Assign the value to the variable. 531Any previous value is overridden. 532.It Ic \&:= 533Assign with expansion, i.e., expand the value before assigning it 534to the variable (extension). 535.It Ic \&+= 536Append the value to the current value of the variable (extension). 537.It Ic \&?= 538Assign the value to the variable if it is not already defined 539.Po 540.Bx 541extension 542.Pc . 543Normally, expansion is not done until the variable is referenced. 544.It Ic \&!= 545Perform variable expansion and pass the result to the shell for 546execution on the spot, assigning the result to the variable. 547Any newlines in the result are also replaced with spaces 548.Po 549.Bx 550extension 551.Pc . 552.It Ic \&!!= 553Perform variable expansion on the spot and pass the result to the shell 554for execution only when the value is needed, assigning the result to 555the variable. 556.Pp 557This is almost identical to 558.Ic \&!= 559except that a shell is only run when the variable value is needed. 560Any newlines in the result are also replaced with spaces 561.Po 562.Ox 563extension 564.Pc . 565.El 566.Pp 567Any whitespace before the assigned 568.Ar value 569is removed; if the value is being appended, a single space is inserted 570between the previous contents of the variable and the appended value. 571.Pp 572Several extended assignment operators may be combined together. 573For instance, 574.Bd -literal -offset indent 575A ?!= cmd 576.Ed 577.Pp 578will only run 579.Qq cmd 580and put its output into 581.Va A 582if 583.Va A 584is not yet defined. 585.Pp 586Combinations that do not make sense, such as 587.Bd -literal -offset indent 588A +!!= cmd 589.Ed 590.Pp 591will not work. 592.Pp 593Variables are expanded by surrounding the variable name with either 594curly braces 595.Pq Ql {} 596or parentheses 597.Pq Ql () 598and preceding it with 599a dollar sign 600.Pq Ql \&$ . 601If the variable name contains only a single letter, the surrounding 602braces or parentheses are not required. 603This shorter form is not recommended. 604.Pp 605Variable substitution occurs at distinct times, depending on the type of line. 606Variables in dependency lines, conditional directives and include statements 607are expanded as the line is read. 608Variables in shell commands are expanded when the shell command is 609executed. 610.Pp 611The four different classes of variables (in order of increasing precedence) 612are: 613.Bl -tag -width Ds 614.It Environment variables 615Variables defined as part of 616.Nm make Ns 's 617environment. 618.It Global variables 619Variables defined in the makefile or in included makefiles. 620.It Command line variables 621Variables defined as part of the command line. 622.It Local variables 623Variables that are defined specific to a certain target. 624Standard local variables are as follows: 625.Bl -tag -width ".ARCHIVE" 626.It Va @ 627The name of the target. 628.It Va \&% 629The name of the archive member (only valid for library rules). 630.It Va \&! 631The name of the archive file (only valid for library rules). 632.It Va \&? 633The list of prerequisites for this target that were deemed out of date. 634.It Va \&< 635The name of the prerequisite from which this target is to be built, if a valid 636inference rule (suffix rule) is in scope. 637.It Va * 638The file prefix of the file, containing only the file portion, 639no suffix or preceding directory components. 640.El 641.Pp 642Those variables 643.Po 644and 645.Va \&> 646.Pc 647may be suffixed with a 648.Sq D 649or a 650.Sq F , 651to yield the filename or directory part of the corresponding variables, e.g., 652.Sq ${ Ns Va @F Ns } 653is equivalent 654to 655.Sq ${@:T} 656and 657.Sq ${ Ns Va @D Ns } 658is equivalent to 659.Sq ${@:H} . 660.Pp 661For maximum compatibility, 662.Sq Va \&< 663should only be used for actual inference rules. 664It is also set for normal target rules when there is an inference rule 665that matches the current target and prerequisite in scope. 666That is, in 667.Bd -literal -offset indent 668\&.SUFFIXES: .c .o 669file.o: file.c 670 cmd1 $< 671 672\&.c.o: 673 cmd2 674.Ed 675.Pp 676building 677.Pa file.o 678will execute 679.Qq cmd1 file.c . 680.Pp 681As an extension, 682.Nm 683supports the following local variables: 684.Bl -tag -width ".ARCHIVE" 685.It Va \&> 686The list of all prerequisites for this target. 687.It Va .ALLSRC 688Synonym for 689.Sq Va \&> . 690.It Va .ARCHIVE 691Synonym for 692.Sq Va \&! . 693.It Va .IMPSRC 694Synonym for 695.Sq Va \&< . 696.It Va .MEMBER 697Synonym for 698.Sq Va \&% . 699.It Va .OODATE 700Synonym for 701.Sq Va \&? . 702.It Va .PREFIX 703Synonym for 704.Sq Va * . 705.It Va .TARGET 706Synonym for 707.Sq Va @ . 708.El 709.Pp 710These variables may be used on the dependency half of dependency 711lines, when they make sense. 712.El 713.Pp 714In addition, 715.Nm 716sets or knows about the following internal variables, or environment 717variables: 718.Bl -tag -width MAKEFLAGS 719.It Va \&$ 720A single dollar sign 721.Ql \&$ , 722i.e., 723.Ql \&$$ 724expands to a single dollar 725sign. 726.It Va .MAKE 727The name that 728.Nm 729was executed with 730.Pq Va argv Ns Op 0 . 731.It Va .CURDIR 732A path to the directory where 733.Nm 734was executed. 735.It Va .OBJDIR 736Path to the directory where targets are built. 737At startup, 738.Nm 739searches for an alternate directory to place target files. 740.Nm 741tries to 742.Xr chdir 2 743into 744.Ev MAKEOBJDIR 745(or 746.Pa obj 747if 748.Ev MAKEOBJDIR 749is not defined), 750and sets 751.Va .OBJDIR 752accordingly. 753Should that fail, 754.Va .OBJDIR 755is set to 756.Va .CURDIR . 757.It Va MAKEFILE_LIST 758The list of files read by 759.Nm . 760.It Va .MAKEFLAGS 761The environment variable 762.Ev MAKEFLAGS 763may contain anything that 764may be specified on 765.Nm make Ns 's 766command line. 767Its contents are stored in 768.Nm make Ns 's 769.Va .MAKEFLAGS 770variable. 771Anything specified on 772.Nm make Ns 's 773command line is appended to the 774.Va .MAKEFLAGS 775variable which is then 776entered into the environment as 777.Ev MAKEFLAGS 778for all programs which 779.Nm 780executes. 781.It Va MFLAGS 782A shorter synonym for 783.Va .MAKEFLAGS . 784.It Ev PWD 785Alternate path to the current directory. 786.Nm 787normally sets 788.Sq Va .CURDIR 789to the canonical path given by 790.Xr getcwd 3 . 791However, if the environment variable 792.Ev PWD 793is set and gives a path to the current directory, then 794.Nm 795sets 796.Sq Va .CURDIR 797to the value of 798.Ev PWD 799instead. 800.Ev PWD 801is always set to the value of 802.Sq Va .OBJDIR 803for all programs which 804.Nm 805executes. 806.It Va .TARGETS 807List of targets 808.Nm 809is currently building. 810.It Va MACHINE 811Name of the machine architecture 812.Nm 813is running on, obtained from the 814.Ev MACHINE 815environment variable, or through 816.Xr uname 3 817if not defined. 818.It Va MACHINE_ARCH 819Name of the machine architecture 820.Nm 821was compiled for, obtained from the 822.Ev MACHINE_ARCH 823environment variable, or defined at compilation time. 824.It Va MACHINE_CPU 825Name of the machine processor 826.Nm 827was compiled for, obtained from the 828.Ev MACHINE_CPU 829environment variable, or defined at compilation time. 830On processors where only one endianness is possible, the value of this 831variable is always the same as 832.Ev MACHINE_ARCH . 833.It Va MAKEFILE 834Possibly the file name of the last makefile that has been read. 835It should not be used; see the 836.Sx BUGS 837section below. 838.It Va .VARIABLES 839List of all the names of global variables that have been set. 840.El 841.Pp 842Variable expansion may be modified to select or modify each word of the 843variable (where 844.Dq word 845is a whitespace delimited sequence of characters). 846The general format of a variable expansion is as follows: 847.Pp 848.Dl {variable[:modifier[:...]]} 849.Pp 850Each modifier begins with a colon and one of the following 851special characters. 852The colon may be escaped with a backslash 853.Pq Ql \e . 854.Bl -tag -width Ds 855.It Cm :E 856Replaces each word in the variable with its suffix. 857.It Cm :H 858Replaces each word in the variable with everything but the last component. 859.It Cm :L 860Replaces each word in the variable with its lower case equivalent. 861.It Cm :U 862Replaces each word in the variable with its upper case equivalent. 863.It Cm :M Ns Ar pattern 864Select only those words that match the rest of the modifier. 865The standard shell wildcard characters 866.Pf ( Ql * , 867.Ql \&? , 868and 869.Ql [] ) 870may 871be used. 872The wildcard characters may be escaped with a backslash 873.Pq Ql \e . 874.It Cm :N Ns Ar pattern 875This is identical to 876.Cm :M , 877but selects all words which do not match 878the rest of the modifier. 879.It Cm :Q 880Quotes every shell meta-character in the variable, so that it can be passed 881safely through recursive invocations of 882.Nm make . 883.It Cm :QL 884Quote list: quotes every shell meta-character in the variable, except 885whitespace, so that it can be passed to a shell's 886.Sq for 887loops. 888.It Cm :R 889Replaces each word in the variable with everything but its suffix. 890.Sm off 891.It Cm :S No \&/ Ar old_string Xo 892.No \&/ Ar new_string 893.No \&/ Op Cm 1g 894.Xc 895.Sm on 896Modify the first occurrence of 897.Ar old_string 898in the variable's value, replacing it with 899.Ar new_string . 900If a 901.Ql g 902is appended to the last slash of the pattern, all occurrences 903in each word are replaced. 904If a 905.Ql 1 906is appended to the last slash of the pattern, only the first word 907is affected. 908If 909.Ar old_string 910begins with a caret 911.Pq Ql ^ , 912.Ar old_string 913is anchored at the beginning of each word. 914If 915.Ar old_string 916ends with a dollar sign 917.Pq Ql \&$ , 918it is anchored at the end of each word. 919Inside 920.Ar new_string , 921an ampersand 922.Pq Ql & 923is replaced by 924.Ar old_string 925(without any 926.Ql ^ 927or 928.Ql \&$ ) . 929Any character may be used as a delimiter for the parts of the modifier 930string. 931The anchoring, ampersand and delimiter characters may be escaped with a 932backslash 933.Pq Ql \e . 934.Pp 935Variable expansion occurs in the normal fashion inside both 936.Ar old_string 937and 938.Ar new_string 939with the single exception that a backslash is used to prevent the expansion 940of a dollar sign 941.Pq Ql \&$ , 942not a preceding dollar sign as is usual. 943.Sm off 944.It Cm :C No \&/ Ar pattern Xo 945.No \&/ Ar replacement 946.No \&/ Op Cm 1g 947.Xc 948.Sm on 949The 950.Cm :C 951modifier is just like the 952.Cm :S 953modifier except that the old and new strings, instead of being 954simple strings, are an extended regular expression (see 955.Xr re_format 7 ) 956and an 957.Xr ed 1 Ns \-style 958replacement string. 959Normally, the first occurrence of the pattern in 960each word of the value is changed. 961The 962.Ql 1 963modifier causes the substitution to apply to at most one word; the 964.Ql g 965modifier causes the substitution to apply to as many instances of the 966search pattern as occur in the word or words it is found in. 967Note that 968.Ql 1 969and 970.Ql g 971are orthogonal; the former specifies whether multiple words are 972potentially affected, the latter whether multiple substitutions can 973potentially occur within each affected word. 974.It Cm :T 975Replaces each word in the variable with its last component. 976.It Ar :old_string Ns = Ns Ar new_string 977This is the 978.At V 979style variable substitution. 980It must be the last modifier specified. 981If 982.Ar old_string 983or 984.Ar new_string 985do not contain the pattern matching character 986.Sq % 987then it is assumed that they are 988anchored at the end of each word, so only suffixes or entire 989words may be replaced. 990Otherwise 991.Sq % 992is the substring of 993.Ar old_string 994to be replaced in 995.Ar new_string . 996The right hand side 997.Pq Ar new_string 998may contain variable values, which will be expanded. 999To put an actual single dollar, just double it. 1000.El 1001.Pp 1002All modifiers are 1003.Bx 1004extensions, except for the standard 1005.At V 1006style variable substitution. 1007.Pp 1008The interpretation of 1009.Sq % 1010and 1011.Sq $ 1012in 1013.At V 1014variable substitutions is not mandated by POSIX, though it is 1015fairly common. 1016.Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS 1017Makefile inclusion, conditional structures and for loops reminiscent 1018of the C programming language are provided in 1019.Nm make . 1020All such structures are identified by a line beginning with a single 1021dot 1022.Pq Ql \&. 1023character. 1024Whitespace characters may follow this dot, e.g., 1025.Bd -literal -offset indent 1026\&.include <file> 1027.Ed 1028and 1029.Bd -literal -offset indent -compact 1030\&. include <file> 1031.Ed 1032.Pp 1033are identical constructs. 1034Files are included with either 1035.Ql .include <file> 1036or 1037.Ql .include Qq file . 1038Variables between the angle brackets or double quotes are expanded 1039to form the file name. 1040If angle brackets are used, the included makefile is expected to be in 1041the system makefile directory. 1042If double quotes are used, the including makefile's directory and any 1043directories specified using the 1044.Fl I 1045option are searched before the system 1046makefile directory. 1047.Pp 1048Conditional expressions are also preceded by a single dot as the first 1049character of a line. 1050The possible conditionals are as follows: 1051.Bl -tag -width Ds 1052.It Ic .undef Ar variable 1053Un-define the specified global variable. 1054Only global variables may be un-defined. 1055.It Ic .poison Ar variable 1056Poison the specified global variable. 1057Any further reference to 1058.Ar variable 1059will be flagged as an error. 1060.It Ic .poison !defined Pq Ar variable 1061It is an error to try to use the value of 1062.Ar variable 1063in a context where it is not defined. 1064.It Ic .poison empty Pq Ar variable 1065It is an error to try to use the value of 1066.Ar variable 1067in a context where it is not defined or is empty. 1068.It Xo 1069.Ic \&.if 1070.Oo \&! Oc Ns Ar expression 1071.Op Ar operator expression ... 1072.Xc 1073Test the value of an expression. 1074.It Xo 1075.Ic .ifdef 1076.Oo \&! Oc Ns Ar variable 1077.Op Ar operator variable ... 1078.Xc 1079Test the value of a variable. 1080.It Xo 1081.Ic .ifndef 1082.Oo \&! Oc Ns Ar variable 1083.Op Ar operator variable ... 1084.Xc 1085Test the value of a variable. 1086.It Xo 1087.Ic .ifmake 1088.Oo \&! Oc Ns Ar target 1089.Op Ar operator target ... 1090.Xc 1091Test the target being built. 1092.It Xo 1093.Ic .ifnmake 1094.Oo \&! Oc Ns Ar target 1095.Op Ar operator target ... 1096.Xc 1097Test the target being built. 1098.It Ic .else 1099Reverse the sense of the last conditional. 1100.It Xo 1101.Ic .elif 1102.Oo \&! Oc Ns Ar expression 1103.Op Ar operator expression ... 1104.Xc 1105A combination of 1106.Sq Ic .else 1107followed by 1108.Sq Ic .if . 1109.It Xo 1110.Ic .elifdef 1111.Oo \&! Oc Ns Ar variable 1112.Op Ar operator variable ... 1113.Xc 1114A combination of 1115.Sq Ic .else 1116followed by 1117.Sq Ic .ifdef . 1118.It Xo 1119.Ic .elifndef 1120.Oo \&! Oc Ns Ar variable 1121.Op Ar operator variable ... 1122.Xc 1123A combination of 1124.Sq Ic .else 1125followed by 1126.Sq Ic .ifndef . 1127.It Xo 1128.Ic .elifmake 1129.Oo \&! Oc Ns Ar target 1130.Op Ar operator target ... 1131.Xc 1132A combination of 1133.Sq Ic .else 1134followed by 1135.Sq Ic .ifmake . 1136.It Xo 1137.Ic .elifnmake 1138.Oo \&! Oc Ns Ar target 1139.Op Ar operator target ... 1140.Xc 1141A combination of 1142.Sq Ic .else 1143followed by 1144.Sq Ic .ifnmake . 1145.It Ic .endif 1146End the body of the conditional. 1147.El 1148.Pp 1149The 1150.Ar operator 1151may be any one of the following: 1152.Bl -tag -width "Cm XX" 1153.It Cm || 1154logical OR 1155.It Cm \&&& 1156Logical AND; of higher precedence than 1157.Cm || . 1158.El 1159.Pp 1160As in C, 1161.Nm 1162will only evaluate a conditional as far as is necessary to determine 1163its value. 1164Parentheses may be used to change the order of evaluation. 1165The boolean operator 1166.Sq Ic \&! 1167may be used to logically negate an entire 1168conditional. 1169It is of higher precedence than 1170.Sq Ic \&&& . 1171.Pp 1172The value of 1173.Ar expression 1174may be any of the following: 1175.Bl -tag -width commands 1176.It Ic commands 1177Takes a target name as an argument and evaluates to true if the target 1178has been defined and has shell commands associated with it. 1179.It Ic defined 1180Takes a variable name as an argument and evaluates to true if the variable 1181has been defined. 1182.It Ic make 1183Takes a target name as an argument and evaluates to true if the target 1184was specified as part of 1185.Nm make Ns 's 1186command line or was declared the default target (either implicitly or 1187explicitly, see 1188.Va .MAIN ) 1189before the line containing the conditional. 1190.It Ic empty 1191Takes a variable, with possible modifiers, and evaluates to true if 1192the expansion of the variable would result in an empty string. 1193.It Ic exists 1194Takes a file name as an argument and evaluates to true if the file exists. 1195The file is searched for on the system search path (see 1196.Va .PATH ) . 1197.It Ic target 1198Takes a target name as an argument and evaluates to true if the target 1199has been defined. 1200.El 1201.Pp 1202.Ar expression 1203may also be an arithmetic or string comparison. 1204Variable expansion is 1205performed on both sides of the comparison, after which the integral 1206values are compared. 1207A value is interpreted as hexadecimal if it is 1208preceded by 0x, otherwise it is decimal; octal numbers are not supported. 1209The standard C relational operators are all supported. 1210If after 1211variable expansion, either the left or right hand side of a 1212.Sq Ic == 1213or 1214.Sq Ic "!=" 1215operator is not an integral value, then 1216string comparison is performed between the expanded 1217variables. 1218If no relational operator is given, it is assumed that the expanded 1219variable is being compared against 0. 1220.Pp 1221When 1222.Nm 1223is evaluating one of these conditional expressions, and it encounters 1224a word it doesn't recognize, either the 1225.Dq make 1226or 1227.Dq defined 1228expression is applied to it, depending on the form of the conditional. 1229If the form is 1230.Sq Ic .ifdef 1231or 1232.Sq Ic .ifndef , 1233the 1234.Dq defined 1235expression is applied. 1236Similarly, if the form is 1237.Sq Ic .ifmake 1238or 1239.Sq Ic .ifnmake , 1240the 1241.Dq make 1242expression is applied. 1243.Pp 1244If the conditional evaluates to true, the parsing of the makefile continues 1245as before. 1246If it evaluates to false, the following lines are skipped. 1247In both cases this continues until a 1248.Sq Ic .else 1249or 1250.Sq Ic .endif 1251is found. 1252.Pp 1253For loops are typically used to apply a set of rules to a list of files. 1254The syntax of a for loop is: 1255.Bd -unfilled -offset indent 1256.Ic .for Ar variable Oo Ar variable ... Oc Ic in Ar expression 1257 <make-rules> 1258.Ic .endfor 1259.Ed 1260.Pp 1261After the for 1262.Ar expression 1263is evaluated, it is split into words. 1264On each iteration of the loop, one word is assigned to each 1265.Ar variable , 1266in order, 1267and these 1268.Ar variables 1269are substituted in the 1270.Ic make-rules 1271inside the body of the for loop. 1272The number of words must match the number of iteration variables; 1273that is, if there are three iteration variables, the number of words 1274must be a multiple of three. 1275.Pp 1276Loops and conditional expressions may nest arbitrarily, but 1277they may not cross include file boundaries. 1278.Pp 1279.Nm 1280also supports 1281.Ic sinclude 1282and 1283.Ic -include 1284for compatibility with other implementations. 1285Both use the same syntax: 1286.Bd -unfilled -offset indent 1287.Ic sinclude Pa file 1288.Ic -include Pa file 1289.Ed 1290.Pp 1291.Po 1292note no quotes around 1293.Pa file 1294.Pc 1295and will include 1296.Pa file , 1297but without any error if it does not exist. 1298.Sh COMMENTS 1299Comments begin with a hash 1300.Pq Ql \&# 1301character, anywhere but in a shell 1302command line, and continue to the end of the line 1303(but a 1304.Pq Ql \&# 1305character in a shell command line will be interpreted as a comment by 1306the shell). 1307.Sh TARGET ATTRIBUTES 1308Some targets may be tagged with some specific attributes by one 1309of the 1310.Sx SPECIAL TARGETS 1311or 1312.Sx SPECIAL PREREQUISITES 1313described below. 1314.Bl -tag -width "Ignoring errors" 1315.It Dq Always build 1316Run the commands associated with this target even if the 1317.Fl n 1318or 1319.Fl t 1320options were specified. 1321Can be used to mark recursive 1322.Nm make Ns 's , 1323but prefer standard 1324.Sq Ic + Ns Ar cmd . 1325.It Dq Cheap 1326In parallel mode, don't scan the commands for occurrences of 1327.Nm , 1328thus letting normal recursive 1329.Fl j 1330behavior apply. 1331.It Dq Expensive 1332In parallel mode, assume commands will invoke recursive commands. 1333Once 1334.Nm 1335starts building an expensive target, it won't start building anything else 1336until that target has finished building. 1337.It Dq Ignoring errors 1338Ignore any errors generating by running shell commands, exactly 1339as if they were all preceded by a dash 1340.Pq Ql \- . 1341.It Dq Phony 1342A phony target is a target that does not correspond to any object in the 1343file system (more like a placeholder for a list of commands). 1344.Pp 1345Phony targets are always out of date at the start of a run, but 1346.Nm 1347still keeps track of when they are built (that is, when the associated 1348command list finishes running). 1349.It Dq Precious 1350Don't remove the target if 1351.Nm 1352is interrupted in the middle of building it. 1353.It Dq Silent 1354Do not display shell commands before running them, exactly as 1355if they were all preceded by a 1356.Sq @ . 1357.El 1358.Sh SPECIAL TARGETS 1359.Nm 1360recognizes standard special targets: 1361.Bl -tag -width ".NOTPARALLEL" 1362.It Ic .DEFAULT 1363If there is a 1364.Ic .DEFAULT 1365target rule, with commands but no prerequisites, and 1366.Nm 1367can't figure out another way to build a target, it will use that 1368list of commands, setting 1369.Va \&< 1370and 1371.Va @ 1372appropriately. 1373.It Ic .IGNORE 1374Mark its prerequisites as 1375.Dq Ignoring errors . 1376.Pp 1377If the list of prerequisites is empty, apply that to all targets, exactly 1378like the 1379.Fl i 1380command-line option. 1381.It Ic .PRECIOUS 1382Mark its prerequisites as 1383.Dq Precious . 1384.Pp 1385If the list of prerequisites is empty, apply that to all targets. 1386.It Ic .SILENT 1387Mark its prerequisites as 1388.Dq Silent . 1389.Pp 1390If the list of prerequisites is empty, apply that to all targets, exactly 1391like the 1392.Fl s 1393command-line option. 1394.It Ic .SUFFIXES 1395See 1396.Sx INFERENCE RULES . 1397.El 1398.Pp 1399and also some other special targets as an extension: 1400.Bl -tag -width ".NOTPARALLEL" 1401.It Ic .BEGIN 1402Command lines attached to this target are executed before anything 1403else is done. 1404.It Ic .CHEAP 1405Mark its prerequisites as 1406.Dq Cheap . 1407.It Ic .END 1408Command lines attached to this target are executed at the end of a successful 1409run. 1410.It Ic .EXPENSIVE 1411Mark its prerequisites as 1412.Dq Expensive . 1413.It Ic .INTERRUPT 1414Command lines attached to this target are executed if 1415.Nm 1416is interrupted by a SIGINT. 1417.It Ic .MAKE 1418Mark its prerequisites as 1419.Dq Always build . 1420Prefer standard 1421.Sq Ic + Ns Ar cmd . 1422.It Ic .MAIN 1423If no target is specified when 1424.Nm 1425is invoked, this target will be built. 1426This is always set, either 1427explicitly, or implicitly when 1428.Nm 1429selects the default target, to give the user a way to refer to the default 1430target on the command line. 1431.It Ic .MAKEFLAGS 1432This target provides a way to specify flags for 1433.Nm 1434when the makefile is used. 1435The flags are as if typed to the shell, though the 1436.Fl f 1437option will have 1438no effect. 1439.It Ic .NOTPARALLEL 1440Disable parallel mode for the current makefile. 1441The 1442.Fl j 1443option is still passed to submakes. 1444.It Ic .NO_PARALLEL 1445Same as above, for compatibility with other pmake variants. 1446.It Ic .ORDER 1447The list of prerequisites should be built in sequence. 1448.It Ic .PATH 1449The prerequisites define a search path: directories that will be searched 1450for files not found in the current directory. 1451If no prerequisites are specified, any previously specified directories are 1452deleted. 1453.It Ic .PATH\fI.suffix\fR 1454This target is only valid if .suffix is a currently valid suffix. 1455The prerequisites defines a search path for files ending in that suffix. 1456For files not found in the current directory, 1457.Nm 1458will first look in that path, before reverting to the default search path. 1459.It Ic .PHONY 1460Mark its prerequisites as 1461.Dq Phony 1462targets. 1463.El 1464.Pp 1465It is an error to use several special targets, or a special target and 1466normal targets, in a single dependency line. 1467.Sh SPECIAL PREREQUISITES 1468Of the special targets described in the previous 1469section, the ones that tag prerequisites can also be used as prerequisites, 1470in which case the corresponding targets will be tagged accordingly. 1471.Pp 1472This is an extension, even for standard special targets. 1473.Pp 1474.Nm 1475also recognizes some other prerequisites: 1476.Bl -tag -width ".PRECIOUS" 1477.It Ic .NOTMAIN 1478Normally 1479.Nm 1480selects the first target it encounters as the default target to be built 1481if no target was specified. 1482This prerequisite prevents this target from being selected. 1483.It Ic .OPTIONAL 1484If a target is marked with this attribute and 1485.Nm 1486can't figure out how to create it, it will ignore this fact and assume 1487the file isn't needed or already exists. 1488.It Ic .USE 1489Turn the target into 1490.Nm make Ns 's 1491version of a macro. 1492When the target is used as a prerequisite for another target, the other target 1493acquires the commands, prerequisites, and attributes (except for 1494.Ic .USE ) 1495of the 1496prerequisite. 1497If the target already has commands, the 1498.Ic .USE 1499target's commands are appended 1500to them. 1501.It Ic .WAIT 1502If 1503.Ic .WAIT 1504appears in a dependency line, the prerequisites that precede it are 1505made before the prerequisites that follow it in the line. 1506Loops are not 1507detected and targets that form loops will be silently ignored. 1508.El 1509.Sh ENVIRONMENT 1510.Nm 1511uses the following environment variables, if they exist: 1512.Ev MACHINE , 1513.Ev MACHINE_ARCH , 1514.Ev MACHINE_CPU , 1515.Ev MAKEFLAGS , 1516.Ev MAKEOBJDIR 1517and 1518.Ev PWD . 1519.Nm 1520also ignores and unsets 1521.Ev CDPATH . 1522.Sh FILES 1523.Bl -tag -width /usr/share/mk -compact 1524.It Pa .depend 1525list of dependencies 1526.It Pa makefile 1527default makefile 1528.It Pa Makefile 1529default makefile if 1530.Pa makefile 1531does not exist 1532.It Pa sys.mk 1533system makefile 1534.It Pa /usr/share/mk 1535system makefile directory 1536.El 1537.Sh EXIT STATUS 1538If 1539.Fl q 1540was specified, the 1541.Nm 1542utility exits with one of the following values: 1543.Pp 1544.Bl -tag -width Ds -offset indent -compact 1545.It 0 1546Normal behavior. 1547.It 1 1548The target was not up to date. 1549.It >1 1550An error occurred. 1551.El 1552.Pp 1553Otherwise, the 1554.Nm 1555utility exits with a value of 0 on success, and >0 if an error occurred. 1556.Sh SEE ALSO 1557.Xr ed 1 , 1558.Xr mkdep 1 , 1559.Xr sh 1 , 1560.Xr getcwd 3 , 1561.Xr uname 3 , 1562.Xr re_format 7 1563.Rs 1564.%A S. I. Feldman 1565.%T Make \(em A Program for Maintaining Computer Programs 1566.\".%R Computing Science Technical Report 1567.\".%N 57 1568.%J Software \(em Practice and Experience 1569.%V 9:4 1570.%P pp. 255-265 1571.%D April 1979 1572.Re 1573.Rs 1574.\" 4.4BSD PSD:12 1575.%A Adam de Boor 1576.%T PMake \(em A Tutorial 1577.%B 4.4BSD Programmer's Supplementary Documents (PSD) 1578.Re 1579.Sh STANDARDS 1580The 1581.Nm 1582utility is mostly compliant with the 1583.St -p1003.1-2008 1584specification, 1585though its presence is optional. 1586.Pp 1587The flags 1588.Op Fl BCDdIjmV 1589are extensions to that specification. 1590.Pp 1591Older versions of 1592.Nm 1593used 1594.Ev MAKE 1595instead of 1596.Ev MAKEFLAGS . 1597This was removed for POSIX compatibility. 1598The internal variable 1599.Va MAKE 1600is set to the same value as 1601.Va .MAKE . 1602Support for this may be removed in the future. 1603.Pp 1604Most of the more esoteric features of 1605.Nm 1606should probably be avoided for greater compatibility. 1607.Sh HISTORY 1608A 1609.Nm 1610command first appeared outside of Bell Labs in PWB/UNIX 1.0. 1611It was replaced in 1612.Bx 4.3 Reno . 1613.Sh AUTHORS 1614.An Stuart Feldman 1615wrote the original implementation at the 1616Bell Labs Computing Science Research Center. 1617.Pp 1618This implementation is a distant derivative of 1619.Nm pmake , 1620originally written by Adam de Boor for the Sprite operating system. 1621.Sh BUGS 1622If the same target is specified several times in complete target rules, 1623.Nm 1624silently ignores all commands after the first non empty set of commands, 1625e.g., in 1626.Bd -literal -offset indent 1627a: 1628 @echo "Executed" 1629a: 1630 @echo "Bad luck" 1631.Ed 1632.Pp 1633@echo "Bad luck" will be ignored. 1634.Pp 1635.Va .TARGETS 1636is not set to the default target when 1637.Nm 1638is invoked without a target name and no 1639.Ic MAIN 1640special target exists. 1641.Pp 1642The evaluation of 1643.Ar expression 1644in a test is somewhat simplistic. 1645Variables don't need to be quoted, but strings do: 1646Tests like 1647.Ql .if ${VAR} == "string" , 1648.Ql .if ${VAR} >= 5 , 1649.Ql .if 5 <= 10 , 1650and 1651.Ql .if "string" == ${VAR} 1652do work, but 1653.Ql .if string = ${VAR} 1654doesn't. 1655.Pp 1656For loops are expanded before tests, so a fragment such as: 1657.Bd -literal -offset indent 1658\&.for TMACHINE in ${SHARED_ARCHS} 1659\&.if "${TMACHINE}" == ${MACHINE} 1660 ... 1661\&.endif 1662\&.endfor 1663.Ed 1664.Pp 1665requires the quotes. 1666.Pp 1667When handling 1668.Pf pre- Bx 4.4 1669archives, 1670.Nm 1671may erroneously mark archive members as out of date if the archive name 1672was truncated. 1673.Pp 1674The handling of 1675.Sq ;\& 1676and other special characters in tests may be utterly bogus. 1677For instance, in 1678.Bd -literal -offset indent 1679\&A=abcd;c.c 1680\&.if ${A:R} == "abcd;c" 1681.Ed 1682.Pp 1683the test will never match, even though the value is correct. 1684.Pp 1685In a .for loop, only the variable value is used; assignments will be 1686evaluated later, e.g., in 1687.Bd -literal -offset indent 1688\&.for I in a b c d 1689I:=${I:S/a/z/} 1690A+=$I 1691\&.endfor 1692.Ed 1693.Pp 1694.Sq A 1695will evaluate to a b c d after the loop, not z b c d. 1696.Pp 1697.Ic ORDER 1698is currently only used in parallel mode, so 1699keep prerequisites ordered for sequential mode! 1700.Pp 1701Distinct target names are treated separately, even though they might 1702correspond to the same file in the file system. 1703This can cause excessive rebuilds of some targets, and bogus 1704races in parallel mode. 1705This can also prevent 1706.Nm 1707from finding a rule to solve a dependency if the target name is not 1708exactly the same as the dependency. 1709.Pp 1710In parallel mode, 1711.Fl j Ar n 1712only limits the number of direct children of 1713.Nm . 1714During recursive invocations, each level may multiply the total number 1715of processes by 1716.Ar n . 1717However, 1718.Nm 1719includes some heuristics to try to prevent catastrophic behavior: 1720if a command is marked as expensive, or preceded by 1721.Sq + , 1722or seems to 1723invoke a program that looks sufficiently like 1724.Sq make , 1725.Nm 1726will assume recursive invocation, and not start any new process until 1727said command has finished running. 1728Thus the number of processes run directly or indirectly by 1729.Nm 1730will increase linearly with each level of recursion instead of exponentially. 1731.Pp 1732The 1733.Va MAKEFILE 1734variable cannot be used reliably. 1735It is a compatibility feature and may get set to the last makefile 1736specified, as it is set by System V make.