⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 make.1

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 1
📖 第 1 页 / 共 2 页
字号:
.B \-f,.B \-p, and.B \-d\) definedfor the command line.Further, upon invocation,.PN makeinvents the variable if it is not in theenvironment, puts the current options into it, and passes it on toinvocations of commands.Thus, MAKEFLAGS always contains thecurrent input options.This proves very useful for super-makes.In fact, as noted above,when the.B \-noption is used, the command $(MAKE)is executed anyway.  Hence, one can perform a .PN make .B \-nrecursively on a whole softwaresystem to see what would have been executed.This is because the \fB\-n\fRis put in MAKEFLAGS and passed to further invocations of $(MAKE).This is one way of debuggingall of the makefiles for a software projectwithout actually doing anything..PP.SS MacrosMacros can be defined in four different ways.  Some macros are definedby default by.PN makeinternally.  All environment variables are assumed to be macrodefinitions and macros can be defined in the makefile as well as on the .PN makecommand line.  By default, the internal default macros are overridden byenvironment variables, macros defined in the makefile overrideenvironment variables and macros defined on the command line overridemacros defined in the makefile.  The.B \-eoption changes this suchthat environment variables override macros defined in the makefile..PPEntries of the form.I string1  =  string2are macro definitions..I String2is defined as all characters up to a comment character oran unescaped new-line.Subsequent appearances of.I $( string1 [: subst1 =[ subst2]])are replaced by.I string2 .The parentheses are optional if asingle character macro name is used andthere is no substitute sequence.The optional.I : subst1 = subst2is a substitute sequence.If it is specified, all non-overlappingoccurrences of \fIsubst1\fR in thenamed macro are replaced by \fIsubst2\fR.The occurrence of \fIsubst1\fP must be a suffix at the end of the word\fIstring1\fP.  Strings (for the purposes of thistype of substitution) are delimited byblanks, tabs, new-line characters, and beginnings of lines.An example of the use of the substitute sequence is shown under.B Libraries..PPThe MACHINE macro is defined by .PN maketo allow for machine independent makefiles. The legal values are: .I vaxor .I mips..SS Internal MacrosThere are five internally maintained macros which are usefulfor writing rules for building targets..TP 15.B $*The macro \fB$*\fR stands forthe file name part of the current dependent with the suffix deleted.It isevaluated only for inference rules..TP.B $@The \fB$@\fR macro stands forthe full target name of the current target.It is evaluatedonly for explicitly named dependencies..TP.B $<The \fB$<\fR macro is only evaluated for inference rules orthe .DEFAULT rule.It isthe module which is out-of-date with respect to the target (that is,the manufactured dependent file name).Thus, in the \fB.c.o\fR rule, the \fB$<\fR macro would evaluate tothe \fB.c\fR file.An example for makingoptimized \fB.o\fR files from \fB.c\fR files is:.EX\&.c.o:cc \-c \-O $\(**.c.EEor:.EX\&.c.o:cc \-c \-O $<.EE.TP 15\fB$?\fRThe \fB$?\fR macro is evaluated when explicit rules from the makefileare evaluated.It isthe list of prerequisites that are out of date with respect tothe target;essentially, those modules which must be rebuilt..TP\fB$%\fRThe \fB$%\fR macro is only evaluated when the target is anarchive library member of the form \fBlib(file.o)\fR.In this case,\fB$@\fR evaluates to \fBlib\fR and \fB$%\fR evaluates to thelibrary member, \fBfile.o\fR..PPFour of the five macros can have alternative forms.When an upper case \fBD\fR or \fBF\fR is appended to any of the fourmacros, the meaning is changed to directory part for \fBD\fRand file part for \fBF\fR.Thus, \fB$(@D)\fR refers to the directorypart of the string \fB$@\fR.If there is no directory part,\&\fB./\fR is generated.The only macro excluded from thisalternative form is \fB$?\fR.The reasons for this are debatable..SS SuffixesCertain names (for instance, those ending with \fB.o\fR)have prerequisites such as \fB.c\fR, \fB.s\fR, which can beinferred.If no update commands for such a file appear in.IR makefile ,and if an inferable prerequisiteexists, that prerequisite is compiled to make the target.In this case,.PN makehasinference ruleswhich allow building files from other filesby examining the suffixes and determining anappropriateinference ruleto use.The current default inference rulesare:.EX 0\&.c \|.c~ \|.sh \|.sh~ \|.c.o \|.c~.o \|.c~.c \|.s.o \|.s~.o \|.y.o \|.y~.o \|.l.o \|.l~.o \|.y.c \|.y~.c \|.l.c \|.c.a \|.c~.a \|.s~.a \|.h~.h.EE.PPThe internal rules for .PN makeare contained in the sourcefile \fBrules.c\fR for the .PN makeprogram.  These rules can be locally modified.To print out the rules compiled into .PN makein a form suitable for recompilation,the following command is used from .PN /bin/sh:.EXmake \-fp \- 2>/dev/null </dev/null.EE.PPThe only peculiarity in this output is the(null)string which .MS printf 3sprints when handed a null string..PPA tilde in the above rules refers to an SCCS file.Thus, therule \fB.c~.o\fR would transform an SCCS C source file into anobject file (\fB.o\fR).Because the \fBs.\fR of the SCCS files is a prefix,it is incompatible with the  .PN make suffix point-of-view.Hence,the tilde is a way of changing any file reference into an SCCSfile reference..PPA rule with only one suffix (that is, \fB.c:\fR) is the definitionof how to build \fIx\fR from \fIx\fR\fB.c\fR.In effect, the other suffix is null.This is useful for building targetsfrom only one source file (forexample, shell procedures, simple C programs)..PPAdditional suffixes are given as thedependency list for .SUFFIXES.Order is significant; the first possible name for which botha file and a rule exist is inferred as a prerequisite.The default list is:.EX\&.SUFFIXES: .o .c .y .l .s.EEHere again, the above command for printing the internal rules display the list of suffixes implemented on the current machine.Multiple suffix lists accumulate;\&.SUFFIXES: with no dependenciesclears the list of suffixes..SS Inference RulesThe first example can be done more briefly..EXpgm: a.o b.o   cc a.o b.o \-o pgma.o b.o: incl.h.EEThis is because .PN makehas a set of internal rules for buildingfiles.The user may add rules to this list by simply puttingthem in the .I makefile..PPCertain macros are used by the default inference rulesto permit the inclusion of optional matter inany resulting commands.For example, CFLAGS, LFLAGS, and YFLAGSare used for compiler options to .MS cc 1 ,.MS lex 1 ,and.MS yacc 1 ,respectively.Again, the previous method for examiningthe current rules is recommended..PPThe inference of prerequisites can be controlled.The rule to create a file with suffix.B \&.ofrom a file with suffix.B \&.cis specified as an entry with \fB.c.o:\fR as the target and no dependents.Shell commands associated with the target define therule for making a \fB.o\fR file from a \fB.c\fR file.Any target that has no slashes in it and starts with a dotis identified as a rule and not a true target..SS LibrariesIf a target or dependency name contains parentheses, it isassumed to be an archive library, the string within parenthesesreferring to a member within the library.Thus \fBlib(file.o)\fR and \fB$(\s-1LIB\s+1)(file.o)\fR both refer toan archive library which contains \fBfile.o\fR. (This assumesthe LIBmacro has been previously defined.)\ The expression \fB$(\s-1LIB\s+1)(file1.o file2.o)\fR is not legal.Rules pertaining to archive libraries have the form.BI \&. \s-1XX\s+1 \&.awhere the.I XXis the suffix from which the archive memberis to be made.An unfortunate byproduct of the current implementationrequires the.I XXto be different from the suffix of the archivemember.Thus, onecannot have \fBlib(file.o)\fR depend upon \fBfile.o\fR explicitly.The most common use of the archive interface follows.Here, we assume the source files are all C type source:.EXlib: lib(file1.o) lib(file2.o) lib(file3.o)   @echo lib is now up-to-date\&.c.a:   $(CC) \-c $(CFLAGS1) $<   ar rv $@ $*.o   rm \-f $*.o.EEIn fact, the \fB.c.a\fR rule listed above is built into .PN makeandis unnecessary in this example.A more interesting, but more limited example of an archive librarymaintenance construction follows:.EXlib: lib(file1.o) lib(file2.o) lib(file3.o)   $(CC) \-c $(CFLAGS) $(?:.o=.c)   ar rv lib $?   rm $?      @echo lib is now up-to-date\&.c.a:;.EEHere the substitution mode of the macro expansions is used.The \fB$?\fRlist is defined to be the set of object file names (inside \fBlib\fR) whose Csource files are out-of-date.  The substitution modetranslates the \fB.o\fR to \fB.c\fR.(Unfortunately, one cannot as yet transformto \fB.c~\fR; however, this may become possible in the future.)\ Note also, the disabling of the\&\fB.c.a:\fR rule, which would havecreated each object file, one by one.This particular construct speeds up archive library maintenance considerably.This type of construct becomes very cumbersome if the archive librarycontains a mix of assembly programs and C programs..SH RestrictionsSome commands return non-zero status inappropriately;use.B \-ito overcome the difficulty.File names with the characters.B "= : @"do not work.Commands that are directly executed by the shell, notably cd(1),are ineffectual across new-lines in.PN make .The syntax \fB(lib(file1.o file2.o file3.o)\fR is illegal.You cannot build \fBlib(file.o)\fR from \fBfile.o\fR.The macro \fB$(a:.o=.c~)\fR does not work..SH Files[Mm]akefile and s\fB.\fR[Mm]akefile.SH See Alsocc(1), cd(1), lex(1), sh(1), yacc(1), s5make(1)

⌨️ 快捷键说明

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