Creating pattern rules

From Notes_Wiki
Revision as of 01:13, 1 January 2013 by Saurabh (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<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 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