ar-lib.m4 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ## -*- Autoconf -*-
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  4. # This file is free software; the Free Software Foundation
  5. # gives unlimited permission to copy and/or distribute it,
  6. # with or without modifications, as long as this notice is preserved.
  7. # AM_PROG_AR([ACT-IF-FAIL])
  8. # -------------------------
  9. # Try to determine the archiver interface, and trigger the ar-lib wrapper
  10. # if it is needed. If the detection of archiver interface fails, run
  11. # ACT-IF-FAIL (default is to abort configure with a proper error message).
  12. AC_DEFUN([AM_PROG_AR],
  13. [AC_BEFORE([$0], [LT_INIT])dnl
  14. AC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl
  15. AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
  16. AC_REQUIRE_AUX_FILE([ar-lib])dnl
  17. AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false])
  18. : ${AR=ar}
  19. AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface],
  20. [AC_LANG_PUSH([C])
  21. am_cv_ar_interface=ar
  22. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])],
  23. [am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
  24. AC_TRY_EVAL([am_ar_try])
  25. if test "$ac_status" -eq 0; then
  26. am_cv_ar_interface=ar
  27. else
  28. am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
  29. AC_TRY_EVAL([am_ar_try])
  30. if test "$ac_status" -eq 0; then
  31. am_cv_ar_interface=lib
  32. else
  33. am_cv_ar_interface=unknown
  34. fi
  35. fi
  36. rm -f conftest.lib libconftest.a
  37. ])
  38. AC_LANG_POP([C])])
  39. case $am_cv_ar_interface in
  40. ar)
  41. ;;
  42. lib)
  43. # Microsoft lib, so override with the ar-lib wrapper script.
  44. # FIXME: It is wrong to rewrite AR.
  45. # But if we don't then we get into trouble of one sort or another.
  46. # A longer-term fix would be to have automake use am__AR in this case,
  47. # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something
  48. # similar.
  49. AR="$am_aux_dir/ar-lib $AR"
  50. ;;
  51. unknown)
  52. m4_default([$1],
  53. [AC_MSG_ERROR([could not determine $AR interface])])
  54. ;;
  55. esac
  56. AC_SUBST([AR])dnl
  57. ])