xref: /freebsd/contrib/bmake/bmake.1 (revision 226192822cddc30cacecd55bccb48f39c653058c)
1*22619282SSimon J. Gerraty.\"	$NetBSD: make.1,v 1.378 2024/07/01 21:02:26 sjg Exp $
23955d011SMarcel Moolenaar.\"
33955d011SMarcel Moolenaar.\" Copyright (c) 1990, 1993
43955d011SMarcel Moolenaar.\"	The Regents of the University of California.  All rights reserved.
53955d011SMarcel Moolenaar.\"
63955d011SMarcel Moolenaar.\" Redistribution and use in source and binary forms, with or without
73955d011SMarcel Moolenaar.\" modification, are permitted provided that the following conditions
83955d011SMarcel Moolenaar.\" are met:
93955d011SMarcel Moolenaar.\" 1. Redistributions of source code must retain the above copyright
103955d011SMarcel Moolenaar.\"    notice, this list of conditions and the following disclaimer.
113955d011SMarcel Moolenaar.\" 2. Redistributions in binary form must reproduce the above copyright
123955d011SMarcel Moolenaar.\"    notice, this list of conditions and the following disclaimer in the
133955d011SMarcel Moolenaar.\"    documentation and/or other materials provided with the distribution.
143955d011SMarcel Moolenaar.\" 3. Neither the name of the University nor the names of its contributors
153955d011SMarcel Moolenaar.\"    may be used to endorse or promote products derived from this software
163955d011SMarcel Moolenaar.\"    without specific prior written permission.
173955d011SMarcel Moolenaar.\"
183955d011SMarcel Moolenaar.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
193955d011SMarcel Moolenaar.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
203955d011SMarcel Moolenaar.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
213955d011SMarcel Moolenaar.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
223955d011SMarcel Moolenaar.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
233955d011SMarcel Moolenaar.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
243955d011SMarcel Moolenaar.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
253955d011SMarcel Moolenaar.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
263955d011SMarcel Moolenaar.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
273955d011SMarcel Moolenaar.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
283955d011SMarcel Moolenaar.\" SUCH DAMAGE.
293955d011SMarcel Moolenaar.\"
303955d011SMarcel Moolenaar.\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
313955d011SMarcel Moolenaar.\"
32*22619282SSimon J. Gerraty.Dd July 1, 2024
3345447996SSimon J. Gerraty.Dt BMAKE 1
343955d011SMarcel Moolenaar.Os
353955d011SMarcel Moolenaar.Sh NAME
363955d011SMarcel Moolenaar.Nm bmake
373955d011SMarcel Moolenaar.Nd maintain program dependencies
383955d011SMarcel Moolenaar.Sh SYNOPSIS
393955d011SMarcel Moolenaar.Nm
40e2eeea75SSimon J. Gerraty.Op Fl BeikNnqrSstWwX
413955d011SMarcel Moolenaar.Op Fl C Ar directory
423955d011SMarcel Moolenaar.Op Fl D Ar variable
433955d011SMarcel Moolenaar.Op Fl d Ar flags
443955d011SMarcel Moolenaar.Op Fl f Ar makefile
453955d011SMarcel Moolenaar.Op Fl I Ar directory
463955d011SMarcel Moolenaar.Op Fl J Ar private
473955d011SMarcel Moolenaar.Op Fl j Ar max_jobs
483955d011SMarcel Moolenaar.Op Fl m Ar directory
493955d011SMarcel Moolenaar.Op Fl T Ar file
503955d011SMarcel Moolenaar.Op Fl V Ar variable
518695518cSSimon J. Gerraty.Op Fl v Ar variable
524fde40d9SSimon J. Gerraty.Op Ar variable\| Ns Cm \&= Ns Ar value
534fde40d9SSimon J. Gerraty.Op Ar target No ...
543955d011SMarcel Moolenaar.Sh DESCRIPTION
553955d011SMarcel Moolenaar.Nm
563955d011SMarcel Moolenaaris a program designed to simplify the maintenance of other programs.
573955d011SMarcel MoolenaarIts input is a list of specifications as to the files upon which programs
583955d011SMarcel Moolenaarand other files depend.
593955d011SMarcel MoolenaarIf no
603955d011SMarcel Moolenaar.Fl f Ar makefile
614fde40d9SSimon J. Gerratyoption is given,
623955d011SMarcel Moolenaar.Nm
634fde40d9SSimon J. Gerratytries to open
64954401e6SSimon J. Gerraty.Sq Pa makefile
653955d011SMarcel Moolenaarthen
66954401e6SSimon J. Gerraty.Sq Pa Makefile
673955d011SMarcel Moolenaarin order to find the specifications.
683955d011SMarcel MoolenaarIf the file
69954401e6SSimon J. Gerraty.Sq Pa .depend
704fde40d9SSimon J. Gerratyexists, it is read, see
714fde40d9SSimon J. Gerraty.Xr mkdep 1 .
723955d011SMarcel Moolenaar.Pp
733955d011SMarcel MoolenaarThis manual page is intended as a reference document only.
743955d011SMarcel MoolenaarFor a more thorough description of
753955d011SMarcel Moolenaar.Nm
763955d011SMarcel Moolenaarand makefiles, please refer to
774fde40d9SSimon J. Gerraty.%T "PMake \- A Tutorial"
784fde40d9SSimon J. Gerraty(from 1993).
793955d011SMarcel Moolenaar.Pp
803955d011SMarcel Moolenaar.Nm
814fde40d9SSimon J. Gerratyprepends the contents of the
824fde40d9SSimon J. Gerraty.Ev MAKEFLAGS
833955d011SMarcel Moolenaarenvironment variable to the command line arguments before parsing them.
843955d011SMarcel Moolenaar.Pp
853955d011SMarcel MoolenaarThe options are as follows:
863955d011SMarcel Moolenaar.Bl -tag -width Ds
873955d011SMarcel Moolenaar.It Fl B
883955d011SMarcel MoolenaarTry to be backwards compatible by executing a single shell per command and
894fde40d9SSimon J. Gerratyby making the sources of a dependency line in sequence.
903955d011SMarcel Moolenaar.It Fl C Ar directory
913955d011SMarcel MoolenaarChange to
923955d011SMarcel Moolenaar.Ar directory
933955d011SMarcel Moolenaarbefore reading the makefiles or doing anything else.
943955d011SMarcel MoolenaarIf multiple
953955d011SMarcel Moolenaar.Fl C
963955d011SMarcel Moolenaaroptions are specified, each is interpreted relative to the previous one:
973955d011SMarcel Moolenaar.Fl C Pa / Fl C Pa etc
983955d011SMarcel Moolenaaris equivalent to
993955d011SMarcel Moolenaar.Fl C Pa /etc .
1003955d011SMarcel Moolenaar.It Fl D Ar variable
1013955d011SMarcel MoolenaarDefine
1023955d011SMarcel Moolenaar.Ar variable
103dba7b0efSSimon J. Gerratyto be 1, in the global scope.
1044fde40d9SSimon J. Gerraty.It Fl d Oo Cm \- Oc Ns Ar flags
1053955d011SMarcel MoolenaarTurn on debugging, and specify which portions of
1063955d011SMarcel Moolenaar.Nm
1073955d011SMarcel Moolenaarare to print debugging information.
1083955d011SMarcel MoolenaarUnless the flags are preceded by
1094fde40d9SSimon J. Gerraty.Ql \- ,
1103955d011SMarcel Moolenaarthey are added to the
1114fde40d9SSimon J. Gerraty.Ev MAKEFLAGS
1124fde40d9SSimon J. Gerratyenvironment variable and are passed on to any child make processes.
1133955d011SMarcel MoolenaarBy default, debugging information is printed to standard error,
1143955d011SMarcel Moolenaarbut this can be changed using the
1154fde40d9SSimon J. Gerraty.Cm F
1163955d011SMarcel Moolenaardebugging flag.
1173955d011SMarcel MoolenaarThe debugging output is always unbuffered; in addition, if debugging
1183955d011SMarcel Moolenaaris enabled but debugging output is not directed to standard output,
1194fde40d9SSimon J. Gerratythe standard output is line buffered.
1204fde40d9SSimon J. GerratyThe available
1214fde40d9SSimon J. Gerraty.Ar flags
1224fde40d9SSimon J. Gerratyare:
1233955d011SMarcel Moolenaar.Bl -tag -width Ds
1244fde40d9SSimon J. Gerraty.It Cm A
1253955d011SMarcel MoolenaarPrint all possible debugging information;
1263955d011SMarcel Moolenaarequivalent to specifying all of the debugging flags.
1274fde40d9SSimon J. Gerraty.It Cm a
1283955d011SMarcel MoolenaarPrint debugging information about archive searching and caching.
1294fde40d9SSimon J. Gerraty.It Cm C
1304fde40d9SSimon J. GerratyPrint debugging information about the current working directory.
1314fde40d9SSimon J. Gerraty.It Cm c
1323955d011SMarcel MoolenaarPrint debugging information about conditional evaluation.
1334fde40d9SSimon J. Gerraty.It Cm d
1343955d011SMarcel MoolenaarPrint debugging information about directory searching and caching.
1354fde40d9SSimon J. Gerraty.It Cm e
1363955d011SMarcel MoolenaarPrint debugging information about failed commands and targets.
1374fde40d9SSimon J. Gerraty.It Cm F Ns Oo Cm \&+ Oc Ns Ar filename
1383955d011SMarcel MoolenaarSpecify where debugging output is written.
1393955d011SMarcel MoolenaarThis must be the last flag, because it consumes the remainder of
1403955d011SMarcel Moolenaarthe argument.
1413955d011SMarcel MoolenaarIf the character immediately after the
1424fde40d9SSimon J. Gerraty.Cm F
1433955d011SMarcel Moolenaarflag is
1443955d011SMarcel Moolenaar.Ql \&+ ,
1454fde40d9SSimon J. Gerratythe file is opened in append mode;
1464fde40d9SSimon J. Gerratyotherwise the file is overwritten.
1473955d011SMarcel MoolenaarIf the file name is
1483955d011SMarcel Moolenaar.Ql stdout
1493955d011SMarcel Moolenaaror
1504fde40d9SSimon J. Gerraty.Ql stderr ,
1514fde40d9SSimon J. Gerratydebugging output is written to the standard output or standard error output
1524fde40d9SSimon J. Gerratyrespectively (and the
1533955d011SMarcel Moolenaar.Ql \&+
1543955d011SMarcel Moolenaaroption has no effect).
1554fde40d9SSimon J. GerratyOtherwise, the output is written to the named file.
1564fde40d9SSimon J. GerratyIf the file name ends with
1574fde40d9SSimon J. Gerraty.Ql .%d ,
1584fde40d9SSimon J. Gerratythe
1593955d011SMarcel Moolenaar.Ql %d
1603955d011SMarcel Moolenaaris replaced by the pid.
1614fde40d9SSimon J. Gerraty.It Cm f
1623955d011SMarcel MoolenaarPrint debugging information about loop evaluation.
1634fde40d9SSimon J. Gerraty.It Cm g1
1643955d011SMarcel MoolenaarPrint the input graph before making anything.
1654fde40d9SSimon J. Gerraty.It Cm g2
1663955d011SMarcel MoolenaarPrint the input graph after making everything, or before exiting
1673955d011SMarcel Moolenaaron error.
1684fde40d9SSimon J. Gerraty.It Cm g3
1693955d011SMarcel MoolenaarPrint the input graph before exiting on error.
1704fde40d9SSimon J. Gerraty.It Cm h
1712c3632d1SSimon J. GerratyPrint debugging information about hash table operations.
1724fde40d9SSimon J. Gerraty.It Cm j
1733955d011SMarcel MoolenaarPrint debugging information about running multiple shells.
1744fde40d9SSimon J. Gerraty.It Cm L
1752c3632d1SSimon J. GerratyTurn on lint checks.
1764fde40d9SSimon J. GerratyThis throws errors for variable assignments that do not parse correctly,
1774fde40d9SSimon J. Gerratyat the time of assignment, so the file and line number are available.
1784fde40d9SSimon J. Gerraty.It Cm l
1793955d011SMarcel MoolenaarPrint commands in Makefiles regardless of whether or not they are prefixed by
1803955d011SMarcel Moolenaar.Ql @
1814fde40d9SSimon J. Gerratyor other
1824fde40d9SSimon J. Gerraty.Dq quiet
1834fde40d9SSimon J. Gerratyflags.
1844fde40d9SSimon J. GerratyAlso known as
1854fde40d9SSimon J. Gerraty.Dq loud
1864fde40d9SSimon J. Gerratybehavior.
1874fde40d9SSimon J. Gerraty.It Cm M
1884fde40d9SSimon J. GerratyPrint debugging information about
1894fde40d9SSimon J. Gerraty.Dq meta
1904fde40d9SSimon J. Gerratymode decisions about targets.
1914fde40d9SSimon J. Gerraty.It Cm m
1923955d011SMarcel MoolenaarPrint debugging information about making targets, including modification
1933955d011SMarcel Moolenaardates.
1944fde40d9SSimon J. Gerraty.It Cm n
1953955d011SMarcel MoolenaarDon't delete the temporary command scripts created when running commands.
1963955d011SMarcel MoolenaarThese temporary scripts are created in the directory
1973955d011SMarcel Moolenaarreferred to by the
1983955d011SMarcel Moolenaar.Ev TMPDIR
1993955d011SMarcel Moolenaarenvironment variable, or in
2003955d011SMarcel Moolenaar.Pa /tmp
2013955d011SMarcel Moolenaarif
2023955d011SMarcel Moolenaar.Ev TMPDIR
2033955d011SMarcel Moolenaaris unset or set to the empty string.
2043955d011SMarcel MoolenaarThe temporary scripts are created by
2053955d011SMarcel Moolenaar.Xr mkstemp 3 ,
2063955d011SMarcel Moolenaarand have names of the form
2073955d011SMarcel Moolenaar.Pa makeXXXXXX .
2083955d011SMarcel Moolenaar.Em NOTE :
2093955d011SMarcel MoolenaarThis can create many files in
2103955d011SMarcel Moolenaar.Ev TMPDIR
2113955d011SMarcel Moolenaaror
2123955d011SMarcel Moolenaar.Pa /tmp ,
2133955d011SMarcel Moolenaarso use with care.
2144fde40d9SSimon J. Gerraty.It Cm p
2153955d011SMarcel MoolenaarPrint debugging information about makefile parsing.
2164fde40d9SSimon J. Gerraty.It Cm s
2173955d011SMarcel MoolenaarPrint debugging information about suffix-transformation rules.
2184fde40d9SSimon J. Gerraty.It Cm t
2193955d011SMarcel MoolenaarPrint debugging information about target list maintenance.
2204fde40d9SSimon J. Gerraty.It Cm V
2213955d011SMarcel MoolenaarForce the
2223955d011SMarcel Moolenaar.Fl V
2234fde40d9SSimon J. Gerratyoption to print raw values of variables,
2244fde40d9SSimon J. Gerratyoverriding the default behavior set via
2258695518cSSimon J. Gerraty.Va .MAKE.EXPAND_VARIABLES .
2264fde40d9SSimon J. Gerraty.It Cm v
2274fde40d9SSimon J. GerratyPrint debugging information about variable assignment and expansion.
2284fde40d9SSimon J. Gerraty.It Cm x
2293955d011SMarcel MoolenaarRun shell commands with
2303955d011SMarcel Moolenaar.Fl x
2313955d011SMarcel Moolenaarso the actual commands are printed as they are executed.
2323955d011SMarcel Moolenaar.El
2333955d011SMarcel Moolenaar.It Fl e
2344fde40d9SSimon J. GerratyLet environment variables override global variables within makefiles.
2353955d011SMarcel Moolenaar.It Fl f Ar makefile
2363955d011SMarcel MoolenaarSpecify a makefile to read instead of the default
2374fde40d9SSimon J. Gerraty.Pa makefile
2384fde40d9SSimon J. Gerratyor
2394fde40d9SSimon J. Gerraty.Pa Makefile .
2403955d011SMarcel MoolenaarIf
2413955d011SMarcel Moolenaar.Ar makefile
2423955d011SMarcel Moolenaaris
2434fde40d9SSimon J. Gerraty.Ql \&- ,
2443955d011SMarcel Moolenaarstandard input is read.
2453955d011SMarcel MoolenaarMultiple makefiles may be specified, and are read in the order specified.
2463955d011SMarcel Moolenaar.It Fl I Ar directory
2473955d011SMarcel MoolenaarSpecify a directory in which to search for makefiles and included makefiles.
2483955d011SMarcel MoolenaarThe system makefile directory (or directories, see the
2493955d011SMarcel Moolenaar.Fl m
2503955d011SMarcel Moolenaaroption) is automatically included as part of this list.
2513955d011SMarcel Moolenaar.It Fl i
2523955d011SMarcel MoolenaarIgnore non-zero exit of shell commands in the makefile.
2533955d011SMarcel MoolenaarEquivalent to specifying
2544fde40d9SSimon J. Gerraty.Ql \&-
2553955d011SMarcel Moolenaarbefore each command line in the makefile.
2563955d011SMarcel Moolenaar.It Fl J Ar private
2573955d011SMarcel MoolenaarThis option should
2583955d011SMarcel Moolenaar.Em not
2593955d011SMarcel Moolenaarbe specified by the user.
2603955d011SMarcel Moolenaar.Pp
2613955d011SMarcel MoolenaarWhen the
262954401e6SSimon J. Gerraty.Fl j
2633955d011SMarcel Moolenaaroption is in use in a recursive build, this option is passed by a make
2643955d011SMarcel Moolenaarto child makes to allow all the make processes in the build to
2653955d011SMarcel Moolenaarcooperate to avoid overloading the system.
2663955d011SMarcel Moolenaar.It Fl j Ar max_jobs
2673955d011SMarcel MoolenaarSpecify the maximum number of jobs that
2683955d011SMarcel Moolenaar.Nm
2693955d011SMarcel Moolenaarmay have running at any one time.
27098875883SSimon J. GerratyIf
27198875883SSimon J. Gerraty.Ar max_jobs
27298875883SSimon J. Gerratyis a floating point number, or ends with
27398875883SSimon J. Gerraty.Ql C ,
27498875883SSimon J. Gerratythen the value is multiplied by the number of CPUs reported online by
27598875883SSimon J. Gerraty.Xr sysconf 3 .
2768c973ee2SSimon J. GerratyThe value of
2778c973ee2SSimon J. Gerraty.Ar max_jobs
2788c973ee2SSimon J. Gerratyis saved in
2793955d011SMarcel Moolenaar.Va .MAKE.JOBS .
2803955d011SMarcel MoolenaarTurns compatibility mode off, unless the
281954401e6SSimon J. Gerraty.Fl B
282954401e6SSimon J. Gerratyoption is also specified.
2833955d011SMarcel MoolenaarWhen compatibility mode is off, all commands associated with a
2843955d011SMarcel Moolenaartarget are executed in a single shell invocation as opposed to the
2853955d011SMarcel Moolenaartraditional one shell invocation per line.
2863955d011SMarcel MoolenaarThis can break traditional scripts which change directories on each
2873955d011SMarcel Moolenaarcommand invocation and then expect to start with a fresh environment
2883955d011SMarcel Moolenaaron the next line.
2893955d011SMarcel MoolenaarIt is more efficient to correct the scripts rather than turn backwards
2903955d011SMarcel Moolenaarcompatibility on.
2918c973ee2SSimon J. Gerraty.Pp
2928c973ee2SSimon J. GerratyA job token pool with
2938c973ee2SSimon J. Gerraty.Ar max_jobs
2948c973ee2SSimon J. Gerratytokens is used to control the total number of jobs running.
2958c973ee2SSimon J. GerratyEach instance of
2968c973ee2SSimon J. Gerraty.Nm
2978c973ee2SSimon J. Gerratywill wait for a token from the pool before running a new job.
2983955d011SMarcel Moolenaar.It Fl k
2993955d011SMarcel MoolenaarContinue processing after errors are encountered, but only on those targets
3003955d011SMarcel Moolenaarthat do not depend on the target whose creation caused the error.
3013955d011SMarcel Moolenaar.It Fl m Ar directory
3024fde40d9SSimon J. GerratySpecify a directory in which to search for
3034fde40d9SSimon J. Gerraty.Pa sys.mk
3044fde40d9SSimon J. Gerratyand makefiles included via the
305ef0b2538SSimon J. Gerraty.Li \&< Ns Ar file Ns Li \&> Ns -style
3063955d011SMarcel Moolenaarinclude statement.
3073955d011SMarcel MoolenaarThe
3083955d011SMarcel Moolenaar.Fl m
3093955d011SMarcel Moolenaaroption can be used multiple times to form a search path.
3104fde40d9SSimon J. GerratyThis path overrides the default system include path
3114fde40d9SSimon J. Gerraty.Pa /usr/share/mk .
3124fde40d9SSimon J. GerratyFurthermore, the system include path is appended to the search path used for
313ef0b2538SSimon J. Gerraty.Li \*q Ns Ar file Ns Li \*q Ns -style
3143955d011SMarcel Moolenaarinclude statements (see the
3153955d011SMarcel Moolenaar.Fl I
3163955d011SMarcel Moolenaaroption).
3174fde40d9SSimon J. GerratyThe system include path can be referenced via the read-only variable
3184fde40d9SSimon J. Gerraty.Va .SYSPATH .
3193955d011SMarcel Moolenaar.Pp
3204fde40d9SSimon J. GerratyIf a directory name in the
3213955d011SMarcel Moolenaar.Fl m
3223955d011SMarcel Moolenaarargument (or the
3233955d011SMarcel Moolenaar.Ev MAKESYSPATH
3243955d011SMarcel Moolenaarenvironment variable) starts with the string
3254fde40d9SSimon J. Gerraty.Ql \&.../ ,
3263955d011SMarcel Moolenaar.Nm
3274fde40d9SSimon J. Gerratysearches for the specified file or directory named in the remaining part
3283955d011SMarcel Moolenaarof the argument string.
3294fde40d9SSimon J. GerratyThe search starts with the current directory
3304fde40d9SSimon J. Gerratyand then works upward towards the root of the file system.
3314fde40d9SSimon J. GerratyIf the search is successful, the resulting directory replaces the
3324fde40d9SSimon J. Gerraty.Ql \&.../
3333955d011SMarcel Moolenaarspecification in the
3343955d011SMarcel Moolenaar.Fl m
3353955d011SMarcel Moolenaarargument.
3364fde40d9SSimon J. GerratyThis feature allows
3373955d011SMarcel Moolenaar.Nm
3384fde40d9SSimon J. Gerratyto easily search in the current source tree for customized
3394fde40d9SSimon J. Gerraty.Pa sys.mk
3404fde40d9SSimon J. Gerratyfiles (e.g., by using
3414fde40d9SSimon J. Gerraty.Ql \&.../mk/sys.mk
3423955d011SMarcel Moolenaaras an argument).
3433955d011SMarcel Moolenaar.It Fl n
3443955d011SMarcel MoolenaarDisplay the commands that would have been executed, but do not
3454fde40d9SSimon J. Gerratyactually execute them unless the target depends on the
3464fde40d9SSimon J. Gerraty.Va .MAKE
3474fde40d9SSimon J. Gerratyspecial source (see below) or the command is prefixed with
3484fde40d9SSimon J. Gerraty.Sq Cm + .
3493955d011SMarcel Moolenaar.It Fl N
3504fde40d9SSimon J. GerratyDisplay the commands that would have been executed,
3514fde40d9SSimon J. Gerratybut do not actually execute any of them;
3524fde40d9SSimon J. Gerratyuseful for debugging top-level makefiles
3533955d011SMarcel Moolenaarwithout descending into subdirectories.
3543955d011SMarcel Moolenaar.It Fl q
3554fde40d9SSimon J. GerratyDo not execute any commands,
3564fde40d9SSimon J. Gerratyinstead exit 0 if the specified targets are up to date, and 1 otherwise.
3573955d011SMarcel Moolenaar.It Fl r
3583955d011SMarcel MoolenaarDo not use the built-in rules specified in the system makefile.
359e2eeea75SSimon J. Gerraty.It Fl S
360e2eeea75SSimon J. GerratyStop processing if an error is encountered.
361e2eeea75SSimon J. GerratyThis is the default behavior and the opposite of
362e2eeea75SSimon J. Gerraty.Fl k .
3633955d011SMarcel Moolenaar.It Fl s
3643955d011SMarcel MoolenaarDo not echo any commands as they are executed.
3653955d011SMarcel MoolenaarEquivalent to specifying
366954401e6SSimon J. Gerraty.Sq Ic @
3673955d011SMarcel Moolenaarbefore each command line in the makefile.
3683955d011SMarcel Moolenaar.It Fl T Ar tracefile
3693955d011SMarcel MoolenaarWhen used with the
3703955d011SMarcel Moolenaar.Fl j
3713955d011SMarcel Moolenaarflag,
3723955d011SMarcel Moolenaarappend a trace record to
3733955d011SMarcel Moolenaar.Ar tracefile
3743955d011SMarcel Moolenaarfor each job started and completed.
3753955d011SMarcel Moolenaar.It Fl t
3763955d011SMarcel MoolenaarRather than re-building a target as specified in the makefile, create it
3773955d011SMarcel Moolenaaror update its modification time to make it appear up-to-date.
3783955d011SMarcel Moolenaar.It Fl V Ar variable
3798695518cSSimon J. GerratyPrint the value of
3808695518cSSimon J. Gerraty.Ar variable .
3813955d011SMarcel MoolenaarDo not build any targets.
3823955d011SMarcel MoolenaarMultiple instances of this option may be specified;
3834fde40d9SSimon J. Gerratythe variables are printed one per line,
3843955d011SMarcel Moolenaarwith a blank line for each null or undefined variable.
385dba7b0efSSimon J. GerratyThe value printed is extracted from the global scope after all
3868695518cSSimon J. Gerratymakefiles have been read.
3874fde40d9SSimon J. Gerraty.Pp
3888695518cSSimon J. GerratyBy default, the raw variable contents (which may
3898695518cSSimon J. Gerratyinclude additional unexpanded variable references) are shown.
3903955d011SMarcel MoolenaarIf
3913955d011SMarcel Moolenaar.Ar variable
3923955d011SMarcel Moolenaarcontains a
3934fde40d9SSimon J. Gerraty.Ql \&$ ,
3944fde40d9SSimon J. Gerratyit is not interpreted as a variable name but rather as an expression.
3954fde40d9SSimon J. GerratyIts value is expanded before printing.
3964fde40d9SSimon J. GerratyThe value is also expanded before printing if
3978695518cSSimon J. Gerraty.Va .MAKE.EXPAND_VARIABLES
3984fde40d9SSimon J. Gerratyis set to true and the
3998695518cSSimon J. Gerraty.Fl dV
4008695518cSSimon J. Gerratyoption has not been used to override it.
4014fde40d9SSimon J. Gerraty.Pp
4028695518cSSimon J. GerratyNote that loop-local and target-local variables, as well as values
4038695518cSSimon J. Gerratytaken temporarily by global variables during makefile processing, are
4048695518cSSimon J. Gerratynot accessible via this option.
4058695518cSSimon J. GerratyThe
4068695518cSSimon J. Gerraty.Fl dv
4078695518cSSimon J. Gerratydebug mode can be used to see these at the cost of generating
4088695518cSSimon J. Gerratysubstantial extraneous output.
4098695518cSSimon J. Gerraty.It Fl v Ar variable
4108695518cSSimon J. GerratyLike
4114fde40d9SSimon J. Gerraty.Fl V ,
4124fde40d9SSimon J. Gerratybut all printed variables are always expanded to their complete value.
4134fde40d9SSimon J. GerratyThe last occurrence of
4148695518cSSimon J. Gerraty.Fl V
4154fde40d9SSimon J. Gerratyor
4164fde40d9SSimon J. Gerraty.Fl v
4174fde40d9SSimon J. Gerratydecides whether all variables are expanded or not.
4183955d011SMarcel Moolenaar.It Fl W
4193955d011SMarcel MoolenaarTreat any warnings during makefile parsing as errors.
420db29cad8SSimon J. Gerraty.It Fl w
421db29cad8SSimon J. GerratyPrint entering and leaving directory messages, pre and post processing.
4223955d011SMarcel Moolenaar.It Fl X
4233955d011SMarcel MoolenaarDon't export variables passed on the command line to the environment
4243955d011SMarcel Moolenaarindividually.
4254fde40d9SSimon J. GerratyVariables passed on the command line are still exported via the
4264fde40d9SSimon J. Gerraty.Ev MAKEFLAGS
4273955d011SMarcel Moolenaarenvironment variable.
4283955d011SMarcel MoolenaarThis option may be useful on systems which have a small limit on the
4293955d011SMarcel Moolenaarsize of command arguments.
4304fde40d9SSimon J. Gerraty.It Ar variable\| Ns Cm \&= Ns Ar value
4313955d011SMarcel MoolenaarSet the value of the variable
4323955d011SMarcel Moolenaar.Ar variable
4333955d011SMarcel Moolenaarto
4343955d011SMarcel Moolenaar.Ar value .
4353955d011SMarcel MoolenaarNormally, all values passed on the command line are also exported to
4363955d011SMarcel Moolenaarsub-makes in the environment.
4373955d011SMarcel MoolenaarThe
4383955d011SMarcel Moolenaar.Fl X
4393955d011SMarcel Moolenaarflag disables this behavior.
4403955d011SMarcel MoolenaarVariable assignments should follow options for POSIX compatibility
4413955d011SMarcel Moolenaarbut no ordering is enforced.
4423955d011SMarcel Moolenaar.El
4433955d011SMarcel Moolenaar.Pp
4444fde40d9SSimon J. GerratyThere are several different types of lines in a makefile: dependency
4453955d011SMarcel Moolenaarspecifications, shell commands, variable assignments, include statements,
4464fde40d9SSimon J. Gerratyconditional directives, for loops, other directives, and comments.
4473955d011SMarcel Moolenaar.Pp
4484fde40d9SSimon J. GerratyLines may be continued from one line to the next
4494fde40d9SSimon J. Gerratyby ending them with a backslash
4503955d011SMarcel Moolenaar.Pq Ql \e .
4513955d011SMarcel MoolenaarThe trailing newline character and initial whitespace on the following
4523955d011SMarcel Moolenaarline are compressed into a single space.
4533955d011SMarcel Moolenaar.Sh FILE DEPENDENCY SPECIFICATIONS
4543955d011SMarcel MoolenaarDependency lines consist of one or more targets, an operator, and zero
4553955d011SMarcel Moolenaaror more sources.
4563955d011SMarcel MoolenaarThis creates a relationship where the targets
4573955d011SMarcel Moolenaar.Dq depend
4584fde40d9SSimon J. Gerratyon the sources and are customarily created from them.
4594fde40d9SSimon J. GerratyA target is considered out of date if it does not exist,
4604fde40d9SSimon J. Gerratyor if its modification time is less than that of any of its sources.
4614fde40d9SSimon J. GerratyAn out-of-date target is re-created, but not until all sources
4622c3632d1SSimon J. Gerratyhave been examined and themselves re-created as needed.
4632c3632d1SSimon J. GerratyThree operators may be used:
4643955d011SMarcel Moolenaar.Bl -tag -width flag
4653955d011SMarcel Moolenaar.It Ic \&:
4662c3632d1SSimon J. GerratyMany dependency lines may name this target but only one may have
4672c3632d1SSimon J. Gerratyattached shell commands.
4682c3632d1SSimon J. GerratyAll sources named in all dependency lines are considered together,
4692c3632d1SSimon J. Gerratyand if needed the attached shell commands are run to create or
4702c3632d1SSimon J. Gerratyre-create the target.
4712c3632d1SSimon J. GerratyIf
4723955d011SMarcel Moolenaar.Nm
4732c3632d1SSimon J. Gerratyis interrupted, the target is removed.
4743955d011SMarcel Moolenaar.It Ic \&!
4752c3632d1SSimon J. GerratyThe same, but the target is always re-created whether or not it is out
4762c3632d1SSimon J. Gerratyof date.
4773955d011SMarcel Moolenaar.It Ic \&::
4782c3632d1SSimon J. GerratyAny dependency line may have attached shell commands, but each one
4792c3632d1SSimon J. Gerratyis handled independently: its sources are considered and the attached
4802c3632d1SSimon J. Gerratyshell commands are run if the target is out of date with respect to
4812c3632d1SSimon J. Gerraty(only) those sources.
4822c3632d1SSimon J. GerratyThus, different groups of the attached shell commands may be run
4832c3632d1SSimon J. Gerratydepending on the circumstances.
4842c3632d1SSimon J. GerratyFurthermore, unlike
4852c3632d1SSimon J. Gerraty.Ic \&: ,
4862c3632d1SSimon J. Gerratyfor dependency lines with no sources, the attached shell
4872c3632d1SSimon J. Gerratycommands are always run.
4882c3632d1SSimon J. GerratyAlso unlike
4892c3632d1SSimon J. Gerraty.Ic \&: ,
4904fde40d9SSimon J. Gerratythe target is not removed if
4913955d011SMarcel Moolenaar.Nm
4923955d011SMarcel Moolenaaris interrupted.
4933955d011SMarcel Moolenaar.El
4944fde40d9SSimon J. Gerraty.Pp
4952c3632d1SSimon J. GerratyAll dependency lines mentioning a particular target must use the same
4962c3632d1SSimon J. Gerratyoperator.
4973955d011SMarcel Moolenaar.Pp
4983955d011SMarcel MoolenaarTargets and sources may contain the shell wildcard values
4993955d011SMarcel Moolenaar.Ql \&? ,
5003955d011SMarcel Moolenaar.Ql * ,
5013955d011SMarcel Moolenaar.Ql [] ,
5023955d011SMarcel Moolenaarand
5033955d011SMarcel Moolenaar.Ql {} .
5043955d011SMarcel MoolenaarThe values
5053955d011SMarcel Moolenaar.Ql \&? ,
5063955d011SMarcel Moolenaar.Ql * ,
5073955d011SMarcel Moolenaarand
5083955d011SMarcel Moolenaar.Ql []
5094fde40d9SSimon J. Gerratymay only be used as part of the final component of the target or source,
5104fde40d9SSimon J. Gerratyand only match existing files.
5113955d011SMarcel MoolenaarThe value
5123955d011SMarcel Moolenaar.Ql {}
5133955d011SMarcel Moolenaarneed not necessarily be used to describe existing files.
5143955d011SMarcel MoolenaarExpansion is in directory order, not alphabetically as done in the shell.
5153955d011SMarcel Moolenaar.Sh SHELL COMMANDS
5164fde40d9SSimon J. GerratyEach target may have associated with it one or more lines of shell commands,
5174fde40d9SSimon J. Gerratynormally used to create the target.
518db29cad8SSimon J. GerratyEach of the lines in this script
5193955d011SMarcel Moolenaar.Em must
5203955d011SMarcel Moolenaarbe preceded by a tab.
521db29cad8SSimon J. Gerraty(For historical reasons, spaces are not accepted.)
5224fde40d9SSimon J. GerratyWhile targets can occur in many dependency lines if desired,
5234fde40d9SSimon J. Gerratyby default only one of these rules may be followed by a creation script.
524db29cad8SSimon J. GerratyIf the
525954401e6SSimon J. Gerraty.Sq Ic \&::
5264fde40d9SSimon J. Gerratyoperator is used, however, all rules may include scripts,
5274fde40d9SSimon J. Gerratyand the respective scripts are executed in the order found.
5283955d011SMarcel Moolenaar.Pp
5294fde40d9SSimon J. GerratyEach line is treated as a separate shell command,
5304fde40d9SSimon J. Gerratyunless the end of line is escaped with a backslash
5314fde40d9SSimon J. Gerraty.Ql \e ,
532db29cad8SSimon J. Gerratyin which case that line and the next are combined.
533db29cad8SSimon J. GerratyIf the first characters of the command are any combination of
534954401e6SSimon J. Gerraty.Sq Ic @ ,
535954401e6SSimon J. Gerraty.Sq Ic + ,
5363955d011SMarcel Moolenaaror
537954401e6SSimon J. Gerraty.Sq Ic \- ,
5383955d011SMarcel Moolenaarthe command is treated specially.
5394fde40d9SSimon J. Gerraty.Bl -tag -offset indent -width indent
5404fde40d9SSimon J. Gerraty.It Ic @
5413955d011SMarcel Moolenaarcauses the command not to be echoed before it is executed.
5424fde40d9SSimon J. Gerraty.It Ic +
5433955d011SMarcel Moolenaarcauses the command to be executed even when
5443955d011SMarcel Moolenaar.Fl n
5453955d011SMarcel Moolenaaris given.
5464fde40d9SSimon J. GerratyThis is similar to the effect of the
5474fde40d9SSimon J. Gerraty.Va .MAKE
5484fde40d9SSimon J. Gerratyspecial source,
5493955d011SMarcel Moolenaarexcept that the effect can be limited to a single line of a script.
5504fde40d9SSimon J. Gerraty.It Ic \-
551db29cad8SSimon J. Gerratyin compatibility mode
5523955d011SMarcel Moolenaarcauses any non-zero exit status of the command line to be ignored.
5534fde40d9SSimon J. Gerraty.El
5543cbdda60SSimon J. Gerraty.Pp
5553cbdda60SSimon J. GerratyWhen
5563cbdda60SSimon J. Gerraty.Nm
5573cbdda60SSimon J. Gerratyis run in jobs mode with
5583cbdda60SSimon J. Gerraty.Fl j Ar max_jobs ,
5594fde40d9SSimon J. Gerratythe entire script for the target is fed to a single instance of the shell.
5603cbdda60SSimon J. GerratyIn compatibility (non-jobs) mode, each command is run in a separate process.
5613cbdda60SSimon J. GerratyIf the command contains any shell meta characters
5624fde40d9SSimon J. Gerraty.Pq Ql #=|^(){};&<>*?[]:$`\e\en ,
5634fde40d9SSimon J. Gerratyit is passed to the shell; otherwise
5643cbdda60SSimon J. Gerraty.Nm
5654fde40d9SSimon J. Gerratyattempts direct execution.
566db29cad8SSimon J. GerratyIf a line starts with
567954401e6SSimon J. Gerraty.Sq Ic \-
5684fde40d9SSimon J. Gerratyand the shell has ErrCtl enabled,
5694fde40d9SSimon J. Gerratyfailure of the command line is ignored as in compatibility mode.
570db29cad8SSimon J. GerratyOtherwise
571954401e6SSimon J. Gerraty.Sq Ic \-
572db29cad8SSimon J. Gerratyaffects the entire job;
5734fde40d9SSimon J. Gerratythe script stops at the first command line that fails,
5744fde40d9SSimon J. Gerratybut the target is not deemed to have failed.
575db29cad8SSimon J. Gerraty.Pp
576db29cad8SSimon J. GerratyMakefiles should be written so that the mode of
577db29cad8SSimon J. Gerraty.Nm
578db29cad8SSimon J. Gerratyoperation does not change their behavior.
5794fde40d9SSimon J. GerratyFor example, any command which uses
580db29cad8SSimon J. Gerraty.Dq cd
581db29cad8SSimon J. Gerratyor
582db29cad8SSimon J. Gerraty.Dq chdir
5834fde40d9SSimon J. Gerratywithout the intention of changing the directory for subsequent commands
584db29cad8SSimon J. Gerratyshould be put in parentheses so it executes in a subshell.
5854fde40d9SSimon J. GerratyTo force the use of a single shell, escape the line breaks so as to make
586db29cad8SSimon J. Gerratythe whole script one command.
587db29cad8SSimon J. GerratyFor example:
588db29cad8SSimon J. Gerraty.Bd -literal -offset indent
589db29cad8SSimon J. Gerratyavoid-chdir-side-effects:
5904fde40d9SSimon J. Gerraty	@echo "Building $@ in $$(pwd)"
591db29cad8SSimon J. Gerraty	@(cd ${.CURDIR} && ${MAKE} $@)
5924fde40d9SSimon J. Gerraty	@echo "Back in $$(pwd)"
593db29cad8SSimon J. Gerraty
594db29cad8SSimon J. Gerratyensure-one-shell-regardless-of-mode:
5954fde40d9SSimon J. Gerraty	@echo "Building $@ in $$(pwd)"; \e
596db29cad8SSimon J. Gerraty	(cd ${.CURDIR} && ${MAKE} $@); \e
5974fde40d9SSimon J. Gerraty	echo "Back in $$(pwd)"
598db29cad8SSimon J. Gerraty.Ed
5993cbdda60SSimon J. Gerraty.Pp
6003cbdda60SSimon J. GerratySince
6013cbdda60SSimon J. Gerraty.Nm
6024fde40d9SSimon J. Gerratychanges the current working directory to
603954401e6SSimon J. Gerraty.Sq Va .OBJDIR
6044fde40d9SSimon J. Gerratybefore executing any targets,
6054fde40d9SSimon J. Gerratyeach child process starts with that as its current working directory.
6063955d011SMarcel Moolenaar.Sh VARIABLE ASSIGNMENTS
607954401e6SSimon J. GerratyVariables in make behave much like macros in the C preprocessor.
608954401e6SSimon J. Gerraty.Pp
609954401e6SSimon J. GerratyVariable assignments have the form
610954401e6SSimon J. Gerraty.Sq Ar NAME Ar op Ar value ,
611954401e6SSimon J. Gerratywhere:
6124fde40d9SSimon J. Gerraty.Bl -tag -offset Ds -width Ds
613954401e6SSimon J. Gerraty.It Ar NAME
614954401e6SSimon J. Gerratyis a single-word variable name,
615954401e6SSimon J. Gerratyconsisting, by tradition, of all upper-case letters,
616954401e6SSimon J. Gerraty.It Ar op
6174fde40d9SSimon J. Gerratyis one of the variable assignment operators described below, and
618954401e6SSimon J. Gerraty.It Ar value
619954401e6SSimon J. Gerratyis interpreted according to the variable assignment operator.
620954401e6SSimon J. Gerraty.El
621954401e6SSimon J. Gerraty.Pp
622954401e6SSimon J. GerratyWhitespace around
623954401e6SSimon J. Gerraty.Ar NAME ,
624954401e6SSimon J. Gerraty.Ar op
625954401e6SSimon J. Gerratyand
626954401e6SSimon J. Gerraty.Ar value
627954401e6SSimon J. Gerratyis discarded.
628954401e6SSimon J. Gerraty.Ss Variable assignment operators
6294fde40d9SSimon J. GerratyThe five operators that assign values to variables are:
6303955d011SMarcel Moolenaar.Bl -tag -width Ds
6313955d011SMarcel Moolenaar.It Ic \&=
6323955d011SMarcel MoolenaarAssign the value to the variable.
633954401e6SSimon J. GerratyAny previous value is overwritten.
6343955d011SMarcel Moolenaar.It Ic \&+=
635954401e6SSimon J. GerratyAppend the value to the current value of the variable,
636954401e6SSimon J. Gerratyseparating them by a single space.
6373955d011SMarcel Moolenaar.It Ic \&?=
6383955d011SMarcel MoolenaarAssign the value to the variable if it is not already defined.
6393955d011SMarcel Moolenaar.It Ic \&:=
6404fde40d9SSimon J. GerratyExpand the value, then assign it to the variable.
641954401e6SSimon J. Gerraty.Pp
6423955d011SMarcel Moolenaar.Em NOTE :
6433955d011SMarcel MoolenaarReferences to undefined variables are
6443955d011SMarcel Moolenaar.Em not
6453955d011SMarcel Moolenaarexpanded.
6463955d011SMarcel MoolenaarThis can cause problems when variable modifiers are used.
6474fde40d9SSimon J. Gerraty.\" See var-op-expand.mk, the section with LATER and INDIRECT.
6483955d011SMarcel Moolenaar.It Ic \&!=
6494fde40d9SSimon J. GerratyExpand the value and pass it to the shell for execution,
6504fde40d9SSimon J. Gerratythen assign the output from the child's standard output to the variable.
6513955d011SMarcel MoolenaarAny newlines in the result are replaced with spaces.
6523955d011SMarcel Moolenaar.El
653954401e6SSimon J. Gerraty.Ss Expansion of variables
6544fde40d9SSimon J. GerratyIn most contexts where variables are expanded,
655954401e6SSimon J. Gerraty.Ql \&$$
656954401e6SSimon J. Gerratyexpands to a single dollar sign.
6574fde40d9SSimon J. GerratyIn other contexts (most variable modifiers, string literals in conditions),
6584fde40d9SSimon J. Gerraty.Ql \&\e$
6594fde40d9SSimon J. Gerratyexpands to a single dollar sign.
6604fde40d9SSimon J. Gerraty.Pp
661954401e6SSimon J. GerratyReferences to variables have the form
6624fde40d9SSimon J. Gerraty.Cm \&${ Ns Ar name Ns Oo Ns Cm \&: Ns Ar modifiers Oc Ns Cm \&}
663954401e6SSimon J. Gerratyor
6644fde40d9SSimon J. Gerraty.Cm \&$( Ns Ar name Ns Oo Ns Cm \&: Ns Ar modifiers Oc Ns Cm \&) .
6654fde40d9SSimon J. GerratyIf the variable name consists of only a single character
6664fde40d9SSimon J. Gerratyand the expression contains no modifiers,
667954401e6SSimon J. Gerratythe surrounding curly braces or parentheses are not required.
6683955d011SMarcel MoolenaarThis shorter form is not recommended.
6693955d011SMarcel Moolenaar.Pp
6704fde40d9SSimon J. GerratyIf the variable name contains a dollar, the name itself is expanded first.
6713955d011SMarcel MoolenaarThis allows almost arbitrary variable names, however names containing dollar,
6724fde40d9SSimon J. Gerratybraces, parentheses or whitespace are really best avoided.
6733955d011SMarcel Moolenaar.Pp
6744fde40d9SSimon J. GerratyIf the result of expanding a nested variable expression contains a dollar sign
675954401e6SSimon J. Gerraty.Pq Ql \&$ ,
6764fde40d9SSimon J. Gerratythe result is subject to further expansion.
6773955d011SMarcel Moolenaar.Pp
678954401e6SSimon J. GerratyVariable substitution occurs at four distinct times, depending on where
6793955d011SMarcel Moolenaarthe variable is being used.
6803955d011SMarcel Moolenaar.Bl -enum
6813955d011SMarcel Moolenaar.It
6823955d011SMarcel MoolenaarVariables in dependency lines are expanded as the line is read.
6833955d011SMarcel Moolenaar.It
684954401e6SSimon J. GerratyVariables in conditionals are expanded individually,
685954401e6SSimon J. Gerratybut only as far as necessary to determine the result of the conditional.
686954401e6SSimon J. Gerraty.It
6873955d011SMarcel MoolenaarVariables in shell commands are expanded when the shell command is
6883955d011SMarcel Moolenaarexecuted.
6893955d011SMarcel Moolenaar.It
6904fde40d9SSimon J. Gerraty.Ic .for
6913955d011SMarcel Moolenaarloop index variables are expanded on each loop iteration.
692954401e6SSimon J. GerratyNote that other variables are not expanded when composing the body of a loop,
693954401e6SSimon J. Gerratyso the following example code:
6943955d011SMarcel Moolenaar.Bd -literal -offset indent
6954fde40d9SSimon J. Gerraty\&.for i in 1 2 3
6963955d011SMarcel Moolenaara+=     ${i}
6973955d011SMarcel Moolenaarj=      ${i}
6983955d011SMarcel Moolenaarb+=     ${j}
6994fde40d9SSimon J. Gerraty\&.endfor
7003955d011SMarcel Moolenaar
7013955d011SMarcel Moolenaarall:
7023955d011SMarcel Moolenaar	@echo ${a}
7033955d011SMarcel Moolenaar	@echo ${b}
7043955d011SMarcel Moolenaar.Ed
7054fde40d9SSimon J. Gerraty.Pp
7064fde40d9SSimon J. Gerratyprints:
7073955d011SMarcel Moolenaar.Bd -literal -offset indent
7083955d011SMarcel Moolenaar1 2 3
7093955d011SMarcel Moolenaar3 3 3
7103955d011SMarcel Moolenaar.Ed
7114fde40d9SSimon J. Gerraty.Pp
7124fde40d9SSimon J. GerratyAfter the loop is executed:
7134fde40d9SSimon J. Gerraty.Bl -tag -offset indent -width indent
7144fde40d9SSimon J. Gerraty.It Va a
7153955d011SMarcel Moolenaarcontains
7164fde40d9SSimon J. Gerraty.Ql ${:U1} ${:U2} ${:U3} ,
7173955d011SMarcel Moolenaarwhich expands to
7184fde40d9SSimon J. Gerraty.Ql 1 2 3 .
7194fde40d9SSimon J. Gerraty.It Va j
7204fde40d9SSimon J. Gerratycontains
7214fde40d9SSimon J. Gerraty.Ql ${:U3} ,
7224fde40d9SSimon J. Gerratywhich expands to
7234fde40d9SSimon J. Gerraty.Ql 3 .
7244fde40d9SSimon J. Gerraty.It Va b
7254fde40d9SSimon J. Gerratycontains
7264fde40d9SSimon J. Gerraty.Ql ${j} ${j} ${j} ,
7274fde40d9SSimon J. Gerratywhich expands to
7284fde40d9SSimon J. Gerraty.Ql ${:U3} ${:U3} ${:U3}
7294fde40d9SSimon J. Gerratyand further to
7304fde40d9SSimon J. Gerraty.Ql 3 3 3 .
7314fde40d9SSimon J. Gerraty.El
7323955d011SMarcel Moolenaar.El
7333955d011SMarcel Moolenaar.Ss Variable classes
7343955d011SMarcel MoolenaarThe four different classes of variables (in order of increasing precedence)
7353955d011SMarcel Moolenaarare:
7363955d011SMarcel Moolenaar.Bl -tag -width Ds
7373955d011SMarcel Moolenaar.It Environment variables
7383955d011SMarcel MoolenaarVariables defined as part of
7393955d011SMarcel Moolenaar.Nm Ns 's
7403955d011SMarcel Moolenaarenvironment.
7413955d011SMarcel Moolenaar.It Global variables
7423955d011SMarcel MoolenaarVariables defined in the makefile or in included makefiles.
7433955d011SMarcel Moolenaar.It Command line variables
7443955d011SMarcel MoolenaarVariables defined as part of the command line.
7453955d011SMarcel Moolenaar.It Local variables
7463955d011SMarcel MoolenaarVariables that are defined specific to a certain target.
747db29cad8SSimon J. Gerraty.El
748db29cad8SSimon J. Gerraty.Pp
7494fde40d9SSimon J. GerratyLocal variables can be set on a dependency line, unless
7501d3f2ddcSSimon J. Gerraty.Va .MAKE.TARGET_LOCAL_VARIABLES
7514fde40d9SSimon J. Gerratyis set to
7529f45a3c8SSimon J. Gerraty.Ql false .
7539f45a3c8SSimon J. GerratyThe rest of the line
7544fde40d9SSimon J. Gerraty(which already has had global variables expanded)
7559f45a3c8SSimon J. Gerratyis the variable value.
7569f45a3c8SSimon J. GerratyFor example:
7579f45a3c8SSimon J. Gerraty.Bd -literal -offset indent
7581d3f2ddcSSimon J. GerratyCOMPILER_WRAPPERS= ccache distcc icecc
7599f45a3c8SSimon J. Gerraty
7609f45a3c8SSimon J. Gerraty${OBJS}: .MAKE.META.CMP_FILTER=${COMPILER_WRAPPERS:S,^,N,}
7619f45a3c8SSimon J. Gerraty.Ed
7629f45a3c8SSimon J. Gerraty.Pp
7639f45a3c8SSimon J. GerratyOnly the targets
7649f45a3c8SSimon J. Gerraty.Ql ${OBJS}
7654fde40d9SSimon J. Gerratyare impacted by that filter (in
7664fde40d9SSimon J. Gerraty.Dq meta
7674fde40d9SSimon J. Gerratymode) and
7684fde40d9SSimon J. Gerratysimply enabling/disabling any of the compiler wrappers does not render all
7699f45a3c8SSimon J. Gerratyof those targets out-of-date.
7709f45a3c8SSimon J. Gerraty.Pp
7719f45a3c8SSimon J. Gerraty.Em NOTE :
7721d3f2ddcSSimon J. Gerratytarget-local variable assignments behave differently in that;
7739f45a3c8SSimon J. Gerraty.Bl -tag -width Ds -offset indent
7749f45a3c8SSimon J. Gerraty.It Ic \&+=
7759f45a3c8SSimon J. GerratyOnly appends to a previous local assignment
7769f45a3c8SSimon J. Gerratyfor the same target and variable.
7779f45a3c8SSimon J. Gerraty.It Ic \&:=
7781d3f2ddcSSimon J. GerratyIs redundant with respect to global variables,
7799f45a3c8SSimon J. Gerratywhich have already been expanded.
7809f45a3c8SSimon J. Gerraty.El
7819f45a3c8SSimon J. Gerraty.Pp
7824fde40d9SSimon J. GerratyThe seven built-in local variables are:
7834fde40d9SSimon J. Gerraty.Bl -tag -width ".Va .ARCHIVE" -offset indent
7843955d011SMarcel Moolenaar.It Va .ALLSRC
7853955d011SMarcel MoolenaarThe list of all sources for this target; also known as
786954401e6SSimon J. Gerraty.Sq Va \&> .
7873955d011SMarcel Moolenaar.It Va .ARCHIVE
788db29cad8SSimon J. GerratyThe name of the archive file; also known as
789954401e6SSimon J. Gerraty.Sq Va \&! .
7903955d011SMarcel Moolenaar.It Va .IMPSRC
7913955d011SMarcel MoolenaarIn suffix-transformation rules, the name/path of the source from which the
7923955d011SMarcel Moolenaartarget is to be transformed (the
7933955d011SMarcel Moolenaar.Dq implied
7943955d011SMarcel Moolenaarsource); also known as
795954401e6SSimon J. Gerraty.Sq Va \&< .
7963955d011SMarcel MoolenaarIt is not defined in explicit rules.
7973955d011SMarcel Moolenaar.It Va .MEMBER
798db29cad8SSimon J. GerratyThe name of the archive member; also known as
799954401e6SSimon J. Gerraty.Sq Va % .
8003955d011SMarcel Moolenaar.It Va .OODATE
8013955d011SMarcel MoolenaarThe list of sources for this target that were deemed out-of-date; also
8023955d011SMarcel Moolenaarknown as
803954401e6SSimon J. Gerraty.Sq Va \&? .
8043955d011SMarcel Moolenaar.It Va .PREFIX
805c1d01b5fSSimon J. GerratyThe name of the target with suffix (if declared in
806c1d01b5fSSimon J. Gerraty.Ic .SUFFIXES )
807c1d01b5fSSimon J. Gerratyremoved; also known as
808954401e6SSimon J. Gerraty.Sq Va * .
8093955d011SMarcel Moolenaar.It Va .TARGET
8103955d011SMarcel MoolenaarThe name of the target; also known as
811954401e6SSimon J. Gerraty.Sq Va @ .
8123bebe729SSimon J. GerratyFor compatibility with other makes this is an alias for
8134fde40d9SSimon J. Gerraty.Va .ARCHIVE
8143bebe729SSimon J. Gerratyin archive member rules.
8153955d011SMarcel Moolenaar.El
8163955d011SMarcel Moolenaar.Pp
8173955d011SMarcel MoolenaarThe shorter forms
8184fde40d9SSimon J. Gerraty.Po
8194fde40d9SSimon J. Gerraty.Sq Va \&> ,
820954401e6SSimon J. Gerraty.Sq Va \&! ,
8214fde40d9SSimon J. Gerraty.Sq Va \&< ,
8224fde40d9SSimon J. Gerraty.Sq Va \&% ,
823954401e6SSimon J. Gerraty.Sq Va \&? ,
8244fde40d9SSimon J. Gerraty.Sq Va \&* ,
8253955d011SMarcel Moolenaarand
8264fde40d9SSimon J. Gerraty.Sq Va \&@
8274fde40d9SSimon J. Gerraty.Pc
8283955d011SMarcel Moolenaarare permitted for backward
829db29cad8SSimon J. Gerratycompatibility with historical makefiles and legacy POSIX make and are
830db29cad8SSimon J. Gerratynot recommended.
831db29cad8SSimon J. Gerraty.Pp
832db29cad8SSimon J. GerratyVariants of these variables with the punctuation followed immediately by
833db29cad8SSimon J. Gerraty.Ql D
834db29cad8SSimon J. Gerratyor
835db29cad8SSimon J. Gerraty.Ql F ,
836954401e6SSimon J. Gerratye.g.\&
8374fde40d9SSimon J. Gerraty.Ql $(@D) ,
838db29cad8SSimon J. Gerratyare legacy forms equivalent to using the
839db29cad8SSimon J. Gerraty.Ql :H
8403955d011SMarcel Moolenaarand
841db29cad8SSimon J. Gerraty.Ql :T
842db29cad8SSimon J. Gerratymodifiers.
843db29cad8SSimon J. GerratyThese forms are accepted for compatibility with
8443955d011SMarcel Moolenaar.At V
845db29cad8SSimon J. Gerratymakefiles and POSIX but are not recommended.
8463955d011SMarcel Moolenaar.Pp
8473955d011SMarcel MoolenaarFour of the local variables may be used in sources on dependency lines
8483955d011SMarcel Moolenaarbecause they expand to the proper value for each target on the line.
8493955d011SMarcel MoolenaarThese variables are
850954401e6SSimon J. Gerraty.Sq Va .TARGET ,
851954401e6SSimon J. Gerraty.Sq Va .PREFIX ,
852954401e6SSimon J. Gerraty.Sq Va .ARCHIVE ,
8533955d011SMarcel Moolenaarand
854954401e6SSimon J. Gerraty.Sq Va .MEMBER .
8553955d011SMarcel Moolenaar.Ss Additional built-in variables
8563955d011SMarcel MoolenaarIn addition,
8573955d011SMarcel Moolenaar.Nm
8583955d011SMarcel Moolenaarsets or knows about the following variables:
8594fde40d9SSimon J. Gerraty.Bl -tag
8604fde40d9SSimon J. Gerraty.\" NB: This list is sorted case-insensitive, ignoring punctuation.
8614fde40d9SSimon J. Gerraty.\" NB: To find all built-in variables in make's source code,
8624fde40d9SSimon J. Gerraty.\" NB: search for Var_*, Global_*, SetVarObjdir, GetBooleanExpr,
8634fde40d9SSimon J. Gerraty.\" NB: and the implementation of Var_SetWithFlags.
8644fde40d9SSimon J. Gerraty.\" NB: Last synced on 2023-01-01.
8653955d011SMarcel Moolenaar.It Va .ALLTARGETS
8664fde40d9SSimon J. GerratyThe list of all targets encountered in the makefiles.
8674fde40d9SSimon J. GerratyIf evaluated during makefile parsing,
8684fde40d9SSimon J. Gerratylists only those targets encountered thus far.
8693955d011SMarcel Moolenaar.It Va .CURDIR
8703955d011SMarcel MoolenaarA path to the directory where
8713955d011SMarcel Moolenaar.Nm
8723955d011SMarcel Moolenaarwas executed.
8733955d011SMarcel MoolenaarRefer to the description of
8744fde40d9SSimon J. Gerraty.Sq Va PWD
8753955d011SMarcel Moolenaarfor more details.
8764fde40d9SSimon J. Gerraty.It Va .ERROR_CMD
8774fde40d9SSimon J. GerratyIs used in error handling, see
8784fde40d9SSimon J. Gerraty.Va MAKE_PRINT_VAR_ON_ERROR .
8794fde40d9SSimon J. Gerraty.It Va .ERROR_CWD
8804fde40d9SSimon J. GerratyIs used in error handling, see
8814fde40d9SSimon J. Gerraty.Va MAKE_PRINT_VAR_ON_ERROR .
882c59c3bf3SSimon J. Gerraty.It Va .ERROR_EXIT
883c59c3bf3SSimon J. GerratyIs used in error handling, see
884c59c3bf3SSimon J. Gerraty.Va MAKE_PRINT_VAR_ON_ERROR .
8854fde40d9SSimon J. Gerraty.It Va .ERROR_META_FILE
8864fde40d9SSimon J. GerratyIs used in error handling in
8874fde40d9SSimon J. Gerraty.Dq meta
8884fde40d9SSimon J. Gerratymode, see
8894fde40d9SSimon J. Gerraty.Va MAKE_PRINT_VAR_ON_ERROR .
8904fde40d9SSimon J. Gerraty.It Va .ERROR_TARGET
8914fde40d9SSimon J. GerratyIs used in error handling, see
8924fde40d9SSimon J. Gerraty.Va MAKE_PRINT_VAR_ON_ERROR .
8935bcb7424SSimon J. Gerraty.It Va .INCLUDEDFROMDIR
8944fde40d9SSimon J. GerratyThe directory of the file this makefile was included from.
8955bcb7424SSimon J. Gerraty.It Va .INCLUDEDFROMFILE
8964fde40d9SSimon J. GerratyThe filename of the file this makefile was included from.
8974fde40d9SSimon J. Gerraty.\" .INCLUDES is intentionally undocumented, as it is obsolete.
8984fde40d9SSimon J. Gerraty.\" .LIBS is intentionally undocumented, as it is obsolete.
8994fde40d9SSimon J. Gerraty.It Va MACHINE
9004fde40d9SSimon J. GerratyThe machine hardware name, see
9014fde40d9SSimon J. Gerraty.Xr uname 1 .
9024fde40d9SSimon J. Gerraty.It Va MACHINE_ARCH
9034fde40d9SSimon J. GerratyThe machine processor architecture name, see
9044fde40d9SSimon J. Gerraty.Xr uname 1 .
9054fde40d9SSimon J. Gerraty.It Va MAKE
9063955d011SMarcel MoolenaarThe name that
9073955d011SMarcel Moolenaar.Nm
9083955d011SMarcel Moolenaarwas executed with
9093955d011SMarcel Moolenaar.Pq Va argv[0] .
9104fde40d9SSimon J. Gerraty.It Va .MAKE
9114fde40d9SSimon J. GerratyThe same as
9124fde40d9SSimon J. Gerraty.Va MAKE ,
9134fde40d9SSimon J. Gerratyfor compatibility.
9143955d011SMarcel MoolenaarThe preferred variable to use is the environment variable
9153955d011SMarcel Moolenaar.Ev MAKE
9164fde40d9SSimon J. Gerratybecause it is more compatible with other make variants
9173955d011SMarcel Moolenaarand cannot be confused with the special target with the same name.
9184fde40d9SSimon J. Gerraty.\" '.MAKE.cmd_filtered' is intentionally undocumented,
9194fde40d9SSimon J. Gerraty.\" as it is an internal implementation detail.
9203955d011SMarcel Moolenaar.It Va .MAKE.DEPENDFILE
9213955d011SMarcel MoolenaarNames the makefile (default
922954401e6SSimon J. Gerraty.Sq Pa .depend )
9233955d011SMarcel Moolenaarfrom which generated dependencies are read.
9244fde40d9SSimon J. Gerraty.It Va .MAKE.DIE_QUIETLY
9254fde40d9SSimon J. GerratyIf set to
9264fde40d9SSimon J. Gerraty.Ql true ,
9274fde40d9SSimon J. Gerratydo not print error information at the end.
9283955d011SMarcel Moolenaar.It Va .MAKE.EXPAND_VARIABLES
9293955d011SMarcel MoolenaarA boolean that controls the default behavior of the
9303955d011SMarcel Moolenaar.Fl V
9313955d011SMarcel Moolenaaroption.
9328695518cSSimon J. GerratyIf true, variable values printed with
9338695518cSSimon J. Gerraty.Fl V
9348695518cSSimon J. Gerratyare fully expanded; if false, the raw variable contents (which may
9358695518cSSimon J. Gerratyinclude additional unexpanded variable references) are shown.
9363955d011SMarcel Moolenaar.It Va .MAKE.EXPORTED
9373955d011SMarcel MoolenaarThe list of variables exported by
9383955d011SMarcel Moolenaar.Nm .
9394fde40d9SSimon J. Gerraty.It Va MAKEFILE
9404fde40d9SSimon J. GerratyThe top-level makefile that is currently read,
9414fde40d9SSimon J. Gerratyas given in the command line.
9424fde40d9SSimon J. Gerraty.It Va .MAKEFLAGS
9433955d011SMarcel MoolenaarThe environment variable
944954401e6SSimon J. Gerraty.Sq Ev MAKEFLAGS
9453955d011SMarcel Moolenaarmay contain anything that
9463955d011SMarcel Moolenaarmay be specified on
9473955d011SMarcel Moolenaar.Nm Ns 's
9483955d011SMarcel Moolenaarcommand line.
9493955d011SMarcel MoolenaarAnything specified on
9503955d011SMarcel Moolenaar.Nm Ns 's
9513955d011SMarcel Moolenaarcommand line is appended to the
9524fde40d9SSimon J. Gerraty.Va .MAKEFLAGS
9534fde40d9SSimon J. Gerratyvariable, which is then added to the environment for all programs that
9543955d011SMarcel Moolenaar.Nm
9553955d011SMarcel Moolenaarexecutes.
9564fde40d9SSimon J. Gerraty.It Va .MAKE.GID
9574fde40d9SSimon J. GerratyThe numeric group ID of the user running
9584fde40d9SSimon J. Gerraty.Nm .
9594fde40d9SSimon J. GerratyIt is read-only.
9604fde40d9SSimon J. Gerraty.It Va .MAKE.JOB.PREFIX
9614fde40d9SSimon J. GerratyIf
9624fde40d9SSimon J. Gerraty.Nm
9634fde40d9SSimon J. Gerratyis run with
9644fde40d9SSimon J. Gerraty.Fl j ,
9654fde40d9SSimon J. Gerratythe output for each target is prefixed with a token
9664fde40d9SSimon J. Gerraty.Dl --- Ar target Li ---
9674fde40d9SSimon J. Gerratythe first part of which can be controlled via
9684fde40d9SSimon J. Gerraty.Va .MAKE.JOB.PREFIX .
9694fde40d9SSimon J. GerratyIf
9704fde40d9SSimon J. Gerraty.Va .MAKE.JOB.PREFIX
9714fde40d9SSimon J. Gerratyis empty, no token is printed.
9724fde40d9SSimon J. GerratyFor example, setting
9734fde40d9SSimon J. Gerraty.Va .MAKE.JOB.PREFIX
9744fde40d9SSimon J. Gerratyto
9754fde40d9SSimon J. Gerraty.Ql ${.newline}---${.MAKE:T}[${.MAKE.PID}]
9764fde40d9SSimon J. Gerratywould produce tokens like
9774fde40d9SSimon J. Gerraty.Dl ---make[1234] Ar target Li ---
9784fde40d9SSimon J. Gerratymaking it easier to track the degree of parallelism being achieved.
9794fde40d9SSimon J. Gerraty.It Va .MAKE.JOBS
9804fde40d9SSimon J. GerratyThe argument to the
9814fde40d9SSimon J. Gerraty.Fl j
9824fde40d9SSimon J. Gerratyoption.
98398875883SSimon J. Gerraty.It Va .MAKE.JOBS.C
98498875883SSimon J. GerratyA read-only boolean that indicates whether the
98598875883SSimon J. Gerraty.Fl j
98698875883SSimon J. Gerratyoption supports use of
98798875883SSimon J. Gerraty.Ql C .
9883955d011SMarcel Moolenaar.It Va .MAKE.LEVEL
9893955d011SMarcel MoolenaarThe recursion depth of
9903955d011SMarcel Moolenaar.Nm .
9914fde40d9SSimon J. GerratyThe top-level instance of
9923955d011SMarcel Moolenaar.Nm
9934fde40d9SSimon J. Gerratyhas level 0, and each child make has its parent level plus 1.
9943955d011SMarcel MoolenaarThis allows tests like:
9953955d011SMarcel Moolenaar.Li .if ${.MAKE.LEVEL} == 0
9964fde40d9SSimon J. Gerratyto protect things which should only be evaluated in the top-level instance of
9974fde40d9SSimon J. Gerraty.Nm .
9984fde40d9SSimon J. Gerraty.It Va .MAKE.LEVEL.ENV
9994fde40d9SSimon J. GerratyThe name of the environment variable that stores the level of nested calls to
10003955d011SMarcel Moolenaar.Nm .
10013955d011SMarcel Moolenaar.It Va .MAKE.MAKEFILE_PREFERENCE
10023955d011SMarcel MoolenaarThe ordered list of makefile names
10033955d011SMarcel Moolenaar(default
1004954401e6SSimon J. Gerraty.Sq Pa makefile ,
1005954401e6SSimon J. Gerraty.Sq Pa Makefile )
10063955d011SMarcel Moolenaarthat
10073955d011SMarcel Moolenaar.Nm
10084fde40d9SSimon J. Gerratylooks for.
10093955d011SMarcel Moolenaar.It Va .MAKE.MAKEFILES
10103955d011SMarcel MoolenaarThe list of makefiles read by
10113955d011SMarcel Moolenaar.Nm ,
10123955d011SMarcel Moolenaarwhich is useful for tracking dependencies.
10133955d011SMarcel MoolenaarEach makefile is recorded only once, regardless of the number of times read.
10143955d011SMarcel Moolenaar.It Va .MAKE.META.BAILIWICK
10154fde40d9SSimon J. GerratyIn
10164fde40d9SSimon J. Gerraty.Dq meta
10174fde40d9SSimon J. Gerratymode, provides a list of prefixes which
10183955d011SMarcel Moolenaarmatch the directories controlled by
10193955d011SMarcel Moolenaar.Nm .
10203955d011SMarcel MoolenaarIf a file that was generated outside of
10213955d011SMarcel Moolenaar.Va .OBJDIR
10223955d011SMarcel Moolenaarbut within said bailiwick is missing,
10233955d011SMarcel Moolenaarthe current target is considered out-of-date.
10249f45a3c8SSimon J. Gerraty.It Va .MAKE.META.CMP_FILTER
10254fde40d9SSimon J. GerratyIn
10264fde40d9SSimon J. Gerraty.Dq meta
10274fde40d9SSimon J. Gerratymode, it can (very rarely!) be useful to filter command
10289f45a3c8SSimon J. Gerratylines before comparison.
10294fde40d9SSimon J. GerratyThis variable can be set to a set of modifiers that are applied to
10309f45a3c8SSimon J. Gerratyeach line of the old and new command that differ, if the filtered
10319f45a3c8SSimon J. Gerratycommands still differ, the target is considered out-of-date.
10323955d011SMarcel Moolenaar.It Va .MAKE.META.CREATED
10334fde40d9SSimon J. GerratyIn
10344fde40d9SSimon J. Gerraty.Dq meta
10354fde40d9SSimon J. Gerratymode, this variable contains a list of all the meta files
10363955d011SMarcel Moolenaarupdated.
10373955d011SMarcel MoolenaarIf not empty, it can be used to trigger processing of
10383955d011SMarcel Moolenaar.Va .MAKE.META.FILES .
10393955d011SMarcel Moolenaar.It Va .MAKE.META.FILES
10404fde40d9SSimon J. GerratyIn
10414fde40d9SSimon J. Gerraty.Dq meta
10424fde40d9SSimon J. Gerratymode, this variable contains a list of all the meta files
10433955d011SMarcel Moolenaarused (updated or not).
10443955d011SMarcel MoolenaarThis list can be used to process the meta files to extract dependency
10453955d011SMarcel Moolenaarinformation.
10464fde40d9SSimon J. Gerraty.It Va .MAKE.META.IGNORE_FILTER
10474fde40d9SSimon J. GerratyProvides a list of variable modifiers to apply to each pathname.
10484fde40d9SSimon J. GerratyIgnore if the expansion is an empty string.
104951ee2c1cSSimon J. Gerraty.It Va .MAKE.META.IGNORE_PATHS
105051ee2c1cSSimon J. GerratyProvides a list of path prefixes that should be ignored;
105151ee2c1cSSimon J. Gerratybecause the contents are expected to change over time.
105251ee2c1cSSimon J. GerratyThe default list includes:
1053954401e6SSimon J. Gerraty.Sq Pa /dev /etc /proc /tmp /var/run /var/tmp
1054e48f47ddSSimon J. Gerraty.It Va .MAKE.META.IGNORE_PATTERNS
1055e48f47ddSSimon J. GerratyProvides a list of patterns to match against pathnames.
1056e48f47ddSSimon J. GerratyIgnore any that match.
10573955d011SMarcel Moolenaar.It Va .MAKE.META.PREFIX
10584fde40d9SSimon J. GerratyDefines the message printed for each meta file updated in
10594fde40d9SSimon J. Gerraty.Dq meta verbose
10604fde40d9SSimon J. Gerratymode.
10613955d011SMarcel MoolenaarThe default value is:
10623955d011SMarcel Moolenaar.Dl Building ${.TARGET:H:tA}/${.TARGET:T}
10634fde40d9SSimon J. Gerraty.It Va .MAKE.MODE
10644fde40d9SSimon J. GerratyProcessed after reading all makefiles.
10654fde40d9SSimon J. GerratyAffects the mode that
10664fde40d9SSimon J. Gerraty.Nm
10674fde40d9SSimon J. Gerratyruns in.
10684fde40d9SSimon J. GerratyIt can contain these keywords:
10694fde40d9SSimon J. Gerraty.Bl -tag -width indent
10704fde40d9SSimon J. Gerraty.It Cm compat
10714fde40d9SSimon J. GerratyLike
10724fde40d9SSimon J. Gerraty.Fl B ,
10734fde40d9SSimon J. Gerratyputs
10744fde40d9SSimon J. Gerraty.Nm
10754fde40d9SSimon J. Gerratyinto
10764fde40d9SSimon J. Gerraty.Dq compat
10774fde40d9SSimon J. Gerratymode.
10784fde40d9SSimon J. Gerraty.It Cm meta
10794fde40d9SSimon J. GerratyPuts
10804fde40d9SSimon J. Gerraty.Nm
10814fde40d9SSimon J. Gerratyinto
10824fde40d9SSimon J. Gerraty.Dq meta
10834fde40d9SSimon J. Gerratymode, where meta files are created for each target
10844fde40d9SSimon J. Gerratyto capture the command run, the output generated, and if
10854fde40d9SSimon J. Gerraty.Xr filemon 4
10864fde40d9SSimon J. Gerratyis available, the system calls which are of interest to
10874fde40d9SSimon J. Gerraty.Nm .
10884fde40d9SSimon J. GerratyThe captured output can be useful when diagnosing errors.
10894fde40d9SSimon J. Gerraty.It Cm curdirOk= Ns Ar bf
10904fde40d9SSimon J. GerratyBy default,
10914fde40d9SSimon J. Gerraty.Nm
10924fde40d9SSimon J. Gerratydoes not create
10934fde40d9SSimon J. Gerraty.Pa .meta
10944fde40d9SSimon J. Gerratyfiles in
10954fde40d9SSimon J. Gerraty.Sq Va .CURDIR .
10964fde40d9SSimon J. GerratyThis can be overridden by setting
10974fde40d9SSimon J. Gerraty.Ar bf
10984fde40d9SSimon J. Gerratyto a value which represents true.
10994fde40d9SSimon J. Gerraty.It Cm missing-meta= Ns Ar bf
11004fde40d9SSimon J. GerratyIf
11014fde40d9SSimon J. Gerraty.Ar bf
11024fde40d9SSimon J. Gerratyis true, a missing
11034fde40d9SSimon J. Gerraty.Pa .meta
11044fde40d9SSimon J. Gerratyfile makes the target out-of-date.
11054fde40d9SSimon J. Gerraty.It Cm missing-filemon= Ns Ar bf
11064fde40d9SSimon J. GerratyIf
11074fde40d9SSimon J. Gerraty.Ar bf
11084fde40d9SSimon J. Gerratyis true, missing filemon data makes the target out-of-date.
11094fde40d9SSimon J. Gerraty.It Cm nofilemon
11104fde40d9SSimon J. GerratyDo not use
11114fde40d9SSimon J. Gerraty.Xr filemon 4 .
11124fde40d9SSimon J. Gerraty.It Cm env
11134fde40d9SSimon J. GerratyFor debugging, it can be useful to include the environment
11144fde40d9SSimon J. Gerratyin the
11154fde40d9SSimon J. Gerraty.Pa .meta
11164fde40d9SSimon J. Gerratyfile.
11174fde40d9SSimon J. Gerraty.It Cm verbose
11184fde40d9SSimon J. GerratyIf in
11194fde40d9SSimon J. Gerraty.Dq meta
11204fde40d9SSimon J. Gerratymode, print a clue about the target being built.
11214fde40d9SSimon J. GerratyThis is useful if the build is otherwise running silently.
11224fde40d9SSimon J. GerratyThe message printed is the expanded value of
11234fde40d9SSimon J. Gerraty.Va .MAKE.META.PREFIX .
11244fde40d9SSimon J. Gerraty.It Cm ignore-cmd
11254fde40d9SSimon J. GerratySome makefiles have commands which are simply not stable.
11264fde40d9SSimon J. GerratyThis keyword causes them to be ignored for
11274fde40d9SSimon J. Gerratydetermining whether a target is out of date in
11284fde40d9SSimon J. Gerraty.Dq meta
11294fde40d9SSimon J. Gerratymode.
11304fde40d9SSimon J. GerratySee also
11314fde40d9SSimon J. Gerraty.Ic .NOMETA_CMP .
11324fde40d9SSimon J. Gerraty.It Cm silent= Ns Ar bf
11334fde40d9SSimon J. GerratyIf
11344fde40d9SSimon J. Gerraty.Ar bf
11354fde40d9SSimon J. Gerratyis true, when a .meta file is created, mark the target
11364fde40d9SSimon J. Gerraty.Ic .SILENT .
11374fde40d9SSimon J. Gerraty.It Cm randomize-targets
11384fde40d9SSimon J. GerratyIn both compat and parallel mode, do not make the targets in the usual order,
11394fde40d9SSimon J. Gerratybut instead randomize their order.
11404fde40d9SSimon J. GerratyThis mode can be used to detect undeclared dependencies between files.
11414fde40d9SSimon J. Gerraty.El
11424fde40d9SSimon J. Gerraty.It Va MAKEOBJDIR
11434fde40d9SSimon J. GerratyUsed to create files in a separate directory, see
11444fde40d9SSimon J. Gerraty.Va .OBJDIR .
11454fde40d9SSimon J. Gerraty.It Va MAKE_OBJDIR_CHECK_WRITABLE
11468d5c8e21SSimon J. GerratyWhen true,
11478d5c8e21SSimon J. Gerraty.Nm
11488d5c8e21SSimon J. Gerratywill check that
11498d5c8e21SSimon J. Gerraty.Va .OBJDIR
11508d5c8e21SSimon J. Gerratyis writable, and issue a warning if not.
11518d5c8e21SSimon J. Gerraty.It Va MAKE_DEBUG_OBJDIR_CHECK_WRITABLE
11528d5c8e21SSimon J. GerratyWhen true and
11538d5c8e21SSimon J. Gerraty.Nm
11548d5c8e21SSimon J. Gerratyis warning about an unwritable
11558d5c8e21SSimon J. Gerraty.Va .OBJDIR ,
11568d5c8e21SSimon J. Gerratyreport the variables listed in
11578d5c8e21SSimon J. Gerraty.Va MAKE_PRINT_VAR_ON_ERROR
11588d5c8e21SSimon J. Gerratyto help debug.
11594fde40d9SSimon J. Gerraty.It Va MAKEOBJDIRPREFIX
11604fde40d9SSimon J. GerratyUsed to create files in a separate directory, see
11614fde40d9SSimon J. Gerraty.Va .OBJDIR .
11624fde40d9SSimon J. Gerraty.It Va .MAKE.OS
11634fde40d9SSimon J. GerratyThe name of the operating system, see
11644fde40d9SSimon J. Gerraty.Xr uname 1 .
11654fde40d9SSimon J. GerratyIt is read-only.
11663955d011SMarcel Moolenaar.It Va .MAKEOVERRIDES
11673955d011SMarcel MoolenaarThis variable is used to record the names of variables assigned to
11683955d011SMarcel Moolenaaron the command line, so that they may be exported as part of
1169954401e6SSimon J. Gerraty.Sq Ev MAKEFLAGS .
1170be19d90bSSimon J. GerratyThis behavior can be disabled by assigning an empty value to
1171954401e6SSimon J. Gerraty.Sq Va .MAKEOVERRIDES
11723955d011SMarcel Moolenaarwithin a makefile.
11733955d011SMarcel MoolenaarExtra variables can be exported from a makefile
11743955d011SMarcel Moolenaarby appending their names to
1175954401e6SSimon J. Gerraty.Sq Va .MAKEOVERRIDES .
1176954401e6SSimon J. Gerraty.Sq Ev MAKEFLAGS
11773955d011SMarcel Moolenaaris re-exported whenever
1178954401e6SSimon J. Gerraty.Sq Va .MAKEOVERRIDES
11793955d011SMarcel Moolenaaris modified.
11801748de26SSimon J. Gerraty.It Va .MAKE.PATH_FILEMON
11811748de26SSimon J. GerratyIf
11821748de26SSimon J. Gerraty.Nm
11831748de26SSimon J. Gerratywas built with
11841748de26SSimon J. Gerraty.Xr filemon 4
11851748de26SSimon J. Gerratysupport, this is set to the path of the device node.
11861748de26SSimon J. GerratyThis allows makefiles to test for this support.
11873955d011SMarcel Moolenaar.It Va .MAKE.PID
11884fde40d9SSimon J. GerratyThe process ID of
11893955d011SMarcel Moolenaar.Nm .
11904fde40d9SSimon J. GerratyIt is read-only.
11913955d011SMarcel Moolenaar.It Va .MAKE.PPID
11924fde40d9SSimon J. GerratyThe parent process ID of
11933955d011SMarcel Moolenaar.Nm .
11944fde40d9SSimon J. GerratyIt is read-only.
11954fde40d9SSimon J. Gerraty.It Va MAKE_PRINT_VAR_ON_ERROR
11964fde40d9SSimon J. GerratyWhen
11974fde40d9SSimon J. Gerraty.Nm
11984fde40d9SSimon J. Gerratystops due to an error, it sets
11994fde40d9SSimon J. Gerraty.Sq Va .ERROR_TARGET
12004fde40d9SSimon J. Gerratyto the name of the target that failed,
1201c59c3bf3SSimon J. Gerraty.Sq Va .ERROR_EXIT
1202c59c3bf3SSimon J. Gerratyto the exit status of the failed target,
12034fde40d9SSimon J. Gerraty.Sq Va .ERROR_CMD
12044fde40d9SSimon J. Gerratyto the commands of the failed target,
12054fde40d9SSimon J. Gerratyand in
12064fde40d9SSimon J. Gerraty.Dq meta
12074fde40d9SSimon J. Gerratymode, it also sets
12084fde40d9SSimon J. Gerraty.Sq Va .ERROR_CWD
12094fde40d9SSimon J. Gerratyto the
12104fde40d9SSimon J. Gerraty.Xr getcwd 3 ,
12114fde40d9SSimon J. Gerratyand
12124fde40d9SSimon J. Gerraty.Sq Va .ERROR_META_FILE
12134fde40d9SSimon J. Gerratyto the path of the meta file (if any) describing the failed target.
12144fde40d9SSimon J. GerratyIt then prints its name and the value of
12154fde40d9SSimon J. Gerraty.Sq Va .CURDIR
12164fde40d9SSimon J. Gerratyas well as the value of any variables named in
12174fde40d9SSimon J. Gerraty.Sq Va MAKE_PRINT_VAR_ON_ERROR .
1218be19d90bSSimon J. Gerraty.It Va .MAKE.SAVE_DOLLARS
12194fde40d9SSimon J. GerratyIf true,
1220be19d90bSSimon J. Gerraty.Ql $$
1221be19d90bSSimon J. Gerratyare preserved when doing
1222be19d90bSSimon J. Gerraty.Ql :=
1223be19d90bSSimon J. Gerratyassignments.
1224be19d90bSSimon J. GerratyThe default is false, for backwards compatibility.
1225be19d90bSSimon J. GerratySet to true for compatability with other makes.
1226be19d90bSSimon J. GerratyIf set to false,
1227be19d90bSSimon J. Gerraty.Ql $$
1228be19d90bSSimon J. Gerratybecomes
1229be19d90bSSimon J. Gerraty.Ql $
1230be19d90bSSimon J. Gerratyper normal evaluation rules.
12314fde40d9SSimon J. Gerraty.It Va .MAKE.TARGET_LOCAL_VARIABLES
12324fde40d9SSimon J. GerratyIf set to
12334fde40d9SSimon J. Gerraty.Ql false ,
12344fde40d9SSimon J. Gerratyapparent variable assignments in dependency lines are
12354fde40d9SSimon J. Gerratytreated as normal sources.
123606b9b3e0SSimon J. Gerraty.It Va .MAKE.UID
12374fde40d9SSimon J. GerratyThe numeric ID of the user running
123806b9b3e0SSimon J. Gerraty.Nm .
12394fde40d9SSimon J. GerratyIt is read-only.
12404fde40d9SSimon J. Gerraty.\" 'MAKE_VERSION' is intentionally undocumented
12414fde40d9SSimon J. Gerraty.\" since it is only defined in the bmake distribution,
12424fde40d9SSimon J. Gerraty.\" but not in NetBSD's native make.
12434fde40d9SSimon J. Gerraty.\" '.meta.%d.lcwd' is intentionally undocumented
12444fde40d9SSimon J. Gerraty.\" since it is an internal implementation detail.
12454fde40d9SSimon J. Gerraty.\" '.meta.%d.ldir' is intentionally undocumented
12464fde40d9SSimon J. Gerraty.\" since it is an internal implementation detail.
12474fde40d9SSimon J. Gerraty.\" 'MFLAGS' is intentionally undocumented
12484fde40d9SSimon J. Gerraty.\" since it is obsolete.
12493955d011SMarcel Moolenaar.It Va .newline
12503955d011SMarcel MoolenaarThis variable is simply assigned a newline character as its value.
12514fde40d9SSimon J. GerratyIt is read-only.
12523955d011SMarcel MoolenaarThis allows expansions using the
12533955d011SMarcel Moolenaar.Cm \&:@
12543955d011SMarcel Moolenaarmodifier to put a newline between
12553955d011SMarcel Moolenaariterations of the loop rather than a space.
12564fde40d9SSimon J. GerratyFor example, in case of an error,
12574fde40d9SSimon J. Gerraty.Nm
12584fde40d9SSimon J. Gerratyprints the variable names and their values using:
12594fde40d9SSimon J. Gerraty.Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
12603955d011SMarcel Moolenaar.It Va .OBJDIR
12613955d011SMarcel MoolenaarA path to the directory where the targets are built.
12623955d011SMarcel MoolenaarIts value is determined by trying to
12633955d011SMarcel Moolenaar.Xr chdir 2
12643955d011SMarcel Moolenaarto the following directories in order and using the first match:
12653955d011SMarcel Moolenaar.Bl -enum
12663955d011SMarcel Moolenaar.It
12674fde40d9SSimon J. Gerraty.Cm ${MAKEOBJDIRPREFIX} Ns Cm ${.CURDIR}
12683955d011SMarcel Moolenaar.Pp
12693955d011SMarcel Moolenaar(Only if
1270954401e6SSimon J. Gerraty.Sq Ev MAKEOBJDIRPREFIX
12713955d011SMarcel Moolenaaris set in the environment or on the command line.)
12723955d011SMarcel Moolenaar.It
12734fde40d9SSimon J. Gerraty.Cm ${MAKEOBJDIR}
12743955d011SMarcel Moolenaar.Pp
12753955d011SMarcel Moolenaar(Only if
1276954401e6SSimon J. Gerraty.Sq Ev MAKEOBJDIR
12773955d011SMarcel Moolenaaris set in the environment or on the command line.)
12783955d011SMarcel Moolenaar.It
12794fde40d9SSimon J. Gerraty.Cm ${.CURDIR} Ns Pa /obj. Ns Cm ${MACHINE}
12803955d011SMarcel Moolenaar.It
12814fde40d9SSimon J. Gerraty.Cm ${.CURDIR} Ns Pa /obj
12823955d011SMarcel Moolenaar.It
12834fde40d9SSimon J. Gerraty.Pa /usr/obj/ Ns Cm ${.CURDIR}
12843955d011SMarcel Moolenaar.It
12854fde40d9SSimon J. Gerraty.Cm ${.CURDIR}
12863955d011SMarcel Moolenaar.El
12873955d011SMarcel Moolenaar.Pp
12884fde40d9SSimon J. GerratyVariable expansion is performed on the value before it is used,
12893955d011SMarcel Moolenaarso expressions such as
12904fde40d9SSimon J. Gerraty.Cm ${.CURDIR:S,^/usr/src,/var/obj,}
12913955d011SMarcel Moolenaarmay be used.
12923955d011SMarcel MoolenaarThis is especially useful with
1293954401e6SSimon J. Gerraty.Sq Ev MAKEOBJDIR .
12943955d011SMarcel Moolenaar.Pp
1295954401e6SSimon J. Gerraty.Sq Va .OBJDIR
1296128a4105SSimon J. Gerratymay be modified in the makefile via the special target
1297954401e6SSimon J. Gerraty.Sq Ic .OBJDIR .
12983955d011SMarcel MoolenaarIn all cases,
12993955d011SMarcel Moolenaar.Nm
13004fde40d9SSimon J. Gerratychanges to the specified directory if it exists, and sets
1301954401e6SSimon J. Gerraty.Sq Va .OBJDIR
1302128a4105SSimon J. Gerratyand
13034fde40d9SSimon J. Gerraty.Sq Va PWD
13043955d011SMarcel Moolenaarto that directory before executing any targets.
1305e2eeea75SSimon J. Gerraty.Pp
1306e2eeea75SSimon J. GerratyExcept in the case of an explicit
1307954401e6SSimon J. Gerraty.Sq Ic .OBJDIR
1308e2eeea75SSimon J. Gerratytarget,
1309e2eeea75SSimon J. Gerraty.Nm
13104fde40d9SSimon J. Gerratychecks that the specified directory is writable and ignores it if not.
1311e2eeea75SSimon J. GerratyThis check can be skipped by setting the environment variable
1312954401e6SSimon J. Gerraty.Sq Ev MAKE_OBJDIR_CHECK_WRITABLE
13134fde40d9SSimon J. Gerratyto
13144fde40d9SSimon J. Gerraty.Dq no .
13153955d011SMarcel Moolenaar.It Va .PARSEDIR
13164fde40d9SSimon J. GerratyThe directory name of the current makefile being parsed.
13173955d011SMarcel Moolenaar.It Va .PARSEFILE
13184fde40d9SSimon J. GerratyThe basename of the current makefile being parsed.
13193955d011SMarcel MoolenaarThis variable and
1320954401e6SSimon J. Gerraty.Sq Va .PARSEDIR
13214fde40d9SSimon J. Gerratyare both set only while the makefiles are being parsed.
13224fde40d9SSimon J. GerratyTo retain their current values,
13234fde40d9SSimon J. Gerratyassign them to a variable using assignment with expansion
1324954401e6SSimon J. Gerraty.Sq Cm \&:= .
13253955d011SMarcel Moolenaar.It Va .PATH
13264fde40d9SSimon J. GerratyThe space-separated list of directories that
13273955d011SMarcel Moolenaar.Nm
13284fde40d9SSimon J. Gerratysearches for files.
13294fde40d9SSimon J. GerratyTo update this search list, use the special target
13304fde40d9SSimon J. Gerraty.Sq Ic .PATH
13314fde40d9SSimon J. Gerratyrather than modifying the variable directly.
13324fde40d9SSimon J. Gerraty.It Va %POSIX
13334fde40d9SSimon J. GerratyIs set in POSIX mode, see the special
13344fde40d9SSimon J. Gerraty.Ql Va .POSIX
13354fde40d9SSimon J. Gerratytarget.
13364fde40d9SSimon J. Gerraty.\" XXX: There is no make variable named 'PWD',
13374fde40d9SSimon J. Gerraty.\" XXX: make only reads and writes the environment variable 'PWD'.
13384fde40d9SSimon J. Gerraty.It Va PWD
13393955d011SMarcel MoolenaarAlternate path to the current directory.
13403955d011SMarcel Moolenaar.Nm
13413955d011SMarcel Moolenaarnormally sets
1342954401e6SSimon J. Gerraty.Sq Va .CURDIR
13433955d011SMarcel Moolenaarto the canonical path given by
13443955d011SMarcel Moolenaar.Xr getcwd 3 .
13453955d011SMarcel MoolenaarHowever, if the environment variable
1346954401e6SSimon J. Gerraty.Sq Ev PWD
13474fde40d9SSimon J. Gerratyis set and gives a path to the current directory,
13483955d011SMarcel Moolenaar.Nm
13493955d011SMarcel Moolenaarsets
1350954401e6SSimon J. Gerraty.Sq Va .CURDIR
13513955d011SMarcel Moolenaarto the value of
1352954401e6SSimon J. Gerraty.Sq Ev PWD
13533955d011SMarcel Moolenaarinstead.
1354be19d90bSSimon J. GerratyThis behavior is disabled if
1355954401e6SSimon J. Gerraty.Sq Ev MAKEOBJDIRPREFIX
13563955d011SMarcel Moolenaaris set or
1357954401e6SSimon J. Gerraty.Sq Ev MAKEOBJDIR
13583955d011SMarcel Moolenaarcontains a variable transform.
13594fde40d9SSimon J. Gerraty.Sq Va PWD
13603955d011SMarcel Moolenaaris set to the value of
1361954401e6SSimon J. Gerraty.Sq Va .OBJDIR
13623955d011SMarcel Moolenaarfor all programs which
13633955d011SMarcel Moolenaar.Nm
13643955d011SMarcel Moolenaarexecutes.
13654fde40d9SSimon J. Gerraty.It Va .SHELL
13662c3632d1SSimon J. GerratyThe pathname of the shell used to run target scripts.
13672c3632d1SSimon J. GerratyIt is read-only.
13684fde40d9SSimon J. Gerraty.It Va .SUFFIXES
136912904384SSimon J. GerratyThe list of known suffixes.
137012904384SSimon J. GerratyIt is read-only.
13714fde40d9SSimon J. Gerraty.It Va .SYSPATH
13724fde40d9SSimon J. GerratyThe space-separated list of directories that
13733955d011SMarcel Moolenaar.Nm
13744fde40d9SSimon J. Gerratysearches for makefiles, referred to as the system include path.
13754fde40d9SSimon J. GerratyTo update this search list, use the special target
13764fde40d9SSimon J. Gerraty.Sq Ic .SYSPATH
13774fde40d9SSimon J. Gerratyrather than modifying the variable which is read-only.
13784fde40d9SSimon J. Gerraty.It Va .TARGETS
13794fde40d9SSimon J. GerratyThe list of targets explicitly specified on the command line, if any.
13804fde40d9SSimon J. Gerraty.It Va VPATH
13814fde40d9SSimon J. GerratyThe colon-separated
13824fde40d9SSimon J. Gerraty.Pq Dq \&:
13834fde40d9SSimon J. Gerratylist of directories that
13844fde40d9SSimon J. Gerraty.Nm
13854fde40d9SSimon J. Gerratysearches for files.
13864fde40d9SSimon J. GerratyThis variable is supported for compatibility with old make programs only, use
1387954401e6SSimon J. Gerraty.Sq Va .PATH
13883955d011SMarcel Moolenaarinstead.
13893955d011SMarcel Moolenaar.El
13903955d011SMarcel Moolenaar.Ss Variable modifiers
13914fde40d9SSimon J. GerratyThe general format of a variable expansion is:
13923955d011SMarcel Moolenaar.Pp
13934fde40d9SSimon J. Gerraty.Sm off
13944fde40d9SSimon J. Gerraty.D1 Ic \&${ Ar variable\| Oo Ic \&: Ar modifier\| Oo Ic \&: No ... Oc Oc Ic \&}
13954fde40d9SSimon J. Gerraty.Sm on
13963955d011SMarcel Moolenaar.Pp
13974fde40d9SSimon J. GerratyEach modifier begins with a colon.
13984fde40d9SSimon J. GerratyTo escape a colon, precede it with a backslash
13994fde40d9SSimon J. Gerraty.Ql \e .
14003955d011SMarcel Moolenaar.Pp
14014fde40d9SSimon J. GerratyA list of indirect modifiers can be specified via a variable, as follows:
14023955d011SMarcel Moolenaar.Pp
14034fde40d9SSimon J. Gerraty.Bd -literal -offset indent
14044fde40d9SSimon J. Gerraty.Ar modifier_variable\^ Li \&= Ar modifier Ns Oo Ic \&: Ns No ... Oc
14054fde40d9SSimon J. Gerraty
14064fde40d9SSimon J. Gerraty.Sm off
14074fde40d9SSimon J. Gerraty.Ic \&${ Ar variable Ic \&:${ Ar modifier_variable Ic \&} Oo Ic \&: No ... Oc Ic \&}
14084fde40d9SSimon J. Gerraty.Sm on
14094fde40d9SSimon J. Gerraty.Ed
14103955d011SMarcel Moolenaar.Pp
14114fde40d9SSimon J. GerratyIn this case, the first modifier in the
14124fde40d9SSimon J. Gerraty.Ar modifier_variable
14134fde40d9SSimon J. Gerratydoes not start with a colon,
14144fde40d9SSimon J. Gerratysince that colon already occurs in the referencing variable.
14154fde40d9SSimon J. GerratyIf any of the modifiers in the
14164fde40d9SSimon J. Gerraty.Ar modifier_variable
14174fde40d9SSimon J. Gerratycontains a dollar sign
14183955d011SMarcel Moolenaar.Pq Ql $ ,
14193955d011SMarcel Moolenaarthese must be doubled to avoid early expansion.
14203955d011SMarcel Moolenaar.Pp
14214fde40d9SSimon J. GerratySome modifiers interpret the expression value as a single string,
14224fde40d9SSimon J. Gerratyothers treat the expression value as a whitespace-separated list of words.
14234fde40d9SSimon J. GerratyWhen splitting a string into words,
14244fde40d9SSimon J. Gerratywhitespace can be escaped using double quotes, single quotes and backslashes,
14254fde40d9SSimon J. Gerratylike in the shell.
14264fde40d9SSimon J. GerratyThe quotes and backslashes are retained in the words.
14274fde40d9SSimon J. Gerraty.Pp
14283955d011SMarcel MoolenaarThe supported modifiers are:
14293955d011SMarcel Moolenaar.Bl -tag -width EEE
14303955d011SMarcel Moolenaar.It Cm \&:E
14314fde40d9SSimon J. GerratyReplaces each word with its suffix.
14323955d011SMarcel Moolenaar.It Cm \&:H
14334fde40d9SSimon J. GerratyReplaces each word with its dirname.
1434954401e6SSimon J. Gerraty.It Cm \&:M\| Ns Ar pattern
14352c3632d1SSimon J. GerratySelects only those words that match
14363955d011SMarcel Moolenaar.Ar pattern .
14373955d011SMarcel MoolenaarThe standard shell wildcard characters
14383955d011SMarcel Moolenaar.Pf ( Ql * ,
14393955d011SMarcel Moolenaar.Ql \&? ,
14403955d011SMarcel Moolenaarand
1441954401e6SSimon J. Gerraty.Ql \&[] )
14423955d011SMarcel Moolenaarmay
14433955d011SMarcel Moolenaarbe used.
14443955d011SMarcel MoolenaarThe wildcard characters may be escaped with a backslash
14453955d011SMarcel Moolenaar.Pq Ql \e .
14460dede8b0SSimon J. GerratyAs a consequence of the way values are split into words, matched,
14474fde40d9SSimon J. Gerratyand then joined, the construct
14484fde40d9SSimon J. Gerraty.Ql ${VAR:M*}
14494fde40d9SSimon J. Gerratyremoves all leading and trailing whitespace
14504fde40d9SSimon J. Gerratyand normalizes the inter-word spacing to a single space.
1451954401e6SSimon J. Gerraty.It Cm \&:N\| Ns Ar pattern
14524fde40d9SSimon J. GerratyThis is the opposite of
1453954401e6SSimon J. Gerraty.Sq Cm \&:M ,
14544fde40d9SSimon J. Gerratyselecting all words which do
14554fde40d9SSimon J. Gerraty.Em not
14564fde40d9SSimon J. Gerratymatch
14573955d011SMarcel Moolenaar.Ar pattern .
14583955d011SMarcel Moolenaar.It Cm \&:O
14594fde40d9SSimon J. GerratyOrders the words lexicographically.
146012904384SSimon J. Gerraty.It Cm \&:On
14614fde40d9SSimon J. GerratyOrders the words numerically.
146212904384SSimon J. GerratyA number followed by one of
146312904384SSimon J. Gerraty.Ql k ,
146412904384SSimon J. Gerraty.Ql M
146512904384SSimon J. Gerratyor
146612904384SSimon J. Gerraty.Ql G
14674fde40d9SSimon J. Gerratyis multiplied by the appropriate factor, which is 1024 for
14684fde40d9SSimon J. Gerraty.Ql k ,
14694fde40d9SSimon J. Gerraty1048576 for
14704fde40d9SSimon J. Gerraty.Ql M ,
14714fde40d9SSimon J. Gerratyor 1073741824 for
14724fde40d9SSimon J. Gerraty.Ql G .
147312904384SSimon J. GerratyBoth upper- and lower-case letters are accepted.
1474ef0b2538SSimon J. Gerraty.It Cm \&:Or
14754fde40d9SSimon J. GerratyOrders the words in reverse lexicographical order.
147612904384SSimon J. Gerraty.It Cm \&:Orn
14774fde40d9SSimon J. GerratyOrders the words in reverse numerical order.
14783955d011SMarcel Moolenaar.It Cm \&:Ox
14794fde40d9SSimon J. GerratyShuffles the words.
14804fde40d9SSimon J. GerratyThe results are different each time you are referring to the
14813955d011SMarcel Moolenaarmodified variable; use the assignment with expansion
1482954401e6SSimon J. Gerraty.Sq Cm \&:=
1483be19d90bSSimon J. Gerratyto prevent such behavior.
14843955d011SMarcel MoolenaarFor example,
14853955d011SMarcel Moolenaar.Bd -literal -offset indent
14863955d011SMarcel MoolenaarLIST=			uno due tre quattro
14873955d011SMarcel MoolenaarRANDOM_LIST=		${LIST:Ox}
14883955d011SMarcel MoolenaarSTATIC_RANDOM_LIST:=	${LIST:Ox}
14893955d011SMarcel Moolenaar
14903955d011SMarcel Moolenaarall:
14913955d011SMarcel Moolenaar	@echo "${RANDOM_LIST}"
14923955d011SMarcel Moolenaar	@echo "${RANDOM_LIST}"
14933955d011SMarcel Moolenaar	@echo "${STATIC_RANDOM_LIST}"
14943955d011SMarcel Moolenaar	@echo "${STATIC_RANDOM_LIST}"
14953955d011SMarcel Moolenaar.Ed
14963955d011SMarcel Moolenaarmay produce output similar to:
14973955d011SMarcel Moolenaar.Bd -literal -offset indent
14983955d011SMarcel Moolenaarquattro due tre uno
14993955d011SMarcel Moolenaartre due quattro uno
15003955d011SMarcel Moolenaardue uno quattro tre
15013955d011SMarcel Moolenaardue uno quattro tre
15023955d011SMarcel Moolenaar.Ed
15033955d011SMarcel Moolenaar.It Cm \&:Q
15044fde40d9SSimon J. GerratyQuotes every shell meta-character in the value, so that it can be passed
15052eae894cSSimon J. Gerratysafely to the shell.
15062eae894cSSimon J. Gerraty.It Cm \&:q
15074fde40d9SSimon J. GerratyQuotes every shell meta-character in the value, and also doubles
15082eae894cSSimon J. Gerraty.Sq $
15092eae894cSSimon J. Gerratycharacters so that it can be passed
15103955d011SMarcel Moolenaarsafely through recursive invocations of
15113955d011SMarcel Moolenaar.Nm .
15124fde40d9SSimon J. GerratyThis is equivalent to
15134fde40d9SSimon J. Gerraty.Sq Cm \&:S/\e\&$/&&/g:Q .
15143955d011SMarcel Moolenaar.It Cm \&:R
15154fde40d9SSimon J. GerratyReplaces each word with everything but its suffix.
15164fde40d9SSimon J. Gerraty.It Cm \&:range Ns Oo Cm = Ns Ar count Oc
15171ce939a7SSimon J. GerratyThe value is an integer sequence representing the words of the original
15181ce939a7SSimon J. Gerratyvalue, or the supplied
15194fde40d9SSimon J. Gerraty.Ar count .
15204fde40d9SSimon J. Gerraty.It Cm \&:gmtime Ns Oo Cm = Ns Ar timestamp Oc
15214fde40d9SSimon J. GerratyThe value is interpreted as a format string for
15223955d011SMarcel Moolenaar.Xr strftime 3 ,
15231ce939a7SSimon J. Gerratyusing
15244fde40d9SSimon J. Gerraty.Xr gmtime 3 ,
15254fde40d9SSimon J. Gerratyproducing the formatted timestamp.
152698875883SSimon J. GerratyNote: the
152798875883SSimon J. Gerraty.Ql %s
152898875883SSimon J. Gerratyformat should only be used with
152998875883SSimon J. Gerraty.Sq Cm \&:localtime .
15301ce939a7SSimon J. GerratyIf a
15314fde40d9SSimon J. Gerraty.Ar timestamp
15321ce939a7SSimon J. Gerratyvalue is not provided or is 0, the current time is used.
15333955d011SMarcel Moolenaar.It Cm \&:hash
15344fde40d9SSimon J. GerratyComputes a 32-bit hash of the value and encodes it as 8 hex digits.
15354fde40d9SSimon J. Gerraty.It Cm \&:localtime Ns Oo Cm = Ns Ar timestamp Oc
15364fde40d9SSimon J. GerratyThe value is interpreted as a format string for
15373955d011SMarcel Moolenaar.Xr strftime 3 ,
15381ce939a7SSimon J. Gerratyusing
15394fde40d9SSimon J. Gerraty.Xr localtime 3 ,
15404fde40d9SSimon J. Gerratyproducing the formatted timestamp.
15411ce939a7SSimon J. GerratyIf a
15424fde40d9SSimon J. Gerraty.Ar timestamp
15431ce939a7SSimon J. Gerratyvalue is not provided or is 0, the current time is used.
1544c1d01b5fSSimon J. Gerraty.It Cm \&:mtime Ns Oo Cm = Ns Ar timestamp Oc
1545c1d01b5fSSimon J. GerratyCall
1546c1d01b5fSSimon J. Gerraty.Xr stat 2
1547c1d01b5fSSimon J. Gerratywith each word as pathname;
1548c1d01b5fSSimon J. Gerratyuse
1549c1d01b5fSSimon J. Gerraty.Ql st_mtime
1550c1d01b5fSSimon J. Gerratyas the new value.
1551c1d01b5fSSimon J. GerratyIf
1552c1d01b5fSSimon J. Gerraty.Xr stat 2
1553c1d01b5fSSimon J. Gerratyfails; use
1554c1d01b5fSSimon J. Gerraty.Ar timestamp
1555c1d01b5fSSimon J. Gerratyor current time.
1556c1d01b5fSSimon J. GerratyIf
1557c1d01b5fSSimon J. Gerraty.Ar timestamp
1558c1d01b5fSSimon J. Gerratyis set to
1559c1d01b5fSSimon J. Gerraty.Ql error ,
1560c1d01b5fSSimon J. Gerratythen
1561c1d01b5fSSimon J. Gerraty.Xr stat 2
1562c1d01b5fSSimon J. Gerratyfailure will cause an error.
15633955d011SMarcel Moolenaar.It Cm \&:tA
15644fde40d9SSimon J. GerratyAttempts to convert the value to an absolute path using
15654fde40d9SSimon J. Gerraty.Xr realpath 3 .
15664fde40d9SSimon J. GerratyIf that fails, the value is unchanged.
15673955d011SMarcel Moolenaar.It Cm \&:tl
15684fde40d9SSimon J. GerratyConverts the value to lower-case letters.
15693955d011SMarcel Moolenaar.It Cm \&:ts Ns Ar c
15704fde40d9SSimon J. GerratyWhen joining the words after a modifier that treats the value as words,
15714fde40d9SSimon J. Gerratythe words are normally separated by a space.
15724fde40d9SSimon J. GerratyThis modifier changes the separator to the character
15733955d011SMarcel Moolenaar.Ar c .
15743955d011SMarcel MoolenaarIf
15753955d011SMarcel Moolenaar.Ar c
15764fde40d9SSimon J. Gerratyis omitted, no separator is used.
15772c3632d1SSimon J. GerratyThe common escapes (including octal numeric codes) work as expected.
1578*22619282SSimon J. Gerraty.It Cm \&:tt
1579*22619282SSimon J. GerratyConverts the first character of each word to upper-case,
1580*22619282SSimon J. Gerratyand the rest to lower-case letters.
15813955d011SMarcel Moolenaar.It Cm \&:tu
15824fde40d9SSimon J. GerratyConverts the value to upper-case letters.
15833955d011SMarcel Moolenaar.It Cm \&:tW
15844fde40d9SSimon J. GerratyCauses subsequent modifiers to treat the value as a single word
15853955d011SMarcel Moolenaar(possibly containing embedded whitespace).
15863955d011SMarcel MoolenaarSee also
1587954401e6SSimon J. Gerraty.Sq Cm \&:[*] .
15883955d011SMarcel Moolenaar.It Cm \&:tw
15894fde40d9SSimon J. GerratyCauses the value to be treated as a list of words.
15903955d011SMarcel MoolenaarSee also
1591954401e6SSimon J. Gerraty.Sq Cm \&:[@] .
15923955d011SMarcel Moolenaar.Sm off
1593954401e6SSimon J. Gerraty.It Cm \&:S\| No \&/ Ar old_string\| No \&/ Ar new_string\| No \&/ Op Cm 1gW
15943955d011SMarcel Moolenaar.Sm on
15952c3632d1SSimon J. GerratyModifies the first occurrence of
15963955d011SMarcel Moolenaar.Ar old_string
15974fde40d9SSimon J. Gerratyin each word of the value, replacing it with
15983955d011SMarcel Moolenaar.Ar new_string .
15993955d011SMarcel MoolenaarIf a
16003955d011SMarcel Moolenaar.Ql g
16014fde40d9SSimon J. Gerratyis appended to the last delimiter of the pattern,
16024fde40d9SSimon J. Gerratyall occurrences in each word are replaced.
16033955d011SMarcel MoolenaarIf a
16043955d011SMarcel Moolenaar.Ql 1
16054fde40d9SSimon J. Gerratyis appended to the last delimiter of the pattern,
16064fde40d9SSimon J. Gerratyonly the first occurrence is affected.
16073955d011SMarcel MoolenaarIf a
16083955d011SMarcel Moolenaar.Ql W
16092c3632d1SSimon J. Gerratyis appended to the last delimiter of the pattern,
16104fde40d9SSimon J. Gerratythe value is treated as a single word.
16113955d011SMarcel MoolenaarIf
16123955d011SMarcel Moolenaar.Ar old_string
16133955d011SMarcel Moolenaarbegins with a caret
16143955d011SMarcel Moolenaar.Pq Ql ^ ,
16153955d011SMarcel Moolenaar.Ar old_string
16163955d011SMarcel Moolenaaris anchored at the beginning of each word.
16173955d011SMarcel MoolenaarIf
16183955d011SMarcel Moolenaar.Ar old_string
16193955d011SMarcel Moolenaarends with a dollar sign
16203955d011SMarcel Moolenaar.Pq Ql \&$ ,
16213955d011SMarcel Moolenaarit is anchored at the end of each word.
16223955d011SMarcel MoolenaarInside
16233955d011SMarcel Moolenaar.Ar new_string ,
16243955d011SMarcel Moolenaaran ampersand
16258695518cSSimon J. Gerraty.Pq Ql &
16263955d011SMarcel Moolenaaris replaced by
16273955d011SMarcel Moolenaar.Ar old_string
16284fde40d9SSimon J. Gerraty(without the anchoring
16293955d011SMarcel Moolenaar.Ql ^
16303955d011SMarcel Moolenaaror
16313955d011SMarcel Moolenaar.Ql \&$ ) .
16324fde40d9SSimon J. GerratyAny character may be used as the delimiter for the parts of the modifier
16333955d011SMarcel Moolenaarstring.
16344fde40d9SSimon J. GerratyThe anchoring, ampersand and delimiter characters can be escaped with a
16353955d011SMarcel Moolenaarbackslash
16363955d011SMarcel Moolenaar.Pq Ql \e .
16373955d011SMarcel Moolenaar.Pp
16384fde40d9SSimon J. GerratyBoth
16393955d011SMarcel Moolenaar.Ar old_string
16403955d011SMarcel Moolenaarand
16413955d011SMarcel Moolenaar.Ar new_string
16424fde40d9SSimon J. Gerratymay contain nested expressions.
16434fde40d9SSimon J. GerratyTo prevent a dollar sign from starting a nested expression,
16444fde40d9SSimon J. Gerratyescape it with a backslash.
16453955d011SMarcel Moolenaar.Sm off
1646954401e6SSimon J. Gerraty.It Cm \&:C\| No \&/ Ar pattern\| No \&/ Ar replacement\| No \&/ Op Cm 1gW
16473955d011SMarcel Moolenaar.Sm on
16483955d011SMarcel MoolenaarThe
16493955d011SMarcel Moolenaar.Cm \&:C
16504fde40d9SSimon J. Gerratymodifier works like the
16513955d011SMarcel Moolenaar.Cm \&:S
16523955d011SMarcel Moolenaarmodifier except that the old and new strings, instead of being
16534fde40d9SSimon J. Gerratysimple strings, are an extended regular expression
16543955d011SMarcel Moolenaar.Ar pattern
16554fde40d9SSimon J. Gerraty(see
16564fde40d9SSimon J. Gerraty.Xr regex 3 )
16573955d011SMarcel Moolenaarand an
16583955d011SMarcel Moolenaar.Xr ed 1 Ns \-style
16593955d011SMarcel Moolenaar.Ar replacement .
16603955d011SMarcel MoolenaarNormally, the first occurrence of the pattern
16613955d011SMarcel Moolenaar.Ar pattern
16623955d011SMarcel Moolenaarin each word of the value is substituted with
16633955d011SMarcel Moolenaar.Ar replacement .
16643955d011SMarcel MoolenaarThe
16653955d011SMarcel Moolenaar.Ql 1
16663955d011SMarcel Moolenaarmodifier causes the substitution to apply to at most one word; the
16673955d011SMarcel Moolenaar.Ql g
16683955d011SMarcel Moolenaarmodifier causes the substitution to apply to as many instances of the
16693955d011SMarcel Moolenaarsearch pattern
16703955d011SMarcel Moolenaar.Ar pattern
16713955d011SMarcel Moolenaaras occur in the word or words it is found in; the
16723955d011SMarcel Moolenaar.Ql W
16733955d011SMarcel Moolenaarmodifier causes the value to be treated as a single word
16743955d011SMarcel Moolenaar(possibly containing embedded whitespace).
16755bcb7424SSimon J. Gerraty.Pp
16765bcb7424SSimon J. GerratyAs for the
16775bcb7424SSimon J. Gerraty.Cm \&:S
16785bcb7424SSimon J. Gerratymodifier, the
16795bcb7424SSimon J. Gerraty.Ar pattern
16805bcb7424SSimon J. Gerratyand
16815bcb7424SSimon J. Gerraty.Ar replacement
16825bcb7424SSimon J. Gerratyare subjected to variable expansion before being parsed as
16835bcb7424SSimon J. Gerratyregular expressions.
16843955d011SMarcel Moolenaar.It Cm \&:T
16854fde40d9SSimon J. GerratyReplaces each word with its last path component (basename).
16863955d011SMarcel Moolenaar.It Cm \&:u
16872c3632d1SSimon J. GerratyRemoves adjacent duplicate words (like
16883955d011SMarcel Moolenaar.Xr uniq 1 ) .
16893955d011SMarcel Moolenaar.Sm off
1690954401e6SSimon J. Gerraty.It Cm \&:\&?\| Ar true_string\| Cm \&: Ar false_string
16913955d011SMarcel Moolenaar.Sm on
16924fde40d9SSimon J. GerratyIf the variable name (not its value), when parsed as a
16934fde40d9SSimon J. Gerraty.Cm .if
16944fde40d9SSimon J. Gerratyconditional expression, evaluates to true, return as its value the
16953955d011SMarcel Moolenaar.Ar true_string ,
16963955d011SMarcel Moolenaarotherwise return the
16973955d011SMarcel Moolenaar.Ar false_string .
16984fde40d9SSimon J. GerratySince the variable name is used as the expression,
16994fde40d9SSimon J. Gerraty\&:\&? must be the first modifier after the variable name
17004fde40d9SSimon J. Gerraty.No itself Ns \^\(em\^ Ns
17014fde40d9SSimon J. Gerratywhich, of course, usually contains variable expansions.
17023955d011SMarcel MoolenaarA common error is trying to use expressions like
17033955d011SMarcel Moolenaar.Dl ${NUMBERS:M42:?match:no}
17044fde40d9SSimon J. Gerratywhich actually tests defined(NUMBERS).
17054fde40d9SSimon J. GerratyTo determine if any words match
17064fde40d9SSimon J. Gerraty.Dq 42 ,
17074fde40d9SSimon J. Gerratyyou need to use something like:
17083955d011SMarcel Moolenaar.Dl ${"${NUMBERS:M42}" != \&"\&":?match:no} .
1709954401e6SSimon J. Gerraty.It Cm :\| Ns Ar old_string\| Ns Cm = Ns Ar new_string
17103955d011SMarcel MoolenaarThis is the
17113955d011SMarcel Moolenaar.At V
17124fde40d9SSimon J. Gerratystyle substitution.
17134fde40d9SSimon J. GerratyIt can only be the last modifier specified,
17144fde40d9SSimon J. Gerratyas a
17154fde40d9SSimon J. Gerraty.Ql \&:
17164fde40d9SSimon J. Gerratyin either
17174fde40d9SSimon J. Gerraty.Ar old_string
17184fde40d9SSimon J. Gerratyor
17194fde40d9SSimon J. Gerraty.Ar new_string
17204fde40d9SSimon J. Gerratyis treated as a regular character, not as the end of the modifier.
17214fde40d9SSimon J. Gerraty.Pp
17223955d011SMarcel MoolenaarIf
17233955d011SMarcel Moolenaar.Ar old_string
17244fde40d9SSimon J. Gerratydoes not contain the pattern matching character
17254fde40d9SSimon J. Gerraty.Ql % ,
17264fde40d9SSimon J. Gerratyand the word ends with
17273955d011SMarcel Moolenaar.Ar old_string
17284fde40d9SSimon J. Gerratyor equals it,
17294fde40d9SSimon J. Gerratythat suffix is replaced with
17303955d011SMarcel Moolenaar.Ar new_string .
17313955d011SMarcel Moolenaar.Pp
17324fde40d9SSimon J. GerratyOtherwise, the first
17334fde40d9SSimon J. Gerraty.Ql %
17344fde40d9SSimon J. Gerratyin
17354fde40d9SSimon J. Gerraty.Ar old_string
17364fde40d9SSimon J. Gerratymatches a possibly empty substring of arbitrary characters,
17374fde40d9SSimon J. Gerratyand if the whole pattern is found in the word,
17384fde40d9SSimon J. Gerratythe matching part is replaced with
17394fde40d9SSimon J. Gerraty.Ar new_string ,
17404fde40d9SSimon J. Gerratyand the first occurrence of
17414fde40d9SSimon J. Gerraty.Ql %
17424fde40d9SSimon J. Gerratyin
17434fde40d9SSimon J. Gerraty.Ar new_string
17444fde40d9SSimon J. Gerraty(if any) is replaced with the substring matched by the
17454fde40d9SSimon J. Gerraty.Ql % .
17464fde40d9SSimon J. Gerraty.Pp
17474fde40d9SSimon J. GerratyBoth
17483955d011SMarcel Moolenaar.Ar old_string
17493955d011SMarcel Moolenaarand
17503955d011SMarcel Moolenaar.Ar new_string
17514fde40d9SSimon J. Gerratymay contain nested expressions.
17524fde40d9SSimon J. GerratyTo prevent a dollar sign from starting a nested expression,
17534fde40d9SSimon J. Gerratyescape it with a backslash.
17543955d011SMarcel Moolenaar.Sm off
17554fde40d9SSimon J. Gerraty.It Cm \&:@ Ar varname\| Cm @ Ar string\| Cm @
17563955d011SMarcel Moolenaar.Sm on
17573955d011SMarcel MoolenaarThis is the loop expansion mechanism from the OSF Development
17583955d011SMarcel MoolenaarEnvironment (ODE) make.
17593955d011SMarcel MoolenaarUnlike
17603955d011SMarcel Moolenaar.Cm \&.for
17612c3632d1SSimon J. Gerratyloops, expansion occurs at the time of reference.
17624fde40d9SSimon J. GerratyFor each word in the value, assign the word to the variable named
17634fde40d9SSimon J. Gerraty.Ar varname
17644fde40d9SSimon J. Gerratyand evaluate
17653955d011SMarcel Moolenaar.Ar string .
17663955d011SMarcel MoolenaarThe ODE convention is that
17674fde40d9SSimon J. Gerraty.Ar varname
17684fde40d9SSimon J. Gerratyshould start and end with a period, for example:
17693955d011SMarcel Moolenaar.Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
17703955d011SMarcel Moolenaar.Pp
17714fde40d9SSimon J. GerratyHowever, a single-letter variable is often more readable:
17723955d011SMarcel Moolenaar.Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
1773954401e6SSimon J. Gerraty.It Cm \&:_ Ns Oo Cm = Ns Ar var Oc
17742c3632d1SSimon J. GerratySaves the current variable value in
17751ce939a7SSimon J. Gerraty.Ql $_
17761ce939a7SSimon J. Gerratyor the named
17774fde40d9SSimon J. Gerraty.Ar var
17781ce939a7SSimon J. Gerratyfor later reference.
17791ce939a7SSimon J. GerratyExample usage:
17801ce939a7SSimon J. Gerraty.Bd -literal -offset indent
17811ce939a7SSimon J. GerratyM_cmpv.units = 1 1000 1000000
17821ce939a7SSimon J. GerratyM_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\
17831ce939a7SSimon J. Gerraty\\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
17841ce939a7SSimon J. Gerraty
17851ce939a7SSimon J. Gerraty.Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
17861ce939a7SSimon J. Gerraty
17871ce939a7SSimon J. Gerraty.Ed
17881ce939a7SSimon J. GerratyHere
17891ce939a7SSimon J. Gerraty.Ql $_
17901ce939a7SSimon J. Gerratyis used to save the result of the
17911ce939a7SSimon J. Gerraty.Ql :S
17921ce939a7SSimon J. Gerratymodifier which is later referenced using the index values from
17931ce939a7SSimon J. Gerraty.Ql :range .
1794954401e6SSimon J. Gerraty.It Cm \&:U\| Ns Ar newval
17952c3632d1SSimon J. GerratyIf the variable is undefined,
1796c59c3bf3SSimon J. Gerratythe optional
17973955d011SMarcel Moolenaar.Ar newval
1798c59c3bf3SSimon J. Gerraty(which may be empty) is the value.
17993955d011SMarcel MoolenaarIf the variable is defined, the existing value is returned.
18003955d011SMarcel MoolenaarThis is another ODE make feature.
18013955d011SMarcel MoolenaarIt is handy for setting per-target CFLAGS for instance:
18023955d011SMarcel Moolenaar.Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
18033955d011SMarcel MoolenaarIf a value is only required if the variable is undefined, use:
18043955d011SMarcel Moolenaar.Dl ${VAR:D:Unewval}
1805954401e6SSimon J. Gerraty.It Cm \&:D\| Ns Ar newval
18062c3632d1SSimon J. GerratyIf the variable is defined,
18073955d011SMarcel Moolenaar.Ar newval
1808c59c3bf3SSimon J. Gerraty(which may be empty) is the value.
18093955d011SMarcel Moolenaar.It Cm \&:L
18103955d011SMarcel MoolenaarThe name of the variable is the value.
18113955d011SMarcel Moolenaar.It Cm \&:P
18124fde40d9SSimon J. GerratyThe path of the node which has the same name as the variable is the value.
18134fde40d9SSimon J. GerratyIf no such node exists or its path is null, the name of the variable is used.
18143955d011SMarcel MoolenaarIn order for this modifier to work, the name (node) must at least have
18154fde40d9SSimon J. Gerratyappeared on the right-hand side of a dependency.
18163955d011SMarcel Moolenaar.Sm off
1817954401e6SSimon J. Gerraty.It Cm \&:\&! Ar cmd\| Cm \&!
18183955d011SMarcel Moolenaar.Sm on
18193955d011SMarcel MoolenaarThe output of running
18203955d011SMarcel Moolenaar.Ar cmd
18213955d011SMarcel Moolenaaris the value.
18223955d011SMarcel Moolenaar.It Cm \&:sh
18234fde40d9SSimon J. GerratyThe value is run as a command, and the output becomes the new value.
18243955d011SMarcel Moolenaar.It Cm \&::= Ns Ar str
18253955d011SMarcel MoolenaarThe variable is assigned the value
18263955d011SMarcel Moolenaar.Ar str
18273955d011SMarcel Moolenaarafter substitution.
18284fde40d9SSimon J. GerratyThis modifier and its variations are useful in obscure situations
18294fde40d9SSimon J. Gerratysuch as wanting to set a variable
18304fde40d9SSimon J. Gerratyat a point where a target's shell commands are being parsed.
18314fde40d9SSimon J. GerratyThese assignment modifiers always expand to nothing.
18323955d011SMarcel Moolenaar.Pp
18333955d011SMarcel MoolenaarThe
1834954401e6SSimon J. Gerraty.Sq Cm \&::
18353955d011SMarcel Moolenaarhelps avoid false matches with the
18363955d011SMarcel Moolenaar.At V
18373955d011SMarcel Moolenaarstyle
18384fde40d9SSimon J. Gerraty.Ql \&:=
18394fde40d9SSimon J. Gerratymodifier and since substitution always occurs, the
18404fde40d9SSimon J. Gerraty.Ql \&::=
18413955d011SMarcel Moolenaarform is vaguely appropriate.
18423955d011SMarcel Moolenaar.It Cm \&::?= Ns Ar str
18433955d011SMarcel MoolenaarAs for
18443955d011SMarcel Moolenaar.Cm \&::=
18453955d011SMarcel Moolenaarbut only if the variable does not already have a value.
18463955d011SMarcel Moolenaar.It Cm \&::+= Ns Ar str
18473955d011SMarcel MoolenaarAppend
18483955d011SMarcel Moolenaar.Ar str
18493955d011SMarcel Moolenaarto the variable.
18503955d011SMarcel Moolenaar.It Cm \&::!= Ns Ar cmd
18513955d011SMarcel MoolenaarAssign the output of
18523955d011SMarcel Moolenaar.Ar cmd
18533955d011SMarcel Moolenaarto the variable.
18543955d011SMarcel Moolenaar.It Cm \&:\&[ Ns Ar range Ns Cm \&]
18553955d011SMarcel MoolenaarSelects one or more words from the value,
18563955d011SMarcel Moolenaaror performs other operations related to the way in which the
18574fde40d9SSimon J. Gerratyvalue is split into words.
18583955d011SMarcel Moolenaar.Pp
18593955d011SMarcel MoolenaarAn empty value, or a value that consists entirely of white-space,
18603955d011SMarcel Moolenaaris treated as a single word.
18613955d011SMarcel MoolenaarFor the purposes of the
1862954401e6SSimon J. Gerraty.Sq Cm \&:[]
18633955d011SMarcel Moolenaarmodifier, the words are indexed both forwards using positive integers
18643955d011SMarcel Moolenaar(where index 1 represents the first word),
18653955d011SMarcel Moolenaarand backwards using negative integers
18663955d011SMarcel Moolenaar(where index \-1 represents the last word).
18673955d011SMarcel Moolenaar.Pp
18683955d011SMarcel MoolenaarThe
18693955d011SMarcel Moolenaar.Ar range
18703955d011SMarcel Moolenaaris subjected to variable expansion, and the expanded result is
18713955d011SMarcel Moolenaarthen interpreted as follows:
18723955d011SMarcel Moolenaar.Bl -tag -width index
18733955d011SMarcel Moolenaar.\" :[n]
18743955d011SMarcel Moolenaar.It Ar index
18753955d011SMarcel MoolenaarSelects a single word from the value.
18763955d011SMarcel Moolenaar.\" :[start..end]
18773955d011SMarcel Moolenaar.It Ar start Ns Cm \&.. Ns Ar end
18783955d011SMarcel MoolenaarSelects all words from
18793955d011SMarcel Moolenaar.Ar start
18803955d011SMarcel Moolenaarto
18813955d011SMarcel Moolenaar.Ar end ,
18823955d011SMarcel Moolenaarinclusive.
18833955d011SMarcel MoolenaarFor example,
1884954401e6SSimon J. Gerraty.Sq Cm \&:[2..-1]
18853955d011SMarcel Moolenaarselects all words from the second word to the last word.
18863955d011SMarcel MoolenaarIf
18873955d011SMarcel Moolenaar.Ar start
18883955d011SMarcel Moolenaaris greater than
18893955d011SMarcel Moolenaar.Ar end ,
18904fde40d9SSimon J. Gerratythe words are output in reverse order.
18913955d011SMarcel MoolenaarFor example,
1892954401e6SSimon J. Gerraty.Sq Cm \&:[-1..1]
18933955d011SMarcel Moolenaarselects all the words from last to first.
18944fde40d9SSimon J. GerratyIf the list is already ordered,
18954fde40d9SSimon J. Gerratythis effectively reverses the list,
18964fde40d9SSimon J. Gerratybut it is more efficient to use
1897954401e6SSimon J. Gerraty.Sq Cm \&:Or
1898ef0b2538SSimon J. Gerratyinstead of
1899954401e6SSimon J. Gerraty.Sq Cm \&:O:[-1..1] .
19003955d011SMarcel Moolenaar.\" :[*]
19013955d011SMarcel Moolenaar.It Cm \&*
19023955d011SMarcel MoolenaarCauses subsequent modifiers to treat the value as a single word
19033955d011SMarcel Moolenaar(possibly containing embedded whitespace).
19043955d011SMarcel MoolenaarAnalogous to the effect of
19054fde40d9SSimon J. Gerraty.Li \&$*
19063955d011SMarcel Moolenaarin Bourne shell.
19073955d011SMarcel Moolenaar.\" :[0]
19083955d011SMarcel Moolenaar.It 0
19093955d011SMarcel MoolenaarMeans the same as
1910954401e6SSimon J. Gerraty.Sq Cm \&:[*] .
19113955d011SMarcel Moolenaar.\" :[*]
19123955d011SMarcel Moolenaar.It Cm \&@
19133955d011SMarcel MoolenaarCauses subsequent modifiers to treat the value as a sequence of words
19143955d011SMarcel Moolenaardelimited by whitespace.
19153955d011SMarcel MoolenaarAnalogous to the effect of
19164fde40d9SSimon J. Gerraty.Li \&$@
19173955d011SMarcel Moolenaarin Bourne shell.
19183955d011SMarcel Moolenaar.\" :[#]
19193955d011SMarcel Moolenaar.It Cm \&#
19203955d011SMarcel MoolenaarReturns the number of words in the value.
19213955d011SMarcel Moolenaar.El \" :[range]
19223955d011SMarcel Moolenaar.El
19234fde40d9SSimon J. Gerraty.Sh DIRECTIVES
19244fde40d9SSimon J. Gerraty.Nm
19254fde40d9SSimon J. Gerratyoffers directives for including makefiles, conditionals and for loops.
19264fde40d9SSimon J. GerratyAll these directives are identified by a line beginning with a single dot
19273955d011SMarcel Moolenaar.Pq Ql \&.
19284fde40d9SSimon J. Gerratycharacter, followed by the keyword of the directive, such as
19294fde40d9SSimon J. Gerraty.Cm include
19304fde40d9SSimon J. Gerratyor
19314fde40d9SSimon J. Gerraty.Cm if .
19324fde40d9SSimon J. Gerraty.Ss File inclusion
19333955d011SMarcel MoolenaarFiles are included with either
1934ef0b2538SSimon J. Gerraty.Cm \&.include \&< Ns Ar file Ns Cm \&>
19353955d011SMarcel Moolenaaror
1936ef0b2538SSimon J. Gerraty.Cm \&.include \&\*q Ns Ar file Ns Cm \&\*q .
19373955d011SMarcel MoolenaarVariables between the angle brackets or double quotes are expanded
19383955d011SMarcel Moolenaarto form the file name.
19393955d011SMarcel MoolenaarIf angle brackets are used, the included makefile is expected to be in
19403955d011SMarcel Moolenaarthe system makefile directory.
19413955d011SMarcel MoolenaarIf double quotes are used, the including makefile's directory and any
19423955d011SMarcel Moolenaardirectories specified using the
19433955d011SMarcel Moolenaar.Fl I
19444fde40d9SSimon J. Gerratyoption are searched before the system makefile directory.
19454fde40d9SSimon J. Gerraty.Pp
19464fde40d9SSimon J. GerratyFor compatibility with other make variants,
19474fde40d9SSimon J. Gerraty.Sq Cm include Ar file No ...
19484fde40d9SSimon J. Gerraty(without leading dot)
19493955d011SMarcel Moolenaaris also accepted.
1950be19d90bSSimon J. Gerraty.Pp
19513955d011SMarcel MoolenaarIf the include statement is written as
19523955d011SMarcel Moolenaar.Cm .-include
19533955d011SMarcel Moolenaaror as
19544fde40d9SSimon J. Gerraty.Cm .sinclude ,
19554fde40d9SSimon J. Gerratyerrors locating and/or opening include files are ignored.
19563955d011SMarcel Moolenaar.Pp
1957be19d90bSSimon J. GerratyIf the include statement is written as
19584fde40d9SSimon J. Gerraty.Cm .dinclude ,
1959be19d90bSSimon J. Gerratynot only are errors locating and/or opening include files ignored,
19604fde40d9SSimon J. Gerratybut stale dependencies within the included file are ignored just like in
1961be19d90bSSimon J. Gerraty.Va .MAKE.DEPENDFILE .
19624fde40d9SSimon J. Gerraty.Ss Exporting variables
19634fde40d9SSimon J. GerratyThe directives for exporting and unexporting variables are:
19643955d011SMarcel Moolenaar.Bl -tag -width Ds
19654fde40d9SSimon J. Gerraty.It Ic .export Ar variable No ...
19663955d011SMarcel MoolenaarExport the specified global variable.
19678d5c8e21SSimon J. Gerraty.Pp
19684fde40d9SSimon J. GerratyFor compatibility with other make programs,
19694fde40d9SSimon J. Gerraty.Cm export Ar variable\| Ns Cm \&= Ns Ar value
19704fde40d9SSimon J. Gerraty(without leading dot) is also accepted.
19713955d011SMarcel Moolenaar.Pp
19723955d011SMarcel MoolenaarAppending a variable name to
19733955d011SMarcel Moolenaar.Va .MAKE.EXPORTED
19743955d011SMarcel Moolenaaris equivalent to exporting a variable.
19758d5c8e21SSimon J. Gerraty.It Ic .export-all
19768d5c8e21SSimon J. GerratyExport all globals except for internal variables (those that start with
19778d5c8e21SSimon J. Gerraty.Ql \&. ) .
19788d5c8e21SSimon J. GerratyThis is not affected by the
19798d5c8e21SSimon J. Gerraty.Fl X
19808d5c8e21SSimon J. Gerratyflag, so should be used with caution.
19814fde40d9SSimon J. Gerraty.It Ic .export-env Ar variable No ...
19823955d011SMarcel MoolenaarThe same as
19833955d011SMarcel Moolenaar.Ql .export ,
19843955d011SMarcel Moolenaarexcept that the variable is not appended to
19853955d011SMarcel Moolenaar.Va .MAKE.EXPORTED .
19863955d011SMarcel MoolenaarThis allows exporting a value to the environment which is different from that
19873955d011SMarcel Moolenaarused by
19883955d011SMarcel Moolenaar.Nm
19893955d011SMarcel Moolenaarinternally.
19904fde40d9SSimon J. Gerraty.It Ic .export-literal Ar variable No ...
1991be19d90bSSimon J. GerratyThe same as
1992be19d90bSSimon J. Gerraty.Ql .export-env ,
1993be19d90bSSimon J. Gerratyexcept that variables in the value are not expanded.
19944fde40d9SSimon J. Gerraty.It Ic .unexport Ar variable No ...
19953955d011SMarcel MoolenaarThe opposite of
19963955d011SMarcel Moolenaar.Ql .export .
19973955d011SMarcel MoolenaarThe specified global
19984fde40d9SSimon J. Gerraty.Ar variable
19994fde40d9SSimon J. Gerratyis removed from
20003955d011SMarcel Moolenaar.Va .MAKE.EXPORTED .
20013955d011SMarcel MoolenaarIf no variable list is provided, all globals are unexported,
20023955d011SMarcel Moolenaarand
20033955d011SMarcel Moolenaar.Va .MAKE.EXPORTED
20043955d011SMarcel Moolenaardeleted.
20053955d011SMarcel Moolenaar.It Ic .unexport-env
20063955d011SMarcel MoolenaarUnexport all globals previously exported and
20073955d011SMarcel Moolenaarclear the environment inherited from the parent.
20084fde40d9SSimon J. GerratyThis operation causes a memory leak of the original environment,
20093955d011SMarcel Moolenaarso should be used sparingly.
20103955d011SMarcel MoolenaarTesting for
20113955d011SMarcel Moolenaar.Va .MAKE.LEVEL
20124fde40d9SSimon J. Gerratybeing 0 would make sense.
20133955d011SMarcel MoolenaarAlso note that any variables which originated in the parent environment
20143955d011SMarcel Moolenaarshould be explicitly preserved if desired.
20153955d011SMarcel MoolenaarFor example:
20163955d011SMarcel Moolenaar.Bd -literal -offset indent
20173955d011SMarcel Moolenaar.Li .if ${.MAKE.LEVEL} == 0
20183955d011SMarcel MoolenaarPATH := ${PATH}
20193955d011SMarcel Moolenaar.Li .unexport-env
20203955d011SMarcel Moolenaar.Li .export PATH
20213955d011SMarcel Moolenaar.Li .endif
20223955d011SMarcel Moolenaar.Pp
20233955d011SMarcel Moolenaar.Ed
20243955d011SMarcel MoolenaarWould result in an environment containing only
2025954401e6SSimon J. Gerraty.Sq Ev PATH ,
20263955d011SMarcel Moolenaarwhich is the minimal useful environment.
20274fde40d9SSimon J. Gerraty.\" TODO: Check the below sentence, environment variables don't start with '.'.
20283955d011SMarcel MoolenaarActually
20294fde40d9SSimon J. Gerraty.Sq Va .MAKE.LEVEL
20304fde40d9SSimon J. Gerratyis also pushed into the new environment.
20314fde40d9SSimon J. Gerraty.El
20324fde40d9SSimon J. Gerraty.Ss Messages
20334fde40d9SSimon J. GerratyThe directives for printing messages to the output are:
20344fde40d9SSimon J. Gerraty.Bl -tag -width Ds
20354fde40d9SSimon J. Gerraty.It Ic .info Ar message
20364fde40d9SSimon J. GerratyThe message is printed along with the name of the makefile and line number.
20373955d011SMarcel Moolenaar.It Ic .warning Ar message
20383955d011SMarcel MoolenaarThe message prefixed by
20394fde40d9SSimon J. Gerraty.Sq Li warning:
20403955d011SMarcel Moolenaaris printed along with the name of the makefile and line number.
20414fde40d9SSimon J. Gerraty.It Ic .error Ar message
20424fde40d9SSimon J. GerratyThe message is printed along with the name of the makefile and line number,
20434fde40d9SSimon J. Gerraty.Nm
20444fde40d9SSimon J. Gerratyexits immediately.
20454fde40d9SSimon J. Gerraty.El
20464fde40d9SSimon J. Gerraty.Ss Conditionals
20474fde40d9SSimon J. GerratyThe directives for conditionals are:
20484fde40d9SSimon J. Gerraty.ds maybenot Oo Ic \&! Oc Ns
20494fde40d9SSimon J. Gerraty.Bl -tag
20504fde40d9SSimon J. Gerraty.It Ic .if \*[maybenot] Ar expression Op Ar operator expression No ...
20513955d011SMarcel MoolenaarTest the value of an expression.
20524fde40d9SSimon J. Gerraty.It Ic .ifdef \*[maybenot] Ar variable Op Ar operator variable No ...
20534fde40d9SSimon J. GerratyTest whether a variable is defined.
20544fde40d9SSimon J. Gerraty.It Ic .ifndef \*[maybenot] Ar variable Op Ar operator variable No ...
20554fde40d9SSimon J. GerratyTest whether a variable is not defined.
20564fde40d9SSimon J. Gerraty.It Ic .ifmake \*[maybenot] Ar target Op Ar operator target No ...
20574fde40d9SSimon J. GerratyTest the target being requested.
20584fde40d9SSimon J. Gerraty.It Ic .ifnmake \*[maybenot] Ar target Op Ar operator target No ...
20594fde40d9SSimon J. GerratyTest the target being requested.
20603955d011SMarcel Moolenaar.It Ic .else
20613955d011SMarcel MoolenaarReverse the sense of the last conditional.
20624fde40d9SSimon J. Gerraty.It Ic .elif \*[maybenot] Ar expression Op Ar operator expression No ...
20633955d011SMarcel MoolenaarA combination of
2064954401e6SSimon J. Gerraty.Sq Ic .else
20653955d011SMarcel Moolenaarfollowed by
2066954401e6SSimon J. Gerraty.Sq Ic .if .
20674fde40d9SSimon J. Gerraty.It Ic .elifdef \*[maybenot] Ar variable Op Ar operator variable No ...
20683955d011SMarcel MoolenaarA combination of
2069954401e6SSimon J. Gerraty.Sq Ic .else
20703955d011SMarcel Moolenaarfollowed by
2071954401e6SSimon J. Gerraty.Sq Ic .ifdef .
20724fde40d9SSimon J. Gerraty.It Ic .elifndef \*[maybenot] Ar variable Op Ar operator variable No ...
20733955d011SMarcel MoolenaarA combination of
2074954401e6SSimon J. Gerraty.Sq Ic .else
20753955d011SMarcel Moolenaarfollowed by
2076954401e6SSimon J. Gerraty.Sq Ic .ifndef .
20774fde40d9SSimon J. Gerraty.It Ic .elifmake \*[maybenot] Ar target Op Ar operator target No ...
20783955d011SMarcel MoolenaarA combination of
2079954401e6SSimon J. Gerraty.Sq Ic .else
20803955d011SMarcel Moolenaarfollowed by
2081954401e6SSimon J. Gerraty.Sq Ic .ifmake .
20824fde40d9SSimon J. Gerraty.It Ic .elifnmake \*[maybenot] Ar target Op Ar operator target No ...
20833955d011SMarcel MoolenaarA combination of
2084954401e6SSimon J. Gerraty.Sq Ic .else
20853955d011SMarcel Moolenaarfollowed by
2086954401e6SSimon J. Gerraty.Sq Ic .ifnmake .
20873955d011SMarcel Moolenaar.It Ic .endif
20883955d011SMarcel MoolenaarEnd the body of the conditional.
20893955d011SMarcel Moolenaar.El
20903955d011SMarcel Moolenaar.Pp
20913955d011SMarcel MoolenaarThe
20923955d011SMarcel Moolenaar.Ar operator
20933955d011SMarcel Moolenaarmay be any one of the following:
20944fde40d9SSimon J. Gerraty.Bl -tag
20954fde40d9SSimon J. Gerraty.It Ic \&|\&|
20963955d011SMarcel MoolenaarLogical OR.
20974fde40d9SSimon J. Gerraty.It Ic \&&&
20984fde40d9SSimon J. GerratyLogical AND; of higher precedence than
20994fde40d9SSimon J. Gerraty.Sq Ic \&|\&| .
21003955d011SMarcel Moolenaar.El
21013955d011SMarcel Moolenaar.Pp
21023955d011SMarcel Moolenaar.Nm
21034fde40d9SSimon J. Gerratyonly evaluates a conditional as far as is necessary to determine its value.
21044fde40d9SSimon J. GerratyParentheses can be used to override the operator precedence.
21053955d011SMarcel MoolenaarThe boolean operator
2106954401e6SSimon J. Gerraty.Sq Ic \&!
210798875883SSimon J. Gerratymay be used to logically negate an expression, typically a function call.
21083955d011SMarcel MoolenaarIt is of higher precedence than
2109954401e6SSimon J. Gerraty.Sq Ic \&&& .
21103955d011SMarcel Moolenaar.Pp
21113955d011SMarcel MoolenaarThe value of
21123955d011SMarcel Moolenaar.Ar expression
21134fde40d9SSimon J. Gerratymay be any of the following function call expressions:
21144fde40d9SSimon J. Gerraty.Bl -tag
21154fde40d9SSimon J. Gerraty.Sm off
21164fde40d9SSimon J. Gerraty.It Ic defined Li \&( Ar varname Li \&)
21174fde40d9SSimon J. Gerraty.Sm on
21184fde40d9SSimon J. GerratyEvaluates to true if the variable
21194fde40d9SSimon J. Gerraty.Ar varname
21203955d011SMarcel Moolenaarhas been defined.
21214fde40d9SSimon J. Gerraty.Sm off
21224fde40d9SSimon J. Gerraty.It Ic make Li \&( Ar target Li \&)
21234fde40d9SSimon J. Gerraty.Sm on
21244fde40d9SSimon J. GerratyEvaluates to true if the target was specified as part of
21253955d011SMarcel Moolenaar.Nm Ns 's
21263955d011SMarcel Moolenaarcommand line or was declared the default target (either implicitly or
21273955d011SMarcel Moolenaarexplicitly, see
21283955d011SMarcel Moolenaar.Va .MAIN )
21293955d011SMarcel Moolenaarbefore the line containing the conditional.
21304fde40d9SSimon J. Gerraty.Sm off
21314fde40d9SSimon J. Gerraty.It Ic empty Li \&( Ar varname Oo Li : Ar modifiers Oc Li \&)
21324fde40d9SSimon J. Gerraty.Sm on
21334fde40d9SSimon J. GerratyEvaluates to true if the expansion of the variable,
21344fde40d9SSimon J. Gerratyafter applying the modifiers, results in an empty string.
21354fde40d9SSimon J. Gerraty.Sm off
21364fde40d9SSimon J. Gerraty.It Ic exists Li \&( Ar pathname Li \&)
21374fde40d9SSimon J. Gerraty.Sm on
21384fde40d9SSimon J. GerratyEvaluates to true if the given pathname exists.
21394fde40d9SSimon J. GerratyIf relative, the pathname is searched for on the system search path (see
21403955d011SMarcel Moolenaar.Va .PATH ) .
21414fde40d9SSimon J. Gerraty.Sm off
21424fde40d9SSimon J. Gerraty.It Ic target Li \&( Ar target Li \&)
21434fde40d9SSimon J. Gerraty.Sm on
21444fde40d9SSimon J. GerratyEvaluates to true if the target has been defined.
21454fde40d9SSimon J. Gerraty.Sm off
21464fde40d9SSimon J. Gerraty.It Ic commands Li \&( Ar target Li \&)
21474fde40d9SSimon J. Gerraty.Sm on
21484fde40d9SSimon J. GerratyEvaluates to true if the target has been defined
21494fde40d9SSimon J. Gerratyand has commands associated with it.
21503955d011SMarcel Moolenaar.El
21513955d011SMarcel Moolenaar.Pp
21523955d011SMarcel Moolenaar.Ar Expression
21533955d011SMarcel Moolenaarmay also be an arithmetic or string comparison.
21544fde40d9SSimon J. GerratyVariable expansion is performed on both sides of the comparison.
21554fde40d9SSimon J. GerratyIf both sides are numeric and neither is enclosed in quotes,
21564fde40d9SSimon J. Gerratythe comparison is done numerically, otherwise lexicographically.
215798875883SSimon J. GerratyA string is interpreted as a hexadecimal integer if it is preceded by
21584fde40d9SSimon J. Gerraty.Li 0x ,
215998875883SSimon J. Gerratyotherwise it is interpreted as a decimal floating-point number;
21604fde40d9SSimon J. Gerratyoctal numbers are not supported.
21614fde40d9SSimon J. Gerraty.Pp
21624fde40d9SSimon J. GerratyAll comparisons may use the operators
21634fde40d9SSimon J. Gerraty.Sq Ic \&==
21644fde40d9SSimon J. Gerratyand
21654fde40d9SSimon J. Gerraty.Sq Ic \&!= .
21664fde40d9SSimon J. GerratyNumeric comparisons may also use the operators
21674fde40d9SSimon J. Gerraty.Sq Ic \&< ,
21684fde40d9SSimon J. Gerraty.Sq Ic \&<= ,
21694fde40d9SSimon J. Gerraty.Sq Ic \&>
21704fde40d9SSimon J. Gerratyand
21714fde40d9SSimon J. Gerraty.Sq Ic \&>= .
21724fde40d9SSimon J. Gerraty.Pp
21734fde40d9SSimon J. GerratyIf the comparison has neither a comparison operator nor a right side,
21744fde40d9SSimon J. Gerratythe expression evaluates to true if it is nonempty
21754fde40d9SSimon J. Gerratyand its numeric value (if any) is not zero.
21763955d011SMarcel Moolenaar.Pp
21773955d011SMarcel MoolenaarWhen
21783955d011SMarcel Moolenaar.Nm
21793955d011SMarcel Moolenaaris evaluating one of these conditional expressions, and it encounters
218098875883SSimon J. Gerratya (whitespace-separated) word it doesn't recognize, either the
21813955d011SMarcel Moolenaar.Dq make
21823955d011SMarcel Moolenaaror
21833955d011SMarcel Moolenaar.Dq defined
21844fde40d9SSimon J. Gerratyfunction is applied to it, depending on the form of the conditional.
21853955d011SMarcel MoolenaarIf the form is
2186954401e6SSimon J. Gerraty.Sq Ic .ifdef ,
21874fde40d9SSimon J. Gerraty.Sq Ic .ifndef
21883955d011SMarcel Moolenaaror
21894fde40d9SSimon J. Gerraty.Sq Ic .if ,
21903955d011SMarcel Moolenaarthe
21913955d011SMarcel Moolenaar.Dq defined
21924fde40d9SSimon J. Gerratyfunction is applied.
21933955d011SMarcel MoolenaarSimilarly, if the form is
2194954401e6SSimon J. Gerraty.Sq Ic .ifmake
21953955d011SMarcel Moolenaaror
2196954401e6SSimon J. Gerraty.Sq Ic .ifnmake ,
2197494f7191SSimon J. Gerratythe
21983955d011SMarcel Moolenaar.Dq make
21994fde40d9SSimon J. Gerratyfunction is applied.
22003955d011SMarcel Moolenaar.Pp
22014fde40d9SSimon J. GerratyIf the conditional evaluates to true,
22024fde40d9SSimon J. Gerratyparsing of the makefile continues as before.
220398875883SSimon J. GerratyIf it evaluates to false, the following lines until the corresponding
220498875883SSimon J. Gerraty.Sq Ic .elif
220598875883SSimon J. Gerratyvariant,
2206954401e6SSimon J. Gerraty.Sq Ic .else
22073955d011SMarcel Moolenaaror
2208954401e6SSimon J. Gerraty.Sq Ic .endif
220998875883SSimon J. Gerratyare skipped.
22104fde40d9SSimon J. Gerraty.Ss For loops
22113955d011SMarcel MoolenaarFor loops are typically used to apply a set of rules to a list of files.
22123955d011SMarcel MoolenaarThe syntax of a for loop is:
22133955d011SMarcel Moolenaar.Pp
22143955d011SMarcel Moolenaar.Bl -tag -compact -width Ds
22154fde40d9SSimon J. Gerraty.It Ic \&.for Ar variable Oo Ar variable No ... Oc Ic in Ar expression
22164fde40d9SSimon J. Gerraty.It Aq Ar make-lines
22173955d011SMarcel Moolenaar.It Ic \&.endfor
22183955d011SMarcel Moolenaar.El
22193955d011SMarcel Moolenaar.Pp
22204fde40d9SSimon J. GerratyThe
22214fde40d9SSimon J. Gerraty.Ar expression
22224fde40d9SSimon J. Gerratyis expanded and then split into words.
22233955d011SMarcel MoolenaarOn each iteration of the loop, one word is taken and assigned to each
22244fde40d9SSimon J. Gerraty.Ar variable ,
22253955d011SMarcel Moolenaarin order, and these
22264fde40d9SSimon J. Gerraty.Ar variables
22273955d011SMarcel Moolenaarare substituted into the
22284fde40d9SSimon J. Gerraty.Ar make-lines
22293955d011SMarcel Moolenaarinside the body of the for loop.
22303955d011SMarcel MoolenaarThe number of words must come out even; that is, if there are three
22313955d011SMarcel Moolenaariteration variables, the number of words provided must be a multiple
22323955d011SMarcel Moolenaarof three.
22334fde40d9SSimon J. Gerraty.Pp
22344fde40d9SSimon J. GerratyIf
22354fde40d9SSimon J. Gerraty.Sq Ic .break
22364fde40d9SSimon J. Gerratyis encountered within a
22374fde40d9SSimon J. Gerraty.Cm \&.for
22384fde40d9SSimon J. Gerratyloop, it causes early termination of the loop, otherwise a parse error.
22394fde40d9SSimon J. Gerraty.\" TODO: Describe limitations with defined/empty.
22404fde40d9SSimon J. Gerraty.Ss Other directives
22414fde40d9SSimon J. Gerraty.Bl -tag -width Ds
22424fde40d9SSimon J. Gerraty.It Ic .undef Ar variable No ...
22434fde40d9SSimon J. GerratyUn-define the specified global variables.
22444fde40d9SSimon J. GerratyOnly global variables can be un-defined.
22454fde40d9SSimon J. Gerraty.El
22463955d011SMarcel Moolenaar.Sh COMMENTS
22473955d011SMarcel MoolenaarComments begin with a hash
22483955d011SMarcel Moolenaar.Pq Ql \&#
22493955d011SMarcel Moolenaarcharacter, anywhere but in a shell
22503955d011SMarcel Moolenaarcommand line, and continue to the end of an unescaped new line.
22513955d011SMarcel Moolenaar.Sh SPECIAL SOURCES (ATTRIBUTES)
22523955d011SMarcel Moolenaar.Bl -tag -width .IGNOREx
22533955d011SMarcel Moolenaar.It Ic .EXEC
22543955d011SMarcel MoolenaarTarget is never out of date, but always execute commands anyway.
22553955d011SMarcel Moolenaar.It Ic .IGNORE
22563955d011SMarcel MoolenaarIgnore any errors from the commands associated with this target, exactly
22573955d011SMarcel Moolenaaras if they all were preceded by a dash
22583955d011SMarcel Moolenaar.Pq Ql \- .
22593955d011SMarcel Moolenaar.\" .It Ic .INVISIBLE
22603955d011SMarcel Moolenaar.\" XXX
22613955d011SMarcel Moolenaar.\" .It Ic .JOIN
22623955d011SMarcel Moolenaar.\" XXX
22633955d011SMarcel Moolenaar.It Ic .MADE
22644fde40d9SSimon J. GerratyMark all sources of this target as being up to date.
22653955d011SMarcel Moolenaar.It Ic .MAKE
22663955d011SMarcel MoolenaarExecute the commands associated with this target even if the
22673955d011SMarcel Moolenaar.Fl n
22683955d011SMarcel Moolenaaror
22693955d011SMarcel Moolenaar.Fl t
22703955d011SMarcel Moolenaaroptions were specified.
22713955d011SMarcel MoolenaarNormally used to mark recursive
22720dede8b0SSimon J. Gerraty.Nm Ns s .
22733955d011SMarcel Moolenaar.It Ic .META
22743955d011SMarcel MoolenaarCreate a meta file for the target, even if it is flagged as
22753955d011SMarcel Moolenaar.Ic .PHONY ,
22763955d011SMarcel Moolenaar.Ic .MAKE ,
22773955d011SMarcel Moolenaaror
22783955d011SMarcel Moolenaar.Ic .SPECIAL .
22793955d011SMarcel MoolenaarUsage in conjunction with
22803955d011SMarcel Moolenaar.Ic .MAKE
22813955d011SMarcel Moolenaaris the most likely case.
22824fde40d9SSimon J. GerratyIn
22834fde40d9SSimon J. Gerraty.Dq meta
22844fde40d9SSimon J. Gerratymode, the target is out-of-date if the meta file is missing.
22853955d011SMarcel Moolenaar.It Ic .NOMETA
22863955d011SMarcel MoolenaarDo not create a meta file for the target.
22873955d011SMarcel MoolenaarMeta files are also not created for
22883955d011SMarcel Moolenaar.Ic .PHONY ,
22893955d011SMarcel Moolenaar.Ic .MAKE ,
22903955d011SMarcel Moolenaaror
22913955d011SMarcel Moolenaar.Ic .SPECIAL
22923955d011SMarcel Moolenaartargets.
22933955d011SMarcel Moolenaar.It Ic .NOMETA_CMP
22943955d011SMarcel MoolenaarIgnore differences in commands when deciding if target is out of date.
22953955d011SMarcel MoolenaarThis is useful if the command contains a value which always changes.
22964fde40d9SSimon J. GerratyIf the number of commands change, though,
22974fde40d9SSimon J. Gerratythe target is still considered out of date.
22981748de26SSimon J. GerratyThe same effect applies to any command line that uses the variable
22991748de26SSimon J. Gerraty.Va .OODATE ,
23001748de26SSimon J. Gerratywhich can be used for that purpose even when not otherwise needed or desired:
23011748de26SSimon J. Gerraty.Bd -literal -offset indent
23021748de26SSimon J. Gerraty
23031748de26SSimon J. Gerratyskip-compare-for-some:
23044fde40d9SSimon J. Gerraty	@echo this is compared
23054fde40d9SSimon J. Gerraty	@echo this is not ${.OODATE:M.NOMETA_CMP}
23064fde40d9SSimon J. Gerraty	@echo this is also compared
23071748de26SSimon J. Gerraty
23081748de26SSimon J. Gerraty.Ed
23091748de26SSimon J. GerratyThe
23101748de26SSimon J. Gerraty.Cm \&:M
23111748de26SSimon J. Gerratypattern suppresses any expansion of the unwanted variable.
23123955d011SMarcel Moolenaar.It Ic .NOPATH
23133955d011SMarcel MoolenaarDo not search for the target in the directories specified by
23144fde40d9SSimon J. Gerraty.Va .PATH .
23153955d011SMarcel Moolenaar.It Ic .NOTMAIN
23163955d011SMarcel MoolenaarNormally
23173955d011SMarcel Moolenaar.Nm
23183955d011SMarcel Moolenaarselects the first target it encounters as the default target to be built
23193955d011SMarcel Moolenaarif no target was specified.
23203955d011SMarcel MoolenaarThis source prevents this target from being selected.
23213955d011SMarcel Moolenaar.It Ic .OPTIONAL
23223955d011SMarcel MoolenaarIf a target is marked with this attribute and
23233955d011SMarcel Moolenaar.Nm
23244fde40d9SSimon J. Gerratycan't figure out how to create it, it ignores this fact and assumes
23253955d011SMarcel Moolenaarthe file isn't needed or already exists.
23263955d011SMarcel Moolenaar.It Ic .PHONY
23274fde40d9SSimon J. GerratyThe target does not correspond to an actual file;
23284fde40d9SSimon J. Gerratyit is always considered to be out of date,
23294fde40d9SSimon J. Gerratyand is not created with the
23303955d011SMarcel Moolenaar.Fl t
23313955d011SMarcel Moolenaaroption.
23323955d011SMarcel MoolenaarSuffix-transformation rules are not applied to
23333955d011SMarcel Moolenaar.Ic .PHONY
23343955d011SMarcel Moolenaartargets.
23353955d011SMarcel Moolenaar.It Ic .PRECIOUS
23363955d011SMarcel MoolenaarWhen
23373955d011SMarcel Moolenaar.Nm
23383955d011SMarcel Moolenaaris interrupted, it normally removes any partially made targets.
23393955d011SMarcel MoolenaarThis source prevents the target from being removed.
23403955d011SMarcel Moolenaar.It Ic .RECURSIVE
23413955d011SMarcel MoolenaarSynonym for
23423955d011SMarcel Moolenaar.Ic .MAKE .
23433955d011SMarcel Moolenaar.It Ic .SILENT
23443955d011SMarcel MoolenaarDo not echo any of the commands associated with this target, exactly
23453955d011SMarcel Moolenaaras if they all were preceded by an at sign
23463955d011SMarcel Moolenaar.Pq Ql @ .
23473955d011SMarcel Moolenaar.It Ic .USE
23483955d011SMarcel MoolenaarTurn the target into
23493955d011SMarcel Moolenaar.Nm Ns 's
23503955d011SMarcel Moolenaarversion of a macro.
23513955d011SMarcel MoolenaarWhen the target is used as a source for another target, the other target
23523955d011SMarcel Moolenaaracquires the commands, sources, and attributes (except for
23533955d011SMarcel Moolenaar.Ic .USE )
23543955d011SMarcel Moolenaarof the
23553955d011SMarcel Moolenaarsource.
23563955d011SMarcel MoolenaarIf the target already has commands, the
23573955d011SMarcel Moolenaar.Ic .USE
23583955d011SMarcel Moolenaartarget's commands are appended
23593955d011SMarcel Moolenaarto them.
23603955d011SMarcel Moolenaar.It Ic .USEBEFORE
23614fde40d9SSimon J. GerratyLike
23623955d011SMarcel Moolenaar.Ic .USE ,
23634fde40d9SSimon J. Gerratybut instead of appending, prepend the
23643955d011SMarcel Moolenaar.Ic .USEBEFORE
23653955d011SMarcel Moolenaartarget commands to the target.
23663955d011SMarcel Moolenaar.It Ic .WAIT
23673955d011SMarcel MoolenaarIf
23683955d011SMarcel Moolenaar.Ic .WAIT
23693955d011SMarcel Moolenaarappears in a dependency line, the sources that precede it are
23703955d011SMarcel Moolenaarmade before the sources that succeed it in the line.
23713955d011SMarcel MoolenaarSince the dependents of files are not made until the file itself
23723955d011SMarcel Moolenaarcould be made, this also stops the dependents being built unless they
23733955d011SMarcel Moolenaarare needed for another branch of the dependency tree.
23743955d011SMarcel MoolenaarSo given:
23753955d011SMarcel Moolenaar.Bd -literal
23763955d011SMarcel Moolenaarx: a .WAIT b
23773955d011SMarcel Moolenaar	echo x
23783955d011SMarcel Moolenaara:
23793955d011SMarcel Moolenaar	echo a
23803955d011SMarcel Moolenaarb: b1
23813955d011SMarcel Moolenaar	echo b
23823955d011SMarcel Moolenaarb1:
23833955d011SMarcel Moolenaar	echo b1
23843955d011SMarcel Moolenaar
23853955d011SMarcel Moolenaar.Ed
23863955d011SMarcel Moolenaarthe output is always
23873955d011SMarcel Moolenaar.Ql a ,
23883955d011SMarcel Moolenaar.Ql b1 ,
23893955d011SMarcel Moolenaar.Ql b ,
23903955d011SMarcel Moolenaar.Ql x .
23914fde40d9SSimon J. Gerraty.Pp
23923955d011SMarcel MoolenaarThe ordering imposed by
23933955d011SMarcel Moolenaar.Ic .WAIT
23943955d011SMarcel Moolenaaris only relevant for parallel makes.
23953955d011SMarcel Moolenaar.El
23963955d011SMarcel Moolenaar.Sh SPECIAL TARGETS
23973955d011SMarcel MoolenaarSpecial targets may not be included with other targets, i.e. they must be
23983955d011SMarcel Moolenaarthe only target specified.
23993955d011SMarcel Moolenaar.Bl -tag -width .BEGINx
24003955d011SMarcel Moolenaar.It Ic .BEGIN
24013955d011SMarcel MoolenaarAny command lines attached to this target are executed before anything
24023955d011SMarcel Moolenaarelse is done.
24033955d011SMarcel Moolenaar.It Ic .DEFAULT
24043955d011SMarcel MoolenaarThis is sort of a
24053955d011SMarcel Moolenaar.Ic .USE
24064fde40d9SSimon J. Gerratyrule for any target (that was used only as a source) that
24073955d011SMarcel Moolenaar.Nm
24083955d011SMarcel Moolenaarcan't figure out any other way to create.
24093955d011SMarcel MoolenaarOnly the shell script is used.
24103955d011SMarcel MoolenaarThe
24114fde40d9SSimon J. Gerraty.Va .IMPSRC
24123955d011SMarcel Moolenaarvariable of a target that inherits
24133955d011SMarcel Moolenaar.Ic .DEFAULT Ns 's
24144fde40d9SSimon J. Gerratycommands is set to the target's own name.
241545447996SSimon J. Gerraty.It Ic .DELETE_ON_ERROR
241645447996SSimon J. GerratyIf this target is present in the makefile, it globally causes make to
241745447996SSimon J. Gerratydelete targets whose commands fail.
241845447996SSimon J. Gerraty(By default, only targets whose commands are interrupted during
241945447996SSimon J. Gerratyexecution are deleted.
242045447996SSimon J. GerratyThis is the historical behavior.)
242145447996SSimon J. GerratyThis setting can be used to help prevent half-finished or malformed
242245447996SSimon J. Gerratytargets from being left around and corrupting future rebuilds.
24233955d011SMarcel Moolenaar.It Ic .END
24243955d011SMarcel MoolenaarAny command lines attached to this target are executed after everything
24254fde40d9SSimon J. Gerratyelse is done successfully.
24263955d011SMarcel Moolenaar.It Ic .ERROR
24273955d011SMarcel MoolenaarAny command lines attached to this target are executed when another target fails.
2428c59c3bf3SSimon J. GerratySee
2429c59c3bf3SSimon J. Gerraty.Va MAKE_PRINT_VAR_ON_ERROR
2430c59c3bf3SSimon J. Gerratyfor the variables that will be set.
24313955d011SMarcel Moolenaar.It Ic .IGNORE
24323955d011SMarcel MoolenaarMark each of the sources with the
24333955d011SMarcel Moolenaar.Ic .IGNORE
24343955d011SMarcel Moolenaarattribute.
24353955d011SMarcel MoolenaarIf no sources are specified, this is the equivalent of specifying the
24363955d011SMarcel Moolenaar.Fl i
24373955d011SMarcel Moolenaaroption.
24383955d011SMarcel Moolenaar.It Ic .INTERRUPT
24393955d011SMarcel MoolenaarIf
24403955d011SMarcel Moolenaar.Nm
24414fde40d9SSimon J. Gerratyis interrupted, the commands for this target are executed.
24423955d011SMarcel Moolenaar.It Ic .MAIN
24433955d011SMarcel MoolenaarIf no target is specified when
24443955d011SMarcel Moolenaar.Nm
24454fde40d9SSimon J. Gerratyis invoked, this target is built.
24463955d011SMarcel Moolenaar.It Ic .MAKEFLAGS
24473955d011SMarcel MoolenaarThis target provides a way to specify flags for
24483955d011SMarcel Moolenaar.Nm
24494fde40d9SSimon J. Gerratyat the time when the makefiles are read.
24503955d011SMarcel MoolenaarThe flags are as if typed to the shell, though the
24513955d011SMarcel Moolenaar.Fl f
24524fde40d9SSimon J. Gerratyoption has
24533955d011SMarcel Moolenaarno effect.
24543955d011SMarcel Moolenaar.\" XXX: NOT YET!!!!
24553955d011SMarcel Moolenaar.\" .It Ic .NOTPARALLEL
24563955d011SMarcel Moolenaar.\" The named targets are executed in non parallel mode.
24573955d011SMarcel Moolenaar.\" If no targets are
24584fde40d9SSimon J. Gerraty.\" specified, all targets are executed in non parallel mode.
24593955d011SMarcel Moolenaar.It Ic .NOPATH
24603955d011SMarcel MoolenaarApply the
24613955d011SMarcel Moolenaar.Ic .NOPATH
24623955d011SMarcel Moolenaarattribute to any specified sources.
24633955d011SMarcel Moolenaar.It Ic .NOTPARALLEL
24643955d011SMarcel MoolenaarDisable parallel mode.
24653955d011SMarcel Moolenaar.It Ic .NO_PARALLEL
24663955d011SMarcel MoolenaarSynonym for
24673955d011SMarcel Moolenaar.Ic .NOTPARALLEL ,
24683955d011SMarcel Moolenaarfor compatibility with other pmake variants.
24694fde40d9SSimon J. Gerraty.It Ic .NOREADONLY
24704fde40d9SSimon J. Gerratyclear the read-only attribute from the global variables specified as sources.
2471128a4105SSimon J. Gerraty.It Ic .OBJDIR
2472128a4105SSimon J. GerratyThe source is a new value for
2473954401e6SSimon J. Gerraty.Sq Va .OBJDIR .
2474128a4105SSimon J. GerratyIf it exists,
2475128a4105SSimon J. Gerraty.Nm
24764fde40d9SSimon J. Gerratychanges the current working directory to it and updates the value of
2477954401e6SSimon J. Gerraty.Sq Va .OBJDIR .
24783955d011SMarcel Moolenaar.It Ic .ORDER
2479954401e6SSimon J. GerratyIn parallel mode, the named targets are made in sequence.
24803955d011SMarcel MoolenaarThis ordering does not add targets to the list of targets to be made.
2481954401e6SSimon J. Gerraty.Pp
24823955d011SMarcel MoolenaarSince the dependents of a target do not get built until the target itself
24833955d011SMarcel Moolenaarcould be built, unless
24843955d011SMarcel Moolenaar.Ql a
24853955d011SMarcel Moolenaaris built by another part of the dependency graph,
24863955d011SMarcel Moolenaarthe following is a dependency loop:
24873955d011SMarcel Moolenaar.Bd -literal
24883955d011SMarcel Moolenaar\&.ORDER: b a
24893955d011SMarcel Moolenaarb: a
24903955d011SMarcel Moolenaar.Ed
24913955d011SMarcel Moolenaar.Pp
24923955d011SMarcel Moolenaar.\" XXX: NOT YET!!!!
24933955d011SMarcel Moolenaar.\" .It Ic .PARALLEL
24943955d011SMarcel Moolenaar.\" The named targets are executed in parallel mode.
24953955d011SMarcel Moolenaar.\" If no targets are
24964fde40d9SSimon J. Gerraty.\" specified, all targets are executed in parallel mode.
24973955d011SMarcel Moolenaar.It Ic .PATH
24983955d011SMarcel MoolenaarThe sources are directories which are to be searched for files not
24993955d011SMarcel Moolenaarfound in the current directory.
25004fde40d9SSimon J. GerratyIf no sources are specified,
25014fde40d9SSimon J. Gerratyany previously specified directories are removed from the search path.
25023955d011SMarcel MoolenaarIf the source is the special
25033955d011SMarcel Moolenaar.Ic .DOTLAST
25044fde40d9SSimon J. Gerratytarget, the current working directory is searched last.
25054fde40d9SSimon J. Gerraty.It Ic .PATH. Ns Ar suffix
25061bbe5942SSimon J. GerratyLike
25071bbe5942SSimon J. Gerraty.Ic .PATH
25081bbe5942SSimon J. Gerratybut applies only to files with a particular suffix.
25091bbe5942SSimon J. GerratyThe suffix must have been previously declared with
25101bbe5942SSimon J. Gerraty.Ic .SUFFIXES .
25113955d011SMarcel Moolenaar.It Ic .PHONY
25123955d011SMarcel MoolenaarApply the
25133955d011SMarcel Moolenaar.Ic .PHONY
25143955d011SMarcel Moolenaarattribute to any specified sources.
25151d3f2ddcSSimon J. Gerraty.It Ic .POSIX
25162f2a5ecdSSimon J. GerratyIf this is the first non-comment line in the main makefile,
25172f2a5ecdSSimon J. Gerratythe variable
25181d3f2ddcSSimon J. Gerraty.Va %POSIX
25192f2a5ecdSSimon J. Gerratyis set to the value
25202f2a5ecdSSimon J. Gerraty.Ql 1003.2
25212f2a5ecdSSimon J. Gerratyand the makefile
25222f2a5ecdSSimon J. Gerraty.Ql <posix.mk>
25232f2a5ecdSSimon J. Gerratyis included if it exists,
25242f2a5ecdSSimon J. Gerratyto provide POSIX-compatible default rules.
25251d3f2ddcSSimon J. GerratyIf
25261d3f2ddcSSimon J. Gerraty.Nm
25271d3f2ddcSSimon J. Gerratyis run with the
25281d3f2ddcSSimon J. Gerraty.Fl r
25294fde40d9SSimon J. Gerratyflag, only
25301d3f2ddcSSimon J. Gerraty.Ql posix.mk
25314fde40d9SSimon J. Gerratycontributes to the default rules.
25323955d011SMarcel Moolenaar.It Ic .PRECIOUS
25333955d011SMarcel MoolenaarApply the
25343955d011SMarcel Moolenaar.Ic .PRECIOUS
25353955d011SMarcel Moolenaarattribute to any specified sources.
25363955d011SMarcel MoolenaarIf no sources are specified, the
25373955d011SMarcel Moolenaar.Ic .PRECIOUS
25384fde40d9SSimon J. Gerratyattribute is applied to every target in the file.
25394fde40d9SSimon J. Gerraty.It Ic .READONLY
25404fde40d9SSimon J. Gerratyset the read-only attribute on the global variables specified as sources.
25413955d011SMarcel Moolenaar.It Ic .SHELL
25423955d011SMarcel MoolenaarSets the shell that
25433955d011SMarcel Moolenaar.Nm
2544d5e0a182SSimon J. Gerratyuses to execute commands.
25453955d011SMarcel MoolenaarThe sources are a set of
25464fde40d9SSimon J. Gerraty.Ar field\| Ns Cm \&= Ns Ar value
25473955d011SMarcel Moolenaarpairs.
25484fde40d9SSimon J. Gerraty.Bl -tag -width ".Li hasErrCtls"
25494fde40d9SSimon J. Gerraty.It Li name
2550be19d90bSSimon J. GerratyThis is the minimal specification, used to select one of the built-in
25513955d011SMarcel Moolenaarshell specs;
25524fde40d9SSimon J. Gerraty.Li sh ,
25534fde40d9SSimon J. Gerraty.Li ksh ,
25543955d011SMarcel Moolenaarand
25554fde40d9SSimon J. Gerraty.Li csh .
25564fde40d9SSimon J. Gerraty.It Li path
25574fde40d9SSimon J. GerratySpecifies the absolute path to the shell.
25584fde40d9SSimon J. Gerraty.It Li hasErrCtl
25593955d011SMarcel MoolenaarIndicates whether the shell supports exit on error.
25604fde40d9SSimon J. Gerraty.It Li check
25613955d011SMarcel MoolenaarThe command to turn on error checking.
25624fde40d9SSimon J. Gerraty.It Li ignore
25633955d011SMarcel MoolenaarThe command to disable error checking.
25644fde40d9SSimon J. Gerraty.It Li echo
25653955d011SMarcel MoolenaarThe command to turn on echoing of commands executed.
25664fde40d9SSimon J. Gerraty.It Li quiet
25673955d011SMarcel MoolenaarThe command to turn off echoing of commands executed.
25684fde40d9SSimon J. Gerraty.It Li filter
25693955d011SMarcel MoolenaarThe output to filter after issuing the
25704fde40d9SSimon J. Gerraty.Li quiet
25713955d011SMarcel Moolenaarcommand.
25723955d011SMarcel MoolenaarIt is typically identical to
25734fde40d9SSimon J. Gerraty.Li quiet .
25744fde40d9SSimon J. Gerraty.It Li errFlag
25753955d011SMarcel MoolenaarThe flag to pass the shell to enable error checking.
25764fde40d9SSimon J. Gerraty.It Li echoFlag
25773955d011SMarcel MoolenaarThe flag to pass the shell to enable command echoing.
25784fde40d9SSimon J. Gerraty.It Li newline
25793955d011SMarcel MoolenaarThe string literal to pass the shell that results in a single newline
25803955d011SMarcel Moolenaarcharacter when used outside of any quoting characters.
25813955d011SMarcel Moolenaar.El
25823955d011SMarcel MoolenaarExample:
25833955d011SMarcel Moolenaar.Bd -literal
25843955d011SMarcel Moolenaar\&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \e
25853955d011SMarcel Moolenaar	check="set \-e" ignore="set +e" \e
25863955d011SMarcel Moolenaar	echo="set \-v" quiet="set +v" filter="set +v" \e
25873955d011SMarcel Moolenaar	echoFlag=v errFlag=e newline="'\en'"
25883955d011SMarcel Moolenaar.Ed
25893955d011SMarcel Moolenaar.It Ic .SILENT
25903955d011SMarcel MoolenaarApply the
25913955d011SMarcel Moolenaar.Ic .SILENT
25923955d011SMarcel Moolenaarattribute to any specified sources.
25933955d011SMarcel MoolenaarIf no sources are specified, the
25943955d011SMarcel Moolenaar.Ic .SILENT
25953955d011SMarcel Moolenaarattribute is applied to every
25963955d011SMarcel Moolenaarcommand in the file.
25971748de26SSimon J. Gerraty.It Ic .STALE
25981748de26SSimon J. GerratyThis target gets run when a dependency file contains stale entries, having
25991748de26SSimon J. Gerraty.Va .ALLSRC
26001748de26SSimon J. Gerratyset to the name of that dependency file.
26013955d011SMarcel Moolenaar.It Ic .SUFFIXES
26023955d011SMarcel MoolenaarEach source specifies a suffix to
26033955d011SMarcel Moolenaar.Nm .
26043955d011SMarcel MoolenaarIf no sources are specified, any previously specified suffixes are deleted.
26053955d011SMarcel MoolenaarIt allows the creation of suffix-transformation rules.
26063955d011SMarcel Moolenaar.Pp
26073955d011SMarcel MoolenaarExample:
26083955d011SMarcel Moolenaar.Bd -literal
26094fde40d9SSimon J. Gerraty\&.SUFFIXES: .c .o
26103955d011SMarcel Moolenaar\&.c.o:
26113955d011SMarcel Moolenaar	cc \-o ${.TARGET} \-c ${.IMPSRC}
26123955d011SMarcel Moolenaar.Ed
26134fde40d9SSimon J. Gerraty.It Ic .SYSPATH
26144fde40d9SSimon J. GerratyThe sources are directories which are to be added to the system
26154fde40d9SSimon J. Gerratyinclude path which
26164fde40d9SSimon J. Gerraty.Nm
26174fde40d9SSimon J. Gerratysearches for makefiles.
26184fde40d9SSimon J. GerratyIf no sources are specified,
26194fde40d9SSimon J. Gerratyany previously specified directories are removed from the system
26204fde40d9SSimon J. Gerratyinclude path.
26213955d011SMarcel Moolenaar.El
26223955d011SMarcel Moolenaar.Sh ENVIRONMENT
26233955d011SMarcel Moolenaar.Nm
26243955d011SMarcel Moolenaaruses the following environment variables, if they exist:
26253955d011SMarcel Moolenaar.Ev MACHINE ,
26263955d011SMarcel Moolenaar.Ev MACHINE_ARCH ,
26273955d011SMarcel Moolenaar.Ev MAKE ,
26283955d011SMarcel Moolenaar.Ev MAKEFLAGS ,
26293955d011SMarcel Moolenaar.Ev MAKEOBJDIR ,
26303955d011SMarcel Moolenaar.Ev MAKEOBJDIRPREFIX ,
26313955d011SMarcel Moolenaar.Ev MAKESYSPATH ,
26323955d011SMarcel Moolenaar.Ev PWD ,
26333955d011SMarcel Moolenaarand
26343955d011SMarcel Moolenaar.Ev TMPDIR .
26353955d011SMarcel Moolenaar.Pp
26363955d011SMarcel Moolenaar.Ev MAKEOBJDIRPREFIX
26373955d011SMarcel Moolenaarand
26383955d011SMarcel Moolenaar.Ev MAKEOBJDIR
26393955d011SMarcel Moolenaarmay only be set in the environment or on the command line to
26403955d011SMarcel Moolenaar.Nm
26413955d011SMarcel Moolenaarand not as makefile variables;
26423955d011SMarcel Moolenaarsee the description of
2643954401e6SSimon J. Gerraty.Sq Va .OBJDIR
26443955d011SMarcel Moolenaarfor more details.
26453955d011SMarcel Moolenaar.Sh FILES
26463955d011SMarcel Moolenaar.Bl -tag -width /usr/share/mk -compact
26473955d011SMarcel Moolenaar.It .depend
26483955d011SMarcel Moolenaarlist of dependencies
26493955d011SMarcel Moolenaar.It makefile
26504fde40d9SSimon J. Gerratyfirst default makefile if no makefile is specified on the command line
26514fde40d9SSimon J. Gerraty.It Makefile
26524fde40d9SSimon J. Gerratysecond default makefile if no makefile is specified on the command line
26533955d011SMarcel Moolenaar.It sys.mk
26543955d011SMarcel Moolenaarsystem makefile
26553955d011SMarcel Moolenaar.It /usr/share/mk
26563955d011SMarcel Moolenaarsystem makefile directory
26573955d011SMarcel Moolenaar.El
26583955d011SMarcel Moolenaar.Sh COMPATIBILITY
26594fde40d9SSimon J. GerratyThe basic make syntax is compatible between different make variants;
26603955d011SMarcel Moolenaarhowever the special variables, variable modifiers and conditionals are not.
2661db29cad8SSimon J. Gerraty.Ss Older versions
2662db29cad8SSimon J. GerratyAn incomplete list of changes in older versions of
2663db29cad8SSimon J. Gerraty.Nm :
26643955d011SMarcel Moolenaar.Pp
26653955d011SMarcel MoolenaarThe way that .for loop variables are substituted changed after
26663955d011SMarcel MoolenaarNetBSD 5.0
26673955d011SMarcel Moolenaarso that they still appear to be variable expansions.
26683955d011SMarcel MoolenaarIn particular this stops them being treated as syntax, and removes some
26693955d011SMarcel Moolenaarobscure problems using them in .if statements.
2670db29cad8SSimon J. Gerraty.Pp
2671db29cad8SSimon J. GerratyThe way that parallel makes are scheduled changed in
2672db29cad8SSimon J. GerratyNetBSD 4.0
2673db29cad8SSimon J. Gerratyso that .ORDER and .WAIT apply recursively to the dependent nodes.
2674db29cad8SSimon J. GerratyThe algorithms used may change again in the future.
2675db29cad8SSimon J. Gerraty.Ss Other make dialects
2676db29cad8SSimon J. GerratyOther make dialects (GNU make, SVR4 make, POSIX make, etc.) do not
2677db29cad8SSimon J. Gerratysupport most of the features of
2678db29cad8SSimon J. Gerraty.Nm
2679db29cad8SSimon J. Gerratyas described in this manual.
2680db29cad8SSimon J. GerratyMost notably:
2681db29cad8SSimon J. Gerraty.Bl -bullet -offset indent
2682db29cad8SSimon J. Gerraty.It
2683db29cad8SSimon J. GerratyThe
2684db29cad8SSimon J. Gerraty.Ic .WAIT
2685db29cad8SSimon J. Gerratyand
2686db29cad8SSimon J. Gerraty.Ic .ORDER
2687db29cad8SSimon J. Gerratydeclarations and most functionality pertaining to parallelization.
26884fde40d9SSimon J. Gerraty(GNU make supports parallelization but lacks the features needed to
2689db29cad8SSimon J. Gerratycontrol it effectively.)
2690db29cad8SSimon J. Gerraty.It
2691db29cad8SSimon J. GerratyDirectives, including for loops and conditionals and most of the
2692db29cad8SSimon J. Gerratyforms of include files.
2693db29cad8SSimon J. Gerraty(GNU make has its own incompatible and less powerful syntax for
2694db29cad8SSimon J. Gerratyconditionals.)
26954fde40d9SSimon J. Gerraty.\" The "less powerful" above means that GNU make does not have the
26964fde40d9SSimon J. Gerraty.\" make(target), target(target) and commands(target) functions.
2697db29cad8SSimon J. Gerraty.It
2698db29cad8SSimon J. GerratyAll built-in variables that begin with a dot.
2699db29cad8SSimon J. Gerraty.It
2700db29cad8SSimon J. GerratyMost of the special sources and targets that begin with a dot,
2701db29cad8SSimon J. Gerratywith the notable exception of
2702db29cad8SSimon J. Gerraty.Ic .PHONY ,
2703db29cad8SSimon J. Gerraty.Ic .PRECIOUS ,
2704db29cad8SSimon J. Gerratyand
2705db29cad8SSimon J. Gerraty.Ic .SUFFIXES .
2706db29cad8SSimon J. Gerraty.It
2707db29cad8SSimon J. GerratyVariable modifiers, except for the
27084fde40d9SSimon J. Gerraty.Ql :old=new
2709db29cad8SSimon J. Gerratystring substitution, which does not portably support globbing with
2710db29cad8SSimon J. Gerraty.Ql %
2711db29cad8SSimon J. Gerratyand historically only works on declared suffixes.
2712db29cad8SSimon J. Gerraty.It
2713db29cad8SSimon J. GerratyThe
2714db29cad8SSimon J. Gerraty.Ic $>
2715db29cad8SSimon J. Gerratyvariable even in its short form; most makes support this functionality
2716db29cad8SSimon J. Gerratybut its name varies.
2717db29cad8SSimon J. Gerraty.El
2718db29cad8SSimon J. Gerraty.Pp
2719db29cad8SSimon J. GerratySome features are somewhat more portable, such as assignment with
2720db29cad8SSimon J. Gerraty.Ic += ,
2721db29cad8SSimon J. Gerraty.Ic ?= ,
2722db29cad8SSimon J. Gerratyand
2723db29cad8SSimon J. Gerraty.Ic != .
2724db29cad8SSimon J. GerratyThe
27254fde40d9SSimon J. Gerraty.Va .PATH
2726db29cad8SSimon J. Gerratyfunctionality is based on an older feature
2727db29cad8SSimon J. Gerraty.Ic VPATH
2728db29cad8SSimon J. Gerratyfound in GNU make and many versions of SVR4 make; however,
2729db29cad8SSimon J. Gerratyhistorically its behavior is too ill-defined (and too buggy) to rely
2730db29cad8SSimon J. Gerratyupon.
2731db29cad8SSimon J. Gerraty.Pp
2732db29cad8SSimon J. GerratyThe
2733db29cad8SSimon J. Gerraty.Ic $@
2734db29cad8SSimon J. Gerratyand
2735db29cad8SSimon J. Gerraty.Ic $<
2736db29cad8SSimon J. Gerratyvariables are more or less universally portable, as is the
2737db29cad8SSimon J. Gerraty.Ic $(MAKE)
2738db29cad8SSimon J. Gerratyvariable.
2739db29cad8SSimon J. GerratyBasic use of suffix rules (for files only in the current directory,
2740db29cad8SSimon J. Gerratynot trying to chain transformations together, etc.) is also reasonably
2741db29cad8SSimon J. Gerratyportable.
27423955d011SMarcel Moolenaar.Sh SEE ALSO
27433955d011SMarcel Moolenaar.Xr mkdep 1
27443955d011SMarcel Moolenaar.Sh HISTORY
27453955d011SMarcel Moolenaar.Nm
27463955d011SMarcel Moolenaaris derived from NetBSD
27473955d011SMarcel Moolenaar.Xr make 1 .
27483955d011SMarcel MoolenaarIt uses autoconf to facilitate portability to other platforms.
274993036677SSimon J. Gerraty.Pp
275093036677SSimon J. GerratyA
275193036677SSimon J. Gerratymake
275293036677SSimon J. Gerratycommand appeared in
275393036677SSimon J. Gerraty.At v7 .
275493036677SSimon J. GerratyThis
275593036677SSimon J. Gerratymake
27564fde40d9SSimon J. Gerratyimplementation is based on Adam de Boor's pmake program,
27574fde40d9SSimon J. Gerratywhich was written for Sprite at Berkeley.
275893036677SSimon J. GerratyIt was designed to be a parallel distributed make running jobs on different
275993036677SSimon J. Gerratymachines using a daemon called
276093036677SSimon J. Gerraty.Dq customs .
276151ee2c1cSSimon J. Gerraty.Pp
276251ee2c1cSSimon J. GerratyHistorically the target/dependency
27634fde40d9SSimon J. Gerraty.Ic FRC
276451ee2c1cSSimon J. Gerratyhas been used to FoRCe rebuilding (since the target/dependency
276551ee2c1cSSimon J. Gerratydoes not exist ... unless someone creates an
27664fde40d9SSimon J. Gerraty.Pa FRC
276751ee2c1cSSimon J. Gerratyfile).
276893036677SSimon J. Gerraty.Sh BUGS
276993036677SSimon J. GerratyThe
277093036677SSimon J. Gerratymake
27714fde40d9SSimon J. Gerratysyntax is difficult to parse.
2772ef0b2538SSimon J. GerratyFor instance, finding the end of a variable's use should involve scanning
2773ef0b2538SSimon J. Gerratyeach of the modifiers, using the correct terminator for each field.
277493036677SSimon J. GerratyIn many places
277593036677SSimon J. Gerratymake
277693036677SSimon J. Gerratyjust counts {} and () in order to find the end of a variable expansion.
277793036677SSimon J. Gerraty.Pp
277893036677SSimon J. GerratyThere is no way of escaping a space character in a filename.
27798c973ee2SSimon J. Gerraty.Pp
27808c973ee2SSimon J. GerratyIn jobs mode, when a target fails;
27818c973ee2SSimon J. Gerratymake
27828c973ee2SSimon J. Gerratywill put an error token into the job token pool.
27838c973ee2SSimon J. GerratyThis will cause all other instances of
27848c973ee2SSimon J. Gerratymake
27858c973ee2SSimon J. Gerratyusing that token pool to abort the build and exit with error code 6.
27868c973ee2SSimon J. GerratySometimes the attempt to suppress a cascade of unnecessary errors,
27878c973ee2SSimon J. Gerratycan result in a seemingly unexplained
27888c973ee2SSimon J. Gerraty.Ql *** Error code 6
2789