################################################################################
#  THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY  #
#  Read the zproject/README.md for information about making permanent changes. #
################################################################################
# Default target
all-local: doc

# Public programs ("main" tags in project.xml), auto-regenerated:
MAN1 = zpinger.1
# Public classes ("class" tags in project.xml), auto-regenerated:
MAN3 = zyre.3 zyre_event.3
# Project overview, written by a human after initial skeleton:
# NOTE: stub doc/zyre.adoc is generated by GSL from project.xml
#       and then comitted to SCM and maintained manually to describe the
#       project (section 7 = Overview, conventions, and miscellaneous).
MAN7 = zyre.7
MAN_DOC = $(MAN1) $(MAN3) $(MAN7)

# Assumption: the single .7 page only covers the project and is maintained
# manually. The SCM-tracked text source file name uses an .adoc extension
# so as not to conflict with generated .txt files (in cases when a "class"
# or a "main" name is same as overall project name).
MAN_TXT = $(MAN7:%.7=%.adoc)

EXTRA_DIST = asciidoc.conf mkman

if INSTALL_MAN
dist_man_MANS = $(MAN_DOC)
endif

if BUILD_DOC
MAN_TXT += $(MAN1:%.1=%.txt)
MAN_TXT += $(MAN3:%.3=%.txt)

DISTCLEANFILES = $(MAN_DOC)

dist-hook : $(MAN_DOC)

SUFFIXES=.txt .adoc .xml .xml7 .1 .3 .7

.txt.xml:
	asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \
        -azyre_version=@PACKAGE_VERSION@ -o$@ $<
.xml.1:
	xmlto -o $(@D) man $<
.xml.3:
	xmlto -o $(@D) man $<

# Special handling for project overview whose basename may collide
# with a main or class name
.adoc.xml7:
	asciidoc -d manpage -b docbook -f $(srcdir)/asciidoc.conf \
        -azyre_version=@PACKAGE_VERSION@ -o$@ $<
.xml7.7:
	xmlto -o $(@D) man $<

# List of *.txt and *.doc files generated during build from comments
# in project program source files and further processed into manpages.
GENERATED_DOCS =

# No-op, docs and texts are generated by mkman in one shot - just
# make a dependency that can not parallelize and break stuff.
# Also, to be validly processed, the dependency must have SOME payload
.txt.doc:
	@true

GENERATED_DOCS += zyre.txt zyre.doc
zyre.txt: $(top_srcdir)/src/zyre.c
	"$(srcdir)/mkman" "zyre" "$(builddir)/zyre.txt" "$(srcdir)/.."

GENERATED_DOCS += zyre_event.txt zyre_event.doc
zyre_event.txt: $(top_srcdir)/src/zyre_event.c
	"$(srcdir)/mkman" "zyre_event" "$(builddir)/zyre_event.txt" "$(srcdir)/.."

### Note: for mains, we keep the source name rather than flattened name:c
### so that the manpages for binary programs match their name, at expense
### of perhaps being built in a subdirectory under doc/.
GENERATED_DOCS += zpinger.txt zpinger.doc
zpinger.txt: $(top_srcdir)/src/zpinger.c
	mkdir -p "$(builddir)/$(@D)"
	"$(srcdir)/mkman" "zpinger" "$(builddir)/zpinger.txt" "$(srcdir)/.."


clean-local:
	rm -f *.1 *.3 *.7 $(GENERATED_DOCS)

doc: $(GENERATED_DOCS)

else
doc:
	@echo "SKIPPING documentation generation and formatting (BUILD_DOC was not required and/or tools are missing)" >&2
endif

EXTRA_DIST += $(MAN_TXT)
################################################################################
#  THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY  #
#  Read the zproject/README.md for information about making permanent changes. #
################################################################################
