aboutsummaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2017-01-05 09:37:00 -0800
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2017-01-12 15:19:04 -0800
commit9f96db71252fc66b72c433e2ca0d49e031c6a5fd (patch)
tree494132dae14dba3de18a9013f2299cfc37cceda5 /meson.build
parent3006686b536942f6f96675e3d12b793087e78e6a (diff)
Added experimental support for building with Meson+Ninja
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build90
1 files changed, 90 insertions, 0 deletions
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..0cce4af
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,90 @@
+# Attention, emacs, please use -*- mode: python -*-
+# (even though this isn't actually Python code)
+
+project('libfuse3', 'c', version: '3.1.0',
+ default_options: [ 'buildtype=plain' ])
+
+#
+# Feature detection
+#
+cfg = configuration_data()
+cc = meson.get_compiler('c')
+
+# Default includes when checking for presence of functions and
+# struct members
+include_default = '
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+'
+
+cfg.set_quoted('PACKAGE_VERSION', meson.project_version())
+
+# Test for presence of some functions
+test_funcs = [ 'fork', 'fstatat', 'openat', 'readlinkat', 'pipe2',
+ 'splice', 'vmsplice', 'posix_fallocate', 'fdatasync',
+ 'utimensat' ]
+foreach func : test_funcs
+ cfg.set('HAVE_' + func.to_upper(),
+ cc.has_function(func, prefix: include_default))
+endforeach
+cfg.set('HAVE_SETXATTR',
+ cc.has_function('setxattr', prefix: '#include <sys/xattr.h>'))
+cfg.set('HAVE_ICONV',
+ cc.has_function('iconv', prefix: '#include <iconv.h>'))
+
+# Test if structs have specific member
+cfg.set('HAVE_STRUCT_STAT_ST_ATIM',
+ cc.has_member('struct stat', 'st_atim',
+ prefix: include_default))
+cfg.set('HAVE_STRUCT_STAT_ST_ATIMESPEC',
+ cc.has_member('struct stat', 'st_atimespec',
+ prefix: include_default))
+
+# Write the test results into config.h (stored in build directory)
+configure_file(output: 'config.h',
+ configuration : cfg)
+
+
+#
+# Compiler configuration
+#
+add_global_arguments('-D_REENTRANT', '-DHAVE_CONFIG_H', '-Wall', '-Wextra', '-Wno-sign-compare',
+ '-Wstrict-prototypes', '-Wmissing-declarations', '-Wwrite-strings',
+ '-O2', '-g', '-fno-strict-aliasing', language: 'c')
+
+# Some (stupid) GCC versions warn about unused return values even when they are
+# casted to void. This makes -Wunused-result pretty useless, since there is no
+# way to suppress the warning when we really *want* to ignore the value.
+code = '''
+__attribute__((warn_unused_result)) int get_4() {
+ return 4;
+}
+int main(void) {
+ (void) get_4();
+ return 0;
+}'''
+if not cc.compiles(code, args: [ '-O0', '-Werror=unused-result' ])
+ message('Compiler warns about unused result even when casting to void')
+ add_global_arguments('-Wno-unused-result', language: 'c')
+endif
+
+# current_build_dir() contains config.h
+include_dirs = include_directories('include', 'lib',
+ meson.current_build_dir())
+
+# Common dependencies
+thread_dep = dependency('threads')
+
+#
+# Read build files from sub-directories
+#
+subdirs = [ 'lib', 'include', 'util', 'example', 'doc', 'test' ]
+foreach n : subdirs
+ subdir(n)
+endforeach