autohdr-subdir-pr12495.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #! /bin/sh
  2. # Copyright (C) 2012-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. # Related to automake bug#12495: Automake shouldn't generate useless
  17. # remake rules for AC_CONFIG_HEADERS arguments after the first one,
  18. # not even when subdirs are involved.
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_CONFIG_HEADERS([a.h b.h sub/c.h])
  22. AC_CONFIG_FILES([sub/Makefile])
  23. AC_OUTPUT
  24. END
  25. mkdir sub
  26. echo SUBDIRS = sub > Makefile.am
  27. : > sub/Makefile.am
  28. $ACLOCAL
  29. $AUTOCONF
  30. $AUTOHEADER
  31. # Even if an AC_CONFIG_HEADERS invocation is passed several files in
  32. # the first argument, only the first one is considered by autoheader
  33. # for automatic generation. Otherwise, the present test case would
  34. test -f a.h.in && test ! -f c.h.in && test ! -f sub/c.h.in \
  35. || fatal_ "unexpected autoheader behavior with multiple" \
  36. "AC_CONFIG_HEADERS arguments"
  37. # Automake should require the missing headers though.
  38. AUTOMAKE_fails -Wno-error -Wnone
  39. grep "^configure\.ac:4:.* required file 'b.h.in' not found" stderr
  40. grep "^configure\.ac:4:.* required file 'sub/c.h.in' not found" stderr
  41. : > b.h.in
  42. : > sub/c.h.in
  43. $AUTOMAKE
  44. ./configure
  45. # Automake should regenerate this.
  46. grep '^$(srcdir)/a\.h\.in:' Makefile.in
  47. # But not these.
  48. grep '[bc]\.h\.in.*:' Makefile.in sub/Makefile.in && exit 1
  49. test -f a.h && test -f b.h && test -f sub/c.h \
  50. || fatal_ "unexpected ./configure behavior with multiple" \
  51. "AC_CONFIG_HEADERS arguments"
  52. rm -f a.h.in a.h
  53. $MAKE
  54. test -f a.h.in
  55. test -f a.h
  56. # We might need to grep the output of GNU make for error messages.
  57. LANG=C LANGUAGE=C LC_ALL=C
  58. export LANG LANGUAGE LC_ALL
  59. ocwd=$(pwd)
  60. for x in b c; do
  61. test $x = b || cd sub
  62. rm -f $x.h.in
  63. run_make -E -e FAIL $x.h.in
  64. test ! -f $x.h.in
  65. if using_gmake; then
  66. grep "No rule to make target [\`\"']$x\.h\.in[\`\"']" stderr
  67. fi
  68. : > $x.h.in
  69. cd "$ocwd" || fatal_ "cannot chdir back"
  70. done
  71. :