c420ec50d229d1bdd00b5915669479043d3c7a26
[platform/upstream/libxml++.git] / docs / reference / meson.build
1 # docs/reference
2
3 # Input: project_build_root, project_source_root, xmlxx_pcname,
4 #        xmlxx_api_version, build_documentation, source_h_files,
5 #        install_datadir, python3, doc_reference_py
6 # Output: install_docdir, install_devhelpdir, book_name
7
8 # There are no built source files in libxml++-2.6.
9
10 tag_file_modules = [
11   'mm-common-libstdc++',
12   'sigc++-2.0',
13   'glibmm-2.4',
14 ]
15 doxygen_tagfiles = ''
16 docinstall_flags = []
17 foreach module : tag_file_modules
18   depmod = dependency(module, required: false)
19   if depmod.found()
20     doxytagfile = depmod.get_pkgconfig_variable('doxytagfile')
21     htmlrefpub = depmod.get_pkgconfig_variable('htmlrefpub', default: '')
22     htmlrefdir = depmod.get_pkgconfig_variable('htmlrefdir', default: '')
23     if htmlrefpub == ''
24       htmlrefpub = htmlrefdir
25     elif htmlrefdir == ''
26       htmlrefdir = htmlrefpub
27     endif
28     doxygen_tagfiles += ' "' + doxytagfile + '=' + htmlrefpub + '"'
29
30     # Doxygen <= 1.8.15
31     docinstall_flags += ['-l', doxytagfile.split('/')[-1] + '@' + htmlrefdir]
32     if htmlrefpub != htmlrefdir
33       # Doxygen >= 1.8.16
34       docinstall_flags += ['-l', 's@' + htmlrefpub + '@' + htmlrefdir]
35     endif
36   endif
37 endforeach
38
39 book_name = xmlxx_pcname
40 book_title = meson.project_name() + ' Reference Manual'
41
42 # Configuration data for Doxyfile.
43 doc_conf_data = configuration_data()
44 doc_conf_data.set('configure_input',
45   'docs/reference/Doxyfile. Generated from Doxyfile.in by meson.configure_file().')
46 doc_conf_data.set('PACKAGE_NAME', meson.project_name())
47 doc_conf_data.set('PACKAGE_VERSION', meson.project_version())
48 doc_conf_data.set('abs_top_builddir', project_build_root)
49 doc_conf_data.set('abs_top_srcdir', project_source_root)
50 doc_conf_data.set('LIBXMLXX_MODULE_NAME', book_name)
51 doc_conf_data.set('DOXYGEN_TAGFILES', doxygen_tagfiles)
52
53 configure_file(
54   input: 'Doxyfile.in',
55   output: '@BASENAME@',
56   configuration: doc_conf_data,
57 )
58
59 # Installation directories relative to {prefix}.
60 install_docdir = install_datadir / 'doc' / book_name
61 install_reference_docdir = install_docdir / 'reference'
62 install_devhelpdir = install_datadir / 'devhelp' / 'books' / book_name
63
64 if not build_documentation
65   # Documentation shall not be built or installed.
66   # Return to the calling meson.build file.
67   subdir_done()
68 endif
69
70 # Input .h files to Doxygen.
71 src_h_files = []
72 foreach file : source_h_files
73   src_h_files += project_source_root / 'libxml++' / file
74 endforeach
75 src_h_files += project_source_root / 'libxml++' / 'libxml++.h'
76
77 doctool_dir = project_source_root / 'untracked' / 'docs' # MMDOCTOOLDIR
78 doctool_dist_dir = 'untracked' / 'docs' # Relative to MESON_DIST_ROOT
79
80 tag_file = custom_target('html_and_tag',
81   input: src_h_files,
82   output: book_name + '.tag',
83   command: [
84     python3, doc_reference_py, 'doxygen',
85     doctool_dir,
86     '@OUTPUT@',
87     '@INPUT@',
88   ],
89   build_by_default: build_documentation,
90   install: true,
91   install_dir: install_reference_docdir,
92 )
93
94 devhelp_file = custom_target('devhelp',
95   input: tag_file,
96   output: book_name + '.devhelp2',
97   command: [
98     python3, doc_reference_py, 'devhelp',
99     doctool_dir,
100     '@INPUT@',
101     '@OUTPUT@',
102     book_name,
103     book_title,
104   ],
105   build_by_default: build_documentation,
106 )
107
108 # Install Devhelp file and html files.
109 meson.add_install_script(
110   python3.path(), doc_reference_py, 'install_doc',
111   doctool_dir,
112   devhelp_file.full_path(),
113   install_devhelpdir,
114   install_reference_docdir / 'html',
115   docinstall_flags
116 )
117
118 if not meson.is_subproject()
119   # Distribute built files and files copied by mm-common-get.
120   # (add_dist_script() is not allowed in a subproject)
121   meson.add_dist_script(
122     python3.path(), doc_reference_py, 'dist_doc',
123     doctool_dir,
124     doctool_dist_dir,
125     meson.current_build_dir(),
126     tag_file.full_path(),
127     devhelp_file.full_path(),
128   )
129 endif