On Thu, 28 Jan 2016 18:00:35 +0100
Mathieu Lirzin <m...@gnu.org> wrote:

> OTOH I must admit that for maintainability reasons I would prefer
> avoiding complexity in Makefiles as much as possible.  This means
> using Automake's abstract concepts as much as possible, having a
> simple dependency graph on top of that, and put things that don't fit
> well in this scheme in individual "build-aux/" scripts.  For that
> reason I still prefer the embed help2man solution.  but otherwise it
> looks nice.  :)

I sympathize with the concerns for maintainability.  In this case, it
seems to me that a few lines of make/shell would be preferable to 20k
lines of perl.  Perhaps the simpler attached patch is better?

`~Eric
From 4f369cb6d49cbb6620a0cae117107d6d5e72edc5 Mon Sep 17 00:00:00 2001
From: Eric Bavier <bav...@member.fsf.org>
Date: Wed, 27 Jan 2016 20:31:04 -0600
Subject: [PATCH] build: Generate man pages after compiling guile objects.

* doc.am (SUBCOMMAND_MANS): New variable.
  (subcommand-manual-target): Add dependency on SUBCOMMAND_MANS.
  Run help2man only if script input is changed.
---
 doc.am | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/doc.am b/doc.am
index ad59aa5..e009a24 100644
--- a/doc.am
+++ b/doc.am
@@ -94,7 +94,7 @@ dvi-local: ps-local
 
 # Manual pages.
 
-doc/guix.1: $(SUBCOMMANDS:%=guix/scripts/%.scm)
+doc/guix.1: $(SUBCOMMANDS:%=guix/scripts/%.scm) $(SUBCOMMAND_MANS)
 	-$(AM_V_HELP2MAN)LANGUAGE= $(top_builddir)/pre-inst-env		\
 	  $(HELP2MAN) --output="$@" guix
 
@@ -106,9 +106,18 @@ doc/guix-daemon.1: nix/nix-daemon/guix-daemon.cc
 
 define subcommand-manual-target
 
-doc/guix-$(1).1: guix/scripts/$(1).scm
-	-$$(AM_V_HELP2MAN)LANGUAGE= $(top_builddir)/pre-inst-env	\
-	  $(HELP2MAN) --output="$$@" "guix $(1)"
+# Note: The dependency on $(GOBJECTS) is to force these docs to be made only
+# after all guile modules have been compiled.  The 'case' ensures the manpages
+# are only generated if the corresponding script source has been changed.
+doc/guix-$(1).1: guix/scripts/$(1).scm $(GOBJECTS)
+	-@case '$$?' in \
+	  *$$<*) \
+	    cmd='LANGUAGE= $(top_builddir)/pre-inst-env \
+                  $(HELP2MAN) --output="$$@" "guix $(1)"'; \
+	    if $(AM_V_P); then echo "$$$$cmd"; else echo "  HELP2MAN" $$@; fi; \
+	    eval "$$$$cmd" ;; \
+	  *) : ;; \
+	esac
 
 endef
 
@@ -129,13 +138,14 @@ SUBCOMMANDS :=					\
   refresh					\
   size						\
   system
+SUBCOMMAND_MANS := $(SUBCOMMANDS:%=doc/guix-%.1)
 
 $(eval $(foreach subcommand,$(SUBCOMMANDS),			\
           $(call subcommand-manual-target,$(subcommand))))
 
 dist_man1_MANS =				\
   doc/guix.1					\
-  $(SUBCOMMANDS:%=doc/guix-%.1)
+  $(SUBCOMMAND_MANS)
 
 if BUILD_DAEMON
 
-- 
2.5.0

Reply via email to