[glib/meson-for-merge] meson: Fix glib, add gobject, gio, gthread, gmodule, etc



commit 213957970ee4e58e37ee2c81766284af34dddcb9
Author: Tim-Philipp Müller <tim centricular com>
Date:   Mon Mar 7 11:13:24 2016 +0000

    meson: Fix glib, add gobject, gio, gthread, gmodule, etc
    
    Several small fixes to the build files.
    
    Lots of tests have also been added, and glib tests pass now.

 config.h.meson                        |  786 ++++++++++++++++++++++
 gio/build_mkenum.py                   |   23 +
 gio/inotify/meson.build               |   13 +
 gio/kqueue/meson.build                |   15 +
 gio/meson.build                       |  802 ++++++++++++++++++++++
 gio/tests/meson.build                 |  219 ++++++
 gio/tests/modules/meson.build         |   13 +
 gio/win32/meson.build                 |   13 +
 gio/xdgmime/meson.build               |   15 +
 glib/glibconfig.h.in                  |   83 +--
 glib/libcharset/meson.build           |    4 +-
 glib/meson.build                      |  108 +++-
 glib/tests/Makefile.am                |    1 +
 glib/tests/meson.build                |  165 +++++
 gmodule/meson.build                   |   90 +++
 gobject/meson.build                   |   65 ++
 gobject/tests/gobject_test_marshal.py |   17 +
 gobject/tests/meson.build             |   69 ++
 gthread/meson.build                   |   11 +
 meson.build                           | 1197 ++++++++++++++++++++++++++-------
 20 files changed, 3405 insertions(+), 304 deletions(-)
---
diff --git a/config.h.meson b/config.h.meson
new file mode 100644
index 0000000..eeb2dea
--- /dev/null
+++ b/config.h.meson
@@ -0,0 +1,786 @@
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define if building universal (internal helper macro) */
+#mesondefine AC_APPLE_UNIVERSAL_BUILD
+
+/* The normal alignment of `guint32', in bytes. */
+#mesondefine ALIGNOF_GUINT32
+
+/* The normal alignment of `guint64', in bytes. */
+#mesondefine ALIGNOF_GUINT64
+
+/* The normal alignment of `unsigned long', in bytes. */
+#mesondefine ALIGNOF_UNSIGNED_LONG
+
+/* poll doesn't work on devices */
+#mesondefine BROKEN_POLL
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+   systems. This function is required for `alloca.c' support on those systems.
+   */
+#mesondefine CRAY_STACKSEG_END
+
+/* Define to 1 if using `alloca.c'. */
+#mesondefine C_ALLOCA
+
+/* Whether to disable memory pools */
+#mesondefine DISABLE_MEM_POOLS
+
+/* Whether to enable GC friendliness by default */
+#mesondefine ENABLE_GC_FRIENDLY_DEFAULT
+
+/* always defined to indicate that i18n is enabled */
+#mesondefine ENABLE_NLS
+
+/* Define the gettext package to be used */
+#mesondefine GETTEXT_PACKAGE
+
+/* Define to the GLIB binary age */
+#mesondefine GLIB_BINARY_AGE
+
+/* Define to the GLIB interface age */
+#mesondefine GLIB_INTERFACE_AGE
+
+/* Define the location where the catalogs will be installed */
+#mesondefine GLIB_LOCALE_DIR
+
+/* Define to the GLIB major version */
+#mesondefine GLIB_MAJOR_VERSION
+
+/* Define to the GLIB micro version */
+#mesondefine GLIB_MICRO_VERSION
+
+/* Define to the GLIB minor version */
+#mesondefine GLIB_MINOR_VERSION
+
+/* A 'va_copy' style function */
+#mesondefine G_VA_COPY
+
+/* 'va_lists' cannot be copies as values */
+#mesondefine G_VA_COPY_AS_ARRAY
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#mesondefine HAVE_ALLOCA
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+   */
+#mesondefine HAVE_ALLOCA_H
+
+/* Define to 1 if you have the <attr/xattr.h> header file. */
+#mesondefine HAVE_ATTR_XATTR_H
+
+/* Define to 1 if you have the `bind_textdomain_codeset' function. */
+#mesondefine HAVE_BIND_TEXTDOMAIN_CODESET
+
+/* Define if you have a version of the snprintf function with semantics as
+   specified by the ISO C99 standard. */
+#mesondefine HAVE_C99_SNPRINTF
+
+/* Define if you have a version of the vsnprintf function with semantics as
+   specified by the ISO C99 standard. */
+#mesondefine HAVE_C99_VSNPRINTF
+
+/* define to 1 if Carbon is available */
+#mesondefine HAVE_CARBON
+
+/* Define to 1 if you have the `clock_gettime' function. */
+#mesondefine HAVE_CLOCK_GETTIME
+
+/* define to 1 if Cocoa is available */
+#mesondefine HAVE_COCOA
+
+/* Have nl_langinfo (CODESET) */
+#mesondefine HAVE_CODESET
+
+/* Define to 1 if you have the <crt_externs.h> header file. */
+#mesondefine HAVE_CRT_EXTERNS_H
+
+/* Define if dbus-1 is available */
+#mesondefine HAVE_DBUS1
+
+/* Define to 1 if you have the `dcgettext' function. */
+#mesondefine HAVE_DCGETTEXT
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+   */
+#mesondefine HAVE_DIRENT_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#mesondefine HAVE_DLFCN_H
+
+/* Define to 1 if using dtrace probes. */
+#mesondefine HAVE_DTRACE
+
+/* Define to 1 if you have the `endmntent' function. */
+#mesondefine HAVE_ENDMNTENT
+
+/* Define to 1 if you have the `endservent' function. */
+#mesondefine HAVE_ENDSERVENT
+
+/* we have the eventfd(2) system call */
+#mesondefine HAVE_EVENTFD
+
+/* Define to 1 if you have the `fallocate' function. */
+#mesondefine HAVE_FALLOCATE
+
+/* Define if we have FAM */
+#mesondefine HAVE_FAM
+
+/* Define to 1 if you have the <fam.h> header file. */
+#mesondefine HAVE_FAM_H
+
+/* Define if we have FAMNoExists in fam */
+#mesondefine HAVE_FAM_NO_EXISTS
+
+/* Define to 1 if you have the `fchmod' function. */
+#mesondefine HAVE_FCHMOD
+
+/* Define to 1 if you have the `fchown' function. */
+#mesondefine HAVE_FCHOWN
+
+/* Define to 1 if you have the `fdwalk' function. */
+#mesondefine HAVE_FDWALK
+
+/* Define to 1 if you have the <fstab.h> header file. */
+#mesondefine HAVE_FSTAB_H
+
+/* Define to 1 if you have the `fsync' function. */
+#mesondefine HAVE_FSYNC
+
+/* we have the futex(2) system call */
+#mesondefine HAVE_FUTEX
+
+/* Define to 1 if you have the `getc_unlocked' function. */
+#mesondefine HAVE_GETC_UNLOCKED
+
+/* Define to 1 if you have the `getfsstat' function. */
+#mesondefine HAVE_GETFSSTAT
+
+/* Define to 1 if you have the `getgrgid_r' function. */
+#mesondefine HAVE_GETGRGID_R
+
+/* Define to 1 if you have the `getmntent_r' function. */
+#mesondefine HAVE_GETMNTENT_R
+
+/* Define to 1 if you have the `getprotobyname_r' function. */
+#mesondefine HAVE_GETPROTOBYNAME_R
+
+/* Define to 1 if you have the `getpwuid_r' function. */
+#mesondefine HAVE_GETPWUID_R
+
+/* Define to 1 if you have the `getresuid' function. */
+#mesondefine HAVE_GETRESUID
+
+/* Define if the GNU gettext() function is already present or preinstalled. */
+#mesondefine HAVE_GETTEXT
+
+/* Define to 1 if you have the `getvfsstat' function. */
+#mesondefine HAVE_GETVFSSTAT
+
+/* Define to 1 if you have the `gmtime_r' function. */
+#mesondefine HAVE_GMTIME_R
+
+/* define to use system printf */
+#mesondefine HAVE_GOOD_PRINTF
+
+/* Define to 1 if you have the `hasmntopt' function. */
+#mesondefine HAVE_HASMNTOPT
+
+/* Define to 1 if you have the `if_indextoname' function. */
+#mesondefine HAVE_IF_INDEXTONAME
+
+/* Define to 1 if you have the `if_nametoindex' function. */
+#mesondefine HAVE_IF_NAMETOINDEX
+
+/* Define to 1 if you have the `inotify_init1' function. */
+#mesondefine HAVE_INOTIFY_INIT1
+
+/* define to support printing 64-bit integers with format I64 */
+#mesondefine HAVE_INT64_AND_I64
+
+/* Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>. */
+#mesondefine HAVE_INTMAX_T
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#mesondefine HAVE_INTTYPES_H
+
+/* Define if <inttypes.h> exists, doesn't clash with <sys/types.h>, and
+   declares uintmax_t. */
+#mesondefine HAVE_INTTYPES_H_WITH_UINTMAX
+
+/* Define if we have struct ip_mreqn */
+#mesondefine HAVE_IP_MREQN
+
+/* Define to 1 if you have the `issetugid' function. */
+#mesondefine HAVE_ISSETUGID
+
+/* Define to 1 if you have the `kevent' function. */
+#mesondefine HAVE_KEVENT
+
+/* Define to 1 if you have the `kqueue' function. */
+#mesondefine HAVE_KQUEUE
+
+/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+#mesondefine HAVE_LANGINFO_CODESET
+
+/* Have nl_langinfo (_NL_CTYPE_OUTDIGITn_MB) */
+#mesondefine HAVE_LANGINFO_OUTDIGIT
+
+/* Have nl_langinfo (PM_STR) */
+#mesondefine HAVE_LANGINFO_TIME
+
+/* Define to 1 if you have the `lchmod' function. */
+#mesondefine HAVE_LCHMOD
+
+/* Define to 1 if you have the `lchown' function. */
+#mesondefine HAVE_LCHOWN
+
+/* Define if your <locale.h> file defines LC_MESSAGES. */
+#mesondefine HAVE_LC_MESSAGES
+
+/* Define if you have the __libc_enable_secure variable (GNU libc, eglibc) */
+#mesondefine HAVE_LIBC_ENABLE_SECURE
+
+/* Define if libelf is available */
+#mesondefine HAVE_LIBELF
+
+/* Define to 1 if you have the <linux/magic.h> header file. */
+#mesondefine HAVE_LINUX_MAGIC_H
+
+/* Define to 1 if you have the <locale.h> header file. */
+#mesondefine HAVE_LOCALE_H
+
+/* Define to 1 if you have the `localtime_r' function. */
+#mesondefine HAVE_LOCALTIME_R
+
+/* Define if you have the 'long double' type. */
+#mesondefine HAVE_LONG_DOUBLE
+
+/* Define if you have the 'long long' type. */
+#mesondefine HAVE_LONG_LONG
+
+/* define if system printf can print long long */
+#mesondefine HAVE_LONG_LONG_FORMAT
+
+/* Define to 1 if you have the `lstat' function. */
+#mesondefine HAVE_LSTAT
+
+/* Define to 1 if you have the <mach/mach_time.h> header file. */
+#mesondefine HAVE_MACH_MACH_TIME_H
+
+/* Define to 1 if you have the <malloc.h> header file. */
+#mesondefine HAVE_MALLOC_H
+
+/* Define to 1 if you have the `mbrtowc' function. */
+#mesondefine HAVE_MBRTOWC
+
+/* Define to 1 if you have the `memalign' function. */
+#mesondefine HAVE_MEMALIGN
+
+/* Define to 1 if you have the `memmem' function. */
+#mesondefine HAVE_MEMMEM
+
+/* Define to 1 if you have the <memory.h> header file. */
+#mesondefine HAVE_MEMORY_H
+
+/* Define to 1 if you have the `mmap' function. */
+#mesondefine HAVE_MMAP
+
+/* Define to 1 if you have the <mntent.h> header file. */
+#mesondefine HAVE_MNTENT_H
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+#mesondefine HAVE_NDIR_H
+
+/* We have AF_NETLINK sockets */
+#mesondefine HAVE_NETLINK
+
+/* Define to 1 if you have the `newlocale' function. */
+#mesondefine HAVE_NEWLOCALE
+
+/* open option O_DIRECTORY */
+#mesondefine HAVE_OPEN_O_DIRECTORY
+
+/* Define to 1 if you have the `pipe2' function. */
+#mesondefine HAVE_PIPE2
+
+/* Define to 1 if you have the `poll' function. */
+#mesondefine HAVE_POLL
+
+/* Define to 1 if you have the `posix_memalign' function. */
+#mesondefine HAVE_POSIX_MEMALIGN
+
+/* Define to 1 if you have the `prlimit' function. */
+#mesondefine HAVE_PRLIMIT
+
+/* Have function pthread_attr_setstacksize */
+#mesondefine HAVE_PTHREAD_ATTR_SETSTACKSIZE
+
+/* Have function pthread_condattr_setclock */
+#mesondefine HAVE_PTHREAD_CONDATTR_SETCLOCK
+
+/* Define to 1 if the system has the type `ptrdiff_t'. */
+#mesondefine HAVE_PTRDIFF_T
+
+/* Define to 1 if you have the `readlink' function. */
+#mesondefine HAVE_READLINK
+
+/* Define to 1 if you have the `recvmmsg' function. */
+#mesondefine HAVE_RECVMMSG
+
+/* Define to 1 if you have the 'res_init' function. */
+#mesondefine HAVE_RES_INIT
+
+/* Define to 1 if you have the <sched.h> header file. */
+#mesondefine HAVE_SCHED_H
+
+/* Define to 1 if libselinux is available */
+#mesondefine HAVE_SELINUX
+
+/* Define to 1 if you have the <selinux/selinux.h> header file. */
+#mesondefine HAVE_SELINUX_SELINUX_H
+
+/* Define to 1 if you have the `sendmmsg' function. */
+#mesondefine HAVE_SENDMMSG
+
+/* Define to 1 if you have the `setenv' function. */
+#mesondefine HAVE_SETENV
+
+/* Define to 1 if you have the `setmntent' function. */
+#mesondefine HAVE_SETMNTENT
+
+/* Define if you have the 'sig_atomic_t' type. */
+#mesondefine HAVE_SIG_ATOMIC_T
+
+/* Define to 1 if you have the `snprintf' function. */
+#mesondefine HAVE_SNPRINTF
+
+/* Define to 1 if you have the `splice' function. */
+#mesondefine HAVE_SPLICE
+
+/* Define to 1 if you have the `statfs' function. */
+#mesondefine HAVE_STATFS
+
+/* Define to 1 if you have the `statvfs' function. */
+#mesondefine HAVE_STATVFS
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#mesondefine HAVE_STDDEF_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#mesondefine HAVE_STDINT_H
+
+/* Define if <stdint.h> exists, doesn't clash with <sys/types.h>, and declares
+   uintmax_t. */
+#mesondefine HAVE_STDINT_H_WITH_UINTMAX
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#mesondefine HAVE_STDLIB_H
+
+/* Define to 1 if you have the `stpcpy' function. */
+#mesondefine HAVE_STPCPY
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#mesondefine HAVE_STRCASECMP
+
+/* Define to 1 if you have the `strerror_r' function. */
+#mesondefine HAVE_STRERROR_R
+
+/* Define to 1 if you have the <strings.h> header file. */
+#mesondefine HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#mesondefine HAVE_STRING_H
+
+/* Have functions strlcpy and strlcat */
+#mesondefine HAVE_STRLCPY
+
+/* Define to 1 if you have the `strncasecmp' function. */
+#mesondefine HAVE_STRNCASECMP
+
+/* Define to 1 if you have the `strnlen' function. */
+#mesondefine HAVE_STRNLEN
+
+/* Define to 1 if you have the `strsignal' function. */
+#mesondefine HAVE_STRSIGNAL
+
+/* Define to 1 if you have the `strtod_l' function. */
+#mesondefine HAVE_STRTOD_L
+
+/* Define to 1 if you have the `strtoll_l' function. */
+#mesondefine HAVE_STRTOLL_L
+
+/* Define to 1 if you have the `strtoull_l' function. */
+#mesondefine HAVE_STRTOULL_L
+
+/* Define to 1 if `d_type' is a member of `struct dirent'. */
+#mesondefine HAVE_STRUCT_DIRENT_D_TYPE
+
+/* Define to 1 if `f_bavail' is a member of `struct statfs'. */
+#mesondefine HAVE_STRUCT_STATFS_F_BAVAIL
+
+/* Define to 1 if `f_fstypename' is a member of `struct statfs'. */
+#mesondefine HAVE_STRUCT_STATFS_F_FSTYPENAME
+
+/* Define to 1 if `f_basetype' is a member of `struct statvfs'. */
+#mesondefine HAVE_STRUCT_STATVFS_F_BASETYPE
+
+/* Define to 1 if `f_fstypename' is a member of `struct statvfs'. */
+#mesondefine HAVE_STRUCT_STATVFS_F_FSTYPENAME
+
+/* Define to 1 if `st_atimensec' is a member of `struct stat'. */
+#mesondefine HAVE_STRUCT_STAT_ST_ATIMENSEC
+
+/* Define to 1 if `st_atim.tv_nsec' is a member of `struct stat'. */
+#mesondefine HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
+
+/* Define to 1 if `st_birthtim' is a member of `struct stat'. */
+#mesondefine HAVE_STRUCT_STAT_ST_BIRTHTIM
+
+/* Define to 1 if `st_birthtime' is a member of `struct stat'. */
+#mesondefine HAVE_STRUCT_STAT_ST_BIRTHTIME
+
+/* Define to 1 if `st_birthtimensec' is a member of `struct stat'. */
+#mesondefine HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
+
+/* Define to 1 if `st_birthtim.tv_nsec' is a member of `struct stat'. */
+#mesondefine HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC
+
+/* Define to 1 if `st_blksize' is a member of `struct stat'. */
+#mesondefine HAVE_STRUCT_STAT_ST_BLKSIZE
+
+/* Define to 1 if `st_blocks' is a member of `struct stat'. */
+#mesondefine HAVE_STRUCT_STAT_ST_BLOCKS
+
+/* Define to 1 if `st_ctimensec' is a member of `struct stat'. */
+#mesondefine HAVE_STRUCT_STAT_ST_CTIMENSEC
+
+/* Define to 1 if `st_ctim.tv_nsec' is a member of `struct stat'. */
+#mesondefine HAVE_STRUCT_STAT_ST_CTIM_TV_NSEC
+
+/* Define to 1 if `st_mtimensec' is a member of `struct stat'. */
+#mesondefine HAVE_STRUCT_STAT_ST_MTIMENSEC
+
+/* Define to 1 if `st_mtim.tv_nsec' is a member of `struct stat'. */
+#mesondefine HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
+
+/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */
+#mesondefine HAVE_STRUCT_TM_TM_GMTOFF
+
+/* Define to 1 if `__tm_gmtoff' is a member of `struct tm'. */
+#mesondefine HAVE_STRUCT_TM___TM_GMTOFF
+
+/* Define to 1 if you have the `symlink' function. */
+#mesondefine HAVE_SYMLINK
+
+/* Define to 1 if you have the `sysctlbyname' function. */
+#mesondefine HAVE_SYSCTLBYNAME
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+   */
+#mesondefine HAVE_SYS_DIR_H
+
+/* Define to 1 if you have the <sys/event.h> header file. */
+#mesondefine HAVE_SYS_EVENT_H
+
+/* Define to 1 if you have the <sys/filio.h> header file. */
+#mesondefine HAVE_SYS_FILIO_H
+
+/* Define to 1 if you have the <sys/inotify.h> header file. */
+#mesondefine HAVE_SYS_INOTIFY_H
+
+/* Define to 1 if you have the <sys/mkdev.h> header file. */
+#mesondefine HAVE_SYS_MKDEV_H
+
+/* Define to 1 if you have the <sys/mntctl.h> header file. */
+#mesondefine HAVE_SYS_MNTCTL_H
+
+/* Define to 1 if you have the <sys/mnttab.h> header file. */
+#mesondefine HAVE_SYS_MNTTAB_H
+
+/* Define to 1 if you have the <sys/mount.h> header file. */
+#mesondefine HAVE_SYS_MOUNT_H
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+   */
+#mesondefine HAVE_SYS_NDIR_H
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#mesondefine HAVE_SYS_PARAM_H
+
+/* Define to 1 if you have the <sys/poll.h> header file. */
+#mesondefine HAVE_SYS_POLL_H
+
+/* Define to 1 if you have the <sys/prctl.h> header file. */
+#mesondefine HAVE_SYS_PRCTL_H
+
+/* Define to 1 if you have the <sys/resource.h> header file. */
+#mesondefine HAVE_SYS_RESOURCE_H
+
+/* found fd_set in sys/select.h */
+#mesondefine HAVE_SYS_SELECT_H
+
+/* Define to 1 if you have the <sys/statfs.h> header file. */
+#mesondefine HAVE_SYS_STATFS_H
+
+/* Define to 1 if you have the <sys/statvfs.h> header file. */
+#mesondefine HAVE_SYS_STATVFS_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#mesondefine HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/sysctl.h> header file. */
+#mesondefine HAVE_SYS_SYSCTL_H
+
+/* Define to 1 if you have the <sys/times.h> header file. */
+#mesondefine HAVE_SYS_TIMES_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#mesondefine HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#mesondefine HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <sys/uio.h> header file. */
+#mesondefine HAVE_SYS_UIO_H
+
+/* Define to 1 if you have the <sys/vfstab.h> header file. */
+#mesondefine HAVE_SYS_VFSTAB_H
+
+/* Define to 1 if you have the <sys/vfs.h> header file. */
+#mesondefine HAVE_SYS_VFS_H
+
+/* Define to 1 if you have the <sys/vmount.h> header file. */
+#mesondefine HAVE_SYS_VMOUNT_H
+
+/* Define to 1 if you have the <sys/wait.h> header file. */
+#mesondefine HAVE_SYS_WAIT_H
+
+/* Define to 1 if you have the <sys/xattr.h> header file. */
+#mesondefine HAVE_SYS_XATTR_H
+
+/* Define to 1 if you have the `timegm' function. */
+#mesondefine HAVE_TIMEGM
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#mesondefine HAVE_UNISTD_H
+
+/* Define if your printf function family supports positional parameters as
+   specified by Unix98. */
+#mesondefine HAVE_UNIX98_PRINTF
+
+/* Define to 1 if you have the `unsetenv' function. */
+#mesondefine HAVE_UNSETENV
+
+/* Define to 1 if you have the `uselocale' function. */
+#mesondefine HAVE_USELOCALE
+
+/* Define to 1 if you have the `utimes' function. */
+#mesondefine HAVE_UTIMES
+
+/* Define to 1 if you have the `valloc' function. */
+#mesondefine HAVE_VALLOC
+
+/* Define to 1 if you have the <values.h> header file. */
+#mesondefine HAVE_VALUES_H
+
+/* Define to 1 if you have the `vasprintf' function. */
+#mesondefine HAVE_VASPRINTF
+
+/* Define to 1 if you have the `vsnprintf' function. */
+#mesondefine HAVE_VSNPRINTF
+
+/* Define if you have the 'wchar_t' type. */
+#mesondefine HAVE_WCHAR_T
+
+/* Define to 1 if you have the `wcslen' function. */
+#mesondefine HAVE_WCSLEN
+
+/* Define if you have the 'wint_t' type. */
+#mesondefine HAVE_WINT_T
+
+/* Have a working bcopy */
+#mesondefine HAVE_WORKING_BCOPY
+
+/* Define to 1 if xattr is available */
+#mesondefine HAVE_XATTR
+
+/* Define to 1 if xattr API uses XATTR_NOFOLLOW */
+#mesondefine HAVE_XATTR_NOFOLLOW
+
+/* Define to 1 if you have the <xlocale.h> header file. */
+#mesondefine HAVE_XLOCALE_H
+
+/* Define to 1 if you have the `_NSGetEnviron' function. */
+#mesondefine HAVE__NSGETENVIRON
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ""
+
+/* Do we cache iconv descriptors */
+#mesondefine NEED_ICONV_CACHE
+
+/* didn't find fd_set */
+#mesondefine NO_FD_SET
+
+/* Define to the address where bug reports for this package should be sent. */
+#mesondefine PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#mesondefine PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#mesondefine PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#mesondefine PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#mesondefine PACKAGE_URL
+
+/* Define to the version of this package. */
+#mesondefine PACKAGE_VERSION
+
+/* define if posix_memalign() can allocate any size */
+#mesondefine POSIX_MEMALIGN_WITH_COMPLIANT_ALLOCS
+
+/* The size of `char', as computed by sizeof. */
+#mesondefine SIZEOF_CHAR
+
+/* The size of `int', as computed by sizeof. */
+#mesondefine SIZEOF_INT
+
+/* The size of `long', as computed by sizeof. */
+#mesondefine SIZEOF_LONG
+
+/* The size of `long long', as computed by sizeof. */
+#mesondefine SIZEOF_LONG_LONG
+
+/* The size of `short', as computed by sizeof. */
+#mesondefine SIZEOF_SHORT
+
+/* The size of `size_t', as computed by sizeof. */
+#mesondefine SIZEOF_SIZE_T
+
+/* The size of `ssize_t', as computed by sizeof. */
+#mesondefine SIZEOF_SSIZE_T
+
+/* The size of `void *', as computed by sizeof. */
+#mesondefine SIZEOF_VOID_P
+
+/* The size of `__int64', as computed by sizeof. */
+#mesondefine SIZEOF___INT64
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at runtime.
+       STACK_DIRECTION > 0 => grows toward higher addresses
+       STACK_DIRECTION < 0 => grows toward lower addresses
+       STACK_DIRECTION = 0 => direction of growth unknown */
+#mesondefine STACK_DIRECTION
+
+/* Number of arguments to statfs() */
+#mesondefine STATFS_ARGS
+
+/* Define to 1 if you have the ANSI C header files. */
+#mesondefine STDC_HEADERS
+
+/* Use no threads */
+/* #undef THREADS_NONE */
+
+/* Use pthreads */
+#mesondefine THREADS_POSIX
+
+/* Use w32 threads */
+#mesondefine THREADS_WIN32
+
+/* Using GNU libiconv */
+#mesondefine USE_LIBICONV_GNU
+
+/* Using a native implementation of iconv in a separate library */
+#mesondefine USE_LIBICONV_NATIVE
+
+/* Define to use statfs() */
+#mesondefine USE_STATFS
+
+/* Define to use statvfs() */
+#mesondefine USE_STATVFS
+
+/* Enable extensions on AIX 3, Interix.  */
+#ifndef _ALL_SOURCE
+#mesondefine _ALL_SOURCE
+#endif
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+#mesondefine _GNU_SOURCE
+#endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+#mesondefine _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+#mesondefine _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+#mesondefine __EXTENSIONS__
+#endif
+
+/* using the system-supplied PCRE library */
+#mesondefine USE_SYSTEM_PCRE
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+#  undef WORDS_BIGENDIAN
+# endif
+#endif
+
+/* Enable large inode numbers on Mac OS X 10.5.  */
+#ifndef _DARWIN_USE_64_BIT_INODE
+# define _DARWIN_USE_64_BIT_INODE 1
+#endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#mesondefine _FILE_OFFSET_BITS
+
+/* defines how to decorate public symbols while building */
+#mesondefine _GLIB_EXTERN
+
+/* Define for large files, on AIX-style hosts. */
+#mesondefine _LARGE_FILES
+
+/* Target the Windows XP API */
+#mesondefine _WIN32_WINNT
+
+/* Needed to get declarations for msg_control and msg_controllen on Solaris */
+#mesondefine _XOPEN_SOURCE
+
+/* Needed to get declarations for msg_control and msg_controllen on Solaris */
+#mesondefine _XOPEN_SOURCE_EXTENDED
+
+/* Needed to get declarations for msg_control and msg_controllen on Solaris */
+#mesondefine __EXTENSIONS__
+
+/* compiler supports atomic operations */
+#mesondefine __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#mesondefine const
+
+/* Define to long or long long if <inttypes.h> and <stdint.h> don't define. */
+#mesondefine intmax_t
+
+/* Define to empty if the C compiler doesn't support this keyword. */
+#mesondefine signed
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#mesondefine size_t
+
+#mesondefine EXEEXT
diff --git a/gio/build_mkenum.py b/gio/build_mkenum.py
new file mode 100755
index 0000000..c93ee32
--- /dev/null
+++ b/gio/build_mkenum.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+
+# This is in its own file rather than inside meson.build
+# because a) mixing the two is ugly and b) trying to
+# make special characters such as \n go through all
+# backends is a fool's errand.
+
+import sys, os, shutil, subprocess
+
+ofilename = sys.argv[1]
+template_file_dir = sys.argv[2]
+template_file_path = template_file_dir + '/' + ofilename + '.template'
+headers = sys.argv[3:]
+
+arg_array = ['--template', template_file_path ]
+
+# FIXME: should use $top_builddir/gobject/glib-mkenums
+cmd = [shutil.which('perl'), shutil.which('glib-mkenums')]
+pc = subprocess.Popen(cmd + arg_array + headers, stdout=subprocess.PIPE)
+(stdo, _) = pc.communicate()
+if pc.returncode != 0:
+    sys.exit(pc.returncode)
+open(ofilename, 'wb').write(stdo)
diff --git a/gio/inotify/meson.build b/gio/inotify/meson.build
new file mode 100644
index 0000000..cc31656
--- /dev/null
+++ b/gio/inotify/meson.build
@@ -0,0 +1,13 @@
+inotify_sources = [
+  'inotify-kernel.c',
+  'inotify-sub.c',
+  'inotify-path.c',
+  'inotify-missing.c',
+  'inotify-helper.c',
+  'ginotifyfilemonitor.c',
+]
+
+inotify_lib = static_library('inotify',
+  sources : inotify_sources,
+  include_directories : inc_dirs,
+  c_args : [ '-DHAVE_CONFIG_H', '-fPIC', '-DG_DISABLE_DEPRECATED' ] + gio_c_args)
diff --git a/gio/kqueue/meson.build b/gio/kqueue/meson.build
new file mode 100644
index 0000000..7405d68
--- /dev/null
+++ b/gio/kqueue/meson.build
@@ -0,0 +1,15 @@
+kqueue_sources = [
+  'gkqueuefilemonitor.c',
+  'kqueue-helper.c',
+  'kqueue-thread.c',
+  'kqueue-sub.c',
+  'kqueue-missing.c',
+  'kqueue-utils.c',
+  'kqueue-exclusions.c',
+  'dep-list.c',
+]
+
+kqueue_lib = static_library('kqueue',
+  sources : kqueue_sources,
+  include_directories : inc_dirs,
+  c_args : [ '-DHAVE_CONFIG_H', '-fPIC', '-DG_DISABLE_DEPRECATED' ] + gio_c_args)
diff --git a/gio/meson.build b/gio/meson.build
new file mode 100644
index 0000000..4b0aeea
--- /dev/null
+++ b/gio/meson.build
@@ -0,0 +1,802 @@
+gio_c_args = [
+  '-DG_LOG_DOMAIN="GLib-GIO"',
+  '-DGIO_COMPILATION',
+  '-DGIO_MODULE_DIR="@0@/gio/modules"'.format(get_option('libdir')),
+]
+
+# FIXME: subdir('gdbus-2.0/codegen')
+
+gnetworking_h_conf = configuration_data()
+
+gnetworking_h_wspiapi_include = ''
+gnetworking_h_nameser_compat_include = ''
+
+if host_machine.system() == 'windows'
+  # <wspiapi.h> in the Windows SDK and in mingw-w64 has wrappers for
+  # inline workarounds for getaddrinfo, getnameinfo and freeaddrinfo if
+  # they aren't present at run-time (on Windows 2000).
+  gnetworking_h_wspiapi_include = '#include <wspiapi.h>'
+endif
+
+if host_machine.system().contains('android')
+  # Android does not have C_IN in public headers, we define it wherever necessary
+  if not cc.compiles('''#include <sys/types.h>
+                        #include <arpa/nameser.h>
+                        int qclass = C_IN;''',
+                     name : 'C_IN in public headers (no arpa/nameser_compat.h needed)')
+    if cc.compiles('''#include <sys/types.h>
+                      #include <arpa/nameser.h>
+                      #include <arpa/nameser_compat.h>
+                      int qclass = C_IN;''',
+                   name : 'arpa/nameser_compat.h needed for C_IN')
+      gnetworking_h_nameser_compat_include = '#include <arpa/nameser_compat.h>'
+    else
+      error('Could not find required includes for ARPA C_IN')
+    endif
+  endif
+endif
+
+network_libs = [ ]
+network_args = [ ]
+if host_machine.system() != 'windows'
+  # res_query()
+  res_query_test = '''#include <resolv.h>
+                      int main (int argc, char ** argv) {
+                        return res_query("test", 0, 0, (void *)0, 0);
+                      }'''
+  res_query_test_full = '''#include <sys/types.h>
+                           #include <netinet/in.h>
+                           #include <arpa/nameser.h>
+                        ''' + res_query_test
+  if not cc.links(res_query_test_full, name : 'res_query()')
+    if cc.links(res_query_test_full, args : '-lresolv', name : 'res_query() in -lresolv')
+      network_libs += [ find_library('resolv') ]
+      network_args += [ '-lresolv' ]
+    elif cc.links(res_query_test, args : '-lbind', name : 'res_query() in -lbind')
+      network_libs += [ find_library('bind') ]
+      network_args += [ '-lbind' ]
+    else
+      error('Could not find res_query()')
+    endif
+  endif
+
+  # socket()
+  socket_test = '''#include <sys/types.h>
+                   #include <sys/socket.h>
+                   int main (int argc, char ** argv) {
+                     return socket(1, 2, 3);
+                   }'''
+  if not cc.links(socket_test, name : 'socket()')
+    if cc.links(socket_test, args : '-lsocket', name : 'socket() in -lsocket')
+      network_libs += [ find_library('socket') ]
+      network_args += [ '-lsocket' ]
+    else
+      error('Could not find socket()')
+    endif
+  endif
+
+  # res_init()
+  if cc.links('''#include <sys/types.h>
+                 #include <netinet/in.h>
+                 #include <arpa/nameser.h>
+                 #include <resolv.h>
+                 int main (int argc, char ** argv) {
+                   return res_init();
+                 }''', args : network_args, name : 'res_init()')
+    glib_conf.set('HAVE_RES_INIT', 1)
+  endif
+
+  if cc.compiles('''#include <netinet/in.h>
+                    struct ip_mreqn foo;''',
+                 name : 'struct ip_mreqn')
+    glib_conf.set('HAVE_IP_MREQN', '/**/')
+  endif
+endif
+
+gnetworking_h_conf.set('WSPIAPI_INCLUDE', gnetworking_h_wspiapi_include)
+gnetworking_h_conf.set('NAMESER_COMPAT_INCLUDE', gnetworking_h_nameser_compat_include)
+
+gnetworking_h = configure_file(input : 'gnetworking.h.in',
+                               output : 'gnetworking.h',
+                               install_dir : 'include/glib-2.0/gio/',
+                               configuration : gnetworking_h_conf)
+
+gdbus_headers = [
+  'gdbusauthobserver.h',
+  'gcredentials.h',
+  'gdbusutils.h',
+  'gdbuserror.h',
+  'gdbusaddress.h',
+  'gdbusconnection.h',
+  'gdbusmessage.h',
+  'gdbusnameowning.h',
+  'gdbusnamewatching.h',
+  'gdbusproxy.h',
+  'gdbusintrospection.h',
+  'gdbusmethodinvocation.h',
+  'gdbusserver.h',
+  'gdbusinterface.h',
+  'gdbusinterfaceskeleton.h',
+  'gdbusobject.h',
+  'gdbusobjectskeleton.h',
+  'gdbusobjectproxy.h',
+  'gdbusobjectmanager.h',
+  'gdbusobjectmanagerclient.h',
+  'gdbusobjectmanagerserver.h',
+  'gtestdbus.h',
+]
+
+gdbus_sources = [
+  'gdbusutils.c',
+  'gdbusaddress.c',
+  'gdbusauthobserver.c',
+  'gdbusauth.c',
+  'gdbusauthmechanism.c',
+  'gdbusauthmechanismanon.c',
+  'gdbusauthmechanismexternal.c',
+  'gdbusauthmechanismsha1.c',
+  'gdbuserror.c',
+  'gdbusconnection.c',
+  'gdbusmessage.c',
+  'gdbusnameowning.c',
+  'gdbusnamewatching.c',
+  'gdbusproxy.c',
+  'gdbusprivate.c',
+  'gdbusintrospection.c',
+  'gdbusmethodinvocation.c',
+  'gdbusserver.c',
+  'gdbusinterface.c',
+  'gdbusinterfaceskeleton.c',
+  'gdbusobject.c',
+  'gdbusobjectskeleton.c',
+  'gdbusobjectproxy.c',
+  'gdbusobjectmanager.c',
+  'gdbusobjectmanagerclient.c',
+  'gdbusobjectmanagerserver.c',
+  'gtestdbus.c',
+]
+
+# FIXME: These are not built into the library yet
+#EXTRA_DIST += gdbusdaemon.c gdbusdaemon.h dbus-daemon.xml
+#gdbus-daemon-generated.h gdbus-daemon-generated.c: $(srcdir)/dbus-daemon.xml 
$(srcdir)/gdbus-2.0/codegen/gdbus-codegen.in
+#  $(AM_V_GEN) UNINSTALLED_GLIB_SRCDIR=$(top_srcdir) ',
+#    UNINSTALLED_GLIB_BUILDDIR=$(top_builddir) ',
+#    $(PYTHON) $(srcdir)/gdbus-2.0/codegen/gdbus-codegen.in ',
+#    --interface-prefix org. ',
+#    --generate-c-code gdbus-daemon-generated ',
+#    --c-namespace _G ',
+#    $(srcdir)/dbus-daemon.xml
+
+settings_headers = [
+  'gsettingsbackend.h',
+  'gsettingsschema.h',
+  'gsettings.h',
+]
+
+settings_sources = [
+  'gvdb/gvdb-reader.c',
+  'gdelayedsettingsbackend.c',
+  'gkeyfilesettingsbackend.c',
+  'gmemorysettingsbackend.c',
+  'gnullsettingsbackend.c',
+  'gsettingsbackend.c',
+  'gsettingsschema.c',
+  'gsettings-mapping.c',
+  'gsettings.c',
+]
+
+if host_machine.system() == 'windows'
+  settings_sources += [ 'gregistrysettingsbackend.c' ]
+endif
+
+# FIXME:
+#if OS_COCOA
+#settings_sources += [ 'gnextstepsettingsbackend.c' ]
+#endif
+
+application_headers = [
+  'gapplication.h',
+  'gapplicationcommandline.h',
+
+  'gactiongroup.h',
+  'gactionmap.h',
+  'gsimpleactiongroup.h',
+  'gremoteactiongroup.h',
+  'gactiongroupexporter.h',
+  'gdbusactiongroup.h',
+  'gaction.h',
+  'gpropertyaction.h',
+  'gsimpleaction.h',
+
+  'gmenumodel.h',
+  'gmenu.h',
+  'gmenuexporter.h',
+  'gdbusmenumodel.h',
+  'gnotification.h',
+]
+
+application_sources = [
+  'gapplication.c',
+  'gapplicationcommandline.c',
+  'gapplicationimpl-dbus.c',
+
+  'gactiongroup.c',
+  'gactionmap.c',
+  'gsimpleactiongroup.c',
+  'gremoteactiongroup.c',
+  'gactiongroupexporter.c',
+  'gdbusactiongroup.c',
+  'gaction.c',
+  'gpropertyaction.c',
+  'gsimpleaction.c',
+
+  'gmenumodel.c',
+  'gmenu.c',
+  'gmenuexporter.c',
+  'gdbusmenumodel.c',
+  'gnotification.c',
+  'gnotificationbackend.c',
+]
+
+local_sources = [
+  'ghttpproxy.c',
+  'ghttpproxy.h',
+  'glocalfile.c',
+  'glocalfile.h',
+  'glocalfileenumerator.c',
+  'glocalfileenumerator.h',
+  'glocalfileinfo.c',
+  'glocalfileinfo.h',
+  'glocalfileinputstream.c',
+  'glocalfileinputstream.h',
+  'glocalfilemonitor.c',
+  'glocalfilemonitor.h',
+  'glocalfileoutputstream.c',
+  'glocalfileoutputstream.h',
+  'glocalfileiostream.c',
+  'glocalfileiostream.h',
+  'glocalvfs.c',
+  'glocalvfs.h',
+  'gsocks4proxy.c',
+  'gsocks4proxy.h',
+  'gsocks4aproxy.c',
+  'gsocks4aproxy.h',
+  'gsocks5proxy.c',
+  'gsocks5proxy.h',
+  'thumbnail-verify.h',
+  'thumbnail-verify.c',
+]
+
+platform_deps = [ ]
+internal_deps = [ ]
+appinfo_sources = [ ]
+
+# inotify
+if glib_conf.has('HAVE_SYS_INOTIFY_H') and have_func_inotify_init1
+  subdir('inotify')
+  internal_deps += [ inotify_lib ]
+endif
+
+# kevent
+if have_func_kqueue and have_func_kevent
+  subdir('kqueue')
+  internal_deps += [ kqueue_lib ]
+endif
+
+if host_machine.system() == 'windows'
+  subdir('win32')
+  internal_deps += [ giowin32_lib ]
+endif
+
+# FIXME: FAM support
+#if HAVE_FAM
+#  subdir('fam')
+#endif
+
+unix_sources = [ ]
+if host_machine.system() != 'windows'
+  appinfo_sources += [ 'gdesktopappinfo.c' ]
+  subdir('xdgmime')
+  internal_deps += [ xdgmime_lib ]
+  unix_sources = [
+    'gfiledescriptorbased.c',
+    'gunixconnection.c',
+    'gunixcredentialsmessage.c',
+    'gunixfdlist.c',
+    'gunixfdmessage.c',
+    'gunixmount.c',
+    'gunixmount.h',
+    'gunixmounts.c',
+    'gunixsocketaddress.c',
+    'gunixvolume.c',
+    'gunixvolume.h',
+    'gunixvolumemonitor.c',
+    'gunixvolumemonitor.h',
+    'gunixinputstream.c',
+    'gunixoutputstream.c',
+    'gcontenttype.c',
+    'gcontenttypeprivate.h',
+    'gfdonotificationbackend.c',
+    'ggtknotificationbackend.c',
+  ]
+
+  # FIXME
+  #if OS_COCOA
+  #unix_sources += gcocoanotificationbackend.c
+  #endif
+
+  gio_unix_include_headers = [
+    'gdesktopappinfo.h',
+    'gfiledescriptorbased.h',
+    'gunixconnection.h',
+    'gunixcredentialsmessage.h',
+    'gunixmounts.h',
+    'gunixfdlist.h',
+    'gunixfdmessage.h',
+    'gunixinputstream.h',
+    'gunixoutputstream.h',
+    'gunixsocketaddress.h',
+  ]
+  install_headers(gio_unix_include_headers, subdir : 'gio-unix-2.0/gio')
+
+  if glib_conf.has('HAVE_NETLINK')
+    unix_sources += [
+      'gnetworkmonitornetlink.c',
+      'gnetworkmonitornm.c',
+    ]
+  endif
+endif
+
+gdbus_daemon_sources = [
+  'gdbusdaemon.c',
+  'gdbus-daemon-generated.c',
+]
+
+win32_actual_sources = gdbus_daemon_sources + [
+  'gwin32registrykey.c',
+  'gcontenttype-win32.c',
+  'gwin32mount.c',
+  'gwin32volumemonitor.c',
+  'gwin32inputstream.c',
+  'gwin32outputstream.c',
+]
+
+if host_machine.system() == 'windows'
+  appinfo_sources += [ 'gwin32appinfo.c' ]
+  platform_deps += [ find_library('shlwapi'),
+                     find_library('ws2_32'),
+                     find_library('dnsapi'),
+                     find_library('iphlpapi') ]
+  # win32_sources = $(win32_actual_sources)
+
+  gio_win32_include_headers = [
+    'gwin32inputstream.h',
+    'gwin32outputstream.h',
+  ]
+  install_headers(gio_win32_include_headers, subdir : 'gio-win32-2.0/gio')
+endif
+
+gio_sources = [
+  'gappinfo.c',
+  'gasynchelper.c',
+  'gasyncinitable.c',
+  'gasyncresult.c',
+  'gbufferedinputstream.c',
+  'gbufferedoutputstream.c',
+  'gbytesicon.c',
+  'gcancellable.c',
+  'gcharsetconverter.c',
+  'gcontextspecificgroup.c',
+  'gconverter.c',
+  'gconverterinputstream.c',
+  'gconverteroutputstream.c',
+  'gcredentials.c',
+  'gdatagrambased.c',
+  'gdatainputstream.c',
+  'gdataoutputstream.c',
+  'gdrive.c',
+  'gdummyfile.c',
+  'gdummyproxyresolver.c',
+  'gdummytlsbackend.c',
+  'gemblem.c',
+  'gemblemedicon.c',
+  'gfile.c',
+  'gfileattribute.c',
+  'gfileenumerator.c',
+  'gfileicon.c',
+  'gfileinfo.c',
+  'gfileinputstream.c',
+  'gfilemonitor.c',
+  'gfilenamecompleter.c',
+  'gfileoutputstream.c',
+  'gfileiostream.c',
+  'gfilterinputstream.c',
+  'gfilteroutputstream.c',
+  'gicon.c',
+  'ginetaddress.c',
+  'ginetaddressmask.c',
+  'ginetsocketaddress.c',
+  'ginitable.c',
+  'ginputstream.c',
+  'gioerror.c',
+  'giomodule.c',
+  'gioscheduler.c',
+  'giostream.c',
+  'gloadableicon.c',
+  'gmount.c',
+  'gmemoryinputstream.c',
+  'gmemoryoutputstream.c',
+  'gmountoperation.c',
+  'gnativevolumemonitor.c',
+  'gnativesocketaddress.c',
+  'gnetworkaddress.c',
+  'gnetworking.c',
+  'gnetworkmonitor.c',
+  'gnetworkmonitorbase.c',
+  'gnetworkservice.c',
+  'goutputstream.c',
+  'gpermission.c',
+  'gpollableinputstream.c',
+  'gpollableoutputstream.c',
+  'gpollableutils.c',
+  'gpollfilemonitor.c',
+  'gproxy.c',
+  'gproxyaddress.c',
+  'gproxyaddressenumerator.c',
+  'gproxyresolver.c',
+  'gresolver.c',
+  'gresource.c',
+  'gresourcefile.c',
+  'gseekable.c',
+  'gsimpleasyncresult.c',
+  'gsimpleiostream.c',
+  'gsimplepermission.c',
+  'gsocket.c',
+  'gsocketaddress.c',
+  'gsocketaddressenumerator.c',
+  'gsocketclient.c',
+  'gsocketconnectable.c',
+  'gsocketconnection.c',
+  'gsocketcontrolmessage.c',
+  'gsocketinputstream.c',
+  'gsocketlistener.c',
+  'gsocketoutputstream.c',
+  'gsubprocesslauncher.c',
+  'gsubprocess.c',
+  'gsocketservice.c',
+  'gsrvtarget.c',
+  'gsimpleproxyresolver.c',
+  'gtask.c',
+  'gtcpconnection.c',
+  'gtcpwrapperconnection.c',
+  'gthreadedsocketservice.c',
+  'gthemedicon.c',
+  'gthreadedresolver.c',
+  'gthreadedresolver.h',
+  'gtlsbackend.c',
+  'gtlscertificate.c',
+  'gtlsclientconnection.c',
+  'gtlsconnection.c',
+  'gtlsdatabase.c',
+  'gtlsfiledatabase.c',
+  'gtlsinteraction.c',
+  'gtlspassword.c',
+  'gtlsserverconnection.c',
+  'gdtlsconnection.c',
+  'gdtlsclientconnection.c',
+  'gdtlsserverconnection.c',
+  'gunionvolumemonitor.c',
+  'gvfs.c',
+  'gvolume.c',
+  'gvolumemonitor.c',
+  'gzlibcompressor.c',
+  'gzlibdecompressor.c',
+# FIXME  'gioenumtypes.c',
+  'glistmodel.c',
+  'gliststore.c',
+]
+
+# FIXME
+gio_sources += appinfo_sources
+gio_sources += unix_sources
+#gio_sources += win32_sources
+gio_sources += application_sources
+gio_sources += settings_sources
+gio_sources += gdbus_sources
+gio_sources += local_sources
+
+foo = '''
+if OS_WIN32_AND_DLL_COMPILATION
+gio_win32_res = gio-win32-res.o
+gio_win32_res_ldflag = -Wl,$(gio_win32_res)
+endif
+
+
+if OS_COCOA
+# This is dumb.  The ObjC source file should be properly named .m
+libgio_2_0_la_CFLAGS += -xobjective-c
+libgio_2_0_la_LDFLAGS += -Wl,-framework,Foundation -Wl,-framework,AppKit
+endif
+
+libgio_2_0_la_DEPENDENCIES = $(gio_win32_res) $(gio_def) $(platform_deps)
+
+gio-win32-res.o: gio.rc
+  '$(WINDRES) gio.rc $@
+
+gioincludedir=$(includedir)/glib-2.0/gio/
+gioinclude_HEADERS =',
+  '$(gio_headers)',
+  'gioenumtypes.h
+
+# these sources (also mentioned above) are generated.
+BUILT_SOURCES +=',
+  'gconstructor_as_data.h',
+  'gioenumtypes.h',
+  'gioenumtypes.c',
+  'gdbus-daemon-generated.c',
+  'gdbus-daemon-generated.h',
+  'gnetworking.h',
+  '$(NULL)
+
+BUILT_EXTRA_DIST +=',
+  'gio.rc
+
+# This is read by gobject-introspection/misc/ and gtk-doc
+gio-public-headers.txt: Makefile
+  '$(AM_V_GEN) echo $(gioinclude_HEADERS) $(giowin32include_HEADERS) $(giounixinclude_HEADERS) > $@.tmp && 
mv $@.tmp $@
+
+all-local: gio-public-headers.txt
+
+gioenumtypes.h: $(gio_headers) gioenumtypes.h.template
+  '$(AM_V_GEN) $(top_builddir)/gobject/glib-mkenums --template $(filter %.template,$^) $(filter-out 
%.template,$^) >',
+  '    gioenumtypes.h.tmp && mv gioenumtypes.h.tmp gioenumtypes.h
+
+gioenumtypes.c: $(gio_headers) gioenumtypes.c.template
+  '$(AM_V_GEN) $(top_builddir)/gobject/glib-mkenums --template $(filter %.template,$^) $(filter-out 
%.template,$^) >',
+  '    gioenumtypes.c.tmp && mv gioenumtypes.c.tmp gioenumtypes.c
+
+gio.def: libgio-2.0.la
+  '$(AM_V_GEN) dumpbin.exe -exports .libs/libgio-2.0-0.dll | awk 'BEGIN { print "EXPORTS" } / +[[:digit:]]+ 
+[[:xdigit:]]+ +[[:xdigit:]]+/{ print $$4 }' > gio.def.tmp && mv gio.def.tmp gio.def
+
+gio-2.0.lib: libgio-2.0.la gio.def
+  '$(AM_V_GEN) lib.exe -machine:@LIB_EXE_MACHINE_FLAG@ -name:libgio-2.0-$(LT_CURRENT_MINUS_AGE).dll 
-def:$(builddir)/gio.def -out:$@
+
+bin_PROGRAMS = gio-querymodules glib-compile-schemas glib-compile-resources gsettings
+
+glib_compile_resources_LDADD = libgio-2.0.la',
+  '$(top_builddir)/gobject/libgobject-2.0.la',
+  '$(top_builddir)/gmodule/libgmodule-2.0.la',
+  '$(top_builddir)/glib/libglib-2.0.la',
+  '$(NULL)
+
+glib_compile_resources_SOURCES =',
+  'gvdb/gvdb-format.h',
+  'gvdb/gvdb-builder.h',
+  'gvdb/gvdb-builder.c',
+  'glib-compile-resources.c
+
+gio_querymodules_SOURCES = gio-querymodules.c
+gio_querymodules_LDADD  = libgio-2.0.la',
+  '$(top_builddir)/gobject/libgobject-2.0.la',
+  '$(top_builddir)/gmodule/libgmodule-2.0.la',
+  '$(top_builddir)/glib/libglib-2.0.la',
+  '$(NULL)
+
+gconstructor_as_data.h: $(top_srcdir)/glib/gconstructor.h data-to-c.pl
+  '$(AM_V_GEN) $(srcdir)/data-to-c.pl $(top_srcdir)/glib/gconstructor.h gconstructor_code > $@.tmp && mv 
$@.tmp $@
+
+glib_compile_schemas_LDADD = $(top_builddir)/glib/libglib-2.0.la
+glib_compile_schemas_SOURCES =',
+  'gconstructor_as_data.h',
+  'gvdb/gvdb-format.h',
+  'gvdb/gvdb-builder.h',
+  'gvdb/gvdb-builder.c',
+  'glib-compile-schemas.c
+
+gsettings_LDADD = libgio-2.0.la',
+  '$(top_builddir)/gobject/libgobject-2.0.la',
+  '$(top_builddir)/gmodule/libgmodule-2.0.la',
+  '$(top_builddir)/glib/libglib-2.0.la',
+  '$(NULL)
+gsettings_SOURCES = gsettings-tool.c
+
+schemadir = $(datadir)/glib-2.0/schemas
+dist_schema_DATA = gschema.dtd
+
+itsdir = $(datadir)/gettext/its
+dist_its_DATA = gschema.loc gschema.its
+
+# ------------------------------------------------------------------------
+# gdbus(1) tool
+
+bin_PROGRAMS += gdbus
+gdbus_SOURCES = gdbus-tool.c
+gdbus_LDADD = libgio-2.0.la',
+  '$(top_builddir)/gobject/libgobject-2.0.la',
+  '$(top_builddir)/gmodule/libgmodule-2.0.la',
+  '$(top_builddir)/glib/libglib-2.0.la',
+  '$(NULL)
+
+if OS_UNIX
+# ------------------------------------------------------------------------
+# gapplication(1) tool
+bin_PROGRAMS += gapplication
+gapplication_SOURCES = gapplication-tool.c
+gapplication_LDADD = libgio-2.0.la',
+  '$(top_builddir)/gobject/libgobject-2.0.la',
+  '$(top_builddir)/gmodule/libgmodule-2.0.la',
+  '$(top_builddir)/glib/libglib-2.0.la',
+  '$(NULL)
+endif
+
+completiondir = $(datadir)/bash-completion/completions
+completion_DATA =',
+  'completion/gapplication',
+  'completion/gdbus',
+  'completion/gsettings',
+  'completion/gresource
+EXTRA_DIST += $(completion_DATA)
+'''
+
+gio_headers = [
+  'gappinfo.h',
+  'gasyncinitable.h',
+  'gasyncresult.h',
+  'gbufferedinputstream.h',
+  'gbufferedoutputstream.h',
+  'gbytesicon.h',
+  'gcancellable.h',
+  'gcontenttype.h',
+  'gcharsetconverter.h',
+  'gconverter.h',
+  'gconverterinputstream.h',
+  'gconverteroutputstream.h',
+  'gdatagrambased.h',
+  'gdatainputstream.h',
+  'gdataoutputstream.h',
+  'gdrive.h',
+  'gemblem.h',
+  'gemblemedicon.h',
+  'gfile.h',
+  'gfileattribute.h',
+  'gfileenumerator.h',
+  'gfileicon.h',
+  'gfileinfo.h',
+  'gfileinputstream.h',
+  'gfilemonitor.h',
+  'gfilenamecompleter.h',
+  'gfileoutputstream.h',
+  'gfileiostream.h',
+  'gfilterinputstream.h',
+  'gfilteroutputstream.h',
+  'gicon.h',
+  'ginetaddress.h',
+  'ginetaddressmask.h',
+  'ginetsocketaddress.h',
+  'ginputstream.h',
+  'ginitable.h',
+  'gio.h',
+  'gio-autocleanups.h',
+  'giotypes.h',
+  'gioenums.h',
+  'gioerror.h',
+  'giomodule.h',
+  'gioscheduler.h',
+  'giostream.h',
+  'gloadableicon.h',
+  'gmount.h',
+  'gmemoryinputstream.h',
+  'gmemoryoutputstream.h',
+  'gmountoperation.h',
+  'gnativevolumemonitor.h',
+  'gnetworkaddress.h',
+  'gnetworkmonitor.h',
+  'gnetworkservice.h',
+  'goutputstream.h',
+  'gpermission.h',
+  'gpollableinputstream.h',
+  'gpollableoutputstream.h',
+  'gpollableutils.h',
+  'gproxyaddress.h',
+  'gproxy.h',
+  'gproxyaddressenumerator.h',
+  'gproxyresolver.h',
+  'gresolver.h',
+  'gresource.h',
+  'gseekable.h',
+  'gsimpleasyncresult.h',
+  'gsimpleiostream.h',
+  'gsimplepermission.h',
+  'gsocket.h',
+  'gsocketaddress.h',
+  'gsocketaddressenumerator.h',
+  'gsocketclient.h',
+  'gsocketconnectable.h',
+  'gsocketconnection.h',
+  'gsocketcontrolmessage.h',
+  'gsocketlistener.h',
+  'gsocketservice.h',
+  'gsrvtarget.h',
+  'gsimpleproxyresolver.h',
+  'gtask.h',
+  'gsubprocess.h',
+  'gsubprocesslauncher.h',
+  'gtcpconnection.h',
+  'gtcpwrapperconnection.h',
+  'gthreadedsocketservice.h',
+  'gthemedicon.h',
+  'gtlsbackend.h',
+  'gtlscertificate.h',
+  'gtlsclientconnection.h',
+  'gtlsconnection.h',
+  'gtlsdatabase.h',
+  'gtlsfiledatabase.h',
+  'gtlsinteraction.h',
+  'gtlspassword.h',
+  'gtlsserverconnection.h',
+  'gdtlsconnection.h',
+  'gdtlsclientconnection.h',
+  'gdtlsserverconnection.h',
+  'gvfs.h',
+  'gvolume.h',
+  'gvolumemonitor.h',
+  'gzlibcompressor.h',
+  'gzlibdecompressor.h',
+  'glistmodel.h',
+  'gliststore.h',
+]
+# FIXME: 'gnetworking.h', - generated? was in nodist_gioinclude_HEADERS
+gio_headers += application_headers
+gio_headers += settings_headers
+gio_headers += gdbus_headers
+install_headers(gio_headers, subdir : 'glib-2.0/gio/')
+
+gio_mkenums = find_program('build_mkenum.py')
+
+gioenumtypes_h = custom_target('gioenumtypes_h',
+  output : 'gioenumtypes.h',
+  input : gio_headers,
+  install : true,
+  install_dir : 'include/glib-2.0/gio/',
+  depends : [ ],
+  command : [ gio_mkenums, '@OUTPUT@', meson.source_root(), '@INPUT@', gnetworking_h ])
+
+gioenumtypes_c = custom_target('gioenumtypes_c',
+  output : 'gioenumtypes.c',
+  input : gio_headers,
+  depends : [ gioenumtypes_h ],
+  command : [ gio_mkenums, '@OUTPUT@', meson.source_root(), '@INPUT@', gnetworking_h, ])
+
+libgio = shared_library('gio',
+  gioenumtypes_h, gioenumtypes_c, gnetworking_h, gio_sources,
+  version : glib_version,
+  soversion : interface_version,
+  install : true,
+  include_directories : inc_dirs,
+  link_with : [ libglib, libgobject, libgmodule ] + internal_deps,
+  #libgio_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS)',
+  #  '$(gio_win32_res_ldflag)',
+  #  '-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)',
+  #  '-export-dynamic $(no_undefined)
+  #$(ZLIB_LIBS)
+  #$(SELINUX_LIBS)
+  #$(GLIB_LIBS)
+  #$(XATTR_LIBS)
+  #$(NETWORK_LIBS)
+  dependencies : [ libz_dep, libdl_dep ] + platform_deps + network_libs,
+  c_args : gio_c_args
+)
+
+# gresource tool
+libelf = dependency('libelf', version : '>= 0.8.12', required : false)
+if libelf.found()
+  glib_conf.set('HAVE_LIBELF', 1)
+endif
+executable('gresource', 'gresource-tool.c',
+  include_directories : inc_dirs,
+  c_args : [ '-DHAVE_CONFIG_H=1' ],
+  link_with : [ libgio, libgobject, libgmodule, libglib ],
+  dependencies : libelf,
+)
+
+subdir('tests')
diff --git a/gio/tests/meson.build b/gio/tests/meson.build
new file mode 100644
index 0000000..3715005
--- /dev/null
+++ b/gio/tests/meson.build
@@ -0,0 +1,219 @@
+#  Test programs buildable on all platforms
+gio_tests = [
+  'appmonitor',
+  'async-close-output-stream',
+  'async-splice-output-stream',
+  'buffered-input-stream',
+  'buffered-output-stream',
+  'cancellable',
+  'contexts',
+  'contenttype',
+  'converter-stream',
+  'credentials',
+  'data-input-stream',
+  'data-output-stream',
+  #'defaultvalue',           # FIXME: needs giotypefuncs.c generated
+  'fileattributematcher',
+  'filter-streams',
+  'giomodule',
+  'gsubprocess',
+  'g-file',
+  'g-file-info',
+  'g-icon',
+  'gdbus-addresses',
+  'gdbus-message',
+  'inet-address',
+  'io-stream',
+  'memory-input-stream',
+  'memory-output-stream',
+  'monitor',
+  'network-address',
+  'network-monitor',
+  'permission',
+  'pollable',
+  'proxy-test',
+  'readwrite',
+  'simple-async-result',
+  'simple-proxy',
+  'sleepy-stream',
+  'socket',
+  'socket-listener',
+  'socket-service',
+  'srvtarget',
+  'task',
+  'vfs',
+  'volumemonitor',
+  'glistmodel',
+  'testfilemonitor',
+]
+
+gio_tests += [
+  'thumbnail-verification',
+]
+
+#  Test programs buildable on UNIX only
+
+if host_machine.system() != 'windows'
+  gio_tests += [
+    'file',
+    'gdbus-peer-object-manager',
+    'gdbus-unix-addresses',
+    'live-g-file',
+    'socket-address',
+    'stream-rw_all',
+    'unix-fd',
+    'unix-streams',
+  ]
+endif
+
+if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
+  gio_tests += [ 'autoptr' ]
+endif
+
+test_env = [
+  'G_TEST_SRCDIR=' + meson.current_source_dir(),
+  'G_TEST_BUILDDIR=' + meson.current_build_dir(),
+]
+
+test_c_args = [
+  '-DHAVE_CONFIG_H=1',
+  '-DG_LOG_DOMAIN="GLib-GIO"',
+  '-DTEST_SERVICES="@0@/gio/tests/services"'.format(meson.build_root()),
+]
+
+foreach test_name : gio_tests
+  src_file = '@0@.c'.format(test_name)
+  # conflicts with glib/tests/autoptr, can't have two targets with same name
+  if test_name == 'autoptr'
+    test_name = 'autoptr-gio'
+  endif
+  exe = executable(test_name, src_file,
+      include_directories : inc_dirs,
+      install : false,
+      c_args : test_c_args,
+      link_with : [ libgio, libgmodule, libglib ],
+      dependencies : deps,
+  )
+  if test_name == 'testfilemonitor'
+    test(test_name, exe, env : test_env, timeout : 45)
+  else
+    test(test_name, exe, env : test_env)
+  endif
+endforeach
+
+uninstalled_test_extra_programs = [
+  'gio-du',
+  'echo-server',
+  'filter-cat',
+  'gapplication-example-actions',
+  'gapplication-example-cmdline',
+  'gapplication-example-cmdline2',
+  'gapplication-example-cmdline3',
+  'gapplication-example-dbushooks',
+  'gapplication-example-open',
+  'gdbus-example-export',
+  'gdbus-example-own-name',
+  'gdbus-example-peer',
+  'gdbus-example-proxy-subclass',
+  'gdbus-example-server',
+  'gdbus-example-subtree',
+  'gdbus-example-watch-name',
+  'gdbus-example-watch-proxy',
+  'gsubprocess-testprog',
+  'httpd',
+  'proxy',
+  'resolver',
+  'send-data',
+  'socket-server',
+]
+
+foreach extra_program : uninstalled_test_extra_programs
+  exe = executable(extra_program, '@0@.c'.format(extra_program),
+      include_directories : inc_dirs,
+      install : false,
+      c_args : test_c_args,
+      link_with : [ libgio, libgmodule, libglib ],
+      dependencies : deps,
+  )
+endforeach
+
+test_extra_programs = [
+  'gdbus-connection-flush-helper',
+  'gdbus-testserver',
+]
+
+exe = executable('tls-certificate', 'tls-certificate.c', 'gtesttlsbackend.c',
+  include_directories : inc_dirs,
+  c_args : test_c_args,
+  link_with : [ libgio, libgmodule, libglib ],
+  dependencies : deps,
+)
+test('tls-certificate', exe, env : test_env)
+
+exe = executable('socket-client', 'socket-client.c', 'gtlsconsoleinteraction.c',
+  include_directories : inc_dirs,
+  c_args : test_c_args,
+  link_with : [ libgio, libgmodule, libglib ],
+  dependencies : deps,
+)
+
+#exe = executable('gdbus-daemon', 'gdbus-daemon.c', '../gdbusdaemon.c',
+#  #meson.build_root() + '/gio/gdbus-daemon-generated.c', # FIXME
+#  include_directories : inc_dirs,
+#  c_args : test_c_args,
+#  link_with : [ libgio, libgmodule, libglib ],
+#  dependencies : deps,
+#)
+#test('gdbus-daemon', exe, env : test_env)
+
+foo = '''
+c_args_atomic = [ ]
+if cc.get_id() == 'gcc'
+  c_args_atomic += [ '-Wstrict-aliasing=2' ]
+endif
+
+# FIXME: consolidate all of these into the array
+exe = executable('overflow-fallback', 'overflow.c',
+  include_directories : inc_dirs,
+  c_args : [ '-DHAVE_CONFIG_H=1', '-D_GLIB_TEST_OVERFLOW_FALLBACK' ],
+  link_with : libglib,
+  dependencies : deps,
+)
+test('overflow-fallback', exe, env : test_env)
+
+exe = executable('642026-ec', '642026.c',
+  include_directories : inc_dirs,
+  c_args : [ '-DHAVE_CONFIG_H=1', '-DG_ERRORCHECK_MUTEXES' ],
+  link_with : libglib,
+  dependencies : deps,
+)
+test('642026-ec', exe, env : test_env)
+
+exe = executable('1bit-emufutex', '1bit-mutex.c',
+  include_directories : inc_dirs,
+  c_args : [ '-DHAVE_CONFIG_H=1', '-DTEST_EMULATED_FUTEX' ],
+  link_with : libglib,
+  dependencies : deps,
+)
+test('1bit-emufutex', exe, env : test_env)
+
+if glib_conf.has('HAVE_EVENTFD')
+  exe = executable('gwakeup-fallback', 'gwakeuptest.c', '../gwakeup.c',
+    include_directories : inc_dirs,
+    c_args : [ '-DHAVE_CONFIG_H=1', '-DTEST_EVENTFD_FALLBACK' ],
+    link_with : libglib,
+    dependencies : deps,
+  )
+  test('gwakeup-fallback', exe, env : test_env)
+endif
+
+# test-spawn-echo helper binary required by the spawn tests
+executable('test-spawn-echo', 'test-spawn-echo.c',
+           include_directories : inc_dirs,
+           c_args : [ '-DHAVE_CONFIG_H=1', '-DG_LOG_DOMAIN="GLib"' ],
+           link_with : libglib,
+           dependencies : deps,
+)
+'''
+
+subdir('modules')
diff --git a/gio/tests/modules/meson.build b/gio/tests/modules/meson.build
new file mode 100644
index 0000000..3d4af50
--- /dev/null
+++ b/gio/tests/modules/meson.build
@@ -0,0 +1,13 @@
+libtestmodulea = shared_library('testmodulea', 'test-module-a.c',
+  install : false,
+  include_directories : inc_dirs,
+  link_with : [ libglib, libgobject, libgmodule, libgio ],
+  c_args : [ ]
+)
+
+libtestmoduleb = shared_library('testmoduleb', 'test-module-b.c',
+  install : false,
+  include_directories : inc_dirs,
+  link_with : [ libglib, libgobject, libgmodule, libgio ],
+  c_args : [ ]
+)
diff --git a/gio/win32/meson.build b/gio/win32/meson.build
new file mode 100644
index 0000000..52d720e
--- /dev/null
+++ b/gio/win32/meson.build
@@ -0,0 +1,13 @@
+giowin32_sources = [
+  'gwin32fsmonitorutils.c',
+  'gwin32filemonitor.c',
+  'gwinhttpvfs.c',
+  'gwinhttpfile.c',
+  'gwinhttpfileinputstream.c',
+  'gwinhttpfileoutputstream.c',
+]
+
+giowin32_lib = static_library('giowin32',
+  sources : giowin32_sources,
+  include_directories : inc_dirs,
+  c_args : [ '-DHAVE_CONFIG_H', '-fPIC', '-DG_DISABLE_DEPRECATED' ] + gio_c_args)
diff --git a/gio/xdgmime/meson.build b/gio/xdgmime/meson.build
new file mode 100644
index 0000000..4b04221
--- /dev/null
+++ b/gio/xdgmime/meson.build
@@ -0,0 +1,15 @@
+xdgmime_sources = [
+  'xdgmime.c',
+  'xdgmimealias.c',
+  'xdgmimecache.c',
+  'xdgmimeglob.c',
+  'xdgmimeicon.c',
+  'xdgmimeint.c',
+  'xdgmimemagic.c',
+  'xdgmimeparent.c',
+]
+
+xdgmime_lib = static_library('xdgmime',
+  sources : xdgmime_sources,
+  include_directories : inc_dirs,
+  c_args : [ '-DHAVE_CONFIG_H', '-DXDG_PREFIX=_gio_xdg', '-fPIC' ])
diff --git a/glib/glibconfig.h.in b/glib/glibconfig.h.in
index 6a7eb2a..87a4a12 100644
--- a/glib/glibconfig.h.in
+++ b/glib/glibconfig.h.in
@@ -8,12 +8,9 @@
 
 #include <glib/gmacros.h>
 
-@INC_LIMITS_H@
-@INC_FLOAT_H@
-@INC_VALUES_H@
-
+#include <limits.h>
+#include <float.h>
 #mesondefine GLIB_HAVE_ALLOCA_H
-#mesondefine GLIB_HAVE_SYS_POLL_H
 
 /* Specifies that GLib's g_print*() functions wrap the
  * system printf functions.  This is useful to know, for example,
@@ -23,21 +20,20 @@
 
 G_BEGIN_DECLS
 
-#define G_MINFLOAT     @glib_mf@
-#define G_MAXFLOAT     @glib_Mf@
-#define G_MINDOUBLE    @glib_md@
-#define G_MAXDOUBLE    @glib_Md@
-#define G_MINSHORT     @glib_ms@
-#define G_MAXSHORT     @glib_Ms@
-#define G_MAXUSHORT    @glib_Mus@
-#define G_MININT       @glib_mi@
-#define G_MAXINT       @glib_Mi@
-#define G_MAXUINT      @glib_Mui@
-#define G_MINLONG      @glib_ml@
-#define G_MAXLONG      @glib_Ml@
-#define G_MAXULONG     @glib_Mul@
-
-/* this should always be true in a modern C/C++ compiler */
+#define G_MINFLOAT     FLT_MIN
+#define G_MAXFLOAT     FLT_MAX
+#define G_MINDOUBLE    DBL_MIN
+#define G_MAXDOUBLE    DBL_MAX
+#define G_MINSHORT     SHRT_MIN
+#define G_MAXSHORT     SHRT_MAX
+#define G_MAXUSHORT    USHRT_MAX
+#define G_MININT       INT_MIN
+#define G_MAXINT       INT_MAX
+#define G_MAXUINT      UINT_MAX
+#define G_MINLONG      LONG_MIN
+#define G_MAXLONG      LONG_MAX
+#define G_MAXULONG     ULONG_MAX
+
 typedef signed char gint8;
 typedef unsigned char guint8;
 
@@ -73,12 +69,14 @@ typedef unsigned @gint32@ guint32;
 #define GLIB_SIZEOF_VOID_P @glib_void_p@
 #define GLIB_SIZEOF_LONG   @glib_long@
 #define GLIB_SIZEOF_SIZE_T @glib_size_t@
+#define GLIB_SIZEOF_SSIZE_T @glib_ssize_t@
 
 typedef signed @glib_size_type_define@ gssize;
 typedef unsigned @glib_size_type_define@ gsize;
 #define G_GSIZE_MODIFIER @gsize_modifier@
-#define G_GSSIZE_FORMAT @gssize_format@
+#define G_GSSIZE_MODIFIER @gssize_modifier@
 #define G_GSIZE_FORMAT @gsize_format@
+#define G_GSSIZE_FORMAT @gssize_format@
 
 #define G_MAXSIZE      G_MAXU@glib_msize_type@
 #define G_MINSSIZE     G_MIN@glib_msize_type@
@@ -92,6 +90,8 @@ typedef gint64 goffset;
 #define G_GOFFSET_FORMAT        G_GINT64_FORMAT
 #define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
 
+#define G_POLLFD_FORMAT @g_pollfd_format@
+
 #define GPOINTER_TO_INT(p)     ((gint)  @glib_gpi_cast@ (p))
 #define GPOINTER_TO_UINT(p)    ((guint) @glib_gpui_cast@ (p))
 
@@ -105,33 +105,22 @@ typedef unsigned @glib_intptr_type_define@ guintptr;
 #define G_GINTPTR_FORMAT        @gintptr_format@
 #define G_GUINTPTR_FORMAT       @guintptr_format@
 
-@glib_atexit@
-@glib_memmove@
-@glib_defines@
+#ifndef G_DISABLE_DEPRECATED
+#define g_ATEXIT(proc) (atexit (proc))
+#define g_memmove(dest,src,len) G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END
+#endif
+
+#define GLIB_MAJOR_VERSION @GLIB_MAJOR_VERSION@
+#define GLIB_MINOR_VERSION @GLIB_MINOR_VERSION@
+#define GLIB_MICRO_VERSION @GLIB_MICRO_VERSION@
+
 @glib_os@
 @glib_static_compilation@
 
 @glib_vacopy@
 
-#ifdef __cplusplus
-#define        G_HAVE_INLINE   1
-#else  /* !__cplusplus */
-@glib_inline@
-#endif /* !__cplusplus */
-
-#ifdef __cplusplus
-#define G_CAN_INLINE   1
-#else  /* !__cplusplus */
-#mesondefine G_CAN_INLINE
-#endif
-
-#ifndef __cplusplus
-#mesondefine G_HAVE_ISO_VARARGS
-#endif
-
-#ifdef __cplusplus
-#mesondefine G_HAVE_ISO_VARARGS
-#endif
+@g_have_iso_c_varargs@
+@g_have_iso_cxx_varargs@
 
 /* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
  * is passed ISO vararg support is turned off, and there is no work
@@ -145,13 +134,7 @@ typedef unsigned @glib_intptr_type_define@ guintptr;
 
 #mesondefine G_HAVE_GROWING_STACK
 
-/* On some systems, like SunOS and NetBSD, EILSEQ is not defined.
- * The correspondence between this and the corresponding definition
- * in libiconv is essential.
- */
-#mesondefine EILSEQ
-
-#mesondefine G_HAVE_GNUC_VISIBILITY
+#define G_HAVE_GNUC_VISIBILITY 1
 
 #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
 #define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
diff --git a/glib/libcharset/meson.build b/glib/libcharset/meson.build
index 0d87d1c..1ee08cc 100644
--- a/glib/libcharset/meson.build
+++ b/glib/libcharset/meson.build
@@ -1,3 +1,3 @@
-charset_lib = shared_library('charset', 'localcharset.c',
+charset_lib = static_library('charset', 'localcharset.c',
   include_directories : inc_dirs,
-  c_args : [ '-DLIBDIR="lib"' ])
+  c_args : [ '-DLIBDIR="lib"', '-fPIC' ])
diff --git a/glib/meson.build b/glib/meson.build
index 40efd90..0c99dfc 100644
--- a/glib/meson.build
+++ b/glib/meson.build
@@ -2,7 +2,101 @@ configure_file(input : 'glibconfig.h.in', output : 'glibconfig.h', configuration
 
 subdir('libcharset')
 
-if host.name() == 'windows'
+glib_headers = [
+  'glib.h',
+  'glib-unix.h',
+  'glib-object.h',
+]
+install_headers(glib_headers, subdir : 'glib-2.0/')
+
+glib_deprecated_headers = [
+  'deprecated/gallocator.h',
+  'deprecated/gcache.h',
+  'deprecated/gcompletion.h',
+  'deprecated/gmain.h',
+  'deprecated/grel.h',
+  'deprecated/gthread.h',
+]
+install_headers(glib_deprecated_headers, subdir : 'glib-2.0/deprecated/')
+
+glib_sub_headers = [
+  'glib-autocleanups.h',
+  'galloca.h',
+  'garray.h',
+  'gasyncqueue.h',
+  'gatomic.h',
+  'gbacktrace.h',
+  'gbase64.h',
+  'gbitlock.h',
+  'gbookmarkfile.h',
+  'gbytes.h',
+  'gcharset.h',
+  'gchecksum.h',
+  'gconvert.h',
+  'gdataset.h',
+  'gdate.h',
+  'gdatetime.h',
+  'gdir.h',
+  'genviron.h',
+  'gerror.h',
+  'gfileutils.h',
+  'ggettext.h',
+  'ghash.h',
+  'ghmac.h',
+  'ghook.h',
+  'ghostutils.h',
+  'gi18n.h',
+  'gi18n-lib.h',
+  'giochannel.h',
+  'gkeyfile.h',
+  'glist.h',
+  'gmacros.h',
+  'gmain.h',
+  'gmappedfile.h',
+  'gmarkup.h',
+  'gmem.h',
+  'gmessages.h',
+  'gnode.h',
+  'goption.h',
+  'gpattern.h',
+  'gpoll.h',
+  'gprimes.h',
+  'gqsort.h',
+  'gquark.h',
+  'gqueue.h',
+  'grand.h',
+  'gregex.h',
+  'gscanner.h',
+  'gsequence.h',
+  'gshell.h',
+  'gslice.h',
+  'gslist.h',
+  'gspawn.h',
+  'gstdio.h',
+  'gstrfuncs.h',
+  'gtestutils.h',
+  'gstring.h',
+  'gstringchunk.h',
+  'gthread.h',
+  'gthreadpool.h',
+  'gtimer.h',
+  'gtimezone.h',
+  'gtrashstack.h',
+  'gtree.h',
+  'gtypes.h',
+  'gunicode.h',
+  'gurifuncs.h',
+  'gutils.h',
+  'gvarianttype.h',
+  'gvariant.h',
+  'gversion.h',
+  'gversionmacros.h',
+  'gwin32.h',
+  'gprintf.h',
+]
+install_headers(glib_sub_headers, subdir : 'glib-2.0/glib/')
+
+if host_machine.system() == 'windows'
   thread_src = ['gthread-win32.c']
   plat_src = []
 else
@@ -70,11 +164,13 @@ glib_sources = [
 'gstrfuncs.c',
 'gstring.c',
 'gstringchunk.c',
+'gtester.c',
 'gtestutils.c',
 'gthread.c',
 'gthreadpool.c',
 'gtimer.c',
 'gtimezone.c',
+'gtranslit.c',
 'gtrashstack.c',
 'gtree.c',
 'guniprop.c',
@@ -96,11 +192,17 @@ glib_sources = [
 
 extra_src = ['gspawn.c', 'giounix.c']
 
+#'gspawn-win32.c', # FIXME
+#'gspawn-win32-helper.c', # FIXME
+
 libglib = shared_library('glib',
 sources : [deprecated_sources, glib_sources, thread_src, plat_src, extra_src],
 version : glib_version,
 soversion : interface_version,
-include_dirs : inc_dirs,
+install : true,
+include_directories : inc_dirs,
 link_with : charset_lib,
-deps : [pcre, thread_lib],
+dependencies : [ pcre, thread_dep, libiconv, librt ],
 c_args : ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION', '-DPCRE_STATIC'])
+
+subdir('tests')
diff --git a/glib/tests/Makefile.am b/glib/tests/Makefile.am
index 43b11f0..1adc50d 100644
--- a/glib/tests/Makefile.am
+++ b/glib/tests/Makefile.am
@@ -180,6 +180,7 @@ atomic_CFLAGS += -Wstrict-aliasing=2
 endif
 
 overflow_fallback_SOURCES = overflow.c
+# FIXME: FLAGS?
 overflow_fallback_FALGS = $(AM_CFLAGS) -D_GLIB_TEST_OVERFLOW_FALLBACK
 
 test_programs += 642026-ec
diff --git a/glib/tests/meson.build b/glib/tests/meson.build
new file mode 100644
index 0000000..9ef1b3d
--- /dev/null
+++ b/glib/tests/meson.build
@@ -0,0 +1,165 @@
+glib_tests = [
+  'array-test',
+  'asyncqueue',
+  'base64',
+  'bitlock',
+  'bookmarkfile',
+  'bytes',
+  'cache',
+  'checksum',
+  'collate',
+  'cond',
+  'convert',
+  'dataset',
+  'date',
+  'dir',
+  'environment',
+  'error',
+  'fileutils',
+  'gdatetime',
+  'gvariant',
+  'hash',
+  'hmac',
+  'hook',
+  'hostutils',
+  'keyfile',
+  'list',
+  'logging',
+  'mainloop',
+  'mappedfile',
+  'markup',
+  'markup-parse',
+  'markup-collect',
+  'markup-escape',
+  'markup-subparser',
+  'mem-overflow',
+  'mutex',
+  'node',
+  'once',
+  'option-context',
+  'option-argv0',
+  'overflow',
+  'pattern',
+  'private',
+  'protocol',
+  'queue',
+  'rand',
+  'rec-mutex',
+  'regex',
+  'rwlock',
+  'scannerapi',
+  'search-utils',
+  'sequence',
+  'shell',
+  'slice',
+  'slist',
+  'sort',
+  'spawn-multithreaded',
+  'spawn-singlethread',
+  'strfuncs',
+  'string',
+  'testing',
+  'test-printf',
+  'thread',
+  'timeout',
+  'timer',
+  'tree',
+  'utf8-performance',
+  'utf8-pointer',
+  'utf8-validate',
+  'utf8-misc',
+  'utils',
+  'unicode',
+  'uri',
+  '1bit-mutex',
+  '642026',
+]
+
+if host_machine.system() != 'windows'
+  glib_tests += [ 'unix', 'include' ]
+endif
+
+if cc.get_id() == 'gcc'
+  glib_tests += [ 'autoptr' ]
+endif
+
+test_env = [
+  'G_TEST_SRCDIR=' + meson.current_source_dir(),
+  'G_TEST_BUILDDIR=' + meson.current_build_dir(),
+]
+
+foreach test_name : glib_tests
+  deps = [ libm, thread_dep ]
+  if test_name == 'regex'
+    deps += [ pcre ]
+  endif
+  exe = executable(test_name, '@0@.c'.format(test_name),
+      include_directories : inc_dirs,
+      c_args : [ '-DHAVE_CONFIG_H=1', '-DG_LOG_DOMAIN="GLib"' ],
+      link_with : libglib,
+      dependencies : deps,
+      install : false,
+  )
+  test(test_name, exe, env : test_env)
+endforeach
+
+c_args_atomic = [ ]
+if cc.get_id() == 'gcc'
+  c_args_atomic += [ '-Wstrict-aliasing=2' ]
+endif
+
+exe = executable('atomic', 'atomic.c',
+  include_directories : inc_dirs,
+  c_args : [ '-DHAVE_CONFIG_H=1' ] + c_args_atomic,
+  link_with : libglib,
+  dependencies : deps,
+)
+test('atomic', exe, env : test_env)
+
+# FIXME: consolidate all of these into the array
+exe = executable('overflow-fallback', 'overflow.c',
+  include_directories : inc_dirs,
+  c_args : [ '-DHAVE_CONFIG_H=1', '-D_GLIB_TEST_OVERFLOW_FALLBACK' ],
+  link_with : libglib,
+  dependencies : deps,
+  install : false,
+)
+test('overflow-fallback', exe, env : test_env)
+
+exe = executable('642026-ec', '642026.c',
+  include_directories : inc_dirs,
+  c_args : [ '-DHAVE_CONFIG_H=1', '-DG_ERRORCHECK_MUTEXES' ],
+  link_with : libglib,
+  dependencies : deps,
+  install : false,
+)
+test('642026-ec', exe, env : test_env)
+
+exe = executable('1bit-emufutex', '1bit-mutex.c',
+  include_directories : inc_dirs,
+  c_args : [ '-DHAVE_CONFIG_H=1', '-DTEST_EMULATED_FUTEX' ],
+  link_with : libglib,
+  dependencies : deps,
+  install : false,
+)
+test('1bit-emufutex', exe, env : test_env)
+
+if glib_conf.has('HAVE_EVENTFD')
+  exe = executable('gwakeup-fallback', 'gwakeuptest.c', '../gwakeup.c',
+    include_directories : inc_dirs,
+    c_args : [ '-DHAVE_CONFIG_H=1', '-DTEST_EVENTFD_FALLBACK' ],
+    link_with : libglib,
+    dependencies : deps,
+    install : false,
+  )
+  test('gwakeup-fallback', exe, env : test_env)
+endif
+
+# test-spawn-echo helper binary required by the spawn tests
+executable('test-spawn-echo', 'test-spawn-echo.c',
+           include_directories : inc_dirs,
+           c_args : [ '-DHAVE_CONFIG_H=1', '-DG_LOG_DOMAIN="GLib"' ],
+           link_with : libglib,
+           dependencies : deps,
+           install : false,
+)
diff --git a/gmodule/meson.build b/gmodule/meson.build
new file mode 100644
index 0000000..465c4e4
--- /dev/null
+++ b/gmodule/meson.build
@@ -0,0 +1,90 @@
+gmoduleconf_conf = configuration_data()
+
+g_module_need_uscore = 0
+g_module_broken_rtld_global = 0
+g_module_have_dlerror = 0
+
+libdl_dep = [ ]
+g_module_lib_args = [ ]
+g_module_impl = ''
+
+dlopen_dlsym_test_code = '''
+#include <dlfcn.h>
+int glib_underscore_test (void) { return 42; }
+int main (int argc, char ** argv) {
+  void *f1 = (void*)0, *f2 = (void*)0, *handle;
+  handle = dlopen ((void*)0, 0);
+  if (handle) {
+    f1 = dlsym (handle, "glib_underscore_test");
+    f2 = dlsym (handle, "_glib_underscore_test");
+  }
+  return (!f2 || f1);
+}'''
+
+# On Windows force native WIN32 shared lib loader
+if host_machine.system() == 'windows'
+  g_module_impl = 'G_MODULE_IMPL_WIN32'
+# Force native AIX library loader
+# dlopen() filepath must be of the form /path/libname.a(libname.so)
+elif host_machine.system() == 'aix'
+  g_module_impl = 'G_MODULE_IMPL_AR'
+elif cc.links(dlopen_dlsym_test_code, name : 'dlopen() and dlsym() in system libraries')
+  g_module_impl = 'G_MODULE_IMPL_DL'
+# NSLinkModule (dyld) in system libraries (Darwin)
+elif cc.has_function('NSLinkModule', prefix : '#include <mach-o/dyld.h>', name : 'NSLinkModule')
+  g_module_impl = 'G_MODULE_IMPL_DYLD'
+  g_module_need_uscore = 1
+elif cc.links(dlopen_dlsym_test_code, args : '-ldl', name : 'dlopen() and dlsym() in libdl')
+  g_module_impl = 'G_MODULE_IMPL_DL'
+  libdl_dep = find_library('dl')
+  g_module_lib_args = '-ldl'
+endif
+
+# additional checks for G_MODULE_IMPL_DL
+if g_module_impl == 'G_MODULE_IMPL_DL'
+  # FIXME: check for OSF1/5.0 RTLD_GLOBAL brokenness (is this still relevant?)
+
+  # Check whether we need preceding underscores
+  if not meson.is_cross_build()
+    # FIXME: communicate result via stdout instead of return value, so non-0 return is not printed in bold 
red
+    rres = cc.run(dlopen_dlsym_test_code,
+                  args : g_module_lib_args,
+                  name : 'dlsym() preceding underscores')
+    if rres.compiled() and rres.returncode() == 0
+      g_module_need_uscore = 1
+    endif
+  endif
+
+  if cc.has_function('dlerror', prefix : '#include <dlfcn.h>', args : g_module_lib_args, name : 'dlerror')
+    g_module_have_dlerror = 1
+  endif
+endif
+
+# Done, have we got an implementation?
+if g_module_impl == ''
+  g_module_impl = '0'
+  message('WARNING: No suitable GModule implementation found!')
+endif
+
+gmoduleconf_conf.set('G_MODULE_IMPL', g_module_impl)
+gmoduleconf_conf.set('G_MODULE_SUPPORTED', g_module_impl != '0')
+gmoduleconf_conf.set('G_MODULE_HAVE_DLERROR', g_module_have_dlerror)
+gmoduleconf_conf.set('G_MODULE_NEED_USCORE', g_module_need_uscore)
+gmoduleconf_conf.set('G_MODULE_BROKEN_RTLD_GLOBAL', g_module_broken_rtld_global)
+
+gmoduleconf_h = configure_file(input : 'gmoduleconf.h.in',
+                               output : 'gmoduleconf.h',
+                               configuration : gmoduleconf_conf)
+
+install_headers([ 'gmodule.h' ], subdir : 'glib-2.0/')
+
+libgmodule = shared_library('gmodule',
+  sources : [ 'gmodule.c' ],
+  version : glib_version,
+  soversion : interface_version,
+  install : true,
+  include_directories : inc_dirs,
+  link_with : libglib,
+  dependencies : libdl_dep,
+  c_args : ['-DG_LOG_DOMAIN="GModule"', '-DG_DISABLE_DEPRECATED' ],
+)
diff --git a/gobject/meson.build b/gobject/meson.build
new file mode 100644
index 0000000..cdb6443
--- /dev/null
+++ b/gobject/meson.build
@@ -0,0 +1,65 @@
+#FIXME
+#if host_machine.system() == 'windows'
+#  plat_src = []
+#else
+#  plat_src = []
+#endif
+
+gobject_install_headers = [
+  'gobject-autocleanups.h',
+  'glib-types.h',
+  'gbinding.h',
+  'gboxed.h',
+  'gclosure.h',
+  'genums.h',
+  'gmarshal.h',
+  'gobject.h',
+  'gparam.h',
+  'gparamspecs.h',
+  'gsignal.h',
+  'gsourceclosure.h',
+  'gtype.h',
+  'gtypemodule.h',
+  'gtypeplugin.h',
+  'gvalue.h',
+  'gvaluearray.h',
+  'gvaluecollector.h',
+  'gvaluetypes.h',
+  'gobjectnotifyqueue.c', # sic
+]
+install_headers(gobject_install_headers, subdir : 'glib-2.0/gobject/')
+
+gobject_c_sources = [
+#  'gobject_probes.d',
+  'gatomicarray.c',
+  'gbinding.c',
+  'gboxed.c',
+  'gclosure.c',
+  'genums.c',
+  'gmarshal.c',
+  'gobject.c',
+  'gobject_trace.h',
+  'gparam.c',
+  'gparamspecs.c',
+  'gsignal.c',
+  'gsourceclosure.c',
+  'gtype.c',
+  'gtypemodule.c',
+  'gtypeplugin.c',
+  'gvalue.c',
+  'gvaluearray.c',
+  'gvaluetransform.c',
+  'gvaluetypes.c',
+]
+
+libgobject = shared_library('gobject',
+sources : [ gobject_c_sources ],
+version : glib_version,
+soversion : interface_version,
+install : true,
+include_directories : inc_dirs,
+link_with : libglib,
+dependencies : libffi_dep,
+c_args : ['-DG_LOG_DOMAIN="GLib-GObject"', '-DGOBJECT_COMPILATION' ])
+
+subdir('tests')
diff --git a/gobject/tests/gobject_test_marshal.py b/gobject/tests/gobject_test_marshal.py
new file mode 100755
index 0000000..a0f6852
--- /dev/null
+++ b/gobject/tests/gobject_test_marshal.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+
+# FIXME: where does the #include "marshalers.h" go?
+
+import sys, subprocess
+
+assert(len(sys.argv) == 3)
+
+_, listname, outname = sys.argv
+
+if outname.endswith('.h'):
+    arg = '--header'
+else:
+    arg = '--body'
+
+output = subprocess.check_output(['glib-genmarshal', '--prefix=test', '--valist-marshallers', arg, listname])
+open(outname, 'wb').write(output)
diff --git a/gobject/tests/meson.build b/gobject/tests/meson.build
new file mode 100644
index 0000000..21aefd9
--- /dev/null
+++ b/gobject/tests/meson.build
@@ -0,0 +1,69 @@
+gobject_tests = [
+  'qdata',
+  'boxed',
+  'enums',
+  'param',
+  'threadtests',
+  'dynamictests',
+  'binding',
+  'properties',
+  'reference',
+  'value',
+  'type',
+  'private',
+  'closure',
+  'object',
+  'signal-handler',
+  'ifaceproperties',
+]
+
+test_env = [
+  'G_TEST_SRCDIR=' + meson.current_source_dir(),
+  'G_TEST_BUILDDIR=' + meson.current_build_dir(),
+]
+
+foreach test_name : gobject_tests
+  deps = [ libm, thread_dep ]
+  test_src = '@0@.c'.format(test_name)
+  # private is an existing or reserved target it seems
+  if test_name == 'private'
+    test_name = 'gobject-private'
+  endif
+  exe = executable(test_name, test_src,
+      include_directories : inc_dirs,
+      c_args : [ '-DHAVE_CONFIG_H=1', '-DG_LOG_DOMAIN="GLib-GObject"' ],
+      link_with : [ libglib, libgobject ],
+      dependencies : deps,
+  )
+  test(test_name, exe, env : test_env)
+endforeach
+
+# The marshalers test requires running a binary, so we cannot build it when
+# cross-compiling
+if not meson.is_cross_build()
+  # FIXME: need to pass this as argument to the genmarshal script
+  # and somehow we need to specify it as build dep of the custom targets
+  # lib_genmarshal = meson.build_root() + '/gobject/glib-genmarshal'
+
+  genmarshal = find_program('gobject_test_marshal.py')
+
+  marshalers_h = custom_target('marshalers_h',
+    output : 'marshalers.h',
+    input : 'marshalers.list',
+    command : [ genmarshal, '@INPUT@', '@OUTPUT@' ],
+  )
+  marshalers_c = custom_target('marshalers_c',
+    output : 'marshalers.c',
+    input : 'marshalers.list',
+    command : [ genmarshal, '@INPUT@', '@OUTPUT@' ],
+  )
+
+  exe = executable('signals',
+      'signals.c', marshalers_h, marshalers_c,
+      include_directories : inc_dirs,
+      c_args : [ '-DHAVE_CONFIG_H=1', '-DG_LOG_DOMAIN="GLib-GObject"' ],
+      link_with : [ libglib, libgobject ],
+      dependencies : deps,
+  )
+  test('signals', exe, env : test_env)
+endif
diff --git a/gthread/meson.build b/gthread/meson.build
new file mode 100644
index 0000000..a12c420
--- /dev/null
+++ b/gthread/meson.build
@@ -0,0 +1,11 @@
+# Just a skeleton lib for backwards compatibility since all the functionaliy
+# has been moved into glib now
+libgthread = shared_library('gthread',
+  sources : [ 'gthread-impl.c' ],
+  version : glib_version,
+  soversion : interface_version,
+  install : true,
+  include_directories : inc_dirs,
+  link_with : libglib,
+  c_args : ['-DG_LOG_DOMAIN="GThread"' ],
+)
diff --git a/meson.build b/meson.build
index e983bd9..19092a4 100644
--- a/meson.build
+++ b/meson.build
@@ -1,246 +1,747 @@
-project('glib', 'c')
+project('glib', 'c', 'cpp',
+  version : '2.47.6',
+  meson_version : '>= 0.30.0',
+  default_options : [ 'warning_level=1',
+                      'c_std=gnu99',
+                      'buildtype=debugoptimized' ])
 
 cc = meson.get_compiler('c')
+cxx = meson.get_compiler('cpp')
 
-major_version = 3
-minor_version = 36
-micro_version = 3
-interface_version = 3
+add_global_arguments('-Werror', language : 'c') # FIXME
 
-glib_version = '3.36.3'
-inc_dirs = include_directories('.', 'glib', 'gmodule')
+major_version = 2
+minor_version = 47
+micro_version = 6
+interface_version = 2 # FIXME
+
+glib_version = meson.project_version()
+inc_dirs = include_directories('.', 'glib', 'gmodule', 'gio')
 
 glib_conf = configuration_data()
 glibconfig_conf = configuration_data()
 
+# accumulated list of defines as we check for them, so we can easily
+# use them later in test programs (autoconf does this automatically)
+glib_conf_prefix = ''
+
 glib_conf.set('GLIB_MAJOR_VERSION', major_version)
 glib_conf.set('GLIB_MINOR_VERSION', minor_version)
 glib_conf.set('GLIB_MICRO_VERSION', micro_version)
 glib_conf.set('GLIB_INTERFACE_AGE', micro_version)
-glib_conf.set('GLIB_BINARY_AGE', 363)
+glib_conf.set('GLIB_BINARY_AGE', major_version * 100 + minor_version * 10 + micro_version)
 glib_conf.set('GETTEXT_PACKAGE', '"glib20"')
+glib_conf.set('PACKAGE_BUGREPORT', '"http://bugzilla.gnome.org/enter_bug.cgi?product=glib";')
+glib_conf.set('PACKAGE_NAME', '"glib"')
+glib_conf.set('PACKAGE_STRING', '"glib @0@"'.format(meson.project_version()))
+glib_conf.set('PACKAGE_TARNAME', '"glib"')
+glib_conf.set('PACKAGE_URL', '""')
+glib_conf.set('PACKAGE_VERSION', '"@0@"'.format(meson.project_version()))
 glib_conf.set('ENABLE_NLS', 1)
-glib_conf.set('HAVE_VASPRINTF', 1)
-glib_conf.set('HAVE_VPRINTF', 1)
-glib_conf.set('HAVE_GOOD_PRINTF', 1)
+glib_conf.set('HAVE_GOOD_PRINTF', 1) # FIXME
+
+glib_conf.set('_GNU_SOURCE', 1)
 
 if run_command('xgettext', '--help').returncode() != 0
   error('GNU Gettext required currently.')
 endif
 glib_conf.set('HAVE_GETTEXT', 1)
-glib_conf.set('GLIB_LOCALE_DIR', '"share/locale"')
+glib_conf.set('GLIB_LOCALE_DIR', '"@0@/share/locale"'.format(get_option('prefix')))
 
-if cc.has_header('locale.h')
-  glib_conf.set('HAVE_LOCALE_H', 1)
-  lc_msg_test = '''#include<locale.h>
-void foo() { LC_MESSAGES; }
-'''
-  if cc.compiles(lc_msg_test)
-    glib_conf.set('HAVE_LC_MESSAGES', 1)
-  endif
-endif
-if cc.has_header('xlocale.h')
-  glib_conf.set('HAVE_XLOCALE_H', 1)
-endif
-
-if host.name() == 'windows'
+# FIXME: what about Cygwin (G_WITH_CYGWIN)
+if host_machine.system() == 'windows'
   glib_os = '''#define G_OS_WIN32
-#define G_PLATFORM_WIN32'''
+               #define G_PLATFORM_WIN32'''
 else
   glib_os = '#define G_OS_UNIX'
 endif
 glibconfig_conf.set('glib_os', glib_os)
 
-glib_conf.set('HAVE_STDIO_H', 1)
-glib_conf.set('HAVE_STDDEF_H', 1)
-if cc.has_header('dirent.h')
-  glib_conf.set('HAVE_DIRENT_H', 1)
+# check for header files
+
+include_sys_param_h_if_available = '''
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif'''
+
+headers = [
+  [ 'stdlib.h', 'HAVE_STDLIB_H' ],
+  [ 'string.h', 'HAVE_STRING_H' ],
+  [ 'strings.h', 'HAVE_STRINGS_H' ],
+  [ 'memory.h', 'HAVE_MEMORY_H' ],
+  [ 'alloca.h', 'HAVE_ALLOCA_H' ],
+  [ 'locale.h', 'HAVE_LOCALE_H' ],
+  [ 'xlocale.h', 'HAVE_XLOCALE_H' ],
+  [ 'float.h', 'HAVE_FLOAT_H' ],
+  [ 'limits.h', 'HAVE_LIMITS_H' ],
+  [ 'pwd.h', 'HAVE_PWD_H' ],
+  [ 'grp.h', 'HAVE_GRP_H' ],
+  [ 'poll.h', 'HAVE_POLL_H' ],
+  [ 'sys/param.h', 'HAVE_SYS_PARAM_H' ],
+  [ 'sys/resource.h', 'HAVE_SYS_RESOURCE_H' ],
+  [ 'mach/mach_time.h', 'HAVE_MACH_MACH_TIME_H' ],
+  [ 'sys/select.h', 'HAVE_SYS_SELECT_H' ],
+  [ 'stdint.h', 'HAVE_STDINT_H' ],
+  [ 'inttypes.h', 'HAVE_INTTYPES_H' ],
+  [ 'sched.h', 'HAVE_SCHED_H' ],
+  [ 'malloc.h', 'HAVE_MALLOC_H' ],
+  [ 'sys/vfs.h', 'HAVE_SYS_VFS_H' ],
+  [ 'sys/vmount.h', 'HAVE_SYS_VMOUNT_H' ],
+  [ 'sys/statfs.h', 'HAVE_SYS_STATFS_H' ],
+  [ 'sys/statvfs.h', 'HAVE_SYS_STATVFS_H' ],
+  [ 'sys/filio.h', 'HAVE_SYS_FILIO_H' ],
+  [ 'mntent.h', 'HAVE_MNTENT_H' ],
+  [ 'sys/mnttab.h', 'HAVE_SYS_MNTTAB_H' ],
+  [ 'sys/vfstab.h', 'HAVE_SYS_VFSTAB_H' ],
+  [ 'sys/mntctl.h', 'HAVE_SYS_mntctl_H' ],
+  [ 'fstab.h', 'HAVE_FSTAB_H' ],
+  [ 'linux/magic.h', 'HAVE_LINUX_MAGIC_H' ],
+  [ 'sys/prctl.h', 'HAVE_SYS_PRCTL_H' ],
+  [ 'dirent.h', 'HAVE_DIRENT_H' ], # Some versions of MSC lack these
+  [ 'sys/time.h', 'HAVE_SYS_TIME_H' ], # Some versions of MSC lack these
+  [ 'sys/times.h', 'HAVE_SYS_TIMES_H' ],
+  [ 'sys/wait.h', 'HAVE_SYS_WAIT_H' ],
+  [ 'unistd.h', 'HAVE_UNISTD_H' ],
+  [ 'values.h', 'HAVE_VALUES_H' ],
+  [ 'sys/types.h', 'HAVE_SYS_TYPES_H' ],
+  [ 'sys/uio.h', 'HAVE_SYS_UIO_H' ],
+  [ 'sys/mkdev.h', 'HAVE_SYS_MKDEV_H' ],
+  [ 'sys/mount.h', 'HAVE_SYS_MOUNT_H', include_sys_param_h_if_available ],
+  [ 'sys/sysctl.h', 'HAVE_SYS_SYSCTL_H', include_sys_param_h_if_available ],
+  [ 'crt_externs.h', 'HAVE_CRT_EXTERNS_H' ],
+  [ 'linux/netlink.h', 'HAVE_NETLINK', '#include <sys/socket.h>' ],
+  [ 'sys/inotify.h', 'HAVE_SYS_INOTIFY_H' ],
+  [ 'sys/event.h', 'HAVE_SYS_EVENT_H' ],
+]
+
+foreach h : headers
+  header_check_prefix = glib_conf_prefix
+  if h.length() == 3
+    header_check_prefix = header_check_prefix + h[2]
+  endif
+  if cc.has_header(h[0], prefix: header_check_prefix)
+    glib_conf.set(h[1], 1)
+    glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(h[1])
+  endif
+endforeach
+
+if glib_conf.has('HAVE_LOCALE_H')
+  if cc.compiles('''#include <locale.h>
+                    void foo() { LC_MESSAGES; }''')
+    glib_conf.set('HAVE_LC_MESSAGES', 1)
+  endif
 endif
-if cc.has_header('float.h')
-  glib_conf.set('HAVE_FLOAT_H', 1)
+
+struct_stat_blkprefix = '''
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_SYS_STATFS_H
+#include <sys/statfs.h>
+#endif
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#ifdef HAVE_SYS_MOUNT_H
+#include <sys/mount.h>
+#endif
+'''
+
+struct_members = [
+  [ 'stat', 'st_mtimensec', 'HAVE_STRUCT_STAT_ST_MTIMENSEC' ],
+  [ 'stat', 'st_mtim.tv_nsec', 'HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC' ],
+  [ 'stat', 'st_atimensec', 'HAVE_STRUCT_STAT_ST_ATIMENSEC' ],
+  [ 'stat', 'st_atim.tv_nsec', 'HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC' ],
+  [ 'stat', 'st_ctimensec', 'HAVE_STRUCT_STAT_ST_CTIMENSEC' ],
+  [ 'stat', 'st_ctim.tv_nsec', 'HAVE_STRUCT_STAT_ST_CTIM_TV_NSEC' ],
+  [ 'stat', 'st_birthtime', 'HAVE_STRUCT_STAT_ST_BIRTHTIME' ],
+  [ 'stat', 'st_birthtimensec', 'HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC' ],
+  [ 'stat', 'st_birthtim', 'HAVE_STRUCT_STAT_ST_BIRTHTIM' ],
+  [ 'stat', 'st_birthtim.tv_nsec', 'HAVE_STRUCT_STAT_ST_BIRTHTIME_TV_NSEC' ],
+  [ 'stat', 'st_blksize', 'HAVE_STRUCT_STAT_ST_BLKSIZE', struct_stat_blkprefix ],
+  [ 'stat', 'st_blocks', 'HAVE_STRUCT_STAT_ST_BLOCKS', struct_stat_blkprefix ],
+  [ 'statfs', 'f_fstypename', 'HAVE_STRUCT_STATFS_F_FSTYPENAME', struct_stat_blkprefix ],
+  [ 'statfs', 'f_bavail', 'HAVE_STRUCT_STATFS_F_BAVAIL', struct_stat_blkprefix ],
+  [ 'dirent', 'd_type', 'HAVE_STRUCT_DIRENT_D_TYPE', '''#include <sys/types.h>
+                                                        #include <dirent.h>''' ],
+]
+
+foreach m : struct_members
+  header_check_prefix = glib_conf_prefix
+  if m.length() == 4
+    header_check_prefix = header_check_prefix + m[3]
+  else
+    header_check_prefix = header_check_prefix + '#include <sys/stat.h>'
+  endif
+  if cc.has_member('struct ' + m[0], m[1], prefix : header_check_prefix)
+    glib_conf.set(m[2], 1)
+    glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(m[2])
+  else
+  endif
+endforeach
+
+#FIXME: maybe we should add available includes all to the glib_conf_prefix list
+# functions
+functions = [
+  [ 'alloca', 'HAVE_ALLOCA', '#include <alloca.h>' ],
+  [ 'mmap', 'HAVE_MMAP', '#include <sys/mman.h>' ],
+  [ 'posix_memalign', 'HAVE_POSIX_MEMALIGN', '#include <stdlib.h>' ],
+  [ 'memalign', 'HAVE_MEMALIGN', '#include <malloc.h>' ],
+  [ 'valloc', 'HAVE_VALLOC', '#include <stdlib.h>' ],
+  [ 'fsync', 'HAVE_FSYNC', '''#ifdef HAVE_UNISTD_H
+                              #include <unistd.h>
+                              #endif''' ],
+  [ 'pipe2', 'HAVE_PIPE2', '''#define _GNU_SOURCE
+                              #include <fcntl.h>
+                              #include <unistd.h>''' ],
+  [ 'issetugid', 'HAVE_ISSETUGID', '#include <unistd.h>' ],
+  [ 'timegm', 'HAVE_TIMEGM', '#include <time.h>' ],
+  [ 'gmtime_r', 'HAVE_GMTIME_R', '#include <time.h>' ],
+  [ 'strerror_r', 'HAVE_STRERROR_R', '#include <string.h>' ],
+  [ 'lstat', 'HAVE_LSTAT', '''#include <sys/types.h>
+                              #include <sys/stat.h>
+                              #include <unistd.h>'''],
+  [ 'strsignal', 'HAVE_STRSIGNAL', '#include <string.h>' ],
+  [ 'vsnprintf', 'HAVE_VSNPRINTF', '#include <stdio.h>' ],
+  [ 'stpcpy', 'HAVE_STPCPY', '#include <string.h>' ],
+  [ 'strcasecmp', 'HAVE_STRCASECMP', '#include <strings.h>' ],
+  [ 'strncasecmp', 'HAVE_STRNCASECMP', '#include <strings.h>' ],
+  [ 'poll', 'HAVE_POLL', '#include <poll.h>' ],
+  [ 'vasprintf', 'HAVE_VASPRINTF', '''#define _GNU_SOURCE
+                                      #include <stdio.h>''' ],
+  [ 'setenv', 'HAVE_SETENV', '#include <stdlib.h>' ],
+  [ 'unsetenv', 'HAVE_UNSETENV', '#include <stdlib.h>' ],
+  [ 'getc_unlocked', 'HAVE_GETC_UNLOCKED', '#include <stdio.h>' ],
+  [ 'readlink', 'HAVE_READLINK', '#include <unistd.h>' ],
+  [ 'symlink', 'HAVE_SYMLINK', '#include <unistd.h>' ],
+  [ 'fdwalk', 'HAVE_FDWALK', '#include <stdlib.h>' ],
+  [ 'memmem', 'HAVE_MEMMEM', '''#define _GNU_SOURCE
+                                #include <string.h>''' ],
+# FIXME: this check doesn't work right, meson detects that it exists even if it's unusable
+#  [ 'lchmod', 'HAVE_LCHMOD', '''#include <sys/stat.h>
+#                                #include <unistd.h>''' ],
+  [ 'lchown', 'HAVE_LCHOWN', '#include <unistd.h>' ],
+  [ 'fchmod', 'HAVE_FCHMOD', '#include <sys/stat.h>' ],
+  [ 'fchown', 'HAVE_FCHOWN', '#include <unistd.h>' ],
+  [ 'utimes', 'HAVE_UTIMES', '#include <sys/time.h>' ],
+  [ 'getresuid', 'HAVE_GETRESUID', '''#define _GNU_SOURCE
+                                      #include <unistd.h>''' ],
+  [ 'getmntent_r', 'HAVE_GETMNTENT_R', '''#include <stdio.h>
+                                          #include <mntent.h>'''],
+  [ 'setmntent', 'HAVE_SETMNTENT', '''#include <stdio.h>
+                                      #include <mntent.h>'''],
+  [ 'endmntent', 'HAVE_ENDMNTENT', '''#include <stdio.h>
+                                      #include <mntent.h>'''],
+  [ 'hasmntopt', 'HAVE_HASMNTOPT', '''#include <stdio.h>
+                                      #include <mntent.h>'''],
+  [ 'getfsstat', 'HAVE_GETFSSTAT', '''#include <sys/param.h>
+                                      #include <sys/ucred.h>
+                                      #include <sys/mount.h''' ],
+  [ 'getvfsstat', 'HAVE_GETVFSSTAT', '''#include <sys/types.h>
+                                        #include <sys/statvfs.h>''' ],
+  [ 'fallocate', 'HAVE_FALLOCATE', '''#define _GNU_SOURCE
+                                      #include <fcntl.h>''' ],
+  [ 'localtime_r', 'HAVE_LOCALTIME_R', '#include <time.h>' ],
+  [ 'gmtime_r', 'HAVE_GMTIME_R', '#include <time.h>' ],
+  [ 'getpwuid_r', 'HAVE_GETPWUID_R', '''#include <sys/types.h>
+                                        #include <pwd.h>''' ],
+  [ 'getgrgid_r', 'HAVE_GETGRGID_R', '''#include <sys/types.h>
+                                        #include <grp.h>''' ],
+  [ 'prlimit', 'HAVE_PRLIMIT', '''#define _GNU_SOURCE
+                                  #include <sys/time.h>
+                                  #include <sys/resource.h>''' ],
+  [ 'snprintf', 'HAVE_SNPRINTF', '#include <stdio.h>' ],
+  [ 'strnlen', 'HAVE_STRNLEN', '#include <string.h>' ],
+  [ 'wcslen', 'HAVE_WCSLEN', '#include <wchar.h>' ],
+  [ 'wcsnlen', 'HAVE_WCSNLEN', '#include <wchar.h>' ],
+  [ 'mbrtowc', 'HAVE_MBRTOWC', '#include <wchar.h>' ],
+  [ 'wcrtomb', 'HAVE_WCRTOMB', '#include <wchar.h>' ],
+  [ 'newlocale', 'HAVE_NEWLOCALE', '#include <locale.h>' ],
+  [ 'uselocale', 'HAVE_USELOCALE', '#include <locale.h>' ],
+  [ 'strtod_l', 'HAVE_STRTOD_L', '''#define _GNU_SOURCE
+                                    #include <stdlib.h>
+                                    #ifdef HAVE_XLOCALE_H
+                                    #include <xlocale.h>
+                                    #endif''' ],
+  [ 'strtoll_l', 'HAVE_STRTOLL_L', '''#define _GNU_SOURCE
+                                      #include <stdlib.h>
+                                      #include <limits.h>
+                                      #ifdef HAVE_XLOCALE_H
+                                      #include <xlocale.h>
+                                      #endif''' ],
+  [ 'strtoull_l', 'HAVE_STRTOULL_L', '''#define _GNU_SOURCE
+                                        #include <stdlib.h>
+                                        #include <limits.h>
+                                        #ifdef HAVE_XLOCALE_H
+                                        #include <xlocale.h>
+                                        #endif''' ],
+  [ 'inotify_init1', 'HAVE_INOTIFY_INIT1', '#include <sys/inotify.h>' ],
+  [ 'kqueue', 'HAVE_KQUEUE', '#include <sys/event.h>' ],
+  [ 'kevent', 'HAVE_KEVENT', '#include <sys/event.h>' ],
+  [ 'getservent', 'HAVE_GETSERVENT', '#include <netdb.h>' ],
+  [ 'getprotobyname_r', 'HAVE_GETPROTOBYNAME_R', '#include <netdb.h>' ],
+  [ 'if_indextoname', 'HAVE_IF_INDEXTONAME', '#include <net/if.h>' ],
+  [ 'if_nametoindex', 'HAVE_IF_NAMETOINDEX', '#include <net/if.h>' ],
+  [ 'sendmmsg', 'HAVE_SENDMMSG', '''#define _GNU_SOURCE
+                                    #include <sys/socket.h>''' ],
+  [ 'recvmmsg', 'HAVE_RECVMMSG', '''#define _GNU_SOURCE
+                                    #include <sys/socket.h>''' ],
+]
+
+if glib_conf.has('HAVE_SYS_STATVFS_H')
+  functions += [ [ 'statvfs', 'HAVE_STATVFS', '#include <sys/statvfs.h>'] ]
 endif
-if cc.has_header('limits.h')
-  glib_conf.set('HAVE_LIMITS_H', 1)
+if glib_conf.has('HAVE_SYS_STATFS_H') or glib_conf.has('HAVE_SYS_MOUNT_H')
+  functions += [ [ 'statfs', 'HAVE_STATFS', '''#ifdef HAVE_SYS_STATFS_H
+                                               #include <sys/statfs.h>
+                                               #endif
+                                               #ifdef HAVE_SYS_MOUNT_H
+                                               #include <sys/mount.h>
+                                               #endif'''] ]
 endif
-if cc.has_header('pwd.h')
-  glib_conf.set('HAVE_PWD_H', 1)
+
+# AIX splice is something else
+if host_machine.system() != 'aix'
+  functions += [
+    [ 'splice', 'HAVE_SPLICE', '''#define _GNU_SOURCE
+                                  #include <fcntl.h>''' ]
+  ]
 endif
-if cc.has_header('grp.h')
-  glib_conf.set('HAVE_GRP_H', 1)
+
+foreach f : functions
+  header_check_prefix = glib_conf_prefix
+  if f.length() == 3
+    header_check_prefix = header_check_prefix + f[2]
+  endif
+  if cc.has_function (f[0], prefix : header_check_prefix)
+    glib_conf.set(f[1], 1)
+    glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(f[1])
+    set_variable('have_func_' + f[0], true)
+  else
+    set_variable('have_func_' + f[0], false)
+  endif
+endforeach
+
+# Check whether to use statfs or statvfs
+# Some systems have both statfs and statvfs, pick the most "native" for these
+if have_func_statfs and have_func_statvfs
+  # on solaris and irix, statfs doesn't even have the f_bavail field
+  if not glib_conf.has('HAVE_STRUCT_STATFS_F_BAVAIL')
+    have_func_statfs = false
+  else
+    # at least on linux, statfs is the actual syscall
+    have_func_statvfs = false
+  endif
 endif
-if cc.has_header('sys/param.h')
-  glib_conf.set('HAVE_SYS_PARAM_H', 1)
-  sysparam_include = '#include<sys/param.h>'
+if have_func_statfs
+  glib_conf.set('USE_STATFS', 1)
+  stat_func_to_use = 'statfs'
+elif have_func_statvfs
+  glib_conf.set('USE_STATVFS', 1)
+  stat_func_to_use = 'statvfs'
 else
-  sysparam_include = ''
+  stat_func_to_use = 'neither'
 endif
-if cc.has_header('poll.h')
-  glib_conf.set('HAVE_POLL_H', 1)
+message('Checking whether to use statfs or statvfs .. ' + stat_func_to_use)
+
+# Mac OS X Carbon support
+glib_have_carbon = cc.compiles('''#include <Carbon/Carbon.h>
+                                  #include <CoreServices/CoreServices.h>''',
+                               name : 'Mac OS X Carbon support')
+
+if glib_have_carbon
+  glib_conf.set('HAVE_CARBON', true)
+  CARBON_LIBS='-Wl,-framework,Carbon' # FIXME: propagate to .pc files as well
+else
+  CARBON_LIBS=''
 endif
-if cc.has_header('sys/resource.h')
-  glib_conf.set('HAVE_SYS_RESOURCE_H', 1)
+
+# Check for nl_langinfo and CODESET
+if cc.links('''#include <langinfo.h>
+               int main (int argc, char ** argv) {
+                 char *codeset = nl_langinfo (CODESET);
+                 return 0;
+               }''', name : 'nl_langinfo and CODESET')
+  glib_conf.set('HAVE_LANGINFO_CODESET', 1)
 endif
 
-if cc.has_header('sys/time.h')
-  glib_conf.set('HAVE_SYS_TIME_H', 1)
+# Check for futex(2)
+if cc.links('''#include <linux/futex.h>
+               #include <sys/syscall.h>
+               #include <unistd.h>
+               int main (int argc, char ** argv) {
+                 syscall (__NR_futex, NULL, FUTEX_WAKE, FUTEX_WAIT);
+                 return 0;
+               }''', name : 'futex(2) system call')
+  glib_conf.set('HAVE_FUTEX', 1)
 endif
-if cc.has_header('sys/times.h')
-  glib_conf.set('HAVE_SYS_TIMES_H', 1)
+
+# Check for eventfd(2)
+if cc.links('''#include <sys/eventfd.h>
+               #include <unistd.h>
+               int main (int argc, char ** argv) {
+                 eventfd (0, EFD_CLOEXEC);
+                 return 0;
+               }''', name : 'eventfd(2) system call')
+  glib_conf.set('HAVE_EVENTFD', 1)
 endif
-if cc.has_header('sys/wait.h')
-  glib_conf.set('HAVE_SYS_WAIT_H', 1)
+
+clock_gettime_test_code = '''
+  #include <time.h>
+  struct timespec t;
+  int main (int argc, char ** argv) {
+    return clock_gettime(CLOCK_REALTIME, &t);
+  }'''
+# FIXME: or will librt be in the meson threads dep already?
+librt = [ ]
+if cc.links(clock_gettime_test_code, name : 'clock_gettime')
+  glib_conf.set('HAVE_CLOCK_GETTIME', 1)
+elif cc.links(clock_gettime_test_code, args : '-lrt', name : 'clock_gettime in librt')
+  glib_conf.set('HAVE_CLOCK_GETTIME', 1)
+  librt = find_library('rt')
 endif
-if cc.has_header('unistd.h')
-  glib_conf.set('HAVE_UNISTD_H', 1)
+
+# if statfs() takes 2 arguments (Posix) or 4 (Solaris)
+if have_func_statfs
+  if cc.compiles(glib_conf_prefix + '''
+                 #include <unistd.h>
+                        #ifdef HAVE_SYS_PARAM_H
+                        #include <sys/param.h>
+                        #endif
+                        #ifdef HAVE_SYS_VFS_H
+                        #include <sys/vfs.h>
+                        #endif
+                        #ifdef HAVE_SYS_MOUNT_H
+                        #include <sys/mount.h>
+                        #endif
+                        #ifdef HAVE_SYS_STATFS_H
+                        #include <sys/statfs.h>
+                        #endif
+                        void some_func (void) {
+                          struct statfs st;
+                          statfs(NULL, &st);
+                        }''', name : 'number of arguments to statfs() (n=2)')
+    glib_conf.set('STATFS_ARGS', 2)
+  elif cc.compiles(glib_conf_prefix + '''
+                   #include <unistd.h>
+                          #ifdef HAVE_SYS_PARAM_H
+                          #include <sys/param.h>
+                          #endif
+                          #ifdef HAVE_SYS_VFS_H
+                          #include <sys/vfs.h>
+                          #endif
+                          #ifdef HAVE_SYS_MOUNT_H
+                          #include <sys/mount.h>
+                          #endif
+                          #ifdef HAVE_SYS_STATFS_H
+                          #include <sys/statfs.h>
+                          #endif
+                          void some_func (void) {
+                            struct statfs st;
+                            statfs(NULL, &st, sizeof (st), 0);
+                          }''', name : 'number of arguments to statfs() (n=4)')
+    glib_conf.set('STATFS_ARGS', 4)
+  else
+    error('Unable to determine number of arguments to statfs()')
+  endif
 endif
-if cc.has_header('values.h')
-  glib_conf.set('HAVE_VALUES_H', 1)
+
+# open takes O_DIRECTORY as an option
+#AC_MSG_CHECKING([])
+if cc.compiles('''#include <fcntl.h>
+                  #include <sys/types.h>
+                  #include <sys/stat.h>],
+                  void some_func (void) {
+                    open(0, O_DIRECTORY, 0);
+                  }''', name : 'open() option O_DIRECTORY')
+  glib_conf.set('HAVE_OPEN_O_DIRECTORY', 1)
 endif
 
+# Check whether there is a vsnprintf() function with C99 semantics installed.
+# AC_FUNC_VSNPRINTF_C99
+# Check whether there is a snprintf() function with C99 semantics installed.
+# AC_FUNC_SNPRINTF_C99
+if host_machine.system() == 'windows' and cc.get_id() == 'gcc' # FIXME: is it mingw on windows?
+  # Unfortunately the mingw implementations of C99-style snprintf and vsnprintf
+  # don't seem to be quite good enough, at least not in mingw-runtime-3.14.
+  # (Sorry, I don't know exactly what is the problem, but it is related to
+  # floating point formatting and decimal point vs. comma.)
+  # The simple tests in AC_FUNC_VSNPRINTF_C99 and AC_FUNC_SNPRINTF_C99 aren't
+  # rigorous enough to notice, though.
+  glib_conf.set('HAVE_C99_SNPRINTF', false)
+  glib_conf.set('HAVE_C99_VSNPRINTF', false)
+else
+  vsnprintf_c99_test_code = '''
+#include <stdio.h>
+#include <stdarg.h>
 
-if cc.has_header('sys/select.h')
-  glib_conf.set('HAVE_SYS_SELECT_H', 1)
-endif
-if cc.has_header('sys/types.h')
-  glib_conf.set('HAVE_SYS_TYPES_H', 1)
-endif
-if cc.has_header('stdint.h')
-  glib_conf.set('HAVE_STDINT_H', 1)
-endif
-if cc.has_header('inttypes.h')
-  glib_conf.set('HAVE_INTTYPES_H', 1)
-endif
-if cc.has_header('sched.h')
-  glib_conf.set('HAVE_SCHED_H', 1)
-endif
-if cc.has_header('malloc.h')
-  glib_conf.set('HAVE_MALLOC_H', 1)
-endif
+int
+doit(char * s, ...)
+{
+  char buffer[32];
+  va_list args;
+  int r;
 
-if cc.has_header('sys/vfs.h')
-  glib_conf.set('HAVE_SYS_VFS_H', 1)
-endif
-if cc.has_header('sys/vmount.h')
-  glib_conf.set('HAVE_SYS_VMOUNT_H', 1)
-endif
-if cc.has_header('sys/statvfs.h')
-  glib_conf.set('HAVE_SYS_STATVFS_H', 1)
-endif
-if cc.has_header('sys/filio.h')
-  glib_conf.set('HAVE_SYS_FILIO_H', 1)
-endif
+  va_start(args, s);
+  r = vsnprintf(buffer, 5, s, args);
+  va_end(args);
 
-if cc.has_header('mntent.h')
-  glib_conf.set('HAVE_MNTENT_H', 1)
-endif
-if cc.has_header('sys/mnttab.h')
-  glib_conf.set('HAVE_SYS_MNTTAB_H', 1)
-endif
-if cc.has_header('sys/vfstab.h')
-  glib_conf.set('HAVE_SYS_VFSTAB_H', 1)
-endif
-if cc.has_header('sys/mntctl.h')
-  glib_conf.set('HAVE_SYS_mntctl_H', 1)
-endif
-if cc.has_header('fstab.h')
-  glib_conf.set('HAVE_FSTAB_H', 1)
-endif
+  if (r != 7)
+    exit(1);
 
-if cc.has_header('sys/uio.h')
-  glib_conf.set('HAVE_SYS_UIO_H', 1)
-endif
-if cc.has_header('sys/mkdev.h')
-  glib_conf.set('HAVE_SYS_MKDEV_H', 1)
-endif
+  /* AIX 5.1 and Solaris seems to have a half-baked vsnprintf()
+     implementation. The above will return 7 but if you replace
+     the size of the buffer with 0, it borks! */
+  va_start(args, s);
+  r = vsnprintf(buffer, 0, s, args);
+  va_end(args);
+
+  if (r != 7)
+    exit(1);
+
+  exit(0);
+}
+
+int
+main(void)
+{
+  doit("1234567");
+  exit(1);
+}'''
+
+  rres = cc.run(vsnprintf_c99_test_code, name : 'C99 vsnprintf')
+  if rres.compiled() and rres.returncode() == 0
+    glib_conf.set('HAVE_C99_VSNPRINTF', 1)
+  endif
+
+  snprintf_c99_test_code = '''
+#include <stdio.h>
+#include <stdarg.h>
+
+int
+doit()
+{
+  char buffer[32];
+  va_list args;
+  int r;
+
+  r = snprintf(buffer, 5, "1234567");
+
+  if (r != 7)
+    exit(1);
+
+  r = snprintf(buffer, 0, "1234567");
+
+  if (r != 7)
+    exit(1);
+
+  r = snprintf(NULL, 0, "1234567");
+
+  if (r != 7)
+    exit(1);
+
+  exit(0);
+}
 
-if cc.has_header('linux/magic.h')
-  glib_conf.set('HAVE_LINUX_MAGIC_H', 1)
+int
+main(void)
+{
+  doit();
+  exit(1);
+}'''
+
+  rres = cc.run(snprintf_c99_test_code, name : 'C99 snprintf')
+  if rres.compiled() and rres.returncode() == 0
+    glib_conf.set('HAVE_C99_SNPRINTF', 1)
+  endif
 endif
 
-if cc.has_header('sys/prctl.h')
-  glib_conf.set('HAVE_SYS_PRCTL_H', 1)
+if host_machine.system() == 'windows'
+  glib_conf.set('EXEEXT', '".exe"')
+else
+  glib_conf.set('EXEEXT', '""')
 endif
 
-if cc.has_header('sys/mount.h', prefix : sysparam_include)
-  glib_conf.set('HAVE_SYS_MOUNT_H', 1)
+# Check whether the printf() family supports Unix98 %n$ positional parameters
+# AC_FUNC_PRINTF_UNIX98
+printf_unix98_test_code = '''
+#include <stdio.h>
+
+int
+main (void)
+{
+  char buffer[128];
+
+  sprintf (buffer, "%2\$d %3\$d %1\$d", 1, 2, 3);
+  if (strcmp ("2 3 1", buffer) == 0)
+    exit (0);
+  exit (1);
+}'''
+rres = cc.run(printf_unix98_test_code, name : 'printf unix98 position parameters')
+if rres.compiled() and rres.returncode() == 0
+  glib_conf.set('HAVE_UNIX98_PRINTF', 1)
 endif
-if cc.has_header('sys/sysctl.h', prefix : sysparam_include)
-  glib_conf.set('HAVE_SYS_SYSCTL_H', 1)
+
+# Check for nl_langinfo and CODESET
+if cc.links('''#include <langinfo.h>
+               int main (int argc, char ** argv) {
+                 char *codeset = nl_langinfo (CODESET);
+                 return 0;
+               }''', name : 'nl_langinfo (CODESET)')
+  glib_conf.set('HAVE_CODESET', 1)
 endif
 
-if cc.has_header('xlocale.h')
-  glib_conf.set('HAVE_XLOCALE_H', 1)
+# Check for nl_langinfo and LC_TIME parts that are needed in gdatetime.c
+if cc.links('''#include <langinfo.h>
+               int main (int argc, char ** argv) {
+                 char *str;
+                 str = nl_langinfo (PM_STR);
+                 str = nl_langinfo (D_T_FMT);
+                 str = nl_langinfo (D_FMT);
+                 str = nl_langinfo (T_FMT);
+                 str = nl_langinfo (T_FMT_AMPM);
+                 str = nl_langinfo (MON_1);
+                 str = nl_langinfo (ABMON_12);
+                 str = nl_langinfo (DAY_1);
+                 str = nl_langinfo (ABDAY_7);
+                 return 0;
+               }''', name : 'nl_langinfo (PM_STR)')
+  glib_conf.set('HAVE_LANGINFO_TIME', 1)
+endif
+if cc.links('''#include <langinfo.h>
+               int main (int argc, char ** argv) {
+                 char *str;
+                 str = nl_langinfo (_NL_CTYPE_OUTDIGIT0_MB);
+                 str = nl_langinfo (_NL_CTYPE_OUTDIGIT1_MB);
+                 str = nl_langinfo (_NL_CTYPE_OUTDIGIT2_MB);
+                 str = nl_langinfo (_NL_CTYPE_OUTDIGIT3_MB);
+                 str = nl_langinfo (_NL_CTYPE_OUTDIGIT4_MB);
+                 str = nl_langinfo (_NL_CTYPE_OUTDIGIT5_MB);
+                 str = nl_langinfo (_NL_CTYPE_OUTDIGIT6_MB);
+                 str = nl_langinfo (_NL_CTYPE_OUTDIGIT7_MB);
+                 str = nl_langinfo (_NL_CTYPE_OUTDIGIT8_MB);
+                 str = nl_langinfo (_NL_CTYPE_OUTDIGIT9_MB);
+                 return 0;
+               }''', name : 'nl_langinfo (_NL_CTYPE_OUTDIGITn_MB)')
+  glib_conf.set('HAVE_LANGINFO_OUTDIGIT', 1)
 endif
 
-if cc.has_member('struct stat', 'st_mtimensec', prefix : '#include<sys/stat.h>')
-  glib_conf.set('HAVE_STRUCT_STAT_ST_MTIMENSEC', 1)
+# Check if C compiler supports the 'signed' keyword
+if not cc.compiles('''signed char x;''', name : 'signed')
+  glib_conf.set('signed', '/* NOOP */')
 endif
 
-if cc.has_member('struct stat', 'st_mtim.tv_nsec', prefix : '#include<sys/stat.h>')
-  glib_conf.set('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC', 1)
+# Check if the ptrdiff_t type exists
+if cc.compiles('''#include <stddef.h>
+                  ptrdiff_t x;''', name : 'ptrdiff_t')
+  glib_conf.set('HAVE_PTRDIFF_T', 1)
 endif
 
-if cc.has_member('struct stat', 'st_atimensec', prefix : '#include<sys/stat.h>')
-  glib_conf.set('HAVE_STRUCT_STAT_ST_ATIMENSEC', 1)
+# Check for sig_atomic_t type
+if cc.links('''#include <signal.h>
+               #include <sys/types.h>
+               sig_atomic_t val = 42;
+               int main (int argc, char ** argv) {
+                 return val == 42 ? 0 : 1;
+               }''', name : 'sig_atomic_t')
+  glib_conf.set('HAVE_SIG_ATOMIC_T', 1)
 endif
 
-if cc.has_member('struct stat', 'st_atim.tv_nsec', prefix : '#include<sys/stat.h>')
-  glib_conf.set('HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC', 1)
+# Check if 'long long' works.
+# jm_AC_TYPE_LONG_LONG
+if cc.compiles('''long long ll = 1LL;
+                  int i = 63;
+                  int some_func (void) {
+                    long long llmax = (long long) -1;
+                    return ll << i | ll >> i | llmax / ll | llmax % ll;
+                  }''', name : 'long long')
+  glib_conf.set('HAVE_LONG_LONG', 1)
+  have_long_long = true
+else
+  have_long_long = false
 endif
 
-if cc.has_member('struct stat', 'st_ctimensec', prefix : '#include<sys/stat.h>')
-  glib_conf.set('HAVE_STRUCT_STAT_ST_CTIMENSEC', 1)
+# Test whether the compiler supports the 'long double' type.
+if cc.compiles('''/* The Stardent Vistra knows sizeof(long double), but does not support it.  */
+                  long double foo = 0.0;
+                  /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
+                  int array [2*(sizeof(long double) >= sizeof(double)) - 1];''',
+               name : 'long double')
+  glib_conf.set('HAVE_LONG_DOUBLE', 1)
 endif
 
-if cc.has_member('struct stat', 'st_ctim.tv_nsec', prefix : '#include<sys/stat.h>')
-  glib_conf.set('HAVE_STRUCT_STAT_ST_CTIM_TV_NSEC', 1)
+#dnl Test whether <stddef.h> has the 'wchar_t' type.
+if cc.compiles('''#include <stddef.h>
+                  wchar_t foo = (wchar_t)'\0';''',
+               name : 'wchar_t')
+  glib_conf.set('HAVE_WCHAR_T', 1)
 endif
 
-if cc.has_member('struct stat', 'st_ctim.tv_nsec', prefix : '#include<sys/stat.h>')
-  glib_conf.set('HAVE_STRUCT_STAT_ST_CTIM_TV_NSEC', 1)
+# Test whether <wchar.h> has the 'wint_t' type.
+if cc.compiles('''#include <wchar.h>
+                  wint_t foo = (wchar_t)'\0';''',
+               name : 'wint_t')
+  glib_conf.set('HAVE_WINT_T', 1)
 endif
 
-# Fixme, build properly.
-blkprefix = '''#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/statfs.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-'''
+found_uintmax_t = false
 
-if cc.has_member('struct stat', 'blksize', prefix : blkprefix)
-  glib_conf.set('HAVE_STRUCT_STAT_BLKSIZE', 1)
+# Define HAVE_INTTYPES_H_WITH_UINTMAX if <inttypes.h> exists,
+# doesn't clash with <sys/types.h>, and declares uintmax_t.
+# jm_AC_HEADER_INTTYPES_H
+if cc.compiles('''#include <sys/types.h>
+                  #include <inttypes.h>
+                  void some_func (void) {
+                    uintmax_t i = (uintmax_t) -1;
+                  }''', name : 'uintmax_t in inttypes.h')
+  glib_conf.set('HAVE_INTTYPES_H_WITH_UINTMAX', 1)
+  found_uintmax_t = true
 endif
-if cc.has_member('struct stat', 'st_blocks', prefix : blkprefix)
-  glib_conf.set('HAVE_STRUCT_STAT_BLOCKS', 1)
-endif
-if cc.has_member('struct stat', 'f_fstypename', prefix : blkprefix)
-  glib_conf.set('HAVE_STRUCT_STAT_F_FSTYPENAME', 1)
-endif
-if cc.has_member('struct stat', 'f_bavail', prefix : blkprefix)
-  glib_conf.set('HAVE_STRUCT_STAT_F_BAVAIL', 1)
+
+# Define HAVE_STDINT_H_WITH_UINTMAX if <stdint.h> exists,
+# doesn't clash with <sys/types.h>, and declares uintmax_t.
+# jm_AC_HEADER_STDINT_H
+if cc.compiles('''#include <sys/types.h>
+                  #include <stdint.h>
+                  void some_func (void) {
+                    uintmax_t i = (uintmax_t) -1;
+                  }''', name : 'uintmax_t in stdint.h')
+  glib_conf.set('HAVE_STDINT_H_WITH_UINTMAX', 1)
+  found_uintmax_t = true
 endif
 
-if cc.has_header('string.h')
-  glib_conf.set('HAVE_STRING_H', 1)
+# Define intmax_t to 'long' or 'long long'
+# if it is not already defined in <stdint.h> or <inttypes.h>.
+# For simplicity, we assume that a header file defines 'intmax_t' if and
+# only if it defines 'uintmax_t'.
+if found_uintmax_t
+  glib_conf.set('HAVE_INTMAX_T', 1)
+elif have_long_long
+  glib_conf.set('intmax_t', 'long long')
+else
+  glib_conf.set('intmax_t', 'long')
 endif
 
-# Let's configuring love
 char_size = cc.sizeof('char')
 short_size = cc.sizeof('short')
 int_size = cc.sizeof('int')
 voidp_size = cc.sizeof('void*')
 long_size = cc.sizeof('long')
-long_long_size = cc.sizeof('long long')
+if have_long_long
+  long_long_size = cc.sizeof('long long')
+else
+  long_long_size = 0
+endif
 sizet_size = cc.sizeof('size_t')
+ssizet_size = cc.sizeof('ssize_t')
 
 char_align = cc.alignment('char')
 short_align = cc.alignment('short')
 int_align = cc.alignment('int')
 voidp_align = cc.alignment('void*')
 long_align = cc.alignment('long')
-long_long_align = cc.alignment('long long')
 sizet_align = cc.alignment('size_t')
 
 glib_conf.set('ALIGNOF_UNSIGNED_LONG', long_align)
@@ -251,6 +752,7 @@ glib_conf.set('SIZEOF_SHORT', short_size)
 glib_conf.set('SIZEOF_LONG', long_size)
 glib_conf.set('SIZEOF_LONG_LONG', long_long_size)
 glib_conf.set('SIZEOF_SIZE_T', sizet_size)
+glib_conf.set('SIZEOF_SSIZE_T', ssizet_size)
 glib_conf.set('SIZEOF_VOID_P', voidp_size)
 
 if long_size == 2
@@ -337,36 +839,43 @@ glibconfig_conf.set('gint64_constant', gint64_constant)
 glibconfig_conf.set('guint64_constant', guint64_constant)
 glib_conf.set('ALIGNOF_GUINT64', guint64_align)
 
-# Horrible hack.
-glibconfig_conf.set('gintbits', 32)
-
-if host.name() == 'windows'
+if host_machine.system() == 'windows'
   glibconfig_conf.set('g_pid_type', 'void*')
+  if host_machine.cpu_family() == 'x86_64'
+    glibconfig_conf.set('g_pollfd_format', '"%#I64x"')
+  else
+    glibconfig_conf.set('g_pollfd_format', '"%#x"')
+  endif
 else
   glibconfig_conf.set('g_pid_type', 'int')
+  glibconfig_conf.set('g_pollfd_format', '"%d"')
 endif
 
 if sizet_size == short_size
   glibconfig_conf.set('glib_size_type_define', 'short')
   glibconfig_conf.set('gsize_modifier', '"h"')
+  glibconfig_conf.set('gssize_modifier', '"h"')
   glibconfig_conf.set('gsize_format', '"hu"')
   glibconfig_conf.set('gssize_format', '"hi"')
   glibconfig_conf.set('glib_msize_type', 'SHRT')
 elif sizet_size == int_size
   glibconfig_conf.set('glib_size_type_define', 'int')
   glibconfig_conf.set('gsize_modifier', '""')
+  glibconfig_conf.set('gssize_modifier', '""')
   glibconfig_conf.set('gsize_format', '"u"')
   glibconfig_conf.set('gssize_format', '"i"')
   glibconfig_conf.set('glib_msize_type', 'INT')
 elif sizet_size == long_size
   glibconfig_conf.set('glib_size_type_define', 'long')
   glibconfig_conf.set('gsize_modifier', '"l"')
+  glibconfig_conf.set('gssize_modifier', '"l"')
   glibconfig_conf.set('gsize_format', '"lu"')
   glibconfig_conf.set('gssize_format', '"li"')
   glibconfig_conf.set('glib_msize_type', 'LONG')
 elif sizet_size == long_long_size
   glibconfig_conf.set('glib_size_type_define', 'long long')
   glibconfig_conf.set('gsize_modifier', '"I64"')
+  glibconfig_conf.set('gssize_modifier', '"I64"')
   glibconfig_conf.set('gsize_format', '"I64u"')
   glibconfig_conf.set('gssize_format', '"I64i"')
   glibconfig_conf.set('glib_msize_type', 'INT64')
@@ -374,10 +883,63 @@ else
   error('Could not determine size of size_t.')
 endif
 
+if voidp_size == int_size
+  glibconfig_conf.set('glib_intptr_type_define', 'int')
+  glibconfig_conf.set('gintptr_modifier', '""')
+  glibconfig_conf.set('gintptr_format', '"i"')
+  glibconfig_conf.set('guintptr_format', '"u"')
+  glibconfig_conf.set('glib_gpi_cast', '(gint)')
+  glibconfig_conf.set('glib_gpui_cast', '(guint)')
+elif voidp_size == long_size
+  glibconfig_conf.set('glib_intptr_type_define', 'long')
+  glibconfig_conf.set('gintptr_modifier', '"l"')
+  glibconfig_conf.set('gintptr_format', '"li"')
+  glibconfig_conf.set('guintptr_format', '"lu"')
+  glibconfig_conf.set('glib_gpi_cast', '(glong)')
+  glibconfig_conf.set('glib_gpui_cast', '(gulong)')
+elif voidp_size == long_long_size
+  glibconfig_conf.set('glib_intptr_type_define', 'long long')
+  glibconfig_conf.set('gintptr_modifier', '"I64"')
+  glibconfig_conf.set('gintptr_format', '"I64i"')
+  glibconfig_conf.set('guintptr_format', '"I64u"')
+  glibconfig_conf.set('glib_gpi_cast', '(gint64)')
+  glibconfig_conf.set('glib_gpui_cast', '(guint64)')
+# FIXME
+#elif voidp_size == __int64_size
+#  glib_intptr_type_define=__int64
+#  gintptr_modifier='"I64"'
+#  gintptr_format='"I64i"'
+#  guintptr_format='"I64u"'
+#  glib_gpi_cast='(gint64)'
+#  glib_gpui_cast='(guint64)'
+else
+  error('Could not determine size of void *')
+endif
+
+glibconfig_conf.set('gintbits', int_size * 8)
+glibconfig_conf.set('glongbits', long_size * 8)
+glibconfig_conf.set('gsizebits', sizet_size * 8)
+glibconfig_conf.set('gssizebits', ssizet_size * 8)
+
+# FIXME: maybe meson should tell us the libsuffix?
+if host_machine.system() == 'windows'
+  g_module_suffix = 'dll'
+elif host_machine.system() == 'darwin'
+  g_module_suffix = 'dylib'
+else
+  g_module_suffix = 'so'
+endif
+glibconfig_conf.set('g_module_suffix', g_module_suffix)
+
+glibconfig_conf.set('GLIB_MAJOR_VERSION', major_version)
+glibconfig_conf.set('GLIB_MINOR_VERSION', minor_version)
+glibconfig_conf.set('GLIB_MICRO_VERSION', micro_version)
+
 glibconfig_conf.set('glib_void_p', voidp_size)
 glibconfig_conf.set('glib_long', long_size)
 glibconfig_conf.set('glib_size_t', sizet_size)
-if host.is_big_endian()
+glibconfig_conf.set('glib_ssize_t', ssizet_size)
+if host_machine.endian() == 'big'
   glibconfig_conf.set('g_byte_order', 'G_BIG_ENDIAN')
   glibconfig_conf.set('g_bs_native', 'BE')
   glibconfig_conf.set('g_bs_alien', 'LE')
@@ -387,94 +949,99 @@ else
   glibconfig_conf.set('g_bs_alien', 'BE')
 endif
 
-if cc.has_header('limits.h')
-  glibconfig_conf.set('INC_LIMITS_H', '#include<limits.h>')
-  glibconfig_conf.set('glib_ms', 'SHRT_MIN')
-  glibconfig_conf.set('glib_Ms', 'SHRT_MAX')
-  glibconfig_conf.set('glib_Mus', 'USHRT_MAX')
-  glibconfig_conf.set('glib_mi', 'INT_MIN')
-  glibconfig_conf.set('glib_Mi', 'INT_MAX')
-  glibconfig_conf.set('glib_Mui', 'UINT_MAX')
-  glibconfig_conf.set('glib_ml', 'LONG_MIN')
-  glibconfig_conf.set('glib_Ml', 'LONG_MAX')
-  glibconfig_conf.set('glib_Mul', 'ULONG_MAX')
-endif
-if cc.has_header('float.h')
-  glibconfig_conf.set('INC_FLOAT_H', '#include<float.h>')
-  glibconfig_conf.set('glib_mf', 'FLT_MIN')
-  glibconfig_conf.set('glib_Mf', 'FLT_MAX')
-  glibconfig_conf.set('glib_md', 'DBL_MIN')
-  glibconfig_conf.set('glib_Md', 'DBL_MAX')
-endif
-if cc.has_header('values.h')
-  glibconfig_conf.set('INC_VALUES_H', '#include<values.h>')
-  glibconfig_conf.set('glib_mf', 'MINFLOAT')
-  glibconfig_conf.set('glib_Mf', 'MAXFLOAT')
-  glibconfig_conf.set('glib_md', 'MINDOUBLE')
-  glibconfig_conf.set('glib_Md', 'MAXDOUBLE')
-  glibconfig_conf.set('glib_ms', 'MINSHORT')
-  glibconfig_conf.set('glib_Ms', 'MAXSHORT')
-  glibconfig_conf.set('glib_Mus', '(((gushort)G_MAXSHORT)*2+1)')
-  glibconfig_conf.set('glib_mi', 'MININT')
-  glibconfig_conf.set('glib_Mi', 'MAXINT')
-  glibconfig_conf.set('glib_Mui', '(((guint)G_MAXINT)*2+1)')
-  glibconfig_conf.set('glib_ml', 'MINLONG')
-  glibconfig_conf.set('glib_Ml', 'MAXLONG')
-  glibconfig_conf.set('glib_Mul', '(((gulong)G_MAXLONG)*2+1)')
-endif
-
-if cc.compiles('''#undef inline
-       inline int foo () { return 0; }
-       int main () { return foo (); }''')
-  glibconfig_conf.set('G_HAS_INLINE', 1)
-else
-  glibconfig_conf.set('G_HAS_INLINE', 0)
+# === va_copy checks ===
+# we currently check for all three va_copy possibilities, so we get
+# all results in config.log for bug reports.
+
+foreach try_func : [ '__va_copy', 'va_copy' ]
+  if cc.compiles('''#include <stdarg.h>
+                    #include <stdlib.h>
+                    void f (int i, ...) {
+                    va_list args1, args2;
+                    va_start (args1, i);
+                    @0@ (args2, args1);
+                    if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
+                      exit (1);
+                    va_end (args1); va_end (args2);
+                    }
+                    int main() {
+                      f (0, 42);
+                      return 0;
+                    }'''.format(try_func),
+                    name : try_func + ' check')
+    va_copy_func = try_func
+  endif
+endforeach
+glib_conf.set('G_VA_COPY', va_copy_func)
+glib_vacopy = '#define G_VA_COPY ' + va_copy_func
+
+va_list_val_copy_prog = '''
+  #include <stdarg.h>
+  #include <stdlib.h>
+  void f (int i, ...) {
+    va_list args1, args2;
+    va_start (args1, i);
+    args2 = args1;
+    if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
+      exit (1);
+    va_end (args1); va_end (args2);
+  }
+  int main() {
+    f (0, 42);
+    return 0;
+  }'''
+
+# We do this in two steps so if compilation fails already it looks less alarming
+glib_va_val_copy = false
+if cc.compiles(va_list_val_copy_prog, name : 'va_lists can be copied as values')
+  # FIXME: what to do when cross-compiling?
+  if cc.run(va_list_val_copy_prog, 'va_lists can be copied as values').returncode() == 0
+    glib_va_val_copy = true
+  endif
+endif
+if not glib_va_val_copy
+  glib_va_val_copy = false
+  glib_vacopy = glib_vacopy + '\n#define G_VA_COPY_AS_ARRAY 1'
+  glib_conf.set('G_VA_COPY_AS_ARRAY', 1)
 endif
+glibconfig_conf.set('glib_vacopy', glib_vacopy)
 
-# I can't quite decipher what the multiple consecutive checks
-# are trying to do. Use this, fix if it breaks.
-glibconfig_conf.set('G_CAN_INLINE', '1')
+# check for flavours of varargs macros
+g_have_iso_c_varargs = cc.compiles('''
+  void some_func (void) {
+    int a(int p1, int p2, int p3);
+    #define call_a(...) a(1,__VA_ARGS__)
+    call_a(2,3);
+  }''', name : 'ISO C99 varargs macros in C')
 
-vacopy_src = '''#include <stdarg.h>
-#include <stdlib.h>
-void f (int i, ...) {
-va_list args1, args2;
-va_start (args1, i);
-va_copy (args2, args1);
-if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
-  exit (1);
-va_end (args1); va_end (args2);
-}
-int main() {
-  f (0, 42);
-  return 0;
-}
-'''
-have_vacopy = cc.compiles(vacopy_src)
-
-__vaacopy_src = '''#include <stdarg.h>
-#include <stdlib.h>
-void f (int i, ...) {
-va_list args1, args2;
-va_start (args1, i);
-__va_copy (args2, args1);
-if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
-  exit (1);
-va_end (args1); va_end (args2);
-}
-int main() {
-  f (0, 42);
-  return 0;
-}
-'''
-have___vaacopy = cc.compiles(__vaacopy_src)
+if g_have_iso_c_varargs
+  glibconfig_conf.set('g_have_iso_c_varargs', '''
+#ifndef __cplusplus
+# define G_HAVE_ISO_VARARGS 1
+#endif''')
+endif
+
+g_have_iso_cxx_varargs = cxx.compiles('''
+  void some_func (void) {
+    int a(int p1, int p2, int p3);
+    #define call_a(...) a(1,__VA_ARGS__)
+    call_a(2,3);
+  }''', name : 'ISO C99 varargs macros in C++')
 
-if have_vacopy
-  glib_conf.set('G_VA_COPY', 'va_copy')
-elif have___vacopy
-  glib_conf.set('G_VA_COPY', '__va_copy')
+if g_have_iso_cxx_varargs
+  glibconfig_conf.set('g_have_iso_cxx_varargs', '''
+#ifdef __cplusplus
+# define G_HAVE_ISO_VARARGS 1
+#endif''')
 endif
 
+g_have_gnuc_varargs = cc.compiles('''
+  void some_func (void) {
+    int a(int p1, int p2, int p3);
+    #define call_a(params...) a(1,params)
+    call_a(2,3);
+  }''', name : 'GNUC varargs macros')
+
 if cc.has_header('alloca.h')
   glibconfig_conf.set('GLIB_HAVE_ALLOCA_H', true)
 endif
@@ -499,6 +1066,8 @@ int main(int argc, char **argv) {
   value_POLLHUP = cc.run(templ.format('POLLHUP')).stdout().strip()
   value_POLLNVAL = cc.run(templ.format('POLLNVAL')).stdout().strip()
 else
+  # FIXME?
+  error('FIX POLL* defines')
   value_POLLIN = 1
   value_POLLOUT = 4
   value_POLLPRI = 2
@@ -514,10 +1083,56 @@ glibconfig_conf.set('g_pollerr', value_POLLERR)
 glibconfig_conf.set('g_pollhup', value_POLLHUP)
 glibconfig_conf.set('g_pollnval', value_POLLNVAL)
 
-glibconfig_conf.set('GLIB_USING_SYSTEM_PRINTF', true)
+# Internet address families
+# FIXME: what about Cygwin (G_WITH_CYGWIN)
+if host_machine.system() == 'windows'
+  glib_inet_includes= '''
+#include <winsock2.h>
+'''
+else
+  glib_inet_includes='''
+#include <sys/types.h>
+#include <sys/socket.h>
+'''
+endif
+
+net_defines = [
+  [ 'AF_UNIX', 'g_af_unix' ],
+  [ 'AF_INET', 'g_af_inet' ],
+  [ 'AF_INET6', 'g_af_inet6' ],
+  [ 'MSG_OOB', 'g_msg_oob' ],
+  [ 'MSG_PEEK', 'g_msg_peek' ],
+  [ 'MSG_DONTROUTE', 'g_msg_dontroute' ],
+]
+foreach d : net_defines
+  templ = '''@0@
+#include <stdio.h>
+int main(int argc, char **argv) {
+  printf("%d\n", (int)@1@);
+  return 0;
+}'''
+  # FIXME: fix for cross-compilation
+  if meson.is_cross_build()
+    error('Fix sys define detection for cross build')
+  endif
+  val = cc.run(templ.format(glib_inet_includes, d[0])).stdout().strip()
+  glibconfig_conf.set(d[1], val)
+endforeach
+
+glibconfig_conf.set('GLIB_USING_SYSTEM_PRINTF', true) # FIXME!
+
+# We need a more robust approach here...
+host_cpu_family = host_machine.cpu_family()
+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')
+  glib_memory_barrier_needed = false
+elif host_cpu_family.startswith('sparc') or host_cpu_family.startswith('alpha') or 
host_cpu_family.startswith('powerpc') or host_cpu_family == 'ia64'
+  glib_memory_barrier_needed = true
+else
+  # FIXME: should warn perhaps
+  glib_memory_barrier_needed = true
+endif
+glibconfig_conf.set('G_ATOMIC_OP_MEMORY_BARRIER_NEEDED', glib_memory_barrier_needed)
 
-# Need to check $host for this one.
-glibconfig_conf.set('glib_memory_barrier_needed', true)
 atomictest = '''void func() {
   volatile int atomic = 2;
   __sync_bool_compare_and_swap (&atomic, 2, 3);
@@ -529,10 +1144,94 @@ else
   glibconfig_conf.set('G_ATOMIC_LOCK_FREE', false)
 endif
 
-pcre = dependency('libpcre') # Should check for Unicode support, too.
-thread_lib = find_library('pthread')
+# === Threads ===
 
-configure_file(input : 'config.h.meson', output : 'config.h', configuration : glib_conf)
+# Let meson figure out all this business and whether -pthread or whatnot is needed
+# FIXME: probably needs more tweaking in meson for things like -D_REENTRANT etc.
+thread_dep = dependency('threads')
+
+# Determination of thread implementation
+if host_machine.system() == 'windows'
+  glibconfig_conf.set('g_threads_impl_def', 'WIN32')
+  glib_conf.set('THREADS_WIN32', 1)
+else
+  glibconfig_conf.set('g_threads_impl_def', 'POSIX')
+  glib_conf.set('THREADS_POSIX', 1)
+endif
+
+# FIXME: how to do this when cross-compiling?
+# FIXME: we should make it print the result and always return 0, so that
+# the output in meson shows up as green
+stack_grows_check_prog = '''
+  volatile int *a = 0, *b = 0;
+  void f (int i) {
+    volatile int x = 5;
+    if (i == 0)
+      b = &x;
+    else
+      f (i - 1);
+  }
+  int main () {
+    volatile int y = 7;
+    a = &y;
+    f (100);
+    return b > a ? 0 : 1;
+  }'''
+stack_grows_run_result = cc.run(stack_grows_check_prog, name : 'stack grows check')
+if stack_grows_run_result.compiled() and stack_grows_run_result.returncode() == 0
+  glibconfig_conf.set('G_HAVE_GROWING_STACK', 1)
+else
+  glibconfig_conf.set('G_HAVE_GROWING_STACK', 0)
+endif
+
+# Tests for iconv
+# USE_LIBICONV_GNU: Using GNU libiconv
+# USE_LIBICONV_NATIVE: Using a native implementation of iconv in a separate library
+# On Windows we use a native implementation
+if host_machine.system() == 'windows'
+  glib_conf.set('USE_LIBICONV_NATIVE', true)
+  libiconv = find_library('iconv')
+else
+  # FIXME: add option as well
+  if cc.has_function('iconv_open', prefix : '#include <iconv.h>', name : 'C library iconv')
+    libiconv = [ ]
+  # FIXME: this is all wrong, meson needs a more intuitive check for this, like cc.has_lib_function() or such
+  elif cc.compiles('''#include <iconv.h>
+                      void somefunc (void) {
+                        libiconv_open("foo", "bar")
+                      }''', args : '-liconv', name : 'GNU libiconv')
+    glib_conf.set('USE_LIBICONV_GNU', true)
+    libiconv = find_library('iconv')
+  elif cc.compiles('''#include <iconv.h>
+                      void somefunc (void) {
+                        iconv_open("foo", "bar")
+                      }''', args : '-liconv', name : 'other libiconv')
+    glib_conf.set('USE_LIBICONV_NATIVE', true)
+    libiconv = find_library('iconv')
+  else
+    error('No iconv() implementation found in C library or libiconv')
+  endif
+endif
+
+pcre = dependency('libpcre') # Should check for Unicode support, too. FIXME
+glib_conf.set('USE_SYSTEM_PCRE', '/**/')
+
+libm = find_library('m')
+libffi_dep = dependency('libffi', version : '>= 3.0.0')
+libz_dep = dependency('zlib')
+
+# FIXME: defines in config.h that are not actually used anywhere
+# (we add them for now to minimise the diff)
+glib_conf.set('HAVE_DLFCN_H', 1)
+glib_conf.set('__EXTENSIONS__', 1)
+glib_conf.set('STDC_HEADERS', 1)
+# THREADS_NONE
+glib_conf.set('SIZEOF___INT64', 0)
 
 subdir('glib')
-#subdir('tests')
+subdir('gobject')
+subdir('gthread')
+subdir('gmodule')
+subdir('gio')
+
+configure_file(input : 'config.h.meson', output : 'config.h', configuration : glib_conf)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]