bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Non-recursive Make and prefix-gnulib-mk


From: Marc Nieper-Wißkirchen
Subject: Re: Non-recursive Make and prefix-gnulib-mk
Date: Thu, 16 Dec 2021 17:59:46 +0100

Dear Bruno,

thank you very much for the quick fix.

I am currently testing it.  I still have a problem with the Makefile lines eventually produced by gl_CONDITIONAL_HEADER in m4/gnulib-common.m4.

Am I supposed to set ${gl_source_base_prefix} somewhere?  If it helps:  I am using a configuration based on bootstrap and I have set source_base (and tests_base) in bootstrap.conf.

Thanks,

Marc

Am Mi., 15. Dez. 2021 um 22:43 Uhr schrieb Bruno Haible <bruno@clisp.org>:
Marc Nieper-Wißkirchen wrote:
> I'm using build-aux/prefix-gnulib-mk to rewrite the Gnulib Makefile
> fragment so that it can be included by a Makefile in a top-level directory.
>
> What I haven't managed to get working, though, is renaming the Gnulib lib/
> directory at the same time (by setting $source_base in bootstrap.conf). The
> Perl script build-aux/prefix-gnulib-mk still prefixes the Automake
> variables with lib_ as in
>
> lib_libgnu_la_SOURCES =
>
> I don't know much Perl but the relevant source line seems to be
>
> https://git.savannah.gnu.org/cgit/gnulib.git/tree/build-aux/prefix-gnulib-mk#n165
>
> The issue is possibly fixed just by replacing the string lib_ by %C% (see
> [1]).

Fixed through this patch.

You are right, %C% would also fix it. But since we are generating the Makefile
part anyway and know where it is located, we can just as well put in the actual
relative subdirectory. This makes the generated code easier to understand.


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.

diff --git a/build-aux/prefix-gnulib-mk b/build-aux/prefix-gnulib-mk
index 36f7527fc..4f300c443 100755
--- a/build-aux/prefix-gnulib-mk
+++ b/build-aux/prefix-gnulib-mk
@@ -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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]