2021-09-06 20:45:26 +08:00
|
|
|
project('libfuse3', ['c'], version: '3.10.5',
|
2018-10-16 21:06:19 +08:00
|
|
|
meson_version: '>= 0.42',
|
2021-04-14 01:54:10 +08:00
|
|
|
default_options: [
|
|
|
|
'buildtype=debugoptimized',
|
|
|
|
'cpp_std=c++11',
|
|
|
|
'warning_level=2',
|
|
|
|
])
|
2017-01-06 01:37:00 +08:00
|
|
|
|
2017-08-03 19:44:32 +08:00
|
|
|
|
|
|
|
platform = host_machine.system()
|
|
|
|
if platform == 'darwin'
|
|
|
|
error('libfuse does not support OS-X.\n' +
|
|
|
|
'Take a look at http://osxfuse.github.io/ instead')
|
|
|
|
elif platform == 'cygwin' or platform == 'windows'
|
|
|
|
error('libfuse does not support Windows.\n' +
|
|
|
|
'Take a look at http://www.secfs.net/winfsp/ instead')
|
|
|
|
endif
|
|
|
|
|
2017-01-06 01:37:00 +08:00
|
|
|
#
|
|
|
|
# Feature detection
|
|
|
|
#
|
|
|
|
cfg = configuration_data()
|
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
|
|
|
|
# Default includes when checking for presence of functions and
|
|
|
|
# struct members
|
2018-07-05 02:43:23 +08:00
|
|
|
include_default = '''
|
2017-01-06 01:37:00 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
2018-07-05 02:43:23 +08:00
|
|
|
'''
|
2017-01-24 04:06:25 +08:00
|
|
|
args_default = [ '-D_GNU_SOURCE' ]
|
2017-01-06 01:37:00 +08:00
|
|
|
|
|
|
|
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',
|
2019-04-18 16:55:42 +08:00
|
|
|
'utimensat', 'copy_file_range', 'fallocate' ]
|
2017-01-06 01:37:00 +08:00
|
|
|
foreach func : test_funcs
|
|
|
|
cfg.set('HAVE_' + func.to_upper(),
|
2017-01-24 04:06:25 +08:00
|
|
|
cc.has_function(func, prefix: include_default, args: args_default))
|
2017-01-06 01:37:00 +08:00
|
|
|
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',
|
2017-01-24 04:06:25 +08:00
|
|
|
prefix: include_default,
|
|
|
|
args: args_default))
|
2017-01-06 01:37:00 +08:00
|
|
|
cfg.set('HAVE_STRUCT_STAT_ST_ATIMESPEC',
|
|
|
|
cc.has_member('struct stat', 'st_atimespec',
|
2017-01-24 04:06:25 +08:00
|
|
|
prefix: include_default,
|
|
|
|
args: args_default))
|
2017-01-06 01:37:00 +08:00
|
|
|
|
|
|
|
# Write the test results into config.h (stored in build directory)
|
|
|
|
configure_file(output: 'config.h',
|
|
|
|
configuration : cfg)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Compiler configuration
|
|
|
|
#
|
2021-04-14 01:54:10 +08:00
|
|
|
add_project_arguments('-D_REENTRANT', '-DHAVE_CONFIG_H', '-Wno-sign-compare',
|
2018-08-21 03:32:10 +08:00
|
|
|
'-Wstrict-prototypes', '-Wmissing-declarations', '-Wwrite-strings',
|
|
|
|
'-fno-strict-aliasing', language: 'c')
|
2019-05-06 01:11:03 +08:00
|
|
|
add_project_arguments('-D_REENTRANT', '-DHAVE_CONFIG_H', '-D_GNU_SOURCE',
|
2021-04-14 01:54:10 +08:00
|
|
|
'-Wno-sign-compare', '-Wmissing-declarations',
|
|
|
|
'-Wwrite-strings', '-fno-strict-aliasing', language: 'cpp')
|
2017-01-06 01:37:00 +08:00
|
|
|
|
|
|
|
# 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')
|
2018-08-21 03:32:10 +08:00
|
|
|
add_project_arguments('-Wno-unused-result', language: 'c')
|
2017-01-06 01:37:00 +08:00
|
|
|
endif
|
|
|
|
|
2020-09-11 17:15:43 +08:00
|
|
|
# gcc-10 and newer support the symver attribute which we need to use if we
|
|
|
|
# want to support LTO
|
2020-09-12 16:28:27 +08:00
|
|
|
# recent clang and gcc both support __has_attribute (and if they are too old
|
|
|
|
# to have __has_attribute, then they are too old to support symver)
|
|
|
|
# other compilers might not have __has_attribute, but in those cases
|
|
|
|
# it is safe for this check to fail and for us to fallback to the old _asm_
|
2021-08-04 05:39:46 +08:00
|
|
|
# method for symver. Anyway the attributes not supported by __has_attribute()
|
|
|
|
# unfortunately return true giving a false positive. So let's try to build
|
|
|
|
# using __attribute__ ((symver )) and see the result.
|
2020-09-11 17:15:43 +08:00
|
|
|
code = '''
|
2021-08-04 05:39:46 +08:00
|
|
|
__attribute__ ((symver ("test@TEST")))
|
|
|
|
void foo(void) {
|
|
|
|
}
|
2020-09-12 16:28:27 +08:00
|
|
|
|
2020-09-11 17:15:43 +08:00
|
|
|
int main(void) {
|
|
|
|
return 0;
|
|
|
|
}'''
|
2021-08-04 05:39:46 +08:00
|
|
|
if cc.compiles(code, args: [ '-O0', '-c', '-Werror'])
|
2020-09-11 17:15:43 +08:00
|
|
|
message('Compiler supports symver attribute')
|
|
|
|
add_project_arguments('-DHAVE_SYMVER_ATTRIBUTE', language: 'c')
|
|
|
|
else
|
|
|
|
message('Compiler does not support symver attribute')
|
|
|
|
endif
|
|
|
|
|
2017-03-16 07:52:39 +08:00
|
|
|
# '.' will refer to current build directory, which contains config.h
|
|
|
|
include_dirs = include_directories('include', 'lib', '.')
|
2017-01-06 01:37:00 +08:00
|
|
|
|
|
|
|
# Common dependencies
|
|
|
|
thread_dep = dependency('threads')
|
|
|
|
|
|
|
|
#
|
|
|
|
# Read build files from sub-directories
|
|
|
|
#
|
2021-06-09 16:07:25 +08:00
|
|
|
subdirs = [ 'lib', 'include']
|
2018-09-07 07:07:19 +08:00
|
|
|
if get_option('utils') and not platform.endswith('bsd') and platform != 'dragonfly'
|
|
|
|
subdirs += [ 'util', 'doc' ]
|
2017-08-03 20:04:36 +08:00
|
|
|
endif
|
2018-09-07 07:07:19 +08:00
|
|
|
|
|
|
|
if get_option('examples')
|
|
|
|
subdirs += 'example'
|
|
|
|
endif
|
|
|
|
|
2021-06-09 16:07:25 +08:00
|
|
|
if get_option('tests')
|
|
|
|
subdirs += 'test'
|
|
|
|
endif
|
|
|
|
|
2017-01-06 01:37:00 +08:00
|
|
|
foreach n : subdirs
|
|
|
|
subdir(n)
|
|
|
|
endforeach
|