aboutsummaryrefslogtreecommitdiffstats
path: root/build/Makefile.vty-reference.inc
blob: 878c841fc5b686a8a7c156f0ac639b1bda86b947 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Usage:
# Have files:
# - osmoyada-vty-reference.xml
#   A docbook root XML including a &chapter-vty; reference.
# - vty/*additions*.xml
#   Manual additions to specific VTY nodes, any number of files.
# - vty/*_reference.xml
#   Export from VTY 'show online-help', exactly one file.
#   The vty/*_reference.xml file may also live in the $(builddir)/vty/,
#   in which case you need to add it to BUILT_REFERENCE_XML, and provide a build rule, like:
#      BUILT_REFERENCE_XML = $(builddir)/vty/osmoyada_reference.xml
#      $(builddir)/vty/osmoyada_reference.xml:
#              mkdir -p $(builddir)/vty
#              $(top_builddir)/src/osmoyada --vty-ref-xml > $@
#
# In your Makefile.am,
# - define 'OSMO_GSM_MANUALS_DIR' to point at the osmo-gsm-manuals shared files
#   installation path as returned by "pkg-config osmo-gsm-manuals --variable=osmogsmmanualsdir"
#   (project specific repos set this with configure.ac),
# - define the (single) name of the vty-reference source in VTY_REFERENCE,
# - include this file.
#
# e.g.
#
#     OSMO_GSM_MANUALS_DIR = ..
#     VTY_REFERENCE = osmofoo-vty-reference.xml
#     include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.vty-reference.inc
#
# This uses the Makefile.docbook.inc, you should not mix uses of
# Makefile.vty-reference.inc and Makefile.docbook.inc.
#
# In order to add more than one VTY reference, do this for each additional one:
# - Extend VTY_REFERENCE with the new entry, make sure it ends in "-vty-reference.xml":
#	VTY_REFERENCE = osmofoo-vty-reference.xml osmobar-vty-reference.xml
# - Create a new osmobar-vty-reference.xml file, just like osmofoo-vty-reference.xml, but with
#   "generated/docbook_osmobar-vty-reference.xml" as sections-vty path instead of
#   "generated/docbook_vty.xml".
# - Create vty-osmobar/*_additions.xml and vty-osmobar/*_reference.xml. Pay attention to the
#   directory name, it must start with vty-* instead of "vty" and it must match the prefix of
#   your new VTY_REFERENCE entry ("vty-osmobar" in this example).
# - Add osmobar-vty-reference.xml and vty-osmobar to EXTRA_DIST in Makefile.am.
# - Full example: osmo-sgsn.git I24c3ca2fc2446673edceefb797c7d800c3a1a5d2
# - The vty-osmobar/*_reference.xml may also live in the builddir: add it to
#   BUILT_REFERENCE_XML and provide a build rule, like:
#      BUILT_REFERENCE_XML += $(builddir)/vty-osmobar/osmobar_reference.xml
#      $(builddir)/vty-osmobar/osmobar_reference.xml: $(top_builddir)/src/osmobar
#              mkdir -p $(builddir)/vty-osmobar
#              $(top_builddir)/src/osmobar --vty-ref-xml > $@

DOCBOOKS = $(VTY_REFERENCE)

# Directory for intermediate results
GEN_DIR = generated

# First VTY reference
DOCBOOKS_DEPS = $(GEN_DIR)/docbook_vty.xml

# Additional VTY references: prepend "$(GEN_DIR)/docbook_"
# For example:
# VTY_REFERENCE = osmosgsn-vty-reference.xml osmogbproxy-vty-reference.xml
# DOCBOOK_DEPS = $(GEN_DIR)/docbook_vty.xml $(GEN_DIR)/docbook_osmogbproxy-vty-reference.xml
DOCBOOKS_DEPS += $(patsubst %,$(GEN_DIR)/docbook_%,$(filter-out $(firstword $(VTY_REFERENCE)),$(VTY_REFERENCE)))

include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.docbook.inc

MERGE_DOC = $(shell realpath $(OSMO_GSM_MANUALS_DIR)/merge_doc.xsl)

CLEAN_FILES += $(GEN_DIR)
CLEAN_FILES += $(BUILT_REFERENCE_XML)

# First VTY reference
$(GEN_DIR)/docbook_vty.xml: \
			   $(srcdir)/vty/*xml \
			   $(BUILT_REFERENCE_XML) \
			   $(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
			   $(OSMO_GSM_MANUALS_DIR)/common/chapters/vty.xml \
			   $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl
	mkdir -p $(GEN_DIR)
	$(OSMO_GSM_MANUALS_DIR)/build/vty_reference_combine.sh "$(MERGE_DOC)" \
		$$($(OSMO_GSM_MANUALS_DIR)/build/find_existing_path.sh "vty/*reference.xml" $(builddir) $(srcdir)) \
		$(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
		$(srcdir)/vty/*additions*.xml > $(GEN_DIR)/combined.xml
	xsltproc $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl $(GEN_DIR)/combined.xml \
		> $(GEN_DIR)/docbook_vty.xml

# Additional VTY references
$(GEN_DIR)/docbook_%-vty-reference.xml: \
			 $(srcdir)/vty-%/*xml \
			 $(BUILT_REFERENCE_XML) \
			 $(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
			 $(OSMO_GSM_MANUALS_DIR)/common/chapters/vty.xml \
			 $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl
	export VTYDIR_NAME="vty-$(patsubst $(GEN_DIR)/docbook_%-vty-reference.xml,%,$@)" && \
	export VTYDIR_SRC="$(srcdir)/$$VTYDIR_NAME" && \
	export VTYDIR_BUILD="$(builddir)/$$VTYDIR_NAME" && \
	export VTYGEN="$@_combine" && \
	mkdir -p $$VTYGEN && \
	$(OSMO_GSM_MANUALS_DIR)/build/vty_reference_combine.sh "$(MERGE_DOC)" \
		$$($(OSMO_GSM_MANUALS_DIR)/build/find_existing_path.sh "*reference.xml" $$VTYDIR_BUILD $$VTYDIR_SRC) \
		$(OSMO_GSM_MANUALS_DIR)/common/vty_additions.xml \
		$$VTYDIR_SRC/*additions*.xml > $$VTYGEN/combined.xml && \
	xsltproc $(OSMO_GSM_MANUALS_DIR)/vty_reference.xsl $$VTYGEN/combined.xml > "$@"