Creating pattern rules
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