|
| 1 | +project('liburing', ['c','cpp'], |
| 2 | + version: '2.0', |
| 3 | + license: ['MIT', 'LGPL-2.1-only', 'GPL-2.0-only WITH Linux-syscall-note'], |
| 4 | + meson_version: '>=0.53.0', |
| 5 | + default_options: ['default_library=both', |
| 6 | + 'buildtype=debugoptimized', |
| 7 | + 'c_std=c11', |
| 8 | + 'cpp_std=c++11', |
| 9 | + 'warning_level=2']) |
| 10 | + |
| 11 | +add_project_arguments('-D_GNU_SOURCE', |
| 12 | + '-D__SANE_USERSPACE_TYPES__', |
| 13 | + '-include', meson.current_build_dir() + '/config-host.h', |
| 14 | + '-Wno-unused-parameter', |
| 15 | + '-Wno-sign-compare', |
| 16 | + '-fomit-frame-pointer', |
| 17 | + language: ['c', 'cpp']) |
| 18 | + |
| 19 | +thread_dep = dependency('threads') |
| 20 | + |
| 21 | +cc = meson.get_compiler('c') |
| 22 | + |
| 23 | +has_stringop_overflow = cc.has_argument('-Wstringop-overflow') |
| 24 | +has_array_bounds = cc.has_argument('-Warray-bounds') |
| 25 | + |
| 26 | +has__kernel_rwf_t = cc.has_type('__kernel_rwf_t', prefix: '#include <linux/fs.h>') |
| 27 | + |
| 28 | +has__kernel_timespec = cc.has_members('struct __kernel_timespec', |
| 29 | + 'tv_sec', |
| 30 | + 'tv_nsec', |
| 31 | + prefix: '#include <linux/time.h>') |
| 32 | + |
| 33 | +code = '''#include <sys/types.h> |
| 34 | +#include <sys/stat.h> |
| 35 | +#include <fcntl.h> |
| 36 | +#include <string.h> |
| 37 | +int main(int argc, char **argv) |
| 38 | +{ |
| 39 | + struct open_how how; |
| 40 | + how.flags = 0; |
| 41 | + how.mode = 0; |
| 42 | + how.resolve = 0; |
| 43 | + return 0; |
| 44 | +} |
| 45 | +''' |
| 46 | +has_open_how = cc.compiles(code, name: 'open_how') |
| 47 | + |
| 48 | +code = '''#include <sys/types.h> |
| 49 | +#include <sys/stat.h> |
| 50 | +#include <unistd.h> |
| 51 | +#include <fcntl.h> |
| 52 | +#include <string.h> |
| 53 | +#include <linux/stat.h> |
| 54 | +int main(int argc, char **argv) |
| 55 | +{ |
| 56 | + struct statx x; |
| 57 | +
|
| 58 | + return memset(&x, 0, sizeof(x)) != NULL; |
| 59 | +} |
| 60 | +''' |
| 61 | +has_statx = cc.compiles(code, name: 'statx') |
| 62 | + |
| 63 | +cpp = meson.get_compiler('cpp') |
| 64 | + |
| 65 | +code = '''#include <iostream> |
| 66 | +int main(int argc, char **argv) |
| 67 | +{ |
| 68 | + std::cout << "Test"; |
| 69 | + return 0; |
| 70 | +} |
| 71 | +''' |
| 72 | +has_cxx = cpp.compiles(code, name: 'C++') |
| 73 | + |
| 74 | +has_ucontext = cc.has_type('ucontext_t', prefix: '#include <ucontext.h>') |
| 75 | + |
| 76 | +conf_data = configuration_data() |
| 77 | +conf_data.set('CONFIG_HAVE_KERNEL_RWF_T', has__kernel_rwf_t) |
| 78 | +conf_data.set('CONFIG_HAVE_KERNEL_TIMESPEC', has__kernel_timespec) |
| 79 | +conf_data.set('CONFIG_HAVE_OPEN_HOW', has_open_how) |
| 80 | +conf_data.set('CONFIG_HAVE_STATX', has_statx) |
| 81 | +conf_data.set('CONFIG_HAVE_CXX', has_cxx) |
| 82 | +conf_data.set('CONFIG_HAVE_UCONTEXT', has_ucontext) |
| 83 | +configure_file(output: 'config-host.h', |
| 84 | + configuration: conf_data) |
| 85 | + |
| 86 | +subdir('src') |
| 87 | +subdir('man') |
| 88 | + |
| 89 | +if get_option('examples') |
| 90 | + subdir('examples') |
| 91 | +endif |
| 92 | + |
| 93 | +if get_option('tests') |
| 94 | + if get_option('default_library') != 'both' |
| 95 | + error('default_library=both required to build tests') |
| 96 | + endif |
| 97 | + subdir('test') |
| 98 | +endif |
| 99 | + |
| 100 | +pkg_mod = import('pkgconfig') |
| 101 | +pkg_mod.generate(libraries: liburing, |
| 102 | + name: 'liburing', |
| 103 | + version: meson.project_version(), |
| 104 | + description: 'io_uring library', |
| 105 | + url: 'http://git.kernel.dk/cgit/liburing/') |
| 106 | + |
| 107 | +summary({'bindir': get_option('bindir'), |
| 108 | + 'libdir': get_option('libdir'), |
| 109 | + 'datadir': get_option('datadir'), |
| 110 | + }, section: 'Directories') |
| 111 | +summary({'examples': get_option('examples'), |
| 112 | + 'tests': get_option('tests') |
| 113 | + }, section: 'Configuration', bool_yn: true) |
0 commit comments