bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / code / Atom feed
* inflexible non-recursive support
@ 2021-06-22 16:33 Werner LEMBERG
  2021-06-22 19:06 ` Paul Eggert
  2021-06-23  9:16 ` Werner LEMBERG
  0 siblings, 2 replies; 3+ messages in thread
From: Werner LEMBERG @ 2021-06-22 16:33 UTC (permalink / raw)
  To: bug-gnulib


[c7b1e060d17023065c776757da406d728310cc38]

Dear gnulib maintainers,


Currently, the script `prefix-gnulib-mk` replaces variables like
`libbison_a_SOURCES` with `lib_libbison_a_SOURCES`.  However, this
works only if the directory is indeed `lib/', which is not the general
case.  For example, in my project I would like to call the script as

  prefix-gnulib-mk --lib-name=libgnu gnulib/src/$gnulib_mk

I suggest a patch as below (which needs further polishing to properly
canonicalize the directory path, I guess).

A similar problem exists with
`modules/non-recursive-gnulib-prefix-hack`, which has the directory
name `lib` hard-coded.  Isn't it possible to modify `gnulib-tool` so
that it patches `non-resursive-gnulib-prefix-hack.m4` based on the
value of option `--source-base`?

Right now I have to manually patch `gnulib-comp.m4` (using function
`bootstrap_post_import_hook`) for changing `lib` to `gnulib/src`...


    Werner


======================================================================


diff --git a/build-aux/prefix-gnulib-mk b/build-aux/prefix-gnulib-mk
index 347ddcd64..4eea8b738 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 $varprefix;
 my $lib_name;
 
 sub usage ($)
@@ -162,7 +163,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)/${varprefix}$1/g;
 
   $lhs_and_assign_op . $rhs;
 }
@@ -243,6 +244,8 @@ sub process ($)
 
   my $file = $ARGV[0];
   $prefix = (dirname $file) . '/';
+  $varprefix = $prefix;
+  $varprefix =~ s{/}{_}g;
   warn "prefix=$prefix\n";
 
   process $file;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: inflexible non-recursive support
  2021-06-22 16:33 inflexible non-recursive support Werner LEMBERG
@ 2021-06-22 19:06 ` Paul Eggert
  2021-06-23  9:16 ` Werner LEMBERG
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggert @ 2021-06-22 19:06 UTC (permalink / raw)
  To: Werner LEMBERG, bug-gnulib

On 6/22/21 9:33 AM, Werner LEMBERG wrote:
> I suggest a patch as below (which needs further polishing to properly
> canonicalize the directory path, I guess).

Thanks for the suggestion. Could you spell out a little more what sort 
of polishing would be needed there? (I'm not a regular user of this 
feature....)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: inflexible non-recursive support
  2021-06-22 16:33 inflexible non-recursive support Werner LEMBERG
  2021-06-22 19:06 ` Paul Eggert
@ 2021-06-23  9:16 ` Werner LEMBERG
  1 sibling, 0 replies; 3+ messages in thread
From: Werner LEMBERG @ 2021-06-23  9:16 UTC (permalink / raw)
  To: bug-gnulib


[Please CC me; I'm not on the list.]

I wrote

  For example, in my project I would like to call the script as

    prefix-gnulib-mk --lib-name=libgnu gnulib/src/$gnulib_mk

  I suggest a patch as below (which needs further polishing to
  properly canonicalize the directory path, I guess).

and Paul asked:

  Thanks for the suggestion. Could you spell out a little more what
  sort of polishing would be needed there? (I'm not a regular user of
  this feature....)

Well, people could manually call the script like this

  prefix-gnulib-mk --lib-name=libgnu /home/foo/bar/gnulib/src/gnulib.mk

and the path should be massaged to be relative to the top-level
directory of the project.  Or maybe a warning/error is more
appropriate, disallowing absolute paths.


    Werner


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-23  9:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22 16:33 inflexible non-recursive support Werner LEMBERG
2021-06-22 19:06 ` Paul Eggert
2021-06-23  9:16 ` Werner LEMBERG

Code repositories for project(s) associated with this inbox:

	../../../mirrors/gnulib.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).