Previous Next
Use of pattern rules instead of suffix rules

There is no need for Suffixes any more. This speeds up make since no implicit rules are called.
Advantages of pattern rules

  • More powerful and flexible than suffix rules

  • Possible to add dependencies. For instance, ofiles depend on the Makefiles so ofiles are automatically generated when Makefiles are modified.

Example of a Suffix rule
The disadvantage of suffix rules is that you can't specify any prefixes or letters at the end of a filename. You also can't specify directories.
Example of Pattern rules
Use of suffixes:
  • %.o : %win.c matches a file test.o to testwin.c
Matches object files in a subdirectory:
  • $(OBJECT_DIR)/%.o : %win.c matches a object file test.o in a subdir to testwin.c
Redirection of object files to the subdir can be done without VPATH .

    Note
    Pattern rules and suffix rules cannot be used together to build inherence chains! So if you have self-defined suffix rules, you will need to rewrite these suffix rules to pattern rules.