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

📄 tutorial.ms

📁 早期freebsd实现
💻 MS
📖 第 1 页 / 共 5 页
字号:
Variable assignment..RE.IP "\&"Of these all, the.CW mand.CW sletters will be most useful to you.If the.B \-dis the final argument or the argument from which it would get thesekey letters (see below for a note about which argument would be used)begins with a.B \- ,all of these debugging flags will be set, resulting in massive amountsof output..IP "\fB\-f\fP \fImakefile\fP".Ix 0 def flags -fSpecify a makefile to read different from the standard makefiles.CW Makefile "\&" (or.CW makefile )..Ix 0 ref makefile default.Ix 0 ref makefile otherIf.I makefileis ``\-'', PMake uses the standard input. This is useful for makingquick and dirty makefiles.\|.\|..Ix 0 ref makefile "quick and dirty".IP \fB\-h\fP.Ix 0 def flags -hPrints out a summary of the various flags PMake accepts. It can alsobe used to find out what level of concurrency was compiled into theversion of PMake you are using (look at.B \-Jand.B \-L )and various other information on how PMake was configured..Ix 0 ref configuration.Ix 0 ref makefile system.IP \fB\-i\fP.Ix 0 def flags -iIf you give this flag, PMake will ignore non-zero status returnedby any of its shells. It's like placing a `\-' before all the commandsin the makefile..IP \fB\-k\fP.Ix 0 def flags -kThis is similar to.B \-iin that it allows PMake to continue when it sees an error, but unlike.B \-i ,where PMake continues blithely as if nothing went wrong,.B \-kcauses it to recognize the error and only continue work on thosethings that don't depend on the target, either directly or indirectly (throughdepending on something that depends on it), whose creation returned the error.The `k' is for ``keep going''.\|.\|..Ix 0 ref target.IP \fB\-l\fP.Ix 0 def flags -lPMake has the ability to lock a directory against otherpeople executing it in the same directory (by means of a file called``LOCK.make'' that it creates and checks for in the directory). Thisis a Good Thing because two people doing the same thing in the same placecan be disastrous for the final product (too many cooks and all that).Whether this locking is the default is up to your systemadministrator. If locking is on,.B \-lwill turn it off, and vice versa. Note that this locking will notprevent \fIyou\fP from invoking PMake twice in the same place \*- ifyou own the lock file, PMake will warn you about it but continue to execute..IP \fB\-n\fP.Ix 0 def flags -nThis flag tells PMake not to execute the commands needed to update theout-of-date targets in the makefile. Rather, PMake will simply printthe commands it would have executed and exit. This is particularlyuseful for checking the correctness of a makefile. If PMake doesn't dowhat you expect it to, it's a good chance the makefile is wrong..IP "\fB\-p\fP \fInumber\fP".Ix 0 def flags -p.Ix 0 ref debuggingThis causes PMake to print its input in a reasonable form, thoughnot necessarily one that would make immediate sense to anyone but me. The.I numberis a bitwise-or of 1 and 2 where 1 means it should print the inputbefore doing any processing and 2 says it should print it aftereverything has been re-created. Thus.CW "\-p 3"would print it twice\*-once before processing and once after (youmight find the difference between the two interesting). This is mostlyuseful to me, but you may find it informative in some bizarre circumstances..IP \fB\-q\fP.Ix 0 def flags -qIf you give PMake this flag, it will not try to re-create anything. Itwill just see if anything is out-of-date and exit non-zero if so..IP \fB\-r\fP.Ix 0 def flags -rWhen PMake starts up, it reads a default makefile that tells it whatsort of system it's on and gives it some idea of what to do if youdon't tell it anything. I'll tell you about it in chapter 3. If yougive this flag, PMake won't read the default makefile..IP \fB\-s\fP.Ix 0 def flags -sThis causes PMake to not print commands before they're executed. Itis the equivalent of putting an `@' before every command in themakefile..IP \fB\-t\fP.Ix 0 def flags -tRather than try to re-create a target, PMake will simply ``touch'' itso as to make it appear up-to-date. If the target didn't exist before,it will when PMake finishes, but if the target did exist, it willappear to have been updated..IP \fB\-v\fP.Ix 0 def flags -vThis is a mixed-compatibility flag intended to mimic the System Vversion of Make. It is the same as giving.B \-B ,and.B \-Vas well as turning off directory locking. Targets can still be createdin parallel, however. This is the mode PMake will enter if it isinvoked either as.CW smake '' ``or.CW vmake ''. ``.IP \fB\-x\fP.Ix 0 def flags -xThis tells PMake it's ok to export jobs to other machines, if they'reavailable. It is used when running in Make mode, as exporting in thismode tends to make things run slower than if the commands were justexecuted locally..IP \fB\-B\fP.Ix 0 ref compatibility.Ix 0 def flags -BForces PMake to be as backwards-compatible with Make as possible whilestill being itself.This includes:.RS.IP \(bu 2Executing one shell per shell command.IP \(bu 2Expanding anything that looks even vaguely like a variable, with theempty string replacing any variable PMake doesn't know..IP \(bu 2Refusing to allow you to escape a `#' with a backslash..IP \(bu 2Permitting undefined variables on dependency lines and conditionals(see below). Normally this causes PMake to abort..RE.IP \fB\-C\fP.Ix 0 def flags -CThis nullifies any and all compatibility mode flags you may have givenor implied up to the time the.B \-Cis encountered. It is useful mostly in a makefile that you wrote for PMaketo avoid bad things happening when someone runs PMake as.CW make '' ``or has things set in the environment that tell it to be compatible..B \-Cis.I notplaced in the.CW PMAKEenvironment variable or the.CW .MAKEFLAGSor.CW MFLAGSglobal variables..Ix 0 ref variable environment PMAKE.Ix 0 ref variable global .MAKEFLAGS.Ix 0 ref variable global MFLAGS.Ix 0 ref .MAKEFLAGS variable.Ix 0 ref MFLAGS.IP "\fB\-D\fP \fIvariable\fP".Ix 0 def flags -DAllows you to define a variable to have .CW 1 '' ``as its value.  The variable is a global variable, not a command-linevariable. This is useful mostly for people who are used to the Ccompiler arguments and those using conditionals, which I'll get intoin section 4.3.Rm 1 4.3.IP "\fB\-I\fP \fIdirectory\fP".Ix 0 def flags -ITells PMake another place to search for included makefiles. Yetanother thing to be explained in chapter 3 (section 3.2, to beprecise)..Rm 2 3.2.IP "\fB\-J\fP \fInumber\fP".Ix 0 def flags -JGives the absolute maximum number of targets to create at once on bothlocal and remote machines..IP "\fB\-L\fP \fInumber\fP".Ix 0 def flags -LThis specifies the maximum number of targets to create on the localmachine at once. This may be 0, though you should be wary of doingthis, as PMake may hang until a remote machine becomes available, ifone is not available when it is started..IP \fB\-M\fP.Ix 0 ref compatibility.Ix 0 def flags -MThis is the flag that provides absolute, complete, full compatibilitywith Make. It still allows you to use all but a few of the features ofPMake, but it is non-parallel. This is the mode PMake enters if youcall it.CW make .'' ``.IP \fB\-P\fP.Ix 0 def flags -P.Ix 0 ref "output control"When creating targets in parallel, several shells are executing atonce, each wanting to write its own two cent's-worth to the screen.This output must be captured by PMake in some way in order to preventthe screen from being filled with garbage even more indecipherablethan you usually see. PMake has two ways of doing this, one of whichprovides for much cleaner output and a clear separation between theoutput of different jobs, the other of which provides a more immediateresponse so one can tell what is really happpening. The former is doneby notifying you when the creation of a target starts, capturing theoutput and transferring it to the screen all at once when the jobfinishes. The latter is done by catching the output of the shell (andits children) and buffering it until an entire line is received, thenprinting that line preceded by an indication of which job producedthe output. Since I prefer this second method, it is the one used bydefault. The first method will be used if you give the.B \-Pflag to PMake..IP \fB\-V\fP.Ix 0 def flags -VAs mentioned before, the.B \-Vflag tells PMake to use Make's style of expanding variables,substituting the empty string for any variable it doesn't know..IP \fB\-W\fP.Ix 0 def flags -WThere are several times when PMake will print a message at you that isonly a warning, i.e. it can continue to work in spite of your havingdone something silly (such as forgotten a leading tab for a shellcommand). Sometimes you are well aware of silly things you have doneand would like PMake to stop bothering you. This flag tells it to shutup about anything non-fatal..IP \fB\-X\fP.Ix 0 def flags -XThis flag causes PMake to not attempt to export any jobs to anothermachine..LPSeveral flags may follow a single `\-'. Those flags that requirearguments take them from successive parameters. E.g..DSpmake -fDnI server.mk DEBUG /chip2/X/server/include.DEwill cause PMake to read.CW server.mkas the input makefile, define the variable.CW DEBUGas a global variable and look for included makefiles in the directory.CW /chip2/X/server/include ..xH 2 Summary.LPA makefile is made of four types of lines:.RS.IP \(bu 2Dependency lines.IP \(bu 2Creation commands.IP \(bu 2Variable assignments.IP \(bu 2Comments, include statements and conditional directives.RE.LPA dependency line is a list of one or more targets, an operator.CW : ', (`.CW :: ', `or.CW ! '), `and a list of zero or more sources. Sources may contain wildcards andcertain local variables..LPA creation command is a regular shell command preceded by a tab. Inaddition, if the first two characters after the tab (and otherwhitespace) are a combination of.CW @ ' `or.CW - ', `PMake will cause the command to not be printed (if the character is.CW @ ') `or errors from it to be ignored (if.CW - '). `A blank line, dependency line or variable assignment terminates acreation script. There may be only one creation script for each targetwith a.CW : ' `or.CW ! ' `operator..LPVariables are places to store text. They may be unconditionallyassigned-to using the.CW = ' `.Ix 0 ref =.Ix 0 ref variable assignmentoperator, appended-to using the.CW += ' `.Ix 0 ref +=.Ix 0 ref variable assignment appendedoperator, conditionally (if the variable is undefined) assigned-towith the.CW ?= ' `.Ix 0 ref ?=.Ix 0 ref variable assignment conditionaloperator, and assigned-to with variable expansion with the.CW := ' `.Ix 0 ref :=.Ix 0 ref variable assignment expandedoperator. The output of a shell command may be assigned to a variableusing the.CW != ' `.Ix 0 ref !=.Ix 0 ref variable assignment shell-outputoperator.  Variables may be expanded (their value inserted) by enclosingtheir name in parentheses or curly braces, prceeded by a dollar sign.A dollar sign may be escaped with another dollar sign. Variables arenot expanded if PMake doesn't know about them. There are seven localvariables:.CW .TARGET ,.CW .ALLSRC ,.CW .OODATE ,.CW .PREFIX ,.CW .IMPSRC ,.CW .ARCHIVE ,and.CW .MEMBER .Four of them.CW .TARGET , (.CW .PREFIX ,.CW .ARCHIVE ,and.CW .MEMBER )may be used to specify ``dynamic sources.''.Ix 0 ref "dynamic source".Ix 0 ref source dynamicVariables are good. Know them. Love them. Live them..LPDebugging of makefiles is best accomplished using the.B \-n ,.B "\-d m" ,and.B "\-p 2"flags..xH 2 Exercises.ce\s+4\fBTBA\fP\s0.xH 1 Short-cuts and Other Nice Things.LPBased on what I've told you so far, you may have gotten the impressionthat PMake is just a way of storing away commands and making sure youdon't forget to compile something. Good. That's just what it is.However, the ways I've described have been inelegant, at best, andpainful, at worst.This chapter contains things that make thewriting of makefiles easier and the makefiles themselves shorter andeasier to modify (and, occasionally, simpler). In this chapter, Iassume you are somewhat morefamiliar with Sprite (or UNIX, if that's what you're using) than I didin chapter 2, just so you're on your toes.So without further ado....xH 2 Transformation Rules.LPAs you know, a file's name consists of two parts: a base name, whichgives some hint as to the contents of the file, and a suffix, whichusually indicates the format of the file.Over the years, as.UXhas developed,naming conventions, with regard to suffixes, have also developed that havebecome almost as incontrovertible as Law. E.g. a file ending in.CW .cis assumed to contain C source code; one with a.CW .osuffix is assumed to be a compiled, relocatable object file that maybe linked into any program; a file with a.CW .mssuffix is usually a text file to be processed by Troff with the \-msmacro package, and so on.One of the best aspects of both Make and PMake comes from theirunderstanding of how the suffix of a file pertains to its contents andtheir ability to do things with a file based soley on its suffix. Thisability comes from something known as a transformation rule. Atransformation rule specifies how to change a file with one suffixinto a file with another suffix..LPA transformation rule looks much like a dependency line, except thetarget is made of two known suffixes stuck together. Suffixes are madeknown to PMake by placing them as sources on a dependency line whosetarget is the special target.CW .SUFFIXES .E.g..DS\&.SUFFIXES       : .o .c\&.c.o            :        $(CC) $(CFLAGS) -c $(.IMPSRC)

⌨️ 快捷键说明

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