1project('glib', 'c', 'cpp', 2 version : '2.68.1', 3 # NOTE: We keep this pinned at 0.49 because that's what Debian 10 ships 4 meson_version : '>= 0.49.2', 5 default_options : [ 6 'buildtype=debugoptimized', 7 'warning_level=1', 8 'c_std=gnu99' 9 ] 10) 11 12cc = meson.get_compiler('c') 13cxx = meson.get_compiler('cpp') 14 15cc_can_run = not meson.is_cross_build() or meson.has_exe_wrapper() 16 17if cc.get_id() == 'msvc' 18 # Ignore several spurious warnings for things glib does very commonly 19 # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it 20 # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once 21 # NOTE: Only add warnings here if you are sure they're spurious 22 add_project_arguments('/wd4035', '/wd4715', '/wd4116', 23 '/wd4046', '/wd4068', '/wo4090', '/FImsvc_recommended_pragmas.h',language : 'c') 24 # Disable SAFESEH with MSVC for plugins and libs that use external deps that 25 # are built with MinGW 26 noseh_link_args = ['/SAFESEH:NO'] 27 # Set the input and exec encoding to utf-8, like is the default with GCC 28 add_project_arguments(cc.get_supported_arguments(['/utf-8']), language: 'c') 29else 30 noseh_link_args = [] 31 # -mms-bitfields vs -fnative-struct ? 32endif 33 34host_system = host_machine.system() 35 36if host_system == 'darwin' 37 ios_test_code = '''#include <TargetConditionals.h> 38 #if ! TARGET_OS_IPHONE 39 #error "Not iOS/tvOS/watchOS/iPhoneSimulator" 40 #endif''' 41 if cc.compiles(ios_test_code, name : 'building for iOS') 42 host_system = 'ios' 43 endif 44endif 45 46glib_version = meson.project_version() 47glib_api_version = '2.0' 48version_arr = glib_version.split('.') 49major_version = version_arr[0].to_int() 50minor_version = version_arr[1].to_int() 51micro_version = version_arr[2].to_int() 52 53interface_age = minor_version.is_odd() ? 0 : micro_version 54binary_age = 100 * minor_version + micro_version 55 56soversion = 0 57# Maintain compatibility with previous libtool versioning 58# current = minor * 100 + micro 59current = binary_age - interface_age 60library_version = '@0@.@1@.@2@'.format(soversion, current, interface_age) 61darwin_versions = [current + 1, '@0@.@1@'.format(current + 1, interface_age)] 62 63configinc = include_directories('.') 64glibinc = include_directories('glib') 65gobjectinc = include_directories('gobject') 66gmoduleinc = include_directories('gmodule') 67gioinc = include_directories('gio') 68 69glib_prefix = get_option('prefix') 70glib_bindir = join_paths(glib_prefix, get_option('bindir')) 71glib_libdir = join_paths(glib_prefix, get_option('libdir')) 72glib_libexecdir = join_paths(glib_prefix, get_option('libexecdir')) 73glib_datadir = join_paths(glib_prefix, get_option('datadir')) 74glib_pkgdatadir = join_paths(glib_datadir, 'glib-2.0') 75glib_includedir = join_paths(glib_prefix, get_option('includedir')) 76if get_option('gio_module_dir') != '' 77 glib_giomodulesdir = join_paths(glib_prefix, get_option('gio_module_dir')) 78else 79 glib_giomodulesdir = join_paths(glib_libdir, 'gio', 'modules') 80endif 81 82glib_pkgconfigreldir = join_paths(glib_libdir, 'pkgconfig') 83 84if get_option('charsetalias_dir') != '' 85 glib_charsetaliasdir = join_paths(glib_prefix, get_option('charsetalias_dir')) 86else 87 glib_charsetaliasdir = glib_libdir 88endif 89 90glib_localstatedir = get_option('localstatedir') 91if not glib_localstatedir.startswith('/') 92 # See https://mesonbuild.com/Builtin-options.html#directories 93 glib_localstatedir = join_paths(glib_prefix, glib_localstatedir) 94endif 95 96installed_tests_metadir = join_paths(glib_datadir, 'installed-tests', meson.project_name()) 97installed_tests_execdir = join_paths(glib_libexecdir, 'installed-tests', meson.project_name()) 98installed_tests_enabled = get_option('installed_tests') 99installed_tests_template = files('template.test.in') 100installed_tests_template_tap = files('template-tap.test.in') 101 102# Don’t build the tests unless we can run them (either natively, in an exe wrapper, or by installing them for later use) 103build_tests = get_option('tests') and (not meson.is_cross_build() or (meson.is_cross_build() and meson.has_exe_wrapper()) or installed_tests_enabled) 104 105add_project_arguments('-D_GNU_SOURCE', language: 'c') 106 107if host_system == 'qnx' 108 add_project_arguments('-D_QNX_SOURCE', language: 'c') 109endif 110 111# Disable strict aliasing; 112# see https://bugzilla.gnome.org/show_bug.cgi?id=791622 113if cc.has_argument('-fno-strict-aliasing') 114 add_project_arguments('-fno-strict-aliasing', language: 'c') 115endif 116 117######################## 118# Configuration begins # 119######################## 120glib_conf = configuration_data() 121glibconfig_conf = configuration_data() 122 123# accumulated list of defines as we check for them, so we can easily 124# use them later in test programs (autoconf does this automatically) 125glib_conf_prefix = '' 126 127glib_conf.set('GLIB_MAJOR_VERSION', major_version) 128glib_conf.set('GLIB_MINOR_VERSION', minor_version) 129glib_conf.set('GLIB_MICRO_VERSION', micro_version) 130glib_conf.set('GLIB_INTERFACE_AGE', interface_age) 131glib_conf.set('GLIB_BINARY_AGE', binary_age) 132glib_conf.set_quoted('GETTEXT_PACKAGE', 'glib20') 133glib_conf.set_quoted('PACKAGE_BUGREPORT', 'https://gitlab.gnome.org/GNOME/glib/issues/new') 134glib_conf.set_quoted('PACKAGE_NAME', 'glib') 135glib_conf.set_quoted('PACKAGE_STRING', 'glib @0@'.format(meson.project_version())) 136glib_conf.set_quoted('PACKAGE_TARNAME', 'glib') 137glib_conf.set_quoted('PACKAGE_URL', '') 138glib_conf.set_quoted('PACKAGE_VERSION', meson.project_version()) 139glib_conf.set('ENABLE_NLS', 1) 140 141# used by the .rc.in files 142glibconfig_conf.set('LT_CURRENT_MINUS_AGE', soversion) 143 144glib_conf.set('_GNU_SOURCE', 1) 145 146if host_system == 'windows' 147 # Poll doesn't work on devices on Windows 148 glib_conf.set('BROKEN_POLL', true) 149endif 150 151if host_system == 'windows' and cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl' 152 # FIXME: Ideally we shouldn't depend on this on Windows and should use 153 # 64 bit capable Windows API that also works with MSVC. 154 # The autotools build did set this for mingw and while meson sets it 155 # for gcc/clang by default, it doesn't do so on Windows. 156 glib_conf.set('_FILE_OFFSET_BITS', 64) 157endif 158 159# Check for GNU visibility attributes 160g_have_gnuc_visibility = cc.compiles(''' 161 void 162 __attribute__ ((visibility ("hidden"))) 163 f_hidden (void) 164 { 165 } 166 void 167 __attribute__ ((visibility ("internal"))) 168 f_internal (void) 169 { 170 } 171 void 172 __attribute__ ((visibility ("default"))) 173 f_default (void) 174 { 175 } 176 int main (void) 177 { 178 f_hidden(); 179 f_internal(); 180 f_default(); 181 return 0; 182 } 183 ''', 184 # Not supported by MSVC, but MSVC also won't support visibility, 185 # so it's OK to pass -Werror explicitly. Replace with 186 # override_options : 'werror=true' once that is supported 187 args: ['-Werror'], 188 name : 'GNU C visibility attributes test') 189 190if g_have_gnuc_visibility 191 glibconfig_conf.set('G_HAVE_GNUC_VISIBILITY', '1') 192endif 193 194# Detect and set symbol visibility 195glib_hidden_visibility_args = [] 196if get_option('default_library') != 'static' 197 if host_system == 'windows' or host_system == 'cygwin' 198 glib_conf.set('DLL_EXPORT', true) 199 if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl' 200 glib_conf.set('_GLIB_EXTERN', '__declspec(dllexport) extern') 201 elif cc.has_argument('-fvisibility=hidden') 202 glib_conf.set('_GLIB_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) extern') 203 glib_hidden_visibility_args = ['-fvisibility=hidden'] 204 endif 205 elif cc.has_argument('-fvisibility=hidden') 206 glib_conf.set('_GLIB_EXTERN', '__attribute__((visibility("default"))) extern') 207 glib_hidden_visibility_args = ['-fvisibility=hidden'] 208 endif 209endif 210 211if get_option('default_library') == 'static' 212 glibconfig_conf.set('GLIB_STATIC_COMPILATION', '1') 213 glibconfig_conf.set('GOBJECT_STATIC_COMPILATION', '1') 214endif 215 216# Cygwin glib port maintainers made it clear 217# (via the patches they apply) that they want no 218# part of glib W32 code, therefore we do not define 219# G_PLATFORM_WIN32 for host_system == 'cygwin'. 220# This makes G_PLATFORM_WIN32 a synonym for 221# G_OS_WIN32. 222if host_system == 'windows' 223 glib_os = '''#define G_OS_WIN32 224#define G_PLATFORM_WIN32''' 225elif host_system == 'cygwin' 226 glib_os = '''#define G_OS_UNIX 227#define G_WITH_CYGWIN''' 228else 229 glib_os = '#define G_OS_UNIX' 230endif 231glibconfig_conf.set('glib_os', glib_os) 232 233# We need to know the CRT being used to determine what .lib files we need on 234# Visual Studio for dependencies that don't normally come with pkg-config files 235vs_crt = 'release' 236vs_crt_opt = get_option('b_vscrt') 237if vs_crt_opt in ['mdd', 'mtd'] 238 vs_crt = 'debug' 239elif vs_crt_opt == 'from_buildtype' 240 if get_option('buildtype') == 'debug' 241 vs_crt = 'debug' 242 endif 243endif 244 245# Use debug/optimization flags to determine whether to enable debug or disable 246# cast checks 247glib_debug_cflags = [] 248glib_debug = get_option('glib_debug') 249if glib_debug.enabled() or (glib_debug.auto() and get_option('debug')) 250 glib_debug_cflags += ['-DG_ENABLE_DEBUG'] 251 message('Enabling various debug infrastructure') 252elif get_option('optimization') in ['2', '3', 's'] 253 glib_debug_cflags += ['-DG_DISABLE_CAST_CHECKS'] 254 message('Disabling cast checks') 255endif 256 257if not get_option('glib_assert') 258 glib_debug_cflags += ['-DG_DISABLE_ASSERT'] 259 message('Disabling GLib asserts') 260endif 261 262if not get_option('glib_checks') 263 glib_debug_cflags += ['-DG_DISABLE_CHECKS'] 264 message('Disabling GLib checks') 265endif 266 267add_project_arguments(glib_debug_cflags, language: 'c') 268 269# check for header files 270 271headers = [ 272 'alloca.h', 273 'crt_externs.h', 274 'dirent.h', # MSC does not come with this by default 275 'float.h', 276 'fstab.h', 277 'grp.h', 278 'inttypes.h', 279 'limits.h', 280 'linux/magic.h', 281 'locale.h', 282 'mach/mach_time.h', 283 'memory.h', 284 'mntent.h', 285 'poll.h', 286 'pwd.h', 287 'sched.h', 288 'spawn.h', 289 'stdatomic.h', 290 'stdint.h', 291 'stdlib.h', 292 'string.h', 293 'strings.h', 294 'sys/auxv.h', 295 'sys/event.h', 296 'sys/filio.h', 297 'sys/inotify.h', 298 'sys/mkdev.h', 299 'sys/mntctl.h', 300 'sys/mnttab.h', 301 'sys/mount.h', 302 'sys/param.h', 303 'sys/resource.h', 304 'sys/select.h', 305 'sys/statfs.h', 306 'sys/stat.h', 307 'sys/statvfs.h', 308 'sys/sysctl.h', 309 'sys/time.h', # MSC does not come with this by default 310 'sys/times.h', 311 'sys/types.h', 312 'sys/uio.h', 313 'sys/vfs.h', 314 'sys/vfstab.h', 315 'sys/vmount.h', 316 'sys/wait.h', 317 'termios.h', 318 'unistd.h', 319 'values.h', 320 'wchar.h', 321 'xlocale.h', 322] 323 324foreach h : headers 325 if cc.has_header(h) 326 define = 'HAVE_' + h.underscorify().to_upper() 327 glib_conf.set(define, 1) 328 glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(define) 329 endif 330endforeach 331 332# FIXME: Use cc.check_header from Meson 0.47. 333# FreeBSD includes a malloc.h which always throw compilation error. 334if cc.compiles('#include <malloc.h>', name : 'malloc.h') 335 glib_conf.set('HAVE_MALLOC_H', 1) 336 glib_conf_prefix = glib_conf_prefix + '#define HAVE_MALLOC_H 1\n' 337endif 338 339if cc.has_header('linux/netlink.h') 340 glib_conf.set('HAVE_NETLINK', 1) 341endif 342 343# Is statx() supported? Android systems don’t reliably support it as of August 2020. 344statx_code = ''' 345 #ifndef _GNU_SOURCE 346 #define _GNU_SOURCE 347 #endif 348 #include <sys/stat.h> 349 #include <fcntl.h> 350 int main (void) 351 { 352 struct statx stat_buf; 353 return statx (AT_FDCWD, "/", AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS | STATX_BTIME, &stat_buf); 354 } 355 ''' 356if host_system != 'android' and cc.compiles(statx_code, name : 'statx() test') 357 glib_conf.set('HAVE_STATX', 1) 358endif 359 360if glib_conf.has('HAVE_LOCALE_H') 361 if cc.has_header_symbol('locale.h', 'LC_MESSAGES') 362 glib_conf.set('HAVE_LC_MESSAGES', 1) 363 endif 364endif 365 366struct_stat_blkprefix = ''' 367#include <sys/types.h> 368#include <sys/stat.h> 369#ifdef HAVE_UNISTD_H 370#include <unistd.h> 371#endif 372#ifdef HAVE_SYS_STATFS_H 373#include <sys/statfs.h> 374#endif 375#ifdef HAVE_SYS_PARAM_H 376#include <sys/param.h> 377#endif 378#ifdef HAVE_SYS_MOUNT_H 379#include <sys/mount.h> 380#endif 381''' 382 383struct_members = [ 384 [ 'stat', 'st_mtimensec' ], 385 [ 'stat', 'st_mtim.tv_nsec' ], 386 [ 'stat', 'st_atimensec' ], 387 [ 'stat', 'st_atim.tv_nsec' ], 388 [ 'stat', 'st_ctimensec' ], 389 [ 'stat', 'st_ctim.tv_nsec' ], 390 [ 'stat', 'st_birthtime' ], 391 [ 'stat', 'st_birthtimensec' ], 392 [ 'stat', 'st_birthtim' ], 393 [ 'stat', 'st_birthtim.tv_nsec' ], 394 [ 'stat', 'st_blksize', struct_stat_blkprefix ], 395 [ 'stat', 'st_blocks', struct_stat_blkprefix ], 396 [ 'statfs', 'f_fstypename', struct_stat_blkprefix ], 397 [ 'statfs', 'f_bavail', struct_stat_blkprefix ], 398 [ 'dirent', 'd_type', '''#include <sys/types.h> 399 #include <dirent.h>''' ], 400 [ 'statvfs', 'f_basetype', '#include <sys/statvfs.h>' ], 401 [ 'statvfs', 'f_fstypename', '#include <sys/statvfs.h>' ], 402 [ 'tm', 'tm_gmtoff', '#include <time.h>' ], 403 [ 'tm', '__tm_gmtoff', '#include <time.h>' ], 404] 405 406foreach m : struct_members 407 header_check_prefix = glib_conf_prefix 408 if m.length() == 3 409 header_check_prefix = header_check_prefix + m[2] 410 else 411 header_check_prefix = header_check_prefix + '#include <sys/stat.h>' 412 endif 413 if cc.has_member('struct ' + m[0], m[1], prefix : header_check_prefix) 414 define = 'HAVE_STRUCT_@0@_@1@'.format(m[0].to_upper(), m[1].underscorify().to_upper()) 415 glib_conf.set(define, 1) 416 glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(define) 417 else 418 endif 419endforeach 420 421# Compiler flags 422if cc.get_id() == 'gcc' or cc.get_id() == 'clang' 423 warning_c_args = [ 424 '-Wduplicated-branches', 425 '-Wimplicit-fallthrough', 426 '-Wmisleading-indentation', 427 '-Wstrict-prototypes', 428 '-Wunused', 429 # Due to maintained deprecated code, we do not want to see unused parameters 430 '-Wno-unused-parameter', 431 # Due to pervasive use of things like GPOINTER_TO_UINT(), we do not support 432 # building with -Wbad-function-cast. 433 '-Wno-bad-function-cast', 434 '-Wno-cast-function-type', 435 # Due to function casts through (void*) we cannot support -Wpedantic: 436 # https://wiki.gnome.org/Projects/GLib/CompilerRequirements#Function_pointer_conversions. 437 '-Wno-pedantic', 438 # A zero-length format string shouldn't be considered an issue. 439 '-Wno-format-zero-length', 440 '-Werror=declaration-after-statement', 441 '-Werror=format=2', 442 '-Werror=implicit-function-declaration', 443 '-Werror=init-self', 444 '-Werror=missing-include-dirs', 445 '-Werror=missing-prototypes', 446 '-Werror=pointer-arith', 447 ] 448 warning_c_link_args = [ 449 '-Wl,-z,nodelete', 450 ] 451 if get_option('bsymbolic_functions') 452 warning_c_link_args += ['-Wl,-Bsymbolic-functions'] 453 endif 454else 455 warning_c_args = [] 456 warning_c_link_args = [] 457endif 458 459add_project_arguments(cc.get_supported_arguments(warning_c_args), language: 'c') 460 461# FIXME: We cannot build some of the GResource tests with -z nodelete, which 462# means we cannot use that flag in add_project_link_arguments(), and must add 463# it to the relevant targets manually. We do the same with -Bsymbolic-functions 464# because that is what the autotools build did. 465# See https://github.com/mesonbuild/meson/pull/3520 for a way to eventually 466# improve this. 467glib_link_flags = cc.get_supported_link_arguments(warning_c_link_args) 468 469# Windows SDK requirements and checks 470if host_system == 'windows' 471 # Check whether we're building for UWP apps 472 code = ''' 473 #include <windows.h> 474 #if !(WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) 475 #error "Not building for UWP" 476 #endif''' 477 if cc.compiles(code, name : 'building for UWP') 478 glib_conf.set('G_WINAPI_ONLY_APP', true) 479 # We require Windows 10+ on WinRT 480 glib_conf.set('_WIN32_WINNT', '0x0A00') 481 uwp_gio_deps = [cc.find_library('shcore'), 482 cc.find_library('runtimeobject')] 483 else 484 # We require Windows 7+ on Win32 485 glib_conf.set('_WIN32_WINNT', '0x0601') 486 uwp_gio_deps = [] 487 endif 488endif 489 490functions = [ 491 'close_range', 492 'endmntent', 493 'endservent', 494 'epoll_create', 495 'fallocate', 496 'fchmod', 497 'fchown', 498 'fdwalk', 499 'fsync', 500 'getauxval', 501 'getc_unlocked', 502 'getfsstat', 503 'getgrgid_r', 504 'getmntent_r', 505 'getpwuid_r', 506 'getresuid', 507 'getvfsstat', 508 'gmtime_r', 509 'hasmntopt', 510 'inotify_init1', 511 'issetugid', 512 'kevent', 513 'kqueue', 514 'lchmod', 515 'lchown', 516 'link', 517 'localtime_r', 518 'lstat', 519 'mbrtowc', 520 'memalign', 521 'mmap', 522 'newlocale', 523 'pipe2', 524 'poll', 525 'prlimit', 526 'readlink', 527 'recvmmsg', 528 'sendmmsg', 529 'setenv', 530 'setmntent', 531 'strerror_r', 532 'strnlen', 533 'strsignal', 534 'strtod_l', 535 'strtoll_l', 536 'strtoull_l', 537 'symlink', 538 'timegm', 539 'unsetenv', 540 'uselocale', 541 'utimes', 542 'valloc', 543 'vasprintf', 544 'vsnprintf', 545 'wcrtomb', 546 'wcslen', 547 'wcsnlen', 548 'sysctlbyname', 549] 550 551# _NSGetEnviron is available on iOS too, but its usage gets apps rejected from 552# the app store since it's considered 'private API' 553if host_system == 'darwin' 554 functions += ['_NSGetEnviron'] 555endif 556 557if glib_conf.has('HAVE_SYS_STATVFS_H') 558 functions += ['statvfs'] 559else 560 have_func_statvfs = false 561endif 562if glib_conf.has('HAVE_SYS_STATFS_H') or glib_conf.has('HAVE_SYS_MOUNT_H') 563 functions += ['statfs'] 564else 565 have_func_statfs = false 566endif 567 568if host_system == 'windows' 569 iphlpapi_dep = cc.find_library('iphlpapi') 570 iphlpapi_funcs = ['if_nametoindex', 'if_indextoname'] 571 foreach ifunc : iphlpapi_funcs 572 iphl_prefix = '''#define _WIN32_WINNT @0@ 573 #include <winsock2.h> 574 #include <iphlpapi.h>'''.format(glib_conf.get('_WIN32_WINNT')) 575 if cc.has_function(ifunc, 576 prefix : iphl_prefix, 577 dependencies : iphlpapi_dep) 578 idefine = 'HAVE_' + ifunc.underscorify().to_upper() 579 glib_conf.set(idefine, 1) 580 glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(idefine) 581 set_variable('have_func_' + ifunc, true) 582 else 583 set_variable('have_func_' + ifunc, false) 584 endif 585 endforeach 586else 587 functions += ['if_indextoname', 'if_nametoindex'] 588endif 589 590# AIX splice is something else 591if host_system != 'aix' 592 functions += ['splice'] 593endif 594 595foreach f : functions 596 if cc.has_function(f) 597 define = 'HAVE_' + f.underscorify().to_upper() 598 glib_conf.set(define, 1) 599 glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(define) 600 set_variable('have_func_' + f, true) 601 else 602 set_variable('have_func_' + f, false) 603 endif 604endforeach 605 606# Check that stpcpy() is usable; must use header. 607# cc.has_function() in some cases (clang, gcc 10+) assumes that if the 608# compiler provides a builtin of the same name that the function exists, while 609# it's in fact not provided by any header or library. This is true for 610# stpcpy() on Windows using clang and gcc as well as posix_memalign() using 611# gcc on Windows. Skip these checks on Windows for now to avoid false 612# positives. See https://github.com/mesonbuild/meson/pull/7116, 613# https://github.com/mesonbuild/meson/issues/3672 and 614# https://github.com/mesonbuild/meson/issues/5628. 615# FIXME: Once meson no longer returns success for stpcpy() and 616# posix_memalign() on Windows using GCC and clang we can remove this. 617if host_system != 'windows' and cc.has_function('stpcpy', prefix : '#include <string.h>') 618 glib_conf.set('HAVE_STPCPY', 1) 619endif 620 621# When building for Android-20 and earlier, require Meson 0.54.2 or newer. 622# This is needed, because Meson build versions prior to 0.54.2 return false 623# positive for stpcpy has_function check when building for legacy Android. 624if host_system == 'android' 625 android_is_older = cc.compiles('''#if __ANDROID_API__ >= 21 626 #error Android is 21 or newer 627 #endif''') 628 if android_is_older and meson.version().version_compare('< 0.54.2') 629 error('Compiling for <Android-21 requires Meson 0.54.2 or newer') 630 endif 631endif 632 633 634# Check that posix_memalign() is usable; must use header 635if host_system != 'windows' and cc.has_function('posix_memalign', prefix : '#include <stdlib.h>') 636 glib_conf.set('HAVE_POSIX_MEMALIGN', 1) 637endif 638 639# Check that posix_spawn() is usable; must use header 640if cc.has_function('posix_spawn', prefix : '#include <spawn.h>') 641 glib_conf.set('HAVE_POSIX_SPAWN', 1) 642endif 643 644# Check whether strerror_r returns char * 645if have_func_strerror_r 646 if cc.compiles('''#define _GNU_SOURCE 647 #include <string.h> 648 int func (void) { 649 char error_string[256]; 650 char *ptr = strerror_r (-2, error_string, 256); 651 char c = *strerror_r (-2, error_string, 256); 652 return c != 0 && ptr != (void*) 0L; 653 } 654 ''', 655 name : 'strerror_r() returns char *') 656 glib_conf.set('STRERROR_R_CHAR_P', 1, 657 description: 'Defined if strerror_r returns char *') 658 endif 659endif 660 661# Special-case these functions that have alternative names on Windows/MSVC 662if cc.has_function('snprintf') or cc.has_header_symbol('stdio.h', 'snprintf') 663 glib_conf.set('HAVE_SNPRINTF', 1) 664 glib_conf_prefix = glib_conf_prefix + '#define HAVE_SNPRINTF 1\n' 665elif cc.has_function('_snprintf') or cc.has_header_symbol('stdio.h', '_snprintf') 666 hack_define = '1\n#define snprintf _snprintf' 667 glib_conf.set('HAVE_SNPRINTF', hack_define) 668 glib_conf_prefix = glib_conf_prefix + '#define HAVE_SNPRINTF ' + hack_define 669endif 670 671if cc.has_function('strcasecmp', prefix: '#include <strings.h>') 672 glib_conf.set('HAVE_STRCASECMP', 1) 673 glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRCASECMP 1\n' 674elif cc.has_function('_stricmp') 675 hack_define = '1\n#define strcasecmp _stricmp' 676 glib_conf.set('HAVE_STRCASECMP', hack_define) 677 glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRCASECMP ' + hack_define 678endif 679 680if cc.has_function('strncasecmp', prefix: '#include <strings.h>') 681 glib_conf.set('HAVE_STRNCASECMP', 1) 682 glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRNCASECMP 1\n' 683elif cc.has_function('_strnicmp') 684 hack_define = '1\n#define strncasecmp _strnicmp' 685 glib_conf.set('HAVE_STRNCASECMP', hack_define) 686 glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRNCASECMP ' + hack_define 687endif 688 689if cc.has_header_symbol('sys/sysmacros.h', 'major') 690 glib_conf.set('MAJOR_IN_SYSMACROS', 1) 691elif cc.has_header_symbol('sys/mkdev.h', 'major') 692 glib_conf.set('MAJOR_IN_MKDEV', 1) 693elif cc.has_header_symbol('sys/types.h', 'major') 694 glib_conf.set('MAJOR_IN_TYPES', 1) 695endif 696 697if cc.has_header_symbol('dlfcn.h', 'RTLD_LAZY') 698 glib_conf.set('HAVE_RTLD_LAZY', 1) 699endif 700 701if cc.has_header_symbol('dlfcn.h', 'RTLD_NOW') 702 glib_conf.set('HAVE_RTLD_NOW', 1) 703endif 704 705if cc.has_header_symbol('dlfcn.h', 'RTLD_GLOBAL') 706 glib_conf.set('HAVE_RTLD_GLOBAL', 1) 707endif 708 709have_rtld_next = false 710if cc.has_header_symbol('dlfcn.h', 'RTLD_NEXT', args: '-D_GNU_SOURCE') 711 have_rtld_next = true 712 glib_conf.set('HAVE_RTLD_NEXT', 1) 713endif 714 715# Check whether to use statfs or statvfs 716# Some systems have both statfs and statvfs, pick the most "native" for these 717if have_func_statfs and have_func_statvfs 718 # on solaris and irix, statfs doesn't even have the f_bavail field 719 if not glib_conf.has('HAVE_STRUCT_STATFS_F_BAVAIL') 720 have_func_statfs = false 721 else 722 # at least on linux, statfs is the actual syscall 723 have_func_statvfs = false 724 endif 725endif 726if have_func_statfs 727 glib_conf.set('USE_STATFS', 1) 728 stat_func_to_use = 'statfs' 729elif have_func_statvfs 730 glib_conf.set('USE_STATVFS', 1) 731 stat_func_to_use = 'statvfs' 732else 733 stat_func_to_use = 'neither' 734endif 735message('Checking whether to use statfs or statvfs .. ' + stat_func_to_use) 736 737if host_system == 'linux' 738 if cc.has_function('mkostemp', 739 prefix: '''#define _GNU_SOURCE 740 #include <stdlib.h>''') 741 glib_conf.set('HAVE_MKOSTEMP', 1) 742 endif 743endif 744 745osx_ldflags = [] 746glib_have_os_x_9_or_later = false 747glib_have_carbon = false 748glib_have_cocoa = false 749if host_system == 'darwin' 750 add_languages('objc') 751 objcc = meson.get_compiler('objc') 752 753 osx_ldflags += ['-Wl,-framework,CoreFoundation'] 754 755 # Mac OS X Carbon support 756 glib_have_carbon = objcc.compiles('''#include <Carbon/Carbon.h> 757 #include <CoreServices/CoreServices.h>''', 758 name : 'Mac OS X Carbon support') 759 760 if glib_have_carbon 761 glib_conf.set('HAVE_CARBON', true) 762 osx_ldflags += '-Wl,-framework,Carbon' 763 glib_have_os_x_9_or_later = objcc.compiles('''#include <AvailabilityMacros.h> 764 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 765 #error Compiling for minimum OS X version before 10.9 766 #endif''', 767 name : 'OS X 9 or later') 768 endif 769 770 # Mac OS X Cocoa support 771 glib_have_cocoa = objcc.compiles('''#include <Cocoa/Cocoa.h> 772 #ifdef GNUSTEP_BASE_VERSION 773 #error "Detected GNUstep, not Cocoa" 774 #endif''', 775 name : 'Mac OS X Cocoa support') 776 777 if glib_have_cocoa 778 glib_conf.set('HAVE_COCOA', true) 779 osx_ldflags += ['-Wl,-framework,Foundation', '-Wl,-framework,AppKit'] 780 endif 781 782 # FIXME: libgio mix C and objC source files and there is no way to reliably 783 # know which language flags it's going to use to link. Add to both languages 784 # for now. See https://github.com/mesonbuild/meson/issues/3585. 785 add_project_link_arguments(osx_ldflags, language : ['objc', 'c']) 786endif 787 788if host_system == 'qnx' 789 glib_conf.set('HAVE_QNX', 1) 790endif 791 792# Check for futex(2) 793if cc.links('''#include <linux/futex.h> 794 #include <sys/syscall.h> 795 #include <unistd.h> 796 int main (int argc, char ** argv) { 797 syscall (__NR_futex, NULL, FUTEX_WAKE, FUTEX_WAIT); 798 return 0; 799 }''', name : 'futex(2) system call') 800 glib_conf.set('HAVE_FUTEX', 1) 801endif 802 803# Check for eventfd(2) 804if cc.links('''#include <sys/eventfd.h> 805 #include <unistd.h> 806 int main (int argc, char ** argv) { 807 eventfd (0, EFD_CLOEXEC); 808 return 0; 809 }''', name : 'eventfd(2) system call') 810 glib_conf.set('HAVE_EVENTFD', 1) 811endif 812 813# Check for __uint128_t (gcc) by checking for 128-bit division 814uint128_t_src = '''int main() { 815static __uint128_t v1 = 100; 816static __uint128_t v2 = 10; 817static __uint128_t u; 818u = v1 / v2; 819}''' 820if cc.compiles(uint128_t_src, name : '__uint128_t available') 821 glib_conf.set('HAVE_UINT128_T', 1) 822endif 823 824clock_gettime_test_code = ''' 825 #include <time.h> 826 struct timespec t; 827 int main (int argc, char ** argv) { 828 return clock_gettime(CLOCK_REALTIME, &t); 829 }''' 830librt = [] 831if cc.links(clock_gettime_test_code, name : 'clock_gettime') 832 glib_conf.set('HAVE_CLOCK_GETTIME', 1) 833elif cc.links(clock_gettime_test_code, args : '-lrt', name : 'clock_gettime in librt') 834 glib_conf.set('HAVE_CLOCK_GETTIME', 1) 835 librt = cc.find_library('rt') 836endif 837 838dlopen_dlsym_test_code = ''' 839#include <dlfcn.h> 840int glib_underscore_test (void) { return 42; } 841int main (int argc, char ** argv) { 842 void *f1 = (void*)0, *f2 = (void*)0, *handle; 843 handle = dlopen ((void*)0, 0); 844 if (handle) { 845 f1 = dlsym (handle, "glib_underscore_test"); 846 f2 = dlsym (handle, "_glib_underscore_test"); 847 } 848 return (!f2 || f1); 849}''' 850libdl_dep = [] 851if cc.links(dlopen_dlsym_test_code, name : 'dlopen() and dlsym() in system libraries') 852 have_dlopen_dlsym = true 853elif cc.links(dlopen_dlsym_test_code, args : '-ldl', name : 'dlopen() and dlsym() in libdl') 854 have_dlopen_dlsym = true 855 libdl_dep = cc.find_library('dl') 856else 857 have_dlopen_dlsym = false 858endif 859 860# if statfs() takes 2 arguments (Posix) or 4 (Solaris) 861if have_func_statfs 862 if cc.compiles(glib_conf_prefix + ''' 863 #include <unistd.h> 864 #ifdef HAVE_SYS_PARAM_H 865 #include <sys/param.h> 866 #endif 867 #ifdef HAVE_SYS_VFS_H 868 #include <sys/vfs.h> 869 #endif 870 #ifdef HAVE_SYS_MOUNT_H 871 #include <sys/mount.h> 872 #endif 873 #ifdef HAVE_SYS_STATFS_H 874 #include <sys/statfs.h> 875 #endif 876 void some_func (void) { 877 struct statfs st; 878 statfs("/", &st); 879 }''', name : 'number of arguments to statfs() (n=2)') 880 glib_conf.set('STATFS_ARGS', 2) 881 elif cc.compiles(glib_conf_prefix + ''' 882 #include <unistd.h> 883 #ifdef HAVE_SYS_PARAM_H 884 #include <sys/param.h> 885 #endif 886 #ifdef HAVE_SYS_VFS_H 887 #include <sys/vfs.h> 888 #endif 889 #ifdef HAVE_SYS_MOUNT_H 890 #include <sys/mount.h> 891 #endif 892 #ifdef HAVE_SYS_STATFS_H 893 #include <sys/statfs.h> 894 #endif 895 void some_func (void) { 896 struct statfs st; 897 statfs("/", &st, sizeof (st), 0); 898 }''', name : 'number of arguments to statfs() (n=4)') 899 glib_conf.set('STATFS_ARGS', 4) 900 else 901 error('Unable to determine number of arguments to statfs()') 902 endif 903endif 904 905# open takes O_DIRECTORY as an option 906#AC_MSG_CHECKING([]) 907if cc.compiles('''#include <fcntl.h> 908 #include <sys/types.h> 909 #include <sys/stat.h> 910 void some_func (void) { 911 open(0, O_DIRECTORY, 0); 912 }''', name : 'open() option O_DIRECTORY') 913 glib_conf.set('HAVE_OPEN_O_DIRECTORY', 1) 914endif 915 916# fcntl takes F_FULLFSYNC as an option 917# See https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fsync.2.html 918if cc.compiles('''#include <fcntl.h> 919 #include <sys/types.h> 920 #include <sys/stat.h> 921 void some_func (void) { 922 fcntl(0, F_FULLFSYNC, 0); 923 }''', name : 'fcntl() option F_FULLFSYNC') 924 glib_conf.set('HAVE_FCNTL_F_FULLFSYNC', 1) 925endif 926 927# Check whether there is a vsnprintf() function with C99 semantics installed. 928# (similar tests to AC_FUNC_VSNPRINTF_C99) 929# Check whether there is a snprintf() function with C99 semantics installed. 930# (similar tests to AC_FUNC_SNPRINTF_C99) 931# Check whether there is a printf() function with Unix98 semantics installed. 932# (similar tests to AC_FUNC_PRINTF_UNIX98) 933have_good_vsnprintf = false 934have_good_snprintf = false 935have_good_printf = false 936 937if host_system == 'windows' and (cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl') 938 # Unfortunately the Visual Studio 2015+ implementations of C99-style 939 # snprintf and vsnprintf don't seem to be quite good enough. 940 # (Sorry, I don't know exactly what is the problem, 941 # but it is related to floating point formatting and decimal point vs. comma.) 942 # The simple tests in AC_FUNC_VSNPRINTF_C99 and AC_FUNC_SNPRINTF_C99 aren't 943 # rigorous enough to notice, though. 944 glib_conf.set('HAVE_C99_SNPRINTF', false) 945 glib_conf.set('HAVE_C99_VSNPRINTF', false) 946 glib_conf.set('HAVE_UNIX98_PRINTF', false) 947elif not cc_can_run and host_system in ['ios', 'darwin'] 948 # All these are true when compiling natively on macOS, so we should use good 949 # defaults when building for iOS and tvOS. 950 glib_conf.set('HAVE_C99_SNPRINTF', true) 951 glib_conf.set('HAVE_C99_VSNPRINTF', true) 952 glib_conf.set('HAVE_UNIX98_PRINTF', true) 953 have_good_vsnprintf = true 954 have_good_snprintf = true 955 have_good_printf = true 956else 957 vsnprintf_c99_test_code = ''' 958#include <stdio.h> 959#include <stdarg.h> 960 961int 962doit(char * s, ...) 963{ 964 char buffer[32]; 965 va_list args; 966 int r; 967 968 va_start(args, s); 969 r = vsnprintf(buffer, 5, s, args); 970 va_end(args); 971 972 if (r != 7) 973 exit(1); 974 975 /* AIX 5.1 and Solaris seems to have a half-baked vsnprintf() 976 implementation. The above will return 7 but if you replace 977 the size of the buffer with 0, it borks! */ 978 va_start(args, s); 979 r = vsnprintf(buffer, 0, s, args); 980 va_end(args); 981 982 if (r != 7) 983 exit(1); 984 985 exit(0); 986} 987 988int 989main(void) 990{ 991 doit("1234567"); 992 exit(1); 993}''' 994 995 if cc_can_run 996 rres = cc.run(vsnprintf_c99_test_code, name : 'C99 vsnprintf') 997 if rres.compiled() and rres.returncode() == 0 998 glib_conf.set('HAVE_C99_VSNPRINTF', 1) 999 have_good_vsnprintf = true 1000 endif 1001 else 1002 have_good_vsnprintf = meson.get_cross_property('have_c99_vsnprintf', false) 1003 glib_conf.set('HAVE_C99_VSNPRINTF', have_good_vsnprintf) 1004 endif 1005 1006 snprintf_c99_test_code = ''' 1007#include <stdio.h> 1008#include <stdarg.h> 1009 1010int 1011doit() 1012{ 1013 char buffer[32]; 1014 va_list args; 1015 int r; 1016 1017 r = snprintf(buffer, 5, "1234567"); 1018 1019 if (r != 7) 1020 exit(1); 1021 1022 r = snprintf(buffer, 0, "1234567"); 1023 1024 if (r != 7) 1025 exit(1); 1026 1027 r = snprintf(NULL, 0, "1234567"); 1028 1029 if (r != 7) 1030 exit(1); 1031 1032 exit(0); 1033} 1034 1035int 1036main(void) 1037{ 1038 doit(); 1039 exit(1); 1040}''' 1041 1042 if cc_can_run 1043 rres = cc.run(snprintf_c99_test_code, name : 'C99 snprintf') 1044 if rres.compiled() and rres.returncode() == 0 1045 glib_conf.set('HAVE_C99_SNPRINTF', 1) 1046 have_good_snprintf = true 1047 endif 1048 else 1049 have_good_snprintf = meson.get_cross_property('have_c99_snprintf', false) 1050 glib_conf.set('HAVE_C99_SNPRINTF', have_good_snprintf) 1051 endif 1052 1053 printf_unix98_test_code = ''' 1054#include <stdio.h> 1055 1056int 1057main (void) 1058{ 1059 char buffer[128]; 1060 1061 sprintf (buffer, "%2\$d %3\$d %1\$d", 1, 2, 3); 1062 if (strcmp ("2 3 1", buffer) == 0) 1063 exit (0); 1064 exit (1); 1065}''' 1066 1067 if cc_can_run 1068 rres = cc.run(printf_unix98_test_code, name : 'Unix98 printf positional parameters') 1069 if rres.compiled() and rres.returncode() == 0 1070 glib_conf.set('HAVE_UNIX98_PRINTF', 1) 1071 have_good_printf = true 1072 endif 1073 else 1074 have_good_printf = meson.get_cross_property('have_unix98_printf', false) 1075 glib_conf.set('HAVE_UNIX98_PRINTF', have_good_printf) 1076 endif 1077endif 1078 1079if host_system == 'windows' 1080 glib_conf.set_quoted('EXEEXT', '.exe') 1081else 1082 glib_conf.set('EXEEXT', '') 1083endif 1084 1085# Our printf is 'good' only if vsnpintf()/snprintf()/printf() supports C99 well enough 1086use_system_printf = have_good_vsnprintf and have_good_snprintf and have_good_printf 1087glib_conf.set('USE_SYSTEM_PRINTF', use_system_printf) 1088glibconfig_conf.set('GLIB_USING_SYSTEM_PRINTF', use_system_printf) 1089 1090if not use_system_printf 1091 # gnulib has vasprintf so override the previous check 1092 glib_conf.set('HAVE_VASPRINTF', 1) 1093endif 1094 1095# Check for nl_langinfo and CODESET 1096if cc.links('''#include <langinfo.h> 1097 int main (int argc, char ** argv) { 1098 char *codeset = nl_langinfo (CODESET); 1099 return 0; 1100 }''', name : 'nl_langinfo and CODESET') 1101 glib_conf.set('HAVE_LANGINFO_CODESET', 1) 1102 glib_conf.set('HAVE_CODESET', 1) 1103endif 1104 1105# Check for nl_langinfo and LC_TIME parts that are needed in gdatetime.c 1106if cc.links('''#include <langinfo.h> 1107 int main (int argc, char ** argv) { 1108 char *str; 1109 str = nl_langinfo (PM_STR); 1110 str = nl_langinfo (D_T_FMT); 1111 str = nl_langinfo (D_FMT); 1112 str = nl_langinfo (T_FMT); 1113 str = nl_langinfo (T_FMT_AMPM); 1114 str = nl_langinfo (MON_1); 1115 str = nl_langinfo (ABMON_12); 1116 str = nl_langinfo (DAY_1); 1117 str = nl_langinfo (ABDAY_7); 1118 return 0; 1119 }''', name : 'nl_langinfo (PM_STR)') 1120 glib_conf.set('HAVE_LANGINFO_TIME', 1) 1121endif 1122if cc.links('''#include <langinfo.h> 1123 int main (int argc, char ** argv) { 1124 char *str; 1125 str = nl_langinfo (_NL_CTYPE_OUTDIGIT0_MB); 1126 str = nl_langinfo (_NL_CTYPE_OUTDIGIT1_MB); 1127 str = nl_langinfo (_NL_CTYPE_OUTDIGIT2_MB); 1128 str = nl_langinfo (_NL_CTYPE_OUTDIGIT3_MB); 1129 str = nl_langinfo (_NL_CTYPE_OUTDIGIT4_MB); 1130 str = nl_langinfo (_NL_CTYPE_OUTDIGIT5_MB); 1131 str = nl_langinfo (_NL_CTYPE_OUTDIGIT6_MB); 1132 str = nl_langinfo (_NL_CTYPE_OUTDIGIT7_MB); 1133 str = nl_langinfo (_NL_CTYPE_OUTDIGIT8_MB); 1134 str = nl_langinfo (_NL_CTYPE_OUTDIGIT9_MB); 1135 return 0; 1136 }''', name : 'nl_langinfo (_NL_CTYPE_OUTDIGITn_MB)') 1137 glib_conf.set('HAVE_LANGINFO_OUTDIGIT', 1) 1138endif 1139 1140# Check for nl_langinfo and alternative month names 1141if cc.links('''#ifndef _GNU_SOURCE 1142 # define _GNU_SOURCE 1143 #endif 1144 #include <langinfo.h> 1145 int main (int argc, char ** argv) { 1146 char *str; 1147 str = nl_langinfo (ALTMON_1); 1148 str = nl_langinfo (ALTMON_2); 1149 str = nl_langinfo (ALTMON_3); 1150 str = nl_langinfo (ALTMON_4); 1151 str = nl_langinfo (ALTMON_5); 1152 str = nl_langinfo (ALTMON_6); 1153 str = nl_langinfo (ALTMON_7); 1154 str = nl_langinfo (ALTMON_8); 1155 str = nl_langinfo (ALTMON_9); 1156 str = nl_langinfo (ALTMON_10); 1157 str = nl_langinfo (ALTMON_11); 1158 str = nl_langinfo (ALTMON_12); 1159 return 0; 1160 }''', name : 'nl_langinfo (ALTMON_n)') 1161 glib_conf.set('HAVE_LANGINFO_ALTMON', 1) 1162endif 1163 1164# Check for nl_langinfo and abbreviated alternative month names 1165if cc.links('''#ifndef _GNU_SOURCE 1166 # define _GNU_SOURCE 1167 #endif 1168 #include <langinfo.h> 1169 int main (int argc, char ** argv) { 1170 char *str; 1171 str = nl_langinfo (_NL_ABALTMON_1); 1172 str = nl_langinfo (_NL_ABALTMON_2); 1173 str = nl_langinfo (_NL_ABALTMON_3); 1174 str = nl_langinfo (_NL_ABALTMON_4); 1175 str = nl_langinfo (_NL_ABALTMON_5); 1176 str = nl_langinfo (_NL_ABALTMON_6); 1177 str = nl_langinfo (_NL_ABALTMON_7); 1178 str = nl_langinfo (_NL_ABALTMON_8); 1179 str = nl_langinfo (_NL_ABALTMON_9); 1180 str = nl_langinfo (_NL_ABALTMON_10); 1181 str = nl_langinfo (_NL_ABALTMON_11); 1182 str = nl_langinfo (_NL_ABALTMON_12); 1183 return 0; 1184 }''', name : 'nl_langinfo (_NL_ABALTMON_n)') 1185 glib_conf.set('HAVE_LANGINFO_ABALTMON', 1) 1186endif 1187 1188# Check if C compiler supports the 'signed' keyword 1189if not cc.compiles('''signed char x;''', name : 'signed') 1190 glib_conf.set('signed', '/* NOOP */') 1191endif 1192 1193# Check if the ptrdiff_t type exists 1194if cc.has_header_symbol('stddef.h', 'ptrdiff_t') 1195 glib_conf.set('HAVE_PTRDIFF_T', 1) 1196endif 1197 1198# Check for sig_atomic_t type 1199if cc.links('''#include <signal.h> 1200 #include <sys/types.h> 1201 sig_atomic_t val = 42; 1202 int main (int argc, char ** argv) { 1203 return val == 42 ? 0 : 1; 1204 }''', name : 'sig_atomic_t') 1205 glib_conf.set('HAVE_SIG_ATOMIC_T', 1) 1206endif 1207 1208# Check if 'long long' works 1209# jm_AC_TYPE_LONG_LONG 1210if cc.compiles('''long long ll = 1LL; 1211 int i = 63; 1212 int some_func (void) { 1213 long long llmax = (long long) -1; 1214 return ll << i | ll >> i | llmax / ll | llmax % ll; 1215 }''', name : 'long long') 1216 glib_conf.set('HAVE_LONG_LONG', 1) 1217 have_long_long = true 1218else 1219 have_long_long = false 1220endif 1221 1222# Test whether the compiler supports the 'long double' type. 1223if cc.compiles('''/* The Stardent Vistra knows sizeof(long double), but does not support it. */ 1224 long double foo = 0.0; 1225 /* On Ultrix 4.3 cc, long double is 4 and double is 8. */ 1226 int array [2*(sizeof(long double) >= sizeof(double)) - 1];''', 1227 name : 'long double') 1228 glib_conf.set('HAVE_LONG_DOUBLE', 1) 1229endif 1230 1231# Test whether <stddef.h> has the 'wchar_t' type. 1232if cc.has_header_symbol('stddef.h', 'wchar_t') 1233 glib_conf.set('HAVE_WCHAR_T', 1) 1234endif 1235 1236# Test whether <wchar.h> has the 'wint_t' type. 1237if cc.has_header_symbol('wchar.h', 'wint_t') 1238 glib_conf.set('HAVE_WINT_T', 1) 1239endif 1240 1241found_uintmax_t = false 1242 1243# Define HAVE_INTTYPES_H_WITH_UINTMAX if <inttypes.h> exists, 1244# doesn't clash with <sys/types.h>, and declares uintmax_t. 1245# jm_AC_HEADER_INTTYPES_H 1246if cc.compiles('''#include <sys/types.h> 1247 #include <inttypes.h> 1248 void some_func (void) { 1249 uintmax_t i = (uintmax_t) -1; 1250 }''', name : 'uintmax_t in inttypes.h') 1251 glib_conf.set('HAVE_INTTYPES_H_WITH_UINTMAX', 1) 1252 found_uintmax_t = true 1253endif 1254 1255# Define HAVE_STDINT_H_WITH_UINTMAX if <stdint.h> exists, 1256# doesn't clash with <sys/types.h>, and declares uintmax_t. 1257# jm_AC_HEADER_STDINT_H 1258if cc.compiles('''#include <sys/types.h> 1259 #include <stdint.h> 1260 void some_func (void) { 1261 uintmax_t i = (uintmax_t) -1; 1262 }''', name : 'uintmax_t in stdint.h') 1263 glib_conf.set('HAVE_STDINT_H_WITH_UINTMAX', 1) 1264 found_uintmax_t = true 1265endif 1266 1267# Define intmax_t to 'long' or 'long long' 1268# if it is not already defined in <stdint.h> or <inttypes.h>. 1269# For simplicity, we assume that a header file defines 'intmax_t' if and 1270# only if it defines 'uintmax_t'. 1271if found_uintmax_t 1272 glib_conf.set('HAVE_INTMAX_T', 1) 1273elif have_long_long 1274 glib_conf.set('intmax_t', 'long long') 1275else 1276 glib_conf.set('intmax_t', 'long') 1277endif 1278 1279char_size = cc.sizeof('char') 1280short_size = cc.sizeof('short') 1281int_size = cc.sizeof('int') 1282voidp_size = cc.sizeof('void*') 1283long_size = cc.sizeof('long') 1284if have_long_long 1285 long_long_size = cc.sizeof('long long') 1286else 1287 long_long_size = 0 1288endif 1289sizet_size = cc.sizeof('size_t') 1290if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl' 1291 ssizet_size = cc.sizeof('SSIZE_T', prefix : '#include <BaseTsd.h>') 1292else 1293 ssizet_size = cc.sizeof('ssize_t', prefix : '#include <unistd.h>') 1294endif 1295 1296# Some platforms (Apple) hard-code int64_t to long long instead of 1297# using long on 64-bit architectures. This can cause type mismatch 1298# warnings when trying to interface with code using the standard 1299# library type. Test for the warnings and set gint64 to whichever 1300# works. 1301if long_long_size == long_size 1302 if cc.compiles('''#if defined(_AIX) && !defined(__GNUC__) 1303 #pragma options langlvl=stdc99 1304 #endif 1305 #pragma GCC diagnostic error "-Wincompatible-pointer-types" 1306 #include <stdint.h> 1307 #include <stdio.h> 1308 int main () { 1309 int64_t i1 = 1; 1310 long *i2 = &i1; 1311 return 1; 1312 }''', name : 'int64_t is long') 1313 int64_t_typedef = 'long' 1314 elif cc.compiles('''#if defined(_AIX) && !defined(__GNUC__) 1315 #pragma options langlvl=stdc99 1316 #endif 1317 #pragma GCC diagnostic error "-Wincompatible-pointer-types" 1318 #include <stdint.h> 1319 #include <stdio.h> 1320 int main () { 1321 int64_t i1 = 1; 1322 long long *i2 = &i1; 1323 return 1; 1324 }''', name : 'int64_t is long long') 1325 int64_t_typedef = 'long long' 1326 endif 1327endif 1328 1329int64_m = 'll' 1330char_align = cc.alignment('char') 1331short_align = cc.alignment('short') 1332int_align = cc.alignment('int') 1333voidp_align = cc.alignment('void*') 1334long_align = cc.alignment('long') 1335long_long_align = cc.alignment('long long') 1336# NOTE: We don't check for size of __int64 because long long is guaranteed to 1337# be 64-bit in C99, and it is available on all supported compilers 1338sizet_align = cc.alignment('size_t') 1339 1340glib_conf.set('ALIGNOF_UNSIGNED_LONG', long_align) 1341 1342glib_conf.set('SIZEOF_CHAR', char_size) 1343glib_conf.set('SIZEOF_INT', int_size) 1344glib_conf.set('SIZEOF_SHORT', short_size) 1345glib_conf.set('SIZEOF_LONG', long_size) 1346glib_conf.set('SIZEOF_LONG_LONG', long_long_size) 1347glib_conf.set('SIZEOF_SIZE_T', sizet_size) 1348glib_conf.set('SIZEOF_SSIZE_T', ssizet_size) 1349glib_conf.set('SIZEOF_VOID_P', voidp_size) 1350glib_conf.set('SIZEOF_WCHAR_T', cc.sizeof('wchar_t', prefix: '#include <stddef.h>')) 1351 1352if short_size == 2 1353 gint16 = 'short' 1354 gint16_modifier='h' 1355 gint16_format='hi' 1356 guint16_format='hu' 1357elif int_size == 2 1358 gint16 = 'int' 1359 gint16_modifier='' 1360 gint16_format='i' 1361 guint16_format='u' 1362else 1363 error('Compiler provides no native 16-bit integer type') 1364endif 1365glibconfig_conf.set('gint16', gint16) 1366glibconfig_conf.set_quoted('gint16_modifier', gint16_modifier) 1367glibconfig_conf.set_quoted('gint16_format', gint16_format) 1368glibconfig_conf.set_quoted('guint16_format', guint16_format) 1369 1370if short_size == 4 1371 gint32 = 'short' 1372 gint32_modifier='h' 1373 gint32_format='hi' 1374 guint32_format='hu' 1375 guint32_align = short_align 1376elif int_size == 4 1377 gint32 = 'int' 1378 gint32_modifier='' 1379 gint32_format='i' 1380 guint32_format='u' 1381 guint32_align = int_align 1382elif long_size == 4 1383 gint32 = 'long' 1384 gint32_modifier='l' 1385 gint32_format='li' 1386 guint32_format='lu' 1387 guint32_align = long_align 1388else 1389 error('Compiler provides no native 32-bit integer type') 1390endif 1391glibconfig_conf.set('gint32', gint32) 1392glibconfig_conf.set_quoted('gint32_modifier', gint32_modifier) 1393glibconfig_conf.set_quoted('gint32_format', gint32_format) 1394glibconfig_conf.set_quoted('guint32_format', guint32_format) 1395glib_conf.set('ALIGNOF_GUINT32', guint32_align) 1396 1397if int_size == 8 1398 gint64 = 'int' 1399 gint64_modifier='' 1400 gint64_format='i' 1401 guint64_format='u' 1402 glib_extension='' 1403 gint64_constant='(val)' 1404 guint64_constant='(val)' 1405 guint64_align = int_align 1406elif long_size == 8 and (long_long_size != long_size or int64_t_typedef == 'long') 1407 gint64 = 'long' 1408 glib_extension='' 1409 gint64_modifier='l' 1410 gint64_format='li' 1411 guint64_format='lu' 1412 gint64_constant='(val##L)' 1413 guint64_constant='(val##UL)' 1414 guint64_align = long_align 1415elif long_long_size == 8 and (long_long_size != long_size or int64_t_typedef == 'long long') 1416 gint64 = 'long long' 1417 glib_extension='G_GNUC_EXTENSION ' 1418 gint64_modifier=int64_m 1419 gint64_format=int64_m + 'i' 1420 guint64_format=int64_m + 'u' 1421 gint64_constant='(G_GNUC_EXTENSION (val##LL))' 1422 guint64_constant='(G_GNUC_EXTENSION (val##ULL))' 1423 guint64_align = long_long_align 1424else 1425 error('Compiler provides no native 64-bit integer type') 1426endif 1427glibconfig_conf.set('glib_extension', glib_extension) 1428glibconfig_conf.set('gint64', gint64) 1429glibconfig_conf.set_quoted('gint64_modifier', gint64_modifier) 1430glibconfig_conf.set_quoted('gint64_format', gint64_format) 1431glibconfig_conf.set_quoted('guint64_format', guint64_format) 1432glibconfig_conf.set('gint64_constant', gint64_constant) 1433glibconfig_conf.set('guint64_constant', guint64_constant) 1434glib_conf.set('ALIGNOF_GUINT64', guint64_align) 1435 1436if host_system == 'windows' 1437 glibconfig_conf.set('g_pid_type', 'void*') 1438 glibconfig_conf.set_quoted('g_pid_format', 'p') 1439 if host_machine.cpu_family() == 'x86_64' 1440 glibconfig_conf.set_quoted('g_pollfd_format', '%#' + int64_m + 'x') 1441 else 1442 glibconfig_conf.set_quoted('g_pollfd_format', '%#x') 1443 endif 1444 glibconfig_conf.set('g_dir_separator', '\\\\') 1445 glibconfig_conf.set('g_searchpath_separator', ';') 1446else 1447 glibconfig_conf.set('g_pid_type', 'int') 1448 glibconfig_conf.set_quoted('g_pid_format', 'i') 1449 glibconfig_conf.set_quoted('g_pollfd_format', '%d') 1450 glibconfig_conf.set('g_dir_separator', '/') 1451 glibconfig_conf.set('g_searchpath_separator', ':') 1452endif 1453 1454g_sizet_compatibility = { 1455 'short': sizet_size == short_size, 1456 'int': sizet_size == int_size, 1457 'long': sizet_size == long_size, 1458 'long long': sizet_size == long_long_size, 1459} 1460 1461# Do separate checks for gcc/clang (and ignore other compilers for now), since 1462# we need to explicitly pass -Werror to the compilers. 1463# FIXME: https://github.com/mesonbuild/meson/issues/5399 1464# We can’t simplify these checks using a foreach loop because dictionary keys 1465# have to be string literals. 1466# FIXME: https://github.com/mesonbuild/meson/issues/5231 1467if cc.get_id() == 'gcc' or cc.get_id() == 'clang' 1468 g_sizet_compatibility += { 1469 'short': g_sizet_compatibility['short'] and cc.compiles( 1470 '''#include <stddef.h> 1471 size_t f (size_t *i) { return *i + 1; } 1472 int main (void) { 1473 unsigned short i = 0; 1474 f (&i); 1475 return 0; 1476 }''', 1477 args: ['-Werror'], 1478 name : 'GCC size_t typedef is short'), 1479 'int': g_sizet_compatibility['int'] and cc.compiles( 1480 '''#include <stddef.h> 1481 size_t f (size_t *i) { return *i + 1; } 1482 int main (void) { 1483 unsigned int i = 0; 1484 f (&i); 1485 return 0; 1486 }''', 1487 args: ['-Werror'], 1488 name : 'GCC size_t typedef is int'), 1489 'long': g_sizet_compatibility['long'] and cc.compiles( 1490 '''#include <stddef.h> 1491 size_t f (size_t *i) { return *i + 1; } 1492 int main (void) { 1493 unsigned long i = 0; 1494 f (&i); 1495 return 0; 1496 }''', 1497 args: ['-Werror'], 1498 name : 'GCC size_t typedef is long'), 1499 'long long': g_sizet_compatibility['long long'] and cc.compiles( 1500 '''#include <stddef.h> 1501 size_t f (size_t *i) { return *i + 1; } 1502 int main (void) { 1503 unsigned long long i = 0; 1504 f (&i); 1505 return 0; 1506 }''', 1507 args: ['-Werror'], 1508 name : 'GCC size_t typedef is long long'), 1509 } 1510endif 1511 1512if host_system == 'linux-gnu_ilp32' 1513if g_sizet_compatibility['short'] 1514 glibconfig_conf.set('glib_size_type_define', 'short') 1515 glibconfig_conf.set_quoted('gsize_modifier', 'h') 1516 glibconfig_conf.set_quoted('gssize_modifier', 'h') 1517 glibconfig_conf.set_quoted('gsize_format', 'hu') 1518 glibconfig_conf.set_quoted('gssize_format', 'hi') 1519 glibconfig_conf.set('glib_msize_type', 'SHRT') 1520elif g_sizet_compatibility['long'] 1521 glibconfig_conf.set('glib_size_type_define', 'long') 1522 glibconfig_conf.set_quoted('gsize_modifier', 'l') 1523 glibconfig_conf.set_quoted('gssize_modifier', 'l') 1524 glibconfig_conf.set_quoted('gsize_format', 'lu') 1525 glibconfig_conf.set_quoted('gssize_format', 'li') 1526 glibconfig_conf.set('glib_msize_type', 'LONG') 1527elif g_sizet_compatibility['int'] 1528 glibconfig_conf.set('glib_size_type_define', 'int') 1529 glibconfig_conf.set_quoted('gsize_modifier', '') 1530 glibconfig_conf.set_quoted('gssize_modifier', '') 1531 glibconfig_conf.set_quoted('gsize_format', 'u') 1532 glibconfig_conf.set_quoted('gssize_format', 'i') 1533 glibconfig_conf.set('glib_msize_type', 'INT') 1534elif g_sizet_compatibility['long long'] 1535 glibconfig_conf.set('glib_size_type_define', 'long long') 1536 glibconfig_conf.set_quoted('gsize_modifier', int64_m) 1537 glibconfig_conf.set_quoted('gssize_modifier', int64_m) 1538 glibconfig_conf.set_quoted('gsize_format', int64_m + 'u') 1539 glibconfig_conf.set_quoted('gssize_format', int64_m + 'i') 1540 glibconfig_conf.set('glib_msize_type', 'INT64') 1541else 1542 error('Could not determine size of size_t.') 1543endif 1544 1545else 1546if g_sizet_compatibility['short'] 1547 glibconfig_conf.set('glib_size_type_define', 'short') 1548 glibconfig_conf.set_quoted('gsize_modifier', 'h') 1549 glibconfig_conf.set_quoted('gssize_modifier', 'h') 1550 glibconfig_conf.set_quoted('gsize_format', 'hu') 1551 glibconfig_conf.set_quoted('gssize_format', 'hi') 1552 glibconfig_conf.set('glib_msize_type', 'SHRT') 1553elif g_sizet_compatibility['int'] 1554 glibconfig_conf.set('glib_size_type_define', 'int') 1555 glibconfig_conf.set_quoted('gsize_modifier', '') 1556 glibconfig_conf.set_quoted('gssize_modifier', '') 1557 glibconfig_conf.set_quoted('gsize_format', 'u') 1558 glibconfig_conf.set_quoted('gssize_format', 'i') 1559 glibconfig_conf.set('glib_msize_type', 'INT') 1560elif g_sizet_compatibility['long'] 1561 glibconfig_conf.set('glib_size_type_define', 'long') 1562 glibconfig_conf.set_quoted('gsize_modifier', 'l') 1563 glibconfig_conf.set_quoted('gssize_modifier', 'l') 1564 glibconfig_conf.set_quoted('gsize_format', 'lu') 1565 glibconfig_conf.set_quoted('gssize_format', 'li') 1566 glibconfig_conf.set('glib_msize_type', 'LONG') 1567elif g_sizet_compatibility['long long'] 1568 glibconfig_conf.set('glib_size_type_define', 'long long') 1569 glibconfig_conf.set_quoted('gsize_modifier', int64_m) 1570 glibconfig_conf.set_quoted('gssize_modifier', int64_m) 1571 glibconfig_conf.set_quoted('gsize_format', int64_m + 'u') 1572 glibconfig_conf.set_quoted('gssize_format', int64_m + 'i') 1573 glibconfig_conf.set('glib_msize_type', 'INT64') 1574else 1575 error('Could not determine size of size_t.') 1576endif 1577endif 1578 1579if voidp_size == int_size 1580 glibconfig_conf.set('glib_intptr_type_define', 'int') 1581 glibconfig_conf.set_quoted('gintptr_modifier', '') 1582 glibconfig_conf.set_quoted('gintptr_format', 'i') 1583 glibconfig_conf.set_quoted('guintptr_format', 'u') 1584 glibconfig_conf.set('glib_gpi_cast', '(gint)') 1585 glibconfig_conf.set('glib_gpui_cast', '(guint)') 1586elif voidp_size == long_size 1587 glibconfig_conf.set('glib_intptr_type_define', 'long') 1588 glibconfig_conf.set_quoted('gintptr_modifier', 'l') 1589 glibconfig_conf.set_quoted('gintptr_format', 'li') 1590 glibconfig_conf.set_quoted('guintptr_format', 'lu') 1591 glibconfig_conf.set('glib_gpi_cast', '(glong)') 1592 glibconfig_conf.set('glib_gpui_cast', '(gulong)') 1593elif voidp_size == long_long_size 1594 glibconfig_conf.set('glib_intptr_type_define', 'long long') 1595 glibconfig_conf.set_quoted('gintptr_modifier', int64_m) 1596 glibconfig_conf.set_quoted('gintptr_format', int64_m + 'i') 1597 glibconfig_conf.set_quoted('guintptr_format', int64_m + 'u') 1598 glibconfig_conf.set('glib_gpi_cast', '(gint64)') 1599 glibconfig_conf.set('glib_gpui_cast', '(guint64)') 1600else 1601 error('Could not determine size of void *') 1602endif 1603 1604if long_size != 8 and long_long_size != 8 and int_size != 8 1605 error('GLib requires a 64-bit type. You might want to consider using the GNU C compiler.') 1606endif 1607 1608glibconfig_conf.set('gintbits', int_size * 8) 1609glibconfig_conf.set('glongbits', long_size * 8) 1610glibconfig_conf.set('gsizebits', sizet_size * 8) 1611glibconfig_conf.set('gssizebits', ssizet_size * 8) 1612 1613# XXX: https://gitlab.gnome.org/GNOME/glib/issues/1413 1614if host_system == 'windows' 1615 g_module_suffix = 'dll' 1616else 1617 g_module_suffix = 'so' 1618endif 1619glibconfig_conf.set('g_module_suffix', g_module_suffix) 1620 1621glibconfig_conf.set('GLIB_MAJOR_VERSION', major_version) 1622glibconfig_conf.set('GLIB_MINOR_VERSION', minor_version) 1623glibconfig_conf.set('GLIB_MICRO_VERSION', micro_version) 1624glibconfig_conf.set('GLIB_VERSION', glib_version) 1625 1626glibconfig_conf.set('glib_void_p', voidp_size) 1627glibconfig_conf.set('glib_long', long_size) 1628glibconfig_conf.set('glib_size_t', sizet_size) 1629glibconfig_conf.set('glib_ssize_t', ssizet_size) 1630if host_machine.endian() == 'big' 1631 glibconfig_conf.set('g_byte_order', 'G_BIG_ENDIAN') 1632 glibconfig_conf.set('g_bs_native', 'BE') 1633 glibconfig_conf.set('g_bs_alien', 'LE') 1634else 1635 glibconfig_conf.set('g_byte_order', 'G_LITTLE_ENDIAN') 1636 glibconfig_conf.set('g_bs_native', 'LE') 1637 glibconfig_conf.set('g_bs_alien', 'BE') 1638endif 1639 1640# === va_copy checks === 1641# we currently check for all three va_copy possibilities, so we get 1642# all results in config.log for bug reports. 1643 1644va_copy_func = '' 1645foreach try_func : [ '__va_copy', 'va_copy' ] 1646 if cc.compiles('''#include <stdarg.h> 1647 #include <stdlib.h> 1648 #ifdef _MSC_VER 1649 # include "msvc_recommended_pragmas.h" 1650 #endif 1651 void f (int i, ...) { 1652 va_list args1, args2; 1653 va_start (args1, i); 1654 @0@ (args2, args1); 1655 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) 1656 exit (1); 1657 va_end (args1); va_end (args2); 1658 } 1659 int main() { 1660 f (0, 42); 1661 return 0; 1662 }'''.format(try_func), 1663 name : try_func + ' check') 1664 va_copy_func = try_func 1665 endif 1666endforeach 1667if va_copy_func != '' 1668 glib_conf.set('G_VA_COPY', va_copy_func) 1669 glib_vacopy = '#define G_VA_COPY ' + va_copy_func 1670else 1671 glib_vacopy = '/* #undef G_VA_COPY */' 1672endif 1673 1674va_list_val_copy_prog = ''' 1675 #include <stdarg.h> 1676 #include <stdlib.h> 1677 void f (int i, ...) { 1678 va_list args1, args2; 1679 va_start (args1, i); 1680 args2 = args1; 1681 if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) 1682 exit (1); 1683 va_end (args1); va_end (args2); 1684 } 1685 int main() { 1686 f (0, 42); 1687 return 0; 1688 }''' 1689 1690if cc_can_run 1691 rres = cc.run(va_list_val_copy_prog, name : 'va_lists can be copied as values') 1692 glib_va_val_copy = rres.returncode() == 0 1693else 1694 glib_va_val_copy = meson.get_cross_property('va_val_copy', true) 1695endif 1696if not glib_va_val_copy 1697 glib_vacopy = glib_vacopy + '\n#define G_VA_COPY_AS_ARRAY 1' 1698 glib_conf.set('G_VA_COPY_AS_ARRAY', 1) 1699endif 1700glibconfig_conf.set('glib_vacopy', glib_vacopy) 1701 1702# check for flavours of varargs macros 1703g_have_iso_c_varargs = cc.compiles(''' 1704 void some_func (void) { 1705 int a(int p1, int p2, int p3); 1706 #define call_a(...) a(1,__VA_ARGS__) 1707 call_a(2,3); 1708 }''', name : 'ISO C99 varargs macros in C') 1709 1710if g_have_iso_c_varargs 1711 glibconfig_conf.set('g_have_iso_c_varargs', ''' 1712#ifndef __cplusplus 1713# define G_HAVE_ISO_VARARGS 1 1714#endif''') 1715endif 1716 1717g_have_iso_cxx_varargs = cxx.compiles(''' 1718 void some_func (void) { 1719 int a(int p1, int p2, int p3); 1720 #define call_a(...) a(1,__VA_ARGS__) 1721 call_a(2,3); 1722 }''', name : 'ISO C99 varargs macros in C++') 1723 1724if g_have_iso_cxx_varargs 1725 glibconfig_conf.set('g_have_iso_cxx_varargs', ''' 1726#ifdef __cplusplus 1727# define G_HAVE_ISO_VARARGS 1 1728#endif''') 1729endif 1730 1731g_have_gnuc_varargs = cc.compiles(''' 1732 void some_func (void) { 1733 int a(int p1, int p2, int p3); 1734 #define call_a(params...) a(1,params) 1735 call_a(2,3); 1736 }''', name : 'GNUC varargs macros') 1737 1738if cc.has_header('alloca.h') 1739 glibconfig_conf.set('GLIB_HAVE_ALLOCA_H', true) 1740endif 1741has_syspoll = cc.has_header('sys/poll.h') 1742has_systypes = cc.has_header('sys/types.h') 1743if has_syspoll 1744 glibconfig_conf.set('GLIB_HAVE_SYS_POLL_H', true) 1745endif 1746has_winsock2 = cc.has_header('winsock2.h') 1747 1748if has_syspoll and has_systypes 1749 poll_includes = ''' 1750 #include<sys/poll.h> 1751 #include<sys/types.h>''' 1752elif has_winsock2 1753 poll_includes = ''' 1754 #define _WIN32_WINNT @0@ 1755 #include <winsock2.h>'''.format(glib_conf.get('_WIN32_WINNT')) 1756else 1757 # FIXME? 1758 error('FIX POLL* defines') 1759endif 1760 1761poll_defines = [ 1762 [ 'POLLIN', 'g_pollin', 1 ], 1763 [ 'POLLOUT', 'g_pollout', 4 ], 1764 [ 'POLLPRI', 'g_pollpri', 2 ], 1765 [ 'POLLERR', 'g_pollerr', 8 ], 1766 [ 'POLLHUP', 'g_pollhup', 16 ], 1767 [ 'POLLNVAL', 'g_pollnval', 32 ], 1768] 1769 1770if has_syspoll and has_systypes 1771 foreach d : poll_defines 1772 val = cc.compute_int(d[0], prefix: poll_includes) 1773 glibconfig_conf.set(d[1], val) 1774 endforeach 1775elif has_winsock2 1776 # Due to a missed bug in configure.ac the poll test 1777 # never succeeded on Windows and used some pre-defined 1778 # values as a fallback. Keep using them to maintain 1779 # ABI compatibility with autotools builds of glibs 1780 # and with *any* glib-using code compiled against them, 1781 # since these values end up in a public header glibconfig.h. 1782 foreach d : poll_defines 1783 glibconfig_conf.set(d[1], d[2]) 1784 endforeach 1785endif 1786 1787# Internet address families 1788# FIXME: what about Cygwin (G_WITH_CYGWIN) 1789if host_system == 'windows' 1790 inet_includes = ''' 1791 #include <winsock2.h>''' 1792else 1793 inet_includes = ''' 1794 #include <sys/types.h> 1795 #include <sys/socket.h>''' 1796endif 1797 1798inet_defines = [ 1799 [ 'AF_UNIX', 'g_af_unix' ], 1800 [ 'AF_INET', 'g_af_inet' ], 1801 [ 'AF_INET6', 'g_af_inet6' ], 1802 [ 'MSG_OOB', 'g_msg_oob' ], 1803 [ 'MSG_PEEK', 'g_msg_peek' ], 1804 [ 'MSG_DONTROUTE', 'g_msg_dontroute' ], 1805] 1806foreach d : inet_defines 1807 val = cc.compute_int(d[0], prefix: inet_includes) 1808 glibconfig_conf.set(d[1], val) 1809endforeach 1810 1811if host_system == 'windows' 1812 have_ipv6 = true 1813else 1814 have_ipv6 = cc.has_type('struct in6_addr', prefix: '#include <netinet/in.h>') 1815endif 1816glib_conf.set('HAVE_IPV6', have_ipv6) 1817 1818# We need to decide at configure time if GLib will use real atomic 1819# operations ("lock free") or emulated ones with a mutex. This is 1820# because we must put this information in glibconfig.h so we know if 1821# it is safe or not to inline using compiler intrinsics directly from 1822# the header. 1823# 1824# We also publish the information via G_ATOMIC_LOCK_FREE in case the 1825# user is interested in knowing if they can use the atomic ops across 1826# processes. 1827# 1828# We can currently support the atomic ops natively when building GLib 1829# with recent versions of GCC or MSVC. 1830# 1831# Note that the atomic ops are only available with GCC on x86 when 1832# using -march=i486 or higher. If we detect that the atomic ops are 1833# not available but would be available given the right flags, we want 1834# to abort and advise the user to fix their CFLAGS. It's better to do 1835# that then to silently fall back on emulated atomic ops just because 1836# the user had the wrong build environment. 1837atomictest = '''int main() { 1838 int atomic = 2; 1839 __sync_bool_compare_and_swap (&atomic, 2, 3); 1840 return 0; 1841} 1842''' 1843 1844atomicdefine = ''' 1845#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1846#error "compiler has atomic ops, but doesn't define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4" 1847#endif 1848''' 1849 1850# We know that we can always use real ("lock free") atomic operations with MSVC 1851if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl' or cc.links(atomictest, name : 'atomic ops') 1852 have_atomic_lock_free = true 1853 if cc.get_id() == 'gcc' and not cc.compiles(atomicdefine, name : 'atomic ops define') 1854 # Old gcc release may provide 1855 # __sync_bool_compare_and_swap but doesn't define 1856 # __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1857 glib_conf.set('__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4', true) 1858 endif 1859else 1860 have_atomic_lock_free = false 1861 if host_machine.cpu_family() == 'x86' and cc.links(atomictest, args : '-march=i486') 1862 error('GLib must be built with -march=i486 or later.') 1863 endif 1864endif 1865glibconfig_conf.set('G_ATOMIC_LOCK_FREE', have_atomic_lock_free) 1866 1867# === Threads === 1868 1869# Determination of thread implementation 1870if host_system == 'windows' and not get_option('force_posix_threads') 1871 thread_dep = [] 1872 threads_implementation = 'win32' 1873 glibconfig_conf.set('g_threads_impl_def', 'WIN32') 1874 glib_conf.set('THREADS_WIN32', 1) 1875else 1876 thread_dep = dependency('threads') 1877 threads_implementation = 'posix' 1878 pthread_prefix = ''' 1879 #ifndef _GNU_SOURCE 1880 # define _GNU_SOURCE 1881 #endif 1882 #include <pthread.h>''' 1883 glibconfig_conf.set('g_threads_impl_def', 'POSIX') 1884 glib_conf.set('THREADS_POSIX', 1) 1885 if cc.has_header_symbol('pthread.h', 'pthread_attr_setstacksize') 1886 glib_conf.set('HAVE_PTHREAD_ATTR_SETSTACKSIZE', 1) 1887 endif 1888 if cc.has_header_symbol('pthread.h', 'pthread_attr_setinheritsched') 1889 glib_conf.set('HAVE_PTHREAD_ATTR_SETINHERITSCHED', 1) 1890 endif 1891 if cc.has_header_symbol('pthread.h', 'pthread_condattr_setclock') 1892 glib_conf.set('HAVE_PTHREAD_CONDATTR_SETCLOCK', 1) 1893 endif 1894 if cc.has_header_symbol('pthread.h', 'pthread_cond_timedwait_relative_np') 1895 glib_conf.set('HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP', 1) 1896 endif 1897 if cc.has_header_symbol('pthread.h', 'pthread_getname_np', prefix : pthread_prefix) 1898 glib_conf.set('HAVE_PTHREAD_GETNAME_NP', 1) 1899 endif 1900 1901 if cc.has_header_symbol('sys/syscall.h', 'SYS_sched_getattr') 1902 glib_conf.set('HAVE_SYS_SCHED_GETATTR', 1) 1903 endif 1904 1905 # Assume that pthread_setname_np is available in some form; same as configure 1906 if cc.links(pthread_prefix + ''' 1907 int main() { 1908 pthread_setname_np("example"); 1909 return 0; 1910 }''', 1911 name : 'pthread_setname_np(const char*)', 1912 dependencies : thread_dep) 1913 # macOS and iOS 1914 glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID', 1) 1915 elif cc.links(pthread_prefix + ''' 1916 int main() { 1917 pthread_setname_np(pthread_self(), "example"); 1918 return 0; 1919 }''', 1920 name : 'pthread_setname_np(pthread_t, const char*)', 1921 dependencies : thread_dep) 1922 # Linux, Solaris, etc. 1923 glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITH_TID', 1) 1924 elif cc.links(pthread_prefix + ''' 1925 int main() { 1926 pthread_setname_np(pthread_self(), "%s", "example"); 1927 return 0; 1928 }''', 1929 name : 'pthread_setname_np(pthread_t, const char*, void*)', 1930 dependencies : thread_dep) 1931 # NetBSD 1932 glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG', 1) 1933 elif cc.links(pthread_prefix + ''' 1934 #include <pthread_np.h> 1935 int main() { 1936 pthread_set_name_np(pthread_self(), "example"); 1937 return 0; 1938 }''', 1939 name : 'pthread_set_name_np(pthread_t, const char*)', 1940 dependencies : thread_dep) 1941 # FreeBSD, DragonFlyBSD, OpenBSD, etc. 1942 glib_conf.set('HAVE_PTHREAD_SET_NAME_NP', 1) 1943 endif 1944endif 1945 1946# FIXME: we should make it print the result and always return 0, so that 1947# the output in meson shows up as green 1948# volatile is needed here to avoid optimisations in the test 1949stack_grows_check_prog = ''' 1950 volatile int *a = 0, *b = 0; 1951 void f (int i) { 1952 volatile int x = 5; 1953 if (i == 0) 1954 b = &x; 1955 else 1956 f (i - 1); 1957 } 1958 int main () { 1959 volatile int y = 7; 1960 a = &y; 1961 f (100); 1962 return b > a ? 0 : 1; 1963 }''' 1964 1965if cc_can_run 1966 rres = cc.run(stack_grows_check_prog, name : 'stack grows check') 1967 growing_stack = rres.returncode() == 0 1968else 1969 growing_stack = meson.get_cross_property('growing_stack', false) 1970endif 1971 1972glibconfig_conf.set10('G_HAVE_GROWING_STACK', growing_stack) 1973 1974# Tests for iconv 1975# 1976# We should never use the MinGW C library's iconv because it may not be 1977# available in the actual runtime environment. On Windows, we always use 1978# the built-in implementation 1979iconv_opt = get_option('iconv') 1980if host_system == 'windows' 1981 libiconv = [] 1982 # We have a #include "win_iconv.c" in gconvert.c on Windows, so we don't need 1983 # any external library for it 1984 if iconv_opt != 'auto' 1985 warning('-Diconv was set to @0@, which was ignored') 1986 endif 1987else 1988 found_iconv = false 1989 if ['auto', 'libc'].contains(iconv_opt) and cc.has_function('iconv_open') 1990 libiconv = [] 1991 found_iconv = true 1992 endif 1993 if not found_iconv and ['auto', 'external'].contains(iconv_opt) and cc.has_header_symbol('iconv.h', 'iconv_open') 1994 libiconv = [cc.find_library('iconv')] 1995 found_iconv = true 1996 endif 1997 1998 if not found_iconv 1999 error('iconv implementation "@0@" not found'.format(iconv_opt)) 2000 endif 2001endif 2002 2003if get_option('internal_pcre') 2004 pcre = [] 2005 use_system_pcre = false 2006else 2007 use_system_pcre = true 2008 pcre2 = dependency('libpcre2-8', version: '>= 10.32', required : true) 2009endif 2010glib_conf.set('USE_SYSTEM_PCRE', use_system_pcre) 2011 2012libm = cc.find_library('m', required : false) 2013libffi_dep = dependency('libffi', version : '>= 3.0.0', fallback : ['libffi', 'ffi_dep']) 2014 2015if get_option('wrap_mode') == 'forcefallback' 2016 # Respects "wrap_mode=forcefallback" option 2017 libz_dep = subproject('zlib').get_variable('zlib_dep') 2018else 2019 # Don't use the bundled ZLib sources until we are sure that we can't find it on 2020 # the system 2021 libz_dep = dependency('zlib', required : false) 2022endif 2023 2024if not libz_dep.found() 2025 if cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl' 2026 libz_dep = cc.find_library('z', required : false) 2027 else 2028 libz_dep = cc.find_library('zlib1', required : false) 2029 if not libz_dep.found() 2030 libz_dep = cc.find_library('zlib', required : false) 2031 endif 2032 endif 2033 if not libz_dep.found() or not cc.has_header('zlib.h') 2034 libz_dep = subproject('zlib').get_variable('zlib_dep') 2035 endif 2036endif 2037 2038# First check in libc, fallback to libintl, and as last chance build 2039# proxy-libintl subproject. 2040# FIXME: glib-gettext.m4 has much more checks to detect broken/uncompatible 2041# implementations. This could be extended if issues are found in some platforms. 2042libintl_deps = [] 2043if cc.has_function('ngettext') 2044 have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset') 2045else 2046 # First just find the bare library. 2047 libintl = cc.find_library('intl', required : false) 2048 # The bare library probably won't link without help if it's static. 2049 if libintl.found() and not cc.has_function('ngettext', dependencies : libintl) 2050 libintl_iconv = cc.find_library('iconv', required : false) 2051 # libintl supports different threading APIs, which may not 2052 # require additional flags, but it defaults to using pthreads if 2053 # found. Meson's "threads" dependency does not allow you to 2054 # prefer pthreads. We may not be using pthreads for glib itself 2055 # either so just link the library to satisfy libintl rather than 2056 # also defining the macros with the -pthread flag. 2057 libintl_pthread = cc.find_library('pthread', required : false) 2058 # Try linking with just libiconv. 2059 if libintl_iconv.found() and cc.has_function('ngettext', dependencies : [libintl, libintl_iconv]) 2060 libintl_deps += [libintl_iconv] 2061 # Then also try linking with pthreads. 2062 elif libintl_iconv.found() and libintl_pthread.found() and cc.has_function('ngettext', dependencies : [libintl, libintl_iconv, libintl_pthread]) 2063 libintl_deps += [libintl_iconv, libintl_pthread] 2064 else 2065 libintl = disabler() 2066 endif 2067 endif 2068 if not libintl.found() 2069 libintl = subproject('proxy-libintl').get_variable('intl_dep') 2070 libintl_deps = [libintl] + libintl_deps 2071 have_bind_textdomain_codeset = true # proxy-libintl supports it 2072 else 2073 libintl_deps = [libintl] + libintl_deps 2074 have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset', 2075 dependencies : libintl_deps) 2076 endif 2077endif 2078 2079glib_conf.set('HAVE_BIND_TEXTDOMAIN_CODESET', have_bind_textdomain_codeset) 2080 2081# We require gettext to always be present 2082glib_conf.set('HAVE_DCGETTEXT', 1) 2083glib_conf.set('HAVE_GETTEXT', 1) 2084 2085glib_conf.set_quoted('GLIB_LOCALE_DIR', join_paths(glib_datadir, 'locale')) 2086 2087# libmount is only used by gio, but we need to fetch the libs to generate the 2088# pkg-config file below 2089libmount_dep = [] 2090if host_system == 'linux' 2091 libmount_dep = dependency('mount', version : '>=2.23', required : get_option('libmount')) 2092 glib_conf.set('HAVE_LIBMOUNT', libmount_dep.found()) 2093endif 2094 2095if host_system == 'windows' 2096 winsock2 = cc.find_library('ws2_32') 2097endif 2098 2099selinux_dep = [] 2100if host_system == 'linux' 2101 selinux_dep = dependency('libselinux', version: '>=2.2', required: get_option('selinux')) 2102 2103 glib_conf.set('HAVE_SELINUX', selinux_dep.found()) 2104endif 2105 2106xattr_dep = [] 2107if host_system != 'windows' and get_option('xattr') 2108 # either glibc or libattr can provide xattr support 2109 # for both of them, we check for getxattr being in 2110 # the library and a valid xattr header. 2111 2112 # try glibc 2113 if cc.has_function('getxattr') and cc.has_header('sys/xattr.h') 2114 glib_conf.set('HAVE_SYS_XATTR_H', 1) 2115 glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format('HAVE_SYS_XATTR_H') 2116 #failure. try libattr 2117 elif cc.has_header_symbol('attr/xattr.h', 'getxattr') 2118 glib_conf.set('HAVE_ATTR_XATTR_H', 1) 2119 glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format('HAVE_ATTR_XATTR_H') 2120 xattr_dep = [cc.find_library('xattr')] 2121 else 2122 error('No getxattr implementation found in C library or libxattr') 2123 endif 2124 2125 glib_conf.set('HAVE_XATTR', 1) 2126 if cc.compiles(glib_conf_prefix + ''' 2127 #include <stdio.h> 2128 #ifdef HAVE_SYS_TYPES_H 2129 #include <sys/types.h> 2130 #endif 2131 #ifdef HAVE_SYS_XATTR_H 2132 #include <sys/xattr.h> 2133 #elif HAVE_ATTR_XATTR_H 2134 #include <attr/xattr.h> 2135 #endif 2136 2137 int main (void) { 2138 ssize_t len = getxattr("", "", NULL, 0, 0, XATTR_NOFOLLOW); 2139 return len; 2140 }''', 2141 name : 'XATTR_NOFOLLOW') 2142 glib_conf.set('HAVE_XATTR_NOFOLLOW', 1) 2143 endif 2144endif 2145 2146# If strlcpy is present (BSD and similar), check that it conforms to the BSD 2147# specification. Specifically Solaris 8's strlcpy() does not, see 2148# https://bugzilla.gnome.org/show_bug.cgi?id=53933 for further context. 2149if cc.has_function('strlcpy') 2150 if cc_can_run 2151 rres = cc.run('''#include <stdlib.h> 2152 #include <string.h> 2153 int main() { 2154 char p[10]; 2155 (void) strlcpy (p, "hi", 10); 2156 if (strlcat (p, "bye", 0) != 3) 2157 return 1; 2158 return 0; 2159 }''', 2160 name : 'OpenBSD strlcpy/strlcat') 2161 if rres.compiled() and rres.returncode() == 0 2162 glib_conf.set('HAVE_STRLCPY', 1) 2163 endif 2164 elif meson.get_cross_property('have_strlcpy', false) 2165 glib_conf.set('HAVE_STRLCPY', 1) 2166 endif 2167endif 2168 2169cmdline_test_code = ''' 2170#include <fcntl.h> 2171#include <sys/stat.h> 2172#include <stdio.h> 2173#include <stdlib.h> 2174 2175static int 2176__getcmdline (void) 2177{ 2178/* This code is a dumbed-down version of g_file_get_contents() */ 2179#ifndef O_BINARY 2180#define O_BINARY 0 2181#endif 2182#define BUFSIZE 1024 2183 char result[BUFSIZE]; 2184 struct stat stat_buf; 2185 2186 int fd = open ("/proc/self/cmdline", O_RDONLY|O_BINARY); 2187 if (fd < 0) 2188 exit (1); 2189 if (fstat (fd, &stat_buf)) 2190 exit (1); 2191 2192 if (stat_buf.st_size > 0 && S_ISREG (stat_buf.st_mode)) 2193 { 2194 if (read (fd, result, BUFSIZE) <= 0) 2195 exit (1); 2196 } 2197 else 2198 { 2199 FILE *f = fdopen (fd, "r"); 2200 if (f == NULL) 2201 exit (1); 2202 2203 if (fread (result, 1, BUFSIZE, f) <= 0) 2204 exit (1); 2205 } 2206 2207 return 0; 2208} 2209 2210int 2211main (void) 2212{ 2213 exit (__getcmdline ()); 2214}''' 2215 2216if cc_can_run 2217 rres = cc.run(cmdline_test_code, name : '/proc/self/cmdline') 2218 have_proc_self_cmdline = rres.compiled() and rres.returncode() == 0 2219else 2220 have_proc_self_cmdline = meson.get_cross_property('have_proc_self_cmdline', false) 2221endif 2222 2223glib_conf.set('HAVE_PROC_SELF_CMDLINE', have_proc_self_cmdline) 2224 2225python = import('python').find_installation('python3') 2226# used for '#!/usr/bin/env <name>' 2227python_name = 'python3' 2228 2229python_version = python.language_version() 2230python_version_req = '>=3.5' 2231if not python_version.version_compare(python_version_req) 2232 error('Requires Python @0@, @1@ found.'.format(python_version_req, python_version)) 2233endif 2234 2235# Determine which user environment-dependent files that we want to install 2236have_bash = find_program('bash', required : false).found() # For completion scripts 2237bash_comp_dep = dependency('bash-completion', version: '>=2.0', required: false) 2238have_sh = find_program('sh', required : false).found() # For glib-gettextize 2239 2240# Some installed tests require a custom environment 2241env_program = find_program('env', required: installed_tests_enabled) 2242 2243# FIXME: How to detect Solaris? https://github.com/mesonbuild/meson/issues/1578 2244if host_system == 'sunos' 2245 glib_conf.set('_XOPEN_SOURCE_EXTENDED', 1) 2246 glib_conf.set('_XOPEN_SOURCE', 2) 2247 glib_conf.set('__EXTENSIONS__',1) 2248endif 2249 2250# Sadly Meson does not expose this value: 2251# https://github.com/mesonbuild/meson/pull/3460 2252if host_system == 'windows' 2253 # Autotools explicitly removed --Wl,--export-all-symbols from windows builds, 2254 # with no explanation. Do the same here for now but this could be revisited if 2255 # if causes issues. 2256 export_dynamic_ldflags = [] 2257elif host_system == 'cygwin' 2258 export_dynamic_ldflags = ['-Wl,--export-all-symbols'] 2259elif host_system in ['darwin', 'ios'] 2260 export_dynamic_ldflags = [] 2261elif host_system == 'sunos' 2262 export_dynamic_ldflags = [] 2263else 2264 export_dynamic_ldflags = ['-Wl,--export-dynamic'] 2265endif 2266 2267win32_cflags = [] 2268win32_ldflags = [] 2269if host_system == 'windows' and cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl' 2270 # Ensure MSVC-compatible struct packing convention is used when 2271 # compiling for Win32 with gcc. It is used for the whole project and exposed 2272 # in glib-2.0.pc. 2273 win32_cflags = ['-mms-bitfields'] 2274 add_project_arguments(win32_cflags, language : 'c') 2275 2276 # Win32 API libs, used only by libglib and exposed in glib-2.0.pc 2277 win32_ldflags = ['-lws2_32', '-lole32', '-lwinmm', '-lshlwapi'] 2278elif host_system == 'cygwin' 2279 win32_ldflags = ['-luser32', '-lkernel32'] 2280endif 2281 2282# Tracing: dtrace 2283want_dtrace = get_option('dtrace') 2284enable_dtrace = false 2285 2286# Since dtrace support is opt-in we just error out if it was requested but 2287# is not available. We don't bother with autodetection yet. 2288if want_dtrace 2289 if glib_have_carbon 2290 error('GLib dtrace support not yet compatible with macOS dtrace') 2291 endif 2292 dtrace = find_program('dtrace', required : true) # error out if not found 2293 if not cc.has_header('sys/sdt.h') 2294 error('dtrace support needs sys/sdt.h header') 2295 endif 2296 # FIXME: autotools build also passes -fPIC -DPIC but is it needed in this case? 2297 dtrace_obj_gen = generator(dtrace, 2298 output : '@BASENAME@.o', 2299 arguments : ['-G', '-s', '@INPUT@', '-o', '@OUTPUT@']) 2300 # FIXME: $(SED) -e "s,define STAP_HAS_SEMAPHORES 1,undef STAP_HAS_SEMAPHORES," 2301 # -e "s,define _SDT_HAS_SEMAPHORES 1,undef _SDT_HAS_SEMAPHORES," 2302 dtrace_hdr_gen = generator(dtrace, 2303 output : '@BASENAME@.h', 2304 arguments : ['-h', '-s', '@INPUT@', '-o', '@OUTPUT@']) 2305 glib_conf.set('HAVE_DTRACE', 1) 2306 enable_dtrace = true 2307endif 2308 2309# systemtap 2310want_systemtap = get_option('systemtap') 2311enable_systemtap = false 2312 2313if want_systemtap and enable_dtrace 2314 tapset_install_dir = get_option('tapset_install_dir') 2315 if tapset_install_dir == '' 2316 tapset_install_dir = join_paths(get_option('datadir'), 'systemtap/tapset', host_machine.cpu_family()) 2317 endif 2318 stp_cdata = configuration_data() 2319 stp_cdata.set('ABS_GLIB_RUNTIME_LIBDIR', glib_libdir) 2320 stp_cdata.set('LT_CURRENT', minor_version * 100) 2321 stp_cdata.set('LT_REVISION', micro_version) 2322 enable_systemtap = true 2323endif 2324 2325test_timeout = 60 2326test_timeout_slow = 180 2327 2328pkg = import('pkgconfig') 2329windows = import('windows') 2330subdir('glib') 2331subdir('gobject') 2332subdir('gthread') 2333subdir('gmodule') 2334subdir('gio') 2335subdir('fuzzing') 2336if build_tests 2337 subdir('tests') 2338endif 2339 2340# xgettext is optional (on Windows for instance) 2341if find_program('xgettext', required : get_option('nls')).found() 2342 subdir('po') 2343endif 2344 2345# Install glib-gettextize executable, if a UNIX-style shell is found 2346if have_sh 2347 # These should not contain " quotes around the values 2348 gettextize_conf = configuration_data() 2349 gettextize_conf.set('PACKAGE', 'glib') 2350 gettextize_conf.set('VERSION', meson.project_version()) 2351 gettextize_conf.set('prefix', glib_prefix) 2352 gettextize_conf.set('datarootdir', glib_datadir) 2353 gettextize_conf.set('datadir', glib_datadir) 2354 configure_file(input : 'glib-gettextize.in', 2355 install_dir : glib_bindir, 2356 output : 'glib-gettextize', 2357 configuration : gettextize_conf) 2358endif 2359 2360# Install m4 macros that other projects use 2361install_data('m4macros/glib-2.0.m4', 'm4macros/glib-gettext.m4', 'm4macros/gsettings.m4', 2362 install_dir : join_paths(get_option('datadir'), 'aclocal')) 2363 2364if host_system != 'windows' 2365 # Install Valgrind suppression file (except on Windows, 2366 # as Valgrind is currently not supported on Windows) 2367 install_data('glib.supp', 2368 install_dir : join_paths(get_option('datadir'), 'glib-2.0', 'valgrind')) 2369endif 2370 2371configure_file(output : 'config.h', configuration : glib_conf) 2372 2373if host_system == 'windows' 2374 install_headers([ 'msvc_recommended_pragmas.h' ], subdir : 'glib-2.0') 2375endif 2376 2377if get_option('man') 2378 xsltproc = find_program('xsltproc', required : true) 2379 xsltproc_command = [ 2380 xsltproc, 2381 '--nonet', 2382 '--stringparam', 'man.output.quietly', '1', 2383 '--stringparam', 'funcsynopsis.style', 'ansi', 2384 '--stringparam', 'man.th.extra1.suppress', '1', 2385 '--stringparam', 'man.authors.section.enabled', '0', 2386 '--stringparam', 'man.copyright.section.enabled', '0', 2387 '-o', '@OUTPUT@', 2388 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl', 2389 '@INPUT@', 2390 ] 2391 man1_dir = join_paths(glib_prefix, get_option('mandir'), 'man1') 2392endif 2393 2394gnome = import('gnome') 2395subdir('docs/reference') 2396