1project(
2  'gtranslator', 'c',
3  version: '40.0',
4  license: 'GPL3+',
5  meson_version: '>= 0.50.0',
6)
7
8###########
9# Version #
10###########
11
12gtr_version = meson.project_version()
13version_array = gtr_version.split('.')
14gtr_major_version = version_array[0].to_int()
15gtr_minor_version = version_array[1].to_int()
16
17#################
18# Default paths #
19#################
20
21gtr_prefix = get_option('prefix')
22gtr_datadir = join_paths(gtr_prefix, get_option('datadir'))
23gtr_includedir = join_paths(gtr_prefix, get_option('includedir'))
24gtr_libdir = join_paths(gtr_prefix, get_option('libdir'))
25gtr_localedir = join_paths(gtr_prefix, get_option('localedir'))
26
27gtr_pkgdatadir = join_paths(gtr_datadir, meson.project_name())
28
29###########
30# Options #
31###########
32
33gtr_namespace = 'org.gnome.Gtranslator'
34
35gtr_buildtype = get_option('buildtype')
36gtr_debug = gtr_buildtype.contains('debug')
37
38if gtr_debug
39  profile = 'Devel'
40  name_suffix = ' (Development)'
41  vcs_tag = run_command(find_program('git'), 'rev-parse', '--short', 'HEAD').stdout().strip()
42  version_suffix = '-' + (vcs_tag == '' ? 'devel' : vcs_tag)
43else
44  profile = ''
45  name_suffix = ''
46  version_suffix = ''
47endif
48
49gtr_app_id = gtr_namespace + profile
50
51cc = meson.get_compiler('c')
52
53config_h = configuration_data()
54
55set_defines = [
56  # package
57  ['PACKAGE', meson.project_name()],
58  ['PACKAGE_DATADIR', gtr_datadir],
59  ['PACKAGE_LIBDIR', gtr_libdir],
60  ['PACKAGE_LOCALEDIR', gtr_localedir],
61  ['PACKAGE_URL', 'https://wiki.gnome.org/Apps/Gtranslator'],
62  ['PACKAGE_VERSION', gtr_version],
63  ['PACKAGE_APPID', gtr_app_id],
64  # i18
65  ['GETTEXT_PACKAGE', meson.project_name()],
66]
67
68foreach define: set_defines
69  config_h.set_quoted(define[0], define[1])
70endforeach
71
72assert(cc.has_function('strerror'), '"strerror" not found')
73
74# Compiler flags
75common_flags = ['-DHAVE_CONFIG_H']
76
77if gtr_debug
78  common_flags += ['-DG_DISABLE_CAST_CHECKS']
79elif gtr_buildtype == 'release'
80  common_flags += [
81    '-DG_DISABLE_ASSERT',
82    #'-DG_DISABLE_CHECKS',
83    '-DG_DISABLE_CAST_CHECKS',
84  ]
85endif
86
87add_project_arguments(common_flags, language: 'c')
88
89gnome = import('gnome')
90i18n = import('i18n')
91pkg = import('pkgconfig')
92
93top_inc = include_directories('.')
94
95data_dir = join_paths(meson.source_root(), 'data')
96po_dir = join_paths(meson.source_root(), 'po')
97src_dir = join_paths(meson.source_root(), 'src')
98
99################
100# Dependencies #
101################
102
103glib_dep = dependency('glib-2.0', version: '>= 2.36.0')
104gtk_dep = dependency('gtk+-3.0', version: '>= 3.22.20')
105libhandy_dep = dependency('libhandy-1', version: '>= 1.0.0')
106
107gtr_deps = [
108  glib_dep,
109  gtk_dep,
110  libhandy_dep,
111  dependency('libdazzle-1.0', version: '>= 3.33.90'),
112  dependency('libgda-5.0'),
113  dependency('gio-2.0', version: '>= 2.36.0'),
114  dependency('gsettings-desktop-schemas'),
115  dependency('gspell-1', version: '>= 1.2.0'),
116  dependency('gthread-2.0', version: '>= 2.13.0'),
117  dependency('gtksourceview-4', version: '>= 4.0.2'),
118  dependency('libxml-2.0', version: '>= 2.4.12'),
119  dependency('libsoup-2.4'),
120  dependency('json-glib-1.0', version: '>= 1.2.0'),
121  cc.find_library('gettextpo'),
122]
123
124gtr_schemasdir = dependency('gio-2.0').get_pkgconfig_variable('schemasdir', define_variable: ['datadir', gtr_datadir])
125if gtr_schemasdir == ''
126  gtr_schemasdir = join_paths(gtr_datadir, 'glib-2.0', 'schemas')
127  message(gtr_schemasdir)
128endif
129
130itstool = find_program  ('itstool')
131
132###########
133# Subdirs #
134###########
135
136subdir('data')
137subdir('src')
138subdir('po')
139subdir('help')
140subdir('man')
141
142
143enable_gtk_doc = get_option('gtk_doc')
144if enable_gtk_doc
145  gtk_doc_dep = dependency('gtk-doc', version: '>= 1.28')
146  gtr_deps += gtk_doc_dep
147  subdir('doc/reference')
148endif
149
150configure_file(
151  output: 'config.h',
152  configuration: config_h,
153)
154
155meson.add_install_script(
156  'build-aux/meson/meson_post_install.py',
157  gtr_datadir,
158  gtr_schemasdir,
159)
160
161output = '\n\n      GTranslator ' + gtr_version + '\n'
162output += '      =========================\n\n'
163output += '          Source ..........................: ' + meson.current_source_dir() + '\n'
164output += '          Prefix ..........................: ' + gtr_prefix + '\n'
165output += '          Compiler ........................: ' + cc.get_id() + '\n\n'
166output += '      Development options\n'
167output += '          Enable Debug: ...................: ' + gtr_debug.to_string() + '\n'
168output += '          Enable Documentation: ...........: ' + enable_gtk_doc.to_string() + '\n\n'
169output += '    Now type "ninja -C ' + meson.current_build_dir() + '" to build ' + meson.project_name() + '\n\n'
170message(output)
171