text: .\"  .\" $FreeBSD: src/usr.bin/make/make.1,v 1.30 2000/05/14 23:03:45 will Exp $ .\" .Dd March 19, 1994 .Dt MAKE 1 .Os .Sh NAME .Nm bsdmake .Nd maintain program dependencies .Sh SYNOPSIS .Nm bsdmake .Op Fl BPSeiknqrstv  bsdmake is the BSD make program. On Darwin, 'make' is a symlink to 'gnumake', the GNU make program. .Nm Make is a program designed to simplify the maintenance of other programs. Its input is a list of specifications describing dependency relationships between the generation of files and programs. The first of .Ql Pa makefile and .Ql Pa Makefile that can be found in either the current directory or a special object directory (see .Ql Va .OBJDIR ) will be read for this list of specifications. If the file .Ql. Currently a no-op.  .Ql Pa makefile and .Ql Pa Makefile . If .Ar makefile is .Ql \- , \- .Ql Ic @ before each command line in the makefile. .It Fl t Rather than re-building a target as specified in the makefile, create it or update its modification time to make it appear up-to-date. .It Fl V Ar variable Print .Nm make Ar variable Ns No = Ns Ar value Set the value of the variable .Ar variable to .Ar value .  expressions .Ql ? , .Ql * , .Ql [] and .Ql {} . The expressions .Ql ? , .Ql * and .Ql [] may only be used as part of the final component of the target or source, and must be used to describe existing files. The expression  or first two characters of the command line are .Ql Ic @ and/or .Ql Ic \- , the command is treated specially. A .Ql Ic @ causes the command not to be echoed before it is executed. A .Ql Ic \- causes any non-zero exit status of the command line to be ignored. .Sh VARIABLE ASSIGNMENTS Variables in .Nm are much like variables in the shell, and, by tradition, consist of all upper-case letters.. .It Ic \&!= Expand the value and pass it to the shell for execution and assign the result to the variable. Any newlines in the result are replaced with spaces. .El .Pp Any whitespace make \&> . .It Va .ARCHIVE The name of the archive file; also known as .Ql Va \&! . .It Va .IMPSRC The name/path of the source from which the target is to be transformed (the .Dq implied source); also known as .Ql Va \&< . .It Va .MEMBER The name of the archive member; also known as .Ql Va \&% . .It Va .OODATE The list of sources for this target that were deemed out-of-date; also known as .Ql Va \&? . .It Va .PREFIX The file prefix of the file, containing only the file portion, no suffix or preceding directory components; also known as .Ql Va * . .It Va .TARGET The name of the target; also known as .Ql Va @ . .El .Pp The shorter forms .Ql Va @ , .Ql Va ! , .Ql Va \&< , .Ql Va \&% , .Ql Va ? , .Ql Va \&> , and .Ql Va * are permitted for backward compatibility and are not recommended. The six variables .Ql Va "@F" , .Ql Va "@D" , .Ql Va "<F" , .Ql Va " .Pp In addition, .Nm sets or knows about the following internal variables or environment variables: .Bl -tag -width MAKEFLAGS .It Va \&$ A single dollar sign .Ql \&$ , i.e. .Ql \&$$ expands to a single dollar sign. .It Va MAKE The name that .Nm was executed with .Pq Va argv Ns Op 0 . .It Va .CURDIR A path to the directory where .Nm was executed. }/`cwd` .It ${MAKEOBJDIR} .It obj.${MACHINE} .It obj .It /usr/obj/`cwd` .El .Pp The first directory that .Nm successfully changes into is used. If either .Ev MAKEOBJDIRPREFIX or .Ev MAKEOBJDIR is defined but .Nm is unable to change into the corresponding directory, then the current directory is used without checking the remainder of the list. If they are undefined and .Nm is unable to change into any of the remaining three directories, then the current directory is used. .It Va .MAKEFLAGS The environment variable .Ev MAKEFLAGS may contain anything that may be specified on .Nm make Ns 's command line. Its contents are stored in .Nm make Ns 's .Va .MAKEFLAGS variable. Anything specified on .Nm make Ns 's command line is appended to the .Va .MAKEFLAGS variable which is then entered into the environment as .Ev MAKEFLAGS for all programs which .Nm executes. .It Va MFLAGS A synonym for .Va .MAKEFLAGS provided for backward compatibility. .It Ev PWD Alternate path to the current directory. Supported if built with WANT_ENV_PWD defined. .Nm normally sets .Ql Va .CURDIR to the canonical path given by .Xr getcwd 3 . However, if the environment variable .Ev PWD is set and gives a path to the current directory, then .Nm sets .Ql Va .CURDIR to the value of .Ev PWD instead. .Ev PWD is always set to the value of .Ql Va .OBJDIR for all programs which .Nm executes.  2 .Nm E\& .It Cm E Replaces each word in the variable with its suffix. .It Cm H Replaces each word in the variable with everything but the last component. .It Cm M Ns Ar pattern Select only those words that match the rest of the modifier. The standard shell wildcard characters .Pf ( Ql * , .Ql ? , and .Ql Op ) may be used. The wildcard characters may be escaped with a backslash .Pq Ql \e . .It Cm N Ns Ar pattern This is identical to .Cm M , but selects all words which do not match the rest of the modifier. .It Cm Q Quotes every shell meta-character in the variable, so that it can be passed safely through recursive invocations of .Nm make . . & is replaced by .Ar old_string .. .It Cm T Replaces each word in the variable with its last component.  .El .Sh DIRECTIVES, CONDITIONALS, AND FOR LOOPS Directives, conditionals, and for loops reminiscent of the C programming language are provided in .Nm make . All such structures are identified by a line beginning with a single dot .Pq Ql \&. character. The following directives are supported: .Bl -tag -width Ds .It Ic \&.include Ar <file> .It Ic \&.include Ar \*qfile\*q.  standard output and .Nm make terminates with exit code 1. Ar target .Op Ar operator target ... .Xc Test the target being built. .It Ic .else Reverse the sense of the last conditional. .It Xo .Ic .elif .Oo \&! Oc Ar expression .Op Ar operator expression ... .Xc A combination of .Ql Ic .else followed by .Ql Ic .if . .It Xo .Ic .elifdef .Oo \&! Oc Ns Ar variable .Op Ar operator variable ... .Xc A combination of .Ql Ic .else followed by .Ql Ic .ifdef . .It Xo .Ic .elifndef .Oo \&! Oc Ns Ar variable .Op Ar operator variable ... .Xc A combination of .Ql Ic .else followed by .Ql Ic .ifndef . .It Xo .Ic .elifmake .Oo \&! Oc Ns Ar target .Op Ar operator target ... .Xc A combination of .Ql Ic .else followed by .Ql Ic .ifmake . .It Xo .Ic .elifnmake .Oo \&! Oc Ns Ar target .Op Ar operator target ... .Xc A combination of .Ql Ic .else followed by .Ql Ic .ifnmake . .It Ic .endif End the body of the conditional. .El .Pp The .Ar operator may be any one of the following: .Bl -tag -width "Cm XX" .It Cm \&|\&| logical OR .It Cm \&&& Logical .Tn AND ; of higher precedence than .Ql Ic || .  \&&& . .Pp The value of .Ar expression may be any of the following: .Bl -tag -width Ic defined .It Ic defined Takes a variable name as an argument and evaluates to true if the variable has been defined. .It Ic make Takes a target name as an argument and evaluates to true if the target was specified as part of .Nm make. .El .Pp An . .Pp When .Nm is evaluating one of these conditional expressions, and it encounters a word it doesn't recognize, either the .Dq make or .Dq defined expression is applied to it, depending on the form of the conditional. If the form is .Ql Ic .ifdef or .Ql Ic .ifndef ,: .Bl -tag -width Ds .It Xo .Ic \&.for .Ar variable .Ic in .Ar expression .Xc .It Xo <make-rules> .Xc .It Xo .Ic \&.endfor .Xc .El .IGNORE  make Ns 's .   make  .BEGIN  .  .NOTPARALLEL Disable parallel mode. .It Ic .NO_PARALLEL Same as above, for compatibility with other pmake variants. .It Ic .ORDER The named targets are made in sequence. .\". Where possible, use of .Ic .PATH is preferred over use of the .Va VPATH variable. .It Ic .PATH\fIsuffix\fR The sources are directories which are to be searched for suffixed files not found in the current directory. .Nm Make make . If no sources are specified, any previous specified suffices are deleted.  .Nm Make uses the following environment variables, if they exist: .Ev MACHINE , .Ev MAKE , .Ev MAKEFLAGS , .Ev MAKEOBJDIR , .Ev MAKEOBJDIRPREFIX , and .Ev PWD . .Sh FILES .Bl -tag -width /usr/share/doc/psd/12.make -compact .It Pa .depend list of dependencies .It Pa Makefile list of dependencies .It Pa makefile list of dependencies .It obj object directory .It Pa sys.mk system makefile .It Pa /usr/share/mk system makefile directory .It /usr/share/doc/psd/12.make PMake tutorial .It Pa /usr/obj default .Ev MAKEOBJDIRPREFIX directory. .El  doesn't work. .Pp For loops are expanded before tests, so a fragment such as: .Bd -literal \&.for TMACHINE in ${SHARED_ARCHS} \&.if ${TMACHINE} = ${MACHINE} ... \&.endif \&.endfor .Ed won't work, and should be rewritten the other way around. .Sh SEE ALSO .Xr mkdep 1 .Rs .%T "PMake - A Tutorial" .Re .Sh HISTORY A .Nm command appeared in .At v7 .