am-missing-prog.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #! /bin/sh
  2. # Copyright (C) 2003-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 AM_MISSING_PROG.
  17. . test-init.sh
  18. cat >> configure.ac <<'END'
  19. AM_MISSING_PROG([NO_SUCH_COMMAND], [am-none-none])
  20. AM_MISSING_PROG([MISMATCHED_COMMAND], [am-exit-63])
  21. AM_MISSING_PROG([OVERRIDDEN_COMMAND], [am-none-none])
  22. AM_MISSING_PROG([COMMAND_FOUND], [my-command])
  23. AC_OUTPUT
  24. END
  25. mkdir bin
  26. cat > bin/am-exit-63 <<'END'
  27. #!/bin/sh
  28. echo "Oops, I'm too old"
  29. exit 63
  30. END
  31. cat > bin/am-overridden <<'END'
  32. #!/bin/sh
  33. echo "Hey, I'm OK!"
  34. exit 0
  35. END
  36. cat > bin/my-command <<'END'
  37. #!/bin/sh
  38. echo SNAFU
  39. exit 0
  40. END
  41. chmod a+x bin/*
  42. PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH
  43. cat > Makefile.am <<'END'
  44. # Different for different targets, for the sake of parallel make.
  45. o = $@-stdout
  46. e = $@-stderr
  47. debug_info = grep . $@-stdout $@-stderr
  48. status_is = $(debug_info); echo $@: st=$$st; test $$st -eq
  49. w_mis = 'am-none-none' is needed, and is missing on your system
  50. w_old = 'am-exit-63' is needed, and is probably too old
  51. test1:
  52. st=0; $(NO_SUCH_COMMAND) >$o 2>$e || st=$$?; $(status_is) 127
  53. grep "^WARNING: $(w_mis)" $e
  54. test ! -s $o
  55. test2:
  56. st=0; $(MISMATCHED_COMMAND) >$o 2>$e || st=$$?; $(status_is) 63
  57. grep "^WARNING: $(w_old)" $e
  58. test "`cat $o`" = "Oops, I'm too old"
  59. test3:
  60. st=0; $(OVERRIDDEN_COMMAND) >$o 2>$e || st=$$?; $(status_is) 0
  61. st=0; $(OVERRIDDEN_COMMAND) >$o 2>$e || st=$$?; \
  62. test ! -s $e
  63. test "`cat $o`" = "Hey, I'm OK!"
  64. test4:
  65. st=0; $(COMMAND_FOUND) >$o 2>$e || st=$$?; $(status_is) 0
  66. test ! -s $e
  67. test "`cat $o`" = SNAFU
  68. check-local: test1 test2 test2 test4
  69. .PHONY: test1 test2 test2 test4
  70. CLEANFILES = test[1234]-stdout test[1234]-stderr
  71. END
  72. $ACLOCAL
  73. $AUTOCONF
  74. $AUTOMAKE
  75. ./configure OVERRIDDEN_COMMAND=am-overridden
  76. $FGREP COMMAND Makefile.in Makefile # For debugging.
  77. grep "^NO_SUCH_COMMAND = \${SHELL} .*/missing .*am-none-none" Makefile
  78. grep "^MISMATCHED_COMMAND = \${SHELL} .*/missing .*am-exit-63" Makefile
  79. grep "^COMMAND_FOUND = \${SHELL} .*/missing .*my-command" Makefile
  80. grep '^OVERRIDDEN_COMMAND = am-overridden *$' Makefile
  81. $MAKE test1 test2 test3 test4
  82. $MAKE distcheck DISTCHECK_CONFIGURE_FLAGS='OVERRIDDEN_COMMAND=am-overridden'
  83. :