1.\" $NetBSD: make.1,v 1.160 2009/08/26 23:18:57 sjg Exp $ 2.\" 3.\" Copyright (c) 1990, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 31.\" 32.Dd August 26, 2009 33.Dt MAKE 1 34.Os 35.Sh NAME 36.Nm make 37.Nd maintain program dependencies 38.Sh SYNOPSIS 39.Nm 40.Op Fl BeikNnqrstWX 41.Bk -words 42.Op Fl C Ar directory 43.Ek 44.Bk -words 45.Op Fl D Ar variable 46.Ek 47.Bk -words 48.Op Fl d Ar flags 49.Ek 50.Bk -words 51.Op Fl f Ar makefile 52.Ek 53.Bk -words 54.Op Fl I Ar directory 55.Ek 56.Bk -words 57.Op Fl J Ar private 58.Ek 59.Bk -words 60.Op Fl j Ar max_jobs 61.Ek 62.Bk -words 63.Op Fl m Ar directory 64.Ek 65.Bk -words 66.Op Fl T Ar file 67.Ek 68.Bk -words 69.Op Fl V Ar variable 70.Ek 71.Op Ar variable=value 72.Bk -words 73.Op Ar target ... 74.Ek 75.Sh DESCRIPTION 76.Nm 77is a program designed to simplify the maintenance of other programs. 78Its input is a list of specifications as to the files upon which programs 79and other files depend. 80If no 81.Fl f Ar makefile 82makefile option is given, 83.Nm 84will try to open 85.Ql Pa makefile 86then 87.Ql Pa Makefile 88in order to find the specifications. 89If the file 90.Ql Pa .depend 91exists, it is read (see 92.Xr mkdep 1 ) . 93.Pp 94This manual page is intended as a reference document only. 95For a more thorough description of 96.Nm 97and makefiles, please refer to 98.%T "Make \- A Tutorial" . 99.Pp 100.Nm 101will prepend the contents of the 102.Va MAKEFLAGS 103environment variable to the command line arguments before parsing them. 104.Pp 105The options are as follows: 106.Bl -tag -width Ds 107.It Fl B 108Try to be backwards compatible by executing a single shell per command and 109by executing the commands to make the sources of a dependency line in sequence. 110.It Fl C Ar directory 111Change to 112.Ar directory 113before reading the makefiles or doing anything else. 114If multiple 115.Fl C 116options are specified, each is interpreted relative to the previous one: 117.Fl C Pa / Fl C Pa etc 118is equivalent to 119.Fl C Pa /etc . 120.It Fl D Ar variable 121Define 122.Ar variable 123to be 1, in the global context. 124.It Fl d Ar [-]flags 125Turn on debugging, and specify which portions of 126.Nm 127are to print debugging information. 128Unless the flags are preceded by 129.Ql - 130they are added to the 131.Va MAKEFLAGS 132environment variable and will be processed by any child make processes. 133By default, debugging information is printed to standard error, 134but this can be changed using the 135.Ar F 136debugging flag. 137The debugging output is always unbuffered; in addition, if debugging 138is enabled but debugging output is not directed to standard output, 139then the standard output is line buffered. 140.Ar Flags 141is one or more of the following: 142.Bl -tag -width Ds 143.It Ar A 144Print all possible debugging information; 145equivalent to specifying all of the debugging flags. 146.It Ar a 147Print debugging information about archive searching and caching. 148.It Ar C 149Print debugging information about current working directory. 150.It Ar c 151Print debugging information about conditional evaluation. 152.It Ar d 153Print debugging information about directory searching and caching. 154.It Ar e 155Print debugging information about failed commands and targets. 156.It Ar F Ns Oo Sy \&+ Oc Ns Ar filename 157Specify where debugging output is written. 158This must be the last flag, because it consumes the remainder of 159the argument. 160If the character immediately after the 161.Ql F 162flag is 163.Ql \&+ , 164then the file will be opened in append mode; 165otherwise the file will be overwritten. 166If the file name is 167.Ql stdout 168or 169.Ql stderr 170then debugging output will be written to the 171standard output or standard error output file descriptors respectively 172(and the 173.Ql \&+ 174option has no effect). 175Otherwise, the output will be written to the named file. 176If the file name ends 177.Ql .%d 178then the 179.Ql %d 180is replaced by the pid. 181.It Ar f 182Print debugging information about loop evaluation. 183.It Ar "g1" 184Print the input graph before making anything. 185.It Ar "g2" 186Print the input graph after making everything, or before exiting 187on error. 188.It Ar "g3" 189Print the input graph before exiting on error. 190.It Ar j 191Print debugging information about running multiple shells. 192.It Ar l 193Print commands in Makefiles regardless of whether or not they are prefixed by 194.Ql @ 195or other "quiet" flags. 196Also known as "loud" behavior. 197.It Ar m 198Print debugging information about making targets, including modification 199dates. 200.It Ar n 201Don't delete the temporary command scripts created when running commands. 202These temporary scripts are created in the directory 203referred to by the 204.Ev TMPDIR 205environment variable, or in 206.Pa /tmp 207if 208.Ev TMPDIR 209is unset or set to the empty string. 210The temporary scripts are created by 211.Xr mkstemp 3 , 212and have names of the form 213.Pa makeXXXXXX . 214.Em NOTE : 215This can create many files in 216.Ev TMPDIR 217or 218.Pa /tmp , 219so use with care. 220.It Ar p 221Print debugging information about makefile parsing. 222.It Ar s 223Print debugging information about suffix-transformation rules. 224.It Ar t 225Print debugging information about target list maintenance. 226.It Ar v 227Print debugging information about variable assignment. 228.It Ar x 229Run shell commands with 230.Fl x 231so the actual commands are printed as they are executed. 232.El 233.It Fl e 234Specify that environment variables override macro assignments within 235makefiles. 236.It Fl f Ar makefile 237Specify a makefile to read instead of the default 238.Ql Pa makefile . 239If 240.Ar makefile 241is 242.Ql Fl , 243standard input is read. 244Multiple makefiles may be specified, and are read in the order specified. 245.It Fl I Ar directory 246Specify a directory in which to search for makefiles and included makefiles. 247The system makefile directory (or directories, see the 248.Fl m 249option) is automatically included as part of this list. 250.It Fl i 251Ignore non-zero exit of shell commands in the makefile. 252Equivalent to specifying 253.Ql Fl 254before each command line in the makefile. 255.It Fl J Ar private 256This option should 257.Em not 258be specified by the user. 259.Pp 260When the 261.Ar j 262option is in use in a recursive build, this option is passed by a make 263to child makes to allow all the make processes in the build to 264cooperate to avoid overloading the system. 265.It Fl j Ar max_jobs 266Specify the maximum number of jobs that 267.Nm 268may have running at any one time. 269Turns compatibility mode off, unless the 270.Ar B 271flag is also specified. 272When compatibility mode is off, all commands associated with a 273target are executed in a single shell invocation as opposed to the 274traditional one shell invocation per line. 275This can break traditional scripts which change directories on each 276command invocation and then expect to start with a fresh environment 277on the next line. 278It is more efficient to correct the scripts rather than turn backwards 279compatibility on. 280.It Fl k 281Continue processing after errors are encountered, but only on those targets 282that do not depend on the target whose creation caused the error. 283.It Fl m Ar directory 284Specify a directory in which to search for sys.mk and makefiles included 285via the 286.Ao Ar file Ac Ns -style 287include statement. 288The 289.Fl m 290option can be used multiple times to form a search path. 291This path will override the default system include path: /usr/share/mk. 292Furthermore the system include path will be appended to the search path used 293for 294.Qo Ar file Qc Ns -style 295include statements (see the 296.Fl I 297option). 298.Pp 299If a file or directory name in the 300.Fl m 301argument (or the 302.Ev MAKESYSPATH 303environment variable) starts with the string 304.Qq \&.../ 305then 306.Nm 307will search for the specified file or directory named in the remaining part 308of the argument string. 309The search starts with the current directory of 310the Makefile and then works upward towards the root of the filesystem. 311If the search is successful, then the resulting directory replaces the 312.Qq \&.../ 313specification in the 314.Fl m 315argument. 316If used, this feature allows 317.Nm 318to easily search in the current source tree for customized sys.mk files 319(e.g., by using 320.Qq \&.../mk/sys.mk 321as an argument). 322.It Fl n 323Display the commands that would have been executed, but do not 324actually execute them unless the target depends on the .MAKE special 325source (see below). 326.It Fl N 327Display the commands which would have been executed, but do not 328actually execute any of them; useful for debugging top-level makefiles 329without descending into subdirectories. 330.It Fl q 331Do not execute any commands, but exit 0 if the specified targets are 332up-to-date and 1, otherwise. 333.It Fl r 334Do not use the built-in rules specified in the system makefile. 335.It Fl s 336Do not echo any commands as they are executed. 337Equivalent to specifying 338.Ql Ic @ 339before each command line in the makefile. 340.It Fl T Ar tracefile 341When used with the 342.Fl j 343flag, 344append a trace record to 345.Ar tracefile 346for each job started and completed. 347.It Fl t 348Rather than re-building a target as specified in the makefile, create it 349or update its modification time to make it appear up-to-date. 350.It Fl V Ar variable 351Print 352.Nm Ns 's 353idea of the value of 354.Ar variable , 355in the global context. 356Do not build any targets. 357Multiple instances of this option may be specified; 358the variables will be printed one per line, 359with a blank line for each null or undefined variable. 360If 361.Ar variable 362contains a 363.Ql \&$ 364then the value will be expanded before printing. 365.It Fl W 366Treat any warnings during makefile parsing as errors. 367.It Fl X 368Don't export variables passed on the command line to the environment 369individually. 370Variables passed on the command line are still exported 371via the 372.Va MAKEFLAGS 373environment variable. 374This option may be useful on systems which have a small limit on the 375size of command arguments. 376.It Ar variable=value 377Set the value of the variable 378.Ar variable 379to 380.Ar value . 381Normally, all values passed on the command line are also exported to 382sub-makes in the environment. 383The 384.Fl X 385flag disables this behavior. 386Variable assignments should follow options for POSIX compatibility 387but no ordering is enforced. 388.El 389.Pp 390There are seven different types of lines in a makefile: file dependency 391specifications, shell commands, variable assignments, include statements, 392conditional directives, for loops, and comments. 393.Pp 394In general, lines may be continued from one line to the next by ending 395them with a backslash 396.Pq Ql \e . 397The trailing newline character and initial whitespace on the following 398line are compressed into a single space. 399.Sh FILE DEPENDENCY SPECIFICATIONS 400Dependency lines consist of one or more targets, an operator, and zero 401or more sources. 402This creates a relationship where the targets 403.Dq depend 404on the sources 405and are usually created from them. 406The exact relationship between the target and the source is determined 407by the operator that separates them. 408The three operators are as follows: 409.Bl -tag -width flag 410.It Ic \&: 411A target is considered out-of-date if its modification time is less than 412those of any of its sources. 413Sources for a target accumulate over dependency lines when this operator 414is used. 415The target is removed if 416.Nm 417is interrupted. 418.It Ic \&! 419Targets are always re-created, but not until all sources have been 420examined and re-created as necessary. 421Sources for a target accumulate over dependency lines when this operator 422is used. 423The target is removed if 424.Nm 425is interrupted. 426.It Ic \&:: 427If no sources are specified, the target is always re-created. 428Otherwise, a target is considered out-of-date if any of its sources has 429been modified more recently than the target. 430Sources for a target do not accumulate over dependency lines when this 431operator is used. 432The target will not be removed if 433.Nm 434is interrupted. 435.El 436.Pp 437Targets and sources may contain the shell wildcard values 438.Ql \&? , 439.Ql * , 440.Ql [] , 441and 442.Ql {} . 443The values 444.Ql \&? , 445.Ql * , 446and 447.Ql [] 448may only be used as part of the final 449component of the target or source, and must be used to describe existing 450files. 451The value 452.Ql {} 453need not necessarily be used to describe existing files. 454Expansion is in directory order, not alphabetically as done in the shell. 455.Sh SHELL COMMANDS 456Each target may have associated with it a series of shell commands, normally 457used to create the target. 458Each of the commands in this script 459.Em must 460be preceded by a tab. 461While any target may appear on a dependency line, only one of these 462dependencies may be followed by a creation script, unless the 463.Ql Ic \&:: 464operator is used. 465.Pp 466If the first characters of the command line are any combination of 467.Ql Ic @ , 468.Ql Ic + , 469or 470.Ql Ic \- , 471the command is treated specially. 472A 473.Ql Ic @ 474causes the command not to be echoed before it is executed. 475A 476.Ql Ic + 477causes the command to be executed even when 478.Fl n 479is given. 480This is similar to the effect of the .MAKE special source, 481except that the effect can be limited to a single line of a script. 482A 483.Ql Ic \- 484causes any non-zero exit status of the command line to be ignored. 485.Sh VARIABLE ASSIGNMENTS 486Variables in make are much like variables in the shell, and, by tradition, 487consist of all upper-case letters. 488.Ss Variable assignment modifiers 489The five operators that can be used to assign values to variables are as 490follows: 491.Bl -tag -width Ds 492.It Ic \&= 493Assign the value to the variable. 494Any previous value is overridden. 495.It Ic \&+= 496Append the value to the current value of the variable. 497.It Ic \&?= 498Assign the value to the variable if it is not already defined. 499.It Ic \&:= 500Assign with expansion, i.e. expand the value before assigning it 501to the variable. 502Normally, expansion is not done until the variable is referenced. 503.Em NOTE : 504References to undefined variables are 505.Em not 506expanded. 507This can cause problems when variable modifiers are used. 508.It Ic \&!= 509Expand the value and pass it to the shell for execution and assign 510the result to the variable. 511Any newlines in the result are replaced with spaces. 512.El 513.Pp 514Any white-space before the assigned 515.Ar value 516is removed; if the value is being appended, a single space is inserted 517between the previous contents of the variable and the appended value. 518.Pp 519Variables are expanded by surrounding the variable name with either 520curly braces 521.Pq Ql {} 522or parentheses 523.Pq Ql () 524and preceding it with 525a dollar sign 526.Pq Ql \&$ . 527If the variable name contains only a single letter, the surrounding 528braces or parentheses are not required. 529This shorter form is not recommended. 530.Pp 531If the variable name contains a dollar, then the name itself is expanded first. 532This allows almost arbitrary variable names, however names containing dollar, 533braces, parenthesis, or whitespace are really best avoided! 534.Pp 535If the result of expanding a variable contains a dollar sign 536.Pq Ql \&$ 537the string is expanded again. 538.Pp 539Variable substitution occurs at two distinct times, depending on where 540the variable is being used. 541Variables in dependency lines are expanded as the line is read. 542Variables in shell commands are expanded when the shell command is 543executed. 544.Ss Variable classes 545The four different classes of variables (in order of increasing precedence) 546are: 547.Bl -tag -width Ds 548.It Environment variables 549Variables defined as part of 550.Nm Ns 's 551environment. 552.It Global variables 553Variables defined in the makefile or in included makefiles. 554.It Command line variables 555Variables defined as part of the command line. 556.It Local variables 557Variables that are defined specific to a certain target. 558The seven local variables are as follows: 559.Bl -tag -width ".ARCHIVE" 560.It Va .ALLSRC 561The list of all sources for this target; also known as 562.Ql Va \&\*[Gt] . 563.It Va .ARCHIVE 564The name of the archive file. 565.It Va .IMPSRC 566In suffix-transformation rules, the name/path of the source from which the 567target is to be transformed (the 568.Dq implied 569source); also known as 570.Ql Va \&\*[Lt] . 571It is not defined in explicit rules. 572.It Va .MEMBER 573The name of the archive member. 574.It Va .OODATE 575The list of sources for this target that were deemed out-of-date; also 576known as 577.Ql Va \&? . 578.It Va .PREFIX 579The file prefix of the file, containing only the file portion, no suffix 580or preceding directory components; also known as 581.Ql Va * . 582.It Va .TARGET 583The name of the target; also known as 584.Ql Va @ . 585.El 586.Pp 587The shorter forms 588.Ql Va @ , 589.Ql Va \&? , 590.Ql Va \&\*[Lt] , 591.Ql Va \&\*[Gt] , 592and 593.Ql Va * 594are permitted for backward 595compatibility with historical makefiles and are not recommended. 596The six variables 597.Ql Va "@F" , 598.Ql Va "@D" , 599.Ql Va "\*[Lt]F" , 600.Ql Va "\*[Lt]D" , 601.Ql Va "*F" , 602and 603.Ql Va "*D" 604are permitted for compatibility with 605.At V 606makefiles and are not recommended. 607.Pp 608Four of the local variables may be used in sources on dependency lines 609because they expand to the proper value for each target on the line. 610These variables are 611.Ql Va .TARGET , 612.Ql Va .PREFIX , 613.Ql Va .ARCHIVE , 614and 615.Ql Va .MEMBER . 616.El 617.Ss Additional built-in variables 618In addition, 619.Nm 620sets or knows about the following variables: 621.Bl -tag -width .MAKEOVERRIDES 622.It Va \&$ 623A single dollar sign 624.Ql \&$ , 625i.e. 626.Ql \&$$ 627expands to a single dollar 628sign. 629.It Va .ALLTARGETS 630The list of all targets encountered in the Makefile. 631If evaluated during 632Makefile parsing, lists only those targets encountered thus far. 633.It Va .CURDIR 634A path to the directory where 635.Nm 636was executed. 637Refer to the description of 638.Ql Ev PWD 639for more details. 640.It Ev MAKE 641The name that 642.Nm 643was executed with 644.Pq Va argv[0] . 645For compatibility 646.Nm 647also sets 648.Va .MAKE 649with the same value. 650The preferred variable to use is the environment variable 651.Ev MAKE 652because it is more compatible with other versions of 653.Nm 654and cannot be confused with the special target with the same name. 655.It Va .MAKE.EXPORTED 656The list of variables exported by 657.Nm . 658.It Va .MAKE.MAKEFILES 659The list of makefiles read by 660.Nm , 661which is useful for tracking dependencies. 662Each makefile is recorded only once, regardless of the number of times read. 663.It Va .MAKE.PID 664The process-id of 665.Nm . 666.It Va .MAKE.PPID 667The parent process-id of 668.Nm . 669.It Va .MAKE.JOB.PREFIX 670If 671.Nm 672is run with 673.Ar j 674then output for each target is prefixed with a token 675.Ql --- target --- 676the first part of which can be controlled via 677.Va .MAKE.JOB.PREFIX . 678.br 679For example: 680.Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}] 681would produce tokens like 682.Ql ---make[1234] target --- 683making it easier to track the degree of parallelism being achieved. 684.It Ev MAKEFLAGS 685The environment variable 686.Ql Ev MAKEFLAGS 687may contain anything that 688may be specified on 689.Nm Ns 's 690command line. 691Anything specified on 692.Nm Ns 's 693command line is appended to the 694.Ql Ev MAKEFLAGS 695variable which is then 696entered into the environment for all programs which 697.Nm 698executes. 699.It Va .MAKEOVERRIDES 700This variable is used to record the names of variables assigned to 701on the command line, so that they may be exported as part of 702.Ql Ev MAKEFLAGS . 703This behaviour can be disabled by assigning an empty value to 704.Ql Va .MAKEOVERRIDES 705within a makefile. 706Extra variables can be exported from a makefile 707by appending their names to 708.Ql Va .MAKEOVERRIDES . 709.Ql Ev MAKEFLAGS 710is re-exported whenever 711.Ql Va .MAKEOVERRIDES 712is modified. 713.It Va MAKE_PRINT_VAR_ON_ERROR 714When 715.Nm 716stops due to an error, it prints its name and the value of 717.Ql Va .CURDIR 718as well as the value of any variables named in 719.Ql Va MAKE_PRINT_VAR_ON_ERROR . 720.It Va .newline 721This variable is simply assigned a newline character as its value. 722This allows expansions using the 723.Cm \&:@ 724modifier to put a newline between 725iterations of the loop rather than a space. 726For example, the printing of 727.Ql Va MAKE_PRINT_VAR_ON_ERROR 728could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}. 729.It Va .OBJDIR 730A path to the directory where the targets are built. 731Its value is determined by trying to 732.Xr chdir 2 733to the following directories in order and using the first match: 734.Bl -enum 735.It 736.Ev ${MAKEOBJDIRPREFIX}${.CURDIR} 737.Pp 738(Only if 739.Ql Ev MAKEOBJDIRPREFIX 740is set in the environment or on the command line.) 741.It 742.Ev ${MAKEOBJDIR} 743.Pp 744(Only if 745.Ql Ev MAKEOBJDIR 746is set in the environment or on the command line.) 747.It 748.Ev ${.CURDIR} Ns Pa /obj. Ns Ev ${MACHINE} 749.It 750.Ev ${.CURDIR} Ns Pa /obj 751.It 752.Pa /usr/obj/ Ns Ev ${.CURDIR} 753.It 754.Ev ${.CURDIR} 755.El 756.Pp 757Variable expansion is performed on the value before it's used, 758so expressions such as 759.Dl ${.CURDIR:C,^/usr/src,/var/obj,} 760may be used. 761.Pp 762.Ql Va .OBJDIR 763may be modified in the makefile as a global variable. 764In all cases, 765.Nm 766will 767.Xr chdir 2 768to 769.Ql Va .OBJDIR 770and set 771.Ql Ev PWD 772to that directory before executing any targets. 773. 774.It Va .PARSEDIR 775A path to the directory of the current 776.Ql Pa Makefile 777being parsed. 778.It Va .PARSEFILE 779The basename of the current 780.Ql Pa Makefile 781being parsed. 782This variable and 783.Ql Va .PARSEDIR 784are both set only while the 785.Ql Pa Makefiles 786are being parsed. 787.It Va .PATH 788A variable that represents the list of directories that 789.Nm 790will search for files. 791The search list should be updated using the target 792.Ql Va .PATH 793rather than the variable. 794.It Ev PWD 795Alternate path to the current directory. 796.Nm 797normally sets 798.Ql Va .CURDIR 799to the canonical path given by 800.Xr getcwd 3 . 801However, if the environment variable 802.Ql Ev PWD 803is set and gives a path to the current directory, then 804.Nm 805sets 806.Ql Va .CURDIR 807to the value of 808.Ql Ev PWD 809instead. 810This behaviour is disabled if 811.Ql Ev MAKEOBJDIRPREFIX 812is set or 813.Ql Ev MAKEOBJDIR 814contains a variable transform. 815.Ql Ev PWD 816is set to the value of 817.Ql Va .OBJDIR 818for all programs which 819.Nm 820executes. 821.It Ev VPATH 822Colon-separated 823.Pq Dq \&: 824lists of directories that 825.Nm 826will search for files. 827The variable is supported for compatibility with old make programs only, 828use 829.Ql Va .PATH 830instead. 831.El 832.Ss Variable modifiers 833Variable expansion may be modified to select or modify each word of the 834variable (where a 835.Dq word 836is white-space delimited sequence of characters). 837The general format of a variable expansion is as follows: 838.Pp 839.Dl ${variable[:modifier[:...]]} 840.Pp 841Each modifier begins with a colon, 842which may be escaped with a backslash 843.Pq Ql \e . 844.Pp 845A set of modifiers can be specified via a variable, as follows: 846.Pp 847.Dl modifier_variable=modifier[:...] 848.Dl ${variable:${modifier_variable}[:...]} 849.Pp 850In this case the first modifier in the modifier_variable does not 851start with a colon, since that must appear in the referencing 852variable. 853If any of the modifiers in the modifier_variable contain a dollar sign 854.Pq Ql $ , 855these must be doubled to avoid early expansion. 856.Pp 857The supported modifiers are: 858.Bl -tag -width EEE 859.It Cm \&:E 860Replaces each word in the variable with its suffix. 861.It Cm \&:H 862Replaces each word in the variable with everything but the last component. 863.It Cm \&:M Ns Ar pattern 864Select only those words that match 865.Ar pattern . 866The standard shell wildcard characters 867.Pf ( Ql * , 868.Ql \&? , 869and 870.Ql Op ) 871may 872be used. 873The wildcard characters may be escaped with a backslash 874.Pq Ql \e . 875.It Cm \&:N Ns Ar pattern 876This is identical to 877.Ql Cm \&:M , 878but selects all words which do not match 879.Ar pattern . 880.It Cm \&:O 881Order every word in variable alphabetically. 882To sort words in 883reverse order use the 884.Ql Cm \&:O:[-1..1] 885combination of modifiers. 886.It Cm \&:Ox 887Randomize words in variable. 888The results will be different each time you are referring to the 889modified variable; use the assignment with expansion 890.Pq Ql Cm \&:= 891to prevent such behaviour. 892For example, 893.Bd -literal -offset indent 894LIST= uno due tre quattro 895RANDOM_LIST= ${LIST:Ox} 896STATIC_RANDOM_LIST:= ${LIST:Ox} 897 898all: 899 @echo "${RANDOM_LIST}" 900 @echo "${RANDOM_LIST}" 901 @echo "${STATIC_RANDOM_LIST}" 902 @echo "${STATIC_RANDOM_LIST}" 903.Ed 904may produce output similar to: 905.Bd -literal -offset indent 906quattro due tre uno 907tre due quattro uno 908due uno quattro tre 909due uno quattro tre 910.Ed 911.It Cm \&:Q 912Quotes every shell meta-character in the variable, so that it can be passed 913safely through recursive invocations of 914.Nm . 915.It Cm \&:R 916Replaces each word in the variable with everything but its suffix. 917.It Cm \&:tl 918Converts variable to lower-case letters. 919.It Cm \&:ts Ns Ar c 920Words in the variable are normally separated by a space on expansion. 921This modifier sets the separator to the character 922.Ar c . 923If 924.Ar c 925is omitted, then no separator is used. 926.It Cm \&:tu 927Converts variable to upper-case letters. 928.It Cm \&:tW 929Causes the value to be treated as a single word 930(possibly containing embedded white space). 931See also 932.Ql Cm \&:[*] . 933.It Cm \&:tw 934Causes the value to be treated as a sequence of 935words delimited by white space. 936See also 937.Ql Cm \&:[@] . 938.Sm off 939.It Cm \&:S No \&/ Ar old_string Xo 940.No \&/ Ar new_string 941.No \&/ Op Cm 1gW 942.Xc 943.Sm on 944Modify the first occurrence of 945.Ar old_string 946in the variable's value, replacing it with 947.Ar new_string . 948If a 949.Ql g 950is appended to the last slash of the pattern, all occurrences 951in each word are replaced. 952If a 953.Ql 1 954is appended to the last slash of the pattern, only the first word 955is affected. 956If a 957.Ql W 958is appended to the last slash of the pattern, 959then the value is treated as a single word 960(possibly containing embedded white space). 961If 962.Ar old_string 963begins with a caret 964.Pq Ql ^ , 965.Ar old_string 966is anchored at the beginning of each word. 967If 968.Ar old_string 969ends with a dollar sign 970.Pq Ql \&$ , 971it is anchored at the end of each word. 972Inside 973.Ar new_string , 974an ampersand 975.Pq Ql \*[Am] 976is replaced by 977.Ar old_string 978(without any 979.Ql ^ 980or 981.Ql \&$ ) . 982Any character may be used as a delimiter for the parts of the modifier 983string. 984The anchoring, ampersand and delimiter characters may be escaped with a 985backslash 986.Pq Ql \e . 987.Pp 988Variable expansion occurs in the normal fashion inside both 989.Ar old_string 990and 991.Ar new_string 992with the single exception that a backslash is used to prevent the expansion 993of a dollar sign 994.Pq Ql \&$ , 995not a preceding dollar sign as is usual. 996.Sm off 997.It Cm \&:C No \&/ Ar pattern Xo 998.No \&/ Ar replacement 999.No \&/ Op Cm 1gW 1000.Xc 1001.Sm on 1002The 1003.Cm \&:C 1004modifier is just like the 1005.Cm \&:S 1006modifier except that the old and new strings, instead of being 1007simple strings, are a regular expression (see 1008.Xr regex 3 ) 1009string 1010.Ar pattern 1011and an 1012.Xr ed 1 Ns \-style 1013string 1014.Ar replacement . 1015Normally, the first occurrence of the pattern 1016.Ar pattern 1017in each word of the value is substituted with 1018.Ar replacement . 1019The 1020.Ql 1 1021modifier causes the substitution to apply to at most one word; the 1022.Ql g 1023modifier causes the substitution to apply to as many instances of the 1024search pattern 1025.Ar pattern 1026as occur in the word or words it is found in; the 1027.Ql W 1028modifier causes the value to be treated as a single word 1029(possibly containing embedded white space). 1030Note that 1031.Ql 1 1032and 1033.Ql g 1034are orthogonal; the former specifies whether multiple words are 1035potentially affected, the latter whether multiple substitutions can 1036potentially occur within each affected word. 1037.It Cm \&:T 1038Replaces each word in the variable with its last component. 1039.It Cm \&:u 1040Remove adjacent duplicate words (like 1041.Xr uniq 1 ) . 1042.Sm off 1043.It Cm \&:\&? Ar true_string Cm \&: Ar false_string 1044.Sm on 1045If the variable name (not its value), when parsed as a .if conditional 1046expression, evaluates to true, return as its value the 1047.Ar true_string , 1048otherwise return the 1049.Ar false_string . 1050Since the variable name is used as the expression, \&:\&? must be the 1051first modifier after the variable name itself - which will, of course, 1052usually contain variable expansions. 1053If the expression is a single token, it will likely be treated as a check 1054for the name being defined. 1055.It Ar :old_string=new_string 1056This is the 1057.At V 1058style variable substitution. 1059It must be the last modifier specified. 1060If 1061.Ar old_string 1062or 1063.Ar new_string 1064do not contain the pattern matching character 1065.Ar % 1066then it is assumed that they are 1067anchored at the end of each word, so only suffixes or entire 1068words may be replaced. 1069Otherwise 1070.Ar % 1071is the substring of 1072.Ar old_string 1073to be replaced in 1074.Ar new_string . 1075.Pp 1076Variable expansion occurs in the normal fashion inside both 1077.Ar old_string 1078and 1079.Ar new_string 1080with the single exception that a backslash is used to prevent the 1081expansion of a dollar sign 1082.Pq Ql \&$ , 1083not a preceding dollar sign as is usual. 1084.Sm off 1085.It Cm \&:@ Ar temp Cm @ Xo 1086.Ar string Cm @ 1087.Sm on 1088.Xc 1089This is the loop expansion mechanism from the OSF Development 1090Environment (ODE) make. 1091Unlike 1092.Cm \&.for 1093loops expansion occurs at the time of 1094reference. 1095Assign 1096.Ar temp 1097to each word in the variable and evaluate 1098.Ar string . 1099The ODE convention is that 1100.Ar temp 1101should start and end with a period. 1102For example. 1103.Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@} 1104.It Cm \&:U Ns Ar newval 1105If the variable is undefined 1106.Ar newval 1107is the value. 1108If the variable is defined, the existing value is returned. 1109This is another ODE make feature. 1110It is handy for setting per-target CFLAGS for instance: 1111.Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}} 1112If a value is only required if the variable is undefined, use: 1113.Dl ${VAR:D:Unewval} 1114.It Cm \&:D Ns Ar newval 1115If the variable is defined 1116.Ar newval 1117is the value. 1118.It Cm \&:L 1119The name of the variable is the value. 1120.It Cm \&:P 1121The path of the node which has the same name as the variable 1122is the value. 1123If no such node exists or its path is null, then the 1124name of the variable is used. 1125.Sm off 1126.It Cm \&:\&! Ar cmd Cm \&! 1127.Sm on 1128The output of running 1129.Ar cmd 1130is the value. 1131.It Cm \&:sh 1132If the variable is non-empty it is run as a command and the output 1133becomes the new value. 1134.It Cm \&::= Ns Ar str 1135The variable is assigned the value 1136.Ar str 1137after substitution. 1138This modifier and its variations are useful in 1139obscure situations such as wanting to set a variable when shell commands 1140are being parsed. 1141These assignment modifiers always expand to 1142nothing, so if appearing in a rule line by themselves should be 1143preceded with something to keep 1144.Nm 1145happy. 1146.Pp 1147The 1148.Ql Cm \&:: 1149helps avoid false matches with the 1150.At V 1151style 1152.Cm \&:= 1153modifier and since substitution always occurs the 1154.Cm \&::= 1155form is vaguely appropriate. 1156.It Cm \&::?= Ns Ar str 1157As for 1158.Cm \&::= 1159but only if the variable does not already have a value. 1160.It Cm \&::+= Ns Ar str 1161Append 1162.Ar str 1163to the variable. 1164.It Cm \&::!= Ns Ar cmd 1165Assign the output of 1166.Ar cmd 1167to the variable. 1168.It Cm \&:\&[ Ns Ar range Ns Cm \&] 1169Selects one or more words from the value, 1170or performs other operations related to the way in which the 1171value is divided into words. 1172.Pp 1173Ordinarily, a value is treated as a sequence of words 1174delimited by white space. 1175Some modifiers suppress this behaviour, 1176causing a value to be treated as a single word 1177(possibly containing embedded white space). 1178An empty value, or a value that consists entirely of white-space, 1179is treated as a single word. 1180For the purposes of the 1181.Ql Cm \&:[] 1182modifier, the words are indexed both forwards using positive integers 1183(where index 1 represents the first word), 1184and backwards using negative integers 1185(where index -1 represents the last word). 1186.Pp 1187The 1188.Ar range 1189is subjected to variable expansion, and the expanded result is 1190then interpreted as follows: 1191.Bl -tag -width index 1192.\" :[n] 1193.It Ar index 1194Selects a single word from the value. 1195.\" :[start..end] 1196.It Ar start Ns Cm \&.. Ns Ar end 1197Selects all words from 1198.Ar start 1199to 1200.Ar end , 1201inclusive. 1202For example, 1203.Ql Cm \&:[2..-1] 1204selects all words from the second word to the last word. 1205If 1206.Ar start 1207is greater than 1208.Ar end , 1209then the words are output in reverse order. 1210For example, 1211.Ql Cm \&:[-1..1] 1212selects all the words from last to first. 1213.\" :[*] 1214.It Cm \&* 1215Causes subsequent modifiers to treat the value as a single word 1216(possibly containing embedded white space). 1217Analogous to the effect of 1218\&"$*\&" 1219in Bourne shell. 1220.\" :[0] 1221.It 0 1222Means the same as 1223.Ql Cm \&:[*] . 1224.\" :[*] 1225.It Cm \&@ 1226Causes subsequent modifiers to treat the value as a sequence of words 1227delimited by white space. 1228Analogous to the effect of 1229\&"$@\&" 1230in Bourne shell. 1231.\" :[#] 1232.It Cm \&# 1233Returns the number of words in the value. 1234.El \" :[range] 1235.El 1236.Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS 1237Makefile inclusion, conditional structures and for loops reminiscent 1238of the C programming language are provided in 1239.Nm . 1240All such structures are identified by a line beginning with a single 1241dot 1242.Pq Ql \&. 1243character. 1244Files are included with either 1245.Cm \&.include Aq Ar file 1246or 1247.Cm \&.include Pf \*q Ar file Ns \*q . 1248Variables between the angle brackets or double quotes are expanded 1249to form the file name. 1250If angle brackets are used, the included makefile is expected to be in 1251the system makefile directory. 1252If double quotes are used, the including makefile's directory and any 1253directories specified using the 1254.Fl I 1255option are searched before the system 1256makefile directory. 1257For compatibility with other versions of 1258.Nm 1259.Ql include file ... 1260is also accepted. 1261If the include statement is written as 1262.Cm .-include 1263or as 1264.Cm .sinclude 1265then errors locating and/or opening include files are ignored. 1266.Pp 1267Conditional expressions are also preceded by a single dot as the first 1268character of a line. 1269The possible conditionals are as follows: 1270.Bl -tag -width Ds 1271.It Ic .export Ar variable 1272Export the specified global variable. 1273If no variable is provided, all globals are exported 1274except for internal variables (those that start with 1275.Ql \&. ) . 1276This is not affected by the 1277.Fl X 1278flag, so should be used with caution. 1279Appending a variable name to 1280.Va .MAKE.EXPORTED 1281is equivalent to exporting a variable. 1282.It Ic .undef Ar variable 1283Un-define the specified global variable. 1284Only global variables may be un-defined. 1285.It Xo 1286.Ic \&.if 1287.Oo \&! Oc Ns Ar expression 1288.Op Ar operator expression ... 1289.Xc 1290Test the value of an expression. 1291.It Xo 1292.Ic .ifdef 1293.Oo \&! Oc Ns Ar variable 1294.Op Ar operator variable ... 1295.Xc 1296Test the value of a variable. 1297.It Xo 1298.Ic .ifndef 1299.Oo \&! Oc Ns Ar variable 1300.Op Ar operator variable ... 1301.Xc 1302Test the value of a variable. 1303.It Xo 1304.Ic .ifmake 1305.Oo \&! Oc Ns Ar target 1306.Op Ar operator target ... 1307.Xc 1308Test the target being built. 1309.It Xo 1310.Ic .ifnmake 1311.Oo \&! Ns Oc Ar target 1312.Op Ar operator target ... 1313.Xc 1314Test the target being built. 1315.It Ic .else 1316Reverse the sense of the last conditional. 1317.It Xo 1318.Ic .elif 1319.Oo \&! Ns Oc Ar expression 1320.Op Ar operator expression ... 1321.Xc 1322A combination of 1323.Ql Ic .else 1324followed by 1325.Ql Ic .if . 1326.It Xo 1327.Ic .elifdef 1328.Oo \&! Oc Ns Ar variable 1329.Op Ar operator variable ... 1330.Xc 1331A combination of 1332.Ql Ic .else 1333followed by 1334.Ql Ic .ifdef . 1335.It Xo 1336.Ic .elifndef 1337.Oo \&! Oc Ns Ar variable 1338.Op Ar operator variable ... 1339.Xc 1340A combination of 1341.Ql Ic .else 1342followed by 1343.Ql Ic .ifndef . 1344.It Xo 1345.Ic .elifmake 1346.Oo \&! Oc Ns Ar target 1347.Op Ar operator target ... 1348.Xc 1349A combination of 1350.Ql Ic .else 1351followed by 1352.Ql Ic .ifmake . 1353.It Xo 1354.Ic .elifnmake 1355.Oo \&! Oc Ns Ar target 1356.Op Ar operator target ... 1357.Xc 1358A combination of 1359.Ql Ic .else 1360followed by 1361.Ql Ic .ifnmake . 1362.It Ic .endif 1363End the body of the conditional. 1364.El 1365.Pp 1366The 1367.Ar operator 1368may be any one of the following: 1369.Bl -tag -width "Cm XX" 1370.It Cm \&|\&| 1371Logical OR. 1372.It Cm \&\*[Am]\*[Am] 1373Logical 1374.Tn AND ; 1375of higher precedence than 1376.Dq \&|\&| . 1377.El 1378.Pp 1379As in C, 1380.Nm 1381will only evaluate a conditional as far as is necessary to determine 1382its value. 1383Parentheses may be used to change the order of evaluation. 1384The boolean operator 1385.Ql Ic \&! 1386may be used to logically negate an entire 1387conditional. 1388It is of higher precedence than 1389.Ql Ic \&\*[Am]\*[Am] . 1390.Pp 1391The value of 1392.Ar expression 1393may be any of the following: 1394.Bl -tag -width defined 1395.It Ic defined 1396Takes a variable name as an argument and evaluates to true if the variable 1397has been defined. 1398.It Ic make 1399Takes a target name as an argument and evaluates to true if the target 1400was specified as part of 1401.Nm Ns 's 1402command line or was declared the default target (either implicitly or 1403explicitly, see 1404.Va .MAIN ) 1405before the line containing the conditional. 1406.It Ic empty 1407Takes a variable, with possible modifiers, and evaluates to true if 1408the expansion of the variable would result in an empty string. 1409.It Ic exists 1410Takes a file name as an argument and evaluates to true if the file exists. 1411The file is searched for on the system search path (see 1412.Va .PATH ) . 1413.It Ic target 1414Takes a target name as an argument and evaluates to true if the target 1415has been defined. 1416.It Ic commands 1417Takes a target name as an argument and evaluates to true if the target 1418has been defined and has commands associated with it. 1419.El 1420.Pp 1421.Ar Expression 1422may also be an arithmetic or string comparison. 1423Variable expansion is 1424performed on both sides of the comparison, after which the integral 1425values are compared. 1426A value is interpreted as hexadecimal if it is 1427preceded by 0x, otherwise it is decimal; octal numbers are not supported. 1428The standard C relational operators are all supported. 1429If after 1430variable expansion, either the left or right hand side of a 1431.Ql Ic == 1432or 1433.Ql Ic "!=" 1434operator is not an integral value, then 1435string comparison is performed between the expanded 1436variables. 1437If no relational operator is given, it is assumed that the expanded 1438variable is being compared against 0 or an empty string in the case 1439of a string comparison. 1440.Pp 1441When 1442.Nm 1443is evaluating one of these conditional expressions, and it encounters 1444a (white-space separated) word it doesn't recognize, either the 1445.Dq make 1446or 1447.Dq defined 1448expression is applied to it, depending on the form of the conditional. 1449If the form is 1450.Ql Ic .ifdef , 1451.Ql Ic .ifndef , 1452or 1453.Ql Ic .if 1454the 1455.Dq defined 1456expression is applied. 1457Similarly, if the form is 1458.Ql Ic .ifmake 1459or 1460.Ql Ic .ifnmake , the 1461.Dq make 1462expression is applied. 1463.Pp 1464If the conditional evaluates to true the parsing of the makefile continues 1465as before. 1466If it evaluates to false, the following lines are skipped. 1467In both cases this continues until a 1468.Ql Ic .else 1469or 1470.Ql Ic .endif 1471is found. 1472.Pp 1473For loops are typically used to apply a set of rules to a list of files. 1474The syntax of a for loop is: 1475.Pp 1476.Bl -tag -compact -width Ds 1477.It Xo 1478.Ic \&.for 1479.Ar variable 1480.Op Ar variable ... 1481.Ic in 1482.Ar expression 1483.Xc 1484.It Aq make-rules 1485.It Ic \&.endfor 1486.El 1487.Pp 1488After the for 1489.Ic expression 1490is evaluated, it is split into words. 1491On each iteration of the loop, one word is taken and assigned to each 1492.Ic variable , 1493in order, and these 1494.Ic variables 1495are substituted into the 1496.Ic make-rules 1497inside the body of the for loop. 1498The number of words must come out even; that is, if there are three 1499iteration variables, the number of words provided must be a multiple 1500of three. 1501.Sh COMMENTS 1502Comments begin with a hash 1503.Pq Ql \&# 1504character, anywhere but in a shell 1505command line, and continue to the end of an unescaped new line. 1506.Sh SPECIAL SOURCES (ATTRIBUTES) 1507.Bl -tag -width .IGNOREx 1508.It Ic .EXEC 1509Target is never out of date, but always execute commands anyway. 1510.It Ic .IGNORE 1511Ignore any errors from the commands associated with this target, exactly 1512as if they all were preceded by a dash 1513.Pq Ql \- . 1514.\" .It Ic .INVISIBLE 1515.\" XXX 1516.\" .It Ic .JOIN 1517.\" XXX 1518.It Ic .MADE 1519Mark all sources of this target as being up-to-date. 1520.It Ic .MAKE 1521Execute the commands associated with this target even if the 1522.Fl n 1523or 1524.Fl t 1525options were specified. 1526Normally used to mark recursive 1527.Nm Ns 's . 1528.It Ic .NOPATH 1529Do not search for the target in the directories specified by 1530.Ic .PATH . 1531.It Ic .NOTMAIN 1532Normally 1533.Nm 1534selects the first target it encounters as the default target to be built 1535if no target was specified. 1536This source prevents this target from being selected. 1537.It Ic .OPTIONAL 1538If a target is marked with this attribute and 1539.Nm 1540can't figure out how to create it, it will ignore this fact and assume 1541the file isn't needed or already exists. 1542.It Ic .PHONY 1543The target does not 1544correspond to an actual file; it is always considered to be out of date, 1545and will not be created with the 1546.Fl t 1547option. 1548.It Ic .PRECIOUS 1549When 1550.Nm 1551is interrupted, it normally removes any partially made targets. 1552This source prevents the target from being removed. 1553.It Ic .RECURSIVE 1554Synonym for 1555.Ic .MAKE . 1556.It Ic .SILENT 1557Do not echo any of the commands associated with this target, exactly 1558as if they all were preceded by an at sign 1559.Pq Ql @ . 1560.It Ic .USE 1561Turn the target into 1562.Nm Ns 's 1563version of a macro. 1564When the target is used as a source for another target, the other target 1565acquires the commands, sources, and attributes (except for 1566.Ic .USE ) 1567of the 1568source. 1569If the target already has commands, the 1570.Ic .USE 1571target's commands are appended 1572to them. 1573.It Ic .USEBEFORE 1574Exactly like 1575.Ic .USE , 1576but prepend the 1577.Ic .USEBEFORE 1578target commands to the target. 1579.It Ic .WAIT 1580If 1581.Ic .WAIT 1582appears in a dependency line, the sources that precede it are 1583made before the sources that succeed it in the line. 1584Since the dependents of files are not made until the file itself 1585could be made, this also stops the dependents being built unless they 1586are needed for another branch of the dependency tree. 1587So given: 1588.Bd -literal 1589x: a .WAIT b 1590 echo x 1591a: 1592 echo a 1593b: b1 1594 echo b 1595b1: 1596 echo b1 1597 1598.Ed 1599the output is always 1600.Ql a , 1601.Ql b1 , 1602.Ql b , 1603.Ql x . 1604.br 1605The ordering imposed by 1606.Ic .WAIT 1607is only relevant for parallel makes. 1608.El 1609.Sh SPECIAL TARGETS 1610Special targets may not be included with other targets, i.e. they must be 1611the only target specified. 1612.Bl -tag -width .BEGINx 1613.It Ic .BEGIN 1614Any command lines attached to this target are executed before anything 1615else is done. 1616.It Ic .DEFAULT 1617This is sort of a 1618.Ic .USE 1619rule for any target (that was used only as a 1620source) that 1621.Nm 1622can't figure out any other way to create. 1623Only the shell script is used. 1624The 1625.Ic .IMPSRC 1626variable of a target that inherits 1627.Ic .DEFAULT Ns 's 1628commands is set 1629to the target's own name. 1630.It Ic .END 1631Any command lines attached to this target are executed after everything 1632else is done. 1633.It Ic .IGNORE 1634Mark each of the sources with the 1635.Ic .IGNORE 1636attribute. 1637If no sources are specified, this is the equivalent of specifying the 1638.Fl i 1639option. 1640.It Ic .INTERRUPT 1641If 1642.Nm 1643is interrupted, the commands for this target will be executed. 1644.It Ic .MAIN 1645If no target is specified when 1646.Nm 1647is invoked, this target will be built. 1648.It Ic .MAKEFLAGS 1649This target provides a way to specify flags for 1650.Nm 1651when the makefile is used. 1652The flags are as if typed to the shell, though the 1653.Fl f 1654option will have 1655no effect. 1656.\" XXX: NOT YET!!!! 1657.\" .It Ic .NOTPARALLEL 1658.\" The named targets are executed in non parallel mode. 1659.\" If no targets are 1660.\" specified, then all targets are executed in non parallel mode. 1661.It Ic .NOPATH 1662Apply the 1663.Ic .NOPATH 1664attribute to any specified sources. 1665.It Ic .NOTPARALLEL 1666Disable parallel mode. 1667.It Ic .NO_PARALLEL 1668Synonym for 1669.Ic .NOTPARALLEL , 1670for compatibility with other pmake variants. 1671.It Ic .ORDER 1672The named targets are made in sequence. 1673This ordering does not add targets to the list of targets to be made. 1674Since the dependents of a target do not get built until the target itself 1675could be built, unless 1676.Ql a 1677is built by another part of the dependency graph, 1678the following is a dependency loop: 1679.Bd -literal 1680\&.ORDER: a b 1681b: a 1682.Ed 1683.Pp 1684The ordering imposed by 1685.Ic .ORDER 1686is only relevant for parallel makes. 1687.\" XXX: NOT YET!!!! 1688.\" .It Ic .PARALLEL 1689.\" The named targets are executed in parallel mode. 1690.\" If no targets are 1691.\" specified, then all targets are executed in parallel mode. 1692.It Ic .PATH 1693The sources are directories which are to be searched for files not 1694found in the current directory. 1695If no sources are specified, any previously specified directories are 1696deleted. 1697If the source is the special 1698.Ic .DOTLAST 1699target, then the current working 1700directory is searched last. 1701.It Ic .PHONY 1702Apply the 1703.Ic .PHONY 1704attribute to any specified sources. 1705.It Ic .PRECIOUS 1706Apply the 1707.Ic .PRECIOUS 1708attribute to any specified sources. 1709If no sources are specified, the 1710.Ic .PRECIOUS 1711attribute is applied to every 1712target in the file. 1713.It Ic .SHELL 1714Sets the shell that 1715.Nm 1716will use to execute commands. 1717The sources are a set of 1718.Ar field=value 1719pairs. 1720.Bl -tag -width hasErrCtls 1721.It Ar name 1722This is the minimal specification, used to select one of the builtin 1723shell specs; 1724.Ar sh , 1725.Ar ksh , 1726and 1727.Ar csh . 1728.It Ar path 1729Specifies the path to the shell. 1730.It Ar hasErrCtl 1731Indicates whether the shell supports exit on error. 1732.It Ar check 1733The command to turn on error checking. 1734.It Ar ignore 1735The command to disable error checking. 1736.It Ar echo 1737The command to turn on echoing of commands executed. 1738.It Ar quiet 1739The command to turn off echoing of commands executed. 1740.It Ar filter 1741The output to filter after issuing the 1742.Ar quiet 1743command. 1744It is typically identical to 1745.Ar quiet . 1746.It Ar errFlag 1747The flag to pass the shell to enable error checking. 1748.It Ar echoFlag 1749The flag to pass the shell to enable command echoing. 1750.It Ar newline 1751The string literal to pass the shell that results in a single newline 1752character when used outside of any quoting characters. 1753.El 1754Example: 1755.Bd -literal 1756\&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \\ 1757 check="set -e" ignore="set +e" \\ 1758 echo="set -v" quiet="set +v" filter="set +v" \\ 1759 echoFlag=v errFlag=e newline="'\\n'" 1760.Ed 1761.It Ic .SILENT 1762Apply the 1763.Ic .SILENT 1764attribute to any specified sources. 1765If no sources are specified, the 1766.Ic .SILENT 1767attribute is applied to every 1768command in the file. 1769.It Ic .SUFFIXES 1770Each source specifies a suffix to 1771.Nm . 1772If no sources are specified, any previously specified suffixes are deleted. 1773It allows the creation of suffix-transformation rules. 1774.Pp 1775Example: 1776.Bd -literal 1777\&.SUFFIXES: .o 1778\&.c.o: 1779 cc -o ${.TARGET} -c ${.IMPSRC} 1780.Ed 1781.El 1782.Sh ENVIRONMENT 1783.Nm 1784uses the following environment variables, if they exist: 1785.Ev MACHINE , 1786.Ev MACHINE_ARCH , 1787.Ev MAKE , 1788.Ev MAKEFLAGS , 1789.Ev MAKEOBJDIR , 1790.Ev MAKEOBJDIRPREFIX , 1791.Ev MAKESYSPATH , 1792.Ev PWD , 1793and 1794.Ev TMPDIR . 1795.Pp 1796.Ev MAKEOBJDIRPREFIX 1797and 1798.Ev MAKEOBJDIR 1799may only be set in the environment or on the command line to 1800.Nm 1801and not as makefile variables; 1802see the description of 1803.Ql Va .OBJDIR 1804for more details. 1805.Sh FILES 1806.Bl -tag -width /usr/share/mk -compact 1807.It .depend 1808list of dependencies 1809.It Makefile 1810list of dependencies 1811.It makefile 1812list of dependencies 1813.It sys.mk 1814system makefile 1815.It /usr/share/mk 1816system makefile directory 1817.El 1818.Sh COMPATIBILITY 1819The basic make syntax is compatible between different versions of make, 1820however the special variables, variable modifiers and conditionals are not. 1821.Pp 1822The way that parallel makes are scheduled changed in 1823.Nx 4.0 1824so that .ORDER and .WAIT apply recursively to the dependant nodes. 1825The algorithms used may change again in the future. 1826.Pp 1827The way that .for loop variables are substituted changed after 1828.Nx 5.0 1829so that they still appear to be variable expansions. 1830In particular this stops them being treated as syntax, and removes some 1831obscure problems using them in .if statements. 1832.Sh SEE ALSO 1833.Xr mkdep 1 1834.Sh HISTORY 1835A 1836.Nm 1837command appeared in 1838.At v7 . 1839.Sh BUGS 1840The 1841.Nm 1842syntax is difficult to parse without actually acting of the data. 1843For instance finding the end of a variable use should involve scanning each 1844the modifiers using the correct terminator for each field. 1845In many places 1846.Nm 1847just counts {} and () in order to find the end of a variable expansion. 1848.Pp 1849There is no way of escaping a space character in a filename. 1850