1*0a6a1f1dSLionel Sambuc.\" $NetBSD: make.1,v 1.249 2015/06/05 07:33:40 wiz Exp $ 22e2caf59SThomas Veerman.\" 32e2caf59SThomas Veerman.\" Copyright (c) 1990, 1993 42e2caf59SThomas Veerman.\" The Regents of the University of California. All rights reserved. 52e2caf59SThomas Veerman.\" 62e2caf59SThomas Veerman.\" Redistribution and use in source and binary forms, with or without 72e2caf59SThomas Veerman.\" modification, are permitted provided that the following conditions 82e2caf59SThomas Veerman.\" are met: 92e2caf59SThomas Veerman.\" 1. Redistributions of source code must retain the above copyright 102e2caf59SThomas Veerman.\" notice, this list of conditions and the following disclaimer. 112e2caf59SThomas Veerman.\" 2. Redistributions in binary form must reproduce the above copyright 122e2caf59SThomas Veerman.\" notice, this list of conditions and the following disclaimer in the 132e2caf59SThomas Veerman.\" documentation and/or other materials provided with the distribution. 142e2caf59SThomas Veerman.\" 3. Neither the name of the University nor the names of its contributors 152e2caf59SThomas Veerman.\" may be used to endorse or promote products derived from this software 162e2caf59SThomas Veerman.\" without specific prior written permission. 172e2caf59SThomas Veerman.\" 182e2caf59SThomas Veerman.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 192e2caf59SThomas Veerman.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 202e2caf59SThomas Veerman.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 212e2caf59SThomas Veerman.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 222e2caf59SThomas Veerman.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 232e2caf59SThomas Veerman.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 242e2caf59SThomas Veerman.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 252e2caf59SThomas Veerman.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 262e2caf59SThomas Veerman.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 272e2caf59SThomas Veerman.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 282e2caf59SThomas Veerman.\" SUCH DAMAGE. 292e2caf59SThomas Veerman.\" 302e2caf59SThomas Veerman.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 312e2caf59SThomas Veerman.\" 32*0a6a1f1dSLionel Sambuc.Dd June 4, 2015 332e2caf59SThomas Veerman.Dt MAKE 1 342e2caf59SThomas Veerman.Os 352e2caf59SThomas Veerman.Sh NAME 362e2caf59SThomas Veerman.Nm make 372e2caf59SThomas Veerman.Nd maintain program dependencies 382e2caf59SThomas Veerman.Sh SYNOPSIS 392e2caf59SThomas Veerman.Nm 4084d9c625SLionel Sambuc.Op Fl BeikNnqrstWwX 412e2caf59SThomas Veerman.Op Fl C Ar directory 422e2caf59SThomas Veerman.Op Fl D Ar variable 432e2caf59SThomas Veerman.Op Fl d Ar flags 442e2caf59SThomas Veerman.Op Fl f Ar makefile 452e2caf59SThomas Veerman.Op Fl I Ar directory 462e2caf59SThomas Veerman.Op Fl J Ar private 472e2caf59SThomas Veerman.Op Fl j Ar max_jobs 482e2caf59SThomas Veerman.Op Fl m Ar directory 492e2caf59SThomas Veerman.Op Fl T Ar file 502e2caf59SThomas Veerman.Op Fl V Ar variable 512e2caf59SThomas Veerman.Op Ar variable=value 522e2caf59SThomas Veerman.Op Ar target ... 532e2caf59SThomas Veerman.Sh DESCRIPTION 542e2caf59SThomas Veerman.Nm 552e2caf59SThomas Veermanis a program designed to simplify the maintenance of other programs. 562e2caf59SThomas VeermanIts input is a list of specifications as to the files upon which programs 572e2caf59SThomas Veermanand other files depend. 582e2caf59SThomas VeermanIf no 592e2caf59SThomas Veerman.Fl f Ar makefile 602e2caf59SThomas Veermanmakefile option is given, 612e2caf59SThomas Veerman.Nm 622e2caf59SThomas Veermanwill try to open 632e2caf59SThomas Veerman.Ql Pa makefile 642e2caf59SThomas Veermanthen 652e2caf59SThomas Veerman.Ql Pa Makefile 662e2caf59SThomas Veermanin order to find the specifications. 672e2caf59SThomas VeermanIf the file 682e2caf59SThomas Veerman.Ql Pa .depend 692e2caf59SThomas Veermanexists, it is read (see 702e2caf59SThomas Veerman.Xr mkdep 1 ) . 712e2caf59SThomas Veerman.Pp 722e2caf59SThomas VeermanThis manual page is intended as a reference document only. 732e2caf59SThomas VeermanFor a more thorough description of 742e2caf59SThomas Veerman.Nm 752e2caf59SThomas Veermanand makefiles, please refer to 762e2caf59SThomas Veerman.%T "PMake \- A Tutorial" . 772e2caf59SThomas Veerman.Pp 782e2caf59SThomas Veerman.Nm 792e2caf59SThomas Veermanwill prepend the contents of the 802e2caf59SThomas Veerman.Va MAKEFLAGS 812e2caf59SThomas Veermanenvironment variable to the command line arguments before parsing them. 822e2caf59SThomas Veerman.Pp 832e2caf59SThomas VeermanThe options are as follows: 842e2caf59SThomas Veerman.Bl -tag -width Ds 852e2caf59SThomas Veerman.It Fl B 862e2caf59SThomas VeermanTry to be backwards compatible by executing a single shell per command and 872e2caf59SThomas Veermanby executing the commands to make the sources of a dependency line in sequence. 882e2caf59SThomas Veerman.It Fl C Ar directory 892e2caf59SThomas VeermanChange to 902e2caf59SThomas Veerman.Ar directory 912e2caf59SThomas Veermanbefore reading the makefiles or doing anything else. 922e2caf59SThomas VeermanIf multiple 932e2caf59SThomas Veerman.Fl C 942e2caf59SThomas Veermanoptions are specified, each is interpreted relative to the previous one: 952e2caf59SThomas Veerman.Fl C Pa / Fl C Pa etc 962e2caf59SThomas Veermanis equivalent to 972e2caf59SThomas Veerman.Fl C Pa /etc . 982e2caf59SThomas Veerman.It Fl D Ar variable 992e2caf59SThomas VeermanDefine 1002e2caf59SThomas Veerman.Ar variable 1012e2caf59SThomas Veermanto be 1, in the global context. 1022e2caf59SThomas Veerman.It Fl d Ar [-]flags 1032e2caf59SThomas VeermanTurn on debugging, and specify which portions of 1042e2caf59SThomas Veerman.Nm 1052e2caf59SThomas Veermanare to print debugging information. 1062e2caf59SThomas VeermanUnless the flags are preceded by 1072e2caf59SThomas Veerman.Ql \- 1082e2caf59SThomas Veermanthey are added to the 1092e2caf59SThomas Veerman.Va MAKEFLAGS 1102e2caf59SThomas Veermanenvironment variable and will be processed by any child make processes. 1112e2caf59SThomas VeermanBy default, debugging information is printed to standard error, 1122e2caf59SThomas Veermanbut this can be changed using the 1132e2caf59SThomas Veerman.Ar F 1142e2caf59SThomas Veermandebugging flag. 1152e2caf59SThomas VeermanThe debugging output is always unbuffered; in addition, if debugging 1162e2caf59SThomas Veermanis enabled but debugging output is not directed to standard output, 1172e2caf59SThomas Veermanthen the standard output is line buffered. 1182e2caf59SThomas Veerman.Ar Flags 1192e2caf59SThomas Veermanis one or more of the following: 1202e2caf59SThomas Veerman.Bl -tag -width Ds 1212e2caf59SThomas Veerman.It Ar A 1222e2caf59SThomas VeermanPrint all possible debugging information; 1232e2caf59SThomas Veermanequivalent to specifying all of the debugging flags. 1242e2caf59SThomas Veerman.It Ar a 1252e2caf59SThomas VeermanPrint debugging information about archive searching and caching. 1262e2caf59SThomas Veerman.It Ar C 1272e2caf59SThomas VeermanPrint debugging information about current working directory. 1282e2caf59SThomas Veerman.It Ar c 1292e2caf59SThomas VeermanPrint debugging information about conditional evaluation. 1302e2caf59SThomas Veerman.It Ar d 1312e2caf59SThomas VeermanPrint debugging information about directory searching and caching. 1322e2caf59SThomas Veerman.It Ar e 1332e2caf59SThomas VeermanPrint debugging information about failed commands and targets. 1342e2caf59SThomas Veerman.It Ar F Ns Oo Sy \&+ Oc Ns Ar filename 1352e2caf59SThomas VeermanSpecify where debugging output is written. 1362e2caf59SThomas VeermanThis must be the last flag, because it consumes the remainder of 1372e2caf59SThomas Veermanthe argument. 1382e2caf59SThomas VeermanIf the character immediately after the 1392e2caf59SThomas Veerman.Ql F 1402e2caf59SThomas Veermanflag is 1412e2caf59SThomas Veerman.Ql \&+ , 1422e2caf59SThomas Veermanthen the file will be opened in append mode; 1432e2caf59SThomas Veermanotherwise the file will be overwritten. 1442e2caf59SThomas VeermanIf the file name is 1452e2caf59SThomas Veerman.Ql stdout 1462e2caf59SThomas Veermanor 1472e2caf59SThomas Veerman.Ql stderr 1482e2caf59SThomas Veermanthen debugging output will be written to the 1492e2caf59SThomas Veermanstandard output or standard error output file descriptors respectively 1502e2caf59SThomas Veerman(and the 1512e2caf59SThomas Veerman.Ql \&+ 1522e2caf59SThomas Veermanoption has no effect). 1532e2caf59SThomas VeermanOtherwise, the output will be written to the named file. 1542e2caf59SThomas VeermanIf the file name ends 1552e2caf59SThomas Veerman.Ql .%d 1562e2caf59SThomas Veermanthen the 1572e2caf59SThomas Veerman.Ql %d 1582e2caf59SThomas Veermanis replaced by the pid. 1592e2caf59SThomas Veerman.It Ar f 1602e2caf59SThomas VeermanPrint debugging information about loop evaluation. 1612e2caf59SThomas Veerman.It Ar "g1" 1622e2caf59SThomas VeermanPrint the input graph before making anything. 1632e2caf59SThomas Veerman.It Ar "g2" 1642e2caf59SThomas VeermanPrint the input graph after making everything, or before exiting 1652e2caf59SThomas Veermanon error. 1662e2caf59SThomas Veerman.It Ar "g3" 1672e2caf59SThomas VeermanPrint the input graph before exiting on error. 1682e2caf59SThomas Veerman.It Ar j 1692e2caf59SThomas VeermanPrint debugging information about running multiple shells. 1702e2caf59SThomas Veerman.It Ar l 1712e2caf59SThomas VeermanPrint commands in Makefiles regardless of whether or not they are prefixed by 1722e2caf59SThomas Veerman.Ql @ 1732e2caf59SThomas Veermanor other "quiet" flags. 1742e2caf59SThomas VeermanAlso known as "loud" behavior. 1752e2caf59SThomas Veerman.It Ar M 1762e2caf59SThomas VeermanPrint debugging information about "meta" mode decisions about targets. 1772e2caf59SThomas Veerman.It Ar m 1782e2caf59SThomas VeermanPrint debugging information about making targets, including modification 1792e2caf59SThomas Veermandates. 1802e2caf59SThomas Veerman.It Ar n 1812e2caf59SThomas VeermanDon't delete the temporary command scripts created when running commands. 1822e2caf59SThomas VeermanThese temporary scripts are created in the directory 1832e2caf59SThomas Veermanreferred to by the 1842e2caf59SThomas Veerman.Ev TMPDIR 1852e2caf59SThomas Veermanenvironment variable, or in 1862e2caf59SThomas Veerman.Pa /tmp 1872e2caf59SThomas Veermanif 1882e2caf59SThomas Veerman.Ev TMPDIR 1892e2caf59SThomas Veermanis unset or set to the empty string. 1902e2caf59SThomas VeermanThe temporary scripts are created by 1912e2caf59SThomas Veerman.Xr mkstemp 3 , 1922e2caf59SThomas Veermanand have names of the form 1932e2caf59SThomas Veerman.Pa makeXXXXXX . 1942e2caf59SThomas Veerman.Em NOTE : 1952e2caf59SThomas VeermanThis can create many files in 1962e2caf59SThomas Veerman.Ev TMPDIR 1972e2caf59SThomas Veermanor 1982e2caf59SThomas Veerman.Pa /tmp , 1992e2caf59SThomas Veermanso use with care. 2002e2caf59SThomas Veerman.It Ar p 2012e2caf59SThomas VeermanPrint debugging information about makefile parsing. 2022e2caf59SThomas Veerman.It Ar s 2032e2caf59SThomas VeermanPrint debugging information about suffix-transformation rules. 2042e2caf59SThomas Veerman.It Ar t 2052e2caf59SThomas VeermanPrint debugging information about target list maintenance. 2062bc7c627SLionel Sambuc.It Ar V 2072bc7c627SLionel SambucForce the 2082bc7c627SLionel Sambuc.Fl V 2092bc7c627SLionel Sambucoption to print raw values of variables. 2102e2caf59SThomas Veerman.It Ar v 2112e2caf59SThomas VeermanPrint debugging information about variable assignment. 2122e2caf59SThomas Veerman.It Ar x 2132e2caf59SThomas VeermanRun shell commands with 2142e2caf59SThomas Veerman.Fl x 2152e2caf59SThomas Veermanso the actual commands are printed as they are executed. 2162e2caf59SThomas Veerman.El 2172e2caf59SThomas Veerman.It Fl e 2182e2caf59SThomas VeermanSpecify that environment variables override macro assignments within 2192e2caf59SThomas Veermanmakefiles. 2202e2caf59SThomas Veerman.It Fl f Ar makefile 2212e2caf59SThomas VeermanSpecify a makefile to read instead of the default 2222e2caf59SThomas Veerman.Ql Pa makefile . 2232e2caf59SThomas VeermanIf 2242e2caf59SThomas Veerman.Ar makefile 2252e2caf59SThomas Veermanis 2262e2caf59SThomas Veerman.Ql Fl , 2272e2caf59SThomas Veermanstandard input is read. 2282e2caf59SThomas VeermanMultiple makefiles may be specified, and are read in the order specified. 2292e2caf59SThomas Veerman.It Fl I Ar directory 2302e2caf59SThomas VeermanSpecify a directory in which to search for makefiles and included makefiles. 2312e2caf59SThomas VeermanThe system makefile directory (or directories, see the 2322e2caf59SThomas Veerman.Fl m 2332e2caf59SThomas Veermanoption) is automatically included as part of this list. 2342e2caf59SThomas Veerman.It Fl i 2352e2caf59SThomas VeermanIgnore non-zero exit of shell commands in the makefile. 2362e2caf59SThomas VeermanEquivalent to specifying 2372e2caf59SThomas Veerman.Ql Fl 2382e2caf59SThomas Veermanbefore each command line in the makefile. 2392e2caf59SThomas Veerman.It Fl J Ar private 2402e2caf59SThomas VeermanThis option should 2412e2caf59SThomas Veerman.Em not 2422e2caf59SThomas Veermanbe specified by the user. 2432e2caf59SThomas Veerman.Pp 2442e2caf59SThomas VeermanWhen the 2452e2caf59SThomas Veerman.Ar j 2462e2caf59SThomas Veermanoption is in use in a recursive build, this option is passed by a make 2472e2caf59SThomas Veermanto child makes to allow all the make processes in the build to 2482e2caf59SThomas Veermancooperate to avoid overloading the system. 2492e2caf59SThomas Veerman.It Fl j Ar max_jobs 2502e2caf59SThomas VeermanSpecify the maximum number of jobs that 2512e2caf59SThomas Veerman.Nm 2522e2caf59SThomas Veermanmay have running at any one time. 2532e2caf59SThomas VeermanThe value is saved in 2542e2caf59SThomas Veerman.Va .MAKE.JOBS . 2552e2caf59SThomas VeermanTurns compatibility mode off, unless the 2562e2caf59SThomas Veerman.Ar B 2572e2caf59SThomas Veermanflag is also specified. 2582e2caf59SThomas VeermanWhen compatibility mode is off, all commands associated with a 2592e2caf59SThomas Veermantarget are executed in a single shell invocation as opposed to the 2602e2caf59SThomas Veermantraditional one shell invocation per line. 2612e2caf59SThomas VeermanThis can break traditional scripts which change directories on each 2622e2caf59SThomas Veermancommand invocation and then expect to start with a fresh environment 2632e2caf59SThomas Veermanon the next line. 2642e2caf59SThomas VeermanIt is more efficient to correct the scripts rather than turn backwards 2652e2caf59SThomas Veermancompatibility on. 2662e2caf59SThomas Veerman.It Fl k 2672e2caf59SThomas VeermanContinue processing after errors are encountered, but only on those targets 2682e2caf59SThomas Veermanthat do not depend on the target whose creation caused the error. 2692e2caf59SThomas Veerman.It Fl m Ar directory 2702e2caf59SThomas VeermanSpecify a directory in which to search for sys.mk and makefiles included 2712e2caf59SThomas Veermanvia the 2722e2caf59SThomas Veerman.Ao Ar file Ac Ns -style 2732e2caf59SThomas Veermaninclude statement. 2742e2caf59SThomas VeermanThe 2752e2caf59SThomas Veerman.Fl m 2762e2caf59SThomas Veermanoption can be used multiple times to form a search path. 2772e2caf59SThomas VeermanThis path will override the default system include path: /usr/share/mk. 2782e2caf59SThomas VeermanFurthermore the system include path will be appended to the search path used 2792e2caf59SThomas Veermanfor 2802e2caf59SThomas Veerman.Qo Ar file Qc Ns -style 2812e2caf59SThomas Veermaninclude statements (see the 2822e2caf59SThomas Veerman.Fl I 2832e2caf59SThomas Veermanoption). 2842e2caf59SThomas Veerman.Pp 2852e2caf59SThomas VeermanIf a file or directory name in the 2862e2caf59SThomas Veerman.Fl m 2872e2caf59SThomas Veermanargument (or the 2882e2caf59SThomas Veerman.Ev MAKESYSPATH 2892e2caf59SThomas Veermanenvironment variable) starts with the string 2902e2caf59SThomas Veerman.Qq \&.../ 2912e2caf59SThomas Veermanthen 2922e2caf59SThomas Veerman.Nm 2932e2caf59SThomas Veermanwill search for the specified file or directory named in the remaining part 2942e2caf59SThomas Veermanof the argument string. 2952e2caf59SThomas VeermanThe search starts with the current directory of 2962e2caf59SThomas Veermanthe Makefile and then works upward towards the root of the filesystem. 2972e2caf59SThomas VeermanIf the search is successful, then the resulting directory replaces the 2982e2caf59SThomas Veerman.Qq \&.../ 2992e2caf59SThomas Veermanspecification in the 3002e2caf59SThomas Veerman.Fl m 3012e2caf59SThomas Veermanargument. 3022e2caf59SThomas VeermanIf used, this feature allows 3032e2caf59SThomas Veerman.Nm 3042e2caf59SThomas Veermanto easily search in the current source tree for customized sys.mk files 3052e2caf59SThomas Veerman(e.g., by using 3062e2caf59SThomas Veerman.Qq \&.../mk/sys.mk 3072e2caf59SThomas Veermanas an argument). 3082e2caf59SThomas Veerman.It Fl n 3092e2caf59SThomas VeermanDisplay the commands that would have been executed, but do not 3102e2caf59SThomas Veermanactually execute them unless the target depends on the .MAKE special 3112e2caf59SThomas Veermansource (see below). 3122e2caf59SThomas Veerman.It Fl N 3132e2caf59SThomas VeermanDisplay the commands which would have been executed, but do not 3142e2caf59SThomas Veermanactually execute any of them; useful for debugging top-level makefiles 3152e2caf59SThomas Veermanwithout descending into subdirectories. 3162e2caf59SThomas Veerman.It Fl q 3172e2caf59SThomas VeermanDo not execute any commands, but exit 0 if the specified targets are 3182e2caf59SThomas Veermanup-to-date and 1, otherwise. 3192e2caf59SThomas Veerman.It Fl r 3202e2caf59SThomas VeermanDo not use the built-in rules specified in the system makefile. 3212e2caf59SThomas Veerman.It Fl s 3222e2caf59SThomas VeermanDo not echo any commands as they are executed. 3232e2caf59SThomas VeermanEquivalent to specifying 3242e2caf59SThomas Veerman.Ql Ic @ 3252e2caf59SThomas Veermanbefore each command line in the makefile. 3262e2caf59SThomas Veerman.It Fl T Ar tracefile 3272e2caf59SThomas VeermanWhen used with the 3282e2caf59SThomas Veerman.Fl j 3292e2caf59SThomas Veermanflag, 3302e2caf59SThomas Veermanappend a trace record to 3312e2caf59SThomas Veerman.Ar tracefile 3322e2caf59SThomas Veermanfor each job started and completed. 3332e2caf59SThomas Veerman.It Fl t 3342e2caf59SThomas VeermanRather than re-building a target as specified in the makefile, create it 3352e2caf59SThomas Veermanor update its modification time to make it appear up-to-date. 3362e2caf59SThomas Veerman.It Fl V Ar variable 3372e2caf59SThomas VeermanPrint 3382e2caf59SThomas Veerman.Nm Ns 's 3392e2caf59SThomas Veermanidea of the value of 3402e2caf59SThomas Veerman.Ar variable , 3412e2caf59SThomas Veermanin the global context. 3422e2caf59SThomas VeermanDo not build any targets. 3432e2caf59SThomas VeermanMultiple instances of this option may be specified; 3442e2caf59SThomas Veermanthe variables will be printed one per line, 3452e2caf59SThomas Veermanwith a blank line for each null or undefined variable. 3462e2caf59SThomas VeermanIf 3472e2caf59SThomas Veerman.Ar variable 3482e2caf59SThomas Veermancontains a 3492e2caf59SThomas Veerman.Ql \&$ 3502e2caf59SThomas Veermanthen the value will be expanded before printing. 3512e2caf59SThomas Veerman.It Fl W 3522e2caf59SThomas VeermanTreat any warnings during makefile parsing as errors. 353*0a6a1f1dSLionel Sambuc.It Fl w 354*0a6a1f1dSLionel SambucPrint entering and leaving directory messages, pre and post processing. 3552e2caf59SThomas Veerman.It Fl X 3562e2caf59SThomas VeermanDon't export variables passed on the command line to the environment 3572e2caf59SThomas Veermanindividually. 3582e2caf59SThomas VeermanVariables passed on the command line are still exported 3592e2caf59SThomas Veermanvia the 3602e2caf59SThomas Veerman.Va MAKEFLAGS 3612e2caf59SThomas Veermanenvironment variable. 3622e2caf59SThomas VeermanThis option may be useful on systems which have a small limit on the 3632e2caf59SThomas Veermansize of command arguments. 3642e2caf59SThomas Veerman.It Ar variable=value 3652e2caf59SThomas VeermanSet the value of the variable 3662e2caf59SThomas Veerman.Ar variable 3672e2caf59SThomas Veermanto 3682e2caf59SThomas Veerman.Ar value . 3692e2caf59SThomas VeermanNormally, all values passed on the command line are also exported to 3702e2caf59SThomas Veermansub-makes in the environment. 3712e2caf59SThomas VeermanThe 3722e2caf59SThomas Veerman.Fl X 3732e2caf59SThomas Veermanflag disables this behavior. 3742e2caf59SThomas VeermanVariable assignments should follow options for POSIX compatibility 3752e2caf59SThomas Veermanbut no ordering is enforced. 3762e2caf59SThomas Veerman.El 3772e2caf59SThomas Veerman.Pp 3782e2caf59SThomas VeermanThere are seven different types of lines in a makefile: file dependency 3792e2caf59SThomas Veermanspecifications, shell commands, variable assignments, include statements, 3802e2caf59SThomas Veermanconditional directives, for loops, and comments. 3812e2caf59SThomas Veerman.Pp 3822e2caf59SThomas VeermanIn general, lines may be continued from one line to the next by ending 3832e2caf59SThomas Veermanthem with a backslash 3842e2caf59SThomas Veerman.Pq Ql \e . 3852e2caf59SThomas VeermanThe trailing newline character and initial whitespace on the following 3862e2caf59SThomas Veermanline are compressed into a single space. 3872e2caf59SThomas Veerman.Sh FILE DEPENDENCY SPECIFICATIONS 3882e2caf59SThomas VeermanDependency lines consist of one or more targets, an operator, and zero 3892e2caf59SThomas Veermanor more sources. 3902e2caf59SThomas VeermanThis creates a relationship where the targets 3912e2caf59SThomas Veerman.Dq depend 3922e2caf59SThomas Veermanon the sources 3932e2caf59SThomas Veermanand are usually created from them. 3942e2caf59SThomas VeermanThe exact relationship between the target and the source is determined 3952e2caf59SThomas Veermanby the operator that separates them. 3962e2caf59SThomas VeermanThe three operators are as follows: 3972e2caf59SThomas Veerman.Bl -tag -width flag 3982e2caf59SThomas Veerman.It Ic \&: 3992e2caf59SThomas VeermanA target is considered out-of-date if its modification time is less than 4002e2caf59SThomas Veermanthose of any of its sources. 4012e2caf59SThomas VeermanSources for a target accumulate over dependency lines when this operator 4022e2caf59SThomas Veermanis used. 4032e2caf59SThomas VeermanThe target is removed if 4042e2caf59SThomas Veerman.Nm 4052e2caf59SThomas Veermanis interrupted. 4062e2caf59SThomas Veerman.It Ic \&! 4072e2caf59SThomas VeermanTargets are always re-created, but not until all sources have been 4082e2caf59SThomas Veermanexamined and re-created as necessary. 4092e2caf59SThomas VeermanSources for a target accumulate over dependency lines when this operator 4102e2caf59SThomas Veermanis used. 4112e2caf59SThomas VeermanThe target is removed if 4122e2caf59SThomas Veerman.Nm 4132e2caf59SThomas Veermanis interrupted. 4142e2caf59SThomas Veerman.It Ic \&:: 4152e2caf59SThomas VeermanIf no sources are specified, the target is always re-created. 4162e2caf59SThomas VeermanOtherwise, a target is considered out-of-date if any of its sources has 4172e2caf59SThomas Veermanbeen modified more recently than the target. 4182e2caf59SThomas VeermanSources for a target do not accumulate over dependency lines when this 4192e2caf59SThomas Veermanoperator is used. 4202e2caf59SThomas VeermanThe target will not be removed if 4212e2caf59SThomas Veerman.Nm 4222e2caf59SThomas Veermanis interrupted. 4232e2caf59SThomas Veerman.El 4242e2caf59SThomas Veerman.Pp 4252e2caf59SThomas VeermanTargets and sources may contain the shell wildcard values 4262e2caf59SThomas Veerman.Ql \&? , 4272e2caf59SThomas Veerman.Ql * , 4282e2caf59SThomas Veerman.Ql [] , 4292e2caf59SThomas Veermanand 4302e2caf59SThomas Veerman.Ql {} . 4312e2caf59SThomas VeermanThe values 4322e2caf59SThomas Veerman.Ql \&? , 4332e2caf59SThomas Veerman.Ql * , 4342e2caf59SThomas Veermanand 4352e2caf59SThomas Veerman.Ql [] 4362e2caf59SThomas Veermanmay only be used as part of the final 4372e2caf59SThomas Veermancomponent of the target or source, and must be used to describe existing 4382e2caf59SThomas Veermanfiles. 4392e2caf59SThomas VeermanThe value 4402e2caf59SThomas Veerman.Ql {} 4412e2caf59SThomas Veermanneed not necessarily be used to describe existing files. 4422e2caf59SThomas VeermanExpansion is in directory order, not alphabetically as done in the shell. 4432e2caf59SThomas Veerman.Sh SHELL COMMANDS 444*0a6a1f1dSLionel SambucEach target may have associated with it one or more lines of shell 445*0a6a1f1dSLionel Sambuccommands, normally 4462e2caf59SThomas Veermanused to create the target. 447*0a6a1f1dSLionel SambucEach of the lines in this script 4482e2caf59SThomas Veerman.Em must 4492e2caf59SThomas Veermanbe preceded by a tab. 450*0a6a1f1dSLionel Sambuc(For historical reasons, spaces are not accepted.) 451*0a6a1f1dSLionel SambucWhile targets can appear in many dependency lines if desired, by 452*0a6a1f1dSLionel Sambucdefault only one of these rules may be followed by a creation 453*0a6a1f1dSLionel Sambucscript. 454*0a6a1f1dSLionel SambucIf the 4552e2caf59SThomas Veerman.Ql Ic \&:: 456*0a6a1f1dSLionel Sambucoperator is used, however, all rules may include scripts and the 457*0a6a1f1dSLionel Sambucscripts are executed in the order found. 4582e2caf59SThomas Veerman.Pp 459*0a6a1f1dSLionel SambucEach line is treated as a separate shell command, unless the end of 460*0a6a1f1dSLionel Sambucline is escaped with a backslash 461*0a6a1f1dSLionel Sambuc.Pq Ql \e 462*0a6a1f1dSLionel Sambucin which case that line and the next are combined. 463*0a6a1f1dSLionel Sambuc.\" The escaped newline is retained and passed to the shell, which 464*0a6a1f1dSLionel Sambuc.\" normally ignores it. 465*0a6a1f1dSLionel Sambuc.\" However, the tab at the beginning of the following line is removed. 466*0a6a1f1dSLionel SambucIf the first characters of the command are any combination of 4672e2caf59SThomas Veerman.Ql Ic @ , 4682e2caf59SThomas Veerman.Ql Ic + , 4692e2caf59SThomas Veermanor 4702e2caf59SThomas Veerman.Ql Ic \- , 4712e2caf59SThomas Veermanthe command is treated specially. 4722e2caf59SThomas VeermanA 4732e2caf59SThomas Veerman.Ql Ic @ 4742e2caf59SThomas Veermancauses the command not to be echoed before it is executed. 4752e2caf59SThomas VeermanA 4762e2caf59SThomas Veerman.Ql Ic + 4772e2caf59SThomas Veermancauses the command to be executed even when 4782e2caf59SThomas Veerman.Fl n 4792e2caf59SThomas Veermanis given. 4802e2caf59SThomas VeermanThis is similar to the effect of the .MAKE special source, 4812e2caf59SThomas Veermanexcept that the effect can be limited to a single line of a script. 4822e2caf59SThomas VeermanA 4832e2caf59SThomas Veerman.Ql Ic \- 484*0a6a1f1dSLionel Sambucin compatibility mode 4852e2caf59SThomas Veermancauses any non-zero exit status of the command line to be ignored. 48684d9c625SLionel Sambuc.Pp 48784d9c625SLionel SambucWhen 48884d9c625SLionel Sambuc.Nm 48984d9c625SLionel Sambucis run in jobs mode with 49084d9c625SLionel Sambuc.Fl j Ar max_jobs , 49184d9c625SLionel Sambucthe entire script for the target is fed to a 49284d9c625SLionel Sambucsingle instance of the shell. 49384d9c625SLionel SambucIn compatibility (non-jobs) mode, each command is run in a separate process. 49484d9c625SLionel SambucIf the command contains any shell meta characters 49584d9c625SLionel Sambuc.Pq Ql #=|^(){};&<>*?[]:$`\e\en 496*0a6a1f1dSLionel Sambucit will be passed to the shell; otherwise 49784d9c625SLionel Sambuc.Nm 49884d9c625SLionel Sambucwill attempt direct execution. 499*0a6a1f1dSLionel SambucIf a line starts with 500*0a6a1f1dSLionel Sambuc.Ql Ic \- 501*0a6a1f1dSLionel Sambucand the shell has ErrCtl enabled then failure of the command line 502*0a6a1f1dSLionel Sambucwill be ignored as in compatibility mode. 503*0a6a1f1dSLionel SambucOtherwise 504*0a6a1f1dSLionel Sambuc.Ql Ic \- 505*0a6a1f1dSLionel Sambucaffects the entire job; 506*0a6a1f1dSLionel Sambucthe script will stop at the first command line that fails, 507*0a6a1f1dSLionel Sambucbut the target will not be deemed to have failed. 508*0a6a1f1dSLionel Sambuc.Pp 509*0a6a1f1dSLionel SambucMakefiles should be written so that the mode of 510*0a6a1f1dSLionel Sambuc.Nm 511*0a6a1f1dSLionel Sambucoperation does not change their behavior. 512*0a6a1f1dSLionel SambucFor example, any command which needs to use 513*0a6a1f1dSLionel Sambuc.Dq cd 514*0a6a1f1dSLionel Sambucor 515*0a6a1f1dSLionel Sambuc.Dq chdir 516*0a6a1f1dSLionel Sambucwithout potentially changing the directory for subsequent commands 517*0a6a1f1dSLionel Sambucshould be put in parentheses so it executes in a subshell. 518*0a6a1f1dSLionel SambucTo force the use of one shell, escape the line breaks so as to make 519*0a6a1f1dSLionel Sambucthe whole script one command. 520*0a6a1f1dSLionel SambucFor example: 521*0a6a1f1dSLionel Sambuc.Bd -literal -offset indent 522*0a6a1f1dSLionel Sambucavoid-chdir-side-effects: 523*0a6a1f1dSLionel Sambuc @echo Building $@ in `pwd` 524*0a6a1f1dSLionel Sambuc @(cd ${.CURDIR} && ${MAKE} $@) 525*0a6a1f1dSLionel Sambuc @echo Back in `pwd` 526*0a6a1f1dSLionel Sambuc 527*0a6a1f1dSLionel Sambucensure-one-shell-regardless-of-mode: 528*0a6a1f1dSLionel Sambuc @echo Building $@ in `pwd`; \e 529*0a6a1f1dSLionel Sambuc (cd ${.CURDIR} && ${MAKE} $@); \e 530*0a6a1f1dSLionel Sambuc echo Back in `pwd` 531*0a6a1f1dSLionel Sambuc.Ed 53284d9c625SLionel Sambuc.Pp 53384d9c625SLionel SambucSince 53484d9c625SLionel Sambuc.Nm 53584d9c625SLionel Sambucwill 53684d9c625SLionel Sambuc.Xr chdir 2 53784d9c625SLionel Sambucto 53884d9c625SLionel Sambuc.Ql Va .OBJDIR 53984d9c625SLionel Sambucbefore executing any targets, each child process 54084d9c625SLionel Sambucstarts with that as its current working directory. 5412e2caf59SThomas Veerman.Sh VARIABLE ASSIGNMENTS 5422e2caf59SThomas VeermanVariables in make are much like variables in the shell, and, by tradition, 5432e2caf59SThomas Veermanconsist of all upper-case letters. 5442e2caf59SThomas Veerman.Ss Variable assignment modifiers 5452e2caf59SThomas VeermanThe five operators that can be used to assign values to variables are as 5462e2caf59SThomas Veermanfollows: 5472e2caf59SThomas Veerman.Bl -tag -width Ds 5482e2caf59SThomas Veerman.It Ic \&= 5492e2caf59SThomas VeermanAssign the value to the variable. 5502e2caf59SThomas VeermanAny previous value is overridden. 5512e2caf59SThomas Veerman.It Ic \&+= 5522e2caf59SThomas VeermanAppend the value to the current value of the variable. 5532e2caf59SThomas Veerman.It Ic \&?= 5542e2caf59SThomas VeermanAssign the value to the variable if it is not already defined. 5552e2caf59SThomas Veerman.It Ic \&:= 5562e2caf59SThomas VeermanAssign with expansion, i.e. expand the value before assigning it 5572e2caf59SThomas Veermanto the variable. 5582e2caf59SThomas VeermanNormally, expansion is not done until the variable is referenced. 5592e2caf59SThomas Veerman.Em NOTE : 5602e2caf59SThomas VeermanReferences to undefined variables are 5612e2caf59SThomas Veerman.Em not 5622e2caf59SThomas Veermanexpanded. 5632e2caf59SThomas VeermanThis can cause problems when variable modifiers are used. 5642e2caf59SThomas Veerman.It Ic \&!= 5652e2caf59SThomas VeermanExpand the value and pass it to the shell for execution and assign 5662e2caf59SThomas Veermanthe result to the variable. 5672e2caf59SThomas VeermanAny newlines in the result are replaced with spaces. 5682e2caf59SThomas Veerman.El 5692e2caf59SThomas Veerman.Pp 5702e2caf59SThomas VeermanAny white-space before the assigned 5712e2caf59SThomas Veerman.Ar value 5722e2caf59SThomas Veermanis removed; if the value is being appended, a single space is inserted 5732e2caf59SThomas Veermanbetween the previous contents of the variable and the appended value. 5742e2caf59SThomas Veerman.Pp 5752e2caf59SThomas VeermanVariables are expanded by surrounding the variable name with either 5762e2caf59SThomas Veermancurly braces 5772e2caf59SThomas Veerman.Pq Ql {} 5782e2caf59SThomas Veermanor parentheses 5792e2caf59SThomas Veerman.Pq Ql () 5802e2caf59SThomas Veermanand preceding it with 5812e2caf59SThomas Veermana dollar sign 5822e2caf59SThomas Veerman.Pq Ql \&$ . 5832e2caf59SThomas VeermanIf the variable name contains only a single letter, the surrounding 5842e2caf59SThomas Veermanbraces or parentheses are not required. 5852e2caf59SThomas VeermanThis shorter form is not recommended. 5862e2caf59SThomas Veerman.Pp 5872e2caf59SThomas VeermanIf the variable name contains a dollar, then the name itself is expanded first. 5882e2caf59SThomas VeermanThis allows almost arbitrary variable names, however names containing dollar, 5892e2caf59SThomas Veermanbraces, parenthesis, or whitespace are really best avoided! 5902e2caf59SThomas Veerman.Pp 5912e2caf59SThomas VeermanIf the result of expanding a variable contains a dollar sign 5922e2caf59SThomas Veerman.Pq Ql \&$ 5932e2caf59SThomas Veermanthe string is expanded again. 5942e2caf59SThomas Veerman.Pp 5952e2caf59SThomas VeermanVariable substitution occurs at three distinct times, depending on where 5962e2caf59SThomas Veermanthe variable is being used. 5972e2caf59SThomas Veerman.Bl -enum 5982e2caf59SThomas Veerman.It 5992e2caf59SThomas VeermanVariables in dependency lines are expanded as the line is read. 6002e2caf59SThomas Veerman.It 6012e2caf59SThomas VeermanVariables in shell commands are expanded when the shell command is 6022e2caf59SThomas Veermanexecuted. 6032e2caf59SThomas Veerman.It 6042e2caf59SThomas Veerman.Dq .for 6052e2caf59SThomas Veermanloop index variables are expanded on each loop iteration. 6062e2caf59SThomas VeermanNote that other variables are not expanded inside loops so 6072e2caf59SThomas Veermanthe following example code: 6082e2caf59SThomas Veerman.Bd -literal -offset indent 6092e2caf59SThomas Veerman 6102e2caf59SThomas Veerman.Dv .for i in 1 2 3 6112e2caf59SThomas Veermana+= ${i} 6122e2caf59SThomas Veermanj= ${i} 6132e2caf59SThomas Veermanb+= ${j} 6142e2caf59SThomas Veerman.Dv .endfor 6152e2caf59SThomas Veerman 6162e2caf59SThomas Veermanall: 6172e2caf59SThomas Veerman @echo ${a} 6182e2caf59SThomas Veerman @echo ${b} 6192e2caf59SThomas Veerman 6202e2caf59SThomas Veerman.Ed 6212e2caf59SThomas Veermanwill print: 6222e2caf59SThomas Veerman.Bd -literal -offset indent 6232e2caf59SThomas Veerman1 2 3 6242e2caf59SThomas Veerman3 3 3 6252e2caf59SThomas Veerman 6262e2caf59SThomas Veerman.Ed 6272e2caf59SThomas VeermanBecause while ${a} contains 6282e2caf59SThomas Veerman.Dq 1 2 3 6292e2caf59SThomas Veermanafter the loop is executed, ${b} 6302e2caf59SThomas Veermancontains 6312e2caf59SThomas Veerman.Dq ${j} ${j} ${j} 6322e2caf59SThomas Veermanwhich expands to 6332e2caf59SThomas Veerman.Dq 3 3 3 6342e2caf59SThomas Veermansince after the loop completes ${j} contains 6352e2caf59SThomas Veerman.Dq 3 . 6362e2caf59SThomas Veerman.El 6372e2caf59SThomas Veerman.Ss Variable classes 6382e2caf59SThomas VeermanThe four different classes of variables (in order of increasing precedence) 6392e2caf59SThomas Veermanare: 6402e2caf59SThomas Veerman.Bl -tag -width Ds 6412e2caf59SThomas Veerman.It Environment variables 6422e2caf59SThomas VeermanVariables defined as part of 6432e2caf59SThomas Veerman.Nm Ns 's 6442e2caf59SThomas Veermanenvironment. 6452e2caf59SThomas Veerman.It Global variables 6462e2caf59SThomas VeermanVariables defined in the makefile or in included makefiles. 6472e2caf59SThomas Veerman.It Command line variables 6482e2caf59SThomas VeermanVariables defined as part of the command line. 6492e2caf59SThomas Veerman.It Local variables 6502e2caf59SThomas VeermanVariables that are defined specific to a certain target. 651*0a6a1f1dSLionel Sambuc.El 652*0a6a1f1dSLionel Sambuc.Pp 653*0a6a1f1dSLionel SambucLocal variables are all built in and their values vary magically from 654*0a6a1f1dSLionel Sambuctarget to target. 655*0a6a1f1dSLionel SambucIt is not currently possible to define new local variables. 6562e2caf59SThomas VeermanThe seven local variables are as follows: 657*0a6a1f1dSLionel Sambuc.Bl -tag -width ".ARCHIVE" -offset indent 6582e2caf59SThomas Veerman.It Va .ALLSRC 6592e2caf59SThomas VeermanThe list of all sources for this target; also known as 6602e2caf59SThomas Veerman.Ql Va \&\*[Gt] . 6612e2caf59SThomas Veerman.It Va .ARCHIVE 662*0a6a1f1dSLionel SambucThe name of the archive file; also known as 663*0a6a1f1dSLionel Sambuc.Ql Va \&! . 6642e2caf59SThomas Veerman.It Va .IMPSRC 6652e2caf59SThomas VeermanIn suffix-transformation rules, the name/path of the source from which the 6662e2caf59SThomas Veermantarget is to be transformed (the 6672e2caf59SThomas Veerman.Dq implied 6682e2caf59SThomas Veermansource); also known as 6692e2caf59SThomas Veerman.Ql Va \&\*[Lt] . 6702e2caf59SThomas VeermanIt is not defined in explicit rules. 6712e2caf59SThomas Veerman.It Va .MEMBER 672*0a6a1f1dSLionel SambucThe name of the archive member; also known as 673*0a6a1f1dSLionel Sambuc.Ql Va % . 6742e2caf59SThomas Veerman.It Va .OODATE 6752e2caf59SThomas VeermanThe list of sources for this target that were deemed out-of-date; also 6762e2caf59SThomas Veermanknown as 6772e2caf59SThomas Veerman.Ql Va \&? . 6782e2caf59SThomas Veerman.It Va .PREFIX 6792e2caf59SThomas VeermanThe file prefix of the target, containing only the file portion, no suffix 6802e2caf59SThomas Veermanor preceding directory components; also known as 6812e2caf59SThomas Veerman.Ql Va * . 682*0a6a1f1dSLionel SambucThe suffix must be one of the known suffixes declared with 683*0a6a1f1dSLionel Sambuc.Ic .SUFFIXES 684*0a6a1f1dSLionel Sambucor it will not be recognized. 6852e2caf59SThomas Veerman.It Va .TARGET 6862e2caf59SThomas VeermanThe name of the target; also known as 6872e2caf59SThomas Veerman.Ql Va @ . 6882e2caf59SThomas Veerman.El 6892e2caf59SThomas Veerman.Pp 6902e2caf59SThomas VeermanThe shorter forms 691*0a6a1f1dSLionel Sambuc.Ql ( Va \*[Gt] , 692*0a6a1f1dSLionel Sambuc.Ql Va \&! , 693*0a6a1f1dSLionel Sambuc.Ql Va \*[Lt] , 694*0a6a1f1dSLionel Sambuc.Ql Va % , 6952e2caf59SThomas Veerman.Ql Va \&? , 696*0a6a1f1dSLionel Sambuc.Ql Va * , 6972e2caf59SThomas Veermanand 698*0a6a1f1dSLionel Sambuc.Ql Va @ ) 6992e2caf59SThomas Veermanare permitted for backward 700*0a6a1f1dSLionel Sambuccompatibility with historical makefiles and legacy POSIX make and are 701*0a6a1f1dSLionel Sambucnot recommended. 702*0a6a1f1dSLionel Sambuc.Pp 703*0a6a1f1dSLionel SambucVariants of these variables with the punctuation followed immediately by 704*0a6a1f1dSLionel Sambuc.Ql D 705*0a6a1f1dSLionel Sambucor 706*0a6a1f1dSLionel Sambuc.Ql F , 707*0a6a1f1dSLionel Sambuce.g. 708*0a6a1f1dSLionel Sambuc.Ql Va $(@D) , 709*0a6a1f1dSLionel Sambucare legacy forms equivalent to using the 710*0a6a1f1dSLionel Sambuc.Ql :H 7112e2caf59SThomas Veermanand 712*0a6a1f1dSLionel Sambuc.Ql :T 713*0a6a1f1dSLionel Sambucmodifiers. 714*0a6a1f1dSLionel SambucThese forms are accepted for compatibility with 7152e2caf59SThomas Veerman.At V 716*0a6a1f1dSLionel Sambucmakefiles and POSIX but are not recommended. 7172e2caf59SThomas Veerman.Pp 7182e2caf59SThomas VeermanFour of the local variables may be used in sources on dependency lines 7192e2caf59SThomas Veermanbecause they expand to the proper value for each target on the line. 7202e2caf59SThomas VeermanThese variables are 7212e2caf59SThomas Veerman.Ql Va .TARGET , 7222e2caf59SThomas Veerman.Ql Va .PREFIX , 7232e2caf59SThomas Veerman.Ql Va .ARCHIVE , 7242e2caf59SThomas Veermanand 7252e2caf59SThomas Veerman.Ql Va .MEMBER . 7262e2caf59SThomas Veerman.Ss Additional built-in variables 7272e2caf59SThomas VeermanIn addition, 7282e2caf59SThomas Veerman.Nm 7292e2caf59SThomas Veermansets or knows about the following variables: 7302e2caf59SThomas Veerman.Bl -tag -width .MAKEOVERRIDES 7312e2caf59SThomas Veerman.It Va \&$ 7322e2caf59SThomas VeermanA single dollar sign 7332e2caf59SThomas Veerman.Ql \&$ , 7342e2caf59SThomas Veermani.e. 7352e2caf59SThomas Veerman.Ql \&$$ 7362e2caf59SThomas Veermanexpands to a single dollar 7372e2caf59SThomas Veermansign. 7382e2caf59SThomas Veerman.It Va .ALLTARGETS 7392e2caf59SThomas VeermanThe list of all targets encountered in the Makefile. 7402e2caf59SThomas VeermanIf evaluated during 7412e2caf59SThomas VeermanMakefile parsing, lists only those targets encountered thus far. 7422e2caf59SThomas Veerman.It Va .CURDIR 7432e2caf59SThomas VeermanA path to the directory where 7442e2caf59SThomas Veerman.Nm 7452e2caf59SThomas Veermanwas executed. 7462e2caf59SThomas VeermanRefer to the description of 7472e2caf59SThomas Veerman.Ql Ev PWD 7482e2caf59SThomas Veermanfor more details. 749*0a6a1f1dSLionel Sambuc.It Va .INCLUDEDFROMDIR 750*0a6a1f1dSLionel SambucThe directory of the file this Makefile was included from. 751*0a6a1f1dSLionel Sambuc.It Va .INCLUDEDFROMFILE 752*0a6a1f1dSLionel SambucThe filename of the file this Makefile was included from. 7532e2caf59SThomas Veerman.It Ev MAKE 7542e2caf59SThomas VeermanThe name that 7552e2caf59SThomas Veerman.Nm 7562e2caf59SThomas Veermanwas executed with 7572e2caf59SThomas Veerman.Pq Va argv[0] . 7582e2caf59SThomas VeermanFor compatibility 7592e2caf59SThomas Veerman.Nm 7602e2caf59SThomas Veermanalso sets 7612e2caf59SThomas Veerman.Va .MAKE 7622e2caf59SThomas Veermanwith the same value. 7632e2caf59SThomas VeermanThe preferred variable to use is the environment variable 7642e2caf59SThomas Veerman.Ev MAKE 7652e2caf59SThomas Veermanbecause it is more compatible with other versions of 7662e2caf59SThomas Veerman.Nm 7672e2caf59SThomas Veermanand cannot be confused with the special target with the same name. 7682e2caf59SThomas Veerman.It Va .MAKE.DEPENDFILE 7692e2caf59SThomas VeermanNames the makefile (default 7702e2caf59SThomas Veerman.Ql Pa .depend ) 7712e2caf59SThomas Veermanfrom which generated dependencies are read. 7722bc7c627SLionel Sambuc.It Va .MAKE.EXPAND_VARIABLES 7732bc7c627SLionel SambucA boolean that controls the default behavior of the 7742bc7c627SLionel Sambuc.Fl V 7752bc7c627SLionel Sambucoption. 7762e2caf59SThomas Veerman.It Va .MAKE.EXPORTED 7772e2caf59SThomas VeermanThe list of variables exported by 7782e2caf59SThomas Veerman.Nm . 7792e2caf59SThomas Veerman.It Va .MAKE.JOBS 7802e2caf59SThomas VeermanThe argument to the 7812e2caf59SThomas Veerman.Fl j 7822e2caf59SThomas Veermanoption. 7832e2caf59SThomas Veerman.It Va .MAKE.JOB.PREFIX 7842e2caf59SThomas VeermanIf 7852e2caf59SThomas Veerman.Nm 7862e2caf59SThomas Veermanis run with 7872e2caf59SThomas Veerman.Ar j 7882e2caf59SThomas Veermanthen output for each target is prefixed with a token 7892e2caf59SThomas Veerman.Ql --- target --- 7902e2caf59SThomas Veermanthe first part of which can be controlled via 7912e2caf59SThomas Veerman.Va .MAKE.JOB.PREFIX . 79284d9c625SLionel SambucIf 79384d9c625SLionel Sambuc.Va .MAKE.JOB.PREFIX 79484d9c625SLionel Sambucis empty, no token is printed. 7952e2caf59SThomas Veerman.br 7962e2caf59SThomas VeermanFor example: 7972e2caf59SThomas Veerman.Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}] 7982e2caf59SThomas Veermanwould produce tokens like 7992e2caf59SThomas Veerman.Ql ---make[1234] target --- 8002e2caf59SThomas Veermanmaking it easier to track the degree of parallelism being achieved. 8012e2caf59SThomas Veerman.It Ev MAKEFLAGS 8022e2caf59SThomas VeermanThe environment variable 8032e2caf59SThomas Veerman.Ql Ev MAKEFLAGS 8042e2caf59SThomas Veermanmay contain anything that 8052e2caf59SThomas Veermanmay be specified on 8062e2caf59SThomas Veerman.Nm Ns 's 8072e2caf59SThomas Veermancommand line. 8082e2caf59SThomas VeermanAnything specified on 8092e2caf59SThomas Veerman.Nm Ns 's 8102e2caf59SThomas Veermancommand line is appended to the 8112e2caf59SThomas Veerman.Ql Ev MAKEFLAGS 8122e2caf59SThomas Veermanvariable which is then 8132e2caf59SThomas Veermanentered into the environment for all programs which 8142e2caf59SThomas Veerman.Nm 8152e2caf59SThomas Veermanexecutes. 8162e2caf59SThomas Veerman.It Va .MAKE.LEVEL 8172e2caf59SThomas VeermanThe recursion depth of 8182e2caf59SThomas Veerman.Nm . 8192e2caf59SThomas VeermanThe initial instance of 8202e2caf59SThomas Veerman.Nm 8212e2caf59SThomas Veermanwill be 0, and an incremented value is put into the environment 8222e2caf59SThomas Veermanto be seen by the next generation. 8232e2caf59SThomas VeermanThis allows tests like: 8242e2caf59SThomas Veerman.Li .if ${.MAKE.LEVEL} == 0 8252e2caf59SThomas Veermanto protect things which should only be evaluated in the initial instance of 8262e2caf59SThomas Veerman.Nm . 8272e2caf59SThomas Veerman.It Va .MAKE.MAKEFILE_PREFERENCE 8282e2caf59SThomas VeermanThe ordered list of makefile names 8292e2caf59SThomas Veerman(default 8302e2caf59SThomas Veerman.Ql Pa makefile , 8312e2caf59SThomas Veerman.Ql Pa Makefile ) 8322e2caf59SThomas Veermanthat 8332e2caf59SThomas Veerman.Nm 8342e2caf59SThomas Veermanwill look for. 8352e2caf59SThomas Veerman.It Va .MAKE.MAKEFILES 8362e2caf59SThomas VeermanThe list of makefiles read by 8372e2caf59SThomas Veerman.Nm , 8382e2caf59SThomas Veermanwhich is useful for tracking dependencies. 8392e2caf59SThomas VeermanEach makefile is recorded only once, regardless of the number of times read. 8402e2caf59SThomas Veerman.It Va .MAKE.MODE 8412e2caf59SThomas VeermanProcessed after reading all makefiles. 8422e2caf59SThomas VeermanCan affect the mode that 8432e2caf59SThomas Veerman.Nm 8442e2caf59SThomas Veermanruns in. 8452e2caf59SThomas VeermanIt can contain a number of keywords: 8462e2caf59SThomas Veerman.Bl -hang -width ignore-cmd 8472e2caf59SThomas Veerman.It Pa compat 8482e2caf59SThomas VeermanLike 8492e2caf59SThomas Veerman.Fl B , 8502e2caf59SThomas Veermanputs 8512e2caf59SThomas Veerman.Nm 8522e2caf59SThomas Veermaninto "compat" mode. 8532e2caf59SThomas Veerman.It Pa meta 8542e2caf59SThomas VeermanPuts 8552e2caf59SThomas Veerman.Nm 8562e2caf59SThomas Veermaninto "meta" mode, where meta files are created for each target 8572e2caf59SThomas Veermanto capture the command run, the output generated and if 8582e2caf59SThomas Veerman.Xr filemon 4 8592e2caf59SThomas Veermanis available, the system calls which are of interest to 8602e2caf59SThomas Veerman.Nm . 8612e2caf59SThomas VeermanThe captured output can be very useful when diagnosing errors. 8622e2caf59SThomas Veerman.It Pa curdirOk= Ar bf 8632e2caf59SThomas VeermanNormally 8642e2caf59SThomas Veerman.Nm 8652e2caf59SThomas Veermanwill not create .meta files in 8662e2caf59SThomas Veerman.Ql Va .CURDIR . 8672e2caf59SThomas VeermanThis can be overridden by setting 8682e2caf59SThomas Veerman.Va bf 8692e2caf59SThomas Veermanto a value which represents True. 8702e2caf59SThomas Veerman.It Pa env 8712e2caf59SThomas VeermanFor debugging, it can be useful to inlcude the environment 8722e2caf59SThomas Veermanin the .meta file. 8732e2caf59SThomas Veerman.It Pa verbose 8742e2caf59SThomas VeermanIf in "meta" mode, print a clue about the target being built. 8752e2caf59SThomas VeermanThis is useful if the build is otherwise running silently. 8762e2caf59SThomas VeermanThe message printed the value of: 8772e2caf59SThomas Veerman.Va .MAKE.META.PREFIX . 8782e2caf59SThomas Veerman.It Pa ignore-cmd 8792e2caf59SThomas VeermanSome makefiles have commands which are simply not stable. 8802e2caf59SThomas VeermanThis keyword causes them to be ignored for 8812e2caf59SThomas Veermandetermining whether a target is out of date in "meta" mode. 8822e2caf59SThomas VeermanSee also 8832e2caf59SThomas Veerman.Ic .NOMETA_CMP . 8842e2caf59SThomas Veerman.It Pa silent= Ar bf 8852e2caf59SThomas VeermanIf 8862e2caf59SThomas Veerman.Va bf 8872e2caf59SThomas Veermanis True, when a .meta file is created, mark the target 8882e2caf59SThomas Veerman.Ic .SILENT . 8892e2caf59SThomas Veerman.El 8902e2caf59SThomas Veerman.It Va .MAKE.META.BAILIWICK 8912e2caf59SThomas VeermanIn "meta" mode, provides a list of prefixes which 8922e2caf59SThomas Veermanmatch the directories controlled by 8932e2caf59SThomas Veerman.Nm . 8942e2caf59SThomas VeermanIf a file that was generated outside of 8952e2caf59SThomas Veerman.Va .OBJDIR 8962e2caf59SThomas Veermanbut within said bailiwick is missing, 8972e2caf59SThomas Veermanthe current target is considered out-of-date. 8982e2caf59SThomas Veerman.It Va .MAKE.META.CREATED 8992e2caf59SThomas VeermanIn "meta" mode, this variable contains a list of all the meta files 9002e2caf59SThomas Veermanupdated. 9012e2caf59SThomas VeermanIf not empty, it can be used to trigger processing of 9022e2caf59SThomas Veerman.Va .MAKE.META.FILES . 9032e2caf59SThomas Veerman.It Va .MAKE.META.FILES 9042e2caf59SThomas VeermanIn "meta" mode, this variable contains a list of all the meta files 9052e2caf59SThomas Veermanused (updated or not). 9062e2caf59SThomas VeermanThis list can be used to process the meta files to extract dependency 9072e2caf59SThomas Veermaninformation. 90884d9c625SLionel Sambuc.It Va .MAKE.META.IGNORE_PATHS 90984d9c625SLionel SambucProvides a list of path prefixes that should be ignored; 91084d9c625SLionel Sambucbecause the contents are expected to change over time. 91184d9c625SLionel SambucThe default list includes: 91284d9c625SLionel Sambuc.Ql Pa /dev /etc /proc /tmp /var/run /var/tmp 9132e2caf59SThomas Veerman.It Va .MAKE.META.PREFIX 9142e2caf59SThomas VeermanDefines the message printed for each meta file updated in "meta verbose" mode. 9152e2caf59SThomas VeermanThe default value is: 9162e2caf59SThomas Veerman.Dl Building ${.TARGET:H:tA}/${.TARGET:T} 9172e2caf59SThomas Veerman.It Va .MAKEOVERRIDES 9182e2caf59SThomas VeermanThis variable is used to record the names of variables assigned to 9192e2caf59SThomas Veermanon the command line, so that they may be exported as part of 9202e2caf59SThomas Veerman.Ql Ev MAKEFLAGS . 9212e2caf59SThomas VeermanThis behaviour can be disabled by assigning an empty value to 9222e2caf59SThomas Veerman.Ql Va .MAKEOVERRIDES 9232e2caf59SThomas Veermanwithin a makefile. 9242e2caf59SThomas VeermanExtra variables can be exported from a makefile 9252e2caf59SThomas Veermanby appending their names to 9262e2caf59SThomas Veerman.Ql Va .MAKEOVERRIDES . 9272e2caf59SThomas Veerman.Ql Ev MAKEFLAGS 9282e2caf59SThomas Veermanis re-exported whenever 9292e2caf59SThomas Veerman.Ql Va .MAKEOVERRIDES 9302e2caf59SThomas Veermanis modified. 93184d9c625SLionel Sambuc.It Va .MAKE.PATH_FILEMON 93284d9c625SLionel SambucIf 93384d9c625SLionel Sambuc.Nm 93484d9c625SLionel Sambucwas built with 93584d9c625SLionel Sambuc.Xr filemon 4 93684d9c625SLionel Sambucsupport, this is set to the path of the device node. 93784d9c625SLionel SambucThis allows makefiles to test for this support. 9382e2caf59SThomas Veerman.It Va .MAKE.PID 9392e2caf59SThomas VeermanThe process-id of 9402e2caf59SThomas Veerman.Nm . 9412e2caf59SThomas Veerman.It Va .MAKE.PPID 9422e2caf59SThomas VeermanThe parent process-id of 9432e2caf59SThomas Veerman.Nm . 9442e2caf59SThomas Veerman.It Va MAKE_PRINT_VAR_ON_ERROR 9452e2caf59SThomas VeermanWhen 9462e2caf59SThomas Veerman.Nm 9472e2caf59SThomas Veermanstops due to an error, it prints its name and the value of 9482e2caf59SThomas Veerman.Ql Va .CURDIR 9492e2caf59SThomas Veermanas well as the value of any variables named in 9502e2caf59SThomas Veerman.Ql Va MAKE_PRINT_VAR_ON_ERROR . 9512e2caf59SThomas Veerman.It Va .newline 9522e2caf59SThomas VeermanThis variable is simply assigned a newline character as its value. 9532e2caf59SThomas VeermanThis allows expansions using the 9542e2caf59SThomas Veerman.Cm \&:@ 9552e2caf59SThomas Veermanmodifier to put a newline between 9562e2caf59SThomas Veermaniterations of the loop rather than a space. 9572e2caf59SThomas VeermanFor example, the printing of 9582e2caf59SThomas Veerman.Ql Va MAKE_PRINT_VAR_ON_ERROR 9592e2caf59SThomas Veermancould be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}. 9602e2caf59SThomas Veerman.It Va .OBJDIR 9612e2caf59SThomas VeermanA path to the directory where the targets are built. 9622e2caf59SThomas VeermanIts value is determined by trying to 9632e2caf59SThomas Veerman.Xr chdir 2 9642e2caf59SThomas Veermanto the following directories in order and using the first match: 9652e2caf59SThomas Veerman.Bl -enum 9662e2caf59SThomas Veerman.It 9672e2caf59SThomas Veerman.Ev ${MAKEOBJDIRPREFIX}${.CURDIR} 9682e2caf59SThomas Veerman.Pp 9692e2caf59SThomas Veerman(Only if 9702e2caf59SThomas Veerman.Ql Ev MAKEOBJDIRPREFIX 9712e2caf59SThomas Veermanis set in the environment or on the command line.) 9722e2caf59SThomas Veerman.It 9732e2caf59SThomas Veerman.Ev ${MAKEOBJDIR} 9742e2caf59SThomas Veerman.Pp 9752e2caf59SThomas Veerman(Only if 9762e2caf59SThomas Veerman.Ql Ev MAKEOBJDIR 9772e2caf59SThomas Veermanis set in the environment or on the command line.) 9782e2caf59SThomas Veerman.It 9792e2caf59SThomas Veerman.Ev ${.CURDIR} Ns Pa /obj. Ns Ev ${MACHINE} 9802e2caf59SThomas Veerman.It 9812e2caf59SThomas Veerman.Ev ${.CURDIR} Ns Pa /obj 9822e2caf59SThomas Veerman.It 9832e2caf59SThomas Veerman.Pa /usr/obj/ Ns Ev ${.CURDIR} 9842e2caf59SThomas Veerman.It 9852e2caf59SThomas Veerman.Ev ${.CURDIR} 9862e2caf59SThomas Veerman.El 9872e2caf59SThomas Veerman.Pp 9882e2caf59SThomas VeermanVariable expansion is performed on the value before it's used, 9892e2caf59SThomas Veermanso expressions such as 9902e2caf59SThomas Veerman.Dl ${.CURDIR:S,^/usr/src,/var/obj,} 9912e2caf59SThomas Veermanmay be used. 9922e2caf59SThomas VeermanThis is especially useful with 9932e2caf59SThomas Veerman.Ql Ev MAKEOBJDIR . 9942e2caf59SThomas Veerman.Pp 9952e2caf59SThomas Veerman.Ql Va .OBJDIR 996*0a6a1f1dSLionel Sambucmay be modified in the makefile via the special target 997*0a6a1f1dSLionel Sambuc.Ql Ic .OBJDIR . 9982e2caf59SThomas VeermanIn all cases, 9992e2caf59SThomas Veerman.Nm 10002e2caf59SThomas Veermanwill 10012e2caf59SThomas Veerman.Xr chdir 2 1002*0a6a1f1dSLionel Sambucto the specified directory if it exists, and set 10032e2caf59SThomas Veerman.Ql Va .OBJDIR 1004*0a6a1f1dSLionel Sambucand 10052e2caf59SThomas Veerman.Ql Ev PWD 10062e2caf59SThomas Veermanto that directory before executing any targets. 10072e2caf59SThomas Veerman. 10082e2caf59SThomas Veerman.It Va .PARSEDIR 10092e2caf59SThomas VeermanA path to the directory of the current 10102e2caf59SThomas Veerman.Ql Pa Makefile 10112e2caf59SThomas Veermanbeing parsed. 10122e2caf59SThomas Veerman.It Va .PARSEFILE 10132e2caf59SThomas VeermanThe basename of the current 10142e2caf59SThomas Veerman.Ql Pa Makefile 10152e2caf59SThomas Veermanbeing parsed. 10162e2caf59SThomas VeermanThis variable and 10172e2caf59SThomas Veerman.Ql Va .PARSEDIR 10182e2caf59SThomas Veermanare both set only while the 10192e2caf59SThomas Veerman.Ql Pa Makefiles 10202e2caf59SThomas Veermanare being parsed. 10212e2caf59SThomas VeermanIf you want to retain their current values, assign them to a variable 10222e2caf59SThomas Veermanusing assignment with expansion: 10232e2caf59SThomas Veerman.Pq Ql Cm \&:= . 10242e2caf59SThomas Veerman.It Va .PATH 10252e2caf59SThomas VeermanA variable that represents the list of directories that 10262e2caf59SThomas Veerman.Nm 10272e2caf59SThomas Veermanwill search for files. 10282e2caf59SThomas VeermanThe search list should be updated using the target 10292e2caf59SThomas Veerman.Ql Va .PATH 10302e2caf59SThomas Veermanrather than the variable. 10312e2caf59SThomas Veerman.It Ev PWD 10322e2caf59SThomas VeermanAlternate path to the current directory. 10332e2caf59SThomas Veerman.Nm 10342e2caf59SThomas Veermannormally sets 10352e2caf59SThomas Veerman.Ql Va .CURDIR 10362e2caf59SThomas Veermanto the canonical path given by 10372e2caf59SThomas Veerman.Xr getcwd 3 . 10382e2caf59SThomas VeermanHowever, if the environment variable 10392e2caf59SThomas Veerman.Ql Ev PWD 10402e2caf59SThomas Veermanis set and gives a path to the current directory, then 10412e2caf59SThomas Veerman.Nm 10422e2caf59SThomas Veermansets 10432e2caf59SThomas Veerman.Ql Va .CURDIR 10442e2caf59SThomas Veermanto the value of 10452e2caf59SThomas Veerman.Ql Ev PWD 10462e2caf59SThomas Veermaninstead. 10472e2caf59SThomas VeermanThis behaviour is disabled if 10482e2caf59SThomas Veerman.Ql Ev MAKEOBJDIRPREFIX 10492e2caf59SThomas Veermanis set or 10502e2caf59SThomas Veerman.Ql Ev MAKEOBJDIR 10512e2caf59SThomas Veermancontains a variable transform. 10522e2caf59SThomas Veerman.Ql Ev PWD 10532e2caf59SThomas Veermanis set to the value of 10542e2caf59SThomas Veerman.Ql Va .OBJDIR 10552e2caf59SThomas Veermanfor all programs which 10562e2caf59SThomas Veerman.Nm 10572e2caf59SThomas Veermanexecutes. 10582e2caf59SThomas Veerman.It Ev .TARGETS 10592e2caf59SThomas VeermanThe list of targets explicitly specified on the command line, if any. 10602e2caf59SThomas Veerman.It Ev VPATH 10612e2caf59SThomas VeermanColon-separated 10622e2caf59SThomas Veerman.Pq Dq \&: 10632e2caf59SThomas Veermanlists of directories that 10642e2caf59SThomas Veerman.Nm 10652e2caf59SThomas Veermanwill search for files. 10662e2caf59SThomas VeermanThe variable is supported for compatibility with old make programs only, 10672e2caf59SThomas Veermanuse 10682e2caf59SThomas Veerman.Ql Va .PATH 10692e2caf59SThomas Veermaninstead. 10702e2caf59SThomas Veerman.El 10712e2caf59SThomas Veerman.Ss Variable modifiers 10722e2caf59SThomas VeermanVariable expansion may be modified to select or modify each word of the 10732e2caf59SThomas Veermanvariable (where a 10742e2caf59SThomas Veerman.Dq word 10752e2caf59SThomas Veermanis white-space delimited sequence of characters). 10762e2caf59SThomas VeermanThe general format of a variable expansion is as follows: 10772e2caf59SThomas Veerman.Pp 10782e2caf59SThomas Veerman.Dl ${variable[:modifier[:...]]} 10792e2caf59SThomas Veerman.Pp 10802e2caf59SThomas VeermanEach modifier begins with a colon, 10812e2caf59SThomas Veermanwhich may be escaped with a backslash 10822e2caf59SThomas Veerman.Pq Ql \e . 10832e2caf59SThomas Veerman.Pp 10842e2caf59SThomas VeermanA set of modifiers can be specified via a variable, as follows: 10852e2caf59SThomas Veerman.Pp 10862e2caf59SThomas Veerman.Dl modifier_variable=modifier[:...] 10872e2caf59SThomas Veerman.Dl ${variable:${modifier_variable}[:...]} 10882e2caf59SThomas Veerman.Pp 10892e2caf59SThomas VeermanIn this case the first modifier in the modifier_variable does not 10902e2caf59SThomas Veermanstart with a colon, since that must appear in the referencing 10912e2caf59SThomas Veermanvariable. 10922e2caf59SThomas VeermanIf any of the modifiers in the modifier_variable contain a dollar sign 10932e2caf59SThomas Veerman.Pq Ql $ , 10942e2caf59SThomas Veermanthese must be doubled to avoid early expansion. 10952e2caf59SThomas Veerman.Pp 10962e2caf59SThomas VeermanThe supported modifiers are: 10972e2caf59SThomas Veerman.Bl -tag -width EEE 10982e2caf59SThomas Veerman.It Cm \&:E 10992e2caf59SThomas VeermanReplaces each word in the variable with its suffix. 11002e2caf59SThomas Veerman.It Cm \&:H 11012e2caf59SThomas VeermanReplaces each word in the variable with everything but the last component. 11022e2caf59SThomas Veerman.It Cm \&:M Ns Ar pattern 11032e2caf59SThomas VeermanSelect only those words that match 11042e2caf59SThomas Veerman.Ar pattern . 11052e2caf59SThomas VeermanThe standard shell wildcard characters 11062e2caf59SThomas Veerman.Pf ( Ql * , 11072e2caf59SThomas Veerman.Ql \&? , 11082e2caf59SThomas Veermanand 11092e2caf59SThomas Veerman.Ql Oo Oc ) 11102e2caf59SThomas Veermanmay 11112e2caf59SThomas Veermanbe used. 11122e2caf59SThomas VeermanThe wildcard characters may be escaped with a backslash 11132e2caf59SThomas Veerman.Pq Ql \e . 111484d9c625SLionel SambucAs a consequence of the way values are split into words, matched, 111584d9c625SLionel Sambucand then joined, a construct like 111684d9c625SLionel Sambuc.Dl ${VAR:M*} 111784d9c625SLionel Sambucwill normalise the inter-word spacing, removing all leading and 111884d9c625SLionel Sambuctrailing space, and converting multiple consecutive spaces 111984d9c625SLionel Sambucto single spaces. 112084d9c625SLionel Sambuc. 11212e2caf59SThomas Veerman.It Cm \&:N Ns Ar pattern 11222e2caf59SThomas VeermanThis is identical to 11232e2caf59SThomas Veerman.Ql Cm \&:M , 11242e2caf59SThomas Veermanbut selects all words which do not match 11252e2caf59SThomas Veerman.Ar pattern . 11262e2caf59SThomas Veerman.It Cm \&:O 11272e2caf59SThomas VeermanOrder every word in variable alphabetically. 11282e2caf59SThomas VeermanTo sort words in 11292e2caf59SThomas Veermanreverse order use the 11302e2caf59SThomas Veerman.Ql Cm \&:O:[-1..1] 11312e2caf59SThomas Veermancombination of modifiers. 11322e2caf59SThomas Veerman.It Cm \&:Ox 11332e2caf59SThomas VeermanRandomize words in variable. 11342e2caf59SThomas VeermanThe results will be different each time you are referring to the 11352e2caf59SThomas Veermanmodified variable; use the assignment with expansion 11362e2caf59SThomas Veerman.Pq Ql Cm \&:= 11372e2caf59SThomas Veermanto prevent such behaviour. 11382e2caf59SThomas VeermanFor example, 11392e2caf59SThomas Veerman.Bd -literal -offset indent 11402e2caf59SThomas VeermanLIST= uno due tre quattro 11412e2caf59SThomas VeermanRANDOM_LIST= ${LIST:Ox} 11422e2caf59SThomas VeermanSTATIC_RANDOM_LIST:= ${LIST:Ox} 11432e2caf59SThomas Veerman 11442e2caf59SThomas Veermanall: 11452e2caf59SThomas Veerman @echo "${RANDOM_LIST}" 11462e2caf59SThomas Veerman @echo "${RANDOM_LIST}" 11472e2caf59SThomas Veerman @echo "${STATIC_RANDOM_LIST}" 11482e2caf59SThomas Veerman @echo "${STATIC_RANDOM_LIST}" 11492e2caf59SThomas Veerman.Ed 11502e2caf59SThomas Veermanmay produce output similar to: 11512e2caf59SThomas Veerman.Bd -literal -offset indent 11522e2caf59SThomas Veermanquattro due tre uno 11532e2caf59SThomas Veermantre due quattro uno 11542e2caf59SThomas Veermandue uno quattro tre 11552e2caf59SThomas Veermandue uno quattro tre 11562e2caf59SThomas Veerman.Ed 11572e2caf59SThomas Veerman.It Cm \&:Q 11582e2caf59SThomas VeermanQuotes every shell meta-character in the variable, so that it can be passed 11592e2caf59SThomas Veermansafely through recursive invocations of 11602e2caf59SThomas Veerman.Nm . 11612e2caf59SThomas Veerman.It Cm \&:R 11622e2caf59SThomas VeermanReplaces each word in the variable with everything but its suffix. 11632e2caf59SThomas Veerman.It Cm \&:gmtime 11642e2caf59SThomas VeermanThe value is a format string for 11652e2caf59SThomas Veerman.Xr strftime 3 , 11662e2caf59SThomas Veermanusing the current 11672e2caf59SThomas Veerman.Xr gmtime 3 . 11682e2caf59SThomas Veerman.It Cm \&:hash 11692e2caf59SThomas VeermanCompute a 32bit hash of the value and encode it as hex digits. 11702e2caf59SThomas Veerman.It Cm \&:localtime 11712e2caf59SThomas VeermanThe value is a format string for 11722e2caf59SThomas Veerman.Xr strftime 3 , 11732e2caf59SThomas Veermanusing the current 11742e2caf59SThomas Veerman.Xr localtime 3 . 11752e2caf59SThomas Veerman.It Cm \&:tA 11762e2caf59SThomas VeermanAttempt to convert variable to an absolute path using 11772e2caf59SThomas Veerman.Xr realpath 3 , 11782e2caf59SThomas Veermanif that fails, the value is unchanged. 11792e2caf59SThomas Veerman.It Cm \&:tl 11802e2caf59SThomas VeermanConverts variable to lower-case letters. 11812e2caf59SThomas Veerman.It Cm \&:ts Ns Ar c 11822e2caf59SThomas VeermanWords in the variable are normally separated by a space on expansion. 11832e2caf59SThomas VeermanThis modifier sets the separator to the character 11842e2caf59SThomas Veerman.Ar c . 11852e2caf59SThomas VeermanIf 11862e2caf59SThomas Veerman.Ar c 11872e2caf59SThomas Veermanis omitted, then no separator is used. 11882e2caf59SThomas VeermanThe common escapes (including octal numeric codes), work as expected. 11892e2caf59SThomas Veerman.It Cm \&:tu 11902e2caf59SThomas VeermanConverts variable to upper-case letters. 11912e2caf59SThomas Veerman.It Cm \&:tW 11922e2caf59SThomas VeermanCauses the value to be treated as a single word 11932e2caf59SThomas Veerman(possibly containing embedded white space). 11942e2caf59SThomas VeermanSee also 11952e2caf59SThomas Veerman.Ql Cm \&:[*] . 11962e2caf59SThomas Veerman.It Cm \&:tw 11972e2caf59SThomas VeermanCauses the value to be treated as a sequence of 11982e2caf59SThomas Veermanwords delimited by white space. 11992e2caf59SThomas VeermanSee also 12002e2caf59SThomas Veerman.Ql Cm \&:[@] . 12012e2caf59SThomas Veerman.Sm off 12022e2caf59SThomas Veerman.It Cm \&:S No \&/ Ar old_string No \&/ Ar new_string No \&/ Op Cm 1gW 12032e2caf59SThomas Veerman.Sm on 12042e2caf59SThomas VeermanModify the first occurrence of 12052e2caf59SThomas Veerman.Ar old_string 12062e2caf59SThomas Veermanin the variable's value, replacing it with 12072e2caf59SThomas Veerman.Ar new_string . 12082e2caf59SThomas VeermanIf a 12092e2caf59SThomas Veerman.Ql g 12102e2caf59SThomas Veermanis appended to the last slash of the pattern, all occurrences 12112e2caf59SThomas Veermanin each word are replaced. 12122e2caf59SThomas VeermanIf a 12132e2caf59SThomas Veerman.Ql 1 12142e2caf59SThomas Veermanis appended to the last slash of the pattern, only the first word 12152e2caf59SThomas Veermanis affected. 12162e2caf59SThomas VeermanIf a 12172e2caf59SThomas Veerman.Ql W 12182e2caf59SThomas Veermanis appended to the last slash of the pattern, 12192e2caf59SThomas Veermanthen the value is treated as a single word 12202e2caf59SThomas Veerman(possibly containing embedded white space). 12212e2caf59SThomas VeermanIf 12222e2caf59SThomas Veerman.Ar old_string 12232e2caf59SThomas Veermanbegins with a caret 12242e2caf59SThomas Veerman.Pq Ql ^ , 12252e2caf59SThomas Veerman.Ar old_string 12262e2caf59SThomas Veermanis anchored at the beginning of each word. 12272e2caf59SThomas VeermanIf 12282e2caf59SThomas Veerman.Ar old_string 12292e2caf59SThomas Veermanends with a dollar sign 12302e2caf59SThomas Veerman.Pq Ql \&$ , 12312e2caf59SThomas Veermanit is anchored at the end of each word. 12322e2caf59SThomas VeermanInside 12332e2caf59SThomas Veerman.Ar new_string , 12342e2caf59SThomas Veermanan ampersand 12352e2caf59SThomas Veerman.Pq Ql \*[Am] 12362e2caf59SThomas Veermanis replaced by 12372e2caf59SThomas Veerman.Ar old_string 12382e2caf59SThomas Veerman(without any 12392e2caf59SThomas Veerman.Ql ^ 12402e2caf59SThomas Veermanor 12412e2caf59SThomas Veerman.Ql \&$ ) . 12422e2caf59SThomas VeermanAny character may be used as a delimiter for the parts of the modifier 12432e2caf59SThomas Veermanstring. 12442e2caf59SThomas VeermanThe anchoring, ampersand and delimiter characters may be escaped with a 12452e2caf59SThomas Veermanbackslash 12462e2caf59SThomas Veerman.Pq Ql \e . 12472e2caf59SThomas Veerman.Pp 12482e2caf59SThomas VeermanVariable expansion occurs in the normal fashion inside both 12492e2caf59SThomas Veerman.Ar old_string 12502e2caf59SThomas Veermanand 12512e2caf59SThomas Veerman.Ar new_string 12522e2caf59SThomas Veermanwith the single exception that a backslash is used to prevent the expansion 12532e2caf59SThomas Veermanof a dollar sign 12542e2caf59SThomas Veerman.Pq Ql \&$ , 12552e2caf59SThomas Veermannot a preceding dollar sign as is usual. 12562e2caf59SThomas Veerman.Sm off 12572e2caf59SThomas Veerman.It Cm \&:C No \&/ Ar pattern No \&/ Ar replacement No \&/ Op Cm 1gW 12582e2caf59SThomas Veerman.Sm on 12592e2caf59SThomas VeermanThe 12602e2caf59SThomas Veerman.Cm \&:C 12612e2caf59SThomas Veermanmodifier is just like the 12622e2caf59SThomas Veerman.Cm \&:S 12632e2caf59SThomas Veermanmodifier except that the old and new strings, instead of being 126484d9c625SLionel Sambucsimple strings, are an extended regular expression (see 12652e2caf59SThomas Veerman.Xr regex 3 ) 12662e2caf59SThomas Veermanstring 12672e2caf59SThomas Veerman.Ar pattern 12682e2caf59SThomas Veermanand an 12692e2caf59SThomas Veerman.Xr ed 1 Ns \-style 12702e2caf59SThomas Veermanstring 12712e2caf59SThomas Veerman.Ar replacement . 12722e2caf59SThomas VeermanNormally, the first occurrence of the pattern 12732e2caf59SThomas Veerman.Ar pattern 12742e2caf59SThomas Veermanin each word of the value is substituted with 12752e2caf59SThomas Veerman.Ar replacement . 12762e2caf59SThomas VeermanThe 12772e2caf59SThomas Veerman.Ql 1 12782e2caf59SThomas Veermanmodifier causes the substitution to apply to at most one word; the 12792e2caf59SThomas Veerman.Ql g 12802e2caf59SThomas Veermanmodifier causes the substitution to apply to as many instances of the 12812e2caf59SThomas Veermansearch pattern 12822e2caf59SThomas Veerman.Ar pattern 12832e2caf59SThomas Veermanas occur in the word or words it is found in; the 12842e2caf59SThomas Veerman.Ql W 12852e2caf59SThomas Veermanmodifier causes the value to be treated as a single word 12862e2caf59SThomas Veerman(possibly containing embedded white space). 12872e2caf59SThomas VeermanNote that 12882e2caf59SThomas Veerman.Ql 1 12892e2caf59SThomas Veermanand 12902e2caf59SThomas Veerman.Ql g 12912e2caf59SThomas Veermanare orthogonal; the former specifies whether multiple words are 12922e2caf59SThomas Veermanpotentially affected, the latter whether multiple substitutions can 12932e2caf59SThomas Veermanpotentially occur within each affected word. 1294*0a6a1f1dSLionel Sambuc.Pp 1295*0a6a1f1dSLionel SambucAs for the 1296*0a6a1f1dSLionel Sambuc.Cm \&:S 1297*0a6a1f1dSLionel Sambucmodifier, the 1298*0a6a1f1dSLionel Sambuc.Ar pattern 1299*0a6a1f1dSLionel Sambucand 1300*0a6a1f1dSLionel Sambuc.Ar replacement 1301*0a6a1f1dSLionel Sambucare subjected to variable expansion before being parsed as 1302*0a6a1f1dSLionel Sambucregular expressions. 13032e2caf59SThomas Veerman.It Cm \&:T 13042e2caf59SThomas VeermanReplaces each word in the variable with its last component. 13052e2caf59SThomas Veerman.It Cm \&:u 13062e2caf59SThomas VeermanRemove adjacent duplicate words (like 13072e2caf59SThomas Veerman.Xr uniq 1 ) . 13082e2caf59SThomas Veerman.Sm off 13092e2caf59SThomas Veerman.It Cm \&:\&? Ar true_string Cm \&: Ar false_string 13102e2caf59SThomas Veerman.Sm on 13112e2caf59SThomas VeermanIf the variable name (not its value), when parsed as a .if conditional 13122e2caf59SThomas Veermanexpression, evaluates to true, return as its value the 13132e2caf59SThomas Veerman.Ar true_string , 13142e2caf59SThomas Veermanotherwise return the 13152e2caf59SThomas Veerman.Ar false_string . 13162e2caf59SThomas VeermanSince the variable name is used as the expression, \&:\&? must be the 13172e2caf59SThomas Veermanfirst modifier after the variable name itself - which will, of course, 13182e2caf59SThomas Veermanusually contain variable expansions. 13192e2caf59SThomas VeermanA common error is trying to use expressions like 13202e2caf59SThomas Veerman.Dl ${NUMBERS:M42:?match:no} 13212e2caf59SThomas Veermanwhich actually tests defined(NUMBERS), 13222e2caf59SThomas Veermanto determine is any words match "42" you need to use something like: 13232e2caf59SThomas Veerman.Dl ${"${NUMBERS:M42}" != \&"\&":?match:no} . 13242e2caf59SThomas Veerman.It Ar :old_string=new_string 13252e2caf59SThomas VeermanThis is the 13262e2caf59SThomas Veerman.At V 13272e2caf59SThomas Veermanstyle variable substitution. 13282e2caf59SThomas VeermanIt must be the last modifier specified. 13292e2caf59SThomas VeermanIf 13302e2caf59SThomas Veerman.Ar old_string 13312e2caf59SThomas Veermanor 13322e2caf59SThomas Veerman.Ar new_string 13332e2caf59SThomas Veermando not contain the pattern matching character 13342e2caf59SThomas Veerman.Ar % 13352e2caf59SThomas Veermanthen it is assumed that they are 13362e2caf59SThomas Veermananchored at the end of each word, so only suffixes or entire 13372e2caf59SThomas Veermanwords may be replaced. 13382e2caf59SThomas VeermanOtherwise 13392e2caf59SThomas Veerman.Ar % 13402e2caf59SThomas Veermanis the substring of 13412e2caf59SThomas Veerman.Ar old_string 13422e2caf59SThomas Veermanto be replaced in 13432e2caf59SThomas Veerman.Ar new_string . 13442e2caf59SThomas Veerman.Pp 13452e2caf59SThomas VeermanVariable expansion occurs in the normal fashion inside both 13462e2caf59SThomas Veerman.Ar old_string 13472e2caf59SThomas Veermanand 13482e2caf59SThomas Veerman.Ar new_string 13492e2caf59SThomas Veermanwith the single exception that a backslash is used to prevent the 13502e2caf59SThomas Veermanexpansion of a dollar sign 13512e2caf59SThomas Veerman.Pq Ql \&$ , 13522e2caf59SThomas Veermannot a preceding dollar sign as is usual. 13532e2caf59SThomas Veerman.Sm off 13542e2caf59SThomas Veerman.It Cm \&:@ Ar temp Cm @ Ar string Cm @ 13552e2caf59SThomas Veerman.Sm on 13562e2caf59SThomas VeermanThis is the loop expansion mechanism from the OSF Development 13572e2caf59SThomas VeermanEnvironment (ODE) make. 13582e2caf59SThomas VeermanUnlike 13592e2caf59SThomas Veerman.Cm \&.for 13602e2caf59SThomas Veermanloops expansion occurs at the time of 13612e2caf59SThomas Veermanreference. 13622e2caf59SThomas VeermanAssign 13632e2caf59SThomas Veerman.Ar temp 13642e2caf59SThomas Veermanto each word in the variable and evaluate 13652e2caf59SThomas Veerman.Ar string . 13662e2caf59SThomas VeermanThe ODE convention is that 13672e2caf59SThomas Veerman.Ar temp 13682e2caf59SThomas Veermanshould start and end with a period. 13692e2caf59SThomas VeermanFor example. 13702e2caf59SThomas Veerman.Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@} 13712e2caf59SThomas Veerman.Pp 137284d9c625SLionel SambucHowever a single character variable is often more readable: 13732e2caf59SThomas Veerman.Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@} 13742e2caf59SThomas Veerman.It Cm \&:U Ns Ar newval 13752e2caf59SThomas VeermanIf the variable is undefined 13762e2caf59SThomas Veerman.Ar newval 13772e2caf59SThomas Veermanis the value. 13782e2caf59SThomas VeermanIf the variable is defined, the existing value is returned. 13792e2caf59SThomas VeermanThis is another ODE make feature. 13802e2caf59SThomas VeermanIt is handy for setting per-target CFLAGS for instance: 13812e2caf59SThomas Veerman.Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}} 13822e2caf59SThomas VeermanIf a value is only required if the variable is undefined, use: 13832e2caf59SThomas Veerman.Dl ${VAR:D:Unewval} 13842e2caf59SThomas Veerman.It Cm \&:D Ns Ar newval 13852e2caf59SThomas VeermanIf the variable is defined 13862e2caf59SThomas Veerman.Ar newval 13872e2caf59SThomas Veermanis the value. 13882e2caf59SThomas Veerman.It Cm \&:L 13892e2caf59SThomas VeermanThe name of the variable is the value. 13902e2caf59SThomas Veerman.It Cm \&:P 13912e2caf59SThomas VeermanThe path of the node which has the same name as the variable 13922e2caf59SThomas Veermanis the value. 13932e2caf59SThomas VeermanIf no such node exists or its path is null, then the 13942e2caf59SThomas Veermanname of the variable is used. 13952e2caf59SThomas VeermanIn order for this modifier to work, the name (node) must at least have 13962e2caf59SThomas Veermanappeared on the rhs of a dependency. 13972e2caf59SThomas Veerman.Sm off 13982e2caf59SThomas Veerman.It Cm \&:\&! Ar cmd Cm \&! 13992e2caf59SThomas Veerman.Sm on 14002e2caf59SThomas VeermanThe output of running 14012e2caf59SThomas Veerman.Ar cmd 14022e2caf59SThomas Veermanis the value. 14032e2caf59SThomas Veerman.It Cm \&:sh 14042e2caf59SThomas VeermanIf the variable is non-empty it is run as a command and the output 14052e2caf59SThomas Veermanbecomes the new value. 14062e2caf59SThomas Veerman.It Cm \&::= Ns Ar str 14072e2caf59SThomas VeermanThe variable is assigned the value 14082e2caf59SThomas Veerman.Ar str 14092e2caf59SThomas Veermanafter substitution. 14102e2caf59SThomas VeermanThis modifier and its variations are useful in 14112e2caf59SThomas Veermanobscure situations such as wanting to set a variable when shell commands 14122e2caf59SThomas Veermanare being parsed. 14132e2caf59SThomas VeermanThese assignment modifiers always expand to 14142e2caf59SThomas Veermannothing, so if appearing in a rule line by themselves should be 14152e2caf59SThomas Veermanpreceded with something to keep 14162e2caf59SThomas Veerman.Nm 14172e2caf59SThomas Veermanhappy. 14182e2caf59SThomas Veerman.Pp 14192e2caf59SThomas VeermanThe 14202e2caf59SThomas Veerman.Ql Cm \&:: 14212e2caf59SThomas Veermanhelps avoid false matches with the 14222e2caf59SThomas Veerman.At V 14232e2caf59SThomas Veermanstyle 14242e2caf59SThomas Veerman.Cm \&:= 14252e2caf59SThomas Veermanmodifier and since substitution always occurs the 14262e2caf59SThomas Veerman.Cm \&::= 14272e2caf59SThomas Veermanform is vaguely appropriate. 14282e2caf59SThomas Veerman.It Cm \&::?= Ns Ar str 14292e2caf59SThomas VeermanAs for 14302e2caf59SThomas Veerman.Cm \&::= 14312e2caf59SThomas Veermanbut only if the variable does not already have a value. 14322e2caf59SThomas Veerman.It Cm \&::+= Ns Ar str 14332e2caf59SThomas VeermanAppend 14342e2caf59SThomas Veerman.Ar str 14352e2caf59SThomas Veermanto the variable. 14362e2caf59SThomas Veerman.It Cm \&::!= Ns Ar cmd 14372e2caf59SThomas VeermanAssign the output of 14382e2caf59SThomas Veerman.Ar cmd 14392e2caf59SThomas Veermanto the variable. 14402e2caf59SThomas Veerman.It Cm \&:\&[ Ns Ar range Ns Cm \&] 14412e2caf59SThomas VeermanSelects one or more words from the value, 14422e2caf59SThomas Veermanor performs other operations related to the way in which the 14432e2caf59SThomas Veermanvalue is divided into words. 14442e2caf59SThomas Veerman.Pp 14452e2caf59SThomas VeermanOrdinarily, a value is treated as a sequence of words 14462e2caf59SThomas Veermandelimited by white space. 14472e2caf59SThomas VeermanSome modifiers suppress this behaviour, 14482e2caf59SThomas Veermancausing a value to be treated as a single word 14492e2caf59SThomas Veerman(possibly containing embedded white space). 14502e2caf59SThomas VeermanAn empty value, or a value that consists entirely of white-space, 14512e2caf59SThomas Veermanis treated as a single word. 14522e2caf59SThomas VeermanFor the purposes of the 14532e2caf59SThomas Veerman.Ql Cm \&:[] 14542e2caf59SThomas Veermanmodifier, the words are indexed both forwards using positive integers 14552e2caf59SThomas Veerman(where index 1 represents the first word), 14562e2caf59SThomas Veermanand backwards using negative integers 14572e2caf59SThomas Veerman(where index \-1 represents the last word). 14582e2caf59SThomas Veerman.Pp 14592e2caf59SThomas VeermanThe 14602e2caf59SThomas Veerman.Ar range 14612e2caf59SThomas Veermanis subjected to variable expansion, and the expanded result is 14622e2caf59SThomas Veermanthen interpreted as follows: 14632e2caf59SThomas Veerman.Bl -tag -width index 14642e2caf59SThomas Veerman.\" :[n] 14652e2caf59SThomas Veerman.It Ar index 14662e2caf59SThomas VeermanSelects a single word from the value. 14672e2caf59SThomas Veerman.\" :[start..end] 14682e2caf59SThomas Veerman.It Ar start Ns Cm \&.. Ns Ar end 14692e2caf59SThomas VeermanSelects all words from 14702e2caf59SThomas Veerman.Ar start 14712e2caf59SThomas Veermanto 14722e2caf59SThomas Veerman.Ar end , 14732e2caf59SThomas Veermaninclusive. 14742e2caf59SThomas VeermanFor example, 14752e2caf59SThomas Veerman.Ql Cm \&:[2..-1] 14762e2caf59SThomas Veermanselects all words from the second word to the last word. 14772e2caf59SThomas VeermanIf 14782e2caf59SThomas Veerman.Ar start 14792e2caf59SThomas Veermanis greater than 14802e2caf59SThomas Veerman.Ar end , 14812e2caf59SThomas Veermanthen the words are output in reverse order. 14822e2caf59SThomas VeermanFor example, 14832e2caf59SThomas Veerman.Ql Cm \&:[-1..1] 14842e2caf59SThomas Veermanselects all the words from last to first. 14852e2caf59SThomas Veerman.\" :[*] 14862e2caf59SThomas Veerman.It Cm \&* 14872e2caf59SThomas VeermanCauses subsequent modifiers to treat the value as a single word 14882e2caf59SThomas Veerman(possibly containing embedded white space). 14892e2caf59SThomas VeermanAnalogous to the effect of 14902e2caf59SThomas Veerman\&"$*\&" 14912e2caf59SThomas Veermanin Bourne shell. 14922e2caf59SThomas Veerman.\" :[0] 14932e2caf59SThomas Veerman.It 0 14942e2caf59SThomas VeermanMeans the same as 14952e2caf59SThomas Veerman.Ql Cm \&:[*] . 14962e2caf59SThomas Veerman.\" :[*] 14972e2caf59SThomas Veerman.It Cm \&@ 14982e2caf59SThomas VeermanCauses subsequent modifiers to treat the value as a sequence of words 14992e2caf59SThomas Veermandelimited by white space. 15002e2caf59SThomas VeermanAnalogous to the effect of 15012e2caf59SThomas Veerman\&"$@\&" 15022e2caf59SThomas Veermanin Bourne shell. 15032e2caf59SThomas Veerman.\" :[#] 15042e2caf59SThomas Veerman.It Cm \&# 15052e2caf59SThomas VeermanReturns the number of words in the value. 15062e2caf59SThomas Veerman.El \" :[range] 15072e2caf59SThomas Veerman.El 15082e2caf59SThomas Veerman.Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS 15092e2caf59SThomas VeermanMakefile inclusion, conditional structures and for loops reminiscent 15102e2caf59SThomas Veermanof the C programming language are provided in 15112e2caf59SThomas Veerman.Nm . 15122e2caf59SThomas VeermanAll such structures are identified by a line beginning with a single 15132e2caf59SThomas Veermandot 15142e2caf59SThomas Veerman.Pq Ql \&. 15152e2caf59SThomas Veermancharacter. 15162e2caf59SThomas VeermanFiles are included with either 15172e2caf59SThomas Veerman.Cm \&.include Aq Ar file 15182e2caf59SThomas Veermanor 15192e2caf59SThomas Veerman.Cm \&.include Pf \*q Ar file Ns \*q . 15202e2caf59SThomas VeermanVariables between the angle brackets or double quotes are expanded 15212e2caf59SThomas Veermanto form the file name. 15222e2caf59SThomas VeermanIf angle brackets are used, the included makefile is expected to be in 15232e2caf59SThomas Veermanthe system makefile directory. 15242e2caf59SThomas VeermanIf double quotes are used, the including makefile's directory and any 15252e2caf59SThomas Veermandirectories specified using the 15262e2caf59SThomas Veerman.Fl I 15272e2caf59SThomas Veermanoption are searched before the system 15282e2caf59SThomas Veermanmakefile directory. 15292e2caf59SThomas VeermanFor compatibility with other versions of 15302e2caf59SThomas Veerman.Nm 15312e2caf59SThomas Veerman.Ql include file ... 15322e2caf59SThomas Veermanis also accepted. 15332e2caf59SThomas VeermanIf the include statement is written as 15342e2caf59SThomas Veerman.Cm .-include 15352e2caf59SThomas Veermanor as 15362e2caf59SThomas Veerman.Cm .sinclude 15372e2caf59SThomas Veermanthen errors locating and/or opening include files are ignored. 15382e2caf59SThomas Veerman.Pp 15392e2caf59SThomas VeermanConditional expressions are also preceded by a single dot as the first 15402e2caf59SThomas Veermancharacter of a line. 15412e2caf59SThomas VeermanThe possible conditionals are as follows: 15422e2caf59SThomas Veerman.Bl -tag -width Ds 15432e2caf59SThomas Veerman.It Ic .error Ar message 15442e2caf59SThomas VeermanThe message is printed along with the name of the makefile and line number, 15452e2caf59SThomas Veermanthen 15462e2caf59SThomas Veerman.Nm 15472e2caf59SThomas Veermanwill exit. 15482e2caf59SThomas Veerman.It Ic .export Ar variable ... 15492e2caf59SThomas VeermanExport the specified global variable. 15502e2caf59SThomas VeermanIf no variable list is provided, all globals are exported 15512e2caf59SThomas Veermanexcept for internal variables (those that start with 15522e2caf59SThomas Veerman.Ql \&. ) . 15532e2caf59SThomas VeermanThis is not affected by the 15542e2caf59SThomas Veerman.Fl X 15552e2caf59SThomas Veermanflag, so should be used with caution. 15562e2caf59SThomas VeermanFor compatibility with other 15572e2caf59SThomas Veerman.Nm 15582e2caf59SThomas Veermanprograms 15592e2caf59SThomas Veerman.Ql export variable=value 15602e2caf59SThomas Veermanis also accepted. 15612e2caf59SThomas Veerman.Pp 15622e2caf59SThomas VeermanAppending a variable name to 15632e2caf59SThomas Veerman.Va .MAKE.EXPORTED 15642e2caf59SThomas Veermanis equivalent to exporting a variable. 15652e2caf59SThomas Veerman.It Ic .export-env Ar variable ... 15662e2caf59SThomas VeermanThe same as 15672e2caf59SThomas Veerman.Ql .export , 15682e2caf59SThomas Veermanexcept that the variable is not appended to 15692e2caf59SThomas Veerman.Va .MAKE.EXPORTED . 15702e2caf59SThomas VeermanThis allows exporting a value to the environment which is different from that 15712e2caf59SThomas Veermanused by 15722e2caf59SThomas Veerman.Nm 15732e2caf59SThomas Veermaninternally. 15742e2caf59SThomas Veerman.It Ic .info Ar message 15752e2caf59SThomas VeermanThe message is printed along with the name of the makefile and line number. 15762e2caf59SThomas Veerman.It Ic .undef Ar variable 15772e2caf59SThomas VeermanUn-define the specified global variable. 15782e2caf59SThomas VeermanOnly global variables may be un-defined. 15792e2caf59SThomas Veerman.It Ic .unexport Ar variable ... 15802e2caf59SThomas VeermanThe opposite of 15812e2caf59SThomas Veerman.Ql .export . 15822e2caf59SThomas VeermanThe specified global 15832e2caf59SThomas Veerman.Va variable 15842e2caf59SThomas Veermanwill be removed from 15852e2caf59SThomas Veerman.Va .MAKE.EXPORTED . 15862e2caf59SThomas VeermanIf no variable list is provided, all globals are unexported, 15872e2caf59SThomas Veermanand 15882e2caf59SThomas Veerman.Va .MAKE.EXPORTED 15892e2caf59SThomas Veermandeleted. 15902e2caf59SThomas Veerman.It Ic .unexport-env 15912e2caf59SThomas VeermanUnexport all globals previously exported and 15922e2caf59SThomas Veermanclear the environment inherited from the parent. 15932e2caf59SThomas VeermanThis operation will cause a memory leak of the original environment, 15942e2caf59SThomas Veermanso should be used sparingly. 15952e2caf59SThomas VeermanTesting for 15962e2caf59SThomas Veerman.Va .MAKE.LEVEL 15972e2caf59SThomas Veermanbeing 0, would make sense. 15982e2caf59SThomas VeermanAlso note that any variables which originated in the parent environment 15992e2caf59SThomas Veermanshould be explicitly preserved if desired. 16002e2caf59SThomas VeermanFor example: 16012e2caf59SThomas Veerman.Bd -literal -offset indent 16022e2caf59SThomas Veerman.Li .if ${.MAKE.LEVEL} == 0 16032e2caf59SThomas VeermanPATH := ${PATH} 16042e2caf59SThomas Veerman.Li .unexport-env 16052e2caf59SThomas Veerman.Li .export PATH 16062e2caf59SThomas Veerman.Li .endif 16072e2caf59SThomas Veerman.Pp 16082e2caf59SThomas Veerman.Ed 16092e2caf59SThomas VeermanWould result in an environment containing only 16102e2caf59SThomas Veerman.Ql Ev PATH , 16112e2caf59SThomas Veermanwhich is the minimal useful environment. 16122e2caf59SThomas VeermanActually 16132e2caf59SThomas Veerman.Ql Ev .MAKE.LEVEL 16142e2caf59SThomas Veermanwill also be pushed into the new environment. 16152e2caf59SThomas Veerman.It Ic .warning Ar message 16162e2caf59SThomas VeermanThe message prefixed by 16172e2caf59SThomas Veerman.Ql Pa warning: 16182e2caf59SThomas Veermanis printed along with the name of the makefile and line number. 16192e2caf59SThomas Veerman.It Ic \&.if Oo \&! Oc Ns Ar expression Op Ar operator expression ... 16202e2caf59SThomas VeermanTest the value of an expression. 16212e2caf59SThomas Veerman.It Ic .ifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ... 16222e2caf59SThomas VeermanTest the value of a variable. 16232e2caf59SThomas Veerman.It Ic .ifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ... 16242e2caf59SThomas VeermanTest the value of a variable. 16252e2caf59SThomas Veerman.It Ic .ifmake Oo \&! Oc Ns Ar target Op Ar operator target ... 16262e2caf59SThomas VeermanTest the target being built. 16272e2caf59SThomas Veerman.It Ic .ifnmake Oo \&! Ns Oc Ar target Op Ar operator target ... 16282e2caf59SThomas VeermanTest the target being built. 16292e2caf59SThomas Veerman.It Ic .else 16302e2caf59SThomas VeermanReverse the sense of the last conditional. 16312e2caf59SThomas Veerman.It Ic .elif Oo \&! Ns Oc Ar expression Op Ar operator expression ... 16322e2caf59SThomas VeermanA combination of 16332e2caf59SThomas Veerman.Ql Ic .else 16342e2caf59SThomas Veermanfollowed by 16352e2caf59SThomas Veerman.Ql Ic .if . 16362e2caf59SThomas Veerman.It Ic .elifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ... 16372e2caf59SThomas VeermanA combination of 16382e2caf59SThomas Veerman.Ql Ic .else 16392e2caf59SThomas Veermanfollowed by 16402e2caf59SThomas Veerman.Ql Ic .ifdef . 16412e2caf59SThomas Veerman.It Ic .elifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ... 16422e2caf59SThomas VeermanA combination of 16432e2caf59SThomas Veerman.Ql Ic .else 16442e2caf59SThomas Veermanfollowed by 16452e2caf59SThomas Veerman.Ql Ic .ifndef . 16462e2caf59SThomas Veerman.It Ic .elifmake Oo \&! Oc Ns Ar target Op Ar operator target ... 16472e2caf59SThomas VeermanA combination of 16482e2caf59SThomas Veerman.Ql Ic .else 16492e2caf59SThomas Veermanfollowed by 16502e2caf59SThomas Veerman.Ql Ic .ifmake . 16512e2caf59SThomas Veerman.It Ic .elifnmake Oo \&! Oc Ns Ar target Op Ar operator target ... 16522e2caf59SThomas VeermanA combination of 16532e2caf59SThomas Veerman.Ql Ic .else 16542e2caf59SThomas Veermanfollowed by 16552e2caf59SThomas Veerman.Ql Ic .ifnmake . 16562e2caf59SThomas Veerman.It Ic .endif 16572e2caf59SThomas VeermanEnd the body of the conditional. 16582e2caf59SThomas Veerman.El 16592e2caf59SThomas Veerman.Pp 16602e2caf59SThomas VeermanThe 16612e2caf59SThomas Veerman.Ar operator 16622e2caf59SThomas Veermanmay be any one of the following: 16632e2caf59SThomas Veerman.Bl -tag -width "Cm XX" 16642e2caf59SThomas Veerman.It Cm \&|\&| 16652e2caf59SThomas VeermanLogical OR. 16662e2caf59SThomas Veerman.It Cm \&\*[Am]\*[Am] 16672e2caf59SThomas VeermanLogical 16682e2caf59SThomas Veerman.Tn AND ; 16692e2caf59SThomas Veermanof higher precedence than 16702e2caf59SThomas Veerman.Dq \&|\&| . 16712e2caf59SThomas Veerman.El 16722e2caf59SThomas Veerman.Pp 16732e2caf59SThomas VeermanAs in C, 16742e2caf59SThomas Veerman.Nm 16752e2caf59SThomas Veermanwill only evaluate a conditional as far as is necessary to determine 16762e2caf59SThomas Veermanits value. 16772e2caf59SThomas VeermanParentheses may be used to change the order of evaluation. 16782e2caf59SThomas VeermanThe boolean operator 16792e2caf59SThomas Veerman.Ql Ic \&! 16802e2caf59SThomas Veermanmay be used to logically negate an entire 16812e2caf59SThomas Veermanconditional. 16822e2caf59SThomas VeermanIt is of higher precedence than 16832e2caf59SThomas Veerman.Ql Ic \&\*[Am]\*[Am] . 16842e2caf59SThomas Veerman.Pp 16852e2caf59SThomas VeermanThe value of 16862e2caf59SThomas Veerman.Ar expression 16872e2caf59SThomas Veermanmay be any of the following: 16882e2caf59SThomas Veerman.Bl -tag -width defined 16892e2caf59SThomas Veerman.It Ic defined 16902e2caf59SThomas VeermanTakes a variable name as an argument and evaluates to true if the variable 16912e2caf59SThomas Veermanhas been defined. 16922e2caf59SThomas Veerman.It Ic make 16932e2caf59SThomas VeermanTakes a target name as an argument and evaluates to true if the target 16942e2caf59SThomas Veermanwas specified as part of 16952e2caf59SThomas Veerman.Nm Ns 's 16962e2caf59SThomas Veermancommand line or was declared the default target (either implicitly or 16972e2caf59SThomas Veermanexplicitly, see 16982e2caf59SThomas Veerman.Va .MAIN ) 16992e2caf59SThomas Veermanbefore the line containing the conditional. 17002e2caf59SThomas Veerman.It Ic empty 17012e2caf59SThomas VeermanTakes a variable, with possible modifiers, and evaluates to true if 17022e2caf59SThomas Veermanthe expansion of the variable would result in an empty string. 17032e2caf59SThomas Veerman.It Ic exists 17042e2caf59SThomas VeermanTakes a file name as an argument and evaluates to true if the file exists. 17052e2caf59SThomas VeermanThe file is searched for on the system search path (see 17062e2caf59SThomas Veerman.Va .PATH ) . 17072e2caf59SThomas Veerman.It Ic target 17082e2caf59SThomas VeermanTakes a target name as an argument and evaluates to true if the target 17092e2caf59SThomas Veermanhas been defined. 17102e2caf59SThomas Veerman.It Ic commands 17112e2caf59SThomas VeermanTakes a target name as an argument and evaluates to true if the target 17122e2caf59SThomas Veermanhas been defined and has commands associated with it. 17132e2caf59SThomas Veerman.El 17142e2caf59SThomas Veerman.Pp 17152e2caf59SThomas Veerman.Ar Expression 17162e2caf59SThomas Veermanmay also be an arithmetic or string comparison. 17172e2caf59SThomas VeermanVariable expansion is 17182e2caf59SThomas Veermanperformed on both sides of the comparison, after which the integral 17192e2caf59SThomas Veermanvalues are compared. 17202e2caf59SThomas VeermanA value is interpreted as hexadecimal if it is 17212e2caf59SThomas Veermanpreceded by 0x, otherwise it is decimal; octal numbers are not supported. 17222e2caf59SThomas VeermanThe standard C relational operators are all supported. 17232e2caf59SThomas VeermanIf after 17242e2caf59SThomas Veermanvariable expansion, either the left or right hand side of a 17252e2caf59SThomas Veerman.Ql Ic == 17262e2caf59SThomas Veermanor 17272e2caf59SThomas Veerman.Ql Ic "!=" 17282e2caf59SThomas Veermanoperator is not an integral value, then 17292e2caf59SThomas Veermanstring comparison is performed between the expanded 17302e2caf59SThomas Veermanvariables. 17312e2caf59SThomas VeermanIf no relational operator is given, it is assumed that the expanded 17322e2caf59SThomas Veermanvariable is being compared against 0 or an empty string in the case 17332e2caf59SThomas Veermanof a string comparison. 17342e2caf59SThomas Veerman.Pp 17352e2caf59SThomas VeermanWhen 17362e2caf59SThomas Veerman.Nm 17372e2caf59SThomas Veermanis evaluating one of these conditional expressions, and it encounters 17382e2caf59SThomas Veermana (white-space separated) word it doesn't recognize, either the 17392e2caf59SThomas Veerman.Dq make 17402e2caf59SThomas Veermanor 17412e2caf59SThomas Veerman.Dq defined 17422e2caf59SThomas Veermanexpression is applied to it, depending on the form of the conditional. 17432e2caf59SThomas VeermanIf the form is 17442e2caf59SThomas Veerman.Ql Ic .ifdef , 17452e2caf59SThomas Veerman.Ql Ic .ifndef , 17462e2caf59SThomas Veermanor 17472e2caf59SThomas Veerman.Ql Ic .if 17482e2caf59SThomas Veermanthe 17492e2caf59SThomas Veerman.Dq defined 17502e2caf59SThomas Veermanexpression is applied. 17512e2caf59SThomas VeermanSimilarly, if the form is 17522e2caf59SThomas Veerman.Ql Ic .ifmake 17532e2caf59SThomas Veermanor 17542e2caf59SThomas Veerman.Ql Ic .ifnmake , the 17552e2caf59SThomas Veerman.Dq make 17562e2caf59SThomas Veermanexpression is applied. 17572e2caf59SThomas Veerman.Pp 17582e2caf59SThomas VeermanIf the conditional evaluates to true the parsing of the makefile continues 17592e2caf59SThomas Veermanas before. 17602e2caf59SThomas VeermanIf it evaluates to false, the following lines are skipped. 17612e2caf59SThomas VeermanIn both cases this continues until a 17622e2caf59SThomas Veerman.Ql Ic .else 17632e2caf59SThomas Veermanor 17642e2caf59SThomas Veerman.Ql Ic .endif 17652e2caf59SThomas Veermanis found. 17662e2caf59SThomas Veerman.Pp 17672e2caf59SThomas VeermanFor loops are typically used to apply a set of rules to a list of files. 17682e2caf59SThomas VeermanThe syntax of a for loop is: 17692e2caf59SThomas Veerman.Pp 17702e2caf59SThomas Veerman.Bl -tag -compact -width Ds 17712e2caf59SThomas Veerman.It Ic \&.for Ar variable Oo Ar variable ... Oc Ic in Ar expression 17722e2caf59SThomas Veerman.It Aq make-rules 17732e2caf59SThomas Veerman.It Ic \&.endfor 17742e2caf59SThomas Veerman.El 17752e2caf59SThomas Veerman.Pp 17762e2caf59SThomas VeermanAfter the for 17772e2caf59SThomas Veerman.Ic expression 17782e2caf59SThomas Veermanis evaluated, it is split into words. 17792e2caf59SThomas VeermanOn each iteration of the loop, one word is taken and assigned to each 17802e2caf59SThomas Veerman.Ic variable , 17812e2caf59SThomas Veermanin order, and these 17822e2caf59SThomas Veerman.Ic variables 17832e2caf59SThomas Veermanare substituted into the 17842e2caf59SThomas Veerman.Ic make-rules 17852e2caf59SThomas Veermaninside the body of the for loop. 17862e2caf59SThomas VeermanThe number of words must come out even; that is, if there are three 17872e2caf59SThomas Veermaniteration variables, the number of words provided must be a multiple 17882e2caf59SThomas Veermanof three. 17892e2caf59SThomas Veerman.Sh COMMENTS 17902e2caf59SThomas VeermanComments begin with a hash 17912e2caf59SThomas Veerman.Pq Ql \&# 17922e2caf59SThomas Veermancharacter, anywhere but in a shell 17932e2caf59SThomas Veermancommand line, and continue to the end of an unescaped new line. 17942e2caf59SThomas Veerman.Sh SPECIAL SOURCES (ATTRIBUTES) 17952e2caf59SThomas Veerman.Bl -tag -width .IGNOREx 17962e2caf59SThomas Veerman.It Ic .EXEC 17972e2caf59SThomas VeermanTarget is never out of date, but always execute commands anyway. 17982e2caf59SThomas Veerman.It Ic .IGNORE 17992e2caf59SThomas VeermanIgnore any errors from the commands associated with this target, exactly 18002e2caf59SThomas Veermanas if they all were preceded by a dash 18012e2caf59SThomas Veerman.Pq Ql \- . 18022e2caf59SThomas Veerman.\" .It Ic .INVISIBLE 18032e2caf59SThomas Veerman.\" XXX 18042e2caf59SThomas Veerman.\" .It Ic .JOIN 18052e2caf59SThomas Veerman.\" XXX 18062e2caf59SThomas Veerman.It Ic .MADE 18072e2caf59SThomas VeermanMark all sources of this target as being up-to-date. 18082e2caf59SThomas Veerman.It Ic .MAKE 18092e2caf59SThomas VeermanExecute the commands associated with this target even if the 18102e2caf59SThomas Veerman.Fl n 18112e2caf59SThomas Veermanor 18122e2caf59SThomas Veerman.Fl t 18132e2caf59SThomas Veermanoptions were specified. 18142e2caf59SThomas VeermanNormally used to mark recursive 181584d9c625SLionel Sambuc.Nm Ns s . 18162e2caf59SThomas Veerman.It Ic .META 18172e2caf59SThomas VeermanCreate a meta file for the target, even if it is flagged as 18182e2caf59SThomas Veerman.Ic .PHONY , 18192e2caf59SThomas Veerman.Ic .MAKE , 18202e2caf59SThomas Veermanor 18212e2caf59SThomas Veerman.Ic .SPECIAL . 18222e2caf59SThomas VeermanUsage in conjunction with 18232e2caf59SThomas Veerman.Ic .MAKE 18242e2caf59SThomas Veermanis the most likely case. 18252e2caf59SThomas VeermanIn "meta" mode, the target is out-of-date if the meta file is missing. 18262e2caf59SThomas Veerman.It Ic .NOMETA 18272e2caf59SThomas VeermanDo not create a meta file for the target. 18282e2caf59SThomas VeermanMeta files are also not created for 18292e2caf59SThomas Veerman.Ic .PHONY , 18302e2caf59SThomas Veerman.Ic .MAKE , 18312e2caf59SThomas Veermanor 18322e2caf59SThomas Veerman.Ic .SPECIAL 18332e2caf59SThomas Veermantargets. 18342e2caf59SThomas Veerman.It Ic .NOMETA_CMP 18352e2caf59SThomas VeermanIgnore differences in commands when deciding if target is out of date. 18362e2caf59SThomas VeermanThis is useful if the command contains a value which always changes. 18372e2caf59SThomas VeermanIf the number of commands change, though, the target will still be out of date. 183884d9c625SLionel SambucThe same effect applies to any command line that uses the variable 183984d9c625SLionel Sambuc.Va .OODATE , 184084d9c625SLionel Sambucwhich can be used for that purpose even when not otherwise needed or desired: 184184d9c625SLionel Sambuc.Bd -literal -offset indent 184284d9c625SLionel Sambuc 184384d9c625SLionel Sambucskip-compare-for-some: 184484d9c625SLionel Sambuc @echo this will be compared 184584d9c625SLionel Sambuc @echo this will not ${.OODATE:M.NOMETA_CMP} 184684d9c625SLionel Sambuc @echo this will also be compared 184784d9c625SLionel Sambuc 184884d9c625SLionel Sambuc.Ed 184984d9c625SLionel SambucThe 185084d9c625SLionel Sambuc.Cm \&:M 185184d9c625SLionel Sambucpattern suppresses any expansion of the unwanted variable. 18522e2caf59SThomas Veerman.It Ic .NOPATH 18532e2caf59SThomas VeermanDo not search for the target in the directories specified by 18542e2caf59SThomas Veerman.Ic .PATH . 18552e2caf59SThomas Veerman.It Ic .NOTMAIN 18562e2caf59SThomas VeermanNormally 18572e2caf59SThomas Veerman.Nm 18582e2caf59SThomas Veermanselects the first target it encounters as the default target to be built 18592e2caf59SThomas Veermanif no target was specified. 18602e2caf59SThomas VeermanThis source prevents this target from being selected. 18612e2caf59SThomas Veerman.It Ic .OPTIONAL 18622e2caf59SThomas VeermanIf a target is marked with this attribute and 18632e2caf59SThomas Veerman.Nm 18642e2caf59SThomas Veermancan't figure out how to create it, it will ignore this fact and assume 18652e2caf59SThomas Veermanthe file isn't needed or already exists. 18662e2caf59SThomas Veerman.It Ic .PHONY 18672e2caf59SThomas VeermanThe target does not 18682e2caf59SThomas Veermancorrespond to an actual file; it is always considered to be out of date, 18692e2caf59SThomas Veermanand will not be created with the 18702e2caf59SThomas Veerman.Fl t 18712e2caf59SThomas Veermanoption. 18722e2caf59SThomas VeermanSuffix-transformation rules are not applied to 18732e2caf59SThomas Veerman.Ic .PHONY 18742e2caf59SThomas Veermantargets. 18752e2caf59SThomas Veerman.It Ic .PRECIOUS 18762e2caf59SThomas VeermanWhen 18772e2caf59SThomas Veerman.Nm 18782e2caf59SThomas Veermanis interrupted, it normally removes any partially made targets. 18792e2caf59SThomas VeermanThis source prevents the target from being removed. 18802e2caf59SThomas Veerman.It Ic .RECURSIVE 18812e2caf59SThomas VeermanSynonym for 18822e2caf59SThomas Veerman.Ic .MAKE . 18832e2caf59SThomas Veerman.It Ic .SILENT 18842e2caf59SThomas VeermanDo not echo any of the commands associated with this target, exactly 18852e2caf59SThomas Veermanas if they all were preceded by an at sign 18862e2caf59SThomas Veerman.Pq Ql @ . 18872e2caf59SThomas Veerman.It Ic .USE 18882e2caf59SThomas VeermanTurn the target into 18892e2caf59SThomas Veerman.Nm Ns 's 18902e2caf59SThomas Veermanversion of a macro. 18912e2caf59SThomas VeermanWhen the target is used as a source for another target, the other target 18922e2caf59SThomas Veermanacquires the commands, sources, and attributes (except for 18932e2caf59SThomas Veerman.Ic .USE ) 18942e2caf59SThomas Veermanof the 18952e2caf59SThomas Veermansource. 18962e2caf59SThomas VeermanIf the target already has commands, the 18972e2caf59SThomas Veerman.Ic .USE 18982e2caf59SThomas Veermantarget's commands are appended 18992e2caf59SThomas Veermanto them. 19002e2caf59SThomas Veerman.It Ic .USEBEFORE 19012e2caf59SThomas VeermanExactly like 19022e2caf59SThomas Veerman.Ic .USE , 19032e2caf59SThomas Veermanbut prepend the 19042e2caf59SThomas Veerman.Ic .USEBEFORE 19052e2caf59SThomas Veermantarget commands to the target. 19062e2caf59SThomas Veerman.It Ic .WAIT 19072e2caf59SThomas VeermanIf 19082e2caf59SThomas Veerman.Ic .WAIT 19092e2caf59SThomas Veermanappears in a dependency line, the sources that precede it are 19102e2caf59SThomas Veermanmade before the sources that succeed it in the line. 19112e2caf59SThomas VeermanSince the dependents of files are not made until the file itself 19122e2caf59SThomas Veermancould be made, this also stops the dependents being built unless they 19132e2caf59SThomas Veermanare needed for another branch of the dependency tree. 19142e2caf59SThomas VeermanSo given: 19152e2caf59SThomas Veerman.Bd -literal 19162e2caf59SThomas Veermanx: a .WAIT b 19172e2caf59SThomas Veerman echo x 19182e2caf59SThomas Veermana: 19192e2caf59SThomas Veerman echo a 19202e2caf59SThomas Veermanb: b1 19212e2caf59SThomas Veerman echo b 19222e2caf59SThomas Veermanb1: 19232e2caf59SThomas Veerman echo b1 19242e2caf59SThomas Veerman 19252e2caf59SThomas Veerman.Ed 19262e2caf59SThomas Veermanthe output is always 19272e2caf59SThomas Veerman.Ql a , 19282e2caf59SThomas Veerman.Ql b1 , 19292e2caf59SThomas Veerman.Ql b , 19302e2caf59SThomas Veerman.Ql x . 19312e2caf59SThomas Veerman.br 19322e2caf59SThomas VeermanThe ordering imposed by 19332e2caf59SThomas Veerman.Ic .WAIT 19342e2caf59SThomas Veermanis only relevant for parallel makes. 19352e2caf59SThomas Veerman.El 19362e2caf59SThomas Veerman.Sh SPECIAL TARGETS 19372e2caf59SThomas VeermanSpecial targets may not be included with other targets, i.e. they must be 19382e2caf59SThomas Veermanthe only target specified. 19392e2caf59SThomas Veerman.Bl -tag -width .BEGINx 19402e2caf59SThomas Veerman.It Ic .BEGIN 19412e2caf59SThomas VeermanAny command lines attached to this target are executed before anything 19422e2caf59SThomas Veermanelse is done. 19432e2caf59SThomas Veerman.It Ic .DEFAULT 19442e2caf59SThomas VeermanThis is sort of a 19452e2caf59SThomas Veerman.Ic .USE 19462e2caf59SThomas Veermanrule for any target (that was used only as a 19472e2caf59SThomas Veermansource) that 19482e2caf59SThomas Veerman.Nm 19492e2caf59SThomas Veermancan't figure out any other way to create. 19502e2caf59SThomas VeermanOnly the shell script is used. 19512e2caf59SThomas VeermanThe 19522e2caf59SThomas Veerman.Ic .IMPSRC 19532e2caf59SThomas Veermanvariable of a target that inherits 19542e2caf59SThomas Veerman.Ic .DEFAULT Ns 's 19552e2caf59SThomas Veermancommands is set 19562e2caf59SThomas Veermanto the target's own name. 19572e2caf59SThomas Veerman.It Ic .END 19582e2caf59SThomas VeermanAny command lines attached to this target are executed after everything 19592e2caf59SThomas Veermanelse is done. 19602e2caf59SThomas Veerman.It Ic .ERROR 19612e2caf59SThomas VeermanAny command lines attached to this target are executed when another target fails. 19622e2caf59SThomas VeermanThe 19632e2caf59SThomas Veerman.Ic .ERROR_TARGET 19642e2caf59SThomas Veermanvariable is set to the target that failed. 19652e2caf59SThomas VeermanSee also 19662e2caf59SThomas Veerman.Ic MAKE_PRINT_VAR_ON_ERROR . 19672e2caf59SThomas Veerman.It Ic .IGNORE 19682e2caf59SThomas VeermanMark each of the sources with the 19692e2caf59SThomas Veerman.Ic .IGNORE 19702e2caf59SThomas Veermanattribute. 19712e2caf59SThomas VeermanIf no sources are specified, this is the equivalent of specifying the 19722e2caf59SThomas Veerman.Fl i 19732e2caf59SThomas Veermanoption. 19742e2caf59SThomas Veerman.It Ic .INTERRUPT 19752e2caf59SThomas VeermanIf 19762e2caf59SThomas Veerman.Nm 19772e2caf59SThomas Veermanis interrupted, the commands for this target will be executed. 19782e2caf59SThomas Veerman.It Ic .MAIN 19792e2caf59SThomas VeermanIf no target is specified when 19802e2caf59SThomas Veerman.Nm 19812e2caf59SThomas Veermanis invoked, this target will be built. 19822e2caf59SThomas Veerman.It Ic .MAKEFLAGS 19832e2caf59SThomas VeermanThis target provides a way to specify flags for 19842e2caf59SThomas Veerman.Nm 19852e2caf59SThomas Veermanwhen the makefile is used. 19862e2caf59SThomas VeermanThe flags are as if typed to the shell, though the 19872e2caf59SThomas Veerman.Fl f 19882e2caf59SThomas Veermanoption will have 19892e2caf59SThomas Veermanno effect. 19902e2caf59SThomas Veerman.\" XXX: NOT YET!!!! 19912e2caf59SThomas Veerman.\" .It Ic .NOTPARALLEL 19922e2caf59SThomas Veerman.\" The named targets are executed in non parallel mode. 19932e2caf59SThomas Veerman.\" If no targets are 19942e2caf59SThomas Veerman.\" specified, then all targets are executed in non parallel mode. 19952e2caf59SThomas Veerman.It Ic .NOPATH 19962e2caf59SThomas VeermanApply the 19972e2caf59SThomas Veerman.Ic .NOPATH 19982e2caf59SThomas Veermanattribute to any specified sources. 19992e2caf59SThomas Veerman.It Ic .NOTPARALLEL 20002e2caf59SThomas VeermanDisable parallel mode. 20012e2caf59SThomas Veerman.It Ic .NO_PARALLEL 20022e2caf59SThomas VeermanSynonym for 20032e2caf59SThomas Veerman.Ic .NOTPARALLEL , 20042e2caf59SThomas Veermanfor compatibility with other pmake variants. 2005*0a6a1f1dSLionel Sambuc.It Ic .OBJDIR 2006*0a6a1f1dSLionel SambucThe source is a new value for 2007*0a6a1f1dSLionel Sambuc.Ql Va .OBJDIR . 2008*0a6a1f1dSLionel SambucIf it exists, 2009*0a6a1f1dSLionel Sambuc.Nm 2010*0a6a1f1dSLionel Sambucwill 2011*0a6a1f1dSLionel Sambuc.Xr chdir 2 2012*0a6a1f1dSLionel Sambucto it and update the value of 2013*0a6a1f1dSLionel Sambuc.Ql Va .OBJDIR . 20142e2caf59SThomas Veerman.It Ic .ORDER 20152e2caf59SThomas VeermanThe named targets are made in sequence. 20162e2caf59SThomas VeermanThis ordering does not add targets to the list of targets to be made. 20172e2caf59SThomas VeermanSince the dependents of a target do not get built until the target itself 20182e2caf59SThomas Veermancould be built, unless 20192e2caf59SThomas Veerman.Ql a 20202e2caf59SThomas Veermanis built by another part of the dependency graph, 20212e2caf59SThomas Veermanthe following is a dependency loop: 20222e2caf59SThomas Veerman.Bd -literal 20232e2caf59SThomas Veerman\&.ORDER: b a 20242e2caf59SThomas Veermanb: a 20252e2caf59SThomas Veerman.Ed 20262e2caf59SThomas Veerman.Pp 20272e2caf59SThomas VeermanThe ordering imposed by 20282e2caf59SThomas Veerman.Ic .ORDER 20292e2caf59SThomas Veermanis only relevant for parallel makes. 20302e2caf59SThomas Veerman.\" XXX: NOT YET!!!! 20312e2caf59SThomas Veerman.\" .It Ic .PARALLEL 20322e2caf59SThomas Veerman.\" The named targets are executed in parallel mode. 20332e2caf59SThomas Veerman.\" If no targets are 20342e2caf59SThomas Veerman.\" specified, then all targets are executed in parallel mode. 20352e2caf59SThomas Veerman.It Ic .PATH 20362e2caf59SThomas VeermanThe sources are directories which are to be searched for files not 20372e2caf59SThomas Veermanfound in the current directory. 20382e2caf59SThomas VeermanIf no sources are specified, any previously specified directories are 20392e2caf59SThomas Veermandeleted. 20402e2caf59SThomas VeermanIf the source is the special 20412e2caf59SThomas Veerman.Ic .DOTLAST 20422e2caf59SThomas Veermantarget, then the current working 20432e2caf59SThomas Veermandirectory is searched last. 204484d9c625SLionel Sambuc.It Ic .PATH. Ns Va suffix 204584d9c625SLionel SambucLike 204684d9c625SLionel Sambuc.Ic .PATH 204784d9c625SLionel Sambucbut applies only to files with a particular suffix. 204884d9c625SLionel SambucThe suffix must have been previously declared with 204984d9c625SLionel Sambuc.Ic .SUFFIXES . 20502e2caf59SThomas Veerman.It Ic .PHONY 20512e2caf59SThomas VeermanApply the 20522e2caf59SThomas Veerman.Ic .PHONY 20532e2caf59SThomas Veermanattribute to any specified sources. 20542e2caf59SThomas Veerman.It Ic .PRECIOUS 20552e2caf59SThomas VeermanApply the 20562e2caf59SThomas Veerman.Ic .PRECIOUS 20572e2caf59SThomas Veermanattribute to any specified sources. 20582e2caf59SThomas VeermanIf no sources are specified, the 20592e2caf59SThomas Veerman.Ic .PRECIOUS 20602e2caf59SThomas Veermanattribute is applied to every 20612e2caf59SThomas Veermantarget in the file. 20622e2caf59SThomas Veerman.It Ic .SHELL 20632e2caf59SThomas VeermanSets the shell that 20642e2caf59SThomas Veerman.Nm 20652e2caf59SThomas Veermanwill use to execute commands. 20662e2caf59SThomas VeermanThe sources are a set of 20672e2caf59SThomas Veerman.Ar field=value 20682e2caf59SThomas Veermanpairs. 20692e2caf59SThomas Veerman.Bl -tag -width hasErrCtls 20702e2caf59SThomas Veerman.It Ar name 20712e2caf59SThomas VeermanThis is the minimal specification, used to select one of the builtin 20722e2caf59SThomas Veermanshell specs; 20732e2caf59SThomas Veerman.Ar sh , 20742e2caf59SThomas Veerman.Ar ksh , 20752e2caf59SThomas Veermanand 20762e2caf59SThomas Veerman.Ar csh . 20772e2caf59SThomas Veerman.It Ar path 20782e2caf59SThomas VeermanSpecifies the path to the shell. 20792e2caf59SThomas Veerman.It Ar hasErrCtl 20802e2caf59SThomas VeermanIndicates whether the shell supports exit on error. 20812e2caf59SThomas Veerman.It Ar check 20822e2caf59SThomas VeermanThe command to turn on error checking. 20832e2caf59SThomas Veerman.It Ar ignore 20842e2caf59SThomas VeermanThe command to disable error checking. 20852e2caf59SThomas Veerman.It Ar echo 20862e2caf59SThomas VeermanThe command to turn on echoing of commands executed. 20872e2caf59SThomas Veerman.It Ar quiet 20882e2caf59SThomas VeermanThe command to turn off echoing of commands executed. 20892e2caf59SThomas Veerman.It Ar filter 20902e2caf59SThomas VeermanThe output to filter after issuing the 20912e2caf59SThomas Veerman.Ar quiet 20922e2caf59SThomas Veermancommand. 20932e2caf59SThomas VeermanIt is typically identical to 20942e2caf59SThomas Veerman.Ar quiet . 20952e2caf59SThomas Veerman.It Ar errFlag 20962e2caf59SThomas VeermanThe flag to pass the shell to enable error checking. 20972e2caf59SThomas Veerman.It Ar echoFlag 20982e2caf59SThomas VeermanThe flag to pass the shell to enable command echoing. 20992e2caf59SThomas Veerman.It Ar newline 21002e2caf59SThomas VeermanThe string literal to pass the shell that results in a single newline 21012e2caf59SThomas Veermancharacter when used outside of any quoting characters. 21022e2caf59SThomas Veerman.El 21032e2caf59SThomas VeermanExample: 21042e2caf59SThomas Veerman.Bd -literal 21052e2caf59SThomas Veerman\&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \e 21062e2caf59SThomas Veerman check="set \-e" ignore="set +e" \e 21072e2caf59SThomas Veerman echo="set \-v" quiet="set +v" filter="set +v" \e 21082e2caf59SThomas Veerman echoFlag=v errFlag=e newline="'\en'" 21092e2caf59SThomas Veerman.Ed 21102e2caf59SThomas Veerman.It Ic .SILENT 21112e2caf59SThomas VeermanApply the 21122e2caf59SThomas Veerman.Ic .SILENT 21132e2caf59SThomas Veermanattribute to any specified sources. 21142e2caf59SThomas VeermanIf no sources are specified, the 21152e2caf59SThomas Veerman.Ic .SILENT 21162e2caf59SThomas Veermanattribute is applied to every 21172e2caf59SThomas Veermancommand in the file. 211884d9c625SLionel Sambuc.It Ic .STALE 211984d9c625SLionel SambucThis target gets run when a dependency file contains stale entries, having 212084d9c625SLionel Sambuc.Va .ALLSRC 212184d9c625SLionel Sambucset to the name of that dependency file. 21222e2caf59SThomas Veerman.It Ic .SUFFIXES 21232e2caf59SThomas VeermanEach source specifies a suffix to 21242e2caf59SThomas Veerman.Nm . 21252e2caf59SThomas VeermanIf no sources are specified, any previously specified suffixes are deleted. 21262e2caf59SThomas VeermanIt allows the creation of suffix-transformation rules. 21272e2caf59SThomas Veerman.Pp 21282e2caf59SThomas VeermanExample: 21292e2caf59SThomas Veerman.Bd -literal 21302e2caf59SThomas Veerman\&.SUFFIXES: .o 21312e2caf59SThomas Veerman\&.c.o: 21322e2caf59SThomas Veerman cc \-o ${.TARGET} \-c ${.IMPSRC} 21332e2caf59SThomas Veerman.Ed 21342e2caf59SThomas Veerman.El 21352e2caf59SThomas Veerman.Sh ENVIRONMENT 21362e2caf59SThomas Veerman.Nm 21372e2caf59SThomas Veermanuses the following environment variables, if they exist: 21382e2caf59SThomas Veerman.Ev MACHINE , 21392e2caf59SThomas Veerman.Ev MACHINE_ARCH , 21402e2caf59SThomas Veerman.Ev MAKE , 21412e2caf59SThomas Veerman.Ev MAKEFLAGS , 21422e2caf59SThomas Veerman.Ev MAKEOBJDIR , 21432e2caf59SThomas Veerman.Ev MAKEOBJDIRPREFIX , 21442e2caf59SThomas Veerman.Ev MAKESYSPATH , 21452e2caf59SThomas Veerman.Ev PWD , 21462e2caf59SThomas Veermanand 21472e2caf59SThomas Veerman.Ev TMPDIR . 21482e2caf59SThomas Veerman.Pp 21492e2caf59SThomas Veerman.Ev MAKEOBJDIRPREFIX 21502e2caf59SThomas Veermanand 21512e2caf59SThomas Veerman.Ev MAKEOBJDIR 21522e2caf59SThomas Veermanmay only be set in the environment or on the command line to 21532e2caf59SThomas Veerman.Nm 21542e2caf59SThomas Veermanand not as makefile variables; 21552e2caf59SThomas Veermansee the description of 21562e2caf59SThomas Veerman.Ql Va .OBJDIR 21572e2caf59SThomas Veermanfor more details. 21582e2caf59SThomas Veerman.Sh FILES 21592e2caf59SThomas Veerman.Bl -tag -width /usr/share/mk -compact 21602e2caf59SThomas Veerman.It .depend 21612e2caf59SThomas Veermanlist of dependencies 21622e2caf59SThomas Veerman.It Makefile 21632e2caf59SThomas Veermanlist of dependencies 21642e2caf59SThomas Veerman.It makefile 21652e2caf59SThomas Veermanlist of dependencies 21662e2caf59SThomas Veerman.It sys.mk 21672e2caf59SThomas Veermansystem makefile 21682e2caf59SThomas Veerman.It /usr/share/mk 21692e2caf59SThomas Veermansystem makefile directory 21702e2caf59SThomas Veerman.El 21712e2caf59SThomas Veerman.Sh COMPATIBILITY 2172*0a6a1f1dSLionel SambucThe basic make syntax is compatible between different versions of make; 21732e2caf59SThomas Veermanhowever the special variables, variable modifiers and conditionals are not. 2174*0a6a1f1dSLionel Sambuc.Ss Older versions 2175*0a6a1f1dSLionel SambucAn incomplete list of changes in older versions of 2176*0a6a1f1dSLionel Sambuc.Nm : 21772e2caf59SThomas Veerman.Pp 21782e2caf59SThomas VeermanThe way that .for loop variables are substituted changed after 21792e2caf59SThomas Veerman.Nx 5.0 21802e2caf59SThomas Veermanso that they still appear to be variable expansions. 21812e2caf59SThomas VeermanIn particular this stops them being treated as syntax, and removes some 21822e2caf59SThomas Veermanobscure problems using them in .if statements. 2183*0a6a1f1dSLionel Sambuc.Pp 2184*0a6a1f1dSLionel SambucThe way that parallel makes are scheduled changed in 2185*0a6a1f1dSLionel Sambuc.Nx 4.0 2186*0a6a1f1dSLionel Sambucso that .ORDER and .WAIT apply recursively to the dependent nodes. 2187*0a6a1f1dSLionel SambucThe algorithms used may change again in the future. 2188*0a6a1f1dSLionel Sambuc.Ss Other make dialects 2189*0a6a1f1dSLionel SambucOther make dialects (GNU make, SVR4 make, POSIX make, etc.) do not 2190*0a6a1f1dSLionel Sambucsupport most of the features of 2191*0a6a1f1dSLionel Sambuc.Nm 2192*0a6a1f1dSLionel Sambucas described in this manual. 2193*0a6a1f1dSLionel SambucMost notably: 2194*0a6a1f1dSLionel Sambuc.Bl -bullet -offset indent 2195*0a6a1f1dSLionel Sambuc.It 2196*0a6a1f1dSLionel SambucThe 2197*0a6a1f1dSLionel Sambuc.Ic .WAIT 2198*0a6a1f1dSLionel Sambucand 2199*0a6a1f1dSLionel Sambuc.Ic .ORDER 2200*0a6a1f1dSLionel Sambucdeclarations and most functionality pertaining to parallelization. 2201*0a6a1f1dSLionel Sambuc(GNU make supports parallelization but lacks these features needed to 2202*0a6a1f1dSLionel Sambuccontrol it effectively.) 2203*0a6a1f1dSLionel Sambuc.It 2204*0a6a1f1dSLionel SambucDirectives, including for loops and conditionals and most of the 2205*0a6a1f1dSLionel Sambucforms of include files. 2206*0a6a1f1dSLionel Sambuc(GNU make has its own incompatible and less powerful syntax for 2207*0a6a1f1dSLionel Sambucconditionals.) 2208*0a6a1f1dSLionel Sambuc.It 2209*0a6a1f1dSLionel SambucAll built-in variables that begin with a dot. 2210*0a6a1f1dSLionel Sambuc.It 2211*0a6a1f1dSLionel SambucMost of the special sources and targets that begin with a dot, 2212*0a6a1f1dSLionel Sambucwith the notable exception of 2213*0a6a1f1dSLionel Sambuc.Ic .PHONY , 2214*0a6a1f1dSLionel Sambuc.Ic .PRECIOUS , 2215*0a6a1f1dSLionel Sambucand 2216*0a6a1f1dSLionel Sambuc.Ic .SUFFIXES . 2217*0a6a1f1dSLionel Sambuc.It 2218*0a6a1f1dSLionel SambucVariable modifiers, except for the 2219*0a6a1f1dSLionel Sambuc.Dl :old=new 2220*0a6a1f1dSLionel Sambucstring substitution, which does not portably support globbing with 2221*0a6a1f1dSLionel Sambuc.Ql % 2222*0a6a1f1dSLionel Sambucand historically only works on declared suffixes. 2223*0a6a1f1dSLionel Sambuc.It 2224*0a6a1f1dSLionel SambucThe 2225*0a6a1f1dSLionel Sambuc.Ic $> 2226*0a6a1f1dSLionel Sambucvariable even in its short form; most makes support this functionality 2227*0a6a1f1dSLionel Sambucbut its name varies. 2228*0a6a1f1dSLionel Sambuc.El 2229*0a6a1f1dSLionel Sambuc.Pp 2230*0a6a1f1dSLionel SambucSome features are somewhat more portable, such as assignment with 2231*0a6a1f1dSLionel Sambuc.Ic += , 2232*0a6a1f1dSLionel Sambuc.Ic ?= , 2233*0a6a1f1dSLionel Sambucand 2234*0a6a1f1dSLionel Sambuc.Ic != . 2235*0a6a1f1dSLionel SambucThe 2236*0a6a1f1dSLionel Sambuc.Ic .PATH 2237*0a6a1f1dSLionel Sambucfunctionality is based on an older feature 2238*0a6a1f1dSLionel Sambuc.Ic VPATH 2239*0a6a1f1dSLionel Sambucfound in GNU make and many versions of SVR4 make; however, 2240*0a6a1f1dSLionel Sambuchistorically its behavior is too ill-defined (and too buggy) to rely 2241*0a6a1f1dSLionel Sambucupon. 2242*0a6a1f1dSLionel Sambuc.Pp 2243*0a6a1f1dSLionel SambucThe 2244*0a6a1f1dSLionel Sambuc.Ic $@ 2245*0a6a1f1dSLionel Sambucand 2246*0a6a1f1dSLionel Sambuc.Ic $< 2247*0a6a1f1dSLionel Sambucvariables are more or less universally portable, as is the 2248*0a6a1f1dSLionel Sambuc.Ic $(MAKE) 2249*0a6a1f1dSLionel Sambucvariable. 2250*0a6a1f1dSLionel SambucBasic use of suffix rules (for files only in the current directory, 2251*0a6a1f1dSLionel Sambucnot trying to chain transformations together, etc.) is also reasonably 2252*0a6a1f1dSLionel Sambucportable. 22532e2caf59SThomas Veerman.Sh SEE ALSO 22542e2caf59SThomas Veerman.Xr mkdep 1 22552e2caf59SThomas Veerman.Sh HISTORY 22562e2caf59SThomas VeermanA 22572e2caf59SThomas Veerman.Nm 22582e2caf59SThomas Veermancommand appeared in 22592e2caf59SThomas Veerman.At v7 . 22602e2caf59SThomas VeermanThis 22612e2caf59SThomas Veerman.Nm 22622e2caf59SThomas Veermanimplementation is based on Adam De Boor's pmake program which was written 22632bc7c627SLionel Sambucfor Sprite at Berkeley. 22642e2caf59SThomas VeermanIt was designed to be a parallel distributed make running jobs on different 22652e2caf59SThomas Veermanmachines using a daemon called 22662e2caf59SThomas Veerman.Dq customs . 226784d9c625SLionel Sambuc.Pp 226884d9c625SLionel SambucHistorically the target/dependency 226984d9c625SLionel Sambuc.Dq FRC 227084d9c625SLionel Sambuchas been used to FoRCe rebuilding (since the target/dependency 227184d9c625SLionel Sambucdoes not exist... unless someone creates an 227284d9c625SLionel Sambuc.Dq FRC 227384d9c625SLionel Sambucfile). 22742e2caf59SThomas Veerman.Sh BUGS 22752e2caf59SThomas VeermanThe 22762e2caf59SThomas Veerman.Nm 22772e2caf59SThomas Veermansyntax is difficult to parse without actually acting of the data. 22782e2caf59SThomas VeermanFor instance finding the end of a variable use should involve scanning each 22792e2caf59SThomas Veermanthe modifiers using the correct terminator for each field. 22802e2caf59SThomas VeermanIn many places 22812e2caf59SThomas Veerman.Nm 22822e2caf59SThomas Veermanjust counts {} and () in order to find the end of a variable expansion. 22832e2caf59SThomas Veerman.Pp 22842e2caf59SThomas VeermanThere is no way of escaping a space character in a filename. 2285