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 Please note that the ./configure mechanism should not blindly be used
to build a GLib to be distributed to other developers because it to build a GLib to be distributed to other developers because it
produces a compiler-dependent glibconfig.h. For instance, the typedef produces a compiler-dependent glibconfig.h.
for gint64 is long long with gcc, but __int64 with MSVC.
Except for this and a few other minor issues, there shouldn't be any 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 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; *token_p = G_TOKEN_FLOAT;
if (scanner->config->store_int64) 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; value_p->v_float = value_p->v_int64;
#endif
} }
else else
value_p->v_float = value_p->v_int; value_p->v_float = value_p->v_int;

View File

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