[glib/wip/meson: 14/53] meson: initial glib build



commit ce4217677b457f9d4db6aba4f15449eaf64106fa
Author: Jussi Pakkanen <jpakkane gmail com>
Date:   Wed Aug 7 23:41:12 2013 +0300

    meson: initial glib build
    
    https://mail.gnome.org/archives/gtk-devel-list/2013-August/msg00001.html

 glib/glibconfig.h.in        |  222 ++++++++++++++++++
 glib/libcharset/meson.build |    3 +
 glib/meson.build            |  106 +++++++++
 meson.build                 |  538 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 869 insertions(+), 0 deletions(-)
---
diff --git a/glib/glibconfig.h.in b/glib/glibconfig.h.in
new file mode 100644
index 0000000..6a7eb2a
--- /dev/null
+++ b/glib/glibconfig.h.in
@@ -0,0 +1,222 @@
+/* glibconfig.h
+ *
+ * This is a generated file.  Please modify 'glibconfig.h.in'
+ */
+
+#ifndef __GLIBCONFIG_H__
+#define __GLIBCONFIG_H__
+
+#include <glib/gmacros.h>
+
+@INC_LIMITS_H@
+@INC_FLOAT_H@
+@INC_VALUES_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,
+ * when using glibc's register_printf_function().
+ */
+#mesondefine GLIB_USING_SYSTEM_PRINTF
+
+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 */
+typedef signed char gint8;
+typedef unsigned char guint8;
+
+typedef signed @gint16@ gint16;
+typedef unsigned @gint16@ guint16;
+
+#define G_GINT16_MODIFIER @gint16_modifier@
+#define G_GINT16_FORMAT @gint16_format@
+#define G_GUINT16_FORMAT @guint16_format@
+
+
+typedef signed @gint32@ gint32;
+typedef unsigned @gint32@ guint32;
+
+#define G_GINT32_MODIFIER @gint32_modifier@
+#define G_GINT32_FORMAT @gint32_format@
+#define G_GUINT32_FORMAT @guint32_format@
+
+
+#define G_HAVE_GINT64 1          /* deprecated, always true */
+
+@glib_extension@typedef signed @gint64@ gint64;
+@glib_extension@typedef unsigned @gint64@ guint64;
+
+#define G_GINT64_CONSTANT(val) @gint64_constant@
+#define G_GUINT64_CONSTANT(val)        @guint64_constant@
+
+#define G_GINT64_MODIFIER @gint64_modifier@
+#define G_GINT64_FORMAT @gint64_format@
+#define G_GUINT64_FORMAT @guint64_format@
+
+
+#define GLIB_SIZEOF_VOID_P @glib_void_p@
+#define GLIB_SIZEOF_LONG   @glib_long@
+#define GLIB_SIZEOF_SIZE_T @glib_size_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_GSIZE_FORMAT @gsize_format@
+
+#define G_MAXSIZE      G_MAXU@glib_msize_type@
+#define G_MINSSIZE     G_MIN@glib_msize_type@
+#define G_MAXSSIZE     G_MAX@glib_msize_type@
+
+typedef gint64 goffset;
+#define G_MINOFFSET    G_MININT64
+#define G_MAXOFFSET    G_MAXINT64
+
+#define G_GOFFSET_MODIFIER      G_GINT64_MODIFIER
+#define G_GOFFSET_FORMAT        G_GINT64_FORMAT
+#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
+
+#define GPOINTER_TO_INT(p)     ((gint)  @glib_gpi_cast@ (p))
+#define GPOINTER_TO_UINT(p)    ((guint) @glib_gpui_cast@ (p))
+
+#define GINT_TO_POINTER(i)     ((gpointer) @glib_gpi_cast@ (i))
+#define GUINT_TO_POINTER(u)    ((gpointer) @glib_gpui_cast@ (u))
+
+typedef signed @glib_intptr_type_define@ gintptr;
+typedef unsigned @glib_intptr_type_define@ guintptr;
+
+#define G_GINTPTR_MODIFIER      @gintptr_modifier@
+#define G_GINTPTR_FORMAT        @gintptr_format@
+#define G_GUINTPTR_FORMAT       @guintptr_format@
+
+@glib_atexit@
+@glib_memmove@
+@glib_defines@
+@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
+
+/* 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
+ * around to turn it on, so we unconditionally turn it off.
+ */
+#if __GNUC__ == 2 && __GNUC_MINOR__ == 95
+#  undef G_HAVE_ISO_VARARGS
+#endif
+
+#define G_HAVE_GNUC_VARARGS 1
+
+#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
+
+#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
+#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
+#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
+#define G_GNUC_INTERNAL __hidden
+#elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY)
+#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
+#else
+#define G_GNUC_INTERNAL
+#endif
+
+#define G_THREADS_ENABLED
+#define G_THREADS_IMPL_@g_threads_impl_def@
+
+#mesondefine G_ATOMIC_OP_MEMORY_BARRIER_NEEDED
+#mesondefine G_ATOMIC_LOCK_FREE
+
+#define GINT16_TO_@g_bs_native@(val)   ((gint16) (val))
+#define GUINT16_TO_@g_bs_native@(val)  ((guint16) (val))
+#define GINT16_TO_@g_bs_alien@(val)    ((gint16) GUINT16_SWAP_LE_BE (val))
+#define GUINT16_TO_@g_bs_alien@(val)   (GUINT16_SWAP_LE_BE (val))
+
+#define GINT32_TO_@g_bs_native@(val)   ((gint32) (val))
+#define GUINT32_TO_@g_bs_native@(val)  ((guint32) (val))
+#define GINT32_TO_@g_bs_alien@(val)    ((gint32) GUINT32_SWAP_LE_BE (val))
+#define GUINT32_TO_@g_bs_alien@(val)   (GUINT32_SWAP_LE_BE (val))
+
+#define GINT64_TO_@g_bs_native@(val)   ((gint64) (val))
+#define GUINT64_TO_@g_bs_native@(val)  ((guint64) (val))
+#define GINT64_TO_@g_bs_alien@(val)    ((gint64) GUINT64_SWAP_LE_BE (val))
+#define GUINT64_TO_@g_bs_alien@(val)   (GUINT64_SWAP_LE_BE (val))
+
+#define GLONG_TO_LE(val)       ((glong) GINT@glongbits@_TO_LE (val))
+#define GULONG_TO_LE(val)      ((gulong) GUINT@glongbits@_TO_LE (val))
+#define GLONG_TO_BE(val)       ((glong) GINT@glongbits@_TO_BE (val))
+#define GULONG_TO_BE(val)      ((gulong) GUINT@glongbits@_TO_BE (val))
+#define GINT_TO_LE(val)                ((gint) GINT@gintbits@_TO_LE (val))
+#define GUINT_TO_LE(val)       ((guint) GUINT@gintbits@_TO_LE (val))
+#define GINT_TO_BE(val)                ((gint) GINT@gintbits@_TO_BE (val))
+#define GUINT_TO_BE(val)       ((guint) GUINT@gintbits@_TO_BE (val))
+#define GSIZE_TO_LE(val)       ((gsize) GUINT@gsizebits@_TO_LE (val))
+#define GSSIZE_TO_LE(val)      ((gssize) GINT@gsizebits@_TO_LE (val))
+#define GSIZE_TO_BE(val)       ((gsize) GUINT@gsizebits@_TO_BE (val))
+#define GSSIZE_TO_BE(val)      ((gssize) GINT@gsizebits@_TO_BE (val))
+#define G_BYTE_ORDER @g_byte_order@
+
+#define GLIB_SYSDEF_POLLIN =@g_pollin@
+#define GLIB_SYSDEF_POLLOUT =@g_pollout@
+#define GLIB_SYSDEF_POLLPRI =@g_pollpri@
+#define GLIB_SYSDEF_POLLHUP =@g_pollhup@
+#define GLIB_SYSDEF_POLLERR =@g_pollerr@
+#define GLIB_SYSDEF_POLLNVAL =@g_pollnval@
+
+#define G_MODULE_SUFFIX "@g_module_suffix@"
+
+typedef @g_pid_type@ GPid;
+
+#define GLIB_SYSDEF_AF_UNIX @g_af_unix@
+#define GLIB_SYSDEF_AF_INET @g_af_inet@
+#define GLIB_SYSDEF_AF_INET6 @g_af_inet6@
+
+#define GLIB_SYSDEF_MSG_OOB @g_msg_oob@
+#define GLIB_SYSDEF_MSG_PEEK @g_msg_peek@
+#define GLIB_SYSDEF_MSG_DONTROUTE @g_msg_dontroute@
+
+G_END_DECLS
+
+#endif /* __GLIBCONFIG_H__ */
diff --git a/glib/libcharset/meson.build b/glib/libcharset/meson.build
new file mode 100644
index 0000000..0d87d1c
--- /dev/null
+++ b/glib/libcharset/meson.build
@@ -0,0 +1,3 @@
+charset_lib = shared_library('charset', 'localcharset.c',
+  include_directories : inc_dirs,
+  c_args : [ '-DLIBDIR="lib"' ])
diff --git a/glib/meson.build b/glib/meson.build
new file mode 100644
index 0000000..40efd90
--- /dev/null
+++ b/glib/meson.build
@@ -0,0 +1,106 @@
+configure_file(input : 'glibconfig.h.in', output : 'glibconfig.h', configuration : glibconfig_conf)
+
+subdir('libcharset')
+
+if host.name() == 'windows'
+  thread_src = ['gthread-win32.c']
+  plat_src = []
+else
+  thread_src = ['gthread-posix.c']
+  plat_src = ['glib-unix.c']
+endif
+
+deprecated_sources = [
+'deprecated/gallocator.c',
+'deprecated/gcache.c',
+'deprecated/gcompletion.c',
+'deprecated/grel.c',
+'deprecated/gthread-deprecated.c']
+
+glib_sources = [
+'garray.c',
+'gasyncqueue.c',
+'gatomic.c',
+'gbacktrace.c',
+'gbase64.c',
+'gbitlock.c',
+'gbookmarkfile.c',
+'gbytes.c',
+'gcharset.c',
+'gchecksum.c',
+'gconvert.c',
+'gdataset.c',
+'gdate.c',
+'gdatetime.c',
+'gdir.c',
+'genviron.c',
+'gerror.c',
+'gfileutils.c',
+'ggettext.c',
+'ghash.c',
+'ghmac.c',
+'ghook.c',
+'ghostutils.c',
+'giochannel.c',
+'gkeyfile.c',
+'glib-init.c',
+'glib-private.c',
+'glist.c',
+'gmain.c',
+'gmappedfile.c',
+'gmarkup.c',
+'gmem.c',
+'gmessages.c',
+'gnode.c',
+'goption.c',
+'gpattern.c',
+'gpoll.c',
+'gprimes.c',
+'gqsort.c',
+'gquark.c',
+'gqueue.c',
+'grand.c',
+'gregex.c',
+'gscanner.c',
+'gsequence.c',
+'gshell.c',
+'gslice.c',
+'gslist.c',
+'gstdio.c',
+'gstrfuncs.c',
+'gstring.c',
+'gstringchunk.c',
+'gtestutils.c',
+'gthread.c',
+'gthreadpool.c',
+'gtimer.c',
+'gtimezone.c',
+'gtrashstack.c',
+'gtree.c',
+'guniprop.c',
+'gutf8.c',
+'gunibreak.c',
+'gunicollate.c',
+'gunidecomp.c',
+'gurifuncs.c',
+'gutils.c',
+'gvariant.c',
+'gvariant-core.c',
+'gvariant-parser.c',
+'gvariant-serialiser.c',
+'gvarianttypeinfo.c',
+'gvarianttype.c',
+'gversion.c',
+'gwakeup.c',
+'gprintf.c',]
+
+extra_src = ['gspawn.c', 'giounix.c']
+
+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,
+link_with : charset_lib,
+deps : [pcre, thread_lib],
+c_args : ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION', '-DPCRE_STATIC'])
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..e983bd9
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,538 @@
+project('glib', 'c')
+
+cc = meson.get_compiler('c')
+
+major_version = 3
+minor_version = 36
+micro_version = 3
+interface_version = 3
+
+glib_version = '3.36.3'
+inc_dirs = include_directories('.', 'glib', 'gmodule')
+
+glib_conf = configuration_data()
+glibconfig_conf = configuration_data()
+
+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('GETTEXT_PACKAGE', '"glib20"')
+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)
+
+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"')
+
+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'
+  glib_os = '''#define G_OS_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)
+endif
+if cc.has_header('float.h')
+  glib_conf.set('HAVE_FLOAT_H', 1)
+endif
+if cc.has_header('limits.h')
+  glib_conf.set('HAVE_LIMITS_H', 1)
+endif
+if cc.has_header('pwd.h')
+  glib_conf.set('HAVE_PWD_H', 1)
+endif
+if cc.has_header('grp.h')
+  glib_conf.set('HAVE_GRP_H', 1)
+endif
+if cc.has_header('sys/param.h')
+  glib_conf.set('HAVE_SYS_PARAM_H', 1)
+  sysparam_include = '#include<sys/param.h>'
+else
+  sysparam_include = ''
+endif
+if cc.has_header('poll.h')
+  glib_conf.set('HAVE_POLL_H', 1)
+endif
+if cc.has_header('sys/resource.h')
+  glib_conf.set('HAVE_SYS_RESOURCE_H', 1)
+endif
+
+if cc.has_header('sys/time.h')
+  glib_conf.set('HAVE_SYS_TIME_H', 1)
+endif
+if cc.has_header('sys/times.h')
+  glib_conf.set('HAVE_SYS_TIMES_H', 1)
+endif
+if cc.has_header('sys/wait.h')
+  glib_conf.set('HAVE_SYS_WAIT_H', 1)
+endif
+if cc.has_header('unistd.h')
+  glib_conf.set('HAVE_UNISTD_H', 1)
+endif
+if cc.has_header('values.h')
+  glib_conf.set('HAVE_VALUES_H', 1)
+endif
+
+
+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
+
+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
+
+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 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
+
+if cc.has_header('linux/magic.h')
+  glib_conf.set('HAVE_LINUX_MAGIC_H', 1)
+endif
+
+if cc.has_header('sys/prctl.h')
+  glib_conf.set('HAVE_SYS_PRCTL_H', 1)
+endif
+
+if cc.has_header('sys/mount.h', prefix : sysparam_include)
+  glib_conf.set('HAVE_SYS_MOUNT_H', 1)
+endif
+if cc.has_header('sys/sysctl.h', prefix : sysparam_include)
+  glib_conf.set('HAVE_SYS_SYSCTL_H', 1)
+endif
+
+if cc.has_header('xlocale.h')
+  glib_conf.set('HAVE_XLOCALE_H', 1)
+endif
+
+if cc.has_member('struct stat', 'st_mtimensec', prefix : '#include<sys/stat.h>')
+  glib_conf.set('HAVE_STRUCT_STAT_ST_MTIMENSEC', 1)
+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)
+endif
+
+if cc.has_member('struct stat', 'st_atimensec', prefix : '#include<sys/stat.h>')
+  glib_conf.set('HAVE_STRUCT_STAT_ST_ATIMENSEC', 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)
+endif
+
+if cc.has_member('struct stat', 'st_ctimensec', prefix : '#include<sys/stat.h>')
+  glib_conf.set('HAVE_STRUCT_STAT_ST_CTIMENSEC', 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)
+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)
+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>
+'''
+
+if cc.has_member('struct stat', 'blksize', prefix : blkprefix)
+  glib_conf.set('HAVE_STRUCT_STAT_BLKSIZE', 1)
+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)
+endif
+
+if cc.has_header('string.h')
+  glib_conf.set('HAVE_STRING_H', 1)
+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')
+sizet_size = cc.sizeof('size_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)
+
+glib_conf.set('SIZEOF_CHAR', char_size)
+glib_conf.set('SIZEOF_INT', int_size)
+glib_conf.set('SIZEOF_SHORT', short_size)
+glib_conf.set('SIZEOF_LONG', long_size)
+glib_conf.set('SIZEOF_LONG_LONG', long_long_size)
+glib_conf.set('SIZEOF_SIZE_T', sizet_size)
+glib_conf.set('SIZEOF_VOID_P', voidp_size)
+
+if long_size == 2
+  # configure.ac does not work if this is the case. So we don't either.
+  gint16 = 'long'
+endif
+if int_size == 2
+  gint16 = 'int'
+  gint16_modifier='""'
+  gint16_format='"i"'
+  guint16_format='"u"'
+endif
+if short_size == 2
+  gint16 = 'short'
+  gint16_modifier='"h"'
+  gint16_format='"hi"'
+  guint16_format='"hu"'
+endif
+glibconfig_conf.set('gint16', gint16)
+glibconfig_conf.set('gint16_modifier', gint16_modifier)
+glibconfig_conf.set('gint16_format', gint16_format)
+glibconfig_conf.set('guint16_format', guint16_format)
+
+if long_size == 4
+  gint32 = 'long'
+  gint32_modifier='"l"'
+  gint32_format='"li"'
+  guint32_format='"lu"'
+  guint32_align = long_align
+endif
+if int_size == 4
+  gint32 = 'int'
+  gint32_modifier='""'
+  gint32_format='"i"'
+  guint32_format='"u"'
+  guint32_align = int_align
+endif
+if short_size == 4
+  gint32 = 'short'
+  gint32_modifier='"h"'
+  gint32_format='"hi"'
+  guint32_format='"hu"'
+  guint32_align = short_align
+endif
+glibconfig_conf.set('gint32', gint32)
+glibconfig_conf.set('gint32_modifier', gint32_modifier)
+glibconfig_conf.set('gint32_format', gint32_format)
+glibconfig_conf.set('guint32_format', guint32_format)
+glib_conf.set('ALIGNOF_GUINT32', guint32_align)
+
+if long_long_size == 8
+  # Currently broken.
+  gint64 = 'long long'
+endif
+if long_size == 8
+  gint64 = 'long'
+  gint64_modifier='"l"'
+  gint64_format='"li"'
+  guint64_format='"lu"'
+  glib_extension=''
+  gint64_constant='(val##L)'
+  guint64_constant='(val##UL)'
+  guint64_align = long_align
+endif
+if int_size == 8
+  gint64 = 'int'
+  gint64_modifier='""'
+  gint64_format='"i"'
+  guint64_format='"u"'
+  glib_extension=''
+  gint64_constant='(val)'
+  guint64_constant='(val)'
+  guint64_align = int_align
+endif
+if short_size == 8
+  # Another one broken in configure.ac
+  gint64 = 'short'
+endif
+glibconfig_conf.set('gint64', gint64)
+glibconfig_conf.set('gint64_modifier', gint64_modifier)
+glibconfig_conf.set('gint64_format', gint64_format)
+glibconfig_conf.set('guint64_format', guint64_format)
+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'
+  glibconfig_conf.set('g_pid_type', 'void*')
+else
+  glibconfig_conf.set('g_pid_type', 'int')
+endif
+
+if sizet_size == short_size
+  glibconfig_conf.set('glib_size_type_define', 'short')
+  glibconfig_conf.set('gsize_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('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('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('gsize_format', '"I64u"')
+  glibconfig_conf.set('gssize_format', '"I64i"')
+  glibconfig_conf.set('glib_msize_type', 'INT64')
+else
+  error('Could not determine size of size_t.')
+endif
+
+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('g_byte_order', 'G_BIG_ENDIAN')
+  glibconfig_conf.set('g_bs_native', 'BE')
+  glibconfig_conf.set('g_bs_alien', 'LE')
+else
+  glibconfig_conf.set('g_byte_order', 'G_LITTLE_ENDIAN')
+  glibconfig_conf.set('g_bs_native', 'LE')
+  glibconfig_conf.set('g_bs_alien', 'BE')
+endif
+
+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)
+endif
+
+# 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')
+
+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 have_vacopy
+  glib_conf.set('G_VA_COPY', 'va_copy')
+elif have___vacopy
+  glib_conf.set('G_VA_COPY', '__va_copy')
+endif
+
+if cc.has_header('alloca.h')
+  glibconfig_conf.set('GLIB_HAVE_ALLOCA_H', true)
+endif
+has_syspoll = cc.has_header('sys/poll.h')
+has_systypes = cc.has_header('sys/types.h')
+if has_syspoll
+  glibconfig_conf.set('GLIB_HAVE_SYS_POLL_H', true)
+endif
+
+if has_syspoll and has_systypes
+  templ = '''#include<sys/poll.h>
+#include<sys/types.h>
+#include<stdio.h>
+int main(int argc, char **argv) {
+  printf("%d\n", (int)@0@);
+  return 0;
+}'''
+  value_POLLIN = cc.run(templ.format('POLLIN')).stdout().strip()
+  value_POLLOUT = cc.run(templ.format('POLLOUT')).stdout().strip()
+  value_POLLPRI = cc.run(templ.format('POLLPRI')).stdout().strip()
+  value_POLLERR = cc.run(templ.format('POLLERR')).stdout().strip()
+  value_POLLHUP = cc.run(templ.format('POLLHUP')).stdout().strip()
+  value_POLLNVAL = cc.run(templ.format('POLLNVAL')).stdout().strip()
+else
+  value_POLLIN = 1
+  value_POLLOUT = 4
+  value_POLLPRI = 2
+  value_POLLERR = 8
+  value_POLLHUP = 16
+  value_POLLNVAL = 32
+endif
+
+glibconfig_conf.set('g_pollin', value_POLLIN)
+glibconfig_conf.set('g_pollout', value_POLLOUT)
+glibconfig_conf.set('g_pollpri', value_POLLPRI)
+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)
+
+# 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);
+}
+'''
+if cc.compiles(atomictest)
+  glibconfig_conf.set('G_ATOMIC_LOCK_FREE', true)
+else
+  glibconfig_conf.set('G_ATOMIC_LOCK_FREE', false)
+endif
+
+pcre = dependency('libpcre') # Should check for Unicode support, too.
+thread_lib = find_library('pthread')
+
+configure_file(input : 'config.h.meson', output : 'config.h', configuration : glib_conf)
+
+subdir('glib')
+#subdir('tests')


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