[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Support AC_CONFIG_LIBOBJ_DIR (fixes PR/401)
From: |
Gary V. Vaughan |
Subject: |
Re: [PATCH] Support AC_CONFIG_LIBOBJ_DIR (fixes PR/401) |
Date: |
Wed, 20 Apr 2005 14:47:55 +0100 |
User-agent: |
Mozilla Thunderbird 0.9 (X11/20041103) |
Salut Alexandre,
Alexandre Duret-Lutz wrote:
>>>>"Gary" == Gary V Vaughan <address@hidden> writes:
>
> Sorry, I think you are misunderstanding the purpose of
> AC_CONFIG_LIBOBJ_DIR. But you are breaking common uses of
> @LIBOBJS@ while bending it the way you think it should work. Or
> maybe I am just misreading your patches. At least I would like
> to see a test case proving the converse.
Ah yes, thankyou. Agreed. Here are improved patches to implement
referencing LIBOBJs from any directory, including test cases, as per
your note in PR/401:
> A variation is to always define LIBOBJS='${LIBOBJ_DIR}foo.o \
> ${LIBOBJ_DIR}bar.o' and let Automake define LIBOBJ_DIR differently
> in each Makefile.am.
ChangeLog entries for automake:
2005-04-20 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.
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.
> I do agree that the current @LIBOBJS@ interface lacks some
> features. For instance the ability to refer to objects in other
> directories (this is more than what you were after: some people
> want to use @LIBOBJS@ in src/Makefile.in while the object files
> are in lib/, so the object files in @LIBOBJS@ should look like
> ../lib/foobar.$(OBJEXT)).
These patches allow this usage pattern.
> Or the possibility to the several
> @address@hidden variables and not only one
But not this one, although I too would like to see this. In m4,
I install libm4.la which is built using a LIBOBJS, but I also want
to link the m4 binary with getopt.c et. al. on non-GNU machines. With
the current model the getopt LIBOBJS get lumped into libm4.la, which
is wrong.
> Maybe doing these require a new interface, and
> maybe the actual @LIBOBJS@ can be a special case of that new
> interface (I know I'm vague :))
Also agreed.
There are no regressions when using any combination of patched or unpatched
automake and/or autoconf with respect to these patches, so they are in that
respect independent... however both are required to get the benefit of being
able to reference LIBOBJS from any Makefile.am. Please apply, so I can
commit my fix to libtool CVS for installing a correctly bootstrapped libltdl
into non-autotools using projects.
Cheers,
Gary.
--
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
--- 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-20 14:18:36.000000000 +0100
+++ tests/pr401.test 2005-04-20 14:17:48.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
--- lib/autoconf/general.m4.orig 2003-10-27 11:10:56.000000000 +0000
+++ lib/autoconf/general.m4 2005-04-20 14:38:32.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,8 +2435,9 @@
# _AC_LIBOBJS_NORMALIZE
# ---------------------
-# Clean up LIBOBJS abd LTLIBOBJS so that they work with 1. ac_objext,
-# 2. Automake's ANSI2KNR, 3. Libtool, 4. combination of the three.
+# Clean up LIBOBJS and LTLIBOBJS so that they work with 1. ac_objext,
+# 2. AC_CONFIG_LIBOBJ_DIR, 3. Automake's ANSI2KNR, 4. Libtool,
+# 5. any combination of the above.
# Used with AC_CONFIG_COMMANDS_PRE.
AC_DEFUN([_AC_LIBOBJS_NORMALIZE],
[ac_libobjs=
@@ -2445,9 +2446,9 @@
# 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.
+ 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])
signature.asc
Description: OpenPGP digital signature