Imported Upstream version 1.0.2
[platform/upstream/fribidi.git] / doc / meson.build
1 c2man = find_program('c2man', required: false)
2
3 if not c2man.found()
4   error('c2man is required to build documentation. Or disable with -Ddocs=false')
5 endif
6
7 # Extract list of man pages (one man page per symbol) from lib/libfribidi.def
8 python3 = import('python3').find_python()
9
10 result = run_command(python3,
11   '-c', 'import sys; print(open(sys.argv[1], "r").read())',
12   files('../lib/fribidi.def'))
13
14 if result.returncode() != 0
15   error('Could not extract list of symbols from fribidi.def.')
16 endif
17
18 gen_man_pages = []
19
20 syms = result.stdout().strip().split('\n')
21 foreach sym : syms
22   # for consistency with autotools build and because we don't pass -v to c2man
23   if sym != 'fribidi_unicode_version' and sym != 'fribidi_version_info'
24     gen_man_pages += ['@0@.3'.format(sym)]
25   endif
26 endforeach
27
28 c2man_incs = []
29 c2man_incs += ['-I' + join_paths(meson.source_root(), 'lib')]
30 c2man_incs += ['-I' + join_paths(meson.build_root(), 'lib')]
31 c2man_incs += ['-I' + join_paths(meson.source_root(), 'gen.tab')]
32 c2man_incs += ['-I' + join_paths(meson.build_root(), 'gen.tab')]
33
34 custom_target('man pages',
35   command: [c2man, '-T', 'n', '-M', 'Programmer\'s Manual', c2man_incs,
36             '-D__FRIBIDI_DOC', '-DDONT_HAVE_FRIBIDI_CONFIG_H',
37             '-o@0@'.format(meson.current_build_dir()),
38            fribidi_headers],
39   depends: [fribidi_unicode_version_h],
40   output: gen_man_pages,
41   install_dir: join_paths(get_option('prefix'), get_option('mandir'), 'man3'),
42   install: true)