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',
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',
222 install_headers(glib_sub_headers, subdir : 'glib-2.0/glib')
224 deprecated_sources = files(
225 'deprecated/gallocator.c',
226 'deprecated/gcache.c',
227 'deprecated/gcompletion.c',
229 'deprecated/gthread-deprecated.c'
232 glib_sources = files(
287 'gstrfuncsprivate.h',
313 'gvariant-serialiser.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']
364 pcre_objects = [libpcre.extract_all_objects()]
367 glib_c_args = ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args
368 libglib = library('glib-2.0',
369 glib_dtrace_obj, glib_dtrace_hdr,
370 sources : [deprecated_sources, glib_sources],
371 objects : [charset_lib.extract_all_objects()] + gnulib_objects + pcre_objects,
372 version : library_version,
373 soversion : soversion,
374 darwin_versions : darwin_versions,
376 # intl.lib is not compatible with SAFESEH
377 link_args : [noseh_link_args, glib_link_flags, win32_ldflags],
378 include_directories : configinc,
379 dependencies : pcre_deps + [thread_dep, librt] + libintl_deps + libiconv + platform_deps + gnulib_libm_dependency + [libsysprof_capture_dep],
380 c_args : glib_c_args,
381 objc_args : glib_c_args,
384 libglib_dep = declare_dependency(
386 dependencies : libintl_deps,
387 # We sadly need to export configinc here because everyone includes <glib/*.h>
388 include_directories : [configinc, glibinc])
390 pkg.generate(libglib,
391 libraries : [libintl_deps],
392 libraries_private : [osx_ldflags, win32_ldflags],
393 subdirs : ['glib-2.0'],
394 extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
395 variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')),
396 'glib_genmarshal=' + join_paths('${bindir}', 'glib-genmarshal'),
397 'gobject_query=' + join_paths('${bindir}', 'gobject-query'),
398 'glib_mkenums=' + join_paths('${bindir}', 'glib-mkenums')],
399 version : glib_version,
400 install_dir : glib_pkgconfigreldir,
401 filebase : 'glib-2.0',
403 description : 'C Utility Library',
406 if meson.version().version_compare('>=0.54.0')
407 meson.override_dependency('glib-2.0', libglib_dep)
410 # On Windows, glib needs a spawn helper for g_spawn* API
411 if host_system == 'windows'
412 if host_machine.cpu_family() == 'x86'
413 executable('gspawn-win32-helper', 'gspawn-win32-helper.c',
416 include_directories : configinc,
417 dependencies : [libglib_dep])
418 executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
420 c_args : ['-DHELPER_CONSOLE'],
421 include_directories : configinc,
422 dependencies : [libglib_dep])
424 executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
427 include_directories : configinc,
428 dependencies : [libglib_dep])
429 executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
431 c_args : ['-DHELPER_CONSOLE'],
432 include_directories : configinc,
433 dependencies : [libglib_dep])
436 gtester = executable('gtester', 'gtester.c',
438 c_args : ['-UG_DISABLE_ASSERT'],
439 include_directories : configinc,
440 dependencies : [libglib_dep])
443 report_conf = configuration_data()
444 report_conf.set('GLIB_VERSION', glib_version)
445 report_conf.set('PYTHON', python_name)
447 input: 'gtester-report.in',
448 output: 'gtester-report',
449 install_dir: get_option('bindir'),
450 configuration: report_conf,
451 install_mode: 'rwxr-xr-x'
454 install_data('glib_gdb.py', install_dir : join_paths(glib_pkgdatadir, 'gdb'))
456 gdb_conf = configuration_data()
457 gdb_conf.set('datadir', glib_datadir)
458 # This is also used in gobject/meson.build
459 if host_system != 'windows'
460 # XXX: We add a leading './' because glib_libdir is an absolute path and we
461 # need it to be a relative path so that join_paths appends it to the end.
462 gdb_install_dir = join_paths(glib_datadir, 'gdb', 'auto-load', './' + glib_libdir)
464 # FIXME: Cannot install on Windows because the path will contain a drive
465 # letter and colons are not allowed in paths.
466 gdb_install_dir = false
469 input: 'libglib-gdb.py.in',
470 output: 'libglib-2.0.so.@0@-gdb.py'.format(library_version),
471 configuration: gdb_conf,
472 install_dir: gdb_install_dir,
476 glib_stp = configure_file(input : 'glib.stp.in',
477 output : '@0@.stp'.format(libglib.full_path().split('/').get(-1)),
478 configuration : stp_cdata,
479 install_dir : tapset_install_dir,