preproc-c-compile.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #! /bin/sh
  2. # Copyright (C) 2013-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 pre-processing substitutions '%reldir%' and '%canon_reldir%'
  17. # with C compilation and subdir objects.
  18. require=cc
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_PROG_CC
  22. AM_PROG_CC_C_O
  23. AC_CONFIG_FILES([zot/Makefile])
  24. AC_OUTPUT
  25. END
  26. mkdir foo
  27. mkdir foo/bar
  28. mkdir foo/foobar
  29. mkdir zot
  30. cat > Makefile.am << 'END'
  31. AUTOMAKE_OPTIONS = subdir-objects
  32. SUBDIRS = zot
  33. bin_PROGRAMS =
  34. include $(top_srcdir)/foo/local.mk
  35. include $(srcdir)/foo/foobar/local.mk
  36. include local.mk
  37. check-local:
  38. is $(bin_PROGRAMS) == \
  39. foo/mumble2$(EXEEXT) \
  40. foo/bar/mumble$(EXEEXT) \
  41. foo/foobar/mumble$(EXEEXT) \
  42. mumble$(EXEEXT)
  43. test '$(mumble_SOURCES)' = one.c
  44. test '$(foo_mumble2_SOURCES)' = foo/one.c
  45. test '$(foo_bar_mumble_SOURCES)' = foo/bar/one.c
  46. test '$(foo_foobar_mumble_SOURCES)' = foo/foobar/one.c
  47. test -f mumble$(EXEEXT)
  48. test -f foo/mumble2$(EXEEXT)
  49. test -f foo/bar/mumble$(EXEEXT)
  50. test -f foo/foobar/mumble$(EXEEXT)
  51. test -f zot/mumble$(EXEEXT)
  52. : Test some of the object files too.
  53. test -f one.$(OBJEXT)
  54. test -f foo/foobar/one.$(OBJEXT)
  55. test -f zot/one.$(OBJEXT)
  56. END
  57. cat > zot/Makefile.am << 'END'
  58. AUTOMAKE_OPTIONS = subdir-objects
  59. bin_PROGRAMS =
  60. include $(top_srcdir)/zot/local.mk
  61. test:
  62. test '$(bin_PROGRAMS)' = mumble$(EXEEXT)
  63. test '$(mumble_SOURCES)' = one.c
  64. check-local: test
  65. END
  66. cat > local.mk << 'END'
  67. bin_PROGRAMS += %reldir%/mumble
  68. %canon_reldir%_mumble_SOURCES = %reldir%/one.c
  69. END
  70. echo 'int main (void) { return 0; }' > one.c
  71. sed 's/mumble/mumble2/' local.mk > foo/local.mk
  72. cp local.mk foo/bar
  73. cp local.mk foo/foobar
  74. cp local.mk zot
  75. echo "include %reldir%/bar/local.mk" >> foo/local.mk
  76. cp one.c foo
  77. cp one.c foo/bar
  78. cp one.c foo/foobar
  79. cp one.c zot
  80. $ACLOCAL
  81. $AUTOCONF
  82. $AUTOMAKE
  83. ./configure
  84. $MAKE
  85. $MAKE check-local
  86. if ! cross_compiling; then
  87. ./mumble
  88. ./foo/mumble2
  89. ./foo/bar/mumble
  90. ./foo/foobar/mumble
  91. ./zot/mumble
  92. fi
  93. (cd zot && $MAKE test)
  94. # GNU install refuses to override a just-installed file; since we
  95. # have plenty of 'mumble' dummy programs to install in the same
  96. # location, such "overridden installations" are not a problem for
  97. # us; so just force the use the 'install-sh' script.
  98. ac_cv_path_install=$(pwd)/install-sh; export ac_cv_path_install
  99. $MAKE distcheck
  100. :