Merge branch '1313-config-cleanups' into 'master'

More config.h fixups for Meson

Closes #1313

See merge request GNOME/glib!283
This commit is contained in:
Xavier Claessens 2018-08-31 12:56:26 +00:00
commit b2375471cc
3 changed files with 45 additions and 22 deletions

View File

@ -145,8 +145,7 @@ prebuilt binaries are included in the "dev" packages.
Please note that the ./configure mechanism should not blindly be used
to build a GLib to be distributed to other developers because it
produces a compiler-dependent glibconfig.h. For instance, the typedef
for gint64 is long long with gcc, but __int64 with MSVC.
produces a compiler-dependent glibconfig.h.
Except for this and a few other minor issues, there shouldn't be any
reason to distribute separate GLib headers and DLLs for gcc and MSVC6

View File

@ -1697,12 +1697,7 @@ g_scanner_get_token_i (GScanner *scanner,
*token_p = G_TOKEN_FLOAT;
if (scanner->config->store_int64)
{
#ifdef _MSC_VER
/* work around error C2520, see gvaluetransform.c */
value_p->v_float = (__int64)value_p->v_int64;
#else
value_p->v_float = value_p->v_int64;
#endif
}
else
value_p->v_float = value_p->v_int;

View File

@ -738,12 +738,14 @@ if cc.compiles('''#include <fcntl.h>
endif
# Check whether there is a vsnprintf() function with C99 semantics installed.
# AC_FUNC_VSNPRINTF_C99
# (similar tests to AC_FUNC_VSNPRINTF_C99)
# Check whether there is a snprintf() function with C99 semantics installed.
# AC_FUNC_SNPRINTF_C99
# (similar tests to AC_FUNC_SNPRINTF_C99)
# Check whether there is a printf() function with Unix98 semantics installed.
# (similar tests to AC_FUNC_PRINTF_UNIX98)
have_good_vsnprintf = false
have_good_snprintf = false
have_good_printf = false
if host_system == 'windows' and cc.get_id() == 'msvc'
# Unfortunately the Visual Studio 2015+ implementations of C99-style
@ -754,6 +756,7 @@ if host_system == 'windows' and cc.get_id() == 'msvc'
# rigorous enough to notice, though.
glib_conf.set('HAVE_C99_SNPRINTF', false)
glib_conf.set('HAVE_C99_VSNPRINTF', false)
glib_conf.set('HAVE_UNIX98_PRINTF', false)
else
vsnprintf_c99_test_code = '''
#include <stdio.h>
@ -850,6 +853,31 @@ main(void)
have_good_snprintf = meson.get_cross_property('have_c99_snprintf', false)
glib_conf.set('HAVE_C99_SNPRINTF', have_good_snprintf)
endif
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);
}'''
if cc_can_run
rres = cc.run(printf_unix98_test_code, name : 'Unix98 printf positional parameters')
if rres.compiled() and rres.returncode() == 0
glib_conf.set('HAVE_UNIX98_PRINTF', 1)
have_good_printf = true
endif
else
have_good_printf = meson.get_cross_property('have_unix98_printf', false)
glib_conf.set('HAVE_UNIX98_PRINTF', have_good_printf)
endif
endif
if host_system == 'windows'
@ -858,20 +886,22 @@ else
glib_conf.set('EXEEXT', '')
endif
if have_good_vsnprintf and have_good_snprintf
# Our printf is 'good' only if vsnpintf()/snprintf() supports C99 well enough
glib_conf.set('HAVE_GOOD_PRINTF', 1) # FIXME: Check for HAVE_UNIX98_PRINTF?
if have_good_vsnprintf and have_good_snprintf and have_good_printf
# Our printf is 'good' only if vsnpintf()/snprintf()/printf() supports C99 well enough
glib_conf.set('HAVE_GOOD_PRINTF', 1)
else
glib_conf.set('HAVE_VASPRINTF', 1)
endif
glibconfig_conf.set('GLIB_USING_SYSTEM_PRINTF',
have_good_vsnprintf and have_good_snprintf and have_good_printf)
# Check whether the printf() family supports Unix98 %n$ positional parameters
# AC_FUNC_PRINTF_UNIX98
# Nothing uses HAVE_UNIX98_PRINTF
# Check for nl_langinfo and CODESET
# FIXME: Check for HAVE_BIND_TEXTDOMAIN_CODESET
if cc.links('''#include <langinfo.h>
int main (int argc, char ** argv) {
char *codeset = nl_langinfo (CODESET);
@ -1493,8 +1523,6 @@ foreach d : inet_defines
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')
@ -1745,13 +1773,20 @@ endif
# implementations. This could be extended if issues are found in some platforms.
if cc.has_function('ngettext')
libintl = []
have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset')
else
libintl = cc.find_library('intl', required : false)
if not libintl.found()
libintl = subproject('proxy-libintl').get_variable('intl_dep')
have_bind_textdomain_codeset = true # proxy-libintl supports it
else
have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset',
dependencies : libintl)
endif
endif
glib_conf.set('HAVE_BIND_TEXTDOMAIN_CODESET', have_bind_textdomain_codeset)
# We require gettext to always be present
glib_conf.set('HAVE_DCGETTEXT', 1)
glib_conf.set('HAVE_GETTEXT', 1)
@ -1853,12 +1888,6 @@ have_bash = find_program('bash', required : false).found() # For completion scri
have_m4 = find_program('m4', required : false).found() # For m4 macros
have_sh = find_program('sh', required : false).found() # For glib-gettextize
# 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('STDC_HEADERS', 1)
glib_conf.set('SIZEOF___INT64', 8)
# FIXME: How to detect Solaris? https://github.com/mesonbuild/meson/issues/1578
if host_system == 'sunos'
glib_conf.set('_XOPEN_SOURCE_EXTENDED', 1)