Difference between revisions of "Creating pattern rules"

From Notes_Wiki
(Created page with "<yambe:breadcrumb>Makefile|Makefile</yambe:breadcrumb> =Creating pattern rules= Make supports implicit pattern rules for creating .o files from .c files. It is possible to ex...")
 
m
Line 1: Line 1:
<yambe:breadcrumb>Makefile|Makefile</yambe:breadcrumb>
<yambe:breadcrumb self="Creating pattern rules">Makefile|Makefile</yambe:breadcrumb>
=Creating pattern rules=
=Creating pattern rules=


Line 7: Line 7:
</pre>
</pre>
Note the use of special variables $< and $@ which refer to source and target respectively in creation of pattern. Also note that pattern rule has two patterns separated by ':' then a recipe at the end separated from second pattern by ';'. This pattern rule will allow creation of .svg files from .dot files
Note the use of special variables $< and $@ which refer to source and target respectively in creation of pattern. Also note that pattern rule has two patterns separated by ':' then a recipe at the end separated from second pattern by ';'. This pattern rule will allow creation of .svg files from .dot files
<yambe:breadcrumb self="Creating pattern rules">Makefile|Makefile</yambe:breadcrumb>

Revision as of 08:57, 12 September 2018

<yambe:breadcrumb self="Creating pattern rules">Makefile|Makefile</yambe:breadcrumb>

Creating pattern rules

Make supports implicit pattern rules for creating .o files from .c files. It is possible to extend the rule-set and create more rules to create user-defined rules. To create own rules the target must contain exactly one % character which will match with any string or length one or more. Example pattern rule is:

%.svg : %.dot ; dot -Tsvg $< > $@

Note the use of special variables $< and $@ which refer to source and target respectively in creation of pattern. Also note that pattern rule has two patterns separated by ':' then a recipe at the end separated from second pattern by ';'. This pattern rule will allow creation of .svg files from .dot files


<yambe:breadcrumb self="Creating pattern rules">Makefile|Makefile</yambe:breadcrumb>