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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
|
# Copyright © 2019, 2020, 2021 Christian Persch
#
# This programme is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This programme is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this programme. If not, see <https://www.gnu.org/licenses/>.
project(
'gnome-terminal',
['c', 'cpp',],
default_options: [
'buildtype=release',
'warning_level=' + (meson.version().version_compare('>= 0.50.0') ? '0' : '1'),
'b_ndebug=false',
],
license: [
'GPL-3.0-or-later', # the programme
'GPL-3.0-only', 'CC-BY-SA-3.0', # the documentation
'GFDL-1.3-only', # the appstream data
],
meson_version: '>= 0.61.0',
version: '3.46.8',
)
# Naming
gt_name = 'gnome-terminal'
gt_dns_name = 'org.gnome.Terminal'
# Compiler requirements
c_req_std = 'gnu11'
cxx_req_std = 'gnu++14'
gxx_req_version = '4.8.1'
clangxx_req_version = '3.3'
# Requirements
vte_req = 'vte-2.91'
vte_req_version = '0.70.0'
glib_req_version = '2.52.0'
glib_min_req_version = '2.52'
glib_max_allowed_version = '2.52'
gtk_req_version = '3.22.27'
gtk_min_req_version = '3.18'
gtk_max_allowed_version = '3.24'
libnautilus_ext_req_version = '43'
pcre2_req_version = '10.00'
schemas_req_version = '0.1.0'
# Versioning
gt_version = meson.project_version()
version_split = meson.project_version().split('.')
gt_major_version = version_split[0].to_int()
gt_minor_version = version_split[1].to_int()
gt_micro_version = version_split[2].to_int()
# Directories
gt_bindir = get_option('bindir')
gt_datadir = get_option('datadir')
gt_includedir = get_option('includedir')
gt_libdir = get_option('libdir')
gt_libexecdir = get_option('libexecdir')
gt_localedir = get_option('localedir')
gt_mandir = get_option('mandir')
gt_prefix = get_option('prefix')
gt_pkgdatadir = gt_datadir / gt_name
gt_pkglibdir = gt_libdir / gt_name
gt_schemadir = gt_datadir / 'glib-2.0' / 'schemas'
gt_searchproviderdir = gt_datadir / 'gnome-shell' / 'search-providers'
gt_nautilusextensiondir = gt_libdir / 'nautilus' / 'extensions-4'
gt_dbusinterfacedir = gt_datadir / 'dbus-1' / 'interfaces'
gt_dbusservicedir = gt_datadir / 'dbus-1' / 'services'
# It is correct for this to be in ${prefix}/lib, even on systems where that
# does not match ${libdir}. This is what systemd uses on such platforms.
gt_systemduserdir = 'lib' / 'systemd' / 'user'
# Debug
enable_debug = get_option('dbg') or get_option('debug') or get_option('buildtype').contains('debug')
# Meson modules
gnome = import('gnome')
i18n = import('i18n')
pkg = import('pkgconfig')
# i18n
gt_gettext_domain = gt_name
po_dir = meson.current_source_dir() / 'po'
# Compilers
# C compiler
cc = meson.get_compiler('c')
c_std_opt = '-std=' + c_req_std
assert(cc.has_argument(c_std_opt), 'option ' + c_std_opt + ' not supported by ' + cc.get_id())
add_project_arguments(c_std_opt, language: 'c')
# C++ compiler
cxx = meson.get_compiler('cpp')
cxx_std_opt = '-std=' + cxx_req_std
assert(cxx.has_argument(cxx_std_opt), 'option ' + cxx_std_opt + ' not supported by ' + cxx.get_id())
add_project_arguments(cxx_std_opt, language: 'cpp')
# The above only checks that the compiler supports the given -std option,
# but not that the compiler really supports that C++ standard version.
# Do a simple version check based on
# https://gcc.gnu.org/projects/cxx-status.html and
# https://clang.llvm.org/cxx_status.html
# for the C++ features that vte actually uses.
if cxx.get_id() == 'gcc'
assert(cxx.version().version_compare('>=' + gxx_req_version), 'needs g++ >= ' + gxx_req_version + ' for ' + cxx_req_std + ' support')
endif
if cxx.get_id() == 'clang'
assert(cxx.version().version_compare('>=' + clangxx_req_version), 'needs clang++ >= ' + clangxx_req_version + ' for ' + cxx_req_std + ' support')
endif
# Include directories
top_inc = include_directories('.')
# Asserts must not be disabled
assert(get_option('b_ndebug') == 'false', 'assertions may not be disabled')
# Start config.h
config_h = configuration_data()
config_h.set_quoted('GETTEXT_PACKAGE', gt_gettext_domain)
config_h.set_quoted('VERSION', gt_version)
config_h.set('ENABLE_DEBUG', enable_debug)
config_h.set('ENABLE_SEARCH_PROVIDER', get_option('search_provider'))
# Enable libc features
libc_feature_defines = [
['_GNU_SOURCE', '1'],
['_POSIX_C_SOURCE', '200809L'],
['_XOPEN_SOURCE', '700'],
['_XOPEN_SOURCE_EXTENDED', '1'],
]
system = host_machine.system()
if system == 'freebsd'
# Defining _POSIX_C_SOURCE above makes freebsd not expose some functionality
# that's hidden behind __BSD_VISIBLE. Not defininy any of the above however
# makes it expose verything.
libc_feature_defines = []
elif system == 'darwin'
# See issue #2592
libc_feature_defines += [
['_DARWIN_C_SOURCE', '1'],
]
elif system == 'netbsd'
libc_feature_defines += [
['_NETBSD_SOURCE', '1'],
]
elif system == 'openbsd'
libc_feature_defines += [
['_BSD_SOURCE', '1'],
]
endif
foreach f: libc_feature_defines
config_h.set(f[0], f[1])
endforeach
# Min/max version requirement flags
minver = glib_min_req_version.split('.')
maxver = glib_max_allowed_version.split('.')
glib_version_cxxflags = [
'-DGLIB_VERSION_MIN_REQUIRED=(G_ENCODE_VERSION(' + minver[0] + ',' + minver[1] + '))',
'-DGLIB_VERSION_MAX_ALLOWED=(G_ENCODE_VERSION(' + maxver[0] + ',' + maxver[1] + '))',
]
minver = gtk_min_req_version.split('.')
maxver = gtk_max_allowed_version.split('.')
gtk_version_cxxflags = [
'-DGDK_VERSION_MIN_REQUIRED=(G_ENCODE_VERSION(' + minver[0] + ',' + minver[1] + '))',
'-DGDK_VERSION_MAX_ALLOWED=(G_ENCODE_VERSION(' + maxver[0] + ',' + maxver[1] + '))',
]
version_cxxflags = glib_version_cxxflags + gtk_version_cxxflags
# Asserts must not be disabled
assert(get_option('b_ndebug') == 'false', 'assertions may not be disabled')
# LTO very much NOT supported
assert(get_option('b_lto') == false, 'LTO not supported')
# Compiler flags
compiler_flags_common = [
'-Waggregate-return',
'-Wall',
'-Wcast-align',
'-Wendif-labels',
'-Werror=init-self',
'-Werror=missing-include-dirs',
'-Werror=pointer-arith',
'-Wextra',
'-Wfloat-equal',
'-Wformat-signedness',
'-Wimplicit',
'-Wlogical-op',
'-Wmissing-declarations',
'-Wmissing-format-attribute',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wnested-externs',
'-Wno-maybe-uninitialized',
'-Wno-missing-field-initializers',
'-Wno-switch-enum',
'-Wno-unused-parameter',
'-Wold-style-definition',
'-Wpacked',
'-Wshadow',
'-Wsign-compare',
'-Wstrict-aliasing=2',
'-Wstrict-prototypes',
'-Wundef',
'-Wuninitialized',
'-Wunsafe-loop-optimizations',
'-Wvla',
'-Wwrite-strings',
'-fdiagnostics-show-option',
'-fno-common',
'-fstack-protector',
'-fstack-protector-strong',
'-fvisibility=hidden',
]
if enable_debug
compiler_flags_common += [
'-ggdb3',
]
endif
# These are currently needed but the code should be fixed instead
compiler_flags_common_undesirable = [
'-fno-strict-aliasing'
]
compiler_flags_c_required = [
'-fvisibility=hidden',
]
compiler_flags_c_only = [
'-Waggregate-return',
'-Werror=implicit-function-declaration',
'-Werror=missing-prototypes',
'-Wimplicit',
'-Wimplicit-fallthrough=3',
'-Wmissing-parameter-type',
'-Wnested-externs',
'-Wold-style-declaration',
'-Wold-style-definition',
'-Woverride-init',
'-Wsign-compare',
'-Wstrict-prototypes',
]
compiler_flags_cxx_only = [
'-Wimplicit-fallthrough=5',
'-Wnon-virtual-dtor',
'-Wstrict-null-sentinel',
]
compiler_flags_cxx_required = [
'-fvisibility-inlines-hidden',
'-fvisibility=hidden',
]
global_cflags = cc.get_supported_arguments(compiler_flags_common +
compiler_flags_common_undesirable +
compiler_flags_c_only +
compiler_flags_c_required)
global_cxxflags = cxx.get_supported_arguments(compiler_flags_common +
compiler_flags_common_undesirable +
compiler_flags_cxx_only +
compiler_flags_cxx_required)
foreach flag: compiler_flags_cxx_required
assert(cxx.has_argument(flag), flag + ' is required but not supported')
endforeach
# These flags have to be tested together
compiler_flags_common_multi = [
[
'-Werror=format=2',
'-Werror=format-nonliteral',
'-Werror=format-security',
],
]
foreach flags : compiler_flags_common_multi
if cc.has_multi_arguments(flags)
global_cflags += flags
endif
endforeach
# ... and now make these flags the default
add_project_arguments(global_cflags, language: 'c',)
add_project_arguments(global_cxxflags, language: 'cpp')
# Dependencies
vte_dep = dependency(vte_req, version: '>=' + vte_req_version)
gio_dep = dependency('gio-2.0', version: '>=' + glib_req_version)
gio_unix_dep = dependency('gio-unix-2.0', version: '>=' + glib_req_version)
glib_dep = dependency('glib-2.0', version: '>=' + glib_req_version)
gtk_dep = dependency('gtk+-3.0', version: '>=' + gtk_req_version)
pcre2_dep = dependency('libpcre2-8', version: '>=' + pcre2_req_version)
pthreads_dep = dependency('threads')
schemas_dep = dependency('gsettings-desktop-schemas',
version: '>=' + schemas_req_version)
uuid_dep = dependency('uuid')
if get_option('nautilus_extension')
libnautilus_extension_dep = dependency('libnautilus-extension-4', version: '>=' + libnautilus_ext_req_version,)
else
libnautilus_extension_dep = dependency('', required: false,)
endif
if gtk_dep.get_pkgconfig_variable('targets').contains('x11')
x11_dep = dependency('x11')
else
x11_dep = dependency('', required: false)
endif
# Write config.h
configure_file(
output: 'config.h',
configuration: config_h,
)
# Utilities
glib_compile_schemas = find_program('glib-compile-schemas')
xsltproc = find_program('xsltproc')
# Subdirs
subdir('src')
subdir('data')
subdir('po')
if get_option('docs')
subdir('help')
subdir('man')
endif
# Dist
meson.add_dist_script(
find_program('meson_changelog.sh'),
)
# Simple compat Makefile
makefile_conf = configuration_data()
makefile_conf.set('srcdir', meson.current_source_dir())
makefile_conf.set('builddir', meson.current_build_dir())
configure_file(
input: 'Makefile.meson',
output: '@BASENAME@',
configuration: makefile_conf,
)
# .gitignore everything in the build directory
configure_file(
output: '.gitignore',
command: ['echo', '**/**',],
capture: true,
install: false,
)
# Summary
output = '\n'
output += 'Configuration for gnome-terminal:\n\n'
output += ' Version: ' + gt_version + '\n'
output += '\n'
output += ' C compiler: ' + cc.get_id() + ' (version ' + cc.version() + ')\n'
output += ' C++ compiler: ' + cxx.get_id() + ' (version ' + cxx.version() + ')\n'
output += '\n'
output += ' Coverage: ' + get_option('b_coverage').to_string() + '\n'
output += ' Documentation: ' + get_option('docs').to_string() + '\n'
output += ' Debug: ' + enable_debug.to_string() + '\n'
output += '\n'
output += ' Prefix: ' + get_option('prefix') + '\n'
output += '\n'
output += ' Nautilus extension: ' + get_option('nautilus_extension').to_string() + '\n'
output += ' Search provider: ' + get_option('search_provider').to_string() + '\n'
message(output)
# Done
|