gettext-macros.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  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.
  8. #
  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.
  13. #
  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/>.
  16. # Try to find the gettext '.m4' files and make them easily accessed
  17. # to the test cases requiring them.
  18. # See also automake bug#9807.
  19. . test-init.sh
  20. extract_program_version ()
  21. {
  22. "$1" --version | sed 1q | $PERL -ne '/(\d(?:\.\d+)+)/ and print "$1\n"'
  23. }
  24. echo "# Automatically generated by $me." > get.sh
  25. echo : >> get.sh
  26. # The 'autopoint' script will look into Makefile.am.
  27. echo ACLOCAL_AMFLAGS = -I m4 > Makefile.am
  28. # Prefer autopoint to gettextize, since the latter unconditionally
  29. # requires user interaction to complete; yes, this means confirmation
  30. # from /dev/tty (!) -- see:
  31. # <http://lists.gnu.org/archive/html/bug-gettext/2011-12/msg00000.html>
  32. # We will need to specify the correct autopoint version in the
  33. # AM_GNU_GETTEXT_VERSION call in configure.ac if we want autopoint to
  34. # setup the correct infrastructure -- in particular, for what concerns
  35. # us, to bring in all the required .m4 files.
  36. autopoint_version=$(extract_program_version autopoint) \
  37. && test -n "$autopoint_version" \
  38. || autopoint_version=0.10.35
  39. cat > configure.ac <<END
  40. AC_INIT([foo], [1.0])
  41. AC_PROG_CC
  42. # Both required by autopoint.
  43. AM_GNU_GETTEXT
  44. AM_GNU_GETTEXT_VERSION([$autopoint_version])
  45. END
  46. if autopoint --force && test -f m4/gettext.m4; then
  47. echo "ACLOCAL_PATH='$(pwd)/m4':\$ACLOCAL_PATH" >> get.sh
  48. echo "export ACLOCAL_PATH" >> get.sh
  49. else
  50. # Older versions of gettext might not have an autopoint program
  51. # available, but this doesn't mean the user hasn't made the gettext
  52. # macros available, e.g., by properly setting ACLOCAL_PATH.
  53. rm -rf m4
  54. mkdir m4
  55. # See below for an explanation about the use the of '-Wno-syntax'.
  56. if $ACLOCAL -Wno-syntax -I m4 --install && test -f m4/gettext.m4; then
  57. : # Gettext macros already accessible by default.
  58. else
  59. echo "skip_all_ \"couldn't find or get gettext macros\"" >> get.sh
  60. fi
  61. fi
  62. cat >> get.sh <<'END'
  63. # Even recent versions of gettext used the now-obsolete 'AM_PROG_MKDIR_P'
  64. # m4 macro. So we need the following to avoid spurious errors.
  65. ACLOCAL="$ACLOCAL -Wno-obsolete"
  66. AUTOMAKE="$AUTOMAKE -Wno-obsolete"
  67. END
  68. . ./get.sh
  69. $ACLOCAL --force -I m4 || cat >> get.sh <<'END'
  70. # We need to use '-Wno-syntax', since we do not want our test suite
  71. # to fail merely because some third-party '.m4' file is underquoted.
  72. ACLOCAL="$ACLOCAL -Wno-syntax"
  73. END
  74. # Remove any Makefile.in possibly created by autopoint, to avoid spurious
  75. # maintainer-check failures.
  76. rm -f $(find . -name Makefile.in)
  77. # The file autopoint might have copied in the 'm4' subdirectory of the
  78. # test directory are going to be needed by other tests, so we must not
  79. # remove the test directory.
  80. keep_testdirs=yes
  81. :