When gnulib-tool or a bootstrap script uses the option --local-dir,
include the "modules" files in a release with DIST_COMMON. Otherwise,
these source files are present in checkouts but not in distribution.

The resulting gnulib.mk from gnulib-tool has comments
with the options used to generate it:

  # Generated by gnulib-tool.
  # Reproduce by:
  # gnulib-tool --import --local-dir=gl \
  # ...

Regex match and parse this information to get any local directories.

For example, coreutils uses a local gnulib directory "gl"
so am__DIST_COMMON will include "$(top_srcdir)/gl/modules".

* bin/automake.in (read_am_file): push "modules" subdirectory of
  local gnulib directories to dist_common if it exists.

Signed-off-by: Michael Pratt <mcpr...@pm.me>
---
 bin/automake.in | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/bin/automake.in b/bin/automake.in
index a17f45236..b757a78e4 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -6520,6 +6520,16 @@ sub read_am_file
        }
        elsif (/$COMMENT_PATTERN/o)
        {
+           # Distribute local gnulib modules.
+           if ($amfile =~ /\/gnulib\.mk/o)
+           {
+               if ($_ =~ /--local-dir=([^\\\s]*)/o)
+               {
+                   push_dist_common ("\$\(top_srcdir\)/$1/modules")
+                     if -d "$1/modules";
+               }
+           }
+
            # Stick comments before the incoming macro or rule.  Make
            # sure a blank line precedes the first block of comments.
            $spacing = "\n" unless $blank;
-- 
2.30.2





Reply via email to