title: Autotools Setup for Static and Shared Libraries
body: <p>We have a large code base that I'm converting to autotools to help target multiple platforms / configurations. Basically, we have:</p>
  
  <pre><code>|-- configure.ac
  |-- Makefile.am
  |-- dependency1
  |   `-- Makefile.am
  |-- dependency2
  |   `-- Makefile.am
  `-- dependency3
      `-- Makefile.am
  </code></pre>
  
  <p>The dependency folders are common across many projects, so The <code>Makefile.am</code> files create <code>libdependencyX.la</code> files. In the root <code>Makefile.am</code>, I then use <code>LIBADD</code> to combine everything to create a final shared library. This all works create.</p>
  
  <p>We have the need to create both shared and static versions of our library. How would I go about this? All of the dependencies just use <code>LTLIBRARIES</code> to make everything.</p>
  
  <p>The original solution was just a giant Makefile that created a series of <code>.o</code> files and then building the resulting <code>.so</code> or <code>.a</code> in the end.</p>
  
  <p><strong>Update 2015-03-11</strong></p>
  
  <p>The issue I'm having is that I can get static or shared, but not both. The root <code>Makefile.am</code> looks like this for the final library.</p>
  
  <pre><code>lib_LTLIBRARIES = libroot.la
  libroot_la_SOURCES = root.c
  libroot_la_LIBADD = dependency1/libdependency1.la \
                      dependency2/libdependency2.la \
                      dependency3/libdependency3.la
  libroot_la_LDFLAGS = -shared
  </code></pre>
  
  <p>Switching the <code>-shared</code> to <code>-static</code> gives me the <code>.a</code>, but how can I get both? <code>--enable-shared / --enable-static</code> doesn't seem to change anything.</p>