On Tue, Mar 17, 2009 at 01:14:33AM +0100, Bruno Haible wrote:
> Colin Watson wrote:
> > I would find it more elegant to install all the files separately and
> > have a defined ordering between them
> 
> It may work for you. For the general developer, I think it opens too
> many pitfalls (missing -I options, confusion about which file is used,
> possibly empty directories after "make distrib", ...).

I take the point about 'make dist', at least.

How about the attached patch to autopoint which causes it to look
through all m4 directories in ACLOCAL_AMFLAGS and compare serial
numbers? That would avoid the problem of 'make dist' forgetting to ship
files even if you do use multiple m4 directories; the files will simply
not be copied into the package at all, which surely makes it easier to
understand what's going on.

> > Beyond the gettext compatibility issue, there are many files in gnulib
> > that have serial lines in a format not recognised by aclocal that have
> > nothing to do with gettext. Is there a good reason for these?
> 
> The reason is transparency and ease of debugging: There are cases when
> 'aclocal' copies the contents of the .m4 file. When I have a configure file
> that does not work and look at the aclocal.m4 from which it was generated,
> I want to know from which .m4 file each snippet came from.

You can do this with aclocal's documented format too, since it permits
and ignores any trailing garbage after the serial number itself.

  # serial 5 snprintf.m4

Thanks,

-- 
Colin Watson                                       [cjwat...@debian.org]
Index: gettext-tools/misc/autopoint.in
===================================================================
RCS file: /sources/gettext/gettext/gettext-tools/misc/autopoint.in,v
retrieving revision 1.40
diff -p -u -r1.40 autopoint.in
--- gettext-tools/misc/autopoint.in	7 Dec 2008 16:20:56 -0000	1.40
+++ gettext-tools/misc/autopoint.in	17 Mar 2009 02:06:23 -0000
@@ -352,6 +352,7 @@ fi
 
 # Check in which directory the *.m4 macros belong.
 m4dir=m4
+all_m4dirs=
 if test -f Makefile.am; then
   # A package using automake.
   # Extract the macro directory name from Makefile.am.
@@ -359,8 +360,11 @@ if test -f Makefile.am; then
   m4dir_is_next=
   for arg in $aclocal_amflags; do
     if test -n "$m4dir_is_next"; then
-      m4dir="$arg"
-      break
+      if [ -z "$m4dir" ]; then
+        m4dir="$arg"
+      fi
+      all_m4dirs="$all_m4dirs $arg"
+      m4dir_is_next=
     else
       if test "X$arg" = "X-I"; then
         m4dir_is_next=yes
@@ -505,6 +509,30 @@ func_compare ()
   fi
 }
 
+# func_compare_all gettextfile
+# searches for all files in the package with the same name as gettextfile,
+# and runs func_compare on each. Returns 0 if the file from gettext can be
+# used, or 1 if it should be skipped.
+func_compare_all ()
+{
+  case "$1" in
+    *.m4)
+      base=`echo "$1" | sed -e 's,.*/,,'`
+      for dir in $all_m4dirs; do
+        if test -f "$dir/$base"; then
+          if ! func_compare "$dir/$base" "$1"; then
+            return 1
+          fi
+        fi
+      done
+      true
+      ;;
+    *)
+      true
+      ;;
+  esac
+}
+
 # If some files have been locally modified and we have not been requested
 # to overwrite them, then bail out. This is better than leaving a source
 # package around where half of the files are locally modified and half are
@@ -514,10 +542,10 @@ if test -z "$force"; then
   func_tmpdir
   mismatchfile="$tmp"/autopoint.diff
   for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do
-    func_destfile "$file"
-    if test -n "$destfile"; then
-      if test -f "$destfile"; then
-        if func_compare "$destfile" "$work_dir/archive/$file"; then
+    if func_compare_all "$work_dir/archive/$file"; then
+      func_destfile "$file"
+      if test -n "$destfile"; then
+        if test -f "$destfile"; then
           if test -n "$sharedowner"; then
             echo "autopoint: warning: File $destfile has been locally modified." 1>&2
           else
@@ -581,11 +609,11 @@ func_backup ()
 
 # Now copy the files.
 for file in `find "$work_dir/archive" -type f -print | sed -e "s,^$work_dir/archive/,," | LC_ALL=C sort`; do
-  func_destfile "$file"
   mustcopy=
-  if test -n "$destfile"; then
-    if test -f "$destfile"; then
-      if func_compare "$destfile" "$work_dir/archive/$file"; then
+  if func_compare_all "$work_dir/archive/$file"; then
+    func_destfile "$file"
+    if test -n "$destfile"; then
+      if test -f "$destfile"; then
         if test -n "$force"; then
           # Overwrite locally modified file.
           mustcopy=yes

Reply via email to