pr307.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #! /bin/sh
  2. # Copyright (C) 2002-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 for PR 307: depcomp with depmode=dashmstdout libtool race condition
  17. # Report from Laurent Morichetti.
  18. # (Also exercises check_LTLIBRARIES.)
  19. #
  20. # == Report ==
  21. # The dashmstdout depmode calls libtool in parallel to generate the
  22. # dependencies (with -M flag) and to build the objfile (both have
  23. # --mode=compile and -o).
  24. # The process with 'libtool --mode=compile .* -M' can corrupt the objfile
  25. # as none is generated by the compiler. Since --mode=compile and -o are
  26. # set libtool assumes that a objfile should be generated and will execute
  27. # invalid $mv & $LN_S.
  28. #
  29. # == Fix ==
  30. # Now 'depcomp' never compute dependencies in the background, as this can
  31. # cause races with libtool. Compute the dependencies after the actual
  32. # compilation.
  33. required='libtoolize gcc'
  34. . test-init.sh
  35. cat >> configure.ac << 'END'
  36. AC_PROG_CC
  37. AM_PROG_AR
  38. AC_PROG_LIBTOOL
  39. AC_OUTPUT
  40. END
  41. cat > Makefile.am << 'END'
  42. check_LTLIBRARIES = librace.la
  43. librace_la_SOURCES = a.c b.c c.c d.c e.c f.c g.c h.c
  44. # Make sure the dependencies are updated.
  45. check-local:
  46. for i in $(librace_la_SOURCES:.c=.Plo); do \
  47. echo "checking ./$(DEPDIR)/$$i"; \
  48. grep 'foo\.h' ./$(DEPDIR)/$$i >tst || exit 1; \
  49. test `wc -l <tst` -eq 2 || exit 1; \
  50. done
  51. END
  52. : >foo.h
  53. for i in a b c d e f g h; do
  54. unindent >$i.c <<EOF
  55. #include "foo.h"
  56. int $i () { return 0; }
  57. EOF
  58. done
  59. libtoolize --force
  60. $ACLOCAL
  61. $AUTOCONF
  62. $AUTOMAKE -a
  63. # Sanity check: make sure the variable we are attempting to force
  64. # is indeed used by configure.
  65. grep am_cv_CC_dependencies_compiler_type configure
  66. ./configure am_cv_CC_dependencies_compiler_type=dashmstdout
  67. $MAKE
  68. test -f librace.la && exit 1
  69. $MAKE check
  70. # The failure we check usually occurs during the above build,
  71. # with an output such as:
  72. #
  73. # mv -f .libs/f.lo f.lo
  74. # mv: cannot stat '.libs/f.lo': No such file or directory
  75. #
  76. # (This may happen on 'f' or on some other files.)
  77. test -f librace.la
  78. test -f tst # A proof that check-local was run.
  79. :