On 12/20/21 01:08, Bruno Haible wrote:
@NMD@ $(MKDIR_P) '%reldir%' && \
Although that'd work, it might be a bit of a maintenance hassle.
How instead using a new macro $(AUTOMAKE_MKDIR_P) instead of $(MKDIR_P)?
AUTOMAKE_MKDIR_P would default to $(MKDIR_P), but GNU Emacs could
override this and set AUTOMAKE_MKDIR_P=':'. This would let us use
ordinary Make and shell syntax rather than inventing a new one.
One related topic. Many Gnulib modules list makefile rules containing
many instances of '&& \' at line ends. How about if we omit the '&& \'
when that's easy? Something like the attached, but for all the modules
not just this one. I noticed this when looking at the $(MKDIR_P) stuff.
This would break apart 'make' recipes into smaller commands, which is a
good thing. And it would let GNU make invoke rm, mkdir, sed, and mv
directly instead of via a subshell, which would be a minor efficiency plus.
(I suppose we should also omit that 'rm -f $@-t $@'; it shouldn't be
needed and it just slows things down on slow build hosts like some of
those that I use.)
If we do the above, we should be able to add a sed command like this:
/^ \$(AM_V_at)\$(AUTOMAKE_MKDIR_P) '\.'$/d
at the appropriate places in gnulib-tool, to omit the odd-looking 'mkdir
-p .' calls from the makefiles and make logs.diff --git a/modules/alloca-opt b/modules/alloca-opt
index 30d0ad4e7..afa670ee0 100644
--- a/modules/alloca-opt
+++ b/modules/alloca-opt
@@ -21,12 +21,16 @@ BUILT_SOURCES += $(ALLOCA_H)
# doesn't have one that works with the given compiler.
if GL_GENERATE_ALLOCA_H
alloca.h: alloca.in.h $(top_builddir)/config.status
- $(AM_V_GEN)rm -f $@-t $@ && \
- $(MKDIR_P) '%reldir%' && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''HAVE_ALLOCA_H''@|$(HAVE_ALLOCA_H)|g' < $(srcdir)/alloca.in.h; \
- } > $@-t && \
- mv -f $@-t $@
+ $(AM_V_at)rm -f $@-t $@
+ $(AM_V_at)$(MKDIR_P) '%reldir%'
+ $(AM_V_at)sed -n \
+ -e h \
+ -e '1s,.*,/* DO NOT EDIT! GENERATED AUTOMATICALLY! *,w $@-t' \
+ -e g \
+ -e 's|@''HAVE_ALLOCA_H''@|$(HAVE_ALLOCA_H)|g' \
+ -e 'w $@-t' \
+ $(srcdir)/alloca.in.h
+ $(AM_V_GEN)mv -f $@-t $@
else
alloca.h: $(top_builddir)/config.status
rm -f $@