ar-lib5b.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #! /bin/sh
  2. # Copyright (C) 2011-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 if AM_PROG_AR triggers the use of the ar-lib script.
  17. # This test does not require Microsoft lib.
  18. # Keep this test in sync with sister test 'ar-lib5a.sh'.
  19. . test-init.sh
  20. cat > configure.ac << END
  21. AC_INIT([$me], [1.0])
  22. AC_CONFIG_AUX_DIR([auxdir])
  23. AM_INIT_AUTOMAKE
  24. AC_CONFIG_FILES([Makefile])
  25. AC_PROG_CC
  26. AM_PROG_AR
  27. AC_PROG_RANLIB
  28. # We want to test the content of am_cv_ar_interface in the Makefile.
  29. AC_SUBST([am_cv_ar_interface])
  30. AC_OUTPUT
  31. END
  32. cat > Makefile.am << 'END'
  33. lib_LIBRARIES = libwish.a
  34. libwish_a_SOURCES = wish.c
  35. check-local:
  36. test x'$(am_cv_ar_interface)' = x'lib'
  37. test -f ar-lib-worked
  38. MOSTLYCLEANFILES = ar-lib-worked
  39. END
  40. cat > wish.c << 'END'
  41. int wish(void) { return 0; }
  42. END
  43. mkdir auxdir
  44. cat > auxdir/ar-lib << 'END'
  45. #! /bin/sh
  46. :> ar-lib-worked
  47. END
  48. chmod +x auxdir/ar-lib
  49. # Let's fake microsoft lib.
  50. mkdir bin
  51. cat > bin/lib << 'END'
  52. #! /bin/sh
  53. echo lib command line: $* >&2 # For debugging.
  54. case " $* " in
  55. # The '-OUT:' option is used by tests in configure. So don't create
  56. # the 'ar-lib-worked' file here, as that might cause spurious passes
  57. # of this test; but don't fail either, as that would confuse said
  58. # configure tests.
  59. *' -OUT:'*) exit 0;;
  60. # This means that $* looks like a command-line for 'ar'. We have to
  61. # exit with failure here, to accommodate the two following ortoghonal
  62. # scenarios:
  63. # 1. when 'lib' is tested by configure, this will tell that it does
  64. # not use the ar(1) interface, so that the 'ar-lib' script will
  65. # get involved;
  66. # 2. when 'lib' is called by the Makefile, an ar-style command line
  67. # passed to it would mean that the 'ar-lib' script has failed to
  68. # properly munge the command line, or hasn't been invoked to do so.
  69. *\ c*) exit 1;;
  70. # Assume everything else is OK.
  71. *) : > ar-lib-worked;;
  72. esac
  73. END
  74. chmod +x bin/lib
  75. PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH
  76. $ACLOCAL
  77. $AUTOCONF
  78. $AUTOMAKE --add-missing
  79. # Sanity check: test that it is ok to use 'am_cv_ar_interface' as we do.
  80. $FGREP 'am_cv_ar_interface=' configure
  81. ./configure AR=lib RANLIB=:
  82. $MAKE check
  83. $MAKE distcheck DISTCHECK_CONFIGURE_FLAGS="AR=lib RANLIB=:"
  84. :