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