.. i've taken keithmarshall@ off Cc:, my mail-provider cannot
    deliver to this address

Werner LEMBERG <w...@gnu.org> wrote:
 |>  IMO, "--without-doc" should not apply to the "make dist" goal.
 |
 |Yep.
 |
 |> I also think having a check here and there is not a bad thing.  I'll
 |> add it for my patch.
 |
 |OK.

Ok, i've added a simple blocker for the documentation.

 |> In fact it seems that AC_ARG_WITH doesn't allow to define an
 |> enumeration of allowed arguments, so that this is implied as well
 |> as anything else!
 |
 |Have a look at
 |
 |  http://www.gnu.org/software/autoconf-archive/ax_arg_with_p\
 |  ath_style.html#ax_arg_with_path_style
 |
 |for an example how to do that.

I think what we have should cover the needs, but of course i can
change the patch to use case..esac and globbing instead of exact
matching on request.

Well ok, i'll attach what i have now (because i/and won't be
online until monday), it seems to work well.
Making the examples conditional was painful and i needed to part
the Makefile.sub files pretty much to get that done, just until
a minute before: it would have been much easier to implement
a simple on/off switch.

So please take these as a first draft only.  A couple of questions
are unanswered, you should test wether you like the changed
messages, for example.  And `other' documentation (e.g., `pic.ms')
is yet automatically selected if just any other documentation is
installed.  I'm willing to adjust all this to make it acceptable
for GNU Troff.
Ciao,

 |    Werner

--steffen
commit 496da1bfd77667644d7e3177e7a8a3b0ce764327
Author: Steffen (Daode) Nurpmeso <sdao...@users.sf.net>
Date:   2014-03-15 20:57:47 +0100

    Configuration: add --with-doc[=info,pdf,html,examples]
---
 Makefile.in                    |  56 +++++++++++++--
 configure.ac                   |   1 +
 contrib/chem/Makefile.sub      |  28 ++++----
 contrib/gdiffmk/Makefile.sub   |   5 +-
 contrib/glilypond/Makefile.sub |   4 +-
 contrib/gperl/Makefile.sub     |   2 +-
 contrib/groffer/Makefile.sub   |   6 +-
 contrib/hdtbl/Makefile.sub     |  33 ++++++---
 contrib/mom/Makefile.sub       |  78 +++++++++++++++------
 contrib/pdfmark/Makefile.sub   |  22 +++---
 doc/Makefile.sub               | 133 ++++++++++++++++++++++--------------
 m4/groff.m4                    | 150 +++++++++++++++++++++++++++++++++--------
 12 files changed, 377 insertions(+), 141 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index f9da331..57b5dbc 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -264,15 +264,42 @@ man5dir=$(manroot)/man$(man5ext)
 man7ext=7
 man7dir=$(manroot)/man$(man7ext)
 
+# `dist' target is disallowed in some `configure' combinations
+doc_dist_target_ok=@doc_dist_target_ok@
+
+# The configure script checks whether the user wants the info documentation.
+# For the repo version this mechanism also suppresses building via `makeinfo'
+make_infodoc=@make_infodoc@
+make_install_infodoc=@make_install_infodoc@
+make_uninstall_infodoc=@make_uninstall_infodoc@
+
 # The configure script checks whether all necessary utility programs for
 # grohtml are available -- only then we can build the HTML documentation.
-make_html=@make_html@
-make_install_html=@make_install_html@
+make_htmldoc=@make_htmldoc@
+make_install_htmldoc=@make_install_htmldoc@
+make_uninstall_htmldoc=@make_uninstall_htmldoc@
+make_htmlexamples=@make_htmlexamples@
+make_install_htmlexamples=@make_install_htmlexamples@
+make_uninstall_htmlexamples=@make_uninstall_htmlexamples@
 
 # The configure script also checks whether all necessary utility programs
 # for pdfroff are available -- only then we can build PDF documentation.
 make_pdfdoc=@make_pdfdoc@
 make_install_pdfdoc=@make_install_pdfdoc@
+make_uninstall_pdfdoc=@make_uninstall_pdfdoc@
+make_pdfexamples=@make_pdfexamples@
+make_install_pdfexamples=@make_install_pdfexamples@
+make_uninstall_pdfexamples=@make_uninstall_pdfexamples@
+
+# Generated `other' documentation, like `meref.me', `pic.ms'..
+make_otherdoc=@make_otherdoc@
+make_install_otherdoc=@make_install_otherdoc@
+make_uninstall_otherdoc=@make_uninstall_otherdoc@
+
+# Non-HTML, non-PDF examples
+make_examples=@make_examples@
+make_install_examples=@make_install_examples@
+make_uninstall_examples=@make_uninstall_examples@
 
 # All the previous installation directories, when used, are prefixed with
 # $(DESTDIR) during install and uninstall, to support staged installations.
@@ -534,10 +561,27 @@ MDEFINES=\
   "libprogramdir=$(libprogramdir)" \
   "localfontdir=$(localfontdir)" \
   "localtmacdir=$(localtmacdir)" \
-  "make_html=$(make_html)" \
-  "make_install_html=$(make_install_html)" \
+  "make_infodoc=$(make_infodoc)" \
+  "make_install_infodoc=$(make_install_infodoc)" \
+  "make_uninstall_infodoc=$(make_uninstall_infodoc)" \
+  "make_htmldoc=$(make_htmldoc)" \
+  "make_install_htmldoc=$(make_install_htmldoc)" \
+  "make_uninstall_htmldoc=$(make_uninstall_htmldoc)" \
+  "make_htmlexamples=$(make_htmlexamples)" \
+  "make_install_htmlexamples=$(make_install_htmlexamples)" \
+  "make_uninstall_htmlexamples=$(make_uninstall_htmlexamples)" \
   "make_pdfdoc=$(make_pdfdoc)" \
   "make_install_pdfdoc=$(make_install_pdfdoc)" \
+  "make_uninstall_pdfdoc=$(make_uninstall_pdfdoc)" \
+  "make_pdfexamples=$(make_pdfexamples)" \
+  "make_install_pdfexamples=$(make_install_pdfexamples)" \
+  "make_uninstall_pdfexamples=$(make_uninstall_pdfexamples)" \
+  "make_otherdoc=$(make_otherdoc)" \
+  "make_install_otherdoc=$(make_install_otherdoc)" \
+  "make_uninstall_otherdoc=$(make_uninstall_otherdoc)" \
+  "make_examples=$(make_examples)" \
+  "make_install_examples=$(make_install_examples)" \
+  "make_uninstall_examples=$(make_uninstall_examples)" \
   "man1dir=$(man1dir)" \
   "man1ext=$(man1ext)" \
   "man5dir=$(man5dir)" \
@@ -830,6 +874,10 @@ $(INCDIRS) $(PROGDEPDIRS) $(SHPROGDIRS) $(OTHERDIRS): FORCE
 
 .PHONY: dist
 dist:
+	if test "${doc_dist_target_ok}" != yes; then \
+	  echo "This configuration is not applicable to \`dist' target";\
+	  exit 1;\
+	fi
 	-rm -fr tmp
 	rm -f groff-$(version)$(revision).tar.gz
 	mkdir tmp
diff --git a/configure.ac b/configure.ac
index 72fe2fc..af5ce27 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,6 +69,7 @@ GROFF_PERL
 GROFF_PRINT
 AC_PROG_EGREP
 GROFF_PROG_YACC
+GROFF_DOC_CHECK
 GROFF_MAKEINFO
 AC_PROG_RANLIB
 GROFF_INSTALL_SH
diff --git a/contrib/chem/Makefile.sub b/contrib/chem/Makefile.sub
index 93f3e19..6784192 100644
--- a/contrib/chem/Makefile.sub
+++ b/contrib/chem/Makefile.sub
@@ -35,13 +35,14 @@ MOSTLYCLEANADD=\
 # not all make programs have $(RM) predefined.
 RM=rm -f
 
-all: README examples/README examples/122/README \
-     chem \
-     $(MAN1)
+all: README chem $(MAN1) $(make_examples)
 
 README: $(srcdir)/README.txt
 	sed -e "s|@g@|$(g)|g" $? >$@
 
+.PHONY: examples
+examples: examples/README examples/122/README
+
 examples/README: $(srcdir)/examples/README.txt
 	-test -d examples || $(mkinstalldirs) examples
 	sed -e "s|@g@|$(g)|g" $? >$@
@@ -62,10 +63,8 @@ chem: $(srcdir)/chem.pl $(SH_DEPS_SED_SCRIPT)
 	  $(srcdir)/chem.pl >$@
 	chmod +x $@
 
-install_data: chem \
-              README examples/README examples/122/README \
-              $(srcdir)/chem.pic \
-              $(srcdir)/examples/*.chem $(srcdir)/examples/122/*.chem
+install_data: install_always $(make_install_examples)
+install_always: chem README $(srcdir)/chem.pic
 	-test -d $(DESTDIR)$(bindir) || $(mkinstalldirs) $(DESTDIR)$(bindir)
 	$(RM) $(DESTDIR)$(bindir)/$(g)chem
 	$(INSTALL_SCRIPT) chem $(DESTDIR)$(bindir)/$(g)chem
@@ -74,6 +73,8 @@ install_data: chem \
 	$(RM) $(DESTDIR)$(datasubdir)/pic/chem.pic
 	$(INSTALL_DATA) $(srcdir)/chem.pic \
           $(DESTDIR)$(datasubdir)/pic/chem.pic
+
+install_examples: install_always examples
 	-test -d $(DESTDIR)$(exampledir)/chem \
           || $(mkinstalldirs) $(DESTDIR)$(exampledir)/chem
 	-test -d $(DESTDIR)$(exampledir)/chem/122 \
@@ -93,13 +94,16 @@ install_data: chem \
           $(INSTALL_DATA) $$i $(DESTDIR)$(exampledir)/chem/122/$$n; \
         done
 
-uninstall_sub:
-	$(RM) $(DESTDIR)$(bindir)/chem
-	$(RM) $(DESTDIR)$(datasubdir)/pic/chem.pic
+uninstall_sub: uninstall_always $(make_uninstall_examples)
+uninstall_always:
+	-$(RM) $(DESTDIR)$(bindir)/chem
+	-$(RM) $(DESTDIR)$(datasubdir)/pic/chem.pic
 	-rmdir $(DESTDIR)$(datasubdir)/pic
-	$(RM) $(DESTDIR)$(exampledir)/chem/122/*
+
+uninstall_examples: uninstall_always
+	-$(RM) $(DESTDIR)$(exampledir)/chem/122/*
 	-rmdir $(DESTDIR)$(exampledir)/chem/122
-	$(RM) $(DESTDIR)$(exampledir)/chem/*
+	-$(RM) $(DESTDIR)$(exampledir)/chem/*
 	-rmdir $(DESTDIR)$(exampledir)/chem
 	-rmdir $(DESTDIR)$(exampledir)
 
diff --git a/contrib/gdiffmk/Makefile.sub b/contrib/gdiffmk/Makefile.sub
index c3179ff..d3299c7 100644
--- a/contrib/gdiffmk/Makefile.sub
+++ b/contrib/gdiffmk/Makefile.sub
@@ -27,6 +27,9 @@
 MAN1=gdiffmk.n
 MOSTLYCLEANADD=gdiffmk tests/runtests
 
+# not all make programs have $(RM) predefined.
+RM=rm -f
+
 all: gdiffmk
 
 gdiffmk: gdiffmk.sh
@@ -42,4 +45,4 @@ install_data: gdiffmk
 	$(INSTALL_SCRIPT) gdiffmk $(DESTDIR)$(bindir)/gdiffmk
 
 uninstall_sub:
-	-rm -f $(DESTDIR)$(bindir)/gdiffmk
+	-$(RM) $(DESTDIR)$(bindir)/gdiffmk
diff --git a/contrib/glilypond/Makefile.sub b/contrib/glilypond/Makefile.sub
index 0ff5e3e..e36f23a 100644
--- a/contrib/glilypond/Makefile.sub
+++ b/contrib/glilypond/Makefile.sub
@@ -71,8 +71,8 @@ install_data: glilypond $(GLILYPOND_LIB)
 
 
 uninstall_sub:
-	$(RM) $(DESTDIR)$(bindir)/glilypond;
-	for f in $(GLILYPOND_); do \
+	-$(RM) $(DESTDIR)$(bindir)/glilypond;
+	-for f in $(GLILYPOND_); do \
 		$(RM) $(DESTDIR)$(glilypond_dir)/$$f; \
 	done
 	-rmdir $(DESTDIR)$(glilypond_dir)
diff --git a/contrib/gperl/Makefile.sub b/contrib/gperl/Makefile.sub
index 02f24f4..240f7cb 100644
--- a/contrib/gperl/Makefile.sub
+++ b/contrib/gperl/Makefile.sub
@@ -52,7 +52,7 @@ install_data: gperl
 
 .PHONY: uninstall_sub
 uninstall_sub:
-	$(RM) $(DESTDIR)$(bindir)/gperl
+	-$(RM) $(DESTDIR)$(bindir)/gperl
 
 
 ########################################################################
diff --git a/contrib/groffer/Makefile.sub b/contrib/groffer/Makefile.sub
index 65ae56d..cfe17fb 100644
--- a/contrib/groffer/Makefile.sub
+++ b/contrib/groffer/Makefile.sub
@@ -104,9 +104,9 @@ install_data: groffer
         fi;
 
 uninstall_sub:
-	$(RM) $(DESTDIR)$(bindir)/groffer
-	for f in $(ROFF2PROGS); do $(RM) $(DESTDIR)$(bindir)/$$f; done
-	for f in $(GROFFER_PERL_) version.sh; do \
+	-$(RM) $(DESTDIR)$(bindir)/groffer
+	-for f in $(ROFF2PROGS); do $(RM) $(DESTDIR)$(bindir)/$$f; done
+	-for f in $(GROFFER_PERL_) version.sh; do \
           $(RM) $(DESTDIR)$(groffer_dir)/$$f; \
         done
 	-rmdir $(DESTDIR)$(libdir)/groff/groffer
diff --git a/contrib/hdtbl/Makefile.sub b/contrib/hdtbl/Makefile.sub
index f894a8e..cb95df9 100644
--- a/contrib/hdtbl/Makefile.sub
+++ b/contrib/hdtbl/Makefile.sub
@@ -87,6 +87,9 @@ MOSTLYCLEANADD=\
   stamp-strip \
   hdmisc.tmac-s hdtbl.tmac-s
 
+# Some `makes' don't predefine RM...
+RM=rm -f
+
 .SUFFIXES: .roff .in .ps
 
 .roff.ps:
@@ -96,8 +99,10 @@ MOSTLYCLEANADD=\
 .in.roff:
 	sed -e "s|@fontdir@|$(fontdir)|" $< >$@
 
+all: $(make_examples) stamp-strip
 
-all: $(PROCESSEDEXAMPLEFILES) stamp-strip
+.PHONY: examples
+examples: $(PROCESSEDEXAMPLEFILES)
 
 $(PROCESSEDEXAMPLEFILES): gnu.eps examples/stamp examples/common.roff
 
@@ -117,38 +122,44 @@ examples/stamp:
 
 stamp-strip: $(STRIPFILES)
 	for f in $(STRIPFILES); do \
-	  rm -f $$f-s; \
+	  $(RM) $$f-s; \
 	  sed -f $(top_srcdir)/tmac/strip.sed $(srcdir)/$$f >$$f-s; \
 	done
 	touch $@
 
-install_data: $(STRIPFILES) $(EXAMPLEFILES) $(GENFILES) \
-              $(PROCESSEDEXAMPLEFILES) gnu.eps stamp-strip
+install_data: install_always $(make_install_examples)
+install_always: $(STRIPFILES) $(GENFILES)
 	-test -d $(DESTDIR)$(tmacdir) || $(mkinstalldirs) $(DESTDIR)$(tmacdir)
 	for f in $(STRIPFILES); do \
-	  rm -f $(DESTDIR)$(tmacdir)/$$f; \
+	  $(RM) $(DESTDIR)$(tmacdir)/$$f; \
 	  $(INSTALL_DATA) $$f-s $(DESTDIR)$(tmacdir)/$$f; \
 	done
+
+install_examples: install_always $(EXAMPLEFILES) $(PROCESSEDEXAMPLEFILES) \
+                  gnu.eps stamp-strip
 	-test -d $(DESTDIR)$(exampledir)/hdtbl \
 	  || $(mkinstalldirs) $(DESTDIR)$(exampledir)/hdtbl
 	for f in $(EXAMPLEFILES_); do \
-	  rm -f $(DESTDIR)$(exampledir)/hdtbl/$$f; \
+	  $(RM) $(DESTDIR)$(exampledir)/hdtbl/$$f; \
 	  $(INSTALL_DATA) $(srcdir)/examples/$$f \
 	    $(DESTDIR)$(exampledir)/hdtbl/$$f; \
 	done
 	for f in $(PROCESSEDEXAMPLEFILES_) $(GENFILES_); do \
-	  rm -f $(DESTDIR)$(exampledir)/hdtbl/$$f; \
+	  $(RM) $(DESTDIR)$(exampledir)/hdtbl/$$f; \
 	  $(INSTALL_DATA) examples/$$f $(DESTDIR)$(exampledir)/hdtbl/$$f; \
 	done
 	$(INSTALL_DATA) gnu.eps $(DESTDIR)$(exampledir)/hdtbl/gnu.eps
 
-uninstall_sub:
+uninstall_sub: uninstall_always $(uninstall_examples)
+uninstall_always:
 	-for f in $(STRIPFILES); do \
-	  rm -f $(DESTDIR)$(tmacdir)/$$f; \
+	  $(RM) $(DESTDIR)$(tmacdir)/$$f; \
 	done
+
+uninstall_examples: uninstall_always
 	-for f in $(EXAMPLEFILES_) $(PROCESSEDEXAMPLEFILES_) \
                   $(GENFILES_); do \
-	  rm -f $(DESTDIR)$(exampledir)/hdtbl/$$f; \
+	  $(RM) $(DESTDIR)$(exampledir)/hdtbl/$$f; \
 	done
-	-rm $(DESTDIR)$(exampledir)/hdtbl/gnu.eps
+	-$(RM) $(DESTDIR)$(exampledir)/hdtbl/gnu.eps
 	-rmdir $(DESTDIR)$(exampledir)/hdtbl
diff --git a/contrib/mom/Makefile.sub b/contrib/mom/Makefile.sub
index e956346..4acf3bc 100644
--- a/contrib/mom/Makefile.sub
+++ b/contrib/mom/Makefile.sub
@@ -108,6 +108,9 @@ MOSTLYCLEANADD=\
   examples/stamp \
   om.tmac-s
 
+# not all make programs have $(RM) predefined.
+RM=rm -f
+
 #.SUFFIXES: .mom .ps
 #.mom.ps:
 #	$(GROFF) -Tps -mom $< >$@
@@ -116,10 +119,12 @@ MOSTLYCLEANADD=\
 .mom.pdf:
 	$(PDFMOM) $< >$@
 
-all: stamp-strip $(PROCESSEDEXAMPLEFILES)
+all: stamp-strip $(make_pdfexamples)
 
 $(PROCESSEDEXAMPLEFILES): penguin.ps penguin.pdf examples/stamp
 
+pdfexamples: $(PROCESSEDEXAMPLEFILES)
+
 penguin.ps:
 	cp $(srcdir)/examples/penguin.ps .
 penguin.pdf:
@@ -129,61 +134,90 @@ examples/stamp:
 	test -d examples || $(mkinstalldirs) examples
 	touch $@
 
-install_data: stamp-strip $(NORMALFILES) $(HTMLDOCFILES) \
-              $(EXAMPLEFILES) $(PROCESSEDEXAMPLEFILES)
+install_data: install_always \
+              $(make_install_pdfdoc) $(make_install_htmldoc) \
+	      $(make_install_examples)
+install_always: stamp-strip $(NORMALFILES)
 	-test -d $(DESTDIR)$(tmacdir) || $(mkinstalldirs) $(DESTDIR)$(tmacdir)
 	for f in $(NORMALFILES); do \
-	  rm -f $(DESTDIR)$(tmacdir)/$$f; \
+	  $(RM) $(DESTDIR)$(tmacdir)/$$f; \
 	  $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(tmacdir)/$$f; \
 	done
 	for f in $(STRIPFILES); do \
-	  rm -f $(DESTDIR)$(tmacdir)/$$f; \
+	  $(RM) $(DESTDIR)$(tmacdir)/$$f; \
 	  $(INSTALL_DATA) $$f-s $(DESTDIR)$(tmacdir)/$$f; \
 	done
+
+install_pdfdoc:
+# Since this uses examples/, it's in install_pdfexamples
+
+install_htmldoc: install_always $(HTMLDOCFILES)
 	-test -d $(DESTDIR)$(htmldocdir)/mom \
-	  || $(mkinstalldirs) $(DESTDIR)$(htmldocdir)/mom
-	for f in $(HTMLDOCFILES_); do \
-	  rm -f $(DESTDIR)$(htmldocdir)/mom/$$f; \
+	    || $(mkinstalldirs) $(DESTDIR)$(htmldocdir)/mom
+	-for f in $(HTMLDOCFILES_); do \
+	  $(RM) $(DESTDIR)$(htmldocdir)/mom/$$f; \
 	  $(INSTALL_DATA) $(srcdir)/momdoc/$$f \
 	    $(DESTDIR)$(htmldocdir)/mom/$$f; \
 	done
+
+install_examples: install_examples_always $(make_install_pdfexamples)
+install_examples_always: $(EXAMPLEFILES)
 	-test -d $(DESTDIR)$(exampledir)/mom \
 	  || $(mkinstalldirs) $(DESTDIR)$(exampledir)/mom
-	for f in $(EXAMPLEFILES_); do \
-	  rm -f $(DESTDIR)$(exampledir)/mom/$$f; \
+	-for f in $(EXAMPLEFILES_); do \
+	  $(RM) $(DESTDIR)$(exampledir)/mom/$$f; \
 	  $(INSTALL_DATA) $(srcdir)/examples/$$f \
 	    $(DESTDIR)$(exampledir)/mom/$$f; \
 	done
-	for f in $(PROCESSEDEXAMPLEFILES_); do \
-	  rm -f $(DESTDIR)$(exampledir)/mom/$$f; \
+
+install_pdfexamples: install_examples_always $(PROCESSEDEXAMPLEFILES)
+	-for f in $(PROCESSEDEXAMPLEFILES_); do \
+	  $(RM) $(DESTDIR)$(exampledir)/mom/$$f; \
 	  $(INSTALL_DATA) examples/$$f $(DESTDIR)$(exampledir)/mom/$$f; \
 	done
 	-test -d $(DESTDIR)$(pdfdocdir) \
 	  || $(mkinstalldirs) $(DESTDIR)$(pdfdocdir)
-	for f in $(PDFDOCFILE); do \
-	  rm -f $(DESTDIR)$(pdfdocdir)/$$f; \
+	-for f in $(PDFDOCFILE); do \
+	  $(RM) $(DESTDIR)$(pdfdocdir)/$$f; \
 	  ln -s $(exampledir)/mom/$$f $(DESTDIR)$(pdfdocdir)/$$f; \
 	done
 
 stamp-strip: $(STRIPFILES)
 	for f in $(STRIPFILES); do \
-	  rm -f $$f-s; \
+	  $(RM) $$f-s; \
 	  sed -f $(top_srcdir)/tmac/strip.sed $(srcdir)/$$f >$$f-s; \
 	done
 	touch $@
 
-uninstall_sub:
+uninstall_sub: uninstall_always \
+               $(make_uninstall_pdfdoc) $(make_uninstall_htmldoc) \
+	       $(make_uninstall_examples)
+uninstall_always:
 	-for f in $(NORMALFILES) $(STRIPFILES); do \
-	  rm -f $(DESTDIR)$(tmacdir)/$$f; \
+	  $(RM) $(DESTDIR)$(tmacdir)/$$f; \
 	done
+
+uninstall_pdfdoc: uninstall_always
+# Since that used examples/, it's in uninstall_pdfexamples
+
+uninstall_htmldoc: uninstall_always
 	-for f in $(HTMLDOCFILES_); do \
-	  rm -f $(DESTDIR)$(htmldocdir)/mom/$$f; \
+	  $(RM) $(DESTDIR)$(htmldocdir)/mom/$$f; \
 	done
 	-rmdir $(DESTDIR)$(htmldocdir)/mom
-	-for f in $(EXAMPLEFILES_) $(PROCESSEDEXAMPLEFILES_); do \
-	  rm -f $(DESTDIR)$(exampledir)/mom/$$f; \
+
+uninstall_examples: uninstall_examples_always $(make_uninstall_pdfexamples)
+	-rmdir $(DESTDIR)$(exampledir)/mom
+
+uninstall_examples_always:
+	-for f in $(EXAMPLEFILES_); do \
+	  $(RM) $(DESTDIR)$(exampledir)/mom/$$f; \
 	done
+
+uninstall_pdfexamples: uninstall_examples_always
 	-for f in $(PDFDOCFILE); do \
-	  rm -f $(DESTDIR)$(pdfdocdir)/$$f; \
+	  $(RM) $(DESTDIR)$(pdfdocdir)/$$f; \
+	done
+	-for f in $(PROCESSEDEXAMPLEFILES_); do \
+	  $(RM) $(DESTDIR)$(exampledir)/mom/$$f; \
 	done
-	-rmdir $(DESTDIR)$(exampledir)/mom
diff --git a/contrib/pdfmark/Makefile.sub b/contrib/pdfmark/Makefile.sub
index 768f24a..6507797 100644
--- a/contrib/pdfmark/Makefile.sub
+++ b/contrib/pdfmark/Makefile.sub
@@ -90,33 +90,37 @@ pdfroff: pdfroff.sh $(SH_DEPS_SED_SCRIPT)
 	    -e "s|@GROFF_BIN_DIR@|$(bindir)|" $(srcdir)/pdfroff.sh >$@
 	chmod +x $@
 
-install_data: $(make_install_pdfdoc)
-	-test -d $(DESTDIR)$(bindir) || $(mkinstalldirs) $(DESTDIR)$(bindir)
+install_data: install_always $(make_install_pdfdoc)
+install_always:
+	test -d $(DESTDIR)$(bindir) || $(mkinstalldirs) $(DESTDIR)$(bindir)
 	for f in $(CMDFILES); do \
 	  $(RM) $(DESTDIR)$(bindir)/$$f; \
 	  $(INSTALL_SCRIPT) $$f $(DESTDIR)$(bindir)/$$f; \
 	done
-	-test -d $(DESTDIR)$(tmacdir) || $(mkinstalldirs) $(DESTDIR)$(tmacdir)
+	test -d $(DESTDIR)$(tmacdir) || $(mkinstalldirs) $(DESTDIR)$(tmacdir)
 	for f in $(TMACFILES); do \
 	  $(RM) $(DESTDIR)$(tmacdir)/$$f; \
 	  $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(tmacdir)/$$f; \
 	done
 
-install_pdfdoc:
-	-test -d $(DESTDIR)$(pdfdocdir) \
+install_pdfdoc: install_always
+	test -d $(DESTDIR)$(pdfdocdir) \
 	  || $(mkinstalldirs) $(DESTDIR)$(pdfdocdir)
 	for f in $(PDFDOCFILES); do \
 	  $(RM) $(DESTDIR)$(pdfdocdir)/$$f; \
 	  $(INSTALL_DATA) $$f $(DESTDIR)$(pdfdocdir)/$$f; \
 	done
 
-uninstall_sub:
-	for f in $(CMDFILES); do \
+uninstall_sub: uninstall_always $(make_uninstall_pdfdoc)
+uninstall_always:
+	-for f in $(CMDFILES); do \
 	  $(RM) $(DESTDIR)$(bindir)/$$f; \
 	done
-	for f in $(TMACFILES); do \
+	-for f in $(TMACFILES); do \
 	  $(RM) $(DESTDIR)$(tmacdir)/$$f; \
 	done
-	for f in $(PDFDOCFILES); do \
+
+uninstall_pdfdoc: uninstall_always
+	-for f in $(PDFDOCFILES); do \
 	  $(RM) $(DESTDIR)$(pdfdocdir)/$$f; \
 	done
diff --git a/doc/Makefile.sub b/doc/Makefile.sub
index e6df86b..23b8d26 100644
--- a/doc/Makefile.sub
+++ b/doc/Makefile.sub
@@ -108,6 +108,9 @@ MOSTLYCLEANNOTSRCDIRADD=\
   groff-*.info \
   gnu.eps
 
+# not all make programs have $(RM) predefined.
+RM=rm -f
+
 .SUFFIXES: .me .ms .ps .html
 
 # For simplicity, we always call preconv, grn, and eqn.
@@ -121,10 +124,16 @@ MOSTLYCLEANNOTSRCDIRADD=\
 	$(GROFF) -Tps -ms -mwww >$@
 
 
-all: groff.info $(PROCESSEDDOCFILES) prepare_examples \
-     $(PROCESSEDEXAMPLEFILES) $(make_html)
+all: $(make_otherdoc) $(make_infodoc) $(make_htmldoc) \
+     $(make_examples) $(make_htmlexamples)
+
+otherdoc: $(PROCESSEDDOCFILES)
+infodoc: groff.info
+htmldoc: $(HTMLDOCFILES)
+
+examples: prepare_examples $(PROCESSEDEXAMPLEFILES)
 
-html: $(HTMLDOCFILES) $(HTMLEXAMPLEFILES)
+html_examples: $(HTMLEXAMPLEFILES)
 
 prepare_examples: examples.stamp
 
@@ -163,8 +172,24 @@ grnexmpl.ps: grnexmpl.me grnexmpl.g
 
 distfiles: groff.info gnu.eps
 
-install_data: groff.info gnu.eps $(DOCFILES) $(PROCESSEDDOCFILES) \
-              $(make_install_html) $(EXAMPLEFILES) $(PROCESSEDEXAMPLEFILES)
+install_data: install_always $(make_install_otherdoc) \
+              $(make_install_infodoc) $(make_install_htmldoc) \
+	      $(make_install_examples)
+
+install_always:
+	test -d $(DESTDIR)$(docdir) || $(mkinstalldirs) $(DESTDIR)$(docdir)
+
+install_otherdoc: install_always $(DOCFILES) $(PROCESSEDDOCFILES)
+	for f in $(DOCFILES); do \
+	  $(RM) $(DESTDIR)$(docdir)/$$f; \
+	  $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(docdir)/$$f; \
+	done
+	for f in $(PROCESSEDDOCFILES); do \
+	  $(RM) $(DESTDIR)$(docdir)/$$f; \
+	  $(INSTALL_DATA) $$f $(DESTDIR)$(docdir)/$$f; \
+	done
+
+install_infodoc: install_always groff.info
 # Prefer info files in builddir over srcdir; we test for
 # the existence of `groff.info'.
 	-test -d $(DESTDIR)$(infodir) || $(mkinstalldirs) $(DESTDIR)$(infodir)
@@ -172,78 +197,88 @@ install_data: groff.info gnu.eps $(DOCFILES) $(PROCESSEDDOCFILES) \
 	  test -f "groff.info" || d=$(srcdir); \
 	  for p in $$d/groff.info `ls $$d/groff.info*`; do \
 	    f=`basename $$p`; \
-	    rm -f $(DESTDIR)$(infodir)/$$f; \
+	    $(RM) $(DESTDIR)$(infodir)/$$f; \
 	    $(INSTALL_DATA) $$p $(DESTDIR)$(infodir)/$$f; \
 	  done
 	$(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) \
 	  $(DESTDIR)$(infodir)/groff.info
-	-test -d $(DESTDIR)$(docdir) || $(mkinstalldirs) $(DESTDIR)$(docdir)
-	for f in $(DOCFILES); do \
-	  rm -f $(DESTDIR)$(docdir)/$$f; \
-	  $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(docdir)/$$f; \
-	done
-	for f in $(PROCESSEDDOCFILES); do \
-	  rm -f $(DESTDIR)$(docdir)/$$f; \
-	  $(INSTALL_DATA) $$f $(DESTDIR)$(docdir)/$$f; \
-	done
-# Prefer gnu.eps in builddir over srcdir.
-	-test -d $(DESTDIR)$(exampledir) \
-	  || $(mkinstalldirs) $(DESTDIR)$(exampledir)
-	d=.; \
-	  test -f "gnu.eps" || d=$(srcdir); \
-	  rm -f $(DESTDIR)$(exampledir)/gnu.eps; \
-	  $(INSTALL_DATA) $$d/gnu.eps $(DESTDIR)$(exampledir)/gnu.eps
-	for f in $(EXAMPLEFILES); do \
-	  rm -f $(DESTDIR)$(exampledir)/$$f; \
-	  $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(exampledir)/$$f; \
-	done
-	for f in $(PROCESSEDEXAMPLEFILES); do \
-	  rm -f $(DESTDIR)$(exampledir)/$$f; \
-	  $(INSTALL_DATA) $$f $(DESTDIR)$(exampledir)/$$f; \
-	done
 
-install_html: $(HTMLDOCFILES) $(HTMLEXAMPLEFILES)
+install_htmldoc: install_always $(HTMLDOCFILES)
 	-test -d $(DESTDIR)$(htmldocdir) \
 	  || $(mkinstalldirs) $(DESTDIR)$(htmldocdir)
 	for f in `ls $(HTMLDOCFILESALL)`; do \
-	  rm -f $(DESTDIR)$(htmldocdir)/$$f; \
+	  $(RM) $(DESTDIR)$(htmldocdir)/$$f; \
 	  $(INSTALL_DATA) $$f $(DESTDIR)$(htmldocdir)/$$f; \
 	done
 	-test -d $(DESTDIR)$(htmldocimagedir) \
 	  || $(mkinstalldirs) $(DESTDIR)$(htmldocimagedir)
-	rm -f $(DESTDIR)$(htmldocimagedir)/$(HTMLDOCIMAGEFILES)
+	$(RM) $(DESTDIR)$(htmldocimagedir)/$(HTMLDOCIMAGEFILES)
 	$(INSTALL_DATA) $(imagedir)/$(HTMLDOCIMAGEFILES) \
 	  $(DESTDIR)$(htmldocimagedir)
+
+install_examples: install_always install_examples_always \
+		  $(make_install_htmlexamples)
+install_examples_always: gnu.eps $(EXAMPLEFILES) $(PROCESSEDEXAMPLEFILES)
+# Prefer gnu.eps in builddir over srcdir.
 	-test -d $(DESTDIR)$(exampledir) \
 	  || $(mkinstalldirs) $(DESTDIR)$(exampledir)
+	d=.; \
+	  test -f "gnu.eps" || d=$(srcdir); \
+	  $(RM) $(DESTDIR)$(exampledir)/gnu.eps; \
+	  $(INSTALL_DATA) $$d/gnu.eps $(DESTDIR)$(exampledir)/gnu.eps
+	-for f in $(EXAMPLEFILES); do \
+	  $(RM) $(DESTDIR)$(exampledir)/$$f; \
+	  $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(exampledir)/$$f; \
+	done
+	-for f in $(PROCESSEDEXAMPLEFILES); do \
+	  $(RM) $(DESTDIR)$(exampledir)/$$f; \
+	  $(INSTALL_DATA) $$f $(DESTDIR)$(exampledir)/$$f; \
+	done
+
+install_htmlexamples: install_examples_always $(HTMLEXAMPLEFILES)
 	for f in `ls $(HTMLEXAMPLEFILESALL)`; do \
-	  rm -f $(DESTDIR)$(exampledir)/$$f; \
+	  $(RM) $(DESTDIR)$(exampledir)/$$f; \
 	  $(INSTALL_DATA) $$f $(DESTDIR)$(exampledir)/$$f; \
 	done
 	-test -d $(DESTDIR)$(exampleimagedir) \
 	  || $(mkinstalldirs) $(DESTDIR)$(exampleimagedir)
-	rm -f $(DESTDIR)$(exampleimagedir)/$(HTMLEXAMPLEIMAGEFILES)
+	$(RM) $(DESTDIR)$(exampleimagedir)/$(HTMLEXAMPLEIMAGEFILES)
 	$(INSTALL_DATA) $(imagedir)/$(HTMLEXAMPLEIMAGEFILES) \
 	  $(DESTDIR)$(exampleimagedir)
 
-uninstall_sub:
-	$(INSTALL_INFO) --remove --info-dir=$(DESTDIR)$(infodir) \
-	  $(DESTDIR)$(infodir)/groff.info
-	-for f in groff `ls groff.info*`; do \
-	  rm -f $(DESTDIR)$(infodir)/$$f; \
-	done
+uninstall_sub: uninstall_always \
+               $(make_uninstall_infodoc) $(make_uninstall_htmldoc) \
+               $(make_uninstall_examples)
+uninstall_always:
 	-for f in $(DOCFILES) $(PROCESSEDDOCFILES); do \
-	  rm -f $(DESTDIR)$(docdir)/$$f; \
+	  $(RM) $(DESTDIR)$(docdir)/$$f; \
+	done
+
+uninstall_infodoc: uninstall_always
+	-$(INSTALL_INFO) --remove --info-dir=$(DESTDIR)$(infodir) \
+	  $(DESTDIR)$(infodir)/groff.info;\
+	-for f in groff `ls groff.info*`; do \
+	  $(RM) $(DESTDIR)$(infodir)/$$f;\
 	done
+
+uninstall_htmldoc: uninstall_always
 	-for f in `ls $(HTMLDOCFILESALL)`; do \
-	  rm -f $(DESTDIR)$(htmldocdir)/$$f; \
+	  $(RM) $(DESTDIR)$(htmldocdir)/$$f;\
 	done
-	-rm -f $(DESTDIR)$(htmldocimagedir)/$(HTMLDOCIMAGEFILES)
+	-$(RM) $(DESTDIR)$(htmldocimagedir)/$(HTMLDOCIMAGEFILES)
 	-rmdir $(DESTDIR)$(htmldocimagedir)
-	-for f in $(EXAMPLEFILES) $(PROCESSEDEXAMPLEFILES) \
-	          `ls $(HTMLEXAMPLEFILESALL)`; do \
-	  rm -f $(DESTDIR)$(exampledir)/$$f; \
+
+uninstall_examples: uninstall_always uninstall_examples_always \
+                    $(make_uninstall_htmlexamples)
+uninstall_examples_always:
+	-for f in $(EXAMPLEFILES) $(PROCESSEDEXAMPLEFILES); do \
+	  $(RM) $(DESTDIR)$(exampledir)/$$f;\
+	done
+	-$(RM) $(DESTDIR)$(exampledir)/gnu.eps
+
+uninstall_htmlexamples: uninstall_examples_always
+	-for f in `ls $(HTMLEXAMPLEFILESALL)`; do \
+	  $(RM) $(DESTDIR)$(exampledir)/$$f;\
 	done
-	-rm -f $(DESTDIR)$(exampledir)/gnu.eps
-	-rm -f $(DESTDIR)$(exampleimagedir)/$(HTMLEXAMPLEIMAGEFILES)
+	-$(RM) $(DESTDIR)$(exampleimagedir)/$(HTMLEXAMPLEIMAGEFILES)
 	-rmdir $(DESTDIR)$(exampleimagedir)
diff --git a/m4/groff.m4 b/m4/groff.m4
index 9b4ce26..cc0ab74 100644
--- a/m4/groff.m4
+++ b/m4/groff.m4
@@ -71,10 +71,70 @@ AC_DEFUN([GROFF_PERL],
      AC_MSG_ERROR([perl version is too old], 1))])
 
 
+# It is possible to fine-tune generation of documenation
+
+AC_DEFUN([GROFF_DOC_CHECK],
+  [AC_ARG_WITH([doc],
+    [AS_HELP_STRING([--with-doc[[=TYPE]]],
+      [choose which manuals (beside man pages) are desirable. \
+      Give TYPE as a comma-separated list of one or multiple of \
+      `info', `pdf' and `html', as well as `examples', \
+      to restrict what is produced])],
+    [doc=${withval}],
+    [doc=yes])
+  test "${doc}" = "no" && doc=''
+  if test "${doc}" = yes; then
+    doc_dist_target_ok=yes
+    docadd_other=yes
+    docadd_info=yes docadd_pdf=yes docadd_html=yes docadd_examples=yes
+  else
+    # Don't use case/esac, verify input
+    doc_dist_target_ok=no
+    docadd_other=
+    docadd_info= docadd_pdf= docadd_html= docadd_examples=
+    test -n "${doc}" && docadd_other=yes
+    OFS=${IFS}
+    IFS=','
+    set -- ${doc}
+    IFS=${OFS}
+    for i
+    do
+      test "${i}" = info     && { docadd_info=yes; continue; }
+      test "${i}" = pdf      && { docadd_pdf=yes; continue; }
+      test "${i}" = html     && { docadd_html=yes; continue; }
+      test "${i}" = examples && { docadd_examples=yes; continue; }
+      AC_MSG_WARN([Invalid --with-doc argument:] ${i})
+    done
+  fi
+  if test "${docadd_other}" = yes; then
+    make_otherdoc=otherdoc
+    make_install_otherdoc=install_otherdoc
+    make_uninstall_otherdoc=uninstall_otherdoc
+  else
+    make_otherdoc= make_install_otherdoc= make_uninstall_otherdoc=
+  fi
+  if test "${docadd_examples}" = yes; then
+    make_examples=examples
+    make_install_examples=install_examples
+    make_uninstall_examples=uninstall_examples
+  else
+    make_examples= make_install_examples= make_uninstall_examples=
+  fi
+  AC_SUBST([doc_dist_target_ok])
+  AC_SUBST([make_otherdoc])
+  AC_SUBST([make_install_otherdoc])
+  AC_SUBST([make_uninstall_otherdoc])
+  AC_SUBST([make_examples])
+  AC_SUBST([make_install_examples])
+  AC_SUBST([make_uninstall_examples])])
+
+
 # We need makeinfo 4.8 or newer.
 
 AC_DEFUN([GROFF_MAKEINFO],
-  [missing=
+  [make_infodoc= make_install_infodoc= make_uninstall_infodoc= MAKEINFO=
+  if test "${docadd_info}" = yes; then
+   missing=
    AC_CHECK_PROG([MAKEINFO], [makeinfo], [makeinfo])
    if test -z "$MAKEINFO"; then
      missing="\`makeinfo' is missing."
@@ -107,15 +167,22 @@ AC_DEFUN([GROFF_MAKEINFO],
 `groff.texinfo' into a PDF or HTML document.])
      fi
    fi
-   AC_SUBST([MAKEINFO])])
+   make_infodoc=infodoc
+   make_install_infodoc=install_infodoc
+   make_uninstall_infodoc=uninstall_infodoc
+  fi
+  AC_SUBST([MAKEINFO])
+  AC_SUBST([make_infodoc])
+  AC_SUBST([make_install_infodoc])
+  AC_SUBST([make_uninstall_infodoc])])
 
 
 # The following programs are needed for grohtml.
 
 AC_DEFUN([GROFF_HTML_PROGRAMS],
-  [AC_REQUIRE([GROFF_GHOSTSCRIPT_PATH])
-   make_html=html
-   make_install_html=install_html
+  [make_htmldoc= make_install_htmldoc= make_uninstall_htmldoc=
+   make_htmlexamples= make_install_htmlexamples= make_uninstall_htmlexamples=
+   AC_REQUIRE([GROFF_GHOSTSCRIPT_PATH])
 
    missing=
    AC_FOREACH([groff_prog],
@@ -127,7 +194,18 @@ AC_DEFUN([GROFF_HTML_PROGRAMS],
 
    test "$GHOSTSCRIPT" = "missing" && missing="$missing \`gs'"
 
-   if test -n "$missing"; then
+   if test -z "${missing}"; then
+     if test "${docadd_html}" = yes; then
+       make_htmldoc=htmldoc
+       make_install_htmldoc=install_htmldoc
+       make_uninstall_htmldoc=uninstall_htmldoc
+       if test "${docadd_examples}" = yes; then
+         make_htmlexamples=html_examples
+         make_install_htmlexamples=install_htmlexamples
+         make_uninstall_htmlexamples=uninstall_htmlexamples
+       fi
+     fi
+   else
      plural=`set $missing; test $[#] -gt 1 && echo s`
      missing=`set $missing
        missing=""
@@ -142,56 +220,72 @@ AC_DEFUN([GROFF_HTML_PROGRAMS],
 	 done
 	 echo $missing`
 
-     make_html=
-     make_install_html=
+     docnote=.
+     test "${docadd_html}" = yes && docnote=';
+  therefore, it will neither be possible to prepare, nor to install,
+  documentation in HTML format.'
 
      AC_MSG_WARN([missing program$plural:
 
   The program$plural
      $missing
   cannot be found in the PATH.
-  Consequently, groff's HTML backend (grohtml) will not work properly;
-  therefore, it will neither be possible to prepare, nor to install,
-  documentation in HTML format.
+  Consequently, groff's HTML backend (grohtml) will not work properly${docnote}
      ])
    fi
-
-   AC_SUBST([make_html])
-   AC_SUBST([make_install_html])])
+   AC_SUBST([make_htmldoc])
+   AC_SUBST([make_install_htmldoc])
+   AC_SUBST([make_uninstall_htmldoc])
+   AC_SUBST([make_htmlexamples])
+   AC_SUBST([make_install_htmlexamples])
+   AC_SUBST([make_uninstall_htmlexamples])])
 
 
 # To produce PDF docs, we need both awk and ghostscript.
 
 AC_DEFUN([GROFF_PDFDOC_PROGRAMS],
-  [AC_REQUIRE([GROFF_AWK_PATH])
+  [make_pdfdoc= make_install_pdfdoc= make_uninstall_pdfdoc=
+   make_pdfexamples= make_install_pdfexamples= make_uninstall_pdfexamples=
+   AC_REQUIRE([GROFF_AWK_PATH])
    AC_REQUIRE([GROFF_GHOSTSCRIPT_PATH])
 
-   make_pdfdoc=pdfdoc
-   make_install_pdfdoc=install_pdfdoc
-
    missing=""
    test "$AWK" = missing && missing="\`awk'"
    test "$GHOSTSCRIPT" = missing && missing="$missing \`gs'"
-   if test -n "$missing"; then
+   if test -z "${missing}"; then
+     if test "${docadd_pdf}" = yes; then
+       make_pdfdoc=pdfdoc
+       make_install_pdfdoc=install_pdfdoc
+       make_uninstall_pdfdoc=uninstall_pdfdoc
+       if test "${docadd_examples}" = yes; then
+         make_pdfexamples=pdfexamples
+         make_install_pdfexamples=install_pdfexamples
+         make_uninstall_pdfexamples=uninstall_pdfexamples
+       fi
+     fi
+   else
      plural=`set $missing; test $[#] -eq 2 && echo s`
      test x$plural = xs \
        && missing=`set $missing; echo "$[1] and $[2]"` \
        || missing=`echo $missing`
 
-     make_pdfdoc=
-     make_install_pdfdoc=
+     docnote=.
+     test "${docadd_pdf}" = yes && docnote=';
+  therefore, it will neither be possible to prepare, nor to install,
+  documentation and most of the examples in PDF format.'
 
      AC_MSG_WARN([missing program$plural:
 
   The program$plural $missing cannot be found in the PATH.
-  Consequently, groff's PDF formatter (pdfroff) will not work properly;
-  therefore, it will neither be possible to prepare, nor to install,
-  documentation in PDF format.
+  Consequently, groff's PDF formatter (pdfroff) will not work properly${docnote}
      ])
    fi
-
    AC_SUBST([make_pdfdoc])
-   AC_SUBST([make_install_pdfdoc])])
+   AC_SUBST([make_install_pdfdoc])
+   AC_SUBST([make_uninstall_pdfdoc])
+   AC_SUBST([make_pdfexamples])
+   AC_SUBST([make_install_pdfexamples])
+   AC_SUBST([make_uninstall_pdfexamples])])
 
 
 # Check whether pnmtops can handle the -nosetpage option.
@@ -800,7 +894,9 @@ AC_DEFUN([GROFF_INSTALL_SH],
 # Test whether install-info is available.
 
 AC_DEFUN([GROFF_INSTALL_INFO],
-  [AC_CHECK_PROGS([INSTALL_INFO], [install-info], [:])])
+  [if test "$docadd_info" = yes; then
+    AC_CHECK_PROGS([INSTALL_INFO], [install-info], [:])
+  fi])
 
 
 # At least one UNIX system, Apple Macintosh Rhapsody 5.5,
commit 9e0c3b8f49020d6eb31624bd653e50214cbe2cc4 (HEAD, refs/heads/withdoc)
Author: Steffen (Daode) Nurpmeso <sdao...@users.sf.net>
Date:   2014-03-15 20:57:50 +0100

    configure: regenerate
---
 configure | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 138 insertions(+), 27 deletions(-)

diff --git a/configure b/configure
index 274ff49..fc65e8b 100755
--- a/configure
+++ b/configure
@@ -627,12 +627,20 @@ ac_func_list=
 ac_subst_vars='LTLIBOBJS
 GLIBC21
 pnmtops_nosetpage
+make_uninstall_pdfexamples
+make_install_pdfexamples
+make_pdfexamples
+make_uninstall_pdfdoc
 make_install_pdfdoc
 make_pdfdoc
 ac_ct_AWK
 ALT_AWK_PROGS
-make_install_html
-make_html
+make_uninstall_htmlexamples
+make_install_htmlexamples
+make_htmlexamples
+make_uninstall_htmldoc
+make_install_htmldoc
+make_htmldoc
 pnmtops
 psselect
 pnmtopng
@@ -669,7 +677,17 @@ INSTALL_SCRIPT
 INSTALL_PROGRAM
 INSTALL_INFO
 RANLIB
+make_uninstall_infodoc
+make_install_infodoc
+make_infodoc
 MAKEINFO
+make_uninstall_examples
+make_install_examples
+make_examples
+make_uninstall_otherdoc
+make_install_otherdoc
+make_otherdoc
+doc_dist_target_ok
 YACC
 DVIPRINT
 PSPRINT
@@ -752,6 +770,7 @@ enable_option_checking
 with_x
 with_appresdir
 with_grofferdir
+with_doc
 with_gnu_ld
 enable_rpath
 with_libiconv_prefix
@@ -1399,6 +1418,10 @@ Optional Packages:
   --with-x                use the X Window System
   --with-appresdir=DIR    X11 application resource files
   --with-grofferdir=DIR   groffer files location
+  --with-doc[=TYPE]       choose which manuals (beside man pages) are
+                          desirable. Give TYPE as a comma-separated list of
+                          one or multiple of `info', `pdf' and `html', as well
+                          as `examples', to restrict what is produced
   --with-gnu-ld           assume the C compiler uses GNU ld default=no
   --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
   --without-libiconv-prefix     don't search for libiconv in includedir and libdir
@@ -6034,7 +6057,63 @@ fi
 done
 test -n "$YACC" || YACC="yacc"
 
-missing=
+
+# Check whether --with-doc was given.
+if test "${with_doc+set}" = set; then :
+  withval=$with_doc; doc=${withval}
+else
+  doc=yes
+fi
+
+  test "${doc}" = "no" && doc=''
+  if test "${doc}" = yes; then
+    doc_dist_target_ok=yes
+    docadd_other=yes
+    docadd_info=yes docadd_pdf=yes docadd_html=yes docadd_examples=yes
+  else
+    # Don't use case/esac, verify input
+    doc_dist_target_ok=no
+    docadd_other=
+    docadd_info= docadd_pdf= docadd_html= docadd_examples=
+    test -n "${doc}" && docadd_other=yes
+    OFS=${IFS}
+    IFS=','
+    set -- ${doc}
+    IFS=${OFS}
+    for i
+    do
+      test "${i}" = info     && { docadd_info=yes; continue; }
+      test "${i}" = pdf      && { docadd_pdf=yes; continue; }
+      test "${i}" = html     && { docadd_html=yes; continue; }
+      test "${i}" = examples && { docadd_examples=yes; continue; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Invalid --with-doc argument: ${i}" >&5
+$as_echo "$as_me: WARNING: Invalid --with-doc argument: ${i}" >&2;}
+    done
+  fi
+  if test "${docadd_other}" = yes; then
+    make_otherdoc=otherdoc
+    make_install_otherdoc=install_otherdoc
+    make_uninstall_otherdoc=uninstall_otherdoc
+  else
+    make_otherdoc= make_install_otherdoc= make_uninstall_otherdoc=
+  fi
+  if test "${docadd_examples}" = yes; then
+    make_examples=examples
+    make_install_examples=install_examples
+    make_uninstall_examples=uninstall_examples
+  else
+    make_examples= make_install_examples= make_uninstall_examples=
+  fi
+
+
+
+
+
+
+
+make_infodoc= make_install_infodoc= make_uninstall_infodoc= MAKEINFO=
+  if test "${docadd_info}" = yes; then
+   missing=
    # Extract the first word of "makeinfo", so it can be a program name with args.
 set dummy makeinfo; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -6108,6 +6187,13 @@ Get the \`texinfo' package version 4.8 or newer if you want to convert
 \`groff.texinfo' into a PDF or HTML document." >&2;}
      fi
    fi
+   make_infodoc=infodoc
+   make_install_infodoc=install_infodoc
+   make_uninstall_infodoc=uninstall_infodoc
+  fi
+
+
+
 
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
@@ -6233,7 +6319,8 @@ ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
 
    ac_dir=`cd $ac_aux_dir; pwd`
    ac_install_sh="$ac_dir/install-sh -c"
-for ac_prog in install-info
+if test "$docadd_info" = yes; then
+    for ac_prog in install-info
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -6276,6 +6363,7 @@ fi
 done
 test -n "$INSTALL_INFO" || INSTALL_INFO=":"
 
+  fi
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
 # incompatible versions:
@@ -10235,9 +10323,9 @@ fi
 fi
 
    test "$GHOSTSCRIPT" = "no" && GHOSTSCRIPT=missing
+make_htmldoc= make_install_htmldoc= make_uninstall_htmldoc=
+   make_htmlexamples= make_install_htmlexamples= make_uninstall_htmlexamples=
 
-   make_html=html
-   make_install_html=install_html
 
    missing=
    # Extract the first word of "pnmcut", so it can be a program name with args.
@@ -10444,7 +10532,18 @@ fi
 
    test "$GHOSTSCRIPT" = "missing" && missing="$missing \`gs'"
 
-   if test -n "$missing"; then
+   if test -z "${missing}"; then
+     if test "${docadd_html}" = yes; then
+       make_htmldoc=htmldoc
+       make_install_htmldoc=install_htmldoc
+       make_uninstall_htmldoc=uninstall_htmldoc
+       if test "${docadd_examples}" = yes; then
+         make_htmlexamples=html_examples
+         make_install_htmlexamples=install_htmlexamples
+         make_uninstall_htmlexamples=uninstall_htmlexamples
+       fi
+     fi
+   else
      plural=`set $missing; test $# -gt 1 && echo s`
      missing=`set $missing
        missing=""
@@ -10459,32 +10558,33 @@ fi
 	 done
 	 echo $missing`
 
-     make_html=
-     make_install_html=
+     docnote=.
+     test "${docadd_html}" = yes && docnote=';
+  therefore, it will neither be possible to prepare, nor to install,
+  documentation in HTML format.'
 
      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: missing program$plural:
 
   The program$plural
      $missing
   cannot be found in the PATH.
-  Consequently, groff's HTML backend (grohtml) will not work properly;
-  therefore, it will neither be possible to prepare, nor to install,
-  documentation in HTML format.
+  Consequently, groff's HTML backend (grohtml) will not work properly${docnote}
      " >&5
 $as_echo "$as_me: WARNING: missing program$plural:
 
   The program$plural
      $missing
   cannot be found in the PATH.
-  Consequently, groff's HTML backend (grohtml) will not work properly;
-  therefore, it will neither be possible to prepare, nor to install,
-  documentation in HTML format.
+  Consequently, groff's HTML backend (grohtml) will not work properly${docnote}
      " >&2;}
    fi
 
 
 
 
+
+
+
 # Check whether --with-alt-awk was given.
 if test "${with_alt_awk+set}" = set; then :
   withval=$with_alt_awk; ALT_AWK_PROGS="$withval"
@@ -10602,42 +10702,53 @@ fi
 fi
 
    test "$AWK" = "no" && AWK=missing
+make_pdfdoc= make_install_pdfdoc= make_uninstall_pdfdoc=
+   make_pdfexamples= make_install_pdfexamples= make_uninstall_pdfexamples=
 
 
 
-   make_pdfdoc=pdfdoc
-   make_install_pdfdoc=install_pdfdoc
-
    missing=""
    test "$AWK" = missing && missing="\`awk'"
    test "$GHOSTSCRIPT" = missing && missing="$missing \`gs'"
-   if test -n "$missing"; then
+   if test -z "${missing}"; then
+     if test "${docadd_pdf}" = yes; then
+       make_pdfdoc=pdfdoc
+       make_install_pdfdoc=install_pdfdoc
+       make_uninstall_pdfdoc=uninstall_pdfdoc
+       if test "${docadd_examples}" = yes; then
+         make_pdfexamples=pdfexamples
+         make_install_pdfexamples=install_pdfexamples
+         make_uninstall_pdfexamples=uninstall_pdfexamples
+       fi
+     fi
+   else
      plural=`set $missing; test $# -eq 2 && echo s`
      test x$plural = xs \
        && missing=`set $missing; echo "$1 and $2"` \
        || missing=`echo $missing`
 
-     make_pdfdoc=
-     make_install_pdfdoc=
+     docnote=.
+     test "${docadd_pdf}" = yes && docnote=';
+  therefore, it will neither be possible to prepare, nor to install,
+  documentation and most of the examples in PDF format.'
 
      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: missing program$plural:
 
   The program$plural $missing cannot be found in the PATH.
-  Consequently, groff's PDF formatter (pdfroff) will not work properly;
-  therefore, it will neither be possible to prepare, nor to install,
-  documentation in PDF format.
+  Consequently, groff's PDF formatter (pdfroff) will not work properly${docnote}
      " >&5
 $as_echo "$as_me: WARNING: missing program$plural:
 
   The program$plural $missing cannot be found in the PATH.
-  Consequently, groff's PDF formatter (pdfroff) will not work properly;
-  therefore, it will neither be possible to prepare, nor to install,
-  documentation in PDF format.
+  Consequently, groff's PDF formatter (pdfroff) will not work properly${docnote}
      " >&2;}
    fi
 
 
 
+
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pnmtops can handle the -nosetpage option" >&5
 $as_echo_n "checking whether pnmtops can handle the -nosetpage option... " >&6; }
    if echo P2 2 2 255 0 1 2 0 | pnmtops -nosetpage > /dev/null 2>&1 ; then

Reply via email to