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)
10 # libsysprof-capture support
11 libsysprof_capture_dep = dependency('sysprof-capture-4', version: '>= 3.38.0',
12 required: get_option('sysprof'),
14 'enable_examples=false',
22 fallback: ['sysprof', 'libsysprof_capture_dep'],
24 glib_conf.set('HAVE_SYSPROF', libsysprof_capture_dep.found())
26 # TODO: gnulib_objects, pcre_objects and pcre_deps are a workaround for
27 # <https://github.com/mesonbuild/meson/issues/3934> and
28 # <https://github.com/mesonbuild/meson/issues/3937>. When we can depend
29 # on a meson version where those are fixed, revert the commit that
30 # introduced this workaround.
34 gnulib_libm_dependency = []
35 glib_conf.set ('gl_unused', '')
36 glib_conf.set ('gl_extern_inline', '')
38 subdir ('gnulib/gl_extern_inline')
39 subdir ('gnulib/gl_cv_long_double_equals_double')
40 subdir ('gnulib/gl_cv_cc_double_expbit0')
41 subdir ('gnulib/gl_cv_func_printf_precision')
42 subdir ('gnulib/gl_cv_func_printf_enomem')
43 subdir ('gnulib/gl_cv_func_printf_flag_zero')
44 subdir ('gnulib/gl_cv_func_printf_flag_leftadjust')
45 subdir ('gnulib/gl_cv_func_printf_flag_grouping')
46 subdir ('gnulib/gl_cv_func_printf_directive_a')
47 subdir ('gnulib/gl_cv_func_printf_directive_f')
48 subdir ('gnulib/gl_cv_func_printf_directive_ls')
49 subdir ('gnulib/gl_cv_func_printf_long_double')
50 subdir ('gnulib/gl_cv_func_printf_infinite')
51 subdir ('gnulib/gl_cv_func_printf_infinite_long_double')
54 /* Define as a marker that can be attached to declarations that might not
55 be used. This helps to reduce warnings, such as from
56 GCC -Wunused-parameter. */
57 #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
58 # define _GL_UNUSED __attribute__ ((__unused__))
63 glib_conf.set ('gl_unused', gl_unused)
64 glib_conf.set ('gl_extern_inline', gl_extern_inline)
66 if (gl_cv_long_double_equals_double)
67 glib_conf.set ('HAVE_SAME_LONG_DOUBLE_AS_DOUBLE', 1)
70 if (gl_cv_cc_double_expbit0_word >= 0 and
71 gl_cv_cc_double_expbit0_bit >= 0)
72 glib_conf.set('DBL_EXPBIT0_WORD', gl_cv_cc_double_expbit0_word)
73 glib_conf.set('DBL_EXPBIT0_BIT', gl_cv_cc_double_expbit0_bit)
76 if not gl_cv_func_printf_precision
77 glib_conf.set('NEED_PRINTF_UNBOUNDED_PRECISION', 1)
80 if not gl_cv_func_printf_enomem
81 glib_conf.set('NEED_PRINTF_ENOMEM', 1)
84 if not gl_cv_func_printf_flag_leftadjust
85 glib_conf.set('NEED_PRINTF_FLAG_LEFTADJUST', 1)
88 if not gl_cv_func_printf_flag_zero
89 glib_conf.set('NEED_PRINTF_FLAG_ZERO', 1)
92 if not gl_cv_func_printf_flag_grouping
93 glib_conf.set('NEED_PRINTF_FLAG_GROUPING', 1)
96 if not gl_cv_func_printf_directive_a
97 glib_conf.set('NEED_PRINTF_DIRECTIVE_A', 1)
100 if not gl_cv_func_printf_directive_f
101 glib_conf.set('NEED_PRINTF_DIRECTIVE_F', 1)
104 if not gl_cv_func_printf_directive_ls
105 glib_conf.set('NEED_PRINTF_DIRECTIVE_LS', 1)
108 if (not gl_cv_func_printf_precision or
109 not gl_cv_func_printf_enomem)
110 glib_conf.set('NEED_PRINTF_DOUBLE', 1)
111 glib_conf.set('NEED_PRINTF_LONG_DOUBLE', 1)
114 if not gl_cv_func_printf_infinite
115 glib_conf.set('NEED_PRINTF_INFINITE_DOUBLE', 1)
118 if gl_cv_func_printf_long_double and gl_cv_func_printf_infinite_long_double
119 glib_conf.set('NEED_PRINTF_INFINITE_LONG_DOUBLE', 1)
123 gnulib_objects = [gnulib_lib.extract_all_objects()]
126 glib_headers = files(
131 install_headers(glib_headers, subdir : 'glib-2.0')
133 glib_deprecated_headers = files(
134 'deprecated/gallocator.h',
135 'deprecated/gcache.h',
136 'deprecated/gcompletion.h',
137 'deprecated/gmain.h',
139 'deprecated/gthread.h',
141 install_headers(glib_deprecated_headers, subdir : 'glib-2.0/glib/deprecated')
143 glib_sub_headers = files(
144 'glib-autocleanups.h',
223 install_headers(glib_sub_headers, subdir : 'glib-2.0/glib')
225 deprecated_sources = files(
226 'deprecated/gallocator.c',
227 'deprecated/gcache.c',
228 'deprecated/gcompletion.c',
230 'deprecated/gthread-deprecated.c'
233 glib_sources = files(
314 'gvariant-serialiser.c',
315 'gvarianttypeinfo.c',
322 if host_system == 'windows'
323 glib_win_rc = configure_file(
326 configuration: glibconfig_conf,
328 glib_win_res = windows.compile_resources(glib_win_rc)
329 glib_sources += [glib_win_res]
330 glib_sources += files('gwin32.c', 'gspawn-win32.c', 'giowin32.c')
331 platform_deps = [winsock2, cc.find_library('winmm')]
332 if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
333 glib_sources += files('dirent/wdirent.c')
336 glib_sources += files('glib-unix.c', 'gspawn.c', 'giounix.c')
341 glib_sources += files('gosxutils.m')
344 glib_sources += files('gthread-@0@.c'.format(threads_implementation))
347 glib_dtrace_obj = dtrace_obj_gen.process('glib_probes.d')
348 glib_dtrace_hdr = dtrace_hdr_gen.process('glib_probes.d')
354 pcre_static_args = []
356 if use_pcre_static_flag
357 pcre_static_args = ['-DPCRE_STATIC']
365 pcre_objects = [libpcre.extract_all_objects()]
368 glib_c_args = ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args
369 libglib = library('glib-2.0',
370 glib_dtrace_obj, glib_dtrace_hdr,
371 sources : [deprecated_sources, glib_sources],
372 objects : [charset_lib.extract_all_objects()] + gnulib_objects + pcre_objects,
373 version : library_version,
374 soversion : soversion,
375 darwin_versions : darwin_versions,
377 # intl.lib is not compatible with SAFESEH
378 link_args : [noseh_link_args, glib_link_flags, win32_ldflags],
379 include_directories : configinc,
380 dependencies : pcre_deps + [thread_dep, librt] + libintl_deps + libiconv + platform_deps + [gnulib_libm_dependency, libm] + [libsysprof_capture_dep],
381 c_args : glib_c_args,
382 objc_args : glib_c_args,
385 libglib_dep = declare_dependency(
387 dependencies : libintl_deps,
388 # We sadly need to export configinc here because everyone includes <glib/*.h>
389 include_directories : [configinc, glibinc])
391 pkg.generate(libglib,
392 libraries : [libintl_deps],
393 libraries_private : [osx_ldflags, win32_ldflags],
394 subdirs : ['glib-2.0'],
395 extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
396 variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')),
397 'glib_genmarshal=' + join_paths('${bindir}', 'glib-genmarshal'),
398 'gobject_query=' + join_paths('${bindir}', 'gobject-query'),
399 'glib_mkenums=' + join_paths('${bindir}', 'glib-mkenums')],
400 version : glib_version,
401 install_dir : glib_pkgconfigreldir,
402 filebase : 'glib-2.0',
404 description : 'C Utility Library',
407 if meson.version().version_compare('>=0.54.0')
408 meson.override_dependency('glib-2.0', libglib_dep)
411 # On Windows, glib needs a spawn helper for g_spawn* API
412 if host_system == 'windows'
413 if host_machine.cpu_family() == 'x86'
414 executable('gspawn-win32-helper', 'gspawn-win32-helper.c',
417 include_directories : configinc,
418 dependencies : [libglib_dep])
419 executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
421 c_args : ['-DHELPER_CONSOLE'],
422 include_directories : configinc,
423 dependencies : [libglib_dep])
425 executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
428 include_directories : configinc,
429 dependencies : [libglib_dep])
430 executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
432 c_args : ['-DHELPER_CONSOLE'],
433 include_directories : configinc,
434 dependencies : [libglib_dep])
437 gtester = executable('gtester', 'gtester.c',
439 c_args : ['-UG_DISABLE_ASSERT'],
440 include_directories : configinc,
441 dependencies : [libglib_dep])
444 report_conf = configuration_data()
445 report_conf.set('GLIB_VERSION', glib_version)
446 report_conf.set('PYTHON', python_name)
448 input: 'gtester-report.in',
449 output: 'gtester-report',
450 install_dir: get_option('bindir'),
451 configuration: report_conf,
452 install_mode: 'rwxr-xr-x'
455 install_data('glib_gdb.py', install_dir : join_paths(glib_pkgdatadir, 'gdb'))
457 gdb_conf = configuration_data()
458 gdb_conf.set('datadir', glib_datadir)
459 # This is also used in gobject/meson.build
460 if host_system != 'windows'
461 # XXX: We add a leading './' because glib_libdir is an absolute path and we
462 # need it to be a relative path so that join_paths appends it to the end.
463 gdb_install_dir = join_paths(glib_datadir, 'gdb', 'auto-load', './' + glib_libdir)
465 # FIXME: Cannot install on Windows because the path will contain a drive
466 # letter and colons are not allowed in paths.
467 gdb_install_dir = false
470 input: 'libglib-gdb.py.in',
471 output: 'libglib-2.0.so.@0@-gdb.py'.format(library_version),
472 configuration: gdb_conf,
473 install_dir: gdb_install_dir,
477 glib_stp = configure_file(input : 'glib.stp.in',
478 output : '@0@.stp'.format(libglib.full_path().split('/').get(-1)),
479 configuration : stp_cdata,
480 install_dir : tapset_install_dir,