<p>I haven't seen any questions relating to GNU autoconf/automake builds, but I'm hoping at least some of you out there are familiar with it.  Here goes:</p>

<p>I have a project (I'll call it myproject) that includes another project (vendor).  The vendor project is a standalone project maintained by someone else.  Including a project like this is fairly <a href="http://www.gnu.org/software/autoconf/manual/autoconf.html#Subdirectories" rel="nofollow noreferrer">straightforward</a>, but in this case there is a tiny snag: each project generates its own <code>config.h</code> file, each of which defines standard macros such as PACKAGE, VERSION, etc.  This means that, during the build, when vendor is being built, I get lots of errors like this:</p>

<pre><code>... warning: "VERSION" redefined
... warning: this is the location of the previous definition
... warning: "PACKAGE" redefined
... warning: this is the location of the previous definition
</code></pre>

<p>These are just warnings, for the time being at least, but I would like to get rid of them.  The only relevant information I've been able to turn up with a Google search is <a href="http://sourceware.org/ml/automake/2004-03/msg00130.html" rel="nofollow noreferrer">this</a> thread on the automake mailing list, which isn't a whole lot of help.  Does anybody else have any better ideas?</p>

[{'answer_id': 9214, 'author': 'David Joyner', 'author_id': 1146, 'author_profile': 'https://Stackoverflow.com/users/1146', 'pm_score': 2, 'selected': False, 'text': "<p>It's definitely a hack, but I post-process the autogen'd <code>config.h</code> file:</p>\n\n<pre><code>sed -e 's/.*PACKAGE_.*//' &lt; config.h &gt; config.h.sed &amp;&amp; mv config.h.sed config.h\n</code></pre>\n\n<p>This is tolerable in our build environment but I'd be interested in a cleaner way.</p>\n"}, {'answer_id': 11269, 'author': 'Jason Day', 'author_id': 737, 'author_profile': 'https://Stackoverflow.com/users/737', 'pm_score': 1, 'selected': False, 'text': '<p>It turns out there was a very simple solution in my case.  The vendor project gathers several header files into one monolithic header file, which is then <code>#include</code>d by the vendor sources.  But the make rule that builds the monolithic header accidentally included the generated <code>config.h</code>.  The presence of the PACKAGE, VERSION, etc. config variables in the monolithic header is what was causing the redefinition warnings.  It turns out that the vendor\'s <code>config.h</code> was irrelevant, because "config.h" always resolved to <code>$(top_builddir)/config.h</code>.</p>\n\n<p>I believe this is the way it\'s supposed to work.  By default a subproject should be including the enclosing project\'s <code>config.h</code> instead of its own, unless the subproject explicitly includes its own, or manipulates the INCLUDE path so that its own directory comes before <code>$(top_builddir)</code>, or otherwise manipulates the header files as in my case.</p>\n'}, {'answer_id': 26994, 'author': 'Thomas Vander Stichele', 'author_id': 2900, 'author_profile': 'https://Stackoverflow.com/users/2900', 'pm_score': 4, 'selected': True, 'text': '<p>Some notes:</p>\n\n<ul>\n<li>you didn\'t mention how <code>config.h</code> was included - with quotes or angle brackets. See <a href="https://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename">this other question</a> for more information on the difference. In short, <code>config.h</code> is typically included with quotes, not angle brackets, and this should make the preprocessor prefer the <code>config.h</code> from the project\'s own directory (which is usually what you want)</li>\n<li>You say that a subproject should be including the enclosing project\'s <code>config.h</code> Normally this is not at all what you want. The subproject is standalone, and its PACKAGE and VERSION should be the one of that subproject, not yours. If you include libxml in your xmlreader project for example, you would still want the libxml code to be compiled with PACKAGE libxml and VERSION (whatever the libxml version is).</li>\n<li>It is usually a big mistake to have <code>config.h</code> be included from public headers. <code>config.h</code> is always private to your project or the subproject, and should only be included from .c files. So, if your vendor\'s documentation says to include their "vendor.h" and that public header includes <code>config.h</code> somehow, then that is a no-no. Similarly, if your project is a library, don\'t include <code>config.h</code> anywhere from your publically installed headers.</li>\n</ul>\n'}]
['https://Stackoverflow.com/questions/7398', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/737/']