[master] 942d61288 build: Turn dot into a "proper" maintainer program

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Jun 12 13:43:05 UTC 2023


commit 942d61288ca1398883f437cf118bb4a28580bbb5
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Mar 6 06:21:28 2023 +0100

    build: Turn dot into a "proper" maintainer program
    
    The --enable-maintainer-mode option has been used in autogen.des for a
    while now and it has allowed automatic reconfiguration and hot reload of
    makefiles.
    
    For the next step, we can turn certain programs into maintainer programs
    and only require them when they are absolutely needed. This is what we
    currently do with SVG files generated from dot files, checked in git and
    optionally required, with an error message when rebuild is not possible.
    
    It turns out we only need 3 lines in configure.ac to implement all that,
    with the following differences:
    
    - no more `./configure --with-dot[=...]` option
      - use `./configure DOT=...` to override the default `dot` command
      - or alternatively run configure with `DOT=...` in the environment
    - generic missing error message (but referencing dot) from make
    - no need to reconfigure once `dot` is in the PATH
    
    The DOT override is actually documented in `./configure --help` like the
    `--with-dot[=...]` option was.
    
    While dot is our most emblematic maintainer tool, with its build targets
    checked in all the way in the git repository, this could be applied to
    other maintainer programs like sphinx-build and rst2man that should not
    be required when building from a dist archive.

diff --git a/Makefile.am b/Makefile.am
index 5e2db4419..f9cad589d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -85,19 +85,8 @@ witness.dot: all
 		lib/libvmod_*/
 
 .dot.svg:
-if ! HAVE_DOT
-	@echo ==================================================
-	@echo You need graphviz installed to generate svg output
-	@echo ==================================================
-	@false
-else
 	$(AM_V_GEN) $(DOT) -Tsvg $< >$@
-endif
 
-if HAVE_DOT
 witness: witness.svg
-else
-witness: witness.dot
-endif
 
 .PHONY: cscope witness.dot
diff --git a/configure.ac b/configure.ac
index fb0b8d202..c1877cee0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,16 +79,9 @@ if test "x$RST2HTML" = "xno"; then
      [rst2html not found - (Weird, we found rst2man?!)])
 fi
 
-AC_ARG_WITH([dot],
-  AS_HELP_STRING([--with-dot=PATH],
-		 [Location of the dot tool from graphviz (auto)]),
-  [DOT="$withval"],
-  [AC_CHECK_PROGS(DOT, [dot], [no])
-   if test "x$DOT" = "xno"; then
-     AC_MSG_WARN(
-       [dot not found - build will fail if svg files are out of date.])
-   fi])
-AM_CONDITIONAL(HAVE_DOT,[test "x$DOT" != "xno"])
+AC_ARG_VAR([DOT], [The dot program from graphviz to build SVG graphics])
+AM_MISSING_PROG([DOT], [dot])
+AC_CHECK_PROGS([DOT], [dot])
 
 # Define VMOD flags
 _VARNISH_VMOD_LDFLAGS
diff --git a/doc/graphviz/Makefile.am b/doc/graphviz/Makefile.am
index f135000c9..6fed3ae87 100644
--- a/doc/graphviz/Makefile.am
+++ b/doc/graphviz/Makefile.am
@@ -35,10 +35,8 @@ SVGS = \
 	cache_req_fsm.svg \
 	cache_fetch.svg
 
-if HAVE_DOT
 CLEANFILES = \
 	$(PDFS)
-endif
 
 pdf: $(PDFS)
 
@@ -46,31 +44,10 @@ html: $(SVGS) link_srcdir
 
 # XXX does not fit onto a4 unless in landscape
 cache_fetch.pdf: cache_fetch.dot
-if ! HAVE_DOT
-	@echo ==================================================
-	@echo You need graphviz installed to generate pdf output
-	@echo ==================================================
-	@false
-else
-	@DOT@ -Tpdf -Gsize=$(SIZE) -Grotate=90 $< >$@
-endif
+	$(AM_V_GEN) $(DOT) -Tpdf -Gsize=$(SIZE) -Grotate=90 $< >$@
 
 .dot.pdf:
-if ! HAVE_DOT
-	@echo ==================================================
-	@echo You need graphviz installed to generate pdf output
-	@echo ==================================================
-	@false
-else
-	@DOT@ -Tpdf -Gsize=$(SIZE) $< >$@
-endif
+	$(AM_V_GEN) $(DOT) -Tpdf -Gsize=$(SIZE) $< >$@
 
 .dot.svg:
-if ! HAVE_DOT
-	@echo ==================================================
-	@echo You need graphviz installed to generate svg output
-	@echo ==================================================
-	@false
-else
-	@DOT@ -Tsvg $< >$@
-endif
+	$(AM_V_GEN) $(DOT) -Tsvg $< >$@


More information about the varnish-commit mailing list