]> git.tdb.fi Git - ext/sigc++-2.0.git/blob - docs/manual/meson.build
Adjust the name of the library to match upstream
[ext/sigc++-2.0.git] / docs / manual / meson.build
1 # docs/manual
2
3 # input: install_datadir, sigcxx_pcname, tutorial_custom_cmd, python3,
4 #        build_documentation, install_docdir, can_add_dist_script, xsltproc
5 # output: can_parse_and_validate, build_pdf_by_default, can_build_pdf,
6 #         install_tutorialdir
7
8 xmllint = find_program('xmllint', required: false)
9 can_parse_and_validate = xmllint.found()
10
11 validate = get_option('validation') ? 'true' : 'false'
12
13 dblatex = find_program('dblatex', required: false)
14 can_build_pdf = dblatex.found() or (xsltproc.found() and \
15                 find_program('fop', required: false).found())
16 build_pdf_by_default = get_option('build-pdf')
17
18 # Installation directories are relative to {prefix}.
19 install_tutorialdir = install_docdir / 'tutorial'
20
21 if not build_documentation
22   # Documentation shall not be built or installed.
23   # Return to the calling meson.build file.
24   subdir_done()
25 endif
26
27 # Check if xmllint can be used.
28 if xmllint.found()
29   can_parse_and_validate = run_command(
30     python3, tutorial_custom_cmd, 'xmllint',
31     validate,
32     meson.current_source_dir() / 'can_use_xmllint.xml',
33     meson.current_build_dir() / 'can_use_xmllint.stamp',
34     check: false,
35   ).returncode() == 0
36   if not can_parse_and_validate
37     # The DocBook V5.0 package is called docbook5-xml in Ubuntu,
38     # docbook5-schemas in Fedora. It may have other names in other distros.
39     warning('Can\'t validate XML file.\n' +
40       'xmllint does not support Relax NG schemas and DocBook V5.0.\n' +
41       'DocBook V5.0 support may require docbook5-xml, docbook5-schemas or a similar package.'
42     )
43   endif
44 endif
45
46 install_data('..' / 'index.html', install_dir: install_docdir)
47 install_data('..' / 'images' / 'libsigc_logo.gif',
48              '..' / 'images' / 'top.gif',
49              install_dir: install_docdir / 'images')
50
51 doc_dist_dir = 'untracked' / 'docs' / 'manual' # Relative to MESON_DIST_ROOT
52
53 sigc_manual_xml = 'libsigc_manual.xml'
54 sigc_manual_pdf = 'libsigc_manual.pdf'
55
56 # Create an html version of the DocBook.
57 custom_target('manual_html',
58   input: sigc_manual_xml,
59   output: 'html',
60   command: [
61     python3, tutorial_custom_cmd, 'html',
62     '@INPUT@',
63     '@OUTPUT@',
64   ],
65   build_by_default: true,
66   install: true,
67   install_dir: install_tutorialdir
68 )
69
70 if can_parse_and_validate
71   # Parse and possibly validate the DocBook.
72   custom_target('manual_xmllint',
73     input: sigc_manual_xml,
74     output: 'manual_xmllint.stamp',
75     command: [
76       python3, tutorial_custom_cmd, 'xmllint',
77       validate,
78       '@INPUT@',
79       '@OUTPUT@'
80     ],
81     build_by_default: true,
82   )
83 endif
84
85 if can_build_pdf
86   # Create a PDF file of the DocBook.
87   # Prefer dblatex, if both dblatex and fop are available.
88   custom_target('manual_pdf',
89     input: sigc_manual_xml,
90     output: sigc_manual_pdf,
91     command: [
92       python3, tutorial_custom_cmd,
93       dblatex.found() ? 'dblatex' : 'fop',
94       '@INPUT@',
95       '@OUTPUT@'
96     ],
97     build_by_default: build_pdf_by_default,
98   )
99 endif
100
101 if can_add_dist_script
102   # Distribute built files.
103   meson.add_dist_script(
104     python3, tutorial_custom_cmd, 'dist_doc',
105     doc_dist_dir,
106     meson.current_build_dir(),
107     meson.current_source_dir() / sigc_manual_xml,
108     meson.current_build_dir() / sigc_manual_pdf,
109   )
110 endif