From f598096149dcee92fbb0381382dbf6dfab7911b5 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Mon, 30 Jun 2008 01:18:28 +0200
Subject: [PATCH] Recommend to put gnulib-cache.m4 into EXTRA_DIST.

---
 ChangeLog   |  6 ++++++
 gnulib-tool | 12 ++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 87da51d984..3667cde684 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-06-29  Bruno Haible  <bruno@clisp.org>
+
+	* gnulib-tool (func_import): Recommend to put gnulib-cache.m4 into
+	EXTRA_DIST.
+	Reported by Sylvain Beucler <beuc@beuc.net>.
+
 2008-06-26  Jim Meyering  <meyering@redhat.com>
 
 	make several modules depend on the "open" module
diff --git a/gnulib-tool b/gnulib-tool
index 7b660b90ce..989869d07e 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -3409,6 +3409,18 @@ func_import ()
     fi
   fi
   echo "  - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
+  {
+    # Find the first parent directory of $m4base that contains a Makefile.am.
+    sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
+s,//*$,/,'
+    sed_butlast='s,[^/][^/]*//*$,,'
+    dir1="${m4base}/"; dir2=""
+    while test -n "$dir1" && test ! -f "${destdir}/${dir1}Makefile.am"; do
+      dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
+      dir1=`echo "$dir1" | sed -e "$sed_butlast"`
+    done
+    echo "  - mention ${dir2}gnulib-cache.m4 in EXTRA_DIST in ${dir1}Makefile.am."
+  }
   echo "  - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
   echo "  - invoke ${macro_prefix}_INIT in $configure_ac."
 }
-- 
2.30.2