diff options
author | Leonard Kugis <leonard@kug.is> | 2025-10-02 17:57:20 +0200 |
---|---|---|
committer | Leonard Kugis <leonard@kug.is> | 2025-10-02 17:57:20 +0200 |
commit | 0b693eca087419554361df06c66664a3c651fe74 (patch) | |
tree | 9fb0c363e446308561d9b478d2fe2515ede2963f /meson.build | |
parent | 65e1d31000f6a31c882134277758b03cb980581a (diff) | |
download | bindfs-0b693eca087419554361df06c66664a3c651fe74.tar.gz |
Adjusted meson config for android compatibility
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 135 |
1 files changed, 76 insertions, 59 deletions
diff --git a/meson.build b/meson.build index 7f2adef..bcef245 100644 --- a/meson.build +++ b/meson.build @@ -1,78 +1,95 @@ -project( - 'bindfs', - 'c', - version: '0.0.0', - default_options: ['warning_level=2', 'c_std=gnu11'] +project('bindfs', 'c', + version: '1.18.2', + default_options: [ + 'c_std=gnu11', # wie configure.ac für FUSE3 + 'warning_level=2' + ] ) +# --- config.h erzeugen (Ersatz für AC_CONFIG_HEADERS + Checks) --- cc = meson.get_compiler('c') +conf = configuration_data() + +# Entspricht PACKAGE_STRING aus configure.ac +conf.set('PACKAGE_STRING', '"@0@ @1@"'.format(meson.project_name(), meson.project_version())) -# ---- Abhängigkeiten ---- -# Bevorzuge FUSE2 (alte API), falle auf FUSE3 zurück. -fuse_dep = dependency('fuse', required: false) # pkg-config: fuse (FUSE2) -if fuse_dep.found() - add_project_arguments('-DFUSE_USE_VERSION=26', language: 'c') # FUSE2 API -else - fuse_dep = dependency('fuse3', required: true) - add_project_arguments('-DFUSE_USE_VERSION=30', language: 'c') # FUSE3 API - add_project_arguments('-DBINDFS_USE_FUSE3', language: 'c') +# Header-/Funktions-Checks wie in configure.ac +if cc.has_header('sys/file.h') + conf.set('HAVE_SYS_FILE_H', 1) endif -threads_dep = dependency('threads', required: true) -dl_dep = cc.find_library('dl', required: true) -rt_dep = cc.find_library('rt', required: false) -iconv_dep = dependency('iconv', required: false) +# utimensat / lutimes / futimesat +if cc.has_function('utimensat', prefix: ''' + #include <fcntl.h> + #include <sys/stat.h> + #include <sys/types.h> + #include <unistd.h> +''') + conf.set('HAVE_UTIMENSAT', 1) +endif -deps = [fuse_dep, threads_dep, dl_dep] -if rt_dep.found() - deps += rt_dep +if cc.has_function('lutimes', prefix: '#include <sys/time.h>') + conf.set('HAVE_LUTIMES', 1) endif -if iconv_dep.found() - deps += iconv_dep + +if cc.has_function('futimesat', prefix: ''' + #include <sys/time.h> + #include <fcntl.h> +''') + conf.set('HAVE_FUTIMESAT', 1) endif -# ---- Allgemeine Compiler-Flags ---- -# GNU-Extensions (pipe2 etc.) & große Offsets. -add_project_arguments( - '-D_GNU_SOURCE', - '-D_FILE_OFFSET_BITS=64', - # S_ISDIR etc.: stellt sicher, dass <sys/stat.h> überall drin ist - '-include', 'sys/stat.h', - language: 'c' -) +# xattr-Funktionen +foreach f : ['setxattr','getxattr','listxattr','removexattr', + 'lsetxattr','lgetxattr','llistxattr','lremovexattr'] + if cc.has_function(f, prefix: '#include <sys/xattr.h>') + conf.set('HAVE_@0@'.format(f.to_upper()), 1) + endif +endforeach + +# struct stat ... tv_nsec vorhanden? +have_stat_nsec = cc.compiles(''' + #include <sys/types.h> + #include <sys/stat.h> + #include <unistd.h> + int main(void){ struct stat st; st.st_mtim.tv_nsec = 123; return 0; } +''') +if have_stat_nsec + conf.set('HAVE_STAT_NANOSEC', 1) +endif -# ---- Feature-Checks (ersetzt configure.ac) ---- -# Achtung: passende Includes pro Funktion setzen. -have_pipe2 = cc.has_function('pipe2', prefix: '#include <unistd.h>') -have_posix_spawn = cc.has_function('posix_spawn', prefix: '#include <spawn.h>') -have_copy_file_range = cc.has_function('copy_file_range', prefix: '#include <unistd.h>') +# config.h in der Build-Root erzeugen +configure_file(output: 'config.h', configuration: conf) -# Utimens-Varianten – bindfs.c entscheidet anhand dieser Makros: -have_utimensat = cc.has_function('utimensat', prefix: '#define _GNU_SOURCE\n#include <sys/stat.h>\n#include <fcntl.h>') -have_lutimes = cc.has_function('lutimes', prefix: '#include <sys/time.h>') -have_futimesat = cc.has_function('futimesat', prefix: '#include <sys/time.h>\n#include <fcntl.h>\n#include <unistd.h>') +# Dependencies +fuse3_dep = dependency('fuse3', version: '>=3.4.0', required: true) +#threads = dependency('threads') +dl_dep = cc.find_library('dl', required: true) +iconv_dep = dependency('iconv', required: false) # Android: yes; Linux: ja nach System -conf = configuration_data() -conf.set('HAVE_PIPE2', have_pipe2) -conf.set('HAVE_POSIX_SPAWN', have_posix_spawn) -conf.set('HAVE_COPY_FILE_RANGE', have_copy_file_range) +# Entspricht my_CPPFLAGS in configure.ac +add_project_arguments( + [ + '-D_REENTRANT', + '-D_FILE_OFFSET_BITS=64', + '-D_XOPEN_SOURCE=700', + '-D__BSD_VISIBLE=1', + '-D_BSD_SOURCE', + '-D_DEFAULT_SOURCE', + # Autotools bei FUSE3: + '-DHAVE_FUSE_3=1', + '-DFUSE_USE_VERSION=34', # genau wie CHECK_FUSE3 in configure.ac + ], + language: 'c' +) -# Diese drei sind wichtig, damit der #error in bindfs_utimens nicht triggert: -conf.set('HAVE_UTIMENSAT', have_utimensat) -conf.set('HAVE_LUTIMES', have_lutimes) -conf.set('HAVE_FUTIMESAT', have_futimesat) +add_project_arguments(['-include', 'sys/stat.h'], language: 'c') # required for S_ISDIR -# Autotools-kompatible Makros, die der Code nutzt -conf.set_quoted('PACKAGE_NAME', meson.project_name()) -conf.set_quoted('PACKAGE_VERSION', meson.project_version()) -conf.set_quoted('PACKAGE_STRING', meson.project_name() + ' ' + meson.project_version()) +# Entspricht my_CFLAGS / my_LDFLAGS +add_project_arguments(['-Wall','-Wextra','-Wpedantic','-fno-common'], language: 'c') -# Exakt "config.h" erzeugen (liegt im Build-Root) -configure_file(output: 'config.h', configuration: conf) +add_project_arguments(['-pthread'], language: 'c') +add_project_link_arguments(['-pthread'], language: 'c') -# ---- Unterverzeichnisse ---- subdir('src') -# ---- Manpage installieren ---- -install_data('src/bindfs.1', install_dir: get_option('mandir') / 'man1') - |