02.05.2013 Views

Using MKS Make

Using MKS Make

Using MKS Make

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

How <strong>Make</strong> Finds Files<br />

If you specify the .SOURCE or .SOURCE.x targets more than once,<br />

<strong>MKS</strong> <strong>Make</strong> appends all the prerequisites to one list. However, you can clear<br />

the list of prerequisites by specifying the target with a null prerequisite list.<br />

In addition, you can use <strong>MKS</strong> <strong>Make</strong>’s :- rule operator to clear a previously<br />

set list of path names. Thus, the following two examples are equivalent.<br />

.SOURCE :<br />

.SOURCE : /usr/fred /usr/gerry<br />

# these two lines are equivalent to the next one<br />

.SOURCE :- /usr/fred /usr/gerry<br />

More generally, the processing of the .SOURCE special targets is identical to<br />

the processing of the .SUFFIXES special targets.<br />

Example: Directory Navigation Within a <strong>Make</strong>file<br />

Sometimes you might want to have a recipe run while the directory is set to<br />

something else other than the current directory. The .SETDIR attribute tells<br />

make to change the current directory for the duration of the recipe with the<br />

attribute set. Here’s an example:<br />

all: subdir two<br />

echo not in subdir<br />

pwd<br />

# Remember to clean up afterwards by<br />

# removing subdir.<br />

subdir:<br />

mkdir subdir<br />

# Note: We can't put "subdir" as a prerequisite<br />

# for "two" because subdir has to exist before<br />

# anything to do with "two" is processed.<br />

two .SETDIR=subdir:<br />

echo in subdir<br />

pwd<br />

Note that .SETDIR does not work with metarules.<br />

Example: Including External <strong>Make</strong>files<br />

<strong>Make</strong> has facilities for including other makefiles into the current makefile.<br />

Normally, make looks in the current directory for these files. The special<br />

targets, .INCLUDEDIRS and .INCLUDE, can be used to inform make to look<br />

elsewhere for these files.<br />

The following example relates back to the following three makefiles, two of<br />

which are located in the subdirectories 1 and 2.<br />

<strong>Using</strong> <strong>MKS</strong> <strong>Make</strong> 41

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

Saved successfully!

Ooh no, something went wrong!