From: Alexandre Duret-Lutz Date: Sat, 22 May 2004 14:23:54 +0000 (+0000) Subject: * automake.in (handle_libraries): Make the diagnostic about X-Git-Tag: Release-1-8b~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a91f0ec9d8016b8415c9fdf3b94ca98d1cbf39d7;p=thirdparty%2Fautomake.git * automake.in (handle_libraries): Make the diagnostic about non standard libraries a warning in foreign packages. This is already the case in handle_ltlibraries. (handle_libraries, handle_ltlibraries): Suggest a standard library name in the diagnostic, to help newcomers. * tests/stdlib.test, tests/stdlib2.test: Check for these suggestions. --- diff --git a/ChangeLog b/ChangeLog index a85b04394..852170f89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2004-05-22 Alexandre Duret-Lutz + * automake.in (handle_libraries): Make the diagnostic about + non standard libraries a warning in foreign packages. This + is already the case in handle_ltlibraries. + (handle_libraries, handle_ltlibraries): Suggest a standard + library name in the diagnostic, to help newcomers. + * tests/stdlib.test, tests/stdlib2.test: Check for these + suggestions. + Check directory names for unportable names. Shaking the code to check this also led to the removal of the no-"/"-in-SUBDIRS restriction, and a fix to _do_recursive_traversal. diff --git a/automake.in b/automake.in index afd4b93e8..7914b9d53 100755 --- a/automake.in +++ b/automake.in @@ -2357,9 +2357,15 @@ sub handle_libraries my $seen_libobjs = 0; # Check that the library fits the standard naming convention. - if (basename ($onelib) !~ /^lib.*\.a/) + my $bn = basename ($onelib); + if ($bn !~ /^lib.*\.a$/) { - error $where, "`$onelib' is not a standard library name"; + $bn =~ s/^(?:lib)?(.*?)(?:\.[^.]*)?$/lib$1.a/; + my $suggestion = dirname ($onelib) . "/$bn"; + $suggestion =~ s|^\./||g; + msg ('error-gnu/warn', $where, + "`$onelib' is not a standard library name\n" + . "did you mean `$suggestion'?") } $where->push_context ("while processing library `$onelib'"); @@ -2523,25 +2529,40 @@ sub handle_ltlibraries '_DEPENDENCIES'); # Check that the library fits the standard naming convention. - my $libname_rx = "^lib.*\.la"; + my $libname_rx = '^lib.*\.la'; my $ldvar = var ("${xlib}_LDFLAGS") || var ('AM_LDFLAGS'); my $ldvar2 = var ('LDFLAGS'); if (($ldvar && grep (/-module/, $ldvar->value_as_list_recursive)) || ($ldvar2 && grep (/-module/, $ldvar2->value_as_list_recursive))) { # Relax name checking for libtool modules. - $libname_rx = "\.la"; + $libname_rx = '\.la'; } - if (basename ($onelib) !~ /$libname_rx$/) + + my $bn = basename ($onelib); + if ($bn !~ /$libname_rx$/) { + my $type = 'library'; + if ($libname_rx eq '\.la') + { + $bn =~ s/^(lib|)(.*?)(?:\.[^.]*)?$/$1$2.la/; + $type = 'module'; + } + else + { + $bn =~ s/^(?:lib)?(.*?)(?:\.[^.]*)?$/lib$1.la/; + } + my $suggestion = dirname ($onelib) . "/$bn"; + $suggestion =~ s|^\./||g; msg ('error-gnu/warn', $where, - "`$onelib' is not a standard libtool library name"); + "`$onelib' is not a standard libtool $type name\n" + . "did you mean `$suggestion'?") } $where->push_context ("while processing Libtool library `$onelib'"); $where->set (INTERNAL->get); - # Make sure we at look at these. + # Make sure we look at these. set_seen ($xlib . '_LDFLAGS'); set_seen ($xlib . '_DEPENDENCIES'); diff --git a/tests/stdlib.test b/tests/stdlib.test index 1f4bdad4f..9c0282d65 100755 --- a/tests/stdlib.test +++ b/tests/stdlib.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1996, 2001, 2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 1996, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -30,10 +30,11 @@ AC_PROG_RANLIB END cat > Makefile.am << 'END' -noinst_LIBRARIES = foo +noinst_LIBRARIES = sub/foo END $ACLOCAL AUTOMAKE_fails # We're specifically testing for line-number information. -grep 'Makefile.am:1:.*foo.*standard library name' stderr +grep 'Makefile.am:1:.*sub/foo.*standard library name' stderr +grep 'Makefile.am:1:.*sub/libfoo.a.*' stderr diff --git a/tests/stdlib2.test b/tests/stdlib2.test index eee1c5134..37102f748 100755 --- a/tests/stdlib2.test +++ b/tests/stdlib2.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -51,12 +51,14 @@ END $ACLOCAL AUTOMAKE_fails --add-missing --gnu -grep 'nonstandard.la.*not a standard libtool library name' stderr +grep 'Makefile.am:2:.*nonstandard.la.*standard libtool library name' stderr +grep 'Makefile.am:2:.*libnonstandard.la' stderr -# We will use -Wno-gnu to disable the warning about setting LDFLAGS. +# We will use -Wno-gnu to disable the warning about setting LDFLAGS (below) # Make sure nonstandard names are diagnosed anyway. AUTOMAKE_fails --add-missing --gnu -Wno-gnu -grep 'nonstandard.la.*not a standard libtool library name' stderr +grep 'Makefile.am:2:.*nonstandard.la.*standard libtool library name' stderr +grep 'Makefile.am:2:.*libnonstandard.la' stderr # Make sure nonstandard_la_LDFLAGS is read even if LDFLAGS is used. cat >Makefile.inc <<'EOF' @@ -78,6 +80,20 @@ nonstandard_la_LDFLAGS = -lfoo AM_LDFLAGS = -module EOF AUTOMAKE_fails +grep 'Makefile.am:2:.*nonstandard.la.*standard libtool library name' stderr +grep 'Makefile.am:2:.*libnonstandard.la' stderr echo 'AM_LDFLAGS = -module' > Makefile.inc $AUTOMAKE + +# For module, Automake should not suggest the lib prefix. +cat > Makefile.am << 'END' +include Makefile.inc +lib_LTLIBRARIES = nonstandard +nonstandard_SOURCES = foo.c +FOO = -module +END + +AUTOMAKE_fails +grep "Makefile.am:2:.*nonstandard'.*standard libtool module name" stderr +grep 'Makefile.am:2:.*`nonstandard.la' stderr