test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / gettext-macros.sh
blob63a66208417d224323d8bb2ae53ca90c7c768d2c
1 #! /bin/sh
2 # Copyright (C) 2011-2024 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)
7 # any later version.
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 <https://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.
21 . test-init.sh
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
29 echo : >> get.sh
31 # The 'autopoint' script will look into Makefile.am.
32 echo ACLOCAL_AMFLAGS = -I m4 > Makefile.am
34 # Prefer autopoint to gettextize, since the latter unconditionally
35 # requires user interaction to complete; yes, this means confirmation
36 # from /dev/tty (!) -- see:
37 # <https://lists.gnu.org/archive/html/bug-gettext/2011-12/msg00000.html>
39 # We will need to specify the correct autopoint version in the
40 # AM_GNU_GETTEXT_VERSION call in configure.ac if we want autopoint to
41 # setup the correct infrastructure -- in particular, for what concerns
42 # us, to bring in all the required .m4 files.
43 autopoint_version=$(extract_program_version autopoint) \
44 && test -n "$autopoint_version" \
45 || autopoint_version=0.10.35
47 cat > configure.ac <<END
48 AC_INIT([foo], [1.0])
49 AC_PROG_CC
50 # Both required by autopoint. Newer gettext (0.20+) requires external.
51 AM_GNU_GETTEXT([external])
52 AM_GNU_GETTEXT_VERSION([$autopoint_version])
53 END
55 if autopoint --force && test -f m4/gettext.m4; then
56 echo "ACLOCAL_PATH='$(pwd)/m4':\$ACLOCAL_PATH" >> get.sh
57 echo "export ACLOCAL_PATH" >> get.sh
58 else
59 # Older versions of gettext might not have an autopoint program
60 # available, but this doesn't mean the user hasn't made the gettext
61 # macros available, e.g., by properly setting ACLOCAL_PATH.
62 rm -rf m4
63 mkdir m4
64 # See below for an explanation about the use the of '-Wno-syntax'.
65 if $ACLOCAL -Wno-syntax -I m4 --install && test -f m4/gettext.m4; then
66 : # Gettext macros already accessible by default.
67 else
68 echo "skip_all_ \"couldn't find or get gettext macros\"" >> get.sh
72 cat >> get.sh <<'END'
73 # Even recent versions of gettext used the now-obsolete 'AM_PROG_MKDIR_P'
74 # m4 macro. So we need the following to avoid spurious errors.
75 ACLOCAL="$ACLOCAL -Wno-obsolete"
76 AUTOMAKE="$AUTOMAKE -Wno-obsolete"
77 END
79 . ./get.sh
81 $ACLOCAL --force -I m4 || cat >> get.sh <<'END'
82 # We need to use '-Wno-syntax', since we do not want our test suite
83 # to fail merely because some third-party '.m4' file is underquoted.
84 ACLOCAL="$ACLOCAL -Wno-syntax"
85 END
87 # Remove any Makefile.in possibly created by autopoint, to avoid spurious
88 # maintainer-check failures.
89 rm -f $(find . -name Makefile.in)
91 # The file autopoint might have copied in the 'm4' subdirectory of the
92 # test directory are going to be needed by other tests, so we must not
93 # remove the test directory.
94 keep_testdirs=yes