xref: /freebsd/contrib/bmake/bmake.1 (revision 988758838533b24f5893b36514fe2c68a3f911a2)
1*98875883SSimon J. Gerraty.\"	$NetBSD: make.1,v 1.371 2023/09/10 21:52:36 rillig 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*98875883SSimon J. Gerraty.Dd September 9, 2023
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.
270*98875883SSimon J. GerratyIf
271*98875883SSimon J. Gerraty.Ar max_jobs
272*98875883SSimon J. Gerratyis a floating point number, or ends with
273*98875883SSimon J. Gerraty.Ql C ,
274*98875883SSimon J. Gerratythen the value is multiplied by the number of CPUs reported online by
275*98875883SSimon 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 .
8824fde40d9SSimon J. Gerraty.It Va .ERROR_META_FILE
8834fde40d9SSimon J. GerratyIs used in error handling in
8844fde40d9SSimon J. Gerraty.Dq meta
8854fde40d9SSimon J. Gerratymode, see
8864fde40d9SSimon J. Gerraty.Va MAKE_PRINT_VAR_ON_ERROR .
8874fde40d9SSimon J. Gerraty.It Va .ERROR_TARGET
8884fde40d9SSimon J. GerratyIs used in error handling, see
8894fde40d9SSimon J. Gerraty.Va MAKE_PRINT_VAR_ON_ERROR .
8905bcb7424SSimon J. Gerraty.It Va .INCLUDEDFROMDIR
8914fde40d9SSimon J. GerratyThe directory of the file this makefile was included from.
8925bcb7424SSimon J. Gerraty.It Va .INCLUDEDFROMFILE
8934fde40d9SSimon J. GerratyThe filename of the file this makefile was included from.
8944fde40d9SSimon J. Gerraty.\" .INCLUDES is intentionally undocumented, as it is obsolete.
8954fde40d9SSimon J. Gerraty.\" .LIBS is intentionally undocumented, as it is obsolete.
8964fde40d9SSimon J. Gerraty.It Va MACHINE
8974fde40d9SSimon J. GerratyThe machine hardware name, see
8984fde40d9SSimon J. Gerraty.Xr uname 1 .
8994fde40d9SSimon J. Gerraty.It Va MACHINE_ARCH
9004fde40d9SSimon J. GerratyThe machine processor architecture name, see
9014fde40d9SSimon J. Gerraty.Xr uname 1 .
9024fde40d9SSimon J. Gerraty.It Va MAKE
9033955d011SMarcel MoolenaarThe name that
9043955d011SMarcel Moolenaar.Nm
9053955d011SMarcel Moolenaarwas executed with
9063955d011SMarcel Moolenaar.Pq Va argv[0] .
9074fde40d9SSimon J. Gerraty.It Va .MAKE
9084fde40d9SSimon J. GerratyThe same as
9094fde40d9SSimon J. Gerraty.Va MAKE ,
9104fde40d9SSimon J. Gerratyfor compatibility.
9113955d011SMarcel MoolenaarThe preferred variable to use is the environment variable
9123955d011SMarcel Moolenaar.Ev MAKE
9134fde40d9SSimon J. Gerratybecause it is more compatible with other make variants
9143955d011SMarcel Moolenaarand cannot be confused with the special target with the same name.
9154fde40d9SSimon J. Gerraty.\" '.MAKE.cmd_filtered' is intentionally undocumented,
9164fde40d9SSimon J. Gerraty.\" as it is an internal implementation detail.
9173955d011SMarcel Moolenaar.It Va .MAKE.DEPENDFILE
9183955d011SMarcel MoolenaarNames the makefile (default
919954401e6SSimon J. Gerraty.Sq Pa .depend )
9203955d011SMarcel Moolenaarfrom which generated dependencies are read.
9214fde40d9SSimon J. Gerraty.It Va .MAKE.DIE_QUIETLY
9224fde40d9SSimon J. GerratyIf set to
9234fde40d9SSimon J. Gerraty.Ql true ,
9244fde40d9SSimon J. Gerratydo not print error information at the end.
9253955d011SMarcel Moolenaar.It Va .MAKE.EXPAND_VARIABLES
9263955d011SMarcel MoolenaarA boolean that controls the default behavior of the
9273955d011SMarcel Moolenaar.Fl V
9283955d011SMarcel Moolenaaroption.
9298695518cSSimon J. GerratyIf true, variable values printed with
9308695518cSSimon J. Gerraty.Fl V
9318695518cSSimon J. Gerratyare fully expanded; if false, the raw variable contents (which may
9328695518cSSimon J. Gerratyinclude additional unexpanded variable references) are shown.
9333955d011SMarcel Moolenaar.It Va .MAKE.EXPORTED
9343955d011SMarcel MoolenaarThe list of variables exported by
9353955d011SMarcel Moolenaar.Nm .
9364fde40d9SSimon J. Gerraty.It Va MAKEFILE
9374fde40d9SSimon J. GerratyThe top-level makefile that is currently read,
9384fde40d9SSimon J. Gerratyas given in the command line.
9394fde40d9SSimon J. Gerraty.It Va .MAKEFLAGS
9403955d011SMarcel MoolenaarThe environment variable
941954401e6SSimon J. Gerraty.Sq Ev MAKEFLAGS
9423955d011SMarcel Moolenaarmay contain anything that
9433955d011SMarcel Moolenaarmay be specified on
9443955d011SMarcel Moolenaar.Nm Ns 's
9453955d011SMarcel Moolenaarcommand line.
9463955d011SMarcel MoolenaarAnything specified on
9473955d011SMarcel Moolenaar.Nm Ns 's
9483955d011SMarcel Moolenaarcommand line is appended to the
9494fde40d9SSimon J. Gerraty.Va .MAKEFLAGS
9504fde40d9SSimon J. Gerratyvariable, which is then added to the environment for all programs that
9513955d011SMarcel Moolenaar.Nm
9523955d011SMarcel Moolenaarexecutes.
9534fde40d9SSimon J. Gerraty.It Va .MAKE.GID
9544fde40d9SSimon J. GerratyThe numeric group ID of the user running
9554fde40d9SSimon J. Gerraty.Nm .
9564fde40d9SSimon J. GerratyIt is read-only.
9574fde40d9SSimon J. Gerraty.It Va .MAKE.JOB.PREFIX
9584fde40d9SSimon J. GerratyIf
9594fde40d9SSimon J. Gerraty.Nm
9604fde40d9SSimon J. Gerratyis run with
9614fde40d9SSimon J. Gerraty.Fl j ,
9624fde40d9SSimon J. Gerratythe output for each target is prefixed with a token
9634fde40d9SSimon J. Gerraty.Dl --- Ar target Li ---
9644fde40d9SSimon J. Gerratythe first part of which can be controlled via
9654fde40d9SSimon J. Gerraty.Va .MAKE.JOB.PREFIX .
9664fde40d9SSimon J. GerratyIf
9674fde40d9SSimon J. Gerraty.Va .MAKE.JOB.PREFIX
9684fde40d9SSimon J. Gerratyis empty, no token is printed.
9694fde40d9SSimon J. GerratyFor example, setting
9704fde40d9SSimon J. Gerraty.Va .MAKE.JOB.PREFIX
9714fde40d9SSimon J. Gerratyto
9724fde40d9SSimon J. Gerraty.Ql ${.newline}---${.MAKE:T}[${.MAKE.PID}]
9734fde40d9SSimon J. Gerratywould produce tokens like
9744fde40d9SSimon J. Gerraty.Dl ---make[1234] Ar target Li ---
9754fde40d9SSimon J. Gerratymaking it easier to track the degree of parallelism being achieved.
9764fde40d9SSimon J. Gerraty.It Va .MAKE.JOBS
9774fde40d9SSimon J. GerratyThe argument to the
9784fde40d9SSimon J. Gerraty.Fl j
9794fde40d9SSimon J. Gerratyoption.
980*98875883SSimon J. Gerraty.It Va .MAKE.JOBS.C
981*98875883SSimon J. GerratyA read-only boolean that indicates whether the
982*98875883SSimon J. Gerraty.Fl j
983*98875883SSimon J. Gerratyoption supports use of
984*98875883SSimon J. Gerraty.Ql C .
9853955d011SMarcel Moolenaar.It Va .MAKE.LEVEL
9863955d011SMarcel MoolenaarThe recursion depth of
9873955d011SMarcel Moolenaar.Nm .
9884fde40d9SSimon J. GerratyThe top-level instance of
9893955d011SMarcel Moolenaar.Nm
9904fde40d9SSimon J. Gerratyhas level 0, and each child make has its parent level plus 1.
9913955d011SMarcel MoolenaarThis allows tests like:
9923955d011SMarcel Moolenaar.Li .if ${.MAKE.LEVEL} == 0
9934fde40d9SSimon J. Gerratyto protect things which should only be evaluated in the top-level instance of
9944fde40d9SSimon J. Gerraty.Nm .
9954fde40d9SSimon J. Gerraty.It Va .MAKE.LEVEL.ENV
9964fde40d9SSimon J. GerratyThe name of the environment variable that stores the level of nested calls to
9973955d011SMarcel Moolenaar.Nm .
9983955d011SMarcel Moolenaar.It Va .MAKE.MAKEFILE_PREFERENCE
9993955d011SMarcel MoolenaarThe ordered list of makefile names
10003955d011SMarcel Moolenaar(default
1001954401e6SSimon J. Gerraty.Sq Pa makefile ,
1002954401e6SSimon J. Gerraty.Sq Pa Makefile )
10033955d011SMarcel Moolenaarthat
10043955d011SMarcel Moolenaar.Nm
10054fde40d9SSimon J. Gerratylooks for.
10063955d011SMarcel Moolenaar.It Va .MAKE.MAKEFILES
10073955d011SMarcel MoolenaarThe list of makefiles read by
10083955d011SMarcel Moolenaar.Nm ,
10093955d011SMarcel Moolenaarwhich is useful for tracking dependencies.
10103955d011SMarcel MoolenaarEach makefile is recorded only once, regardless of the number of times read.
10113955d011SMarcel Moolenaar.It Va .MAKE.META.BAILIWICK
10124fde40d9SSimon J. GerratyIn
10134fde40d9SSimon J. Gerraty.Dq meta
10144fde40d9SSimon J. Gerratymode, provides a list of prefixes which
10153955d011SMarcel Moolenaarmatch the directories controlled by
10163955d011SMarcel Moolenaar.Nm .
10173955d011SMarcel MoolenaarIf a file that was generated outside of
10183955d011SMarcel Moolenaar.Va .OBJDIR
10193955d011SMarcel Moolenaarbut within said bailiwick is missing,
10203955d011SMarcel Moolenaarthe current target is considered out-of-date.
10219f45a3c8SSimon J. Gerraty.It Va .MAKE.META.CMP_FILTER
10224fde40d9SSimon J. GerratyIn
10234fde40d9SSimon J. Gerraty.Dq meta
10244fde40d9SSimon J. Gerratymode, it can (very rarely!) be useful to filter command
10259f45a3c8SSimon J. Gerratylines before comparison.
10264fde40d9SSimon J. GerratyThis variable can be set to a set of modifiers that are applied to
10279f45a3c8SSimon J. Gerratyeach line of the old and new command that differ, if the filtered
10289f45a3c8SSimon J. Gerratycommands still differ, the target is considered out-of-date.
10293955d011SMarcel Moolenaar.It Va .MAKE.META.CREATED
10304fde40d9SSimon J. GerratyIn
10314fde40d9SSimon J. Gerraty.Dq meta
10324fde40d9SSimon J. Gerratymode, this variable contains a list of all the meta files
10333955d011SMarcel Moolenaarupdated.
10343955d011SMarcel MoolenaarIf not empty, it can be used to trigger processing of
10353955d011SMarcel Moolenaar.Va .MAKE.META.FILES .
10363955d011SMarcel Moolenaar.It Va .MAKE.META.FILES
10374fde40d9SSimon J. GerratyIn
10384fde40d9SSimon J. Gerraty.Dq meta
10394fde40d9SSimon J. Gerratymode, this variable contains a list of all the meta files
10403955d011SMarcel Moolenaarused (updated or not).
10413955d011SMarcel MoolenaarThis list can be used to process the meta files to extract dependency
10423955d011SMarcel Moolenaarinformation.
10434fde40d9SSimon J. Gerraty.It Va .MAKE.META.IGNORE_FILTER
10444fde40d9SSimon J. GerratyProvides a list of variable modifiers to apply to each pathname.
10454fde40d9SSimon J. GerratyIgnore if the expansion is an empty string.
104651ee2c1cSSimon J. Gerraty.It Va .MAKE.META.IGNORE_PATHS
104751ee2c1cSSimon J. GerratyProvides a list of path prefixes that should be ignored;
104851ee2c1cSSimon J. Gerratybecause the contents are expected to change over time.
104951ee2c1cSSimon J. GerratyThe default list includes:
1050954401e6SSimon J. Gerraty.Sq Pa /dev /etc /proc /tmp /var/run /var/tmp
1051e48f47ddSSimon J. Gerraty.It Va .MAKE.META.IGNORE_PATTERNS
1052e48f47ddSSimon J. GerratyProvides a list of patterns to match against pathnames.
1053e48f47ddSSimon J. GerratyIgnore any that match.
10543955d011SMarcel Moolenaar.It Va .MAKE.META.PREFIX
10554fde40d9SSimon J. GerratyDefines the message printed for each meta file updated in
10564fde40d9SSimon J. Gerraty.Dq meta verbose
10574fde40d9SSimon J. Gerratymode.
10583955d011SMarcel MoolenaarThe default value is:
10593955d011SMarcel Moolenaar.Dl Building ${.TARGET:H:tA}/${.TARGET:T}
10604fde40d9SSimon J. Gerraty.It Va .MAKE.MODE
10614fde40d9SSimon J. GerratyProcessed after reading all makefiles.
10624fde40d9SSimon J. GerratyAffects the mode that
10634fde40d9SSimon J. Gerraty.Nm
10644fde40d9SSimon J. Gerratyruns in.
10654fde40d9SSimon J. GerratyIt can contain these keywords:
10664fde40d9SSimon J. Gerraty.Bl -tag -width indent
10674fde40d9SSimon J. Gerraty.It Cm compat
10684fde40d9SSimon J. GerratyLike
10694fde40d9SSimon J. Gerraty.Fl B ,
10704fde40d9SSimon J. Gerratyputs
10714fde40d9SSimon J. Gerraty.Nm
10724fde40d9SSimon J. Gerratyinto
10734fde40d9SSimon J. Gerraty.Dq compat
10744fde40d9SSimon J. Gerratymode.
10754fde40d9SSimon J. Gerraty.It Cm meta
10764fde40d9SSimon J. GerratyPuts
10774fde40d9SSimon J. Gerraty.Nm
10784fde40d9SSimon J. Gerratyinto
10794fde40d9SSimon J. Gerraty.Dq meta
10804fde40d9SSimon J. Gerratymode, where meta files are created for each target
10814fde40d9SSimon J. Gerratyto capture the command run, the output generated, and if
10824fde40d9SSimon J. Gerraty.Xr filemon 4
10834fde40d9SSimon J. Gerratyis available, the system calls which are of interest to
10844fde40d9SSimon J. Gerraty.Nm .
10854fde40d9SSimon J. GerratyThe captured output can be useful when diagnosing errors.
10864fde40d9SSimon J. Gerraty.It Cm curdirOk= Ns Ar bf
10874fde40d9SSimon J. GerratyBy default,
10884fde40d9SSimon J. Gerraty.Nm
10894fde40d9SSimon J. Gerratydoes not create
10904fde40d9SSimon J. Gerraty.Pa .meta
10914fde40d9SSimon J. Gerratyfiles in
10924fde40d9SSimon J. Gerraty.Sq Va .CURDIR .
10934fde40d9SSimon J. GerratyThis can be overridden by setting
10944fde40d9SSimon J. Gerraty.Ar bf
10954fde40d9SSimon J. Gerratyto a value which represents true.
10964fde40d9SSimon J. Gerraty.It Cm missing-meta= Ns Ar bf
10974fde40d9SSimon J. GerratyIf
10984fde40d9SSimon J. Gerraty.Ar bf
10994fde40d9SSimon J. Gerratyis true, a missing
11004fde40d9SSimon J. Gerraty.Pa .meta
11014fde40d9SSimon J. Gerratyfile makes the target out-of-date.
11024fde40d9SSimon J. Gerraty.It Cm missing-filemon= Ns Ar bf
11034fde40d9SSimon J. GerratyIf
11044fde40d9SSimon J. Gerraty.Ar bf
11054fde40d9SSimon J. Gerratyis true, missing filemon data makes the target out-of-date.
11064fde40d9SSimon J. Gerraty.It Cm nofilemon
11074fde40d9SSimon J. GerratyDo not use
11084fde40d9SSimon J. Gerraty.Xr filemon 4 .
11094fde40d9SSimon J. Gerraty.It Cm env
11104fde40d9SSimon J. GerratyFor debugging, it can be useful to include the environment
11114fde40d9SSimon J. Gerratyin the
11124fde40d9SSimon J. Gerraty.Pa .meta
11134fde40d9SSimon J. Gerratyfile.
11144fde40d9SSimon J. Gerraty.It Cm verbose
11154fde40d9SSimon J. GerratyIf in
11164fde40d9SSimon J. Gerraty.Dq meta
11174fde40d9SSimon J. Gerratymode, print a clue about the target being built.
11184fde40d9SSimon J. GerratyThis is useful if the build is otherwise running silently.
11194fde40d9SSimon J. GerratyThe message printed is the expanded value of
11204fde40d9SSimon J. Gerraty.Va .MAKE.META.PREFIX .
11214fde40d9SSimon J. Gerraty.It Cm ignore-cmd
11224fde40d9SSimon J. GerratySome makefiles have commands which are simply not stable.
11234fde40d9SSimon J. GerratyThis keyword causes them to be ignored for
11244fde40d9SSimon J. Gerratydetermining whether a target is out of date in
11254fde40d9SSimon J. Gerraty.Dq meta
11264fde40d9SSimon J. Gerratymode.
11274fde40d9SSimon J. GerratySee also
11284fde40d9SSimon J. Gerraty.Ic .NOMETA_CMP .
11294fde40d9SSimon J. Gerraty.It Cm silent= Ns Ar bf
11304fde40d9SSimon J. GerratyIf
11314fde40d9SSimon J. Gerraty.Ar bf
11324fde40d9SSimon J. Gerratyis true, when a .meta file is created, mark the target
11334fde40d9SSimon J. Gerraty.Ic .SILENT .
11344fde40d9SSimon J. Gerraty.It Cm randomize-targets
11354fde40d9SSimon J. GerratyIn both compat and parallel mode, do not make the targets in the usual order,
11364fde40d9SSimon J. Gerratybut instead randomize their order.
11374fde40d9SSimon J. GerratyThis mode can be used to detect undeclared dependencies between files.
11384fde40d9SSimon J. Gerraty.El
11394fde40d9SSimon J. Gerraty.It Va MAKEOBJDIR
11404fde40d9SSimon J. GerratyUsed to create files in a separate directory, see
11414fde40d9SSimon J. Gerraty.Va .OBJDIR .
11424fde40d9SSimon J. Gerraty.It Va MAKE_OBJDIR_CHECK_WRITABLE
11434fde40d9SSimon J. GerratyUsed to force a separate directory for the created files,
11444fde40d9SSimon J. Gerratyeven if that directory is not writable, see
11454fde40d9SSimon J. Gerraty.Va .OBJDIR .
11464fde40d9SSimon J. Gerraty.It Va MAKEOBJDIRPREFIX
11474fde40d9SSimon J. GerratyUsed to create files in a separate directory, see
11484fde40d9SSimon J. Gerraty.Va .OBJDIR .
11494fde40d9SSimon J. Gerraty.It Va .MAKE.OS
11504fde40d9SSimon J. GerratyThe name of the operating system, see
11514fde40d9SSimon J. Gerraty.Xr uname 1 .
11524fde40d9SSimon J. GerratyIt is read-only.
11533955d011SMarcel Moolenaar.It Va .MAKEOVERRIDES
11543955d011SMarcel MoolenaarThis variable is used to record the names of variables assigned to
11553955d011SMarcel Moolenaaron the command line, so that they may be exported as part of
1156954401e6SSimon J. Gerraty.Sq Ev MAKEFLAGS .
1157be19d90bSSimon J. GerratyThis behavior can be disabled by assigning an empty value to
1158954401e6SSimon J. Gerraty.Sq Va .MAKEOVERRIDES
11593955d011SMarcel Moolenaarwithin a makefile.
11603955d011SMarcel MoolenaarExtra variables can be exported from a makefile
11613955d011SMarcel Moolenaarby appending their names to
1162954401e6SSimon J. Gerraty.Sq Va .MAKEOVERRIDES .
1163954401e6SSimon J. Gerraty.Sq Ev MAKEFLAGS
11643955d011SMarcel Moolenaaris re-exported whenever
1165954401e6SSimon J. Gerraty.Sq Va .MAKEOVERRIDES
11663955d011SMarcel Moolenaaris modified.
11671748de26SSimon J. Gerraty.It Va .MAKE.PATH_FILEMON
11681748de26SSimon J. GerratyIf
11691748de26SSimon J. Gerraty.Nm
11701748de26SSimon J. Gerratywas built with
11711748de26SSimon J. Gerraty.Xr filemon 4
11721748de26SSimon J. Gerratysupport, this is set to the path of the device node.
11731748de26SSimon J. GerratyThis allows makefiles to test for this support.
11743955d011SMarcel Moolenaar.It Va .MAKE.PID
11754fde40d9SSimon J. GerratyThe process ID of
11763955d011SMarcel Moolenaar.Nm .
11774fde40d9SSimon J. GerratyIt is read-only.
11783955d011SMarcel Moolenaar.It Va .MAKE.PPID
11794fde40d9SSimon J. GerratyThe parent process ID of
11803955d011SMarcel Moolenaar.Nm .
11814fde40d9SSimon J. GerratyIt is read-only.
11824fde40d9SSimon J. Gerraty.It Va MAKE_PRINT_VAR_ON_ERROR
11834fde40d9SSimon J. GerratyWhen
11844fde40d9SSimon J. Gerraty.Nm
11854fde40d9SSimon J. Gerratystops due to an error, it sets
11864fde40d9SSimon J. Gerraty.Sq Va .ERROR_TARGET
11874fde40d9SSimon J. Gerratyto the name of the target that failed,
11884fde40d9SSimon J. Gerraty.Sq Va .ERROR_CMD
11894fde40d9SSimon J. Gerratyto the commands of the failed target,
11904fde40d9SSimon J. Gerratyand in
11914fde40d9SSimon J. Gerraty.Dq meta
11924fde40d9SSimon J. Gerratymode, it also sets
11934fde40d9SSimon J. Gerraty.Sq Va .ERROR_CWD
11944fde40d9SSimon J. Gerratyto the
11954fde40d9SSimon J. Gerraty.Xr getcwd 3 ,
11964fde40d9SSimon J. Gerratyand
11974fde40d9SSimon J. Gerraty.Sq Va .ERROR_META_FILE
11984fde40d9SSimon J. Gerratyto the path of the meta file (if any) describing the failed target.
11994fde40d9SSimon J. GerratyIt then prints its name and the value of
12004fde40d9SSimon J. Gerraty.Sq Va .CURDIR
12014fde40d9SSimon J. Gerratyas well as the value of any variables named in
12024fde40d9SSimon J. Gerraty.Sq Va MAKE_PRINT_VAR_ON_ERROR .
1203be19d90bSSimon J. Gerraty.It Va .MAKE.SAVE_DOLLARS
12044fde40d9SSimon J. GerratyIf true,
1205be19d90bSSimon J. Gerraty.Ql $$
1206be19d90bSSimon J. Gerratyare preserved when doing
1207be19d90bSSimon J. Gerraty.Ql :=
1208be19d90bSSimon J. Gerratyassignments.
1209be19d90bSSimon J. GerratyThe default is false, for backwards compatibility.
1210be19d90bSSimon J. GerratySet to true for compatability with other makes.
1211be19d90bSSimon J. GerratyIf set to false,
1212be19d90bSSimon J. Gerraty.Ql $$
1213be19d90bSSimon J. Gerratybecomes
1214be19d90bSSimon J. Gerraty.Ql $
1215be19d90bSSimon J. Gerratyper normal evaluation rules.
12164fde40d9SSimon J. Gerraty.It Va .MAKE.TARGET_LOCAL_VARIABLES
12174fde40d9SSimon J. GerratyIf set to
12184fde40d9SSimon J. Gerraty.Ql false ,
12194fde40d9SSimon J. Gerratyapparent variable assignments in dependency lines are
12204fde40d9SSimon J. Gerratytreated as normal sources.
122106b9b3e0SSimon J. Gerraty.It Va .MAKE.UID
12224fde40d9SSimon J. GerratyThe numeric ID of the user running
122306b9b3e0SSimon J. Gerraty.Nm .
12244fde40d9SSimon J. GerratyIt is read-only.
12254fde40d9SSimon J. Gerraty.\" 'MAKE_VERSION' is intentionally undocumented
12264fde40d9SSimon J. Gerraty.\" since it is only defined in the bmake distribution,
12274fde40d9SSimon J. Gerraty.\" but not in NetBSD's native make.
12284fde40d9SSimon J. Gerraty.\" '.meta.%d.lcwd' is intentionally undocumented
12294fde40d9SSimon J. Gerraty.\" since it is an internal implementation detail.
12304fde40d9SSimon J. Gerraty.\" '.meta.%d.ldir' is intentionally undocumented
12314fde40d9SSimon J. Gerraty.\" since it is an internal implementation detail.
12324fde40d9SSimon J. Gerraty.\" 'MFLAGS' is intentionally undocumented
12334fde40d9SSimon J. Gerraty.\" since it is obsolete.
12343955d011SMarcel Moolenaar.It Va .newline
12353955d011SMarcel MoolenaarThis variable is simply assigned a newline character as its value.
12364fde40d9SSimon J. GerratyIt is read-only.
12373955d011SMarcel MoolenaarThis allows expansions using the
12383955d011SMarcel Moolenaar.Cm \&:@
12393955d011SMarcel Moolenaarmodifier to put a newline between
12403955d011SMarcel Moolenaariterations of the loop rather than a space.
12414fde40d9SSimon J. GerratyFor example, in case of an error,
12424fde40d9SSimon J. Gerraty.Nm
12434fde40d9SSimon J. Gerratyprints the variable names and their values using:
12444fde40d9SSimon J. Gerraty.Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
12453955d011SMarcel Moolenaar.It Va .OBJDIR
12463955d011SMarcel MoolenaarA path to the directory where the targets are built.
12473955d011SMarcel MoolenaarIts value is determined by trying to
12483955d011SMarcel Moolenaar.Xr chdir 2
12493955d011SMarcel Moolenaarto the following directories in order and using the first match:
12503955d011SMarcel Moolenaar.Bl -enum
12513955d011SMarcel Moolenaar.It
12524fde40d9SSimon J. Gerraty.Cm ${MAKEOBJDIRPREFIX} Ns Cm ${.CURDIR}
12533955d011SMarcel Moolenaar.Pp
12543955d011SMarcel Moolenaar(Only if
1255954401e6SSimon J. Gerraty.Sq Ev MAKEOBJDIRPREFIX
12563955d011SMarcel Moolenaaris set in the environment or on the command line.)
12573955d011SMarcel Moolenaar.It
12584fde40d9SSimon J. Gerraty.Cm ${MAKEOBJDIR}
12593955d011SMarcel Moolenaar.Pp
12603955d011SMarcel Moolenaar(Only if
1261954401e6SSimon J. Gerraty.Sq Ev MAKEOBJDIR
12623955d011SMarcel Moolenaaris set in the environment or on the command line.)
12633955d011SMarcel Moolenaar.It
12644fde40d9SSimon J. Gerraty.Cm ${.CURDIR} Ns Pa /obj. Ns Cm ${MACHINE}
12653955d011SMarcel Moolenaar.It
12664fde40d9SSimon J. Gerraty.Cm ${.CURDIR} Ns Pa /obj
12673955d011SMarcel Moolenaar.It
12684fde40d9SSimon J. Gerraty.Pa /usr/obj/ Ns Cm ${.CURDIR}
12693955d011SMarcel Moolenaar.It
12704fde40d9SSimon J. Gerraty.Cm ${.CURDIR}
12713955d011SMarcel Moolenaar.El
12723955d011SMarcel Moolenaar.Pp
12734fde40d9SSimon J. GerratyVariable expansion is performed on the value before it is used,
12743955d011SMarcel Moolenaarso expressions such as
12754fde40d9SSimon J. Gerraty.Cm ${.CURDIR:S,^/usr/src,/var/obj,}
12763955d011SMarcel Moolenaarmay be used.
12773955d011SMarcel MoolenaarThis is especially useful with
1278954401e6SSimon J. Gerraty.Sq Ev MAKEOBJDIR .
12793955d011SMarcel Moolenaar.Pp
1280954401e6SSimon J. Gerraty.Sq Va .OBJDIR
1281128a4105SSimon J. Gerratymay be modified in the makefile via the special target
1282954401e6SSimon J. Gerraty.Sq Ic .OBJDIR .
12833955d011SMarcel MoolenaarIn all cases,
12843955d011SMarcel Moolenaar.Nm
12854fde40d9SSimon J. Gerratychanges to the specified directory if it exists, and sets
1286954401e6SSimon J. Gerraty.Sq Va .OBJDIR
1287128a4105SSimon J. Gerratyand
12884fde40d9SSimon J. Gerraty.Sq Va PWD
12893955d011SMarcel Moolenaarto that directory before executing any targets.
1290e2eeea75SSimon J. Gerraty.Pp
1291e2eeea75SSimon J. GerratyExcept in the case of an explicit
1292954401e6SSimon J. Gerraty.Sq Ic .OBJDIR
1293e2eeea75SSimon J. Gerratytarget,
1294e2eeea75SSimon J. Gerraty.Nm
12954fde40d9SSimon J. Gerratychecks that the specified directory is writable and ignores it if not.
1296e2eeea75SSimon J. GerratyThis check can be skipped by setting the environment variable
1297954401e6SSimon J. Gerraty.Sq Ev MAKE_OBJDIR_CHECK_WRITABLE
12984fde40d9SSimon J. Gerratyto
12994fde40d9SSimon J. Gerraty.Dq no .
13003955d011SMarcel Moolenaar.It Va .PARSEDIR
13014fde40d9SSimon J. GerratyThe directory name of the current makefile being parsed.
13023955d011SMarcel Moolenaar.It Va .PARSEFILE
13034fde40d9SSimon J. GerratyThe basename of the current makefile being parsed.
13043955d011SMarcel MoolenaarThis variable and
1305954401e6SSimon J. Gerraty.Sq Va .PARSEDIR
13064fde40d9SSimon J. Gerratyare both set only while the makefiles are being parsed.
13074fde40d9SSimon J. GerratyTo retain their current values,
13084fde40d9SSimon J. Gerratyassign them to a variable using assignment with expansion
1309954401e6SSimon J. Gerraty.Sq Cm \&:= .
13103955d011SMarcel Moolenaar.It Va .PATH
13114fde40d9SSimon J. GerratyThe space-separated list of directories that
13123955d011SMarcel Moolenaar.Nm
13134fde40d9SSimon J. Gerratysearches for files.
13144fde40d9SSimon J. GerratyTo update this search list, use the special target
13154fde40d9SSimon J. Gerraty.Sq Ic .PATH
13164fde40d9SSimon J. Gerratyrather than modifying the variable directly.
13174fde40d9SSimon J. Gerraty.It Va %POSIX
13184fde40d9SSimon J. GerratyIs set in POSIX mode, see the special
13194fde40d9SSimon J. Gerraty.Ql Va .POSIX
13204fde40d9SSimon J. Gerratytarget.
13214fde40d9SSimon J. Gerraty.\" XXX: There is no make variable named 'PWD',
13224fde40d9SSimon J. Gerraty.\" XXX: make only reads and writes the environment variable 'PWD'.
13234fde40d9SSimon J. Gerraty.It Va PWD
13243955d011SMarcel MoolenaarAlternate path to the current directory.
13253955d011SMarcel Moolenaar.Nm
13263955d011SMarcel Moolenaarnormally sets
1327954401e6SSimon J. Gerraty.Sq Va .CURDIR
13283955d011SMarcel Moolenaarto the canonical path given by
13293955d011SMarcel Moolenaar.Xr getcwd 3 .
13303955d011SMarcel MoolenaarHowever, if the environment variable
1331954401e6SSimon J. Gerraty.Sq Ev PWD
13324fde40d9SSimon J. Gerratyis set and gives a path to the current directory,
13333955d011SMarcel Moolenaar.Nm
13343955d011SMarcel Moolenaarsets
1335954401e6SSimon J. Gerraty.Sq Va .CURDIR
13363955d011SMarcel Moolenaarto the value of
1337954401e6SSimon J. Gerraty.Sq Ev PWD
13383955d011SMarcel Moolenaarinstead.
1339be19d90bSSimon J. GerratyThis behavior is disabled if
1340954401e6SSimon J. Gerraty.Sq Ev MAKEOBJDIRPREFIX
13413955d011SMarcel Moolenaaris set or
1342954401e6SSimon J. Gerraty.Sq Ev MAKEOBJDIR
13433955d011SMarcel Moolenaarcontains a variable transform.
13444fde40d9SSimon J. Gerraty.Sq Va PWD
13453955d011SMarcel Moolenaaris set to the value of
1346954401e6SSimon J. Gerraty.Sq Va .OBJDIR
13473955d011SMarcel Moolenaarfor all programs which
13483955d011SMarcel Moolenaar.Nm
13493955d011SMarcel Moolenaarexecutes.
13504fde40d9SSimon J. Gerraty.It Va .SHELL
13512c3632d1SSimon J. GerratyThe pathname of the shell used to run target scripts.
13522c3632d1SSimon J. GerratyIt is read-only.
13534fde40d9SSimon J. Gerraty.It Va .SUFFIXES
135412904384SSimon J. GerratyThe list of known suffixes.
135512904384SSimon J. GerratyIt is read-only.
13564fde40d9SSimon J. Gerraty.It Va .SYSPATH
13574fde40d9SSimon J. GerratyThe space-separated list of directories that
13583955d011SMarcel Moolenaar.Nm
13594fde40d9SSimon J. Gerratysearches for makefiles, referred to as the system include path.
13604fde40d9SSimon J. GerratyTo update this search list, use the special target
13614fde40d9SSimon J. Gerraty.Sq Ic .SYSPATH
13624fde40d9SSimon J. Gerratyrather than modifying the variable which is read-only.
13634fde40d9SSimon J. Gerraty.It Va .TARGETS
13644fde40d9SSimon J. GerratyThe list of targets explicitly specified on the command line, if any.
13654fde40d9SSimon J. Gerraty.It Va VPATH
13664fde40d9SSimon J. GerratyThe colon-separated
13674fde40d9SSimon J. Gerraty.Pq Dq \&:
13684fde40d9SSimon J. Gerratylist of directories that
13694fde40d9SSimon J. Gerraty.Nm
13704fde40d9SSimon J. Gerratysearches for files.
13714fde40d9SSimon J. GerratyThis variable is supported for compatibility with old make programs only, use
1372954401e6SSimon J. Gerraty.Sq Va .PATH
13733955d011SMarcel Moolenaarinstead.
13743955d011SMarcel Moolenaar.El
13753955d011SMarcel Moolenaar.Ss Variable modifiers
13764fde40d9SSimon J. GerratyThe general format of a variable expansion is:
13773955d011SMarcel Moolenaar.Pp
13784fde40d9SSimon J. Gerraty.Sm off
13794fde40d9SSimon J. Gerraty.D1 Ic \&${ Ar variable\| Oo Ic \&: Ar modifier\| Oo Ic \&: No ... Oc Oc Ic \&}
13804fde40d9SSimon J. Gerraty.Sm on
13813955d011SMarcel Moolenaar.Pp
13824fde40d9SSimon J. GerratyEach modifier begins with a colon.
13834fde40d9SSimon J. GerratyTo escape a colon, precede it with a backslash
13844fde40d9SSimon J. Gerraty.Ql \e .
13853955d011SMarcel Moolenaar.Pp
13864fde40d9SSimon J. GerratyA list of indirect modifiers can be specified via a variable, as follows:
13873955d011SMarcel Moolenaar.Pp
13884fde40d9SSimon J. Gerraty.Bd -literal -offset indent
13894fde40d9SSimon J. Gerraty.Ar modifier_variable\^ Li \&= Ar modifier Ns Oo Ic \&: Ns No ... Oc
13904fde40d9SSimon J. Gerraty
13914fde40d9SSimon J. Gerraty.Sm off
13924fde40d9SSimon J. Gerraty.Ic \&${ Ar variable Ic \&:${ Ar modifier_variable Ic \&} Oo Ic \&: No ... Oc Ic \&}
13934fde40d9SSimon J. Gerraty.Sm on
13944fde40d9SSimon J. Gerraty.Ed
13953955d011SMarcel Moolenaar.Pp
13964fde40d9SSimon J. GerratyIn this case, the first modifier in the
13974fde40d9SSimon J. Gerraty.Ar modifier_variable
13984fde40d9SSimon J. Gerratydoes not start with a colon,
13994fde40d9SSimon J. Gerratysince that colon already occurs in the referencing variable.
14004fde40d9SSimon J. GerratyIf any of the modifiers in the
14014fde40d9SSimon J. Gerraty.Ar modifier_variable
14024fde40d9SSimon J. Gerratycontains a dollar sign
14033955d011SMarcel Moolenaar.Pq Ql $ ,
14043955d011SMarcel Moolenaarthese must be doubled to avoid early expansion.
14053955d011SMarcel Moolenaar.Pp
14064fde40d9SSimon J. GerratySome modifiers interpret the expression value as a single string,
14074fde40d9SSimon J. Gerratyothers treat the expression value as a whitespace-separated list of words.
14084fde40d9SSimon J. GerratyWhen splitting a string into words,
14094fde40d9SSimon J. Gerratywhitespace can be escaped using double quotes, single quotes and backslashes,
14104fde40d9SSimon J. Gerratylike in the shell.
14114fde40d9SSimon J. GerratyThe quotes and backslashes are retained in the words.
14124fde40d9SSimon J. Gerraty.Pp
14133955d011SMarcel MoolenaarThe supported modifiers are:
14143955d011SMarcel Moolenaar.Bl -tag -width EEE
14153955d011SMarcel Moolenaar.It Cm \&:E
14164fde40d9SSimon J. GerratyReplaces each word with its suffix.
14173955d011SMarcel Moolenaar.It Cm \&:H
14184fde40d9SSimon J. GerratyReplaces each word with its dirname.
1419954401e6SSimon J. Gerraty.It Cm \&:M\| Ns Ar pattern
14202c3632d1SSimon J. GerratySelects only those words that match
14213955d011SMarcel Moolenaar.Ar pattern .
14223955d011SMarcel MoolenaarThe standard shell wildcard characters
14233955d011SMarcel Moolenaar.Pf ( Ql * ,
14243955d011SMarcel Moolenaar.Ql \&? ,
14253955d011SMarcel Moolenaarand
1426954401e6SSimon J. Gerraty.Ql \&[] )
14273955d011SMarcel Moolenaarmay
14283955d011SMarcel Moolenaarbe used.
14293955d011SMarcel MoolenaarThe wildcard characters may be escaped with a backslash
14303955d011SMarcel Moolenaar.Pq Ql \e .
14310dede8b0SSimon J. GerratyAs a consequence of the way values are split into words, matched,
14324fde40d9SSimon J. Gerratyand then joined, the construct
14334fde40d9SSimon J. Gerraty.Ql ${VAR:M*}
14344fde40d9SSimon J. Gerratyremoves all leading and trailing whitespace
14354fde40d9SSimon J. Gerratyand normalizes the inter-word spacing to a single space.
1436954401e6SSimon J. Gerraty.It Cm \&:N\| Ns Ar pattern
14374fde40d9SSimon J. GerratyThis is the opposite of
1438954401e6SSimon J. Gerraty.Sq Cm \&:M ,
14394fde40d9SSimon J. Gerratyselecting all words which do
14404fde40d9SSimon J. Gerraty.Em not
14414fde40d9SSimon J. Gerratymatch
14423955d011SMarcel Moolenaar.Ar pattern .
14433955d011SMarcel Moolenaar.It Cm \&:O
14444fde40d9SSimon J. GerratyOrders the words lexicographically.
144512904384SSimon J. Gerraty.It Cm \&:On
14464fde40d9SSimon J. GerratyOrders the words numerically.
144712904384SSimon J. GerratyA number followed by one of
144812904384SSimon J. Gerraty.Ql k ,
144912904384SSimon J. Gerraty.Ql M
145012904384SSimon J. Gerratyor
145112904384SSimon J. Gerraty.Ql G
14524fde40d9SSimon J. Gerratyis multiplied by the appropriate factor, which is 1024 for
14534fde40d9SSimon J. Gerraty.Ql k ,
14544fde40d9SSimon J. Gerraty1048576 for
14554fde40d9SSimon J. Gerraty.Ql M ,
14564fde40d9SSimon J. Gerratyor 1073741824 for
14574fde40d9SSimon J. Gerraty.Ql G .
145812904384SSimon J. GerratyBoth upper- and lower-case letters are accepted.
1459ef0b2538SSimon J. Gerraty.It Cm \&:Or
14604fde40d9SSimon J. GerratyOrders the words in reverse lexicographical order.
146112904384SSimon J. Gerraty.It Cm \&:Orn
14624fde40d9SSimon J. GerratyOrders the words in reverse numerical order.
14633955d011SMarcel Moolenaar.It Cm \&:Ox
14644fde40d9SSimon J. GerratyShuffles the words.
14654fde40d9SSimon J. GerratyThe results are different each time you are referring to the
14663955d011SMarcel Moolenaarmodified variable; use the assignment with expansion
1467954401e6SSimon J. Gerraty.Sq Cm \&:=
1468be19d90bSSimon J. Gerratyto prevent such behavior.
14693955d011SMarcel MoolenaarFor example,
14703955d011SMarcel Moolenaar.Bd -literal -offset indent
14713955d011SMarcel MoolenaarLIST=			uno due tre quattro
14723955d011SMarcel MoolenaarRANDOM_LIST=		${LIST:Ox}
14733955d011SMarcel MoolenaarSTATIC_RANDOM_LIST:=	${LIST:Ox}
14743955d011SMarcel Moolenaar
14753955d011SMarcel Moolenaarall:
14763955d011SMarcel Moolenaar	@echo "${RANDOM_LIST}"
14773955d011SMarcel Moolenaar	@echo "${RANDOM_LIST}"
14783955d011SMarcel Moolenaar	@echo "${STATIC_RANDOM_LIST}"
14793955d011SMarcel Moolenaar	@echo "${STATIC_RANDOM_LIST}"
14803955d011SMarcel Moolenaar.Ed
14813955d011SMarcel Moolenaarmay produce output similar to:
14823955d011SMarcel Moolenaar.Bd -literal -offset indent
14833955d011SMarcel Moolenaarquattro due tre uno
14843955d011SMarcel Moolenaartre due quattro uno
14853955d011SMarcel Moolenaardue uno quattro tre
14863955d011SMarcel Moolenaardue uno quattro tre
14873955d011SMarcel Moolenaar.Ed
14883955d011SMarcel Moolenaar.It Cm \&:Q
14894fde40d9SSimon J. GerratyQuotes every shell meta-character in the value, so that it can be passed
14902eae894cSSimon J. Gerratysafely to the shell.
14912eae894cSSimon J. Gerraty.It Cm \&:q
14924fde40d9SSimon J. GerratyQuotes every shell meta-character in the value, and also doubles
14932eae894cSSimon J. Gerraty.Sq $
14942eae894cSSimon J. Gerratycharacters so that it can be passed
14953955d011SMarcel Moolenaarsafely through recursive invocations of
14963955d011SMarcel Moolenaar.Nm .
14974fde40d9SSimon J. GerratyThis is equivalent to
14984fde40d9SSimon J. Gerraty.Sq Cm \&:S/\e\&$/&&/g:Q .
14993955d011SMarcel Moolenaar.It Cm \&:R
15004fde40d9SSimon J. GerratyReplaces each word with everything but its suffix.
15014fde40d9SSimon J. Gerraty.It Cm \&:range Ns Oo Cm = Ns Ar count Oc
15021ce939a7SSimon J. GerratyThe value is an integer sequence representing the words of the original
15031ce939a7SSimon J. Gerratyvalue, or the supplied
15044fde40d9SSimon J. Gerraty.Ar count .
15054fde40d9SSimon J. Gerraty.It Cm \&:gmtime Ns Oo Cm = Ns Ar timestamp Oc
15064fde40d9SSimon J. GerratyThe value is interpreted as a format string for
15073955d011SMarcel Moolenaar.Xr strftime 3 ,
15081ce939a7SSimon J. Gerratyusing
15094fde40d9SSimon J. Gerraty.Xr gmtime 3 ,
15104fde40d9SSimon J. Gerratyproducing the formatted timestamp.
1511*98875883SSimon J. GerratyNote: the
1512*98875883SSimon J. Gerraty.Ql %s
1513*98875883SSimon J. Gerratyformat should only be used with
1514*98875883SSimon J. Gerraty.Sq Cm \&:localtime .
15151ce939a7SSimon J. GerratyIf a
15164fde40d9SSimon J. Gerraty.Ar timestamp
15171ce939a7SSimon J. Gerratyvalue is not provided or is 0, the current time is used.
15183955d011SMarcel Moolenaar.It Cm \&:hash
15194fde40d9SSimon J. GerratyComputes a 32-bit hash of the value and encodes it as 8 hex digits.
15204fde40d9SSimon J. Gerraty.It Cm \&:localtime 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 localtime 3 ,
15254fde40d9SSimon J. Gerratyproducing the formatted timestamp.
15261ce939a7SSimon J. GerratyIf a
15274fde40d9SSimon J. Gerraty.Ar timestamp
15281ce939a7SSimon J. Gerratyvalue is not provided or is 0, the current time is used.
1529c1d01b5fSSimon J. Gerraty.It Cm \&:mtime Ns Oo Cm = Ns Ar timestamp Oc
1530c1d01b5fSSimon J. GerratyCall
1531c1d01b5fSSimon J. Gerraty.Xr stat 2
1532c1d01b5fSSimon J. Gerratywith each word as pathname;
1533c1d01b5fSSimon J. Gerratyuse
1534c1d01b5fSSimon J. Gerraty.Ql st_mtime
1535c1d01b5fSSimon J. Gerratyas the new value.
1536c1d01b5fSSimon J. GerratyIf
1537c1d01b5fSSimon J. Gerraty.Xr stat 2
1538c1d01b5fSSimon J. Gerratyfails; use
1539c1d01b5fSSimon J. Gerraty.Ar timestamp
1540c1d01b5fSSimon J. Gerratyor current time.
1541c1d01b5fSSimon J. GerratyIf
1542c1d01b5fSSimon J. Gerraty.Ar timestamp
1543c1d01b5fSSimon J. Gerratyis set to
1544c1d01b5fSSimon J. Gerraty.Ql error ,
1545c1d01b5fSSimon J. Gerratythen
1546c1d01b5fSSimon J. Gerraty.Xr stat 2
1547c1d01b5fSSimon J. Gerratyfailure will cause an error.
15483955d011SMarcel Moolenaar.It Cm \&:tA
15494fde40d9SSimon J. GerratyAttempts to convert the value to an absolute path using
15504fde40d9SSimon J. Gerraty.Xr realpath 3 .
15514fde40d9SSimon J. GerratyIf that fails, the value is unchanged.
15523955d011SMarcel Moolenaar.It Cm \&:tl
15534fde40d9SSimon J. GerratyConverts the value to lower-case letters.
15543955d011SMarcel Moolenaar.It Cm \&:ts Ns Ar c
15554fde40d9SSimon J. GerratyWhen joining the words after a modifier that treats the value as words,
15564fde40d9SSimon J. Gerratythe words are normally separated by a space.
15574fde40d9SSimon J. GerratyThis modifier changes the separator to the character
15583955d011SMarcel Moolenaar.Ar c .
15593955d011SMarcel MoolenaarIf
15603955d011SMarcel Moolenaar.Ar c
15614fde40d9SSimon J. Gerratyis omitted, no separator is used.
15622c3632d1SSimon J. GerratyThe common escapes (including octal numeric codes) work as expected.
15633955d011SMarcel Moolenaar.It Cm \&:tu
15644fde40d9SSimon J. GerratyConverts the value to upper-case letters.
15653955d011SMarcel Moolenaar.It Cm \&:tW
15664fde40d9SSimon J. GerratyCauses subsequent modifiers to treat the value as a single word
15673955d011SMarcel Moolenaar(possibly containing embedded whitespace).
15683955d011SMarcel MoolenaarSee also
1569954401e6SSimon J. Gerraty.Sq Cm \&:[*] .
15703955d011SMarcel Moolenaar.It Cm \&:tw
15714fde40d9SSimon J. GerratyCauses the value to be treated as a list of words.
15723955d011SMarcel MoolenaarSee also
1573954401e6SSimon J. Gerraty.Sq Cm \&:[@] .
15743955d011SMarcel Moolenaar.Sm off
1575954401e6SSimon J. Gerraty.It Cm \&:S\| No \&/ Ar old_string\| No \&/ Ar new_string\| No \&/ Op Cm 1gW
15763955d011SMarcel Moolenaar.Sm on
15772c3632d1SSimon J. GerratyModifies the first occurrence of
15783955d011SMarcel Moolenaar.Ar old_string
15794fde40d9SSimon J. Gerratyin each word of the value, replacing it with
15803955d011SMarcel Moolenaar.Ar new_string .
15813955d011SMarcel MoolenaarIf a
15823955d011SMarcel Moolenaar.Ql g
15834fde40d9SSimon J. Gerratyis appended to the last delimiter of the pattern,
15844fde40d9SSimon J. Gerratyall occurrences in each word are replaced.
15853955d011SMarcel MoolenaarIf a
15863955d011SMarcel Moolenaar.Ql 1
15874fde40d9SSimon J. Gerratyis appended to the last delimiter of the pattern,
15884fde40d9SSimon J. Gerratyonly the first occurrence is affected.
15893955d011SMarcel MoolenaarIf a
15903955d011SMarcel Moolenaar.Ql W
15912c3632d1SSimon J. Gerratyis appended to the last delimiter of the pattern,
15924fde40d9SSimon J. Gerratythe value is treated as a single word.
15933955d011SMarcel MoolenaarIf
15943955d011SMarcel Moolenaar.Ar old_string
15953955d011SMarcel Moolenaarbegins with a caret
15963955d011SMarcel Moolenaar.Pq Ql ^ ,
15973955d011SMarcel Moolenaar.Ar old_string
15983955d011SMarcel Moolenaaris anchored at the beginning of each word.
15993955d011SMarcel MoolenaarIf
16003955d011SMarcel Moolenaar.Ar old_string
16013955d011SMarcel Moolenaarends with a dollar sign
16023955d011SMarcel Moolenaar.Pq Ql \&$ ,
16033955d011SMarcel Moolenaarit is anchored at the end of each word.
16043955d011SMarcel MoolenaarInside
16053955d011SMarcel Moolenaar.Ar new_string ,
16063955d011SMarcel Moolenaaran ampersand
16078695518cSSimon J. Gerraty.Pq Ql &
16083955d011SMarcel Moolenaaris replaced by
16093955d011SMarcel Moolenaar.Ar old_string
16104fde40d9SSimon J. Gerraty(without the anchoring
16113955d011SMarcel Moolenaar.Ql ^
16123955d011SMarcel Moolenaaror
16133955d011SMarcel Moolenaar.Ql \&$ ) .
16144fde40d9SSimon J. GerratyAny character may be used as the delimiter for the parts of the modifier
16153955d011SMarcel Moolenaarstring.
16164fde40d9SSimon J. GerratyThe anchoring, ampersand and delimiter characters can be escaped with a
16173955d011SMarcel Moolenaarbackslash
16183955d011SMarcel Moolenaar.Pq Ql \e .
16193955d011SMarcel Moolenaar.Pp
16204fde40d9SSimon J. GerratyBoth
16213955d011SMarcel Moolenaar.Ar old_string
16223955d011SMarcel Moolenaarand
16233955d011SMarcel Moolenaar.Ar new_string
16244fde40d9SSimon J. Gerratymay contain nested expressions.
16254fde40d9SSimon J. GerratyTo prevent a dollar sign from starting a nested expression,
16264fde40d9SSimon J. Gerratyescape it with a backslash.
16273955d011SMarcel Moolenaar.Sm off
1628954401e6SSimon J. Gerraty.It Cm \&:C\| No \&/ Ar pattern\| No \&/ Ar replacement\| No \&/ Op Cm 1gW
16293955d011SMarcel Moolenaar.Sm on
16303955d011SMarcel MoolenaarThe
16313955d011SMarcel Moolenaar.Cm \&:C
16324fde40d9SSimon J. Gerratymodifier works like the
16333955d011SMarcel Moolenaar.Cm \&:S
16343955d011SMarcel Moolenaarmodifier except that the old and new strings, instead of being
16354fde40d9SSimon J. Gerratysimple strings, are an extended regular expression
16363955d011SMarcel Moolenaar.Ar pattern
16374fde40d9SSimon J. Gerraty(see
16384fde40d9SSimon J. Gerraty.Xr regex 3 )
16393955d011SMarcel Moolenaarand an
16403955d011SMarcel Moolenaar.Xr ed 1 Ns \-style
16413955d011SMarcel Moolenaar.Ar replacement .
16423955d011SMarcel MoolenaarNormally, the first occurrence of the pattern
16433955d011SMarcel Moolenaar.Ar pattern
16443955d011SMarcel Moolenaarin each word of the value is substituted with
16453955d011SMarcel Moolenaar.Ar replacement .
16463955d011SMarcel MoolenaarThe
16473955d011SMarcel Moolenaar.Ql 1
16483955d011SMarcel Moolenaarmodifier causes the substitution to apply to at most one word; the
16493955d011SMarcel Moolenaar.Ql g
16503955d011SMarcel Moolenaarmodifier causes the substitution to apply to as many instances of the
16513955d011SMarcel Moolenaarsearch pattern
16523955d011SMarcel Moolenaar.Ar pattern
16533955d011SMarcel Moolenaaras occur in the word or words it is found in; the
16543955d011SMarcel Moolenaar.Ql W
16553955d011SMarcel Moolenaarmodifier causes the value to be treated as a single word
16563955d011SMarcel Moolenaar(possibly containing embedded whitespace).
16575bcb7424SSimon J. Gerraty.Pp
16585bcb7424SSimon J. GerratyAs for the
16595bcb7424SSimon J. Gerraty.Cm \&:S
16605bcb7424SSimon J. Gerratymodifier, the
16615bcb7424SSimon J. Gerraty.Ar pattern
16625bcb7424SSimon J. Gerratyand
16635bcb7424SSimon J. Gerraty.Ar replacement
16645bcb7424SSimon J. Gerratyare subjected to variable expansion before being parsed as
16655bcb7424SSimon J. Gerratyregular expressions.
16663955d011SMarcel Moolenaar.It Cm \&:T
16674fde40d9SSimon J. GerratyReplaces each word with its last path component (basename).
16683955d011SMarcel Moolenaar.It Cm \&:u
16692c3632d1SSimon J. GerratyRemoves adjacent duplicate words (like
16703955d011SMarcel Moolenaar.Xr uniq 1 ) .
16713955d011SMarcel Moolenaar.Sm off
1672954401e6SSimon J. Gerraty.It Cm \&:\&?\| Ar true_string\| Cm \&: Ar false_string
16733955d011SMarcel Moolenaar.Sm on
16744fde40d9SSimon J. GerratyIf the variable name (not its value), when parsed as a
16754fde40d9SSimon J. Gerraty.Cm .if
16764fde40d9SSimon J. Gerratyconditional expression, evaluates to true, return as its value the
16773955d011SMarcel Moolenaar.Ar true_string ,
16783955d011SMarcel Moolenaarotherwise return the
16793955d011SMarcel Moolenaar.Ar false_string .
16804fde40d9SSimon J. GerratySince the variable name is used as the expression,
16814fde40d9SSimon J. Gerraty\&:\&? must be the first modifier after the variable name
16824fde40d9SSimon J. Gerraty.No itself Ns \^\(em\^ Ns
16834fde40d9SSimon J. Gerratywhich, of course, usually contains variable expansions.
16843955d011SMarcel MoolenaarA common error is trying to use expressions like
16853955d011SMarcel Moolenaar.Dl ${NUMBERS:M42:?match:no}
16864fde40d9SSimon J. Gerratywhich actually tests defined(NUMBERS).
16874fde40d9SSimon J. GerratyTo determine if any words match
16884fde40d9SSimon J. Gerraty.Dq 42 ,
16894fde40d9SSimon J. Gerratyyou need to use something like:
16903955d011SMarcel Moolenaar.Dl ${"${NUMBERS:M42}" != \&"\&":?match:no} .
1691954401e6SSimon J. Gerraty.It Cm :\| Ns Ar old_string\| Ns Cm = Ns Ar new_string
16923955d011SMarcel MoolenaarThis is the
16933955d011SMarcel Moolenaar.At V
16944fde40d9SSimon J. Gerratystyle substitution.
16954fde40d9SSimon J. GerratyIt can only be the last modifier specified,
16964fde40d9SSimon J. Gerratyas a
16974fde40d9SSimon J. Gerraty.Ql \&:
16984fde40d9SSimon J. Gerratyin either
16994fde40d9SSimon J. Gerraty.Ar old_string
17004fde40d9SSimon J. Gerratyor
17014fde40d9SSimon J. Gerraty.Ar new_string
17024fde40d9SSimon J. Gerratyis treated as a regular character, not as the end of the modifier.
17034fde40d9SSimon J. Gerraty.Pp
17043955d011SMarcel MoolenaarIf
17053955d011SMarcel Moolenaar.Ar old_string
17064fde40d9SSimon J. Gerratydoes not contain the pattern matching character
17074fde40d9SSimon J. Gerraty.Ql % ,
17084fde40d9SSimon J. Gerratyand the word ends with
17093955d011SMarcel Moolenaar.Ar old_string
17104fde40d9SSimon J. Gerratyor equals it,
17114fde40d9SSimon J. Gerratythat suffix is replaced with
17123955d011SMarcel Moolenaar.Ar new_string .
17133955d011SMarcel Moolenaar.Pp
17144fde40d9SSimon J. GerratyOtherwise, the first
17154fde40d9SSimon J. Gerraty.Ql %
17164fde40d9SSimon J. Gerratyin
17174fde40d9SSimon J. Gerraty.Ar old_string
17184fde40d9SSimon J. Gerratymatches a possibly empty substring of arbitrary characters,
17194fde40d9SSimon J. Gerratyand if the whole pattern is found in the word,
17204fde40d9SSimon J. Gerratythe matching part is replaced with
17214fde40d9SSimon J. Gerraty.Ar new_string ,
17224fde40d9SSimon J. Gerratyand the first occurrence of
17234fde40d9SSimon J. Gerraty.Ql %
17244fde40d9SSimon J. Gerratyin
17254fde40d9SSimon J. Gerraty.Ar new_string
17264fde40d9SSimon J. Gerraty(if any) is replaced with the substring matched by the
17274fde40d9SSimon J. Gerraty.Ql % .
17284fde40d9SSimon J. Gerraty.Pp
17294fde40d9SSimon J. GerratyBoth
17303955d011SMarcel Moolenaar.Ar old_string
17313955d011SMarcel Moolenaarand
17323955d011SMarcel Moolenaar.Ar new_string
17334fde40d9SSimon J. Gerratymay contain nested expressions.
17344fde40d9SSimon J. GerratyTo prevent a dollar sign from starting a nested expression,
17354fde40d9SSimon J. Gerratyescape it with a backslash.
17363955d011SMarcel Moolenaar.Sm off
17374fde40d9SSimon J. Gerraty.It Cm \&:@ Ar varname\| Cm @ Ar string\| Cm @
17383955d011SMarcel Moolenaar.Sm on
17393955d011SMarcel MoolenaarThis is the loop expansion mechanism from the OSF Development
17403955d011SMarcel MoolenaarEnvironment (ODE) make.
17413955d011SMarcel MoolenaarUnlike
17423955d011SMarcel Moolenaar.Cm \&.for
17432c3632d1SSimon J. Gerratyloops, expansion occurs at the time of reference.
17444fde40d9SSimon J. GerratyFor each word in the value, assign the word to the variable named
17454fde40d9SSimon J. Gerraty.Ar varname
17464fde40d9SSimon J. Gerratyand evaluate
17473955d011SMarcel Moolenaar.Ar string .
17483955d011SMarcel MoolenaarThe ODE convention is that
17494fde40d9SSimon J. Gerraty.Ar varname
17504fde40d9SSimon J. Gerratyshould start and end with a period, for example:
17513955d011SMarcel Moolenaar.Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
17523955d011SMarcel Moolenaar.Pp
17534fde40d9SSimon J. GerratyHowever, a single-letter variable is often more readable:
17543955d011SMarcel Moolenaar.Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
1755954401e6SSimon J. Gerraty.It Cm \&:_ Ns Oo Cm = Ns Ar var Oc
17562c3632d1SSimon J. GerratySaves the current variable value in
17571ce939a7SSimon J. Gerraty.Ql $_
17581ce939a7SSimon J. Gerratyor the named
17594fde40d9SSimon J. Gerraty.Ar var
17601ce939a7SSimon J. Gerratyfor later reference.
17611ce939a7SSimon J. GerratyExample usage:
17621ce939a7SSimon J. Gerraty.Bd -literal -offset indent
17631ce939a7SSimon J. GerratyM_cmpv.units = 1 1000 1000000
17641ce939a7SSimon J. GerratyM_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\
17651ce939a7SSimon J. Gerraty\\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
17661ce939a7SSimon J. Gerraty
17671ce939a7SSimon J. Gerraty.Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
17681ce939a7SSimon J. Gerraty
17691ce939a7SSimon J. Gerraty.Ed
17701ce939a7SSimon J. GerratyHere
17711ce939a7SSimon J. Gerraty.Ql $_
17721ce939a7SSimon J. Gerratyis used to save the result of the
17731ce939a7SSimon J. Gerraty.Ql :S
17741ce939a7SSimon J. Gerratymodifier which is later referenced using the index values from
17751ce939a7SSimon J. Gerraty.Ql :range .
1776954401e6SSimon J. Gerraty.It Cm \&:U\| Ns Ar newval
17772c3632d1SSimon J. GerratyIf the variable is undefined,
17783955d011SMarcel Moolenaar.Ar newval
17793955d011SMarcel Moolenaaris the value.
17803955d011SMarcel MoolenaarIf the variable is defined, the existing value is returned.
17813955d011SMarcel MoolenaarThis is another ODE make feature.
17823955d011SMarcel MoolenaarIt is handy for setting per-target CFLAGS for instance:
17833955d011SMarcel Moolenaar.Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
17843955d011SMarcel MoolenaarIf a value is only required if the variable is undefined, use:
17853955d011SMarcel Moolenaar.Dl ${VAR:D:Unewval}
1786954401e6SSimon J. Gerraty.It Cm \&:D\| Ns Ar newval
17872c3632d1SSimon J. GerratyIf the variable is defined,
17883955d011SMarcel Moolenaar.Ar newval
17893955d011SMarcel Moolenaaris the value.
17903955d011SMarcel Moolenaar.It Cm \&:L
17913955d011SMarcel MoolenaarThe name of the variable is the value.
17923955d011SMarcel Moolenaar.It Cm \&:P
17934fde40d9SSimon J. GerratyThe path of the node which has the same name as the variable is the value.
17944fde40d9SSimon J. GerratyIf no such node exists or its path is null, the name of the variable is used.
17953955d011SMarcel MoolenaarIn order for this modifier to work, the name (node) must at least have
17964fde40d9SSimon J. Gerratyappeared on the right-hand side of a dependency.
17973955d011SMarcel Moolenaar.Sm off
1798954401e6SSimon J. Gerraty.It Cm \&:\&! Ar cmd\| Cm \&!
17993955d011SMarcel Moolenaar.Sm on
18003955d011SMarcel MoolenaarThe output of running
18013955d011SMarcel Moolenaar.Ar cmd
18023955d011SMarcel Moolenaaris the value.
18033955d011SMarcel Moolenaar.It Cm \&:sh
18044fde40d9SSimon J. GerratyThe value is run as a command, and the output becomes the new value.
18053955d011SMarcel Moolenaar.It Cm \&::= Ns Ar str
18063955d011SMarcel MoolenaarThe variable is assigned the value
18073955d011SMarcel Moolenaar.Ar str
18083955d011SMarcel Moolenaarafter substitution.
18094fde40d9SSimon J. GerratyThis modifier and its variations are useful in obscure situations
18104fde40d9SSimon J. Gerratysuch as wanting to set a variable
18114fde40d9SSimon J. Gerratyat a point where a target's shell commands are being parsed.
18124fde40d9SSimon J. GerratyThese assignment modifiers always expand to nothing.
18133955d011SMarcel Moolenaar.Pp
18143955d011SMarcel MoolenaarThe
1815954401e6SSimon J. Gerraty.Sq Cm \&::
18163955d011SMarcel Moolenaarhelps avoid false matches with the
18173955d011SMarcel Moolenaar.At V
18183955d011SMarcel Moolenaarstyle
18194fde40d9SSimon J. Gerraty.Ql \&:=
18204fde40d9SSimon J. Gerratymodifier and since substitution always occurs, the
18214fde40d9SSimon J. Gerraty.Ql \&::=
18223955d011SMarcel Moolenaarform is vaguely appropriate.
18233955d011SMarcel Moolenaar.It Cm \&::?= Ns Ar str
18243955d011SMarcel MoolenaarAs for
18253955d011SMarcel Moolenaar.Cm \&::=
18263955d011SMarcel Moolenaarbut only if the variable does not already have a value.
18273955d011SMarcel Moolenaar.It Cm \&::+= Ns Ar str
18283955d011SMarcel MoolenaarAppend
18293955d011SMarcel Moolenaar.Ar str
18303955d011SMarcel Moolenaarto the variable.
18313955d011SMarcel Moolenaar.It Cm \&::!= Ns Ar cmd
18323955d011SMarcel MoolenaarAssign the output of
18333955d011SMarcel Moolenaar.Ar cmd
18343955d011SMarcel Moolenaarto the variable.
18353955d011SMarcel Moolenaar.It Cm \&:\&[ Ns Ar range Ns Cm \&]
18363955d011SMarcel MoolenaarSelects one or more words from the value,
18373955d011SMarcel Moolenaaror performs other operations related to the way in which the
18384fde40d9SSimon J. Gerratyvalue is split into words.
18393955d011SMarcel Moolenaar.Pp
18403955d011SMarcel MoolenaarAn empty value, or a value that consists entirely of white-space,
18413955d011SMarcel Moolenaaris treated as a single word.
18423955d011SMarcel MoolenaarFor the purposes of the
1843954401e6SSimon J. Gerraty.Sq Cm \&:[]
18443955d011SMarcel Moolenaarmodifier, the words are indexed both forwards using positive integers
18453955d011SMarcel Moolenaar(where index 1 represents the first word),
18463955d011SMarcel Moolenaarand backwards using negative integers
18473955d011SMarcel Moolenaar(where index \-1 represents the last word).
18483955d011SMarcel Moolenaar.Pp
18493955d011SMarcel MoolenaarThe
18503955d011SMarcel Moolenaar.Ar range
18513955d011SMarcel Moolenaaris subjected to variable expansion, and the expanded result is
18523955d011SMarcel Moolenaarthen interpreted as follows:
18533955d011SMarcel Moolenaar.Bl -tag -width index
18543955d011SMarcel Moolenaar.\" :[n]
18553955d011SMarcel Moolenaar.It Ar index
18563955d011SMarcel MoolenaarSelects a single word from the value.
18573955d011SMarcel Moolenaar.\" :[start..end]
18583955d011SMarcel Moolenaar.It Ar start Ns Cm \&.. Ns Ar end
18593955d011SMarcel MoolenaarSelects all words from
18603955d011SMarcel Moolenaar.Ar start
18613955d011SMarcel Moolenaarto
18623955d011SMarcel Moolenaar.Ar end ,
18633955d011SMarcel Moolenaarinclusive.
18643955d011SMarcel MoolenaarFor example,
1865954401e6SSimon J. Gerraty.Sq Cm \&:[2..-1]
18663955d011SMarcel Moolenaarselects all words from the second word to the last word.
18673955d011SMarcel MoolenaarIf
18683955d011SMarcel Moolenaar.Ar start
18693955d011SMarcel Moolenaaris greater than
18703955d011SMarcel Moolenaar.Ar end ,
18714fde40d9SSimon J. Gerratythe words are output in reverse order.
18723955d011SMarcel MoolenaarFor example,
1873954401e6SSimon J. Gerraty.Sq Cm \&:[-1..1]
18743955d011SMarcel Moolenaarselects all the words from last to first.
18754fde40d9SSimon J. GerratyIf the list is already ordered,
18764fde40d9SSimon J. Gerratythis effectively reverses the list,
18774fde40d9SSimon J. Gerratybut it is more efficient to use
1878954401e6SSimon J. Gerraty.Sq Cm \&:Or
1879ef0b2538SSimon J. Gerratyinstead of
1880954401e6SSimon J. Gerraty.Sq Cm \&:O:[-1..1] .
18813955d011SMarcel Moolenaar.\" :[*]
18823955d011SMarcel Moolenaar.It Cm \&*
18833955d011SMarcel MoolenaarCauses subsequent modifiers to treat the value as a single word
18843955d011SMarcel Moolenaar(possibly containing embedded whitespace).
18853955d011SMarcel MoolenaarAnalogous to the effect of
18864fde40d9SSimon J. Gerraty.Li \&$*
18873955d011SMarcel Moolenaarin Bourne shell.
18883955d011SMarcel Moolenaar.\" :[0]
18893955d011SMarcel Moolenaar.It 0
18903955d011SMarcel MoolenaarMeans the same as
1891954401e6SSimon J. Gerraty.Sq Cm \&:[*] .
18923955d011SMarcel Moolenaar.\" :[*]
18933955d011SMarcel Moolenaar.It Cm \&@
18943955d011SMarcel MoolenaarCauses subsequent modifiers to treat the value as a sequence of words
18953955d011SMarcel Moolenaardelimited by whitespace.
18963955d011SMarcel MoolenaarAnalogous to the effect of
18974fde40d9SSimon J. Gerraty.Li \&$@
18983955d011SMarcel Moolenaarin Bourne shell.
18993955d011SMarcel Moolenaar.\" :[#]
19003955d011SMarcel Moolenaar.It Cm \&#
19013955d011SMarcel MoolenaarReturns the number of words in the value.
19023955d011SMarcel Moolenaar.El \" :[range]
19033955d011SMarcel Moolenaar.El
19044fde40d9SSimon J. Gerraty.Sh DIRECTIVES
19054fde40d9SSimon J. Gerraty.Nm
19064fde40d9SSimon J. Gerratyoffers directives for including makefiles, conditionals and for loops.
19074fde40d9SSimon J. GerratyAll these directives are identified by a line beginning with a single dot
19083955d011SMarcel Moolenaar.Pq Ql \&.
19094fde40d9SSimon J. Gerratycharacter, followed by the keyword of the directive, such as
19104fde40d9SSimon J. Gerraty.Cm include
19114fde40d9SSimon J. Gerratyor
19124fde40d9SSimon J. Gerraty.Cm if .
19134fde40d9SSimon J. Gerraty.Ss File inclusion
19143955d011SMarcel MoolenaarFiles are included with either
1915ef0b2538SSimon J. Gerraty.Cm \&.include \&< Ns Ar file Ns Cm \&>
19163955d011SMarcel Moolenaaror
1917ef0b2538SSimon J. Gerraty.Cm \&.include \&\*q Ns Ar file Ns Cm \&\*q .
19183955d011SMarcel MoolenaarVariables between the angle brackets or double quotes are expanded
19193955d011SMarcel Moolenaarto form the file name.
19203955d011SMarcel MoolenaarIf angle brackets are used, the included makefile is expected to be in
19213955d011SMarcel Moolenaarthe system makefile directory.
19223955d011SMarcel MoolenaarIf double quotes are used, the including makefile's directory and any
19233955d011SMarcel Moolenaardirectories specified using the
19243955d011SMarcel Moolenaar.Fl I
19254fde40d9SSimon J. Gerratyoption are searched before the system makefile directory.
19264fde40d9SSimon J. Gerraty.Pp
19274fde40d9SSimon J. GerratyFor compatibility with other make variants,
19284fde40d9SSimon J. Gerraty.Sq Cm include Ar file No ...
19294fde40d9SSimon J. Gerraty(without leading dot)
19303955d011SMarcel Moolenaaris also accepted.
1931be19d90bSSimon J. Gerraty.Pp
19323955d011SMarcel MoolenaarIf the include statement is written as
19333955d011SMarcel Moolenaar.Cm .-include
19343955d011SMarcel Moolenaaror as
19354fde40d9SSimon J. Gerraty.Cm .sinclude ,
19364fde40d9SSimon J. Gerratyerrors locating and/or opening include files are ignored.
19373955d011SMarcel Moolenaar.Pp
1938be19d90bSSimon J. GerratyIf the include statement is written as
19394fde40d9SSimon J. Gerraty.Cm .dinclude ,
1940be19d90bSSimon J. Gerratynot only are errors locating and/or opening include files ignored,
19414fde40d9SSimon J. Gerratybut stale dependencies within the included file are ignored just like in
1942be19d90bSSimon J. Gerraty.Va .MAKE.DEPENDFILE .
19434fde40d9SSimon J. Gerraty.Ss Exporting variables
19444fde40d9SSimon J. GerratyThe directives for exporting and unexporting variables are:
19453955d011SMarcel Moolenaar.Bl -tag -width Ds
19464fde40d9SSimon J. Gerraty.It Ic .export Ar variable No ...
19473955d011SMarcel MoolenaarExport the specified global variable.
19483955d011SMarcel MoolenaarIf no variable list is provided, all globals are exported
19493955d011SMarcel Moolenaarexcept for internal variables (those that start with
19503955d011SMarcel Moolenaar.Ql \&. ) .
19513955d011SMarcel MoolenaarThis is not affected by the
19523955d011SMarcel Moolenaar.Fl X
19533955d011SMarcel Moolenaarflag, so should be used with caution.
19544fde40d9SSimon J. GerratyFor compatibility with other make programs,
19554fde40d9SSimon J. Gerraty.Cm export Ar variable\| Ns Cm \&= Ns Ar value
19564fde40d9SSimon J. Gerraty(without leading dot) is also accepted.
19573955d011SMarcel Moolenaar.Pp
19583955d011SMarcel MoolenaarAppending a variable name to
19593955d011SMarcel Moolenaar.Va .MAKE.EXPORTED
19603955d011SMarcel Moolenaaris equivalent to exporting a variable.
19614fde40d9SSimon J. Gerraty.It Ic .export-env Ar variable No ...
19623955d011SMarcel MoolenaarThe same as
19633955d011SMarcel Moolenaar.Ql .export ,
19643955d011SMarcel Moolenaarexcept that the variable is not appended to
19653955d011SMarcel Moolenaar.Va .MAKE.EXPORTED .
19663955d011SMarcel MoolenaarThis allows exporting a value to the environment which is different from that
19673955d011SMarcel Moolenaarused by
19683955d011SMarcel Moolenaar.Nm
19693955d011SMarcel Moolenaarinternally.
19704fde40d9SSimon J. Gerraty.It Ic .export-literal Ar variable No ...
1971be19d90bSSimon J. GerratyThe same as
1972be19d90bSSimon J. Gerraty.Ql .export-env ,
1973be19d90bSSimon J. Gerratyexcept that variables in the value are not expanded.
19744fde40d9SSimon J. Gerraty.It Ic .unexport Ar variable No ...
19753955d011SMarcel MoolenaarThe opposite of
19763955d011SMarcel Moolenaar.Ql .export .
19773955d011SMarcel MoolenaarThe specified global
19784fde40d9SSimon J. Gerraty.Ar variable
19794fde40d9SSimon J. Gerratyis removed from
19803955d011SMarcel Moolenaar.Va .MAKE.EXPORTED .
19813955d011SMarcel MoolenaarIf no variable list is provided, all globals are unexported,
19823955d011SMarcel Moolenaarand
19833955d011SMarcel Moolenaar.Va .MAKE.EXPORTED
19843955d011SMarcel Moolenaardeleted.
19853955d011SMarcel Moolenaar.It Ic .unexport-env
19863955d011SMarcel MoolenaarUnexport all globals previously exported and
19873955d011SMarcel Moolenaarclear the environment inherited from the parent.
19884fde40d9SSimon J. GerratyThis operation causes a memory leak of the original environment,
19893955d011SMarcel Moolenaarso should be used sparingly.
19903955d011SMarcel MoolenaarTesting for
19913955d011SMarcel Moolenaar.Va .MAKE.LEVEL
19924fde40d9SSimon J. Gerratybeing 0 would make sense.
19933955d011SMarcel MoolenaarAlso note that any variables which originated in the parent environment
19943955d011SMarcel Moolenaarshould be explicitly preserved if desired.
19953955d011SMarcel MoolenaarFor example:
19963955d011SMarcel Moolenaar.Bd -literal -offset indent
19973955d011SMarcel Moolenaar.Li .if ${.MAKE.LEVEL} == 0
19983955d011SMarcel MoolenaarPATH := ${PATH}
19993955d011SMarcel Moolenaar.Li .unexport-env
20003955d011SMarcel Moolenaar.Li .export PATH
20013955d011SMarcel Moolenaar.Li .endif
20023955d011SMarcel Moolenaar.Pp
20033955d011SMarcel Moolenaar.Ed
20043955d011SMarcel MoolenaarWould result in an environment containing only
2005954401e6SSimon J. Gerraty.Sq Ev PATH ,
20063955d011SMarcel Moolenaarwhich is the minimal useful environment.
20074fde40d9SSimon J. Gerraty.\" TODO: Check the below sentence, environment variables don't start with '.'.
20083955d011SMarcel MoolenaarActually
20094fde40d9SSimon J. Gerraty.Sq Va .MAKE.LEVEL
20104fde40d9SSimon J. Gerratyis also pushed into the new environment.
20114fde40d9SSimon J. Gerraty.El
20124fde40d9SSimon J. Gerraty.Ss Messages
20134fde40d9SSimon J. GerratyThe directives for printing messages to the output are:
20144fde40d9SSimon J. Gerraty.Bl -tag -width Ds
20154fde40d9SSimon J. Gerraty.It Ic .info Ar message
20164fde40d9SSimon J. GerratyThe message is printed along with the name of the makefile and line number.
20173955d011SMarcel Moolenaar.It Ic .warning Ar message
20183955d011SMarcel MoolenaarThe message prefixed by
20194fde40d9SSimon J. Gerraty.Sq Li warning:
20203955d011SMarcel Moolenaaris printed along with the name of the makefile and line number.
20214fde40d9SSimon J. Gerraty.It Ic .error Ar message
20224fde40d9SSimon J. GerratyThe message is printed along with the name of the makefile and line number,
20234fde40d9SSimon J. Gerraty.Nm
20244fde40d9SSimon J. Gerratyexits immediately.
20254fde40d9SSimon J. Gerraty.El
20264fde40d9SSimon J. Gerraty.Ss Conditionals
20274fde40d9SSimon J. GerratyThe directives for conditionals are:
20284fde40d9SSimon J. Gerraty.ds maybenot Oo Ic \&! Oc Ns
20294fde40d9SSimon J. Gerraty.Bl -tag
20304fde40d9SSimon J. Gerraty.It Ic .if \*[maybenot] Ar expression Op Ar operator expression No ...
20313955d011SMarcel MoolenaarTest the value of an expression.
20324fde40d9SSimon J. Gerraty.It Ic .ifdef \*[maybenot] Ar variable Op Ar operator variable No ...
20334fde40d9SSimon J. GerratyTest whether a variable is defined.
20344fde40d9SSimon J. Gerraty.It Ic .ifndef \*[maybenot] Ar variable Op Ar operator variable No ...
20354fde40d9SSimon J. GerratyTest whether a variable is not defined.
20364fde40d9SSimon J. Gerraty.It Ic .ifmake \*[maybenot] Ar target Op Ar operator target No ...
20374fde40d9SSimon J. GerratyTest the target being requested.
20384fde40d9SSimon J. Gerraty.It Ic .ifnmake \*[maybenot] Ar target Op Ar operator target No ...
20394fde40d9SSimon J. GerratyTest the target being requested.
20403955d011SMarcel Moolenaar.It Ic .else
20413955d011SMarcel MoolenaarReverse the sense of the last conditional.
20424fde40d9SSimon J. Gerraty.It Ic .elif \*[maybenot] Ar expression Op Ar operator expression No ...
20433955d011SMarcel MoolenaarA combination of
2044954401e6SSimon J. Gerraty.Sq Ic .else
20453955d011SMarcel Moolenaarfollowed by
2046954401e6SSimon J. Gerraty.Sq Ic .if .
20474fde40d9SSimon J. Gerraty.It Ic .elifdef \*[maybenot] Ar variable Op Ar operator variable No ...
20483955d011SMarcel MoolenaarA combination of
2049954401e6SSimon J. Gerraty.Sq Ic .else
20503955d011SMarcel Moolenaarfollowed by
2051954401e6SSimon J. Gerraty.Sq Ic .ifdef .
20524fde40d9SSimon J. Gerraty.It Ic .elifndef \*[maybenot] Ar variable Op Ar operator variable No ...
20533955d011SMarcel MoolenaarA combination of
2054954401e6SSimon J. Gerraty.Sq Ic .else
20553955d011SMarcel Moolenaarfollowed by
2056954401e6SSimon J. Gerraty.Sq Ic .ifndef .
20574fde40d9SSimon J. Gerraty.It Ic .elifmake \*[maybenot] Ar target Op Ar operator target No ...
20583955d011SMarcel MoolenaarA combination of
2059954401e6SSimon J. Gerraty.Sq Ic .else
20603955d011SMarcel Moolenaarfollowed by
2061954401e6SSimon J. Gerraty.Sq Ic .ifmake .
20624fde40d9SSimon J. Gerraty.It Ic .elifnmake \*[maybenot] Ar target Op Ar operator target No ...
20633955d011SMarcel MoolenaarA combination of
2064954401e6SSimon J. Gerraty.Sq Ic .else
20653955d011SMarcel Moolenaarfollowed by
2066954401e6SSimon J. Gerraty.Sq Ic .ifnmake .
20673955d011SMarcel Moolenaar.It Ic .endif
20683955d011SMarcel MoolenaarEnd the body of the conditional.
20693955d011SMarcel Moolenaar.El
20703955d011SMarcel Moolenaar.Pp
20713955d011SMarcel MoolenaarThe
20723955d011SMarcel Moolenaar.Ar operator
20733955d011SMarcel Moolenaarmay be any one of the following:
20744fde40d9SSimon J. Gerraty.Bl -tag
20754fde40d9SSimon J. Gerraty.It Ic \&|\&|
20763955d011SMarcel MoolenaarLogical OR.
20774fde40d9SSimon J. Gerraty.It Ic \&&&
20784fde40d9SSimon J. GerratyLogical AND; of higher precedence than
20794fde40d9SSimon J. Gerraty.Sq Ic \&|\&| .
20803955d011SMarcel Moolenaar.El
20813955d011SMarcel Moolenaar.Pp
20823955d011SMarcel Moolenaar.Nm
20834fde40d9SSimon J. Gerratyonly evaluates a conditional as far as is necessary to determine its value.
20844fde40d9SSimon J. GerratyParentheses can be used to override the operator precedence.
20853955d011SMarcel MoolenaarThe boolean operator
2086954401e6SSimon J. Gerraty.Sq Ic \&!
2087*98875883SSimon J. Gerratymay be used to logically negate an expression, typically a function call.
20883955d011SMarcel MoolenaarIt is of higher precedence than
2089954401e6SSimon J. Gerraty.Sq Ic \&&& .
20903955d011SMarcel Moolenaar.Pp
20913955d011SMarcel MoolenaarThe value of
20923955d011SMarcel Moolenaar.Ar expression
20934fde40d9SSimon J. Gerratymay be any of the following function call expressions:
20944fde40d9SSimon J. Gerraty.Bl -tag
20954fde40d9SSimon J. Gerraty.Sm off
20964fde40d9SSimon J. Gerraty.It Ic defined Li \&( Ar varname Li \&)
20974fde40d9SSimon J. Gerraty.Sm on
20984fde40d9SSimon J. GerratyEvaluates to true if the variable
20994fde40d9SSimon J. Gerraty.Ar varname
21003955d011SMarcel Moolenaarhas been defined.
21014fde40d9SSimon J. Gerraty.Sm off
21024fde40d9SSimon J. Gerraty.It Ic make Li \&( Ar target Li \&)
21034fde40d9SSimon J. Gerraty.Sm on
21044fde40d9SSimon J. GerratyEvaluates to true if the target was specified as part of
21053955d011SMarcel Moolenaar.Nm Ns 's
21063955d011SMarcel Moolenaarcommand line or was declared the default target (either implicitly or
21073955d011SMarcel Moolenaarexplicitly, see
21083955d011SMarcel Moolenaar.Va .MAIN )
21093955d011SMarcel Moolenaarbefore the line containing the conditional.
21104fde40d9SSimon J. Gerraty.Sm off
21114fde40d9SSimon J. Gerraty.It Ic empty Li \&( Ar varname Oo Li : Ar modifiers Oc Li \&)
21124fde40d9SSimon J. Gerraty.Sm on
21134fde40d9SSimon J. GerratyEvaluates to true if the expansion of the variable,
21144fde40d9SSimon J. Gerratyafter applying the modifiers, results in an empty string.
21154fde40d9SSimon J. Gerraty.Sm off
21164fde40d9SSimon J. Gerraty.It Ic exists Li \&( Ar pathname Li \&)
21174fde40d9SSimon J. Gerraty.Sm on
21184fde40d9SSimon J. GerratyEvaluates to true if the given pathname exists.
21194fde40d9SSimon J. GerratyIf relative, the pathname is searched for on the system search path (see
21203955d011SMarcel Moolenaar.Va .PATH ) .
21214fde40d9SSimon J. Gerraty.Sm off
21224fde40d9SSimon J. Gerraty.It Ic target Li \&( Ar target Li \&)
21234fde40d9SSimon J. Gerraty.Sm on
21244fde40d9SSimon J. GerratyEvaluates to true if the target has been defined.
21254fde40d9SSimon J. Gerraty.Sm off
21264fde40d9SSimon J. Gerraty.It Ic commands Li \&( Ar target Li \&)
21274fde40d9SSimon J. Gerraty.Sm on
21284fde40d9SSimon J. GerratyEvaluates to true if the target has been defined
21294fde40d9SSimon J. Gerratyand has commands associated with it.
21303955d011SMarcel Moolenaar.El
21313955d011SMarcel Moolenaar.Pp
21323955d011SMarcel Moolenaar.Ar Expression
21333955d011SMarcel Moolenaarmay also be an arithmetic or string comparison.
21344fde40d9SSimon J. GerratyVariable expansion is performed on both sides of the comparison.
21354fde40d9SSimon J. GerratyIf both sides are numeric and neither is enclosed in quotes,
21364fde40d9SSimon J. Gerratythe comparison is done numerically, otherwise lexicographically.
2137*98875883SSimon J. GerratyA string is interpreted as a hexadecimal integer if it is preceded by
21384fde40d9SSimon J. Gerraty.Li 0x ,
2139*98875883SSimon J. Gerratyotherwise it is interpreted as a decimal floating-point number;
21404fde40d9SSimon J. Gerratyoctal numbers are not supported.
21414fde40d9SSimon J. Gerraty.Pp
21424fde40d9SSimon J. GerratyAll comparisons may use the operators
21434fde40d9SSimon J. Gerraty.Sq Ic \&==
21444fde40d9SSimon J. Gerratyand
21454fde40d9SSimon J. Gerraty.Sq Ic \&!= .
21464fde40d9SSimon J. GerratyNumeric comparisons may also use the operators
21474fde40d9SSimon J. Gerraty.Sq Ic \&< ,
21484fde40d9SSimon J. Gerraty.Sq Ic \&<= ,
21494fde40d9SSimon J. Gerraty.Sq Ic \&>
21504fde40d9SSimon J. Gerratyand
21514fde40d9SSimon J. Gerraty.Sq Ic \&>= .
21524fde40d9SSimon J. Gerraty.Pp
21534fde40d9SSimon J. GerratyIf the comparison has neither a comparison operator nor a right side,
21544fde40d9SSimon J. Gerratythe expression evaluates to true if it is nonempty
21554fde40d9SSimon J. Gerratyand its numeric value (if any) is not zero.
21563955d011SMarcel Moolenaar.Pp
21573955d011SMarcel MoolenaarWhen
21583955d011SMarcel Moolenaar.Nm
21593955d011SMarcel Moolenaaris evaluating one of these conditional expressions, and it encounters
2160*98875883SSimon J. Gerratya (whitespace-separated) word it doesn't recognize, either the
21613955d011SMarcel Moolenaar.Dq make
21623955d011SMarcel Moolenaaror
21633955d011SMarcel Moolenaar.Dq defined
21644fde40d9SSimon J. Gerratyfunction is applied to it, depending on the form of the conditional.
21653955d011SMarcel MoolenaarIf the form is
2166954401e6SSimon J. Gerraty.Sq Ic .ifdef ,
21674fde40d9SSimon J. Gerraty.Sq Ic .ifndef
21683955d011SMarcel Moolenaaror
21694fde40d9SSimon J. Gerraty.Sq Ic .if ,
21703955d011SMarcel Moolenaarthe
21713955d011SMarcel Moolenaar.Dq defined
21724fde40d9SSimon J. Gerratyfunction is applied.
21733955d011SMarcel MoolenaarSimilarly, if the form is
2174954401e6SSimon J. Gerraty.Sq Ic .ifmake
21753955d011SMarcel Moolenaaror
2176954401e6SSimon J. Gerraty.Sq Ic .ifnmake ,
2177494f7191SSimon J. Gerratythe
21783955d011SMarcel Moolenaar.Dq make
21794fde40d9SSimon J. Gerratyfunction is applied.
21803955d011SMarcel Moolenaar.Pp
21814fde40d9SSimon J. GerratyIf the conditional evaluates to true,
21824fde40d9SSimon J. Gerratyparsing of the makefile continues as before.
2183*98875883SSimon J. GerratyIf it evaluates to false, the following lines until the corresponding
2184*98875883SSimon J. Gerraty.Sq Ic .elif
2185*98875883SSimon J. Gerratyvariant,
2186954401e6SSimon J. Gerraty.Sq Ic .else
21873955d011SMarcel Moolenaaror
2188954401e6SSimon J. Gerraty.Sq Ic .endif
2189*98875883SSimon J. Gerratyare skipped.
21904fde40d9SSimon J. Gerraty.Ss For loops
21913955d011SMarcel MoolenaarFor loops are typically used to apply a set of rules to a list of files.
21923955d011SMarcel MoolenaarThe syntax of a for loop is:
21933955d011SMarcel Moolenaar.Pp
21943955d011SMarcel Moolenaar.Bl -tag -compact -width Ds
21954fde40d9SSimon J. Gerraty.It Ic \&.for Ar variable Oo Ar variable No ... Oc Ic in Ar expression
21964fde40d9SSimon J. Gerraty.It Aq Ar make-lines
21973955d011SMarcel Moolenaar.It Ic \&.endfor
21983955d011SMarcel Moolenaar.El
21993955d011SMarcel Moolenaar.Pp
22004fde40d9SSimon J. GerratyThe
22014fde40d9SSimon J. Gerraty.Ar expression
22024fde40d9SSimon J. Gerratyis expanded and then split into words.
22033955d011SMarcel MoolenaarOn each iteration of the loop, one word is taken and assigned to each
22044fde40d9SSimon J. Gerraty.Ar variable ,
22053955d011SMarcel Moolenaarin order, and these
22064fde40d9SSimon J. Gerraty.Ar variables
22073955d011SMarcel Moolenaarare substituted into the
22084fde40d9SSimon J. Gerraty.Ar make-lines
22093955d011SMarcel Moolenaarinside the body of the for loop.
22103955d011SMarcel MoolenaarThe number of words must come out even; that is, if there are three
22113955d011SMarcel Moolenaariteration variables, the number of words provided must be a multiple
22123955d011SMarcel Moolenaarof three.
22134fde40d9SSimon J. Gerraty.Pp
22144fde40d9SSimon J. GerratyIf
22154fde40d9SSimon J. Gerraty.Sq Ic .break
22164fde40d9SSimon J. Gerratyis encountered within a
22174fde40d9SSimon J. Gerraty.Cm \&.for
22184fde40d9SSimon J. Gerratyloop, it causes early termination of the loop, otherwise a parse error.
22194fde40d9SSimon J. Gerraty.\" TODO: Describe limitations with defined/empty.
22204fde40d9SSimon J. Gerraty.Ss Other directives
22214fde40d9SSimon J. Gerraty.Bl -tag -width Ds
22224fde40d9SSimon J. Gerraty.It Ic .undef Ar variable No ...
22234fde40d9SSimon J. GerratyUn-define the specified global variables.
22244fde40d9SSimon J. GerratyOnly global variables can be un-defined.
22254fde40d9SSimon J. Gerraty.El
22263955d011SMarcel Moolenaar.Sh COMMENTS
22273955d011SMarcel MoolenaarComments begin with a hash
22283955d011SMarcel Moolenaar.Pq Ql \&#
22293955d011SMarcel Moolenaarcharacter, anywhere but in a shell
22303955d011SMarcel Moolenaarcommand line, and continue to the end of an unescaped new line.
22313955d011SMarcel Moolenaar.Sh SPECIAL SOURCES (ATTRIBUTES)
22323955d011SMarcel Moolenaar.Bl -tag -width .IGNOREx
22333955d011SMarcel Moolenaar.It Ic .EXEC
22343955d011SMarcel MoolenaarTarget is never out of date, but always execute commands anyway.
22353955d011SMarcel Moolenaar.It Ic .IGNORE
22363955d011SMarcel MoolenaarIgnore any errors from the commands associated with this target, exactly
22373955d011SMarcel Moolenaaras if they all were preceded by a dash
22383955d011SMarcel Moolenaar.Pq Ql \- .
22393955d011SMarcel Moolenaar.\" .It Ic .INVISIBLE
22403955d011SMarcel Moolenaar.\" XXX
22413955d011SMarcel Moolenaar.\" .It Ic .JOIN
22423955d011SMarcel Moolenaar.\" XXX
22433955d011SMarcel Moolenaar.It Ic .MADE
22444fde40d9SSimon J. GerratyMark all sources of this target as being up to date.
22453955d011SMarcel Moolenaar.It Ic .MAKE
22463955d011SMarcel MoolenaarExecute the commands associated with this target even if the
22473955d011SMarcel Moolenaar.Fl n
22483955d011SMarcel Moolenaaror
22493955d011SMarcel Moolenaar.Fl t
22503955d011SMarcel Moolenaaroptions were specified.
22513955d011SMarcel MoolenaarNormally used to mark recursive
22520dede8b0SSimon J. Gerraty.Nm Ns s .
22533955d011SMarcel Moolenaar.It Ic .META
22543955d011SMarcel MoolenaarCreate a meta file for the target, even if it is flagged as
22553955d011SMarcel Moolenaar.Ic .PHONY ,
22563955d011SMarcel Moolenaar.Ic .MAKE ,
22573955d011SMarcel Moolenaaror
22583955d011SMarcel Moolenaar.Ic .SPECIAL .
22593955d011SMarcel MoolenaarUsage in conjunction with
22603955d011SMarcel Moolenaar.Ic .MAKE
22613955d011SMarcel Moolenaaris the most likely case.
22624fde40d9SSimon J. GerratyIn
22634fde40d9SSimon J. Gerraty.Dq meta
22644fde40d9SSimon J. Gerratymode, the target is out-of-date if the meta file is missing.
22653955d011SMarcel Moolenaar.It Ic .NOMETA
22663955d011SMarcel MoolenaarDo not create a meta file for the target.
22673955d011SMarcel MoolenaarMeta files are also not created for
22683955d011SMarcel Moolenaar.Ic .PHONY ,
22693955d011SMarcel Moolenaar.Ic .MAKE ,
22703955d011SMarcel Moolenaaror
22713955d011SMarcel Moolenaar.Ic .SPECIAL
22723955d011SMarcel Moolenaartargets.
22733955d011SMarcel Moolenaar.It Ic .NOMETA_CMP
22743955d011SMarcel MoolenaarIgnore differences in commands when deciding if target is out of date.
22753955d011SMarcel MoolenaarThis is useful if the command contains a value which always changes.
22764fde40d9SSimon J. GerratyIf the number of commands change, though,
22774fde40d9SSimon J. Gerratythe target is still considered out of date.
22781748de26SSimon J. GerratyThe same effect applies to any command line that uses the variable
22791748de26SSimon J. Gerraty.Va .OODATE ,
22801748de26SSimon J. Gerratywhich can be used for that purpose even when not otherwise needed or desired:
22811748de26SSimon J. Gerraty.Bd -literal -offset indent
22821748de26SSimon J. Gerraty
22831748de26SSimon J. Gerratyskip-compare-for-some:
22844fde40d9SSimon J. Gerraty	@echo this is compared
22854fde40d9SSimon J. Gerraty	@echo this is not ${.OODATE:M.NOMETA_CMP}
22864fde40d9SSimon J. Gerraty	@echo this is also compared
22871748de26SSimon J. Gerraty
22881748de26SSimon J. Gerraty.Ed
22891748de26SSimon J. GerratyThe
22901748de26SSimon J. Gerraty.Cm \&:M
22911748de26SSimon J. Gerratypattern suppresses any expansion of the unwanted variable.
22923955d011SMarcel Moolenaar.It Ic .NOPATH
22933955d011SMarcel MoolenaarDo not search for the target in the directories specified by
22944fde40d9SSimon J. Gerraty.Va .PATH .
22953955d011SMarcel Moolenaar.It Ic .NOTMAIN
22963955d011SMarcel MoolenaarNormally
22973955d011SMarcel Moolenaar.Nm
22983955d011SMarcel Moolenaarselects the first target it encounters as the default target to be built
22993955d011SMarcel Moolenaarif no target was specified.
23003955d011SMarcel MoolenaarThis source prevents this target from being selected.
23013955d011SMarcel Moolenaar.It Ic .OPTIONAL
23023955d011SMarcel MoolenaarIf a target is marked with this attribute and
23033955d011SMarcel Moolenaar.Nm
23044fde40d9SSimon J. Gerratycan't figure out how to create it, it ignores this fact and assumes
23053955d011SMarcel Moolenaarthe file isn't needed or already exists.
23063955d011SMarcel Moolenaar.It Ic .PHONY
23074fde40d9SSimon J. GerratyThe target does not correspond to an actual file;
23084fde40d9SSimon J. Gerratyit is always considered to be out of date,
23094fde40d9SSimon J. Gerratyand is not created with the
23103955d011SMarcel Moolenaar.Fl t
23113955d011SMarcel Moolenaaroption.
23123955d011SMarcel MoolenaarSuffix-transformation rules are not applied to
23133955d011SMarcel Moolenaar.Ic .PHONY
23143955d011SMarcel Moolenaartargets.
23153955d011SMarcel Moolenaar.It Ic .PRECIOUS
23163955d011SMarcel MoolenaarWhen
23173955d011SMarcel Moolenaar.Nm
23183955d011SMarcel Moolenaaris interrupted, it normally removes any partially made targets.
23193955d011SMarcel MoolenaarThis source prevents the target from being removed.
23203955d011SMarcel Moolenaar.It Ic .RECURSIVE
23213955d011SMarcel MoolenaarSynonym for
23223955d011SMarcel Moolenaar.Ic .MAKE .
23233955d011SMarcel Moolenaar.It Ic .SILENT
23243955d011SMarcel MoolenaarDo not echo any of the commands associated with this target, exactly
23253955d011SMarcel Moolenaaras if they all were preceded by an at sign
23263955d011SMarcel Moolenaar.Pq Ql @ .
23273955d011SMarcel Moolenaar.It Ic .USE
23283955d011SMarcel MoolenaarTurn the target into
23293955d011SMarcel Moolenaar.Nm Ns 's
23303955d011SMarcel Moolenaarversion of a macro.
23313955d011SMarcel MoolenaarWhen the target is used as a source for another target, the other target
23323955d011SMarcel Moolenaaracquires the commands, sources, and attributes (except for
23333955d011SMarcel Moolenaar.Ic .USE )
23343955d011SMarcel Moolenaarof the
23353955d011SMarcel Moolenaarsource.
23363955d011SMarcel MoolenaarIf the target already has commands, the
23373955d011SMarcel Moolenaar.Ic .USE
23383955d011SMarcel Moolenaartarget's commands are appended
23393955d011SMarcel Moolenaarto them.
23403955d011SMarcel Moolenaar.It Ic .USEBEFORE
23414fde40d9SSimon J. GerratyLike
23423955d011SMarcel Moolenaar.Ic .USE ,
23434fde40d9SSimon J. Gerratybut instead of appending, prepend the
23443955d011SMarcel Moolenaar.Ic .USEBEFORE
23453955d011SMarcel Moolenaartarget commands to the target.
23463955d011SMarcel Moolenaar.It Ic .WAIT
23473955d011SMarcel MoolenaarIf
23483955d011SMarcel Moolenaar.Ic .WAIT
23493955d011SMarcel Moolenaarappears in a dependency line, the sources that precede it are
23503955d011SMarcel Moolenaarmade before the sources that succeed it in the line.
23513955d011SMarcel MoolenaarSince the dependents of files are not made until the file itself
23523955d011SMarcel Moolenaarcould be made, this also stops the dependents being built unless they
23533955d011SMarcel Moolenaarare needed for another branch of the dependency tree.
23543955d011SMarcel MoolenaarSo given:
23553955d011SMarcel Moolenaar.Bd -literal
23563955d011SMarcel Moolenaarx: a .WAIT b
23573955d011SMarcel Moolenaar	echo x
23583955d011SMarcel Moolenaara:
23593955d011SMarcel Moolenaar	echo a
23603955d011SMarcel Moolenaarb: b1
23613955d011SMarcel Moolenaar	echo b
23623955d011SMarcel Moolenaarb1:
23633955d011SMarcel Moolenaar	echo b1
23643955d011SMarcel Moolenaar
23653955d011SMarcel Moolenaar.Ed
23663955d011SMarcel Moolenaarthe output is always
23673955d011SMarcel Moolenaar.Ql a ,
23683955d011SMarcel Moolenaar.Ql b1 ,
23693955d011SMarcel Moolenaar.Ql b ,
23703955d011SMarcel Moolenaar.Ql x .
23714fde40d9SSimon J. Gerraty.Pp
23723955d011SMarcel MoolenaarThe ordering imposed by
23733955d011SMarcel Moolenaar.Ic .WAIT
23743955d011SMarcel Moolenaaris only relevant for parallel makes.
23753955d011SMarcel Moolenaar.El
23763955d011SMarcel Moolenaar.Sh SPECIAL TARGETS
23773955d011SMarcel MoolenaarSpecial targets may not be included with other targets, i.e. they must be
23783955d011SMarcel Moolenaarthe only target specified.
23793955d011SMarcel Moolenaar.Bl -tag -width .BEGINx
23803955d011SMarcel Moolenaar.It Ic .BEGIN
23813955d011SMarcel MoolenaarAny command lines attached to this target are executed before anything
23823955d011SMarcel Moolenaarelse is done.
23833955d011SMarcel Moolenaar.It Ic .DEFAULT
23843955d011SMarcel MoolenaarThis is sort of a
23853955d011SMarcel Moolenaar.Ic .USE
23864fde40d9SSimon J. Gerratyrule for any target (that was used only as a source) that
23873955d011SMarcel Moolenaar.Nm
23883955d011SMarcel Moolenaarcan't figure out any other way to create.
23893955d011SMarcel MoolenaarOnly the shell script is used.
23903955d011SMarcel MoolenaarThe
23914fde40d9SSimon J. Gerraty.Va .IMPSRC
23923955d011SMarcel Moolenaarvariable of a target that inherits
23933955d011SMarcel Moolenaar.Ic .DEFAULT Ns 's
23944fde40d9SSimon J. Gerratycommands is set to the target's own name.
239545447996SSimon J. Gerraty.It Ic .DELETE_ON_ERROR
239645447996SSimon J. GerratyIf this target is present in the makefile, it globally causes make to
239745447996SSimon J. Gerratydelete targets whose commands fail.
239845447996SSimon J. Gerraty(By default, only targets whose commands are interrupted during
239945447996SSimon J. Gerratyexecution are deleted.
240045447996SSimon J. GerratyThis is the historical behavior.)
240145447996SSimon J. GerratyThis setting can be used to help prevent half-finished or malformed
240245447996SSimon J. Gerratytargets from being left around and corrupting future rebuilds.
24033955d011SMarcel Moolenaar.It Ic .END
24043955d011SMarcel MoolenaarAny command lines attached to this target are executed after everything
24054fde40d9SSimon J. Gerratyelse is done successfully.
24063955d011SMarcel Moolenaar.It Ic .ERROR
24073955d011SMarcel MoolenaarAny command lines attached to this target are executed when another target fails.
24083955d011SMarcel MoolenaarThe
24094fde40d9SSimon J. Gerraty.Va .ERROR_TARGET
24103955d011SMarcel Moolenaarvariable is set to the target that failed.
24113955d011SMarcel MoolenaarSee also
24124fde40d9SSimon J. Gerraty.Va MAKE_PRINT_VAR_ON_ERROR .
24133955d011SMarcel Moolenaar.It Ic .IGNORE
24143955d011SMarcel MoolenaarMark each of the sources with the
24153955d011SMarcel Moolenaar.Ic .IGNORE
24163955d011SMarcel Moolenaarattribute.
24173955d011SMarcel MoolenaarIf no sources are specified, this is the equivalent of specifying the
24183955d011SMarcel Moolenaar.Fl i
24193955d011SMarcel Moolenaaroption.
24203955d011SMarcel Moolenaar.It Ic .INTERRUPT
24213955d011SMarcel MoolenaarIf
24223955d011SMarcel Moolenaar.Nm
24234fde40d9SSimon J. Gerratyis interrupted, the commands for this target are executed.
24243955d011SMarcel Moolenaar.It Ic .MAIN
24253955d011SMarcel MoolenaarIf no target is specified when
24263955d011SMarcel Moolenaar.Nm
24274fde40d9SSimon J. Gerratyis invoked, this target is built.
24283955d011SMarcel Moolenaar.It Ic .MAKEFLAGS
24293955d011SMarcel MoolenaarThis target provides a way to specify flags for
24303955d011SMarcel Moolenaar.Nm
24314fde40d9SSimon J. Gerratyat the time when the makefiles are read.
24323955d011SMarcel MoolenaarThe flags are as if typed to the shell, though the
24333955d011SMarcel Moolenaar.Fl f
24344fde40d9SSimon J. Gerratyoption has
24353955d011SMarcel Moolenaarno effect.
24363955d011SMarcel Moolenaar.\" XXX: NOT YET!!!!
24373955d011SMarcel Moolenaar.\" .It Ic .NOTPARALLEL
24383955d011SMarcel Moolenaar.\" The named targets are executed in non parallel mode.
24393955d011SMarcel Moolenaar.\" If no targets are
24404fde40d9SSimon J. Gerraty.\" specified, all targets are executed in non parallel mode.
24413955d011SMarcel Moolenaar.It Ic .NOPATH
24423955d011SMarcel MoolenaarApply the
24433955d011SMarcel Moolenaar.Ic .NOPATH
24443955d011SMarcel Moolenaarattribute to any specified sources.
24453955d011SMarcel Moolenaar.It Ic .NOTPARALLEL
24463955d011SMarcel MoolenaarDisable parallel mode.
24473955d011SMarcel Moolenaar.It Ic .NO_PARALLEL
24483955d011SMarcel MoolenaarSynonym for
24493955d011SMarcel Moolenaar.Ic .NOTPARALLEL ,
24503955d011SMarcel Moolenaarfor compatibility with other pmake variants.
24514fde40d9SSimon J. Gerraty.It Ic .NOREADONLY
24524fde40d9SSimon J. Gerratyclear the read-only attribute from the global variables specified as sources.
2453128a4105SSimon J. Gerraty.It Ic .OBJDIR
2454128a4105SSimon J. GerratyThe source is a new value for
2455954401e6SSimon J. Gerraty.Sq Va .OBJDIR .
2456128a4105SSimon J. GerratyIf it exists,
2457128a4105SSimon J. Gerraty.Nm
24584fde40d9SSimon J. Gerratychanges the current working directory to it and updates the value of
2459954401e6SSimon J. Gerraty.Sq Va .OBJDIR .
24603955d011SMarcel Moolenaar.It Ic .ORDER
2461954401e6SSimon J. GerratyIn parallel mode, the named targets are made in sequence.
24623955d011SMarcel MoolenaarThis ordering does not add targets to the list of targets to be made.
2463954401e6SSimon J. Gerraty.Pp
24643955d011SMarcel MoolenaarSince the dependents of a target do not get built until the target itself
24653955d011SMarcel Moolenaarcould be built, unless
24663955d011SMarcel Moolenaar.Ql a
24673955d011SMarcel Moolenaaris built by another part of the dependency graph,
24683955d011SMarcel Moolenaarthe following is a dependency loop:
24693955d011SMarcel Moolenaar.Bd -literal
24703955d011SMarcel Moolenaar\&.ORDER: b a
24713955d011SMarcel Moolenaarb: a
24723955d011SMarcel Moolenaar.Ed
24733955d011SMarcel Moolenaar.Pp
24743955d011SMarcel Moolenaar.\" XXX: NOT YET!!!!
24753955d011SMarcel Moolenaar.\" .It Ic .PARALLEL
24763955d011SMarcel Moolenaar.\" The named targets are executed in parallel mode.
24773955d011SMarcel Moolenaar.\" If no targets are
24784fde40d9SSimon J. Gerraty.\" specified, all targets are executed in parallel mode.
24793955d011SMarcel Moolenaar.It Ic .PATH
24803955d011SMarcel MoolenaarThe sources are directories which are to be searched for files not
24813955d011SMarcel Moolenaarfound in the current directory.
24824fde40d9SSimon J. GerratyIf no sources are specified,
24834fde40d9SSimon J. Gerratyany previously specified directories are removed from the search path.
24843955d011SMarcel MoolenaarIf the source is the special
24853955d011SMarcel Moolenaar.Ic .DOTLAST
24864fde40d9SSimon J. Gerratytarget, the current working directory is searched last.
24874fde40d9SSimon J. Gerraty.It Ic .PATH. Ns Ar suffix
24881bbe5942SSimon J. GerratyLike
24891bbe5942SSimon J. Gerraty.Ic .PATH
24901bbe5942SSimon J. Gerratybut applies only to files with a particular suffix.
24911bbe5942SSimon J. GerratyThe suffix must have been previously declared with
24921bbe5942SSimon J. Gerraty.Ic .SUFFIXES .
24933955d011SMarcel Moolenaar.It Ic .PHONY
24943955d011SMarcel MoolenaarApply the
24953955d011SMarcel Moolenaar.Ic .PHONY
24963955d011SMarcel Moolenaarattribute to any specified sources.
24971d3f2ddcSSimon J. Gerraty.It Ic .POSIX
24982f2a5ecdSSimon J. GerratyIf this is the first non-comment line in the main makefile,
24992f2a5ecdSSimon J. Gerratythe variable
25001d3f2ddcSSimon J. Gerraty.Va %POSIX
25012f2a5ecdSSimon J. Gerratyis set to the value
25022f2a5ecdSSimon J. Gerraty.Ql 1003.2
25032f2a5ecdSSimon J. Gerratyand the makefile
25042f2a5ecdSSimon J. Gerraty.Ql <posix.mk>
25052f2a5ecdSSimon J. Gerratyis included if it exists,
25062f2a5ecdSSimon J. Gerratyto provide POSIX-compatible default rules.
25071d3f2ddcSSimon J. GerratyIf
25081d3f2ddcSSimon J. Gerraty.Nm
25091d3f2ddcSSimon J. Gerratyis run with the
25101d3f2ddcSSimon J. Gerraty.Fl r
25114fde40d9SSimon J. Gerratyflag, only
25121d3f2ddcSSimon J. Gerraty.Ql posix.mk
25134fde40d9SSimon J. Gerratycontributes to the default rules.
25143955d011SMarcel Moolenaar.It Ic .PRECIOUS
25153955d011SMarcel MoolenaarApply the
25163955d011SMarcel Moolenaar.Ic .PRECIOUS
25173955d011SMarcel Moolenaarattribute to any specified sources.
25183955d011SMarcel MoolenaarIf no sources are specified, the
25193955d011SMarcel Moolenaar.Ic .PRECIOUS
25204fde40d9SSimon J. Gerratyattribute is applied to every target in the file.
25214fde40d9SSimon J. Gerraty.It Ic .READONLY
25224fde40d9SSimon J. Gerratyset the read-only attribute on the global variables specified as sources.
25233955d011SMarcel Moolenaar.It Ic .SHELL
25243955d011SMarcel MoolenaarSets the shell that
25253955d011SMarcel Moolenaar.Nm
25264fde40d9SSimon J. Gerratyuses to execute commands in jobs mode.
25273955d011SMarcel MoolenaarThe sources are a set of
25284fde40d9SSimon J. Gerraty.Ar field\| Ns Cm \&= Ns Ar value
25293955d011SMarcel Moolenaarpairs.
25304fde40d9SSimon J. Gerraty.Bl -tag -width ".Li hasErrCtls"
25314fde40d9SSimon J. Gerraty.It Li name
2532be19d90bSSimon J. GerratyThis is the minimal specification, used to select one of the built-in
25333955d011SMarcel Moolenaarshell specs;
25344fde40d9SSimon J. Gerraty.Li sh ,
25354fde40d9SSimon J. Gerraty.Li ksh ,
25363955d011SMarcel Moolenaarand
25374fde40d9SSimon J. Gerraty.Li csh .
25384fde40d9SSimon J. Gerraty.It Li path
25394fde40d9SSimon J. GerratySpecifies the absolute path to the shell.
25404fde40d9SSimon J. Gerraty.It Li hasErrCtl
25413955d011SMarcel MoolenaarIndicates whether the shell supports exit on error.
25424fde40d9SSimon J. Gerraty.It Li check
25433955d011SMarcel MoolenaarThe command to turn on error checking.
25444fde40d9SSimon J. Gerraty.It Li ignore
25453955d011SMarcel MoolenaarThe command to disable error checking.
25464fde40d9SSimon J. Gerraty.It Li echo
25473955d011SMarcel MoolenaarThe command to turn on echoing of commands executed.
25484fde40d9SSimon J. Gerraty.It Li quiet
25493955d011SMarcel MoolenaarThe command to turn off echoing of commands executed.
25504fde40d9SSimon J. Gerraty.It Li filter
25513955d011SMarcel MoolenaarThe output to filter after issuing the
25524fde40d9SSimon J. Gerraty.Li quiet
25533955d011SMarcel Moolenaarcommand.
25543955d011SMarcel MoolenaarIt is typically identical to
25554fde40d9SSimon J. Gerraty.Li quiet .
25564fde40d9SSimon J. Gerraty.It Li errFlag
25573955d011SMarcel MoolenaarThe flag to pass the shell to enable error checking.
25584fde40d9SSimon J. Gerraty.It Li echoFlag
25593955d011SMarcel MoolenaarThe flag to pass the shell to enable command echoing.
25604fde40d9SSimon J. Gerraty.It Li newline
25613955d011SMarcel MoolenaarThe string literal to pass the shell that results in a single newline
25623955d011SMarcel Moolenaarcharacter when used outside of any quoting characters.
25633955d011SMarcel Moolenaar.El
25643955d011SMarcel MoolenaarExample:
25653955d011SMarcel Moolenaar.Bd -literal
25663955d011SMarcel Moolenaar\&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \e
25673955d011SMarcel Moolenaar	check="set \-e" ignore="set +e" \e
25683955d011SMarcel Moolenaar	echo="set \-v" quiet="set +v" filter="set +v" \e
25693955d011SMarcel Moolenaar	echoFlag=v errFlag=e newline="'\en'"
25703955d011SMarcel Moolenaar.Ed
25713955d011SMarcel Moolenaar.It Ic .SILENT
25723955d011SMarcel MoolenaarApply the
25733955d011SMarcel Moolenaar.Ic .SILENT
25743955d011SMarcel Moolenaarattribute to any specified sources.
25753955d011SMarcel MoolenaarIf no sources are specified, the
25763955d011SMarcel Moolenaar.Ic .SILENT
25773955d011SMarcel Moolenaarattribute is applied to every
25783955d011SMarcel Moolenaarcommand in the file.
25791748de26SSimon J. Gerraty.It Ic .STALE
25801748de26SSimon J. GerratyThis target gets run when a dependency file contains stale entries, having
25811748de26SSimon J. Gerraty.Va .ALLSRC
25821748de26SSimon J. Gerratyset to the name of that dependency file.
25833955d011SMarcel Moolenaar.It Ic .SUFFIXES
25843955d011SMarcel MoolenaarEach source specifies a suffix to
25853955d011SMarcel Moolenaar.Nm .
25863955d011SMarcel MoolenaarIf no sources are specified, any previously specified suffixes are deleted.
25873955d011SMarcel MoolenaarIt allows the creation of suffix-transformation rules.
25883955d011SMarcel Moolenaar.Pp
25893955d011SMarcel MoolenaarExample:
25903955d011SMarcel Moolenaar.Bd -literal
25914fde40d9SSimon J. Gerraty\&.SUFFIXES: .c .o
25923955d011SMarcel Moolenaar\&.c.o:
25933955d011SMarcel Moolenaar	cc \-o ${.TARGET} \-c ${.IMPSRC}
25943955d011SMarcel Moolenaar.Ed
25954fde40d9SSimon J. Gerraty.It Ic .SYSPATH
25964fde40d9SSimon J. GerratyThe sources are directories which are to be added to the system
25974fde40d9SSimon J. Gerratyinclude path which
25984fde40d9SSimon J. Gerraty.Nm
25994fde40d9SSimon J. Gerratysearches for makefiles.
26004fde40d9SSimon J. GerratyIf no sources are specified,
26014fde40d9SSimon J. Gerratyany previously specified directories are removed from the system
26024fde40d9SSimon J. Gerratyinclude path.
26033955d011SMarcel Moolenaar.El
26043955d011SMarcel Moolenaar.Sh ENVIRONMENT
26053955d011SMarcel Moolenaar.Nm
26063955d011SMarcel Moolenaaruses the following environment variables, if they exist:
26073955d011SMarcel Moolenaar.Ev MACHINE ,
26083955d011SMarcel Moolenaar.Ev MACHINE_ARCH ,
26093955d011SMarcel Moolenaar.Ev MAKE ,
26103955d011SMarcel Moolenaar.Ev MAKEFLAGS ,
26113955d011SMarcel Moolenaar.Ev MAKEOBJDIR ,
26123955d011SMarcel Moolenaar.Ev MAKEOBJDIRPREFIX ,
26133955d011SMarcel Moolenaar.Ev MAKESYSPATH ,
26143955d011SMarcel Moolenaar.Ev PWD ,
26153955d011SMarcel Moolenaarand
26163955d011SMarcel Moolenaar.Ev TMPDIR .
26173955d011SMarcel Moolenaar.Pp
26183955d011SMarcel Moolenaar.Ev MAKEOBJDIRPREFIX
26193955d011SMarcel Moolenaarand
26203955d011SMarcel Moolenaar.Ev MAKEOBJDIR
26213955d011SMarcel Moolenaarmay only be set in the environment or on the command line to
26223955d011SMarcel Moolenaar.Nm
26233955d011SMarcel Moolenaarand not as makefile variables;
26243955d011SMarcel Moolenaarsee the description of
2625954401e6SSimon J. Gerraty.Sq Va .OBJDIR
26263955d011SMarcel Moolenaarfor more details.
26273955d011SMarcel Moolenaar.Sh FILES
26283955d011SMarcel Moolenaar.Bl -tag -width /usr/share/mk -compact
26293955d011SMarcel Moolenaar.It .depend
26303955d011SMarcel Moolenaarlist of dependencies
26313955d011SMarcel Moolenaar.It makefile
26324fde40d9SSimon J. Gerratyfirst default makefile if no makefile is specified on the command line
26334fde40d9SSimon J. Gerraty.It Makefile
26344fde40d9SSimon J. Gerratysecond default makefile if no makefile is specified on the command line
26353955d011SMarcel Moolenaar.It sys.mk
26363955d011SMarcel Moolenaarsystem makefile
26373955d011SMarcel Moolenaar.It /usr/share/mk
26383955d011SMarcel Moolenaarsystem makefile directory
26393955d011SMarcel Moolenaar.El
26403955d011SMarcel Moolenaar.Sh COMPATIBILITY
26414fde40d9SSimon J. GerratyThe basic make syntax is compatible between different make variants;
26423955d011SMarcel Moolenaarhowever the special variables, variable modifiers and conditionals are not.
2643db29cad8SSimon J. Gerraty.Ss Older versions
2644db29cad8SSimon J. GerratyAn incomplete list of changes in older versions of
2645db29cad8SSimon J. Gerraty.Nm :
26463955d011SMarcel Moolenaar.Pp
26473955d011SMarcel MoolenaarThe way that .for loop variables are substituted changed after
26483955d011SMarcel MoolenaarNetBSD 5.0
26493955d011SMarcel Moolenaarso that they still appear to be variable expansions.
26503955d011SMarcel MoolenaarIn particular this stops them being treated as syntax, and removes some
26513955d011SMarcel Moolenaarobscure problems using them in .if statements.
2652db29cad8SSimon J. Gerraty.Pp
2653db29cad8SSimon J. GerratyThe way that parallel makes are scheduled changed in
2654db29cad8SSimon J. GerratyNetBSD 4.0
2655db29cad8SSimon J. Gerratyso that .ORDER and .WAIT apply recursively to the dependent nodes.
2656db29cad8SSimon J. GerratyThe algorithms used may change again in the future.
2657db29cad8SSimon J. Gerraty.Ss Other make dialects
2658db29cad8SSimon J. GerratyOther make dialects (GNU make, SVR4 make, POSIX make, etc.) do not
2659db29cad8SSimon J. Gerratysupport most of the features of
2660db29cad8SSimon J. Gerraty.Nm
2661db29cad8SSimon J. Gerratyas described in this manual.
2662db29cad8SSimon J. GerratyMost notably:
2663db29cad8SSimon J. Gerraty.Bl -bullet -offset indent
2664db29cad8SSimon J. Gerraty.It
2665db29cad8SSimon J. GerratyThe
2666db29cad8SSimon J. Gerraty.Ic .WAIT
2667db29cad8SSimon J. Gerratyand
2668db29cad8SSimon J. Gerraty.Ic .ORDER
2669db29cad8SSimon J. Gerratydeclarations and most functionality pertaining to parallelization.
26704fde40d9SSimon J. Gerraty(GNU make supports parallelization but lacks the features needed to
2671db29cad8SSimon J. Gerratycontrol it effectively.)
2672db29cad8SSimon J. Gerraty.It
2673db29cad8SSimon J. GerratyDirectives, including for loops and conditionals and most of the
2674db29cad8SSimon J. Gerratyforms of include files.
2675db29cad8SSimon J. Gerraty(GNU make has its own incompatible and less powerful syntax for
2676db29cad8SSimon J. Gerratyconditionals.)
26774fde40d9SSimon J. Gerraty.\" The "less powerful" above means that GNU make does not have the
26784fde40d9SSimon J. Gerraty.\" make(target), target(target) and commands(target) functions.
2679db29cad8SSimon J. Gerraty.It
2680db29cad8SSimon J. GerratyAll built-in variables that begin with a dot.
2681db29cad8SSimon J. Gerraty.It
2682db29cad8SSimon J. GerratyMost of the special sources and targets that begin with a dot,
2683db29cad8SSimon J. Gerratywith the notable exception of
2684db29cad8SSimon J. Gerraty.Ic .PHONY ,
2685db29cad8SSimon J. Gerraty.Ic .PRECIOUS ,
2686db29cad8SSimon J. Gerratyand
2687db29cad8SSimon J. Gerraty.Ic .SUFFIXES .
2688db29cad8SSimon J. Gerraty.It
2689db29cad8SSimon J. GerratyVariable modifiers, except for the
26904fde40d9SSimon J. Gerraty.Ql :old=new
2691db29cad8SSimon J. Gerratystring substitution, which does not portably support globbing with
2692db29cad8SSimon J. Gerraty.Ql %
2693db29cad8SSimon J. Gerratyand historically only works on declared suffixes.
2694db29cad8SSimon J. Gerraty.It
2695db29cad8SSimon J. GerratyThe
2696db29cad8SSimon J. Gerraty.Ic $>
2697db29cad8SSimon J. Gerratyvariable even in its short form; most makes support this functionality
2698db29cad8SSimon J. Gerratybut its name varies.
2699db29cad8SSimon J. Gerraty.El
2700db29cad8SSimon J. Gerraty.Pp
2701db29cad8SSimon J. GerratySome features are somewhat more portable, such as assignment with
2702db29cad8SSimon J. Gerraty.Ic += ,
2703db29cad8SSimon J. Gerraty.Ic ?= ,
2704db29cad8SSimon J. Gerratyand
2705db29cad8SSimon J. Gerraty.Ic != .
2706db29cad8SSimon J. GerratyThe
27074fde40d9SSimon J. Gerraty.Va .PATH
2708db29cad8SSimon J. Gerratyfunctionality is based on an older feature
2709db29cad8SSimon J. Gerraty.Ic VPATH
2710db29cad8SSimon J. Gerratyfound in GNU make and many versions of SVR4 make; however,
2711db29cad8SSimon J. Gerratyhistorically its behavior is too ill-defined (and too buggy) to rely
2712db29cad8SSimon J. Gerratyupon.
2713db29cad8SSimon J. Gerraty.Pp
2714db29cad8SSimon J. GerratyThe
2715db29cad8SSimon J. Gerraty.Ic $@
2716db29cad8SSimon J. Gerratyand
2717db29cad8SSimon J. Gerraty.Ic $<
2718db29cad8SSimon J. Gerratyvariables are more or less universally portable, as is the
2719db29cad8SSimon J. Gerraty.Ic $(MAKE)
2720db29cad8SSimon J. Gerratyvariable.
2721db29cad8SSimon J. GerratyBasic use of suffix rules (for files only in the current directory,
2722db29cad8SSimon J. Gerratynot trying to chain transformations together, etc.) is also reasonably
2723db29cad8SSimon J. Gerratyportable.
27243955d011SMarcel Moolenaar.Sh SEE ALSO
27253955d011SMarcel Moolenaar.Xr mkdep 1
27263955d011SMarcel Moolenaar.Sh HISTORY
27273955d011SMarcel Moolenaar.Nm
27283955d011SMarcel Moolenaaris derived from NetBSD
27293955d011SMarcel Moolenaar.Xr make 1 .
27303955d011SMarcel MoolenaarIt uses autoconf to facilitate portability to other platforms.
273193036677SSimon J. Gerraty.Pp
273293036677SSimon J. GerratyA
273393036677SSimon J. Gerratymake
273493036677SSimon J. Gerratycommand appeared in
273593036677SSimon J. Gerraty.At v7 .
273693036677SSimon J. GerratyThis
273793036677SSimon J. Gerratymake
27384fde40d9SSimon J. Gerratyimplementation is based on Adam de Boor's pmake program,
27394fde40d9SSimon J. Gerratywhich was written for Sprite at Berkeley.
274093036677SSimon J. GerratyIt was designed to be a parallel distributed make running jobs on different
274193036677SSimon J. Gerratymachines using a daemon called
274293036677SSimon J. Gerraty.Dq customs .
274351ee2c1cSSimon J. Gerraty.Pp
274451ee2c1cSSimon J. GerratyHistorically the target/dependency
27454fde40d9SSimon J. Gerraty.Ic FRC
274651ee2c1cSSimon J. Gerratyhas been used to FoRCe rebuilding (since the target/dependency
274751ee2c1cSSimon J. Gerratydoes not exist ... unless someone creates an
27484fde40d9SSimon J. Gerraty.Pa FRC
274951ee2c1cSSimon J. Gerratyfile).
275093036677SSimon J. Gerraty.Sh BUGS
275193036677SSimon J. GerratyThe
275293036677SSimon J. Gerratymake
27534fde40d9SSimon J. Gerratysyntax is difficult to parse.
2754ef0b2538SSimon J. GerratyFor instance, finding the end of a variable's use should involve scanning
2755ef0b2538SSimon J. Gerratyeach of the modifiers, using the correct terminator for each field.
275693036677SSimon J. GerratyIn many places
275793036677SSimon J. Gerratymake
275893036677SSimon J. Gerratyjust counts {} and () in order to find the end of a variable expansion.
275993036677SSimon J. Gerraty.Pp
276093036677SSimon J. GerratyThere is no way of escaping a space character in a filename.
27618c973ee2SSimon J. Gerraty.Pp
27628c973ee2SSimon J. GerratyIn jobs mode, when a target fails;
27638c973ee2SSimon J. Gerratymake
27648c973ee2SSimon J. Gerratywill put an error token into the job token pool.
27658c973ee2SSimon J. GerratyThis will cause all other instances of
27668c973ee2SSimon J. Gerratymake
27678c973ee2SSimon J. Gerratyusing that token pool to abort the build and exit with error code 6.
27688c973ee2SSimon J. GerratySometimes the attempt to suppress a cascade of unnecessary errors,
27698c973ee2SSimon J. Gerratycan result in a seemingly unexplained
27708c973ee2SSimon J. Gerraty.Ql *** Error code 6
2771