2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Try to find the gettext '.m4' files and make them easily accessed
18 # to the test cases requiring them.
19 # See also automake bug#9807.
23 extract_program_version ()
25 "$1" --version | sed 1q | $PERL -ne '/(\d(?:\.\d+)+)/ and print "$1\n"'
28 echo "# Automatically generated by $me." > get.sh
31 # The 'gettextize' and 'autopoint' scripts will look into Makefile.am.
32 echo ACLOCAL_AMFLAGS = -I m4 > Makefile.am
34 # Prefer autopoint to gettextize, since the more modern versions of the
35 # latter might unconditionally require user interaction to complete;
36 # yes, this means confirmation from /dev/tty (!) -- see:
37 # <http://lists.gnu.org/archive/html/bug-gettext/2011-12/msg00000.html>
38 # Since this "forced interaction" behaviour of gettextize wasn't present
39 # before the introduction of autopoint, we should be able to safely
40 # fall back to calling gettextize non-interactively if autopoint is not
42 if autopoint --version; then
43 am_gettextize_command=autopoint
45 am_gettextize_command=gettextize
48 # We will need to specify the correct autopoint (or gettextize) version
49 # in the AM_GNU_GETTEXT_VERSION call in configure.ac if we want autopoint
50 # (or gettextize) to setup the correct infrastructure -- in particular,
51 # for what concerns us, to bring in all the required .m4 files.
52 autopoint_version=$(extract_program_version $am_gettextize_command) \
53 && test -n "$autopoint_version" \
54 || autopoint_version=0.10.35
56 cat > configure.ac <<END
59 # Both required by autopoint.
61 AM_GNU_GETTEXT_VERSION([$autopoint_version])
64 if ! ($am_gettextize_command --force && test -f m4/gettext.m4); then
65 # Older versions of gettext might not have a gettextize program
66 # available, but this doesn't mean the user hasn't made the gettext
67 # macros available, e.g., by properly setting ACLOCAL_PATH.
70 # See below for an explanation about the use the of '-Wno-syntax'.
71 if $ACLOCAL -Wno-syntax -I m4 --install && test -f m4/gettext.m4; then
72 : # Gettext macros already accessible by default.
74 echo "skip_all_ \"couldn't find or get gettext macros\"" >> get.sh
78 echo "ACLOCAL_PATH='$(pwd)/m4':\$ACLOCAL_PATH" >> get.sh
79 echo "export ACLOCAL_PATH" >> get.sh
81 # Even recent versions of gettext used the now-obsolete 'AM_PROG_MKDIR_P'
82 # m4 macro. So we need the following to avoid spurious errors.
83 echo 'AC_DEFUN([AM_PROG_MKDIR_P], [AC_PROG_MKDIR_P([$@])])' >> m4/mk-dirp.m4
87 $ACLOCAL --force -I m4 || cat >> get.sh <<'END'
88 # We need to use '-Wno-syntax', since we do not want our test suite
89 # to fail merely because some third-party '.m4' file is underquoted.
90 ACLOCAL="$ACLOCAL -Wno-syntax"
93 # Remove any Makefile.in possibly created by gettextize/autopoint, to
94 # avoid spurious maintainer-check failures.
95 rm -f $(find . -name Makefile.in)
97 # The file gettextize or autopoint might have copied in the 'm4'
98 # subdirectory of the test directory are going to be needed by
99 # other tests, so we must not remove the test directory.