1project('libfuse3', ['cpp', 'c'], version: '3.8.0', 2 meson_version: '>= 0.42', 3 default_options: [ 'buildtype=debugoptimized' ]) 4 5 6platform = host_machine.system() 7if platform == 'darwin' 8 error('libfuse does not support OS-X.\n' + 9 'Take a look at http://osxfuse.github.io/ instead') 10elif platform == 'cygwin' or platform == 'windows' 11 error('libfuse does not support Windows.\n' + 12 'Take a look at http://www.secfs.net/winfsp/ instead') 13endif 14 15# 16# Feature detection 17# 18cfg = configuration_data() 19cc = meson.get_compiler('c') 20 21# Default includes when checking for presence of functions and 22# struct members 23include_default = ''' 24#include <stdio.h> 25#include <stdlib.h> 26#include <stddef.h> 27#include <unistd.h> 28#include <sys/types.h> 29#include <sys/stat.h> 30#include <fcntl.h> 31''' 32args_default = [ '-D_GNU_SOURCE' ] 33 34cfg.set_quoted('PACKAGE_VERSION', meson.project_version()) 35 36# Test for presence of some functions 37test_funcs = [ 'fork', 'fstatat', 'openat', 'readlinkat', 'pipe2', 38 'splice', 'vmsplice', 'posix_fallocate', 'fdatasync', 39 'utimensat', 'copy_file_range', 'fallocate' ] 40foreach func : test_funcs 41 cfg.set('HAVE_' + func.to_upper(), 42 cc.has_function(func, prefix: include_default, args: args_default)) 43endforeach 44cfg.set('HAVE_SETXATTR', 45 cc.has_function('setxattr', prefix: '#include <sys/xattr.h>')) 46cfg.set('HAVE_ICONV', 47 cc.has_function('iconv', prefix: '#include <iconv.h>')) 48 49# Test if structs have specific member 50cfg.set('HAVE_STRUCT_STAT_ST_ATIM', 51 cc.has_member('struct stat', 'st_atim', 52 prefix: include_default, 53 args: args_default)) 54cfg.set('HAVE_STRUCT_STAT_ST_ATIMESPEC', 55 cc.has_member('struct stat', 'st_atimespec', 56 prefix: include_default, 57 args: args_default)) 58 59# Write the test results into config.h (stored in build directory) 60configure_file(output: 'config.h', 61 configuration : cfg) 62 63# 64# Compiler configuration 65# 66add_project_arguments('-D_REENTRANT', '-DHAVE_CONFIG_H', '-Wall', '-Wextra', '-Wno-sign-compare', 67 '-Wstrict-prototypes', '-Wmissing-declarations', '-Wwrite-strings', 68 '-fno-strict-aliasing', language: 'c') 69add_project_arguments('-D_REENTRANT', '-DHAVE_CONFIG_H', '-D_GNU_SOURCE', 70 '-Wall', '-Wextra', '-Wno-sign-compare', '-std=c++11', 71 '-Wmissing-declarations', '-Wwrite-strings', 72 '-fno-strict-aliasing', language: 'cpp') 73 74# Some (stupid) GCC versions warn about unused return values even when they are 75# casted to void. This makes -Wunused-result pretty useless, since there is no 76# way to suppress the warning when we really *want* to ignore the value. 77code = ''' 78__attribute__((warn_unused_result)) int get_4() { 79 return 4; 80} 81int main(void) { 82 (void) get_4(); 83 return 0; 84}''' 85if not cc.compiles(code, args: [ '-O0', '-Werror=unused-result' ]) 86 message('Compiler warns about unused result even when casting to void') 87 add_project_arguments('-Wno-unused-result', language: 'c') 88endif 89 90# '.' will refer to current build directory, which contains config.h 91include_dirs = include_directories('include', 'lib', '.') 92 93# Common dependencies 94thread_dep = dependency('threads') 95 96# 97# Read build files from sub-directories 98# 99subdirs = [ 'lib', 'include', 'test' ] 100if get_option('utils') and not platform.endswith('bsd') and platform != 'dragonfly' 101 subdirs += [ 'util', 'doc' ] 102endif 103 104if get_option('examples') 105 subdirs += 'example' 106endif 107 108foreach n : subdirs 109 subdir(n) 110endforeach 111