Imported Upstream version 2.14.2
[platform/upstream/fontconfig.git] / doc / meson.build
1 doc_targets = []
2
3 docbook2man = find_program('docbook2man', required: get_option('doc-man'))
4 docbook2txt = find_program('docbook2txt', required: get_option('doc-txt'))
5 docbook2pdf = find_program('docbook2pdf', required: get_option('doc-pdf'))
6 docbook2html = find_program('docbook2html', required: get_option('doc-html'))
7
8 # docbook is very spammy
9 run_quiet = find_program('run-quiet.py')
10
11 # .fncs files
12 doc_funcs_fncs = [
13   'fcatomic',
14   'fcblanks',
15   'fccache',
16   'fccharset',
17   'fcconfig',
18   'fcconstant',
19   'fcdircache',
20   'fcfile',
21   'fcfontset',
22   'fcformat',
23   'fcfreetype',
24   'fcinit',
25   'fclangset',
26   'fcmatrix',
27   'fcobjectset',
28   'fcobjecttype',
29   'fcpattern',
30   'fcrange',
31   'fcstring',
32   'fcstrset',
33   'fcvalue',
34   'fcweight',
35 ]
36
37 fncs_files = []
38 foreach f : doc_funcs_fncs
39   fncs_files += files('@0@.fncs'.format(f))
40 endforeach
41
42 man_pages = []
43
44 extract_man_list = find_program('extract-man-list.py')
45 man_list = run_command(extract_man_list, fncs_files, check: true).stdout().split()
46
47 foreach m : man_list
48   man_pages += ['@0@.3'.format(m)]
49 endforeach
50
51 # Generate sgml pages for funcs
52 edit_sgml = find_program('edit-sgml.py')
53
54 # copy into build directory, it includes generated files from build directory
55 fontconfig_devel_sgml = configure_file(output: 'fontconfig-devel.sgml',
56   input: 'fontconfig-devel.sgml',
57   copy: true)
58
59 fontconfig_user_sgml = configure_file(output: 'fontconfig-user.sgml',
60   input: 'fontconfig-user.sgml',
61   copy: true)
62
63 version_conf = configuration_data()
64 version_conf.set('VERSION', meson.project_version())
65
66 configure_file(output: 'version.sgml',
67   input: 'version.sgml.in',
68   configuration: version_conf)
69
70 confdir_conf = configuration_data()
71 confdir_conf.set('BASECONFIGDIR', fc_configdir)
72
73 confdir_sgml = configure_file(output: 'confdir.sgml',
74   input: 'confdir.sgml.in',
75   configuration: confdir_conf)
76
77 funcs_sgml = []
78
79 foreach f : doc_funcs_fncs
80   funcs_sgml += [custom_target('@0@.sgml'.format(f),
81     input: [files('func.sgml'), files('@0@.fncs'.format(f))],
82     output: '@0@.sgml'.format(f),
83     command: [edit_sgml, '@INPUT0@', '@INPUT1@', '@OUTPUT@'],
84     install: false)]
85 endforeach
86
87 if docbook2man.found()
88   doc_targets += ['man']
89
90   custom_target('devel-man',
91     input: [fontconfig_devel_sgml, funcs_sgml],
92     output: man_pages,
93     command: [run_quiet, docbook2man, '@INPUT0@', '--output', '@OUTDIR@'],
94     build_by_default: true,
95     install_dir: get_option('mandir') / 'man3',
96     install: true)
97
98   # fonts.conf(5)
99   custom_target('fonts-conf-5-man-page',
100     input: [fontconfig_user_sgml],
101     output: 'fonts-conf.5',
102     command: [run_quiet, docbook2man, '@INPUT0@', '--output', '@OUTDIR@'],
103     install_dir: get_option('mandir') / 'man5',
104     build_by_default: true,
105     install: true)
106
107   # Generate man pages for tools
108   foreach t : tools_man_pages
109     # docbook2man doesn't seem to have a --quiet option unfortunately
110     custom_target('@0@-man-page'.format(t),
111       input: '../@0@/@0@.sgml'.format(t),
112       output: '@0@.1'.format(t),
113       command: [run_quiet, docbook2man, '@INPUT@', '--output', '@OUTDIR@'],
114       install_dir: get_option('mandir') / 'man1',
115       install: true)
116   endforeach
117 endif
118
119 if docbook2pdf.found()
120   doc_targets += ['PDF']
121
122   custom_target('devel-pdf',
123     input: [fontconfig_devel_sgml, funcs_sgml],
124     output: 'fontconfig-devel.pdf',
125     command: [run_quiet, docbook2pdf, '@INPUT0@', '--output', '@OUTDIR@'],
126     build_by_default: true,
127     install_dir: get_option('datadir') / 'doc' / 'fontconfig',
128     install: true)
129
130   custom_target('user-pdf',
131     input: [fontconfig_user_sgml, funcs_sgml],
132     output: 'fontconfig-user.pdf',
133     command: [run_quiet, docbook2pdf, '@INPUT0@', '--output', '@OUTDIR@'],
134     build_by_default: true,
135     install_dir: get_option('datadir') / 'doc' / 'fontconfig',
136     install: true)
137 endif
138
139 if docbook2txt.found()
140   doc_targets += ['Text']
141
142   custom_target('devel-txt',
143     input: [fontconfig_devel_sgml, funcs_sgml],
144     output: 'fontconfig-devel.txt',
145     command: [run_quiet, docbook2txt, '@INPUT0@', '--output', '@OUTDIR@'],
146     build_by_default: true,
147     install_dir: get_option('datadir') / 'doc' / 'fontconfig',
148     install: true)
149
150   custom_target('user-txt',
151     input: [fontconfig_user_sgml, funcs_sgml],
152     output: 'fontconfig-user.txt',
153     command: [run_quiet, docbook2txt, '@INPUT0@', '--output', '@OUTDIR@'],
154     build_by_default: true,
155     install_dir: get_option('datadir') / 'doc' / 'fontconfig',
156     install: true)
157 endif
158
159 if docbook2html.found()
160   doc_targets += ['HTML']
161
162   custom_target('devel-html',
163     input: [fontconfig_devel_sgml, funcs_sgml],
164     output: 'fontconfig-devel.html',
165     command: [run_quiet, docbook2html, '--nochunks', '@INPUT0@', '--output', '@OUTDIR@'],
166     build_by_default: true,
167     install_dir: get_option('datadir') / 'doc' / 'fontconfig',
168     install: true)
169
170   custom_target('user-html',
171     input: [fontconfig_user_sgml, funcs_sgml],
172     output: 'fontconfig-user.html',
173     command: [run_quiet, docbook2html, '--nochunks', '@INPUT0@', '--output', '@OUTDIR@'],
174     build_by_default: true,
175     install_dir: get_option('datadir') / 'doc' / 'fontconfig',
176     install: true)
177 endif