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
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<yambe:breadcrumb>Makefile|Makefile</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Programming tools]] > [[Makefile]] > [[Creating pattern rules]]
=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:
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:
Line 7: Line 6:
</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
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Programming tools]] > [[Makefile]] > [[Creating pattern rules]]

Latest revision as of 15:55, 24 August 2022

Home > CentOS > CentOS 6.x > Programming tools > Makefile > 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


Home > CentOS > CentOS 6.x > Programming tools > Makefile > Creating pattern rules