Edit

kc3-lang/automake/m4/ar-lib.m4

Branch :

  • Show log

    Commit

  • Author : Stefano Lattarini
    Date : 2013-05-15 10:14:46
    Hash : e90126cf
    Message : AM_PROG_CC_C_O: don't rely on AC_PROG_CC_C_O, re-implement similar logic ** Theoretical problems of AC_PROG_CC_C_O: Both cc and $CC are checked to see if they support the '-c' and '-o' options together. This behaviour is highly inconsistent with that of the other macros related to C compiler checks -- which test only $CC. It can also cause unwarranted uses of the 'compile' script on systems where the default 'cc' is inferior, but the user is compiling with a proper, different compiler (e.g., gcc). ** Practical problems with our previous implementation of C support m4 macros in Automake: - AM_PROG_AR must now be called *before* AC_PROG_CC; this wasn't the case before, and it turns out there are packages in the wild that relied on the old behaviour. - The cross-referenced requirements and macro rewrites juggled among AC_PROG_CC, AC_PROG_CC_C_O and AM_PROG_CC_C_O caused warnings in autoconf; for example, in our test 't/libobj3.sh', we could see warnings like these (here slightly tweaked for legibility): configure.ac:5: AC_REQUIRE: `AC_PROG_CC' expanded before required autoconf/c.m4:567: AC_PROG_CC_C_O is expanded from... autoconf/c.m4:429: AC_LANG_COMPILER(C) is expanded from... autoconf/lang.m4:329: AC_LANG_COMPILER_REQUIRE is expanded from... autoconf/general.m4:2606: AC_COMPILE_IFELSE is expanded from... m4sugar/m4sh.m4:639: AS_IF is expanded from... autoconf/general.m4:2031: AC_CACHE_VAL is expanded from... autoconf/general.m4:2052: AC_CACHE_CHECK is expanded from... aclocal.m4:70: AM_PROG_AR is expanded from... configure.ac:5: the top level ** Fix all of that: We fix all of the described issues with a new internal m4 macro _AM_PROG_CC_C_O (inspired to, but not based on, AC_PROG_CC_C_O) that gets tacked on to AC_PROG_CC automatically (this is done in the Automake-generated aclocal.m4) and that takes care of checking and adjusting '$CC' for "-c -o" support. The macro AM_PROG_CC_C_O is still present, but is now just a thin wrapper around such Automake-enhanced AC_PROG_CC. It is worth noting that the present patch causes three slight *backward-incompatibilities*: 1. The name cache variable used by AM_PROG_CC_C_O is no longer computed (at configure runtime!) from the content of '$CC', but is statically defined as 'am_cv_prog_cc_c_o'. 2. 'cc' is no longer checked by AM_PROG_CC_C_O, only '$CC' is. 3. AM_PROG_CC_C_O no longer AC_DEFINE the C preprocessor symbol 'NO_MINUS_C_MINUS_O'. Given however that the third change can easily be worked around, that the first two changes can be legitimately seen as bug fixes, and that the new semantics introduced by such changes will simplify the transition to Automake 2.0 (when the 'subdir-objects' will always be enabled unconditionally), we believe they are acceptable to be shipped with Automake 1.14. With this patch, we also revert some of the testsuite adjustments done in previous commit v1.13.2-178-g9877109 of 2013-05-24 (compile: rewrite AC_PROG_CC with AM_PROG_CC_C_O contents). Such adjustments are no longer needed. * m4/minuso.m4 (_AM_PROG_CC_C_O): New internal macro, basically and adjusted version of a merge between Autoconf-provided AC_PROG_CC_C_O and our old implementation of AM_PROG_CC_C_O. (AM_PROG_CC_C_O): Redefine as a simple wrapper around AC_PROG_CC. * m4/init.m4 (AC_PROG_CC): Append _AM_PROG_CC_C_O, not AM_PROG_CC_C_O, to the pre-existing expansion of this macro. * m4/ar-lib.m4 (AM_PROG_AR): No longer require it to be expanded after AC_PROG_CC. * t/aclocal-deps.sh: Move AC_PROG_CC invocation after AC_PROG_RANLIB and AM_PROG_AR invocations. Things should work this way too (as they used to). * t/subobj-clean-lt-pr10697.sh: Likewise. * t/alloca.sh: Move AC_PROG_CC invocation after AM_PROG_AR invocation. * t/condlib.sh: Likewise. * t/aclocal-deps.sh: Move AC_PROG_CC invocation after LT_INIT and AM_PROG_AR invocations. Make autoconf and autoheader warnings fatal. * t/am-prog-cc-c-o.sh: Adjust to the new semantics, enhance a little, and reduce code duplication. * t/ccnoco.sh: Make autoconf warnings fatal. * t/subpkg.sh: Likewise. * t/ccnoco-lib.sh: Likewise, and fix a comment. * t/link_cond.sh: Enhance a couple of error messages. * configure.ac: Drop "nullification" of AM_PROG_CC_C_O. * NEWS: Adjust. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>

  • m4/ar-lib.m4
  • ##                                                          -*- Autoconf -*-
    # Copyright (C) 2011-2013 Free Software Foundation, Inc.
    #
    # This file is free software; the Free Software Foundation
    # gives unlimited permission to copy and/or distribute it,
    # with or without modifications, as long as this notice is preserved.
    
    # AM_PROG_AR([ACT-IF-FAIL])
    # -------------------------
    # Try to determine the archiver interface, and trigger the ar-lib wrapper
    # if it is needed.  If the detection of archiver interface fails, run
    # ACT-IF-FAIL (default is to abort configure with a proper error message).
    AC_DEFUN([AM_PROG_AR],
    [AC_BEFORE([$0], [LT_INIT])dnl
    AC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl
    AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
    AC_REQUIRE_AUX_FILE([ar-lib])dnl
    AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false])
    : ${AR=ar}
    
    AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface],
      [AC_LANG_PUSH([C])
       am_cv_ar_interface=ar
       AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])],
         [am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
          AC_TRY_EVAL([am_ar_try])
          if test "$ac_status" -eq 0; then
            am_cv_ar_interface=ar
          else
            am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
            AC_TRY_EVAL([am_ar_try])
            if test "$ac_status" -eq 0; then
              am_cv_ar_interface=lib
            else
              am_cv_ar_interface=unknown
            fi
          fi
          rm -f conftest.lib libconftest.a
         ])
       AC_LANG_POP([C])])
    
    case $am_cv_ar_interface in
    ar)
      ;;
    lib)
      # Microsoft lib, so override with the ar-lib wrapper script.
      # FIXME: It is wrong to rewrite AR.
      # But if we don't then we get into trouble of one sort or another.
      # A longer-term fix would be to have automake use am__AR in this case,
      # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something
      # similar.
      AR="$am_aux_dir/ar-lib $AR"
      ;;
    unknown)
      m4_default([$1],
                 [AC_MSG_ERROR([could not determine $AR interface])])
      ;;
    esac
    AC_SUBST([AR])dnl
    ])