Skip to content

Commit

Permalink
fuse: clean up meson build
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Sep 3, 2022
1 parent 8bb8925 commit b4bb222
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 144 deletions.
1 change: 1 addition & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@
"fuse"
],
"versions": [
"2.9.9-2",
"2.9.9-1"
]
},
Expand Down
95 changes: 46 additions & 49 deletions subprojects/packagefiles/fuse/lib/meson.build
Original file line number Diff line number Diff line change
@@ -1,66 +1,63 @@
libfuse_sources = [
'fuse.c',
'fuse_i.h',
'fuse_kern_chan.c',
'fuse_loop.c',
'fuse_loop_mt.c',
'fuse_lowlevel.c',
'fuse_misc.h',
'fuse_mt.c',
'fuse_opt.c',
'fuse_session.c',
'fuse_signals.c',
'buffer.c',
'cuse_lowlevel.c',
'helper.c',
'modules/subdir.c',
]
libfuse_sources = files(
'fuse.c',
'fuse_kern_chan.c',
'fuse_loop.c',
'fuse_loop_mt.c',
'fuse_lowlevel.c',
'fuse_misc.h',
'fuse_mt.c',
'fuse_opt.c',
'fuse_session.c',
'fuse_signals.c',
'buffer.c',
'cuse_lowlevel.c',
'helper.c',
'modules/subdir.c',
)

if host_machine.system().startswith('linux')
libfuse_sources += [ 'mount.c', 'mount_util.c' ]
else
libfuse_sources += [ 'mount_bsd.c' ]
endif
libfuse_sources += host_machine.system() == 'linux' ? files('mount.c', 'mount_util.c') : files('mount_bsd.c')

deps = [ thread_dep ]
if cfg.get('HAVE_ICONV')
libfuse_sources += [ 'modules/iconv.c' ]
libiconv = cc.find_library('iconv', required: false)
if libiconv.found()
deps += [ libiconv ]
endif
libfuse_sources += files('modules/iconv.c')
deps += iconv_dep
endif

libdl = cc.find_library('dl', required: false)
if meson.version().version_compare('>= 0.62')
libdl = dependency('dl')
else
libdl = cc.find_library('dl', required: false)
endif
if libdl.found()
deps += [ libdl ]
deps += libdl
endif

if host_machine.system().startswith('netbsd')
deps += [ cc.find_library('perfuse'),
cc.find_library('puffs') ]
deps += cc.find_library('perfuse')
deps += cc.find_library('puffs')
else
# Required for clock_gettime before glibc 2.17
deps += cc.find_library('rt')
# Required for clock_gettime before glibc 2.17
deps += cc.find_library('rt')
endif

fusermount_path = join_paths(get_option('prefix'), get_option('bindir'))
libfuse = library('fuse', libfuse_sources, version: meson.project_version(),
soversion: '2', include_directories: include_dirs,
dependencies: deps, install: true,
link_depends: 'fuse_versionscript',
c_args: [ '-DFUSE_USE_VERSION=35',
'-DFUSERMOUNT_DIR="@0@"'.format(fusermount_path) ],
link_args: ['-Wl,--version-script,' + meson.current_source_dir()
+ '/fuse_versionscript' ])
libfuse = library(
'fuse',
libfuse_sources,
version: meson.project_version(),
include_directories: include_dirs,
dependencies: deps,
install: true,
link_depends: 'fuse_versionscript',
c_args: ['-DFUSE_USE_VERSION=26', '-DFUSERMOUNT_DIR="@0@"'.format(fusermount_path)],
link_args: ['-Wl,--version-script,' + meson.current_source_dir() + '/fuse_versionscript'],
)

pkg = import('pkgconfig')
pkg.generate(libraries: [ libfuse, '-lpthread' ],
libraries_private: '-ldl',
version: meson.project_version(),
name: 'fuse',
description: 'Filesystem in Userspace',
subdirs: 'fuse')
pkg.generate(
libfuse,
description: 'Filesystem in Userspace',
subdirs: 'fuse',
)

libfuse_dep = declare_dependency(include_directories: include_dirs,
link_with: libfuse, dependencies: deps)
libfuse_dep = declare_dependency(include_directories: include_dirs, link_with: libfuse, dependencies: deps)
142 changes: 64 additions & 78 deletions subprojects/packagefiles/fuse/meson.build
Original file line number Diff line number Diff line change
@@ -1,94 +1,81 @@
project('libfuse3', ['c'], version: '2.9.9',
meson_version: '>= 0.49',
default_options: [
'buildtype=debugoptimized',
'cpp_std=c++11',
'warning_level=2',
])

project('libfuse', 'c', version: '2.9.9', default_options: ['buildtype=debugoptimized'], meson_version: '>=0.49.0')

platform = host_machine.system()
if platform == 'darwin'
error('libfuse does not support OS-X.\n' +
'Take a look at http://osxfuse.github.io/ instead')
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')
error('libfuse does not support Windows.\n' + 'Take a look at http://www.secfs.net/winfsp/ instead')
endif

# Common dependencies
if meson.version().version_compare('>= 0.60')
iconv_dep = dependency('iconv', required: false)
else
iconv_open_snippet = '''#include <iconv.h>
int main() {
iconv_open("","");
}'''
have_iconv = compiler.links(iconv_open_snippet, name: 'iconv_open')
if not have_iconv
iconv_dep = compiler.find_library('iconv', required: false)
else
iconv_dep = declare_dependency()
endif
endif
thread_dep = dependency('threads')

#
# 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', 'copy_file_range', 'fallocate' ]
foreach func : test_funcs
cfg.set('HAVE_' + func.to_upper(),
cc.has_function(func, prefix: include_default, args: args_default))
test_funcs = [
'fork',
'fstatat',
'openat',
'readlinkat',
'pipe2',
'splice',
'vmsplice',
'posix_fallocate',
'fdatasync',
'utimensat',
'copy_file_range',
'fallocate',
]
foreach f : test_funcs
cfg.set('HAVE_@0@'.format(f.underscorify().to_upper()), cc.has_function(f))
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>'))

cfg.set('HAVE_SETXATTR', cc.has_function('setxattr', prefix: '#include <sys/xattr.h>'))
cfg.set('HAVE_ICONV', iconv_dep.found())

# 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))
foreach m : [ 'st_atim', 'st_atimespec' ]
cfg.set('HAVE_STRUCT_STAT_@0@'.format(m.underscorify().to_upper()), cc.has_member('struct stat', m, prefix: '#include <sys/stat.h>\n', args: '-D_GNU_SOURCE'))
endforeach

# Write the test results into config.h (stored in build directory)
configure_file(output: 'config.h',
configuration : cfg)
configure_file(output: 'config.h', configuration: cfg)

#
# Compiler configuration
#
add_project_arguments('-D_REENTRANT', '-DHAVE_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_CONFIG_H', '-D_GNU_SOURCE', '-D_FILE_OFFSET_BITS=64',
'-Wno-sign-compare', '-Wmissing-declarations',
'-Wwrite-strings', '-fno-strict-aliasing', language: 'cpp')

# 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_project_arguments('-Wno-unused-result', language: 'c')
endif
add_project_arguments(
'-D_REENTRANT',
'-DHAVE_CONFIG_H',
'-Wno-sign-compare',
'-Wno-unused-result',
'-Wstrict-prototypes',
'-Wmissing-declarations',
'-Wwrite-strings',
'-fno-strict-aliasing',
language: 'c',
)

# gcc-10 and newer support the symver attribute which we need to use if we
# want to support LTO
Expand All @@ -97,7 +84,8 @@ endif
# 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_
# method for symver
code = '''
code = (
'''
#if defined __has_attribute
# if !__has_attribute (symver)
# error symver attribute not supported
Expand All @@ -109,27 +97,25 @@ code = '''
int main(void) {
return 0;
}'''
if cc.compiles(code, args: [ '-O0', '-c'])
message('Compiler supports symver attribute')
add_project_arguments('-DHAVE_SYMVER_ATTRIBUTE', language: 'c')
)
if cc.compiles(code, args: ['-O0', '-c'])
message('Compiler supports symver attribute')
add_project_arguments('-DHAVE_SYMVER_ATTRIBUTE', language: 'c')
else
message('Compiler does not support symver attribute')
message('Compiler does not support symver attribute')
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']
subdirs = ['lib', 'include']
if get_option('utils') and not platform.endswith('bsd') and platform != 'dragonfly'
subdirs += [ 'util' ]
subdirs += 'util'
endif

foreach n : subdirs
subdir(n)
subdir(n)
endforeach
43 changes: 26 additions & 17 deletions subprojects/packagefiles/fuse/util/meson.build
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
executable('fusermount', ['fusermount.c', '../lib/mount_util.c'],
include_directories: include_dirs,
install: true,
install_dir: get_option('bindir')
)
executable(
'fusermount',
'fusermount.c',
'../lib/mount_util.c',
include_directories: include_dirs,
install: true,
)

executable('ulockmgr_server', ['ulockmgr_server.c'],
include_directories: include_dirs,
install: true,
dependencies: [dependency('threads')],
install_dir: get_option('bindir')
)
#does not compile with glibc greater than 2.33
if cc.get_define('__GLIBC_MINOR__', prefix: '#include <stdint.h>\n') < '34'
executable(
'ulockmgr_server',
'ulockmgr_server.c',
include_directories: include_dirs,
install: true,
dependencies: thread_dep,
)
endif

executable('mount.fuse', ['mount.fuse.c'],
include_directories: include_dirs,
link_with: [ libfuse ],
install: true,
install_dir: get_option('sbindir'),
c_args: '-DFUSE_USE_VERSION=26')
executable(
'mount.fuse',
'mount.fuse.c',
include_directories: include_dirs,
link_with: libfuse,
install: true,
install_dir: get_option('sbindir'),
c_args: '-DFUSE_USE_VERSION=26',
)


udevrulesdir = get_option('udevrulesdir')
Expand Down

0 comments on commit b4bb222

Please sign in to comment.