Hi Alexandre,
Alexandre Duret-Lutz wrote:
MA> This is a proposed patch to use partial linking with Automake-1.9.6
Thanks for the proposal, I plan to look at it on saturday. 1.9.6 is a problem
since this branch is two-year old.
Not a problem, I will look at the CVS code base and see how the change
can be made there.
MA> A copy of the patch is also available for download at :
Please send updates to this list too, as an attachment (because
the inlined one doesn't look right on the tabs).
See attached file :
patch-automake-1.9.6_1.9.6-reloc
I also noticed that the perl code was munged in some regexp on the mail
archive,
because of email addresses scrubbing, so attachments are definitively
better.
Cheers,
Marc Alff
diff -Naur automake-1.9.6/ChangeLog automake-1.9.6-reloc/ChangeLog
--- automake-1.9.6/ChangeLog 2005-07-10 19:41:36.000000000 +0000
+++ automake-1.9.6-reloc/ChangeLog 2006-03-18 16:15:12.000000000 +0000
@@ -1,3 +1,13 @@
+
+2006-03-18 Marc Alff <[EMAIL PROTECTED]>
+
+ * lib/am/reloc.am : New file
+ * lib/am/relocs.am : New file
+ * lib/am/Makefile.am : Adjust.
+ * lib/tests/reloc[1..5].test : New files.
+ * lib/tests/Makefile.am : Adjust.
+ * automake.in : implement the new _RELOCATABLES primary
(handle_relocatables).
+
2005-07-10 Alexandre Duret-Lutz <[EMAIL PROTECTED]>
* configure.ac, NEWS: Bump version to 1.9.6.
diff -Naur automake-1.9.6/automake.in automake-1.9.6-reloc/automake.in
--- automake-1.9.6/automake.in 2005-06-30 21:17:13.000000000 +0000
+++ automake-1.9.6-reloc/automake.in 2006-03-18 16:15:12.000000000 +0000
@@ -2331,6 +2331,113 @@
}
+# handle_relocatables ()
+# -------------------
+# Handle relocatables.
+sub handle_relocatables
+{
+ my @liblist = &am_install_var ('relocs', 'RELOCATABLES',
+ 'noinst', 'check');
+ return if ! @liblist;
+
+ my @prefix = am_primary_prefixes ('RELOCATABLES', 0,
+ 'noinst', 'check');
+
+ if (@prefix)
+ {
+ my $var = rvar ($prefix[0] . '_RELOCATABLES');
+ $var->requires_variables ('relocatables used', 'LIBTOOL');
+ }
+
+ &define_variable ('LDRFLAGS', '', INTERNAL);
+ &define_variable ('LDR', '$(LIBTOOL) --mode=link $(CC)', INTERNAL);
+
+ foreach my $pair (@liblist)
+ {
+ my ($where, $onelib) = @$pair;
+
+ my $seen_libobjs = 0;
+ # Check that the library fits the standard naming convention.
+ my $bn = basename ($onelib);
+ if ($bn !~ /^.*\.o(bj)?$/)
+ {
+ $bn =~ s/^(?:lib)?(.*?)(?:\.[^.]*)?$/$1.o or $1.obj/;
+ my $suggestion = dirname ($onelib) . "/$bn";
+ $suggestion =~ s|^\./||g;
+ msg ('error-gnu/warn', $where,
+ "`$onelib' is not a standard object name\n"
+ . "did you mean `$suggestion'?")
+ }
+
+ $where->push_context ("while processing relocatable `$onelib'");
+ $where->set (INTERNAL->get);
+
+ my $obj = get_object_extension '.$(OBJEXT)';
+
+ # Canonicalize names and check for misspellings.
+ my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
+ '_OBJECTS', '_DEPENDENCIES',
+ '_LDR', '_LDRFLAGS');
+
+ if (! var ($xlib . '_LDRFLAGS'))
+ {
+ &define_variable ($xlib . '_LDRFLAGS', '$(LDRFLAGS)', $where);
+ }
+
+ if (! var ($xlib . '_LDR'))
+ {
+ &define_variable ($xlib . '_LDR', '$(LDR)', $where);
+ }
+
+ # Generate support for conditional object inclusion in
+ # libraries.
+ if (var ($xlib . '_LIBADD'))
+ {
+ if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
+ {
+ $seen_libobjs = 1;
+ }
+ }
+ else
+ {
+ &define_variable ($xlib . "_LIBADD", '', $where);
+ }
+
+ reject_var ($xlib . '_LDADD',
+ "use `${xlib}_LIBADD', not `${xlib}_LDADD'");
+
+ # Make sure we at look at this.
+ set_seen ($xlib . '_DEPENDENCIES');
+
+ &handle_source_transform ($xlib, $onelib, $obj, $where,
+ NONLIBTOOL => 1, LIBTOOL => 0);
+
+ # If the resulting library lies into a subdirectory,
+ # make sure this directory will exist.
+ my $dirstamp = require_build_directory_maybe ($onelib);
+
+ # So far, $onelib was a lazy .o or .obj notation
+ # Change it to the portable .$(OBJEXT) before generating code
+ $onelib =~ s/\.o(bj)?$//g;
+ $onelib .= "\.\$(OBJEXT)";
+
+ $output_rules .= &file_contents ('reloc',
+ $where,
+ RELOCATABLE => $onelib,
+ XRELOCATABLE => $xlib,
+ DIRSTAMP => $dirstamp);
+
+ if ($seen_libobjs)
+ {
+ if (var ($xlib . '_LIBADD'))
+ {
+ &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
+ }
+ }
+ }
+}
+
+
# handle_libraries ()
# -------------------
# Handle libraries.
@@ -6448,6 +6555,32 @@
}
+# &append_objext ($MACRO)
+# -----------------------
+# Macro is an Automake magic macro which primary is RELOCATABLES, e.g.
+# noinst_RELOCATABLES. Make sure these programs have .$(OBJEXT) appended,
+# as well as .o or .obj removed.
+sub append_objext ($)
+{
+ my ($macro) = @_;
+
+ prog_error "append_objext ($macro)"
+ unless $macro =~ /_RELOCATABLES$/;
+
+ transform_variable_recursively
+ ($macro, $macro, 'am__OBJEXT', 0, INTERNAL,
+ sub {
+ my ($subvar, $val, $cond, $full_cond) = @_;
+ # remove .o and .obj
+ $val =~ s/\.o(bj)?$//g;
+ # Append .$(OBJEXT) unless the user did it already, or it's a
+ # @[EMAIL PROTECTED]
+ $val .= '.$(OBJEXT)' unless $val =~ /(?:\.\$\(OBJEXT\)$|[EMAIL
PROTECTED]@]$)/;
+ return $val;
+ });
+}
+
+
# @PREFIX
# &am_primary_prefixes ($PRIMARY, $CAN_DIST, @PREFIXES)
# -----------------------------------------------------
@@ -6646,6 +6779,10 @@
# EXEEXT.
append_exeext ($one_name)
if $primary eq 'PROGRAMS';
+ # Another blatant hack: we rewrite each _RELOCATABLES primary to include
+ # OBJEXT.
+ append_objext ($one_name)
+ if $primary eq 'RELOCATABLES';
# "EXTRA" shouldn't be used when generating clean targets,
# all, or install targets. We used to warn if EXTRA_FOO was
# defined uselessly, but this was annoying.
@@ -7165,6 +7302,7 @@
handle_configure ($makefile_am, $makefile_in, $makefile, @inputs);
handle_gettext;
+ handle_relocatables;
handle_libraries;
handle_ltlibraries;
handle_programs;
diff -Naur automake-1.9.6/lib/am/Makefile.am
automake-1.9.6-reloc/lib/am/Makefile.am
--- automake-1.9.6/lib/am/Makefile.am 2005-05-14 20:21:06.000000000 +0000
+++ automake-1.9.6-reloc/lib/am/Makefile.am 2006-03-18 16:15:12.000000000
+0000
@@ -54,6 +54,8 @@
program.am \
progs.am \
python.am \
+reloc.am \
+relocs.am \
remake-hdr.am \
scripts.am \
subdirs.am \
diff -Naur automake-1.9.6/lib/am/reloc.am automake-1.9.6-reloc/lib/am/reloc.am
--- automake-1.9.6/lib/am/reloc.am 1970-01-01 00:00:00.000000000 +0000
+++ automake-1.9.6-reloc/lib/am/reloc.am 2006-03-18 16:15:12.000000000
+0000
@@ -0,0 +1,22 @@
+## automake - create Makefile.in from Makefile.am
+## Copyright (C) 2006 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, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301, USA.
+
+%RELOCATABLE%: $(%XRELOCATABLE%_OBJECTS) $(%XRELOCATABLE%_DEPENDENCIES)
%DIRSTAMP%
+ -rm -f %RELOCATABLE%
+ $(%XRELOCATABLE%_LDR) $(%XRELOCATABLE%_LDRFLAGS) -o %RELOCATABLE%
$(%XRELOCATABLE%_OBJECTS) $(%XRELOCATABLE%_LIBADD)
+
diff -Naur automake-1.9.6/lib/am/relocs.am automake-1.9.6-reloc/lib/am/relocs.am
--- automake-1.9.6/lib/am/relocs.am 1970-01-01 00:00:00.000000000 +0000
+++ automake-1.9.6-reloc/lib/am/relocs.am 2006-03-18 16:15:12.000000000
+0000
@@ -0,0 +1,26 @@
+## automake - create Makefile.in from Makefile.am
+## Copyright (C) 2006 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, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301, USA.
+
+## ---------- ##
+## Cleaning. ##
+## ---------- ##
+
+.PHONY clean-am: clean-%DIR%RELOCATABLES
+clean-%DIR%RELOCATABLES:
+ -test -z "$(%DIR%_RELOCATABLES)" || rm -f $(%DIR%_RELOCATABLES)
+
diff -Naur automake-1.9.6/tests/Makefile.am
automake-1.9.6-reloc/tests/Makefile.am
--- automake-1.9.6/tests/Makefile.am 2005-06-30 21:17:13.000000000 +0000
+++ automake-1.9.6-reloc/tests/Makefile.am 2006-03-18 16:15:12.000000000
+0000
@@ -431,6 +431,11 @@
python12.test \
recurs.test \
recurs2.test \
+reloc1.test \
+reloc2.test \
+reloc3.test \
+reloc4.test \
+reloc5.test \
remake.test \
remake2.test \
remake3.test \
diff -Naur automake-1.9.6/tests/reloc1.test
automake-1.9.6-reloc/tests/reloc1.test
--- automake-1.9.6/tests/reloc1.test 1970-01-01 00:00:00.000000000 +0000
+++ automake-1.9.6-reloc/tests/reloc1.test 2006-03-18 16:15:12.000000000
+0000
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# test of _RELOCATABLES functionality : verify that AC_PROG_LIBTOOL is required
+
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<'EOF'
+AC_PROG_CC
+AC_OUTPUT
+EOF
+
+
+cat > Makefile.am << 'EOF'
+noinst_RELOCATABLES = all.o
+EOF
+
+$ACLOCAL
+$AUTOCONF
+AUTOMAKE_fails
+grep "relocatables used but .LIBTOOL. is undefined" stderr
+grep AC_PROG_LIBTOOL stderr
diff -Naur automake-1.9.6/tests/reloc2.test
automake-1.9.6-reloc/tests/reloc2.test
--- automake-1.9.6/tests/reloc2.test 1970-01-01 00:00:00.000000000 +0000
+++ automake-1.9.6-reloc/tests/reloc2.test 2006-03-18 16:15:12.000000000
+0000
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# test of _RELOCATABLES functionality : verify object extention
+
+required='libtool'
+
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<'EOF'
+AC_PROG_CC
+AC_PROG_LIBTOOL
+AC_OUTPUT
+EOF
+
+
+cat > Makefile.am << 'EOF'
+noinst_RELOCATABLES = all.bug
+all_bug_SOURCES = a.c b.c
+EOF
+
+: > ltmain.sh
+
+$ACLOCAL
+$AUTOCONF
+AUTOMAKE_fails --add-missing
+grep ".all\.bug. is not a standard object name" stderr
+grep "did you mean .all\.o or all\.obj." stderr
+
diff -Naur automake-1.9.6/tests/reloc3.test
automake-1.9.6-reloc/tests/reloc3.test
--- automake-1.9.6/tests/reloc3.test 1970-01-01 00:00:00.000000000 +0000
+++ automake-1.9.6-reloc/tests/reloc3.test 2006-03-18 16:15:12.000000000
+0000
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# test of _RELOCATABLES functionality : verify generated makefile
+
+required='libtool'
+
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<'EOF'
+AC_PROG_CC
+AC_PROG_LIBTOOL
+AC_OUTPUT
+EOF
+
+cat > Makefile.am << 'EOF'
+noinst_RELOCATABLES = all1.o all2.obj all3.o all4.obj
+all1_o_SOURCES = a1.c b1.c
+all2_obj_SOURCES = a2.c b2.c
+all3_o_SOURCES = a3.c b3.c
+all3_o_LIBADD = all3.stuff all3-more.stuff
+all4_obj_SOURCES = a4.c b4.c
+all4_obj_LDR = my-own-ldr
+all4_obj_LDRFLAGS = my-own-ldr-flags
+EOF
+
+: > ltmain.sh
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+## Verify defaults
+
+grep "^LDRFLAGS =$" Makefile.in
+grep "^LDR = \$(LIBTOOL) --mode=link \$(CC)$" Makefile.in
+
+## Verify _SOURCES is detected and used
+
+grep "^all1_o_SOURCES = a1\.c b1\.c" Makefile.in
+grep "^all2_obj_SOURCES = a2\.c b2\.c" Makefile.in
+
+## Verify that dependent objects properly uses $(OBJEXT)
+
+grep "^am_all1_o_OBJECTS = a1.\$(OBJEXT) b1.\$(OBJEXT)" Makefile.in
+grep "^all1_o_OBJECTS = \$(am_all1_o_OBJECTS)" Makefile.in
+
+grep "^am_all2_obj_OBJECTS = a2.\$(OBJEXT) b2.\$(OBJEXT)" Makefile.in
+grep "^all2_obj_OBJECTS = \$(am_all2_obj_OBJECTS)" Makefile.in
+
+## Verify that target objects properly uses $(OBJEXT)
+grep "^all1\.\$(OBJEXT): \$(all1_o_OBJECTS) \$(all1_o_DEPENDENCIES)"
Makefile.in
+grep "^all2\.\$(OBJEXT): \$(all2_obj_OBJECTS) \$(all2_obj_DEPENDENCIES)"
Makefile.in
+
+## Verify _LDADD is detected and used
+
+grep "^all3_o_DEPENDENCIES = all3\.stuff all3-more\.stuff" Makefile.in
+
+## Verify _LDRFLAGS is detected and used
+
+grep "^all4_obj_LDRFLAGS = my-own-ldr-flags$" Makefile.in
+
+## Verify _LDR is detected and used
+
+grep "^all4_obj_LDR = my-own-ldr$" Makefile.in
+
diff -Naur automake-1.9.6/tests/reloc4.test
automake-1.9.6-reloc/tests/reloc4.test
--- automake-1.9.6/tests/reloc4.test 1970-01-01 00:00:00.000000000 +0000
+++ automake-1.9.6-reloc/tests/reloc4.test 2006-03-18 16:15:12.000000000
+0000
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# test of _RELOCATABLES functionality
+
+required='libtool'
+
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<'EOF'
+AC_PROG_CXX
+AC_PROG_LIBTOOL
+AC_OUTPUT
+EOF
+
+
+cat > Makefile.am << 'EOF'
+noinst_RELOCATABLES = all.o
+all_o_SOURCES = a.cpp b.cpp
+EOF
+
+libtoolize
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+$AUTOMAKE
+
+cat >a.cpp <<EOF
+void foo(){}
+EOF
+
+cat >b.cpp <<EOF
+void bar(){}
+EOF
+
+./configure --prefix `pwd`
+$MAKE
+test -f all.o || test -f all.obj
+
+$MAKE distcheck
+test -f reloc4-1.0.tar.gz
+
diff -Naur automake-1.9.6/tests/reloc5.test
automake-1.9.6-reloc/tests/reloc5.test
--- automake-1.9.6/tests/reloc5.test 1970-01-01 00:00:00.000000000 +0000
+++ automake-1.9.6-reloc/tests/reloc5.test 2006-03-18 16:15:12.000000000
+0000
@@ -0,0 +1,100 @@
+#! /bin/sh
+# Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# test of _RELOCATABLES functionality
+
+required='libtool'
+
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<'EOF'
+AC_PROG_CXX
+AC_PROG_LIBTOOL
+AC_OUTPUT
+EOF
+
+
+cat > Makefile.am << 'EOF'
+noinst_RELOCATABLES = all.o
+all_o_SOURCES = a.cpp b.cpp
+
+noinst_PROGRAMS = proof
+proof_SOURCES = proof.cpp
+proof_LDADD = all.$(OBJEXT)
+
+verify:
+ proof$(EXEEXT)
+EOF
+
+libtoolize
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+$AUTOMAKE
+
+cat >a.cpp <<EOF
+extern int magic ;
+class A {
+ public: A() {
+ magic += 10 ;
+ }
+};
+static A a ;
+EOF
+
+cat >b.cpp <<EOF
+extern int magic ;
+class B {
+ public: B() {
+ magic += 20 ;
+ }
+};
+static B b ;
+EOF
+
+cat >proof.cpp <<EOF
+extern int magic ;
+int magic = 0 ;
+
+int main(int, char*[])
+{
+ if (magic == 0)
+ {
+ return -1 ;
+ }
+
+ if (magic != 30)
+ {
+ return -2 ;
+ }
+
+ // believe it or not, the expected result is 30
+ return 0 ;
+}
+EOF
+
+./configure --prefix `pwd`
+$MAKE
+proof
+
+$MAKE distcheck