File: meson.build

package info (click to toggle)
vte2.91 0.62.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,856 kB
  • sloc: cpp: 34,802; ansic: 5,160; sh: 623; xml: 155; makefile: 66; python: 8
file content (513 lines) | stat: -rw-r--r-- 14,058 bytes parent folder | download
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
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
# Copyright © 2018, 2019 Iñigo Martínez
# Copyright © 2019 Christian Persch
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This library 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 Lesser
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library.  If not, see <https://www.gnu.org/licenses/>.

project(
  'vte',
  ['c', 'cpp'],
  version: '0.62.3',
  license: ['LGPL-3.0-or-later', 'GPL-3.0-or-later'],
  default_options: [
    'buildtype=release',
    'c_std=gnu11',
    'cpp_std=gnu++17',
    'warning_level=0',
    'b_ndebug=false',
  ],
  meson_version: '>= 0.50.0',
)

# Requirements

gtk3_req_version          = '3.20.0'
gtk3_min_req_version      = '3.18'
gtk3_max_allowed_version  = '3.20'
gtk4_req_version          = '4.0.0'

fribidi_req_version       = '1.0.0'
gio_req_version           = '2.52.0'
glib_req_version          = '2.52.0'
glib_min_req_version      = '2.52'
glib_max_allowed_version  = '2.52'
gnutls_req_version        = '3.2.7'
icu_uc_req_version        = '4.8'
pango_req_version         = '1.22.0'
pcre2_req_version         = '10.21'
systemd_req_version       = '220'

# API

vte_api_major_version = 2
vte_api_minor_version = 91
vte_api_version = '@0@.@1@'.format(vte_api_major_version, vte_api_minor_version)
vte_api_name = 'vte-@0@.@1@'.format(vte_api_major_version, vte_api_minor_version)

vte_gtk3_api_version = '@0@.@1@'.format(vte_api_major_version, vte_api_minor_version)
vte_gtk4_api_version = '@0@.@1@'.format(vte_api_major_version + 1, vte_api_minor_version)

vte_gtk3_api_name = 'vte-' + vte_gtk3_api_version
vte_gtk4_api_name = 'vte-' + vte_gtk4_api_version

vte_gtk3_api_path = vte_gtk3_api_name / 'vte'
vte_gtk4_api_path = vte_gtk4_api_name / 'vte'

# Library versioning

vte_version = meson.project_version()
version_array = vte_version.split('.')
vte_major_version = version_array[0].to_int()
vte_minor_version = version_array[1].to_int()
vte_micro_version = version_array[2].to_int()

libvte_soversion = 0

lt_revision = (vte_minor_version.is_odd() ? 0 : vte_micro_version)
lt_age = vte_minor_version * 100 + vte_micro_version - lt_revision
lt_current = vte_major_version + lt_age

libvte_gtk3_soversion = '@0@.@1@.@2@'.format(libvte_soversion, lt_current, lt_revision)
libvte_gtk4_soversion = libvte_soversion.to_string()

# i18n

vte_gettext_domain = vte_api_name

# Directories

vte_datadir = get_option('datadir')
vte_includedir = get_option('includedir')
vte_libexecdir = get_option('libexecdir')
vte_localedir = get_option('localedir')
vte_prefix = get_option('prefix')
vte_sysconfdir = get_option('sysconfdir')

# 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.
vte_systemduserunitdir = vte_prefix / 'lib' / 'systemd' / 'user'

# Debug

enable_debug = get_option('debugg') or get_option('debug') or get_option('buildtype').contains('debug')

# Meson modules

gnome = import('gnome')
pkg = import('pkgconfig')

# Compilers

cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')

top_inc = include_directories('.')

# Start config.h

config_h = configuration_data()

config_h.set_quoted('GETTEXT_PACKAGE', vte_gettext_domain)
config_h.set_quoted('VERSION', vte_version)
config_h.set('VTE_DEBUG', enable_debug)
config_h.set('WITH_A11Y', get_option('a11y'))
config_h.set('WITH_FRIBIDI', get_option('fribidi'))
config_h.set('WITH_GNUTLS', get_option('gnutls'))
config_h.set('WITH_ICU', get_option('icu'))

ver = glib_min_req_version.split('.')
config_h.set('GLIB_VERSION_MIN_REQUIRED', '(G_ENCODE_VERSION(' + ver[0] + ',' + ver[1] + '))')
ver = glib_max_allowed_version.split('.')
config_h.set('GLIB_VERSION_MAX_ALLOWED', '(G_ENCODE_VERSION(' + ver[0] + ',' + ver[1] + '))')

if get_option('gtk3')
  gtk3_version_cppflags = []

  ver = gtk3_min_req_version.split('.')
  gtk3_version_cppflags += '-DGDK_VERSION_MIN_REQUIRED=(G_ENCODE_VERSION(' + ver[0] + ',' + ver[1] + '))'

  ver = gtk3_max_allowed_version.split('.')
  gtk3_version_cppflags += '-DGDK_VERSION_MAX_ALLOWED=(G_ENCODE_VERSION(' + ver[0] + ',' + ver[1] + '))'
endif

# FIXME AC_USE_SYSTEM_EXTENSIONS also supported non-gnu systems
config_h.set10('_GNU_SOURCE', true)

# Check headers

check_headers = [
  'locale.h',
  'pty.h',
  'stropts.h',
  'sys/resource.h',
  'sys/select.h',
  'sys/syslimits.h',
  'sys/termios.h',
  'sys/types.h',
  'sys/wait.h',
  'termios.h',
  'util.h',
  'wchar.h',
]

foreach header: check_headers
  config_h.set('HAVE_' + header.underscorify().to_upper(), cxx.has_header(header))
endforeach

# Check for symbols

check_symbols_required = [
  ['TIOCGWINSZ', 'sys/ioctl.h'],
]

foreach symbol: check_symbols_required
  assert(cxx.has_header_symbol(symbol[1], symbol[0]), symbol[0] + ' not found')
endforeach

# Check for functions

check_functions_required = [
  'fork',
  'grantpt',
  'posix_openpt',
  'ptsname',
  'tcgetattr',
  'unlockpt',
]

foreach func: check_functions_required
  assert(cxx.has_function(func), func + ' not found')
endforeach

check_functions = [
  'explicit_bzero',
  'fdwalk',
  'pread',
  'pwrite',
  'strchrnul',
]

foreach func: check_functions
  config_h.set('HAVE_' + func.underscorify().to_upper(), cxx.has_function(func))
endforeach

# Math functions

libm_dep = cxx.find_library('m')

check_math_functions_required = [
  'ceil',
  'floor',
]

foreach func: check_math_functions_required
  assert(cxx.has_function(func, dependencies: libm_dep), func + ' not found')
endforeach

check_math_functions = [
  'round',
]

foreach func: check_math_functions
  config_h.set('HAVE_' + func.underscorify().to_upper(), cxx.has_function(func, dependencies: libm_dep))
endforeach

# Compiler

# Meson has a misfeature where it allows the user to override the -std option
# for the C/C++ compiler. Disallow that.

assert(get_option('c_std') == 'gnu11', 'cannot override C std version')
assert(get_option('cpp_std') == 'gnu++17', 'cannot override C++ std version')

# Meson only checks that -std supports the given string, 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#cxx17

if cxx.get_id() == 'gcc'
  assert(cxx.version().version_compare('>= 7.0'), 'needs G++ >= 7 for C++17 support')
endif

# 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 = [
  '-Wall',
  '-Wextra',
  '-Wcast-align',
  '-Wcast-function-type',
  '-Wclobbered',
  '-Wempty-body',
  '-Wendif-labels',
  '-Werror=init-self',
  '-Werror=missing-include-dirs',
  '-Werror=pointer-arith',
  '-Wfloat-equal',
  '-Wignored-qualifiers',
  '-Winvalid-pch',
  '-Wlogical-op',
  '-Wmisleading-indentation',
  '-Wmissing-declarations',
  '-Wmissing-field-initializers',
  '-Wmissing-format-attribute',
  '-Wmissing-include-dirs',
  '-Wmissing-noreturn',
  '-Wno-address-of-packed-member',
  '-Wno-missing-field-initializers',
  '-Wno-packed',
  '-Wno-switch-enum',
  '-Wno-unused-parameter',
  '-Wshadow',
  '-Wshift-negative-value',
  '-Wsign-compare',
  '-Wstrict-aliasing=2',
  '-Wtype-limits',
  '-Wundef',
  '-Wuninitialized',
  '-Wuninitialized',
  '-Wunsafe-loop-optimizations',
  '-Wunused',
  '-Wunused-but-set-parameter',
  '-Wunused-but-set-variable',
  '-Wunused-function',
  '-Wunused-label',
  '-Wunused-local-typedefs',
  '-Wunused-value',
  '-Wunused-variable',
  '-Wvla',
  '-Wwrite-strings',
  '-fdiagnostics-show-option',
  '-fno-common',
  '-fno-semantic-interposition',
  '-fstack-protector',
  '-fstack-protector-strong',
]

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_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)
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 = [
  # These only work together with -Wformat
  [
    '-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
  if cxx.has_multi_arguments(flags)
    global_cxxflags += flags
  endif
endforeach

# ... and now make these flags the default

add_project_arguments(global_cflags, language: 'c')
add_project_arguments(global_cxxflags, language: 'cpp')

# Linker flags

linker_flags = [
  ['-Wl,-Bsymbolic', false,],
  ['-Wl,-Bsymbolic-functions', get_option('_b_symbolic_functions'),],
]

foreach flag: linker_flags
  if cc.has_link_argument(flag[0])
    add_project_link_arguments(flag[0], language: 'c')
  elif flag[1]
    assert(false, flag[0] + ' is required but not supported')
  endif

  if cxx.has_link_argument(flag[0])
    add_project_link_arguments(flag[0], language: 'cpp')
  elif flag[1]
    assert(false, flag[0] + ' is required but not supported')
  endif
endforeach

# Dependencies

gio_dep      = dependency('gio-2.0',    version: '>=' + gio_req_version)
glib_dep     = dependency('glib-2.0',   version: '>=' + glib_req_version)
gobject_dep  = dependency('gobject-2.0')
pango_dep    = dependency('pango',      version: '>=' + pango_req_version)
pcre2_dep    = dependency('libpcre2-8', version: '>=' + pcre2_req_version)
pthreads_dep = dependency('threads')
zlib_dep     = dependency('zlib')

if get_option('fribidi')
  fribidi_dep = dependency('fribidi', version: '>=' + fribidi_req_version)
else
  fribidi_dep = dependency('', required: false)
endif

if get_option('gnutls')
  gnutls_dep = dependency('gnutls', version: '>=' + gnutls_req_version)
else
  gnutls_dep = dependency('', required: false)
endif

if get_option('gtk3')
  gtk3_dep = dependency('gtk+-3.0', version: '>=' + gtk3_req_version)
else
  gtk3_dep = dependency('', required: false)
endif

if get_option('gtk4')
  gtk4_dep = dependency('gtk+-4.0', version: '>=' + gtk4_req_version)
else
  gtk4_dep = dependency('', required: false)
endif

if get_option('icu')
  icu_dep = dependency('icu-uc', version: '>=' + icu_uc_req_version)
else
  icu_dep = dependency('', required: false)
endif

if host_machine.system() == 'linux' and get_option('_systemd')
  systemd_dep = dependency('libsystemd', version: '>=' + systemd_req_version)
else
  systemd_dep = dependency('', required: false)
endif

config_h.set('WITH_SYSTEMD', systemd_dep.found())

# Write config.h

configure_file(
  output: 'config.h',
  configuration: config_h,
)

# Subdirs

subdir('src')
subdir('bindings')
subdir('po')

if get_option('docs')
  subdir('doc/reference')
endif

# Simple compat Makefile

makefile_conf = configuration_data()
makefile_conf.set('srcdir', meson.current_source_dir())
makefile_conf.set('builddir', meson.current_build_dir())
makefile_conf.set('vte_gtk3_api_version', vte_gtk3_api_version)
makefile_conf.set('vte_gtk4_api_version', vte_gtk4_api_version)

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 VTE:\n\n'
output += '  Version:      ' + vte_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 += '  Debug:        ' + enable_debug.to_string() + '\n'
output += '\n'
output += '  A11y:         ' + get_option('a11y').to_string() + '\n'
output += '  Docs:         ' + get_option('docs').to_string() + '\n'
output += '  FRIBIDI:      ' + get_option('fribidi').to_string() + '\n'
output += '  GNUTLS:       ' + get_option('gnutls').to_string() + '\n'
output += '  GTK+ 3.0:     ' + get_option('gtk3').to_string() + '\n'
output += '  GTK+ 4.0:     ' + get_option('gtk4').to_string() + '\n'
output += '  ICU:          ' + get_option('icu').to_string() + '\n'
output += '  GIR:          ' + get_option('gir').to_string() + '\n'
output += '  systemd:      ' + systemd_dep.found().to_string() + '\n'
output += '  Vala:         ' + get_option('vapi').to_string() + '\n'
output += '\n'
output += '  Prefix:       ' + get_option('prefix') + '\n'
message(output)

# Done