1 configure_file(input : 'glibconfig.h.in', output : 'glibconfig.h',
2 install_dir : join_paths(get_option('libdir'), 'glib-2.0/include'),
3 configuration : glibconfig_conf)
7 # libsysprof-capture support
8 libsysprof_capture_dep = dependency('sysprof-capture-4', version: '>= 3.38.0',
9 required: get_option('sysprof'),
11 'enable_examples=false',
19 fallback: ['sysprof', 'libsysprof_capture_dep'],
21 glib_conf.set('HAVE_SYSPROF', libsysprof_capture_dep.found())
23 # TODO: gnulib_objects is a workaround for
24 # <https://github.com/mesonbuild/meson/issues/3934> and
25 # <https://github.com/mesonbuild/meson/issues/3937>. When we can depend
26 # on a meson version where those are fixed, revert the commit that
27 # introduced this workaround.
31 gnulib_libm_dependency = []
32 glib_conf.set ('gl_unused', '')
33 glib_conf.set ('gl_extern_inline', '')
35 subdir ('gnulib/gl_extern_inline')
36 subdir ('gnulib/gl_cv_long_double_equals_double')
37 subdir ('gnulib/gl_cv_cc_double_expbit0')
38 subdir ('gnulib/gl_cv_func_printf_precision')
39 subdir ('gnulib/gl_cv_func_printf_enomem')
40 subdir ('gnulib/gl_cv_func_printf_flag_zero')
41 subdir ('gnulib/gl_cv_func_printf_flag_leftadjust')
42 subdir ('gnulib/gl_cv_func_printf_flag_grouping')
43 subdir ('gnulib/gl_cv_func_printf_directive_a')
44 subdir ('gnulib/gl_cv_func_printf_directive_f')
45 subdir ('gnulib/gl_cv_func_printf_directive_ls')
46 subdir ('gnulib/gl_cv_func_printf_long_double')
47 subdir ('gnulib/gl_cv_func_printf_infinite')
48 subdir ('gnulib/gl_cv_func_printf_infinite_long_double')
51 /* Define as a marker that can be attached to declarations that might not
52 be used. This helps to reduce warnings, such as from
53 GCC -Wunused-parameter. */
54 #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
55 # define _GL_UNUSED __attribute__ ((__unused__))
60 glib_conf.set ('gl_unused', gl_unused)
61 glib_conf.set ('gl_extern_inline', gl_extern_inline)
63 if (gl_cv_long_double_equals_double)
64 glib_conf.set ('HAVE_SAME_LONG_DOUBLE_AS_DOUBLE', 1)
67 if (gl_cv_cc_double_expbit0_word >= 0 and
68 gl_cv_cc_double_expbit0_bit >= 0)
69 glib_conf.set('DBL_EXPBIT0_WORD', gl_cv_cc_double_expbit0_word)
70 glib_conf.set('DBL_EXPBIT0_BIT', gl_cv_cc_double_expbit0_bit)
73 if not gl_cv_func_printf_precision
74 glib_conf.set('NEED_PRINTF_UNBOUNDED_PRECISION', 1)
77 if not gl_cv_func_printf_enomem
78 glib_conf.set('NEED_PRINTF_ENOMEM', 1)
81 if not gl_cv_func_printf_flag_leftadjust
82 glib_conf.set('NEED_PRINTF_FLAG_LEFTADJUST', 1)
85 if not gl_cv_func_printf_flag_zero
86 glib_conf.set('NEED_PRINTF_FLAG_ZERO', 1)
89 if not gl_cv_func_printf_flag_grouping
90 glib_conf.set('NEED_PRINTF_FLAG_GROUPING', 1)
93 if not gl_cv_func_printf_directive_a
94 glib_conf.set('NEED_PRINTF_DIRECTIVE_A', 1)
97 if not gl_cv_func_printf_directive_f
98 glib_conf.set('NEED_PRINTF_DIRECTIVE_F', 1)
101 if not gl_cv_func_printf_directive_ls
102 glib_conf.set('NEED_PRINTF_DIRECTIVE_LS', 1)
105 if (not gl_cv_func_printf_precision or
106 not gl_cv_func_printf_enomem)
107 glib_conf.set('NEED_PRINTF_DOUBLE', 1)
108 glib_conf.set('NEED_PRINTF_LONG_DOUBLE', 1)
111 if not gl_cv_func_printf_infinite
112 glib_conf.set('NEED_PRINTF_INFINITE_DOUBLE', 1)
115 if gl_cv_func_printf_long_double and gl_cv_func_printf_infinite_long_double
116 glib_conf.set('NEED_PRINTF_INFINITE_LONG_DOUBLE', 1)
120 gnulib_objects = [gnulib_lib.extract_all_objects()]
123 glib_headers = files(
128 install_headers(glib_headers, subdir : 'glib-2.0')
130 glib_deprecated_headers = files(
131 'deprecated/gallocator.h',
132 'deprecated/gcache.h',
133 'deprecated/gcompletion.h',
134 'deprecated/gmain.h',
136 'deprecated/gthread.h',
138 install_headers(glib_deprecated_headers, subdir : 'glib-2.0/glib/deprecated')
140 glib_sub_headers = files(
141 'glib-autocleanups.h',
221 install_headers(glib_sub_headers, subdir : 'glib-2.0/glib')
223 deprecated_sources = files(
224 'deprecated/gallocator.c',
225 'deprecated/gcache.c',
226 'deprecated/gcompletion.c',
228 'deprecated/gthread-deprecated.c'
231 glib_sources = files(
312 'gvariant-serialiser.c',
313 'gvariant-vectors.c',
314 'gvarianttypeinfo.c',
321 if host_system == 'windows'
322 glib_win_rc = configure_file(
325 configuration: glibconfig_conf,
327 glib_win_res = windows.compile_resources(glib_win_rc)
328 glib_sources += [glib_win_res]
329 glib_sources += files('gwin32.c', 'gspawn-win32.c', 'giowin32.c')
330 platform_deps = [winsock2, cc.find_library('winmm')]
331 if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
332 glib_sources += files('dirent/wdirent.c')
335 glib_sources += files('glib-unix.c', 'gspawn.c', 'giounix.c')
340 glib_sources += files('gosxutils.m')
343 glib_sources += files('gthread-@0@.c'.format(threads_implementation))
346 glib_dtrace_obj = dtrace_obj_gen.process('glib_probes.d')
347 glib_dtrace_hdr = dtrace_hdr_gen.process('glib_probes.d')
353 pcre_static_args = []
355 if use_pcre_static_flag
356 pcre_static_args = ['-DPCRE_STATIC']
359 glib_c_args = ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args
360 libglib = library('glib-2.0',
361 glib_dtrace_obj, glib_dtrace_hdr,
362 sources : [deprecated_sources, glib_sources],
363 objects : [charset_lib.extract_all_objects()] + gnulib_objects,
364 version : library_version,
365 soversion : soversion,
366 darwin_versions : darwin_versions,
368 # intl.lib is not compatible with SAFESEH
369 link_args : [noseh_link_args, glib_link_flags, win32_ldflags],
370 include_directories : configinc,
371 dependencies : [pcre, thread_dep, librt] + libintl_deps + libiconv + platform_deps + [gnulib_libm_dependency, libm] + [libsysprof_capture_dep],
372 c_args : glib_c_args,
373 objc_args : glib_c_args,
376 libglib_dep = declare_dependency(
378 dependencies : libintl_deps,
379 # We sadly need to export configinc here because everyone includes <glib/*.h>
380 include_directories : [configinc, glibinc])
382 pkg.generate(libglib,
383 libraries : [libintl_deps],
384 libraries_private : [osx_ldflags, win32_ldflags],
385 subdirs : ['glib-2.0'],
386 extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
387 variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')),
388 'glib_genmarshal=' + join_paths('${bindir}', 'glib-genmarshal'),
389 'gobject_query=' + join_paths('${bindir}', 'gobject-query'),
390 'glib_mkenums=' + join_paths('${bindir}', 'glib-mkenums')],
391 version : glib_version,
392 install_dir : glib_pkgconfigreldir,
393 filebase : 'glib-2.0',
395 description : 'C Utility Library',
398 if meson.version().version_compare('>=0.54.0')
399 meson.override_dependency('glib-2.0', libglib_dep)
402 # On Windows, glib needs a spawn helper for g_spawn* API
403 if host_system == 'windows'
404 if host_machine.cpu_family() == 'x86'
405 executable('gspawn-win32-helper', 'gspawn-win32-helper.c',
408 include_directories : configinc,
409 dependencies : [libglib_dep])
410 executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
412 c_args : ['-DHELPER_CONSOLE'],
413 include_directories : configinc,
414 dependencies : [libglib_dep])
416 executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
419 include_directories : configinc,
420 dependencies : [libglib_dep])
421 executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
423 c_args : ['-DHELPER_CONSOLE'],
424 include_directories : configinc,
425 dependencies : [libglib_dep])
428 gtester = executable('gtester', 'gtester.c',
430 c_args : ['-UG_DISABLE_ASSERT'],
431 include_directories : configinc,
432 dependencies : [libglib_dep])
435 report_conf = configuration_data()
436 report_conf.set('GLIB_VERSION', glib_version)
437 report_conf.set('PYTHON', python_name)
439 input: 'gtester-report.in',
440 output: 'gtester-report',
441 install_dir: get_option('bindir'),
442 configuration: report_conf,
443 install_mode: 'rwxr-xr-x'
446 install_data('glib_gdb.py', install_dir : join_paths(glib_pkgdatadir, 'gdb'))
448 gdb_conf = configuration_data()
449 gdb_conf.set('datadir', glib_datadir)
450 # This is also used in gobject/meson.build
451 if host_system != 'windows'
452 # XXX: We add a leading './' because glib_libdir is an absolute path and we
453 # need it to be a relative path so that join_paths appends it to the end.
454 gdb_install_dir = join_paths(glib_datadir, 'gdb', 'auto-load', './' + glib_libdir)
456 # FIXME: Cannot install on Windows because the path will contain a drive
457 # letter and colons are not allowed in paths.
458 gdb_install_dir = false
461 input: 'libglib-gdb.py.in',
462 output: 'libglib-2.0.so.@0@-gdb.py'.format(library_version),
463 configuration: gdb_conf,
464 install_dir: gdb_install_dir,
468 glib_stp = configure_file(input : 'glib.stp.in',
469 output : '@0@.stp'.format(libglib.full_path().split('/').get(-1)),
470 configuration : stp_cdata,
471 install_dir : tapset_install_dir,