| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | project('glib', 'c', 'cpp',
 | 
					
						
							| 
									
										
										
										
											2021-09-17 11:15:53 +01:00
										 |  |  |  |   version : '2.70.0',
 | 
					
						
							| 
									
										
										
										
											2019-06-17 16:55:24 +01:00
										 |  |  |  |   # NOTE: We keep this pinned at 0.49 because that's what Debian 10 ships
 | 
					
						
							|  |  |  |  |   meson_version : '>= 0.49.2',
 | 
					
						
							| 
									
										
										
										
											2016-12-09 14:30:22 -05:00
										 |  |  |  |   default_options : [
 | 
					
						
							| 
									
										
										
										
											2018-03-28 21:37:38 -04:00
										 |  |  |  |     'buildtype=debugoptimized',
 | 
					
						
							| 
									
										
										
										
											2016-12-09 14:30:22 -05:00
										 |  |  |  |     'warning_level=1',
 | 
					
						
							| 
									
										
										
										
											2019-08-13 18:34:04 +02:00
										 |  |  |  |     'c_std=gnu99'
 | 
					
						
							| 
									
										
										
										
											2016-12-09 14:30:22 -05:00
										 |  |  |  |   ]
 | 
					
						
							|  |  |  |  | )
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | cc = meson.get_compiler('c')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | cxx = meson.get_compiler('cpp')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:25 -04:00
										 |  |  |  | cc_can_run = not meson.is_cross_build() or meson.has_exe_wrapper()
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-20 10:15:02 +08:00
										 |  |  |  | if cc.get_argument_syntax() == 'msvc'
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   # Ignore several spurious warnings for things glib does very commonly
 | 
					
						
							| 
									
										
										
										
											2021-03-20 10:15:02 +08:00
										 |  |  |  |   # (also for clang-cl)
 | 
					
						
							|  |  |  |  |   add_project_arguments('/FImsvc_recommended_pragmas.h',language : 'c')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | if cc.get_id() == 'msvc'
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
 | 
					
						
							|  |  |  |  |   # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
 | 
					
						
							|  |  |  |  |   # NOTE: Only add warnings here if you are sure they're spurious
 | 
					
						
							| 
									
										
										
										
											2017-07-17 12:49:24 +08:00
										 |  |  |  |   add_project_arguments('/wd4035', '/wd4715', '/wd4116',
 | 
					
						
							| 
									
										
										
										
											2021-03-20 10:15:02 +08:00
										 |  |  |  |     '/wd4046', '/wd4068', '/wo4090',language : 'c')
 | 
					
						
							|  |  |  |  |   # Set the input and exec encoding to utf-8, like is the default with GCC
 | 
					
						
							|  |  |  |  |   add_project_arguments(cc.get_supported_arguments(['/utf-8']), language: 'c')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   # Disable SAFESEH with MSVC for plugins and libs that use external deps that
 | 
					
						
							|  |  |  |  |   # are built with MinGW
 | 
					
						
							|  |  |  |  |   noseh_link_args = ['/SAFESEH:NO']
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   noseh_link_args = []
 | 
					
						
							|  |  |  |  |   # -mms-bitfields vs -fnative-struct ?
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | host_system = host_machine.system()
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-29 00:31:35 +05:30
										 |  |  |  | if host_system == 'darwin'
 | 
					
						
							|  |  |  |  |   ios_test_code = '''#include <TargetConditionals.h>
 | 
					
						
							|  |  |  |  |   #if ! TARGET_OS_IPHONE
 | 
					
						
							|  |  |  |  |   #error "Not iOS/tvOS/watchOS/iPhoneSimulator"
 | 
					
						
							|  |  |  |  |   #endif'''
 | 
					
						
							|  |  |  |  |   if cc.compiles(ios_test_code, name : 'building for iOS')
 | 
					
						
							|  |  |  |  |     host_system = 'ios'
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | glib_version = meson.project_version()
 | 
					
						
							| 
									
										
										
										
											2016-12-07 05:28:33 -05:00
										 |  |  |  | glib_api_version = '2.0'
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | version_arr = glib_version.split('.')
 | 
					
						
							| 
									
										
										
										
											2017-07-14 13:56:02 +01:00
										 |  |  |  | major_version = version_arr[0].to_int()
 | 
					
						
							|  |  |  |  | minor_version = version_arr[1].to_int()
 | 
					
						
							|  |  |  |  | micro_version = version_arr[2].to_int()
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | interface_age = minor_version.is_odd() ? 0 : micro_version
 | 
					
						
							|  |  |  |  | binary_age = 100 * minor_version + micro_version
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | soversion = 0
 | 
					
						
							|  |  |  |  | # Maintain compatibility with previous libtool versioning
 | 
					
						
							|  |  |  |  | # current = minor * 100 + micro
 | 
					
						
							| 
									
										
										
										
											2018-08-29 15:36:23 +05:30
										 |  |  |  | current = binary_age - interface_age
 | 
					
						
							|  |  |  |  | library_version = '@0@.@1@.@2@'.format(soversion, current, interface_age)
 | 
					
						
							|  |  |  |  | darwin_versions = [current + 1, '@0@.@1@'.format(current + 1, interface_age)]
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | configinc = include_directories('.')
 | 
					
						
							|  |  |  |  | glibinc = include_directories('glib')
 | 
					
						
							|  |  |  |  | gobjectinc = include_directories('gobject')
 | 
					
						
							|  |  |  |  | gmoduleinc = include_directories('gmodule')
 | 
					
						
							|  |  |  |  | gioinc = include_directories('gio')
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | glib_prefix = get_option('prefix')
 | 
					
						
							| 
									
										
										
										
											2017-07-17 10:54:28 +01:00
										 |  |  |  | glib_bindir = join_paths(glib_prefix, get_option('bindir'))
 | 
					
						
							| 
									
										
										
										
											2016-12-09 14:30:22 -05:00
										 |  |  |  | glib_libdir = join_paths(glib_prefix, get_option('libdir'))
 | 
					
						
							| 
									
										
										
										
											2018-07-16 13:39:44 -04:00
										 |  |  |  | glib_libexecdir = join_paths(glib_prefix, get_option('libexecdir'))
 | 
					
						
							| 
									
										
										
										
											2016-12-09 14:30:22 -05:00
										 |  |  |  | glib_datadir = join_paths(glib_prefix, get_option('datadir'))
 | 
					
						
							|  |  |  |  | glib_pkgdatadir = join_paths(glib_datadir, 'glib-2.0')
 | 
					
						
							|  |  |  |  | glib_includedir = join_paths(glib_prefix, get_option('includedir'))
 | 
					
						
							| 
									
										
										
										
											2020-02-07 16:34:13 +00:00
										 |  |  |  | if get_option('gio_module_dir') != ''
 | 
					
						
							|  |  |  |  |   glib_giomodulesdir = join_paths(glib_prefix, get_option('gio_module_dir'))
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							| 
									
										
										
										
											2017-11-28 10:44:04 -05:00
										 |  |  |  |   glib_giomodulesdir = join_paths(glib_libdir, 'gio', 'modules')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-14 13:56:47 +01:00
										 |  |  |  | glib_pkgconfigreldir = join_paths(glib_libdir, 'pkgconfig')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-07 16:34:13 +00:00
										 |  |  |  | if get_option('charsetalias_dir') != ''
 | 
					
						
							|  |  |  |  |   glib_charsetaliasdir = join_paths(glib_prefix, get_option('charsetalias_dir'))
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   glib_charsetaliasdir = glib_libdir
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-24 11:58:49 +00:00
										 |  |  |  | glib_localstatedir = get_option('localstatedir')
 | 
					
						
							|  |  |  |  | if not glib_localstatedir.startswith('/')
 | 
					
						
							|  |  |  |  |   # See https://mesonbuild.com/Builtin-options.html#directories
 | 
					
						
							|  |  |  |  |   glib_localstatedir = join_paths(glib_prefix, glib_localstatedir)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-16 13:39:44 -04:00
										 |  |  |  | installed_tests_metadir = join_paths(glib_datadir, 'installed-tests', meson.project_name())
 | 
					
						
							|  |  |  |  | installed_tests_execdir = join_paths(glib_libexecdir, 'installed-tests', meson.project_name())
 | 
					
						
							|  |  |  |  | installed_tests_enabled = get_option('installed_tests')
 | 
					
						
							|  |  |  |  | installed_tests_template = files('template.test.in')
 | 
					
						
							| 
									
										
										
										
											2018-09-23 13:44:15 -04:00
										 |  |  |  | installed_tests_template_tap = files('template-tap.test.in')
 | 
					
						
							| 
									
										
										
										
											2018-07-16 13:39:44 -04:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-01 19:51:48 +01:00
										 |  |  |  | # Don’t build the tests unless we can run them (either natively, in an exe wrapper, or by installing them for later use)
 | 
					
						
							| 
									
										
										
										
											2019-04-27 17:04:26 +02:00
										 |  |  |  | build_tests = get_option('tests') and (not meson.is_cross_build() or (meson.is_cross_build() and meson.has_exe_wrapper()) or installed_tests_enabled)
 | 
					
						
							| 
									
										
										
										
											2019-10-01 19:51:48 +01:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-09 21:29:13 +01:00
										 |  |  |  | add_project_arguments('-D_GNU_SOURCE', language: 'c')
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-19 23:17:11 +01:00
										 |  |  |  | if host_system == 'qnx'
 | 
					
						
							|  |  |  |  |   add_project_arguments('-D_QNX_SOURCE', language: 'c')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 17:49:05 +00:00
										 |  |  |  | # Disable strict aliasing;
 | 
					
						
							|  |  |  |  | # see https://bugzilla.gnome.org/show_bug.cgi?id=791622
 | 
					
						
							| 
									
										
										
										
											2018-01-10 16:59:46 +00:00
										 |  |  |  | if cc.has_argument('-fno-strict-aliasing')
 | 
					
						
							|  |  |  |  |   add_project_arguments('-fno-strict-aliasing', language: 'c')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2017-12-21 17:49:05 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | ########################
 | 
					
						
							|  |  |  |  | # Configuration begins #
 | 
					
						
							|  |  |  |  | ########################
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | glib_conf = configuration_data()
 | 
					
						
							|  |  |  |  | glibconfig_conf = configuration_data()
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # accumulated list of defines as we check for them, so we can easily
 | 
					
						
							|  |  |  |  | # use them later in test programs (autoconf does this automatically)
 | 
					
						
							|  |  |  |  | glib_conf_prefix = ''
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | glib_conf.set('GLIB_MAJOR_VERSION', major_version)
 | 
					
						
							|  |  |  |  | glib_conf.set('GLIB_MINOR_VERSION', minor_version)
 | 
					
						
							|  |  |  |  | glib_conf.set('GLIB_MICRO_VERSION', micro_version)
 | 
					
						
							| 
									
										
										
										
											2017-07-14 13:56:02 +01:00
										 |  |  |  | glib_conf.set('GLIB_INTERFACE_AGE', interface_age)
 | 
					
						
							|  |  |  |  | glib_conf.set('GLIB_BINARY_AGE', binary_age)
 | 
					
						
							| 
									
										
										
										
											2016-12-09 14:30:22 -05:00
										 |  |  |  | glib_conf.set_quoted('GETTEXT_PACKAGE', 'glib20')
 | 
					
						
							| 
									
										
										
										
											2018-05-31 23:44:02 +02:00
										 |  |  |  | glib_conf.set_quoted('PACKAGE_BUGREPORT', 'https://gitlab.gnome.org/GNOME/glib/issues/new')
 | 
					
						
							| 
									
										
										
										
											2016-12-09 14:30:22 -05:00
										 |  |  |  | glib_conf.set_quoted('PACKAGE_NAME', 'glib')
 | 
					
						
							|  |  |  |  | glib_conf.set_quoted('PACKAGE_STRING', 'glib @0@'.format(meson.project_version()))
 | 
					
						
							|  |  |  |  | glib_conf.set_quoted('PACKAGE_TARNAME', 'glib')
 | 
					
						
							|  |  |  |  | glib_conf.set_quoted('PACKAGE_URL', '')
 | 
					
						
							|  |  |  |  | glib_conf.set_quoted('PACKAGE_VERSION', meson.project_version())
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | glib_conf.set('ENABLE_NLS', 1)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-27 21:21:15 +02:00
										 |  |  |  | # used by the .rc.in files
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('LT_CURRENT_MINUS_AGE', soversion)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | glib_conf.set('_GNU_SOURCE', 1)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if host_system == 'windows'
 | 
					
						
							|  |  |  |  |   # Poll doesn't work on devices on Windows
 | 
					
						
							|  |  |  |  |   glib_conf.set('BROKEN_POLL', true)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-10 00:22:51 +08:00
										 |  |  |  | if host_system == 'windows' and cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl'
 | 
					
						
							| 
									
										
										
										
											2018-08-05 21:56:38 +02:00
										 |  |  |  |   # FIXME: Ideally we shouldn't depend on this on Windows and should use
 | 
					
						
							|  |  |  |  |   # 64 bit capable Windows API that also works with MSVC.
 | 
					
						
							|  |  |  |  |   # The autotools build did set this for mingw and while meson sets it
 | 
					
						
							|  |  |  |  |   # for gcc/clang by default, it doesn't do so on Windows.
 | 
					
						
							|  |  |  |  |   glib_conf.set('_FILE_OFFSET_BITS', 64)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-23 18:26:01 +00:00
										 |  |  |  | # Check for GNU visibility attributes
 | 
					
						
							|  |  |  |  | g_have_gnuc_visibility = cc.compiles('''
 | 
					
						
							|  |  |  |  |   void
 | 
					
						
							|  |  |  |  |   __attribute__ ((visibility ("hidden")))
 | 
					
						
							|  |  |  |  |        f_hidden (void)
 | 
					
						
							|  |  |  |  |   {
 | 
					
						
							|  |  |  |  |   }
 | 
					
						
							|  |  |  |  |   void
 | 
					
						
							|  |  |  |  |   __attribute__ ((visibility ("internal")))
 | 
					
						
							|  |  |  |  |        f_internal (void)
 | 
					
						
							|  |  |  |  |   {
 | 
					
						
							|  |  |  |  |   }
 | 
					
						
							|  |  |  |  |   void
 | 
					
						
							|  |  |  |  |   __attribute__ ((visibility ("default")))
 | 
					
						
							|  |  |  |  |        f_default (void)
 | 
					
						
							|  |  |  |  |   {
 | 
					
						
							|  |  |  |  |   }
 | 
					
						
							|  |  |  |  |   int main (void)
 | 
					
						
							|  |  |  |  |   {
 | 
					
						
							|  |  |  |  |     f_hidden();
 | 
					
						
							|  |  |  |  |     f_internal();
 | 
					
						
							|  |  |  |  |     f_default();
 | 
					
						
							|  |  |  |  |     return 0;
 | 
					
						
							|  |  |  |  |   }
 | 
					
						
							|  |  |  |  |   ''',
 | 
					
						
							|  |  |  |  |   # Not supported by MSVC, but MSVC also won't support visibility,
 | 
					
						
							|  |  |  |  |   # so it's OK to pass -Werror explicitly. Replace with
 | 
					
						
							|  |  |  |  |   # override_options : 'werror=true' once that is supported
 | 
					
						
							|  |  |  |  |   args: ['-Werror'],
 | 
					
						
							|  |  |  |  |   name : 'GNU C visibility attributes test')
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | if g_have_gnuc_visibility
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('G_HAVE_GNUC_VISIBILITY', '1')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | # Detect and set symbol visibility
 | 
					
						
							| 
									
										
										
										
											2017-02-16 09:52:58 +00:00
										 |  |  |  | glib_hidden_visibility_args = []
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if get_option('default_library') != 'static'
 | 
					
						
							| 
									
										
										
										
											2019-03-20 21:10:58 +00:00
										 |  |  |  |   if host_system == 'windows' or host_system == 'cygwin'
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |     glib_conf.set('DLL_EXPORT', true)
 | 
					
						
							| 
									
										
										
										
											2019-07-10 00:22:51 +08:00
										 |  |  |  |     if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |       glib_conf.set('_GLIB_EXTERN', '__declspec(dllexport) extern')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 06:34:47 +05:30
										 |  |  |  |     elif cc.has_argument('-fvisibility=hidden')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |       glib_conf.set('_GLIB_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) extern')
 | 
					
						
							| 
									
										
										
										
											2017-02-16 09:52:58 +00:00
										 |  |  |  |       glib_hidden_visibility_args = ['-fvisibility=hidden']
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |     endif
 | 
					
						
							| 
									
										
										
										
											2016-12-21 06:34:47 +05:30
										 |  |  |  |   elif cc.has_argument('-fvisibility=hidden')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |     glib_conf.set('_GLIB_EXTERN', '__attribute__((visibility("default"))) extern')
 | 
					
						
							| 
									
										
										
										
											2017-02-16 09:52:58 +00:00
										 |  |  |  |     glib_hidden_visibility_args = ['-fvisibility=hidden']
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   endif
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-15 11:01:04 +00:00
										 |  |  |  | if get_option('default_library') == 'static'
 | 
					
						
							| 
									
										
										
										
											2017-07-16 16:41:02 +02:00
										 |  |  |  |     glibconfig_conf.set('GLIB_STATIC_COMPILATION', '1')
 | 
					
						
							|  |  |  |  |     glibconfig_conf.set('GOBJECT_STATIC_COMPILATION', '1')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-20 19:05:19 +00:00
										 |  |  |  | # Cygwin glib port maintainers made it clear
 | 
					
						
							|  |  |  |  | # (via the patches they apply) that they want no
 | 
					
						
							|  |  |  |  | # part of glib W32 code, therefore we do not define
 | 
					
						
							|  |  |  |  | # G_PLATFORM_WIN32 for host_system == 'cygwin'.
 | 
					
						
							|  |  |  |  | # This makes G_PLATFORM_WIN32 a synonym for
 | 
					
						
							|  |  |  |  | # G_OS_WIN32.
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if host_system == 'windows'
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   glib_os = '''#define G_OS_WIN32
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | #define G_PLATFORM_WIN32'''
 | 
					
						
							| 
									
										
										
										
											2019-03-20 19:05:19 +00:00
										 |  |  |  | elif host_system == 'cygwin'
 | 
					
						
							| 
									
										
										
										
											2019-05-21 18:54:34 +02:00
										 |  |  |  |   glib_os = '''#define G_OS_UNIX
 | 
					
						
							| 
									
										
										
										
											2019-03-20 19:05:19 +00:00
										 |  |  |  | #define G_WITH_CYGWIN'''
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | else
 | 
					
						
							|  |  |  |  |   glib_os = '#define G_OS_UNIX'
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('glib_os', glib_os)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-12 17:42:27 +05:30
										 |  |  |  | # We need to know the CRT being used to determine what .lib files we need on
 | 
					
						
							|  |  |  |  | # Visual Studio for dependencies that don't normally come with pkg-config files
 | 
					
						
							|  |  |  |  | vs_crt = 'release'
 | 
					
						
							|  |  |  |  | vs_crt_opt = get_option('b_vscrt')
 | 
					
						
							|  |  |  |  | if vs_crt_opt in ['mdd', 'mtd']
 | 
					
						
							|  |  |  |  |   vs_crt = 'debug'
 | 
					
						
							|  |  |  |  | elif vs_crt_opt == 'from_buildtype'
 | 
					
						
							|  |  |  |  |   if get_option('buildtype') == 'debug'
 | 
					
						
							|  |  |  |  |     vs_crt = 'debug'
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2017-08-15 17:08:47 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-05 00:36:50 +05:30
										 |  |  |  | # Use debug/optimization flags to determine whether to enable debug or disable
 | 
					
						
							|  |  |  |  | # cast checks
 | 
					
						
							| 
									
										
										
										
											2018-03-28 21:37:38 -04:00
										 |  |  |  | glib_debug_cflags = []
 | 
					
						
							| 
									
										
										
										
											2021-01-20 00:37:22 +01:00
										 |  |  |  | glib_debug = get_option('glib_debug')
 | 
					
						
							|  |  |  |  | if glib_debug.enabled() or (glib_debug.auto() and get_option('debug'))
 | 
					
						
							| 
									
										
										
										
											2018-03-28 21:37:38 -04:00
										 |  |  |  |   glib_debug_cflags += ['-DG_ENABLE_DEBUG']
 | 
					
						
							| 
									
										
										
										
											2020-03-05 00:36:50 +05:30
										 |  |  |  |   message('Enabling various debug infrastructure')
 | 
					
						
							|  |  |  |  | elif get_option('optimization') in ['2', '3', 's']
 | 
					
						
							| 
									
										
										
										
											2018-03-28 21:37:38 -04:00
										 |  |  |  |   glib_debug_cflags += ['-DG_DISABLE_CAST_CHECKS']
 | 
					
						
							| 
									
										
										
										
											2020-03-05 00:36:50 +05:30
										 |  |  |  |   message('Disabling cast checks')
 | 
					
						
							| 
									
										
										
										
											2018-03-28 21:37:38 -04:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 15:14:31 -04:00
										 |  |  |  | if not get_option('glib_assert')
 | 
					
						
							|  |  |  |  |   glib_debug_cflags += ['-DG_DISABLE_ASSERT']
 | 
					
						
							|  |  |  |  |   message('Disabling GLib asserts')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | if not get_option('glib_checks')
 | 
					
						
							|  |  |  |  |   glib_debug_cflags += ['-DG_DISABLE_CHECKS']
 | 
					
						
							|  |  |  |  |   message('Disabling GLib checks')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-28 21:37:38 -04:00
										 |  |  |  | add_project_arguments(glib_debug_cflags, language: 'c')
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # check for header files
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | headers = [
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'alloca.h',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'crt_externs.h',
 | 
					
						
							|  |  |  |  |   'dirent.h', # MSC does not come with this by default
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'float.h',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'fstab.h',
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'grp.h',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'inttypes.h',
 | 
					
						
							|  |  |  |  |   'limits.h',
 | 
					
						
							|  |  |  |  |   'linux/magic.h',
 | 
					
						
							|  |  |  |  |   'locale.h',
 | 
					
						
							|  |  |  |  |   'mach/mach_time.h',
 | 
					
						
							|  |  |  |  |   'memory.h',
 | 
					
						
							|  |  |  |  |   'mntent.h',
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'poll.h',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'pwd.h',
 | 
					
						
							|  |  |  |  |   'sched.h',
 | 
					
						
							| 
									
										
										
										
											2018-09-24 01:36:35 -05:00
										 |  |  |  |   'spawn.h',
 | 
					
						
							| 
									
										
										
										
											2017-07-21 19:40:48 +02:00
										 |  |  |  |   'stdatomic.h',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'stdint.h',
 | 
					
						
							|  |  |  |  |   'stdlib.h',
 | 
					
						
							|  |  |  |  |   'string.h',
 | 
					
						
							|  |  |  |  |   'strings.h',
 | 
					
						
							| 
									
										
										
										
											2018-05-31 11:31:23 +02:00
										 |  |  |  |   'sys/auxv.h',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'sys/event.h',
 | 
					
						
							|  |  |  |  |   'sys/filio.h',
 | 
					
						
							|  |  |  |  |   'sys/inotify.h',
 | 
					
						
							|  |  |  |  |   'sys/mkdev.h',
 | 
					
						
							|  |  |  |  |   'sys/mntctl.h',
 | 
					
						
							|  |  |  |  |   'sys/mnttab.h',
 | 
					
						
							|  |  |  |  |   'sys/mount.h',
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'sys/param.h',
 | 
					
						
							|  |  |  |  |   'sys/resource.h',
 | 
					
						
							|  |  |  |  |   'sys/select.h',
 | 
					
						
							|  |  |  |  |   'sys/statfs.h',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'sys/stat.h',
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'sys/statvfs.h',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'sys/sysctl.h',
 | 
					
						
							| 
									
										
										
										
											2017-07-17 12:49:24 +08:00
										 |  |  |  |   'sys/time.h', # MSC does not come with this by default
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'sys/times.h',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'sys/types.h',
 | 
					
						
							|  |  |  |  |   'sys/uio.h',
 | 
					
						
							|  |  |  |  |   'sys/vfs.h',
 | 
					
						
							|  |  |  |  |   'sys/vfstab.h',
 | 
					
						
							|  |  |  |  |   'sys/vmount.h',
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'sys/wait.h',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'termios.h',
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'unistd.h',
 | 
					
						
							|  |  |  |  |   'values.h',
 | 
					
						
							| 
									
										
										
										
											2019-05-22 19:26:41 +02:00
										 |  |  |  |   'wchar.h',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'xlocale.h',
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | ]
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | foreach h : headers
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   if cc.has_header(h)
 | 
					
						
							|  |  |  |  |     define = 'HAVE_' + h.underscorify().to_upper()
 | 
					
						
							|  |  |  |  |     glib_conf.set(define, 1)
 | 
					
						
							|  |  |  |  |     glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(define)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   endif
 | 
					
						
							|  |  |  |  | endforeach
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-26 12:14:35 +08:00
										 |  |  |  | # FIXME: Use cc.check_header from Meson 0.47.
 | 
					
						
							|  |  |  |  | # FreeBSD includes a malloc.h which always throw compilation error.
 | 
					
						
							|  |  |  |  | if cc.compiles('#include <malloc.h>', name : 'malloc.h')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_MALLOC_H', 1)
 | 
					
						
							|  |  |  |  |   glib_conf_prefix = glib_conf_prefix + '#define HAVE_MALLOC_H 1\n'
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  | if cc.has_header('linux/netlink.h')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_NETLINK', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-14 16:04:37 +01:00
										 |  |  |  | # Is statx() supported? Android systems don’t reliably support it as of August 2020.
 | 
					
						
							|  |  |  |  | statx_code = '''
 | 
					
						
							|  |  |  |  |   #ifndef _GNU_SOURCE
 | 
					
						
							|  |  |  |  |   #define _GNU_SOURCE
 | 
					
						
							|  |  |  |  |   #endif
 | 
					
						
							|  |  |  |  |   #include <sys/stat.h>
 | 
					
						
							|  |  |  |  |   #include <fcntl.h>
 | 
					
						
							|  |  |  |  |   int main (void)
 | 
					
						
							|  |  |  |  |   {
 | 
					
						
							|  |  |  |  |     struct statx stat_buf;
 | 
					
						
							|  |  |  |  |     return statx (AT_FDCWD, "/", AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS | STATX_BTIME, &stat_buf);
 | 
					
						
							|  |  |  |  |   }
 | 
					
						
							|  |  |  |  |   '''
 | 
					
						
							|  |  |  |  | if host_system != 'android' and cc.compiles(statx_code, name : 'statx() test')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_STATX', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | if glib_conf.has('HAVE_LOCALE_H')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   if cc.has_header_symbol('locale.h', 'LC_MESSAGES')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |     glib_conf.set('HAVE_LC_MESSAGES', 1)
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | struct_stat_blkprefix = '''
 | 
					
						
							|  |  |  |  | #include <sys/types.h>
 | 
					
						
							|  |  |  |  | #include <sys/stat.h>
 | 
					
						
							|  |  |  |  | #ifdef HAVE_UNISTD_H
 | 
					
						
							|  |  |  |  | #include <unistd.h>
 | 
					
						
							|  |  |  |  | #endif
 | 
					
						
							|  |  |  |  | #ifdef HAVE_SYS_STATFS_H
 | 
					
						
							|  |  |  |  | #include <sys/statfs.h>
 | 
					
						
							|  |  |  |  | #endif
 | 
					
						
							|  |  |  |  | #ifdef HAVE_SYS_PARAM_H
 | 
					
						
							|  |  |  |  | #include <sys/param.h>
 | 
					
						
							|  |  |  |  | #endif
 | 
					
						
							|  |  |  |  | #ifdef HAVE_SYS_MOUNT_H
 | 
					
						
							|  |  |  |  | #include <sys/mount.h>
 | 
					
						
							|  |  |  |  | #endif
 | 
					
						
							|  |  |  |  | '''
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | struct_members = [
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   [ 'stat', 'st_mtimensec' ],
 | 
					
						
							|  |  |  |  |   [ 'stat', 'st_mtim.tv_nsec' ],
 | 
					
						
							|  |  |  |  |   [ 'stat', 'st_atimensec' ],
 | 
					
						
							|  |  |  |  |   [ 'stat', 'st_atim.tv_nsec' ],
 | 
					
						
							|  |  |  |  |   [ 'stat', 'st_ctimensec' ],
 | 
					
						
							|  |  |  |  |   [ 'stat', 'st_ctim.tv_nsec' ],
 | 
					
						
							|  |  |  |  |   [ 'stat', 'st_birthtime' ],
 | 
					
						
							|  |  |  |  |   [ 'stat', 'st_birthtimensec' ],
 | 
					
						
							|  |  |  |  |   [ 'stat', 'st_birthtim' ],
 | 
					
						
							|  |  |  |  |   [ 'stat', 'st_birthtim.tv_nsec' ],
 | 
					
						
							|  |  |  |  |   [ 'stat', 'st_blksize', struct_stat_blkprefix ],
 | 
					
						
							|  |  |  |  |   [ 'stat', 'st_blocks', struct_stat_blkprefix ],
 | 
					
						
							|  |  |  |  |   [ 'statfs', 'f_fstypename', struct_stat_blkprefix ],
 | 
					
						
							|  |  |  |  |   [ 'statfs', 'f_bavail', struct_stat_blkprefix ],
 | 
					
						
							|  |  |  |  |   [ 'dirent', 'd_type', '''#include <sys/types.h>
 | 
					
						
							|  |  |  |  |                            #include <dirent.h>''' ],
 | 
					
						
							| 
									
										
										
										
											2018-06-14 14:32:49 -04:00
										 |  |  |  |   [ 'statvfs', 'f_basetype', '#include <sys/statvfs.h>' ],
 | 
					
						
							|  |  |  |  |   [ 'statvfs', 'f_fstypename', '#include <sys/statvfs.h>' ],
 | 
					
						
							|  |  |  |  |   [ 'tm', 'tm_gmtoff', '#include <time.h>' ],
 | 
					
						
							|  |  |  |  |   [ 'tm', '__tm_gmtoff', '#include <time.h>' ],
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | ]
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | foreach m : struct_members
 | 
					
						
							|  |  |  |  |   header_check_prefix = glib_conf_prefix
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   if m.length() == 3
 | 
					
						
							|  |  |  |  |     header_check_prefix = header_check_prefix + m[2]
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   else
 | 
					
						
							|  |  |  |  |     header_check_prefix = header_check_prefix + '#include <sys/stat.h>'
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  |   if cc.has_member('struct ' + m[0], m[1], prefix : header_check_prefix)
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |     define = 'HAVE_STRUCT_@0@_@1@'.format(m[0].to_upper(), m[1].underscorify().to_upper())
 | 
					
						
							|  |  |  |  |     glib_conf.set(define, 1)
 | 
					
						
							|  |  |  |  |     glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(define)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   else
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  | endforeach
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 19:14:08 +02:00
										 |  |  |  | # Compiler flags
 | 
					
						
							|  |  |  |  | if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
 | 
					
						
							| 
									
										
										
										
											2018-11-14 09:38:33 -05:00
										 |  |  |  |   warning_c_args = [
 | 
					
						
							| 
									
										
										
										
											2018-02-16 19:14:08 +02:00
										 |  |  |  |     '-Wduplicated-branches',
 | 
					
						
							| 
									
										
										
										
											2018-09-02 20:47:48 +02:00
										 |  |  |  |     '-Wimplicit-fallthrough',
 | 
					
						
							| 
									
										
										
										
											2018-05-30 10:12:01 +01:00
										 |  |  |  |     '-Wmisleading-indentation',
 | 
					
						
							| 
									
										
										
										
											2018-02-16 19:14:08 +02:00
										 |  |  |  |     '-Wstrict-prototypes',
 | 
					
						
							| 
									
										
										
										
											2018-05-25 13:38:29 +01:00
										 |  |  |  |     '-Wunused',
 | 
					
						
							| 
									
										
										
										
											2019-02-07 13:01:16 +01:00
										 |  |  |  |     # Due to maintained deprecated code, we do not want to see unused parameters
 | 
					
						
							|  |  |  |  |     '-Wno-unused-parameter',
 | 
					
						
							| 
									
										
										
										
											2018-07-10 17:44:22 +02:00
										 |  |  |  |     # Due to pervasive use of things like GPOINTER_TO_UINT(), we do not support
 | 
					
						
							|  |  |  |  |     # building with -Wbad-function-cast.
 | 
					
						
							|  |  |  |  |     '-Wno-bad-function-cast',
 | 
					
						
							| 
									
										
										
										
											2019-01-27 12:11:09 +01:00
										 |  |  |  |     '-Wno-cast-function-type',
 | 
					
						
							| 
									
										
										
										
											2019-01-23 13:38:40 +00:00
										 |  |  |  |     # Due to function casts through (void*) we cannot support -Wpedantic:
 | 
					
						
							|  |  |  |  |     # https://wiki.gnome.org/Projects/GLib/CompilerRequirements#Function_pointer_conversions.
 | 
					
						
							|  |  |  |  |     '-Wno-pedantic',
 | 
					
						
							| 
									
										
										
										
											2020-04-27 16:19:35 +03:00
										 |  |  |  |     # A zero-length format string shouldn't be considered an issue.
 | 
					
						
							|  |  |  |  |     '-Wno-format-zero-length',
 | 
					
						
							| 
									
										
										
										
											2018-02-16 19:14:08 +02:00
										 |  |  |  |     '-Werror=declaration-after-statement',
 | 
					
						
							|  |  |  |  |     '-Werror=format=2',
 | 
					
						
							|  |  |  |  |     '-Werror=implicit-function-declaration',
 | 
					
						
							|  |  |  |  |     '-Werror=init-self',
 | 
					
						
							|  |  |  |  |     '-Werror=missing-include-dirs',
 | 
					
						
							|  |  |  |  |     '-Werror=missing-prototypes',
 | 
					
						
							|  |  |  |  |     '-Werror=pointer-arith',
 | 
					
						
							|  |  |  |  |   ]
 | 
					
						
							| 
									
										
										
										
											2018-11-14 09:38:33 -05:00
										 |  |  |  |   warning_c_link_args = [
 | 
					
						
							| 
									
										
										
										
											2018-04-24 16:36:50 -04:00
										 |  |  |  |     '-Wl,-z,nodelete',
 | 
					
						
							|  |  |  |  |   ]
 | 
					
						
							|  |  |  |  |   if get_option('bsymbolic_functions')
 | 
					
						
							| 
									
										
										
										
											2018-11-14 09:38:33 -05:00
										 |  |  |  |     warning_c_link_args += ['-Wl,-Bsymbolic-functions']
 | 
					
						
							| 
									
										
										
										
											2018-04-24 16:36:50 -04:00
										 |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2018-02-16 19:14:08 +02:00
										 |  |  |  | else
 | 
					
						
							| 
									
										
										
										
											2018-11-14 09:38:33 -05:00
										 |  |  |  |   warning_c_args = []
 | 
					
						
							|  |  |  |  |   warning_c_link_args = []
 | 
					
						
							| 
									
										
										
										
											2018-02-16 19:14:08 +02:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-14 09:38:33 -05:00
										 |  |  |  | add_project_arguments(cc.get_supported_arguments(warning_c_args), language: 'c')
 | 
					
						
							| 
									
										
										
										
											2018-05-01 09:44:19 -04:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | # FIXME: We cannot build some of the GResource tests with -z nodelete, which
 | 
					
						
							|  |  |  |  | # means we cannot use that flag in add_project_link_arguments(), and must add
 | 
					
						
							|  |  |  |  | # it to the relevant targets manually. We do the same with -Bsymbolic-functions
 | 
					
						
							|  |  |  |  | # because that is what the autotools build did.
 | 
					
						
							|  |  |  |  | # See https://github.com/mesonbuild/meson/pull/3520 for a way to eventually
 | 
					
						
							|  |  |  |  | # improve this.
 | 
					
						
							| 
									
										
										
										
											2018-11-14 09:38:33 -05:00
										 |  |  |  | glib_link_flags = cc.get_supported_link_arguments(warning_c_link_args)
 | 
					
						
							| 
									
										
										
										
											2018-02-16 19:14:08 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-14 10:43:49 +05:30
										 |  |  |  | # Windows SDK requirements and checks
 | 
					
						
							| 
									
										
										
										
											2017-07-18 22:19:54 +08:00
										 |  |  |  | if host_system == 'windows'
 | 
					
						
							| 
									
										
										
										
											2019-08-14 10:43:49 +05:30
										 |  |  |  |   # Check whether we're building for UWP apps
 | 
					
						
							|  |  |  |  |   code = '''
 | 
					
						
							|  |  |  |  |   #include <windows.h>
 | 
					
						
							|  |  |  |  |   #if !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP))
 | 
					
						
							|  |  |  |  |   #error "Not building for UWP"
 | 
					
						
							|  |  |  |  |   #endif'''
 | 
					
						
							|  |  |  |  |   if cc.compiles(code, name : 'building for UWP')
 | 
					
						
							|  |  |  |  |     glib_conf.set('G_WINAPI_ONLY_APP', true)
 | 
					
						
							|  |  |  |  |     # We require Windows 10+ on WinRT
 | 
					
						
							|  |  |  |  |     glib_conf.set('_WIN32_WINNT', '0x0A00')
 | 
					
						
							| 
									
										
										
										
											2020-06-04 15:13:33 +00:00
										 |  |  |  |     uwp_gio_deps = [cc.find_library('shcore'),
 | 
					
						
							|  |  |  |  |                     cc.find_library('runtimeobject')]
 | 
					
						
							| 
									
										
										
										
											2019-08-14 10:43:49 +05:30
										 |  |  |  |   else
 | 
					
						
							|  |  |  |  |     # We require Windows 7+ on Win32
 | 
					
						
							|  |  |  |  |     glib_conf.set('_WIN32_WINNT', '0x0601')
 | 
					
						
							| 
									
										
										
										
											2020-06-04 15:13:33 +00:00
										 |  |  |  |     uwp_gio_deps = []
 | 
					
						
							| 
									
										
										
										
											2019-08-14 10:43:49 +05:30
										 |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2017-07-18 22:19:54 +08:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | functions = [
 | 
					
						
							| 
									
										
										
										
											2020-10-12 18:10:45 +01:00
										 |  |  |  |   'close_range',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'endmntent',
 | 
					
						
							|  |  |  |  |   'endservent',
 | 
					
						
							| 
									
										
										
										
											2021-01-19 22:14:41 +01:00
										 |  |  |  |   'epoll_create',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'fallocate',
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'fchmod',
 | 
					
						
							|  |  |  |  |   'fchown',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'fdwalk',
 | 
					
						
							|  |  |  |  |   'fsync',
 | 
					
						
							| 
									
										
										
										
											2018-10-28 01:37:39 +08:00
										 |  |  |  |   'getauxval',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'getc_unlocked',
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'getfsstat',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'getgrgid_r',
 | 
					
						
							|  |  |  |  |   'getmntent_r',
 | 
					
						
							|  |  |  |  |   'getpwuid_r',
 | 
					
						
							|  |  |  |  |   'getresuid',
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'getvfsstat',
 | 
					
						
							|  |  |  |  |   'gmtime_r',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'hasmntopt',
 | 
					
						
							|  |  |  |  |   'inotify_init1',
 | 
					
						
							|  |  |  |  |   'issetugid',
 | 
					
						
							|  |  |  |  |   'kevent',
 | 
					
						
							|  |  |  |  |   'kqueue',
 | 
					
						
							|  |  |  |  |   'lchmod',
 | 
					
						
							|  |  |  |  |   'lchown',
 | 
					
						
							|  |  |  |  |   'link',
 | 
					
						
							|  |  |  |  |   'localtime_r',
 | 
					
						
							|  |  |  |  |   'lstat',
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'mbrtowc',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'memalign',
 | 
					
						
							|  |  |  |  |   'mmap',
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'newlocale',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'pipe2',
 | 
					
						
							|  |  |  |  |   'poll',
 | 
					
						
							|  |  |  |  |   'prlimit',
 | 
					
						
							|  |  |  |  |   'readlink',
 | 
					
						
							|  |  |  |  |   'recvmmsg',
 | 
					
						
							|  |  |  |  |   'sendmmsg',
 | 
					
						
							|  |  |  |  |   'setenv',
 | 
					
						
							|  |  |  |  |   'setmntent',
 | 
					
						
							|  |  |  |  |   'strerror_r',
 | 
					
						
							|  |  |  |  |   'strnlen',
 | 
					
						
							|  |  |  |  |   'strsignal',
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   'strtod_l',
 | 
					
						
							|  |  |  |  |   'strtoll_l',
 | 
					
						
							|  |  |  |  |   'strtoull_l',
 | 
					
						
							| 
									
										
										
										
											2018-05-28 12:03:32 +01:00
										 |  |  |  |   'symlink',
 | 
					
						
							|  |  |  |  |   'timegm',
 | 
					
						
							|  |  |  |  |   'unsetenv',
 | 
					
						
							|  |  |  |  |   'uselocale',
 | 
					
						
							|  |  |  |  |   'utimes',
 | 
					
						
							|  |  |  |  |   'valloc',
 | 
					
						
							|  |  |  |  |   'vasprintf',
 | 
					
						
							|  |  |  |  |   'vsnprintf',
 | 
					
						
							|  |  |  |  |   'wcrtomb',
 | 
					
						
							|  |  |  |  |   'wcslen',
 | 
					
						
							|  |  |  |  |   'wcsnlen',
 | 
					
						
							| 
									
										
										
										
											2018-06-14 14:51:08 -04:00
										 |  |  |  |   'sysctlbyname',
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | ]
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-29 00:31:35 +05:30
										 |  |  |  | # _NSGetEnviron is available on iOS too, but its usage gets apps rejected from
 | 
					
						
							|  |  |  |  | # the app store since it's considered 'private API'
 | 
					
						
							|  |  |  |  | if host_system == 'darwin'
 | 
					
						
							|  |  |  |  |   functions += ['_NSGetEnviron']
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | if glib_conf.has('HAVE_SYS_STATVFS_H')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   functions += ['statvfs']
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | else
 | 
					
						
							|  |  |  |  |   have_func_statvfs = false
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | if glib_conf.has('HAVE_SYS_STATFS_H') or glib_conf.has('HAVE_SYS_MOUNT_H')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   functions += ['statfs']
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | else
 | 
					
						
							|  |  |  |  |   have_func_statfs = false
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-18 22:19:54 +08:00
										 |  |  |  | if host_system == 'windows'
 | 
					
						
							|  |  |  |  |   iphlpapi_dep = cc.find_library('iphlpapi')
 | 
					
						
							|  |  |  |  |   iphlpapi_funcs = ['if_nametoindex', 'if_indextoname']
 | 
					
						
							|  |  |  |  |   foreach ifunc : iphlpapi_funcs
 | 
					
						
							| 
									
										
										
										
											2018-05-29 17:10:09 +05:30
										 |  |  |  |     iphl_prefix =  '''#define _WIN32_WINNT @0@
 | 
					
						
							|  |  |  |  |       #include <winsock2.h>
 | 
					
						
							|  |  |  |  |       #include <iphlpapi.h>'''.format(glib_conf.get('_WIN32_WINNT'))
 | 
					
						
							| 
									
										
										
										
											2017-07-18 22:19:54 +08:00
										 |  |  |  |     if cc.has_function(ifunc,
 | 
					
						
							| 
									
										
										
										
											2018-05-29 17:10:09 +05:30
										 |  |  |  |                        prefix : iphl_prefix,
 | 
					
						
							| 
									
										
										
										
											2017-07-18 22:19:54 +08:00
										 |  |  |  |                        dependencies : iphlpapi_dep)
 | 
					
						
							|  |  |  |  |       idefine = 'HAVE_' + ifunc.underscorify().to_upper()
 | 
					
						
							|  |  |  |  |       glib_conf.set(idefine, 1)
 | 
					
						
							|  |  |  |  |       glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(idefine)
 | 
					
						
							|  |  |  |  |       set_variable('have_func_' + ifunc, true)
 | 
					
						
							|  |  |  |  |     else
 | 
					
						
							|  |  |  |  |       set_variable('have_func_' + ifunc, false)
 | 
					
						
							|  |  |  |  |     endif
 | 
					
						
							|  |  |  |  |   endforeach
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   functions += ['if_indextoname', 'if_nametoindex']
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # AIX splice is something else
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if host_system != 'aix'
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   functions += ['splice']
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | foreach f : functions
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |   if cc.has_function(f)
 | 
					
						
							|  |  |  |  |     define = 'HAVE_' + f.underscorify().to_upper()
 | 
					
						
							|  |  |  |  |     glib_conf.set(define, 1)
 | 
					
						
							|  |  |  |  |     glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(define)
 | 
					
						
							|  |  |  |  |     set_variable('have_func_' + f, true)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   else
 | 
					
						
							| 
									
										
										
										
											2016-12-21 08:50:30 +05:30
										 |  |  |  |     set_variable('have_func_' + f, false)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   endif
 | 
					
						
							|  |  |  |  | endforeach
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-31 23:54:17 +03:00
										 |  |  |  | # Check that stpcpy() is usable; must use header.
 | 
					
						
							|  |  |  |  | # cc.has_function() in some cases (clang, gcc 10+) assumes that if the
 | 
					
						
							|  |  |  |  | # compiler provides a builtin of the same name that the function exists, while
 | 
					
						
							|  |  |  |  | # it's in fact not provided by any header or library. This is true for
 | 
					
						
							|  |  |  |  | # stpcpy() on Windows using clang and gcc as well as posix_memalign() using
 | 
					
						
							|  |  |  |  | # gcc on Windows. Skip these checks on Windows for now to avoid false
 | 
					
						
							|  |  |  |  | # positives. See https://github.com/mesonbuild/meson/pull/7116,
 | 
					
						
							|  |  |  |  | # https://github.com/mesonbuild/meson/issues/3672 and
 | 
					
						
							|  |  |  |  | # https://github.com/mesonbuild/meson/issues/5628.
 | 
					
						
							|  |  |  |  | # FIXME: Once meson no longer returns success for stpcpy() and
 | 
					
						
							|  |  |  |  | # posix_memalign() on Windows using GCC and clang we can remove this.
 | 
					
						
							|  |  |  |  | if host_system != 'windows' and cc.has_function('stpcpy', prefix : '#include <string.h>')
 | 
					
						
							| 
									
										
										
										
											2018-03-21 09:52:10 +00:00
										 |  |  |  |   glib_conf.set('HAVE_STPCPY', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-08 11:29:24 +00:00
										 |  |  |  | # When building for Android-20 and earlier, require Meson 0.54.2 or newer.
 | 
					
						
							|  |  |  |  | # This is needed, because Meson build versions prior to 0.54.2 return false
 | 
					
						
							|  |  |  |  | # positive for stpcpy has_function check when building for legacy Android.
 | 
					
						
							| 
									
										
										
										
											2020-12-29 18:47:34 +01:00
										 |  |  |  | if host_system == 'android'
 | 
					
						
							| 
									
										
										
										
											2020-06-08 11:29:24 +00:00
										 |  |  |  |     android_is_older = cc.compiles('''#if __ANDROID_API__ >= 21
 | 
					
						
							|  |  |  |  |                                         #error Android is 21 or newer
 | 
					
						
							|  |  |  |  |                                     #endif''')
 | 
					
						
							|  |  |  |  |     if android_is_older and meson.version().version_compare('< 0.54.2')
 | 
					
						
							|  |  |  |  |       error('Compiling for <Android-21 requires Meson 0.54.2 or newer')
 | 
					
						
							|  |  |  |  |     endif
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:19:36 +05:30
										 |  |  |  | # Check that posix_memalign() is usable; must use header
 | 
					
						
							| 
									
										
										
										
											2020-03-31 23:54:17 +03:00
										 |  |  |  | if host_system != 'windows' and cc.has_function('posix_memalign', prefix : '#include <stdlib.h>')
 | 
					
						
							| 
									
										
										
										
											2018-03-21 09:52:10 +00:00
										 |  |  |  |   glib_conf.set('HAVE_POSIX_MEMALIGN', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												gspawn: Optimize with posix_spawn codepath
When the amount of free memory on the system is somewhat low, gnome-shell
will sometimes fail to launch apps, reporting the error:
  fork(): Cannot allocate memory
fork() is failing here because while cloning the process virtual address
space, Linux worries that the thread being forked may end up COWing the
entire address space of the parent process (gnome-shell, which is
memory-hungry), and there is not enough free memory to permit that to
happen.
In this case we are simply calling fork() in order to quickly call exec(),
which will throw away the entirity of the duplicated VM, so we should
look for ways to avoid the overcommit check.
The well known solution to this is to use clone(CLONE_VM) or vfork(), which
completely avoids creating a new memory address space for the child.
However, that comes with a bunch of caveats and complications:
  https://gist.github.com/nicowilliams/a8a07b0fc75df05f684c23c18d7db234
  https://ewontfix.com/7/
In 2016, glibc's posix_spawn() was rewritten to use this approach
while also resolving the concerns.
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9ff72da471a509a8c19791efe469f47fa6977410
I experimented with a similar approach in glib, but it was not practical
because glibc has several items of important internal knowledge (such as
knowing which signals should be given special treatment because they are
NPTL implementation details) that are not cleanly exposed elsewhere.
Instead, this patch adapts the gspawn code to use posix_spawn() where
possible, which will reap the benefits of that implementation.
The posix_spawn API is more limited than the gspawn API though,
partly due to natural limitations of using CLONE_VM, so the posix_spawn
path is added as a separate codepath which is only executed when the
conditions are right. Callers such as gnome-shell will have to be modified
to meet these conditions, such as not having a child_setup function.
In addition to allowing for the gnome-shell "Cannot allocate memory"
failure to be avoided, this should result in a general speedup in this
area, because fork()'s behaviour of cloning the entire VM space
has a cost which is now avoided. posix_spawn() has also recently
been optimized on OpenSolaris as the most performant way to spawn
a child process.
											
										 
											2018-05-28 14:45:45 -06:00
										 |  |  |  | # Check that posix_spawn() is usable; must use header
 | 
					
						
							|  |  |  |  | if cc.has_function('posix_spawn', prefix : '#include <spawn.h>')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_POSIX_SPAWN', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-19 10:34:45 +01:00
										 |  |  |  | # Check whether strerror_r returns char *
 | 
					
						
							|  |  |  |  | if have_func_strerror_r
 | 
					
						
							|  |  |  |  |   if cc.compiles('''#define _GNU_SOURCE
 | 
					
						
							|  |  |  |  |                     #include <string.h>
 | 
					
						
							|  |  |  |  |                     int func (void) {
 | 
					
						
							|  |  |  |  |                       char error_string[256];
 | 
					
						
							|  |  |  |  |                       char *ptr = strerror_r (-2, error_string, 256);
 | 
					
						
							|  |  |  |  |                       char c = *strerror_r (-2, error_string, 256);
 | 
					
						
							|  |  |  |  |                       return c != 0 && ptr != (void*) 0L;
 | 
					
						
							|  |  |  |  |                     }
 | 
					
						
							|  |  |  |  |                  ''',
 | 
					
						
							|  |  |  |  |                  name : 'strerror_r() returns char *')
 | 
					
						
							|  |  |  |  |     glib_conf.set('STRERROR_R_CHAR_P', 1,
 | 
					
						
							|  |  |  |  |                   description: 'Defined if strerror_r returns char *')
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | # Special-case these functions that have alternative names on Windows/MSVC
 | 
					
						
							|  |  |  |  | if cc.has_function('snprintf') or cc.has_header_symbol('stdio.h', 'snprintf')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_SNPRINTF', 1)
 | 
					
						
							|  |  |  |  |   glib_conf_prefix = glib_conf_prefix + '#define HAVE_SNPRINTF 1\n'
 | 
					
						
							|  |  |  |  | elif cc.has_function('_snprintf') or cc.has_header_symbol('stdio.h', '_snprintf')
 | 
					
						
							|  |  |  |  |   hack_define = '1\n#define snprintf _snprintf'
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_SNPRINTF', hack_define)
 | 
					
						
							|  |  |  |  |   glib_conf_prefix = glib_conf_prefix + '#define HAVE_SNPRINTF ' + hack_define
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-28 02:27:13 +06:00
										 |  |  |  | if cc.has_function('strcasecmp', prefix: '#include <strings.h>')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   glib_conf.set('HAVE_STRCASECMP', 1)
 | 
					
						
							|  |  |  |  |   glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRCASECMP 1\n'
 | 
					
						
							|  |  |  |  | elif cc.has_function('_stricmp')
 | 
					
						
							|  |  |  |  |   hack_define = '1\n#define strcasecmp _stricmp'
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_STRCASECMP', hack_define)
 | 
					
						
							|  |  |  |  |   glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRCASECMP ' + hack_define
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-28 02:27:13 +06:00
										 |  |  |  | if cc.has_function('strncasecmp', prefix: '#include <strings.h>')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   glib_conf.set('HAVE_STRNCASECMP', 1)
 | 
					
						
							|  |  |  |  |   glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRNCASECMP 1\n'
 | 
					
						
							|  |  |  |  | elif cc.has_function('_strnicmp')
 | 
					
						
							|  |  |  |  |   hack_define = '1\n#define strncasecmp _strnicmp'
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_STRNCASECMP', hack_define)
 | 
					
						
							|  |  |  |  |   glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRNCASECMP ' + hack_define
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-23 11:58:51 -04:00
										 |  |  |  | if cc.has_header_symbol('sys/sysmacros.h', 'major')
 | 
					
						
							|  |  |  |  |   glib_conf.set('MAJOR_IN_SYSMACROS', 1)
 | 
					
						
							|  |  |  |  | elif cc.has_header_symbol('sys/mkdev.h', 'major')
 | 
					
						
							|  |  |  |  |   glib_conf.set('MAJOR_IN_MKDEV', 1)
 | 
					
						
							| 
									
										
										
										
											2018-06-03 02:17:51 +08:00
										 |  |  |  | elif cc.has_header_symbol('sys/types.h', 'major')
 | 
					
						
							|  |  |  |  |   glib_conf.set('MAJOR_IN_TYPES', 1)
 | 
					
						
							| 
									
										
										
										
											2017-06-23 11:58:51 -04:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-23 12:36:38 -04:00
										 |  |  |  | if cc.has_header_symbol('dlfcn.h', 'RTLD_LAZY')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_RTLD_LAZY', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | if cc.has_header_symbol('dlfcn.h', 'RTLD_NOW')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_RTLD_NOW', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | if cc.has_header_symbol('dlfcn.h', 'RTLD_GLOBAL')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_RTLD_GLOBAL', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-20 18:52:48 +00:00
										 |  |  |  | have_rtld_next = false
 | 
					
						
							| 
									
										
										
										
											2019-04-16 09:22:11 -07:00
										 |  |  |  | if cc.has_header_symbol('dlfcn.h', 'RTLD_NEXT', args: '-D_GNU_SOURCE')
 | 
					
						
							| 
									
										
										
										
											2019-03-20 18:52:48 +00:00
										 |  |  |  |   have_rtld_next = true
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_RTLD_NEXT', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Check whether to use statfs or statvfs
 | 
					
						
							|  |  |  |  | # Some systems have both statfs and statvfs, pick the most "native" for these
 | 
					
						
							|  |  |  |  | if have_func_statfs and have_func_statvfs
 | 
					
						
							|  |  |  |  |   # on solaris and irix, statfs doesn't even have the f_bavail field
 | 
					
						
							|  |  |  |  |   if not glib_conf.has('HAVE_STRUCT_STATFS_F_BAVAIL')
 | 
					
						
							|  |  |  |  |     have_func_statfs = false
 | 
					
						
							|  |  |  |  |   else
 | 
					
						
							|  |  |  |  |     # at least on linux, statfs is the actual syscall
 | 
					
						
							|  |  |  |  |     have_func_statvfs = false
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | if have_func_statfs
 | 
					
						
							|  |  |  |  |   glib_conf.set('USE_STATFS', 1)
 | 
					
						
							|  |  |  |  |   stat_func_to_use = 'statfs'
 | 
					
						
							|  |  |  |  | elif have_func_statvfs
 | 
					
						
							|  |  |  |  |   glib_conf.set('USE_STATVFS', 1)
 | 
					
						
							|  |  |  |  |   stat_func_to_use = 'statvfs'
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | else
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   stat_func_to_use = 'neither'
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | message('Checking whether to use statfs or statvfs .. ' + stat_func_to_use)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-09 11:46:48 +01:00
										 |  |  |  | if host_system == 'linux'
 | 
					
						
							|  |  |  |  |   if cc.has_function('mkostemp',
 | 
					
						
							|  |  |  |  |                      prefix: '''#define _GNU_SOURCE
 | 
					
						
							|  |  |  |  |                                 #include <stdlib.h>''')
 | 
					
						
							|  |  |  |  |     glib_conf.set('HAVE_MKOSTEMP', 1)
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-04 15:55:59 -05:00
										 |  |  |  | osx_ldflags = []
 | 
					
						
							| 
									
										
										
										
											2017-05-13 11:10:52 +01:00
										 |  |  |  | glib_have_os_x_9_or_later = false
 | 
					
						
							| 
									
										
										
										
											2018-05-23 09:16:35 -04:00
										 |  |  |  | glib_have_carbon = false
 | 
					
						
							|  |  |  |  | glib_have_cocoa = false
 | 
					
						
							|  |  |  |  | if host_system == 'darwin'
 | 
					
						
							|  |  |  |  |   add_languages('objc')
 | 
					
						
							|  |  |  |  |   objcc = meson.get_compiler('objc')
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   osx_ldflags += ['-Wl,-framework,CoreFoundation']
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   # Mac OS X Carbon support
 | 
					
						
							|  |  |  |  |   glib_have_carbon = objcc.compiles('''#include <Carbon/Carbon.h>
 | 
					
						
							|  |  |  |  |                                        #include <CoreServices/CoreServices.h>''',
 | 
					
						
							|  |  |  |  |                                     name : 'Mac OS X Carbon support')
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   if glib_have_carbon
 | 
					
						
							|  |  |  |  |     glib_conf.set('HAVE_CARBON', true)
 | 
					
						
							|  |  |  |  |     osx_ldflags += '-Wl,-framework,Carbon'
 | 
					
						
							|  |  |  |  |     glib_have_os_x_9_or_later = objcc.compiles('''#include <AvailabilityMacros.h>
 | 
					
						
							|  |  |  |  |                                                   #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
 | 
					
						
							|  |  |  |  |                                                   #error Compiling for minimum OS X version before 10.9
 | 
					
						
							|  |  |  |  |                                                   #endif''',
 | 
					
						
							|  |  |  |  |                                                name : 'OS X 9 or later')
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2017-05-13 11:10:52 +01:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-23 09:16:35 -04:00
										 |  |  |  |   # Mac OS X Cocoa support
 | 
					
						
							|  |  |  |  |   glib_have_cocoa = objcc.compiles('''#include <Cocoa/Cocoa.h>
 | 
					
						
							|  |  |  |  |                                       #ifdef GNUSTEP_BASE_VERSION
 | 
					
						
							|  |  |  |  |                                       #error "Detected GNUstep, not Cocoa"
 | 
					
						
							|  |  |  |  |                                       #endif''',
 | 
					
						
							|  |  |  |  |                                    name : 'Mac OS X Cocoa support')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-23 09:16:35 -04:00
										 |  |  |  |   if glib_have_cocoa
 | 
					
						
							|  |  |  |  |     glib_conf.set('HAVE_COCOA', true)
 | 
					
						
							|  |  |  |  |     osx_ldflags += ['-Wl,-framework,Foundation', '-Wl,-framework,AppKit']
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2017-05-13 11:10:52 +01:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-23 09:16:35 -04:00
										 |  |  |  |   # FIXME: libgio mix C and objC source files and there is no way to reliably
 | 
					
						
							|  |  |  |  |   # know which language flags it's going to use to link. Add to both languages
 | 
					
						
							|  |  |  |  |   # for now. See https://github.com/mesonbuild/meson/issues/3585.
 | 
					
						
							|  |  |  |  |   add_project_link_arguments(osx_ldflags, language : ['objc', 'c'])
 | 
					
						
							| 
									
										
										
										
											2017-05-13 11:10:52 +01:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-25 17:54:03 +02:00
										 |  |  |  | if host_system == 'qnx'
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_QNX', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Check for futex(2)
 | 
					
						
							|  |  |  |  | if cc.links('''#include <linux/futex.h>
 | 
					
						
							|  |  |  |  |                #include <sys/syscall.h>
 | 
					
						
							|  |  |  |  |                #include <unistd.h>
 | 
					
						
							|  |  |  |  |                int main (int argc, char ** argv) {
 | 
					
						
							|  |  |  |  |                  syscall (__NR_futex, NULL, FUTEX_WAKE, FUTEX_WAIT);
 | 
					
						
							|  |  |  |  |                  return 0;
 | 
					
						
							|  |  |  |  |                }''', name : 'futex(2) system call')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_FUTEX', 1)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | # Check for eventfd(2)
 | 
					
						
							|  |  |  |  | if cc.links('''#include <sys/eventfd.h>
 | 
					
						
							|  |  |  |  |                #include <unistd.h>
 | 
					
						
							|  |  |  |  |                int main (int argc, char ** argv) {
 | 
					
						
							|  |  |  |  |                  eventfd (0, EFD_CLOEXEC);
 | 
					
						
							|  |  |  |  |                  return 0;
 | 
					
						
							|  |  |  |  |                }''', name : 'eventfd(2) system call')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_EVENTFD', 1)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 17:13:12 -07:00
										 |  |  |  | # Check for __uint128_t (gcc) by checking for 128-bit division
 | 
					
						
							|  |  |  |  | uint128_t_src = '''int main() {
 | 
					
						
							|  |  |  |  | static __uint128_t v1 = 100;
 | 
					
						
							|  |  |  |  | static __uint128_t v2 = 10;
 | 
					
						
							|  |  |  |  | static __uint128_t u;
 | 
					
						
							|  |  |  |  | u = v1 / v2;
 | 
					
						
							|  |  |  |  | }'''
 | 
					
						
							|  |  |  |  | if cc.compiles(uint128_t_src, name : '__uint128_t available')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_UINT128_T', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | clock_gettime_test_code = '''
 | 
					
						
							|  |  |  |  |   #include <time.h>
 | 
					
						
							|  |  |  |  |   struct timespec t;
 | 
					
						
							|  |  |  |  |   int main (int argc, char ** argv) {
 | 
					
						
							|  |  |  |  |     return clock_gettime(CLOCK_REALTIME, &t);
 | 
					
						
							|  |  |  |  |   }'''
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | librt = []
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | if cc.links(clock_gettime_test_code, name : 'clock_gettime')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_CLOCK_GETTIME', 1)
 | 
					
						
							|  |  |  |  | elif cc.links(clock_gettime_test_code, args : '-lrt', name : 'clock_gettime in librt')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_CLOCK_GETTIME', 1)
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   librt = cc.find_library('rt')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-29 23:19:08 +08:00
										 |  |  |  | dlopen_dlsym_test_code = '''
 | 
					
						
							|  |  |  |  | #include <dlfcn.h>
 | 
					
						
							|  |  |  |  | int glib_underscore_test (void) { return 42; }
 | 
					
						
							|  |  |  |  | int main (int argc, char ** argv) {
 | 
					
						
							|  |  |  |  |   void *f1 = (void*)0, *f2 = (void*)0, *handle;
 | 
					
						
							|  |  |  |  |   handle = dlopen ((void*)0, 0);
 | 
					
						
							|  |  |  |  |   if (handle) {
 | 
					
						
							|  |  |  |  |     f1 = dlsym (handle, "glib_underscore_test");
 | 
					
						
							|  |  |  |  |     f2 = dlsym (handle, "_glib_underscore_test");
 | 
					
						
							|  |  |  |  |   }
 | 
					
						
							|  |  |  |  |   return (!f2 || f1);
 | 
					
						
							|  |  |  |  | }'''
 | 
					
						
							|  |  |  |  | libdl_dep = []
 | 
					
						
							|  |  |  |  | if cc.links(dlopen_dlsym_test_code, name : 'dlopen() and dlsym() in system libraries')
 | 
					
						
							|  |  |  |  |   have_dlopen_dlsym = true
 | 
					
						
							|  |  |  |  | elif cc.links(dlopen_dlsym_test_code, args : '-ldl', name : 'dlopen() and dlsym() in libdl')
 | 
					
						
							|  |  |  |  |   have_dlopen_dlsym = true
 | 
					
						
							|  |  |  |  |   libdl_dep = cc.find_library('dl')
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   have_dlopen_dlsym = false
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # if statfs() takes 2 arguments (Posix) or 4 (Solaris)
 | 
					
						
							|  |  |  |  | if have_func_statfs
 | 
					
						
							|  |  |  |  |   if cc.compiles(glib_conf_prefix + '''
 | 
					
						
							|  |  |  |  |                  #include <unistd.h>
 | 
					
						
							|  |  |  |  |                         #ifdef HAVE_SYS_PARAM_H
 | 
					
						
							|  |  |  |  |                         #include <sys/param.h>
 | 
					
						
							|  |  |  |  |                         #endif
 | 
					
						
							|  |  |  |  |                         #ifdef HAVE_SYS_VFS_H
 | 
					
						
							|  |  |  |  |                         #include <sys/vfs.h>
 | 
					
						
							|  |  |  |  |                         #endif
 | 
					
						
							|  |  |  |  |                         #ifdef HAVE_SYS_MOUNT_H
 | 
					
						
							|  |  |  |  |                         #include <sys/mount.h>
 | 
					
						
							|  |  |  |  |                         #endif
 | 
					
						
							|  |  |  |  |                         #ifdef HAVE_SYS_STATFS_H
 | 
					
						
							|  |  |  |  |                         #include <sys/statfs.h>
 | 
					
						
							|  |  |  |  |                         #endif
 | 
					
						
							|  |  |  |  |                         void some_func (void) {
 | 
					
						
							|  |  |  |  |                           struct statfs st;
 | 
					
						
							| 
									
										
										
										
											2016-12-21 06:34:47 +05:30
										 |  |  |  |                           statfs("/", &st);
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |                         }''', name : 'number of arguments to statfs() (n=2)')
 | 
					
						
							|  |  |  |  |     glib_conf.set('STATFS_ARGS', 2)
 | 
					
						
							|  |  |  |  |   elif cc.compiles(glib_conf_prefix + '''
 | 
					
						
							|  |  |  |  |                    #include <unistd.h>
 | 
					
						
							|  |  |  |  |                           #ifdef HAVE_SYS_PARAM_H
 | 
					
						
							|  |  |  |  |                           #include <sys/param.h>
 | 
					
						
							|  |  |  |  |                           #endif
 | 
					
						
							|  |  |  |  |                           #ifdef HAVE_SYS_VFS_H
 | 
					
						
							|  |  |  |  |                           #include <sys/vfs.h>
 | 
					
						
							|  |  |  |  |                           #endif
 | 
					
						
							|  |  |  |  |                           #ifdef HAVE_SYS_MOUNT_H
 | 
					
						
							|  |  |  |  |                           #include <sys/mount.h>
 | 
					
						
							|  |  |  |  |                           #endif
 | 
					
						
							|  |  |  |  |                           #ifdef HAVE_SYS_STATFS_H
 | 
					
						
							|  |  |  |  |                           #include <sys/statfs.h>
 | 
					
						
							|  |  |  |  |                           #endif
 | 
					
						
							|  |  |  |  |                           void some_func (void) {
 | 
					
						
							|  |  |  |  |                             struct statfs st;
 | 
					
						
							| 
									
										
										
										
											2016-12-21 06:34:47 +05:30
										 |  |  |  |                             statfs("/", &st, sizeof (st), 0);
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |                           }''', name : 'number of arguments to statfs() (n=4)')
 | 
					
						
							|  |  |  |  |     glib_conf.set('STATFS_ARGS', 4)
 | 
					
						
							|  |  |  |  |   else
 | 
					
						
							|  |  |  |  |     error('Unable to determine number of arguments to statfs()')
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | # open takes O_DIRECTORY as an option
 | 
					
						
							|  |  |  |  | #AC_MSG_CHECKING([])
 | 
					
						
							|  |  |  |  | if cc.compiles('''#include <fcntl.h>
 | 
					
						
							|  |  |  |  |                   #include <sys/types.h>
 | 
					
						
							| 
									
										
										
										
											2020-05-13 11:12:22 +12:00
										 |  |  |  |                   #include <sys/stat.h>
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |                   void some_func (void) {
 | 
					
						
							|  |  |  |  |                     open(0, O_DIRECTORY, 0);
 | 
					
						
							|  |  |  |  |                   }''', name : 'open() option O_DIRECTORY')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_OPEN_O_DIRECTORY', 1)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-27 18:54:12 +01:00
										 |  |  |  | # fcntl takes F_FULLFSYNC as an option
 | 
					
						
							|  |  |  |  | # See https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fsync.2.html
 | 
					
						
							|  |  |  |  | if cc.compiles('''#include <fcntl.h>
 | 
					
						
							|  |  |  |  |                   #include <sys/types.h>
 | 
					
						
							|  |  |  |  |                   #include <sys/stat.h>
 | 
					
						
							|  |  |  |  |                   void some_func (void) {
 | 
					
						
							|  |  |  |  |                     fcntl(0, F_FULLFSYNC, 0);
 | 
					
						
							|  |  |  |  |                   }''', name : 'fcntl() option F_FULLFSYNC')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_FCNTL_F_FULLFSYNC', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Check whether there is a vsnprintf() function with C99 semantics installed.
 | 
					
						
							| 
									
										
										
										
											2018-08-29 11:57:44 +01:00
										 |  |  |  | # (similar tests to AC_FUNC_VSNPRINTF_C99)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Check whether there is a snprintf() function with C99 semantics installed.
 | 
					
						
							| 
									
										
										
										
											2018-08-29 11:57:44 +01:00
										 |  |  |  | # (similar tests to AC_FUNC_SNPRINTF_C99)
 | 
					
						
							|  |  |  |  | # Check whether there is a printf() function with Unix98 semantics installed.
 | 
					
						
							|  |  |  |  | # (similar tests to AC_FUNC_PRINTF_UNIX98)
 | 
					
						
							| 
									
										
										
										
											2017-07-17 15:51:54 +08:00
										 |  |  |  | have_good_vsnprintf = false
 | 
					
						
							|  |  |  |  | have_good_snprintf = false
 | 
					
						
							| 
									
										
										
										
											2018-08-29 11:57:44 +01:00
										 |  |  |  | have_good_printf = false
 | 
					
						
							| 
									
										
										
										
											2017-07-17 15:51:54 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-10 00:22:51 +08:00
										 |  |  |  | if host_system == 'windows' and (cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl')
 | 
					
						
							| 
									
										
										
										
											2018-05-10 16:04:01 +02:00
										 |  |  |  |   # Unfortunately the Visual Studio 2015+ implementations of C99-style
 | 
					
						
							|  |  |  |  |   # snprintf and vsnprintf don't seem to be quite good enough.
 | 
					
						
							|  |  |  |  |   # (Sorry, I don't know exactly what is the problem,
 | 
					
						
							| 
									
										
										
										
											2017-07-17 15:51:54 +08:00
										 |  |  |  |   # but it is related to floating point formatting and decimal point vs. comma.)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   # The simple tests in AC_FUNC_VSNPRINTF_C99 and AC_FUNC_SNPRINTF_C99 aren't
 | 
					
						
							|  |  |  |  |   # rigorous enough to notice, though.
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_C99_SNPRINTF', false)
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_C99_VSNPRINTF', false)
 | 
					
						
							| 
									
										
										
										
											2018-08-29 11:57:44 +01:00
										 |  |  |  |   glib_conf.set('HAVE_UNIX98_PRINTF', false)
 | 
					
						
							| 
									
										
										
										
											2020-08-06 05:02:59 +05:30
										 |  |  |  | elif not cc_can_run and host_system in ['ios', 'darwin']
 | 
					
						
							|  |  |  |  |   # All these are true when compiling natively on macOS, so we should use good
 | 
					
						
							|  |  |  |  |   # defaults when building for iOS and tvOS.
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_C99_SNPRINTF', true)
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_C99_VSNPRINTF', true)
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_UNIX98_PRINTF', true)
 | 
					
						
							|  |  |  |  |   have_good_vsnprintf = true
 | 
					
						
							|  |  |  |  |   have_good_snprintf = true
 | 
					
						
							|  |  |  |  |   have_good_printf = true
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | else
 | 
					
						
							|  |  |  |  |   vsnprintf_c99_test_code = '''
 | 
					
						
							|  |  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  |  | #include <stdarg.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-14 05:20:11 -05:00
										 |  |  |  | #include <stdlib.h>
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | int
 | 
					
						
							|  |  |  |  | doit(char * s, ...)
 | 
					
						
							|  |  |  |  | {
 | 
					
						
							|  |  |  |  |   char buffer[32];
 | 
					
						
							|  |  |  |  |   va_list args;
 | 
					
						
							|  |  |  |  |   int r;
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   va_start(args, s);
 | 
					
						
							|  |  |  |  |   r = vsnprintf(buffer, 5, s, args);
 | 
					
						
							|  |  |  |  |   va_end(args);
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   if (r != 7)
 | 
					
						
							|  |  |  |  |     exit(1);
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   /* AIX 5.1 and Solaris seems to have a half-baked vsnprintf()
 | 
					
						
							|  |  |  |  |      implementation. The above will return 7 but if you replace
 | 
					
						
							|  |  |  |  |      the size of the buffer with 0, it borks! */
 | 
					
						
							|  |  |  |  |   va_start(args, s);
 | 
					
						
							|  |  |  |  |   r = vsnprintf(buffer, 0, s, args);
 | 
					
						
							|  |  |  |  |   va_end(args);
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   if (r != 7)
 | 
					
						
							|  |  |  |  |     exit(1);
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   exit(0);
 | 
					
						
							|  |  |  |  | }
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | int
 | 
					
						
							|  |  |  |  | main(void)
 | 
					
						
							|  |  |  |  | {
 | 
					
						
							|  |  |  |  |   doit("1234567");
 | 
					
						
							|  |  |  |  |   exit(1);
 | 
					
						
							|  |  |  |  | }'''
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:25 -04:00
										 |  |  |  |   if cc_can_run
 | 
					
						
							|  |  |  |  |     rres = cc.run(vsnprintf_c99_test_code, name : 'C99 vsnprintf')
 | 
					
						
							|  |  |  |  |     if rres.compiled() and rres.returncode() == 0
 | 
					
						
							|  |  |  |  |       glib_conf.set('HAVE_C99_VSNPRINTF', 1)
 | 
					
						
							|  |  |  |  |       have_good_vsnprintf = true
 | 
					
						
							|  |  |  |  |     endif
 | 
					
						
							|  |  |  |  |   else
 | 
					
						
							|  |  |  |  |       have_good_vsnprintf = meson.get_cross_property('have_c99_vsnprintf', false)
 | 
					
						
							|  |  |  |  |       glib_conf.set('HAVE_C99_VSNPRINTF', have_good_vsnprintf)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   snprintf_c99_test_code = '''
 | 
					
						
							|  |  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  |  | #include <stdarg.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-14 05:20:11 -05:00
										 |  |  |  | #include <stdlib.h>
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | int
 | 
					
						
							|  |  |  |  | doit()
 | 
					
						
							|  |  |  |  | {
 | 
					
						
							|  |  |  |  |   char buffer[32];
 | 
					
						
							|  |  |  |  |   va_list args;
 | 
					
						
							|  |  |  |  |   int r;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   r = snprintf(buffer, 5, "1234567");
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   if (r != 7)
 | 
					
						
							|  |  |  |  |     exit(1);
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   r = snprintf(buffer, 0, "1234567");
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   if (r != 7)
 | 
					
						
							|  |  |  |  |     exit(1);
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   r = snprintf(NULL, 0, "1234567");
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   if (r != 7)
 | 
					
						
							|  |  |  |  |     exit(1);
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   exit(0);
 | 
					
						
							|  |  |  |  | }
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | int
 | 
					
						
							|  |  |  |  | main(void)
 | 
					
						
							|  |  |  |  | {
 | 
					
						
							|  |  |  |  |   doit();
 | 
					
						
							|  |  |  |  |   exit(1);
 | 
					
						
							|  |  |  |  | }'''
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:25 -04:00
										 |  |  |  |   if cc_can_run
 | 
					
						
							|  |  |  |  |     rres = cc.run(snprintf_c99_test_code, name : 'C99 snprintf')
 | 
					
						
							|  |  |  |  |     if rres.compiled() and rres.returncode() == 0
 | 
					
						
							|  |  |  |  |       glib_conf.set('HAVE_C99_SNPRINTF', 1)
 | 
					
						
							|  |  |  |  |       have_good_snprintf = true
 | 
					
						
							|  |  |  |  |     endif
 | 
					
						
							|  |  |  |  |   else
 | 
					
						
							|  |  |  |  |       have_good_snprintf = meson.get_cross_property('have_c99_snprintf', false)
 | 
					
						
							|  |  |  |  |       glib_conf.set('HAVE_C99_SNPRINTF', have_good_snprintf)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2018-08-29 11:57:44 +01:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |   printf_unix98_test_code = '''
 | 
					
						
							|  |  |  |  | #include <stdio.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-14 05:20:11 -05:00
										 |  |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  |  | #include <string.h>
 | 
					
						
							| 
									
										
										
										
											2018-08-29 11:57:44 +01:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | int
 | 
					
						
							|  |  |  |  | main (void)
 | 
					
						
							|  |  |  |  | {
 | 
					
						
							|  |  |  |  |   char buffer[128];
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   sprintf (buffer, "%2\$d %3\$d %1\$d", 1, 2, 3);
 | 
					
						
							|  |  |  |  |   if (strcmp ("2 3 1", buffer) == 0)
 | 
					
						
							|  |  |  |  |     exit (0);
 | 
					
						
							|  |  |  |  |   exit (1);
 | 
					
						
							|  |  |  |  | }'''
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   if cc_can_run
 | 
					
						
							|  |  |  |  |     rres = cc.run(printf_unix98_test_code, name : 'Unix98 printf positional parameters')
 | 
					
						
							|  |  |  |  |     if rres.compiled() and rres.returncode() == 0
 | 
					
						
							|  |  |  |  |       glib_conf.set('HAVE_UNIX98_PRINTF', 1)
 | 
					
						
							|  |  |  |  |       have_good_printf = true
 | 
					
						
							|  |  |  |  |     endif
 | 
					
						
							|  |  |  |  |   else
 | 
					
						
							|  |  |  |  |       have_good_printf = meson.get_cross_property('have_unix98_printf', false)
 | 
					
						
							|  |  |  |  |       glib_conf.set('HAVE_UNIX98_PRINTF', have_good_printf)
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if host_system == 'windows'
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   glib_conf.set_quoted('EXEEXT', '.exe')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | else
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   glib_conf.set('EXEEXT', '')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-10 16:45:31 +02:00
										 |  |  |  | # Our printf is 'good' only if vsnpintf()/snprintf()/printf() supports C99 well enough
 | 
					
						
							|  |  |  |  | use_system_printf = have_good_vsnprintf and have_good_snprintf and have_good_printf
 | 
					
						
							|  |  |  |  | glib_conf.set('USE_SYSTEM_PRINTF', use_system_printf)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('GLIB_USING_SYSTEM_PRINTF', use_system_printf)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | if not use_system_printf
 | 
					
						
							|  |  |  |  |   # gnulib has vasprintf so override the previous check
 | 
					
						
							| 
									
										
										
										
											2017-07-17 15:51:54 +08:00
										 |  |  |  |   glib_conf.set('HAVE_VASPRINTF', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Check for nl_langinfo and CODESET
 | 
					
						
							|  |  |  |  | if cc.links('''#include <langinfo.h>
 | 
					
						
							|  |  |  |  |                int main (int argc, char ** argv) {
 | 
					
						
							|  |  |  |  |                  char *codeset = nl_langinfo (CODESET);
 | 
					
						
							|  |  |  |  |                  return 0;
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |                }''', name : 'nl_langinfo and CODESET')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_LANGINFO_CODESET', 1)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   glib_conf.set('HAVE_CODESET', 1)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Check for nl_langinfo and LC_TIME parts that are needed in gdatetime.c
 | 
					
						
							|  |  |  |  | if cc.links('''#include <langinfo.h>
 | 
					
						
							|  |  |  |  |                int main (int argc, char ** argv) {
 | 
					
						
							|  |  |  |  |                  char *str;
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (PM_STR);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (D_T_FMT);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (D_FMT);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (T_FMT);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (T_FMT_AMPM);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (MON_1);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ABMON_12);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (DAY_1);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ABDAY_7);
 | 
					
						
							|  |  |  |  |                  return 0;
 | 
					
						
							|  |  |  |  |                }''', name : 'nl_langinfo (PM_STR)')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_LANGINFO_TIME', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | if cc.links('''#include <langinfo.h>
 | 
					
						
							|  |  |  |  |                int main (int argc, char ** argv) {
 | 
					
						
							|  |  |  |  |                  char *str;
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT0_MB);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT1_MB);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT2_MB);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT3_MB);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT4_MB);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT5_MB);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT6_MB);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT7_MB);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT8_MB);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT9_MB);
 | 
					
						
							|  |  |  |  |                  return 0;
 | 
					
						
							|  |  |  |  |                }''', name : 'nl_langinfo (_NL_CTYPE_OUTDIGITn_MB)')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_LANGINFO_OUTDIGIT', 1)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-24 11:19:13 +01:00
										 |  |  |  | # Check for nl_langinfo and alternative month names
 | 
					
						
							|  |  |  |  | if cc.links('''#ifndef _GNU_SOURCE
 | 
					
						
							|  |  |  |  |               # define _GNU_SOURCE
 | 
					
						
							|  |  |  |  |               #endif
 | 
					
						
							|  |  |  |  |               #include <langinfo.h>
 | 
					
						
							|  |  |  |  |                int main (int argc, char ** argv) {
 | 
					
						
							|  |  |  |  |                  char *str;
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ALTMON_1);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ALTMON_2);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ALTMON_3);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ALTMON_4);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ALTMON_5);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ALTMON_6);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ALTMON_7);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ALTMON_8);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ALTMON_9);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ALTMON_10);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ALTMON_11);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (ALTMON_12);
 | 
					
						
							|  |  |  |  |                  return 0;
 | 
					
						
							|  |  |  |  |                }''', name : 'nl_langinfo (ALTMON_n)')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_LANGINFO_ALTMON', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | # Check for nl_langinfo and abbreviated alternative month names
 | 
					
						
							|  |  |  |  | if cc.links('''#ifndef _GNU_SOURCE
 | 
					
						
							|  |  |  |  |               # define _GNU_SOURCE
 | 
					
						
							|  |  |  |  |               #endif
 | 
					
						
							|  |  |  |  |               #include <langinfo.h>
 | 
					
						
							|  |  |  |  |                int main (int argc, char ** argv) {
 | 
					
						
							|  |  |  |  |                  char *str;
 | 
					
						
							| 
									
										
										
										
											2019-05-10 00:40:27 +02:00
										 |  |  |  |                  str = nl_langinfo (_NL_ABALTMON_1);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_ABALTMON_2);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_ABALTMON_3);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_ABALTMON_4);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_ABALTMON_5);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_ABALTMON_6);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_ABALTMON_7);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_ABALTMON_8);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_ABALTMON_9);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_ABALTMON_10);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_ABALTMON_11);
 | 
					
						
							|  |  |  |  |                  str = nl_langinfo (_NL_ABALTMON_12);
 | 
					
						
							| 
									
										
										
										
											2017-03-24 11:19:13 +01:00
										 |  |  |  |                  return 0;
 | 
					
						
							| 
									
										
										
										
											2019-05-10 00:40:27 +02:00
										 |  |  |  |                }''', name : 'nl_langinfo (_NL_ABALTMON_n)')
 | 
					
						
							| 
									
										
										
										
											2017-03-24 11:19:13 +01:00
										 |  |  |  |   glib_conf.set('HAVE_LANGINFO_ABALTMON', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-01 12:47:27 +01:00
										 |  |  |  | # Check for nl_langinfo and _NL_TIME_CODESET
 | 
					
						
							|  |  |  |  | if cc.links('''#include <langinfo.h>
 | 
					
						
							|  |  |  |  |                int main (int argc, char ** argv) {
 | 
					
						
							|  |  |  |  |                  char *codeset = nl_langinfo (_NL_TIME_CODESET);
 | 
					
						
							|  |  |  |  |                  return 0;
 | 
					
						
							|  |  |  |  |                }''', name : 'nl_langinfo and _NL_TIME_CODESET')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_LANGINFO_TIME_CODESET', 1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Check if C compiler supports the 'signed' keyword
 | 
					
						
							|  |  |  |  | if not cc.compiles('''signed char x;''', name : 'signed')
 | 
					
						
							|  |  |  |  |   glib_conf.set('signed', '/* NOOP */')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Check if the ptrdiff_t type exists
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if cc.has_header_symbol('stddef.h', 'ptrdiff_t')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   glib_conf.set('HAVE_PTRDIFF_T', 1)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Check for sig_atomic_t type
 | 
					
						
							|  |  |  |  | if cc.links('''#include <signal.h>
 | 
					
						
							|  |  |  |  |                #include <sys/types.h>
 | 
					
						
							|  |  |  |  |                sig_atomic_t val = 42;
 | 
					
						
							|  |  |  |  |                int main (int argc, char ** argv) {
 | 
					
						
							|  |  |  |  |                  return val == 42 ? 0 : 1;
 | 
					
						
							|  |  |  |  |                }''', name : 'sig_atomic_t')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_SIG_ATOMIC_T', 1)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-05 16:23:02 -04:00
										 |  |  |  | # Check if 'long long' works
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # jm_AC_TYPE_LONG_LONG
 | 
					
						
							|  |  |  |  | if cc.compiles('''long long ll = 1LL;
 | 
					
						
							|  |  |  |  |                   int i = 63;
 | 
					
						
							|  |  |  |  |                   int some_func (void) {
 | 
					
						
							|  |  |  |  |                     long long llmax = (long long) -1;
 | 
					
						
							|  |  |  |  |                     return ll << i | ll >> i | llmax / ll | llmax % ll;
 | 
					
						
							|  |  |  |  |                   }''', name : 'long long')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_LONG_LONG', 1)
 | 
					
						
							|  |  |  |  |   have_long_long = true
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   have_long_long = false
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Test whether the compiler supports the 'long double' type.
 | 
					
						
							|  |  |  |  | if cc.compiles('''/* The Stardent Vistra knows sizeof(long double), but does not support it.  */
 | 
					
						
							|  |  |  |  |                   long double foo = 0.0;
 | 
					
						
							|  |  |  |  |                   /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
 | 
					
						
							|  |  |  |  |                   int array [2*(sizeof(long double) >= sizeof(double)) - 1];''',
 | 
					
						
							|  |  |  |  |                name : 'long double')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_LONG_DOUBLE', 1)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-22 09:48:42 +01:00
										 |  |  |  | # Test whether <stddef.h> has the 'wchar_t' type.
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if cc.has_header_symbol('stddef.h', 'wchar_t')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   glib_conf.set('HAVE_WCHAR_T', 1)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Test whether <wchar.h> has the 'wint_t' type.
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if cc.has_header_symbol('wchar.h', 'wint_t')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   glib_conf.set('HAVE_WINT_T', 1)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | found_uintmax_t = false
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Define HAVE_INTTYPES_H_WITH_UINTMAX if <inttypes.h> exists,
 | 
					
						
							|  |  |  |  | # doesn't clash with <sys/types.h>, and declares uintmax_t.
 | 
					
						
							|  |  |  |  | # jm_AC_HEADER_INTTYPES_H
 | 
					
						
							|  |  |  |  | if cc.compiles('''#include <sys/types.h>
 | 
					
						
							|  |  |  |  |                   #include <inttypes.h>
 | 
					
						
							|  |  |  |  |                   void some_func (void) {
 | 
					
						
							|  |  |  |  |                     uintmax_t i = (uintmax_t) -1;
 | 
					
						
							|  |  |  |  |                   }''', name : 'uintmax_t in inttypes.h')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_INTTYPES_H_WITH_UINTMAX', 1)
 | 
					
						
							|  |  |  |  |   found_uintmax_t = true
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | # Define HAVE_STDINT_H_WITH_UINTMAX if <stdint.h> exists,
 | 
					
						
							|  |  |  |  | # doesn't clash with <sys/types.h>, and declares uintmax_t.
 | 
					
						
							|  |  |  |  | # jm_AC_HEADER_STDINT_H
 | 
					
						
							|  |  |  |  | if cc.compiles('''#include <sys/types.h>
 | 
					
						
							|  |  |  |  |                   #include <stdint.h>
 | 
					
						
							|  |  |  |  |                   void some_func (void) {
 | 
					
						
							|  |  |  |  |                     uintmax_t i = (uintmax_t) -1;
 | 
					
						
							|  |  |  |  |                   }''', name : 'uintmax_t in stdint.h')
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_STDINT_H_WITH_UINTMAX', 1)
 | 
					
						
							|  |  |  |  |   found_uintmax_t = true
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Define intmax_t to 'long' or 'long long'
 | 
					
						
							|  |  |  |  | # if it is not already defined in <stdint.h> or <inttypes.h>.
 | 
					
						
							|  |  |  |  | # For simplicity, we assume that a header file defines 'intmax_t' if and
 | 
					
						
							|  |  |  |  | # only if it defines 'uintmax_t'.
 | 
					
						
							|  |  |  |  | if found_uintmax_t
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_INTMAX_T', 1)
 | 
					
						
							|  |  |  |  | elif have_long_long
 | 
					
						
							|  |  |  |  |   glib_conf.set('intmax_t', 'long long')
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   glib_conf.set('intmax_t', 'long')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | char_size = cc.sizeof('char')
 | 
					
						
							|  |  |  |  | short_size = cc.sizeof('short')
 | 
					
						
							|  |  |  |  | int_size = cc.sizeof('int')
 | 
					
						
							|  |  |  |  | voidp_size = cc.sizeof('void*')
 | 
					
						
							|  |  |  |  | long_size = cc.sizeof('long')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | if have_long_long
 | 
					
						
							|  |  |  |  |   long_long_size = cc.sizeof('long long')
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   long_long_size = 0
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | sizet_size = cc.sizeof('size_t')
 | 
					
						
							| 
									
										
										
										
											2019-07-10 00:22:51 +08:00
										 |  |  |  | if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   ssizet_size = cc.sizeof('SSIZE_T', prefix : '#include <BaseTsd.h>')
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							| 
									
										
										
										
											2020-11-15 00:37:19 +00:00
										 |  |  |  |   ssizet_size = cc.sizeof('ssize_t', prefix : '#include <unistd.h>')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-13 16:38:51 -08:00
										 |  |  |  | # Some platforms (Apple) hard-code int64_t to long long instead of
 | 
					
						
							|  |  |  |  | # using long on 64-bit architectures. This can cause type mismatch
 | 
					
						
							|  |  |  |  | # warnings when trying to interface with code using the standard
 | 
					
						
							|  |  |  |  | # library type. Test for the warnings and set gint64 to whichever
 | 
					
						
							|  |  |  |  | # works.
 | 
					
						
							|  |  |  |  | if long_long_size == long_size
 | 
					
						
							|  |  |  |  |   if cc.compiles('''#if defined(_AIX) && !defined(__GNUC__)
 | 
					
						
							|  |  |  |  |                     #pragma options langlvl=stdc99
 | 
					
						
							|  |  |  |  |                     #endif
 | 
					
						
							|  |  |  |  |                     #pragma GCC diagnostic error "-Wincompatible-pointer-types"
 | 
					
						
							|  |  |  |  |                     #include <stdint.h>
 | 
					
						
							|  |  |  |  |                     #include <stdio.h>
 | 
					
						
							|  |  |  |  |                     int main () {
 | 
					
						
							|  |  |  |  |                       int64_t i1 = 1;
 | 
					
						
							|  |  |  |  |                       long *i2 = &i1;
 | 
					
						
							|  |  |  |  |                       return 1;
 | 
					
						
							|  |  |  |  |                     }''', name : 'int64_t is long')
 | 
					
						
							|  |  |  |  |     int64_t_typedef = 'long'
 | 
					
						
							|  |  |  |  |   elif cc.compiles('''#if defined(_AIX) && !defined(__GNUC__)
 | 
					
						
							|  |  |  |  |                       #pragma options langlvl=stdc99
 | 
					
						
							|  |  |  |  |                       #endif
 | 
					
						
							|  |  |  |  |                       #pragma GCC diagnostic error "-Wincompatible-pointer-types"
 | 
					
						
							|  |  |  |  |                       #include <stdint.h>
 | 
					
						
							|  |  |  |  |                       #include <stdio.h>
 | 
					
						
							|  |  |  |  |                       int main () {
 | 
					
						
							|  |  |  |  |                         int64_t i1 = 1;
 | 
					
						
							|  |  |  |  |                         long long *i2 = &i1;
 | 
					
						
							|  |  |  |  |                         return 1;
 | 
					
						
							|  |  |  |  |                       }''', name : 'int64_t is long long')
 | 
					
						
							|  |  |  |  |     int64_t_typedef = 'long long'
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-05 18:33:47 +02:00
										 |  |  |  | int64_m = 'll'
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | char_align = cc.alignment('char')
 | 
					
						
							|  |  |  |  | short_align = cc.alignment('short')
 | 
					
						
							|  |  |  |  | int_align = cc.alignment('int')
 | 
					
						
							|  |  |  |  | voidp_align = cc.alignment('void*')
 | 
					
						
							|  |  |  |  | long_align = cc.alignment('long')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | long_long_align = cc.alignment('long long')
 | 
					
						
							|  |  |  |  | # NOTE: We don't check for size of __int64 because long long is guaranteed to
 | 
					
						
							|  |  |  |  | # be 64-bit in C99, and it is available on all supported compilers
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | sizet_align = cc.alignment('size_t')
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | glib_conf.set('ALIGNOF_UNSIGNED_LONG', long_align)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | glib_conf.set('SIZEOF_CHAR', char_size)
 | 
					
						
							|  |  |  |  | glib_conf.set('SIZEOF_INT', int_size)
 | 
					
						
							|  |  |  |  | glib_conf.set('SIZEOF_SHORT', short_size)
 | 
					
						
							|  |  |  |  | glib_conf.set('SIZEOF_LONG', long_size)
 | 
					
						
							|  |  |  |  | glib_conf.set('SIZEOF_LONG_LONG', long_long_size)
 | 
					
						
							|  |  |  |  | glib_conf.set('SIZEOF_SIZE_T', sizet_size)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | glib_conf.set('SIZEOF_SSIZE_T', ssizet_size)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | glib_conf.set('SIZEOF_VOID_P', voidp_size)
 | 
					
						
							| 
									
										
										
										
											2019-05-22 19:26:41 +02:00
										 |  |  |  | glib_conf.set('SIZEOF_WCHAR_T', cc.sizeof('wchar_t', prefix: '#include <stddef.h>'))
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | if short_size == 2
 | 
					
						
							|  |  |  |  |   gint16 = 'short'
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   gint16_modifier='h'
 | 
					
						
							|  |  |  |  |   gint16_format='hi'
 | 
					
						
							|  |  |  |  |   guint16_format='hu'
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | elif int_size == 2
 | 
					
						
							|  |  |  |  |   gint16 = 'int'
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   gint16_modifier=''
 | 
					
						
							|  |  |  |  |   gint16_format='i'
 | 
					
						
							|  |  |  |  |   guint16_format='u'
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | else
 | 
					
						
							|  |  |  |  |   error('Compiler provides no native 16-bit integer type')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('gint16', gint16)
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  | glibconfig_conf.set_quoted('gint16_modifier', gint16_modifier)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set_quoted('gint16_format', gint16_format)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set_quoted('guint16_format', guint16_format)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | if short_size == 4
 | 
					
						
							|  |  |  |  |   gint32 = 'short'
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   gint32_modifier='h'
 | 
					
						
							|  |  |  |  |   gint32_format='hi'
 | 
					
						
							|  |  |  |  |   guint32_format='hu'
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   guint32_align = short_align
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | elif int_size == 4
 | 
					
						
							|  |  |  |  |   gint32 = 'int'
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   gint32_modifier=''
 | 
					
						
							|  |  |  |  |   gint32_format='i'
 | 
					
						
							|  |  |  |  |   guint32_format='u'
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   guint32_align = int_align
 | 
					
						
							|  |  |  |  | elif long_size == 4
 | 
					
						
							|  |  |  |  |   gint32 = 'long'
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   gint32_modifier='l'
 | 
					
						
							|  |  |  |  |   gint32_format='li'
 | 
					
						
							|  |  |  |  |   guint32_format='lu'
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   guint32_align = long_align
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   error('Compiler provides no native 32-bit integer type')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('gint32', gint32)
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  | glibconfig_conf.set_quoted('gint32_modifier', gint32_modifier)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set_quoted('gint32_format', gint32_format)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set_quoted('guint32_format', guint32_format)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | glib_conf.set('ALIGNOF_GUINT32', guint32_align)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | if int_size == 8
 | 
					
						
							|  |  |  |  |   gint64 = 'int'
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   gint64_modifier=''
 | 
					
						
							|  |  |  |  |   gint64_format='i'
 | 
					
						
							|  |  |  |  |   guint64_format='u'
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   glib_extension=''
 | 
					
						
							|  |  |  |  |   gint64_constant='(val)'
 | 
					
						
							|  |  |  |  |   guint64_constant='(val)'
 | 
					
						
							|  |  |  |  |   guint64_align = int_align
 | 
					
						
							| 
									
										
										
										
											2014-12-13 16:38:51 -08:00
										 |  |  |  | elif long_size == 8 and (long_long_size != long_size or int64_t_typedef == 'long')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   gint64 = 'long'
 | 
					
						
							|  |  |  |  |   glib_extension=''
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   gint64_modifier='l'
 | 
					
						
							|  |  |  |  |   gint64_format='li'
 | 
					
						
							|  |  |  |  |   guint64_format='lu'
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   gint64_constant='(val##L)'
 | 
					
						
							|  |  |  |  |   guint64_constant='(val##UL)'
 | 
					
						
							|  |  |  |  |   guint64_align = long_align
 | 
					
						
							| 
									
										
										
										
											2014-12-13 16:38:51 -08:00
										 |  |  |  | elif long_long_size == 8 and (long_long_size != long_size or int64_t_typedef == 'long long')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   gint64 = 'long long'
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:39:31 +02:00
										 |  |  |  |   glib_extension='G_GNUC_EXTENSION '
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   gint64_modifier=int64_m
 | 
					
						
							|  |  |  |  |   gint64_format=int64_m + 'i'
 | 
					
						
							|  |  |  |  |   guint64_format=int64_m + 'u'
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:39:31 +02:00
										 |  |  |  |   gint64_constant='(G_GNUC_EXTENSION (val##LL))'
 | 
					
						
							|  |  |  |  |   guint64_constant='(G_GNUC_EXTENSION (val##ULL))'
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   guint64_align = long_long_align
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   error('Compiler provides no native 64-bit integer type')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:39:31 +02:00
										 |  |  |  | glibconfig_conf.set('glib_extension', glib_extension)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | glibconfig_conf.set('gint64', gint64)
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  | glibconfig_conf.set_quoted('gint64_modifier', gint64_modifier)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set_quoted('gint64_format', gint64_format)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set_quoted('guint64_format', guint64_format)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | glibconfig_conf.set('gint64_constant', gint64_constant)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('guint64_constant', guint64_constant)
 | 
					
						
							|  |  |  |  | glib_conf.set('ALIGNOF_GUINT64', guint64_align)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if host_system == 'windows'
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   glibconfig_conf.set('g_pid_type', 'void*')
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   glibconfig_conf.set_quoted('g_pid_format', 'p')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   if host_machine.cpu_family() == 'x86_64'
 | 
					
						
							| 
									
										
										
										
											2018-05-05 18:33:47 +02:00
										 |  |  |  |     glibconfig_conf.set_quoted('g_pollfd_format', '%#' + int64_m + 'x')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   else
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |     glibconfig_conf.set_quoted('g_pollfd_format', '%#x')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2018-01-10 15:57:46 +00:00
										 |  |  |  |   glibconfig_conf.set('g_dir_separator', '\\\\')
 | 
					
						
							| 
									
										
										
										
											2015-10-29 08:53:00 +02:00
										 |  |  |  |   glibconfig_conf.set('g_searchpath_separator', ';')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | else
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('g_pid_type', 'int')
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   glibconfig_conf.set_quoted('g_pid_format', 'i')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('g_pollfd_format', '%d')
 | 
					
						
							| 
									
										
										
										
											2015-10-29 08:53:00 +02:00
										 |  |  |  |   glibconfig_conf.set('g_dir_separator', '/')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('g_searchpath_separator', ':')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-28 17:05:46 +00:00
										 |  |  |  | g_sizet_compatibility = {
 | 
					
						
							|  |  |  |  |   'short': sizet_size == short_size,
 | 
					
						
							|  |  |  |  |   'int': sizet_size == int_size,
 | 
					
						
							|  |  |  |  |   'long': sizet_size == long_size,
 | 
					
						
							|  |  |  |  |   'long long': sizet_size == long_long_size,
 | 
					
						
							|  |  |  |  | }
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | # Do separate checks for gcc/clang (and ignore other compilers for now), since
 | 
					
						
							|  |  |  |  | # we need to explicitly pass -Werror to the compilers.
 | 
					
						
							|  |  |  |  | # FIXME: https://github.com/mesonbuild/meson/issues/5399
 | 
					
						
							|  |  |  |  | # We can’t simplify these checks using a foreach loop because dictionary keys
 | 
					
						
							|  |  |  |  | # have to be string literals.
 | 
					
						
							|  |  |  |  | # FIXME: https://github.com/mesonbuild/meson/issues/5231
 | 
					
						
							|  |  |  |  | if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
 | 
					
						
							|  |  |  |  |   g_sizet_compatibility += {
 | 
					
						
							|  |  |  |  |     'short': g_sizet_compatibility['short'] and cc.compiles(
 | 
					
						
							|  |  |  |  |         '''#include <stddef.h>
 | 
					
						
							|  |  |  |  |         size_t f (size_t *i) { return *i + 1; }
 | 
					
						
							|  |  |  |  |         int main (void) {
 | 
					
						
							|  |  |  |  |           unsigned short i = 0;
 | 
					
						
							|  |  |  |  |           f (&i);
 | 
					
						
							|  |  |  |  |           return 0;
 | 
					
						
							|  |  |  |  |         }''',
 | 
					
						
							|  |  |  |  |         args: ['-Werror'],
 | 
					
						
							|  |  |  |  |         name : 'GCC size_t typedef is short'),
 | 
					
						
							|  |  |  |  |     'int': g_sizet_compatibility['int'] and cc.compiles(
 | 
					
						
							|  |  |  |  |         '''#include <stddef.h>
 | 
					
						
							|  |  |  |  |         size_t f (size_t *i) { return *i + 1; }
 | 
					
						
							|  |  |  |  |         int main (void) {
 | 
					
						
							|  |  |  |  |           unsigned int i = 0;
 | 
					
						
							|  |  |  |  |           f (&i);
 | 
					
						
							|  |  |  |  |           return 0;
 | 
					
						
							|  |  |  |  |         }''',
 | 
					
						
							|  |  |  |  |         args: ['-Werror'],
 | 
					
						
							|  |  |  |  |         name : 'GCC size_t typedef is int'),
 | 
					
						
							|  |  |  |  |     'long': g_sizet_compatibility['long'] and cc.compiles(
 | 
					
						
							|  |  |  |  |         '''#include <stddef.h>
 | 
					
						
							|  |  |  |  |         size_t f (size_t *i) { return *i + 1; }
 | 
					
						
							|  |  |  |  |         int main (void) {
 | 
					
						
							|  |  |  |  |           unsigned long i = 0;
 | 
					
						
							|  |  |  |  |           f (&i);
 | 
					
						
							|  |  |  |  |           return 0;
 | 
					
						
							|  |  |  |  |         }''',
 | 
					
						
							|  |  |  |  |         args: ['-Werror'],
 | 
					
						
							|  |  |  |  |         name : 'GCC size_t typedef is long'),
 | 
					
						
							|  |  |  |  |     'long long': g_sizet_compatibility['long long'] and cc.compiles(
 | 
					
						
							|  |  |  |  |         '''#include <stddef.h>
 | 
					
						
							|  |  |  |  |         size_t f (size_t *i) { return *i + 1; }
 | 
					
						
							|  |  |  |  |         int main (void) {
 | 
					
						
							|  |  |  |  |           unsigned long long i = 0;
 | 
					
						
							|  |  |  |  |           f (&i);
 | 
					
						
							|  |  |  |  |           return 0;
 | 
					
						
							|  |  |  |  |         }''',
 | 
					
						
							|  |  |  |  |         args: ['-Werror'],
 | 
					
						
							|  |  |  |  |         name : 'GCC size_t typedef is long long'),
 | 
					
						
							|  |  |  |  |   }
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | if g_sizet_compatibility['short']
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   glibconfig_conf.set('glib_size_type_define', 'short')
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   glibconfig_conf.set_quoted('gsize_modifier', 'h')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gssize_modifier', 'h')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gsize_format', 'hu')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gssize_format', 'hi')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   glibconfig_conf.set('glib_msize_type', 'SHRT')
 | 
					
						
							| 
									
										
										
										
											2019-10-28 17:05:46 +00:00
										 |  |  |  | elif g_sizet_compatibility['int']
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   glibconfig_conf.set('glib_size_type_define', 'int')
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   glibconfig_conf.set_quoted('gsize_modifier', '')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gssize_modifier', '')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gsize_format', 'u')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gssize_format', 'i')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   glibconfig_conf.set('glib_msize_type', 'INT')
 | 
					
						
							| 
									
										
										
										
											2019-10-28 17:05:46 +00:00
										 |  |  |  | elif g_sizet_compatibility['long']
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   glibconfig_conf.set('glib_size_type_define', 'long')
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   glibconfig_conf.set_quoted('gsize_modifier', 'l')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gssize_modifier', 'l')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gsize_format', 'lu')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gssize_format', 'li')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   glibconfig_conf.set('glib_msize_type', 'LONG')
 | 
					
						
							| 
									
										
										
										
											2019-10-28 17:05:46 +00:00
										 |  |  |  | elif g_sizet_compatibility['long long']
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   glibconfig_conf.set('glib_size_type_define', 'long long')
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   glibconfig_conf.set_quoted('gsize_modifier', int64_m)
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gssize_modifier', int64_m)
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gsize_format', int64_m + 'u')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gssize_format', int64_m + 'i')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   glibconfig_conf.set('glib_msize_type', 'INT64')
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   error('Could not determine size of size_t.')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | if voidp_size == int_size
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('glib_intptr_type_define', 'int')
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   glibconfig_conf.set_quoted('gintptr_modifier', '')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gintptr_format', 'i')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('guintptr_format', 'u')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   glibconfig_conf.set('glib_gpi_cast', '(gint)')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('glib_gpui_cast', '(guint)')
 | 
					
						
							|  |  |  |  | elif voidp_size == long_size
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('glib_intptr_type_define', 'long')
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   glibconfig_conf.set_quoted('gintptr_modifier', 'l')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gintptr_format', 'li')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('guintptr_format', 'lu')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   glibconfig_conf.set('glib_gpi_cast', '(glong)')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('glib_gpui_cast', '(gulong)')
 | 
					
						
							|  |  |  |  | elif voidp_size == long_long_size
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('glib_intptr_type_define', 'long long')
 | 
					
						
							| 
									
										
										
										
											2017-07-17 21:31:39 +02:00
										 |  |  |  |   glibconfig_conf.set_quoted('gintptr_modifier', int64_m)
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('gintptr_format', int64_m + 'i')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set_quoted('guintptr_format', int64_m + 'u')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   glibconfig_conf.set('glib_gpi_cast', '(gint64)')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('glib_gpui_cast', '(guint64)')
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   error('Could not determine size of void *')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if long_size != 8 and long_long_size != 8 and int_size != 8
 | 
					
						
							|  |  |  |  |   error('GLib requires a 64-bit type. You might want to consider using the GNU C compiler.')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | glibconfig_conf.set('gintbits', int_size * 8)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('glongbits', long_size * 8)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('gsizebits', sizet_size * 8)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('gssizebits', ssizet_size * 8)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-11 07:02:08 +05:30
										 |  |  |  | # XXX: https://gitlab.gnome.org/GNOME/glib/issues/1413
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if host_system == 'windows'
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   g_module_suffix = 'dll'
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   g_module_suffix = 'so'
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('g_module_suffix', g_module_suffix)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('GLIB_MAJOR_VERSION', major_version)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('GLIB_MINOR_VERSION', minor_version)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('GLIB_MICRO_VERSION', micro_version)
 | 
					
						
							| 
									
										
										
										
											2017-12-14 13:32:56 +01:00
										 |  |  |  | glibconfig_conf.set('GLIB_VERSION', glib_version)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | glibconfig_conf.set('glib_void_p', voidp_size)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('glib_long', long_size)
 | 
					
						
							|  |  |  |  | glibconfig_conf.set('glib_size_t', sizet_size)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | glibconfig_conf.set('glib_ssize_t', ssizet_size)
 | 
					
						
							|  |  |  |  | if host_machine.endian() == 'big'
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   glibconfig_conf.set('g_byte_order', 'G_BIG_ENDIAN')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('g_bs_native', 'BE')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('g_bs_alien', 'LE')
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('g_byte_order', 'G_LITTLE_ENDIAN')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('g_bs_native', 'LE')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('g_bs_alien', 'BE')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # === va_copy checks ===
 | 
					
						
							|  |  |  |  | # we currently check for all three va_copy possibilities, so we get
 | 
					
						
							|  |  |  |  | # all results in config.log for bug reports.
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-17 12:49:24 +08:00
										 |  |  |  | va_copy_func = ''
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | foreach try_func : [ '__va_copy', 'va_copy' ]
 | 
					
						
							|  |  |  |  |   if cc.compiles('''#include <stdarg.h>
 | 
					
						
							|  |  |  |  |                     #include <stdlib.h>
 | 
					
						
							| 
									
										
										
										
											2017-07-17 12:49:24 +08:00
										 |  |  |  |                     #ifdef _MSC_VER
 | 
					
						
							|  |  |  |  |                     # include "msvc_recommended_pragmas.h"
 | 
					
						
							|  |  |  |  |                     #endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |                     void f (int i, ...) {
 | 
					
						
							|  |  |  |  |                     va_list args1, args2;
 | 
					
						
							|  |  |  |  |                     va_start (args1, i);
 | 
					
						
							|  |  |  |  |                     @0@ (args2, args1);
 | 
					
						
							|  |  |  |  |                     if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
 | 
					
						
							|  |  |  |  |                       exit (1);
 | 
					
						
							|  |  |  |  |                     va_end (args1); va_end (args2);
 | 
					
						
							|  |  |  |  |                     }
 | 
					
						
							|  |  |  |  |                     int main() {
 | 
					
						
							|  |  |  |  |                       f (0, 42);
 | 
					
						
							|  |  |  |  |                       return 0;
 | 
					
						
							|  |  |  |  |                     }'''.format(try_func),
 | 
					
						
							|  |  |  |  |                     name : try_func + ' check')
 | 
					
						
							|  |  |  |  |     va_copy_func = try_func
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  | endforeach
 | 
					
						
							| 
									
										
										
										
											2017-07-17 12:49:24 +08:00
										 |  |  |  | if va_copy_func != ''
 | 
					
						
							|  |  |  |  |   glib_conf.set('G_VA_COPY', va_copy_func)
 | 
					
						
							|  |  |  |  |   glib_vacopy = '#define G_VA_COPY ' + va_copy_func
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   glib_vacopy = '/* #undef G_VA_COPY */'
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | va_list_val_copy_prog = '''
 | 
					
						
							|  |  |  |  |   #include <stdarg.h>
 | 
					
						
							|  |  |  |  |   #include <stdlib.h>
 | 
					
						
							|  |  |  |  |   void f (int i, ...) {
 | 
					
						
							|  |  |  |  |     va_list args1, args2;
 | 
					
						
							|  |  |  |  |     va_start (args1, i);
 | 
					
						
							|  |  |  |  |     args2 = args1;
 | 
					
						
							|  |  |  |  |     if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
 | 
					
						
							|  |  |  |  |       exit (1);
 | 
					
						
							|  |  |  |  |     va_end (args1); va_end (args2);
 | 
					
						
							|  |  |  |  |   }
 | 
					
						
							|  |  |  |  |   int main() {
 | 
					
						
							|  |  |  |  |     f (0, 42);
 | 
					
						
							|  |  |  |  |     return 0;
 | 
					
						
							|  |  |  |  |   }'''
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:25 -04:00
										 |  |  |  | if cc_can_run
 | 
					
						
							|  |  |  |  |   rres = cc.run(va_list_val_copy_prog, name : 'va_lists can be copied as values')
 | 
					
						
							|  |  |  |  |   glib_va_val_copy = rres.returncode() == 0
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   glib_va_val_copy = meson.get_cross_property('va_val_copy', true)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | if not glib_va_val_copy
 | 
					
						
							|  |  |  |  |   glib_vacopy = glib_vacopy + '\n#define G_VA_COPY_AS_ARRAY 1'
 | 
					
						
							|  |  |  |  |   glib_conf.set('G_VA_COPY_AS_ARRAY', 1)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | glibconfig_conf.set('glib_vacopy', glib_vacopy)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # check for flavours of varargs macros
 | 
					
						
							|  |  |  |  | g_have_iso_c_varargs = cc.compiles('''
 | 
					
						
							|  |  |  |  |   void some_func (void) {
 | 
					
						
							|  |  |  |  |     int a(int p1, int p2, int p3);
 | 
					
						
							|  |  |  |  |     #define call_a(...) a(1,__VA_ARGS__)
 | 
					
						
							|  |  |  |  |     call_a(2,3);
 | 
					
						
							|  |  |  |  |   }''', name : 'ISO C99 varargs macros in C')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | if g_have_iso_c_varargs
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('g_have_iso_c_varargs', '''
 | 
					
						
							|  |  |  |  | #ifndef __cplusplus
 | 
					
						
							|  |  |  |  | # define G_HAVE_ISO_VARARGS 1
 | 
					
						
							|  |  |  |  | #endif''')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | g_have_iso_cxx_varargs = cxx.compiles('''
 | 
					
						
							|  |  |  |  |   void some_func (void) {
 | 
					
						
							|  |  |  |  |     int a(int p1, int p2, int p3);
 | 
					
						
							|  |  |  |  |     #define call_a(...) a(1,__VA_ARGS__)
 | 
					
						
							|  |  |  |  |     call_a(2,3);
 | 
					
						
							|  |  |  |  |   }''', name : 'ISO C99 varargs macros in C++')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | if g_have_iso_cxx_varargs
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('g_have_iso_cxx_varargs', '''
 | 
					
						
							|  |  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  |  | # define G_HAVE_ISO_VARARGS 1
 | 
					
						
							|  |  |  |  | #endif''')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | g_have_gnuc_varargs = cc.compiles('''
 | 
					
						
							|  |  |  |  |   void some_func (void) {
 | 
					
						
							|  |  |  |  |     int a(int p1, int p2, int p3);
 | 
					
						
							|  |  |  |  |     #define call_a(params...) a(1,params)
 | 
					
						
							|  |  |  |  |     call_a(2,3);
 | 
					
						
							|  |  |  |  |   }''', name : 'GNUC varargs macros')
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | if cc.has_header('alloca.h')
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('GLIB_HAVE_ALLOCA_H', true)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | has_syspoll = cc.has_header('sys/poll.h')
 | 
					
						
							|  |  |  |  | has_systypes = cc.has_header('sys/types.h')
 | 
					
						
							|  |  |  |  | if has_syspoll
 | 
					
						
							|  |  |  |  |   glibconfig_conf.set('GLIB_HAVE_SYS_POLL_H', true)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | has_winsock2 = cc.has_header('winsock2.h')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | if has_syspoll and has_systypes
 | 
					
						
							| 
									
										
										
										
											2018-04-06 13:46:15 -04:00
										 |  |  |  |   poll_includes = '''
 | 
					
						
							|  |  |  |  |       #include<sys/poll.h>
 | 
					
						
							|  |  |  |  |       #include<sys/types.h>'''
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | elif has_winsock2
 | 
					
						
							| 
									
										
										
										
											2018-04-06 13:46:15 -04:00
										 |  |  |  |   poll_includes = '''
 | 
					
						
							| 
									
										
										
										
											2018-05-29 17:10:09 +05:30
										 |  |  |  |       #define _WIN32_WINNT @0@
 | 
					
						
							|  |  |  |  |       #include <winsock2.h>'''.format(glib_conf.get('_WIN32_WINNT'))
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | else
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   # FIXME?
 | 
					
						
							|  |  |  |  |   error('FIX POLL* defines')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-06 13:46:15 -04:00
										 |  |  |  | poll_defines = [
 | 
					
						
							| 
									
										
										
										
											2018-03-31 13:59:55 +00:00
										 |  |  |  |   [ 'POLLIN', 'g_pollin', 1 ],
 | 
					
						
							|  |  |  |  |   [ 'POLLOUT', 'g_pollout', 4 ],
 | 
					
						
							|  |  |  |  |   [ 'POLLPRI', 'g_pollpri', 2 ],
 | 
					
						
							|  |  |  |  |   [ 'POLLERR', 'g_pollerr', 8 ],
 | 
					
						
							|  |  |  |  |   [ 'POLLHUP', 'g_pollhup', 16 ],
 | 
					
						
							|  |  |  |  |   [ 'POLLNVAL', 'g_pollnval', 32 ],
 | 
					
						
							| 
									
										
										
										
											2018-04-06 13:46:15 -04:00
										 |  |  |  | ]
 | 
					
						
							| 
									
										
										
										
											2018-03-31 13:59:55 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | if has_syspoll and has_systypes
 | 
					
						
							|  |  |  |  |   foreach d : poll_defines
 | 
					
						
							|  |  |  |  |     val = cc.compute_int(d[0], prefix: poll_includes)
 | 
					
						
							|  |  |  |  |     glibconfig_conf.set(d[1], val)
 | 
					
						
							|  |  |  |  |   endforeach
 | 
					
						
							|  |  |  |  | elif has_winsock2
 | 
					
						
							|  |  |  |  |   # Due to a missed bug in configure.ac the poll test
 | 
					
						
							|  |  |  |  |   # never succeeded on Windows and used some pre-defined
 | 
					
						
							|  |  |  |  |   # values as a fallback. Keep using them to maintain
 | 
					
						
							|  |  |  |  |   # ABI compatibility with autotools builds of glibs
 | 
					
						
							|  |  |  |  |   # and with *any* glib-using code compiled against them,
 | 
					
						
							|  |  |  |  |   # since these values end up in a public header glibconfig.h.
 | 
					
						
							|  |  |  |  |   foreach d : poll_defines
 | 
					
						
							|  |  |  |  |     glibconfig_conf.set(d[1], d[2])
 | 
					
						
							|  |  |  |  |   endforeach
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Internet address families
 | 
					
						
							|  |  |  |  | # FIXME: what about Cygwin (G_WITH_CYGWIN)
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if host_system == 'windows'
 | 
					
						
							| 
									
										
										
										
											2018-04-06 13:46:15 -04:00
										 |  |  |  |   inet_includes = '''
 | 
					
						
							|  |  |  |  |       #include <winsock2.h>'''
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | else
 | 
					
						
							| 
									
										
										
										
											2018-04-06 13:46:15 -04:00
										 |  |  |  |   inet_includes = '''
 | 
					
						
							|  |  |  |  |       #include <sys/types.h>
 | 
					
						
							|  |  |  |  |       #include <sys/socket.h>'''
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-06 13:46:15 -04:00
										 |  |  |  | inet_defines = [
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   [ 'AF_UNIX', 'g_af_unix' ],
 | 
					
						
							|  |  |  |  |   [ 'AF_INET', 'g_af_inet' ],
 | 
					
						
							|  |  |  |  |   [ 'AF_INET6', 'g_af_inet6' ],
 | 
					
						
							|  |  |  |  |   [ 'MSG_OOB', 'g_msg_oob' ],
 | 
					
						
							|  |  |  |  |   [ 'MSG_PEEK', 'g_msg_peek' ],
 | 
					
						
							|  |  |  |  |   [ 'MSG_DONTROUTE', 'g_msg_dontroute' ],
 | 
					
						
							|  |  |  |  | ]
 | 
					
						
							| 
									
										
										
										
											2018-04-06 13:46:15 -04:00
										 |  |  |  | foreach d : inet_defines
 | 
					
						
							|  |  |  |  |   val = cc.compute_int(d[0], prefix: inet_includes)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   glibconfig_conf.set(d[1], val)
 | 
					
						
							|  |  |  |  | endforeach
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-06 00:16:36 +01:00
										 |  |  |  | if host_system == 'windows'
 | 
					
						
							|  |  |  |  |   have_ipv6 = true
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   have_ipv6 = cc.has_type('struct in6_addr', prefix: '#include <netinet/in.h>')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | glib_conf.set('HAVE_IPV6', have_ipv6)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-22 09:48:04 +01:00
										 |  |  |  | # We need to decide at configure time if GLib will use real atomic
 | 
					
						
							|  |  |  |  | # operations ("lock free") or emulated ones with a mutex.  This is
 | 
					
						
							|  |  |  |  | # because we must put this information in glibconfig.h so we know if
 | 
					
						
							|  |  |  |  | # it is safe or not to inline using compiler intrinsics directly from
 | 
					
						
							|  |  |  |  | # the header.
 | 
					
						
							|  |  |  |  | #
 | 
					
						
							|  |  |  |  | # We also publish the information via G_ATOMIC_LOCK_FREE in case the
 | 
					
						
							|  |  |  |  | # user is interested in knowing if they can use the atomic ops across
 | 
					
						
							|  |  |  |  | # processes.
 | 
					
						
							|  |  |  |  | #
 | 
					
						
							|  |  |  |  | # We can currently support the atomic ops natively when building GLib
 | 
					
						
							|  |  |  |  | # with recent versions of GCC or MSVC.
 | 
					
						
							|  |  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2017-06-14 23:57:11 +01:00
										 |  |  |  | # Note that the atomic ops are only available with GCC on x86 when
 | 
					
						
							|  |  |  |  | # using -march=i486 or higher.  If we detect that the atomic ops are
 | 
					
						
							|  |  |  |  | # not available but would be available given the right flags, we want
 | 
					
						
							|  |  |  |  | # to abort and advise the user to fix their CFLAGS.  It's better to do
 | 
					
						
							|  |  |  |  | # that then to silently fall back on emulated atomic ops just because
 | 
					
						
							|  |  |  |  | # the user had the wrong build environment.
 | 
					
						
							| 
									
										
										
										
											2018-05-16 12:16:17 +01:00
										 |  |  |  | atomictest = '''int main() {
 | 
					
						
							| 
									
										
										
										
											2020-11-11 19:23:18 +00:00
										 |  |  |  |   int atomic = 2;
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  |   __sync_bool_compare_and_swap (&atomic, 2, 3);
 | 
					
						
							| 
									
										
										
										
											2018-05-16 12:16:17 +01:00
										 |  |  |  |   return 0;
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | }
 | 
					
						
							|  |  |  |  | '''
 | 
					
						
							| 
									
										
										
										
											2018-05-17 22:19:59 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-22 11:45:37 +05:30
										 |  |  |  | atomicdefine = '''
 | 
					
						
							|  |  |  |  | #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
 | 
					
						
							|  |  |  |  | #error "compiler has atomic ops, but doesn't define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4"
 | 
					
						
							|  |  |  |  | #endif
 | 
					
						
							|  |  |  |  | '''
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-17 22:19:59 +02:00
										 |  |  |  | # We know that we can always use real ("lock free") atomic operations with MSVC
 | 
					
						
							| 
									
										
										
										
											2019-07-10 00:22:51 +08:00
										 |  |  |  | if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl' or cc.links(atomictest, name : 'atomic ops')
 | 
					
						
							| 
									
										
										
										
											2018-05-22 11:45:37 +05:30
										 |  |  |  |   have_atomic_lock_free = true
 | 
					
						
							| 
									
										
										
										
											2019-07-14 19:25:28 +02:00
										 |  |  |  |   if cc.get_id() == 'gcc' and not cc.compiles(atomicdefine, name : 'atomic ops define')
 | 
					
						
							|  |  |  |  |     # Old gcc release may provide
 | 
					
						
							| 
									
										
										
										
											2018-05-22 11:45:37 +05:30
										 |  |  |  |     # __sync_bool_compare_and_swap but doesn't define
 | 
					
						
							|  |  |  |  |     # __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
 | 
					
						
							|  |  |  |  |     glib_conf.set('__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4', true)
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | else
 | 
					
						
							| 
									
										
										
										
											2018-05-22 11:45:37 +05:30
										 |  |  |  |   have_atomic_lock_free = false
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:08:51 +05:30
										 |  |  |  |   if host_machine.cpu_family() == 'x86' and cc.links(atomictest, args : '-march=i486')
 | 
					
						
							| 
									
										
										
										
											2017-06-14 23:57:11 +01:00
										 |  |  |  |     error('GLib must be built with -march=i486 or later.')
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2018-05-22 11:45:37 +05:30
										 |  |  |  | glibconfig_conf.set('G_ATOMIC_LOCK_FREE', have_atomic_lock_free)
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # === Threads ===
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Determination of thread implementation
 | 
					
						
							| 
									
										
										
										
											2018-05-15 14:05:50 -04:00
										 |  |  |  | if host_system == 'windows' and not get_option('force_posix_threads')
 | 
					
						
							|  |  |  |  |   thread_dep = []
 | 
					
						
							|  |  |  |  |   threads_implementation = 'win32'
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   glibconfig_conf.set('g_threads_impl_def', 'WIN32')
 | 
					
						
							|  |  |  |  |   glib_conf.set('THREADS_WIN32', 1)
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							| 
									
										
										
										
											2018-05-15 14:05:50 -04:00
										 |  |  |  |   thread_dep = dependency('threads')
 | 
					
						
							|  |  |  |  |   threads_implementation = 'posix'
 | 
					
						
							| 
									
										
										
										
											2018-04-23 10:33:44 -04:00
										 |  |  |  |   pthread_prefix = '''
 | 
					
						
							|  |  |  |  |       #ifndef _GNU_SOURCE
 | 
					
						
							|  |  |  |  |       # define _GNU_SOURCE
 | 
					
						
							|  |  |  |  |       #endif
 | 
					
						
							|  |  |  |  |       #include <pthread.h>'''
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  |   glibconfig_conf.set('g_threads_impl_def', 'POSIX')
 | 
					
						
							|  |  |  |  |   glib_conf.set('THREADS_POSIX', 1)
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   if cc.has_header_symbol('pthread.h', 'pthread_attr_setstacksize')
 | 
					
						
							|  |  |  |  |     glib_conf.set('HAVE_PTHREAD_ATTR_SETSTACKSIZE', 1)
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2019-12-24 15:33:30 +02:00
										 |  |  |  |   if cc.has_header_symbol('pthread.h', 'pthread_attr_setinheritsched')
 | 
					
						
							|  |  |  |  |     glib_conf.set('HAVE_PTHREAD_ATTR_SETINHERITSCHED', 1)
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   if cc.has_header_symbol('pthread.h', 'pthread_condattr_setclock')
 | 
					
						
							|  |  |  |  |     glib_conf.set('HAVE_PTHREAD_CONDATTR_SETCLOCK', 1)
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  |   if cc.has_header_symbol('pthread.h', 'pthread_cond_timedwait_relative_np')
 | 
					
						
							|  |  |  |  |     glib_conf.set('HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP', 1)
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2018-04-23 10:33:44 -04:00
										 |  |  |  |   if cc.has_header_symbol('pthread.h', 'pthread_getname_np', prefix : pthread_prefix)
 | 
					
						
							|  |  |  |  |     glib_conf.set('HAVE_PTHREAD_GETNAME_NP', 1)
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2020-01-16 16:02:39 +02:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-19 10:48:33 +02:00
										 |  |  |  |   if cc.has_header_symbol('sys/syscall.h', 'SYS_sched_getattr')
 | 
					
						
							| 
									
										
										
										
											2020-01-16 16:02:39 +02:00
										 |  |  |  |     glib_conf.set('HAVE_SYS_SCHED_GETATTR', 1)
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-14 00:05:52 +05:30
										 |  |  |  |   # Assume that pthread_setname_np is available in some form; same as configure
 | 
					
						
							| 
									
										
										
										
											2018-04-23 10:33:44 -04:00
										 |  |  |  |   if cc.links(pthread_prefix + '''
 | 
					
						
							| 
									
										
										
										
											2017-08-09 21:31:59 +01:00
										 |  |  |  |               int main() {
 | 
					
						
							|  |  |  |  |                 pthread_setname_np("example");
 | 
					
						
							| 
									
										
										
										
											2018-05-17 15:10:50 +01:00
										 |  |  |  |                 return 0;
 | 
					
						
							| 
									
										
										
										
											2017-08-09 21:31:59 +01:00
										 |  |  |  |               }''',
 | 
					
						
							|  |  |  |  |               name : 'pthread_setname_np(const char*)',
 | 
					
						
							|  |  |  |  |               dependencies : thread_dep)
 | 
					
						
							| 
									
										
										
										
											2017-08-14 00:05:52 +05:30
										 |  |  |  |     # macOS and iOS
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |     glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID', 1)
 | 
					
						
							| 
									
										
										
										
											2018-04-23 10:33:44 -04:00
										 |  |  |  |   elif cc.links(pthread_prefix + '''
 | 
					
						
							| 
									
										
										
										
											2017-08-09 21:31:59 +01:00
										 |  |  |  |                 int main() {
 | 
					
						
							|  |  |  |  |                   pthread_setname_np(pthread_self(), "example");
 | 
					
						
							| 
									
										
										
										
											2018-05-17 15:10:50 +01:00
										 |  |  |  |                   return 0;
 | 
					
						
							| 
									
										
										
										
											2017-08-09 21:31:59 +01:00
										 |  |  |  |                 }''',
 | 
					
						
							|  |  |  |  |                 name : 'pthread_setname_np(pthread_t, const char*)',
 | 
					
						
							|  |  |  |  |                 dependencies : thread_dep)
 | 
					
						
							| 
									
										
										
										
											2017-08-14 00:05:52 +05:30
										 |  |  |  |     # Linux, Solaris, etc.
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |     glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITH_TID', 1)
 | 
					
						
							| 
									
										
										
										
											2019-08-30 01:24:08 +08:00
										 |  |  |  |   elif cc.links(pthread_prefix + '''
 | 
					
						
							|  |  |  |  |                 int main() {
 | 
					
						
							|  |  |  |  |                   pthread_setname_np(pthread_self(), "%s", "example");
 | 
					
						
							|  |  |  |  |                   return 0;
 | 
					
						
							|  |  |  |  |                 }''',
 | 
					
						
							|  |  |  |  |                 name : 'pthread_setname_np(pthread_t, const char*, void*)',
 | 
					
						
							|  |  |  |  |                 dependencies : thread_dep)
 | 
					
						
							|  |  |  |  |     # NetBSD
 | 
					
						
							|  |  |  |  |     glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG', 1)
 | 
					
						
							|  |  |  |  |   elif cc.links(pthread_prefix + '''
 | 
					
						
							|  |  |  |  |                 #include <pthread_np.h>
 | 
					
						
							|  |  |  |  |                 int main() {
 | 
					
						
							|  |  |  |  |                   pthread_set_name_np(pthread_self(), "example");
 | 
					
						
							|  |  |  |  |                   return 0;
 | 
					
						
							|  |  |  |  |                 }''',
 | 
					
						
							|  |  |  |  |                 name : 'pthread_set_name_np(pthread_t, const char*)',
 | 
					
						
							|  |  |  |  |                 dependencies : thread_dep)
 | 
					
						
							|  |  |  |  |     # FreeBSD, DragonFlyBSD, OpenBSD, etc.
 | 
					
						
							|  |  |  |  |     glib_conf.set('HAVE_PTHREAD_SET_NAME_NP', 1)
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | # FIXME: we should make it print the result and always return 0, so that
 | 
					
						
							|  |  |  |  | # the output in meson shows up as green
 | 
					
						
							| 
									
										
										
										
											2020-11-11 19:23:18 +00:00
										 |  |  |  | # volatile is needed here to avoid optimisations in the test
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | stack_grows_check_prog = '''
 | 
					
						
							|  |  |  |  |   volatile int *a = 0, *b = 0;
 | 
					
						
							|  |  |  |  |   void f (int i) {
 | 
					
						
							|  |  |  |  |     volatile int x = 5;
 | 
					
						
							|  |  |  |  |     if (i == 0)
 | 
					
						
							|  |  |  |  |       b = &x;
 | 
					
						
							|  |  |  |  |     else
 | 
					
						
							|  |  |  |  |       f (i - 1);
 | 
					
						
							|  |  |  |  |   }
 | 
					
						
							|  |  |  |  |   int main () {
 | 
					
						
							|  |  |  |  |     volatile int y = 7;
 | 
					
						
							|  |  |  |  |     a = &y;
 | 
					
						
							|  |  |  |  |     f (100);
 | 
					
						
							|  |  |  |  |     return b > a ? 0 : 1;
 | 
					
						
							|  |  |  |  |   }'''
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:25 -04:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | if cc_can_run
 | 
					
						
							|  |  |  |  |   rres = cc.run(stack_grows_check_prog, name : 'stack grows check')
 | 
					
						
							|  |  |  |  |   growing_stack = rres.returncode() == 0
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | else
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:25 -04:00
										 |  |  |  |   growing_stack = meson.get_cross_property('growing_stack', false)
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-23 12:59:40 -04:00
										 |  |  |  | glibconfig_conf.set10('G_HAVE_GROWING_STACK', growing_stack)
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:25 -04:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | # Tests for iconv
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | #
 | 
					
						
							| 
									
										
										
										
											2019-03-29 18:01:47 +05:30
										 |  |  |  | # We should never use the MinGW C library's iconv because it may not be
 | 
					
						
							|  |  |  |  | # available in the actual runtime environment. On Windows, we always use
 | 
					
						
							|  |  |  |  | # the built-in implementation
 | 
					
						
							|  |  |  |  | iconv_opt = get_option('iconv')
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if host_system == 'windows'
 | 
					
						
							|  |  |  |  |   libiconv = []
 | 
					
						
							| 
									
										
										
										
											2019-03-29 18:01:47 +05:30
										 |  |  |  |   # We have a #include "win_iconv.c" in gconvert.c on Windows, so we don't need
 | 
					
						
							|  |  |  |  |   # any external library for it
 | 
					
						
							|  |  |  |  |   if iconv_opt != 'auto'
 | 
					
						
							|  |  |  |  |     warning('-Diconv was set to @0@, which was ignored')
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | else
 | 
					
						
							| 
									
										
										
										
											2017-11-28 10:44:04 -05:00
										 |  |  |  |   found_iconv = false
 | 
					
						
							| 
									
										
										
										
											2019-03-29 18:01:47 +05:30
										 |  |  |  |   if ['auto', 'libc'].contains(iconv_opt) and cc.has_function('iconv_open')
 | 
					
						
							|  |  |  |  |     libiconv = []
 | 
					
						
							|  |  |  |  |     found_iconv = true
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2019-04-04 05:12:35 +05:30
										 |  |  |  |   if not found_iconv and ['auto', 'external'].contains(iconv_opt) and cc.has_header_symbol('iconv.h', 'iconv_open')
 | 
					
						
							| 
									
										
										
										
											2019-03-29 18:01:47 +05:30
										 |  |  |  |     libiconv = [cc.find_library('iconv')]
 | 
					
						
							|  |  |  |  |     found_iconv = true
 | 
					
						
							| 
									
										
										
										
											2017-11-28 10:44:04 -05:00
										 |  |  |  |   endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   if not found_iconv
 | 
					
						
							| 
									
										
										
										
											2018-05-16 14:26:11 +05:30
										 |  |  |  |     error('iconv implementation "@0@" not found'.format(iconv_opt))
 | 
					
						
							| 
									
										
										
										
											2017-11-28 10:44:04 -05:00
										 |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-09 12:26:30 +01:00
										 |  |  |  | pcre = dependency('libpcre', version: '>= 8.31', required : false) # Should check for Unicode support, too. FIXME
 | 
					
						
							|  |  |  |  | if not pcre.found()
 | 
					
						
							|  |  |  |  |   if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
 | 
					
						
							|  |  |  |  |   # MSVC: Search for the PCRE library by the configuration, which corresponds
 | 
					
						
							|  |  |  |  |   # to the output of CMake builds of PCRE.  Note that debugoptimized
 | 
					
						
							|  |  |  |  |   # is really a Release build with .PDB files.
 | 
					
						
							|  |  |  |  |     if vs_crt == 'debug'
 | 
					
						
							|  |  |  |  |       pcre = cc.find_library('pcred', required : false)
 | 
					
						
							|  |  |  |  |     else
 | 
					
						
							|  |  |  |  |       pcre = cc.find_library('pcre', required : false)
 | 
					
						
							| 
									
										
										
										
											2017-08-15 17:08:47 +08:00
										 |  |  |  |     endif
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2017-07-21 14:03:05 +01:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-09 12:26:30 +01:00
										 |  |  |  | # Try again with the fallback
 | 
					
						
							|  |  |  |  | if not pcre.found()
 | 
					
						
							|  |  |  |  |   pcre = dependency('libpcre', required : true, fallback : ['libpcre', 'pcre_dep'])
 | 
					
						
							|  |  |  |  |   use_pcre_static_flag = true
 | 
					
						
							|  |  |  |  | elif host_system == 'windows'
 | 
					
						
							|  |  |  |  |   pcre_static = cc.links('''#define PCRE_STATIC
 | 
					
						
							|  |  |  |  |                             #include <pcre.h>
 | 
					
						
							|  |  |  |  |                             int main() {
 | 
					
						
							|  |  |  |  |                               void *p = NULL;
 | 
					
						
							|  |  |  |  |                               pcre_free(p);
 | 
					
						
							|  |  |  |  |                               return 0;
 | 
					
						
							|  |  |  |  |                             }''',
 | 
					
						
							|  |  |  |  |                          dependencies: pcre,
 | 
					
						
							|  |  |  |  |                          name : 'Windows system PCRE is a static build')
 | 
					
						
							|  |  |  |  |   use_pcre_static_flag = pcre_static
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   use_pcre_static_flag = false
 | 
					
						
							| 
									
										
										
										
											2017-07-25 16:28:29 +08:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | libm = cc.find_library('m', required : false)
 | 
					
						
							| 
									
										
										
										
											2017-03-21 16:49:09 +05:30
										 |  |  |  | libffi_dep = dependency('libffi', version : '>= 3.0.0', fallback : ['libffi', 'ffi_dep'])
 | 
					
						
							| 
									
										
										
										
											2017-08-15 17:08:47 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-22 19:14:43 +09:00
										 |  |  |  | if get_option('wrap_mode') == 'forcefallback'
 | 
					
						
							|  |  |  |  |   # Respects "wrap_mode=forcefallback" option
 | 
					
						
							|  |  |  |  |   libz_dep = subproject('zlib').get_variable('zlib_dep')
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   # Don't use the bundled ZLib sources until we are sure that we can't find it on
 | 
					
						
							|  |  |  |  |   # the system
 | 
					
						
							|  |  |  |  |   libz_dep = dependency('zlib', required : false)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 10:59:21 -04:00
										 |  |  |  | if not libz_dep.found()
 | 
					
						
							| 
									
										
										
										
											2019-07-10 00:22:51 +08:00
										 |  |  |  |   if cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl'
 | 
					
						
							| 
									
										
										
										
											2018-10-09 10:59:21 -04:00
										 |  |  |  |     libz_dep = cc.find_library('z', required : false)
 | 
					
						
							|  |  |  |  |   else
 | 
					
						
							| 
									
										
										
										
											2017-08-15 17:08:47 +08:00
										 |  |  |  |     libz_dep = cc.find_library('zlib1', required : false)
 | 
					
						
							| 
									
										
										
										
											2018-06-05 10:51:03 -04:00
										 |  |  |  |     if not libz_dep.found()
 | 
					
						
							| 
									
										
										
										
											2017-08-15 17:08:47 +08:00
										 |  |  |  |       libz_dep = cc.find_library('zlib', required : false)
 | 
					
						
							|  |  |  |  |     endif
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2018-11-21 15:11:57 -05:00
										 |  |  |  |   if not libz_dep.found() or not cc.has_header('zlib.h')
 | 
					
						
							|  |  |  |  |     libz_dep = subproject('zlib').get_variable('zlib_dep')
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2018-10-09 10:59:21 -04:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-20 00:08:19 -04:00
										 |  |  |  | # First check in libc, fallback to libintl, and as last chance build
 | 
					
						
							|  |  |  |  | # proxy-libintl subproject.
 | 
					
						
							|  |  |  |  | # FIXME: glib-gettext.m4 has much more checks to detect broken/uncompatible
 | 
					
						
							|  |  |  |  | # implementations. This could be extended if issues are found in some platforms.
 | 
					
						
							| 
									
										
										
										
											2020-04-13 14:54:15 +01:00
										 |  |  |  | libintl_deps = []
 | 
					
						
							| 
									
										
										
										
											2021-05-16 11:58:26 +02:00
										 |  |  |  | if cc.has_function('ngettext', args : osx_ldflags)
 | 
					
						
							| 
									
										
										
										
											2018-08-29 11:59:47 +01:00
										 |  |  |  |   have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset')
 | 
					
						
							| 
									
										
										
										
											2017-03-21 22:06:22 +05:30
										 |  |  |  | else
 | 
					
						
							| 
									
										
										
										
											2020-04-13 14:54:15 +01:00
										 |  |  |  |   # First just find the bare library.
 | 
					
						
							| 
									
										
										
										
											2018-05-20 00:08:19 -04:00
										 |  |  |  |   libintl = cc.find_library('intl', required : false)
 | 
					
						
							| 
									
										
										
										
											2020-04-13 14:54:15 +01:00
										 |  |  |  |   # The bare library probably won't link without help if it's static.
 | 
					
						
							| 
									
										
										
										
											2021-05-16 11:58:26 +02:00
										 |  |  |  |   if libintl.found() and not cc.has_function('ngettext', args : osx_ldflags, dependencies : libintl)
 | 
					
						
							| 
									
										
										
										
											2020-04-13 14:54:15 +01:00
										 |  |  |  |      libintl_iconv = cc.find_library('iconv', required : false)
 | 
					
						
							|  |  |  |  |      # libintl supports different threading APIs, which may not
 | 
					
						
							|  |  |  |  |      # require additional flags, but it defaults to using pthreads if
 | 
					
						
							|  |  |  |  |      # found. Meson's "threads" dependency does not allow you to
 | 
					
						
							|  |  |  |  |      # prefer pthreads. We may not be using pthreads for glib itself
 | 
					
						
							|  |  |  |  |      # either so just link the library to satisfy libintl rather than
 | 
					
						
							|  |  |  |  |      # also defining the macros with the -pthread flag.
 | 
					
						
							|  |  |  |  |      libintl_pthread = cc.find_library('pthread', required : false)
 | 
					
						
							|  |  |  |  |      # Try linking with just libiconv.
 | 
					
						
							| 
									
										
										
										
											2021-05-16 11:58:26 +02:00
										 |  |  |  |      if libintl_iconv.found() and cc.has_function('ngettext', args : osx_ldflags, dependencies : [libintl, libintl_iconv])
 | 
					
						
							| 
									
										
										
										
											2020-04-13 14:54:15 +01:00
										 |  |  |  |        libintl_deps += [libintl_iconv]
 | 
					
						
							|  |  |  |  |      # Then also try linking with pthreads.
 | 
					
						
							| 
									
										
										
										
											2021-05-16 11:58:26 +02:00
										 |  |  |  |      elif libintl_iconv.found() and libintl_pthread.found() and cc.has_function('ngettext', args : osx_ldflags, dependencies : [libintl, libintl_iconv, libintl_pthread])
 | 
					
						
							| 
									
										
										
										
											2020-04-13 14:54:15 +01:00
										 |  |  |  |        libintl_deps += [libintl_iconv, libintl_pthread]
 | 
					
						
							|  |  |  |  |      else
 | 
					
						
							|  |  |  |  |        libintl = disabler()
 | 
					
						
							|  |  |  |  |      endif
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2018-05-20 00:08:19 -04:00
										 |  |  |  |   if not libintl.found()
 | 
					
						
							|  |  |  |  |     libintl = subproject('proxy-libintl').get_variable('intl_dep')
 | 
					
						
							| 
									
										
										
										
											2020-04-13 14:54:15 +01:00
										 |  |  |  |     libintl_deps = [libintl] + libintl_deps
 | 
					
						
							| 
									
										
										
										
											2018-08-29 11:59:47 +01:00
										 |  |  |  |     have_bind_textdomain_codeset = true  # proxy-libintl supports it
 | 
					
						
							|  |  |  |  |   else
 | 
					
						
							| 
									
										
										
										
											2020-04-13 14:54:15 +01:00
										 |  |  |  |     libintl_deps = [libintl] + libintl_deps
 | 
					
						
							| 
									
										
										
										
											2021-05-16 11:58:26 +02:00
										 |  |  |  |     have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset', args : osx_ldflags,
 | 
					
						
							| 
									
										
										
										
											2020-04-13 14:54:15 +01:00
										 |  |  |  |                                                    dependencies : libintl_deps)
 | 
					
						
							| 
									
										
										
										
											2018-05-20 00:08:19 -04:00
										 |  |  |  |   endif
 | 
					
						
							| 
									
										
										
										
											2017-03-21 22:06:22 +05:30
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2018-05-20 00:08:19 -04:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-29 11:59:47 +01:00
										 |  |  |  | glib_conf.set('HAVE_BIND_TEXTDOMAIN_CODESET', have_bind_textdomain_codeset)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-21 22:06:22 +05:30
										 |  |  |  | # We require gettext to always be present
 | 
					
						
							| 
									
										
										
										
											2018-05-20 00:08:19 -04:00
										 |  |  |  | glib_conf.set('HAVE_DCGETTEXT', 1)
 | 
					
						
							| 
									
										
										
										
											2017-03-21 22:06:22 +05:30
										 |  |  |  | glib_conf.set('HAVE_GETTEXT', 1)
 | 
					
						
							| 
									
										
										
										
											2018-05-20 00:08:19 -04:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-21 22:06:22 +05:30
										 |  |  |  | glib_conf.set_quoted('GLIB_LOCALE_DIR', join_paths(glib_datadir, 'locale'))
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-21 06:34:47 +05:30
										 |  |  |  | # libmount is only used by gio, but we need to fetch the libs to generate the
 | 
					
						
							|  |  |  |  | # pkg-config file below
 | 
					
						
							|  |  |  |  | libmount_dep = []
 | 
					
						
							| 
									
										
										
										
											2020-01-29 11:15:47 +00:00
										 |  |  |  | if host_system == 'linux'
 | 
					
						
							|  |  |  |  |   libmount_dep = dependency('mount', version : '>=2.23', required : get_option('libmount'))
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_LIBMOUNT', libmount_dep.found())
 | 
					
						
							| 
									
										
										
										
											2016-12-21 06:34:47 +05:30
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | if host_system == 'windows'
 | 
					
						
							|  |  |  |  |   winsock2 = cc.find_library('ws2_32')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-28 10:44:04 -05:00
										 |  |  |  | selinux_dep = []
 | 
					
						
							| 
									
										
										
										
											2018-11-20 08:55:26 -03:00
										 |  |  |  | if host_system == 'linux'
 | 
					
						
							| 
									
										
										
										
											2020-12-01 13:08:30 +04:00
										 |  |  |  |   selinux_dep = dependency('libselinux', version: '>=2.2', required: get_option('selinux'))
 | 
					
						
							| 
									
										
										
										
											2018-11-20 08:55:26 -03:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_SELINUX', selinux_dep.found())
 | 
					
						
							| 
									
										
										
										
											2017-11-28 10:44:04 -05:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | xattr_dep = []
 | 
					
						
							| 
									
										
										
										
											2017-12-25 22:17:49 +01:00
										 |  |  |  | if host_system != 'windows' and get_option('xattr')
 | 
					
						
							| 
									
										
										
										
											2017-11-28 10:44:04 -05:00
										 |  |  |  |   # either glibc or libattr can provide xattr support
 | 
					
						
							|  |  |  |  |   # for both of them, we check for getxattr being in
 | 
					
						
							|  |  |  |  |   # the library and a valid xattr header.
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   # try glibc
 | 
					
						
							|  |  |  |  |   if cc.has_function('getxattr') and cc.has_header('sys/xattr.h')
 | 
					
						
							|  |  |  |  |     glib_conf.set('HAVE_SYS_XATTR_H', 1)
 | 
					
						
							|  |  |  |  |     glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format('HAVE_SYS_XATTR_H')
 | 
					
						
							|  |  |  |  |   #failure. try libattr
 | 
					
						
							|  |  |  |  |   elif cc.has_header_symbol('attr/xattr.h', 'getxattr')
 | 
					
						
							|  |  |  |  |     glib_conf.set('HAVE_ATTR_XATTR_H', 1)
 | 
					
						
							|  |  |  |  |     glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format('HAVE_ATTR_XATTR_H')
 | 
					
						
							|  |  |  |  |     xattr_dep = [cc.find_library('xattr')]
 | 
					
						
							|  |  |  |  |   else
 | 
					
						
							|  |  |  |  |     error('No getxattr implementation found in C library or libxattr')
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_XATTR', 1)
 | 
					
						
							|  |  |  |  |   if cc.compiles(glib_conf_prefix + '''
 | 
					
						
							|  |  |  |  |                  #include <stdio.h>
 | 
					
						
							|  |  |  |  |                  #ifdef HAVE_SYS_TYPES_H
 | 
					
						
							|  |  |  |  |                  #include <sys/types.h>
 | 
					
						
							|  |  |  |  |                  #endif
 | 
					
						
							|  |  |  |  |                  #ifdef HAVE_SYS_XATTR_H
 | 
					
						
							|  |  |  |  |                  #include <sys/xattr.h>
 | 
					
						
							|  |  |  |  |                  #elif HAVE_ATTR_XATTR_H
 | 
					
						
							|  |  |  |  |                  #include <attr/xattr.h>
 | 
					
						
							|  |  |  |  |                  #endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                  int main (void) {
 | 
					
						
							|  |  |  |  |                    ssize_t len = getxattr("", "", NULL, 0, 0, XATTR_NOFOLLOW);
 | 
					
						
							| 
									
										
										
										
											2018-05-17 15:10:50 +01:00
										 |  |  |  |                    return len;
 | 
					
						
							| 
									
										
										
										
											2017-11-28 10:44:04 -05:00
										 |  |  |  |                  }''',
 | 
					
						
							|  |  |  |  |                  name : 'XATTR_NOFOLLOW')
 | 
					
						
							|  |  |  |  |     glib_conf.set('HAVE_XATTR_NOFOLLOW', 1)
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-13 16:22:09 +00:00
										 |  |  |  | # If strlcpy is present (BSD and similar), check that it conforms to the BSD
 | 
					
						
							|  |  |  |  | # specification. Specifically Solaris 8's strlcpy() does not, see
 | 
					
						
							|  |  |  |  | # https://bugzilla.gnome.org/show_bug.cgi?id=53933 for further context.
 | 
					
						
							|  |  |  |  | if cc.has_function('strlcpy')
 | 
					
						
							|  |  |  |  |   if cc_can_run
 | 
					
						
							|  |  |  |  |     rres = cc.run('''#include <stdlib.h>
 | 
					
						
							|  |  |  |  |                     #include <string.h>
 | 
					
						
							|  |  |  |  |                     int main() {
 | 
					
						
							|  |  |  |  |                       char p[10];
 | 
					
						
							|  |  |  |  |                       (void) strlcpy (p, "hi", 10);
 | 
					
						
							|  |  |  |  |                       if (strlcat (p, "bye", 0) != 3)
 | 
					
						
							|  |  |  |  |                         return 1;
 | 
					
						
							|  |  |  |  |                       return 0;
 | 
					
						
							|  |  |  |  |                     }''',
 | 
					
						
							|  |  |  |  |                   name : 'OpenBSD strlcpy/strlcat')
 | 
					
						
							|  |  |  |  |     if rres.compiled() and rres.returncode() == 0
 | 
					
						
							|  |  |  |  |       glib_conf.set('HAVE_STRLCPY', 1)
 | 
					
						
							|  |  |  |  |     endif
 | 
					
						
							|  |  |  |  |   elif meson.get_cross_property('have_strlcpy', false)
 | 
					
						
							| 
									
										
										
										
											2018-06-14 14:00:43 -04:00
										 |  |  |  |     glib_conf.set('HAVE_STRLCPY', 1)
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-20 21:19:29 +00:00
										 |  |  |  | cmdline_test_code = '''
 | 
					
						
							|  |  |  |  | #include <fcntl.h>
 | 
					
						
							|  |  |  |  | #include <sys/stat.h>
 | 
					
						
							|  |  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  |  | #include <stdlib.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-14 05:20:11 -05:00
										 |  |  |  | #include <unistd.h>
 | 
					
						
							| 
									
										
										
										
											2019-03-20 21:19:29 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | static int
 | 
					
						
							|  |  |  |  | __getcmdline (void)
 | 
					
						
							|  |  |  |  | {
 | 
					
						
							|  |  |  |  | /* This code is a dumbed-down version of g_file_get_contents() */
 | 
					
						
							| 
									
										
										
										
											2019-04-07 18:41:39 +00:00
										 |  |  |  | #ifndef O_BINARY
 | 
					
						
							|  |  |  |  | #define O_BINARY 0
 | 
					
						
							|  |  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-03-20 21:19:29 +00:00
										 |  |  |  | #define BUFSIZE 1024
 | 
					
						
							|  |  |  |  |   char result[BUFSIZE];
 | 
					
						
							|  |  |  |  |   struct stat stat_buf;
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   int fd = open ("/proc/self/cmdline", O_RDONLY|O_BINARY);
 | 
					
						
							| 
									
										
										
										
											2020-03-08 15:39:23 +09:00
										 |  |  |  |   if (fd < 0)
 | 
					
						
							|  |  |  |  |     exit (1);
 | 
					
						
							|  |  |  |  |   if (fstat (fd, &stat_buf))
 | 
					
						
							|  |  |  |  |     exit (1);
 | 
					
						
							| 
									
										
										
										
											2019-03-20 21:19:29 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |   if (stat_buf.st_size > 0 && S_ISREG (stat_buf.st_mode))
 | 
					
						
							| 
									
										
										
										
											2020-03-08 15:39:23 +09:00
										 |  |  |  |     {
 | 
					
						
							|  |  |  |  |       if (read (fd, result, BUFSIZE) <= 0)
 | 
					
						
							|  |  |  |  |         exit (1);
 | 
					
						
							|  |  |  |  |     }
 | 
					
						
							| 
									
										
										
										
											2019-03-20 21:19:29 +00:00
										 |  |  |  |   else
 | 
					
						
							|  |  |  |  |     {
 | 
					
						
							|  |  |  |  |       FILE *f = fdopen (fd, "r");
 | 
					
						
							| 
									
										
										
										
											2020-03-08 15:39:23 +09:00
										 |  |  |  |       if (f == NULL)
 | 
					
						
							|  |  |  |  |         exit (1);
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       if (fread (result, 1, BUFSIZE, f) <= 0)
 | 
					
						
							|  |  |  |  |         exit (1);
 | 
					
						
							| 
									
										
										
										
											2019-03-20 21:19:29 +00:00
										 |  |  |  |     }
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   return 0;
 | 
					
						
							|  |  |  |  | }
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | int
 | 
					
						
							|  |  |  |  | main (void)
 | 
					
						
							|  |  |  |  | {
 | 
					
						
							|  |  |  |  |   exit (__getcmdline ());
 | 
					
						
							|  |  |  |  | }'''
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | if cc_can_run
 | 
					
						
							|  |  |  |  |   rres = cc.run(cmdline_test_code, name : '/proc/self/cmdline')
 | 
					
						
							|  |  |  |  |   have_proc_self_cmdline = rres.compiled() and rres.returncode() == 0
 | 
					
						
							|  |  |  |  | else
 | 
					
						
							|  |  |  |  |   have_proc_self_cmdline = meson.get_cross_property('have_proc_self_cmdline', false)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | glib_conf.set('HAVE_PROC_SELF_CMDLINE', have_proc_self_cmdline)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 17:03:22 +02:00
										 |  |  |  | python = import('python').find_installation('python3')
 | 
					
						
							|  |  |  |  | # used for '#!/usr/bin/env <name>'
 | 
					
						
							|  |  |  |  | python_name = 'python3'
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-20 11:52:03 +02:00
										 |  |  |  | python_version = python.language_version()
 | 
					
						
							| 
									
										
										
										
											2019-09-30 11:23:20 +01:00
										 |  |  |  | python_version_req = '>=3.5'
 | 
					
						
							| 
									
										
										
										
											2018-07-20 11:52:03 +02:00
										 |  |  |  | if not python_version.version_compare(python_version_req)
 | 
					
						
							|  |  |  |  |   error('Requires Python @0@, @1@ found.'.format(python_version_req, python_version))
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-27 16:48:11 +08:00
										 |  |  |  | # Determine which user environment-dependent files that we want to install
 | 
					
						
							|  |  |  |  | have_bash = find_program('bash', required : false).found() # For completion scripts
 | 
					
						
							| 
									
										
										
										
											2021-01-24 15:54:18 +01:00
										 |  |  |  | bash_comp_dep = dependency('bash-completion', version: '>=2.0', required: false)
 | 
					
						
							| 
									
										
										
										
											2017-07-27 16:48:11 +08:00
										 |  |  |  | have_sh = find_program('sh', required : false).found() # For glib-gettextize
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-12 11:29:10 +00:00
										 |  |  |  | # Some installed tests require a custom environment
 | 
					
						
							|  |  |  |  | env_program = find_program('env', required: installed_tests_enabled)
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-05 16:30:04 -04:00
										 |  |  |  | # FIXME: How to detect Solaris? https://github.com/mesonbuild/meson/issues/1578
 | 
					
						
							|  |  |  |  | if host_system == 'sunos'
 | 
					
						
							|  |  |  |  |   glib_conf.set('_XOPEN_SOURCE_EXTENDED', 1)
 | 
					
						
							|  |  |  |  |   glib_conf.set('_XOPEN_SOURCE', 2)
 | 
					
						
							|  |  |  |  |   glib_conf.set('__EXTENSIONS__',1)
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-03 11:13:40 -05:00
										 |  |  |  | # Sadly Meson does not expose this value:
 | 
					
						
							|  |  |  |  | # https://github.com/mesonbuild/meson/pull/3460
 | 
					
						
							|  |  |  |  | if host_system == 'windows'
 | 
					
						
							|  |  |  |  |   # Autotools explicitly removed --Wl,--export-all-symbols from windows builds,
 | 
					
						
							|  |  |  |  |   # with no explanation. Do the same here for now but this could be revisited if
 | 
					
						
							|  |  |  |  |   # if causes issues.
 | 
					
						
							|  |  |  |  |   export_dynamic_ldflags = []
 | 
					
						
							|  |  |  |  | elif host_system == 'cygwin'
 | 
					
						
							|  |  |  |  |   export_dynamic_ldflags = ['-Wl,--export-all-symbols']
 | 
					
						
							| 
									
										
										
										
											2020-05-29 00:31:35 +05:30
										 |  |  |  | elif host_system in ['darwin', 'ios']
 | 
					
						
							| 
									
										
										
										
											2018-01-03 11:13:40 -05:00
										 |  |  |  |   export_dynamic_ldflags = []
 | 
					
						
							| 
									
										
										
										
											2019-10-04 13:23:25 -07:00
										 |  |  |  | elif host_system == 'sunos'
 | 
					
						
							|  |  |  |  |   export_dynamic_ldflags = []
 | 
					
						
							| 
									
										
										
										
											2018-01-03 11:13:40 -05:00
										 |  |  |  | else
 | 
					
						
							|  |  |  |  |   export_dynamic_ldflags = ['-Wl,--export-dynamic']
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2018-05-15 15:17:28 -04:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | win32_cflags = []
 | 
					
						
							|  |  |  |  | win32_ldflags = []
 | 
					
						
							| 
									
										
										
										
											2019-07-10 00:22:51 +08:00
										 |  |  |  | if host_system == 'windows' and cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl'
 | 
					
						
							| 
									
										
										
										
											2018-05-15 15:17:28 -04:00
										 |  |  |  |   # Ensure MSVC-compatible struct packing convention is used when
 | 
					
						
							|  |  |  |  |   # compiling for Win32 with gcc. It is used for the whole project and exposed
 | 
					
						
							|  |  |  |  |   # in glib-2.0.pc.
 | 
					
						
							|  |  |  |  |   win32_cflags = ['-mms-bitfields']
 | 
					
						
							|  |  |  |  |   add_project_arguments(win32_cflags, language : 'c')
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |   # Win32 API libs, used only by libglib and exposed in glib-2.0.pc
 | 
					
						
							|  |  |  |  |   win32_ldflags = ['-lws2_32', '-lole32', '-lwinmm', '-lshlwapi']
 | 
					
						
							|  |  |  |  | elif host_system == 'cygwin'
 | 
					
						
							|  |  |  |  |   win32_ldflags = ['-luser32', '-lkernel32']
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-25 17:02:51 +00:00
										 |  |  |  | # Tracing: dtrace
 | 
					
						
							| 
									
										
										
										
											2017-11-28 10:44:04 -05:00
										 |  |  |  | want_dtrace = get_option('dtrace')
 | 
					
						
							| 
									
										
										
										
											2017-01-25 17:02:51 +00:00
										 |  |  |  | enable_dtrace = false
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | # Since dtrace support is opt-in we just error out if it was requested but
 | 
					
						
							|  |  |  |  | # is not available. We don't bother with autodetection yet.
 | 
					
						
							|  |  |  |  | if want_dtrace
 | 
					
						
							|  |  |  |  |   if glib_have_carbon
 | 
					
						
							|  |  |  |  |     error('GLib dtrace support not yet compatible with macOS dtrace')
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  |   dtrace = find_program('dtrace', required : true) # error out if not found
 | 
					
						
							|  |  |  |  |   if not cc.has_header('sys/sdt.h')
 | 
					
						
							|  |  |  |  |     error('dtrace support needs sys/sdt.h header')
 | 
					
						
							|  |  |  |  |   endif
 | 
					
						
							|  |  |  |  |   # FIXME: autotools build also passes -fPIC -DPIC but is it needed in this case?
 | 
					
						
							|  |  |  |  |   dtrace_obj_gen = generator(dtrace,
 | 
					
						
							|  |  |  |  |     output : '@BASENAME@.o',
 | 
					
						
							|  |  |  |  |     arguments : ['-G', '-s', '@INPUT@', '-o', '@OUTPUT@'])
 | 
					
						
							|  |  |  |  |   # FIXME: $(SED) -e "s,define STAP_HAS_SEMAPHORES 1,undef STAP_HAS_SEMAPHORES,"
 | 
					
						
							|  |  |  |  |   #               -e "s,define _SDT_HAS_SEMAPHORES 1,undef _SDT_HAS_SEMAPHORES,"
 | 
					
						
							|  |  |  |  |   dtrace_hdr_gen = generator(dtrace,
 | 
					
						
							|  |  |  |  |     output : '@BASENAME@.h',
 | 
					
						
							|  |  |  |  |     arguments : ['-h', '-s', '@INPUT@', '-o', '@OUTPUT@'])
 | 
					
						
							|  |  |  |  |   glib_conf.set('HAVE_DTRACE', 1)
 | 
					
						
							|  |  |  |  |   enable_dtrace = true
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | # systemtap
 | 
					
						
							| 
									
										
										
										
											2017-11-28 10:44:04 -05:00
										 |  |  |  | want_systemtap = get_option('systemtap')
 | 
					
						
							| 
									
										
										
										
											2017-01-25 17:02:51 +00:00
										 |  |  |  | enable_systemtap = false
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | if want_systemtap and enable_dtrace
 | 
					
						
							| 
									
										
										
										
											2017-11-28 10:44:04 -05:00
										 |  |  |  |   tapset_install_dir = get_option('tapset_install_dir')
 | 
					
						
							| 
									
										
										
										
											2017-01-25 17:02:51 +00:00
										 |  |  |  |   if tapset_install_dir == ''
 | 
					
						
							| 
									
										
										
										
											2017-11-28 14:03:11 +00:00
										 |  |  |  |     tapset_install_dir = join_paths(get_option('datadir'), 'systemtap/tapset', host_machine.cpu_family())
 | 
					
						
							| 
									
										
										
										
											2017-01-25 17:02:51 +00:00
										 |  |  |  |   endif
 | 
					
						
							|  |  |  |  |   stp_cdata = configuration_data()
 | 
					
						
							|  |  |  |  |   stp_cdata.set('ABS_GLIB_RUNTIME_LIBDIR', glib_libdir)
 | 
					
						
							| 
									
										
										
										
											2018-02-12 12:28:28 +00:00
										 |  |  |  |   stp_cdata.set('LT_CURRENT', minor_version * 100)
 | 
					
						
							|  |  |  |  |   stp_cdata.set('LT_REVISION', micro_version)
 | 
					
						
							| 
									
										
										
										
											2017-01-25 17:02:51 +00:00
										 |  |  |  |   enable_systemtap = true
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-01 09:38:40 +00:00
										 |  |  |  | test_timeout = 60
 | 
					
						
							| 
									
										
										
										
											2019-06-20 08:40:42 +01:00
										 |  |  |  | test_timeout_slow = 180
 | 
					
						
							| 
									
										
										
										
											2017-01-25 17:02:51 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 14:47:04 -05:00
										 |  |  |  | pkg = import('pkgconfig')
 | 
					
						
							| 
									
										
										
										
											2017-12-14 13:32:56 +01:00
										 |  |  |  | windows = import('windows')
 | 
					
						
							| 
									
										
										
										
											2013-08-07 23:41:12 +03:00
										 |  |  |  | subdir('glib')
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | subdir('gobject')
 | 
					
						
							|  |  |  |  | subdir('gthread')
 | 
					
						
							|  |  |  |  | subdir('gmodule')
 | 
					
						
							|  |  |  |  | subdir('gio')
 | 
					
						
							| 
									
										
										
										
											2018-10-11 00:02:03 +00:00
										 |  |  |  | subdir('fuzzing')
 | 
					
						
							| 
									
										
										
										
											2019-04-16 10:19:41 +00:00
										 |  |  |  | if build_tests
 | 
					
						
							|  |  |  |  |   subdir('tests')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-03-07 11:13:24 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-20 11:28:56 -05:00
										 |  |  |  | # xgettext is optional (on Windows for instance)
 | 
					
						
							|  |  |  |  | if find_program('xgettext', required : get_option('nls')).found()
 | 
					
						
							|  |  |  |  |   subdir('po')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-27 16:48:11 +08:00
										 |  |  |  | # Install glib-gettextize executable, if a UNIX-style shell is found
 | 
					
						
							|  |  |  |  | if have_sh
 | 
					
						
							| 
									
										
										
										
											2018-05-23 15:11:09 -04:00
										 |  |  |  |   # These should not contain " quotes around the values
 | 
					
						
							| 
									
										
										
										
											2018-09-02 20:35:26 +02:00
										 |  |  |  |   gettextize_conf = configuration_data()
 | 
					
						
							|  |  |  |  |   gettextize_conf.set('PACKAGE', 'glib')
 | 
					
						
							|  |  |  |  |   gettextize_conf.set('VERSION', meson.project_version())
 | 
					
						
							|  |  |  |  |   gettextize_conf.set('prefix', glib_prefix)
 | 
					
						
							|  |  |  |  |   gettextize_conf.set('datarootdir', glib_datadir)
 | 
					
						
							|  |  |  |  |   gettextize_conf.set('datadir', glib_datadir)
 | 
					
						
							| 
									
										
										
										
											2017-07-27 16:48:11 +08:00
										 |  |  |  |   configure_file(input : 'glib-gettextize.in',
 | 
					
						
							| 
									
										
										
										
											2018-08-31 15:58:38 +02:00
										 |  |  |  |     install_dir : glib_bindir,
 | 
					
						
							| 
									
										
										
										
											2017-07-27 16:48:11 +08:00
										 |  |  |  |     output : 'glib-gettextize',
 | 
					
						
							| 
									
										
										
										
											2018-09-02 20:35:26 +02:00
										 |  |  |  |     configuration : gettextize_conf)
 | 
					
						
							| 
									
										
										
										
											2017-07-27 16:48:11 +08:00
										 |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-10 12:44:59 +01:00
										 |  |  |  | # Install m4 macros that other projects use
 | 
					
						
							|  |  |  |  | install_data('m4macros/glib-2.0.m4', 'm4macros/glib-gettext.m4', 'm4macros/gsettings.m4',
 | 
					
						
							|  |  |  |  |   install_dir : join_paths(get_option('datadir'), 'aclocal'))
 | 
					
						
							| 
									
										
										
										
											2017-07-27 16:48:11 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | if host_system != 'windows'
 | 
					
						
							|  |  |  |  |   # Install Valgrind suppression file (except on Windows,
 | 
					
						
							|  |  |  |  |   # as Valgrind is currently not supported on Windows)
 | 
					
						
							|  |  |  |  |   install_data('glib.supp',
 | 
					
						
							|  |  |  |  |     install_dir : join_paths(get_option('datadir'), 'glib-2.0', 'valgrind'))
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-12-21 04:07:24 +05:30
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-23 15:11:09 -04:00
										 |  |  |  | configure_file(output : 'config.h', configuration : glib_conf)
 | 
					
						
							| 
									
										
										
										
											2016-12-06 08:07:03 -05:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-16 17:44:20 +08:00
										 |  |  |  | if host_system == 'windows'
 | 
					
						
							|  |  |  |  |   install_headers([ 'msvc_recommended_pragmas.h' ], subdir : 'glib-2.0')
 | 
					
						
							|  |  |  |  | endif
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-28 10:44:04 -05:00
										 |  |  |  | if get_option('man')
 | 
					
						
							|  |  |  |  |   xsltproc = find_program('xsltproc', required : true)
 | 
					
						
							| 
									
										
										
										
											2016-12-07 05:28:33 -05:00
										 |  |  |  |   xsltproc_command = [
 | 
					
						
							|  |  |  |  |     xsltproc,
 | 
					
						
							|  |  |  |  |     '--nonet',
 | 
					
						
							|  |  |  |  |     '--stringparam', 'man.output.quietly', '1',
 | 
					
						
							|  |  |  |  |     '--stringparam', 'funcsynopsis.style', 'ansi',
 | 
					
						
							|  |  |  |  |     '--stringparam', 'man.th.extra1.suppress', '1',
 | 
					
						
							|  |  |  |  |     '--stringparam', 'man.authors.section.enabled', '0',
 | 
					
						
							|  |  |  |  |     '--stringparam', 'man.copyright.section.enabled', '0',
 | 
					
						
							|  |  |  |  |     '-o', '@OUTPUT@',
 | 
					
						
							|  |  |  |  |     'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl',
 | 
					
						
							|  |  |  |  |     '@INPUT@',
 | 
					
						
							|  |  |  |  |   ]
 | 
					
						
							| 
									
										
										
										
											2020-02-07 16:34:13 +00:00
										 |  |  |  |   man1_dir = join_paths(glib_prefix, get_option('mandir'), 'man1')
 | 
					
						
							| 
									
										
										
										
											2016-12-06 08:07:03 -05:00
										 |  |  |  | endif
 | 
					
						
							| 
									
										
										
										
											2016-12-07 05:28:33 -05:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | gnome = import('gnome')
 | 
					
						
							| 
									
										
										
										
											2019-05-22 19:26:41 +02:00
										 |  |  |  | subdir('docs/reference')
 |