automake-patches
[Top][All Lists]
Advanced

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

FYI: accept -dlopen and -dlpreopen in _LIBADD


From: Alexandre Duret-Lutz
Subject: FYI: accept -dlopen and -dlpreopen in _LIBADD
Date: Sat, 01 Feb 2003 00:40:38 +0100
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu)

I'm installing the following on HEAD.

I was trying to split handle_lib_objects_cond (before I change it to
use traverse_variable_recursively) when I found out there was no
test case for the -dlopen/-dlpreopen support.  The test case
shows that Automakes forbid -dlopen/-dlpreopen in _LIBADD although
Libtool supports it, so I've changed this: we now run the same
code on LDADD and LIBADD.

2003-01-31  Alexandre Duret-Lutz  <address@hidden>

        * automake.in (handle_lib_objects_cond): Ignore -dlopen and
        -dlpreopen in _LIBADD variables too.
        (handle_LIBOBJS, handle_ALLOCA): New functions, extracted from
        handle_lib_objects_cond.
        * tests/libtool7.test: New file.
        * tests/Makefile.am (TESTS): Add libtool7.test.

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1422
diff -u -r1.1422 automake.in
--- automake.in 31 Jan 2003 22:57:22 -0000      1.1422
+++ automake.in 31 Jan 2003 23:37:40 -0000
@@ -2942,105 +2942,61 @@
 # Subroutine of handle_lib_objects: handle a particular condition.
 sub handle_lib_objects_cond
 {
-    my ($xname, $var, $cond) = @_;
+  my ($xname, $var, $cond) = @_;
 
-    # We recognize certain things that are commonly put in LIBADD or
-    # LDADD.
-    my @dep_list = ();
+  # We recognize certain things that are commonly put in LIBADD or
+  # LDADD.
+  my @dep_list = ();
 
-    my $seen_libobjs = 0;
-    my $flagvar = 0;
+  my $seen_libobjs = 0;
+  my $flagvar = 0;
 
-    foreach my $lsearch (&variable_value_as_list_recursive ($var, $cond))
+  foreach my $lsearch (&variable_value_as_list_recursive ($var, $cond))
     {
-       # Skip -lfoo and -Ldir; these are explicitly allowed.
-       next if $lsearch =~ /^-[lL]/;
-       if (! $flagvar && $lsearch =~ /^-/)
+      if (! $flagvar && $lsearch =~ /^-/)
        {
-           if ($var =~ /^(.*)LDADD$/)
-           {
-               # Skip -dlopen and -dlpreopen; these are explicitly allowed.
-               next if $lsearch =~ /^-dl(pre)?open$/;
-               my $prefix = $1 || 'AM_';
-               err_var ($var, "linker flags such as `$lsearch' belong in "
-                        . "`${prefix}LDFLAGS");
-           }
-           else
-           {
-               $var =~ /^(.*)LIBADD$/;
-               # Only get this error once.
-               $flagvar = 1;
-               err_var ($var, "linker flags such as `$lsearch' belong in "
-                        . "`${1}LDFLAGS");
-           }
+         # Skip -lfoo and -Ldir; these are explicitly allowed.
+         next if $lsearch =~ /^-[lL]/;
+         # Skip -dlopen and -dlpreopen; these are explicitly allowed
+         # for Libtool libraries or programs.  (Actually we are a bit
+         # laxest here since this code also applies to non-libtool
+         # libraries or programs, for which -dlopen and -dlopreopen
+         # are pure non-sence.  Diagnosting this doesn't seems very
+         # important: the developer will quickly get complaints from
+         # the linker.)
+         next if $lsearch =~ /^-dl(?:pre)?open$/;
+
+         prog_error ("unexpected variable name `$var'")
+           unless $var =~ /^(.*)(?:LIB|LD)ADD$/;
+
+         my $prefix = $1 || 'AM_';
+         # Only get this error once.
+         $flagvar = 1;
+         err_var ($var, "linker flags such as `$lsearch' belong in "
+                  . "`${prefix}LDFLAGS");
+       }
+
+      # Assume we have a file of some sort, and push it onto the
+      # dependency list.  Autoconf substitutions are not pushed;
+      # rarely is a new dependency substituted into e.g. foo_LDADD
+      # -- but bad things (e.g. -lX11) are routinely substituted.
+      # Note that LIBOBJS and ALLOCA are exceptions to this rule,
+      # and handled specially below.
+      push (@dep_list, $lsearch)
+       unless $lsearch =~ /address@hidden@$/;
+
+      # Automatically handle LIBOBJS and ALLOCA substitutions.
+      # Basically this means adding entries to dep_files.
+      if ($lsearch =~ /^\@(LT)address@hidden/)
+       {
+         handle_LIBOBJS ($var, $cond, $1);
+         $seen_libobjs = 1;
+         push (@dep_list, $lsearch);
        }
-
-       # Assume we have a file of some sort, and push it onto the
-       # dependency list.  Autoconf substitutions are not pushed;
-       # rarely is a new dependency substituted into e.g. foo_LDADD
-       # -- but "bad things (e.g. -lX11) are routinely substituted.
-       # Note that LIBOBJS and ALLOCA are exceptions to this rule,
-       # and handled specially below.
-       push (@dep_list, $lsearch)
-           unless $lsearch =~ /address@hidden@$/;
-
-       # Automatically handle LIBOBJS and ALLOCA substitutions.
-       # Basically this means adding entries to dep_files.
-       if ($lsearch =~ /^\@(LT)address@hidden/)
-       {
-           my $lt = $1 ? $1 : '';
-           my $myobjext = ($1 ? 'l' : '') . 'o';
-
-           push (@dep_list, $lsearch);
-           $seen_libobjs = 1;
-           if (! keys %libsources
-               && ! variable_defined ($lt . 'LIBOBJS'))
-           {
-               err_var ($var, "address@hidden@ seen but never set in "
-                        . "`$configure_ac'");
-           }
-
-           foreach my $iter (keys %libsources)
-           {
-               if ($iter =~ /\.[cly]$/)
-               {
-                   &saw_extension ($&);
-                   &saw_extension ('.c');
-               }
-
-               if ($iter =~ /\.h$/)
-               {
-                   require_file_with_macro ($cond, $var, FOREIGN, $iter);
-               }
-               elsif ($iter ne 'alloca.c')
-               {
-                   my $rewrite = $iter;
-                   $rewrite =~ s/\.c$/.P$myobjext/;
-                   $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
-                   $rewrite = "^" . quotemeta ($iter) . "\$";
-                   # Only require the file if it is not a built source.
-                   if (! variable_defined ('BUILT_SOURCES')
-                       || ! grep (/$rewrite/,
-                                  &variable_value_as_list_recursive (
-                                       'BUILT_SOURCES', 'all')))
-                   {
-                       require_file_with_macro ($cond, $var, FOREIGN, $iter);
-                   }
-               }
-           }
-       }
-       elsif ($lsearch =~ /^\@(LT)address@hidden/)
+      elsif ($lsearch =~ /^\@(LT)address@hidden/)
        {
-           my $lt = $1 ? $1 : '';
-           my $myobjext = ($1 ? 'l' : '') . 'o';
-
-           push (@dep_list, $lsearch);
-           err_var ($var, "address@hidden@ seen but `AC_FUNC_ALLOCA' not in "
-                    . "`$configure_ac'")
-             if ! defined $libsources{'alloca.c'};
-           $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
-           require_file_with_macro ($cond, $var, FOREIGN, 'alloca.c');
-           &saw_extension ('c');
+         handle_ALLOCA ($var, $cond, $1);
+         push (@dep_list, $lsearch);
        }
     }
 
@@ -3062,6 +3018,61 @@
   return $seen_libobjs;
 }
 
+sub handle_LIBOBJS ($$$)
+{
+  my ($var, $cond, $lt) = @_;
+  $lt ||= '';
+  my $myobjext = ($1 ? 'l' : '') . 'o';
+
+  if (! keys %libsources && ! variable_defined ($lt . 'LIBOBJS'))
+    {
+      err_var ($var, "address@hidden@ seen but never set in "
+              . "`$configure_ac'");
+    }
+
+  foreach my $iter (keys %libsources)
+    {
+      if ($iter =~ /\.[cly]$/)
+       {
+         &saw_extension ($&);
+         &saw_extension ('.c');
+       }
+
+      if ($iter =~ /\.h$/)
+       {
+         require_file_with_macro ($cond, $var, FOREIGN, $iter);
+       }
+      elsif ($iter ne 'alloca.c')
+       {
+         my $rewrite = $iter;
+         $rewrite =~ s/\.c$/.P$myobjext/;
+         $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
+         $rewrite = "^" . quotemeta ($iter) . "\$";
+         # Only require the file if it is not a built source.
+         if (! variable_defined ('BUILT_SOURCES')
+             || ! grep (/$rewrite/,
+                        &variable_value_as_list_recursive ('BUILT_SOURCES',
+                                                           'all')))
+           {
+             require_file_with_macro ($cond, $var, FOREIGN, $iter);
+           }
+       }
+    }
+}
+
+sub handle_ALLOCA ($$$)
+{
+  my ($var, $cond, $lt) = @_;
+  my $myobjext = ($1 ? 'l' : '') . 'o';
+
+  err_var ($var, "address@hidden@ seen but `AC_FUNC_ALLOCA' not in "
+          . "`$configure_ac'")
+    if ! defined $libsources{'alloca.c'};
+  $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
+  require_file_with_macro ($cond, $var, FOREIGN, 'alloca.c');
+  &saw_extension ('c');
+}
+
 # Canonicalize the input parameter
 sub canonicalize
 {
@@ -3341,6 +3352,8 @@
          &define_variable ($xlib . '_AR', '$(AR) cru', $where);
        }
 
+      # Generate support for conditional object inclusion in
+      # libraries.
       if (variable_defined ($xlib . '_LIBADD'))
        {
          if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
@@ -3350,8 +3363,6 @@
        }
       else
        {
-         # Generate support for conditional object inclusion in
-         # libraries.
          &define_variable ($xlib . "_LIBADD", '', $where);
        }
 
@@ -3483,6 +3494,8 @@
          &define_variable ($xlib . '_LDFLAGS', '', $where);
        }
 
+      # Generate support for conditional object inclusion in
+      # libraries.
       if (variable_defined ($xlib . '_LIBADD'))
        {
          if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
@@ -3492,8 +3505,6 @@
        }
       else
        {
-         # Generate support for conditional object inclusion in
-         # libraries.
          &define_variable ($xlib . "_LIBADD", '', $where);
        }
 
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.465
diff -u -r1.465 Makefile.am
--- tests/Makefile.am   28 Jan 2003 23:24:25 -0000      1.465
+++ tests/Makefile.am   31 Jan 2003 23:37:41 -0000
@@ -241,6 +241,7 @@
 libtool4.test \
 libtool5.test \
 libtool6.test \
+libtool7.test \
 link_c_cxx.test        \
 link_dist.test \
 link_fc.test \
Index: tests/libtool7.test
===================================================================
RCS file: tests/libtool7.test
diff -N tests/libtool7.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/libtool7.test 31 Jan 2003 23:37:41 -0000
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2003  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.
+
+# Make sure we allow Libtool's -dlopen/-dlpreopen
+
+required='libtoolize gcc'
+. ./defs || exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_LIBTOOL_DLOPEN
+AM_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LTLIBRARIES = libmod1.la mod2.la
+libmod1_la_SOURCES = mod1.c
+libmod1_la_LDFLAGS = -module
+libmod1_la_LIBADD = -dlopen mod2.la
+mod2_la_SOURCES = mod2.c
+mod2_la_LDFLAGS = -module
+
+bin_PROGRAMS = prg
+prg_SOURCES = prg.c
+prg_LDADD = -dlopen libmod1.la -dlpreopen mod2.la
+
+print:
+       @echo 1BEG: $(prg_DEPENDENCIES) :END1
+       @echo 2BEG: $(libmod1_la_DEPENDENCIES) :END2
+
+END
+
+mkdir liba
+
+cat > mod1.c << 'END'
+int
+mod1 ()
+{
+   return 1;
+}
+END
+
+cat > mod2.c << 'END'
+int
+mod2 ()
+{
+   return 2;
+}
+END
+
+cat > prg.c << 'END'
+int
+main ()
+{
+   return 0;
+}
+END
+
+libtoolize --force --copy
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing --copy
+
+./configure
+$MAKE print >output 2>&1
+cat output
+grep '1BEG: libmod1.la mod2.la :END1' output
+grep '2BEG: mod2.la :END2' output
+$MAKE

-- 
Alexandre Duret-Lutz





reply via email to

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