automake-patches
[Top][All Lists]
Advanced

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

Re: [PATCH PING] Support AC_CONFIG_LIBOBJ_DIR (fixes PR/401)


From: Gary V. Vaughan
Subject: Re: [PATCH PING] Support AC_CONFIG_LIBOBJ_DIR (fixes PR/401)
Date: Sun, 08 May 2005 23:04:12 +0100
User-agent: Mozilla Thunderbird 1.0 (Macintosh/20041206)

It's been a couple of weeks since there was any movement on this
thread... just a gentle reminder that the automake section is still
awaiting attention.

Cheers,
        Gary.

Gary V. Vaughan wrote:
> Salut Alexandre,
>
> Thanks for the feedback:
>
> Alexandre Duret-Lutz wrote:
>
>>* LIBOBJDIR seems worthy to document from the Autoconf user perspective.
>>  Non-automake might also benefit from this; and we should avoid using
>>  undocumented interfaces in Automake.
>
>
> Okay, I've added that to the attached revision of this patch.
>
>
>>* The comment in _AC_LIBOBJS_NORMALIZE seems misleading to me,
>>  because LIBOBJDIR is unrelated to the macro
>>  AC_CONFIG_LIBOBJ_DIR as far as Autoconf is concerned.
>>  AC_CONFIG_LIBOBJ_DIR specifies where the *sources* files are.
>>  LIBOBJDIR is a prefix variable the user cano use to relocate
>>  the *object* files.  This is not necessary the same place.
>
>
> True enough also.  I've changed the comments to describe the situation more
> accurately.
>
>
>>* Autoconf needs to be adjusted to reflect the fact that
>>  Automake scans a new macro. See the comment above the %traced
>>  variable you modified in scan_autoconf_trace.
>
>
> AC_CONFIG_LIBOBJ_DIR is already there in autoconf-2.59 and HEAD.
>
>
>>* Better write ${LIBOBJDIR} instead of $(LIBOBJDIR) in @LIBOBJS@
>>  (for the same reason we use ${prefix}, etc.)
>
>
> I disagree, LIBOBJDIR is a make macro not a shell variable, so it is more akin
> to $(srcdir) than ${prefix}.  If I'm missing something, feel free to change it
> before committing.
>
>
>>* The Automake manual should be updated at least in two places:
>>    - the place where it documents all the macros that can
>>      affect its behavior (your patch causes
>>      AC_CONFIG_LIBOBJ_DIR to have a stronger semantic when used
>>      with Automake than when used with only Autoconf).
>>    - the section about how LIBOBJS is used.
>>* Use $PERL, not perl.
>
>
> Both done.  Thanks for the pointers.
>
>
>>* AFAICT your patch assumes that users use option `subdir-objects' when
>>  using @LIBOBJS@ remotely. I think we should also support the other case.
>>
>>I suggest you don't bother with the last point unless it looks
>>easy to you.  I'll probably find some time this week-end or next
>>week.
>
>
> Agreed on all counts.  My perl-fu is as always insufficient to the task,
> thanks for offering to do the rest.
>
> ChangeLog entries for automake:
>
> 2005-04-25  Gary V. Vaughan  <address@hidden>
>
>       Fixes PR/401
>       * automake.in (config_libobj_dir): Either `.' or whatever directory is
>       given to AC_CONFIG_LIBOBJ_DIR in configure.ac.
>       (scan_autoconf_traces): Set config_libobj_dir.
>       (sub_read_am_file): Define LIBOBJDIR according to relative path from
>       each Makefile to AC_CONFIG_LIBOBJ_DIR directory.
>       (require_libobj_with_macro): Use $config_libobj_dir when looking for
>       LIBOBJs.
>       (handle_LIBOBJS, handle_ALLOCA): Use it.
>       * tests/Makefile.am (TESTS): Declare pr401.test.
>       * tests/pr401.test: New test.
>       * doc/automake.texi (LIBOBJS): Document changes in behaviour of
>       LIBOBJS, ALLOCA, LTLIBOBJS & LTALLOCA in the presence of
>       subdir-objects and an invocation of AC_CONFIG_LIBOBJ_DIR.
>
> And autoconf:
>
> 2004-04-20  Gary V. Vaughan  <address@hidden>
>
>       * lib/autoconf/general.m4 (_AC_LIBOBJS_NORMALIZE): Prepend each object
>       named in LIBOBJS and LTLIBOBJS with the $(LIBOBJDIR), as set by latest
>       automake.
>
> Cheers,
>       Gary.
>
>
> ------------------------------------------------------------------------
>
> --- automake.in.orig  2005-02-12 10:06:56.000000000 +0000
> +++ automake.in       2005-04-20 14:08:05.000000000 +0100
> @@ -142,6 +142,7 @@
>  use Automake::RuleDef;
>  use Automake::Wrap 'makefile_wrap';
>  use File::Basename;
> +use File::Spec;
>  use Carp;
>
>  ## ----------- ##
> @@ -333,6 +334,10 @@
>  # in Makefiles.
>  my $am_config_aux_dir = '';
>
> +# Directory to search for AC_LIBSOURCE file, as set by AC_CONFIG_LIBOBJ_DIR
> +# in configure.ac.
> +my $config_libobj_dir = '';
> +
>  # Whether AM_GNU_GETTEXT has been seen in configure.ac.
>  my $seen_gettext = 0;
>  # Whether AM_GNU_GETTEXT([external]) is used.
> @@ -2067,7 +2072,7 @@
>
>        if ($iter =~ /\.h$/)
>       {
> -       require_file_with_macro ($cond, $var, FOREIGN, $iter);
> +       require_libobj_with_macro ($cond, $var, FOREIGN, $iter);
>       }
>        elsif ($iter ne 'alloca.c')
>       {
> @@ -2079,7 +2084,7 @@
>         my $bs = var ('BUILT_SOURCES');
>         if (! $bs || ! grep (/$rewrite/, $bs->value_as_list_recursive))
>           {
> -           require_file_with_macro ($cond, $var, FOREIGN, $iter);
> +           require_libobj_with_macro ($cond, $var, FOREIGN, $iter);
>           }
>       }
>      }
> @@ -2092,7 +2097,7 @@
>    $lt ||= '';
>    $var->requires_variables ("address@hidden@ used", $lt . 'ALLOCA');
>    $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
> -  require_file_with_macro ($cond, $var, FOREIGN, 'alloca.c');
> +  require_libobj_with_macro ($cond, $var, FOREIGN, 'alloca.c');
>    &saw_extension ('c');
>  }
>
> @@ -4636,6 +4641,7 @@
>               AC_CONFIG_AUX_DIR => 1,
>               AC_CONFIG_FILES => 1,
>               AC_CONFIG_HEADERS => 1,
> +             AC_CONFIG_LIBOBJ_DIR => 1,
>               AC_CONFIG_LINKS => 1,
>               AC_INIT => 0,
>               AC_LIBSOURCE => 1,
> @@ -4731,6 +4737,12 @@
>             push @config_headers, $spec;
>           }
>       }
> +      elsif ($macro eq 'AC_CONFIG_LIBOBJ_DIR')
> +     {
> +       $config_libobj_dir = $args[1];
> +       $relative_dir = '.';
> +       check_directory ($config_libobj_dir, $where);
> +     }
>        elsif ($macro eq 'AC_CONFIG_LINKS')
>       {
>         foreach my $spec (split (' ', $args[1]))
> @@ -5761,6 +5773,15 @@
>      use constant IN_COMMENT => 2;
>      my $prev_state = IN_RULE_DEF;
>
> +    # Calculate the relative path from this Makefile to LIBOBJDIR.
> +    my $am_libobj_dir = '';
> +    unless ($config_libobj_dir eq '')
> +      {
> +     my $dir = File::Spec->abs2rel ($config_libobj_dir, $relative_dir);
> +     $am_libobj_dir = "$dir/" unless $dir eq '';
> +      }
> +    &define_variable ('LIBOBJDIR', "$am_libobj_dir", INTERNAL);
> +
>      while ($_ = $am_file->getline)
>      {
>          $where->set ("$amfile:$.");
> @@ -6975,6 +6996,22 @@
>      require_file ($macro->rdef ($cond)->location, $mystrict, @files);
>  }
>
> +# &require_libobj_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
> +# -------------------------------------------------------------
> +sub require_libobj_with_macro ($$$@)
> +{
> +    my ($cond, $macro, $mystrict, @files) = @_;
> +    $macro = rvar ($macro) unless ref $macro;
> +    if ($config_libobj_dir eq '')
> +      {
> +     require_file ($macro->rdef ($cond)->location, $mystrict, @files);
> +      }
> +    else
> +      {
> +     require_file_internal ($macro->rdef ($cond)->location, $mystrict,
> +                            $config_libobj_dir, @files);
> +      }
> +}
>
>  # &require_conf_file ($WHERE, $MYSTRICT, @FILES)
>  # ----------------------------------------------
> --- tests/Makefile.am.orig    2005-04-20 13:09:37.000000000 +0100
> +++ tests/Makefile.am 2005-04-20 13:39:05.000000000 +0100
> @@ -405,6 +405,7 @@
>  pr300-ltlib.test \
>  pr300-prog.test \
>  pr307.test \
> +pr401.test \
>  prefix.test \
>  primary.test \
>  primary2.test \
> --- /dev/null 2005-04-25 18:07:47.000000000 +0100
> +++ tests/pr401.test  2005-04-25 18:24:31.000000000 +0100
> @@ -0,0 +1,155 @@
> +#! /bin/sh
> +# Copyright (C) 2005  Free Software Foundation, Inc.
> +#
> +# This file is part of GNU Automake.
> +#
> +# GNU Automake 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.
> +#
> +# GNU Automake 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 Automake; see the file COPYING.  If not, write to
> +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
> +# Boston, MA 02111-1307, USA.
> +
> +# Check support for AC_CONFIG_LIBOBJ_DIR vs LIBOBJS.
> +
> +required=gcc
> +. ./defs || exit 1
> +
> +set -e
> +
> +mkdir lib src
> +
> +cat >lib/feep.c <<'EOF'
> +char *
> +feep ()
> +{
> +  return "feep";
> +}
> +EOF
> +
> +cat >src/feep.c <<'EOF'
> +#include <stdio.h>
> +
> +extern char *feep ();
> +
> +int
> +main (int argc, char **argv)
> +{
> +  printf ("%s\n", feep ());
> +  return 0;
> +}
> +EOF
> +
> +cat >>configure.in << 'EOF'
> +## These lines are activated for later tests
> +#: AC_CONFIG_LIBOBJ_DIR([lib])
> +AC_PROG_CC
> +#: AM_PROG_CC_C_O
> +AC_LIBOBJ([feep])
> +AC_LIBSOURCE([feep.c])
> +AC_PROG_RANLIB
> +AC_CONFIG_FILES([lib/Makefile src/Makefile])
> +AC_OUTPUT
> +EOF
> +
> +## ------------------------------------------ ##
> +## First a test of traditional LIBOBJS usage. ##
> +## ------------------------------------------ ##
> +
> +cat >Makefile.am <<'EOF'
> +SUBDIRS = lib src
> +EOF
> +
> +cat >lib/Makefile.am <<'EOF'
> +noinst_LIBRARIES = libfeep.a
> +libfeep_a_SOURCES =
> +libfeep_a_LIBADD = $(LIBOBJS)
> +EOF
> +
> +cat >src/Makefile.am <<'EOF'
> +check_PROGRAMS = feep
> +feep_LDADD = $(top_builddir)/lib/libfeep.a
> +
> +TESTS = feep
> +EOF
> +
> +$ACLOCAL
> +$AUTOCONF
> +$AUTOMAKE
> +./configure
> +$MAKE
> +$MAKE check
> +
> +rm -f configure Makefile* lib/Makefile* src/Makefile* */feep.o */libfeep.a
> +
> +
> +## -------------------------------------------- ##
> +## Test using LIBOBJS from a sibling directory. ##
> +## -------------------------------------------- ##
> +
> +$PERL -pi -e 's/#: //' configure.in
> +$PERL -pi -e 's/lib\/Makefile //' configure.in
> +
> +cat >Makefile.am <<'EOF'
> +SUBDIRS = src
> +EOF
> +
> +cat > src/Makefile.am <<'EOF'
> +AUTOMAKE_OPTIONS = subdir-objects
> +
> +noinst_LIBRARIES = libfeep.a
> +libfeep_a_SOURCES =
> +libfeep_a_LIBADD = $(LIBOBJS)
> +
> +check_PROGRAMS = feep
> +feep_LDADD = ./libfeep.a
> +
> +TESTS = feep
> +EOF
> +
> +$ACLOCAL
> +$AUTOCONF
> +$AUTOMAKE --add-missing
> +./configure
> +$MAKE
> +$MAKE check
> +
> +rm -f configure Makefile* src/Makefile* */feep.o */libfeep.a
> +
> +
> +## ----------------------------------------- ##
> +## Test using LIBOBJS from parent directory. ##
> +## ----------------------------------------- ##
> +
> +$PERL -pi -e 's/^.*src\/Makefile.*$//' configure.in
> +
> +cat >Makefile.am <<'EOF'
> +AUTOMAKE_OPTIONS = subdir-objects
> +
> +noinst_LIBRARIES = lib/libfeep.a
> +lib_libfeep_a_SOURCES =
> +lib_libfeep_a_LIBADD = $(LIBOBJS)
> +
> +check_PROGRAMS = src/feep
> +src_feep_SOURCES = src/feep.c
> +src_feep_LDADD = ./lib/libfeep.a
> +
> +TESTS = src/feep
> +EOF
> +
> +$ACLOCAL
> +$AUTOCONF
> +$AUTOMAKE
> +./configure
> +$MAKE
> +$MAKE check
> +
> +rm -f configure Makefile* */feep.o */libfeep.a
> --- doc/automake.texi.orig    2005-04-25 18:27:36.000000000 +0100
> +++ doc/automake.texi 2005-04-25 19:31:09.000000000 +0100
> @@ -3785,7 +3785,10 @@
>
>  The @code{AC_CONFIG_LIBOBJ_DIR} tells Autoconf that the source files
>  of these object files are to be found in the @file{lib/} directory.
> -Automake does not yet use this information; it knows the source files
> +
> +In conjunction with @code{subdir-objects}, Automake uses this
> +information to deduce that the object files will be in the same
> +subdirectory relative to @code{$top_builddir}; it knows the source files
>  are expected to be in the directory where the @code{$(LIBOBJS)} and
>  @code{$(ALLOCA)} variables are used.
>
> @@ -3831,13 +3834,9 @@
>  tool2_SOURCES = @dots{}
>  @end example
>
> -Please note it would be wrong to use the @code{$(LIBOBJS)} or
> address@hidden(ALLOCA)} in @file{src/Makefile.am}, because these variables
> -contains unprefixed object names, and for instance
> address@hidden(OBJEXT)} is not buildable in the @file{src/} directory.
> -(Actually if you try using @code{$(LIBOBJS)} in @file{src/}, Automake
> -will require a copy of @file{malloc.c}, @file{memcmp.c},
> address@hidden, @file{alloca.c} in @file{src/} too.)
> +Please note @code{$(LIBOBJS)} or @code{$(ALLOCA)} can only be used in
> address@hidden/Makefile.am} in @code{subdir-objects} mode, because these
> +variables contain object names prefixed with @code{$(LIBOBJDIR)}.
>
>  Because @code{$(LIBOBJS)} and @code{$(ALLOCA)} contain object
>  filenames that end with @code{.$(OBJEXT)}, they are not suitable for
>
>
> ------------------------------------------------------------------------
>
> --- lib/autoconf/general.m4.orig      2003-10-27 11:10:56.000000000 +0000
> +++ lib/autoconf/general.m4   2005-04-25 17:56:48.000000000 +0100
> @@ -1,7 +1,7 @@
>  # This file is part of Autoconf.                       -*- Autoconf -*-
>  # Parameterized macros.
>  # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
> -# 2002, 2003, Free Software Foundation, Inc.
> +# 2002, 2003, 2005, 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
> @@ -2435,7 +2435,7 @@
>
>  # _AC_LIBOBJS_NORMALIZE
>  # ---------------------
> -# Clean up LIBOBJS abd LTLIBOBJS so that they work with 1. ac_objext,
> +# Clean up LIBOBJS and LTLIBOBJS so that they work with 1. ac_objext,
>  # 2. Automake's ANSI2KNR, 3. Libtool, 4. combination of the three.
>  # Used with AC_CONFIG_COMMANDS_PRE.
>  AC_DEFUN([_AC_LIBOBJS_NORMALIZE],
> @@ -2445,9 +2445,10 @@
>    # 1. Remove the extension, and $U if already installed.
>    ac_i=`echo "$ac_i" |
>        sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
> -  # 2. Add them.
> -  ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
> -  ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
> +  # 2. Prepend LIBOBJDIR.  When used with automake>1.9.5 LIBOBJDIR
> +  #    will be set to the directory where LIBOBJS objects are built.
> +  ac_libobjs="$ac_libobjs \$(LIBOBJDIR)$ac_i\$U.$ac_objext"
> +  ac_ltlibobjs="$ac_ltlibobjs \$(LIBOBJDIR)$ac_i"'$U.lo'
>  done
>  AC_SUBST([LIB@&address@hidden, [$ac_libobjs])
>  AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
> --- doc/autoconf.texi.orig    2005-04-25 18:04:28.000000000 +0100
> +++ doc/autoconf.texi 2005-04-25 18:18:15.000000000 +0100
> @@ -4330,7 +4330,10 @@
>  @command{configure} might need to know the replacement directory for the
>  following reasons: (i) some checks use the replacement files, (ii) some
>  macros bypass broken system headers by installing links to the
> -replacement headers, etc.
> +replacement headers, etc. (iii) when used in conjunction with Automake,
> +within each @file{Makefile}, @var{directory} is used as a relative path
> +from @code{$(top_srcdir)} to each object named in @code(LIBOBJS) and
> address@hidden(LTLIBOBJS).
>  @end defmac
>
>  @sp 1
> @@ -14447,6 +14450,13 @@
>
>  Note that @code{U} must not be used in your Makefiles.
>
> address@hidden LIBOBJDIR
> +When used with Automake 1.9.6 or newer, a suitable value for
> address@hidden is set so that the @code{LIBOBJS} and @code{LTLIBOBJS}
> +can be referenced from any @file{Makefile.am}.  Even without Automake,
> +arranging for @code{LIBOBJDIR} to be set correctly will enable
> +referencing @code{LIBOBJS} and @code{LTLIBOBJS} in another directory.
> +
>
>  @node AC_FOO_IFELSE vs AC_TRY_FOO
>  @subsection @code{AC_FOO_IFELSE} vs.@: @code{AC_TRY_FOO}


--
Gary V. Vaughan      ())_.  address@hidden,gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker           / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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