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 'gvarianttypeinfo.c',
320 if host_system == 'windows'
321 glib_win_rc = configure_file(
324 configuration: glibconfig_conf,
326 glib_win_res = windows.compile_resources(glib_win_rc)
327 glib_sources += [glib_win_res]
328 glib_sources += files('gwin32.c', 'gspawn-win32.c', 'giowin32.c')
329 platform_deps = [winsock2, cc.find_library('winmm')]
330 if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
331 glib_sources += files('dirent/wdirent.c')
334 glib_sources += files('glib-unix.c', 'gspawn.c', 'giounix.c')
339 glib_sources += files('gosxutils.m')
342 glib_sources += files('gthread-@0@.c'.format(threads_implementation))
345 glib_dtrace_obj = dtrace_obj_gen.process('glib_probes.d')
346 glib_dtrace_hdr = dtrace_hdr_gen.process('glib_probes.d')
352 pcre_static_args = []
354 if use_pcre_static_flag
355 pcre_static_args = ['-DPCRE_STATIC']
358 glib_c_args = ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args
359 libglib = library('glib-2.0',
360 glib_dtrace_obj, glib_dtrace_hdr,
361 sources : [deprecated_sources, glib_sources],
362 objects : [charset_lib.extract_all_objects()] + gnulib_objects,
363 version : library_version,
364 soversion : soversion,
365 darwin_versions : darwin_versions,
367 # intl.lib is not compatible with SAFESEH
368 link_args : [noseh_link_args, glib_link_flags, win32_ldflags],
369 include_directories : configinc,
370 dependencies : [pcre, thread_dep, librt] + libintl_deps + libiconv + platform_deps + [gnulib_libm_dependency, libm] + [libsysprof_capture_dep],
371 c_args : glib_c_args,
372 objc_args : glib_c_args,
375 libglib_dep = declare_dependency(
377 dependencies : libintl_deps,
378 # We sadly need to export configinc here because everyone includes <glib/*.h>
379 include_directories : [configinc, glibinc])
381 pkg.generate(libglib,
382 libraries : [libintl_deps],
383 libraries_private : [osx_ldflags, win32_ldflags],
384 subdirs : ['glib-2.0'],
385 extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
386 variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')),
387 'glib_genmarshal=' + join_paths('${bindir}', 'glib-genmarshal'),
388 'gobject_query=' + join_paths('${bindir}', 'gobject-query'),
389 'glib_mkenums=' + join_paths('${bindir}', 'glib-mkenums')],
390 version : glib_version,
391 install_dir : glib_pkgconfigreldir,
392 filebase : 'glib-2.0',
394 description : 'C Utility Library',
397 if meson.version().version_compare('>=0.54.0')
398 meson.override_dependency('glib-2.0', libglib_dep)
401 # On Windows, glib needs a spawn helper for g_spawn* API
402 if host_system == 'windows'
403 if host_machine.cpu_family() == 'x86'
404 executable('gspawn-win32-helper', 'gspawn-win32-helper.c',
407 include_directories : configinc,
408 dependencies : [libglib_dep])
409 executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
411 c_args : ['-DHELPER_CONSOLE'],
412 include_directories : configinc,
413 dependencies : [libglib_dep])
415 executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
418 include_directories : configinc,
419 dependencies : [libglib_dep])
420 executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
422 c_args : ['-DHELPER_CONSOLE'],
423 include_directories : configinc,
424 dependencies : [libglib_dep])
427 gtester = executable('gtester', 'gtester.c',
429 c_args : ['-UG_DISABLE_ASSERT'],
430 include_directories : configinc,
431 dependencies : [libglib_dep])
434 report_conf = configuration_data()
435 report_conf.set('GLIB_VERSION', glib_version)
436 report_conf.set('PYTHON', python_name)
438 input: 'gtester-report.in',
439 output: 'gtester-report',
440 install_dir: get_option('bindir'),
441 configuration: report_conf,
442 install_mode: 'rwxr-xr-x'
445 install_data('glib_gdb.py', install_dir : join_paths(glib_pkgdatadir, 'gdb'))
447 gdb_conf = configuration_data()
448 gdb_conf.set('datadir', glib_datadir)
449 # This is also used in gobject/meson.build
450 if host_system != 'windows'
451 # XXX: We add a leading './' because glib_libdir is an absolute path and we
452 # need it to be a relative path so that join_paths appends it to the end.
453 gdb_install_dir = join_paths(glib_datadir, 'gdb', 'auto-load', './' + glib_libdir)
455 # FIXME: Cannot install on Windows because the path will contain a drive
456 # letter and colons are not allowed in paths.
457 gdb_install_dir = false
460 input: 'libglib-gdb.py.in',
461 output: 'libglib-2.0.so.@0@-gdb.py'.format(library_version),
462 configuration: gdb_conf,
463 install_dir: gdb_install_dir,
467 glib_stp = configure_file(input : 'glib.stp.in',
468 output : '@0@.stp'.format(libglib.full_path().split('/').get(-1)),
469 configuration : stp_cdata,
470 install_dir : tapset_install_dir,