Makefile Concise Guide (3 ))

Source: Internet
Author: User
Makefile Concise Guide (3) 2010/06/08 14:52

Target and dependent can also be a label rather than a file ). In this case, it is called "pseudo target ). The name of the pseudo target cannot be the same as any file name in the current directory. If a pseudo-dotarget is to be used as a dependent, it must appear as a target in a dependent line. When the pseudo target is used as the target, the associated commands block will be executed, and nmake will assign it a hypothetical time stamp. This time stamp is equal to the maximum time stamp in its dependents, or, if it does not have a dependent, it is equal to the current time. This hypothetical time stamp is used for validity evaluation when the pseudo target is used as the dependent. The biggest benefit of this feature is that you can allow nmake to construct multiple targets without listing each target in the nmake command line. For example:

ALL: setenv project1.exe project2.exe

Project1.exe: project1.obj

Link project1;

Project2.exe: project2.obj

Link project2;

Setenv:

Set Lib = \ project \ Lib

In the preceding example, there are two pseudo targets, one being all and the other being setenv. The first step is the setenvevaluation. The second step is the configuration environment variable lib. then, project1.exeand project2.exe are updated in sequence.

Commands Block

The second line starts to the next Dependent line Between Commands Block , Which provides Dependents Any one Time stamp Greater Target The sequence of commands to be executed ( Commadns Block It can also be empty. At this time, Nmake ). Command Line It must start with a blank space ( Dependent line On the contrary, Nmake This feature is used to distinguish the two. Dependent line And Commands Block There cannot be blank lines between the first statement (that is, there is nothing except a line break. Therefore, only one blank space or tab row is valid.Nmake Interpret it as NULL command ), But in Command lines There can be blank lines between them. Commands Block Each Command in can be any valid command in the console. In fact Commands Block As A Batch Processing file consisting of console command sequences.

In additionCommands BlockYou can also add one or more so-called command modifiers (Command Modifier) To implement some additional control over the command. Command modifiers include the following:3Type:

1) @ command

Remove allStdout.

2)-[number] command

Turn off the check for the return value of this command. By default, if a command returns a non-0Value, thenNmakeThe execution will stop. However, if you add"-", ThenNmakeThe return value of this command is ignored. If-"Followed by an integer, thenNmakeAny return values greater than this integer are ignored.

3 )! Command

If the command execution object is$ **Or$?(Both are pre-defined macros. The former indicates the correspondingDependent lineAllDependent, The latter indicates all RatioTargetHas a largerTime stampOfDependent), Then the "!" The modifier will execute the command on each independent file described by the two macros.

NmakeSome syntaxes can be found inCommands BlockIndicates the correspondingDependent lineThe firstDependent. For example:

Foo.exe: C: \ sample \ first. OBJ c: \ sample \ second. OBJ

Link % s

NmakeSet"Link % s"Is interpreted:

Link c: \ sample \ first. OBJ

If you change the command to"Link % | pff.exe", ThenNmakeIt is interpreted:

Link c: \ sample \ first.exe

% SIndicates the full file name,% | [Part] FIndicates a part of the file name,PartIt can be one or more of the following characters. IfPartNull,% | FAnd% SThe meanings are the same:

1) d: Drive letter;

2) P: Path;

3) f: Basic file name;

4) E: File Extension

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.