forked from libfuse/libfuse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
101 lines (88 loc) · 3.15 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
project('libfuse3', 'c', version: '3.2.0',
meson_version: '>= 0.38',
default_options: [ 'buildtype=debugoptimized' ])
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
#
# Feature detection
#
cfg = configuration_data()
cc = meson.get_compiler('c')
# Default includes when checking for presence of functions and
# struct members
include_default = '
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
'
args_default = [ '-D_GNU_SOURCE' ]
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, args: args_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,
args: args_default))
cfg.set('HAVE_STRUCT_STAT_ST_ATIMESPEC',
cc.has_member('struct stat', 'st_atimespec',
prefix: include_default,
args: args_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',
'-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
# '.' will refer to current build directory, which contains config.h
include_dirs = include_directories('include', 'lib', '.')
# Common dependencies
thread_dep = dependency('threads')
#
# Read build files from sub-directories
#
subdirs = [ 'lib', 'include', 'example', 'doc', 'test' ]
if not platform.endswith('bsd')
subdirs += 'util'
endif
foreach n : subdirs
subdir(n)
endforeach