[ Please remove libtool-patches from followups; this is merely to make them aware of this discussion ]
This proposed patch is short, but requires some more explanation: In CVS Libtool, libltdl may be used as a subpackage within third- party packages; this is nothing new: 1.5.x has this, too[1]. New is that we now actively encourage such users to set AC_CONFIG_AUX_DIR([libltdl/config]) AC_CONFIG_MACRO_DIR([libltdl/m4]) in order to avoid some duplication[2]. For simple packages, this works fine. But now suppose the toplevel package needs `mdate-sh' or some other auxiliary script not needed by libltdl itself. automake --add-missing will install this into libltdl/config, but `make dist' will fail, because the libltdl part of the `distdir' target will remove the previously copied file `libltdl/config/mdate-sh': the toplevel `distdir' target simply does the copying before calling the sub- package target, which then removes its `$(distdir)'. The proposed patch below now allows[3] this to work: subpackages will not clean their `$(distdir)' any more before populating it. (Changing the order is not feasible for other reasons.) This change would also facilitate manual sharing of m4 macro files within subpackage trees: since you're far more likely to have to modify the toplevel package for the tree anyway, you can now m4_include([subpkg/m4/foo.m4]) in toplevel acinclude.m4, and everything will Just Work[tm]. :-) This is very useful for easily building package trees where the top level package is merely glue. Cheers, Ralf [1] New in CVS Libtool is that libltdl may also be used in a non- subpackage fashion. This is not the topic of this message. [2] We are aware that this suggestion is not scalable, and to some extent an artifact of the way libltdl is created. It is not a requirement of the toplevel package to do the sharing, so we still think it's useful for some packages. [3] The $(MAKE) invocation for the subpackage `distdir' is not portable to all `make' implementation (as not all allow to override set macros from the command line); this requirement does not change with the patch. Allow package trees (packages with subpackages) to share common distributed auxiliary files (and directories) that reside within a subpackage. * lib/am/distdir.am (distdir %?TOPDIR_P%): Do not fail if `$(distdir)' already exists. (%?SUBDIRS%): Set `am__remove_distdir' to `:' to prevent removal of subpackage trees for distribution. * tests/subpkg3.test: New test. * tests/Makefile.am: Updated. Index: lib/am/distdir.am =================================================================== RCS file: /cvs/automake/automake/lib/am/distdir.am,v retrieving revision 1.62 diff -u -r1.62 distdir.am --- lib/am/distdir.am 3 Oct 2005 20:48:59 -0000 1.62 +++ lib/am/distdir.am 12 Jan 2006 20:21:07 -0000 @@ -50,7 +50,7 @@ ## if %?TOPDIR_P% $(am__remove_distdir) - mkdir $(distdir) + test -d $(distdir) || mkdir $(distdir) endif %?TOPDIR_P% ## ## @@ -175,6 +175,7 @@ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ + am__remove_distdir=: \ distdir) \ || exit 1; \ fi; \ Index: tests/Makefile.am =================================================================== RCS file: /cvs/automake/automake/tests/Makefile.am,v retrieving revision 1.591 diff -u -r1.591 Makefile.am --- tests/Makefile.am 30 Jun 2005 21:19:47 -0000 1.591 +++ tests/Makefile.am 12 Jan 2006 20:29:27 -0000 @@ -497,6 +497,7 @@ subobjname.test \ subpkg.test \ subpkg2.test \ +subpkg3.test \ subst.test \ subst2.test \ substref.test \ --- /dev/null 1970-01-01 00:00:01.000000000 +0000 +++ tests/subpkg3.test 2006-01-12 20:51:15.000000000 +0100 @@ -0,0 +1,64 @@ +#! /bin/sh +# Copyright (C) 2006 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# GNU Automake is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +# make sure different subpackages may share files and directories. + +. ./defs || exit 1 + +set -e + +cat >Makefile.am <<'END' +SUBDIRS = subpkg +EXTRA_DIST = subpkg/foobar +END + +cat >>configure.in <<'END' +AC_CONFIG_SUBDIRS([subpkg]) +AC_OUTPUT +END + +mkdir subpkg + +cat >subpkg/foobar <<'END' +foobar +END + +cat >subpkg/Makefile.am <<'END' +SUBDIRS = +END +cat >subpkg/configure.in <<'END' +AC_INIT([subpkg], [1.0]) +AM_INIT_AUTOMAKE +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT +END + +$ACLOCAL +$AUTOMAKE +$AUTOCONF + +cd subpkg +$ACLOCAL +$AUTOMAKE +$AUTOCONF +cd .. + +./configure +$MAKE distcheck