xref: /freebsd/contrib/bmake/bmake.1 (revision 494f719155c35fc5aef3d18a6a41f6dc7692cccc)
1*494f7191SSimon J. Gerraty.\"	$NetBSD: make.1,v 1.272 2018/04/02 04:26:17 dholland 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.\"
328695518cSSimon J. Gerraty.Dd June 22, 2017
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
4051ee2c1cSSimon J. Gerraty.Op Fl BeikNnqrstWwX
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
523955d011SMarcel Moolenaar.Op Ar variable=value
533955d011SMarcel Moolenaar.Op Ar target ...
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
613955d011SMarcel Moolenaarmakefile option is given,
623955d011SMarcel Moolenaar.Nm
633955d011SMarcel Moolenaarwill try to open
643955d011SMarcel Moolenaar.Ql Pa makefile
653955d011SMarcel Moolenaarthen
663955d011SMarcel Moolenaar.Ql Pa Makefile
673955d011SMarcel Moolenaarin order to find the specifications.
683955d011SMarcel MoolenaarIf the file
693955d011SMarcel Moolenaar.Ql Pa .depend
703955d011SMarcel Moolenaarexists, it is read (see
713955d011SMarcel Moolenaar.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
773955d011SMarcel Moolenaar.%T "PMake \- A Tutorial" .
783955d011SMarcel Moolenaar.Pp
793955d011SMarcel Moolenaar.Nm
803955d011SMarcel Moolenaarwill prepend the contents of the
813955d011SMarcel Moolenaar.Va MAKEFLAGS
823955d011SMarcel Moolenaarenvironment variable to the command line arguments before parsing them.
833955d011SMarcel Moolenaar.Pp
843955d011SMarcel MoolenaarThe options are as follows:
853955d011SMarcel Moolenaar.Bl -tag -width Ds
863955d011SMarcel Moolenaar.It Fl B
873955d011SMarcel MoolenaarTry to be backwards compatible by executing a single shell per command and
883955d011SMarcel Moolenaarby executing the commands to make the sources of a dependency line in sequence.
893955d011SMarcel Moolenaar.It Fl C Ar directory
903955d011SMarcel MoolenaarChange to
913955d011SMarcel Moolenaar.Ar directory
923955d011SMarcel Moolenaarbefore reading the makefiles or doing anything else.
933955d011SMarcel MoolenaarIf multiple
943955d011SMarcel Moolenaar.Fl C
953955d011SMarcel Moolenaaroptions are specified, each is interpreted relative to the previous one:
963955d011SMarcel Moolenaar.Fl C Pa / Fl C Pa etc
973955d011SMarcel Moolenaaris equivalent to
983955d011SMarcel Moolenaar.Fl C Pa /etc .
993955d011SMarcel Moolenaar.It Fl D Ar variable
1003955d011SMarcel MoolenaarDefine
1013955d011SMarcel Moolenaar.Ar variable
1023955d011SMarcel Moolenaarto be 1, in the global context.
1033955d011SMarcel Moolenaar.It Fl d Ar [-]flags
1043955d011SMarcel MoolenaarTurn on debugging, and specify which portions of
1053955d011SMarcel Moolenaar.Nm
1063955d011SMarcel Moolenaarare to print debugging information.
1073955d011SMarcel MoolenaarUnless the flags are preceded by
1083955d011SMarcel Moolenaar.Ql \-
1093955d011SMarcel Moolenaarthey are added to the
1103955d011SMarcel Moolenaar.Va MAKEFLAGS
1113955d011SMarcel Moolenaarenvironment variable and will be processed by any child make processes.
1123955d011SMarcel MoolenaarBy default, debugging information is printed to standard error,
1133955d011SMarcel Moolenaarbut this can be changed using the
1143955d011SMarcel Moolenaar.Ar F
1153955d011SMarcel Moolenaardebugging flag.
1163955d011SMarcel MoolenaarThe debugging output is always unbuffered; in addition, if debugging
1173955d011SMarcel Moolenaaris enabled but debugging output is not directed to standard output,
1183955d011SMarcel Moolenaarthen the standard output is line buffered.
1193955d011SMarcel Moolenaar.Ar Flags
1203955d011SMarcel Moolenaaris one or more of the following:
1213955d011SMarcel Moolenaar.Bl -tag -width Ds
1223955d011SMarcel Moolenaar.It Ar A
1233955d011SMarcel MoolenaarPrint all possible debugging information;
1243955d011SMarcel Moolenaarequivalent to specifying all of the debugging flags.
1253955d011SMarcel Moolenaar.It Ar a
1263955d011SMarcel MoolenaarPrint debugging information about archive searching and caching.
1273955d011SMarcel Moolenaar.It Ar C
1283955d011SMarcel MoolenaarPrint debugging information about current working directory.
1293955d011SMarcel Moolenaar.It Ar c
1303955d011SMarcel MoolenaarPrint debugging information about conditional evaluation.
1313955d011SMarcel Moolenaar.It Ar d
1323955d011SMarcel MoolenaarPrint debugging information about directory searching and caching.
1333955d011SMarcel Moolenaar.It Ar e
1343955d011SMarcel MoolenaarPrint debugging information about failed commands and targets.
1353955d011SMarcel Moolenaar.It Ar F Ns Oo Sy \&+ Oc Ns Ar filename
1363955d011SMarcel MoolenaarSpecify where debugging output is written.
1373955d011SMarcel MoolenaarThis must be the last flag, because it consumes the remainder of
1383955d011SMarcel Moolenaarthe argument.
1393955d011SMarcel MoolenaarIf the character immediately after the
1403955d011SMarcel Moolenaar.Ql F
1413955d011SMarcel Moolenaarflag is
1423955d011SMarcel Moolenaar.Ql \&+ ,
1433955d011SMarcel Moolenaarthen the file will be opened in append mode;
1443955d011SMarcel Moolenaarotherwise the file will be overwritten.
1453955d011SMarcel MoolenaarIf the file name is
1463955d011SMarcel Moolenaar.Ql stdout
1473955d011SMarcel Moolenaaror
1483955d011SMarcel Moolenaar.Ql stderr
1493955d011SMarcel Moolenaarthen debugging output will be written to the
1503955d011SMarcel Moolenaarstandard output or standard error output file descriptors respectively
1513955d011SMarcel Moolenaar(and the
1523955d011SMarcel Moolenaar.Ql \&+
1533955d011SMarcel Moolenaaroption has no effect).
1543955d011SMarcel MoolenaarOtherwise, the output will be written to the named file.
1553955d011SMarcel MoolenaarIf the file name ends
1563955d011SMarcel Moolenaar.Ql .%d
1573955d011SMarcel Moolenaarthen the
1583955d011SMarcel Moolenaar.Ql %d
1593955d011SMarcel Moolenaaris replaced by the pid.
1603955d011SMarcel Moolenaar.It Ar f
1613955d011SMarcel MoolenaarPrint debugging information about loop evaluation.
1623955d011SMarcel Moolenaar.It Ar "g1"
1633955d011SMarcel MoolenaarPrint the input graph before making anything.
1643955d011SMarcel Moolenaar.It Ar "g2"
1653955d011SMarcel MoolenaarPrint the input graph after making everything, or before exiting
1663955d011SMarcel Moolenaaron error.
1673955d011SMarcel Moolenaar.It Ar "g3"
1683955d011SMarcel MoolenaarPrint the input graph before exiting on error.
1693955d011SMarcel Moolenaar.It Ar j
1703955d011SMarcel MoolenaarPrint debugging information about running multiple shells.
1713955d011SMarcel Moolenaar.It Ar l
1723955d011SMarcel MoolenaarPrint commands in Makefiles regardless of whether or not they are prefixed by
1733955d011SMarcel Moolenaar.Ql @
1743955d011SMarcel Moolenaaror other "quiet" flags.
1753955d011SMarcel MoolenaarAlso known as "loud" behavior.
1763955d011SMarcel Moolenaar.It Ar M
1773955d011SMarcel MoolenaarPrint debugging information about "meta" mode decisions about targets.
1783955d011SMarcel Moolenaar.It Ar m
1793955d011SMarcel MoolenaarPrint debugging information about making targets, including modification
1803955d011SMarcel Moolenaardates.
1813955d011SMarcel Moolenaar.It Ar n
1823955d011SMarcel MoolenaarDon't delete the temporary command scripts created when running commands.
1833955d011SMarcel MoolenaarThese temporary scripts are created in the directory
1843955d011SMarcel Moolenaarreferred to by the
1853955d011SMarcel Moolenaar.Ev TMPDIR
1863955d011SMarcel Moolenaarenvironment variable, or in
1873955d011SMarcel Moolenaar.Pa /tmp
1883955d011SMarcel Moolenaarif
1893955d011SMarcel Moolenaar.Ev TMPDIR
1903955d011SMarcel Moolenaaris unset or set to the empty string.
1913955d011SMarcel MoolenaarThe temporary scripts are created by
1923955d011SMarcel Moolenaar.Xr mkstemp 3 ,
1933955d011SMarcel Moolenaarand have names of the form
1943955d011SMarcel Moolenaar.Pa makeXXXXXX .
1953955d011SMarcel Moolenaar.Em NOTE :
1963955d011SMarcel MoolenaarThis can create many files in
1973955d011SMarcel Moolenaar.Ev TMPDIR
1983955d011SMarcel Moolenaaror
1993955d011SMarcel Moolenaar.Pa /tmp ,
2003955d011SMarcel Moolenaarso use with care.
2013955d011SMarcel Moolenaar.It Ar p
2023955d011SMarcel MoolenaarPrint debugging information about makefile parsing.
2033955d011SMarcel Moolenaar.It Ar s
2043955d011SMarcel MoolenaarPrint debugging information about suffix-transformation rules.
2053955d011SMarcel Moolenaar.It Ar t
2063955d011SMarcel MoolenaarPrint debugging information about target list maintenance.
2073955d011SMarcel Moolenaar.It Ar V
2083955d011SMarcel MoolenaarForce the
2093955d011SMarcel Moolenaar.Fl V
2108695518cSSimon J. Gerratyoption to print raw values of variables, overriding the default behavior
2118695518cSSimon J. Gerratyset via
2128695518cSSimon J. Gerraty.Va .MAKE.EXPAND_VARIABLES .
2133955d011SMarcel Moolenaar.It Ar v
2143955d011SMarcel MoolenaarPrint debugging information about variable assignment.
2153955d011SMarcel Moolenaar.It Ar x
2163955d011SMarcel MoolenaarRun shell commands with
2173955d011SMarcel Moolenaar.Fl x
2183955d011SMarcel Moolenaarso the actual commands are printed as they are executed.
2193955d011SMarcel Moolenaar.El
2203955d011SMarcel Moolenaar.It Fl e
2213955d011SMarcel MoolenaarSpecify that environment variables override macro assignments within
2223955d011SMarcel Moolenaarmakefiles.
2233955d011SMarcel Moolenaar.It Fl f Ar makefile
2243955d011SMarcel MoolenaarSpecify a makefile to read instead of the default
2253955d011SMarcel Moolenaar.Ql Pa makefile .
2263955d011SMarcel MoolenaarIf
2273955d011SMarcel Moolenaar.Ar makefile
2283955d011SMarcel Moolenaaris
2293955d011SMarcel Moolenaar.Ql Fl ,
2303955d011SMarcel Moolenaarstandard input is read.
2313955d011SMarcel MoolenaarMultiple makefiles may be specified, and are read in the order specified.
2323955d011SMarcel Moolenaar.It Fl I Ar directory
2333955d011SMarcel MoolenaarSpecify a directory in which to search for makefiles and included makefiles.
2343955d011SMarcel MoolenaarThe system makefile directory (or directories, see the
2353955d011SMarcel Moolenaar.Fl m
2363955d011SMarcel Moolenaaroption) is automatically included as part of this list.
2373955d011SMarcel Moolenaar.It Fl i
2383955d011SMarcel MoolenaarIgnore non-zero exit of shell commands in the makefile.
2393955d011SMarcel MoolenaarEquivalent to specifying
2403955d011SMarcel Moolenaar.Ql Fl
2413955d011SMarcel Moolenaarbefore each command line in the makefile.
2423955d011SMarcel Moolenaar.It Fl J Ar private
2433955d011SMarcel MoolenaarThis option should
2443955d011SMarcel Moolenaar.Em not
2453955d011SMarcel Moolenaarbe specified by the user.
2463955d011SMarcel Moolenaar.Pp
2473955d011SMarcel MoolenaarWhen the
2483955d011SMarcel Moolenaar.Ar j
2493955d011SMarcel Moolenaaroption is in use in a recursive build, this option is passed by a make
2503955d011SMarcel Moolenaarto child makes to allow all the make processes in the build to
2513955d011SMarcel Moolenaarcooperate to avoid overloading the system.
2523955d011SMarcel Moolenaar.It Fl j Ar max_jobs
2533955d011SMarcel MoolenaarSpecify the maximum number of jobs that
2543955d011SMarcel Moolenaar.Nm
2553955d011SMarcel Moolenaarmay have running at any one time.
2563955d011SMarcel MoolenaarThe value is saved in
2573955d011SMarcel Moolenaar.Va .MAKE.JOBS .
2583955d011SMarcel MoolenaarTurns compatibility mode off, unless the
2593955d011SMarcel Moolenaar.Ar B
2603955d011SMarcel Moolenaarflag is also specified.
2613955d011SMarcel MoolenaarWhen compatibility mode is off, all commands associated with a
2623955d011SMarcel Moolenaartarget are executed in a single shell invocation as opposed to the
2633955d011SMarcel Moolenaartraditional one shell invocation per line.
2643955d011SMarcel MoolenaarThis can break traditional scripts which change directories on each
2653955d011SMarcel Moolenaarcommand invocation and then expect to start with a fresh environment
2663955d011SMarcel Moolenaaron the next line.
2673955d011SMarcel MoolenaarIt is more efficient to correct the scripts rather than turn backwards
2683955d011SMarcel Moolenaarcompatibility on.
2693955d011SMarcel Moolenaar.It Fl k
2703955d011SMarcel MoolenaarContinue processing after errors are encountered, but only on those targets
2713955d011SMarcel Moolenaarthat do not depend on the target whose creation caused the error.
2723955d011SMarcel Moolenaar.It Fl m Ar directory
2733955d011SMarcel MoolenaarSpecify a directory in which to search for sys.mk and makefiles included
2743955d011SMarcel Moolenaarvia the
2753955d011SMarcel Moolenaar.Ao Ar file Ac Ns -style
2763955d011SMarcel Moolenaarinclude statement.
2773955d011SMarcel MoolenaarThe
2783955d011SMarcel Moolenaar.Fl m
2793955d011SMarcel Moolenaaroption can be used multiple times to form a search path.
2803955d011SMarcel MoolenaarThis path will override the default system include path: /usr/share/mk.
2813955d011SMarcel MoolenaarFurthermore the system include path will be appended to the search path used
2823955d011SMarcel Moolenaarfor
2833955d011SMarcel Moolenaar.Qo Ar file Qc Ns -style
2843955d011SMarcel Moolenaarinclude statements (see the
2853955d011SMarcel Moolenaar.Fl I
2863955d011SMarcel Moolenaaroption).
2873955d011SMarcel Moolenaar.Pp
2883955d011SMarcel MoolenaarIf a file or directory name in the
2893955d011SMarcel Moolenaar.Fl m
2903955d011SMarcel Moolenaarargument (or the
2913955d011SMarcel Moolenaar.Ev MAKESYSPATH
2923955d011SMarcel Moolenaarenvironment variable) starts with the string
2933955d011SMarcel Moolenaar.Qq \&.../
2943955d011SMarcel Moolenaarthen
2953955d011SMarcel Moolenaar.Nm
2963955d011SMarcel Moolenaarwill search for the specified file or directory named in the remaining part
2973955d011SMarcel Moolenaarof the argument string.
2983955d011SMarcel MoolenaarThe search starts with the current directory of
2993955d011SMarcel Moolenaarthe Makefile and then works upward towards the root of the file system.
3003955d011SMarcel MoolenaarIf the search is successful, then the resulting directory replaces the
3013955d011SMarcel Moolenaar.Qq \&.../
3023955d011SMarcel Moolenaarspecification in the
3033955d011SMarcel Moolenaar.Fl m
3043955d011SMarcel Moolenaarargument.
3053955d011SMarcel MoolenaarIf used, this feature allows
3063955d011SMarcel Moolenaar.Nm
3073955d011SMarcel Moolenaarto easily search in the current source tree for customized sys.mk files
3083955d011SMarcel Moolenaar(e.g., by using
3093955d011SMarcel Moolenaar.Qq \&.../mk/sys.mk
3103955d011SMarcel Moolenaaras an argument).
3113955d011SMarcel Moolenaar.It Fl n
3123955d011SMarcel MoolenaarDisplay the commands that would have been executed, but do not
3133955d011SMarcel Moolenaaractually execute them unless the target depends on the .MAKE special
3143955d011SMarcel Moolenaarsource (see below).
3153955d011SMarcel Moolenaar.It Fl N
3163955d011SMarcel MoolenaarDisplay the commands which would have been executed, but do not
3173955d011SMarcel Moolenaaractually execute any of them; useful for debugging top-level makefiles
3183955d011SMarcel Moolenaarwithout descending into subdirectories.
3193955d011SMarcel Moolenaar.It Fl q
3203955d011SMarcel MoolenaarDo not execute any commands, but exit 0 if the specified targets are
3213955d011SMarcel Moolenaarup-to-date and 1, otherwise.
3223955d011SMarcel Moolenaar.It Fl r
3233955d011SMarcel MoolenaarDo not use the built-in rules specified in the system makefile.
3243955d011SMarcel Moolenaar.It Fl s
3253955d011SMarcel MoolenaarDo not echo any commands as they are executed.
3263955d011SMarcel MoolenaarEquivalent to specifying
3273955d011SMarcel Moolenaar.Ql Ic @
3283955d011SMarcel Moolenaarbefore each command line in the makefile.
3293955d011SMarcel Moolenaar.It Fl T Ar tracefile
3303955d011SMarcel MoolenaarWhen used with the
3313955d011SMarcel Moolenaar.Fl j
3323955d011SMarcel Moolenaarflag,
3333955d011SMarcel Moolenaarappend a trace record to
3343955d011SMarcel Moolenaar.Ar tracefile
3353955d011SMarcel Moolenaarfor each job started and completed.
3363955d011SMarcel Moolenaar.It Fl t
3373955d011SMarcel MoolenaarRather than re-building a target as specified in the makefile, create it
3383955d011SMarcel Moolenaaror update its modification time to make it appear up-to-date.
3393955d011SMarcel Moolenaar.It Fl V Ar variable
3408695518cSSimon J. GerratyPrint the value of
3418695518cSSimon J. Gerraty.Ar variable .
3423955d011SMarcel MoolenaarDo not build any targets.
3433955d011SMarcel MoolenaarMultiple instances of this option may be specified;
3443955d011SMarcel Moolenaarthe variables will be printed one per line,
3453955d011SMarcel Moolenaarwith a blank line for each null or undefined variable.
3468695518cSSimon J. GerratyThe value printed is extracted from the global context after all
3478695518cSSimon J. Gerratymakefiles have been read.
3488695518cSSimon J. GerratyBy default, the raw variable contents (which may
3498695518cSSimon J. Gerratyinclude additional unexpanded variable references) are shown.
3503955d011SMarcel MoolenaarIf
3513955d011SMarcel Moolenaar.Ar variable
3523955d011SMarcel Moolenaarcontains a
3533955d011SMarcel Moolenaar.Ql \&$
3548695518cSSimon J. Gerratythen the value will be recursively expanded to its complete resultant
3558695518cSSimon J. Gerratytext before printing.
3568695518cSSimon J. GerratyThe expanded value will also be printed if
3578695518cSSimon J. Gerraty.Va .MAKE.EXPAND_VARIABLES
3588695518cSSimon J. Gerratyis set to true and
3598695518cSSimon J. Gerratythe
3608695518cSSimon J. Gerraty.Fl dV
3618695518cSSimon J. Gerratyoption has not been used to override it.
3628695518cSSimon J. GerratyNote that loop-local and target-local variables, as well as values
3638695518cSSimon J. Gerratytaken temporarily by global variables during makefile processing, are
3648695518cSSimon J. Gerratynot accessible via this option.
3658695518cSSimon J. GerratyThe
3668695518cSSimon J. Gerraty.Fl dv
3678695518cSSimon J. Gerratydebug mode can be used to see these at the cost of generating
3688695518cSSimon J. Gerratysubstantial extraneous output.
3698695518cSSimon J. Gerraty.It Fl v Ar variable
3708695518cSSimon J. GerratyLike
3718695518cSSimon J. Gerraty.Fl V
3728695518cSSimon J. Gerratybut the variable is always expanded to its complete value.
3733955d011SMarcel Moolenaar.It Fl W
3743955d011SMarcel MoolenaarTreat any warnings during makefile parsing as errors.
375db29cad8SSimon J. Gerraty.It Fl w
376db29cad8SSimon J. GerratyPrint entering and leaving directory messages, pre and post processing.
3773955d011SMarcel Moolenaar.It Fl X
3783955d011SMarcel MoolenaarDon't export variables passed on the command line to the environment
3793955d011SMarcel Moolenaarindividually.
3803955d011SMarcel MoolenaarVariables passed on the command line are still exported
3813955d011SMarcel Moolenaarvia the
3823955d011SMarcel Moolenaar.Va MAKEFLAGS
3833955d011SMarcel Moolenaarenvironment variable.
3843955d011SMarcel MoolenaarThis option may be useful on systems which have a small limit on the
3853955d011SMarcel Moolenaarsize of command arguments.
3863955d011SMarcel Moolenaar.It Ar variable=value
3873955d011SMarcel MoolenaarSet the value of the variable
3883955d011SMarcel Moolenaar.Ar variable
3893955d011SMarcel Moolenaarto
3903955d011SMarcel Moolenaar.Ar value .
3913955d011SMarcel MoolenaarNormally, all values passed on the command line are also exported to
3923955d011SMarcel Moolenaarsub-makes in the environment.
3933955d011SMarcel MoolenaarThe
3943955d011SMarcel Moolenaar.Fl X
3953955d011SMarcel Moolenaarflag disables this behavior.
3963955d011SMarcel MoolenaarVariable assignments should follow options for POSIX compatibility
3973955d011SMarcel Moolenaarbut no ordering is enforced.
3983955d011SMarcel Moolenaar.El
3993955d011SMarcel Moolenaar.Pp
4003955d011SMarcel MoolenaarThere are seven different types of lines in a makefile: file dependency
4013955d011SMarcel Moolenaarspecifications, shell commands, variable assignments, include statements,
4023955d011SMarcel Moolenaarconditional directives, for loops, and comments.
4033955d011SMarcel Moolenaar.Pp
4043955d011SMarcel MoolenaarIn general, lines may be continued from one line to the next by ending
4053955d011SMarcel Moolenaarthem with a backslash
4063955d011SMarcel Moolenaar.Pq Ql \e .
4073955d011SMarcel MoolenaarThe trailing newline character and initial whitespace on the following
4083955d011SMarcel Moolenaarline are compressed into a single space.
4093955d011SMarcel Moolenaar.Sh FILE DEPENDENCY SPECIFICATIONS
4103955d011SMarcel MoolenaarDependency lines consist of one or more targets, an operator, and zero
4113955d011SMarcel Moolenaaror more sources.
4123955d011SMarcel MoolenaarThis creates a relationship where the targets
4133955d011SMarcel Moolenaar.Dq depend
4143955d011SMarcel Moolenaaron the sources
4153955d011SMarcel Moolenaarand are usually created from them.
4163955d011SMarcel MoolenaarThe exact relationship between the target and the source is determined
4173955d011SMarcel Moolenaarby the operator that separates them.
4183955d011SMarcel MoolenaarThe three operators are as follows:
4193955d011SMarcel Moolenaar.Bl -tag -width flag
4203955d011SMarcel Moolenaar.It Ic \&:
4213955d011SMarcel MoolenaarA target is considered out-of-date if its modification time is less than
4223955d011SMarcel Moolenaarthose of any of its sources.
4233955d011SMarcel MoolenaarSources for a target accumulate over dependency lines when this operator
4243955d011SMarcel Moolenaaris used.
4253955d011SMarcel MoolenaarThe target is removed if
4263955d011SMarcel Moolenaar.Nm
4273955d011SMarcel Moolenaaris interrupted.
4283955d011SMarcel Moolenaar.It Ic \&!
4293955d011SMarcel MoolenaarTargets are always re-created, but not until all sources have been
4303955d011SMarcel Moolenaarexamined and re-created as necessary.
4313955d011SMarcel MoolenaarSources for a target accumulate over dependency lines when this operator
4323955d011SMarcel Moolenaaris used.
4333955d011SMarcel MoolenaarThe target is removed if
4343955d011SMarcel Moolenaar.Nm
4353955d011SMarcel Moolenaaris interrupted.
4363955d011SMarcel Moolenaar.It Ic \&::
4373955d011SMarcel MoolenaarIf no sources are specified, the target is always re-created.
4383955d011SMarcel MoolenaarOtherwise, a target is considered out-of-date if any of its sources has
4393955d011SMarcel Moolenaarbeen modified more recently than the target.
4403955d011SMarcel MoolenaarSources for a target do not accumulate over dependency lines when this
4413955d011SMarcel Moolenaaroperator is used.
4423955d011SMarcel MoolenaarThe target will not be removed if
4433955d011SMarcel Moolenaar.Nm
4443955d011SMarcel Moolenaaris interrupted.
4453955d011SMarcel Moolenaar.El
4463955d011SMarcel Moolenaar.Pp
4473955d011SMarcel MoolenaarTargets and sources may contain the shell wildcard values
4483955d011SMarcel Moolenaar.Ql \&? ,
4493955d011SMarcel Moolenaar.Ql * ,
4503955d011SMarcel Moolenaar.Ql [] ,
4513955d011SMarcel Moolenaarand
4523955d011SMarcel Moolenaar.Ql {} .
4533955d011SMarcel MoolenaarThe values
4543955d011SMarcel Moolenaar.Ql \&? ,
4553955d011SMarcel Moolenaar.Ql * ,
4563955d011SMarcel Moolenaarand
4573955d011SMarcel Moolenaar.Ql []
4583955d011SMarcel Moolenaarmay only be used as part of the final
4593955d011SMarcel Moolenaarcomponent of the target or source, and must be used to describe existing
4603955d011SMarcel Moolenaarfiles.
4613955d011SMarcel MoolenaarThe value
4623955d011SMarcel Moolenaar.Ql {}
4633955d011SMarcel Moolenaarneed not necessarily be used to describe existing files.
4643955d011SMarcel MoolenaarExpansion is in directory order, not alphabetically as done in the shell.
4653955d011SMarcel Moolenaar.Sh SHELL COMMANDS
466db29cad8SSimon J. GerratyEach target may have associated with it one or more lines of shell
467db29cad8SSimon J. Gerratycommands, normally
4683955d011SMarcel Moolenaarused to create the target.
469db29cad8SSimon J. GerratyEach of the lines in this script
4703955d011SMarcel Moolenaar.Em must
4713955d011SMarcel Moolenaarbe preceded by a tab.
472db29cad8SSimon J. Gerraty(For historical reasons, spaces are not accepted.)
473db29cad8SSimon J. GerratyWhile targets can appear in many dependency lines if desired, by
474db29cad8SSimon J. Gerratydefault only one of these rules may be followed by a creation
475db29cad8SSimon J. Gerratyscript.
476db29cad8SSimon J. GerratyIf the
4773955d011SMarcel Moolenaar.Ql Ic \&::
478db29cad8SSimon J. Gerratyoperator is used, however, all rules may include scripts and the
479db29cad8SSimon J. Gerratyscripts are executed in the order found.
4803955d011SMarcel Moolenaar.Pp
481db29cad8SSimon J. GerratyEach line is treated as a separate shell command, unless the end of
482db29cad8SSimon J. Gerratyline is escaped with a backslash
483db29cad8SSimon J. Gerraty.Pq Ql \e
484db29cad8SSimon J. Gerratyin which case that line and the next are combined.
485db29cad8SSimon J. Gerraty.\" The escaped newline is retained and passed to the shell, which
486db29cad8SSimon J. Gerraty.\" normally ignores it.
487db29cad8SSimon J. Gerraty.\" However, the tab at the beginning of the following line is removed.
488db29cad8SSimon J. GerratyIf the first characters of the command are any combination of
4893955d011SMarcel Moolenaar.Ql Ic @ ,
4903955d011SMarcel Moolenaar.Ql Ic + ,
4913955d011SMarcel Moolenaaror
4923955d011SMarcel Moolenaar.Ql Ic \- ,
4933955d011SMarcel Moolenaarthe command is treated specially.
4943955d011SMarcel MoolenaarA
4953955d011SMarcel Moolenaar.Ql Ic @
4963955d011SMarcel Moolenaarcauses the command not to be echoed before it is executed.
4973955d011SMarcel MoolenaarA
4983955d011SMarcel Moolenaar.Ql Ic +
4993955d011SMarcel Moolenaarcauses the command to be executed even when
5003955d011SMarcel Moolenaar.Fl n
5013955d011SMarcel Moolenaaris given.
5023955d011SMarcel MoolenaarThis is similar to the effect of the .MAKE special source,
5033955d011SMarcel Moolenaarexcept that the effect can be limited to a single line of a script.
5043955d011SMarcel MoolenaarA
5053955d011SMarcel Moolenaar.Ql Ic \-
506db29cad8SSimon J. Gerratyin compatibility mode
5073955d011SMarcel Moolenaarcauses any non-zero exit status of the command line to be ignored.
5083cbdda60SSimon J. Gerraty.Pp
5093cbdda60SSimon J. GerratyWhen
5103cbdda60SSimon J. Gerraty.Nm
5113cbdda60SSimon J. Gerratyis run in jobs mode with
5123cbdda60SSimon J. Gerraty.Fl j Ar max_jobs ,
5133cbdda60SSimon J. Gerratythe entire script for the target is fed to a
5143cbdda60SSimon J. Gerratysingle instance of the shell.
5153cbdda60SSimon J. GerratyIn compatibility (non-jobs) mode, each command is run in a separate process.
5163cbdda60SSimon J. GerratyIf the command contains any shell meta characters
5173cbdda60SSimon J. Gerraty.Pq Ql #=|^(){};&<>*?[]:$`\e\en
518db29cad8SSimon J. Gerratyit will be passed to the shell; otherwise
5193cbdda60SSimon J. Gerraty.Nm
5203cbdda60SSimon J. Gerratywill attempt direct execution.
521db29cad8SSimon J. GerratyIf a line starts with
522db29cad8SSimon J. Gerraty.Ql Ic \-
523db29cad8SSimon J. Gerratyand the shell has ErrCtl enabled then failure of the command line
524db29cad8SSimon J. Gerratywill be ignored as in compatibility mode.
525db29cad8SSimon J. GerratyOtherwise
526db29cad8SSimon J. Gerraty.Ql Ic \-
527db29cad8SSimon J. Gerratyaffects the entire job;
528db29cad8SSimon J. Gerratythe script will stop at the first command line that fails,
529db29cad8SSimon J. Gerratybut the target will not be deemed to have failed.
530db29cad8SSimon J. Gerraty.Pp
531db29cad8SSimon J. GerratyMakefiles should be written so that the mode of
532db29cad8SSimon J. Gerraty.Nm
533db29cad8SSimon J. Gerratyoperation does not change their behavior.
534db29cad8SSimon J. GerratyFor example, any command which needs to use
535db29cad8SSimon J. Gerraty.Dq cd
536db29cad8SSimon J. Gerratyor
537db29cad8SSimon J. Gerraty.Dq chdir
538db29cad8SSimon J. Gerratywithout potentially changing the directory for subsequent commands
539db29cad8SSimon J. Gerratyshould be put in parentheses so it executes in a subshell.
540db29cad8SSimon J. GerratyTo force the use of one shell, escape the line breaks so as to make
541db29cad8SSimon J. Gerratythe whole script one command.
542db29cad8SSimon J. GerratyFor example:
543db29cad8SSimon J. Gerraty.Bd -literal -offset indent
544db29cad8SSimon J. Gerratyavoid-chdir-side-effects:
545db29cad8SSimon J. Gerraty	@echo Building $@ in `pwd`
546db29cad8SSimon J. Gerraty	@(cd ${.CURDIR} && ${MAKE} $@)
547db29cad8SSimon J. Gerraty	@echo Back in `pwd`
548db29cad8SSimon J. Gerraty
549db29cad8SSimon J. Gerratyensure-one-shell-regardless-of-mode:
550db29cad8SSimon J. Gerraty	@echo Building $@ in `pwd`; \e
551db29cad8SSimon J. Gerraty	(cd ${.CURDIR} && ${MAKE} $@); \e
552db29cad8SSimon J. Gerraty	echo Back in `pwd`
553db29cad8SSimon J. Gerraty.Ed
5543cbdda60SSimon J. Gerraty.Pp
5553cbdda60SSimon J. GerratySince
5563cbdda60SSimon J. Gerraty.Nm
5573cbdda60SSimon J. Gerratywill
5583cbdda60SSimon J. Gerraty.Xr chdir 2
5593cbdda60SSimon J. Gerratyto
5603cbdda60SSimon J. Gerraty.Ql Va .OBJDIR
5613cbdda60SSimon J. Gerratybefore executing any targets, each child process
5623cbdda60SSimon J. Gerratystarts with that as its current working directory.
5633955d011SMarcel Moolenaar.Sh VARIABLE ASSIGNMENTS
5643955d011SMarcel MoolenaarVariables in make are much like variables in the shell, and, by tradition,
5653955d011SMarcel Moolenaarconsist of all upper-case letters.
5663955d011SMarcel Moolenaar.Ss Variable assignment modifiers
5673955d011SMarcel MoolenaarThe five operators that can be used to assign values to variables are as
5683955d011SMarcel Moolenaarfollows:
5693955d011SMarcel Moolenaar.Bl -tag -width Ds
5703955d011SMarcel Moolenaar.It Ic \&=
5713955d011SMarcel MoolenaarAssign the value to the variable.
5723955d011SMarcel MoolenaarAny previous value is overridden.
5733955d011SMarcel Moolenaar.It Ic \&+=
5743955d011SMarcel MoolenaarAppend the value to the current value of the variable.
5753955d011SMarcel Moolenaar.It Ic \&?=
5763955d011SMarcel MoolenaarAssign the value to the variable if it is not already defined.
5773955d011SMarcel Moolenaar.It Ic \&:=
5783955d011SMarcel MoolenaarAssign with expansion, i.e. expand the value before assigning it
5793955d011SMarcel Moolenaarto the variable.
5803955d011SMarcel MoolenaarNormally, expansion is not done until the variable is referenced.
5813955d011SMarcel Moolenaar.Em NOTE :
5823955d011SMarcel MoolenaarReferences to undefined variables are
5833955d011SMarcel Moolenaar.Em not
5843955d011SMarcel Moolenaarexpanded.
5853955d011SMarcel MoolenaarThis can cause problems when variable modifiers are used.
5863955d011SMarcel Moolenaar.It Ic \&!=
5873955d011SMarcel MoolenaarExpand the value and pass it to the shell for execution and assign
5883955d011SMarcel Moolenaarthe result to the variable.
5893955d011SMarcel MoolenaarAny newlines in the result are replaced with spaces.
5903955d011SMarcel Moolenaar.El
5913955d011SMarcel Moolenaar.Pp
5923955d011SMarcel MoolenaarAny white-space before the assigned
5933955d011SMarcel Moolenaar.Ar value
5943955d011SMarcel Moolenaaris removed; if the value is being appended, a single space is inserted
5953955d011SMarcel Moolenaarbetween the previous contents of the variable and the appended value.
5963955d011SMarcel Moolenaar.Pp
5973955d011SMarcel MoolenaarVariables are expanded by surrounding the variable name with either
5983955d011SMarcel Moolenaarcurly braces
5993955d011SMarcel Moolenaar.Pq Ql {}
6003955d011SMarcel Moolenaaror parentheses
6013955d011SMarcel Moolenaar.Pq Ql ()
6023955d011SMarcel Moolenaarand preceding it with
6033955d011SMarcel Moolenaara dollar sign
6043955d011SMarcel Moolenaar.Pq Ql \&$ .
6053955d011SMarcel MoolenaarIf the variable name contains only a single letter, the surrounding
6063955d011SMarcel Moolenaarbraces or parentheses are not required.
6073955d011SMarcel MoolenaarThis shorter form is not recommended.
6083955d011SMarcel Moolenaar.Pp
6093955d011SMarcel MoolenaarIf the variable name contains a dollar, then the name itself is expanded first.
6103955d011SMarcel MoolenaarThis allows almost arbitrary variable names, however names containing dollar,
6113955d011SMarcel Moolenaarbraces, parenthesis, or whitespace are really best avoided!
6123955d011SMarcel Moolenaar.Pp
6133955d011SMarcel MoolenaarIf the result of expanding a variable contains a dollar sign
6143955d011SMarcel Moolenaar.Pq Ql \&$
6153955d011SMarcel Moolenaarthe string is expanded again.
6163955d011SMarcel Moolenaar.Pp
6173955d011SMarcel MoolenaarVariable substitution occurs at three distinct times, depending on where
6183955d011SMarcel Moolenaarthe variable is being used.
6193955d011SMarcel Moolenaar.Bl -enum
6203955d011SMarcel Moolenaar.It
6213955d011SMarcel MoolenaarVariables in dependency lines are expanded as the line is read.
6223955d011SMarcel Moolenaar.It
6233955d011SMarcel MoolenaarVariables in shell commands are expanded when the shell command is
6243955d011SMarcel Moolenaarexecuted.
6253955d011SMarcel Moolenaar.It
6263955d011SMarcel Moolenaar.Dq .for
6273955d011SMarcel Moolenaarloop index variables are expanded on each loop iteration.
6283955d011SMarcel MoolenaarNote that other variables are not expanded inside loops so
6293955d011SMarcel Moolenaarthe following example code:
6303955d011SMarcel Moolenaar.Bd -literal -offset indent
6313955d011SMarcel Moolenaar
6323955d011SMarcel Moolenaar.Dv .for i in 1 2 3
6333955d011SMarcel Moolenaara+=     ${i}
6343955d011SMarcel Moolenaarj=      ${i}
6353955d011SMarcel Moolenaarb+=     ${j}
6363955d011SMarcel Moolenaar.Dv .endfor
6373955d011SMarcel Moolenaar
6383955d011SMarcel Moolenaarall:
6393955d011SMarcel Moolenaar	@echo ${a}
6403955d011SMarcel Moolenaar	@echo ${b}
6413955d011SMarcel Moolenaar
6423955d011SMarcel Moolenaar.Ed
6433955d011SMarcel Moolenaarwill print:
6443955d011SMarcel Moolenaar.Bd -literal -offset indent
6453955d011SMarcel Moolenaar1 2 3
6463955d011SMarcel Moolenaar3 3 3
6473955d011SMarcel Moolenaar
6483955d011SMarcel Moolenaar.Ed
6493955d011SMarcel MoolenaarBecause while ${a} contains
6503955d011SMarcel Moolenaar.Dq 1 2 3
6513955d011SMarcel Moolenaarafter the loop is executed, ${b}
6523955d011SMarcel Moolenaarcontains
6533955d011SMarcel Moolenaar.Dq ${j} ${j} ${j}
6543955d011SMarcel Moolenaarwhich expands to
6553955d011SMarcel Moolenaar.Dq 3 3 3
6563955d011SMarcel Moolenaarsince after the loop completes ${j} contains
6573955d011SMarcel Moolenaar.Dq 3 .
6583955d011SMarcel Moolenaar.El
6593955d011SMarcel Moolenaar.Ss Variable classes
6603955d011SMarcel MoolenaarThe four different classes of variables (in order of increasing precedence)
6613955d011SMarcel Moolenaarare:
6623955d011SMarcel Moolenaar.Bl -tag -width Ds
6633955d011SMarcel Moolenaar.It Environment variables
6643955d011SMarcel MoolenaarVariables defined as part of
6653955d011SMarcel Moolenaar.Nm Ns 's
6663955d011SMarcel Moolenaarenvironment.
6673955d011SMarcel Moolenaar.It Global variables
6683955d011SMarcel MoolenaarVariables defined in the makefile or in included makefiles.
6693955d011SMarcel Moolenaar.It Command line variables
6703955d011SMarcel MoolenaarVariables defined as part of the command line.
6713955d011SMarcel Moolenaar.It Local variables
6723955d011SMarcel MoolenaarVariables that are defined specific to a certain target.
673db29cad8SSimon J. Gerraty.El
674db29cad8SSimon J. Gerraty.Pp
675db29cad8SSimon J. GerratyLocal variables are all built in and their values vary magically from
676db29cad8SSimon J. Gerratytarget to target.
677db29cad8SSimon J. GerratyIt is not currently possible to define new local variables.
6783955d011SMarcel MoolenaarThe seven local variables are as follows:
679db29cad8SSimon J. Gerraty.Bl -tag -width ".ARCHIVE" -offset indent
6803955d011SMarcel Moolenaar.It Va .ALLSRC
6813955d011SMarcel MoolenaarThe list of all sources for this target; also known as
6828695518cSSimon J. Gerraty.Ql Va \&> .
6833955d011SMarcel Moolenaar.It Va .ARCHIVE
684db29cad8SSimon J. GerratyThe name of the archive file; also known as
685db29cad8SSimon J. Gerraty.Ql Va \&! .
6863955d011SMarcel Moolenaar.It Va .IMPSRC
6873955d011SMarcel MoolenaarIn suffix-transformation rules, the name/path of the source from which the
6883955d011SMarcel Moolenaartarget is to be transformed (the
6893955d011SMarcel Moolenaar.Dq implied
6903955d011SMarcel Moolenaarsource); also known as
6918695518cSSimon J. Gerraty.Ql Va \&< .
6923955d011SMarcel MoolenaarIt is not defined in explicit rules.
6933955d011SMarcel Moolenaar.It Va .MEMBER
694db29cad8SSimon J. GerratyThe name of the archive member; also known as
695db29cad8SSimon J. Gerraty.Ql Va % .
6963955d011SMarcel Moolenaar.It Va .OODATE
6973955d011SMarcel MoolenaarThe list of sources for this target that were deemed out-of-date; also
6983955d011SMarcel Moolenaarknown as
6993955d011SMarcel Moolenaar.Ql Va \&? .
7003955d011SMarcel Moolenaar.It Va .PREFIX
7013955d011SMarcel MoolenaarThe file prefix of the target, containing only the file portion, no suffix
7023955d011SMarcel Moolenaaror preceding directory components; also known as
7033955d011SMarcel Moolenaar.Ql Va * .
704db29cad8SSimon J. GerratyThe suffix must be one of the known suffixes declared with
705db29cad8SSimon J. Gerraty.Ic .SUFFIXES
706db29cad8SSimon J. Gerratyor it will not be recognized.
7073955d011SMarcel Moolenaar.It Va .TARGET
7083955d011SMarcel MoolenaarThe name of the target; also known as
7093955d011SMarcel Moolenaar.Ql Va @ .
7103bebe729SSimon J. GerratyFor compatibility with other makes this is an alias for
7113bebe729SSimon J. Gerraty.Ic .ARCHIVE
7123bebe729SSimon J. Gerratyin archive member rules.
7133955d011SMarcel Moolenaar.El
7143955d011SMarcel Moolenaar.Pp
7153955d011SMarcel MoolenaarThe shorter forms
7168695518cSSimon J. Gerraty.Ql ( Va > ,
717db29cad8SSimon J. Gerraty.Ql Va \&! ,
7188695518cSSimon J. Gerraty.Ql Va < ,
719db29cad8SSimon J. Gerraty.Ql Va % ,
7203955d011SMarcel Moolenaar.Ql Va \&? ,
721db29cad8SSimon J. Gerraty.Ql Va * ,
7223955d011SMarcel Moolenaarand
723db29cad8SSimon J. Gerraty.Ql Va @ )
7243955d011SMarcel Moolenaarare permitted for backward
725db29cad8SSimon J. Gerratycompatibility with historical makefiles and legacy POSIX make and are
726db29cad8SSimon J. Gerratynot recommended.
727db29cad8SSimon J. Gerraty.Pp
728db29cad8SSimon J. GerratyVariants of these variables with the punctuation followed immediately by
729db29cad8SSimon J. Gerraty.Ql D
730db29cad8SSimon J. Gerratyor
731db29cad8SSimon J. Gerraty.Ql F ,
732db29cad8SSimon J. Gerratye.g.
733db29cad8SSimon J. Gerraty.Ql Va $(@D) ,
734db29cad8SSimon J. Gerratyare legacy forms equivalent to using the
735db29cad8SSimon J. Gerraty.Ql :H
7363955d011SMarcel Moolenaarand
737db29cad8SSimon J. Gerraty.Ql :T
738db29cad8SSimon J. Gerratymodifiers.
739db29cad8SSimon J. GerratyThese forms are accepted for compatibility with
7403955d011SMarcel Moolenaar.At V
741db29cad8SSimon J. Gerratymakefiles and POSIX but are not recommended.
7423955d011SMarcel Moolenaar.Pp
7433955d011SMarcel MoolenaarFour of the local variables may be used in sources on dependency lines
7443955d011SMarcel Moolenaarbecause they expand to the proper value for each target on the line.
7453955d011SMarcel MoolenaarThese variables are
7463955d011SMarcel Moolenaar.Ql Va .TARGET ,
7473955d011SMarcel Moolenaar.Ql Va .PREFIX ,
7483955d011SMarcel Moolenaar.Ql Va .ARCHIVE ,
7493955d011SMarcel Moolenaarand
7503955d011SMarcel Moolenaar.Ql Va .MEMBER .
7513955d011SMarcel Moolenaar.Ss Additional built-in variables
7523955d011SMarcel MoolenaarIn addition,
7533955d011SMarcel Moolenaar.Nm
7543955d011SMarcel Moolenaarsets or knows about the following variables:
7553955d011SMarcel Moolenaar.Bl -tag -width .MAKEOVERRIDES
7563955d011SMarcel Moolenaar.It Va \&$
7573955d011SMarcel MoolenaarA single dollar sign
7583955d011SMarcel Moolenaar.Ql \&$ ,
7593955d011SMarcel Moolenaari.e.
7603955d011SMarcel Moolenaar.Ql \&$$
7613955d011SMarcel Moolenaarexpands to a single dollar
7623955d011SMarcel Moolenaarsign.
7633955d011SMarcel Moolenaar.It Va .ALLTARGETS
7643955d011SMarcel MoolenaarThe list of all targets encountered in the Makefile.
7653955d011SMarcel MoolenaarIf evaluated during
7663955d011SMarcel MoolenaarMakefile parsing, lists only those targets encountered thus far.
7673955d011SMarcel Moolenaar.It Va .CURDIR
7683955d011SMarcel MoolenaarA path to the directory where
7693955d011SMarcel Moolenaar.Nm
7703955d011SMarcel Moolenaarwas executed.
7713955d011SMarcel MoolenaarRefer to the description of
7723955d011SMarcel Moolenaar.Ql Ev PWD
7733955d011SMarcel Moolenaarfor more details.
7745bcb7424SSimon J. Gerraty.It Va .INCLUDEDFROMDIR
7755bcb7424SSimon J. GerratyThe directory of the file this Makefile was included from.
7765bcb7424SSimon J. Gerraty.It Va .INCLUDEDFROMFILE
7775bcb7424SSimon J. GerratyThe filename of the file this Makefile was included from.
7783955d011SMarcel Moolenaar.It Ev MAKE
7793955d011SMarcel MoolenaarThe name that
7803955d011SMarcel Moolenaar.Nm
7813955d011SMarcel Moolenaarwas executed with
7823955d011SMarcel Moolenaar.Pq Va argv[0] .
7833955d011SMarcel MoolenaarFor compatibility
7843955d011SMarcel Moolenaar.Nm
7853955d011SMarcel Moolenaaralso sets
7863955d011SMarcel Moolenaar.Va .MAKE
7873955d011SMarcel Moolenaarwith the same value.
7883955d011SMarcel MoolenaarThe preferred variable to use is the environment variable
7893955d011SMarcel Moolenaar.Ev MAKE
7903955d011SMarcel Moolenaarbecause it is more compatible with other versions of
7913955d011SMarcel Moolenaar.Nm
7923955d011SMarcel Moolenaarand cannot be confused with the special target with the same name.
7933955d011SMarcel Moolenaar.It Va .MAKE.DEPENDFILE
7943955d011SMarcel MoolenaarNames the makefile (default
7953955d011SMarcel Moolenaar.Ql Pa .depend )
7963955d011SMarcel Moolenaarfrom which generated dependencies are read.
7973955d011SMarcel Moolenaar.It Va .MAKE.EXPAND_VARIABLES
7983955d011SMarcel MoolenaarA boolean that controls the default behavior of the
7993955d011SMarcel Moolenaar.Fl V
8003955d011SMarcel Moolenaaroption.
8018695518cSSimon J. GerratyIf true, variable values printed with
8028695518cSSimon J. Gerraty.Fl V
8038695518cSSimon J. Gerratyare fully expanded; if false, the raw variable contents (which may
8048695518cSSimon J. Gerratyinclude additional unexpanded variable references) are shown.
8053955d011SMarcel Moolenaar.It Va .MAKE.EXPORTED
8063955d011SMarcel MoolenaarThe list of variables exported by
8073955d011SMarcel Moolenaar.Nm .
8083955d011SMarcel Moolenaar.It Va .MAKE.JOBS
8093955d011SMarcel MoolenaarThe argument to the
8103955d011SMarcel Moolenaar.Fl j
8113955d011SMarcel Moolenaaroption.
8123955d011SMarcel Moolenaar.It Va .MAKE.JOB.PREFIX
8133955d011SMarcel MoolenaarIf
8143955d011SMarcel Moolenaar.Nm
8153955d011SMarcel Moolenaaris run with
8163955d011SMarcel Moolenaar.Ar j
8173955d011SMarcel Moolenaarthen output for each target is prefixed with a token
8183955d011SMarcel Moolenaar.Ql --- target ---
8193955d011SMarcel Moolenaarthe first part of which can be controlled via
8203955d011SMarcel Moolenaar.Va .MAKE.JOB.PREFIX .
82151ee2c1cSSimon J. GerratyIf
82251ee2c1cSSimon J. Gerraty.Va .MAKE.JOB.PREFIX
82351ee2c1cSSimon J. Gerratyis empty, no token is printed.
8243955d011SMarcel Moolenaar.br
8253955d011SMarcel MoolenaarFor example:
8263955d011SMarcel Moolenaar.Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
8273955d011SMarcel Moolenaarwould produce tokens like
8283955d011SMarcel Moolenaar.Ql ---make[1234] target ---
8293955d011SMarcel Moolenaarmaking it easier to track the degree of parallelism being achieved.
8303955d011SMarcel Moolenaar.It Ev MAKEFLAGS
8313955d011SMarcel MoolenaarThe environment variable
8323955d011SMarcel Moolenaar.Ql Ev MAKEFLAGS
8333955d011SMarcel Moolenaarmay contain anything that
8343955d011SMarcel Moolenaarmay be specified on
8353955d011SMarcel Moolenaar.Nm Ns 's
8363955d011SMarcel Moolenaarcommand line.
8373955d011SMarcel MoolenaarAnything specified on
8383955d011SMarcel Moolenaar.Nm Ns 's
8393955d011SMarcel Moolenaarcommand line is appended to the
8403955d011SMarcel Moolenaar.Ql Ev MAKEFLAGS
8413955d011SMarcel Moolenaarvariable which is then
8423955d011SMarcel Moolenaarentered into the environment for all programs which
8433955d011SMarcel Moolenaar.Nm
8443955d011SMarcel Moolenaarexecutes.
8453955d011SMarcel Moolenaar.It Va .MAKE.LEVEL
8463955d011SMarcel MoolenaarThe recursion depth of
8473955d011SMarcel Moolenaar.Nm .
8483955d011SMarcel MoolenaarThe initial instance of
8493955d011SMarcel Moolenaar.Nm
8503955d011SMarcel Moolenaarwill be 0, and an incremented value is put into the environment
8513955d011SMarcel Moolenaarto be seen by the next generation.
8523955d011SMarcel MoolenaarThis allows tests like:
8533955d011SMarcel Moolenaar.Li .if ${.MAKE.LEVEL} == 0
8543955d011SMarcel Moolenaarto protect things which should only be evaluated in the initial instance of
8553955d011SMarcel Moolenaar.Nm .
8563955d011SMarcel Moolenaar.It Va .MAKE.MAKEFILE_PREFERENCE
8573955d011SMarcel MoolenaarThe ordered list of makefile names
8583955d011SMarcel Moolenaar(default
8593955d011SMarcel Moolenaar.Ql Pa makefile ,
8603955d011SMarcel Moolenaar.Ql Pa Makefile )
8613955d011SMarcel Moolenaarthat
8623955d011SMarcel Moolenaar.Nm
8633955d011SMarcel Moolenaarwill look for.
8643955d011SMarcel Moolenaar.It Va .MAKE.MAKEFILES
8653955d011SMarcel MoolenaarThe list of makefiles read by
8663955d011SMarcel Moolenaar.Nm ,
8673955d011SMarcel Moolenaarwhich is useful for tracking dependencies.
8683955d011SMarcel MoolenaarEach makefile is recorded only once, regardless of the number of times read.
8693955d011SMarcel Moolenaar.It Va .MAKE.MODE
8703955d011SMarcel MoolenaarProcessed after reading all makefiles.
8713955d011SMarcel MoolenaarCan affect the mode that
8723955d011SMarcel Moolenaar.Nm
8733955d011SMarcel Moolenaarruns in.
8743955d011SMarcel MoolenaarIt can contain a number of keywords:
875b778b302SSimon J. Gerraty.Bl -hang -width missing-filemon=bf.
8763955d011SMarcel Moolenaar.It Pa compat
8773955d011SMarcel MoolenaarLike
8783955d011SMarcel Moolenaar.Fl B ,
8793955d011SMarcel Moolenaarputs
8803955d011SMarcel Moolenaar.Nm
8813955d011SMarcel Moolenaarinto "compat" mode.
8823955d011SMarcel Moolenaar.It Pa meta
8833955d011SMarcel MoolenaarPuts
8843955d011SMarcel Moolenaar.Nm
8853955d011SMarcel Moolenaarinto "meta" mode, where meta files are created for each target
8863955d011SMarcel Moolenaarto capture the command run, the output generated and if
8873955d011SMarcel Moolenaar.Xr filemon 4
8883955d011SMarcel Moolenaaris available, the system calls which are of interest to
8893955d011SMarcel Moolenaar.Nm .
8903955d011SMarcel MoolenaarThe captured output can be very useful when diagnosing errors.
8913955d011SMarcel Moolenaar.It Pa curdirOk= Ar bf
8923955d011SMarcel MoolenaarNormally
8933955d011SMarcel Moolenaar.Nm
8943955d011SMarcel Moolenaarwill not create .meta files in
8953955d011SMarcel Moolenaar.Ql Va .CURDIR .
8963955d011SMarcel MoolenaarThis can be overridden by setting
8973955d011SMarcel Moolenaar.Va bf
8983955d011SMarcel Moolenaarto a value which represents True.
899b778b302SSimon J. Gerraty.It Pa missing-meta= Ar bf
900b778b302SSimon J. GerratyIf
901b778b302SSimon J. Gerraty.Va bf
902b778b302SSimon J. Gerratyis True, then a missing .meta file makes the target out-of-date.
903b778b302SSimon J. Gerraty.It Pa missing-filemon= Ar bf
904b778b302SSimon J. GerratyIf
905b778b302SSimon J. Gerraty.Va bf
906b778b302SSimon J. Gerratyis True, then missing filemon data makes the target out-of-date.
907b778b302SSimon J. Gerraty.It Pa nofilemon
908b778b302SSimon J. GerratyDo not use
909b778b302SSimon J. Gerraty.Xr filemon 4 .
9103955d011SMarcel Moolenaar.It Pa env
911be19d90bSSimon J. GerratyFor debugging, it can be useful to include the environment
9123955d011SMarcel Moolenaarin the .meta file.
9133955d011SMarcel Moolenaar.It Pa verbose
9143955d011SMarcel MoolenaarIf in "meta" mode, print a clue about the target being built.
9153955d011SMarcel MoolenaarThis is useful if the build is otherwise running silently.
9163955d011SMarcel MoolenaarThe message printed the value of:
9173955d011SMarcel Moolenaar.Va .MAKE.META.PREFIX .
9183955d011SMarcel Moolenaar.It Pa ignore-cmd
9193955d011SMarcel MoolenaarSome makefiles have commands which are simply not stable.
9203955d011SMarcel MoolenaarThis keyword causes them to be ignored for
9213955d011SMarcel Moolenaardetermining whether a target is out of date in "meta" mode.
9223955d011SMarcel MoolenaarSee also
9233955d011SMarcel Moolenaar.Ic .NOMETA_CMP .
9243955d011SMarcel Moolenaar.It Pa silent= Ar bf
9253955d011SMarcel MoolenaarIf
9263955d011SMarcel Moolenaar.Va bf
9273955d011SMarcel Moolenaaris True, when a .meta file is created, mark the target
9283955d011SMarcel Moolenaar.Ic .SILENT .
9293955d011SMarcel Moolenaar.El
9303955d011SMarcel Moolenaar.It Va .MAKE.META.BAILIWICK
9313955d011SMarcel MoolenaarIn "meta" mode, provides a list of prefixes which
9323955d011SMarcel Moolenaarmatch the directories controlled by
9333955d011SMarcel Moolenaar.Nm .
9343955d011SMarcel MoolenaarIf a file that was generated outside of
9353955d011SMarcel Moolenaar.Va .OBJDIR
9363955d011SMarcel Moolenaarbut within said bailiwick is missing,
9373955d011SMarcel Moolenaarthe current target is considered out-of-date.
9383955d011SMarcel Moolenaar.It Va .MAKE.META.CREATED
9393955d011SMarcel MoolenaarIn "meta" mode, this variable contains a list of all the meta files
9403955d011SMarcel Moolenaarupdated.
9413955d011SMarcel MoolenaarIf not empty, it can be used to trigger processing of
9423955d011SMarcel Moolenaar.Va .MAKE.META.FILES .
9433955d011SMarcel Moolenaar.It Va .MAKE.META.FILES
9443955d011SMarcel MoolenaarIn "meta" mode, this variable contains a list of all the meta files
9453955d011SMarcel Moolenaarused (updated or not).
9463955d011SMarcel MoolenaarThis list can be used to process the meta files to extract dependency
9473955d011SMarcel Moolenaarinformation.
94851ee2c1cSSimon J. Gerraty.It Va .MAKE.META.IGNORE_PATHS
94951ee2c1cSSimon J. GerratyProvides a list of path prefixes that should be ignored;
95051ee2c1cSSimon J. Gerratybecause the contents are expected to change over time.
95151ee2c1cSSimon J. GerratyThe default list includes:
95251ee2c1cSSimon J. Gerraty.Ql Pa /dev /etc /proc /tmp /var/run /var/tmp
953e48f47ddSSimon J. Gerraty.It Va .MAKE.META.IGNORE_PATTERNS
954e48f47ddSSimon J. GerratyProvides a list of patterns to match against pathnames.
955e48f47ddSSimon J. GerratyIgnore any that match.
95695e3ed2cSSimon J. Gerraty.It Va .MAKE.META.IGNORE_FILTER
95795e3ed2cSSimon J. GerratyProvides a list of variable modifiers to apply to each pathname.
95895e3ed2cSSimon J. GerratyIgnore if the expansion is an empty string.
9593955d011SMarcel Moolenaar.It Va .MAKE.META.PREFIX
9603955d011SMarcel MoolenaarDefines the message printed for each meta file updated in "meta verbose" mode.
9613955d011SMarcel MoolenaarThe default value is:
9623955d011SMarcel Moolenaar.Dl Building ${.TARGET:H:tA}/${.TARGET:T}
9633955d011SMarcel Moolenaar.It Va .MAKEOVERRIDES
9643955d011SMarcel MoolenaarThis variable is used to record the names of variables assigned to
9653955d011SMarcel Moolenaaron the command line, so that they may be exported as part of
9663955d011SMarcel Moolenaar.Ql Ev MAKEFLAGS .
967be19d90bSSimon J. GerratyThis behavior can be disabled by assigning an empty value to
9683955d011SMarcel Moolenaar.Ql Va .MAKEOVERRIDES
9693955d011SMarcel Moolenaarwithin a makefile.
9703955d011SMarcel MoolenaarExtra variables can be exported from a makefile
9713955d011SMarcel Moolenaarby appending their names to
9723955d011SMarcel Moolenaar.Ql Va .MAKEOVERRIDES .
9733955d011SMarcel Moolenaar.Ql Ev MAKEFLAGS
9743955d011SMarcel Moolenaaris re-exported whenever
9753955d011SMarcel Moolenaar.Ql Va .MAKEOVERRIDES
9763955d011SMarcel Moolenaaris modified.
9771748de26SSimon J. Gerraty.It Va .MAKE.PATH_FILEMON
9781748de26SSimon J. GerratyIf
9791748de26SSimon J. Gerraty.Nm
9801748de26SSimon J. Gerratywas built with
9811748de26SSimon J. Gerraty.Xr filemon 4
9821748de26SSimon J. Gerratysupport, this is set to the path of the device node.
9831748de26SSimon J. GerratyThis allows makefiles to test for this support.
9843955d011SMarcel Moolenaar.It Va .MAKE.PID
9853955d011SMarcel MoolenaarThe process-id of
9863955d011SMarcel Moolenaar.Nm .
9873955d011SMarcel Moolenaar.It Va .MAKE.PPID
9883955d011SMarcel MoolenaarThe parent process-id of
9893955d011SMarcel Moolenaar.Nm .
990be19d90bSSimon J. Gerraty.It Va .MAKE.SAVE_DOLLARS
991be19d90bSSimon J. Gerratyvalue should be a boolean that controls whether
992be19d90bSSimon J. Gerraty.Ql $$
993be19d90bSSimon J. Gerratyare preserved when doing
994be19d90bSSimon J. Gerraty.Ql :=
995be19d90bSSimon J. Gerratyassignments.
996be19d90bSSimon J. GerratyThe default is false, for backwards compatibility.
997be19d90bSSimon J. GerratySet to true for compatability with other makes.
998be19d90bSSimon J. GerratyIf set to false,
999be19d90bSSimon J. Gerraty.Ql $$
1000be19d90bSSimon J. Gerratybecomes
1001be19d90bSSimon J. Gerraty.Ql $
1002be19d90bSSimon J. Gerratyper normal evaluation rules.
10033955d011SMarcel Moolenaar.It Va MAKE_PRINT_VAR_ON_ERROR
10043955d011SMarcel MoolenaarWhen
10053955d011SMarcel Moolenaar.Nm
100695e3ed2cSSimon J. Gerratystops due to an error, it sets
100795e3ed2cSSimon J. Gerraty.Ql Va .ERROR_TARGET
100895e3ed2cSSimon J. Gerratyto the name of the target that failed,
100995e3ed2cSSimon J. Gerraty.Ql Va .ERROR_CMD
101095e3ed2cSSimon J. Gerratyto the commands of the failed target,
101195e3ed2cSSimon J. Gerratyand in "meta" mode, it also sets
101295e3ed2cSSimon J. Gerraty.Ql Va .ERROR_CWD
101395e3ed2cSSimon J. Gerratyto the
101495e3ed2cSSimon J. Gerraty.Xr getcwd 3 ,
101595e3ed2cSSimon J. Gerratyand
101695e3ed2cSSimon J. Gerraty.Ql Va .ERROR_META_FILE
101795e3ed2cSSimon J. Gerratyto the path of the meta file (if any) describing the failed target.
101895e3ed2cSSimon J. GerratyIt then prints its name and the value of
10193955d011SMarcel Moolenaar.Ql Va .CURDIR
10203955d011SMarcel Moolenaaras well as the value of any variables named in
10213955d011SMarcel Moolenaar.Ql Va MAKE_PRINT_VAR_ON_ERROR .
10223955d011SMarcel Moolenaar.It Va .newline
10233955d011SMarcel MoolenaarThis variable is simply assigned a newline character as its value.
10243955d011SMarcel MoolenaarThis allows expansions using the
10253955d011SMarcel Moolenaar.Cm \&:@
10263955d011SMarcel Moolenaarmodifier to put a newline between
10273955d011SMarcel Moolenaariterations of the loop rather than a space.
10283955d011SMarcel MoolenaarFor example, the printing of
10293955d011SMarcel Moolenaar.Ql Va MAKE_PRINT_VAR_ON_ERROR
10303955d011SMarcel Moolenaarcould be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}.
10313955d011SMarcel Moolenaar.It Va .OBJDIR
10323955d011SMarcel MoolenaarA path to the directory where the targets are built.
10333955d011SMarcel MoolenaarIts value is determined by trying to
10343955d011SMarcel Moolenaar.Xr chdir 2
10353955d011SMarcel Moolenaarto the following directories in order and using the first match:
10363955d011SMarcel Moolenaar.Bl -enum
10373955d011SMarcel Moolenaar.It
10383955d011SMarcel Moolenaar.Ev ${MAKEOBJDIRPREFIX}${.CURDIR}
10393955d011SMarcel Moolenaar.Pp
10403955d011SMarcel Moolenaar(Only if
10413955d011SMarcel Moolenaar.Ql Ev MAKEOBJDIRPREFIX
10423955d011SMarcel Moolenaaris set in the environment or on the command line.)
10433955d011SMarcel Moolenaar.It
10443955d011SMarcel Moolenaar.Ev ${MAKEOBJDIR}
10453955d011SMarcel Moolenaar.Pp
10463955d011SMarcel Moolenaar(Only if
10473955d011SMarcel Moolenaar.Ql Ev MAKEOBJDIR
10483955d011SMarcel Moolenaaris set in the environment or on the command line.)
10493955d011SMarcel Moolenaar.It
10503955d011SMarcel Moolenaar.Ev ${.CURDIR} Ns Pa /obj. Ns Ev ${MACHINE}
10513955d011SMarcel Moolenaar.It
10523955d011SMarcel Moolenaar.Ev ${.CURDIR} Ns Pa /obj
10533955d011SMarcel Moolenaar.It
10543955d011SMarcel Moolenaar.Pa /usr/obj/ Ns Ev ${.CURDIR}
10553955d011SMarcel Moolenaar.It
10563955d011SMarcel Moolenaar.Ev ${.CURDIR}
10573955d011SMarcel Moolenaar.El
10583955d011SMarcel Moolenaar.Pp
10593955d011SMarcel MoolenaarVariable expansion is performed on the value before it's used,
10603955d011SMarcel Moolenaarso expressions such as
10613955d011SMarcel Moolenaar.Dl ${.CURDIR:S,^/usr/src,/var/obj,}
10623955d011SMarcel Moolenaarmay be used.
10633955d011SMarcel MoolenaarThis is especially useful with
10643955d011SMarcel Moolenaar.Ql Ev MAKEOBJDIR .
10653955d011SMarcel Moolenaar.Pp
10663955d011SMarcel Moolenaar.Ql Va .OBJDIR
1067128a4105SSimon J. Gerratymay be modified in the makefile via the special target
1068128a4105SSimon J. Gerraty.Ql Ic .OBJDIR .
10693955d011SMarcel MoolenaarIn all cases,
10703955d011SMarcel Moolenaar.Nm
10713955d011SMarcel Moolenaarwill
10723955d011SMarcel Moolenaar.Xr chdir 2
1073128a4105SSimon J. Gerratyto the specified directory if it exists, and set
10743955d011SMarcel Moolenaar.Ql Va .OBJDIR
1075128a4105SSimon J. Gerratyand
10763955d011SMarcel Moolenaar.Ql Ev PWD
10773955d011SMarcel Moolenaarto that directory before executing any targets.
10783955d011SMarcel Moolenaar.
10793955d011SMarcel Moolenaar.It Va .PARSEDIR
10803955d011SMarcel MoolenaarA path to the directory of the current
10813955d011SMarcel Moolenaar.Ql Pa Makefile
10823955d011SMarcel Moolenaarbeing parsed.
10833955d011SMarcel Moolenaar.It Va .PARSEFILE
10843955d011SMarcel MoolenaarThe basename of the current
10853955d011SMarcel Moolenaar.Ql Pa Makefile
10863955d011SMarcel Moolenaarbeing parsed.
10873955d011SMarcel MoolenaarThis variable and
10883955d011SMarcel Moolenaar.Ql Va .PARSEDIR
10893955d011SMarcel Moolenaarare both set only while the
10903955d011SMarcel Moolenaar.Ql Pa Makefiles
10913955d011SMarcel Moolenaarare being parsed.
10923955d011SMarcel MoolenaarIf you want to retain their current values, assign them to a variable
10933955d011SMarcel Moolenaarusing assignment with expansion:
10943955d011SMarcel Moolenaar.Pq Ql Cm \&:= .
10953955d011SMarcel Moolenaar.It Va .PATH
10963955d011SMarcel MoolenaarA variable that represents the list of directories that
10973955d011SMarcel Moolenaar.Nm
10983955d011SMarcel Moolenaarwill search for files.
10993955d011SMarcel MoolenaarThe search list should be updated using the target
11003955d011SMarcel Moolenaar.Ql Va .PATH
11013955d011SMarcel Moolenaarrather than the variable.
11023955d011SMarcel Moolenaar.It Ev PWD
11033955d011SMarcel MoolenaarAlternate path to the current directory.
11043955d011SMarcel Moolenaar.Nm
11053955d011SMarcel Moolenaarnormally sets
11063955d011SMarcel Moolenaar.Ql Va .CURDIR
11073955d011SMarcel Moolenaarto the canonical path given by
11083955d011SMarcel Moolenaar.Xr getcwd 3 .
11093955d011SMarcel MoolenaarHowever, if the environment variable
11103955d011SMarcel Moolenaar.Ql Ev PWD
11113955d011SMarcel Moolenaaris set and gives a path to the current directory, then
11123955d011SMarcel Moolenaar.Nm
11133955d011SMarcel Moolenaarsets
11143955d011SMarcel Moolenaar.Ql Va .CURDIR
11153955d011SMarcel Moolenaarto the value of
11163955d011SMarcel Moolenaar.Ql Ev PWD
11173955d011SMarcel Moolenaarinstead.
1118be19d90bSSimon J. GerratyThis behavior is disabled if
11193955d011SMarcel Moolenaar.Ql Ev MAKEOBJDIRPREFIX
11203955d011SMarcel Moolenaaris set or
11213955d011SMarcel Moolenaar.Ql Ev MAKEOBJDIR
11223955d011SMarcel Moolenaarcontains a variable transform.
11233955d011SMarcel Moolenaar.Ql Ev PWD
11243955d011SMarcel Moolenaaris set to the value of
11253955d011SMarcel Moolenaar.Ql Va .OBJDIR
11263955d011SMarcel Moolenaarfor all programs which
11273955d011SMarcel Moolenaar.Nm
11283955d011SMarcel Moolenaarexecutes.
11293955d011SMarcel Moolenaar.It Ev .TARGETS
11303955d011SMarcel MoolenaarThe list of targets explicitly specified on the command line, if any.
11313955d011SMarcel Moolenaar.It Ev VPATH
11323955d011SMarcel MoolenaarColon-separated
11333955d011SMarcel Moolenaar.Pq Dq \&:
11343955d011SMarcel Moolenaarlists of directories that
11353955d011SMarcel Moolenaar.Nm
11363955d011SMarcel Moolenaarwill search for files.
11373955d011SMarcel MoolenaarThe variable is supported for compatibility with old make programs only,
11383955d011SMarcel Moolenaaruse
11393955d011SMarcel Moolenaar.Ql Va .PATH
11403955d011SMarcel Moolenaarinstead.
11413955d011SMarcel Moolenaar.El
11423955d011SMarcel Moolenaar.Ss Variable modifiers
11433955d011SMarcel MoolenaarVariable expansion may be modified to select or modify each word of the
11443955d011SMarcel Moolenaarvariable (where a
11453955d011SMarcel Moolenaar.Dq word
11463955d011SMarcel Moolenaaris white-space delimited sequence of characters).
11473955d011SMarcel MoolenaarThe general format of a variable expansion is as follows:
11483955d011SMarcel Moolenaar.Pp
11493955d011SMarcel Moolenaar.Dl ${variable[:modifier[:...]]}
11503955d011SMarcel Moolenaar.Pp
11513955d011SMarcel MoolenaarEach modifier begins with a colon,
11523955d011SMarcel Moolenaarwhich may be escaped with a backslash
11533955d011SMarcel Moolenaar.Pq Ql \e .
11543955d011SMarcel Moolenaar.Pp
11553955d011SMarcel MoolenaarA set of modifiers can be specified via a variable, as follows:
11563955d011SMarcel Moolenaar.Pp
11573955d011SMarcel Moolenaar.Dl modifier_variable=modifier[:...]
11583955d011SMarcel Moolenaar.Dl ${variable:${modifier_variable}[:...]}
11593955d011SMarcel Moolenaar.Pp
11603955d011SMarcel MoolenaarIn this case the first modifier in the modifier_variable does not
11613955d011SMarcel Moolenaarstart with a colon, since that must appear in the referencing
11623955d011SMarcel Moolenaarvariable.
11633955d011SMarcel MoolenaarIf any of the modifiers in the modifier_variable contain a dollar sign
11643955d011SMarcel Moolenaar.Pq Ql $ ,
11653955d011SMarcel Moolenaarthese must be doubled to avoid early expansion.
11663955d011SMarcel Moolenaar.Pp
11673955d011SMarcel MoolenaarThe supported modifiers are:
11683955d011SMarcel Moolenaar.Bl -tag -width EEE
11693955d011SMarcel Moolenaar.It Cm \&:E
11703955d011SMarcel MoolenaarReplaces each word in the variable with its suffix.
11713955d011SMarcel Moolenaar.It Cm \&:H
11723955d011SMarcel MoolenaarReplaces each word in the variable with everything but the last component.
11733955d011SMarcel Moolenaar.It Cm \&:M Ns Ar pattern
11743955d011SMarcel MoolenaarSelect only those words that match
11753955d011SMarcel Moolenaar.Ar pattern .
11763955d011SMarcel MoolenaarThe standard shell wildcard characters
11773955d011SMarcel Moolenaar.Pf ( Ql * ,
11783955d011SMarcel Moolenaar.Ql \&? ,
11793955d011SMarcel Moolenaarand
11803955d011SMarcel Moolenaar.Ql Oo Oc )
11813955d011SMarcel Moolenaarmay
11823955d011SMarcel Moolenaarbe used.
11833955d011SMarcel MoolenaarThe wildcard characters may be escaped with a backslash
11843955d011SMarcel Moolenaar.Pq Ql \e .
11850dede8b0SSimon J. GerratyAs a consequence of the way values are split into words, matched,
11860dede8b0SSimon J. Gerratyand then joined, a construct like
11870dede8b0SSimon J. Gerraty.Dl ${VAR:M*}
1188be19d90bSSimon J. Gerratywill normalize the inter-word spacing, removing all leading and
11890dede8b0SSimon J. Gerratytrailing space, and converting multiple consecutive spaces
11900dede8b0SSimon J. Gerratyto single spaces.
11910dede8b0SSimon J. Gerraty.
11923955d011SMarcel Moolenaar.It Cm \&:N Ns Ar pattern
11933955d011SMarcel MoolenaarThis is identical to
11943955d011SMarcel Moolenaar.Ql Cm \&:M ,
11953955d011SMarcel Moolenaarbut selects all words which do not match
11963955d011SMarcel Moolenaar.Ar pattern .
11973955d011SMarcel Moolenaar.It Cm \&:O
11983955d011SMarcel MoolenaarOrder every word in variable alphabetically.
11993955d011SMarcel MoolenaarTo sort words in
12003955d011SMarcel Moolenaarreverse order use the
12013955d011SMarcel Moolenaar.Ql Cm \&:O:[-1..1]
12023955d011SMarcel Moolenaarcombination of modifiers.
12033955d011SMarcel Moolenaar.It Cm \&:Ox
12043955d011SMarcel MoolenaarRandomize words in variable.
12053955d011SMarcel MoolenaarThe results will be different each time you are referring to the
12063955d011SMarcel Moolenaarmodified variable; use the assignment with expansion
12073955d011SMarcel Moolenaar.Pq Ql Cm \&:=
1208be19d90bSSimon J. Gerratyto prevent such behavior.
12093955d011SMarcel MoolenaarFor example,
12103955d011SMarcel Moolenaar.Bd -literal -offset indent
12113955d011SMarcel MoolenaarLIST=			uno due tre quattro
12123955d011SMarcel MoolenaarRANDOM_LIST=		${LIST:Ox}
12133955d011SMarcel MoolenaarSTATIC_RANDOM_LIST:=	${LIST:Ox}
12143955d011SMarcel Moolenaar
12153955d011SMarcel Moolenaarall:
12163955d011SMarcel Moolenaar	@echo "${RANDOM_LIST}"
12173955d011SMarcel Moolenaar	@echo "${RANDOM_LIST}"
12183955d011SMarcel Moolenaar	@echo "${STATIC_RANDOM_LIST}"
12193955d011SMarcel Moolenaar	@echo "${STATIC_RANDOM_LIST}"
12203955d011SMarcel Moolenaar.Ed
12213955d011SMarcel Moolenaarmay produce output similar to:
12223955d011SMarcel Moolenaar.Bd -literal -offset indent
12233955d011SMarcel Moolenaarquattro due tre uno
12243955d011SMarcel Moolenaartre due quattro uno
12253955d011SMarcel Moolenaardue uno quattro tre
12263955d011SMarcel Moolenaardue uno quattro tre
12273955d011SMarcel Moolenaar.Ed
12283955d011SMarcel Moolenaar.It Cm \&:Q
12293955d011SMarcel MoolenaarQuotes every shell meta-character in the variable, so that it can be passed
12303955d011SMarcel Moolenaarsafely through recursive invocations of
12313955d011SMarcel Moolenaar.Nm .
12323955d011SMarcel Moolenaar.It Cm \&:R
12333955d011SMarcel MoolenaarReplaces each word in the variable with everything but its suffix.
12341ce939a7SSimon J. Gerraty.It Cm \&:range[=count]
12351ce939a7SSimon J. GerratyThe value is an integer sequence representing the words of the original
12361ce939a7SSimon J. Gerratyvalue, or the supplied
12371ce939a7SSimon J. Gerraty.Va count .
12381ce939a7SSimon J. Gerraty.It Cm \&:gmtime[=utc]
12393955d011SMarcel MoolenaarThe value is a format string for
12403955d011SMarcel Moolenaar.Xr strftime 3 ,
12411ce939a7SSimon J. Gerratyusing
12423955d011SMarcel Moolenaar.Xr gmtime 3 .
12431ce939a7SSimon J. GerratyIf a
12441ce939a7SSimon J. Gerraty.Va utc
12451ce939a7SSimon J. Gerratyvalue is not provided or is 0, the current time is used.
12463955d011SMarcel Moolenaar.It Cm \&:hash
1247be19d90bSSimon J. GerratyCompute a 32-bit hash of the value and encode it as hex digits.
12481ce939a7SSimon J. Gerraty.It Cm \&:localtime[=utc]
12493955d011SMarcel MoolenaarThe value is a format string for
12503955d011SMarcel Moolenaar.Xr strftime 3 ,
12511ce939a7SSimon J. Gerratyusing
12523955d011SMarcel Moolenaar.Xr localtime 3 .
12531ce939a7SSimon J. GerratyIf a
12541ce939a7SSimon J. Gerraty.Va utc
12551ce939a7SSimon J. Gerratyvalue is not provided or is 0, the current time is used.
12563955d011SMarcel Moolenaar.It Cm \&:tA
12573955d011SMarcel MoolenaarAttempt to convert variable to an absolute path using
12583955d011SMarcel Moolenaar.Xr realpath 3 ,
12593955d011SMarcel Moolenaarif that fails, the value is unchanged.
12603955d011SMarcel Moolenaar.It Cm \&:tl
12613955d011SMarcel MoolenaarConverts variable to lower-case letters.
12623955d011SMarcel Moolenaar.It Cm \&:ts Ns Ar c
12633955d011SMarcel MoolenaarWords in the variable are normally separated by a space on expansion.
12643955d011SMarcel MoolenaarThis modifier sets the separator to the character
12653955d011SMarcel Moolenaar.Ar c .
12663955d011SMarcel MoolenaarIf
12673955d011SMarcel Moolenaar.Ar c
12683955d011SMarcel Moolenaaris omitted, then no separator is used.
12693955d011SMarcel MoolenaarThe common escapes (including octal numeric codes), work as expected.
12703955d011SMarcel Moolenaar.It Cm \&:tu
12713955d011SMarcel MoolenaarConverts variable to upper-case letters.
12723955d011SMarcel Moolenaar.It Cm \&:tW
12733955d011SMarcel MoolenaarCauses the value to be treated as a single word
12743955d011SMarcel Moolenaar(possibly containing embedded white space).
12753955d011SMarcel MoolenaarSee also
12763955d011SMarcel Moolenaar.Ql Cm \&:[*] .
12773955d011SMarcel Moolenaar.It Cm \&:tw
12783955d011SMarcel MoolenaarCauses the value to be treated as a sequence of
12793955d011SMarcel Moolenaarwords delimited by white space.
12803955d011SMarcel MoolenaarSee also
12813955d011SMarcel Moolenaar.Ql Cm \&:[@] .
12823955d011SMarcel Moolenaar.Sm off
12833955d011SMarcel Moolenaar.It Cm \&:S No \&/ Ar old_string No \&/ Ar new_string No \&/ Op Cm 1gW
12843955d011SMarcel Moolenaar.Sm on
12853955d011SMarcel MoolenaarModify the first occurrence of
12863955d011SMarcel Moolenaar.Ar old_string
12873955d011SMarcel Moolenaarin the variable's value, replacing it with
12883955d011SMarcel Moolenaar.Ar new_string .
12893955d011SMarcel MoolenaarIf a
12903955d011SMarcel Moolenaar.Ql g
12913955d011SMarcel Moolenaaris appended to the last slash of the pattern, all occurrences
12923955d011SMarcel Moolenaarin each word are replaced.
12933955d011SMarcel MoolenaarIf a
12943955d011SMarcel Moolenaar.Ql 1
12953955d011SMarcel Moolenaaris appended to the last slash of the pattern, only the first word
12963955d011SMarcel Moolenaaris affected.
12973955d011SMarcel MoolenaarIf a
12983955d011SMarcel Moolenaar.Ql W
12993955d011SMarcel Moolenaaris appended to the last slash of the pattern,
13003955d011SMarcel Moolenaarthen the value is treated as a single word
13013955d011SMarcel Moolenaar(possibly containing embedded white space).
13023955d011SMarcel MoolenaarIf
13033955d011SMarcel Moolenaar.Ar old_string
13043955d011SMarcel Moolenaarbegins with a caret
13053955d011SMarcel Moolenaar.Pq Ql ^ ,
13063955d011SMarcel Moolenaar.Ar old_string
13073955d011SMarcel Moolenaaris anchored at the beginning of each word.
13083955d011SMarcel MoolenaarIf
13093955d011SMarcel Moolenaar.Ar old_string
13103955d011SMarcel Moolenaarends with a dollar sign
13113955d011SMarcel Moolenaar.Pq Ql \&$ ,
13123955d011SMarcel Moolenaarit is anchored at the end of each word.
13133955d011SMarcel MoolenaarInside
13143955d011SMarcel Moolenaar.Ar new_string ,
13153955d011SMarcel Moolenaaran ampersand
13168695518cSSimon J. Gerraty.Pq Ql &
13173955d011SMarcel Moolenaaris replaced by
13183955d011SMarcel Moolenaar.Ar old_string
13193955d011SMarcel Moolenaar(without any
13203955d011SMarcel Moolenaar.Ql ^
13213955d011SMarcel Moolenaaror
13223955d011SMarcel Moolenaar.Ql \&$ ) .
13233955d011SMarcel MoolenaarAny character may be used as a delimiter for the parts of the modifier
13243955d011SMarcel Moolenaarstring.
13253955d011SMarcel MoolenaarThe anchoring, ampersand and delimiter characters may be escaped with a
13263955d011SMarcel Moolenaarbackslash
13273955d011SMarcel Moolenaar.Pq Ql \e .
13283955d011SMarcel Moolenaar.Pp
13293955d011SMarcel MoolenaarVariable expansion occurs in the normal fashion inside both
13303955d011SMarcel Moolenaar.Ar old_string
13313955d011SMarcel Moolenaarand
13323955d011SMarcel Moolenaar.Ar new_string
13333955d011SMarcel Moolenaarwith the single exception that a backslash is used to prevent the expansion
13343955d011SMarcel Moolenaarof a dollar sign
13353955d011SMarcel Moolenaar.Pq Ql \&$ ,
13363955d011SMarcel Moolenaarnot a preceding dollar sign as is usual.
13373955d011SMarcel Moolenaar.Sm off
13383955d011SMarcel Moolenaar.It Cm \&:C No \&/ Ar pattern No \&/ Ar replacement No \&/ Op Cm 1gW
13393955d011SMarcel Moolenaar.Sm on
13403955d011SMarcel MoolenaarThe
13413955d011SMarcel Moolenaar.Cm \&:C
13423955d011SMarcel Moolenaarmodifier is just like the
13433955d011SMarcel Moolenaar.Cm \&:S
13443955d011SMarcel Moolenaarmodifier except that the old and new strings, instead of being
13450dede8b0SSimon J. Gerratysimple strings, are an extended regular expression (see
13463955d011SMarcel Moolenaar.Xr regex 3 )
13473955d011SMarcel Moolenaarstring
13483955d011SMarcel Moolenaar.Ar pattern
13493955d011SMarcel Moolenaarand an
13503955d011SMarcel Moolenaar.Xr ed 1 Ns \-style
13513955d011SMarcel Moolenaarstring
13523955d011SMarcel Moolenaar.Ar replacement .
13533955d011SMarcel MoolenaarNormally, the first occurrence of the pattern
13543955d011SMarcel Moolenaar.Ar pattern
13553955d011SMarcel Moolenaarin each word of the value is substituted with
13563955d011SMarcel Moolenaar.Ar replacement .
13573955d011SMarcel MoolenaarThe
13583955d011SMarcel Moolenaar.Ql 1
13593955d011SMarcel Moolenaarmodifier causes the substitution to apply to at most one word; the
13603955d011SMarcel Moolenaar.Ql g
13613955d011SMarcel Moolenaarmodifier causes the substitution to apply to as many instances of the
13623955d011SMarcel Moolenaarsearch pattern
13633955d011SMarcel Moolenaar.Ar pattern
13643955d011SMarcel Moolenaaras occur in the word or words it is found in; the
13653955d011SMarcel Moolenaar.Ql W
13663955d011SMarcel Moolenaarmodifier causes the value to be treated as a single word
13673955d011SMarcel Moolenaar(possibly containing embedded white space).
13683955d011SMarcel MoolenaarNote that
13693955d011SMarcel Moolenaar.Ql 1
13703955d011SMarcel Moolenaarand
13713955d011SMarcel Moolenaar.Ql g
13723955d011SMarcel Moolenaarare orthogonal; the former specifies whether multiple words are
13733955d011SMarcel Moolenaarpotentially affected, the latter whether multiple substitutions can
13743955d011SMarcel Moolenaarpotentially occur within each affected word.
13755bcb7424SSimon J. Gerraty.Pp
13765bcb7424SSimon J. GerratyAs for the
13775bcb7424SSimon J. Gerraty.Cm \&:S
13785bcb7424SSimon J. Gerratymodifier, the
13795bcb7424SSimon J. Gerraty.Ar pattern
13805bcb7424SSimon J. Gerratyand
13815bcb7424SSimon J. Gerraty.Ar replacement
13825bcb7424SSimon J. Gerratyare subjected to variable expansion before being parsed as
13835bcb7424SSimon J. Gerratyregular expressions.
13843955d011SMarcel Moolenaar.It Cm \&:T
13853955d011SMarcel MoolenaarReplaces each word in the variable with its last component.
13863955d011SMarcel Moolenaar.It Cm \&:u
13873955d011SMarcel MoolenaarRemove adjacent duplicate words (like
13883955d011SMarcel Moolenaar.Xr uniq 1 ) .
13893955d011SMarcel Moolenaar.Sm off
13903955d011SMarcel Moolenaar.It Cm \&:\&? Ar true_string Cm \&: Ar false_string
13913955d011SMarcel Moolenaar.Sm on
13923955d011SMarcel MoolenaarIf the variable name (not its value), when parsed as a .if conditional
13933955d011SMarcel Moolenaarexpression, evaluates to true, return as its value the
13943955d011SMarcel Moolenaar.Ar true_string ,
13953955d011SMarcel Moolenaarotherwise return the
13963955d011SMarcel Moolenaar.Ar false_string .
13973955d011SMarcel MoolenaarSince the variable name is used as the expression, \&:\&? must be the
13983955d011SMarcel Moolenaarfirst modifier after the variable name itself - which will, of course,
13993955d011SMarcel Moolenaarusually contain variable expansions.
14003955d011SMarcel MoolenaarA common error is trying to use expressions like
14013955d011SMarcel Moolenaar.Dl ${NUMBERS:M42:?match:no}
14023955d011SMarcel Moolenaarwhich actually tests defined(NUMBERS),
14033955d011SMarcel Moolenaarto determine is any words match "42" you need to use something like:
14043955d011SMarcel Moolenaar.Dl ${"${NUMBERS:M42}" != \&"\&":?match:no} .
14053955d011SMarcel Moolenaar.It Ar :old_string=new_string
14063955d011SMarcel MoolenaarThis is the
14073955d011SMarcel Moolenaar.At V
14083955d011SMarcel Moolenaarstyle variable substitution.
14093955d011SMarcel MoolenaarIt must be the last modifier specified.
14103955d011SMarcel MoolenaarIf
14113955d011SMarcel Moolenaar.Ar old_string
14123955d011SMarcel Moolenaaror
14133955d011SMarcel Moolenaar.Ar new_string
14143955d011SMarcel Moolenaardo not contain the pattern matching character
14153955d011SMarcel Moolenaar.Ar %
14163955d011SMarcel Moolenaarthen it is assumed that they are
14173955d011SMarcel Moolenaaranchored at the end of each word, so only suffixes or entire
14183955d011SMarcel Moolenaarwords may be replaced.
14193955d011SMarcel MoolenaarOtherwise
14203955d011SMarcel Moolenaar.Ar %
14213955d011SMarcel Moolenaaris the substring of
14223955d011SMarcel Moolenaar.Ar old_string
14233955d011SMarcel Moolenaarto be replaced in
14243955d011SMarcel Moolenaar.Ar new_string .
14253955d011SMarcel Moolenaar.Pp
14263955d011SMarcel MoolenaarVariable expansion occurs in the normal fashion inside both
14273955d011SMarcel Moolenaar.Ar old_string
14283955d011SMarcel Moolenaarand
14293955d011SMarcel Moolenaar.Ar new_string
14303955d011SMarcel Moolenaarwith the single exception that a backslash is used to prevent the
14313955d011SMarcel Moolenaarexpansion of a dollar sign
14323955d011SMarcel Moolenaar.Pq Ql \&$ ,
14333955d011SMarcel Moolenaarnot a preceding dollar sign as is usual.
14343955d011SMarcel Moolenaar.Sm off
14353955d011SMarcel Moolenaar.It Cm \&:@ Ar temp Cm @ Ar string Cm @
14363955d011SMarcel Moolenaar.Sm on
14373955d011SMarcel MoolenaarThis is the loop expansion mechanism from the OSF Development
14383955d011SMarcel MoolenaarEnvironment (ODE) make.
14393955d011SMarcel MoolenaarUnlike
14403955d011SMarcel Moolenaar.Cm \&.for
14413955d011SMarcel Moolenaarloops expansion occurs at the time of
14423955d011SMarcel Moolenaarreference.
14433955d011SMarcel MoolenaarAssign
14443955d011SMarcel Moolenaar.Ar temp
14453955d011SMarcel Moolenaarto each word in the variable and evaluate
14463955d011SMarcel Moolenaar.Ar string .
14473955d011SMarcel MoolenaarThe ODE convention is that
14483955d011SMarcel Moolenaar.Ar temp
14493955d011SMarcel Moolenaarshould start and end with a period.
14503955d011SMarcel MoolenaarFor example.
14513955d011SMarcel Moolenaar.Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
14523955d011SMarcel Moolenaar.Pp
145351ee2c1cSSimon J. GerratyHowever a single character variable is often more readable:
14543955d011SMarcel Moolenaar.Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
14551ce939a7SSimon J. Gerraty.It Cm \&:_[=var]
14561ce939a7SSimon J. GerratySave the current variable value in
14571ce939a7SSimon J. Gerraty.Ql $_
14581ce939a7SSimon J. Gerratyor the named
14591ce939a7SSimon J. Gerraty.Va var
14601ce939a7SSimon J. Gerratyfor later reference.
14611ce939a7SSimon J. GerratyExample usage:
14621ce939a7SSimon J. Gerraty.Bd -literal -offset indent
14631ce939a7SSimon J. GerratyM_cmpv.units = 1 1000 1000000
14641ce939a7SSimon J. GerratyM_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\
14651ce939a7SSimon J. Gerraty\\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
14661ce939a7SSimon J. Gerraty
14671ce939a7SSimon J. Gerraty.Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
14681ce939a7SSimon J. Gerraty
14691ce939a7SSimon J. Gerraty.Ed
14701ce939a7SSimon J. GerratyHere
14711ce939a7SSimon J. Gerraty.Ql $_
14721ce939a7SSimon J. Gerratyis used to save the result of the
14731ce939a7SSimon J. Gerraty.Ql :S
14741ce939a7SSimon J. Gerratymodifier which is later referenced using the index values from
14751ce939a7SSimon J. Gerraty.Ql :range .
14763955d011SMarcel Moolenaar.It Cm \&:U Ns Ar newval
14773955d011SMarcel MoolenaarIf the variable is undefined
14783955d011SMarcel Moolenaar.Ar newval
14793955d011SMarcel Moolenaaris the value.
14803955d011SMarcel MoolenaarIf the variable is defined, the existing value is returned.
14813955d011SMarcel MoolenaarThis is another ODE make feature.
14823955d011SMarcel MoolenaarIt is handy for setting per-target CFLAGS for instance:
14833955d011SMarcel Moolenaar.Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
14843955d011SMarcel MoolenaarIf a value is only required if the variable is undefined, use:
14853955d011SMarcel Moolenaar.Dl ${VAR:D:Unewval}
14863955d011SMarcel Moolenaar.It Cm \&:D Ns Ar newval
14873955d011SMarcel MoolenaarIf the variable is defined
14883955d011SMarcel Moolenaar.Ar newval
14893955d011SMarcel Moolenaaris the value.
14903955d011SMarcel Moolenaar.It Cm \&:L
14913955d011SMarcel MoolenaarThe name of the variable is the value.
14923955d011SMarcel Moolenaar.It Cm \&:P
14933955d011SMarcel MoolenaarThe path of the node which has the same name as the variable
14943955d011SMarcel Moolenaaris the value.
14953955d011SMarcel MoolenaarIf no such node exists or its path is null, then the
14963955d011SMarcel Moolenaarname of the variable is used.
14973955d011SMarcel MoolenaarIn order for this modifier to work, the name (node) must at least have
14983955d011SMarcel Moolenaarappeared on the rhs of a dependency.
14993955d011SMarcel Moolenaar.Sm off
15003955d011SMarcel Moolenaar.It Cm \&:\&! Ar cmd Cm \&!
15013955d011SMarcel Moolenaar.Sm on
15023955d011SMarcel MoolenaarThe output of running
15033955d011SMarcel Moolenaar.Ar cmd
15043955d011SMarcel Moolenaaris the value.
15053955d011SMarcel Moolenaar.It Cm \&:sh
15063955d011SMarcel MoolenaarIf the variable is non-empty it is run as a command and the output
15073955d011SMarcel Moolenaarbecomes the new value.
15083955d011SMarcel Moolenaar.It Cm \&::= Ns Ar str
15093955d011SMarcel MoolenaarThe variable is assigned the value
15103955d011SMarcel Moolenaar.Ar str
15113955d011SMarcel Moolenaarafter substitution.
15123955d011SMarcel MoolenaarThis modifier and its variations are useful in
15133955d011SMarcel Moolenaarobscure situations such as wanting to set a variable when shell commands
15143955d011SMarcel Moolenaarare being parsed.
15153955d011SMarcel MoolenaarThese assignment modifiers always expand to
15163955d011SMarcel Moolenaarnothing, so if appearing in a rule line by themselves should be
15173955d011SMarcel Moolenaarpreceded with something to keep
15183955d011SMarcel Moolenaar.Nm
15193955d011SMarcel Moolenaarhappy.
15203955d011SMarcel Moolenaar.Pp
15213955d011SMarcel MoolenaarThe
15223955d011SMarcel Moolenaar.Ql Cm \&::
15233955d011SMarcel Moolenaarhelps avoid false matches with the
15243955d011SMarcel Moolenaar.At V
15253955d011SMarcel Moolenaarstyle
15263955d011SMarcel Moolenaar.Cm \&:=
15273955d011SMarcel Moolenaarmodifier and since substitution always occurs the
15283955d011SMarcel Moolenaar.Cm \&::=
15293955d011SMarcel Moolenaarform is vaguely appropriate.
15303955d011SMarcel Moolenaar.It Cm \&::?= Ns Ar str
15313955d011SMarcel MoolenaarAs for
15323955d011SMarcel Moolenaar.Cm \&::=
15333955d011SMarcel Moolenaarbut only if the variable does not already have a value.
15343955d011SMarcel Moolenaar.It Cm \&::+= Ns Ar str
15353955d011SMarcel MoolenaarAppend
15363955d011SMarcel Moolenaar.Ar str
15373955d011SMarcel Moolenaarto the variable.
15383955d011SMarcel Moolenaar.It Cm \&::!= Ns Ar cmd
15393955d011SMarcel MoolenaarAssign the output of
15403955d011SMarcel Moolenaar.Ar cmd
15413955d011SMarcel Moolenaarto the variable.
15423955d011SMarcel Moolenaar.It Cm \&:\&[ Ns Ar range Ns Cm \&]
15433955d011SMarcel MoolenaarSelects one or more words from the value,
15443955d011SMarcel Moolenaaror performs other operations related to the way in which the
15453955d011SMarcel Moolenaarvalue is divided into words.
15463955d011SMarcel Moolenaar.Pp
15473955d011SMarcel MoolenaarOrdinarily, a value is treated as a sequence of words
15483955d011SMarcel Moolenaardelimited by white space.
1549be19d90bSSimon J. GerratySome modifiers suppress this behavior,
15503955d011SMarcel Moolenaarcausing a value to be treated as a single word
15513955d011SMarcel Moolenaar(possibly containing embedded white space).
15523955d011SMarcel MoolenaarAn empty value, or a value that consists entirely of white-space,
15533955d011SMarcel Moolenaaris treated as a single word.
15543955d011SMarcel MoolenaarFor the purposes of the
15553955d011SMarcel Moolenaar.Ql Cm \&:[]
15563955d011SMarcel Moolenaarmodifier, the words are indexed both forwards using positive integers
15573955d011SMarcel Moolenaar(where index 1 represents the first word),
15583955d011SMarcel Moolenaarand backwards using negative integers
15593955d011SMarcel Moolenaar(where index \-1 represents the last word).
15603955d011SMarcel Moolenaar.Pp
15613955d011SMarcel MoolenaarThe
15623955d011SMarcel Moolenaar.Ar range
15633955d011SMarcel Moolenaaris subjected to variable expansion, and the expanded result is
15643955d011SMarcel Moolenaarthen interpreted as follows:
15653955d011SMarcel Moolenaar.Bl -tag -width index
15663955d011SMarcel Moolenaar.\" :[n]
15673955d011SMarcel Moolenaar.It Ar index
15683955d011SMarcel MoolenaarSelects a single word from the value.
15693955d011SMarcel Moolenaar.\" :[start..end]
15703955d011SMarcel Moolenaar.It Ar start Ns Cm \&.. Ns Ar end
15713955d011SMarcel MoolenaarSelects all words from
15723955d011SMarcel Moolenaar.Ar start
15733955d011SMarcel Moolenaarto
15743955d011SMarcel Moolenaar.Ar end ,
15753955d011SMarcel Moolenaarinclusive.
15763955d011SMarcel MoolenaarFor example,
15773955d011SMarcel Moolenaar.Ql Cm \&:[2..-1]
15783955d011SMarcel Moolenaarselects all words from the second word to the last word.
15793955d011SMarcel MoolenaarIf
15803955d011SMarcel Moolenaar.Ar start
15813955d011SMarcel Moolenaaris greater than
15823955d011SMarcel Moolenaar.Ar end ,
15833955d011SMarcel Moolenaarthen the words are output in reverse order.
15843955d011SMarcel MoolenaarFor example,
15853955d011SMarcel Moolenaar.Ql Cm \&:[-1..1]
15863955d011SMarcel Moolenaarselects all the words from last to first.
15873955d011SMarcel Moolenaar.\" :[*]
15883955d011SMarcel Moolenaar.It Cm \&*
15893955d011SMarcel MoolenaarCauses subsequent modifiers to treat the value as a single word
15903955d011SMarcel Moolenaar(possibly containing embedded white space).
15913955d011SMarcel MoolenaarAnalogous to the effect of
15923955d011SMarcel Moolenaar\&"$*\&"
15933955d011SMarcel Moolenaarin Bourne shell.
15943955d011SMarcel Moolenaar.\" :[0]
15953955d011SMarcel Moolenaar.It 0
15963955d011SMarcel MoolenaarMeans the same as
15973955d011SMarcel Moolenaar.Ql Cm \&:[*] .
15983955d011SMarcel Moolenaar.\" :[*]
15993955d011SMarcel Moolenaar.It Cm \&@
16003955d011SMarcel MoolenaarCauses subsequent modifiers to treat the value as a sequence of words
16013955d011SMarcel Moolenaardelimited by white space.
16023955d011SMarcel MoolenaarAnalogous to the effect of
16033955d011SMarcel Moolenaar\&"$@\&"
16043955d011SMarcel Moolenaarin Bourne shell.
16053955d011SMarcel Moolenaar.\" :[#]
16063955d011SMarcel Moolenaar.It Cm \&#
16073955d011SMarcel MoolenaarReturns the number of words in the value.
16083955d011SMarcel Moolenaar.El \" :[range]
16093955d011SMarcel Moolenaar.El
16103955d011SMarcel Moolenaar.Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS
16113955d011SMarcel MoolenaarMakefile inclusion, conditional structures and for loops  reminiscent
16123955d011SMarcel Moolenaarof the C programming language are provided in
16133955d011SMarcel Moolenaar.Nm .
16143955d011SMarcel MoolenaarAll such structures are identified by a line beginning with a single
16153955d011SMarcel Moolenaardot
16163955d011SMarcel Moolenaar.Pq Ql \&.
16173955d011SMarcel Moolenaarcharacter.
16183955d011SMarcel MoolenaarFiles are included with either
16193955d011SMarcel Moolenaar.Cm \&.include Aq Ar file
16203955d011SMarcel Moolenaaror
16213955d011SMarcel Moolenaar.Cm \&.include Pf \*q Ar file Ns \*q .
16223955d011SMarcel MoolenaarVariables between the angle brackets or double quotes are expanded
16233955d011SMarcel Moolenaarto form the file name.
16243955d011SMarcel MoolenaarIf angle brackets are used, the included makefile is expected to be in
16253955d011SMarcel Moolenaarthe system makefile directory.
16263955d011SMarcel MoolenaarIf double quotes are used, the including makefile's directory and any
16273955d011SMarcel Moolenaardirectories specified using the
16283955d011SMarcel Moolenaar.Fl I
16293955d011SMarcel Moolenaaroption are searched before the system
16303955d011SMarcel Moolenaarmakefile directory.
16313955d011SMarcel MoolenaarFor compatibility with other versions of
16323955d011SMarcel Moolenaar.Nm
16333955d011SMarcel Moolenaar.Ql include file ...
16343955d011SMarcel Moolenaaris also accepted.
1635be19d90bSSimon J. Gerraty.Pp
16363955d011SMarcel MoolenaarIf the include statement is written as
16373955d011SMarcel Moolenaar.Cm .-include
16383955d011SMarcel Moolenaaror as
16393955d011SMarcel Moolenaar.Cm .sinclude
16403955d011SMarcel Moolenaarthen errors locating and/or opening include files are ignored.
16413955d011SMarcel Moolenaar.Pp
1642be19d90bSSimon J. GerratyIf the include statement is written as
1643be19d90bSSimon J. Gerraty.Cm .dinclude
1644be19d90bSSimon J. Gerratynot only are errors locating and/or opening include files ignored,
1645be19d90bSSimon J. Gerratybut stale dependencies within the included file will be ignored
1646be19d90bSSimon J. Gerratyjust like
1647be19d90bSSimon J. Gerraty.Va .MAKE.DEPENDFILE .
1648be19d90bSSimon J. Gerraty.Pp
16493955d011SMarcel MoolenaarConditional expressions are also preceded by a single dot as the first
16503955d011SMarcel Moolenaarcharacter of a line.
16513955d011SMarcel MoolenaarThe possible conditionals are as follows:
16523955d011SMarcel Moolenaar.Bl -tag -width Ds
16533955d011SMarcel Moolenaar.It Ic .error Ar message
16543955d011SMarcel MoolenaarThe message is printed along with the name of the makefile and line number,
16553955d011SMarcel Moolenaarthen
16563955d011SMarcel Moolenaar.Nm
16573955d011SMarcel Moolenaarwill exit.
16583955d011SMarcel Moolenaar.It Ic .export Ar variable ...
16593955d011SMarcel MoolenaarExport the specified global variable.
16603955d011SMarcel MoolenaarIf no variable list is provided, all globals are exported
16613955d011SMarcel Moolenaarexcept for internal variables (those that start with
16623955d011SMarcel Moolenaar.Ql \&. ) .
16633955d011SMarcel MoolenaarThis is not affected by the
16643955d011SMarcel Moolenaar.Fl X
16653955d011SMarcel Moolenaarflag, so should be used with caution.
16663955d011SMarcel MoolenaarFor compatibility with other
16673955d011SMarcel Moolenaar.Nm
16683955d011SMarcel Moolenaarprograms
16693955d011SMarcel Moolenaar.Ql export variable=value
16703955d011SMarcel Moolenaaris also accepted.
16713955d011SMarcel Moolenaar.Pp
16723955d011SMarcel MoolenaarAppending a variable name to
16733955d011SMarcel Moolenaar.Va .MAKE.EXPORTED
16743955d011SMarcel Moolenaaris equivalent to exporting a variable.
16753955d011SMarcel Moolenaar.It Ic .export-env Ar variable ...
16763955d011SMarcel MoolenaarThe same as
16773955d011SMarcel Moolenaar.Ql .export ,
16783955d011SMarcel Moolenaarexcept that the variable is not appended to
16793955d011SMarcel Moolenaar.Va .MAKE.EXPORTED .
16803955d011SMarcel MoolenaarThis allows exporting a value to the environment which is different from that
16813955d011SMarcel Moolenaarused by
16823955d011SMarcel Moolenaar.Nm
16833955d011SMarcel Moolenaarinternally.
1684be19d90bSSimon J. Gerraty.It Ic .export-literal Ar variable ...
1685be19d90bSSimon J. GerratyThe same as
1686be19d90bSSimon J. Gerraty.Ql .export-env ,
1687be19d90bSSimon J. Gerratyexcept that variables in the value are not expanded.
16883955d011SMarcel Moolenaar.It Ic .info Ar message
16893955d011SMarcel MoolenaarThe message is printed along with the name of the makefile and line number.
16903955d011SMarcel Moolenaar.It Ic .undef Ar variable
16913955d011SMarcel MoolenaarUn-define the specified global variable.
16923955d011SMarcel MoolenaarOnly global variables may be un-defined.
16933955d011SMarcel Moolenaar.It Ic .unexport Ar variable ...
16943955d011SMarcel MoolenaarThe opposite of
16953955d011SMarcel Moolenaar.Ql .export .
16963955d011SMarcel MoolenaarThe specified global
16973955d011SMarcel Moolenaar.Va variable
16983955d011SMarcel Moolenaarwill be removed from
16993955d011SMarcel Moolenaar.Va .MAKE.EXPORTED .
17003955d011SMarcel MoolenaarIf no variable list is provided, all globals are unexported,
17013955d011SMarcel Moolenaarand
17023955d011SMarcel Moolenaar.Va .MAKE.EXPORTED
17033955d011SMarcel Moolenaardeleted.
17043955d011SMarcel Moolenaar.It Ic .unexport-env
17053955d011SMarcel MoolenaarUnexport all globals previously exported and
17063955d011SMarcel Moolenaarclear the environment inherited from the parent.
17073955d011SMarcel MoolenaarThis operation will cause a memory leak of the original environment,
17083955d011SMarcel Moolenaarso should be used sparingly.
17093955d011SMarcel MoolenaarTesting for
17103955d011SMarcel Moolenaar.Va .MAKE.LEVEL
17113955d011SMarcel Moolenaarbeing 0, would make sense.
17123955d011SMarcel MoolenaarAlso note that any variables which originated in the parent environment
17133955d011SMarcel Moolenaarshould be explicitly preserved if desired.
17143955d011SMarcel MoolenaarFor example:
17153955d011SMarcel Moolenaar.Bd -literal -offset indent
17163955d011SMarcel Moolenaar.Li .if ${.MAKE.LEVEL} == 0
17173955d011SMarcel MoolenaarPATH := ${PATH}
17183955d011SMarcel Moolenaar.Li .unexport-env
17193955d011SMarcel Moolenaar.Li .export PATH
17203955d011SMarcel Moolenaar.Li .endif
17213955d011SMarcel Moolenaar.Pp
17223955d011SMarcel Moolenaar.Ed
17233955d011SMarcel MoolenaarWould result in an environment containing only
17243955d011SMarcel Moolenaar.Ql Ev PATH ,
17253955d011SMarcel Moolenaarwhich is the minimal useful environment.
17263955d011SMarcel MoolenaarActually
17273955d011SMarcel Moolenaar.Ql Ev .MAKE.LEVEL
17283955d011SMarcel Moolenaarwill also be pushed into the new environment.
17293955d011SMarcel Moolenaar.It Ic .warning Ar message
17303955d011SMarcel MoolenaarThe message prefixed by
17313955d011SMarcel Moolenaar.Ql Pa warning:
17323955d011SMarcel Moolenaaris printed along with the name of the makefile and line number.
17333955d011SMarcel Moolenaar.It Ic \&.if Oo \&! Oc Ns Ar expression Op Ar operator expression ...
17343955d011SMarcel MoolenaarTest the value of an expression.
17353955d011SMarcel Moolenaar.It Ic .ifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
17363955d011SMarcel MoolenaarTest the value of a variable.
17373955d011SMarcel Moolenaar.It Ic .ifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
17383955d011SMarcel MoolenaarTest the value of a variable.
17393955d011SMarcel Moolenaar.It Ic .ifmake Oo \&! Oc Ns Ar target Op Ar operator target ...
17403955d011SMarcel MoolenaarTest the target being built.
17413955d011SMarcel Moolenaar.It Ic .ifnmake Oo \&! Ns Oc Ar target Op Ar operator target ...
17423955d011SMarcel MoolenaarTest the target being built.
17433955d011SMarcel Moolenaar.It Ic .else
17443955d011SMarcel MoolenaarReverse the sense of the last conditional.
17453955d011SMarcel Moolenaar.It Ic .elif Oo \&! Ns Oc Ar expression Op Ar operator expression ...
17463955d011SMarcel MoolenaarA combination of
17473955d011SMarcel Moolenaar.Ql Ic .else
17483955d011SMarcel Moolenaarfollowed by
17493955d011SMarcel Moolenaar.Ql Ic .if .
17503955d011SMarcel Moolenaar.It Ic .elifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
17513955d011SMarcel MoolenaarA combination of
17523955d011SMarcel Moolenaar.Ql Ic .else
17533955d011SMarcel Moolenaarfollowed by
17543955d011SMarcel Moolenaar.Ql Ic .ifdef .
17553955d011SMarcel Moolenaar.It Ic .elifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
17563955d011SMarcel MoolenaarA combination of
17573955d011SMarcel Moolenaar.Ql Ic .else
17583955d011SMarcel Moolenaarfollowed by
17593955d011SMarcel Moolenaar.Ql Ic .ifndef .
17603955d011SMarcel Moolenaar.It Ic .elifmake Oo \&! Oc Ns Ar target Op Ar operator target ...
17613955d011SMarcel MoolenaarA combination of
17623955d011SMarcel Moolenaar.Ql Ic .else
17633955d011SMarcel Moolenaarfollowed by
17643955d011SMarcel Moolenaar.Ql Ic .ifmake .
17653955d011SMarcel Moolenaar.It Ic .elifnmake Oo \&! Oc Ns Ar target Op Ar operator target ...
17663955d011SMarcel MoolenaarA combination of
17673955d011SMarcel Moolenaar.Ql Ic .else
17683955d011SMarcel Moolenaarfollowed by
17693955d011SMarcel Moolenaar.Ql Ic .ifnmake .
17703955d011SMarcel Moolenaar.It Ic .endif
17713955d011SMarcel MoolenaarEnd the body of the conditional.
17723955d011SMarcel Moolenaar.El
17733955d011SMarcel Moolenaar.Pp
17743955d011SMarcel MoolenaarThe
17753955d011SMarcel Moolenaar.Ar operator
17763955d011SMarcel Moolenaarmay be any one of the following:
17773955d011SMarcel Moolenaar.Bl -tag -width "Cm XX"
17783955d011SMarcel Moolenaar.It Cm \&|\&|
17793955d011SMarcel MoolenaarLogical OR.
17808695518cSSimon J. Gerraty.It Cm \&&&
17813955d011SMarcel MoolenaarLogical
17823955d011SMarcel Moolenaar.Tn AND ;
17833955d011SMarcel Moolenaarof higher precedence than
17843955d011SMarcel Moolenaar.Dq \&|\&| .
17853955d011SMarcel Moolenaar.El
17863955d011SMarcel Moolenaar.Pp
17873955d011SMarcel MoolenaarAs in C,
17883955d011SMarcel Moolenaar.Nm
17893955d011SMarcel Moolenaarwill only evaluate a conditional as far as is necessary to determine
17903955d011SMarcel Moolenaarits value.
17913955d011SMarcel MoolenaarParentheses may be used to change the order of evaluation.
17923955d011SMarcel MoolenaarThe boolean operator
17933955d011SMarcel Moolenaar.Ql Ic \&!
17943955d011SMarcel Moolenaarmay be used to logically negate an entire
17953955d011SMarcel Moolenaarconditional.
17963955d011SMarcel MoolenaarIt is of higher precedence than
17978695518cSSimon J. Gerraty.Ql Ic \&&& .
17983955d011SMarcel Moolenaar.Pp
17993955d011SMarcel MoolenaarThe value of
18003955d011SMarcel Moolenaar.Ar expression
18013955d011SMarcel Moolenaarmay be any of the following:
18023955d011SMarcel Moolenaar.Bl -tag -width defined
18033955d011SMarcel Moolenaar.It Ic defined
18043955d011SMarcel MoolenaarTakes a variable name as an argument and evaluates to true if the variable
18053955d011SMarcel Moolenaarhas been defined.
18063955d011SMarcel Moolenaar.It Ic make
18073955d011SMarcel MoolenaarTakes a target name as an argument and evaluates to true if the target
18083955d011SMarcel Moolenaarwas specified as part of
18093955d011SMarcel Moolenaar.Nm Ns 's
18103955d011SMarcel Moolenaarcommand line or was declared the default target (either implicitly or
18113955d011SMarcel Moolenaarexplicitly, see
18123955d011SMarcel Moolenaar.Va .MAIN )
18133955d011SMarcel Moolenaarbefore the line containing the conditional.
18143955d011SMarcel Moolenaar.It Ic empty
18153955d011SMarcel MoolenaarTakes a variable, with possible modifiers, and evaluates to true if
18163955d011SMarcel Moolenaarthe expansion of the variable would result in an empty string.
18173955d011SMarcel Moolenaar.It Ic exists
18183955d011SMarcel MoolenaarTakes a file name as an argument and evaluates to true if the file exists.
18193955d011SMarcel MoolenaarThe file is searched for on the system search path (see
18203955d011SMarcel Moolenaar.Va .PATH ) .
18213955d011SMarcel Moolenaar.It Ic target
18223955d011SMarcel MoolenaarTakes a target name as an argument and evaluates to true if the target
18233955d011SMarcel Moolenaarhas been defined.
18243955d011SMarcel Moolenaar.It Ic commands
18253955d011SMarcel MoolenaarTakes a target name as an argument and evaluates to true if the target
18263955d011SMarcel Moolenaarhas been defined and has commands associated with it.
18273955d011SMarcel Moolenaar.El
18283955d011SMarcel Moolenaar.Pp
18293955d011SMarcel Moolenaar.Ar Expression
18303955d011SMarcel Moolenaarmay also be an arithmetic or string comparison.
18313955d011SMarcel MoolenaarVariable expansion is
18323955d011SMarcel Moolenaarperformed on both sides of the comparison, after which the integral
18333955d011SMarcel Moolenaarvalues are compared.
18343955d011SMarcel MoolenaarA value is interpreted as hexadecimal if it is
18353955d011SMarcel Moolenaarpreceded by 0x, otherwise it is decimal; octal numbers are not supported.
18363955d011SMarcel MoolenaarThe standard C relational operators are all supported.
18373955d011SMarcel MoolenaarIf after
18383955d011SMarcel Moolenaarvariable expansion, either the left or right hand side of a
18393955d011SMarcel Moolenaar.Ql Ic ==
18403955d011SMarcel Moolenaaror
18413955d011SMarcel Moolenaar.Ql Ic "!="
18423955d011SMarcel Moolenaaroperator is not an integral value, then
18433955d011SMarcel Moolenaarstring comparison is performed between the expanded
18443955d011SMarcel Moolenaarvariables.
18453955d011SMarcel MoolenaarIf no relational operator is given, it is assumed that the expanded
18463955d011SMarcel Moolenaarvariable is being compared against 0 or an empty string in the case
18473955d011SMarcel Moolenaarof a string comparison.
18483955d011SMarcel Moolenaar.Pp
18493955d011SMarcel MoolenaarWhen
18503955d011SMarcel Moolenaar.Nm
18513955d011SMarcel Moolenaaris evaluating one of these conditional expressions, and it encounters
18523955d011SMarcel Moolenaara (white-space separated) word it doesn't recognize, either the
18533955d011SMarcel Moolenaar.Dq make
18543955d011SMarcel Moolenaaror
18553955d011SMarcel Moolenaar.Dq defined
18563955d011SMarcel Moolenaarexpression is applied to it, depending on the form of the conditional.
18573955d011SMarcel MoolenaarIf the form is
18583955d011SMarcel Moolenaar.Ql Ic .ifdef ,
18593955d011SMarcel Moolenaar.Ql Ic .ifndef ,
18603955d011SMarcel Moolenaaror
18613955d011SMarcel Moolenaar.Ql Ic .if
18623955d011SMarcel Moolenaarthe
18633955d011SMarcel Moolenaar.Dq defined
18643955d011SMarcel Moolenaarexpression is applied.
18653955d011SMarcel MoolenaarSimilarly, if the form is
18663955d011SMarcel Moolenaar.Ql Ic .ifmake
18673955d011SMarcel Moolenaaror
1868*494f7191SSimon J. Gerraty.Ql Ic .ifnmake ,
1869*494f7191SSimon J. Gerratythe
18703955d011SMarcel Moolenaar.Dq make
18713955d011SMarcel Moolenaarexpression is applied.
18723955d011SMarcel Moolenaar.Pp
18733955d011SMarcel MoolenaarIf the conditional evaluates to true the parsing of the makefile continues
18743955d011SMarcel Moolenaaras before.
18753955d011SMarcel MoolenaarIf it evaluates to false, the following lines are skipped.
18763955d011SMarcel MoolenaarIn both cases this continues until a
18773955d011SMarcel Moolenaar.Ql Ic .else
18783955d011SMarcel Moolenaaror
18793955d011SMarcel Moolenaar.Ql Ic .endif
18803955d011SMarcel Moolenaaris found.
18813955d011SMarcel Moolenaar.Pp
18823955d011SMarcel MoolenaarFor loops are typically used to apply a set of rules to a list of files.
18833955d011SMarcel MoolenaarThe syntax of a for loop is:
18843955d011SMarcel Moolenaar.Pp
18853955d011SMarcel Moolenaar.Bl -tag -compact -width Ds
18863955d011SMarcel Moolenaar.It Ic \&.for Ar variable Oo Ar variable ... Oc Ic in Ar expression
18873955d011SMarcel Moolenaar.It Aq make-rules
18883955d011SMarcel Moolenaar.It Ic \&.endfor
18893955d011SMarcel Moolenaar.El
18903955d011SMarcel Moolenaar.Pp
18913955d011SMarcel MoolenaarAfter the for
18923955d011SMarcel Moolenaar.Ic expression
18933955d011SMarcel Moolenaaris evaluated, it is split into words.
18943955d011SMarcel MoolenaarOn each iteration of the loop, one word is taken and assigned to each
18953955d011SMarcel Moolenaar.Ic variable ,
18963955d011SMarcel Moolenaarin order, and these
18973955d011SMarcel Moolenaar.Ic variables
18983955d011SMarcel Moolenaarare substituted into the
18993955d011SMarcel Moolenaar.Ic make-rules
19003955d011SMarcel Moolenaarinside the body of the for loop.
19013955d011SMarcel MoolenaarThe number of words must come out even; that is, if there are three
19023955d011SMarcel Moolenaariteration variables, the number of words provided must be a multiple
19033955d011SMarcel Moolenaarof three.
19043955d011SMarcel Moolenaar.Sh COMMENTS
19053955d011SMarcel MoolenaarComments begin with a hash
19063955d011SMarcel Moolenaar.Pq Ql \&#
19073955d011SMarcel Moolenaarcharacter, anywhere but in a shell
19083955d011SMarcel Moolenaarcommand line, and continue to the end of an unescaped new line.
19093955d011SMarcel Moolenaar.Sh SPECIAL SOURCES (ATTRIBUTES)
19103955d011SMarcel Moolenaar.Bl -tag -width .IGNOREx
19113955d011SMarcel Moolenaar.It Ic .EXEC
19123955d011SMarcel MoolenaarTarget is never out of date, but always execute commands anyway.
19133955d011SMarcel Moolenaar.It Ic .IGNORE
19143955d011SMarcel MoolenaarIgnore any errors from the commands associated with this target, exactly
19153955d011SMarcel Moolenaaras if they all were preceded by a dash
19163955d011SMarcel Moolenaar.Pq Ql \- .
19173955d011SMarcel Moolenaar.\" .It Ic .INVISIBLE
19183955d011SMarcel Moolenaar.\" XXX
19193955d011SMarcel Moolenaar.\" .It Ic .JOIN
19203955d011SMarcel Moolenaar.\" XXX
19213955d011SMarcel Moolenaar.It Ic .MADE
19223955d011SMarcel MoolenaarMark all sources of this target as being up-to-date.
19233955d011SMarcel Moolenaar.It Ic .MAKE
19243955d011SMarcel MoolenaarExecute the commands associated with this target even if the
19253955d011SMarcel Moolenaar.Fl n
19263955d011SMarcel Moolenaaror
19273955d011SMarcel Moolenaar.Fl t
19283955d011SMarcel Moolenaaroptions were specified.
19293955d011SMarcel MoolenaarNormally used to mark recursive
19300dede8b0SSimon J. Gerraty.Nm Ns s .
19313955d011SMarcel Moolenaar.It Ic .META
19323955d011SMarcel MoolenaarCreate a meta file for the target, even if it is flagged as
19333955d011SMarcel Moolenaar.Ic .PHONY ,
19343955d011SMarcel Moolenaar.Ic .MAKE ,
19353955d011SMarcel Moolenaaror
19363955d011SMarcel Moolenaar.Ic .SPECIAL .
19373955d011SMarcel MoolenaarUsage in conjunction with
19383955d011SMarcel Moolenaar.Ic .MAKE
19393955d011SMarcel Moolenaaris the most likely case.
19403955d011SMarcel MoolenaarIn "meta" mode, the target is out-of-date if the meta file is missing.
19413955d011SMarcel Moolenaar.It Ic .NOMETA
19423955d011SMarcel MoolenaarDo not create a meta file for the target.
19433955d011SMarcel MoolenaarMeta files are also not created for
19443955d011SMarcel Moolenaar.Ic .PHONY ,
19453955d011SMarcel Moolenaar.Ic .MAKE ,
19463955d011SMarcel Moolenaaror
19473955d011SMarcel Moolenaar.Ic .SPECIAL
19483955d011SMarcel Moolenaartargets.
19493955d011SMarcel Moolenaar.It Ic .NOMETA_CMP
19503955d011SMarcel MoolenaarIgnore differences in commands when deciding if target is out of date.
19513955d011SMarcel MoolenaarThis is useful if the command contains a value which always changes.
19523955d011SMarcel MoolenaarIf the number of commands change, though, the target will still be out of date.
19531748de26SSimon J. GerratyThe same effect applies to any command line that uses the variable
19541748de26SSimon J. Gerraty.Va .OODATE ,
19551748de26SSimon J. Gerratywhich can be used for that purpose even when not otherwise needed or desired:
19561748de26SSimon J. Gerraty.Bd -literal -offset indent
19571748de26SSimon J. Gerraty
19581748de26SSimon J. Gerratyskip-compare-for-some:
19591748de26SSimon J. Gerraty	@echo this will be compared
19601748de26SSimon J. Gerraty	@echo this will not ${.OODATE:M.NOMETA_CMP}
19611748de26SSimon J. Gerraty	@echo this will also be compared
19621748de26SSimon J. Gerraty
19631748de26SSimon J. Gerraty.Ed
19641748de26SSimon J. GerratyThe
19651748de26SSimon J. Gerraty.Cm \&:M
19661748de26SSimon J. Gerratypattern suppresses any expansion of the unwanted variable.
19673955d011SMarcel Moolenaar.It Ic .NOPATH
19683955d011SMarcel MoolenaarDo not search for the target in the directories specified by
19693955d011SMarcel Moolenaar.Ic .PATH .
19703955d011SMarcel Moolenaar.It Ic .NOTMAIN
19713955d011SMarcel MoolenaarNormally
19723955d011SMarcel Moolenaar.Nm
19733955d011SMarcel Moolenaarselects the first target it encounters as the default target to be built
19743955d011SMarcel Moolenaarif no target was specified.
19753955d011SMarcel MoolenaarThis source prevents this target from being selected.
19763955d011SMarcel Moolenaar.It Ic .OPTIONAL
19773955d011SMarcel MoolenaarIf a target is marked with this attribute and
19783955d011SMarcel Moolenaar.Nm
19793955d011SMarcel Moolenaarcan't figure out how to create it, it will ignore this fact and assume
19803955d011SMarcel Moolenaarthe file isn't needed or already exists.
19813955d011SMarcel Moolenaar.It Ic .PHONY
19823955d011SMarcel MoolenaarThe target does not
19833955d011SMarcel Moolenaarcorrespond to an actual file; it is always considered to be out of date,
19843955d011SMarcel Moolenaarand will not be created with the
19853955d011SMarcel Moolenaar.Fl t
19863955d011SMarcel Moolenaaroption.
19873955d011SMarcel MoolenaarSuffix-transformation rules are not applied to
19883955d011SMarcel Moolenaar.Ic .PHONY
19893955d011SMarcel Moolenaartargets.
19903955d011SMarcel Moolenaar.It Ic .PRECIOUS
19913955d011SMarcel MoolenaarWhen
19923955d011SMarcel Moolenaar.Nm
19933955d011SMarcel Moolenaaris interrupted, it normally removes any partially made targets.
19943955d011SMarcel MoolenaarThis source prevents the target from being removed.
19953955d011SMarcel Moolenaar.It Ic .RECURSIVE
19963955d011SMarcel MoolenaarSynonym for
19973955d011SMarcel Moolenaar.Ic .MAKE .
19983955d011SMarcel Moolenaar.It Ic .SILENT
19993955d011SMarcel MoolenaarDo not echo any of the commands associated with this target, exactly
20003955d011SMarcel Moolenaaras if they all were preceded by an at sign
20013955d011SMarcel Moolenaar.Pq Ql @ .
20023955d011SMarcel Moolenaar.It Ic .USE
20033955d011SMarcel MoolenaarTurn the target into
20043955d011SMarcel Moolenaar.Nm Ns 's
20053955d011SMarcel Moolenaarversion of a macro.
20063955d011SMarcel MoolenaarWhen the target is used as a source for another target, the other target
20073955d011SMarcel Moolenaaracquires the commands, sources, and attributes (except for
20083955d011SMarcel Moolenaar.Ic .USE )
20093955d011SMarcel Moolenaarof the
20103955d011SMarcel Moolenaarsource.
20113955d011SMarcel MoolenaarIf the target already has commands, the
20123955d011SMarcel Moolenaar.Ic .USE
20133955d011SMarcel Moolenaartarget's commands are appended
20143955d011SMarcel Moolenaarto them.
20153955d011SMarcel Moolenaar.It Ic .USEBEFORE
20163955d011SMarcel MoolenaarExactly like
20173955d011SMarcel Moolenaar.Ic .USE ,
20183955d011SMarcel Moolenaarbut prepend the
20193955d011SMarcel Moolenaar.Ic .USEBEFORE
20203955d011SMarcel Moolenaartarget commands to the target.
20213955d011SMarcel Moolenaar.It Ic .WAIT
20223955d011SMarcel MoolenaarIf
20233955d011SMarcel Moolenaar.Ic .WAIT
20243955d011SMarcel Moolenaarappears in a dependency line, the sources that precede it are
20253955d011SMarcel Moolenaarmade before the sources that succeed it in the line.
20263955d011SMarcel MoolenaarSince the dependents of files are not made until the file itself
20273955d011SMarcel Moolenaarcould be made, this also stops the dependents being built unless they
20283955d011SMarcel Moolenaarare needed for another branch of the dependency tree.
20293955d011SMarcel MoolenaarSo given:
20303955d011SMarcel Moolenaar.Bd -literal
20313955d011SMarcel Moolenaarx: a .WAIT b
20323955d011SMarcel Moolenaar	echo x
20333955d011SMarcel Moolenaara:
20343955d011SMarcel Moolenaar	echo a
20353955d011SMarcel Moolenaarb: b1
20363955d011SMarcel Moolenaar	echo b
20373955d011SMarcel Moolenaarb1:
20383955d011SMarcel Moolenaar	echo b1
20393955d011SMarcel Moolenaar
20403955d011SMarcel Moolenaar.Ed
20413955d011SMarcel Moolenaarthe output is always
20423955d011SMarcel Moolenaar.Ql a ,
20433955d011SMarcel Moolenaar.Ql b1 ,
20443955d011SMarcel Moolenaar.Ql b ,
20453955d011SMarcel Moolenaar.Ql x .
20463955d011SMarcel Moolenaar.br
20473955d011SMarcel MoolenaarThe ordering imposed by
20483955d011SMarcel Moolenaar.Ic .WAIT
20493955d011SMarcel Moolenaaris only relevant for parallel makes.
20503955d011SMarcel Moolenaar.El
20513955d011SMarcel Moolenaar.Sh SPECIAL TARGETS
20523955d011SMarcel MoolenaarSpecial targets may not be included with other targets, i.e. they must be
20533955d011SMarcel Moolenaarthe only target specified.
20543955d011SMarcel Moolenaar.Bl -tag -width .BEGINx
20553955d011SMarcel Moolenaar.It Ic .BEGIN
20563955d011SMarcel MoolenaarAny command lines attached to this target are executed before anything
20573955d011SMarcel Moolenaarelse is done.
20583955d011SMarcel Moolenaar.It Ic .DEFAULT
20593955d011SMarcel MoolenaarThis is sort of a
20603955d011SMarcel Moolenaar.Ic .USE
20613955d011SMarcel Moolenaarrule for any target (that was used only as a
20623955d011SMarcel Moolenaarsource) that
20633955d011SMarcel Moolenaar.Nm
20643955d011SMarcel Moolenaarcan't figure out any other way to create.
20653955d011SMarcel MoolenaarOnly the shell script is used.
20663955d011SMarcel MoolenaarThe
20673955d011SMarcel Moolenaar.Ic .IMPSRC
20683955d011SMarcel Moolenaarvariable of a target that inherits
20693955d011SMarcel Moolenaar.Ic .DEFAULT Ns 's
20703955d011SMarcel Moolenaarcommands is set
20713955d011SMarcel Moolenaarto the target's own name.
207245447996SSimon J. Gerraty.It Ic .DELETE_ON_ERROR
207345447996SSimon J. GerratyIf this target is present in the makefile, it globally causes make to
207445447996SSimon J. Gerratydelete targets whose commands fail.
207545447996SSimon J. Gerraty(By default, only targets whose commands are interrupted during
207645447996SSimon J. Gerratyexecution are deleted.
207745447996SSimon J. GerratyThis is the historical behavior.)
207845447996SSimon J. GerratyThis setting can be used to help prevent half-finished or malformed
207945447996SSimon J. Gerratytargets from being left around and corrupting future rebuilds.
20803955d011SMarcel Moolenaar.It Ic .END
20813955d011SMarcel MoolenaarAny command lines attached to this target are executed after everything
20823955d011SMarcel Moolenaarelse is done.
20833955d011SMarcel Moolenaar.It Ic .ERROR
20843955d011SMarcel MoolenaarAny command lines attached to this target are executed when another target fails.
20853955d011SMarcel MoolenaarThe
20863955d011SMarcel Moolenaar.Ic .ERROR_TARGET
20873955d011SMarcel Moolenaarvariable is set to the target that failed.
20883955d011SMarcel MoolenaarSee also
20893955d011SMarcel Moolenaar.Ic MAKE_PRINT_VAR_ON_ERROR .
20903955d011SMarcel Moolenaar.It Ic .IGNORE
20913955d011SMarcel MoolenaarMark each of the sources with the
20923955d011SMarcel Moolenaar.Ic .IGNORE
20933955d011SMarcel Moolenaarattribute.
20943955d011SMarcel MoolenaarIf no sources are specified, this is the equivalent of specifying the
20953955d011SMarcel Moolenaar.Fl i
20963955d011SMarcel Moolenaaroption.
20973955d011SMarcel Moolenaar.It Ic .INTERRUPT
20983955d011SMarcel MoolenaarIf
20993955d011SMarcel Moolenaar.Nm
21003955d011SMarcel Moolenaaris interrupted, the commands for this target will be executed.
21013955d011SMarcel Moolenaar.It Ic .MAIN
21023955d011SMarcel MoolenaarIf no target is specified when
21033955d011SMarcel Moolenaar.Nm
21043955d011SMarcel Moolenaaris invoked, this target will be built.
21053955d011SMarcel Moolenaar.It Ic .MAKEFLAGS
21063955d011SMarcel MoolenaarThis target provides a way to specify flags for
21073955d011SMarcel Moolenaar.Nm
21083955d011SMarcel Moolenaarwhen the makefile is used.
21093955d011SMarcel MoolenaarThe flags are as if typed to the shell, though the
21103955d011SMarcel Moolenaar.Fl f
21113955d011SMarcel Moolenaaroption will have
21123955d011SMarcel Moolenaarno effect.
21133955d011SMarcel Moolenaar.\" XXX: NOT YET!!!!
21143955d011SMarcel Moolenaar.\" .It Ic .NOTPARALLEL
21153955d011SMarcel Moolenaar.\" The named targets are executed in non parallel mode.
21163955d011SMarcel Moolenaar.\" If no targets are
21173955d011SMarcel Moolenaar.\" specified, then all targets are executed in non parallel mode.
21183955d011SMarcel Moolenaar.It Ic .NOPATH
21193955d011SMarcel MoolenaarApply the
21203955d011SMarcel Moolenaar.Ic .NOPATH
21213955d011SMarcel Moolenaarattribute to any specified sources.
21223955d011SMarcel Moolenaar.It Ic .NOTPARALLEL
21233955d011SMarcel MoolenaarDisable parallel mode.
21243955d011SMarcel Moolenaar.It Ic .NO_PARALLEL
21253955d011SMarcel MoolenaarSynonym for
21263955d011SMarcel Moolenaar.Ic .NOTPARALLEL ,
21273955d011SMarcel Moolenaarfor compatibility with other pmake variants.
2128128a4105SSimon J. Gerraty.It Ic .OBJDIR
2129128a4105SSimon J. GerratyThe source is a new value for
2130128a4105SSimon J. Gerraty.Ql Va .OBJDIR .
2131128a4105SSimon J. GerratyIf it exists,
2132128a4105SSimon J. Gerraty.Nm
2133128a4105SSimon J. Gerratywill
2134128a4105SSimon J. Gerraty.Xr chdir 2
2135128a4105SSimon J. Gerratyto it and update the value of
2136128a4105SSimon J. Gerraty.Ql Va .OBJDIR .
21373955d011SMarcel Moolenaar.It Ic .ORDER
21383955d011SMarcel MoolenaarThe named targets are made in sequence.
21393955d011SMarcel MoolenaarThis ordering does not add targets to the list of targets to be made.
21403955d011SMarcel MoolenaarSince the dependents of a target do not get built until the target itself
21413955d011SMarcel Moolenaarcould be built, unless
21423955d011SMarcel Moolenaar.Ql a
21433955d011SMarcel Moolenaaris built by another part of the dependency graph,
21443955d011SMarcel Moolenaarthe following is a dependency loop:
21453955d011SMarcel Moolenaar.Bd -literal
21463955d011SMarcel Moolenaar\&.ORDER: b a
21473955d011SMarcel Moolenaarb: a
21483955d011SMarcel Moolenaar.Ed
21493955d011SMarcel Moolenaar.Pp
21503955d011SMarcel MoolenaarThe ordering imposed by
21513955d011SMarcel Moolenaar.Ic .ORDER
21523955d011SMarcel Moolenaaris only relevant for parallel makes.
21533955d011SMarcel Moolenaar.\" XXX: NOT YET!!!!
21543955d011SMarcel Moolenaar.\" .It Ic .PARALLEL
21553955d011SMarcel Moolenaar.\" The named targets are executed in parallel mode.
21563955d011SMarcel Moolenaar.\" If no targets are
21573955d011SMarcel Moolenaar.\" specified, then all targets are executed in parallel mode.
21583955d011SMarcel Moolenaar.It Ic .PATH
21593955d011SMarcel MoolenaarThe sources are directories which are to be searched for files not
21603955d011SMarcel Moolenaarfound in the current directory.
21613955d011SMarcel MoolenaarIf no sources are specified, any previously specified directories are
21623955d011SMarcel Moolenaardeleted.
21633955d011SMarcel MoolenaarIf the source is the special
21643955d011SMarcel Moolenaar.Ic .DOTLAST
21653955d011SMarcel Moolenaartarget, then the current working
21663955d011SMarcel Moolenaardirectory is searched last.
21671bbe5942SSimon J. Gerraty.It Ic .PATH. Ns Va suffix
21681bbe5942SSimon J. GerratyLike
21691bbe5942SSimon J. Gerraty.Ic .PATH
21701bbe5942SSimon J. Gerratybut applies only to files with a particular suffix.
21711bbe5942SSimon J. GerratyThe suffix must have been previously declared with
21721bbe5942SSimon J. Gerraty.Ic .SUFFIXES .
21733955d011SMarcel Moolenaar.It Ic .PHONY
21743955d011SMarcel MoolenaarApply the
21753955d011SMarcel Moolenaar.Ic .PHONY
21763955d011SMarcel Moolenaarattribute to any specified sources.
21773955d011SMarcel Moolenaar.It Ic .PRECIOUS
21783955d011SMarcel MoolenaarApply the
21793955d011SMarcel Moolenaar.Ic .PRECIOUS
21803955d011SMarcel Moolenaarattribute to any specified sources.
21813955d011SMarcel MoolenaarIf no sources are specified, the
21823955d011SMarcel Moolenaar.Ic .PRECIOUS
21833955d011SMarcel Moolenaarattribute is applied to every
21843955d011SMarcel Moolenaartarget in the file.
21853955d011SMarcel Moolenaar.It Ic .SHELL
21863955d011SMarcel MoolenaarSets the shell that
21873955d011SMarcel Moolenaar.Nm
21883955d011SMarcel Moolenaarwill use to execute commands.
21893955d011SMarcel MoolenaarThe sources are a set of
21903955d011SMarcel Moolenaar.Ar field=value
21913955d011SMarcel Moolenaarpairs.
21923955d011SMarcel Moolenaar.Bl -tag -width hasErrCtls
21933955d011SMarcel Moolenaar.It Ar name
2194be19d90bSSimon J. GerratyThis is the minimal specification, used to select one of the built-in
21953955d011SMarcel Moolenaarshell specs;
21963955d011SMarcel Moolenaar.Ar sh ,
21973955d011SMarcel Moolenaar.Ar ksh ,
21983955d011SMarcel Moolenaarand
21993955d011SMarcel Moolenaar.Ar csh .
22003955d011SMarcel Moolenaar.It Ar path
22013955d011SMarcel MoolenaarSpecifies the path to the shell.
22023955d011SMarcel Moolenaar.It Ar hasErrCtl
22033955d011SMarcel MoolenaarIndicates whether the shell supports exit on error.
22043955d011SMarcel Moolenaar.It Ar check
22053955d011SMarcel MoolenaarThe command to turn on error checking.
22063955d011SMarcel Moolenaar.It Ar ignore
22073955d011SMarcel MoolenaarThe command to disable error checking.
22083955d011SMarcel Moolenaar.It Ar echo
22093955d011SMarcel MoolenaarThe command to turn on echoing of commands executed.
22103955d011SMarcel Moolenaar.It Ar quiet
22113955d011SMarcel MoolenaarThe command to turn off echoing of commands executed.
22123955d011SMarcel Moolenaar.It Ar filter
22133955d011SMarcel MoolenaarThe output to filter after issuing the
22143955d011SMarcel Moolenaar.Ar quiet
22153955d011SMarcel Moolenaarcommand.
22163955d011SMarcel MoolenaarIt is typically identical to
22173955d011SMarcel Moolenaar.Ar quiet .
22183955d011SMarcel Moolenaar.It Ar errFlag
22193955d011SMarcel MoolenaarThe flag to pass the shell to enable error checking.
22203955d011SMarcel Moolenaar.It Ar echoFlag
22213955d011SMarcel MoolenaarThe flag to pass the shell to enable command echoing.
22223955d011SMarcel Moolenaar.It Ar newline
22233955d011SMarcel MoolenaarThe string literal to pass the shell that results in a single newline
22243955d011SMarcel Moolenaarcharacter when used outside of any quoting characters.
22253955d011SMarcel Moolenaar.El
22263955d011SMarcel MoolenaarExample:
22273955d011SMarcel Moolenaar.Bd -literal
22283955d011SMarcel Moolenaar\&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \e
22293955d011SMarcel Moolenaar	check="set \-e" ignore="set +e" \e
22303955d011SMarcel Moolenaar	echo="set \-v" quiet="set +v" filter="set +v" \e
22313955d011SMarcel Moolenaar	echoFlag=v errFlag=e newline="'\en'"
22323955d011SMarcel Moolenaar.Ed
22333955d011SMarcel Moolenaar.It Ic .SILENT
22343955d011SMarcel MoolenaarApply the
22353955d011SMarcel Moolenaar.Ic .SILENT
22363955d011SMarcel Moolenaarattribute to any specified sources.
22373955d011SMarcel MoolenaarIf no sources are specified, the
22383955d011SMarcel Moolenaar.Ic .SILENT
22393955d011SMarcel Moolenaarattribute is applied to every
22403955d011SMarcel Moolenaarcommand in the file.
22411748de26SSimon J. Gerraty.It Ic .STALE
22421748de26SSimon J. GerratyThis target gets run when a dependency file contains stale entries, having
22431748de26SSimon J. Gerraty.Va .ALLSRC
22441748de26SSimon J. Gerratyset to the name of that dependency file.
22453955d011SMarcel Moolenaar.It Ic .SUFFIXES
22463955d011SMarcel MoolenaarEach source specifies a suffix to
22473955d011SMarcel Moolenaar.Nm .
22483955d011SMarcel MoolenaarIf no sources are specified, any previously specified suffixes are deleted.
22493955d011SMarcel MoolenaarIt allows the creation of suffix-transformation rules.
22503955d011SMarcel Moolenaar.Pp
22513955d011SMarcel MoolenaarExample:
22523955d011SMarcel Moolenaar.Bd -literal
22533955d011SMarcel Moolenaar\&.SUFFIXES: .o
22543955d011SMarcel Moolenaar\&.c.o:
22553955d011SMarcel Moolenaar	cc \-o ${.TARGET} \-c ${.IMPSRC}
22563955d011SMarcel Moolenaar.Ed
22573955d011SMarcel Moolenaar.El
22583955d011SMarcel Moolenaar.Sh ENVIRONMENT
22593955d011SMarcel Moolenaar.Nm
22603955d011SMarcel Moolenaaruses the following environment variables, if they exist:
22613955d011SMarcel Moolenaar.Ev MACHINE ,
22623955d011SMarcel Moolenaar.Ev MACHINE_ARCH ,
22633955d011SMarcel Moolenaar.Ev MAKE ,
22643955d011SMarcel Moolenaar.Ev MAKEFLAGS ,
22653955d011SMarcel Moolenaar.Ev MAKEOBJDIR ,
22663955d011SMarcel Moolenaar.Ev MAKEOBJDIRPREFIX ,
22673955d011SMarcel Moolenaar.Ev MAKESYSPATH ,
22683955d011SMarcel Moolenaar.Ev PWD ,
22693955d011SMarcel Moolenaarand
22703955d011SMarcel Moolenaar.Ev TMPDIR .
22713955d011SMarcel Moolenaar.Pp
22723955d011SMarcel Moolenaar.Ev MAKEOBJDIRPREFIX
22733955d011SMarcel Moolenaarand
22743955d011SMarcel Moolenaar.Ev MAKEOBJDIR
22753955d011SMarcel Moolenaarmay only be set in the environment or on the command line to
22763955d011SMarcel Moolenaar.Nm
22773955d011SMarcel Moolenaarand not as makefile variables;
22783955d011SMarcel Moolenaarsee the description of
22793955d011SMarcel Moolenaar.Ql Va .OBJDIR
22803955d011SMarcel Moolenaarfor more details.
22813955d011SMarcel Moolenaar.Sh FILES
22823955d011SMarcel Moolenaar.Bl -tag -width /usr/share/mk -compact
22833955d011SMarcel Moolenaar.It .depend
22843955d011SMarcel Moolenaarlist of dependencies
22853955d011SMarcel Moolenaar.It Makefile
22863955d011SMarcel Moolenaarlist of dependencies
22873955d011SMarcel Moolenaar.It makefile
22883955d011SMarcel Moolenaarlist of dependencies
22893955d011SMarcel Moolenaar.It sys.mk
22903955d011SMarcel Moolenaarsystem makefile
22913955d011SMarcel Moolenaar.It /usr/share/mk
22923955d011SMarcel Moolenaarsystem makefile directory
22933955d011SMarcel Moolenaar.El
22943955d011SMarcel Moolenaar.Sh COMPATIBILITY
2295db29cad8SSimon J. GerratyThe basic make syntax is compatible between different versions of make;
22963955d011SMarcel Moolenaarhowever the special variables, variable modifiers and conditionals are not.
2297db29cad8SSimon J. Gerraty.Ss Older versions
2298db29cad8SSimon J. GerratyAn incomplete list of changes in older versions of
2299db29cad8SSimon J. Gerraty.Nm :
23003955d011SMarcel Moolenaar.Pp
23013955d011SMarcel MoolenaarThe way that .for loop variables are substituted changed after
23023955d011SMarcel MoolenaarNetBSD 5.0
23033955d011SMarcel Moolenaarso that they still appear to be variable expansions.
23043955d011SMarcel MoolenaarIn particular this stops them being treated as syntax, and removes some
23053955d011SMarcel Moolenaarobscure problems using them in .if statements.
2306db29cad8SSimon J. Gerraty.Pp
2307db29cad8SSimon J. GerratyThe way that parallel makes are scheduled changed in
2308db29cad8SSimon J. GerratyNetBSD 4.0
2309db29cad8SSimon J. Gerratyso that .ORDER and .WAIT apply recursively to the dependent nodes.
2310db29cad8SSimon J. GerratyThe algorithms used may change again in the future.
2311db29cad8SSimon J. Gerraty.Ss Other make dialects
2312db29cad8SSimon J. GerratyOther make dialects (GNU make, SVR4 make, POSIX make, etc.) do not
2313db29cad8SSimon J. Gerratysupport most of the features of
2314db29cad8SSimon J. Gerraty.Nm
2315db29cad8SSimon J. Gerratyas described in this manual.
2316db29cad8SSimon J. GerratyMost notably:
2317db29cad8SSimon J. Gerraty.Bl -bullet -offset indent
2318db29cad8SSimon J. Gerraty.It
2319db29cad8SSimon J. GerratyThe
2320db29cad8SSimon J. Gerraty.Ic .WAIT
2321db29cad8SSimon J. Gerratyand
2322db29cad8SSimon J. Gerraty.Ic .ORDER
2323db29cad8SSimon J. Gerratydeclarations and most functionality pertaining to parallelization.
2324db29cad8SSimon J. Gerraty(GNU make supports parallelization but lacks these features needed to
2325db29cad8SSimon J. Gerratycontrol it effectively.)
2326db29cad8SSimon J. Gerraty.It
2327db29cad8SSimon J. GerratyDirectives, including for loops and conditionals and most of the
2328db29cad8SSimon J. Gerratyforms of include files.
2329db29cad8SSimon J. Gerraty(GNU make has its own incompatible and less powerful syntax for
2330db29cad8SSimon J. Gerratyconditionals.)
2331db29cad8SSimon J. Gerraty.It
2332db29cad8SSimon J. GerratyAll built-in variables that begin with a dot.
2333db29cad8SSimon J. Gerraty.It
2334db29cad8SSimon J. GerratyMost of the special sources and targets that begin with a dot,
2335db29cad8SSimon J. Gerratywith the notable exception of
2336db29cad8SSimon J. Gerraty.Ic .PHONY ,
2337db29cad8SSimon J. Gerraty.Ic .PRECIOUS ,
2338db29cad8SSimon J. Gerratyand
2339db29cad8SSimon J. Gerraty.Ic .SUFFIXES .
2340db29cad8SSimon J. Gerraty.It
2341db29cad8SSimon J. GerratyVariable modifiers, except for the
2342db29cad8SSimon J. Gerraty.Dl :old=new
2343db29cad8SSimon J. Gerratystring substitution, which does not portably support globbing with
2344db29cad8SSimon J. Gerraty.Ql %
2345db29cad8SSimon J. Gerratyand historically only works on declared suffixes.
2346db29cad8SSimon J. Gerraty.It
2347db29cad8SSimon J. GerratyThe
2348db29cad8SSimon J. Gerraty.Ic $>
2349db29cad8SSimon J. Gerratyvariable even in its short form; most makes support this functionality
2350db29cad8SSimon J. Gerratybut its name varies.
2351db29cad8SSimon J. Gerraty.El
2352db29cad8SSimon J. Gerraty.Pp
2353db29cad8SSimon J. GerratySome features are somewhat more portable, such as assignment with
2354db29cad8SSimon J. Gerraty.Ic += ,
2355db29cad8SSimon J. Gerraty.Ic ?= ,
2356db29cad8SSimon J. Gerratyand
2357db29cad8SSimon J. Gerraty.Ic != .
2358db29cad8SSimon J. GerratyThe
2359db29cad8SSimon J. Gerraty.Ic .PATH
2360db29cad8SSimon J. Gerratyfunctionality is based on an older feature
2361db29cad8SSimon J. Gerraty.Ic VPATH
2362db29cad8SSimon J. Gerratyfound in GNU make and many versions of SVR4 make; however,
2363db29cad8SSimon J. Gerratyhistorically its behavior is too ill-defined (and too buggy) to rely
2364db29cad8SSimon J. Gerratyupon.
2365db29cad8SSimon J. Gerraty.Pp
2366db29cad8SSimon J. GerratyThe
2367db29cad8SSimon J. Gerraty.Ic $@
2368db29cad8SSimon J. Gerratyand
2369db29cad8SSimon J. Gerraty.Ic $<
2370db29cad8SSimon J. Gerratyvariables are more or less universally portable, as is the
2371db29cad8SSimon J. Gerraty.Ic $(MAKE)
2372db29cad8SSimon J. Gerratyvariable.
2373db29cad8SSimon J. GerratyBasic use of suffix rules (for files only in the current directory,
2374db29cad8SSimon J. Gerratynot trying to chain transformations together, etc.) is also reasonably
2375db29cad8SSimon J. Gerratyportable.
23763955d011SMarcel Moolenaar.Sh SEE ALSO
23773955d011SMarcel Moolenaar.Xr mkdep 1
23783955d011SMarcel Moolenaar.Sh HISTORY
23793955d011SMarcel Moolenaar.Nm
23803955d011SMarcel Moolenaaris derived from NetBSD
23813955d011SMarcel Moolenaar.Xr make 1 .
23823955d011SMarcel MoolenaarIt uses autoconf to facilitate portability to other platforms.
238393036677SSimon J. Gerraty.Pp
238493036677SSimon J. GerratyA
238593036677SSimon J. Gerratymake
238693036677SSimon J. Gerratycommand appeared in
238793036677SSimon J. Gerraty.At v7 .
238893036677SSimon J. GerratyThis
238993036677SSimon J. Gerratymake
239093036677SSimon J. Gerratyimplementation is based on Adam De Boor's pmake program which was written
239193036677SSimon J. Gerratyfor Sprite at Berkeley.
239293036677SSimon J. GerratyIt was designed to be a parallel distributed make running jobs on different
239393036677SSimon J. Gerratymachines using a daemon called
239493036677SSimon J. Gerraty.Dq customs .
239551ee2c1cSSimon J. Gerraty.Pp
239651ee2c1cSSimon J. GerratyHistorically the target/dependency
239751ee2c1cSSimon J. Gerraty.Dq FRC
239851ee2c1cSSimon J. Gerratyhas been used to FoRCe rebuilding (since the target/dependency
239951ee2c1cSSimon J. Gerratydoes not exist... unless someone creates an
240051ee2c1cSSimon J. Gerraty.Dq FRC
240151ee2c1cSSimon J. Gerratyfile).
240293036677SSimon J. Gerraty.Sh BUGS
240393036677SSimon J. GerratyThe
240493036677SSimon J. Gerratymake
240593036677SSimon J. Gerratysyntax is difficult to parse without actually acting of the data.
240693036677SSimon J. GerratyFor instance finding the end of a variable use should involve scanning each
240793036677SSimon J. Gerratythe modifiers using the correct terminator for each field.
240893036677SSimon J. GerratyIn many places
240993036677SSimon J. Gerratymake
241093036677SSimon J. Gerratyjust counts {} and () in order to find the end of a variable expansion.
241193036677SSimon J. Gerraty.Pp
241293036677SSimon J. GerratyThere is no way of escaping a space character in a filename.
2413