[glib: 3/6] meson: Use cc.compiles instead of cc.has_header to check malloc.h



commit f752515925f532916c392ca4043805dab06006c7
Author: Ting-Wei Lan <lantw src gnome org>
Date:   Sat May 26 12:14:35 2018 +0800

    meson: Use cc.compiles instead of cc.has_header to check malloc.h
    
    cc.has_header checks whether a header exists without knowing whether it
    can be used. This is a problem on FreeBSD because its malloc.h is a
    header with an '#error' line which always throw compilation error. To
    avoid false positive in the check result, we use cc.compiles to do a
    full compilation test instead of cc.has_header which only does check
    with preprocessor.

 meson.build | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/meson.build b/meson.build
index 714c8bf93..7e60e9c19 100644
--- a/meson.build
+++ b/meson.build
@@ -219,7 +219,6 @@ headers = [
   'linux/magic.h',
   'locale.h',
   'mach/mach_time.h',
-  'malloc.h',
   'memory.h',
   'mntent.h',
   'poll.h',
@@ -266,6 +265,13 @@ foreach h : headers
   endif
 endforeach
 
+# FIXME: Use cc.check_header from Meson 0.47.
+# FreeBSD includes a malloc.h which always throw compilation error.
+if cc.compiles('#include <malloc.h>', name : 'malloc.h')
+  glib_conf.set('HAVE_MALLOC_H', 1)
+  glib_conf_prefix = glib_conf_prefix + '#define HAVE_MALLOC_H 1\n'
+endif
+
 if cc.has_header('linux/netlink.h')
   glib_conf.set('HAVE_NETLINK', 1)
 endif


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