1 configure_file(input : 'glibconfig.h.in', output : 'glibconfig.h',
3 install_dir : join_paths(get_option('libdir'), 'glib-2.0/include'),
4 configuration : glibconfig_conf)
11 # TODO: gnulib_objects, pcre_objects and pcre_deps are a workaround for
12 # <https://github.com/mesonbuild/meson/issues/3934> and
13 # <https://github.com/mesonbuild/meson/issues/3937>. When we can depend
14 # on a meson version where those are fixed, revert the commit that
15 # introduced this workaround.
16 if have_good_vsnprintf and have_good_snprintf
19 gnulib_libm_dependency = []
20 glib_conf.set ('gl_unused', '')
21 glib_conf.set ('gl_extern_inline', '')
23 subdir ('gnulib/gl_extern_inline')
24 subdir ('gnulib/gl_cv_long_double_equals_double')
25 subdir ('gnulib/gl_cv_cc_double_expbit0')
26 subdir ('gnulib/gl_cv_func_printf_precision')
27 subdir ('gnulib/gl_cv_func_printf_enomem')
28 subdir ('gnulib/gl_cv_func_printf_flag_zero')
29 subdir ('gnulib/gl_cv_func_printf_flag_leftadjust')
30 subdir ('gnulib/gl_cv_func_printf_flag_grouping')
31 subdir ('gnulib/gl_cv_func_printf_directive_a')
32 subdir ('gnulib/gl_cv_func_printf_directive_f')
33 subdir ('gnulib/gl_cv_func_printf_directive_ls')
34 subdir ('gnulib/gl_cv_func_printf_long_double')
35 subdir ('gnulib/gl_cv_func_printf_infinite')
36 subdir ('gnulib/gl_cv_func_printf_infinite_long_double')
39 /* Define as a marker that can be attached to declarations that might not
40 be used. This helps to reduce warnings, such as from
41 GCC -Wunused-parameter. */
42 #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
43 # define _GL_UNUSED __attribute__ ((__unused__))
48 glib_conf.set ('gl_unused', gl_unused)
49 glib_conf.set ('gl_extern_inline', gl_extern_inline)
51 if (gl_cv_long_double_equals_double)
52 glib_conf.set ('HAVE_SAME_LONG_DOUBLE_AS_DOUBLE', 1)
55 if (gl_cv_cc_double_expbit0_word >= 0 and
56 gl_cv_cc_double_expbit0_bit >= 0)
57 glib_conf.set('DBL_EXPBIT0_WORD', gl_cv_cc_double_expbit0_word)
58 glib_conf.set('DBL_EXPBIT0_BIT', gl_cv_cc_double_expbit0_bit)
61 if not gl_cv_func_printf_precision
62 glib_conf.set('NEED_PRINTF_UNBOUNDED_PRECISION', 1)
65 if not gl_cv_func_printf_enomem
66 glib_conf.set('NEED_PRINTF_ENOMEM', 1)
69 if not gl_cv_func_printf_flag_leftadjust
70 glib_conf.set('NEED_PRINTF_FLAG_LEFTADJUST', 1)
73 if not gl_cv_func_printf_flag_zero
74 glib_conf.set('NEED_PRINTF_FLAG_ZERO', 1)
77 if not gl_cv_func_printf_flag_grouping
78 glib_conf.set('NEED_PRINTF_FLAG_GROUPING', 1)
81 if not gl_cv_func_printf_directive_a
82 glib_conf.set('NEED_PRINTF_DIRECTIVE_A', 1)
85 if not gl_cv_func_printf_directive_f
86 glib_conf.set('NEED_PRINTF_DIRECTIVE_F', 1)
89 if not gl_cv_func_printf_directive_ls
90 glib_conf.set('NEED_PRINTF_DIRECTIVE_LS', 1)
93 if (not gl_cv_func_printf_precision or
94 not gl_cv_func_printf_enomem)
95 glib_conf.set('NEED_PRINTF_DOUBLE', 1)
96 glib_conf.set('NEED_PRINTF_LONG_DOUBLE', 1)
99 if not gl_cv_func_printf_infinite
100 glib_conf.set('NEED_PRINTF_INFINITE_DOUBLE', 1)
103 if gl_cv_func_printf_long_double and gl_cv_func_printf_infinite_long_double != 'false'
104 glib_conf.set('NEED_PRINTF_INFINITE_LONG_DOUBLE', 1)
108 gnulib_objects = [gnulib_lib.extract_all_objects()]
111 glib_headers = files(
116 install_headers(glib_headers, subdir : 'glib-2.0')
118 glib_deprecated_headers = files(
119 'deprecated/gallocator.h',
120 'deprecated/gcache.h',
121 'deprecated/gcompletion.h',
122 'deprecated/gmain.h',
124 'deprecated/gthread.h',
126 install_headers(glib_deprecated_headers, subdir : 'glib-2.0/glib/deprecated')
128 glib_sub_headers = files(
129 'glib-autocleanups.h',
207 install_headers(glib_sub_headers, subdir : 'glib-2.0/glib')
209 deprecated_sources = files(
210 'deprecated/gallocator.c',
211 'deprecated/gcache.c',
212 'deprecated/gcompletion.c',
214 'deprecated/gthread-deprecated.c'
217 glib_sources = files(
294 'gvariant-serialiser.c',
295 'gvarianttypeinfo.c',
302 if host_system == 'windows'
303 glib_win_rc = configure_file(
306 configuration: glibconfig_conf,
308 glib_win_res = windows.compile_resources(glib_win_rc)
309 glib_sources += [glib_win_res]
310 glib_sources += files('gwin32.c', 'gspawn-win32.c', 'giowin32.c')
311 platform_deps = [winsock2, cc.find_library('winmm')]
312 if cc.get_id() == 'msvc'
313 glib_sources += files('dirent/wdirent.c')
316 glib_sources += files('glib-unix.c', 'gspawn.c', 'giounix.c')
320 if host_system == 'darwin'
321 glib_sources += files('gosxutils.m')
324 glib_sources += files('gthread-@0@.c'.format(threads_implementation))
327 glib_dtrace_obj = dtrace_obj_gen.process('glib_probes.d')
328 glib_dtrace_hdr = dtrace_hdr_gen.process('glib_probes.d')
334 pcre_static_args = []
336 if use_pcre_static_flag
337 pcre_static_args = ['-DPCRE_STATIC']
345 pcre_objects = [libpcre.extract_all_objects()]
348 glib_c_args = ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args
349 libglib = library('glib-2.0',
350 glib_dtrace_obj, glib_dtrace_hdr,
351 sources : [deprecated_sources, glib_sources],
352 objects : [charset_lib.extract_all_objects()] + gnulib_objects + pcre_objects,
353 version : library_version,
354 soversion : soversion,
355 darwin_versions : darwin_versions,
357 # intl.lib is not compatible with SAFESEH
358 link_args : [noseh_link_args, glib_link_flags, win32_ldflags],
359 include_directories : configinc,
360 dependencies : pcre_deps + [thread_dep, libintl, librt] + libiconv + platform_deps + gnulib_libm_dependency,
361 c_args : glib_c_args,
362 objc_args : glib_c_args,
365 libglib_dep = declare_dependency(
367 # thread_dep doesn't get pulled in from libglib atm,
368 # see https://github.com/mesonbuild/meson/issues/1426
369 dependencies : [thread_dep, libintl],
370 # We sadly need to export configinc here because everyone includes <glib/*.h>
371 include_directories : [configinc, glibinc])
373 pkg.generate(libglib,
374 libraries : [libintl],
375 libraries_private : [osx_ldflags, win32_ldflags],
376 subdirs : ['glib-2.0'],
377 extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
378 variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')),
379 'glib_genmarshal=' + join_paths('${bindir}', 'glib-genmarshal'),
380 'gobject_query=' + join_paths('${bindir}', 'gobject-query'),
381 'glib_mkenums=' + join_paths('${bindir}', 'glib-mkenums')],
382 version : glib_version,
383 install_dir : glib_pkgconfigreldir,
384 filebase : 'glib-2.0',
386 description : 'C Utility Library',
389 # On Windows, glib needs a spawn helper for g_spawn* API
390 if host_system == 'windows'
391 if host_machine.cpu_family() == 'x86'
392 executable('gspawn-win32-helper', 'gspawn-win32-helper.c',
395 include_directories : configinc,
396 dependencies : [libglib_dep])
397 executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
399 c_args : ['-DHELPER_CONSOLE'],
400 include_directories : configinc,
401 dependencies : [libglib_dep])
403 executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
406 include_directories : configinc,
407 dependencies : [libglib_dep])
408 executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
410 c_args : ['-DHELPER_CONSOLE'],
411 include_directories : configinc,
412 dependencies : [libglib_dep])
415 gtester = executable('gtester', 'gtester.c',
417 c_args : ['-UG_DISABLE_ASSERT'],
418 include_directories : configinc,
419 dependencies : [libglib_dep])
422 report_conf = configuration_data()
423 report_conf.set('GLIB_VERSION', glib_version)
424 report_conf.set('PYTHON', python_name)
426 input: 'gtester-report.in',
427 output: 'gtester-report',
428 install_dir: get_option('bindir'),
429 configuration: report_conf,
430 install_mode: 'rwxr-xr-x'
433 install_data('glib_gdb.py', install_dir : join_paths(glib_pkgdatadir, 'gdb'))
435 gdb_conf = configuration_data()
436 gdb_conf.set('datadir', glib_datadir)
437 # This is also used in gobject/meson.build
438 if host_system != 'windows'
439 # XXX: We add a leading './' because glib_libdir is an absolute path and we
440 # need it to be a relative path so that join_paths appends it to the end.
441 gdb_install_dir = join_paths(glib_datadir, 'gdb', 'auto-load', './' + glib_libdir)
443 # FIXME: Cannot install on Windows because the path will contain a drive
444 # letter and colons are not allowed in paths.
445 gdb_install_dir = false
448 input: 'libglib-gdb.py.in',
449 output: 'libglib-2.0.so.@0@-gdb.py'.format(library_version),
450 configuration: gdb_conf,
451 install_dir: gdb_install_dir,
455 glib_stp = configure_file(input : 'glib.stp.in',
456 output : '@0@.stp'.format(libglib.full_path().split('/').get(-1)),
457 configuration : stp_cdata,
458 install_dir : tapset_install_dir,
462 # Don’t build the tests unless we can run them (either natively or in an exe wrapper)
463 build_tests = not meson.is_cross_build() or (meson.is_cross_build() and meson.has_exe_wrapper())