backcompat2.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #! /bin/sh
  2. # Copyright (C) 2010-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. # Backward-compatibility test: check that AM_INIT_AUTOMAKE with two or
  17. # three arguments does AC_DEFINE the symbols PACKAGE and VERSION iff the
  18. # third argument is empty or non-existent.
  19. am_create_testdir=empty
  20. . test-init.sh
  21. # A trick to make the test run muuuch faster, by avoiding repeated
  22. # runs of aclocal (one order of magnitude improvement in speed!).
  23. echo 'AC_INIT(x,0) AM_INIT_AUTOMAKE' > configure.ac
  24. $ACLOCAL
  25. rm -rf configure.ac autom4te.*
  26. touch install-sh missing
  27. cat > config.h.in <<'END'
  28. #undef PACKAGE
  29. #undef VERSION
  30. END
  31. for am_arg3 in ':' 'false' '#' ' '; do
  32. unindent > configure.ac <<END
  33. AC_INIT
  34. AC_CONFIG_HEADERS([config.h])
  35. AM_INIT_AUTOMAKE([pkgname], [pkgversion], [$am_arg3])
  36. AC_OUTPUT
  37. END
  38. cat configure.ac # For debugging.
  39. $AUTOCONF
  40. ./configure
  41. cat config.h # For debugging.
  42. # The non-empty third argument should prevent PACKAGE and VERSION
  43. # from being AC_DEFINE'd.
  44. $EGREP 'pkg(name|version)' config.h && exit 1
  45. # This is required because even relatively-recent versions of the
  46. # BSD shell wrongly exit when the 'errexit' shell flag is active if
  47. # the last command of a compound statement fails, even if it should
  48. # be protected by the use of "&&".
  49. :
  50. done
  51. for am_extra_args in '' ',' ', []'; do
  52. unindent > configure.ac <<END
  53. AC_INIT
  54. AC_CONFIG_HEADERS([config.h])
  55. AM_INIT_AUTOMAKE([pkgname], [pkgversion]$am_extra_args)
  56. AC_OUTPUT
  57. END
  58. cat configure.ac # For debugging.
  59. $AUTOCONF
  60. ./configure
  61. cat config.h # For debugging.
  62. grep '^ *# *define *PACKAGE *"pkgname" *$' config.h
  63. grep '^ *# *define *VERSION *"pkgversion" *$' config.h
  64. done
  65. :