Nikolaus Rath | 7bf25b6 | 2019-04-07 15:05:00 +0100 | [diff] [blame] | 1 | project('libfuse3', 'c', version: '3.5.0', |
Nikolaus Rath | e469e1f | 2018-10-16 06:06:19 -0700 | [diff] [blame] | 2 | meson_version: '>= 0.42', |
Nikolaus Rath | 9d4ec14 | 2017-08-22 11:10:00 +0200 | [diff] [blame] | 3 | default_options: [ 'buildtype=debugoptimized' ]) |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 4 | |
Nikolaus Rath | 430661d | 2017-08-03 13:44:32 +0200 | [diff] [blame] | 5 | |
| 6 | platform = host_machine.system() |
| 7 | if platform == 'darwin' |
| 8 | error('libfuse does not support OS-X.\n' + |
| 9 | 'Take a look at http://osxfuse.github.io/ instead') |
| 10 | elif platform == 'cygwin' or platform == 'windows' |
| 11 | error('libfuse does not support Windows.\n' + |
| 12 | 'Take a look at http://www.secfs.net/winfsp/ instead') |
| 13 | endif |
| 14 | |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 15 | # |
| 16 | # Feature detection |
| 17 | # |
| 18 | cfg = configuration_data() |
| 19 | cc = meson.get_compiler('c') |
| 20 | |
| 21 | # Default includes when checking for presence of functions and |
| 22 | # struct members |
Nikolaus Rath | 0a519c9 | 2018-07-04 19:43:23 +0100 | [diff] [blame] | 23 | include_default = ''' |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 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> |
Nikolaus Rath | 0a519c9 | 2018-07-04 19:43:23 +0100 | [diff] [blame] | 31 | ''' |
Nikolaus Rath | 61c419d | 2017-01-23 12:06:25 -0800 | [diff] [blame] | 32 | args_default = [ '-D_GNU_SOURCE' ] |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 33 | |
| 34 | cfg.set_quoted('PACKAGE_VERSION', meson.project_version()) |
| 35 | |
| 36 | # Test for presence of some functions |
| 37 | test_funcs = [ 'fork', 'fstatat', 'openat', 'readlinkat', 'pipe2', |
| 38 | 'splice', 'vmsplice', 'posix_fallocate', 'fdatasync', |
Liu Bo | 5fc562c | 2019-04-18 01:55:42 -0700 | [diff] [blame^] | 39 | 'utimensat', 'copy_file_range', 'fallocate' ] |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 40 | foreach func : test_funcs |
| 41 | cfg.set('HAVE_' + func.to_upper(), |
Nikolaus Rath | 61c419d | 2017-01-23 12:06:25 -0800 | [diff] [blame] | 42 | cc.has_function(func, prefix: include_default, args: args_default)) |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 43 | endforeach |
| 44 | cfg.set('HAVE_SETXATTR', |
| 45 | cc.has_function('setxattr', prefix: '#include <sys/xattr.h>')) |
| 46 | cfg.set('HAVE_ICONV', |
| 47 | cc.has_function('iconv', prefix: '#include <iconv.h>')) |
| 48 | |
| 49 | # Test if structs have specific member |
| 50 | cfg.set('HAVE_STRUCT_STAT_ST_ATIM', |
| 51 | cc.has_member('struct stat', 'st_atim', |
Nikolaus Rath | 61c419d | 2017-01-23 12:06:25 -0800 | [diff] [blame] | 52 | prefix: include_default, |
| 53 | args: args_default)) |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 54 | cfg.set('HAVE_STRUCT_STAT_ST_ATIMESPEC', |
| 55 | cc.has_member('struct stat', 'st_atimespec', |
Nikolaus Rath | 61c419d | 2017-01-23 12:06:25 -0800 | [diff] [blame] | 56 | prefix: include_default, |
| 57 | args: args_default)) |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 58 | |
| 59 | # Write the test results into config.h (stored in build directory) |
| 60 | configure_file(output: 'config.h', |
| 61 | configuration : cfg) |
| 62 | |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 63 | # |
| 64 | # Compiler configuration |
| 65 | # |
Martin Blanchard | 5246990 | 2018-08-20 20:32:10 +0100 | [diff] [blame] | 66 | add_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') |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 69 | |
| 70 | # Some (stupid) GCC versions warn about unused return values even when they are |
| 71 | # casted to void. This makes -Wunused-result pretty useless, since there is no |
| 72 | # way to suppress the warning when we really *want* to ignore the value. |
| 73 | code = ''' |
| 74 | __attribute__((warn_unused_result)) int get_4() { |
| 75 | return 4; |
| 76 | } |
| 77 | int main(void) { |
| 78 | (void) get_4(); |
| 79 | return 0; |
| 80 | }''' |
| 81 | if not cc.compiles(code, args: [ '-O0', '-Werror=unused-result' ]) |
| 82 | message('Compiler warns about unused result even when casting to void') |
Martin Blanchard | 5246990 | 2018-08-20 20:32:10 +0100 | [diff] [blame] | 83 | add_project_arguments('-Wno-unused-result', language: 'c') |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 84 | endif |
| 85 | |
Nikolaus Rath | 4b58635 | 2017-03-15 16:52:39 -0700 | [diff] [blame] | 86 | # '.' will refer to current build directory, which contains config.h |
| 87 | include_dirs = include_directories('include', 'lib', '.') |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 88 | |
| 89 | # Common dependencies |
| 90 | thread_dep = dependency('threads') |
| 91 | |
| 92 | # |
| 93 | # Read build files from sub-directories |
| 94 | # |
Martin Blanchard | 4a6a5da | 2018-09-07 00:07:19 +0100 | [diff] [blame] | 95 | subdirs = [ 'lib', 'include', 'test' ] |
| 96 | if get_option('utils') and not platform.endswith('bsd') and platform != 'dragonfly' |
| 97 | subdirs += [ 'util', 'doc' ] |
Baptiste Daroussin | 6694370 | 2017-08-03 14:04:36 +0200 | [diff] [blame] | 98 | endif |
Martin Blanchard | 4a6a5da | 2018-09-07 00:07:19 +0100 | [diff] [blame] | 99 | |
| 100 | if get_option('examples') |
| 101 | subdirs += 'example' |
| 102 | endif |
| 103 | |
Nikolaus Rath | 9f96db7 | 2017-01-05 09:37:00 -0800 | [diff] [blame] | 104 | foreach n : subdirs |
| 105 | subdir(n) |
| 106 | endforeach |