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