Note that there are some explanatory texts on larger screens.

plurals
  1. POExpected project/directory structure for Automake?
    primarykey
    data
    text
    <p>I'm developing a static C library, and had been using a bare-bones Makefile. We're now having to support offsite installs and whatnot, and the time has come to move to a more robust build standard. I really want that to be autotools -- I love the automatic conformance to the GNU Build System and I also have found it pretty easy to work with.</p> <p>That said, I have a problem.</p> <p>Here's a rough outline of how the project has been structured:</p> <pre><code>project/ common/ pkg/ inc/ src/ submodule1/ some_thing/ some_other_thing/ submodule2/ . . . </code></pre> <p><code>common</code> contains header files that would be installed on a target system -- one header directly under common, and some other stuff in common/pkg. (Well, it's not really pkg, that's just an example.) Everything under <code>common</code> is <code>.h</code>.</p> <p><code>inc</code> contains internal include files that are strictly implementation-relevant and shouldn't be exposed. Everything under <code>inc</code> is <code>.h</code>.</p> <p><code>src</code> has a directory for each of a number of submodules, and each of the submodules may or may not be divided into pieces (subsubmodules, if you want). Everything under <code>src</code> is <code>.c</code>.</p> <p>The original makefile would set a <code>SOURCES</code> variable consisting of every <code>.c</code> file found recursively in src, add <code>-I./common -I./inc</code>, build the object files, and archive them into a library. Pretty straightforward.</p> <p>Well, with automake, it doesn't seem so simple. I figured out about adding flags to a build target, for instance `project_CPPFLAGS=-I./inc -I./common" -- this solves part of the problem, but I feel like I'm doing something wrong, somehow. </p> <p>With those (suboptimal?) settings, I can get automake building and linking the library, which is exciting enough already, but the real reason I'm here is <code>make install</code>.</p> <h3>The main problem is this:</h3> <p><code>common</code> contains the public interface to the library, if you will. It is needed to build the sources, but it also needs to be installed. If I include it from <code>project/</code>, then automake will see paths like <code>common/thing.h</code> and <code>common/pkg/other.h</code>, and get the paths wrong in <code>includedir</code> on installation. I thought about having it recurse into that directory to build a project that only has installation headers, but that not only smells bad, it didn't work when I tried it. The library headers need a specific tree structure -- <strong>how do I maintain the lib header tree structure, make them available to all the source files, and install them rooted from <code>common</code>?</strong></p> <p>Additionally, is there some more elegant way to handle includes than by forcing <code>-I</code>? I know I have to specify them as <code>HEADERS</code> to get them in distribution packages, but that doesn't actually seem to make them available to be included, leaving me a bit lost.</p> <p>I feel like automake (and perhaps GNU in general) is expecting some structure to my project that I'm just not seeing. <strong>If that's the case, please tell me</strong> -- I'm perfectly willing to spend some time refactoring/reorganizing the project. I really do feel like I'm missing some philosophical bit -- the current structure was designed without guidance or experience, and I am in no way attached to it.</p> <p>Any help is appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload