On Tue, 26 Jan 2016 21:08:36 +0100
Mathieu Lirzin <m...@gnu.org> wrote:

> l...@gnu.org (Ludovic Courtès) writes:
> 
> > Mathieu Lirzin <m...@gnu.org> skribis:
> >
> >> * configure.ac (BUILD_FROM_GIT): New Automake conditional.
> >> * doc.am (SUBCOMMANDS): Delete variable.
> >> (dist_man1_MANS): List all subcommands man pages.
> >> (doc/guix.1): Build only if BUILD_FROM_GIT.  Depend on 'scripts/guix'
> >> instead of all subcommands.
> >> [BUILD_DAEMON] (doc/guix-daemon): Likewise.  Replace the
> >> 'nix/nix-daemon/guix-daemon.cc' prerequisite with 'guix-daemon'.
> >> [BUILD_FROM_GIT] (gen_man): New variable.
> >> [BUILD_FROM_GIT] (doc/guix-%.1): New target.
> >> (CLEANFILES) [BUILD_FROM_GIT]: Add $(dist_man1_MANS).
> >
> > I like the speedup, but not the ‘BUILD_FROM_GIT’ approach.  :-)
> > It reminds me of maintainer-mode and all its warts (info "(automake)
> > maintainer-mode").
> 
> The BUILD_FROM_GIT is inspired by what is done for GNU Hello.  ;)
> However I don't have a strong opinion on this.
> 
> > Namely, I think it’s best to have the help2man rule always triggered
> > whenever the corresponding .scm file is newer, rather than have it
> > triggered or not based on a guess of what the user wants/can do.
> 
> OK.
> 
> > Having said that, I’m not sure what to do.  Commit 0af3f404 reverted the
> > original approach, which was to depend on .go files (and obviously
> > wouldn’t work as we want.)
> >
> > So we want to delay the build of man pages without making the dependency
> > on build products explicit.  Hmm, not sure what can be done.
> 
> I have tried to add $(GOBJECTS) to BUILT_SOURCES and let the man pages
> prerequisites like in 0af3f404.  The problem was that the build didn't
> fully took advantage of possible parallelisms because everything had to
> wait for $(GOBJECTS) to complete before compiling anything else, and the
> modules are loaded using only one thread.
> 
> Another approach is to embed ‘help2man’ (which is what Coreutils is
> doing), so we can let the man pages depend on .go files.  This seems
> reasonable to me even if it means adding 20K of Perl in the repo.  ;)
> 
> WDYT?

Here's my rough first take at this.  It uses the status 77 convention
to update a sentinel file and selectively run help2man.

I realize the silent rule output isn't yet polished.

`~Eric
From 038645a3d14cd10fdb37f94703e463d8f7a3241a 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] doc: Generate manpages after .go are compiled.

* build-aux/compile-all.scm: Exit 77 if no files to compile.
* Makefile.am (make-go): Rename target to make-go.stamp.  Update if any
  files were successfully compiled.
* doc.am (subcommand-manual-target): Add dependency on make-go.stamp.
  Run help2man only if script input is changed.
---
 Makefile.am               | 12 +++++++++---
 build-aux/compile-all.scm |  1 +
 doc.am                    | 15 ++++++++++++---
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 1ede6d4..f97a2a4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -368,15 +368,21 @@ CLEANFILES =					\
 # user ran 'make install' recently).  When that happens, we end up loading
 # those previously-installed .go files, which may be stale, thereby breaking
 # the whole thing.
-%.go: make-go ; @:
-make-go: $(MODULES) guix/config.scm guix/tests.scm
+%.go: make-go.stamp ; @:
+make-go.stamp: $(MODULES) guix/config.scm guix/tests.scm
 	$(AM_V_at)echo "Compiling Scheme modules..." ;			\
 	unset GUILE_LOAD_COMPILED_PATH ;				\
 	host=$(host) srcdir="$(top_srcdir)"				\
 	$(top_builddir)/pre-inst-env					\
 	$(GUILE) -L "$(top_builddir)" -L "$(top_srcdir)"		\
 	  --no-auto-compile 						\
-	  -s "$(top_srcdir)"/build-aux/compile-all.scm $^
+	  -s "$(top_srcdir)"/build-aux/compile-all.scm $^;		\
+	status=$$?; 							\
+	case $$status in						\
+	  77) : ;; 							\
+	  0) touch $@ ;; 						\
+	  *) exit $$status ;; 						\
+	esac
 
 SUFFIXES = .go
 
diff --git a/build-aux/compile-all.scm b/build-aux/compile-all.scm
index e0877db..c8ccbd1 100644
--- a/build-aux/compile-all.scm
+++ b/build-aux/compile-all.scm
@@ -75,6 +75,7 @@
 (match (command-line)
   ((_ . files)
    (let ((files (filter file-needs-compilation? files)))
+     (when (null? files) (primitive-exit 77)) ;skip
      (for-each load-module-file files)
      (let ((mutex (make-mutex)))
        (par-for-each (lambda (file)
diff --git a/doc.am b/doc.am
index f15efcc..b3996d1 100644
--- a/doc.am
+++ b/doc.am
@@ -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
-	-LANGUAGE= $(top_builddir)/pre-inst-env		\
-	  $(HELP2MAN) --output="$$@" "guix $(1)"
+# Note: The dependency on make-go.stamp is to force these docs to be made only
+# after all guile modules have been compiled, so that they are not compiled
+# during this rule.  But we only want to actually generate the manpages if the
+# corresponding script source has been changed.
+doc/guix-$(1).1: guix/scripts/$(1).scm make-go.stamp
+	-$(AM_V_at)case '$$?' in \
+	  *$$<*) \
+	    echo "  GEN     $$@"; \
+	    LANGUAGE= $(top_builddir)/pre-inst-env \
+	    $(HELP2MAN) --output="$$@" "guix $(1)" ;; \
+	  *) : ;; \
+	esac
 
 endef
 
-- 
2.5.0

Reply via email to