While creating a tarball of all header modules to test on AIX, I ran
into the following on my host machine:

    $ gnulib-tool --list  | grep -- '-h$' | xargs gnulib-tool \
        --create-megatestdir --dir testdir-all
    $ cd testdir-all && ./configure && make -j 4 V=0
    [...]
    make[3]: Entering directory 
'/home/collin/.local/src/gnulib/testdir-all/sys_un-h/gllib'
      GEN      sys/types.h
      GEN      sys/socket.h
      GEN      sys/uio.h
      GEN      sys/un.h
    /bin/sh: line 1: sys/un.h-t: No such file or directory
    make[3]: *** [Makefile:1539: sys/un.h] Error 1
    make[3]: *** Waiting for unfinished jobs....
    make[3]: Leaving directory 
'/home/collin/.local/src/gnulib/testdir-all/sys_un-h/gllib'

Excuse the use of V=0, I tried to reproduce it without silent-rules but
was not able to for reasons that will become clear.

This is because the module descriptions Makefile.am has:

    sys/un.h: sys_un.in.h $(top_builddir)/config.status
    @NMD@       $(AM_V_GEN)$(MKDIR_P) '%reldir%'
    [...]

We can see the issues with this by comparing with modules/sys_msg-h, for
example:

    sys/msg.h: sys_msg.in.h $(top_builddir)/config.status
        $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'

When I wrote the sys_un-h module, I must have copied commands from a
non-'sys' header since it is missing the subdirectory. The @NMD@ must
also be removed since gnulib-tool deletes the line to optimize multiple
calls of 'mkdir -p .' which would be emitted otherwise. This cannot be
used for subdirectories of '%reldir%' or else the build can fail.

It usually does not, since sys_socket-h will be built first. But with
parallel jobs, you can get unlucky like I did where the rule for
'sys/un.h' executes faster than the others.

Fixed with the attached patch.

Collin

>From f07c45598e16a06aa9766b8cb45a9fc4448fac07 Mon Sep 17 00:00:00 2001
Message-ID: <f07c45598e16a06aa9766b8cb45a9fc4448fac07.1753151324.git.collin.fu...@gmail.com>
From: Collin Funk <collin.fu...@gmail.com>
Date: Mon, 21 Jul 2025 19:04:09 -0700
Subject: [PATCH] sys_un-h: Make sure that the 'sys' subdirectory is created.

* modules/sys_un-h (Makefile.am): Make the 'sys' subdirectory. Remove
@NMD@ that is not applicable to subdirectories.
---
 ChangeLog        | 6 ++++++
 modules/sys_un-h | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 7f31550390..99ca126183 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-07-21  Collin Funk  <collin.fu...@gmail.com>
+
+	sys_un-h: Make sure that the 'sys' subdirectory is created.
+	* modules/sys_un-h (Makefile.am): Make the 'sys' subdirectory. Remove
+	@NMD@ that is not applicable to subdirectories.
+
 2025-07-21  Bruno Haible  <br...@clisp.org>
 
 	Fix typos.
diff --git a/modules/sys_un-h b/modules/sys_un-h
index 8f80b8b4c7..0e11755d8d 100644
--- a/modules/sys_un-h
+++ b/modules/sys_un-h
@@ -22,7 +22,7 @@ BUILT_SOURCES += $(SYS_UN_H)
 # doesn't have one.
 if GL_GENERATE_SYS_UN_H
 sys/un.h: sys_un.in.h $(top_builddir)/config.status
-@NMD@	$(AM_V_GEN)$(MKDIR_P) '%reldir%'
+	$(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
 	$(gl_V_at)$(SED_HEADER_STDOUT) \
 	      -e 's|@''GUARD_PREFIX''@|${gl_include_guard_prefix}|g' \
 	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-- 
2.50.1

Reply via email to