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.
This commit is contained in:
Ting-Wei Lan 2018-05-26 12:14:35 +08:00
parent 12a7f27256
commit f752515925

View File

@ -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