summaryrefslogtreecommitdiff
path: root/meson.build
blob: 0345989d3e45dd3517ac6014065b33d07eee679e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
project('gtk-doc', 'c',
  version: '1.32.1',
  license: 'GPL2+',
  meson_version: '>= 0.50.0', # needed for https://mesonbuild.com/Python-module.html#path
)

gnome = import('gnome')
python = import('python') # Meson new Python module https://mesonbuild.com/Python-module.html

python3 = python.find_installation('python3')

version = meson.project_version()
package_name = meson.project_name()

# Paths
srcdir = meson.current_source_dir()
builddir = meson.current_build_dir()

prefix = get_option('prefix')

bindir = join_paths(prefix, get_option('bindir'))
libdir = join_paths(prefix, get_option('libdir'))
datadir = join_paths(prefix, get_option('datadir'))

cmakedatadir = join_paths(datadir, 'cmake')

autoconfdatadir = join_paths(datadir, 'aclocal')
pkgdir = join_paths(datadir, package_name)
pkgdatadir = join_paths(pkgdir, 'data')
pkgpythondir = join_paths(pkgdir, 'python')
pkgconfigdir = join_paths(datadir, 'pkgconfig')

# Dependencies
glib_req = '>= 2.38.0'

python_prg = python3

# Python 3 required modules
python3_required_modules = ['pygments']

foreach p : python3_required_modules
  # Source: https://docs.python.org/3/library/importlib.html#checking-if-a-module-can-be-imported
  script = 'import importlib.util; import sys; exit(1) if importlib.util.find_spec(\''+ p +'\') is None else exit(0)'
  if run_command(python3, '-c', script).returncode() != 0
    error('Required Python3 module \'' + p + '\' not found')
  endif
endforeach

pkgconfig_prg = find_program('pkg-config', required: true)
xsltproc_prg = find_program('xsltproc', required: true)
dblatex_prg = find_program('dblatex', required: false)
fop_prg = find_program('fop', required: false)

python_prg_path = join_paths(python_prg.path())
pkgconfig_prg_path = join_paths(pkgconfig_prg.path())
xsltproc_prg_path = join_paths(xsltproc_prg.path())

dblatex_prg_path = ''
if dblatex_prg.found()
  dblatex_prg_path = join_paths(dblatex_prg.path())
endif

fop_prg_path = ''
if fop_prg.found()
  fop_prg_path = join_paths(fop_prg.path())
endif

# Options
generate_pdf_output = true
if not dblatex_prg.found() and not fop_prg.found()
  generate_pdf_output = false
endif

# Code
subdir('gtkdoc')

gtkdoc_binaires = [
  'gtkdoc-check',
  'gtkdoc-depscan',
  'gtkdoc-fixxref',
  'gtkdoc-mkdb',
  'gtkdoc-mkhtml',
  'gtkdoc-mkhtml2',
  'gtkdoc-mkman',
  'gtkdoc-mkpdf',
  'gtkdoc-rebase',
  'gtkdoc-scan',
  'gtkdoc-scangobj',
]

binary_in = configuration_data()
binary_in.set('PYTHON', python_prg_path)
binary_in.set('PKG_CONFIG', pkgconfig_prg_path)

binary_in.set('PYTHON_PACKAGE_DIR', pkgpythondir)

binary_in.set('prefix', get_option('prefix'))
binary_in.set('datarootdir', join_paths('${prefix}', get_option('datadir')))
binary_in.set('datadir', '${datarootdir}')

binary_in.set('PACKAGE', package_name)
binary_in.set('PACKAGE_BUGREPORT', 'https://gitlab.gnome.org/GNOME/gtk-doc/issues')
binary_in.set('PACKAGE_NAME', package_name)
binary_in.set('PACKAGE_STRING', package_name)
binary_in.set('PACKAGE_TARNAME', package_name)
binary_in.set('PACKAGE_URL', 'https://gitlab.gnome.org/GNOME/gtk-doc')
binary_in.set('PACKAGE_VERSION', version)
binary_in.set('VERSION', version)

foreach binary: gtkdoc_binaires
  prog = configure_file(
    input: '@0@.in'.format(binary),
    output: binary,
    configuration: binary_in,
    install: true,
    install_dir: bindir,
  )
  meson.override_find_program(binary, prog)
endforeach

configure_file(
  input: 'gtkdoc_uninstalled.py.in',
  output: 'gtkdoc_uninstalled.py',
  configuration: {
    'sourcedir': meson.current_source_dir(),
    'builddir': meson.current_build_dir(),
  },
)

# Data
gtkdoc_data = [
  'devhelp2.xsd',
  'devhelp2.xsl',
  'gtk-doc.xsl',
  'version-greater-or-equal.xsl',
]

install_data(
  gtkdoc_data,
  install_dir: pkgdatadir,
)

subdir('style')

if get_option('autotools_support') == true
  subdir('buildsystems/autotools')
endif

if get_option('cmake_support') == true
  subdir('buildsystems/cmake')
endif

gtkdoc_pc = configuration_data()
gtkdoc_pc.set('prefix', prefix)
gtkdoc_pc.set('exec_prefix', '${prefix}')
gtkdoc_pc.set('datadir', join_paths('${prefix}', get_option('datadir')))

gtkdoc_pc.set('PACKAGE', package_name)
gtkdoc_pc.set('VERSION', version)

configure_file(
  input: 'gtk-doc.pc.in',
  output: 'gtk-doc.pc',
  configuration: gtkdoc_pc,
  install: true,
  install_dir: pkgconfigdir,
)

subdir('help')
if get_option('tests')
  subdir('tests')
endif

# A dummy dependency object that to use gtkdoc as subproject fallback
# To be used as: dependency('gtk-doc', fallback : ['gtk-doc', 'dummy_dep'])
dummy_dep = declare_dependency()

summary = [
  '',
  '------',
  'gtk-doc @0@'.format(version),
  '',
  'Directories:',
  '             prefix: @0@'.format(prefix),
  '             bindir: @0@'.format(bindir),
  '             libdir: @0@'.format(libdir),
  '            datadir: @0@'.format(datadir),
  '',
  'Configuration:',
  '  Autotools support: @0@'.format(get_option('autotools_support')),
  '      CMake support: @0@'.format(get_option('cmake_support')),
  '         PDF output: @0@'.format(generate_pdf_output),
  '        User manual: @0@'.format(get_option('yelp_manual')),
  '         Test suite: @0@'.format(get_option('tests')),
  '------',
]

message('\n'.join(summary))