qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 118/132] meson: build texi doc


From: Paolo Bonzini
Subject: [PATCH 118/132] meson: build texi doc
Date: Thu, 19 Dec 2019 13:23:38 +0100

From: Marc-André Lureau <address@hidden>

Signed-off-by: Marc-André Lureau <address@hidden>
---
 Makefile                       | 139 ++---------------------------------------
 docs/interop/qemu-ga-ref.texi  |   2 +-
 docs/interop/qemu-qmp-ref.texi |   2 +-
 docs/meson.build               |   1 +
 meson.build                    | 117 +++++++++++++++++++++++++++++++++-
 rules.mak                      |  12 ----
 6 files changed, 125 insertions(+), 148 deletions(-)

diff --git a/Makefile b/Makefile
index c1ea39f..ac21e14 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,6 @@ BUILD_DIR=$(CURDIR)
 SRC_PATH=.
 
 UNCHECKED_GOALS := %clean TAGS cscope ctags dist \
-    html info pdf txt \
     help check-help print-% \
     docker docker-% vm-help vm-test vm-build-%
 
@@ -106,29 +105,13 @@ edk2-decompressed = $(basename $(wildcard 
pc-bios/edk2-*.fd.bz2))
 Makefile: ;
 configure: ;
 
-.PHONY: all clean cscope distclean html info install install-doc \
-       pdf txt recurse-all dist msi FORCE
+.PHONY: all clean cscope distclean install \
+       recurse-all dist msi FORCE
 
 $(call set-vpath, $(SRC_PATH))
 
 LIBS+=-lz $(LIBS_TOOLS)
 
-ifdef BUILD_DOCS
-DOCS=qemu-doc.html qemu-doc.txt qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8
-DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt 
docs/interop/qemu-qmp-ref.7
-DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt 
docs/interop/qemu-ga-ref.7
-DOCS+=docs/qemu-block-drivers.7
-DOCS+=docs/qemu-cpu-models.7
-ifdef CONFIG_VIRTFS
-DOCS+=fsdev/virtfs-proxy-helper.1
-endif
-ifdef CONFIG_TRACE_SYSTEMTAP
-DOCS+=scripts/qemu-trace-stap.1
-endif
-else
-DOCS=
-endif
-
 SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) 
BUILD_DIR=$(BUILD_DIR)
 
 ifneq ($(wildcard config-host.mak),)
@@ -137,7 +120,7 @@ endif
 
 include $(SRC_PATH)/tests/Makefile.include
 
-all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) recurse-all modules
+all: recurse-all modules
 
 DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" 
LIBFDT_srcdir=$(SRC_PATH)/dtc/libfdt
 DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
@@ -225,25 +208,13 @@ qemu-%.tar.bz2:
        $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst 
qemu-%.tar.bz2,%,$@)"
 
 distclean: clean
-       rm -f config-host.mak config-host.h* config-host.ld $(DOCS) 
qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi qemu-monitor-info.texi
+       rm -f config-host.mak config-host.h* config-host.ld
        rm -f tests/tcg/config-*.mak
        rm -f config-all-disas.mak config.status
        rm -f po/*.mo tests/qemu-iotests/common.env
        rm -f roms/seabios/config.mak roms/vgabios/config.mak
-       rm -f qemu-doc.info qemu-doc.aux qemu-doc.cp qemu-doc.cps
-       rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys
-       rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp
-       rm -f qemu-doc.vr qemu-doc.txt
        rm -f config.log
        rm -f linux-headers/asm
-       rm -f docs/version.texi
-       rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
-       rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
-       rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
-       rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
-       rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
-       rm -f docs/qemu-block-drivers.7
-       rm -f docs/qemu-cpu-models.7
        rm -Rf .sdk
        if test -f dtc/version_gen.h; then $(MAKE) $(DTC_MAKE_ARGS) clean; fi
 
@@ -283,39 +254,6 @@ BLOBS=
 DESCS=
 endif
 
-install-doc: $(DOCS)
-       $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
-       $(INSTALL_DATA) qemu-doc.html "$(DESTDIR)$(qemu_docdir)"
-       $(INSTALL_DATA) qemu-doc.txt "$(DESTDIR)$(qemu_docdir)"
-       $(INSTALL_DATA) docs/interop/qemu-qmp-ref.html 
"$(DESTDIR)$(qemu_docdir)"
-       $(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)"
-ifdef CONFIG_POSIX
-       $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
-       $(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1"
-       $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
-       $(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
-       $(INSTALL_DATA) docs/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
-       $(INSTALL_DATA) docs/qemu-cpu-models.7 "$(DESTDIR)$(mandir)/man7"
-ifeq ($(CONFIG_TOOLS),y)
-       $(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1"
-       $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
-       $(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
-endif
-ifdef CONFIG_TRACE_SYSTEMTAP
-       $(INSTALL_DATA) scripts/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1"
-endif
-ifeq ($(CONFIG_GUEST_AGENT),y)
-       $(INSTALL_DATA) qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
-       $(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)"
-       $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)"
-       $(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
-endif
-endif
-ifdef CONFIG_VIRTFS
-       $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
-       $(INSTALL_DATA) fsdev/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
-endif
-
 install-datadir:
        $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
 
@@ -328,7 +266,7 @@ endif
 
 ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
 
-install: all $(if $(BUILD_DOCS),install-doc) install-datadir 
install-localstatedir \
+install: all install-datadir install-localstatedir \
        $(if $(INSTALL_BLOBS),$(edk2-decompressed)) \
        recurse-install
 ifneq ($(vhost-user-json-y),)
@@ -397,67 +335,6 @@ cscope:
        find "$(SRC_PATH)/" -name "*.[chsS]" -print | sed 's,^\./,,' > 
"$(SRC_PATH)/cscope.files"
        cscope -b -i"$(SRC_PATH)/cscope.files"
 
-# documentation
-MAKEINFO=makeinfo
-MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
-MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
-TEXI2PODFLAGS=$(MAKEINFOINCLUDES) -DVERSION="$(VERSION)" 
-DCONFDIR="$(qemu_confdir)"
-TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
-
-%.html: %.texi docs/version.texi
-       $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers 
\
-       --html $< -o $@,"GEN","$@")
-
-%.info: %.texi docs/version.texi
-       $(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
-
-%.txt: %.texi docs/version.texi
-       $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers 
\
-       --plaintext $< -o $@,"GEN","$@")
-
-%.pdf: %.texi docs/version.texi
-       $(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
-
-docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
-       @cp -p $< $@
-
-docs/interop/qemu-ga-qapi.texi: qga/qga-qapi-doc.texi
-       @cp -p $< $@
-
-qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi 
qemu-monitor-info.texi
-qemu.1: qemu-option-trace.texi
-qemu-img.1: qemu-img.texi qemu-option-trace.texi qemu-img-cmds.texi
-fsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi
-qemu-nbd.8: qemu-nbd.texi qemu-option-trace.texi
-qemu-ga.8: qemu-ga.texi
-docs/qemu-block-drivers.7: docs/qemu-block-drivers.texi
-docs/qemu-cpu-models.7: docs/qemu-cpu-models.texi
-scripts/qemu-trace-stap.1: scripts/qemu-trace-stap.texi
-
-html: qemu-doc.html docs/interop/qemu-qmp-ref.html 
docs/interop/qemu-ga-ref.html sphinxdocs
-info: qemu-doc.info docs/interop/qemu-qmp-ref.info 
docs/interop/qemu-ga-ref.info
-pdf: qemu-doc.pdf docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
-txt: qemu-doc.txt docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
-
-qemu-doc.html qemu-doc.info qemu-doc.pdf qemu-doc.txt: \
-       qemu-img.texi qemu-nbd.texi qemu-options.texi \
-       qemu-tech.texi qemu-option-trace.texi \
-       qemu-deprecated.texi qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi \
-       qemu-monitor-info.texi docs/qemu-block-drivers.texi \
-       docs/qemu-cpu-models.texi docs/security.texi
-
-docs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
-    docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
-    docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
-       docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
-
-docs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
-    docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
-    docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
-       docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
-
-$(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
-
 ifdef CONFIG_WIN32
 
 INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
@@ -480,7 +357,7 @@ installer: $(INSTALLER)
 
 INSTDIR=/tmp/qemu-nsis
 
-$(INSTALLER): install-doc $(SRC_PATH)/qemu.nsi
+$(INSTALLER): $(SRC_PATH)/qemu.nsi
        $(MAKE) install prefix=${INSTDIR}
 ifdef SIGNCODE
        (cd ${INSTDIR}; \
@@ -551,10 +428,6 @@ endif
        @echo  '  docker          - Help about targets running tests inside 
containers'
        @echo  '  vm-help         - Help about targets running tests inside VM'
        @echo  ''
-       @echo  'Documentation targets:'
-       @echo  '  html info pdf txt'
-       @echo  '                  - Build documentation in specified format'
-       @echo  ''
 ifdef CONFIG_WIN32
        @echo  'Windows targets:'
        @echo  '  installer       - Build NSIS-based installer for QEMU'
diff --git a/docs/interop/qemu-ga-ref.texi b/docs/interop/qemu-ga-ref.texi
index ddb76ce..a23cc2e 100644
--- a/docs/interop/qemu-ga-ref.texi
+++ b/docs/interop/qemu-ga-ref.texi
@@ -65,7 +65,7 @@ along with this manual.  If not, see 
http://www.gnu.org/licenses/.
 @c for texi2pod:
 @c man begin DESCRIPTION
 
-@include qemu-ga-qapi.texi
+@include qga/qga-qapi-doc.texi
 
 @c man end
 
diff --git a/docs/interop/qemu-qmp-ref.texi b/docs/interop/qemu-qmp-ref.texi
index bb25758..ea1d7fe 100644
--- a/docs/interop/qemu-qmp-ref.texi
+++ b/docs/interop/qemu-qmp-ref.texi
@@ -65,7 +65,7 @@ along with this manual.  If not, see 
http://www.gnu.org/licenses/.
 @c for texi2pod:
 @c man begin DESCRIPTION
 
-@include qemu-qmp-qapi.texi
+@include qapi/qapi-doc.texi
 
 @c man end
 
diff --git a/docs/meson.build b/docs/meson.build
index c71fff9..5d20afb 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -60,6 +60,7 @@ if sphinx.found()
     'specs/ppc-xive.rst',
   ]
   specs = custom_target('sphinx-specs',
+                build_by_default: build_docs,
                 input: specs_rst,
                 depend_files: [files('conf.py', 'specs/conf.py')],
                 output: 'specs',
diff --git a/meson.build b/meson.build
index 5b4b472..40ba735 100644
--- a/meson.build
+++ b/meson.build
@@ -457,13 +457,33 @@ foreach d : hx_headers
                 command: [hxtool, '-h', '@INPUT0@'])
 endforeach
 
+# meson makes it a bit difficult to refer to build targets
+# and texi tools don't generate depfiles
+# let's make doc generation depend on all texi
+texi_deps = [
+  'docs/interop/qemu-ga-ref.texi',
+  'docs/interop/qemu-qmp-ref.texi',
+  'docs/qemu-block-drivers.texi',
+  'docs/qemu-cpu-models.texi',
+  'docs/security.texi',
+  'fsdev/virtfs-proxy-helper.texi',
+  'qemu-deprecated.texi',
+  'qemu-doc.texi',
+  'qemu-ga.texi',
+  'qemu-img.texi',
+  'qemu-nbd.texi',
+  'qemu-option-trace.texi',
+  'qemu-tech.texi',
+  'scripts/qemu-trace-stap.texi',
+]
+
 foreach d : [
   ['qemu-options.hx', 'qemu-options.texi'],
   ['hmp-commands.hx', 'qemu-monitor.texi'],
   ['hmp-commands-info.hx', 'qemu-monitor-info.texi'],
   ['qemu-img-cmds.hx', 'qemu-img-cmds.texi'],
 ]
-  custom_target(d[1],
+  texi_deps += custom_target(d[1],
                 input: files(d[0]),
                 output: d[1],
                 capture: true,
@@ -925,3 +945,98 @@ endif
 
 subdir('pc-bios')
 subdir('docs')
+
+makeinfo = find_program('makeinfo', required: build_docs)
+
+docs_inc = [
+  '-I', meson.current_source_dir(),
+  '-I', meson.current_build_dir() / 'docs',
+  '-I', '@OUTDIR@',
+]
+
+texi = {
+  'qemu-doc': files('qemu-doc.texi'),
+  'qemu-qmp-ref': files('docs/interop/qemu-qmp-ref.texi'),
+}
+if 'CONFIG_GUEST_AGENT' in config_host
+  texi += {'qemu-ga-ref': files('docs/interop/qemu-ga-ref.texi')}
+endif
+
+if makeinfo.found() and build_docs
+  foreach doc, input: texi
+    cmd = [
+      'env', 'LC_ALL=C', makeinfo, '--no-split', '--number-sections', docs_inc,
+      '@INPUT0@', '-o', '@OUTPUT@',
+    ]
+    foreach ext, args: {
+        'info': [],
+        'html': ['--no-headers', '--html'],
+        'txt': ['--no-headers', '--plaintext'],
+    }
+      output = doc + '.' + ext
+      custom_target(output,
+                    input: input + texi_deps,
+                    output: output,
+                    install: true,
+                    install_dir: config_host['qemu_docdir'],
+                    command: cmd + args)
+    endforeach
+  endforeach
+endif
+
+texi2pdf = find_program('texi2pdf', required: false)
+
+if texi2pdf.found()
+  foreach doc, input: texi
+    output = doc + '.pdf'
+    custom_target(output,
+                  input: input + texi_deps,
+                  output: output,
+                  command: [texi2pdf, '-q', docs_inc, '@INPUT0@', '-o', 
'@OUTPUT@'])
+  endforeach
+endif
+
+texi2pod = find_program('scripts/texi2pod.pl')
+pod2man = find_program('pod2man', required: build_docs)
+
+mans = {
+  'qemu-block-drivers.7': files('docs/qemu-block-drivers.texi'),
+  'qemu-cpu-models.7': files('docs/qemu-cpu-models.texi'),
+  'qemu-qmp-ref.7': files('docs/interop/qemu-qmp-ref.texi'),
+  'qemu.1': files('qemu-doc.texi'),
+}
+if 'CONFIG_GUEST_AGENT' in config_host
+  mans += {'qemu-ga-ref.7': files('docs/interop/qemu-ga-ref.texi')}
+  mans += {'qemu-ga.8': files('qemu-ga.texi')}
+endif
+if 'CONFIG_TOOLS' in config_host
+  mans += {'qemu-img.7': files('qemu-img.texi')}
+  mans += {'qemu-nbd.8': files('qemu-nbd.texi')}
+endif
+if 'CONFIG_VIRTFS' in config_host
+  mans += {'virtfs-proxy-helper.1': files('fsdev/virtfs-proxy-helper.texi')}
+endif
+if 'CONFIG_TRACE_SYSTEMTAP' in config_host
+  mans += {'qemu-trace-stap.1': files('scripts/qemu-trace-stap.texi')}
+endif
+
+if pod2man.found() and build_docs
+  foreach man, input: mans
+    pod = custom_target(man + '.pod',
+                        input: input + texi_deps,
+                        output: man + '.pod',
+                        command: [texi2pod,
+                                  '-DVERSION="' + config_host['VERSION'] + '"',
+                                  '-DCONFDIR="' + config_host['qemu_confdir'] 
+ '"',
+                                  '@INPUT0@', '@OUTPUT@'])
+    section = man[-1]
+    man = custom_target(man,
+                        input: pod,
+                        output: man,
+                        capture: true,
+                        install: true,
+                        install_dir: config_host['mandir'] / 'man' + section,
+                        command: [pod2man, '--utf8', '--section=' + section, 
'--center=" "',
+                                  '--release=" "', '@INPUT@'])
+  endforeach
+endif
diff --git a/rules.mak b/rules.mak
index 6c6b909..9259786 100644
--- a/rules.mak
+++ b/rules.mak
@@ -378,15 +378,3 @@ define unnest-vars
         $(eval -include $(patsubst %.o,%.d,$(patsubst %.mo,%.d,$(filter 
%.o,$($v)))))
         $(eval $v := $(filter-out %/,$($v))))
 endef
-
-TEXI2MAN = $(call quiet-command, \
-       perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $(TEXI2PODFLAGS) $< $@.pod 
&& \
-       $(POD2MAN) --section=$(subst .,,$(suffix $@)) --center=" " --release=" 
" $@.pod > $@, \
-       "GEN","$@")
-
-%.1:
-       $(call TEXI2MAN)
-%.7:
-       $(call TEXI2MAN)
-%.8:
-       $(call TEXI2MAN)
-- 
1.8.3.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]