make.1

来自「早期freebsd实现」· 1 代码 · 共 884 行 · 第 1/2 页

1
884 行
字号
Modify the first occurrence of.Ar old_patternin each word to be replaced with.Ar new_pattern .If a.Ql gis appended to the last slash of the pattern, all occurrencesin each word are replaced.If.Ar old_patternbegins with a carat.Pq Ql ^ ,.Ar old_patternis anchored at the beginning of each word.If.Ar old_patternends with a dollar sign.Pq Ql \&$ ,it is anchored at the end of each word.Inside.Ar new_string ,an ampersand.Pq Ql &is replaced by.Ar old_pattern .Any character may be used as a delimiter for the parts of the modifierstring.The anchoring, ampersand and delimiter characters may be escaped with abackslash.Pq Ql \e ..PpVariable expansion occurs in the normal fashion inside both.Ar old_stringand.Ar new_stringwith the single exception that a backslash is used to prevent the expansionof a dollar sign.Pq Ql \&$not a preceding dollar sign as is usual..It Cm TReplaces each word in the variable with its last component..It Ar old_string=new_stringThis is the.At Vstyle variable substitution.It must be the last modifier specified.If .Ar old_stringor.Ar new_stringdo not contain the pattern matching character.Ar %then it is assumed that they are anchored at the end of each word, so only suffixes or entirewords may be replaced. Otherwise .Ar %is the substring of .Ar old_string to be replaced in.Ar new_string.El.Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPSMakefile inclusion, conditional structures 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 singledot.Pq Ql \&.character.Files are included with either.Ql .include <file>or.Ql .include \*qfile\*q .Variables between the angle brackets or double quotes are expandedto form the file name.If angle brackets are used, the included makefile is expected to be inthe system makefile directory.If double quotes are used, the including makefile's directory and anydirectories specified using the.Fl Ioption are searched before the systemmakefile directory..PpConditional expressions are also preceded by a single dot as the firstcharacter of a line.The possible conditionals are as follows:.Bl -tag -width Ds.It Ic .undef Ar variableUn-define the specified global variable.Only global variables may be un-defined..It Xo.Ic \&.if.Oo \&! Oc Ns Ar expression.Op Ar operator expression ....XcTest the value of an expression..It Xo.Ic .ifdef.Oo \&! Oc Ns Ar variable.Op Ar operator variable ....XcTest the value of a variable..It Xo.Ic .ifndef.Oo \&! Oc Ns Ar variable.Op Ar operator variable ....XcTest the value of a variable..It Xo.Ic .ifmake.Oo \&! Oc Ns Ar target.Op Ar operator target ....XcTest the the target being built..It Xo.Ic .ifnmake.Oo \&! Oc Ar target.Op Ar operator target ....XcTest the target being built..It Ic .elseReverse the sense of the last conditional..It Xo.Ic .elif.Oo \&! Oc Ar expression.Op Ar operator expression ....XcA combination of.Ql Ic .elsefollowed by.Ql Ic .if ..It Xo.Ic .elifdef.Oo \&! Oc Ns Ar variable.Op Ar operator variable ....XcA combination of.Ql Ic .elsefollowed by.Ql Ic .ifdef ..It Xo.Ic .elifndef.Oo \&! Oc Ns Ar variable.Op Ar operator variable ....XcA combination of.Ql Ic .elsefollowed by.Ql Ic .ifndef ..It Xo.Ic .elifmake.Oo \&! Oc Ns Ar target.Op Ar operator target ....XcA combination of.Ql Ic .elsefollowed by.Ql Ic .ifmake ..It Xo.Ic .elifnmake.Oo \&! Oc Ns Ar target.Op Ar operator target ....XcA combination of.Ql Ic .elsefollowed by.Ql Ic .ifnmake ..It Ic .endifEnd the body of the conditional..El.PpThe.Ar operatormay be any one of the following:.Bl -tag -width "Cm XX".It Cm \&|\&|logical OR.It Cm \&&&Logical.Tn AND ;of higher precedence than.Dq ..El.PpAs in C,.Nm makewill only evaluate a conditional as far as is necessary to determineits value.Parentheses may be used to change the order of evaluation.The boolean operator.Ql Ic \&!may be used to logically negate an entireconditional.It is of higher precedence than.Ql Ic \&&& ..PpThe value of.Ar expressionmay be any of the following:.Bl -tag -width Ic defined.It Ic definedTakes a variable name as an argument and evaluates to true if the variablehas been defined..It Ic makeTakes a target name as an argument and evaluates to true if the targetwas specified as part of.Nm make Ns 'scommand line or was declared the default target (either implicitly orexplicitly, see.Va .MAIN )before the line containing the conditional..It Ic emptyTakes a variable, with possible modifiers, and evaluates to true ifthe expansion of the variable would result in an empty string..It Ic existsTakes a file name as an argument and evaluates to true if the file exists.The file is searched for on the system search path (see.Va .PATH ) ..It Ic targetTakes a target name as an argument and evaluates to true if the targethas been defined..El.Pp.Ar Expressionmay also be an arithmetic or string comparison.  Variable expansion isperformed on both sides of the comparison, after which the integralvalues are compared.  A value is interpreted as hexadecimal if it ispreceded by 0x, otherwise it is decimal; octal numbers are not supported.The standard C relational operators are all supported.  If aftervariable expansion, either the left or right hand side of a.Ql Ic ==or.Ql Ic "!="operator is not an integral value, thenstring comparison is performed between the expandedvariables.If no relational operator is given, it is assumed that the expandedvariable is being compared against 0..PpWhen.Nm makeis evaluating one of these conditional expression, and it encountersa word it doesn't recognize, either the ``make'' or ``defined''expression is applied to it, depending on the form of the conditional.If the form is.Ql Ic .ifdefor.Ql Ic .ifndef ,the ``defined'' expressionis applied.Similarly, if the form is.Ql Ic .ifmakeor.Ql Ic .ifnmake , the ``make''expression is applied..PpIf the conditional evaluates to true the parsing of the makefile continuesas before.If it evaluates to false, the following lines are skipped.In both cases this continues until a.Ql Ic .elseor.Ql Ic .endifis found..Pp For loops are typically used to apply a set of rules to a list of files.The syntax of a for loop is:.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.ElAfter the for.Ic expression is evaluated, it is split into words. The iteration.Ic variableis successively set to each word, and substituted in the .Ic make-rules inside the body of the for loop..Sh COMMENTSComments begin with a hash.Pq Ql \&#character, anywhere but in a shellcommand line, and continue to the end of the line..Sh SPECIAL SOURCES.Bl -tag -width Ic .IGNORE.It Ic .IGNOREIgnore any errors from the commands associated with this target, exactlyas if they all were preceded by a dash.Pq Ql \- ..It Ic .MAKEExecute the commands associated with this target even if the.Fl nor.Fl toptions were specified.Normally used to mark recursive.Nm make Ns 's ..It Ic .NOTMAINNormally.Nm makeselects the first target it encounters as the default target to be builtif no target was specified.This source prevents this target from being selected..It Ic .OPTIONALIf a target is marked with this attribute and.Nm makecan't figure out how to create it, it will ignore this fact and assumethe file isn't needed or already exists..It Ic .PRECIOUSWhen.Nm makeis interrupted, it removes any partially made targets.This source prevents the target from being removed..It Ic .SILENTDo not echo any of the commands associated with this target, exactlyas if they all were preceded by an at sign.Pq Ql @ ..It Ic .USETurn the target into.Nm make Ns 's .version of a macro.When the target is used as a source for another target, the other targetacquires the commands, sources, and attributes (except for.Ic .USE )of thesource.If the target already has commands, the.Ic .USEtarget's commands are appendedto them..El.Sh "SPECIAL TARGETS"Special targets may not be included with other targets, i.e. they must bethe only target specified..Bl -tag -width Ic .BEGIN.It Ic .BEGINAny command lines attached to this target are executed before anythingelse is done..It Ic .DEFAULTThis is sort of a.Ic .USErule for any target (that was used only as asource) that.Nm makecan't figure out any other way to create.Only the shell script is used.The.Ic .IMPSRCvariable of a target that inherits.Ic .DEFAULT Ns 'scommands is setto the target's own name..It Ic .ENDAny command lines attached to this target are executed after everythingelse is done..It Ic .IGNOREMark each of the sources with the.Ic .IGNOREattribute.If no sources are specified, this is the equivalent of specifying the.Fl ioption..It Ic .INTERRUPTIf.Nm makeis interrupted, the commands for this target will be executed..It Ic .MAINIf no target is specified when.Nm makeis invoked, this target will be built..It Ic .MAKEFLAGSThis target provides a way to specify flags for.Nm makewhen the makefile is used.The flags are as if typed to the shell, though the.Fl foption will haveno effect..It Ic .PATHThe sources are directories which are to be searched for files notfound in the current directory.If no sources are specified, any previously specified directories aredeleted..It Ic .PRECIOUSApply the.Ic .PRECIOUSattribute to any specified sources.If no sources are specified, the.Ic .PRECIOUSattribute is applied to everytarget in the file..It Ic .SILENTApply the.Ic .SILENTattribute to any specified sources.If no sources are specified, the.Ic .SILENTattribute is applied to everycommand in the file..It Ic .SUFFIXESEach source specifies a suffix to.Nm make .If no sources are specified, any previous specified suffices are deleted..Sh ENVIRONMENT.Nm Makeutilizes the following environment variables, if they exist:.Ev MAKE ,.Ev MAKEFLAGSand.Ev MAKEOBJDIR ..Sh FILES.Bl -tag -width /usr/share/mk -compact.It .dependlist of dependencies.It Makefilelist of dependencies.It makefilelist of dependencies.It sys.mksystem makefile.It /usr/share/mksystem makefile directory.El.Sh SEE ALSO.Xr mkdep 1.Sh HISTORYA.Nm Makecommand appeared in.At v7 .

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?