meson: make it easy to add headers to check
authorEric Engestrom <eric.engestrom@imgtec.com>
Mon, 12 Mar 2018 16:17:55 +0000 (16:17 +0000)
committerEric Engestrom <eric.engestrom@imgtec.com>
Wed, 14 Mar 2018 09:47:39 +0000 (09:47 +0000)
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
meson.build

index a0c79e3..b85f1d7 100644 (file)
@@ -186,12 +186,11 @@ else
   dep_rt = []
 endif
 dep_m = cc.find_library('m', required : false)
-if cc.compiles('#include <sys/sysctl.h>', name : 'sys/sysctl.h works')
-  config.set10('HAVE_SYS_SYSCTL_H', true)
-endif
-if cc.compiles('#include <sys/select.h>', name : 'sys/select.h works')
-  config.set10('HAVE_SYS_SELECT_H', true)
-endif
+foreach header : ['sys/sysctl.h', 'sys/select.h']
+  if cc.compiles('#include <@0@>'.format(header), name : '@0@ works'.format(header))
+    config.set10('HAVE_' + header.underscorify().to_upper(), true)
+  endif
+endforeach
 if cc.has_header_symbol('sys/sysmacros.h', 'major')
   config.set10('MAJOR_IN_SYSMACROS', true)
 elif cc.has_header_symbol('sys/mkdev.h', 'major')