When invoked by autoreconf of a project with nested configure.ac files, automake does not respect the disabling of AC_CONFIG_FILES by the top-level configure.ac using AM_COND_IF, resulting in an incorrect Makefile. Re-running autoreconf from within the nested project produces correct output.
http://support.ntp.org/people/hart/am-libopts-subpkg.tar.gz The layout is: am-libopts-subpkg/ configure.ac Makefile.am top.c subproj/ configure.ac Makefile.am sub.c libopts/ m4/ ... Both top.c and sub.c are libopts clients, sharing the single (patched) subproj/libopts bundled copy. The problem is that sometimes subproj/libopts/Makefile.in is generated correctly by the subproj machinery, and other times it is generated incorrectly by the top-level config.status. The resulting subproj/libopts/Makefile breaks "make distcheck" using GNU Make, though curiously FreeBSD's make is able to complete distcheck successfully. The incorrect subproj/libopts/Makefile contains "subdir = subproj/libopts" while the working one has "subdir = libopts". The distcheck break happens when subproj/libopts/Makefile attempts to regenerate itself using a missing automake invocation that contains an extra "subproj/" that makes the filename non-existent. I modified our copy of libopts/m4/libopts.m4, originally from Autogen 5.11.2, to add an optional second argument to LIBOPTS_CHECK which can be used to conditionalize the AC_CONFIG_FILES([${libopts-dir}/Makefile]) under AM_COND_IF. The top-level am-libopts-subpkg/configure.ac uses this facility, so that the top-level config.status does not generate subproj/libopts/Makefile as it would otherwise. Instead, subproj/config.status generates (from its perspective) libopts/Makefile. The problem I had was with autoreconf -i from the top level. After autoreconf completes, subproj/libopts/Makefile.in was consistently incorrect. This can be worked around with, for example: cd .../am-libopts-subpkg autoreconf -i -v --no-recursive cd subproj autoreconf -i -v cd .. After which subproj/libopts/Makefile.in is consistently correct. The workaround was only temporary, as invariably something triggered am--refresh and the incorrect subproj/Makefile stopped progress again. In the end, for the NTP reference implementation, we worked with Bruce Korb to upstream a split of the former LIBOPTS_CHECK functionality into a compatible LIBOPTS_CHECK and a new subset LIBOPTS_CHECK_NOBUILD. By using the latter in the top-level configure.ac, we avoid depending on AM_COND_IF correctly conditionalizing AC_CONFIG_FILES([${libopts-dir}/Makefile]). See also: http://lists.gnu.org/archive/html/automake/2010-11/msg00135.html http://lists.gnu.org/archive/html/automake/2011-01/msg00120.html http://lists.gnu.org/archive/html/automake/2011-01/msg00122.html