make: Archive Suffix Rules

1 
1 11.4 Suffix Rules for Archive Files
1 ===================================
1 
1 You can write a special kind of suffix rule for dealing with archive
1 files.  ⇒Suffix Rules, for a full explanation of suffix rules.
1 Archive suffix rules are obsolete in GNU 'make', because pattern rules
1 for archives are a more general mechanism (⇒Archive Update).  But
1 they are retained for compatibility with other 'make's.
1 
1    To write a suffix rule for archives, you simply write a suffix rule
1 using the target suffix '.a' (the usual suffix for archive files).  For
1 example, here is the old-fashioned suffix rule to update a library
1 archive from C source files:
1 
1      .c.a:
1              $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.o
1              $(AR) r $@ $*.o
1              $(RM) $*.o
1 
1 This works just as if you had written the pattern rule:
1 
1      (%.o): %.c
1              $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.o
1              $(AR) r $@ $*.o
1              $(RM) $*.o
1 
1    In fact, this is just what 'make' does when it sees a suffix rule
1 with '.a' as the target suffix.  Any double-suffix rule '.X.a' is
1 converted to a pattern rule with the target pattern '(%.o)' and a
1 prerequisite pattern of '%.X'.
1 
1    Since you might want to use '.a' as the suffix for some other kind of
1 file, 'make' also converts archive suffix rules to pattern rules in the
1 normal way (⇒Suffix Rules).  Thus a double-suffix rule '.X.a'
1 produces two pattern rules: '(%.o): %.X' and '%.a: %.X'.
1