]> sourceware.org Git - automake.git/commitdiff
* automake.in (handle_lib_objects_cond): Ignore -dlopen and
authorAlexandre Duret-Lutz <adl@gnu.org>
Fri, 31 Jan 2003 23:40:58 +0000 (23:40 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Fri, 31 Jan 2003 23:40:58 +0000 (23:40 +0000)
-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.

ChangeLog
automake.in
tests/Makefile.am
tests/Makefile.in
tests/libtool7.test [new file with mode: 0755]

index d752932f4fdedc0948fe2b9e29a30ca87b4681ee..7c70adf95dde900b055b451e9fd0d5b2b703c197 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2003-01-31  Alexandre Duret-Lutz  <adl@gnu.org>
 
+       * 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.
+
        * automake.texi (Program and Library Variables): Clarify that
        _LIBADD is for libraries and _LDADD for programs.
 
           verbose                 -> verb
        * automake.texi (Invoking Automake): Document -W and --warnings.
        Remove the documentation for --Werror and --Wno-error.
-       * tests/defs: Use -Werror, no --Werror.
+       * tests/defs: Use -Werror, not --Werror.
        * tests/exeext2.test: Test that the error message
        is enabled with -Wobsolete.
        * tests/output5.test: Rewrite to test that Automake complains
index 50359d3ff18630ef2b692b3bb3aa752a3aed8fc1..c6045cb99e64750f3d13331eca944b6654b785f8 100755 (executable)
@@ -2942,105 +2942,61 @@ sub handle_lib_objects
 # 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$/;
 
-       # 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 =~ /^\@.*\@$/;
+         prog_error ("unexpected variable name `$var'")
+           unless $var =~ /^(.*)(?:LIB|LD)ADD$/;
 
-       # Automatically handle LIBOBJS and ALLOCA substitutions.
-       # Basically this means adding entries to dep_files.
-       if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
-       {
-           my $lt = $1 ? $1 : '';
-           my $myobjext = ($1 ? 'l' : '') . 'o';
+         my $prefix = $1 || 'AM_';
+         # Only get this error once.
+         $flagvar = 1;
+         err_var ($var, "linker flags such as `$lsearch' belong in "
+                  . "`${prefix}LDFLAGS");
+       }
 
-           push (@dep_list, $lsearch);
-           $seen_libobjs = 1;
-           if (! keys %libsources
-               && ! variable_defined ($lt . 'LIBOBJS'))
-           {
-               err_var ($var, "\@${lt}LIBOBJS\@ seen but never set in "
-                        . "`$configure_ac'");
-           }
+      # 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 =~ /^\@.*\@$/;
 
-           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);
-                   }
-               }
-           }
+      # Automatically handle LIBOBJS and ALLOCA substitutions.
+      # Basically this means adding entries to dep_files.
+      if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
+       {
+         handle_LIBOBJS ($var, $cond, $1);
+         $seen_libobjs = 1;
+         push (@dep_list, $lsearch);
        }
-       elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
+      elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
        {
-           my $lt = $1 ? $1 : '';
-           my $myobjext = ($1 ? 'l' : '') . 'o';
-
-           push (@dep_list, $lsearch);
-           err_var ($var, "\@${lt}ALLOCA\@ 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 @@ sub handle_lib_objects_cond
   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, "\@${lt}LIBOBJS\@ 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, "\@${lt}ALLOCA\@ 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 @@ sub handle_libraries
          &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 @@ sub handle_libraries
        }
       else
        {
-         # Generate support for conditional object inclusion in
-         # libraries.
          &define_variable ($xlib . "_LIBADD", '', $where);
        }
 
@@ -3483,6 +3494,8 @@ sub handle_ltlibraries
          &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 @@ sub handle_ltlibraries
        }
       else
        {
-         # Generate support for conditional object inclusion in
-         # libraries.
          &define_variable ($xlib . "_LIBADD", '', $where);
        }
 
index b3d905d7622e2fdfb081904546a3744fae7071e2..6a87dcb65ce2812e8378be2e403aa79c09fefc81 100644 (file)
@@ -241,6 +241,7 @@ libtool3.test \
 libtool4.test \
 libtool5.test \
 libtool6.test \
+libtool7.test \
 link_c_cxx.test        \
 link_dist.test \
 link_fc.test \
index aebda5925d3f33718a59a6205e1cf5184ef558fa..0e6e1e40e16dc5468165b08919cc6e728cda89a4 100644 (file)
@@ -335,6 +335,7 @@ libtool3.test \
 libtool4.test \
 libtool5.test \
 libtool6.test \
+libtool7.test \
 link_c_cxx.test        \
 link_dist.test \
 link_fc.test \
diff --git a/tests/libtool7.test b/tests/libtool7.test
new file mode 100755 (executable)
index 0000000..29b4d91
--- /dev/null
@@ -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
This page took 0.051765 seconds and 5 git commands to generate.