Hi Stefano, Den 2010-09-14 20:14 skrev Stefano Lattarini: > On Tuesday 14 September 2010, Peter Rosin wrote: >> Hi! > Hello Peter. Hope you don't mind a quick partial review until we > hear from Ralf...
Not at all, he's got enough to do as it is I would think... >> This is a second attempt to implement AM_PROG_AR. The previous >> attempt was bundled with the addition of the 'ar-lib' script but >> was left behind. I have now fleshed it out with tests and >> portability warnings etc. >> >> I think I have everything in the thread covered: >> http://lists.gnu.org/archive/html/automake-patches/2010-08/msg00116.html >> This is going with case (1) in that message. >> >> However, I have only updated tests/ar.test to cope with the new >> reality. So, a lot of tests (100?) are likely to fall over due to >> the new portability warnings. The reason is that I don't know on >> what branch I should base such an intrusive patch. > You mean a patch adding AM_PROG_AR into all the tests which now requires > it, right? I'd base that on msvc branch (in fact, I'd make it a squash-in > for your attached patch). Yes, that's exactly what I mean. >> I fear that such a patch, when merged elsewhere, will be incomplete > No big deal IMHO, we could resort to a fake merge in such case > (`git commit --amend' can also edit merge commits AFAIK), fixing > all the tests that need to be fixed. And there will be few of > them anyway IMO. Ok. >> or otherwise difficult to merge due to other changes. I'm also not >> sure if this is the desired route. Please advise. > Done :-). But let's hear what Ralf has to say, he might know better. Yes. I don't want to do that bit of work in vain. >> This patch is on top of the msvc branch. >> >> AC_PROG_RANLIB is rendered obsolete by LT_INIT. Is it also rendered >> obsolete by AC_PROG_LIBTOOL? Should I not care about libtool 1.5? >> >> Cheers, >> Peter >> >> diff --git a/ChangeLog b/ChangeLog >> + * tests/ar-lib2.test: New test. Test if AM_PROG_AR triggers >> + install of ar-lib. > I feel that something like "New test, checking that AM_PROG_AR triggers > install of ar-lib" would sound more natural. More instances below. This > is admittedly a bike-shedding issue, so feel free to ignore it. ok >> diff --git a/m4/ar-lib.m4 b/m4/ar-lib.m4 >> +# AM_PROG_AR >> +# -------------- > You should add explanation of what this macro does, and, if it takes > arguments, list them in a sort of "macro prototype"; e.g. > > # AM_PROG_AR([ACT-IF-FAIL]) > # ------------------------- > # Try to determine the the archiver interface (FIXME: more details); > # If unable to, run ACT-IF-FAIL (default: abort configure). > > I guess you can come up with a better explanation ;-) I'm not so sure. I stole yours and added some words instead of the FIXME. >> +AC_CHECK_TOOLS(AR, [ar lib "link -lib"], false) > Why not use proper m4 quoting everywhere? E.g.: > AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false]) Why not indeed. >> +: ${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? >> + 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' > What is the rationale for not redirecting stdout/stderr here, considered > how AC_TRY_EVAL is used above (with redirection)? No rationale at all, I just didn't see any trash. But it's better to redirect now than to wait for the bug report. Fixed. >> + # 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="\$(top_srcdir)/ar-lib \$(AR)" > Do you mean am__AR="$am_aux_dir/ar-lib $AR" ? I'm not sure what I mean actually. I stole shamelessly from m4/minuso.m4. I replaced top_srcdir with am_aux_dir for this round, but kept the Makefile notation, or is that totally bogus too? >> diff --git a/tests/ar-lib4.test b/tests/ar-lib4.test >> +$AUTOCONF > useless autoconf call >> +$AUTOCONF > another useless autoconf call Zapped. Also for ar-lib3.test > This testcase checks for two distinct automake failures; I'd prefer > that to be done in two different tests, one checking for missing > `AM_PROG_AR' call, the other one for missing `ar-lib' auxfile. > WDYT? I added ar-lib7.test and removed the second AUTOMAKE_fails from both ar-lib3.test and ar-lib4.test. >> 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"? > 1. Add proper call to `AC_CONFIG_AUX_DIR' in configure.in (with > argument, say, `arlib-auxdir') > 2. Add to Makefile.am: > check-local: > test -f ar-lib-worked > MOSTLYCLEANFILES = ar-lib-worked > (the last line required for "make distcheck" below) > 3. Put the fake `ar-lib' into `arlib-auxdir'; this way, the call to > automake should ensure that the new code respects AC_CONFIG_AUX_DIR > 4. Make the fake `ar-lib' create the file `ar-lib-worked' in the > current builddir: > $ cat arlib-auxdir/ar-lib > #! /bin/sh > : > ar-lib-worked > 5. Run "$MAKE check" and "$MAKE distcheck" I had to also add a line DISTCHECK_CONFIGURE_FLAGS = AR=lib RANLIB=: to Makefile.am and adjust the creation on configure.in to get the correct ordering. >> 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? >> diff --git a/tests/ar.test b/tests/ar.test >> -$AUTOMAKE >> +$AUTOMAKE --add-missing > I'd rather create a dummy (empty) ar-lib above, and do not change > this line. Ok. >> diff --git a/tests/defs.in b/tests/defs.in >> + ( $AR -? ) || exit_status=$? > Nitpicking: why a subshell here? I started out by copying the cl) branch and it stuck after I realized that lib exited non-zero no matter what when given non-work options (for options that produce output that is, "lib -nologo" does return zero but without output so feels a bit uninformative). Thanks for the review! Below is the next iteration. Cheers, Peter >From a5f4e5632a2a197aceccf560eef2949c5e1cd294 Mon Sep 17 00:00:00 2001 From: Peter Rosin <p...@lysator.liu.se> Date: Tue, 14 Sep 2010 22:53:17 +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: Add above. * automake.in (seen_ar): New variable. (scan_autoconf_traces): Set it. (handle_libraries): Don't set default values for AR and ARFLAGS 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: Add new tests. * NEWS: Update. --- ChangeLog | 35 ++++++++++++++++++++++++++++ NEWS | 3 ++ automake.in | 29 ++++++++++++++++++++++- doc/automake.texi | 18 ++++++++++---- m4/Makefile.am | 1 + m4/Makefile.in | 1 + m4/ar-lib.m4 | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 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 | 41 +++++++++++++++++++++++++++++++++ tests/ar.test | 3 ++ tests/defs.in | 10 ++++++++ 17 files changed, 450 insertions(+), 7 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..36adf60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,38 @@ +2010-09-14 Peter Rosin <p...@lysator.liu.se> + Ralf Wildenhues <ralf.wildenh...@gmx.de> + + 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: Add above. + * automake.in (seen_ar): New variable. + (scan_autoconf_traces): Set it. + (handle_libraries): Don't set default values for AR and ARFLAGS + 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: Add new tests. + * NEWS: Update. + 2010-09-02 Peter Rosin <p...@lysator.liu.se> 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..f672286 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,8 +2721,11 @@ sub handle_libraries $var->requires_variables ('library used', 'RANLIB'); } - &define_variable ('AR', 'ar', INTERNAL); - &define_variable ('ARFLAGS', 'cru', INTERNAL); + if (! $seen_ar) + { + &define_variable ('AR', 'ar', INTERNAL); + &define_variable ('ARFLAGS', 'cru', INTERNAL); + } &define_verbose_tagvar ('AR'); foreach my $pair (@liblist) @@ -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..97d7a60 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -3861,6 +3861,12 @@ 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). +...@item AM_PROG_AR +...@acindex AM_PROG_AR +...@vindex 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. + @item AM_PROG_AS @acindex AM_PROG_AS @vindex CCAS @@ -4485,6 +4491,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 +4930,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 -...@code{ranlib} (Automake will complain otherwise). @code{AR} and -...@code{arflags} default to @code{ar} and @code{cru} respectively; you -can override these two variables my setting them in your -...@file{makefile.am}, by @code{AC_SUBST}ing them from your -...@file{configure.ac}, or by defining a per-library @code{maude_AR} +...@code{ranlib} (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 +...@code{ac_subst}ing 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..f670f6e --- /dev/null +++ b/m4/ar-lib.m4 @@ -0,0 +1,60 @@ +## -*- 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 +# -------------- +# AM_PROG_AR([ACT-IF-FAIL]) +# ------------------------- +# 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). +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)" + 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..63ae2a3 --- /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. + +requires=lib +. ./defs || Exit 1 + +set -e + +cat > configure.in << 'END' +AC_INIT([ar-lib5.test], [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..5182894 --- /dev/null +++ b/tests/ar-lib7.test @@ -0,0 +1,41 @@ +#! /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. + +. ./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 + +$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..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=$? + test $exit_status = 76 && exit 77 + ;; makedepend) echo "$me: running makedepend -f-" ( makedepend -f- ) || exit 77 -- 1.7.1