subobj.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #! /bin/sh
  2. # Copyright (C) 1999-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. # Test of subdir objects with C and C++.
  17. . test-init.sh
  18. cat >> configure.ac <<'END'
  19. AC_PROG_CC
  20. AC_PROG_CXX
  21. AC_PROG_YACC
  22. AC_CONFIG_FILES([sub/Makefile])
  23. AC_OUTPUT
  24. END
  25. $ACLOCAL
  26. : > ylwrap
  27. cat > Makefile.am << 'END'
  28. SUBDIRS = sub
  29. bin_PROGRAMS = wish
  30. wish_SOURCES = generic/a.c
  31. wish_SOURCES += another/z.cxx
  32. END
  33. mkdir sub
  34. cat > sub/Makefile.am << 'END'
  35. dream_SOURCES = generic/b.c more/r.y
  36. bin_PROGRAMS = dream
  37. END
  38. AUTOMAKE_fails
  39. grep "^Makefile\.am:3:.*'generic/a\.c'.* in a subdirectory" stderr
  40. grep "^Makefile\.am:[34]:.*'another/z\.cxx'.* in a subdirectory" stderr
  41. grep "^sub/Makefile\.am:1:.*'generic/b\.c'.* in a subdirectory" stderr
  42. grep "option 'subdir-objects' is disabled" stderr
  43. # Verbose tips should be given, but not too many times.
  44. for msg in \
  45. "possible forward-incompatibility" \
  46. "advi[sc]e.* 'subdir-objects' option throughout" \
  47. "unconditionally.* object file.* same subdirectory" \
  48. ; do
  49. test $(grep -c "$msg" stderr) -eq 1
  50. done
  51. # Guard against stupid typos.
  52. grep 'subdir-object([^s]|$)' stderr && exit 1
  53. $AUTOMAKE -Wno-unsupported
  54. echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am
  55. AUTOMAKE_fails
  56. grep "^Makefile\.am" stderr && exit 1
  57. grep "^sub/Makefile\.am:.*'generic/b\.c'.* in a subdirectory" stderr
  58. grep "option 'subdir-objects' is disabled" stderr
  59. sed 's/^AM_INIT_AUTOMAKE/&([subdir-objects])/' configure.ac > configure.tmp
  60. mv -f configure.tmp configure.ac
  61. $ACLOCAL --force
  62. $AUTOMAKE
  63. rm -f compile
  64. $AUTOMAKE --add-missing 2>stderr || { cat stderr >&2; exit 1; }
  65. cat stderr >&2
  66. # Make sure compile is installed, and that Automake says so.
  67. grep '^configure\.ac:[48]:.*install.*compile' stderr
  68. test -f compile
  69. grep '^generic/a\.\$(OBJEXT):' Makefile.in
  70. grep '^generic/b\.\$(OBJEXT):' sub/Makefile.in
  71. grep '^another/z\.\$(OBJEXT):' Makefile.in
  72. $EGREP '(^|[^/])[abz]\.\$(OBJEXT)' Makefile.in sub/Makefile.in && exit 1
  73. # Opportunistically test for a different bug.
  74. grep '^another/z\.\$(OBJEXT):.*dirstamp' Makefile.in
  75. grep '^generic/b\.\$(OBJEXT):.*dirstamp' sub/Makefile.in
  76. :