summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2015-08-13 18:48:53 +0200
committerJean-Sébastien Pédron <jean-sebastien.pedron@dumbbell.fr>2015-10-20 11:10:48 +0200
commitd1fce2e9ab033221fbb31a893a57ae38b475dd21 (patch)
treed06aa9285d40901628ac41266a833ad6bb2e3ff9 /Makefile
parent75e07313179f6fa6ee06320e842a59917c37f50c (diff)
downloadrabbitmq-server-git-d1fce2e9ab033221fbb31a893a57ae38b475dd21.tar.gz
Makefile: Connect manpages to the build
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile117
1 files changed, 60 insertions, 57 deletions
diff --git a/Makefile b/Makefile
index 20c6317d3b..6602949968 100644
--- a/Makefile
+++ b/Makefile
@@ -5,63 +5,6 @@ dep_rabbitmq_common= git file:///home/dumbbell/Projects/pivotal/other-repos/rabb
.DEFAULT_GOAL = all
-# --------------------------------------------------------------------
-# Man pages.
-# --------------------------------------------------------------------
-
-DOCS_DIR = docs
-MANPAGES = $(patsubst %.xml, %.gz, $(wildcard $(DOCS_DIR)/*.[0-9].xml))
-WEB_MANPAGES = $(patsubst %.xml, %.man.xml, $(wildcard $(DOCS_DIR)/*.[0-9].xml) $(DOCS_DIR)/rabbitmq-service.xml $(DOCS_DIR)/rabbitmq-echopid.xml)
-USAGES_XML = $(DOCS_DIR)/rabbitmqctl.1.xml $(DOCS_DIR)/rabbitmq-plugins.1.xml
-USAGES_ERL = $(foreach XML, $(USAGES_XML), $(call usage_xml_to_erl, $(XML)))
-
-# xmlto can not read from standard input, so we mess with a tmp file.
-%.gz: %.xml $(DOCS_DIR)/examples-to-end.xsl
- $(gen_verbose) xmlto --version | \
- grep -E '^xmlto version 0\.0\.([0-9]|1[1-8])$$' >/dev/null || \
- opt='--stringparam man.indent.verbatims=0' ; \
- xsltproc --novalid $(DOCS_DIR)/examples-to-end.xsl $< > $<.tmp && \
- xmlto -o $(DOCS_DIR) $$opt man $<.tmp && \
- gzip -f $(DOCS_DIR)/`basename $< .xml` && \
- rm -f $<.tmp
-
-# Use tmp files rather than a pipeline so that we get meaningful errors
-# Do not fold the cp into previous line, it's there to stop the file being
-# generated but empty if we fail
-src/%_usage.erl:
- $(gen_verbose) xsltproc --novalid --stringparam modulename "`basename $@ .erl`" \
- $(DOCS_DIR)/usage.xsl $< > $@.tmp && \
- sed -e 's/"/\\"/g' -e 's/%QUOTE%/"/g' $@.tmp > $@.tmp2 && \
- fold -s $@.tmp2 > $@.tmp3 && \
- mv $@.tmp3 $@ && \
- rm $@.tmp $@.tmp2
-
-# We rename the file before xmlto sees it since xmlto will use the name of
-# the file to make internal links.
-%.man.xml: %.xml $(DOCS_DIR)/html-to-website-xml.xsl
- $(gen_verbose) cp $< `basename $< .xml`.xml && \
- xmlto xhtml-nochunks `basename $< .xml`.xml ; \
- rm `basename $< .xml`.xml && \
- cat `basename $< .xml`.html | \
- xsltproc --novalid $(DOCS_DIR)/remove-namespaces.xsl - | \
- xsltproc --novalid --stringparam original `basename $<` $(DOCS_DIR)/html-to-website-xml.xsl - | \
- xmllint --format - > $@ && \
- rm `basename $< .xml`.html
-
-define usage_xml_to_erl
-$(subst __,_,$(patsubst $(DOCS_DIR)/rabbitmq%.1.xml, src/rabbit_%_usage.erl, $(subst -,_,$(1))))
-endef
-
-define usage_dep
-$(call usage_xml_to_erl, $(1)):: $(1) $(DOCS_DIR)/usage.xsl
-endef
-
-$(foreach XML,$(USAGES_XML),$(eval $(call usage_dep, $(XML))))
-
-# --------------------------------------------------------------------
-# Back to main targets.
-# --------------------------------------------------------------------
-
include erlang.mk
ebin/$(PROJECT).app:: $(USAGES_ERL)
@@ -122,3 +65,63 @@ ifndef USE_PROPER_QC
USE_PROPER_QC = $(shell $(ERL) -eval 'io:format({module, proper} =:= code:ensure_loaded(proper)), halt().')
ERLC_OPTS += $(call boolean_macro,$(USE_PROPER_QC),use_proper_qc)
endif
+
+# --------------------------------------------------------------------
+# Man pages.
+# --------------------------------------------------------------------
+
+DOCS_DIR = docs
+MANPAGES = $(patsubst %.xml, %.gz, $(wildcard $(DOCS_DIR)/*.[0-9].xml))
+WEB_MANPAGES = $(patsubst %.xml, %.man.xml, $(wildcard $(DOCS_DIR)/*.[0-9].xml) $(DOCS_DIR)/rabbitmq-service.xml $(DOCS_DIR)/rabbitmq-echopid.xml)
+USAGES_XML = $(DOCS_DIR)/rabbitmqctl.1.xml $(DOCS_DIR)/rabbitmq-plugins.1.xml
+USAGES_ERL = $(foreach XML, $(USAGES_XML), $(call usage_xml_to_erl, $(XML)))
+
+# xmlto can not read from standard input, so we mess with a tmp file.
+%.gz: %.xml $(DOCS_DIR)/examples-to-end.xsl
+ $(gen_verbose) xmlto --version | \
+ grep -E '^xmlto version 0\.0\.([0-9]|1[1-8])$$' >/dev/null || \
+ opt='--stringparam man.indent.verbatims=0' ; \
+ xsltproc --novalid $(DOCS_DIR)/examples-to-end.xsl $< > $<.tmp && \
+ (xmlto -o $(DOCS_DIR) $$opt man $<.tmp 2>&1 | (grep -qv '^Note: Writing' || :)) && \
+ gzip -f $(DOCS_DIR)/`basename $< .xml` && \
+ rm -f $<.tmp
+
+# Use tmp files rather than a pipeline so that we get meaningful errors
+# Do not fold the cp into previous line, it's there to stop the file being
+# generated but empty if we fail
+src/%_usage.erl:
+ $(gen_verbose) xsltproc --novalid --stringparam modulename "`basename $@ .erl`" \
+ $(DOCS_DIR)/usage.xsl $< > $@.tmp && \
+ sed -e 's/"/\\"/g' -e 's/%QUOTE%/"/g' $@.tmp > $@.tmp2 && \
+ fold -s $@.tmp2 > $@.tmp3 && \
+ mv $@.tmp3 $@ && \
+ rm $@.tmp $@.tmp2
+
+# We rename the file before xmlto sees it since xmlto will use the name of
+# the file to make internal links.
+%.man.xml: %.xml $(DOCS_DIR)/html-to-website-xml.xsl
+ $(gen_verbose) cp $< `basename $< .xml`.xml && \
+ xmlto xhtml-nochunks `basename $< .xml`.xml ; \
+ rm `basename $< .xml`.xml && \
+ cat `basename $< .xml`.html | \
+ xsltproc --novalid $(DOCS_DIR)/remove-namespaces.xsl - | \
+ xsltproc --novalid --stringparam original `basename $<` $(DOCS_DIR)/html-to-website-xml.xsl - | \
+ xmllint --format - > $@ && \
+ rm `basename $< .xml`.html
+
+define usage_xml_to_erl
+$(subst __,_,$(patsubst $(DOCS_DIR)/rabbitmq%.1.xml, src/rabbit_%_usage.erl, $(subst -,_,$(1))))
+endef
+
+define usage_dep
+$(call usage_xml_to_erl, $(1)):: $(1) $(DOCS_DIR)/usage.xsl
+endef
+
+$(foreach XML,$(USAGES_XML),$(eval $(call usage_dep, $(XML))))
+
+docs:: $(MANPAGES) $(WEB_MANPAGES)
+
+distclean:: distclean-manpages
+
+distclean-manpages::
+ $(gen_verbose) rm -f $(MANPAGES) $(WEB_MANPAGES)