1# SPDX-License-Identifier: LGPL-2.1 2# 3# Copyright (c) 2023 Daniel Wagner, SUSE LLC 4 5# input text file: man page section 6 7sources = { 8 'libtracefs-sqlhist.txt.1': '1', 9 'libtracefs-cpu-open.txt': '3', 10 'libtracefs-cpu.txt': '3', 11 'libtracefs-dynevents.txt': '3', 12 'libtracefs-eprobes.txt': '3', 13 'libtracefs-error.txt': '3', 14 'libtracefs-events-file.txt': '3', 15 'libtracefs-events-tep.txt': '3', 16 'libtracefs-events.txt': '3', 17 'libtracefs-files.txt': '3', 18 'libtracefs-filter.txt': '3', 19 'libtracefs-function-filter.txt': '3', 20 'libtracefs-hist-cont.txt': '3', 21 'libtracefs-hist-mod.txt': '3', 22 'libtracefs-hist.txt': '3', 23 'libtracefs-instances-affinity.txt': '3', 24 'libtracefs-instances-file-manip.txt': '3', 25 'libtracefs-instances-files.txt': '3', 26 'libtracefs-instances-manage.txt': '3', 27 'libtracefs-instances-utils.txt': '3', 28 'libtracefs-iterator.txt': '3', 29 'libtracefs-kprobes.txt': '3', 30 'libtracefs-log.txt': '3', 31 'libtracefs-marker_raw.txt': '3', 32 'libtracefs-marker.txt': '3', 33 'libtracefs-option-get.txt': '3', 34 'libtracefs-option-misc.txt': '3', 35 'libtracefs-options.txt': '3', 36 'libtracefs-sql.txt': '3', 37 'libtracefs-stream.txt': '3', 38 'libtracefs-synth2.txt': '3', 39 'libtracefs-synth-info.txt': '3', 40 'libtracefs-synth.txt': '3', 41 'libtracefs-traceon.txt': '3', 42 'libtracefs-tracer.txt': '3', 43 'libtracefs.txt': '3', 44 'libtracefs-uprobes.txt': '3', 45 'libtracefs-utils.txt': '3', 46} 47 48conf_dir = meson.current_source_dir() + '/' 49top_source_dir = meson.current_source_dir() + '/../' 50 51## 52# For asciidoc ... 53# -7.1.2, no extra settings are needed. 54# 8.0-, set ASCIIDOC8. 55# 56 57# 58# For docbook-xsl ... 59# -1.68.1, set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0) 60# 1.69.0, no extra settings are needed? 61# 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP? 62# 1.71.1, no extra settings are needed? 63# 1.72.0, set DOCBOOK_XSL_172. 64# 1.73.0-, set ASCIIDOC_NO_ROFF 65# 66 67# 68# If you had been using DOCBOOK_XSL_172 in an attempt to get rid 69# of 'the ".ft C" problem' in your generated manpages, and you 70# instead ended up with weird characters around callouts, try 71# using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8). 72# 73 74if get_option('asciidoctor') 75 asciidoc = find_program('asciidoctor') 76 asciidoc_extra = ['-a', 'compat-mode'] 77 asciidoc_extra += ['-I.'] 78 asciidoc_extra += ['-r', 'asciidoctor-extensions'] 79 asciidoc_extra += ['-a', 'mansource=libtraceevent'] 80 asciidoc_extra += ['-a', 'manmanual="libtraceevent Manual"'] 81 asciidoc_html = 'xhtml5' 82else 83 asciidoc = find_program('asciidoc') 84 asciidoc_extra = ['--unsafe'] 85 asciidoc_extra += ['-f', conf_dir + 'asciidoc.conf'] 86 asciidoc_html = 'xhtml11' 87 88 r = run_command(asciidoc, '--version', check: true) 89 v = r.stdout().strip() 90 if v.version_compare('>=8.0') 91 asciidoc_extra += ['-a', 'asciidoc7compatible'] 92 endif 93endif 94 95manpage_xsl = conf_dir + 'manpage-normal.xsl' 96 97if get_option('docbook-xls-172') 98 asciidoc_extra += ['-a', 'libtraceevent-asciidoc-no-roff'] 99 manpage_xsl = conf_dir + 'manpage-1.72.xsl' 100elif get_option('asciidoc-no-roff') 101 # docbook-xsl after 1.72 needs the regular XSL, but will not 102 # pass-thru raw roff codes from asciidoc.conf, so turn them off. 103 asciidoc_extra += ['-a', 'libtraceevent-asciidoc-no-roff'] 104endif 105 106xmlto = find_program('xmlto') 107xmlto_extra = [] 108 109if get_option('man-bold-literal') 110 xmlto_extra += ['-m ', conf_dir + 'manpage-bold-literal.xsl'] 111endif 112 113if get_option('docbook-suppress-sp') 114 xmlto_extra += ['-m ', conf_dir + 'manpage-suppress-sp.xsl'] 115endif 116 117check_doc = custom_target( 118 'check-doc', 119 output: 'dummy', 120 command : [ 121 top_source_dir + 'check-manpages.sh', 122 meson.current_source_dir()]) 123 124gen = generator( 125 asciidoc, 126 output: '@BASENAME@.xml', 127 arguments: [ 128 '-b', 'docbook', 129 '-d', 'manpage', 130 '-a', 'libtraceevent_version=' + meson.project_version(), 131 '-o', '@OUTPUT@'] 132 + asciidoc_extra 133 + ['@INPUT@']) 134 135man = [] 136html = [] 137foreach txt, section : sources 138 # build man page(s) 139 xml = gen.process(txt) 140 man += custom_target( 141 txt.underscorify() + '_man', 142 input: xml, 143 output: '@BASENAME@.' + section, 144 depends: check_doc, 145 command: [ 146 xmlto, 147 '-m', manpage_xsl, 148 'man', 149 '-o', '@OUTPUT@'] 150 + xmlto_extra 151 + ['@INPUT@']) 152 153 # build html pages 154 html += custom_target( 155 txt.underscorify() + '_html', 156 input: txt, 157 output: '@BASENAME@.html', 158 depends: check_doc, 159 command: [ 160 asciidoc, 161 '-b', asciidoc_html, 162 '-d', 'manpage', 163 '-a', 'libtraceevent_version=' + meson.project_version(), 164 '-o', '@OUTPUT@'] 165 + asciidoc_extra 166 + ['@INPUT@']) 167endforeach 168 169# Install path workaround because: 170# 171# - xmlto might generate more than one file and we would to tell meson 172# about those output files. We could figure out which files are generated 173# (see sed match in check-manpages.sh). 174# 175# - The man page generation puts all the generated files under sub dirs 176# and it's not obvious how to tell Meson it should not do this without 177# causing the install step to fail (confusion where the generated files 178# are stored) 179# 180# - The documentation build is not part of the 'build' target. The user 181# has explicitly to trigger the doc build. Hence the documentation is 182# not added to the 'install' target. 183# 184# Thus just use a plain old shell script to move the generated files to the 185# right location. 186 187conf = configuration_data() 188conf.set('SRCDIR', meson.current_build_dir()) 189conf.set('MANDIR', mandir) 190conf.set('HTMLDIR', htmldir) 191configure_file( 192 input: 'install-docs.sh.in', 193 output: 'install-docs.sh', 194 configuration: conf) 195 196meson.add_install_script( 197 join_paths(meson.current_build_dir(), 'install-docs.sh')) 198