02.05.2013 Views

The Source Integrity Professional Edition User Guide - MKS

The Source Integrity Professional Edition User Guide - MKS

The Source Integrity Professional Edition User Guide - MKS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Using the <strong>MKS</strong> Make Utility<br />

For more information on this<br />

process, see the man page for<br />

the make command.<br />

Suffix Rules<br />

If the object file for the executable does not exist, transitive closure<br />

allows <strong>MKS</strong> Make to infer that it needs to first build the required<br />

object file from source, using this newly generated rule.<br />

When <strong>MKS</strong> Make finishes the computation for the rule head, it marks<br />

that rule head as transitive closure completed. Since it adds all<br />

possible new rules to the rule set the first time it performs the<br />

computation, <strong>MKS</strong> Make will not compute transitive closure again;<br />

nothing new can be added to the rule set.<br />

To understand this process best, you might want to experiment on<br />

small makefiles, using the -v option to the make command. This<br />

displays the behavior in detail: which rules it searches, when it<br />

computes transitive closure, and which rules it adds to the set.<br />

<strong>MKS</strong> Make follows a particular order when attempting to make<br />

inferences.<br />

An older portable form of inference rules, suffix rules use the format<br />

# typical suffix rule<br />

.suf1.suf2:<br />

recipe<br />

<strong>MKS</strong> Make matches the suffixes against the suffix of a target when it<br />

cannot locate an explicit rule for that target. However, suffix rules are<br />

not as powerful or as intuitive as metarules.<br />

For example, to express the dependence of object files upon source<br />

files, you would need a suffix rule that looked like<br />

.c$O:<br />

$(CC) -c $(CFLAGS) $<<br />

Compare this with the equivalent metarule.<br />

# normal rule<br />

file$O : file.c<br />

$(CC) -c $(CFLAGS) file.c<br />

# metarule<br />

%$O : %.c<br />

$(CC) -c $(CFLAGS) $<<br />

You can see that the construction of the suffix rule seems backwards.<br />

By itself, this gives a good reason to avoid suffix rules; you will find<br />

makefiles with suffix rules much more difficult to read.<br />

286 <strong>Source</strong> <strong>Integrity</strong> <strong>Professional</strong> <strong>Edition</strong>

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

Saved successfully!

Ooh no, something went wrong!