# 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);
}
}
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
{
&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'))
}
else
{
- # Generate support for conditional object inclusion in
- # libraries.
&define_variable ($xlib . "_LIBADD", '', $where);
}
&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'))
}
else
{
- # Generate support for conditional object inclusion in
- # libraries.
&define_variable ($xlib . "_LIBADD", '', $where);
}
--- /dev/null
+#! /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