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: Peter Rosin
Subject: Re: [PATCH] Add new 'AM_PROG_AR' macro, triggering the 'ar-lib' script.
Date: Wed, 15 Sep 2010 09:30:16 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2

Hi Stefano,

Den 2010-09-15 01:45 skrev Stefano Lattarini:
>>>> +: ${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'
>>>
>>> What is the rationale for not redirecting stderr here, along with
>>> stdout?
>>
>> But stderr is redirected?
> Where?  Am I mising something?

">&foo" is the same as ">foo 2>&1", or what am I missing?

>>>> diff --git a/tests/ar-lib5.test b/tests/ar-lib5.test
>>>
>>> Hmm... grepping the output of make might be fragile...
>>>
>>> What about rewriting the test on the following lines, to make it
>>> even more "semantic"?
>>> [CUT]
>>>  5. Run "$MAKE check" and "$MAKE distcheck"
>>
>> I had to also add a line
>>  DISTCHECK_CONFIGURE_FLAGS = AR=lib RANLIB=:
>> to Makefile.am
> Yes, sorry I didn't mention it explicitly.  BTW, you could have also
> set DISTCHECK_CONFIGURE_FLAGS on the make command line:
>   $MAKE distcheck DISTCHECK_CONFIGURE_FLAGS='AR=lib RANLIB=:'
> That said, your way too is perfectly fine for the purposes of the test.

I'll leave it as is then.

>>>> diff --git a/tests/ar-lib6.test b/tests/ar-lib6.test
>>>> +$AUTOCONF 2>stderr
>>>> +cat stderr
>>>
>>> Please ansure the stderr is displayed even if autoconf fails:
>>>   $AUTOCONF 2>stderr || { cat stderr >&2; Exit 1; }
>>>   cat stderr >&2
>>>
>>> Yes, I admit this idiom is annoying and should be factored out
>>> somehow... patch in preparation ;-)
>>
>> Ok, can you please hold that until after this is through the pipe
>> though, so that I don't have to fixup when merging?
> Don't worry, the patch is for the tests-init branch, so no merge problems
> for you :-)  Besides, there is a good share of pending patches holding
> that one back, so your patch will almost surely be applied before mine
> anyway.

Ok, phew :-)

>> diff --git a/ChangeLog b/ChangeLog
>> +    * m4/Makefile.am: Add above.
> Better to do this:
>   * m4/Makefile.am (dist_m4data_DATA): Add above.
> or even:
>   * m4/Makefile.am (dist_m4data_DATA): Updated.
> (and ditto in the git commit message).  Sorry for not noticing it in
> the previous review.

Fixed, don't worry about doing multiple rounds, it's not a problem at all.

>> +    * automake.in (seen_ar): New variable.
> s/seen_ar/$seen_ar/ (again, sorry for not noticing it before).
>> +    * tests/Makefile.am: Add new tests.
> Or better:
>   * tests/Makefile.am (TESTS): Update.

Both fixed.

>> diff --git a/m4/ar-lib.m4 b/m4/ar-lib.m4
>> +# Copyright (C) 2010
>> +# Free Software Foundation, Inc.
> I think this should be written as:
>   # Copyright (C) 2010 Free Software Foundation, Inc.
> on a single line.

Fixed.

>> +# AM_PROG_AR
>> +# --------------
> This should be removed, since ...

Oops. Fixed.

>> +# AM_PROG_AR([ACT-IF-FAIL])
>> +# -------------------------
> ... you added this (which is correct AFAICS).
>> +# Try to determine the the archiver interface and trigger the
>> +# ar-lib wrapper if it is needed;
>> +# If unable to, run ACT-IF-FAIL (default: abort configure).
> What about this instead?
>   # 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).

I squashed that in.

>> +  # and then we could set am__AR="\$(am_aux_dir)/ar-lib \$(AR)"
> What about:
>  ``... and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or
>    something similar''.
> instead?  This seems somewhat more correct, without forcing us to be
> overly precise and explicit.

I also changed \$(AR) to $AR and went with your version.

>> diff --git a/tests/ar-lib5.test b/tests/ar-lib5.test
>> +AC_INIT([ar-lib5.test], [1.0])
> We prefer not to hard-code the test name if possible; what about:
>   cat > configure.in << END
>   AC_INIT([$me], [1.0])
> instead?  This shouldn't be a problem, since the rest of the
> configure.in content doesn't require to be quoted.

Sure, I didn't like ar-lib5.test there to begin with. Thanks!

>> diff --git a/tests/ar-lib7.test b/tests/ar-lib7.test
>> +# Test if automake warns if ar-lib is missing.
> Nitpicking again: s/\.$/when AM_PROG_AR is used./ ?

Sure.

>> +
>> +. ./defs || Exit 1
>> +
>> +set -e
>> +
>> +cat >> configure.in << 'END'
>> +AC_PROG_CC
>> +AC_PROG_RANLIB
>> +AM_PROG_AR
>> +END
>> +
>> +cat > Makefile.am << 'END'
>> +lib_LIBRARIES = libfoo.a
>> +libfoo_a_SOURCES = foo.c
>> +END
>>
> Are these truly required?  I mean, if AM_PROG_AR does not require
> AC_PROG_CC and AC_PROG_RANLIB to be called explicitly, the above
> could be simplified to just:
> 
>   cat >> configure.in << 'END'
>   AM_PROG_AR
>   END
> 
>   : > Makefile.am
> 
> right?

Indeed. I ditched the extra baggage.

>> diff --git a/tests/defs.in b/tests/defs.in
>> index af4a3cd..bd2e813 100644
>> --- a/tests/defs.in
>> +++ b/tests/defs.in
>> @@ -156,6 +156,16 @@ do
>>        echo "$me: running $CC -V -help"
>>        ( $CC -V -help ) || exit 77
>>        ;;
>> +    lib)
>> +      AR=lib
>> +      export AR
>> +      # There is no way to get any identifying output with
>> +      # a zero exit status. So, remap exit status 76 to 0.
>> +      echo "$me: running $AR -?"
>> +      exit_status=0
>> +      $AR -? || exit_status=$?
> Very paranoid nitpicking, but... what about using "$AR -\?", to
> be sure not to trigger unexpected file globbing?
>> +      test $exit_status = 76 && exit 77
> I'm not sure I understand the semantic here; an exit status of 76
> means you have the expected `lib' program... and in this case you
> skip the test because it requires `lib' itself?  (BTW, sorry for
> not having noticed this in my prevous review).

Arrgh. I had requires=lib in ar-lib5.test instead of required=lib,
so it didn't really check if lib was there at all, it just blindly
used it. So the above was totally untested dead code. In this
iteration I have tested that the test skips if lib is missing.
Sorry for being so sloppy.

I also added the -\? thing, and for the record I did try to make
the same change for the cl test above in the same file, but that
is no use since cl does the globbing itself (as Windows apps are
supposed to), but it conveniently(?) does so before parsing
options. lib does its globbing after parsing options apparently.

I have also added some words about the optional argument in the
documentation, and I noticed that AM_PROG_AR does not handle
ARFLAGS (which I thought it did), so I adjusted the code in
automake.in:handle_libraries accordingly.

Cheers,
Peter


>From 636897f7a4b158fbc94439509832bb6dac3f100f Mon Sep 17 00:00:00 2001
From: Peter Rosin <address@hidden>
Date: Wed, 15 Sep 2010 08:41:03 +0200
Subject: [PATCH] Add new 'AM_PROG_AR' macro, triggering the 'ar-lib' script.

* m4/ar-lib.m4: New macro AM_PROG_AR, which locates an
archiver and triggers the auxiliary 'ar-lib' script if needed.
* m4/Makefile.am (dist_m4data_DATA): Update.
* automake.in ($seen_ar): New variable.
(scan_autoconf_traces): Set it.
(handle_libraries): Don't set any default value for AR if
AM_PROG_AR has been seen.
(handle_libraries, handle_ltlibraries): Require AM_PROG_AR for
portability.
* doc/automake.texi (Public Macros): Mention the new
'AM_PROG_AR' macro.
(Subpackages): Add AM_PROG_AR to the example.
(A Library): Adjust recommendations for AR given the new
AM_PROG_AR macro.
* tests/ar.test: Adjust to avoid portability warnings.
* tests/ar-lib2.test: New test, checking that AM_PROG_AR triggers
install of ar-lib.
* tests/ar-lib3.test: New test, checking that lib_LIBRARIES
requires AM_PROG_AR.
* tests/ar-lib4.test: New test, checking that lib_LTLIBRARIES
requires AM_PROG_AR.
* tests/ar-lib5.test: New test, checking that AM_PROG_AR triggers
use of ar-lib when the archiver is Microsoft lib.
* tests/ar-lib6.test: New test, checking the ordering of
AM_PROG_AR and LT_INIT.
* tests/ar-lib7.test: New test, checking that automake warns
if ar-lib is missing.
* tests/defs.in: New required entry 'lib'.
* tests/Makefile.am (TESTS): Update.
* NEWS: Update.
---
 ChangeLog          |   35 ++++++++++++++++++++++++++++
 NEWS               |    3 ++
 automake.in        |   27 +++++++++++++++++++++-
 doc/automake.texi  |   21 +++++++++++++----
 m4/Makefile.am     |    1 +
 m4/Makefile.in     |    1 +
 m4/ar-lib.m4       |   58 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/Makefile.am  |    6 +++++
 tests/Makefile.in  |    6 +++++
 tests/ar-lib2.test |   40 ++++++++++++++++++++++++++++++++
 tests/ar-lib3.test |   45 ++++++++++++++++++++++++++++++++++++
 tests/ar-lib4.test |   57 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/ar-lib5.test |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/ar-lib6.test |   38 ++++++++++++++++++++++++++++++
 tests/ar-lib7.test |   36 +++++++++++++++++++++++++++++
 tests/ar.test      |    3 ++
 tests/defs.in      |   10 ++++++++
 17 files changed, 445 insertions(+), 6 deletions(-)
 create mode 100644 m4/ar-lib.m4
 create mode 100755 tests/ar-lib2.test
 create mode 100755 tests/ar-lib3.test
 create mode 100755 tests/ar-lib4.test
 create mode 100755 tests/ar-lib5.test
 create mode 100755 tests/ar-lib6.test
 create mode 100755 tests/ar-lib7.test

diff --git a/ChangeLog b/ChangeLog
index 02f2fcd..01ed54b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2010-09-14  Peter Rosin  <address@hidden>
+           Ralf Wildenhues  <address@hidden>
+
+       Add new 'AM_PROG_AR' macro, triggering the 'ar-lib' script.
+       * m4/ar-lib.m4: New macro AM_PROG_AR, which locates an
+       archiver and triggers the auxiliary 'ar-lib' script if needed.
+       * m4/Makefile.am (dist_m4data_DATA): Update.
+       * automake.in ($seen_ar): New variable.
+       (scan_autoconf_traces): Set it.
+       (handle_libraries): Don't set any default value for AR if
+       AM_PROG_AR has been seen.
+       (handle_libraries, handle_ltlibraries): Require AM_PROG_AR for
+       portability.
+       * doc/automake.texi (Public Macros): Mention the new
+       'AM_PROG_AR' macro.
+       (Subpackages): Add AM_PROG_AR to the example.
+       (A Library): Adjust recommendations for AR given the new
+       AM_PROG_AR macro.
+       * tests/ar.test: Adjust to avoid portability warnings.
+       * tests/ar-lib2.test: New test, checking that AM_PROG_AR triggers
+       install of ar-lib.
+       * tests/ar-lib3.test: New test, checking that lib_LIBRARIES
+       requires AM_PROG_AR.
+       * tests/ar-lib4.test: New test, checking that lib_LTLIBRARIES
+       requires AM_PROG_AR.
+       * tests/ar-lib5.test: New test, checking that AM_PROG_AR triggers
+       use of ar-lib when the archiver is Microsoft lib.
+       * tests/ar-lib6.test: New test, checking the ordering of
+       AM_PROG_AR and LT_INIT.
+       * tests/ar-lib7.test: New test, checking that automake warns
+       if ar-lib is missing.
+       * tests/defs.in: New required entry 'lib'.
+       * tests/Makefile.am (TESTS): Update.
+       * NEWS: Update.
+
 2010-09-02  Peter Rosin  <address@hidden>
 
        Make ar-lib support backslashed files in archives.
diff --git a/NEWS b/NEWS
index 6971bd7..41a6cc8 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@ New in 1.11.0a:
   - The `compile' script now converts some options for MSVC for a better
     user experience.  Similarly, the new `ar-lib' script wraps Microsoft lib.
 
+  - New macro AM_PROG_AR that looks for an archiver and wraps it in the new
+    'ar-lib' auxiliary script if the found archiver is Microsoft lib.
+
 Bugs fixed in 1.11.0a:
 
 * Bugs introduced by 1.11:
diff --git a/automake.in b/automake.in
index 8fd6869..b16ed40 100755
--- 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);
+    }
   &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'")
+       }
     }
 }
 
@@ -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'")
+       }
     }
 }
 
@@ -5242,6 +5262,7 @@ sub scan_autoconf_traces ($)
                AM_GNU_GETTEXT_INTL_SUBDIR => 0,
                AM_INIT_AUTOMAKE => 0,
                AM_MAINTAINER_MODE => 0,
+               AM_PROG_AR => 0,
                AM_PROG_CC_C_O => 0,
                AM_SILENT_RULES => 0,
                _AM_SUBST_NOTMAKE => 1,
@@ -5433,6 +5454,10 @@ sub scan_autoconf_traces ($)
        {
          $seen_maint_mode = $where;
        }
+      elsif ($macro eq 'AM_PROG_AR')
+       {
+         $seen_ar = $where;
+       }
       elsif ($macro eq 'AM_PROG_CC_C_O')
        {
          $seen_cc_c_o = $where;
diff --git a/doc/automake.texi b/doc/automake.texi
index 66c5a7e..84727e1 100644
--- 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])
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..9e127e3
--- /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
+])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 01acd76..ecc6ab6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -89,6 +89,12 @@ ansi8.test \
 ansi9.test \
 ansi10.test \
 ar-lib.test \
+ar-lib2.test \
+ar-lib3.test \
+ar-lib4.test \
+ar-lib5.test \
+ar-lib6.test \
+ar-lib7.test \
 ar.test \
 ar2.test \
 asm.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index ff547a0..32290b6 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -327,6 +327,12 @@ ansi8.test \
 ansi9.test \
 ansi10.test \
 ar-lib.test \
+ar-lib2.test \
+ar-lib3.test \
+ar-lib4.test \
+ar-lib5.test \
+ar-lib6.test \
+ar-lib7.test \
 ar.test \
 ar2.test \
 asm.test \
diff --git a/tests/ar-lib2.test b/tests/ar-lib2.test
new file mode 100755
index 0000000..7697876
--- /dev/null
+++ b/tests/ar-lib2.test
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test if AM_PROG_AR installs ar-lib.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AM_PROG_AR
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = wish
+wish_SOURCES = a.c
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+# Make sure ar-lib is installed, and that Automake says so.
+grep 'install.*ar-lib' stderr
+test -f ar-lib
+
+:
diff --git a/tests/ar-lib3.test b/tests/ar-lib3.test
new file mode 100755
index 0000000..f3e8aa1
--- /dev/null
+++ b/tests/ar-lib3.test
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test if lib_LIBRARIES requests AM_PROG_AR.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+END
+
+cat > Makefile.am << 'END'
+lib_LIBRARIES = libfoo.a
+libfoo_a_SOURCES = foo.c
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+
+grep 'requires.*AM_PROG_AR' stderr
+
+cat >> configure.in << 'END'
+AM_PROG_AR
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+:
diff --git a/tests/ar-lib4.test b/tests/ar-lib4.test
new file mode 100755
index 0000000..4813191
--- /dev/null
+++ b/tests/ar-lib4.test
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test if lib_LTLIBRARIES requests AM_PROG_AR.
+
+required=libtoolize
+. ./defs || Exit 1
+
+set -e
+
+cp configure.in X
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LTLIBRARIES = libfoo.la
+libfoo_la_SOURCES = foo.c
+END
+
+libtoolize
+$ACLOCAL
+AUTOMAKE_fails
+
+grep 'requires.*AM_PROG_AR' stderr
+
+cp X configure.in
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+:
diff --git a/tests/ar-lib5.test b/tests/ar-lib5.test
new file mode 100755
index 0000000..23d3ea8
--- /dev/null
+++ b/tests/ar-lib5.test
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test if AM_PROG_AR triggers the use of the ar-lib script.
+
+required=lib
+. ./defs || Exit 1
+
+set -e
+
+cat > configure.in << END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([auxdir])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LIBRARIES = libwish.a
+libwish_a_SOURCES = wish.c
+
+check-local:
+       test -f ar-lib-worked
+MOSTLYCLEANFILES = ar-lib-worked
+DISTCHECK_CONFIGURE_FLAGS = AR=lib RANLIB=:
+END
+
+cat > wish.c << 'END'
+int wish(void) { return 0; }
+END
+
+mkdir auxdir
+cat > auxdir/ar-lib << 'END'
+# /bin/sh
+:> ar-lib-worked
+END
+chmod +x auxdir/ar-lib
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure AR=lib RANLIB=:
+
+$MAKE check
+$MAKE distcheck
+
+:
diff --git a/tests/ar-lib6.test b/tests/ar-lib6.test
new file mode 100755
index 0000000..704af83
--- /dev/null
+++ b/tests/ar-lib6.test
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test AM_PROG_AR ordering requirements
+
+required=libtoolize
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+m4_ifdef([LT_INIT], [LT_INIT], [AC_PROG_LIBTOOL])
+AM_PROG_AR
+END
+
+libtoolize
+$ACLOCAL
+$AUTOCONF 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+
+$EGREP '(AC_PROG_LIBTOOL|LT_INIT).*before.*AM_PROG_AR' stderr
+
+:
diff --git a/tests/ar-lib7.test b/tests/ar-lib7.test
new file mode 100755
index 0000000..dceb064
--- /dev/null
+++ b/tests/ar-lib7.test
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test if automake warns if ar-lib is missing when AM_PROG_AR is used.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AM_PROG_AR
+END
+
+:> Makefile.am
+
+$ACLOCAL
+AUTOMAKE_fails
+
+grep 'ar-lib.*not found' stderr
+
+$AUTOMAKE --add-missing
+
+:
diff --git a/tests/ar.test b/tests/ar.test
index d68fc54..b7ba080 100755
--- a/tests/ar.test
+++ b/tests/ar.test
@@ -21,6 +21,7 @@
 set -e
 
 cat >> configure.in << 'END'
+AM_PROG_AR
 AC_SUBST([AR], ['echo it works'])
 AC_SUBST([ARFLAGS], ['>'])
 AC_SUBST([RANLIB], ['echo really works >>'])
@@ -32,6 +33,8 @@ lib_LIBRARIES = libfoo.a
 libfoo_a_SOURCES =
 END
 
+:> ar-lib
+
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
diff --git a/tests/defs.in b/tests/defs.in
index af4a3cd..3e2235b 100644
--- a/tests/defs.in
+++ b/tests/defs.in
@@ -156,6 +156,16 @@ do
       echo "$me: running $CC -V -help"
       ( $CC -V -help ) || exit 77
       ;;
+    lib)
+      AR=lib
+      export AR
+      # There is no way to get any identifying output with
+      # a zero exit status. So, remap exit status 76 to 0.
+      echo "$me: running $AR -?"
+      exit_status=0
+      $AR -\? || exit_status=$?
+      test $exit_status = 76 || exit 77
+      ;;
     makedepend)
       echo "$me: running makedepend -f-"
       ( makedepend -f- ) || exit 77
-- 
1.7.1



reply via email to

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