2
0

backcompat6.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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: try to build and distribute a package
  17. # using obsoleted forms of AC_INIT, AM_INIT_AUTOMAKE and AC_OUTPUT,
  18. # and 'configure.in' as autconf input file.
  19. # This script can also serve as mild stress-testing for Automake.
  20. # See also the similar test 'backcompat5.test'.
  21. required=cc
  22. am_create_testdir=empty
  23. . test-init.sh
  24. # Anyone doing something like this in a real-life package probably
  25. # deserves to be killed.
  26. cat > configure.ac <<'END'
  27. dnl: Everything here is *deliberately* underquoted!
  28. AC_INIT(quux.c)
  29. PACKAGE=nonesuch-zardoz
  30. VERSION=nonesuch-0.1
  31. AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
  32. AC_SUBST(one,1)
  33. two=2
  34. AC_SUBST(two, $two)
  35. three=3
  36. AC_SUBST(three)
  37. AC_PROG_CC
  38. AM_CONFIG_HEADER(config.h:config.hin)
  39. AM_CONDITIONAL(CROSS_COMPILING, test "$cross_compiling" = yes)
  40. AC_OUTPUT(Makefile foo.got:foo1.in:foo2.in:foo3.in)
  41. END
  42. echo @one@ > foo1.in
  43. echo @two@ > foo2.in
  44. echo @three@ > foo3.in
  45. cat >config.hin <<'END'
  46. #undef PACKAGE
  47. #undef VERSION
  48. END
  49. cat >> Makefile.am <<'END'
  50. bin_PROGRAMS = foo
  51. foo_SOURCES = quux.c
  52. check-local:
  53. test x'$(PACKAGE)' = x'nonesuch-zardoz'
  54. test x'$(VERSION)' = x'nonesuch-0.1'
  55. if ! CROSS_COMPILING
  56. ./foo
  57. ## Do not anchor the regexps w.r.t. the end of line, because on
  58. ## MinGW/MSYS, grep may assume LF line endings only, while our
  59. ## 'foo' program may generate CRLF line endings.
  60. ./foo | grep '^PACKAGE = nonesuch-zardoz!'
  61. ./foo | echo '^VERSION = nonesuch-0\.1!'
  62. endif
  63. END
  64. cat > quux.c <<'END'
  65. #include <config.h>
  66. #include <stdio.h>
  67. int main (void)
  68. {
  69. printf("PACKAGE = %s!\nVERSION = %s!\n", PACKAGE, VERSION);
  70. return 0;
  71. }
  72. END
  73. $ACLOCAL -Wno-obsolete
  74. $AUTOMAKE -Wno-obsolete --add-missing
  75. $AUTOCONF
  76. ./configure
  77. cat >foo.exp <<'END'
  78. 1
  79. 2
  80. 3
  81. END
  82. diff foo.exp foo.got
  83. $MAKE
  84. $MAKE check
  85. distdir=nonesuch-zardoz-nonesuch-0.1
  86. $MAKE distdir
  87. test -f $distdir/quux.c
  88. test ! -f $distdir/foo.got
  89. $MAKE distcheck
  90. :