automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Add new 'AM_PROG_AR' macro, triggering the 'ar-lib' script.


From: Ralf Wildenhues
Subject: Re: [PATCH] Add new 'AM_PROG_AR' macro, triggering the 'ar-lib' script.
Date: Thu, 16 Sep 2010 20:03:18 +0200
User-agent: Mutt/1.5.20 (2010-08-04)

Hi Peter,

I've looked over the non-testsuite part of this now.  Comments below.
I'll try to get the rest done this weekend.

* Peter Rosin wrote on Thu, Sep 16, 2010 at 10:50:05AM CEST:
> --- a/automake.in
> +++ b/automake.in
> @@ -396,6 +396,9 @@ my $package_version_location;
>  # TRUE if we've seen AM_ENABLE_MULTILIB.
>  my $seen_multilib = 0;
>  
> +# TRUE if we've seen AM_PROG_AR
> +my $seen_ar = 0;
> +
>  # TRUE if we've seen AM_PROG_CC_C_O
>  my $seen_cc_c_o = 0;
>  
> @@ -2718,7 +2721,10 @@ sub handle_libraries
>        $var->requires_variables ('library used', 'RANLIB');
>      }
>  
> -  &define_variable ('AR', 'ar', INTERNAL);
> +  if (! $seen_ar)
> +    {
> +      &define_variable ('AR', 'ar', INTERNAL);
> +    }

I don't think the if is necessary.  define_variable is a no-op if the
variable is already defined.

>    &define_variable ('ARFLAGS', 'cru', INTERNAL);
>    &define_verbose_tagvar ('AR');
>  
> @@ -2800,6 +2806,13 @@ sub handle_libraries
>             &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
>           }
>       }
> +
> +      if (! $seen_ar)
> +     {
> +       msg ('portability', $where,
> +            "`$onelib': linking libraries requires "
> +            . "`AM_PROG_AR' in `$configure_ac'")

I'm kinda wondering whether and how we can make this a bit less daunting
for the user.  Not sure whether to invent another warning category, or
mention "w32" here, or something else that makes it clear that the world
isn't going to end.  Below too, of course.

> +     }
>      }
>  }
>  
> @@ -3037,6 +3050,13 @@ sub handle_ltlibraries
>             &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
>           }
>       }
> +
> +      if (! $seen_ar)
> +     {
> +       msg ('portability', $where,
> +            "`$onelib': linking libtool libraries requires "
> +            . "`AM_PROG_AR' in `$configure_ac'")
> +     }
>      }
>  }
>  

> --- a/doc/automake.texi
> +++ b/doc/automake.texi
> @@ -3861,6 +3861,15 @@ environment, or use the @option{--with-lispdir} option 
> to
>  @command{configure} to explicitly set the correct path (if you're sure
>  you have an @command{emacs} that supports Emacs Lisp).
>  
> address@hidden AM_PROG_AR([ACT_IF_FAIL])

@ovar{act-if-fail}

> address@hidden AM_PROG_AR
> address@hidden AR
> +You must use this macro when you use the archiver in your project, if
> +you want support for weird archivers such as Microsoft lib.  The
> +content of the optional argument is executed if the archiver
> +interface is not recognized; the default action is to abort configure
> +with an error message.
> +
>  @item AM_PROG_AS
>  @acindex AM_PROG_AS
>  @vindex CCAS
> @@ -4485,6 +4494,7 @@ AC_INIT([hand], [1.2])
>  AC_CONFIG_AUX_DIR([.])
>  AM_INIT_AUTOMAKE
>  AC_PROG_CC
> +AM_PROG_AR
>  AC_PROG_RANLIB
>  AC_CONFIG_FILES([Makefile])
>  AC_OUTPUT
> @@ -4923,11 +4933,12 @@ by invoking @samp{$(AR) $(ARFLAGS)} followed by the 
> name of the
>  library and the list of objects, and finally by calling
>  @samp{$(RANLIB)} on that library.  You should call
>  @code{AC_PROG_RANLIB} from your @file{configure.ac} to define
> address@hidden (Automake will complain otherwise).  @code{AR} and
> address@hidden default to @code{ar} and @code{cru} respectively; you
> -can override these two variables my setting them in your
> address@hidden, by @code{AC_SUBST}ing them from your
> address@hidden, or by defining a per-library @code{maude_AR}
> address@hidden (Automake will complain otherwise).  You should also
> +call @code{AM_PROG_AR} to define @code{AR}, in order to support weird
> +archivers.  @code{ARFLAGS} will default to @code{cru}; you can override
> +this variable by setting it in your @file{Makefile.am} or by
> address@hidden it from your @file{configure.ac}.  You can override
> +the @code{AR} variable by defining a per-library @code{maude_AR}
>  variable (@pxref{Program and Library Variables}).
>  
>  @cindex Empty libraries
> diff --git a/m4/Makefile.am b/m4/Makefile.am
> index 0cf074b..c801894 100644
> --- a/m4/Makefile.am
> +++ b/m4/Makefile.am
> @@ -22,6 +22,7 @@ m4datadir = $(datadir)/aclocal-$(APIVERSION)
>  
>  dist_m4data_DATA = \
>  $(top_srcdir)/m4/amversion.m4 \
> +ar-lib.m4 \
>  as.m4 \
>  auxdir.m4 \
>  ccstdc.m4 \
> diff --git a/m4/Makefile.in b/m4/Makefile.in
> index 270ee91..4cd3e28 100644
> --- a/m4/Makefile.in
> +++ b/m4/Makefile.in
> @@ -185,6 +185,7 @@ top_srcdir = @top_srcdir@
>  m4datadir = $(datadir)/aclocal-$(APIVERSION)
>  dist_m4data_DATA = \
>  $(top_srcdir)/m4/amversion.m4 \
> +ar-lib.m4 \
>  as.m4 \
>  auxdir.m4 \
>  ccstdc.m4 \
> diff --git a/m4/ar-lib.m4 b/m4/ar-lib.m4
> new file mode 100644
> index 0000000..f468c76
> --- /dev/null
> +++ b/m4/ar-lib.m4
> @@ -0,0 +1,58 @@
> +##                                                          -*- Autoconf -*-
> +# Copyright (C) 2010 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.
> +
> +# serial 1
> +
> +# 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],
> +  [am_cv_ar_interface=ar
> +   AC_COMPILE_IFELSE([[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
> +          m4_default([$1],
> +            [AC_MSG_ERROR([could not determine $AR interface])])
> +        fi
> +      fi
> +      rm -f conftest.lib libconftest.a
> +     ])
> +   ])
> +
> +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"
> +  ;;
> +esac
> +AC_SUBST([AR])dnl
> +])


Thanks,
Ralf



reply via email to

[Prev in Thread] Current Thread [Next in Thread]