meson: add support for version.ent
[gtk-doc.git] / meson.build
blob70e12fa1feeb14d6e1a56874424a21bc50d2e80a
1 project('gtk-doc', 'c',
2   version: '1.28.1',
3   license: 'GPL2+',
4   meson_version: '>= 0.41.0',
7 gnome = import('gnome')
8 python = import('python3')
10 # Versioning
11 version = meson.project_version()
12 version_arr = version.split('.')
13 version_major = version_arr[0].to_int()
14 version_minor = version_arr[1].to_int()
15 version_micro = version_arr[2].to_int()
17 package_name = meson.project_name()
19 # Paths
20 srcdir = meson.source_root()
21 builddir = meson.build_root()
23 prefix = get_option('prefix')
25 bindir = join_paths(prefix, get_option('bindir'))
26 libdir = join_paths(prefix, get_option('libdir'))
27 datadir = join_paths(prefix, get_option('datadir'))
29 cmakedatadir = join_paths(libdir, 'cmake')
31 autoconfdatadir = join_paths(datadir, 'aclocal')
32 pkgdir = join_paths(datadir, package_name)
33 pkgdatadir = join_paths(pkgdir, 'data')
34 pkgpythondir = join_paths(pkgdir, 'python')
35 pkgconfigdir = join_paths(datadir, 'pkgconfig')
37 # Dependencies
38 glib_req = '>= 2.38.0'
39 python3_req = '>= 3.4.0'
41 glib_dep = dependency('glib-2.0', version: glib_req)
42 gobject_dep = dependency('gobject-2.0', version: glib_req)
43 python3_dep = dependency('python3', version: python3_req)
45 python_prg = python.find_python()
47 pkgconfig_prg = find_program('pkg-config', required: true)
48 xsltproc_prg = find_program('xsltproc', required: true)
49 dblatex_prg = find_program('dblatex', required: false)
50 fop_prg = find_program('fop', required: false)
52 source_highlight_prg = find_program('source-highlight', required: false)
53 highlight_prg = find_program('highlight', required: false)
54 vim_prg = find_program('vim', required: false)
56 python_prg_path = join_paths(python_prg.path())
57 pkgconfig_prg_path = join_paths(pkgconfig_prg.path())
58 xsltproc_prg_path = join_paths(xsltproc_prg.path())
60 dblatex_prg_path = ''
61 if dblatex_prg.found()
62   dblatex_prg_path = join_paths(dblatex_prg.path())
63 endif
65 fop_prg_path = ''
66 if fop_prg.found()
67   fop_prg_path = join_paths(fop_prg.path())
68 endif
70 highlight_prg_path = ''
71 highlight_prg_args = ''
72 if source_highlight_prg.found()
73   highlight_prg_path = join_paths(source_highlight_prg.path())
74   highlight_prg_args = [
75     '-t4',
76     '-s$SRC_LANG',
77     '-cstyle.css',
78     '--no-doc',
79     '-i',
80   ]
81 elif highlight_prg.found()
82   highlight_prg_path = join_paths(highlight_prg.path())
83   highlight_prg_args = [
84     '--syntax=$SRC_LANG',
85     '--out-format=xhtml',
86     '-f',
87     '--class-name=gtkdoc',
88   ]
89 elif vim_prg.found()
90   highlight_prg_path = join_paths(vim_prg.path())
91 endif
93 # Options
94 generate_pdf_output = true
95 if not dblatex_prg.found() and not fop_prg.found()
96   generate_pdf_output = false
97 endif
99 # Code
100 subdir('gtkdoc')
102 gtkdoc_binaires = [
103   'gtkdoc-check',
104   'gtkdoc-depscan',
105   'gtkdoc-fixxref',
106   'gtkdoc-mkdb',
107   'gtkdoc-mkhtml',
108   'gtkdoc-mkhtml2',
109   'gtkdoc-mkman',
110   'gtkdoc-mkpdf',
111   'gtkdoc-rebase',
112   'gtkdoc-scan',
113   'gtkdoc-scangobj',
116 binary_in = configuration_data()
117 binary_in.set('PYTHON', python_prg_path)
118 binary_in.set('PKG_CONFIG', pkgconfig_prg_path)
120 binary_in.set('PYTHON_PACKAGE_DIR', pkgpythondir)
122 binary_in.set('prefix', get_option('prefix'))
123 binary_in.set('datarootdir', join_paths('${prefix}', get_option('datadir')))
124 binary_in.set('datadir', '${datarootdir}')
126 binary_in.set('PACKAGE', package_name)
128 binary_in.set('VERSION', version)
130 foreach binary: gtkdoc_binaires
131   configure_file(
132     input: '@0@.in'.format(binary),
133     output: binary,
134     configuration: binary_in,
135     install: true,
136     install_dir: bindir,
137   )
138 endforeach
140 # Data
141 gtkdoc_data = [
142   'devhelp2.xsd',
143   'devhelp2.xsl',
144   'gtk-doc.xsl',
145   'version-greater-or-equal.xsl',
148 install_data(
149   gtkdoc_data,
150   install_dir: pkgdatadir,
153 subdir('style')
155 if get_option('autotools_support') == true
156   subdir('buildsystems/autotools')
157 endif
159 if get_option('cmake_support') == true
160   subdir('buildsystems/cmake')
161 endif
163 gtkdoc_pc = configuration_data()
164 gtkdoc_pc.set('prefix', prefix)
165 gtkdoc_pc.set('exec_prefix', '${prefix}')
166 gtkdoc_pc.set('datadir', join_paths('${prefix}', get_option('datadir')))
168 gtkdoc_pc.set('PACKAGE', package_name)
169 gtkdoc_pc.set('VERSION', version)
171 configure_file(
172   input: 'gtk-doc.pc.in',
173   output: 'gtk-doc.pc',
174   configuration: gtkdoc_pc,
175   install: true,
176   install_dir: pkgconfigdir,
179 subdir('help')
180 subdir('tests')
182 summary = [
183   '',
184   '------',
185   'gtk-doc @0@'.format(version),
186   '',
187   'Directories:',
188   '             prefix: @0@'.format(prefix),
189   '             bindir: @0@'.format(bindir),
190   '             libdir: @0@'.format(libdir),
191   '            datadir: @0@'.format(datadir),
192   '',
193   'Configuration:',
194   '  Autotools support: @0@'.format(get_option('autotools_support')),
195   '      CMake support: @0@'.format(get_option('cmake_support')),
196   '         PDF output: @0@'.format(generate_pdf_output),
197   '        User manual: @0@'.format(get_option('yelp_manual')),
198   '------',
201 message('\n'.join(summary))