[reviving and old thread] Hello automakers. Ping on this?
Reference: <http://lists.gnu.org/archive/html/automake-patches/2010-09/msg00246.html> I've rebased the patch on latest maint, and successfully re-run the testsuite (no failures with GNU make 3.82, only already-known failures with Solaris 10 XPG4 make and Solaris 10 dmake). The updated patch is attached. OK to apply to maint? Regards, Stefano
From df5375dbfa4f39fa8d59f940e35f78fadae70a92 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini <stefano.lattar...@gmail.com> Date: Fri, 14 May 2010 21:19:32 +0200 Subject: [PATCH] Work around a bug in file-inclusion mechanism of Solaris make. * automake.in (handle_single_transform): In the name of the dependency file: collapse multiple slash characters into a single one. * tests/subobj11a.test: New test. * tests/subobj11b.test: Likewise. * tests/subobj11c.test: Likewise. * tests/depcomp8a.test: Likewise. * tests/depcomp8b.test: Likewise. * tests/Makefile.am (TESTS): Updated. * NEWS: Updated. Report by Stefano Lattarini, quick fix by Ralf Wildenhues, final patch and tests by Stefano Lattarini. --- ChangeLog | 17 ++++++++++ NEWS | 4 ++ automake.in | 26 ++++++++++---- tests/Makefile.am | 5 +++ tests/Makefile.in | 5 +++ tests/depcomp8a.test | 79 +++++++++++++++++++++++++++++++++++++++++++++ tests/depcomp8b.test | 73 ++++++++++++++++++++++++++++++++++++++++++ tests/subobj11a.test | 82 +++++++++++++++++++++++++++++++++++++++++++++++ tests/subobj11b.test | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/subobj11c.test | 53 ++++++++++++++++++++++++++++++ 10 files changed, 423 insertions(+), 8 deletions(-) create mode 100755 tests/depcomp8a.test create mode 100755 tests/depcomp8b.test create mode 100755 tests/subobj11a.test create mode 100755 tests/subobj11b.test create mode 100755 tests/subobj11c.test diff --git a/ChangeLog b/ChangeLog index 3eee3a7..7b9516d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2010-12-17 Ralf Wildenhues <ralf.wildenh...@gmx.de> + Stefano Lattarini <stefano.lattar...@gmail.com> + + Work around a bug in file-inclusion mechanism of Solaris make. + * automake.in (handle_single_transform): In the name of the + dependency file: collapse multiple slash characters into a single + one. + * tests/subobj11a.test: New test. + * tests/subobj11b.test: Likewise. + * tests/subobj11c.test: Likewise. + * tests/depcomp8a.test: Likewise. + * tests/depcomp8b.test: Likewise. + * tests/Makefile.am (TESTS): Updated. + * NEWS: Updated. + Report by Stefano Lattarini, quick fix by Ralf Wildenhues, final + patch and tests by Stefano Lattarini. + 2010-12-16 Stefano Lattarini <stefano.lattar...@gmail.com> docs: list LTLIBRARIES among Automake primaries diff --git a/NEWS b/NEWS index 6bc0d6f..5f1fd5b 100644 --- a/NEWS +++ b/NEWS @@ -49,6 +49,10 @@ Bugs fixed in 1.11.0a: - Rules generated by Automake now try harder to not change any files when `make -n' is invoked. Fixes include compilation of Emacs Lisp, Vala, or Yacc source files and the rule to update config.h. + + - The code for automatic dependency tracking works around a Solaris + make bug triggered by sources containing repeated slashes when the + `subdir-objects' was used. New in 1.11: diff --git a/automake.in b/automake.in index 8f3edde..bf45fa7 100755 --- a/automake.in +++ b/automake.in @@ -2108,14 +2108,24 @@ sub handle_single_transform ($$$$$%) # Transform .o or $o file into .P file (for automatic # dependency code). - if ($lang && $lang->autodep ne 'no') - { - my $depfile = $object; - $depfile =~ s/\.([^.]*)$/.P$1/; - $depfile =~ s/\$\(OBJEXT\)$/o/; - $dep_files{dirname ($depfile) . '/$(DEPDIR)/' - . basename ($depfile)} = 1; - } + # Properly flatten multiple adjacent slashes, as Solaris 10 make + # might fail over them in an include statement. + # Leading double slashes may be special, as per Posix, so deal + # with them carefully. + if ($lang && $lang->autodep ne 'no') + { + my $depfile = $object; + $depfile =~ s/\.([^.]*)$/.P$1/; + $depfile =~ s/\$\(OBJEXT\)$/o/; + my $maybe_extra_leading_slash = ''; + $maybe_extra_leading_slash = '/' if $depfile =~ m,^//[^/],; + $depfile =~ s,/+,/,g; + my $basename = basename ($depfile); + # This might make $dirname empty, but we account for that below. + (my $dirname = dirname ($depfile)) =~ s/\/*$//; + $dirname = $maybe_extra_leading_slash . $dirname; + $dep_files{$dirname . '/$(DEPDIR)/' . $basename} = 1; + } } return @result; diff --git a/tests/Makefile.am b/tests/Makefile.am index dab04e3..8842be3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -262,6 +262,8 @@ depcomp4.test \ depcomp5.test \ depcomp6.test \ depcomp7.test \ +depcomp8a.test \ +depcomp8b.test \ depdist.test \ depend.test \ depend2.test \ @@ -692,6 +694,9 @@ subobj7.test \ subobj8.test \ subobj9.test \ subobj10.test \ +subobj11a.test \ +subobj11b.test \ +subobj11c.test \ subobjname.test \ subpkg.test \ subpkg2.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index de21f43..a9d1fd1 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -529,6 +529,8 @@ depcomp4.test \ depcomp5.test \ depcomp6.test \ depcomp7.test \ +depcomp8a.test \ +depcomp8b.test \ depdist.test \ depend.test \ depend2.test \ @@ -959,6 +961,9 @@ subobj7.test \ subobj8.test \ subobj9.test \ subobj10.test \ +subobj11a.test \ +subobj11b.test \ +subobj11c.test \ subobjname.test \ subpkg.test \ subpkg2.test \ diff --git a/tests/depcomp8a.test b/tests/depcomp8a.test new file mode 100755 index 0000000..b4a0e3a --- /dev/null +++ b/tests/depcomp8a.test @@ -0,0 +1,79 @@ +#! /bin/sh +# Copyright (C) 2010 Free Software Foundation, Inc. +# +# This program 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. +# +# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + +# Test for regressions in computation of names of .Po files for +# automatic dependency tracking. +# Keep this in sync with sister test `depcomp8b.test', which checks the +# same thing for libtool objects. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_PROG_CC +AC_OUTPUT +END + +cat > Makefile.am << 'END' +bin_PROGRAMS = zardoz +zardoz_SOURCES = foo.c sub/bar.c +END + +mkdir sub +cat > foo.c << 'END' +int main(void) +{ + extern int bar; + return bar; +} +END +cat > sub/bar.c << 'END' +extern int bar = 0; +END + +$ACLOCAL +$AUTOMAKE -a +grep include Makefile.in # for debugging +grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in +grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in +grep 'include.*/\./\$(DEPDIR)' Makefile.in && Exit 1 + +$AUTOCONF +./configure +$MAKE +./zardoz +$MAKE distcheck + +# Try again with subdir-objects option. + +echo AM_PROG_CC_C_O >> configure.in +echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am + +$ACLOCAL +$AUTOMAKE -a +grep include Makefile.in # for debugging +grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in +grep 'include.*[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.P' Makefile.in +$EGREP 'include.*/(\.|sub)/\$\(DEPDIR\)' Makefile.in && Exit 1 + +$AUTOCONF +./configure +$MAKE +./zardoz +$MAKE distcheck + +: diff --git a/tests/depcomp8b.test b/tests/depcomp8b.test new file mode 100755 index 0000000..1ae7459 --- /dev/null +++ b/tests/depcomp8b.test @@ -0,0 +1,73 @@ +#! /bin/sh +# Copyright (C) 2010 Free Software Foundation, Inc. +# +# This program 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. +# +# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + +# Test for regressions in computation of names of .Plo files for +# automatic dependency tracking. +# Keep this in sync with sister test `depcomp8a.test', which checks the +# same thing for non-libtool objects. + +required=libtoolize +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_PROG_CC +AC_PROG_LIBTOOL +AC_OUTPUT +END + +cat > Makefile.am << 'END' +lib_LTLIBRARIES = libzardoz.la +libzardoz_la_SOURCES = foo.c sub/bar.c +END + +mkdir sub +echo 'extern int foo = 0;' > foo.c +echo 'extern int bar = 0;' > sub/bar.c + +libtoolize + +$ACLOCAL +$AUTOMAKE -a +grep include Makefile.in # for debugging +grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in +grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in +grep 'include.*/\./\$(DEPDIR)' Makefile.in && Exit 1 + +$AUTOCONF +./configure +$MAKE +$MAKE distcheck + +# Try again with subdir-objects option. + +echo AM_PROG_CC_C_O >> configure.in +echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am + +$ACLOCAL +$AUTOMAKE -a +grep include Makefile.in # for debugging +grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in +grep 'include.*[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.P' Makefile.in +$EGREP 'include.*/(\.|sub)/\$\(DEPDIR\)' Makefile.in && Exit 1 + +$AUTOCONF +./configure +$MAKE +$MAKE distcheck + +: diff --git a/tests/subobj11a.test b/tests/subobj11a.test new file mode 100755 index 0000000..c39e67c --- /dev/null +++ b/tests/subobj11a.test @@ -0,0 +1,82 @@ +#! /bin/sh +# Copyright (C) 2010 Free Software Foundation, Inc. +# +# This program 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. +# +# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + +# Test that automake works around a bug of Solaris Make. The bug is the +# following. If we have a Makefile containg a file inclusion like this: +# include .//foo.mk +# Solaris make fails with a message like: +# make: ... can't find `/foo.mk': No such file or directory +# make: fatal error ... read of include file `/foo.mk' failed +# (even if the file `foo.mk' exists). The error disappear by collapsing +# the repeated slash `/' characters into a single one. +# +# See also sister "grepping" test `subobj11b.test', and related test +# `subobj11c.test'. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_PROG_CC +AM_PROG_CC_C_O +AC_OUTPUT +END + +cat > Makefile.am << 'END' +AUTOMAKE_OPTIONS = subdir-objects +bin_PROGRAMS = foo +## the `.//' is meant +foo_SOURCES = .//src/foo.c +END + +mkdir src + +cat > src/foo.c << 'END' +int main(void) +{ + return 0; +} +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a + +./configure --enable-dependency-tracking + +depdir=`sed -n 's/^ *DEPDIR *= *//p' Makefile` +if test x"$depdir" != x; then + depdir=src/$depdir +else + echo "$me: cannot extract value of DEPDIR from Makefile" >&2 + Exit 1 +fi + +ls -l "$depdir" +test -f "$depdir"/foo.Po + +echo 'quux:; echo "z...@rd@z" >$@' >> "$depdir"/foo.Po + +$MAKE quux +$FGREP "z...@rd@z" quux + +$MAKE + +$MAKE DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' distcheck +$MAKE DISTCHECK_CONFIGURE_FLAGS='--disable-dependency-tracking' distcheck + +: diff --git a/tests/subobj11b.test b/tests/subobj11b.test new file mode 100755 index 0000000..1db5fab --- /dev/null +++ b/tests/subobj11b.test @@ -0,0 +1,87 @@ +#! /bin/sh +# Copyright (C) 2010 Free Software Foundation, Inc. +# +# This program 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. +# +# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + +# Test that automake works around a bug of Solaris Make. The bug is the +# following. If we have a Makefile containg a file inclusion like this: +# include .//foo.mk +# Solaris make fails with a message like: +# make: ... can't find `/foo.mk': No such file or directory +# make: fatal error ... read of include file `/foo.mk' failed +# (even if the file `foo.mk' exists). The error disappear by collapsing +# the repeated slash `/' characters into a single one. +# +# See also "semantic" sister test `subobj11a.test', and related test +# `subobj11c.test'. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_PROG_CC +AM_PROG_CC_C_O +END + +cat > Makefile.am << 'END' +AUTOMAKE_OPTIONS = subdir-objects +bin_PROGRAMS = foo +## The `zardoz' sources should activate a code paths in Automake that +## cannot be sensibly tested by sister test `subobj11a.test'. The other +## sources provide some sort of stress testing. +foo_SOURCES = \ + //server/zardoz0.c \ + //server//zardoz1.c \ + //server/path/to/zardoz2.c \ + //server/another//path///to////zardoz3.c \ + /foobar0.c \ + ///foobar1.c \ + ////foobar2.c \ + /sub///foobar3.c \ + ///sub/foobar4.c \ + .//foobar5.c \ + .//sub/foobar6.c \ + ./sub//foobar7.c \ + .//sub//foobar8.c \ + sub/sub//sub///sub////foobar9.c +END + +$ACLOCAL +$AUTOMAKE -a + +# Be lax in the regexp, to account for automake conditionals, the +# use of @am__include@, and similar stuff. +grep 'include.*//.*foobar' Makefile.in && Exit 1 + +# These checks depend on automake internals, but presently this is +# the only way to test the code path we are interested in. +# Please update these checks when (and if) the relevant automake +# internals are changed. +for x in zardoz0 zardoz1 path/to/zardoz2 another/path/to/zardoz3; do + case $x in + */*) d=`echo $x | sed 's,[^/]*$,,'`; b=`echo $x | sed 's,^.*/,,'`;; + *) d=''; b=$x;; + esac + # Be a little lax in the regexp, to account for automake conditionals, + # quoting, and similar stuff. + grep "^[^/]*am__include[^/]*//server/$d\\\$(DEPDIR)/$b\\.[^/]*$" Makefile.in +done + +# Sanity checks. +for i in 0 1 2 3 4 5 6 7 8 9; do + grep "am__include.*/foobar$i\\." Makefile.in +done + +: diff --git a/tests/subobj11c.test b/tests/subobj11c.test new file mode 100755 index 0000000..9262d15 --- /dev/null +++ b/tests/subobj11c.test @@ -0,0 +1,53 @@ +#! /bin/sh +# Copyright (C) 2010 Free Software Foundation, Inc. +# +# This program 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. +# +# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + +# Automatic dependency tracking with subdir-objects option active: +# check for a pathological case of slash-collapsing in the name of +# included makefile fragments (containing dependency info). +# See also related tests `subobj11a.test' and `subobj11b.test' + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_PROG_CC +AM_PROG_CC_C_O +END + +cat > Makefile.am << 'END' +AUTOMAKE_OPTIONS = subdir-objects +bin_PROGRAMS = foo +foo_SOURCES = //zardoz.c +END + +$ACLOCAL +$AUTOMAKE -a + +# +# This check depends on automake internals, but presently this is +# the only way to test the code path we are interested in. +# Please update these checks when (and if) the relevant automake +# internals are changed. +# +# Be a little lax in the regexp, to account for automake conditionals, +# quoting, and similar stuff. +# +# FIXME: Are we sure this is the most sensible output in our situation? +# +grep '^[^/]*am__include[^/]*//\$(DEPDIR)/zardoz\.[^/]*$' Makefile.in + +: -- 1.7.1