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 # TODO: gnulib_objects, pcre_objects and pcre_deps are a workaround for
11 # <https://github.com/mesonbuild/meson/issues/3934> and
12 # <https://github.com/mesonbuild/meson/issues/3937>. When we can depend
13 # on a meson version where those are fixed, revert the commit that
14 # introduced this workaround.
15 if have_good_vsnprintf and have_good_snprintf
18 gnulib_libm_dependency = []
19 glib_conf.set ('gl_unused', '')
20 glib_conf.set ('gl_extern_inline', '')
22 subdir ('gnulib/gl_extern_inline')
23 subdir ('gnulib/gl_cv_long_double_equals_double')
24 subdir ('gnulib/gl_cv_cc_double_expbit0')
25 subdir ('gnulib/gl_cv_func_printf_precision')
26 subdir ('gnulib/gl_cv_func_printf_enomem')
27 subdir ('gnulib/gl_cv_func_printf_flag_zero')
28 subdir ('gnulib/gl_cv_func_printf_flag_leftadjust')
29 subdir ('gnulib/gl_cv_func_printf_flag_grouping')
30 subdir ('gnulib/gl_cv_func_printf_directive_a')
31 subdir ('gnulib/gl_cv_func_printf_directive_f')
32 subdir ('gnulib/gl_cv_func_printf_directive_ls')
33 subdir ('gnulib/gl_cv_func_printf_long_double')
34 subdir ('gnulib/gl_cv_func_printf_infinite')
35 subdir ('gnulib/gl_cv_func_printf_infinite_long_double')
38 /* Define as a marker that can be attached to declarations that might not
39 be used. This helps to reduce warnings, such as from
40 GCC -Wunused-parameter. */
41 #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
42 # define _GL_UNUSED __attribute__ ((__unused__))
47 glib_conf.set ('gl_unused', gl_unused)
48 glib_conf.set ('gl_extern_inline', gl_extern_inline)
50 if (gl_cv_long_double_equals_double)
51 glib_conf.set ('HAVE_SAME_LONG_DOUBLE_AS_DOUBLE', 1)
54 if (gl_cv_cc_double_expbit0_word >= 0 and
55 gl_cv_cc_double_expbit0_bit >= 0)
56 glib_conf.set('DBL_EXPBIT0_WORD', gl_cv_cc_double_expbit0_word)
57 glib_conf.set('DBL_EXPBIT0_BIT', gl_cv_cc_double_expbit0_bit)
60 if not gl_cv_func_printf_precision
61 glib_conf.set('NEED_PRINTF_UNBOUNDED_PRECISION', 1)
64 if not gl_cv_func_printf_enomem
65 glib_conf.set('NEED_PRINTF_ENOMEM', 1)
68 if not gl_cv_func_printf_flag_leftadjust
69 glib_conf.set('NEED_PRINTF_FLAG_LEFTADJUST', 1)
72 if not gl_cv_func_printf_flag_zero
73 glib_conf.set('NEED_PRINTF_FLAG_ZERO', 1)
76 if not gl_cv_func_printf_flag_grouping
77 glib_conf.set('NEED_PRINTF_FLAG_GROUPING', 1)
80 if not gl_cv_func_printf_directive_a
81 glib_conf.set('NEED_PRINTF_DIRECTIVE_A', 1)
84 if not gl_cv_func_printf_directive_f
85 glib_conf.set('NEED_PRINTF_DIRECTIVE_F', 1)
88 if not gl_cv_func_printf_directive_ls
89 glib_conf.set('NEED_PRINTF_DIRECTIVE_LS', 1)
92 if (not gl_cv_func_printf_precision or
93 not gl_cv_func_printf_enomem)
94 glib_conf.set('NEED_PRINTF_DOUBLE', 1)
95 glib_conf.set('NEED_PRINTF_LONG_DOUBLE', 1)
98 if not gl_cv_func_printf_infinite
99 glib_conf.set('NEED_PRINTF_INFINITE_DOUBLE', 1)
102 if gl_cv_func_printf_long_double and gl_cv_func_printf_infinite_long_double != 'false'
103 glib_conf.set('NEED_PRINTF_INFINITE_LONG_DOUBLE', 1)
107 gnulib_objects = [gnulib_lib.extract_all_objects()]
110 glib_headers = files(
115 install_headers(glib_headers, subdir : 'glib-2.0')
117 glib_deprecated_headers = files(
118 'deprecated/gallocator.h',
119 'deprecated/gcache.h',
120 'deprecated/gcompletion.h',
121 'deprecated/gmain.h',
123 'deprecated/gthread.h',
125 install_headers(glib_deprecated_headers, subdir : 'glib-2.0/glib/deprecated')
127 glib_sub_headers = files(
128 'glib-autocleanups.h',
206 install_headers(glib_sub_headers, subdir : 'glib-2.0/glib')
208 deprecated_sources = files(
209 'deprecated/gallocator.c',
210 'deprecated/gcache.c',
211 'deprecated/gcompletion.c',
213 'deprecated/gthread-deprecated.c'
216 glib_sources = files(
293 'gvariant-serialiser.c',
294 'gvarianttypeinfo.c',
301 if host_system == 'windows'
302 glib_win_rc = configure_file(
305 configuration: glibconfig_conf,
307 glib_win_res = windows.compile_resources(glib_win_rc)
308 glib_sources += [glib_win_res]
309 glib_sources += files('gwin32.c', 'gspawn-win32.c', 'giowin32.c')
310 platform_deps = [winsock2, cc.find_library('winmm')]
311 if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
312 glib_sources += files('dirent/wdirent.c')
315 glib_sources += files('glib-unix.c', 'gspawn.c', 'giounix.c')
319 if host_system == 'darwin'
320 glib_sources += files('gosxutils.m')
323 glib_sources += files('gthread-@0@.c'.format(threads_implementation))
326 glib_dtrace_obj = dtrace_obj_gen.process('glib_probes.d')
327 glib_dtrace_hdr = dtrace_hdr_gen.process('glib_probes.d')
333 pcre_static_args = []
335 if use_pcre_static_flag
336 pcre_static_args = ['-DPCRE_STATIC']
344 pcre_objects = [libpcre.extract_all_objects()]
347 glib_c_args = ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args
348 libglib = library('glib-2.0',
349 glib_dtrace_obj, glib_dtrace_hdr,
350 sources : [deprecated_sources, glib_sources],
351 objects : [charset_lib.extract_all_objects()] + gnulib_objects + pcre_objects,
352 version : library_version,
353 soversion : soversion,
354 darwin_versions : darwin_versions,
356 # intl.lib is not compatible with SAFESEH
357 link_args : [noseh_link_args, glib_link_flags, win32_ldflags],
358 include_directories : configinc,
359 dependencies : pcre_deps + [thread_dep, libintl, librt] + libiconv + platform_deps + gnulib_libm_dependency,
360 c_args : glib_c_args,
361 objc_args : glib_c_args,
364 libglib_dep = declare_dependency(
366 # thread_dep doesn't get pulled in from libglib atm,
367 # see https://github.com/mesonbuild/meson/issues/1426
368 dependencies : [thread_dep, libintl],
369 # We sadly need to export configinc here because everyone includes <glib/*.h>
370 include_directories : [configinc, glibinc])
372 pkg.generate(libglib,
373 libraries : [libintl],
374 libraries_private : [osx_ldflags, win32_ldflags],
375 subdirs : ['glib-2.0'],
376 extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
377 variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')),
378 'glib_genmarshal=' + join_paths('${bindir}', 'glib-genmarshal'),
379 'gobject_query=' + join_paths('${bindir}', 'gobject-query'),
380 'glib_mkenums=' + join_paths('${bindir}', 'glib-mkenums')],
381 version : glib_version,
382 install_dir : glib_pkgconfigreldir,
383 filebase : 'glib-2.0',
385 description : 'C Utility Library',
388 # On Windows, glib needs a spawn helper for g_spawn* API
389 if host_system == 'windows'
390 if host_machine.cpu_family() == 'x86'
391 executable('gspawn-win32-helper', 'gspawn-win32-helper.c',
394 include_directories : configinc,
395 dependencies : [libglib_dep])
396 executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
398 c_args : ['-DHELPER_CONSOLE'],
399 include_directories : configinc,
400 dependencies : [libglib_dep])
402 executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
405 include_directories : configinc,
406 dependencies : [libglib_dep])
407 executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
409 c_args : ['-DHELPER_CONSOLE'],
410 include_directories : configinc,
411 dependencies : [libglib_dep])
414 gtester = executable('gtester', 'gtester.c',
416 c_args : ['-UG_DISABLE_ASSERT'],
417 include_directories : configinc,
418 dependencies : [libglib_dep])
421 report_conf = configuration_data()
422 report_conf.set('GLIB_VERSION', glib_version)
423 report_conf.set('PYTHON', python_name)
425 input: 'gtester-report.in',
426 output: 'gtester-report',
427 install_dir: get_option('bindir'),
428 configuration: report_conf,
429 install_mode: 'rwxr-xr-x'
432 install_data('glib_gdb.py', install_dir : join_paths(glib_pkgdatadir, 'gdb'))
434 gdb_conf = configuration_data()
435 gdb_conf.set('datadir', glib_datadir)
436 # This is also used in gobject/meson.build
437 if host_system != 'windows'
438 # XXX: We add a leading './' because glib_libdir is an absolute path and we
439 # need it to be a relative path so that join_paths appends it to the end.
440 gdb_install_dir = join_paths(glib_datadir, 'gdb', 'auto-load', './' + glib_libdir)
442 # FIXME: Cannot install on Windows because the path will contain a drive
443 # letter and colons are not allowed in paths.
444 gdb_install_dir = false
447 input: 'libglib-gdb.py.in',
448 output: 'libglib-2.0.so.@0@-gdb.py'.format(library_version),
449 configuration: gdb_conf,
450 install_dir: gdb_install_dir,
454 glib_stp = configure_file(input : 'glib.stp.in',
455 output : '@0@.stp'.format(libglib.full_path().split('/').get(-1)),
456 configuration : stp_cdata,
457 install_dir : tapset_install_dir,
461 # Don’t build the tests unless we can run them (either natively or in an exe wrapper)
462 build_tests = not meson.is_cross_build() or (meson.is_cross_build() and meson.has_exe_wrapper())