]> Savannah Git Hosting - gnulib.git/commitdiff
automake-subdir support: Support arbitrary --source-base value.
authorBruno Haible <bruno@clisp.org>
Wed, 15 Dec 2021 21:36:40 +0000 (22:36 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 15 Dec 2021 21:36:40 +0000 (22:36 +0100)
Reported by Marc Nieper-Wißkirchen in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-12/msg00066.html>.

* build-aux/prefix-gnulib-mk ($canon_prefix): New variable.
(prefix): Initialize it.
(prefix_assignment): Use it.

ChangeLog
build-aux/prefix-gnulib-mk

index dafd27b6638bc58ec5a17648acbb702fc9dfecbe..197d497f8915a251b77cec883ed5f704c6a183c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2021-12-15  Bruno Haible  <bruno@clisp.org>
+
+       automake-subdir support: Support arbitrary --source-base value.
+       Reported by Marc Nieper-Wißkirchen in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2021-12/msg00066.html>.
+       * build-aux/prefix-gnulib-mk ($canon_prefix): New variable.
+       (prefix): Initialize it.
+       (prefix_assignment): Use it.
+
 2021-12-15  Bruno Haible  <bruno@clisp.org>
 
        automake-subdir support: Look for 'subdir-objects' also in configure.ac.
index 36f7527fcd7308ade6a982090d487f9b802cb939..4f300c44332dec9673433c261494eee591aff2c3 100755 (executable)
@@ -40,6 +40,7 @@ use File::Basename; # for dirname
 (my $ME = $0) =~ s|.*/||;
 
 my $prefix;
+my $canon_prefix;
 my $lib_name;
 
 sub usage ($)
@@ -171,7 +172,7 @@ sub prefix_assignment ($$)
 
   # Variables whose name depend on the location: libbison_a_SOURCES =>
   # lib_libbison_a_SOURCES.
-  $lhs_and_assign_op =~ s/($lib_name)/lib_$1/g;
+  $lhs_and_assign_op =~ s/($lib_name)/$canon_prefix$1/g;
 
   $lhs_and_assign_op . $rhs;
 }
@@ -187,6 +188,12 @@ sub prefix ($)
   # Work on $_.
   local ($_) = @_;
 
+  # $canon_prefix is derived from $prefix in the same way as Automake
+  # derives %canon_reldir% from %reldir%. See
+  # <https://www.gnu.org/software/automake/manual/html_node/Include.html>.
+  $canon_prefix = $prefix;
+  $canon_prefix =~ s/[^a-zA-Z0-9_]/_/g;
+
   # Prefix all the occurrence of files in rules.  If there is nothing
   # after in the :, it's probably a phony target, or a suffix rule.
   # Don't touch it.