title: Makefile for Shared Libraries?
body: <p>I've just written a Makefile to build a shared library, similar to the following:</p>
  
  <pre><code>libmystuff.so: CFLAGS+=-fPIC -shared
  libmystuff.so: libmystuff.o otherstuff.o
      $(CC) $(CFLAGS) -o $@ $^
  </code></pre>
  
  <p>I like to avoid doing explicit actions when this seems like a common operation, but it seems there's no implicit rule or other built-ins to standardize this. I'm using GNU Make on Linux at the moment, but will need this to work on OS X as well.</p>
  
  <p><strong>EDIT</strong>: I'm asking about make rules rather than compiler/linker flags.</p>
  
  <p>Can you recommend clean, reusable Makefile rules to build shared libs? Perhaps a <code>%.so:</code> or <code>.c.so:</code> type rule?</p>