From 9fbed3bb3bd3583769e4936f8ac91095e97a26d1 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Thu, 5 Jan 2006 23:32:35 +0000 Subject: [PATCH] * automake.in (top_srcdir): New global. (generate_makefile): Compute it. (fill_dist_dirs): New function extracted from handle_dist. (handle_dist, handle_configure): Use fill_dist_dirs. * tests/distdir.test: Test for cases where $(top_srcdir) or $(srcdir) appear in EXTRA_DIST. Report from Sander Niemeijer. --- ChangeLog | 12 ++++++++- automake.in | 66 +++++++++++++++++++++++----------------------- tests/distdir.test | 22 +++++++++++++--- 3 files changed, 63 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index ed8739b3..31b3d391 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ +2006-01-05 Stepan Kasal + Alexandre Duret-Lutz + + * automake.in (top_srcdir): New global. + (generate_makefile): Compute it. + (fill_dist_dirs): New function extracted from handle_dist. + (handle_dist, handle_configure): Use fill_dist_dirs. + * tests/distdir.test: Test for cases where $(top_srcdir) or + $(srcdir) appear in EXTRA_DIST. Report from Sander Niemeijer. + 2006-01-05 Zack Weinberg - Ralf Wildenhues + Ralf Wildenhues * lib/depcomp: Add 'ia64hp' dependency style. Zack's original patch was contributed to GCC on 2005-06-13. diff --git a/automake.in b/automake.in index 81043847..dcccb347 100755 --- a/automake.in +++ b/automake.in @@ -7,7 +7,7 @@ eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' # automake - create Makefile.in from Makefile.am # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006 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 @@ -463,6 +463,9 @@ my $am_relative_dir; my $in_file_name; my $relative_dir; +# Relative path to the top directory. +my $topsrcdir; + # Greatest timestamp of the output's dependencies (excluding # configure's dependencies). my $output_deps_greatest_timestamp; @@ -3485,6 +3488,23 @@ sub for_dist_common return $a cmp $b; } +# fill_dist_dirs(@FILES) +# ---------------------- +# Record in %dist_dirs the directory part of any file passed. +sub fill_dist_dirs (@) +{ + my @copy = @_; + foreach (@copy) + { + s/\$\(top_srcdir\)/$topsrcdir/; + s/\$\(srcdir\)/./; + # Strip any leading `./'. + s,^(:?\./+)*,,; + next unless s,/+[^/]+$,,; + $dist_dirs{$_} = 1 + unless $_ eq '.'; + } +} # handle_dist # ----------- @@ -3602,34 +3622,18 @@ sub handle_dist () # originally, but there were so many requests that I finally # relented. my $extra_dist = var ('EXTRA_DIST'); - if ($extra_dist) - { - # FIXME: This should be fixed to work with conditions. That - # will require only making the entries in %dist_dirs under the - # appropriate condition. This is meaningful if the nature of - # the distribution should depend upon the configure options - # used. - foreach ($extra_dist->value_as_list_recursive (skip_ac_subst => 1)) - { - next unless s,/+[^/]+$,,; - $dist_dirs{$_} = 1 - unless $_ eq '.'; - } - } + # FIXME: This should be fixed to work with conditions. That + # will require only making the entries in %dist_dirs under the + # appropriate condition. This is meaningful if the nature of + # the distribution should depend upon the configure options + # used. + fill_dist_dirs ($extra_dist->value_as_list_recursive (skip_ac_subst => 1)) + if $extra_dist; # We have to check DIST_COMMON for extra directories in case the # user put a source used in AC_OUTPUT into a subdir. - my $topsrcdir = backname ($relative_dir); - foreach (rvar ('DIST_COMMON')->value_as_list_recursive (skip_ac_subst => 1)) - { - s/\$\(top_srcdir\)/$topsrcdir/; - s/\$\(srcdir\)/./; - # Strip any leading `./'. - s,^(:?\./+)*,,; - next unless s,/+[^/]+$,,; - $dist_dirs{$_} = 1 - unless $_ eq '.'; - } + fill_dist_dirs (rvar ('DIST_COMMON') + ->value_as_list_recursive (skip_ac_subst => 1)); $transform{'DISTCHECK-HOOK'} = !! rule 'distcheck-hook'; $transform{'GETTEXT'} = $seen_gettext && !$seen_gettext_external; @@ -4065,13 +4069,8 @@ sub handle_configure ($$$@) # is a bit ugly but it easier than spreading out the logic, # especially in cases like AC_OUTPUT(foo/out:bar/in), where # there is no Makefile in bar/. - if ($relative_dir eq '.') - { - foreach (@inputs) - { - $dist_dirs{dirname ($_)} = 1; - } - } + fill_dist_dirs (@inputs) + if $relative_dir eq '.'; # We skip files that aren't in this directory. However, if # the file's directory does not have a Makefile, and we are @@ -7370,6 +7369,7 @@ sub generate_makefile ($$) $relative_dir = dirname ($makefile); $am_relative_dir = dirname ($makefile_am); + $topsrcdir = backname ($relative_dir); read_main_am_file ($makefile_am); if (handle_options) diff --git a/tests/distdir.test b/tests/distdir.test index 111ec0f9..33247cb9 100755 --- a/tests/distdir.test +++ b/tests/distdir.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1996, 2001, 2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 1996, 2001, 2002, 2003, 2006 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -19,22 +19,38 @@ # Boston, MA 02110-1301, USA. # Test to make sure subdirs in EXTRA_DIST work. Also tests to make -# sure "./" is ignored. +# sure "./" is ignored and *srcdir properly handled. . ./defs || exit 1 set -e +echo AC_OUTPUT >>configure.in + cat > Makefile.am << 'END' -EXTRA_DIST = foo/bar ./joe +EXTRA_DIST = foo/bar ./joe $(top_srcdir)/woo/doo $(srcdir)/dada +check-local: + test -f $(srcdir)/foo/bar + test -f $(srcdir)/woo/doo + test -f $(srcdir)/joe + test -f $(srcdir)/dada END $ACLOCAL +$AUTOCONF $AUTOMAKE +mkdir foo woo +touch foo/bar joe woo/doo dada + grep '\$(mkdir_p).*\.' Makefile.in && exit 1 +grep '\$(mkdir_p).*srcdir' Makefile.in && exit 1 grep '\$(mkdir_p).*foo' Makefile.in # Check to make sure `foo' isn't made in build directory. grep 'mkdir_p.*foo.*foo' Makefile.in && exit 1 + +./configure --prefix `pwd` +$MAKE distcheck + exit 0 -- 2.43.5