ci: collect test coverage and deploy a html report through gitlab pages
[glib.git] / meson.build
blobe1634865bc38fce7f7e1c0594d515a744d39b28d
1 project('glib', 'c', 'cpp',
2   version : '2.57.0',
3   meson_version : '>= 0.46.0',
4   default_options : [
5     'buildtype=debugoptimized',
6     'warning_level=1',
7     'c_std=gnu89'
8   ]
11 cc = meson.get_compiler('c')
12 cxx = meson.get_compiler('cpp')
14 cc_can_run = not meson.is_cross_build() or meson.has_exe_wrapper()
16 if cc.get_id() == 'msvc'
17   # Ignore several spurious warnings for things glib does very commonly
18   # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
19   # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
20   # NOTE: Only add warnings here if you are sure they're spurious
21   add_project_arguments('/wd4035', '/wd4715', '/wd4116',
22     '/wd4046', '/wd4068', '/wo4090', '/FImsvc_recommended_pragmas.h',language : 'c')
23   # Disable SAFESEH with MSVC for plugins and libs that use external deps that
24   # are built with MinGW
25   noseh_link_args = ['/SAFESEH:NO']
26 else
27   noseh_link_args = []
28   # -mms-bitfields vs -fnative-struct ?
29 endif
31 host_system = host_machine.system()
33 glib_version = meson.project_version()
34 glib_api_version = '2.0'
35 version_arr = glib_version.split('.')
36 major_version = version_arr[0].to_int()
37 minor_version = version_arr[1].to_int()
38 micro_version = version_arr[2].to_int()
40 interface_age = minor_version.is_odd() ? 0 : micro_version
41 binary_age = 100 * minor_version + micro_version
43 soversion = 0
44 # Maintain compatibility with previous libtool versioning
45 # current = minor * 100 + micro
46 library_version = '@0@.@1@.@2@'.format(soversion, binary_age - interface_age, interface_age)
48 configinc = include_directories('.')
49 glibinc = include_directories('glib')
50 gobjectinc = include_directories('gobject')
51 gmoduleinc = include_directories('gmodule')
52 gioinc = include_directories('gio')
54 glib_prefix = get_option('prefix')
55 glib_bindir = join_paths(glib_prefix, get_option('bindir'))
56 glib_libdir = join_paths(glib_prefix, get_option('libdir'))
57 glib_datadir = join_paths(glib_prefix, get_option('datadir'))
58 glib_pkgdatadir = join_paths(glib_datadir, 'glib-2.0')
59 glib_includedir = join_paths(glib_prefix, get_option('includedir'))
60 glib_giomodulesdir = get_option('gio_module_dir')
61 if glib_giomodulesdir == ''
62   glib_giomodulesdir = join_paths(glib_libdir, 'gio', 'modules')
63 endif
65 glib_pkgconfigreldir = join_paths(glib_libdir, 'pkgconfig')
67 add_project_arguments('-D_GNU_SOURCE', language: 'c')
69 # Disable strict aliasing;
70 # see https://bugzilla.gnome.org/show_bug.cgi?id=791622
71 if cc.has_argument('-fno-strict-aliasing')
72   add_project_arguments('-fno-strict-aliasing', language: 'c')
73 endif
75 ########################
76 # Configuration begins #
77 ########################
78 glib_conf = configuration_data()
79 glibconfig_conf = configuration_data()
81 # accumulated list of defines as we check for them, so we can easily
82 # use them later in test programs (autoconf does this automatically)
83 glib_conf_prefix = ''
85 glib_conf.set('GLIB_VERSION', glib_version)
86 glib_conf.set('GLIB_MAJOR_VERSION', major_version)
87 glib_conf.set('GLIB_MINOR_VERSION', minor_version)
88 glib_conf.set('GLIB_MICRO_VERSION', micro_version)
89 glib_conf.set('GLIB_INTERFACE_AGE', interface_age)
90 glib_conf.set('GLIB_BINARY_AGE', binary_age)
91 glib_conf.set_quoted('GETTEXT_PACKAGE', 'glib20')
92 glib_conf.set_quoted('PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=glib')
93 glib_conf.set_quoted('PACKAGE_NAME', 'glib')
94 glib_conf.set_quoted('PACKAGE_STRING', 'glib @0@'.format(meson.project_version()))
95 glib_conf.set_quoted('PACKAGE_TARNAME', 'glib')
96 glib_conf.set_quoted('PACKAGE_URL', '')
97 glib_conf.set_quoted('PACKAGE_VERSION', meson.project_version())
98 glib_conf.set('ENABLE_NLS', 1)
100 # Variables used in glib-gettextize and pkg-config files
101 # These should not contain " quotes around the values
102 glib_conf.set('PACKAGE', 'glib')
103 glib_conf.set('VERSION', meson.project_version())
104 glib_conf.set('prefix', glib_prefix)
105 glib_conf.set('exec_prefix', glib_prefix)
106 glib_conf.set('libdir', glib_libdir)
107 glib_conf.set('includedir', glib_includedir)
108 glib_conf.set('datadir', glib_datadir)
109 glib_conf.set('datarootdir', glib_datadir)
111 glib_conf.set('_GNU_SOURCE', 1)
113 if host_system == 'windows'
114   # Poll doesn't work on devices on Windows
115   glib_conf.set('BROKEN_POLL', true)
116 endif
118 # Check for GNU visibility attributes
119 g_have_gnuc_visibility = cc.compiles('''
120   void
121   __attribute__ ((visibility ("hidden")))
122        f_hidden (void)
123   {
124   }
125   void
126   __attribute__ ((visibility ("internal")))
127        f_internal (void)
128   {
129   }
130   void
131   __attribute__ ((visibility ("protected")))
132        f_protected (void)
133   {
134   }
135   void
136   __attribute__ ((visibility ("default")))
137        f_default (void)
138   {
139   }
140   int main (void)
141   {
142     f_hidden();
143     f_internal();
144     f_protected();
145     f_default();
146     return 0;
147   }
148   ''',
149   # Not supported by MSVC, but MSVC also won't support visibility,
150   # so it's OK to pass -Werror explicitly. Replace with
151   # override_options : 'werror=true' once that is supported
152   args: ['-Werror'],
153   name : 'GNU C visibility attributes test')
155 if g_have_gnuc_visibility
156   glibconfig_conf.set('G_HAVE_GNUC_VISIBILITY', '1')
157 endif
159 # Detect and set symbol visibility
160 glib_hidden_visibility_args = []
161 if get_option('default_library') != 'static'
162   if host_system == 'windows'
163     glib_conf.set('DLL_EXPORT', true)
164     if cc.get_id() == 'msvc'
165       glib_conf.set('_GLIB_EXTERN', '__declspec(dllexport) extern')
166     elif cc.has_argument('-fvisibility=hidden')
167       glib_conf.set('_GLIB_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) extern')
168       glib_hidden_visibility_args = ['-fvisibility=hidden']
169     endif
170   elif cc.has_argument('-fvisibility=hidden')
171     glib_conf.set('_GLIB_EXTERN', '__attribute__((visibility("default"))) extern')
172     glib_hidden_visibility_args = ['-fvisibility=hidden']
173   endif
174 endif
176 if host_system == 'windows' and get_option('default_library') == 'static'
177     glibconfig_conf.set('GLIB_STATIC_COMPILATION', '1')
178     glibconfig_conf.set('GOBJECT_STATIC_COMPILATION', '1')
179 endif
181 # FIXME: what about Cygwin (G_WITH_CYGWIN)
182 if host_system == 'windows'
183   glib_os = '''#define G_OS_WIN32
184 #define G_PLATFORM_WIN32'''
185 else
186   glib_os = '#define G_OS_UNIX'
187 endif
188 glibconfig_conf.set('glib_os', glib_os)
190 # We need to know the build type to determine what .lib files we need on Visual Studio
191 # for dependencies that don't normally come with pkg-config files for Visual Studio builds
192 buildtype = get_option('buildtype')
194 glib_debug_cflags = []
195 if buildtype.startswith('debug')
196   glib_debug_cflags += ['-DG_ENABLE_DEBUG']
197 elif buildtype == 'release'
198   glib_debug_cflags += ['-DG_DISABLE_CAST_CHECKS']
199 endif
201 add_project_arguments(glib_debug_cflags, language: 'c')
203 # check for header files
205 headers = [
206   'stdlib.h',
207   'string.h',
208   'strings.h',
209   'memory.h',
210   'alloca.h',
211   'locale.h',
212   'xlocale.h',
213   'float.h',
214   'limits.h',
215   'pwd.h',
216   'grp.h',
217   'poll.h',
218   'termios.h',
219   'sys/param.h',
220   'sys/resource.h',
221   'mach/mach_time.h',
222   'sys/select.h',
223   'stdint.h',
224   'inttypes.h',
225   'sched.h',
226   'malloc.h',
227   'sys/vfs.h',
228   'sys/vmount.h',
229   'sys/statfs.h',
230   'sys/statvfs.h',
231   'sys/filio.h',
232   'mntent.h',
233   'sys/mnttab.h',
234   'sys/vfstab.h',
235   'sys/mntctl.h',
236   'fstab.h',
237   'linux/magic.h',
238   'termios.h',
239   'dirent.h', # MSC does not come with this by default
240   'sys/time.h', # MSC does not come with this by default
241   'sys/times.h',
242   'sys/wait.h',
243   'unistd.h',
244   'values.h',
245   'sys/types.h',
246   'sys/uio.h',
247   'sys/mkdev.h',
248   'sys/mount.h',
249   'sys/sysctl.h',
250   'crt_externs.h',
251   'sys/inotify.h',
252   'sys/event.h',
253   'sys/stat.h',
256 foreach h : headers
257   if cc.has_header(h)
258     define = 'HAVE_' + h.underscorify().to_upper()
259     glib_conf.set(define, 1)
260     glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(define)
261   endif
262 endforeach
264 if cc.has_header('linux/netlink.h')
265   glib_conf.set('HAVE_NETLINK', 1)
266 endif
268 if glib_conf.has('HAVE_LOCALE_H')
269   if cc.has_header_symbol('locale.h', 'LC_MESSAGES')
270     glib_conf.set('HAVE_LC_MESSAGES', 1)
271   endif
272 endif
274 struct_stat_blkprefix = '''
275 #include <sys/types.h>
276 #include <sys/stat.h>
277 #ifdef HAVE_UNISTD_H
278 #include <unistd.h>
279 #endif
280 #ifdef HAVE_SYS_STATFS_H
281 #include <sys/statfs.h>
282 #endif
283 #ifdef HAVE_SYS_PARAM_H
284 #include <sys/param.h>
285 #endif
286 #ifdef HAVE_SYS_MOUNT_H
287 #include <sys/mount.h>
288 #endif
291 struct_members = [
292   [ 'stat', 'st_mtimensec' ],
293   [ 'stat', 'st_mtim.tv_nsec' ],
294   [ 'stat', 'st_atimensec' ],
295   [ 'stat', 'st_atim.tv_nsec' ],
296   [ 'stat', 'st_ctimensec' ],
297   [ 'stat', 'st_ctim.tv_nsec' ],
298   [ 'stat', 'st_birthtime' ],
299   [ 'stat', 'st_birthtimensec' ],
300   [ 'stat', 'st_birthtim' ],
301   [ 'stat', 'st_birthtim.tv_nsec' ],
302   [ 'stat', 'st_blksize', struct_stat_blkprefix ],
303   [ 'stat', 'st_blocks', struct_stat_blkprefix ],
304   [ 'statfs', 'f_fstypename', struct_stat_blkprefix ],
305   [ 'statfs', 'f_bavail', struct_stat_blkprefix ],
306   [ 'dirent', 'd_type', '''#include <sys/types.h>
307                            #include <dirent.h>''' ],
310 foreach m : struct_members
311   header_check_prefix = glib_conf_prefix
312   if m.length() == 3
313     header_check_prefix = header_check_prefix + m[2]
314   else
315     header_check_prefix = header_check_prefix + '#include <sys/stat.h>'
316   endif
317   if cc.has_member('struct ' + m[0], m[1], prefix : header_check_prefix)
318     define = 'HAVE_STRUCT_@0@_@1@'.format(m[0].to_upper(), m[1].underscorify().to_upper())
319     glib_conf.set(define, 1)
320     glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(define)
321   else
322   endif
323 endforeach
325 # Compiler flags
326 if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
327   test_c_args = [
328     '-Wall',
329     '-Wduplicated-branches',
330     '-Wstrict-prototypes',
331     '-Werror=declaration-after-statement',
332     '-Werror=format=2',
333     '-Werror=format-security',
334     '-Werror=implicit-function-declaration',
335     '-Werror=init-self',
336     '-Werror=missing-include-dirs',
337     '-Werror=missing-prototypes',
338     '-Werror=pointer-arith',
339   ]
340   test_c_link_args = [
341     '-Wl,-z,nodelete',
342   ]
343   if get_option('bsymbolic_functions')
344     test_c_link_args += ['-Wl,-Bsymbolic-functions']
345   endif
346 else
347   test_c_args = []
348   test_c_link_args = []
349 endif
351 add_project_arguments(cc.get_supported_arguments(test_c_args), language: 'c')
352 add_project_link_arguments(cc.get_supported_link_arguments(test_c_link_args), language: 'c')
354 # Windows Support (Vista+)
355 if host_system == 'windows'
356   glib_conf.set('_WIN32_WINNT', '0x0601')
357 endif
359 functions = [
360   'alloca',
361   'mmap',
362   'memalign',
363   'valloc',
364   'fsync',
365   'pipe2',
366   'issetugid',
367   'timegm',
368   'gmtime_r',
369   'strerror_r',
370   'lstat',
371   'strsignal',
372   'vsnprintf',
373   'poll',
374   'vasprintf',
375   'setenv',
376   'unsetenv',
377   'getc_unlocked',
378   'readlink',
379   'symlink',
380   'fdwalk',
381   'lchmod',
382   'lchown',
383   'fchmod',
384   'fchown',
385   'utimes',
386   'getresuid',
387   'getmntent_r',
388   'setmntent',
389   'endmntent',
390   'hasmntopt',
391   'getfsstat',
392   'getvfsstat',
393   'fallocate',
394   'localtime_r',
395   'gmtime_r',
396   'getpwuid_r',
397   'getgrgid_r',
398   'prlimit',
399   'strnlen',
400   'wcslen',
401   'wcsnlen',
402   'mbrtowc',
403   'wcrtomb',
404   'newlocale',
405   'uselocale',
406   'strtod_l',
407   'strtoll_l',
408   'strtoull_l',
409   'inotify_init1',
410   'kqueue',
411   'kevent',
412   'endservent',
413   'sendmmsg',
414   'recvmmsg',
415   'link',
418 if glib_conf.has('HAVE_SYS_STATVFS_H')
419   functions += ['statvfs']
420 else
421   have_func_statvfs = false
422 endif
423 if glib_conf.has('HAVE_SYS_STATFS_H') or glib_conf.has('HAVE_SYS_MOUNT_H')
424   functions += ['statfs']
425 else
426   have_func_statfs = false
427 endif
429 if host_system == 'windows'
430   iphlpapi_dep = cc.find_library('iphlpapi')
431   iphlpapi_funcs = ['if_nametoindex', 'if_indextoname']
432   foreach ifunc : iphlpapi_funcs
433     if cc.has_function(ifunc,
434                        prefix : '#define _WIN32_WINNT 0x0601\n#include <winsock2.h>\n#include <iphlpapi.h>',
435                        dependencies : iphlpapi_dep)
436       idefine = 'HAVE_' + ifunc.underscorify().to_upper()
437       glib_conf.set(idefine, 1)
438       glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(idefine)
439       set_variable('have_func_' + ifunc, true)
440     else
441       set_variable('have_func_' + ifunc, false)
442     endif
443   endforeach
444 else
445   functions += ['if_indextoname', 'if_nametoindex']
446 endif
448 # AIX splice is something else
449 if host_system != 'aix'
450   functions += ['splice']
451 endif
453 foreach f : functions
454   if cc.has_function(f)
455     define = 'HAVE_' + f.underscorify().to_upper()
456     glib_conf.set(define, 1)
457     glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(define)
458     set_variable('have_func_' + f, true)
459   else
460     set_variable('have_func_' + f, false)
461   endif
462 endforeach
464 if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
465     no_builtin_args = cc.get_supported_arguments(['-fno-builtin'])
466 else
467     no_builtin_args = []
468 endif
470 # Check that stpcpy() is not a builtin
471 if cc.links('''#include <string.h>
472                int main (int argc, char ** argv) {
473                  char p[10];
474                  return stpcpy (p, argv[0]) != NULL;
475                }
476             ''',
477             args : no_builtin_args,
478             name : 'stpcpy() is not a builtin')
479   glib_conf.set('HAVE_STPCPY', 1)
480 endif
482 # Check that posix_memalign() is not a builtin
483 if cc.links('''#include <stdlib.h>
484                int main (int argc, char ** argv) {
485                  void *p;
486                  return posix_memalign (&p, 16, argc);
487                }
488             ''',
489             args : no_builtin_args,
490             name : 'posix_memalign() is not a builtin')
491   glib_conf.set('HAVE_POSIX_MEMALIGN', 1)
492 endif
494 # Check whether strerror_r returns char *
495 if have_func_strerror_r
496   if cc.compiles('''#define _GNU_SOURCE
497                     #include <string.h>
498                     int func (void) {
499                       char error_string[256];
500                       char *ptr = strerror_r (-2, error_string, 256);
501                       char c = *strerror_r (-2, error_string, 256);
502                       return c != 0 && ptr != (void*) 0L;
503                     }
504                  ''',
505                  name : 'strerror_r() returns char *')
506     glib_conf.set('STRERROR_R_CHAR_P', 1,
507                   description: 'Defined if strerror_r returns char *')
508   endif
509 endif
511 # Special-case these functions that have alternative names on Windows/MSVC
512 if cc.has_function('snprintf') or cc.has_header_symbol('stdio.h', 'snprintf')
513   glib_conf.set('HAVE_SNPRINTF', 1)
514   glib_conf_prefix = glib_conf_prefix + '#define HAVE_SNPRINTF 1\n'
515 elif cc.has_function('_snprintf') or cc.has_header_symbol('stdio.h', '_snprintf')
516   hack_define = '1\n#define snprintf _snprintf'
517   glib_conf.set('HAVE_SNPRINTF', hack_define)
518   glib_conf_prefix = glib_conf_prefix + '#define HAVE_SNPRINTF ' + hack_define
519 endif
521 if cc.has_function('strcasecmp')
522   glib_conf.set('HAVE_STRCASECMP', 1)
523   glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRCASECMP 1\n'
524 elif cc.has_function('_stricmp')
525   hack_define = '1\n#define strcasecmp _stricmp'
526   glib_conf.set('HAVE_STRCASECMP', hack_define)
527   glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRCASECMP ' + hack_define
528 endif
530 if cc.has_function('strncasecmp')
531   glib_conf.set('HAVE_STRNCASECMP', 1)
532   glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRNCASECMP 1\n'
533 elif cc.has_function('_strnicmp')
534   hack_define = '1\n#define strncasecmp _strnicmp'
535   glib_conf.set('HAVE_STRNCASECMP', hack_define)
536   glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRNCASECMP ' + hack_define
537 endif
539 if cc.has_header_symbol('sys/sysmacros.h', 'major')
540   glib_conf.set('MAJOR_IN_SYSMACROS', 1)
541 elif cc.has_header_symbol('sys/mkdev.h', 'major')
542   glib_conf.set('MAJOR_IN_MKDEV', 1)
543 endif
545 if cc.has_header_symbol('dlfcn.h', 'RTLD_LAZY')
546   glib_conf.set('HAVE_RTLD_LAZY', 1)
547 endif
549 if cc.has_header_symbol('dlfcn.h', 'RTLD_NOW')
550   glib_conf.set('HAVE_RTLD_NOW', 1)
551 endif
553 if cc.has_header_symbol('dlfcn.h', 'RTLD_GLOBAL')
554   glib_conf.set('HAVE_RTLD_GLOBAL', 1)
555 endif
557 # Check whether to use statfs or statvfs
558 # Some systems have both statfs and statvfs, pick the most "native" for these
559 if have_func_statfs and have_func_statvfs
560   # on solaris and irix, statfs doesn't even have the f_bavail field
561   if not glib_conf.has('HAVE_STRUCT_STATFS_F_BAVAIL')
562     have_func_statfs = false
563   else
564     # at least on linux, statfs is the actual syscall
565     have_func_statvfs = false
566   endif
567 endif
568 if have_func_statfs
569   glib_conf.set('USE_STATFS', 1)
570   stat_func_to_use = 'statfs'
571 elif have_func_statvfs
572   glib_conf.set('USE_STATVFS', 1)
573   stat_func_to_use = 'statvfs'
574 else
575   stat_func_to_use = 'neither'
576 endif
577 message('Checking whether to use statfs or statvfs .. ' + stat_func_to_use)
579 if host_system == 'linux'
580   if cc.has_function('mkostemp',
581                      prefix: '''#define _GNU_SOURCE
582                                 #include <stdlib.h>''')
583     glib_conf.set('HAVE_MKOSTEMP', 1)
584   endif
585 endif
587 osx_ldflags = []
589 # Mac OS X Carbon support
590 glib_have_carbon = cc.compiles('''#include <Carbon/Carbon.h>
591                                   #include <CoreServices/CoreServices.h>''',
592                                name : 'Mac OS X Carbon support')
594 glib_have_os_x_9_or_later = false
596 if glib_have_carbon
597   glib_conf.set('HAVE_CARBON', true)
598   osx_ldflags += '-Wl,-framework,Carbon'
599   glib_have_os_x_9_or_later = cc.compiles('''#include <AvailabilityMacros.h>
600                                              #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
601                                              #error Compiling for minimum OS X version before 10.9
602                                              #endif''', name : 'OS X 9 or later')
603 endif
605 # Mac OS X Cocoa support
606 glib_have_cocoa = cc.compiles('''#include <Cocoa/Cocoa.h>
607                                  #ifdef GNUSTEP_BASE_VERSION
608                                  #error "Detected GNUstep, not Cocoa"
609                                  #endif''',
610                               name : 'Mac OS X Cocoa support')
612 if glib_have_cocoa
613   glib_conf.set('HAVE_COCOA', true)
614   osx_ldflags += '-Wl,-framework,Foundation -Wl,-framework,AppKit'
615 endif
617 add_project_link_arguments(osx_ldflags, language : 'c')
619 # Check for futex(2)
620 if cc.links('''#include <linux/futex.h>
621                #include <sys/syscall.h>
622                #include <unistd.h>
623                int main (int argc, char ** argv) {
624                  syscall (__NR_futex, NULL, FUTEX_WAKE, FUTEX_WAIT);
625                  return 0;
626                }''', name : 'futex(2) system call')
627   glib_conf.set('HAVE_FUTEX', 1)
628 endif
630 # Check for eventfd(2)
631 if cc.links('''#include <sys/eventfd.h>
632                #include <unistd.h>
633                int main (int argc, char ** argv) {
634                  eventfd (0, EFD_CLOEXEC);
635                  return 0;
636                }''', name : 'eventfd(2) system call')
637   glib_conf.set('HAVE_EVENTFD', 1)
638 endif
640 clock_gettime_test_code = '''
641   #include <time.h>
642   struct timespec t;
643   int main (int argc, char ** argv) {
644     return clock_gettime(CLOCK_REALTIME, &t);
645   }'''
646 librt = []
647 if cc.links(clock_gettime_test_code, name : 'clock_gettime')
648   glib_conf.set('HAVE_CLOCK_GETTIME', 1)
649 elif cc.links(clock_gettime_test_code, args : '-lrt', name : 'clock_gettime in librt')
650   glib_conf.set('HAVE_CLOCK_GETTIME', 1)
651   librt = cc.find_library('rt')
652 endif
654 # if statfs() takes 2 arguments (Posix) or 4 (Solaris)
655 if have_func_statfs
656   if cc.compiles(glib_conf_prefix + '''
657                  #include <unistd.h>
658                         #ifdef HAVE_SYS_PARAM_H
659                         #include <sys/param.h>
660                         #endif
661                         #ifdef HAVE_SYS_VFS_H
662                         #include <sys/vfs.h>
663                         #endif
664                         #ifdef HAVE_SYS_MOUNT_H
665                         #include <sys/mount.h>
666                         #endif
667                         #ifdef HAVE_SYS_STATFS_H
668                         #include <sys/statfs.h>
669                         #endif
670                         void some_func (void) {
671                           struct statfs st;
672                           statfs("/", &st);
673                         }''', name : 'number of arguments to statfs() (n=2)')
674     glib_conf.set('STATFS_ARGS', 2)
675   elif cc.compiles(glib_conf_prefix + '''
676                    #include <unistd.h>
677                           #ifdef HAVE_SYS_PARAM_H
678                           #include <sys/param.h>
679                           #endif
680                           #ifdef HAVE_SYS_VFS_H
681                           #include <sys/vfs.h>
682                           #endif
683                           #ifdef HAVE_SYS_MOUNT_H
684                           #include <sys/mount.h>
685                           #endif
686                           #ifdef HAVE_SYS_STATFS_H
687                           #include <sys/statfs.h>
688                           #endif
689                           void some_func (void) {
690                             struct statfs st;
691                             statfs("/", &st, sizeof (st), 0);
692                           }''', name : 'number of arguments to statfs() (n=4)')
693     glib_conf.set('STATFS_ARGS', 4)
694   else
695     error('Unable to determine number of arguments to statfs()')
696   endif
697 endif
699 # open takes O_DIRECTORY as an option
700 #AC_MSG_CHECKING([])
701 if cc.compiles('''#include <fcntl.h>
702                   #include <sys/types.h>
703                   #include <sys/stat.h>],
704                   void some_func (void) {
705                     open(0, O_DIRECTORY, 0);
706                   }''', name : 'open() option O_DIRECTORY')
707   glib_conf.set('HAVE_OPEN_O_DIRECTORY', 1)
708 endif
710 # Check whether there is a vsnprintf() function with C99 semantics installed.
711 # AC_FUNC_VSNPRINTF_C99
712 # Check whether there is a snprintf() function with C99 semantics installed.
713 # AC_FUNC_SNPRINTF_C99
715 have_good_vsnprintf = false
716 have_good_snprintf = false
718 if host_system == 'windows'
719   # Unfortunately the mingw and Visual Studio 2015+ implementations of C99-style
720   # snprintf and vsnprintf don't seem to be quite good enough, at least not in
721   # mingw-runtime-3.14.  (Sorry, I don't know exactly what is the problem,
722   # but it is related to floating point formatting and decimal point vs. comma.)
723   # The simple tests in AC_FUNC_VSNPRINTF_C99 and AC_FUNC_SNPRINTF_C99 aren't
724   # rigorous enough to notice, though.
725   glib_conf.set('HAVE_C99_SNPRINTF', false)
726   glib_conf.set('HAVE_C99_VSNPRINTF', false)
727 else
728   vsnprintf_c99_test_code = '''
729 #include <stdio.h>
730 #include <stdarg.h>
733 doit(char * s, ...)
735   char buffer[32];
736   va_list args;
737   int r;
739   va_start(args, s);
740   r = vsnprintf(buffer, 5, s, args);
741   va_end(args);
743   if (r != 7)
744     exit(1);
746   /* AIX 5.1 and Solaris seems to have a half-baked vsnprintf()
747      implementation. The above will return 7 but if you replace
748      the size of the buffer with 0, it borks! */
749   va_start(args, s);
750   r = vsnprintf(buffer, 0, s, args);
751   va_end(args);
753   if (r != 7)
754     exit(1);
756   exit(0);
760 main(void)
762   doit("1234567");
763   exit(1);
764 }'''
766   if cc_can_run
767     rres = cc.run(vsnprintf_c99_test_code, name : 'C99 vsnprintf')
768     if rres.compiled() and rres.returncode() == 0
769       glib_conf.set('HAVE_C99_VSNPRINTF', 1)
770       have_good_vsnprintf = true
771     endif
772   else
773       have_good_vsnprintf = meson.get_cross_property('have_c99_vsnprintf', false)
774       glib_conf.set('HAVE_C99_VSNPRINTF', have_good_vsnprintf)
775   endif
777   snprintf_c99_test_code = '''
778 #include <stdio.h>
779 #include <stdarg.h>
782 doit()
784   char buffer[32];
785   va_list args;
786   int r;
788   r = snprintf(buffer, 5, "1234567");
790   if (r != 7)
791     exit(1);
793   r = snprintf(buffer, 0, "1234567");
795   if (r != 7)
796     exit(1);
798   r = snprintf(NULL, 0, "1234567");
800   if (r != 7)
801     exit(1);
803   exit(0);
807 main(void)
809   doit();
810   exit(1);
811 }'''
813   if cc_can_run
814     rres = cc.run(snprintf_c99_test_code, name : 'C99 snprintf')
815     if rres.compiled() and rres.returncode() == 0
816       glib_conf.set('HAVE_C99_SNPRINTF', 1)
817       have_good_snprintf = true
818     endif
819   else
820       have_good_snprintf = meson.get_cross_property('have_c99_snprintf', false)
821       glib_conf.set('HAVE_C99_SNPRINTF', have_good_snprintf)
822   endif
823 endif
825 if host_system == 'windows'
826   glib_conf.set_quoted('EXEEXT', '.exe')
827 else
828   glib_conf.set('EXEEXT', '')
829 endif
831 if have_good_vsnprintf and have_good_snprintf
832   # Our printf is 'good' only if vsnpintf()/snprintf() supports C99 well enough
833   glib_conf.set('HAVE_GOOD_PRINTF', 1) # FIXME: Check for HAVE_UNIX98_PRINTF?
834 else
835   glib_conf.set('HAVE_VASPRINTF', 1)
836 endif
838 # Check whether the printf() family supports Unix98 %n$ positional parameters
839 # AC_FUNC_PRINTF_UNIX98
840 # Nothing uses HAVE_UNIX98_PRINTF
843 # Check for nl_langinfo and CODESET
844 # FIXME: Check for HAVE_BIND_TEXTDOMAIN_CODESET
845 if cc.links('''#include <langinfo.h>
846                int main (int argc, char ** argv) {
847                  char *codeset = nl_langinfo (CODESET);
848                  return 0;
849                }''', name : 'nl_langinfo and CODESET')
850   glib_conf.set('HAVE_LANGINFO_CODESET', 1)
851   glib_conf.set('HAVE_CODESET', 1)
852 endif
854 # Check for nl_langinfo and LC_TIME parts that are needed in gdatetime.c
855 if cc.links('''#include <langinfo.h>
856                int main (int argc, char ** argv) {
857                  char *str;
858                  str = nl_langinfo (PM_STR);
859                  str = nl_langinfo (D_T_FMT);
860                  str = nl_langinfo (D_FMT);
861                  str = nl_langinfo (T_FMT);
862                  str = nl_langinfo (T_FMT_AMPM);
863                  str = nl_langinfo (MON_1);
864                  str = nl_langinfo (ABMON_12);
865                  str = nl_langinfo (DAY_1);
866                  str = nl_langinfo (ABDAY_7);
867                  return 0;
868                }''', name : 'nl_langinfo (PM_STR)')
869   glib_conf.set('HAVE_LANGINFO_TIME', 1)
870 endif
871 if cc.links('''#include <langinfo.h>
872                int main (int argc, char ** argv) {
873                  char *str;
874                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT0_MB);
875                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT1_MB);
876                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT2_MB);
877                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT3_MB);
878                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT4_MB);
879                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT5_MB);
880                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT6_MB);
881                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT7_MB);
882                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT8_MB);
883                  str = nl_langinfo (_NL_CTYPE_OUTDIGIT9_MB);
884                  return 0;
885                }''', name : 'nl_langinfo (_NL_CTYPE_OUTDIGITn_MB)')
886   glib_conf.set('HAVE_LANGINFO_OUTDIGIT', 1)
887 endif
889 # Check for nl_langinfo and alternative month names
890 if cc.links('''#ifndef _GNU_SOURCE
891               # define _GNU_SOURCE
892               #endif
893               #include <langinfo.h>
894                int main (int argc, char ** argv) {
895                  char *str;
896                  str = nl_langinfo (ALTMON_1);
897                  str = nl_langinfo (ALTMON_2);
898                  str = nl_langinfo (ALTMON_3);
899                  str = nl_langinfo (ALTMON_4);
900                  str = nl_langinfo (ALTMON_5);
901                  str = nl_langinfo (ALTMON_6);
902                  str = nl_langinfo (ALTMON_7);
903                  str = nl_langinfo (ALTMON_8);
904                  str = nl_langinfo (ALTMON_9);
905                  str = nl_langinfo (ALTMON_10);
906                  str = nl_langinfo (ALTMON_11);
907                  str = nl_langinfo (ALTMON_12);
908                  return 0;
909                }''', name : 'nl_langinfo (ALTMON_n)')
910   glib_conf.set('HAVE_LANGINFO_ALTMON', 1)
911 endif
913 # Check for nl_langinfo and abbreviated alternative month names
914 if cc.links('''#ifndef _GNU_SOURCE
915               # define _GNU_SOURCE
916               #endif
917               #include <langinfo.h>
918                int main (int argc, char ** argv) {
919                  char *str;
920                  str = nl_langinfo (_NL_ALTMON_1);
921                  str = nl_langinfo (_NL_ALTMON_2);
922                  str = nl_langinfo (_NL_ALTMON_3);
923                  str = nl_langinfo (_NL_ALTMON_4);
924                  str = nl_langinfo (_NL_ALTMON_5);
925                  str = nl_langinfo (_NL_ALTMON_6);
926                  str = nl_langinfo (_NL_ALTMON_7);
927                  str = nl_langinfo (_NL_ALTMON_8);
928                  str = nl_langinfo (_NL_ALTMON_9);
929                  str = nl_langinfo (_NL_ALTMON_10);
930                  str = nl_langinfo (_NL_ALTMON_11);
931                  str = nl_langinfo (_NL_ALTMON_12);
932                  return 0;
933                }''', name : 'nl_langinfo (_NL_ALTMON_n)')
934   glib_conf.set('HAVE_LANGINFO_ABALTMON', 1)
935 endif
937 # Check if C compiler supports the 'signed' keyword
938 if not cc.compiles('''signed char x;''', name : 'signed')
939   glib_conf.set('signed', '/* NOOP */')
940 endif
942 # Check if the ptrdiff_t type exists
943 if cc.has_header_symbol('stddef.h', 'ptrdiff_t')
944   glib_conf.set('HAVE_PTRDIFF_T', 1)
945 endif
947 # Check for sig_atomic_t type
948 if cc.links('''#include <signal.h>
949                #include <sys/types.h>
950                sig_atomic_t val = 42;
951                int main (int argc, char ** argv) {
952                  return val == 42 ? 0 : 1;
953                }''', name : 'sig_atomic_t')
954   glib_conf.set('HAVE_SIG_ATOMIC_T', 1)
955 endif
957 # Check if 'long long' works and what format can be used to print it
958 # jm_AC_TYPE_LONG_LONG
959 # Nothing uses HAVE_LONG_LONG_FORMAT and HAVE_INT64_AND_I64
960 if cc.compiles('''long long ll = 1LL;
961                   int i = 63;
962                   int some_func (void) {
963                     long long llmax = (long long) -1;
964                     return ll << i | ll >> i | llmax / ll | llmax % ll;
965                   }''', name : 'long long')
966   glib_conf.set('HAVE_LONG_LONG', 1)
967   have_long_long = true
968 else
969   have_long_long = false
970 endif
972 # Test whether the compiler supports the 'long double' type.
973 if cc.compiles('''/* The Stardent Vistra knows sizeof(long double), but does not support it.  */
974                   long double foo = 0.0;
975                   /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
976                   int array [2*(sizeof(long double) >= sizeof(double)) - 1];''',
977                name : 'long double')
978   glib_conf.set('HAVE_LONG_DOUBLE', 1)
979 endif
981 #dnl Test whether <stddef.h> has the 'wchar_t' type.
982 if cc.has_header_symbol('stddef.h', 'wchar_t')
983   glib_conf.set('HAVE_WCHAR_T', 1)
984 endif
986 # Test whether <wchar.h> has the 'wint_t' type.
987 if cc.has_header_symbol('wchar.h', 'wint_t')
988   glib_conf.set('HAVE_WINT_T', 1)
989 endif
991 found_uintmax_t = false
993 # Define HAVE_INTTYPES_H_WITH_UINTMAX if <inttypes.h> exists,
994 # doesn't clash with <sys/types.h>, and declares uintmax_t.
995 # jm_AC_HEADER_INTTYPES_H
996 if cc.compiles('''#include <sys/types.h>
997                   #include <inttypes.h>
998                   void some_func (void) {
999                     uintmax_t i = (uintmax_t) -1;
1000                   }''', name : 'uintmax_t in inttypes.h')
1001   glib_conf.set('HAVE_INTTYPES_H_WITH_UINTMAX', 1)
1002   found_uintmax_t = true
1003 endif
1005 # Define HAVE_STDINT_H_WITH_UINTMAX if <stdint.h> exists,
1006 # doesn't clash with <sys/types.h>, and declares uintmax_t.
1007 # jm_AC_HEADER_STDINT_H
1008 if cc.compiles('''#include <sys/types.h>
1009                   #include <stdint.h>
1010                   void some_func (void) {
1011                     uintmax_t i = (uintmax_t) -1;
1012                   }''', name : 'uintmax_t in stdint.h')
1013   glib_conf.set('HAVE_STDINT_H_WITH_UINTMAX', 1)
1014   found_uintmax_t = true
1015 endif
1017 # Define intmax_t to 'long' or 'long long'
1018 # if it is not already defined in <stdint.h> or <inttypes.h>.
1019 # For simplicity, we assume that a header file defines 'intmax_t' if and
1020 # only if it defines 'uintmax_t'.
1021 if found_uintmax_t
1022   glib_conf.set('HAVE_INTMAX_T', 1)
1023 elif have_long_long
1024   glib_conf.set('intmax_t', 'long long')
1025 else
1026   glib_conf.set('intmax_t', 'long')
1027 endif
1029 char_size = cc.sizeof('char')
1030 short_size = cc.sizeof('short')
1031 int_size = cc.sizeof('int')
1032 voidp_size = cc.sizeof('void*')
1033 long_size = cc.sizeof('long')
1034 if have_long_long
1035   long_long_size = cc.sizeof('long long')
1036 else
1037   long_long_size = 0
1038 endif
1039 sizet_size = cc.sizeof('size_t')
1040 if cc.get_id() == 'msvc'
1041   ssizet_size = cc.sizeof('SSIZE_T', prefix : '#include <BaseTsd.h>')
1042 else
1043   ssizet_size = cc.sizeof('ssize_t')
1044 endif
1046 # On Windows, MSVC supports both ll and I64 as format specifiers for 64-bit
1047 # integers, but some versions (at least 4.7.x) of MinGW only support I64.
1048 if host_system == 'windows'
1049   int64_m = 'I64'
1050 else
1051   int64_m = 'll'
1052 endif
1054 char_align = cc.alignment('char')
1055 short_align = cc.alignment('short')
1056 int_align = cc.alignment('int')
1057 voidp_align = cc.alignment('void*')
1058 long_align = cc.alignment('long')
1059 long_long_align = cc.alignment('long long')
1060 # NOTE: We don't check for size of __int64 because long long is guaranteed to
1061 # be 64-bit in C99, and it is available on all supported compilers
1062 sizet_align = cc.alignment('size_t')
1064 glib_conf.set('ALIGNOF_UNSIGNED_LONG', long_align)
1066 glib_conf.set('SIZEOF_CHAR', char_size)
1067 glib_conf.set('SIZEOF_INT', int_size)
1068 glib_conf.set('SIZEOF_SHORT', short_size)
1069 glib_conf.set('SIZEOF_LONG', long_size)
1070 glib_conf.set('SIZEOF_LONG_LONG', long_long_size)
1071 glib_conf.set('SIZEOF_SIZE_T', sizet_size)
1072 glib_conf.set('SIZEOF_SSIZE_T', ssizet_size)
1073 glib_conf.set('SIZEOF_VOID_P', voidp_size)
1075 if short_size == 2
1076   gint16 = 'short'
1077   gint16_modifier='h'
1078   gint16_format='hi'
1079   guint16_format='hu'
1080 elif int_size == 2
1081   gint16 = 'int'
1082   gint16_modifier=''
1083   gint16_format='i'
1084   guint16_format='u'
1085 else
1086   error('Compiler provides no native 16-bit integer type')
1087 endif
1088 glibconfig_conf.set('gint16', gint16)
1089 glibconfig_conf.set_quoted('gint16_modifier', gint16_modifier)
1090 glibconfig_conf.set_quoted('gint16_format', gint16_format)
1091 glibconfig_conf.set_quoted('guint16_format', guint16_format)
1093 if short_size == 4
1094   gint32 = 'short'
1095   gint32_modifier='h'
1096   gint32_format='hi'
1097   guint32_format='hu'
1098   guint32_align = short_align
1099 elif int_size == 4
1100   gint32 = 'int'
1101   gint32_modifier=''
1102   gint32_format='i'
1103   guint32_format='u'
1104   guint32_align = int_align
1105 elif long_size == 4
1106   gint32 = 'long'
1107   gint32_modifier='l'
1108   gint32_format='li'
1109   guint32_format='lu'
1110   guint32_align = long_align
1111 else
1112   error('Compiler provides no native 32-bit integer type')
1113 endif
1114 glibconfig_conf.set('gint32', gint32)
1115 glibconfig_conf.set_quoted('gint32_modifier', gint32_modifier)
1116 glibconfig_conf.set_quoted('gint32_format', gint32_format)
1117 glibconfig_conf.set_quoted('guint32_format', guint32_format)
1118 glib_conf.set('ALIGNOF_GUINT32', guint32_align)
1120 if int_size == 8
1121   gint64 = 'int'
1122   gint64_modifier=''
1123   gint64_format='i'
1124   guint64_format='u'
1125   glib_extension=''
1126   gint64_constant='(val)'
1127   guint64_constant='(val)'
1128   guint64_align = int_align
1129 elif long_size == 8
1130   gint64 = 'long'
1131   glib_extension=''
1132   gint64_modifier='l'
1133   gint64_format='li'
1134   guint64_format='lu'
1135   gint64_constant='(val##L)'
1136   guint64_constant='(val##UL)'
1137   guint64_align = long_align
1138 elif long_long_size == 8
1139   gint64 = 'long long'
1140   glib_extension='G_GNUC_EXTENSION '
1141   gint64_modifier=int64_m
1142   gint64_format=int64_m + 'i'
1143   guint64_format=int64_m + 'u'
1144   gint64_constant='(G_GNUC_EXTENSION (val##LL))'
1145   guint64_constant='(G_GNUC_EXTENSION (val##ULL))'
1146   guint64_align = long_long_align
1147 else
1148   error('Compiler provides no native 64-bit integer type')
1149 endif
1150 glibconfig_conf.set('glib_extension', glib_extension)
1151 glibconfig_conf.set('gint64', gint64)
1152 glibconfig_conf.set_quoted('gint64_modifier', gint64_modifier)
1153 glibconfig_conf.set_quoted('gint64_format', gint64_format)
1154 glibconfig_conf.set_quoted('guint64_format', guint64_format)
1155 glibconfig_conf.set('gint64_constant', gint64_constant)
1156 glibconfig_conf.set('guint64_constant', guint64_constant)
1157 glib_conf.set('ALIGNOF_GUINT64', guint64_align)
1159 if host_system == 'windows'
1160   glibconfig_conf.set('g_pid_type', 'void*')
1161   glibconfig_conf.set_quoted('g_pid_format', 'p')
1162   if host_machine.cpu_family() == 'x86_64'
1163     glibconfig_conf.set_quoted('g_pollfd_format', '%#I64x')
1164   else
1165     glibconfig_conf.set_quoted('g_pollfd_format', '%#x')
1166   endif
1167   glibconfig_conf.set('g_dir_separator', '\\\\')
1168   glibconfig_conf.set('g_searchpath_separator', ';')
1169 else
1170   glibconfig_conf.set('g_pid_type', 'int')
1171   glibconfig_conf.set_quoted('g_pid_format', 'i')
1172   glibconfig_conf.set_quoted('g_pollfd_format', '%d')
1173   glibconfig_conf.set('g_dir_separator', '/')
1174   glibconfig_conf.set('g_searchpath_separator', ':')
1175 endif
1177 if sizet_size == short_size
1178   glibconfig_conf.set('glib_size_type_define', 'short')
1179   glibconfig_conf.set_quoted('gsize_modifier', 'h')
1180   glibconfig_conf.set_quoted('gssize_modifier', 'h')
1181   glibconfig_conf.set_quoted('gsize_format', 'hu')
1182   glibconfig_conf.set_quoted('gssize_format', 'hi')
1183   glibconfig_conf.set('glib_msize_type', 'SHRT')
1184 elif sizet_size == int_size
1185   glibconfig_conf.set('glib_size_type_define', 'int')
1186   glibconfig_conf.set_quoted('gsize_modifier', '')
1187   glibconfig_conf.set_quoted('gssize_modifier', '')
1188   glibconfig_conf.set_quoted('gsize_format', 'u')
1189   glibconfig_conf.set_quoted('gssize_format', 'i')
1190   glibconfig_conf.set('glib_msize_type', 'INT')
1191 elif sizet_size == long_size
1192   glibconfig_conf.set('glib_size_type_define', 'long')
1193   glibconfig_conf.set_quoted('gsize_modifier', 'l')
1194   glibconfig_conf.set_quoted('gssize_modifier', 'l')
1195   glibconfig_conf.set_quoted('gsize_format', 'lu')
1196   glibconfig_conf.set_quoted('gssize_format', 'li')
1197   glibconfig_conf.set('glib_msize_type', 'LONG')
1198 elif sizet_size == long_long_size
1199   glibconfig_conf.set('glib_size_type_define', 'long long')
1200   glibconfig_conf.set_quoted('gsize_modifier', int64_m)
1201   glibconfig_conf.set_quoted('gssize_modifier', int64_m)
1202   glibconfig_conf.set_quoted('gsize_format', int64_m + 'u')
1203   glibconfig_conf.set_quoted('gssize_format', int64_m + 'i')
1204   glibconfig_conf.set('glib_msize_type', 'INT64')
1205 else
1206   error('Could not determine size of size_t.')
1207 endif
1209 if voidp_size == int_size
1210   glibconfig_conf.set('glib_intptr_type_define', 'int')
1211   glibconfig_conf.set_quoted('gintptr_modifier', '')
1212   glibconfig_conf.set_quoted('gintptr_format', 'i')
1213   glibconfig_conf.set_quoted('guintptr_format', 'u')
1214   glibconfig_conf.set('glib_gpi_cast', '(gint)')
1215   glibconfig_conf.set('glib_gpui_cast', '(guint)')
1216 elif voidp_size == long_size
1217   glibconfig_conf.set('glib_intptr_type_define', 'long')
1218   glibconfig_conf.set_quoted('gintptr_modifier', 'l')
1219   glibconfig_conf.set_quoted('gintptr_format', 'li')
1220   glibconfig_conf.set_quoted('guintptr_format', 'lu')
1221   glibconfig_conf.set('glib_gpi_cast', '(glong)')
1222   glibconfig_conf.set('glib_gpui_cast', '(gulong)')
1223 elif voidp_size == long_long_size
1224   glibconfig_conf.set('glib_intptr_type_define', 'long long')
1225   glibconfig_conf.set_quoted('gintptr_modifier', int64_m)
1226   glibconfig_conf.set_quoted('gintptr_format', int64_m + 'i')
1227   glibconfig_conf.set_quoted('guintptr_format', int64_m + 'u')
1228   glibconfig_conf.set('glib_gpi_cast', '(gint64)')
1229   glibconfig_conf.set('glib_gpui_cast', '(guint64)')
1230 else
1231   error('Could not determine size of void *')
1232 endif
1234 if long_size != 8 and long_long_size != 8 and int_size != 8
1235   error('GLib requires a 64-bit type. You might want to consider using the GNU C compiler.')
1236 endif
1238 glibconfig_conf.set('gintbits', int_size * 8)
1239 glibconfig_conf.set('glongbits', long_size * 8)
1240 glibconfig_conf.set('gsizebits', sizet_size * 8)
1241 glibconfig_conf.set('gssizebits', ssizet_size * 8)
1243 # FIXME: maybe meson should tell us the libsuffix?
1244 if host_system == 'windows'
1245   g_module_suffix = 'dll'
1246 elif host_system == 'darwin'
1247   g_module_suffix = 'dylib'
1248 else
1249   g_module_suffix = 'so'
1250 endif
1251 glibconfig_conf.set('g_module_suffix', g_module_suffix)
1253 glibconfig_conf.set('GLIB_MAJOR_VERSION', major_version)
1254 glibconfig_conf.set('GLIB_MINOR_VERSION', minor_version)
1255 glibconfig_conf.set('GLIB_MICRO_VERSION', micro_version)
1256 glibconfig_conf.set('GLIB_VERSION', glib_version)
1258 glibconfig_conf.set('glib_void_p', voidp_size)
1259 glibconfig_conf.set('glib_long', long_size)
1260 glibconfig_conf.set('glib_size_t', sizet_size)
1261 glibconfig_conf.set('glib_ssize_t', ssizet_size)
1262 if host_machine.endian() == 'big'
1263   glibconfig_conf.set('g_byte_order', 'G_BIG_ENDIAN')
1264   glibconfig_conf.set('g_bs_native', 'BE')
1265   glibconfig_conf.set('g_bs_alien', 'LE')
1266 else
1267   glibconfig_conf.set('g_byte_order', 'G_LITTLE_ENDIAN')
1268   glibconfig_conf.set('g_bs_native', 'LE')
1269   glibconfig_conf.set('g_bs_alien', 'BE')
1270 endif
1272 # === va_copy checks ===
1273 # we currently check for all three va_copy possibilities, so we get
1274 # all results in config.log for bug reports.
1276 va_copy_func = ''
1277 foreach try_func : [ '__va_copy', 'va_copy' ]
1278   if cc.compiles('''#include <stdarg.h>
1279                     #include <stdlib.h>
1280                     #ifdef _MSC_VER
1281                     # include "msvc_recommended_pragmas.h"
1282                     #endif
1283                     void f (int i, ...) {
1284                     va_list args1, args2;
1285                     va_start (args1, i);
1286                     @0@ (args2, args1);
1287                     if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1288                       exit (1);
1289                     va_end (args1); va_end (args2);
1290                     }
1291                     int main() {
1292                       f (0, 42);
1293                       return 0;
1294                     }'''.format(try_func),
1295                     name : try_func + ' check')
1296     va_copy_func = try_func
1297   endif
1298 endforeach
1299 if va_copy_func != ''
1300   glib_conf.set('G_VA_COPY', va_copy_func)
1301   glib_vacopy = '#define G_VA_COPY ' + va_copy_func
1302 else
1303   glib_vacopy = '/* #undef G_VA_COPY */'
1304 endif
1306 va_list_val_copy_prog = '''
1307   #include <stdarg.h>
1308   #include <stdlib.h>
1309   void f (int i, ...) {
1310     va_list args1, args2;
1311     va_start (args1, i);
1312     args2 = args1;
1313     if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
1314       exit (1);
1315     va_end (args1); va_end (args2);
1316   }
1317   int main() {
1318     f (0, 42);
1319     return 0;
1320   }'''
1322 if cc_can_run
1323   rres = cc.run(va_list_val_copy_prog, name : 'va_lists can be copied as values')
1324   glib_va_val_copy = rres.returncode() == 0
1325 else
1326   glib_va_val_copy = meson.get_cross_property('va_val_copy', true)
1327 endif
1328 if not glib_va_val_copy
1329   glib_vacopy = glib_vacopy + '\n#define G_VA_COPY_AS_ARRAY 1'
1330   glib_conf.set('G_VA_COPY_AS_ARRAY', 1)
1331 endif
1332 glibconfig_conf.set('glib_vacopy', glib_vacopy)
1334 # check for flavours of varargs macros
1335 g_have_iso_c_varargs = cc.compiles('''
1336   void some_func (void) {
1337     int a(int p1, int p2, int p3);
1338     #define call_a(...) a(1,__VA_ARGS__)
1339     call_a(2,3);
1340   }''', name : 'ISO C99 varargs macros in C')
1342 if g_have_iso_c_varargs
1343   glibconfig_conf.set('g_have_iso_c_varargs', '''
1344 #ifndef __cplusplus
1345 # define G_HAVE_ISO_VARARGS 1
1346 #endif''')
1347 endif
1349 g_have_iso_cxx_varargs = cxx.compiles('''
1350   void some_func (void) {
1351     int a(int p1, int p2, int p3);
1352     #define call_a(...) a(1,__VA_ARGS__)
1353     call_a(2,3);
1354   }''', name : 'ISO C99 varargs macros in C++')
1356 if g_have_iso_cxx_varargs
1357   glibconfig_conf.set('g_have_iso_cxx_varargs', '''
1358 #ifdef __cplusplus
1359 # define G_HAVE_ISO_VARARGS 1
1360 #endif''')
1361 endif
1363 g_have_gnuc_varargs = cc.compiles('''
1364   void some_func (void) {
1365     int a(int p1, int p2, int p3);
1366     #define call_a(params...) a(1,params)
1367     call_a(2,3);
1368   }''', name : 'GNUC varargs macros')
1370 if cc.has_header('alloca.h')
1371   glibconfig_conf.set('GLIB_HAVE_ALLOCA_H', true)
1372 endif
1373 has_syspoll = cc.has_header('sys/poll.h')
1374 has_systypes = cc.has_header('sys/types.h')
1375 if has_syspoll
1376   glibconfig_conf.set('GLIB_HAVE_SYS_POLL_H', true)
1377 endif
1378 has_winsock2 = cc.has_header('winsock2.h')
1380 if has_syspoll and has_systypes
1381   poll_includes = '''
1382       #include<sys/poll.h>
1383       #include<sys/types.h>'''
1384 elif has_winsock2
1385   poll_includes = '''
1386       #define _WIN32_WINNT 0x0600
1387       #include <winsock2.h>'''
1388 else
1389   # FIXME?
1390   error('FIX POLL* defines')
1391 endif
1393 poll_defines = [
1394   [ 'POLLIN', 'g_pollin', 1 ],
1395   [ 'POLLOUT', 'g_pollout', 4 ],
1396   [ 'POLLPRI', 'g_pollpri', 2 ],
1397   [ 'POLLERR', 'g_pollerr', 8 ],
1398   [ 'POLLHUP', 'g_pollhup', 16 ],
1399   [ 'POLLNVAL', 'g_pollnval', 32 ],
1402 if has_syspoll and has_systypes
1403   foreach d : poll_defines
1404     val = cc.compute_int(d[0], prefix: poll_includes)
1405     glibconfig_conf.set(d[1], val)
1406   endforeach
1407 elif has_winsock2
1408   # Due to a missed bug in configure.ac the poll test
1409   # never succeeded on Windows and used some pre-defined
1410   # values as a fallback. Keep using them to maintain
1411   # ABI compatibility with autotools builds of glibs
1412   # and with *any* glib-using code compiled against them,
1413   # since these values end up in a public header glibconfig.h.
1414   foreach d : poll_defines
1415     glibconfig_conf.set(d[1], d[2])
1416   endforeach
1417 endif
1419 # Internet address families
1420 # FIXME: what about Cygwin (G_WITH_CYGWIN)
1421 if host_system == 'windows'
1422   inet_includes = '''
1423       #include <winsock2.h>'''
1424 else
1425   inet_includes = '''
1426       #include <sys/types.h>
1427       #include <sys/socket.h>'''
1428 endif
1430 inet_defines = [
1431   [ 'AF_UNIX', 'g_af_unix' ],
1432   [ 'AF_INET', 'g_af_inet' ],
1433   [ 'AF_INET6', 'g_af_inet6' ],
1434   [ 'MSG_OOB', 'g_msg_oob' ],
1435   [ 'MSG_PEEK', 'g_msg_peek' ],
1436   [ 'MSG_DONTROUTE', 'g_msg_dontroute' ],
1438 foreach d : inet_defines
1439   val = cc.compute_int(d[0], prefix: inet_includes)
1440   glibconfig_conf.set(d[1], val)
1441 endforeach
1443 glibconfig_conf.set('GLIB_USING_SYSTEM_PRINTF', true) # FIXME!
1445 # We need a more robust approach here...
1446 host_cpu_family = host_machine.cpu_family()
1447 if host_cpu_family == 'x86' or host_cpu_family == 'x86_64' or host_cpu_family == 's390' or host_cpu_family == 's390x' or host_cpu_family.startswith('arm') or host_cpu_family.startswith('crisv32') or host_cpu_family.startswith('etrax')
1448   glib_memory_barrier_needed = false
1449 elif host_cpu_family.startswith('sparc') or host_cpu_family.startswith('alpha') or host_cpu_family.startswith('powerpc') or host_cpu_family == 'ia64'
1450   glib_memory_barrier_needed = true
1451 else
1452   warning('Unknown host cpu: ' + host_cpu_family)
1453   glib_memory_barrier_needed = true
1454 endif
1455 glibconfig_conf.set('G_ATOMIC_OP_MEMORY_BARRIER_NEEDED', glib_memory_barrier_needed)
1457 # Note that the atomic ops are only available with GCC on x86 when
1458 # using -march=i486 or higher.  If we detect that the atomic ops are
1459 # not available but would be available given the right flags, we want
1460 # to abort and advise the user to fix their CFLAGS.  It's better to do
1461 # that then to silently fall back on emulated atomic ops just because
1462 # the user had the wrong build environment.
1463 atomictest = '''void func() {
1464   volatile int atomic = 2;
1465   __sync_bool_compare_and_swap (&atomic, 2, 3);
1468 if cc.compiles(atomictest)
1469   glibconfig_conf.set('G_ATOMIC_LOCK_FREE', true)
1470 else
1471   if host_machine.cpu_family() == 'x86' and cc.compiles(atomictest, args : '-march=i486')
1472     error('GLib must be built with -march=i486 or later.')
1473   endif
1474   glibconfig_conf.set('G_ATOMIC_LOCK_FREE', false)
1475 endif
1477 # === Threads ===
1479 # Let meson figure out all this business and whether -pthread or whatnot is needed
1480 # FIXME: probably needs more tweaking in meson for things like -D_REENTRANT etc.
1481 thread_dep = dependency('threads')
1483 # Determination of thread implementation
1484 if host_system == 'windows'
1485   glibconfig_conf.set('g_threads_impl_def', 'WIN32')
1486   glib_conf.set('THREADS_WIN32', 1)
1487 else
1488   pthread_prefix = '''
1489       #ifndef _GNU_SOURCE
1490       # define _GNU_SOURCE
1491       #endif
1492       #include <pthread.h>'''
1493   glibconfig_conf.set('g_threads_impl_def', 'POSIX')
1494   glib_conf.set('THREADS_POSIX', 1)
1495   if cc.has_header_symbol('pthread.h', 'pthread_attr_setstacksize')
1496     glib_conf.set('HAVE_PTHREAD_ATTR_SETSTACKSIZE', 1)
1497   endif
1498   if cc.has_header_symbol('pthread.h', 'pthread_condattr_setclock')
1499     glib_conf.set('HAVE_PTHREAD_CONDATTR_SETCLOCK', 1)
1500   endif
1501   if cc.has_header_symbol('pthread.h', 'pthread_cond_timedwait_relative_np')
1502     glib_conf.set('HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP', 1)
1503   endif
1504   if cc.has_header_symbol('pthread.h', 'pthread_getname_np', prefix : pthread_prefix)
1505     glib_conf.set('HAVE_PTHREAD_GETNAME_NP', 1)
1506   endif
1507   # Assume that pthread_setname_np is available in some form; same as configure
1508   if cc.links(pthread_prefix + '''
1509               int main() {
1510                 pthread_setname_np("example");
1511               }''',
1512               name : 'pthread_setname_np(const char*)',
1513               dependencies : thread_dep)
1514     # macOS and iOS
1515     glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID', 1)
1516   elif cc.links(pthread_prefix + '''
1517                 int main() {
1518                   pthread_setname_np(pthread_self(), "example");
1519                 }''',
1520                 name : 'pthread_setname_np(pthread_t, const char*)',
1521                 dependencies : thread_dep)
1522     # Linux, Solaris, etc.
1523     glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITH_TID', 1)
1524   endif
1525 endif
1527 # FIXME: we should make it print the result and always return 0, so that
1528 # the output in meson shows up as green
1529 stack_grows_check_prog = '''
1530   volatile int *a = 0, *b = 0;
1531   void f (int i) {
1532     volatile int x = 5;
1533     if (i == 0)
1534       b = &x;
1535     else
1536       f (i - 1);
1537   }
1538   int main () {
1539     volatile int y = 7;
1540     a = &y;
1541     f (100);
1542     return b > a ? 0 : 1;
1543   }'''
1545 if cc_can_run
1546   rres = cc.run(stack_grows_check_prog, name : 'stack grows check')
1547   growing_stack = rres.returncode() == 0
1548 else
1549   growing_stack = meson.get_cross_property('growing_stack', false)
1550 endif
1552 glibconfig_conf.set('G_HAVE_GROWING_STACK', growing_stack)
1554 # Tests for iconv
1556 # USE_LIBICONV_GNU: Using GNU libiconv
1557 # USE_LIBICONV_NATIVE: Using a native impl of iconv in a separate library
1559 # We should never use the MinGW C library's iconv. On Windows we use the
1560 # GNU implementation that ships with MinGW.
1562 # On Windows, just always use the built-in implementation
1563 if host_system == 'windows'
1564   libiconv = []
1565   glib_conf.set('USE_LIBICONV_NATIVE', true)
1566 else
1567   found_iconv = false
1568   iconv_opt = get_option('iconv')
1569   if iconv_opt == 'libc'
1570     if cc.has_function('iconv_open')
1571       libiconv = []
1572       found_iconv = true
1573     endif
1574   elif iconv_opt == 'gnu'
1575     if cc.has_header_symbol('iconv.h', 'libiconv_open')
1576       glib_conf.set('USE_LIBICONV_GNU', true)
1577       libiconv = [cc.find_library('iconv')]
1578       found_iconv = true
1579     endif
1580   elif iconv_opt == 'native'
1581     if cc.has_header_symbol('iconv.h', 'iconv_open')
1582       glib_conf.set('USE_LIBICONV_NATIVE', true)
1583       libiconv = [cc.find_library('iconv')]
1584       found_iconv = true
1585     endif
1586   endif
1588   if not found_iconv
1589     error('No iconv() implementation found in C library or libiconv')
1590   endif
1592 endif
1594 if get_option('internal_pcre')
1595   pcre = []
1596   use_system_pcre = false
1597 else
1598   pcre = dependency('libpcre', required : false) # Should check for Unicode support, too. FIXME
1599   if not pcre.found()
1600     if cc.get_id() == 'msvc'
1601     # MSVC: Search for the PCRE library by the configuration, which corresponds
1602     # to the output of CMake builds of PCRE.  Note that debugoptimized
1603     # is really a Release build with .PDB files.
1604       if buildtype == 'debug'
1605         pcre = cc.find_library('pcred', required : false)
1606       else
1607         pcre = cc.find_library('pcre', required : false)
1608       endif
1609     endif
1610   endif
1611   use_system_pcre = pcre.found()
1612 endif
1613 glib_conf.set('USE_SYSTEM_PCRE', use_system_pcre)
1615 use_pcre_static_flag = false
1617 if host_system == 'windows'
1618   if not use_system_pcre
1619     use_pcre_static_flag = true
1620   else
1621     pcre_static = cc.links('''#define PCRE_STATIC
1622                               #include <pcre.h>
1623                               int main() {
1624                                 void *p = NULL;
1625                                 pcre_free(p);
1626                                 return 0;
1627                               }''',
1628                            dependencies: pcre,
1629                            name : 'Windows system PCRE is a static build')
1630     if pcre_static
1631       use_pcre_static_flag = true
1632     endif
1633   endif
1634 endif
1636 libm = cc.find_library('m', required : false)
1637 libffi_dep = dependency('libffi', version : '>= 3.0.0', fallback : ['libffi', 'ffi_dep'])
1638 zlib_libname = '-lz'
1639 if cc.get_id() != 'msvc'
1640   libz_dep = dependency('zlib', fallback : ['zlib', 'zlib_dep'])
1641 else
1642   # MSVC: Don't use the bundled ZLib sources until we are sure that we can't
1643   # find the ZLib .lib
1644   libz_dep = dependency('zlib', required : false)
1646   # MSVC: Search for the ZLib .lib, which corresponds to the results of
1647   # of using ZLib's win32/makefile.msc.
1648   if not libz_dep.found()
1649     libz_dep = cc.find_library('zlib1', required : false)
1650     if libz_dep.found()
1651       zlib_libname = '-lzlib1'
1652     else
1653       libz_dep = cc.find_library('zlib', required : false)
1654       if libz_dep.found()
1655         zlib_libname = '-lzlib'
1656       else
1657         libz_dep = subproject('zlib').get_variable('zlib_dep')
1658       endif
1659     endif
1660   endif
1661 endif
1663 # Only used on non-glibc targets
1664 libintl = cc.find_library('intl', required : false)
1665 if host_system == 'windows' and not libintl.found()
1666   # Used only when the gettext library is not available (MSVC, not MinGW)
1667   libintl = subproject('proxy-libintl').get_variable('intl_dep')
1668   glib_conf.set('HAVE_DCGETTEXT', 1)
1669 else
1670   glib_conf.set('HAVE_DCGETTEXT', cc.has_header_symbol('libintl.h', 'dcgettext'))
1671 endif
1672 # We require gettext to always be present
1673 glib_conf.set('HAVE_GETTEXT', 1)
1674 glib_conf.set_quoted('GLIB_LOCALE_DIR', join_paths(glib_datadir, 'locale'))
1675 # xgettext is optional (on Windows for instance)
1676 xgettext = find_program('xgettext', required : false)
1678 # libmount is only used by gio, but we need to fetch the libs to generate the
1679 # pkg-config file below
1680 libmount_dep = []
1681 if host_system == 'linux' and get_option('libmount')
1682   libmount_dep = [dependency('mount', version : '>=2.23', required : true)]
1683 endif
1685 if host_system == 'windows'
1686   winsock2 = cc.find_library('ws2_32')
1687 endif
1689 selinux_dep = []
1690 if host_system == 'linux' and get_option('selinux')
1691   selinux_dep = [dependency('libselinux')]
1692   glib_conf.set('SELINUX_LIBS', '-lselinux')
1693   glib_conf.set('HAVE_SELINUX', 1)
1694 endif
1696 xattr_dep = []
1697 if host_system != 'windows' and get_option('xattr')
1698   # either glibc or libattr can provide xattr support
1699   # for both of them, we check for getxattr being in
1700   # the library and a valid xattr header.
1702   # try glibc
1703   if cc.has_function('getxattr') and cc.has_header('sys/xattr.h')
1704     glib_conf.set('HAVE_SYS_XATTR_H', 1)
1705     glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format('HAVE_SYS_XATTR_H')
1706   #failure. try libattr
1707   elif cc.has_header_symbol('attr/xattr.h', 'getxattr')
1708     glib_conf.set('HAVE_ATTR_XATTR_H', 1)
1709     glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format('HAVE_ATTR_XATTR_H')
1710     xattr_dep = [cc.find_library('xattr')]
1711   else
1712     error('No getxattr implementation found in C library or libxattr')
1713   endif
1715   glib_conf.set('HAVE_XATTR', 1)
1716   if cc.compiles(glib_conf_prefix + '''
1717                  #include <stdio.h>
1718                  #ifdef HAVE_SYS_TYPES_H
1719                  #include <sys/types.h>
1720                  #endif
1721                  #ifdef HAVE_SYS_XATTR_H
1722                  #include <sys/xattr.h>
1723                  #elif HAVE_ATTR_XATTR_H
1724                  #include <attr/xattr.h>
1725                  #endif
1727                  int main (void) {
1728                    ssize_t len = getxattr("", "", NULL, 0, 0, XATTR_NOFOLLOW);
1729                  }''',
1730                  name : 'XATTR_NOFOLLOW')
1731     glib_conf.set('HAVE_XATTR_NOFOLLOW', 1)
1732   endif
1733 endif
1735 python = import('python3').find_python()
1737 # Determine which user environment-dependent files that we want to install
1738 have_bash = find_program('bash', required : false).found() # For completion scripts
1739 have_m4 = find_program('m4', required : false).found() # For m4 macros
1740 have_sh = find_program('sh', required : false).found() # For glib-gettextize
1742 # FIXME: defines in config.h that are not actually used anywhere
1743 # (we add them for now to minimise the diff)
1744 glib_conf.set('HAVE_DLFCN_H', 1)
1745 glib_conf.set('__EXTENSIONS__', 1)
1746 glib_conf.set('STDC_HEADERS', 1)
1747 # THREADS_NONE
1748 glib_conf.set('SIZEOF___INT64', 8)
1750 # Various substs needed for our pkg-config files
1751 # FIXME: Derive these from the dependency() objects (Meson support needed)
1752 glib_conf.set('ZLIB_LIBS', zlib_libname)
1753 glib_conf.set('LIBFFI_LIBS', '-lffi')
1754 if libintl.found()
1755   glib_conf.set('INTLLIBS', '-lintl')
1756 endif
1757 if libiconv.length() != 0
1758   glib_conf.set('ICONV_LIBS', '-liconv')
1759 endif
1760 if use_system_pcre
1761   glib_conf.set('PCRE_LIBS', '-lpcre')
1762 endif
1763 if libmount_dep.length() != 0
1764   glib_conf.set('LIBMOUNT_LIBS', '-lmount')
1765   glib_conf.set('HAVE_LIBMOUNT', 1)
1766 endif
1767 glib_conf.set('GIO_MODULE_DIR', glib_giomodulesdir)
1768 # FIXME: Missing:
1769 # @COCOA_LIBS@ @CARBON_LIBS@ @G_LIBS_EXTRA@ @GLIB_EXTRA_CFLAGS@
1770 # @G_MODULE_LDFLAGS@
1772 # Tracing: dtrace
1773 want_dtrace = get_option('dtrace')
1774 enable_dtrace = false
1776 # Since dtrace support is opt-in we just error out if it was requested but
1777 # is not available. We don't bother with autodetection yet.
1778 if want_dtrace
1779   if glib_have_carbon
1780     error('GLib dtrace support not yet compatible with macOS dtrace')
1781   endif
1782   dtrace = find_program('dtrace', required : true) # error out if not found
1783   if not cc.has_header('sys/sdt.h')
1784     error('dtrace support needs sys/sdt.h header')
1785   endif
1786   # FIXME: autotools build also passes -fPIC -DPIC but is it needed in this case?
1787   dtrace_obj_gen = generator(dtrace,
1788     output : '@BASENAME@.o',
1789     arguments : ['-G', '-s', '@INPUT@', '-o', '@OUTPUT@'])
1790   # FIXME: $(SED) -e "s,define STAP_HAS_SEMAPHORES 1,undef STAP_HAS_SEMAPHORES,"
1791   #               -e "s,define _SDT_HAS_SEMAPHORES 1,undef _SDT_HAS_SEMAPHORES,"
1792   dtrace_hdr_gen = generator(dtrace,
1793     output : '@BASENAME@.h',
1794     arguments : ['-h', '-s', '@INPUT@', '-o', '@OUTPUT@'])
1795   glib_conf.set('HAVE_DTRACE', 1)
1796   enable_dtrace = true
1797 endif
1799 # systemtap
1800 want_systemtap = get_option('systemtap')
1801 enable_systemtap = false
1803 if want_systemtap and enable_dtrace
1804   tapset_install_dir = get_option('tapset_install_dir')
1805   if tapset_install_dir == ''
1806     tapset_install_dir = join_paths(get_option('datadir'), 'systemtap/tapset', host_machine.cpu_family())
1807   endif
1808   stp_cdata = configuration_data()
1809   stp_cdata.set('ABS_GLIB_RUNTIME_LIBDIR', glib_libdir)
1810   stp_cdata.set('LT_CURRENT', minor_version * 100)
1811   stp_cdata.set('LT_REVISION', micro_version)
1812   enable_systemtap = true
1813 endif
1816 pkg = import('pkgconfig')
1817 windows = import('windows')
1818 subdir('glib')
1819 subdir('gobject')
1820 subdir('gthread')
1821 subdir('gmodule')
1822 subdir('gio')
1823 if xgettext.found()
1824   subdir('po')
1825 endif
1826 subdir('tests')
1828 # NOTE: We skip glib-zip.in because the filenames it assumes don't match ours
1830 # Install glib-gettextize executable, if a UNIX-style shell is found
1831 if have_sh
1832   configure_file(input : 'glib-gettextize.in',
1833     install : true,
1834     install_dir : 'bin',
1835     output : 'glib-gettextize',
1836     configuration : glib_conf)
1837 endif
1839 if have_m4
1840   # Install m4 macros that other projects use
1841   install_data('m4macros/glib-2.0.m4', 'm4macros/glib-gettext.m4', 'm4macros/gsettings.m4',
1842     install_dir : join_paths(get_option('datadir'), 'aclocal'))
1843 endif
1845 if host_system != 'windows'
1846   # Install Valgrind suppression file (except on Windows,
1847   # as Valgrind is currently not supported on Windows)
1848   install_data('glib.supp',
1849     install_dir : join_paths(get_option('datadir'), 'glib-2.0', 'valgrind'))
1850 endif
1852 configure_file(input : 'config.h.meson',
1853   output : 'config.h',
1854   configuration : glib_conf)
1856 if host_system == 'windows'
1857   install_headers([ 'msvc_recommended_pragmas.h' ], subdir : 'glib-2.0')
1858 endif
1860 if get_option('man')
1861   xsltproc = find_program('xsltproc', required : true)
1862   xsltproc_command = [
1863     xsltproc,
1864     '--nonet',
1865     '--stringparam', 'man.output.quietly', '1',
1866     '--stringparam', 'funcsynopsis.style', 'ansi',
1867     '--stringparam', 'man.th.extra1.suppress', '1',
1868     '--stringparam', 'man.authors.section.enabled', '0',
1869     '--stringparam', 'man.copyright.section.enabled', '0',
1870     '-o', '@OUTPUT@',
1871     'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl',
1872     '@INPUT@',
1873   ]
1874   man1_dir = get_option('mandir') + '/man1'
1875 endif
1877 gnome = import('gnome')
1878 subdir('docs/reference/glib')
1879 subdir('docs/reference/gobject')
1880 subdir('docs/reference/gio')