>From 5cc9c775dbe46343b651a7e6ac378f71e6a3b6c1 Mon Sep 17 00:00:00 2001 From: Peter Rosin
Date: Tue, 22 Jan 2013 11:17:11 +0100 Subject: [PATCH] reldir: Add support for relative names in included fragments automake.in (read_am_file): Add third argument specifying the relative directory of this makefile fragment compared to the main level makefile. Replace @am_reldir@ in the fragment with this relative directory. (read_main_am_file): Adjust. t/reldir.sh: New test. t/list-of-tests.mk: Augment. --- automake.in | 28 +++++++++++++++++---- t/list-of-tests.mk | 1 + t/reldir.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 5 deletions(-) create mode 100755 t/reldir.sh diff --git a/automake.in b/automake.in index 0e3b882..4e52aca 100644 --- a/automake.in +++ b/automake.in @@ -6330,15 +6330,15 @@ sub check_trailing_slash ($\$) } -# &read_am_file ($AMFILE, $WHERE) -# ------------------------------- +# &read_am_file ($AMFILE, $WHERE, $RELDIR) +# ---------------------------------------- # Read Makefile.am and set up %contents. Simultaneously copy lines # from Makefile.am into $output_trailer, or define variables as # appropriate. NOTE we put rules in the trailer section. We want # user rules to come after our generated stuff. sub read_am_file ($$) { - my ($amfile, $where) = @_; + my ($amfile, $where, $reldir) = @_; my $am_file = new Automake::XFile ("< $amfile"); verb "reading $amfile"; @@ -6423,6 +6423,18 @@ sub read_am_file ($$) my $new_saw_bk = check_trailing_slash ($where, $_); + if ($reldir ne '.') + { + my $rel_dir = &canonicalize ($reldir); + $_ =~ s/address@hidden@\//${reldir}\//g; + $_ =~ s/address@hidden@_/${rel_dir}_/g; + } + else + { + $_ =~ s/address@hidden@\///g; + $_ =~ s/address@hidden@_//g; + } + if (/$IGNORE_PATTERN/o) { # Merely delete comments beginning with two hashes. @@ -6584,8 +6596,14 @@ sub read_am_file ($$) push_dist_common ("\$\(srcdir\)/$path"); $path = $relative_dir . "/" . $path if $relative_dir ne '.'; } + my $new_reldir = $path; + # $new_reldir =~ s/\$\($reldir\)\///; + if ($new_reldir =~ s/\/[^\/]*$// == 0) + { + $new_reldir = '.'; + } $where->push_context ("'$path' included from here"); - &read_am_file ($path, $where); + &read_am_file ($path, $where, $new_reldir); $where->pop_context; } else @@ -6658,7 +6676,7 @@ sub read_main_am_file ($$) &define_standard_variables; # Read user file, which might override some of our values. - &read_am_file ($amfile, new Automake::Location); + &read_am_file ($amfile, new Automake::Location, '.'); } diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk index 44f598e..9501ed4 100644 --- a/t/list-of-tests.mk +++ b/t/list-of-tests.mk @@ -783,6 +783,7 @@ t/parallel-tests-no-spurious-summary.sh \ t/parallel-tests-exit-statuses.sh \ t/parallel-tests-console-output.sh \ t/parallel-tests-once.sh \ +t/reldir.sh \ t/tests-environment.sh \ t/am-tests-environment.sh \ t/tests-environment-backcompat.sh \ diff --git a/t/reldir.sh b/t/reldir.sh new file mode 100755 index 0000000..97fd0c2 --- /dev/null +++ b/t/reldir.sh @@ -0,0 +1,68 @@ +#! /bin/sh +# Copyright (C) 2003-2012 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