diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2020-06-09 17:08:33 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2020-06-14 23:59:37 +0800 |
commit | 9b59c79e98a19a63ea544a11737fec8cbb6088ea (patch) | |
tree | dfa28b918b1433e4fed090cb09fd4ae7b91f7e8b /glib/gnulib | |
parent | 1cd7d1ade28c0d3466e9269313d14554f71701ea (diff) | |
download | glib-9b59c79e98a19a63ea544a11737fec8cbb6088ea.tar.gz |
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, so that builds on compilers that
lack these functions could be fixed.
Also, if we do have the isnan*() functions, improve the build by not
unnecessarily including the isnan*.c sources in the build.
If the isnan*() functions are found, make sure that the
HAVE_ISNAN*_IN_LIBC macros are defined in the CFLags, so that we do not
accidently require the gnulib implementations for these functions.
Diffstat (limited to 'glib/gnulib')
-rw-r--r-- | glib/gnulib/meson.build | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/glib/gnulib/meson.build b/glib/gnulib/meson.build index 86e0bcbdd..38b530aa0 100644 --- a/glib/gnulib/meson.build +++ b/glib/gnulib/meson.build @@ -191,29 +191,47 @@ nan_tmpl = '''#include <math.h> int main () {return @0@ (x);} ''' -links = cc.links (nan_tmpl.format ('isnan', 'double', '__builtin_isnan'), +links = cc.links (nan_tmpl.format ('isnand', 'double', '__builtin_isnan'), dependencies : [libm]) + 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 +330,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 +351,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'] |