[glib/fix-gnulib-msvc-isnan: 91/91] meson: Fix gnulib build where isnan*() is needed



commit 35684b5e649762147b92e29a813c930744c56f7e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Jun 9 17:08:33 2020 +0800

    meson: Fix gnulib build where isnan*() is needed
    
    We need to include the isnan*.c sources as necessary, if any of the
    isnan*() functions cannot be found.  If they are found, make sure that
    the HAVE_ISNAN*_IN_LIBC is defined in the CFLags.
    
    s

 glib/gnulib/meson.build | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/glib/gnulib/meson.build b/glib/gnulib/meson.build
index 86e0bcbdd..50878de35 100644
--- a/glib/gnulib/meson.build
+++ b/glib/gnulib/meson.build
@@ -193,27 +193,50 @@ nan_tmpl = '''#include <math.h>
 
 links = cc.links (nan_tmpl.format ('isnan', 'double', '__builtin_isnan'),
                   dependencies : [libm])
+
+if not links
+  links = cc.links (nan_tmpl.format ('isnand', 'double', '__builtin_isnan'),
+                    dependencies : [libm])
+endif
+
 math_h_config.set ('HAVE_ISNAN', links ? 1 : 0)
-math_h_config.set ('HAVE_ISNAN_IN_LIBC', links ? 1 : 0)
 set_variable ('have_isnan', links)
 math_h_config.set ('HAVE_ISNAND', links ? 1 : 0)
-math_h_config.set ('HAVE_ISNAND_IN_LIBC', links ? 1 : 0)
 set_variable ('have_isnand', links)
 
+if links
+  extra_gnulib_args += '-DHAVE_ISNAN_IN_LIBC'
+  extra_gnulib_args += '-DHAVE_ISNAND_IN_LIBC'
+endif
+
 links = cc.links (nan_tmpl.format ('isnanf', 'float', '__builtin_isnanf'),
                   dependencies : [libm])
+
 math_h_config.set ('HAVE_ISNANF', links ? 1 : 0)
-math_h_config.set ('HAVE_ISNANF_IN_LIBC', links ? 1 : 0)
 set_variable ('have_isnanf', links)
 
+if links
+  extra_gnulib_args += '-DHAVE_ISNANF_IN_LIBC'
+endif
+
 links = cc.links (nan_tmpl.format ('isnanl', 'long double', '__builtin_isnanl'),
                   dependencies : [libm])
+
 math_h_config.set ('HAVE_ISNANL', links ? 1 : 0)
-math_h_config.set ('HAVE_ISNANL_IN_LIBC', links ? 1 : 0)
 set_variable ('have_isnanl', links)
 
+if links
+  extra_gnulib_args += '-DHAVE_ISNANL_IN_LIBC'
+endif
+
 math_h_config.set ('REPLACE_ISNAN', (have_isnand and have_isnanf and have_isnanl) ? 0 : 1)
 
+other_needed_math_sources = []
+
+if not (have_isnand and have_isnanf and have_isnanl)
+  other_needed_math_sources += [ 'isnand.c', 'isnanf.c', 'isnanl.c' ]
+endif
+
 links = cc.links ('''#include <math.h>
                      double x;
                      int y;
@@ -312,7 +335,6 @@ inf_tmpl = '''#include <math.h>
               int main () {return @0@ (x);}
            '''
 
-other_needed_math_sources = []
 # Some compilers may not have isfinite, isinf available
 foreach f: ['isfinite', 'isinf', 'signbit']
   links = cc.links (inf_tmpl.format('@0@'.format(f)),
@@ -334,7 +356,7 @@ math_h = configure_file (input: 'gnulib_math.h.in',
                          output: 'gnulib_math.h',
                          configuration: math_h_config)
 
-gnulib_sources = ['asnprintf.c', 'printf.c', 'printf-args.c', 'printf-parse.c', 'printf-frexp.c', 
'printf-frexpl.c', 'isnand.c', 'isnanl.c', 'vasnprintf.c', 'xsize.c']
+gnulib_sources = ['asnprintf.c', 'printf.c', 'printf-args.c', 'printf-parse.c', 'printf-frexp.c', 
'printf-frexpl.c', 'vasnprintf.c', 'xsize.c']
 
 if not gl_cv_func_frexp_works
   gnulib_sources += ['frexp.c']


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