automake-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Automake-commit] [SCM] GNU Automake branch, pot-primary, updated. v1.11


From: Bruno Haible
Subject: [Automake-commit] [SCM] GNU Automake branch, pot-primary, updated. v1.11-335-g45c45ae
Date: Sun, 05 Sep 2010 23:34:43 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Automake".

http://git.sv.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=45c45ae4ee5a4a60768a755bc66e707463de8d42

The branch, pot-primary has been updated
       via  45c45ae4ee5a4a60768a755bc66e707463de8d42 (commit)
      from  74ad120b941c73c536d186422805b661863ab93a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 45c45ae4ee5a4a60768a755bc66e707463de8d42
Author: Bruno Haible <address@hidden>
Date:   Mon Sep 6 01:16:56 2010 +0200

    Internationalization tests.
    
    * tests/pot-macro-warn.test: New file.
    * tests/pot-enable1.test: New file.
    * tests/pot-enable2.test: New file.
    * tests/pot-warn1.test: New file.
    * tests/pot-warn2.test: New file.
    * tests/pot-empty.test: New file.
    * tests/pot-no-linguas.test: New file.
    * tests/pot-linguas.test: New file.
    * tests/pot-noinst.test: New file.
    * tests/pot-topsrcdir.test: New file.
    * tests/pot-samedir.test: New file.
    * tests/pot-override1.test: New file.
    * tests/pot-copyright.test: New file.
    * tests/pot-msgidbugs.test: New file.
    * tests/pot-xgettext1.test: New file.
    * tests/pot-xgettext2.test: New file.
    * tests/pot-xgettext3.test: New file.
    * tests/pot-xgettext4.test: New file.
    * tests/pot-download1.test: New file.
    * tests/pot-format-qt1.test: New file.
    * tests/pot-format-java1.test: New file.
    * tests/pot-format-java2.test: New file.
    * tests/pot-format-csharp1.test: New file.
    * tests/pot-format-tcl1.test: New file.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                     |   28 +++
 tests/pot-copyright.test                      |  106 +++++++++
 tests/pot-download1.test                      |   82 +++++++
 tests/pot-empty.test                          |   81 +++++++
 tests/{condhook2.test => pot-enable1.test}    |   43 ++--
 tests/{condhook2.test => pot-enable2.test}    |   43 ++--
 tests/pot-format-csharp1.test                 |  223 +++++++++++++++++++
 tests/pot-format-java1.test                   |  224 +++++++++++++++++++
 tests/pot-format-java2.test                   |  224 +++++++++++++++++++
 tests/pot-format-qt1.test                     |  244 +++++++++++++++++++++
 tests/pot-format-tcl1.test                    |  219 +++++++++++++++++++
 tests/pot-linguas.test                        |  286 +++++++++++++++++++++++++
 tests/{condhook2.test => pot-macro-warn.test} |   45 +++--
 tests/pot-msgidbugs.test                      |  172 +++++++++++++++
 tests/pot-no-linguas.test                     |  176 +++++++++++++++
 tests/pot-noinst.test                         |  258 ++++++++++++++++++++++
 tests/pot-override1.test                      |  145 +++++++++++++
 tests/pot-samedir.test                        |  233 ++++++++++++++++++++
 tests/pot-topsrcdir.test                      |  283 ++++++++++++++++++++++++
 tests/{condhook2.test => pot-warn1.test}      |   42 ++--
 tests/{condhook2.test => pot-warn2.test}      |   40 ++--
 tests/pot-xgettext1.test                      |  106 +++++++++
 tests/pot-xgettext2.test                      |  106 +++++++++
 tests/pot-xgettext3.test                      |  121 +++++++++++
 tests/pot-xgettext4.test                      |  116 ++++++++++
 25 files changed, 3546 insertions(+), 100 deletions(-)
 create mode 100644 tests/pot-copyright.test
 create mode 100644 tests/pot-download1.test
 create mode 100644 tests/pot-empty.test
 copy tests/{condhook2.test => pot-enable1.test} (56%)
 mode change 100755 => 100644
 copy tests/{condhook2.test => pot-enable2.test} (57%)
 mode change 100755 => 100644
 create mode 100644 tests/pot-format-csharp1.test
 create mode 100644 tests/pot-format-java1.test
 create mode 100644 tests/pot-format-java2.test
 create mode 100644 tests/pot-format-qt1.test
 create mode 100644 tests/pot-format-tcl1.test
 create mode 100644 tests/pot-linguas.test
 copy tests/{condhook2.test => pot-macro-warn.test} (57%)
 mode change 100755 => 100644
 create mode 100644 tests/pot-msgidbugs.test
 create mode 100644 tests/pot-no-linguas.test
 create mode 100644 tests/pot-noinst.test
 create mode 100644 tests/pot-override1.test
 create mode 100644 tests/pot-samedir.test
 create mode 100644 tests/pot-topsrcdir.test
 copy tests/{condhook2.test => pot-warn1.test} (59%)
 mode change 100755 => 100644
 copy tests/{condhook2.test => pot-warn2.test} (61%)
 mode change 100755 => 100644
 create mode 100644 tests/pot-xgettext1.test
 create mode 100644 tests/pot-xgettext2.test
 create mode 100644 tests/pot-xgettext3.test
 create mode 100644 tests/pot-xgettext4.test

diff --git a/ChangeLog b/ChangeLog
index ae92079..a21b60a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2010-09-05  Bruno Haible  <address@hidden>
+
+       Internationalization tests.
+       * tests/pot-macro-warn.test: New file.
+       * tests/pot-enable1.test: New file.
+       * tests/pot-enable2.test: New file.
+       * tests/pot-warn1.test: New file.
+       * tests/pot-warn2.test: New file.
+       * tests/pot-empty.test: New file.
+       * tests/pot-no-linguas.test: New file.
+       * tests/pot-linguas.test: New file.
+       * tests/pot-noinst.test: New file.
+       * tests/pot-topsrcdir.test: New file.
+       * tests/pot-samedir.test: New file.
+       * tests/pot-override1.test: New file.
+       * tests/pot-copyright.test: New file.
+       * tests/pot-msgidbugs.test: New file.
+       * tests/pot-xgettext1.test: New file.
+       * tests/pot-xgettext2.test: New file.
+       * tests/pot-xgettext3.test: New file.
+       * tests/pot-xgettext4.test: New file.
+       * tests/pot-download1.test: New file.
+       * tests/pot-format-qt1.test: New file.
+       * tests/pot-format-java1.test: New file.
+       * tests/pot-format-java2.test: New file.
+       * tests/pot-format-csharp1.test: New file.
+       * tests/pot-format-tcl1.test: New file.
+
 2010-08-29  Bruno Haible  <address@hidden>
 
        Internationalization documentation changes.
diff --git a/tests/pot-copyright.test b/tests/pot-copyright.test
new file mode 100644
index 0000000..e4f9ff2
--- /dev/null
+++ b/tests/pot-copyright.test
@@ -0,0 +1,106 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that when a _COPYRIGHT_HOLDER variable is specified, the POT
+# file's header contains the copyright holder.
+
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/main.c
+posub_foo_bar_pot_COPYRIGHT_HOLDER = Yoyodyne, Inc.
+EXTRA_DIST = src/main.c
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, world.\n"));
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR Yoyodyne, Inc.
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-copyright 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.c:4
+#, c-format
+msgid "Hello, world.\n"
+msgstr ""
+END
+
+for builddir in . sub; do
+  if test $builddir = '.'; then
+    sourcedir='.'
+  else
+    sourcedir='..'
+    mkdir $builddir
+  fi
+  instdir="`pwd`/instdir"
+  cd $builddir
+  $sourcedir/configure --prefix="$instdir"
+  make
+
+  # Check that "make dist" creates the expected .pot file.
+  # (It is created under $sourcedir, because the .pot file is distributed.
+  # Cf. the GNU standards, node "Makefile Basics".)
+
+  make dist
+
+  test -f $sourcedir/posub/foo-bar.pot
+  test $builddir = '.' || test ! -f posub/foo-bar.pot
+  cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr 
-d '\r' > actual
+  diff actual $sourcedir/expected
+  rm -f actual
+
+  # Sanity check.
+  make distcheck
+
+  # Clean up.
+  make distclean
+  rm -rf "$instdir"
+  cd $sourcedir
+done
diff --git a/tests/pot-download1.test b/tests/pot-download1.test
new file mode 100644
index 0000000..a70845b
--- /dev/null
+++ b/tests/pot-download1.test
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check the download of translations from the Translation Project.
+
+required='gzip'
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+locale_POTS = clisp.pot
+posub_foo_bar_pot_SOURCES = spvw.c
+clisp_pot_TP_URL = http://translationproject.org/latest/
+EXTRA_DIST = spvw.c
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+cat > spvw.c << 'END'
+#include <stdio.h>
+#include "gettext.h"
+int main ()
+{
+  puts (gettext ("*** - Program stack overflow. RESET"));
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+for builddir in . sub; do
+  if test $builddir = '.'; then
+    sourcedir='.'
+  else
+    sourcedir='..'
+    mkdir $builddir
+  fi
+  instdir="`pwd`/instdir"
+  cd $builddir
+  LINGUAS="de" $sourcedir/configure --prefix="$instdir"
+  make
+
+  # Check that after "make install", a German translation has been installed.
+  make install
+  test -f "$instdir"/share/locale/de/LC_MESSAGES/clisp.mo
+
+  # Check that after "make dist", the tarball does not include the German
+  # translation.
+  make dist
+  gzip -d -c < pot-download1-1.0.tar.gz | tar tf - > filelist
+  if grep '^pot-download1-1\.0/clisp-de\.po$' filelist >/dev/null; then
+    exit 1
+  fi
+  rm -f filelist
+
+  # Sanity check.
+  make distcheck
+
+  # Clean up.
+  make distclean
+  rm -rf "$instdir"
+  cd $sourcedir
+done
diff --git a/tests/pot-empty.test b/tests/pot-empty.test
new file mode 100644
index 0000000..09bca2b
--- /dev/null
+++ b/tests/pot-empty.test
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that when the package contains no internationalized strings,
+# no POT file is created (because it would unnecessarily disturb the
+# translators to ask them to translate an empty file).
+
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/main.c
+EXTRA_DIST = src/main.c
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf ("Hello, world.\n");
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+for builddir in . sub; do
+  if test $builddir = '.'; then
+    sourcedir='.'
+  else
+    sourcedir='..'
+    mkdir $builddir
+  fi
+  instdir="`pwd`/instdir"
+  cd $builddir
+  $sourcedir/configure --prefix="$instdir"
+  make
+  make dist
+
+  # Check that no .pot file was created.
+  test ! -f posub/foo-bar.pot
+
+  make install
+
+  # Check that still, no .pot file was created.
+  test ! -f posub/foo-bar.pot
+
+  # Check that no .mo file was installed, not even its directory was created.
+  test ! -d "$instdir"/share/locale/de/LC_MESSAGES
+
+  # Sanity check.
+  make distcheck
+
+  # Clean up.
+  make distclean
+  rm -rf "$instdir"
+  cd $sourcedir
+done
diff --git a/tests/condhook2.test b/tests/pot-enable1.test
old mode 100755
new mode 100644
similarity index 56%
copy from tests/condhook2.test
copy to tests/pot-enable1.test
index 45e2d43..77b154d
--- a/tests/condhook2.test
+++ b/tests/pot-enable1.test
@@ -1,4 +1,4 @@
-#!/bin/sh
+#! /bin/sh
 # Copyright (C) 2010 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -14,36 +14,39 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test install when a conditional install-*-hook is defined.
-# Keep this in sync with sister test condhook.test.
+# Check that when the AM_POT_TOOLS macro is used, the --enable-nls and
+# --disable-nls options determine the value of USE_NLS, and
+# --help advertises --disable-nls.
 
 . ./defs || Exit 1
 
 set -e
 
-cat >> configure.in << 'END'
-AM_CONDITIONAL([TEST], [true])
-AC_OUTPUT
-END
-
 cat > Makefile.am << 'END'
-sysconf_DATA = mumble
-if TEST
-install-data-hook:
-       : > $(top_srcdir)/good
-endif
+check-USE_NLS-yes:
+       test "@USE_NLS@" = yes
+check-USE_NLS-no:
+       test "@USE_NLS@" = no
 END
 
-: > mumble
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
 
 $ACLOCAL
+$AUTOMAKE -a
 $AUTOCONF
-$AUTOMAKE
 
-./configure --prefix "`pwd`/inst"
+# Check that the --help output advertises --disable-nls.
+./configure --help | grep ' --disable-nls ' >/dev/null
+
+# Check that --enable-nls causes USE_NLS to be yes.
+./configure --enable-nls
+make check-USE_NLS-yes
 
-$MAKE install
-test -f inst/etc/mumble
-test -f good
+make distclean
 
-:
+# Check that --disable-nls causes USE_NLS to be no.
+./configure --disable-nls
+make check-USE_NLS-no
diff --git a/tests/condhook2.test b/tests/pot-enable2.test
old mode 100755
new mode 100644
similarity index 57%
copy from tests/condhook2.test
copy to tests/pot-enable2.test
index 45e2d43..02bde5b
--- a/tests/condhook2.test
+++ b/tests/pot-enable2.test
@@ -1,4 +1,4 @@
-#!/bin/sh
+#! /bin/sh
 # Copyright (C) 2010 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -14,36 +14,39 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test install when a conditional install-*-hook is defined.
-# Keep this in sync with sister test condhook.test.
+# Check that when the AM_NLS macro is used, the --enable-nls and
+# --disable-nls options determine the value of USE_NLS, and
+# --help advertises --disable-nls.
 
 . ./defs || Exit 1
 
 set -e
 
-cat >> configure.in << 'END'
-AM_CONDITIONAL([TEST], [true])
-AC_OUTPUT
-END
-
 cat > Makefile.am << 'END'
-sysconf_DATA = mumble
-if TEST
-install-data-hook:
-       : > $(top_srcdir)/good
-endif
+check-USE_NLS-yes:
+       test "@USE_NLS@" = yes
+check-USE_NLS-no:
+       test "@USE_NLS@" = no
 END
 
-: > mumble
+cat >> configure.in << 'END'
+AM_NLS
+AC_OUTPUT
+END
 
 $ACLOCAL
+$AUTOMAKE -a
 $AUTOCONF
-$AUTOMAKE
 
-./configure --prefix "`pwd`/inst"
+# Check that the --help output advertises --disable-nls.
+./configure --help | grep ' --disable-nls ' >/dev/null
+
+# Check that --enable-nls causes USE_NLS to be yes.
+./configure --enable-nls
+make check-USE_NLS-yes
 
-$MAKE install
-test -f inst/etc/mumble
-test -f good
+make distclean
 
-:
+# Check that --disable-nls causes USE_NLS to be no.
+./configure --disable-nls
+make check-USE_NLS-no
diff --git a/tests/pot-format-csharp1.test b/tests/pot-format-csharp1.test
new file mode 100644
index 0000000..8c7f6c7
--- /dev/null
+++ b/tests/pot-format-csharp1.test
@@ -0,0 +1,223 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check the creation of compiled message catalogs in C# format.
+
+required='gzip'
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+pkglibdir = $(libdir)/$(PACKAGE)
+pkglib_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/main.cs
+posub_foo_bar_pot_LINGUAS = de address@hidden
+posub_foo_bar_pot_CATALOGFORMAT = resources.dll
+EXTRA_DIST = src/main.cs
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/main.cs << 'END'
+using System; /* String, Console */
+using GNU.Gettext; /* GettextResourceManager */
+public class Hello {
+  public static void Main (String[] args) {
+    GettextResourceManager catalog =
+      new GettextResourceManager("foo-bar");
+    Console.WriteLine(catalog.GetString("Hello, world!"));
+  }
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+# .po files for _LINGUAS.
+mkdir posub
+cat > posub/foo-bar-de.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Hallo Welt!"
+END
+cat > posub/address@hidden << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Salut, le monde!"
+END
+
+# A .po file not listed among _LINGUAS, and a junk .resources.dll file.
+cat > posub/foo-bar-es.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Adiós, mundo!"
+END
+mkdir posub/es
+cat > posub/es/foo-bar.resources.dll << 'END'
+junk
+END
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-format-csharp1 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.cs:7
+msgid "Hello, world!"
+msgstr ""
+END
+
+for builddir in . sub; do
+  for config_options in '' 'LINGUAS="es de"'; do
+    if test $builddir = '.'; then
+      sourcedir='.'
+    else
+      sourcedir='..'
+      mkdir $builddir
+    fi
+    instdir="`pwd`/instdir"
+    cd $builddir
+    env $config_options $sourcedir/configure --prefix="$instdir"
+    make
+
+    # Check that "make install" creates the expected .pot file, .po files
+    # and .resources.dll files.
+    # (They are created under $sourcedir, because the files are distributed.
+    # Cf. the GNU standards, node "Makefile Basics".)
+
+    make install
+
+    test -f $sourcedir/posub/foo-bar.pot
+    test $builddir = '.' || test ! -f posub/foo-bar.pot
+    cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C 
tr -d '\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/posub/foo-bar-de.po
+    test ! -f $sourcedir/posub/foo-bar-de.resources.dll
+    test -f $sourcedir/posub/de/foo-bar.resources.dll
+    test -f $sourcedir/posub/address@hidden
+    test ! -f $sourcedir/posub/address@hidden
+    test -f $sourcedir/posub/fr-CA-Latn/foo-bar.resources.dll
+    test ! -f $sourcedir/posub/foo-bar-de.mo
+    test ! -f $sourcedir/posub/address@hidden
+
+    if test -z "$config_options"; then
+      # Check that "make install" installed de,po and address@hidden but not 
es.po.
+      test -f "$instdir"/lib/pot-format-csharp1/de/foo-bar.resources.dll
+      test -f 
"$instdir"/lib/pot-format-csharp1/fr-CA-Latn/foo-bar.resources.dll
+      test ! -f "$instdir"/lib/pot-format-csharp1/es/foo-bar.resources.dll
+    else
+      # Check that "make install" installed de.po but not address@hidden nor 
es.po.
+      test -f "$instdir"/lib/pot-format-csharp1/de/foo-bar.resources.dll
+      test ! -f 
"$instdir"/lib/pot-format-csharp1/fr-CA-Latn/foo-bar.resources.dll
+      test ! -f "$instdir"/lib/pot-format-csharp1/es/foo-bar.resources.dll
+    fi
+    test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.resources.dll
+    test ! -f 
"$instdir"/share/locale/address@hidden/LC_MESSAGES/foo-bar.resources.dll
+    test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.resources.dll
+    test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo
+    test ! -f "$instdir"/share/locale/address@hidden/LC_MESSAGES/foo-bar.mo
+    test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo
+
+    # Check that "make dist" creates the expected .pot file.
+
+    rm -f $sourcedir/posub/foo-bar.pot
+
+    make dist
+
+    test -f $sourcedir/posub/foo-bar.pot
+    test $builddir = '.' || test ! -f posub/foo-bar.pot
+    cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C 
tr -d '\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/posub/foo-bar-de.po
+    test ! -f $sourcedir/posub/foo-bar-de.resources.dll
+    test -f $sourcedir/posub/de/foo-bar.resources.dll
+    test -f $sourcedir/posub/address@hidden
+    test ! -f $sourcedir/posub/address@hidden
+    test -f $sourcedir/posub/fr-CA-Latn/foo-bar.resources.dll
+    test ! -f $sourcedir/posub/foo-bar-de.mo
+    test ! -f $sourcedir/posub/address@hidden
+
+    # Check that the tarball contains posub/foo-bar-{de,fr}.{po,resources.dll}
+    # but not the others, regardless whether LINGUAS was specified or not.
+    gzip -d -c < pot-format-csharp1-1.0.tar.gz | tar tf - > filelist
+    grep '^pot-format-csharp1-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null
+    grep '^pot-format-csharp1-1\.0/posub/de/foo-bar\.resources.dll$' filelist 
>/dev/null
+    grep '^pot-format-csharp1-1\.0/posub/address@hidden' filelist >/dev/null
+    grep '^pot-format-csharp1-1\.0/posub/fr-CA-Latn/foo-bar\.resources.dll$' 
filelist >/dev/null
+    if grep '^pot-format-csharp1-1\.0/posub/foo-bar-es\.po$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-csharp1-1\.0/posub/es/foo-bar\.resources.dll$' 
filelist >/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-csharp1-1\.0/posub/foo-bar-de\.mo$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-csharp1-1\.0/posub/address@hidden' filelist 
>/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-csharp1-1\.0/posub/foo-bar-es\.mo$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    rm -f filelist
+
+    # Sanity check.
+    make distcheck
+
+    # Clean up.
+    make distclean
+    rm -rf "$instdir"
+    cd $sourcedir
+  done
+done
diff --git a/tests/pot-format-java1.test b/tests/pot-format-java1.test
new file mode 100644
index 0000000..6a9259b
--- /dev/null
+++ b/tests/pot-format-java1.test
@@ -0,0 +1,224 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check the creation of compiled message catalogs in Java .properties format.
+# FIXME: Resource names with a dash maybe don't work. If so, it should be
+#        mentioned in the documentation.
+
+required='gzip'
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+pkgresourcesdir = $(pkgdatadir)/resources
+pkgresources_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/Hello.java
+posub_foo_bar_pot_LINGUAS = de fr
+posub_foo_bar_pot_CATALOGFORMAT = properties
+EXTRA_DIST = src/Hello.java
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/Hello.java << 'END'
+import java.util.*;
+import gnu.gettext.*;
+
+public class Hello {
+  public static void main (String[] args) {
+    ResourceBundle catalog = ResourceBundle.getBundle("foo-bar");
+    System.out.println(GettextResource.gettext(catalog,"Hello, world!"));
+  }
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+# .po files for _LINGUAS.
+mkdir posub
+cat > posub/foo-bar-de.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Hallo Welt!"
+END
+cat > posub/foo-bar-fr.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Salut, le monde!"
+END
+
+# A .po file not listed among _LINGUAS, and a junk .properties file.
+cat > posub/foo-bar-es.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Adiós, mundo!"
+END
+cat > posub/foo-bar-es.properties << 'END'
+junk
+END
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-format-java1 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/Hello.java:7
+msgid "Hello, world!"
+msgstr ""
+END
+
+for builddir in . sub; do
+  for config_options in '' 'LINGUAS="es de"'; do
+    if test $builddir = '.'; then
+      sourcedir='.'
+    else
+      sourcedir='..'
+      mkdir $builddir
+    fi
+    instdir="`pwd`/instdir"
+    cd $builddir
+    env $config_options $sourcedir/configure --prefix="$instdir"
+    make
+
+    # Check that "make install" creates the expected .pot file, .po files
+    # and .properties files.
+    # (They are created under $sourcedir, because the files are distributed.
+    # Cf. the GNU standards, node "Makefile Basics".)
+
+    make install
+
+    test -f $sourcedir/posub/foo-bar.pot
+    test $builddir = '.' || test ! -f posub/foo-bar.pot
+    cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C 
tr -d '\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/posub/foo-bar-de.po
+    test ! -f $sourcedir/posub/foo-bar-de.properties
+    test -f $sourcedir/posub/foo-bar_de.properties
+    test -f $sourcedir/posub/foo-bar-fr.po
+    test ! -f $sourcedir/posub/foo-bar-fr.properties
+    test -f $sourcedir/posub/foo-bar_fr.properties
+    test ! -f $sourcedir/posub/foo-bar-de.mo
+    test ! -f $sourcedir/posub/foo-bar-fr.mo
+
+    if test -z "$config_options"; then
+      # Check that "make install" installed de,po and fr.po but not es.po.
+      test -f "$instdir"/share/pot-format-java1/resources/foo-bar_de.properties
+      test -f "$instdir"/share/pot-format-java1/resources/foo-bar_fr.properties
+      test ! -f 
"$instdir"/share/pot-format-java1/resources/foo-bar_es.properties
+    else
+      # Check that "make install" installed de.po but not fr.po nor es.po.
+      test -f "$instdir"/share/pot-format-java1/resources/foo-bar_de.properties
+      test ! -f 
"$instdir"/share/pot-format-java1/resources/foo-bar_fr.properties
+      test ! -f 
"$instdir"/share/pot-format-java1/resources/foo-bar_es.properties
+    fi
+    test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.properties
+    test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.properties
+    test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.properties
+    test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo
+    test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo
+    test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo
+
+    # Check that "make dist" creates the expected .pot file.
+
+    rm -f $sourcedir/posub/foo-bar.pot
+
+    make dist
+
+    test -f $sourcedir/posub/foo-bar.pot
+    test $builddir = '.' || test ! -f posub/foo-bar.pot
+    cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C 
tr -d '\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/posub/foo-bar-de.po
+    test ! -f $sourcedir/posub/foo-bar-de.properties
+    test -f $sourcedir/posub/foo-bar_de.properties
+    test -f $sourcedir/posub/foo-bar-fr.po
+    test ! -f $sourcedir/posub/foo-bar-fr.properties
+    test -f $sourcedir/posub/foo-bar_fr.properties
+    test ! -f $sourcedir/posub/foo-bar-de.mo
+    test ! -f $sourcedir/posub/foo-bar-fr.mo
+
+    # Check that the tarball contains posub/foo-bar-{de,fr}.{po,properties}
+    # but not the others, regardless whether LINGUAS was specified or not.
+    gzip -d -c < pot-format-java1-1.0.tar.gz | tar tf - > filelist
+    grep '^pot-format-java1-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null
+    grep '^pot-format-java1-1\.0/posub/foo-bar_de\.properties$' filelist 
>/dev/null
+    grep '^pot-format-java1-1\.0/posub/foo-bar-fr\.po$' filelist >/dev/null
+    grep '^pot-format-java1-1\.0/posub/foo-bar_fr\.properties$' filelist 
>/dev/null
+    if grep '^pot-format-java1-1\.0/posub/foo-bar-es\.po$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-java1-1\.0/posub/foo-bar_es\.properties$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-java1-1\.0/posub/foo-bar-de\.mo$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-java1-1\.0/posub/foo-bar-fr\.mo$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-java1-1\.0/posub/foo-bar-es\.mo$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    rm -f filelist
+
+    # Sanity check.
+    make distcheck
+
+    # Clean up.
+    make distclean
+    rm -rf "$instdir"
+    cd $sourcedir
+  done
+done
diff --git a/tests/pot-format-java2.test b/tests/pot-format-java2.test
new file mode 100644
index 0000000..e05d08c
--- /dev/null
+++ b/tests/pot-format-java2.test
@@ -0,0 +1,224 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check the creation of compiled message catalogs in Java .class format.
+# FIXME: Class names with a dash probably don't work. If so, it should be
+#        mentioned in the documentation.
+
+required='gzip'
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+pkgresourcesdir = $(pkgdatadir)/resources
+pkgresources_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/Hello.java
+posub_foo_bar_pot_LINGUAS = de fr
+posub_foo_bar_pot_CATALOGFORMAT = class
+EXTRA_DIST = src/Hello.java
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/Hello.java << 'END'
+import java.util.*;
+import gnu.gettext.*;
+
+public class Hello {
+  public static void main (String[] args) {
+    ResourceBundle catalog = ResourceBundle.getBundle("foo-bar");
+    System.out.println(GettextResource.gettext(catalog,"Hello, world!"));
+  }
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+# .po files for _LINGUAS.
+mkdir posub
+cat > posub/foo-bar-de.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Hallo Welt!"
+END
+cat > posub/foo-bar-fr.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Salut, le monde!"
+END
+
+# A .po file not listed among _LINGUAS, and a junk .class file.
+cat > posub/foo-bar-es.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Adiós, mundo!"
+END
+cat > posub/foo-bar-es.class << 'END'
+junk
+END
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-format-java2 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/Hello.java:7
+msgid "Hello, world!"
+msgstr ""
+END
+
+for builddir in . sub; do
+  for config_options in '' 'LINGUAS="es de"'; do
+    if test $builddir = '.'; then
+      sourcedir='.'
+    else
+      sourcedir='..'
+      mkdir $builddir
+    fi
+    instdir="`pwd`/instdir"
+    cd $builddir
+    env $config_options $sourcedir/configure --prefix="$instdir"
+    make
+
+    # Check that "make install" creates the expected .pot file, .po files
+    # and .class files.
+    # (They are created under $sourcedir, because the files are distributed.
+    # Cf. the GNU standards, node "Makefile Basics".)
+
+    make install
+
+    test -f $sourcedir/posub/foo-bar.pot
+    test $builddir = '.' || test ! -f posub/foo-bar.pot
+    cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C 
tr -d '\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/posub/foo-bar-de.po
+    test ! -f $sourcedir/posub/foo-bar-de.class
+    test -f $sourcedir/posub/foo-bar_de.class
+    test -f $sourcedir/posub/foo-bar-fr.po
+    test ! -f $sourcedir/posub/foo-bar-fr.class
+    test -f $sourcedir/posub/foo-bar_fr.class
+    test ! -f $sourcedir/posub/foo-bar-de.mo
+    test ! -f $sourcedir/posub/foo-bar-fr.mo
+
+    if test -z "$config_options"; then
+      # Check that "make install" installed de,po and fr.po but not es.po.
+      test -f "$instdir"/share/pot-format-java2/resources/foo-bar_de.class
+      test -f "$instdir"/share/pot-format-java2/resources/foo-bar_fr.class
+      test ! -f "$instdir"/share/pot-format-java2/resources/foo-bar_es.class
+    else
+      # Check that "make install" installed de.po but not fr.po nor es.po.
+      test -f "$instdir"/share/pot-format-java2/resources/foo-bar_de.class
+      test ! -f "$instdir"/share/pot-format-java2/resources/foo-bar_fr.class
+      test ! -f "$instdir"/share/pot-format-java2/resources/foo-bar_es.class
+    fi
+    test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.class
+    test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.class
+    test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.class
+    test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo
+    test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo
+    test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo
+
+    # Check that "make dist" creates the expected .pot file.
+
+    rm -f $sourcedir/posub/foo-bar.pot
+
+    make dist
+
+    test -f $sourcedir/posub/foo-bar.pot
+    test $builddir = '.' || test ! -f posub/foo-bar.pot
+    cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C 
tr -d '\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/posub/foo-bar-de.po
+    test ! -f $sourcedir/posub/foo-bar-de.class
+    test -f $sourcedir/posub/foo-bar_de.class
+    test -f $sourcedir/posub/foo-bar-fr.po
+    test ! -f $sourcedir/posub/foo-bar-fr.class
+    test -f $sourcedir/posub/foo-bar_fr.class
+    test ! -f $sourcedir/posub/foo-bar-de.mo
+    test ! -f $sourcedir/posub/foo-bar-fr.mo
+
+    # Check that the tarball contains posub/foo-bar-{de,fr}.{po,class} but not
+    # the others, regardless whether LINGUAS was specified or not.
+    gzip -d -c < pot-format-java2-1.0.tar.gz | tar tf - > filelist
+    grep '^pot-format-java2-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null
+    grep '^pot-format-java2-1\.0/posub/foo-bar_de\.class$' filelist >/dev/null
+    grep '^pot-format-java2-1\.0/posub/foo-bar-fr\.po$' filelist >/dev/null
+    grep '^pot-format-java2-1\.0/posub/foo-bar_fr\.class$' filelist >/dev/null
+    if grep '^pot-format-java2-1\.0/posub/foo-bar-es\.po$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-java2-1\.0/posub/foo-bar_es\.class$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-java2-1\.0/posub/foo-bar-de\.mo$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-java2-1\.0/posub/foo-bar-fr\.mo$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-java2-1\.0/posub/foo-bar-es\.mo$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    rm -f filelist
+
+    # Sanity check.
+    make distcheck
+
+    # Clean up.
+    make distclean
+    rm -rf "$instdir"
+    cd $sourcedir
+  done
+done
diff --git a/tests/pot-format-qt1.test b/tests/pot-format-qt1.test
new file mode 100644
index 0000000..797a347
--- /dev/null
+++ b/tests/pot-format-qt1.test
@@ -0,0 +1,244 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check the creation of compiled message catalogs in Qt format.
+
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+pkglocaledir = $(pkgdatadir)/locale
+pkglocale_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/main.cc
+posub_foo_bar_pot_XGETTEXT_OPTIONS = \
+  --qt \
+  --keyword=translate:2 \
+    --flag=translate:2:pass-c-format \
+    --flag=translate:2:pass-qt-format \
+  --keyword=_ \
+    --flag=_:1:pass-c-format \
+    --flag=_:1:pass-qt-format
+posub_foo_bar_pot_LINGUAS = de fr
+posub_foo_bar_pot_CATALOGFORMAT = qm
+AM_CPPFLAGS = -DPKGLOCALEDIR=\"$(pkglocaledir)\"
+EXTRA_DIST = src/main.cc
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/main.cc << 'END'
+#include <qapplication.h>
+#include <qmainwindow.h>
+#include <qlabel.h>
+#include <qstring.h>
+#include <qvbox.h>
+#include <qtextcodec.h>
+
+int
+main (int argc, char *argv[])
+{
+  QApplication application (argc, argv);
+  QTranslator *translator = new QTranslator (NULL);
+  translator->load (QString ("foo-bar") + "_" + QTextCodec::locale(),
+                    PKGLOCALEDIR);
+  application.installTranslator (translator);
+#define _(string) application.translate ("", string)
+  QMainWindow *window = new QMainWindow ();
+  window->setCaption ("Hello example");
+  QVBox *panel = new QVBox (window);
+  panel->setSpacing (2);
+  QLabel *label1 = new QLabel (_("Hello, world!"), panel);
+  panel->resize (panel->sizeHint ());
+  window->resize (panel->frameSize ());
+  application.setMainWidget (window);
+  window->show ();
+  return application.exec ();
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+# .po files for _LINGUAS.
+mkdir posub
+cat > posub/foo-bar-de.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Hallo Welt!"
+END
+cat > posub/foo-bar-fr.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Salut, le monde!"
+END
+
+# A .po file not listed among _LINGUAS, and a junk .qm file.
+cat > posub/foo-bar-es.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Adiós, mundo!"
+END
+cat > posub/foo-bar-es.qm << 'END'
+junk
+END
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-format-qt1 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.cc:21
+msgid "Hello, world!"
+msgstr ""
+END
+
+for builddir in . sub; do
+  for config_options in '' 'LINGUAS="es de"'; do
+    if test $builddir = '.'; then
+      sourcedir='.'
+    else
+      sourcedir='..'
+      mkdir $builddir
+    fi
+    instdir="`pwd`/instdir"
+    cd $builddir
+    env $config_options $sourcedir/configure --prefix="$instdir"
+    make
+
+    # Check that "make install" creates the expected .pot file, .po files
+    # and .qm files.
+    # (They are created under $sourcedir, because the files are distributed.
+    # Cf. the GNU standards, node "Makefile Basics".)
+
+    make install
+
+    test -f $sourcedir/posub/foo-bar.pot
+    test $builddir = '.' || test ! -f posub/foo-bar.pot
+    cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C 
tr -d '\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/posub/foo-bar-de.po
+    test -f $sourcedir/posub/foo-bar-de.qm
+    test -f $sourcedir/posub/foo-bar-fr.po
+    test -f $sourcedir/posub/foo-bar-fr.qm
+    test ! -f $sourcedir/posub/foo-bar-de.mo
+    test ! -f $sourcedir/posub/foo-bar-fr.mo
+
+    if test -z "$config_options"; then
+      # Check that "make install" installed de,po and fr.po but not es.po.
+      test -f "$instdir"/share/pot-format-qt1/locale/foo-bar_de.qm
+      test -f "$instdir"/share/pot-format-qt1/locale/foo-bar_fr.qm
+      test ! -f "$instdir"/share/pot-format-qt1/locale/foo-bar_es.qm
+    else
+      # Check that "make install" installed de.po but not fr.po nor es.po.
+      test -f "$instdir"/share/pot-format-qt1/locale/foo-bar_de.qm
+      test ! -f "$instdir"/share/pot-format-qt1/locale/foo-bar_fr.qm
+      test ! -f "$instdir"/share/pot-format-qt1/locale/foo-bar_es.qm
+    fi
+    test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.qm
+    test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.qm
+    test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.qm
+    test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo
+    test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo
+    test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo
+
+    # Check that "make dist" creates the expected .pot file.
+
+    rm -f $sourcedir/posub/foo-bar.pot
+
+    make dist
+
+    test -f $sourcedir/posub/foo-bar.pot
+    test $builddir = '.' || test ! -f posub/foo-bar.pot
+    cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C 
tr -d '\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/posub/foo-bar-de.po
+    test -f $sourcedir/posub/foo-bar-de.qm
+    test -f $sourcedir/posub/foo-bar-fr.po
+    test -f $sourcedir/posub/foo-bar-fr.qm
+    test ! -f $sourcedir/posub/foo-bar-de.mo
+    test ! -f $sourcedir/posub/foo-bar-fr.mo
+
+    # Check that the tarball contains posub/foo-bar-{de,fr}.{po,qm} but not
+    # the others, regardless whether LINGUAS was specified or not.
+    gzip -d -c < pot-format-qt1-1.0.tar.gz | tar tf - > filelist
+    grep '^pot-format-qt1-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null
+    grep '^pot-format-qt1-1\.0/posub/foo-bar-de\.qm$' filelist >/dev/null
+    grep '^pot-format-qt1-1\.0/posub/foo-bar-fr\.po$' filelist >/dev/null
+    grep '^pot-format-qt1-1\.0/posub/foo-bar-fr\.qm$' filelist >/dev/null
+    if grep '^pot-format-qt1-1\.0/posub/foo-bar-es\.po$' filelist >/dev/null; 
then
+      exit 1
+    fi
+    if grep '^pot-format-qt1-1\.0/posub/foo-bar-es\.qm$' filelist >/dev/null; 
then
+      exit 1
+    fi
+    if grep '^pot-format-qt1-1\.0/posub/foo-bar-de\.mo$' filelist >/dev/null; 
then
+      exit 1
+    fi
+    if grep '^pot-format-qt1-1\.0/posub/foo-bar-fr\.mo$' filelist >/dev/null; 
then
+      exit 1
+    fi
+    if grep '^pot-format-qt1-1\.0/posub/foo-bar-es\.mo$' filelist >/dev/null; 
then
+      exit 1
+    fi
+    rm -f filelist
+
+    # Sanity check.
+    make distcheck
+
+    # Clean up.
+    make distclean
+    rm -rf "$instdir"
+    cd $sourcedir
+  done
+done
diff --git a/tests/pot-format-tcl1.test b/tests/pot-format-tcl1.test
new file mode 100644
index 0000000..109245e
--- /dev/null
+++ b/tests/pot-format-tcl1.test
@@ -0,0 +1,219 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check the creation of compiled message catalogs in Tcl format.
+
+required='gzip'
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+pkgmsgsdir = $(pkgdatadir)/msgs
+pkgmsgs_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/main.tcl
+posub_foo_bar_pot_XGETTEXT_OPTIONS = --keyword=_ --flag=_:1:pass-tcl-format
+posub_foo_bar_pot_LINGUAS = de fr_CA
+posub_foo_bar_pot_CATALOGFORMAT = msg
+EXTRA_DIST = src/main.tcl
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/main.tcl << 'END'
+package require msgcat
+::msgcat::mcload [file join "/usr/share/pot-format-tcl1" "msgs" "foo-bar"]
+proc _ {s} {return [::msgcat::mc $s]}
+
+puts [_ "Hello, world!"]
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+# .po files for _LINGUAS.
+mkdir posub
+cat > posub/foo-bar-de.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Hallo Welt!"
+END
+cat > posub/foo-bar-fr_CA.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Salut, le monde!"
+END
+
+# A .po file not listed among _LINGUAS, and a junk .msg file.
+cat > posub/foo-bar-es.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world!"
+msgstr "Adiós, mundo!"
+END
+cat > posub/foo-bar-es.msg << 'END'
+junk
+END
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-format-tcl1 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.tcl:5
+msgid "Hello, world!"
+msgstr ""
+END
+
+for builddir in . sub; do
+  for config_options in '' 'LINGUAS="es de"'; do
+    if test $builddir = '.'; then
+      sourcedir='.'
+    else
+      sourcedir='..'
+      mkdir $builddir
+    fi
+    instdir="`pwd`/instdir"
+    cd $builddir
+    env $config_options $sourcedir/configure --prefix="$instdir"
+    make
+
+    # Check that "make install" creates the expected .pot file, .po files
+    # and .msg files.
+    # (They are created under $sourcedir, because the files are distributed.
+    # Cf. the GNU standards, node "Makefile Basics".)
+
+    make install
+
+    test -f $sourcedir/posub/foo-bar.pot
+    test $builddir = '.' || test ! -f posub/foo-bar.pot
+    cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C 
tr -d '\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/posub/foo-bar-de.po
+    test ! -f $sourcedir/posub/foo-bar-de.msg
+    test -f $sourcedir/posub/foo-bar/de.msg
+    test -f $sourcedir/posub/foo-bar-fr_CA.po
+    test ! -f $sourcedir/posub/foo-bar-fr_CA.msg
+    test -f $sourcedir/posub/foo-bar/fr_ca.msg
+    test ! -f $sourcedir/posub/foo-bar-de.mo
+    test ! -f $sourcedir/posub/foo-bar-fr_CA.mo
+
+    if test -z "$config_options"; then
+      # Check that "make install" installed de,po and fr_CA.po but not es.po.
+      test -f "$instdir"/share/pot-format-tcl1/msgs/foo-bar/de.msg
+      test -f "$instdir"/share/pot-format-tcl1/msgs/foo-bar/fr_ca.msg
+      test ! -f "$instdir"/share/pot-format-tcl1/msgs/foo-bar/es.msg
+    else
+      # Check that "make install" installed de.po but not fr_CA.po nor es.po.
+      test -f "$instdir"/share/pot-format-tcl1/msgs/foo-bar/de.msg
+      test ! -f "$instdir"/share/pot-format-tcl1/msgs/foo-bar/fr_ca.msg
+      test ! -f "$instdir"/share/pot-format-tcl1/msgs/foo-bar/es.msg
+    fi
+    test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.msg
+    test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.msg
+    test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.msg
+    test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo
+    test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo
+    test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo
+
+    # Check that "make dist" creates the expected .pot file.
+
+    rm -f $sourcedir/posub/foo-bar.pot
+
+    make dist
+
+    test -f $sourcedir/posub/foo-bar.pot
+    test $builddir = '.' || test ! -f posub/foo-bar.pot
+    cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C 
tr -d '\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/posub/foo-bar-de.po
+    test ! -f $sourcedir/posub/foo-bar-de.msg
+    test -f $sourcedir/posub/foo-bar/de.msg
+    test -f $sourcedir/posub/foo-bar-fr_CA.po
+    test ! -f $sourcedir/posub/foo-bar-fr_CA.msg
+    test -f $sourcedir/posub/foo-bar/fr_ca.msg
+    test ! -f $sourcedir/posub/foo-bar-de.mo
+    test ! -f $sourcedir/posub/foo-bar-fr_CA.mo
+
+    # Check that the tarball contains posub/foo-bar-{de,fr}.{po,msg} but not
+    # the others, regardless whether LINGUAS was specified or not.
+    gzip -d -c < pot-format-tcl1-1.0.tar.gz | tar tf - > filelist
+    grep '^pot-format-tcl1-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null
+    grep '^pot-format-tcl1-1\.0/posub/foo-bar/de\.msg$' filelist >/dev/null
+    grep '^pot-format-tcl1-1\.0/posub/foo-bar-fr_CA\.po$' filelist >/dev/null
+    grep '^pot-format-tcl1-1\.0/posub/foo-bar/fr_ca\.msg$' filelist >/dev/null
+    if grep '^pot-format-tcl1-1\.0/posub/foo-bar-es\.po$' filelist >/dev/null; 
then
+      exit 1
+    fi
+    if grep '^pot-format-tcl1-1\.0/posub/foo-bar/es\.msg$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-tcl1-1\.0/posub/foo-bar-de\.mo$' filelist >/dev/null; 
then
+      exit 1
+    fi
+    if grep '^pot-format-tcl1-1\.0/posub/foo-bar-fr_CA\.mo$' filelist 
>/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-format-tcl1-1\.0/posub/foo-bar-es\.mo$' filelist >/dev/null; 
then
+      exit 1
+    fi
+    rm -f filelist
+
+    # Sanity check.
+    make distcheck
+
+    # Clean up.
+    make distclean
+    rm -rf "$instdir"
+    cd $sourcedir
+  done
+done
diff --git a/tests/pot-linguas.test b/tests/pot-linguas.test
new file mode 100644
index 0000000..428152b
--- /dev/null
+++ b/tests/pot-linguas.test
@@ -0,0 +1,286 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that when the _LINGUAS variable is specified, the POT file gets created
+# and the .mo files for the listed languages get installed, but no .mo files
+# for other languages get installed.  Check that the POT file and PO files and
+# MO files get updated by "make install" and "make dist" (but not by "make"!)
+# when some of the source files is changed.
+# FIXME: Should "make install" really update the PO files and MO files?
+#        Current po/Makefile.in.in does not do it.
+
+required='gzip'
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/main.c src/util.c
+posub_foo_bar_pot_LINGUAS = de fr
+EXTRA_DIST = src/main.c src/util.c
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/util.c << 'END'
+#include <stdio.h>
+void usage ()
+{
+  puts (gettext ("See the documentation for details."));
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+# .po files for _LINGUAS.
+mkdir posub
+cat > posub/foo-bar-de.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format
+msgid "Hello, world.\n"
+msgstr "Hallo, Welt.\n"
+END
+cat > posub/foo-bar-fr.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format
+msgid "Hello, world.\n"
+msgstr "Salut, le monde.\n"
+END
+
+# A .po file not listed among _LINGUAS, and a junk .mo file.
+cat > posub/foo-bar-es.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format
+msgid "Hello, world.\n"
+msgstr "Adiós, mundo.\n"
+END
+cat > posub/foo-bar-es.mo << 'END'
+junk
+END
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-linguas 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.c:4
+#, c-format
+msgid "Hello, world.\n"
+msgstr ""
+
+#: src/util.c:4
+msgid "See the documentation for details."
+msgstr ""
+END
+
+for builddir in . sub; do
+  for config_options in '' 'LINGUAS="es de"'; do
+    if test $builddir = '.'; then
+      sourcedir='.'
+    else
+      sourcedir='..'
+      mkdir $builddir
+    fi
+    instdir="`pwd`/instdir"
+    cd $builddir
+    env $config_options $sourcedir/configure --prefix="$instdir"
+    make
+
+    cat > $sourcedir/src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, world.\n"));
+  return 0;
+}
+END
+
+    # Check that "make install" creates the expected .pot file, .po files
+    # and .mo files.
+    # (They are created under $sourcedir, because the files are distributed.
+    # Cf. the GNU standards, node "Makefile Basics".)
+
+    make install
+
+    test -f $sourcedir/posub/foo-bar.pot
+    test $builddir = '.' || test ! -f posub/foo-bar.pot
+    cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C 
tr -d '\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/posub/foo-bar-de.po
+    test -f $sourcedir/posub/foo-bar-de.mo
+    test -f $sourcedir/posub/foo-bar-fr.po
+    test -f $sourcedir/posub/foo-bar-fr.mo
+
+    if test -z "$config_options"; then
+      # Check that "make install" installed de,po and fr.po but not es.po.
+      test -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo
+      test -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo
+      test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo
+    else
+      # Check that "make install" installed de.po but not fr.po nor es.po.
+      test -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo
+      test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo
+      test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo
+    fi
+
+    # Check that "make dist" creates the expected .pot file.
+
+    rm -f $sourcedir/posub/foo-bar.pot
+
+    make dist
+
+    test -f $sourcedir/posub/foo-bar.pot
+    test $builddir = '.' || test ! -f posub/foo-bar.pot
+    cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C 
tr -d '\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/posub/foo-bar-de.po
+    test -f $sourcedir/posub/foo-bar-de.mo
+    test -f $sourcedir/posub/foo-bar-fr.po
+    test -f $sourcedir/posub/foo-bar-fr.mo
+
+    # Check that the tarball contains posub/foo-bar-{de,fr}.{po,mo} but not
+    # the others, regardless whether LINGUAS was specified or not.
+    gzip -d -c < pot-linguas-1.0.tar.gz | tar tf - > filelist
+    grep '^pot-linguas-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null
+    grep '^pot-linguas-1\.0/posub/foo-bar-de\.mo$' filelist >/dev/null
+    grep '^pot-linguas-1\.0/posub/foo-bar-fr\.po$' filelist >/dev/null
+    grep '^pot-linguas-1\.0/posub/foo-bar-fr\.mo$' filelist >/dev/null
+    if grep '^pot-linguas-1\.0/posub/foo-bar-es\.po$' filelist >/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-linguas-1\.0/posub/foo-bar-es\.mo$' filelist >/dev/null; then
+      exit 1
+    fi
+    rm -f filelist
+
+    # Try modifying a source file.
+    cat > $sourcedir/src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, great world!\n"));
+  return 0;
+}
+END
+
+    # Check that "make" does not rebuild the POT file, the PO files, and the
+    # MO files.
+    cp -p $sourcedir/posub/foo-bar.pot $sourcedir/posub/foo-bar.potbak
+    cp -p $sourcedir/posub/foo-bar-de.po $sourcedir/posub/foo-bar-de.pobak
+    cp -p $sourcedir/posub/foo-bar-de.mo $sourcedir/posub/foo-bar-de.mobak
+    cp -p $sourcedir/posub/foo-bar-fr.po $sourcedir/posub/foo-bar-fr.pobak
+    cp -p $sourcedir/posub/foo-bar-fr.mo $sourcedir/posub/foo-bar-fr.mobak
+    cp -p $sourcedir/posub/foo-bar-es.po $sourcedir/posub/foo-bar-es.pobak
+    cp -p $sourcedir/posub/foo-bar-es.mo $sourcedir/posub/foo-bar-es.mobak
+    make
+    diff $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot
+    cmp $sourcedir/posub/foo-bar-de.pobak $sourcedir/posub/foo-bar-de.po 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-fr.pobak $sourcedir/posub/foo-bar-fr.po 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-es.pobak $sourcedir/posub/foo-bar-es.po 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-es.mobak $sourcedir/posub/foo-bar-es.mo 
>/dev/null
+
+    # Check that "make install" updates the POT file, the PO files, and the
+    # MO files listed in the _LINGUAS variable, regardless whether LINGUAS
+    # was specified or not.
+    make install
+    cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null
+    cat $sourcedir/posub/foo-bar-de.po | grep great >/dev/null
+    if cmp $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo 
>/dev/null; then
+      exit 1
+    fi
+    cat $sourcedir/posub/foo-bar-fr.po | grep great >/dev/null
+    if cmp $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo 
>/dev/null; then
+      exit 1
+    fi
+    cmp $sourcedir/posub/foo-bar-es.pobak $sourcedir/posub/foo-bar-es.po 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-es.mobak $sourcedir/posub/foo-bar-es.mo 
>/dev/null
+
+    # Check that "make dist" updates the POT file, the PO files, and the
+    # MO files listed in the _LINGUAS variable, regardless whether LINGUAS
+    # was specified or not.
+    cp -p $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot
+    cp -p $sourcedir/posub/foo-bar-de.pobak $sourcedir/posub/foo-bar-de.po
+    cp -p $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo
+    cp -p $sourcedir/posub/foo-bar-fr.pobak $sourcedir/posub/foo-bar-fr.po
+    cp -p $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo
+    make dist
+    cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null
+    cat $sourcedir/posub/foo-bar-de.po | grep great >/dev/null
+    if cmp $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo 
>/dev/null; then
+      exit 1
+    fi
+    cat $sourcedir/posub/foo-bar-fr.po | grep great >/dev/null
+    if cmp $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo 
>/dev/null; then
+      exit 1
+    fi
+    cmp $sourcedir/posub/foo-bar-es.pobak $sourcedir/posub/foo-bar-es.po 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-es.mobak $sourcedir/posub/foo-bar-es.mo 
>/dev/null
+
+    # Check that the updated PO files contain 'previous msgid' fields.
+    cat $sourcedir/posub/foo-bar-de.po | grep '^#| msgid "Hello, world\.\\n"$' 
>/dev/null
+    cat $sourcedir/posub/foo-bar-fr.po | grep '^#| msgid "Hello, world\.\\n"$' 
>/dev/null
+
+    # Sanity check.
+    make distcheck
+
+    # Clean up.
+    rm -f $sourcedir/posub/foo-bar.potbak $sourcedir/posub/*.pobak 
$sourcedir/posub/*.mobak
+    make distclean
+    rm -rf "$instdir"
+    cd $sourcedir
+  done
+done
diff --git a/tests/condhook2.test b/tests/pot-macro-warn.test
old mode 100755
new mode 100644
similarity index 57%
copy from tests/condhook2.test
copy to tests/pot-macro-warn.test
index 45e2d43..41fb35f
--- a/tests/condhook2.test
+++ b/tests/pot-macro-warn.test
@@ -1,4 +1,4 @@
-#!/bin/sh
+#! /bin/sh
 # Copyright (C) 2010 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -14,36 +14,41 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test install when a conditional install-*-hook is defined.
-# Keep this in sync with sister test condhook.test.
+# Check that when the POTS primary is used, AM_POT_TOOLS must be invoked,
+# otherwise a warning occurs.
 
 . ./defs || Exit 1
 
 set -e
 
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES =
+END
+
+cp configure.in configure.in.bak
 cat >> configure.in << 'END'
-AM_CONDITIONAL([TEST], [true])
 AC_OUTPUT
 END
 
-cat > Makefile.am << 'END'
-sysconf_DATA = mumble
-if TEST
-install-data-hook:
-       : > $(top_srcdir)/good
-endif
-END
+$ACLOCAL
 
-: > mumble
+# Check that there is a warning about the missing AM_POT_TOOLS invocation.
 
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE
+AUTOMAKE_fails -Werror
+grep 'POTS.*AM_POT_TOOLS.*invoked' stderr
 
-./configure --prefix "`pwd`/inst"
+AUTOMAKE_run 0 -Wno-error
+grep 'POTS.*AM_POT_TOOLS.*invoked' stderr
+
+cp configure.in.bak configure.in
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+$ACLOCAL
 
-$MAKE install
-test -f inst/etc/mumble
-test -f good
+# Check that there is no warning any more.
 
-:
+AUTOMAKE_run 0 -Werror
diff --git a/tests/pot-msgidbugs.test b/tests/pot-msgidbugs.test
new file mode 100644
index 0000000..1bf5334
--- /dev/null
+++ b/tests/pot-msgidbugs.test
@@ -0,0 +1,172 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that the value of the 'Report-Msgid-Bugs-To' field in the POT file's
+# header comes from the _MSGID_BUGS_ADDRESS variable if it is specified, or
+# from the third argument of AC_INIT otherwise.
+
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/main.c
+EXTRA_DIST = src/main.c
+END
+
+# Insert an email address as third argument of the AC_INIT invocation.
+mv configure.in configure.in.bak
+sed -e '/AC_INIT/{s/)$/, address@hidden)/}' < configure.in.bak > configure.in
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, world.\n"));
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-msgidbugs 1.0\n"
+"Report-Msgid-Bugs-To: address@hidden"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.c:4
+#, c-format
+msgid "Hello, world.\n"
+msgstr ""
+END
+
+for builddir in . sub1; do
+  if test $builddir = '.'; then
+    sourcedir='.'
+  else
+    sourcedir='..'
+    mkdir $builddir
+  fi
+  instdir="`pwd`/instdir"
+  cd $builddir
+  $sourcedir/configure --prefix="$instdir"
+  make
+
+  # Check that "make dist" creates the expected .pot file.
+  # (It is created under $sourcedir, because the .pot file is distributed.
+  # Cf. the GNU standards, node "Makefile Basics".)
+
+  make dist
+
+  test -f $sourcedir/posub/foo-bar.pot
+  test $builddir = '.' || test ! -f posub/foo-bar.pot
+  cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr 
-d '\r' > actual
+  diff actual $sourcedir/expected
+  rm -f actual
+
+  # Sanity check.
+  make distcheck
+
+  # Clean up.
+  make distclean
+  rm -rf "$instdir"
+  cd $sourcedir
+done
+
+cat >> Makefile.am << 'END'
+posub_foo_bar_pot_MSGID_BUGS_ADDRESS = address@hidden
+END
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-msgidbugs 1.0\n"
+"Report-Msgid-Bugs-To: address@hidden"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.c:4
+#, c-format
+msgid "Hello, world.\n"
+msgstr ""
+END
+
+$AUTOMAKE -a
+
+for builddir in . sub2; do
+  if test $builddir = '.'; then
+    sourcedir='.'
+  else
+    sourcedir='..'
+    mkdir $builddir
+  fi
+  instdir="`pwd`/instdir"
+  cd $builddir
+  $sourcedir/configure --prefix="$instdir"
+  make
+
+  # Check that "make dist" creates the expected .pot file.
+  # (It is created under $sourcedir, because the .pot file is distributed.
+  # Cf. the GNU standards, node "Makefile Basics".)
+
+  make dist
+
+  test -f $sourcedir/posub/foo-bar.pot
+  test $builddir = '.' || test ! -f posub/foo-bar.pot
+  cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr 
-d '\r' > actual
+  diff actual $sourcedir/expected
+  rm -f actual
+
+  # Sanity check.
+  make distcheck
+
+  # Clean up.
+  make distclean
+  rm -rf "$instdir"
+  cd $sourcedir
+done
diff --git a/tests/pot-no-linguas.test b/tests/pot-no-linguas.test
new file mode 100644
index 0000000..f64588a
--- /dev/null
+++ b/tests/pot-no-linguas.test
@@ -0,0 +1,176 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that when no _LINGUAS variable is specified, the POT file gets created
+# but no .mo file gets installed.  Check that the POT file gets updated by
+# "make install" and "make dist" (but not by "make"!) when some of the source
+# files is changed.
+
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/main.c src/util.c
+EXTRA_DIST = src/main.c src/util.c
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/util.c << 'END'
+#include <stdio.h>
+void usage ()
+{
+  puts (gettext ("See the documentation for details."));
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+# A .po file not listed among LINGUAS, and a junk .mo file.
+mkdir posub
+cat > posub/foo-bar-de.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format
+msgid "Hello, world.\n"
+msgstr "Tschüss, alle\n"
+END
+cat > posub/foo-bar-de.mo << 'END'
+junk
+END
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-no-linguas 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.c:4
+#, c-format
+msgid "Hello, world.\n"
+msgstr ""
+
+#: src/util.c:4
+msgid "See the documentation for details."
+msgstr ""
+END
+
+for builddir in . sub; do
+  if test $builddir = '.'; then
+    sourcedir='.'
+  else
+    sourcedir='..'
+    mkdir $builddir
+  fi
+  instdir="`pwd`/instdir"
+  cd $builddir
+  $sourcedir/configure --prefix="$instdir"
+  make
+
+  cat > $sourcedir/src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, world.\n"));
+  return 0;
+}
+END
+
+  # Check that "make dist" creates the expected .pot file.
+  # (It is created under $sourcedir, because the .pot file is distributed.
+  # Cf. the GNU standards, node "Makefile Basics".)
+
+  make dist
+
+  test -f $sourcedir/posub/foo-bar.pot
+  test $builddir = '.' || test ! -f posub/foo-bar.pot
+  cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr 
-d '\r' > actual
+  diff actual $sourcedir/expected
+  rm -f actual
+
+  rm -f $sourcedir/posub/foo-bar.pot
+
+  # Check that "make install" creates the expected .pot file.
+
+  make install
+
+  test -f $sourcedir/posub/foo-bar.pot
+  test $builddir = '.' || test ! -f posub/foo-bar.pot
+  cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr 
-d '\r' > actual
+  diff actual $sourcedir/expected
+  rm -f actual
+
+  # Check that no .mo file was installed, although posub/foo-bar-de.po and
+  # posub/foo-bar-de.mo exist.
+  test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo
+
+  # Try modifying a source file.
+  cat > $sourcedir/src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, great world!\n"));
+  return 0;
+}
+END
+
+  # Check that "make" does not rebuild the POT file.
+  cp -p $sourcedir/posub/foo-bar.pot $sourcedir/posub/foo-bar.potbak
+  make
+  diff $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot
+
+  # Check that "make dist" updates the POT file.
+  make dist
+  cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null
+
+  # Check that "make install" updates the POT file.
+  cp -p $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot
+  make install
+  cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null
+
+  # Sanity check.
+  make distcheck
+
+  # Clean up.
+  rm -f $sourcedir/posub/foo-bar.potbak
+  make distclean
+  rm -rf "$instdir"
+  cd $sourcedir
+done
diff --git a/tests/pot-noinst.test b/tests/pot-noinst.test
new file mode 100644
index 0000000..9c1c922
--- /dev/null
+++ b/tests/pot-noinst.test
@@ -0,0 +1,258 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that when the installation directory is specified as 'noinst', nothing
+# gets installed by "make install". The LINGUAS environment variable at
+# configure time has no effect. Otherwise, everything is the same as in the
+# pot-linguas test.
+
+required='gzip'
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+noinst_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/main.c src/util.c
+posub_foo_bar_pot_LINGUAS = de fr
+EXTRA_DIST = src/main.c src/util.c
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/util.c << 'END'
+#include <stdio.h>
+void usage ()
+{
+  puts (gettext ("See the documentation for details."));
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+# .po files for _LINGUAS.
+mkdir posub
+cat > posub/foo-bar-de.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format
+msgid "Hello, world.\n"
+msgstr "Hallo, Welt.\n"
+END
+cat > posub/foo-bar-fr.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format
+msgid "Hello, world.\n"
+msgstr "Salut, le monde.\n"
+END
+
+# A .po file not listed among _LINGUAS, and a junk .mo file.
+cat > posub/foo-bar-es.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format
+msgid "Hello, world.\n"
+msgstr "Adiós, mundo.\n"
+END
+cat > posub/foo-bar-es.mo << 'END'
+junk
+END
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-noinst 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.c:4
+#, c-format
+msgid "Hello, world.\n"
+msgstr ""
+
+#: src/util.c:4
+msgid "See the documentation for details."
+msgstr ""
+END
+
+for builddir in . sub; do
+  for config_options in '' 'LINGUAS="es de"'; do
+    if test $builddir = '.'; then
+      sourcedir='.'
+    else
+      sourcedir='..'
+      mkdir $builddir
+    fi
+    instdir="`pwd`/instdir"
+    cd $builddir
+    env $config_options $sourcedir/configure --prefix="$instdir"
+    make
+
+    cat > $sourcedir/src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, world.\n"));
+  return 0;
+}
+END
+
+    # Check that "make install" does not create the .pot file and .mo files.
+    # (They are not needed for installation.)
+
+    make install
+
+    test ! -f $sourcedir/posub/foo-bar.pot
+    test ! -f $sourcedir/posub/foo-bar-de.mo
+    test ! -f $sourcedir/posub/foo-bar-fr.mo
+
+    # Check that "make install" installed none of de.po, fr.po, es.po.
+    test ! -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo
+    test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo
+    test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo
+
+    # Check that "make dist" creates the expected .pot file, .po files
+    # and .mo files.
+    # (They are created under $sourcedir, because the files are distributed.
+    # Cf. the GNU standards, node "Makefile Basics".)
+
+    make dist
+
+    test -f $sourcedir/posub/foo-bar.pot
+    test $builddir = '.' || test ! -f posub/foo-bar.pot
+    cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C 
tr -d '\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/posub/foo-bar-de.po
+    test -f $sourcedir/posub/foo-bar-de.mo
+    test -f $sourcedir/posub/foo-bar-fr.po
+    test -f $sourcedir/posub/foo-bar-fr.mo
+
+    # Check that the tarball contains posub/foo-bar-{de,fr}.{po,mo} but not
+    # the others, regardless whether LINGUAS was specified or not.
+    gzip -d -c < pot-noinst-1.0.tar.gz | tar tf - > filelist
+    grep '^pot-noinst-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null
+    grep '^pot-noinst-1\.0/posub/foo-bar-de\.mo$' filelist >/dev/null
+    grep '^pot-noinst-1\.0/posub/foo-bar-fr\.po$' filelist >/dev/null
+    grep '^pot-noinst-1\.0/posub/foo-bar-fr\.mo$' filelist >/dev/null
+    if grep '^pot-noinst-1\.0/posub/foo-bar-es\.po$' filelist >/dev/null; then
+      exit 1
+    fi
+    if grep '^pot-noinst-1\.0/posub/foo-bar-es\.mo$' filelist >/dev/null; then
+      exit 1
+    fi
+    rm -f filelist
+
+    # Try modifying a source file.
+    cat > $sourcedir/src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, great world!\n"));
+  return 0;
+}
+END
+
+    # Check that "make" does not rebuild the POT file, the PO files, and the
+    # MO files.
+    cp -p $sourcedir/posub/foo-bar.pot $sourcedir/posub/foo-bar.potbak
+    cp -p $sourcedir/posub/foo-bar-de.po $sourcedir/posub/foo-bar-de.pobak
+    cp -p $sourcedir/posub/foo-bar-de.mo $sourcedir/posub/foo-bar-de.mobak
+    cp -p $sourcedir/posub/foo-bar-fr.po $sourcedir/posub/foo-bar-fr.pobak
+    cp -p $sourcedir/posub/foo-bar-fr.mo $sourcedir/posub/foo-bar-fr.mobak
+    cp -p $sourcedir/posub/foo-bar-es.po $sourcedir/posub/foo-bar-es.pobak
+    cp -p $sourcedir/posub/foo-bar-es.mo $sourcedir/posub/foo-bar-es.mobak
+    make
+    diff $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot
+    cmp $sourcedir/posub/foo-bar-de.pobak $sourcedir/posub/foo-bar-de.po 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-fr.pobak $sourcedir/posub/foo-bar-fr.po 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-es.pobak $sourcedir/posub/foo-bar-es.po 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-es.mobak $sourcedir/posub/foo-bar-es.mo 
>/dev/null
+
+    # Check that "make install" does not update the POT file, the PO files,
+    # and the MO files.
+    make install
+    diff $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot
+    cmp $sourcedir/posub/foo-bar-de.pobak $sourcedir/posub/foo-bar-de.po 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-fr.pobak $sourcedir/posub/foo-bar-fr.po 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-es.pobak $sourcedir/posub/foo-bar-es.po 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-es.mobak $sourcedir/posub/foo-bar-es.mo 
>/dev/null
+
+    # Check that "make dist" updates the POT file, the PO files, and the
+    # MO files listed in the _LINGUAS variable, regardless whether LINGUAS
+    # was specified or not.
+    make dist
+    cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null
+    cat $sourcedir/posub/foo-bar-de.po | grep great >/dev/null
+    if cmp $sourcedir/posub/foo-bar-de.mobak $sourcedir/posub/foo-bar-de.mo 
>/dev/null; then
+      exit 1
+    fi
+    cat $sourcedir/posub/foo-bar-fr.po | grep great >/dev/null
+    if cmp $sourcedir/posub/foo-bar-fr.mobak $sourcedir/posub/foo-bar-fr.mo 
>/dev/null; then
+      exit 1
+    fi
+    cmp $sourcedir/posub/foo-bar-es.pobak $sourcedir/posub/foo-bar-es.po 
>/dev/null
+    cmp $sourcedir/posub/foo-bar-es.mobak $sourcedir/posub/foo-bar-es.mo 
>/dev/null
+
+    # Check that the updated PO files contain 'previous msgid' fields.
+    cat $sourcedir/posub/foo-bar-de.po | grep '^#| msgid "Hello, world\.\\n"$' 
>/dev/null
+    cat $sourcedir/posub/foo-bar-fr.po | grep '^#| msgid "Hello, world\.\\n"$' 
>/dev/null
+
+    # Sanity check.
+    make distcheck
+
+    # Clean up.
+    rm -f $sourcedir/posub/foo-bar.potbak $sourcedir/posub/*.pobak 
$sourcedir/posub/*.mobak
+    make distclean
+    rm -rf "$instdir"
+    cd $sourcedir
+  done
+done
diff --git a/tests/pot-override1.test b/tests/pot-override1.test
new file mode 100644
index 0000000..6389f54
--- /dev/null
+++ b/tests/pot-override1.test
@@ -0,0 +1,145 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that the rule for creating the .pot file can be overridden.
+# FIXME: Should "make install" really update the PO files and MO files?
+#        Current po/Makefile.in.in does not do it.
+
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/main.c src/util.c
+EXTRA_DIST = src/main.c src/util.c
+
+# A user-written rule that creates the POT file without xgettext.
+$(srcdir)/posub/foo-bar.pot : $(posub_foo_bar_pot_SOURCES)
+       { echo 'msgid ""'; \
+         echo 'msgstr "MIME-Version: 1.0\n"'; \
+         echo '       "Content-Type: text/plain; charset=CHARSET\n"'; \
+         echo '       "Content-Transfer-Encoding: 8bit\n"'; \
+         echo; \
+         for file in $(posub_foo_bar_pot_SOURCES); do \
+           sed -n -e 's/.*gettext *(\(".*"\)).*/msgid \1 msgstr ""/p' < 
$$file; \
+         done; \
+       } > $(srcdir)/posub/foo-bar.pot-t
+       mv $(srcdir)/posub/foo-bar.pot-t $(srcdir)/posub/foo-bar.pot
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/util.c << 'END'
+#include <stdio.h>
+void usage ()
+{
+  puts (gettext ("See the documentation for details."));
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+cat > expected << 'END'
+msgid ""
+msgstr "MIME-Version: 1.0\n"
+       "Content-Type: text/plain; charset=CHARSET\n"
+       "Content-Transfer-Encoding: 8bit\n"
+
+msgid "Hello, world.\n" msgstr ""
+msgid "See the documentation for details." msgstr ""
+END
+
+for builddir in . sub; do
+  if test $builddir = '.'; then
+    sourcedir='.'
+  else
+    sourcedir='..'
+    mkdir $builddir
+  fi
+  instdir="`pwd`/instdir"
+  cd $builddir
+  $sourcedir/configure --prefix="$instdir"
+  make
+
+  cat > $sourcedir/src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, world.\n"));
+  return 0;
+}
+END
+
+  # Check that "make dist" creates the expected .pot file.
+  # (It is created under $sourcedir, because the .pot file is distributed.
+  # Cf. the GNU standards, node "Makefile Basics".)
+
+  make dist
+
+  test -f $sourcedir/posub/foo-bar.pot
+  test $builddir = '.' || test ! -f posub/foo-bar.pot
+  diff $sourcedir/posub/foo-bar.pot $sourcedir/expected
+
+  rm -f $sourcedir/posub/foo-bar.pot
+
+  # Check that "make install" creates the expected .pot file.
+
+  make install
+
+  test -f $sourcedir/posub/foo-bar.pot
+  test $builddir = '.' || test ! -f posub/foo-bar.pot
+  diff $sourcedir/posub/foo-bar.pot $sourcedir/expected
+
+  # Try modifying a source file.
+  cat > $sourcedir/src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, great world!\n"));
+  return 0;
+}
+END
+
+  # Check that "make" does not rebuild the POT file.
+  cp -p $sourcedir/posub/foo-bar.pot $sourcedir/posub/foo-bar.potbak
+  make
+  diff $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot
+
+  # Check that "make dist" updates the POT file.
+  make dist
+  cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null
+
+  # Check that "make install" updates the POT file.
+  cp -p $sourcedir/posub/foo-bar.potbak $sourcedir/posub/foo-bar.pot
+  make install
+  cat $sourcedir/posub/foo-bar.pot | grep great >/dev/null
+
+  # Sanity check.
+  make distcheck
+
+  # Clean up.
+  rm -f $sourcedir/posub/foo-bar.potbak
+  make distclean
+  rm -rf "$instdir"
+  cd $sourcedir
+done
diff --git a/tests/pot-samedir.test b/tests/pot-samedir.test
new file mode 100644
index 0000000..900be4f
--- /dev/null
+++ b/tests/pot-samedir.test
@@ -0,0 +1,233 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that different .pot files in the same directory don't collide.
+
+required='gzip'
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.pot posub/foo-baz.pot
+posub_foo_bar_pot_SOURCES = src/main.c
+posub_foo_bar_pot_LINGUAS = de fr
+posub_foo_baz_pot_SOURCES = src/util.c
+posub_foo_baz_pot_LINGUAS = de it
+EXTRA_DIST = src/main.c src/util.c
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, world.\n"));
+  return 0;
+}
+END
+cat > src/util.c << 'END'
+#include <stdio.h>
+void usage ()
+{
+  puts (gettext ("See the documentation for details."));
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+# .po files for _LINGUAS.
+mkdir posub
+cat > posub/foo-bar-de.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format
+msgid "Hello, world.\n"
+msgstr "Hallo, Welt.\n"
+END
+cat > posub/foo-bar-fr.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format
+msgid "Hello, world.\n"
+msgstr "Salut, le monde.\n"
+END
+cat > posub/foo-baz-de.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "See the documentation for details."
+msgstr "Details entnehmen Sie der Dokumentation."
+END
+cat > posub/foo-baz-it.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "See the documentation for details."
+msgstr "Consultare la documentazione per i dettagli."
+END
+
+cat > expected1 << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-samedir 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.c:4
+#, c-format
+msgid "Hello, world.\n"
+msgstr ""
+END
+
+cat > expected2 << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-samedir 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/util.c:4
+msgid "See the documentation for details."
+msgstr ""
+END
+
+for builddir in . sub; do
+  if test $builddir = '.'; then
+    sourcedir='.'
+  else
+    sourcedir='..'
+    mkdir $builddir
+  fi
+  instdir="`pwd`/instdir"
+  cd $builddir
+  $sourcedir/configure --prefix="$instdir"
+  make
+
+  # Check that "make install" creates the expected .pot files and .mo files.
+  # (They are created under $sourcedir, because the files are distributed.
+  # Cf. the GNU standards, node "Makefile Basics".)
+
+  make install
+
+  test -f $sourcedir/posub/foo-bar.pot
+  test $builddir = '.' || test ! -f posub/foo-bar.pot
+  cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr 
-d '\r' > actual
+  diff actual $sourcedir/expected1
+  rm -f actual
+
+  test -f $sourcedir/posub/foo-baz.pot
+  test $builddir = '.' || test ! -f posub/foo-baz.pot
+  cat $sourcedir/posub/foo-baz.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr 
-d '\r' > actual
+  diff actual $sourcedir/expected2
+  rm -f actual
+
+  test -f $sourcedir/posub/foo-bar-de.mo
+  test -f $sourcedir/posub/foo-bar-fr.mo
+  test -f $sourcedir/posub/foo-baz-de.mo
+  test -f $sourcedir/posub/foo-baz-it.mo
+
+  # Check that "make install" installed the .mo files for the specified
+  # languages.
+  test -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo
+  test -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo
+  test ! -f "$instdir"/share/locale/it/LC_MESSAGES/foo-bar.mo
+  test -f "$instdir"/share/locale/de/LC_MESSAGES/foo-baz.mo
+  test -f "$instdir"/share/locale/it/LC_MESSAGES/foo-baz.mo
+  test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-baz.mo
+  # Check that the two .mo files for the same language are different.
+  if cmp "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo 
"$instdir"/share/locale/de/LC_MESSAGES/foo-baz.mo >/dev/null; then
+    exit 1
+  fi
+
+  make dist
+
+  # Check that the tarball contains the .po files and .mo files for the
+  # specified languages, but not more.
+  gzip -d -c < pot-samedir-1.0.tar.gz | tar tf - > filelist
+  grep '^pot-samedir-1\.0/posub/foo-bar-de\.po$' filelist >/dev/null
+  grep '^pot-samedir-1\.0/posub/foo-bar-de\.mo$' filelist >/dev/null
+  grep '^pot-samedir-1\.0/posub/foo-bar-fr\.po$' filelist >/dev/null
+  grep '^pot-samedir-1\.0/posub/foo-bar-fr\.mo$' filelist >/dev/null
+  if grep '^pot-samedir-1\.0/posub/foo-bar-it\.po$' filelist >/dev/null; then
+    exit 1
+  fi
+  if grep '^pot-samedir-1\.0/posub/foo-bar-it\.mo$' filelist >/dev/null; then
+    exit 1
+  fi
+  grep '^pot-samedir-1\.0/posub/foo-baz-de\.po$' filelist >/dev/null
+  grep '^pot-samedir-1\.0/posub/foo-baz-de\.mo$' filelist >/dev/null
+  grep '^pot-samedir-1\.0/posub/foo-baz-it\.po$' filelist >/dev/null
+  grep '^pot-samedir-1\.0/posub/foo-baz-it\.mo$' filelist >/dev/null
+  if grep '^pot-samedir-1\.0/posub/foo-baz-fr\.po$' filelist >/dev/null; then
+    exit 1
+  fi
+  if grep '^pot-samedir-1\.0/posub/foo-baz-fr\.mo$' filelist >/dev/null; then
+    exit 1
+  fi
+  rm -f filelist
+
+  # Sanity check.
+  make distcheck
+
+  # Clean up.
+  make distclean
+  rm -rf "$instdir"
+  cd $sourcedir
+done
diff --git a/tests/pot-topsrcdir.test b/tests/pot-topsrcdir.test
new file mode 100644
index 0000000..7236eb5
--- /dev/null
+++ b/tests/pot-topsrcdir.test
@@ -0,0 +1,283 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that the POTS primary can be used in the top srcdir, i.e. does not
+# require a subdirectory. Everything else is the same as in the pot-linguas
+# test.
+# FIXME: Should "make install" really update the PO files and MO files?
+#        Current po/Makefile.in.in does not do it.
+
+required='gzip'
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+locale_POTS = foo-bar.pot
+foo_bar_pot_SOURCES = src/main.c src/util.c
+foo_bar_pot_LINGUAS = de fr
+EXTRA_DIST = src/main.c src/util.c
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/util.c << 'END'
+#include <stdio.h>
+void usage ()
+{
+  puts (gettext ("See the documentation for details."));
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+# .po files for _LINGUAS.
+cat > foo-bar-de.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format
+msgid "Hello, world.\n"
+msgstr "Hallo, Welt.\n"
+END
+cat > foo-bar-fr.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format
+msgid "Hello, world.\n"
+msgstr "Salut, le monde.\n"
+END
+
+# A .po file not listed among _LINGUAS, and a junk .mo file.
+cat > foo-bar-es.po << 'END'
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format
+msgid "Hello, world.\n"
+msgstr "Adiós, mundo.\n"
+END
+cat > foo-bar-es.mo << 'END'
+junk
+END
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-linguas 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.c:4
+#, c-format
+msgid "Hello, world.\n"
+msgstr ""
+
+#: src/util.c:4
+msgid "See the documentation for details."
+msgstr ""
+END
+
+for builddir in . sub; do
+  for config_options in '' 'LINGUAS="es de"'; do
+    if test $builddir = '.'; then
+      sourcedir='.'
+    else
+      sourcedir='..'
+      mkdir $builddir
+    fi
+    instdir="`pwd`/instdir"
+    cd $builddir
+    env $config_options $sourcedir/configure --prefix="$instdir"
+    make
+
+    cat > $sourcedir/src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, world.\n"));
+  return 0;
+}
+END
+
+    # Check that "make install" creates the expected .pot file, .po files
+    # and .mo files.
+    # (They are created under $sourcedir, because the files are distributed.
+    # Cf. the GNU standards, node "Makefile Basics".)
+
+    make install
+
+    test -f $sourcedir/foo-bar.pot
+    test $builddir = '.' || test ! -f foo-bar.pot
+    cat $sourcedir/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d 
'\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/foo-bar-de.po
+    test -f $sourcedir/foo-bar-de.mo
+    test -f $sourcedir/foo-bar-fr.po
+    test -f $sourcedir/foo-bar-fr.mo
+
+    if test -z "$config_options"; then
+      # Check that "make install" installed de,po and fr.po but not es.po.
+      test -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo
+      test -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo
+      test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo
+    else
+      # Check that "make install" installed de.po but not fr.po nor es.po.
+      test -f "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo
+      test ! -f "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo
+      test ! -f "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo
+    fi
+
+    # Check that "make dist" creates the expected .pot file.
+
+    rm -f $sourcedir/foo-bar.pot
+
+    make dist
+
+    test -f $sourcedir/foo-bar.pot
+    test $builddir = '.' || test ! -f foo-bar.pot
+    cat $sourcedir/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d 
'\r' > actual
+    diff actual $sourcedir/expected
+    rm -f actual
+
+    test -f $sourcedir/foo-bar-de.po
+    test -f $sourcedir/foo-bar-de.mo
+    test -f $sourcedir/foo-bar-fr.po
+    test -f $sourcedir/foo-bar-fr.mo
+
+    # Check that the tarball contains foo-bar-{de,fr}.{po,mo} but not
+    # the others, regardless whether LINGUAS was specified or not.
+    gzip -d -c < pot-linguas-1.0.tar.gz | tar tf - > filelist
+    grep '^foo-bar-de\.po$' filelist >/dev/null
+    grep '^foo-bar-de\.mo$' filelist >/dev/null
+    grep '^foo-bar-fr\.po$' filelist >/dev/null
+    grep '^foo-bar-fr\.mo$' filelist >/dev/null
+    if grep '^foo-bar-es\.po$' filelist >/dev/null; then
+      exit 1
+    fi
+    if grep '^foo-bar-es\.mo$' filelist >/dev/null; then
+      exit 1
+    fi
+    rm -f filelist
+
+    # Try modifying a source file.
+    cat > $sourcedir/src/main.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, great world!\n"));
+  return 0;
+}
+END
+
+    # Check that "make" does not rebuild the POT file, the PO files, and the
+    # MO files.
+    cp -p $sourcedir/foo-bar.pot $sourcedir/foo-bar.potbak
+    cp -p $sourcedir/foo-bar-de.po $sourcedir/foo-bar-de.pobak
+    cp -p $sourcedir/foo-bar-de.mo $sourcedir/foo-bar-de.mobak
+    cp -p $sourcedir/foo-bar-fr.po $sourcedir/foo-bar-fr.pobak
+    cp -p $sourcedir/foo-bar-fr.mo $sourcedir/foo-bar-fr.mobak
+    cp -p $sourcedir/foo-bar-es.po $sourcedir/foo-bar-es.pobak
+    cp -p $sourcedir/foo-bar-es.mo $sourcedir/foo-bar-es.mobak
+    make
+    diff $sourcedir/foo-bar.potbak $sourcedir/foo-bar.pot
+    cmp $sourcedir/foo-bar-de.pobak $sourcedir/foo-bar-de.po >/dev/null
+    cmp $sourcedir/foo-bar-de.mobak $sourcedir/foo-bar-de.mo >/dev/null
+    cmp $sourcedir/foo-bar-fr.pobak $sourcedir/foo-bar-fr.po >/dev/null
+    cmp $sourcedir/foo-bar-fr.mobak $sourcedir/foo-bar-fr.mo >/dev/null
+    cmp $sourcedir/foo-bar-es.pobak $sourcedir/foo-bar-es.po >/dev/null
+    cmp $sourcedir/foo-bar-es.mobak $sourcedir/foo-bar-es.mo >/dev/null
+
+    # Check that "make install" updates the POT file, the PO files, and the
+    # MO files listed in the _LINGUAS variable, regardless whether LINGUAS
+    # was specified or not.
+    make install
+    cat $sourcedir/foo-bar.pot | grep great >/dev/null
+    cat $sourcedir/foo-bar-de.po | grep great >/dev/null
+    if cmp $sourcedir/foo-bar-de.mobak $sourcedir/foo-bar-de.mo >/dev/null; 
then
+      exit 1
+    fi
+    cat $sourcedir/foo-bar-fr.po | grep great >/dev/null
+    if cmp $sourcedir/foo-bar-fr.mobak $sourcedir/foo-bar-fr.mo >/dev/null; 
then
+      exit 1
+    fi
+    cmp $sourcedir/foo-bar-es.pobak $sourcedir/foo-bar-es.po >/dev/null
+    cmp $sourcedir/foo-bar-es.mobak $sourcedir/foo-bar-es.mo >/dev/null
+
+    # Check that "make dist" updates the POT file, the PO files, and the
+    # MO files listed in the _LINGUAS variable, regardless whether LINGUAS
+    # was specified or not.
+    cp -p $sourcedir/foo-bar.potbak $sourcedir/foo-bar.pot
+    cp -p $sourcedir/foo-bar-de.pobak $sourcedir/foo-bar-de.po
+    cp -p $sourcedir/foo-bar-de.mobak $sourcedir/foo-bar-de.mo
+    cp -p $sourcedir/foo-bar-fr.pobak $sourcedir/foo-bar-fr.po
+    cp -p $sourcedir/foo-bar-fr.mobak $sourcedir/foo-bar-fr.mo
+    make dist
+    cat $sourcedir/foo-bar.pot | grep great >/dev/null
+    cat $sourcedir/foo-bar-de.po | grep great >/dev/null
+    if cmp $sourcedir/foo-bar-de.mobak $sourcedir/foo-bar-de.mo >/dev/null; 
then
+      exit 1
+    fi
+    cat $sourcedir/foo-bar-fr.po | grep great >/dev/null
+    if cmp $sourcedir/foo-bar-fr.mobak $sourcedir/foo-bar-fr.mo >/dev/null; 
then
+      exit 1
+    fi
+    cmp $sourcedir/foo-bar-es.pobak $sourcedir/foo-bar-es.po >/dev/null
+    cmp $sourcedir/foo-bar-es.mobak $sourcedir/foo-bar-es.mo >/dev/null
+
+    # Check that the updated PO files contain 'previous msgid' fields.
+    cat $sourcedir/foo-bar-de.po | grep '^#| msgid "Hello, world\.\\n"$' 
>/dev/null
+    cat $sourcedir/foo-bar-fr.po | grep '^#| msgid "Hello, world\.\\n"$' 
>/dev/null
+
+    # Sanity check.
+    make distcheck
+
+    # Clean up.
+    rm -f $sourcedir/foo-bar.potbak $sourcedir/*.pobak $sourcedir/*.mobak
+    make distclean
+    rm -rf "$instdir"
+    cd $sourcedir
+  done
+done
diff --git a/tests/condhook2.test b/tests/pot-warn1.test
old mode 100755
new mode 100644
similarity index 59%
copy from tests/condhook2.test
copy to tests/pot-warn1.test
index 45e2d43..2c79fb6
--- a/tests/condhook2.test
+++ b/tests/pot-warn1.test
@@ -1,4 +1,4 @@
-#!/bin/sh
+#! /bin/sh
 # Copyright (C) 2010 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -14,36 +14,38 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test install when a conditional install-*-hook is defined.
-# Keep this in sync with sister test condhook.test.
+# Check that when the POTS primary is used, its elements must end in '.pot',
+# otherwise a warning occurs.
 
 . ./defs || Exit 1
 
 set -e
 
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.po
+posub_foo_bar_pot_SOURCES =
+END
+
 cat >> configure.in << 'END'
-AM_CONDITIONAL([TEST], [true])
+AM_POT_TOOLS
 AC_OUTPUT
 END
 
-cat > Makefile.am << 'END'
-sysconf_DATA = mumble
-if TEST
-install-data-hook:
-       : > $(top_srcdir)/good
-endif
-END
+$ACLOCAL
 
-: > mumble
+# Check that there is a warning about the suffix.
 
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE
+AUTOMAKE_fails -Werror
+grep 'POTS.*posub/foo-bar\.po.*\.pot' stderr
+
+AUTOMAKE_run 0 -Wno-error
+grep 'POTS.*posub/foo-bar\.po.*\.pot' stderr
 
-./configure --prefix "`pwd`/inst"
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES =
+END
 
-$MAKE install
-test -f inst/etc/mumble
-test -f good
+# Check that there is no warning any more.
 
-:
+AUTOMAKE_run 0 -Werror
diff --git a/tests/condhook2.test b/tests/pot-warn2.test
old mode 100755
new mode 100644
similarity index 61%
copy from tests/condhook2.test
copy to tests/pot-warn2.test
index 45e2d43..605655a
--- a/tests/condhook2.test
+++ b/tests/pot-warn2.test
@@ -1,4 +1,4 @@
-#!/bin/sh
+#! /bin/sh
 # Copyright (C) 2010 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -14,36 +14,36 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test install when a conditional install-*-hook is defined.
-# Keep this in sync with sister test condhook.test.
+# Check that when the POTS primary is used, the _SOURCES variable must be
+# defined, otherwise a warning occurs.
 
 . ./defs || Exit 1
 
 set -e
 
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.pot
+END
+
 cat >> configure.in << 'END'
-AM_CONDITIONAL([TEST], [true])
+AM_POT_TOOLS
 AC_OUTPUT
 END
 
-cat > Makefile.am << 'END'
-sysconf_DATA = mumble
-if TEST
-install-data-hook:
-       : > $(top_srcdir)/good
-endif
-END
+$ACLOCAL
 
-: > mumble
+# Check that there is a warning about the missing _SOURCES variable.
 
-$ACLOCAL
-$AUTOCONF
-$AUTOMAKE
+AUTOMAKE_fails -Werror
+grep 'posub_foo_bar_pot_SOURCES' stderr
 
-./configure --prefix "`pwd`/inst"
+AUTOMAKE_run 0 -Wno-error
+grep 'posub_foo_bar_pot_SOURCES' stderr
+
+cat >> Makefile.am << 'END'
+posub_foo_bar_pot_SOURCES =
+END
 
-$MAKE install
-test -f inst/etc/mumble
-test -f good
+# Check that there is no warning any more.
 
-:
+AUTOMAKE_run 0 -Werror
diff --git a/tests/pot-xgettext1.test b/tests/pot-xgettext1.test
new file mode 100644
index 0000000..d6cffcc
--- /dev/null
+++ b/tests/pot-xgettext1.test
@@ -0,0 +1,106 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that additional xgettext options can be specified through the
+# _XGETTEXT_OPTIONS variable.
+
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/main.c
+posub_foo_bar_pot_XGETTEXT_OPTIONS = --keyword=_ --flag=_:1:pass-c-format
+EXTRA_DIST = src/main.c
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/main.c << 'END'
+#include <stdio.h>
+#include "gettext.h"
+int main ()
+{
+  printf (_ ("Hello, world.\n"));
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-xgettext1 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.c:5
+#, c-format
+msgid "Hello, world.\n"
+msgstr ""
+END
+
+for builddir in . sub; do
+  if test $builddir = '.'; then
+    sourcedir='.'
+  else
+    sourcedir='..'
+    mkdir $builddir
+  fi
+  instdir="`pwd`/instdir"
+  cd $builddir
+  $sourcedir/configure --prefix="$instdir"
+  make
+
+  # Check that "make dist" creates the expected .pot file.
+  # (It is created under $sourcedir, because the .pot file is distributed.
+  # Cf. the GNU standards, node "Makefile Basics".)
+
+  make dist
+
+  test -f $sourcedir/posub/foo-bar.pot
+  test $builddir = '.' || test ! -f posub/foo-bar.pot
+  cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr 
-d '\r' > actual
+  diff actual $sourcedir/expected
+  rm -f actual
+
+  # Sanity check.
+  make distcheck
+
+  # Clean up.
+  make distclean
+  rm -rf "$instdir"
+  cd $sourcedir
+done
diff --git a/tests/pot-xgettext2.test b/tests/pot-xgettext2.test
new file mode 100644
index 0000000..0c6e326
--- /dev/null
+++ b/tests/pot-xgettext2.test
@@ -0,0 +1,106 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that additional xgettext options can be specified through an
+# AM_XGETTEXT_OPTION invocation.
+
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/main.c
+EXTRA_DIST = src/main.c
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AM_XGETTEXT_OPTION([--keyword=_ --flag=_:1:pass-c-format])
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/main.c << 'END'
+#include <stdio.h>
+#include "gettext.h"
+int main ()
+{
+  printf (_ ("Hello, world.\n"));
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-xgettext2 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.c:5
+#, c-format
+msgid "Hello, world.\n"
+msgstr ""
+END
+
+for builddir in . sub; do
+  if test $builddir = '.'; then
+    sourcedir='.'
+  else
+    sourcedir='..'
+    mkdir $builddir
+  fi
+  instdir="`pwd`/instdir"
+  cd $builddir
+  $sourcedir/configure --prefix="$instdir"
+  make
+
+  # Check that "make dist" creates the expected .pot file.
+  # (It is created under $sourcedir, because the .pot file is distributed.
+  # Cf. the GNU standards, node "Makefile Basics".)
+
+  make dist
+
+  test -f $sourcedir/posub/foo-bar.pot
+  test $builddir = '.' || test ! -f posub/foo-bar.pot
+  cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr 
-d '\r' > actual
+  diff actual $sourcedir/expected
+  rm -f actual
+
+  # Sanity check.
+  make distcheck
+
+  # Clean up.
+  make distclean
+  rm -rf "$instdir"
+  cd $sourcedir
+done
diff --git a/tests/pot-xgettext3.test b/tests/pot-xgettext3.test
new file mode 100644
index 0000000..285646f
--- /dev/null
+++ b/tests/pot-xgettext3.test
@@ -0,0 +1,121 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that multiple specifications of additional xgettext options are
+# cumulative.
+
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+locale_POTS = posub/foo-bar.pot
+posub_foo_bar_pot_SOURCES = src/main.c
+posub_foo_bar_pot_XGETTEXT_OPTIONS = --keyword=_ --flag=_:1:pass-c-format
+EXTRA_DIST = src/main.c
+END
+
+cat >> configure.in << 'END'
+AM_XGETTEXT_OPTION([--flag=error:3:c-format])
+AM_POT_TOOLS
+AM_XGETTEXT_OPTION([--keyword=tr --flag=tr:1:pass-c-format])
+AC_OUTPUT
+END
+
+mkdir src
+cat > src/main.c << 'END'
+#include <stdio.h>
+#include "error.h"
+#include "gettext.h"
+int main ()
+{
+  printf (_ ("Hello, world.\n"));
+  printf (tr ("Nice to meet you."));
+  error (0, 0, "greeting succeeded");
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-xgettext3 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/main.c:6
+#, c-format
+msgid "Hello, world.\n"
+msgstr ""
+
+#: src/main.c:7
+#, c-format
+msgid "Nice to meet you."
+msgstr ""
+
+#: src/main.c:8
+#, c-format
+msgid "greeting succeeded"
+msgstr ""
+END
+
+for builddir in . sub; do
+  if test $builddir = '.'; then
+    sourcedir='.'
+  else
+    sourcedir='..'
+    mkdir $builddir
+  fi
+  instdir="`pwd`/instdir"
+  cd $builddir
+  $sourcedir/configure --prefix="$instdir"
+  make
+
+  # Check that "make dist" creates the expected .pot file.
+  # (It is created under $sourcedir, because the .pot file is distributed.
+  # Cf. the GNU standards, node "Makefile Basics".)
+
+  make dist
+
+  test -f $sourcedir/posub/foo-bar.pot
+  test $builddir = '.' || test ! -f posub/foo-bar.pot
+  cat $sourcedir/posub/foo-bar.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr 
-d '\r' > actual
+  diff actual $sourcedir/expected
+  rm -f actual
+
+  # Sanity check.
+  make distcheck
+
+  # Clean up.
+  make distclean
+  rm -rf "$instdir"
+  cd $sourcedir
+done
diff --git a/tests/pot-xgettext4.test b/tests/pot-xgettext4.test
new file mode 100644
index 0000000..a170525
--- /dev/null
+++ b/tests/pot-xgettext4.test
@@ -0,0 +1,116 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check the example with multiple xgettext invocations, described in the
+# manual.
+
+. ./defs || Exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+locale_POTS = maude.pot
+noinst_POTS = maude1.pot maude2.pot
+maude_pot_SOURCES = maude1.pot maude2.pot
+maude1_pot_SOURCES = maude.c
+maude2_pot_SOURCES = maude.lisp
+EXTRA_DIST = maude.c maude.lisp
+END
+
+cat >> configure.in << 'END'
+AM_POT_TOOLS
+AC_OUTPUT
+END
+
+cat > maude.c << 'END'
+#include <stdio.h>
+int main ()
+{
+  printf (gettext ("Hello, world.\n"));
+  return 0;
+}
+END
+
+cat > maude.lisp << 'END'
+(defun greeting (person)
+  (format t (i18n:gettext "Hello, ~A!~%") person))
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+cat > expected << 'END'
+# SOME DESCRIPTIVE TITLE.
+# This file is put in the public domain.
+# FIRST AUTHOR <address@hidden>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: pot-xgettext1 1.0\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <address@hidden>\n"
+"Language-Team: LANGUAGE <address@hidden>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: maude.c:4
+#, c-format
+msgid "Hello, world.\n"
+msgstr ""
+
+#: maude.lisp:2
+#, lisp-format
+msgid "Hello, ~A!~%"
+msgstr ""
+END
+
+for builddir in . sub; do
+  if test $builddir = '.'; then
+    sourcedir='.'
+  else
+    sourcedir='..'
+    mkdir $builddir
+  fi
+  instdir="`pwd`/instdir"
+  cd $builddir
+  $sourcedir/configure --prefix="$instdir"
+  make
+
+  # Check that "make dist" creates the expected .pot file.
+  # (It is created under $sourcedir, because the .pot file is distributed.
+  # Cf. the GNU standards, node "Makefile Basics".)
+
+  make dist
+
+  test -f $sourcedir/maude.pot
+  test $builddir = '.' || test ! -f maude.pot
+  cat $sourcedir/maude.pot | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' 
> actual
+  diff actual $sourcedir/expected
+  rm -f actual
+
+  # Sanity check.
+  make distcheck
+
+  # Clean up.
+  make distclean
+  rm -rf "$instdir"
+  cd $sourcedir
+done


hooks/post-receive
-- 
GNU Automake



reply via email to

[Prev in Thread] Current Thread [Next in Thread]