Fix: standardize man pages building/installing
[lttng-tools.git] / doc / man / Makefile.am
index ac5b21f73e7a8b8b46237ce69f60d9ffabe08635..d8882028a594bcc15b2f650b0184e50401774ca0 100644 (file)
@@ -1,5 +1,5 @@
-# Man pages are only built if the --enable-build-man-pages option was passed
-# to the configure script.
+# Man pages are only built if the --enable-man-pages option was
+# passed to the configure script.
 #
 # They should always be built before creating a distribution tarball.
 
 #
 # They should always be built before creating a distribution tarball.
 
@@ -38,27 +38,6 @@ MAN1_NO_ASCIIDOC_NAMES =
 MAN3_NO_ASCIIDOC_NAMES = lttng-health-check
 MAN8_NO_ASCIIDOC_NAMES =
 
 MAN3_NO_ASCIIDOC_NAMES = lttng-health-check
 MAN8_NO_ASCIIDOC_NAMES =
 
-# man pages destinations
-MAN1 = $(addsuffix .1,$(MAN1_NAMES))
-MAN3 = $(addsuffix .3,$(MAN3_NAMES))
-MAN8 = $(addsuffix .8,$(MAN8_NAMES))
-MAN1_NO_ASCIIDOC = $(addsuffix .1,$(MAN1_NO_ASCIIDOC_NAMES))
-MAN3_NO_ASCIIDOC = $(addsuffix .3,$(MAN3_NO_ASCIIDOC_NAMES))
-MAN8_NO_ASCIIDOC = $(addsuffix .8,$(MAN8_NO_ASCIIDOC_NAMES))
-MAN = $(MAN1) $(MAN3) $(MAN8)
-
-# those are always installed since they are written in troff
-dist_man1_MANS = $(MAN1_NO_ASCIIDOC)
-dist_man3_MANS = $(MAN3_NO_ASCIIDOC)
-dist_man8_MANS = $(MAN8_NO_ASCIIDOC)
-
-# only build man pages if it was enabled
-if BUILD_MAN_PAGES
-# dist + install
-dist_man1_MANS += $(MAN1)
-dist_man3_MANS += $(MAN3)
-dist_man8_MANS += $(MAN8)
-
 # AsciiDoc sources and outputs
 MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES))
 MAN3_TXT = $(call manaddsuffix,.3.txt,$(MAN3_NAMES))
 # AsciiDoc sources and outputs
 MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES))
 MAN3_TXT = $(call manaddsuffix,.3.txt,$(MAN3_NAMES))
@@ -85,9 +64,21 @@ XSL_SRC_FILES = $(addprefix $(srcdir)/xsl/,$(XSL_FILES))
 # common dependencies
 COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT)
 
 # common dependencies
 COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT)
 
+# man pages destinations
+MAN1 = $(addsuffix .1,$(MAN1_NAMES))
+MAN3 = $(addsuffix .3,$(MAN3_NAMES))
+MAN8 = $(addsuffix .8,$(MAN8_NAMES))
+MAN1_NO_ASCIIDOC = $(addsuffix .1,$(MAN1_NO_ASCIIDOC_NAMES))
+MAN3_NO_ASCIIDOC = $(addsuffix .3,$(MAN3_NO_ASCIIDOC_NAMES))
+MAN8_NO_ASCIIDOC = $(addsuffix .8,$(MAN8_NO_ASCIIDOC_NAMES))
+MAN = $(MAN1) $(MAN3) $(MAN8)
+
+if MAN_PAGES_OPT
+# at this point, we know the user asked to build the man pages
+if HAVE_ASCIIDOC_XMLTO
 # tools
 ADOC = $(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \
 # tools
 ADOC = $(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \
-       -a lttng_version=$(PACKAGE_VERSION)
+       -a lttng_version="$(PACKAGE_VERSION)"
 ADOC_DOCBOOK = $(ADOC) -b docbook
 XTO = $(XMLTO) -m $(firstword $(XSL_SRC_FILES)) man
 
 ADOC_DOCBOOK = $(ADOC) -b docbook
 XTO = $(XMLTO) -m $(firstword $(XSL_SRC_FILES)) man
 
@@ -110,21 +101,39 @@ XTO = $(XMLTO) -m $(firstword $(XSL_SRC_FILES)) man
 %.8: %.8.xml $(XSL_SRC_FILES)
        $(XTO) $<
 
 %.8: %.8.xml $(XSL_SRC_FILES)
        $(XTO) $<
 
-clean-local:
-       rm -rf $(MAN_XML)
-       rm -rf $(MAN)
-else
-if IN_GIT_REPO
-# we are in the Git repo: the man pages should be built for distribution
-dist-hook:
-       @echo
-       @echo 'Error: Please build the man pages before creating a tarball.'
-       @echo
+# only clean the generated files if we have the tools to generate them again
+CLEANFILES = $(MAN_XML) $(MAN)
+else # HAVE_ASCIIDOC_XMLTO
+# create man page targets used to stop the build if we want to
+# build the man pages, but we don't have the necessary tools to do so
+ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing."
+ERR_MSG += "Make sure both tools are installed and run the configure script again."
+
+%.1: $(srcdir)/%.1.txt $(COMMON_DEPS)
+       @echo $(ERR_MSG)
+       @false
+
+%.3: $(srcdir)/%.3.txt $(COMMON_DEPS)
+       @echo $(ERR_MSG)
+       @false
+
+%.8: $(srcdir)/%.8.txt $(COMMON_DEPS)
+       @echo $(ERR_MSG)
        @false
        @false
-else
-# we are in the tarball, hence the man pages are already built
+endif # HAVE_ASCIIDOC_XMLTO
+endif # MAN_PAGES_OPT
+
+# those are always installed since they are directly written in troff
+dist_man1_MANS = $(MAN1_NO_ASCIIDOC)
+dist_man3_MANS = $(MAN3_NO_ASCIIDOC)
+dist_man8_MANS = $(MAN8_NO_ASCIIDOC)
+
+if MAN_PAGES_OPT
+# building man pages: we can install and distribute them
 dist_man1_MANS += $(MAN1)
 dist_man3_MANS += $(MAN3)
 dist_man8_MANS += $(MAN8)
 dist_man1_MANS += $(MAN1)
 dist_man3_MANS += $(MAN3)
 dist_man8_MANS += $(MAN8)
-endif # IN_GIT_REPO
-endif # BUILD_MAN_PAGES
+endif # MAN_PAGES_OPT
+
+# always distribute the source files
+EXTRA_DIST = $(MAN_TXT) $(COMMON_TXT) $(XSL_SRC_FILES) $(ASCIIDOC_CONF)
This page took 0.025223 seconds and 5 git commands to generate.