Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc

09.06.2013 Views

XENIX Programming make: Program Maintainer make also has built-in pseudo-target names that modify its operation. The pseudotarget name ".IGNO RE" causes make to ignore errors during execution of commands, allowing make to continue after an error. This is the same as the -i option. (make also ignores errors for a given command if the command string begins with a hyphen (-).) The pseudo-target name ".DEFAULT" defines the commands to be executed when no built-in rule or user-defined dependency line exists for the given target. You may give any number of commands with this name. If ".DEFAULT" is not used and an undefined target is given, make prints a message and stops. The pseudo-target name ".PRECIOUS" prevents dependents of the current target from being deleted when make is terminated using the INTERRUPT or QUIT key, and the pseudo-target name ".SILENT" has the same effect as the -s option. Using Macros An important feature of a makefile is that it can contain macros. A macro is a short name that represents a file name or command option. The macros can be defined when you invoke make or in the makefile itself. A macro definition is a line containing an equal sign not preceded by a colon or a tab. The name (string of letters and digits) to the left of the equal sign (trailing blanks and tabs are stripped) is assigned the string of characters following the equal sign (leading blanks and tabs are stripped). The following are valid macro definitions: 2 = xyz abc = -II -ly LIBES = The last definition assigns "LIBES" the null string. A macro that is never explicitly defined has the null string as its value. A macro is invoked by preceding the name by a dollar sign; macro names longer than one character must be placed in parentheses. The name of the macro is either the single character after the dollar sign or a name inside parentheses. The following are valid macro invocations: $(CFLAGS) $2 $(xy) $Z $(Z) The last two invocations are identical. 4-5

make: Program Maintainer XENIX Programming Macros are typically used as placeholders for values that may change from time to time. For example, the following makefile uses two macros for the names of object files to be linked and for the name of the library. OBJECTS = x.o y.o z.o LIBES = -lin prog: $(OBJECTS) cc $(OBJECTS) $(LIBES) -o prog If this makefile is invoked with the command make it will link the three object files with the lex library specified with the -lin switch. You may include a macro definition in a command line. A macro definition argument has the same form as a macro definition in a makefile. Macros in a command line override corresponding definitions found in the makefile. For example, the command make "LIBES = -lin -lm" assigns the library options -lin and -lm to LIBES. (It is necessary to quote argu ments with embedded blanks in XENIX commands.) You can modify all or part of the value generated from a macro invocation without changing the macro itself by using the substitution sequence. The sequence has the form name : st1 = [ st2 1 where name is the name of the macro whose value is to be modified, stl is the character or characters to be modified, and st2 is the character or characters to replace the modified characters. If st2 is not given, st l is replaced by a null character. The substitution sequence is typically used to allow user-defined metacharacters in a makefile. For example, suppose that ".x" is to be used as a metacharacter for a prefix and suppose that a makefile contains the definition Fl LES = prog 1.x prog2.x prog3.x Then the macro invocation $(FILES : .x = .o) generates the value prog1.o prog2.o prog3.o The actual value of FILES remains unchanged. 4-6

<strong>XENIX</strong> Programming make: Program Maintainer<br />

make also has built-in pseudo-target names that modify its operation. The pseudotarget<br />

name ".IGNO RE" causes make to ignore errors during execution of commands,<br />

allowing make to continue after an error. This is the same as the -i option. (make also<br />

ignores errors for a given command if the command string begins with a hyphen (-).)<br />

The pseudo-target name ".DEFAULT" defines the commands to be executed when no<br />

built-in rule or user-defined dependency line exists for the given target. You may give<br />

any number of commands with this name. If ".DEFAULT" is not used and an undefined<br />

target is given, make prints a message and stops.<br />

The pseudo-target name ".PRECIOUS" prevents dependents of the current target from<br />

being deleted when make is terminated using the INTERRUPT or QUIT key, and the<br />

pseudo-target name ".SILENT" has the same effect as the -s option.<br />

Using Macros<br />

An important feature of a makefile is that it can contain macros. A macro is a short<br />

name that represents a file name or command option. The macros can be defined when<br />

you invoke make or in the makefile itself.<br />

A macro definition is a line containing an equal sign not preceded by a colon or a tab.<br />

The name (string of letters and digits) to the left of the equal sign (trailing blanks and<br />

tabs are stripped) is assigned the string of characters following the equal sign (leading<br />

blanks and tabs are stripped). The following are valid macro definitions:<br />

2 = xyz<br />

abc = -II -ly<br />

LIBES =<br />

The last definition assigns "LIBES" the null string. A macro that is never explicitly<br />

defined has the null string as its value.<br />

A macro is invoked by preceding the name by a dollar sign; macro names longer than one<br />

character must be placed in parentheses. The name of the macro is either the single<br />

character after the dollar sign or a name inside parentheses. The following are valid<br />

macro invocations:<br />

$(CFLAGS)<br />

$2<br />

$(xy)<br />

$Z<br />

$(Z)<br />

The last two invocations are identical.<br />

4-5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!