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