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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
project('libfuse3', ['c'],
version: '3.17.4',
meson_version: '>= 0.60.0',
default_options: [
'buildtype=debugoptimized',
'c_std=gnu11',
'cpp_std=c++17',
'warning_level=2',
],
)
# --- Versionsaufbereitung (wie bisher) ---
version_parts = meson.project_version().split('-')
base_version = version_parts[0]
version_list = base_version.split('.')
FUSE_MAJOR_VERSION = version_list[0]
FUSE_MINOR_VERSION = version_list[1]
FUSE_HOTFIX_VERSION = version_list[2]
FUSE_RC_VERSION = version_parts.length() > 1 ? version_parts[1] : ''
platform = host_machine.system()
if platform == 'darwin'
error('libfuse does not support OS-X.\n' +
'See http://osxfuse.github.io/ or https://www.fuse-t.org/')
elif platform == 'cygwin' or platform == 'windows'
error('libfuse does not support Windows.\n' +
'See http://www.secfs.net/winfsp/')
endif
cc = meson.get_compiler('c')
# --- Öffentliche Konfiguration, wird installiert (libfuse_config.h) ---
public_cfg = configuration_data()
public_cfg.set('FUSE_MAJOR_VERSION', FUSE_MAJOR_VERSION)
public_cfg.set('FUSE_MINOR_VERSION', FUSE_MINOR_VERSION)
public_cfg.set('FUSE_HOTFIX_VERSION', FUSE_HOTFIX_VERSION)
public_cfg.set('FUSE_RC_VERSION', FUSE_RC_VERSION)
# --- Private Konfiguration, nur beim Bauen (fuse_config.h) ---
private_cfg = configuration_data()
private_cfg.set_quoted('PACKAGE_VERSION', meson.project_version())
# Default-Includes/Args für Funktions-/Struct-Checks
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>
#include <pthread.h>
'''
args_default = ['-D_GNU_SOURCE']
# Funktionschecks
foreach func : [
'fork','fstatat','openat','readlinkat','pipe2','splice','vmsplice',
'posix_fallocate','fdatasync','utimensat','copy_file_range','fallocate'
]
private_cfg.set('HAVE_' + func.to_upper(),
cc.has_function(func, prefix: include_default, args: args_default)
)
endforeach
# Spezialfälle, die gelinkt werden müssen
special_funcs = {
'pthread_setname_np' : '''
#include <pthread.h>
int main(void) {
pthread_t t = pthread_self();
pthread_setname_np(t, "test");
return 0;
}''',
'close_range' : '''
#include <unistd.h>
#include <fcntl.h>
#include <linux/close_range.h>
int main(void){
unsigned int flags = CLOSE_RANGE_UNSHARE;
return close_range(3, ~0U, flags);
}'''
}
foreach name, code : special_funcs
private_cfg.set('HAVE_' + name.to_upper(),
cc.links(code, args: args_default, name: name + ' check')
)
endforeach
# Weitere Checks
private_cfg.set('HAVE_SETXATTR', cc.has_function('setxattr', prefix: '#include <sys/xattr.h>'))
private_cfg.set('HAVE_ICONV', cc.has_function('iconv', prefix: '#include <iconv.h>'))
private_cfg.set('HAVE_BACKTRACE', cc.has_function('backtrace', prefix: '#include <execinfo.h>'))
# Struct-Member
private_cfg.set('HAVE_STRUCT_STAT_ST_ATIM',
cc.has_member('struct stat', 'st_atim',
prefix: include_default + '#include <sys/stat.h>',
args: args_default
)
)
private_cfg.set('HAVE_STRUCT_STAT_ST_ATIMESPEC',
cc.has_member('struct stat', 'st_atimespec',
prefix: include_default + '#include <sys/stat.h>',
args: args_default
)
)
# --- Compiler-/Projektflags ---
add_project_arguments(
[
'-D_REENTRANT',
'-DHAVE_LIBFUSE_PRIVATE_CONFIG_H',
'-Wno-sign-compare',
'-D_FILE_OFFSET_BITS=64',
'-Wstrict-prototypes',
'-Wmissing-declarations',
'-Wwrite-strings',
'-fno-strict-aliasing',
],
language: 'c'
)
add_project_arguments(
[
'-D_REENTRANT',
'-DHAVE_LIBFUSE_PRIVATE_CONFIG_H',
'-D_GNU_SOURCE',
'-D_FILE_OFFSET_BITS=64',
'-Wno-sign-compare',
'-Wmissing-declarations',
'-Wwrite-strings',
'-fno-strict-aliasing',
],
language: 'cpp'
)
# Warnung "unused result" ggf. neutralisieren (wie bisher)
code_unused_result = '''
__attribute__((warn_unused_result)) int get_4() { return 4; }
int main(void) { (void)get_4(); return 0; }
'''
if not cc.compiles(code_unused_result, args: ['-O0','-Werror=unused-result'])
message('Compiler warns about unused result even when casting to void')
add_project_arguments('-Wno-unused-result', language: 'c')
endif
# --- Versionierte Symbole (wie bisher) ---
versioned_symbols = 1
code_libc = '''
int main(void) {
#if (defined(__UCLIBC__) || defined(__APPLE__))
#error
#endif
return 0;
}'''
if not cc.compiles(code_libc, args: ['-O0'])
versioned_symbols = 0
endif
if get_option('disable-libc-symbol-version')
versioned_symbols = 0
endif
if versioned_symbols == 1
message('Enabling versioned libc symbols')
public_cfg.set('LIBFUSE_BUILT_WITH_VERSIONED_SYMBOLS', 1)
code_symver = '''
__attribute__ ((symver("test@TEST"))) void foo(void) {}
int main(void){ return 0; }
'''
if cc.compiles(code_symver, args: ['-O0','-c','-Werror'])
message('Compiler supports symver attribute')
add_project_arguments('-DHAVE_SYMVER_ATTRIBUTE', language: 'c')
else
message('Compiler does not support symver attribute')
endif
else
message('Disabling versioned libc symbols')
endif
# --- Workaround für bestimmte musl-Varianten (unverändert) ---
detect_getmntent_needs_unescape = '''
#define _GNU_SOURCE
#include <mntent.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define dir_space_tab "dir\\040space\\011tab"
int main() {
const char *fake_mtab = "name " dir_space_tab " type opts 0 0\\n";
FILE *f = fmemopen((void *)fake_mtab, strlen(fake_mtab)+1, "r");
struct mntent *entp = getmntent(f);
fclose(f);
if (!entp) return 1;
if (strcmp(entp->mnt_dir, dir_space_tab)==0)
printf("needs escaping\\n");
else
printf("no need to escape\\n");
}
'''
if not meson.is_cross_build()
r = cc.run(detect_getmntent_needs_unescape)
if r.compiled() and r.returncode() == 0 and r.stdout().strip() == 'needs escaping'
message('getmntent does not unescape')
add_project_arguments('-DGETMNTENT_NEEDS_UNESCAPING', language: 'c')
endif
endif
# --- Header mit Ergebnissen erzeugen ---
configure_file(output: 'fuse_config.h', configuration: private_cfg)
configure_file(
output: 'libfuse_config.h',
configuration: public_cfg,
install: true,
install_dir: join_paths(get_option('includedir'), 'fuse3'),
)
# Includes (Builddir enthält fuse_config.h)
include_dirs = include_directories('include', 'lib', '.')
# --- Gemeinsame Dependencies ---
# Threads (niemals -lpthread in öffentliche Libs packen!)
thread_dep = dependency('threads')
# dl: auf Android unnötig (bionic liefert das intern),
# auf anderen Linuxen weiter verfügbar halten.
dl_dep = cc.find_library('dl', required: platform != 'android')
# Für Android (und generell) lieber das Flag -pthread setzen,
# statt -lpthread zu verlinken.
add_project_link_arguments('-pthread', language: 'c')
# Diese Variable wird in lib/meson.build beim pkgconfig.generate()
# als libraries_private: verwendet, damit -lpthread/-ldl NICHT in Libs: landen.
fuse_pc_libs_private = []
if thread_dep.found()
fuse_pc_libs_private += thread_dep
endif
if dl_dep.found()
fuse_pc_libs_private += dl_dep
endif
# --- Unterverzeichnisse bauen ---
subdirs = ['lib', 'include']
if get_option('utils') and not platform.endswith('bsd') and platform != 'dragonfly'
subdirs += ['util', 'doc']
endif
if get_option('examples')
subdirs += 'example'
endif
if get_option('tests')
subdirs += 'test'
endif
foreach n : subdirs
subdir(n)
endforeach
|