• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1project('libfuse3', ['c'], version: '3.10.5',
2        meson_version: '>= 0.42',
3        default_options: [
4            'buildtype=debugoptimized',
5            'cpp_std=c++11',
6            'warning_level=2',
7        ])
8
9
10platform = host_machine.system()
11if platform == 'darwin'
12  error('libfuse does not support OS-X.\n' +
13        'Take a look at http://osxfuse.github.io/ instead')
14elif platform == 'cygwin' or platform == 'windows'
15  error('libfuse does not support Windows.\n' +
16        'Take a look at http://www.secfs.net/winfsp/ instead')
17endif
18
19#
20# Feature detection
21#
22cfg = configuration_data()
23cc = meson.get_compiler('c')
24
25# Default includes when checking for presence of functions and
26# struct members
27include_default = '''
28#include <stdio.h>
29#include <stdlib.h>
30#include <stddef.h>
31#include <unistd.h>
32#include <sys/types.h>
33#include <sys/stat.h>
34#include <fcntl.h>
35'''
36args_default = [ '-D_GNU_SOURCE' ]
37
38cfg.set_quoted('PACKAGE_VERSION', meson.project_version())
39
40# Test for presence of some functions
41test_funcs = [ 'fork', 'fstatat', 'openat', 'readlinkat', 'pipe2',
42               'splice', 'vmsplice', 'posix_fallocate', 'fdatasync',
43               'utimensat', 'copy_file_range', 'fallocate' ]
44foreach func : test_funcs
45    cfg.set('HAVE_' + func.to_upper(),
46        cc.has_function(func, prefix: include_default, args: args_default))
47endforeach
48cfg.set('HAVE_SETXATTR',
49        cc.has_function('setxattr', prefix: '#include <sys/xattr.h>'))
50cfg.set('HAVE_ICONV',
51        cc.has_function('iconv', prefix: '#include <iconv.h>'))
52
53# Test if structs have specific member
54cfg.set('HAVE_STRUCT_STAT_ST_ATIM',
55         cc.has_member('struct stat', 'st_atim',
56                       prefix: include_default,
57                       args: args_default))
58cfg.set('HAVE_STRUCT_STAT_ST_ATIMESPEC',
59         cc.has_member('struct stat', 'st_atimespec',
60                       prefix: include_default,
61                       args: args_default))
62
63# Write the test results into config.h (stored in build directory)
64configure_file(output: 'config.h',
65               configuration : cfg)
66
67#
68# Compiler configuration
69#
70add_project_arguments('-D_REENTRANT', '-DHAVE_CONFIG_H', '-Wno-sign-compare',
71                      '-Wstrict-prototypes', '-Wmissing-declarations', '-Wwrite-strings',
72                      '-fno-strict-aliasing', language: 'c')
73add_project_arguments('-D_REENTRANT', '-DHAVE_CONFIG_H', '-D_GNU_SOURCE',
74                     '-Wno-sign-compare', '-Wmissing-declarations',
75                     '-Wwrite-strings', '-fno-strict-aliasing', language: 'cpp')
76
77# Some (stupid) GCC versions warn about unused return values even when they are
78# casted to void. This makes -Wunused-result pretty useless, since there is no
79# way to suppress the warning when we really *want* to ignore the value.
80code = '''
81__attribute__((warn_unused_result)) int get_4() {
82    return 4;
83}
84int main(void) {
85    (void) get_4();
86    return 0;
87}'''
88if not cc.compiles(code, args: [ '-O0', '-Werror=unused-result' ])
89     message('Compiler warns about unused result even when casting to void')
90     add_project_arguments('-Wno-unused-result', language: 'c')
91endif
92
93# gcc-10 and newer support the symver attribute which we need to use if we
94# want to support LTO
95# recent clang and gcc both support __has_attribute (and if they are too old
96# to have __has_attribute, then they are too old to support symver)
97# other compilers might not have __has_attribute, but in those cases
98# it is safe for this check to fail and for us to fallback to the old _asm_
99# method for symver. Anyway the attributes not supported by __has_attribute()
100# unfortunately return true giving a false positive. So let's try to build
101# using __attribute__ ((symver )) and see the result.
102code = '''
103__attribute__ ((symver ("test@TEST")))
104void foo(void) {
105}
106
107int main(void) {
108    return 0;
109}'''
110if cc.compiles(code, args: [ '-O0', '-c', '-Werror'])
111     message('Compiler supports symver attribute')
112     add_project_arguments('-DHAVE_SYMVER_ATTRIBUTE', language: 'c')
113else
114     message('Compiler does not support symver attribute')
115endif
116
117# '.' will refer to current build directory, which contains config.h
118include_dirs = include_directories('include', 'lib', '.')
119
120# Common dependencies
121thread_dep = dependency('threads')
122
123#
124# Read build files from sub-directories
125#
126subdirs = [ 'lib', 'include']
127if get_option('utils') and not platform.endswith('bsd') and platform != 'dragonfly'
128  subdirs += [ 'util', 'doc' ]
129endif
130
131if get_option('examples')
132  subdirs += 'example'
133endif
134
135if get_option('tests')
136  subdirs += 'test'
137endif
138
139foreach n : subdirs
140    subdir(n)
141endforeach
142