From: Alexandre Duret-Lutz Date: Fri, 31 Jan 2003 23:40:58 +0000 (+0000) Subject: * automake.in (handle_lib_objects_cond): Ignore -dlopen and X-Git-Tag: Release-1-7b~293 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=f56c975a4bac475dff025f0d1a912bae2ed5210a;p=automake.git * 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. --- diff --git a/ChangeLog b/ChangeLog index d752932f..7c70adf9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2003-01-31 Alexandre Duret-Lutz + * 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. @@ -1978,7 +1985,7 @@ 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 diff --git a/automake.in b/automake.in index 50359d3f..c6045cb9 100755 --- a/automake.in +++ b/automake.in @@ -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); } diff --git a/tests/Makefile.am b/tests/Makefile.am index b3d905d7..6a87dcb6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -241,6 +241,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/Makefile.in b/tests/Makefile.in index aebda592..0e6e1e40 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -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 index 00000000..29b4d919 --- /dev/null +++ b/tests/libtool7.test @@ -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