blob: 5797fec3fa7eff51efe375e56154ab8765880ac0 [file] [log] [blame]
Nikolaus Rath7bf25b62019-04-07 15:05:00 +01001project('libfuse3', 'c', version: '3.5.0',
Nikolaus Rathe469e1f2018-10-16 06:06:19 -07002 meson_version: '>= 0.42',
Nikolaus Rath9d4ec142017-08-22 11:10:00 +02003 default_options: [ 'buildtype=debugoptimized' ])
Nikolaus Rath9f96db72017-01-05 09:37:00 -08004
Nikolaus Rath430661d2017-08-03 13:44:32 +02005
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
Nikolaus Rath9f96db72017-01-05 09:37:00 -080015#
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
Nikolaus Rath0a519c92018-07-04 19:43:23 +010023include_default = '''
Nikolaus Rath9f96db72017-01-05 09:37:00 -080024#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 Rath0a519c92018-07-04 19:43:23 +010031'''
Nikolaus Rath61c419d2017-01-23 12:06:25 -080032args_default = [ '-D_GNU_SOURCE' ]
Nikolaus Rath9f96db72017-01-05 09:37:00 -080033
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',
Liu Bo5fc562c2019-04-18 01:55:42 -070039 'utimensat', 'copy_file_range', 'fallocate' ]
Nikolaus Rath9f96db72017-01-05 09:37:00 -080040foreach func : test_funcs
41 cfg.set('HAVE_' + func.to_upper(),
Nikolaus Rath61c419d2017-01-23 12:06:25 -080042 cc.has_function(func, prefix: include_default, args: args_default))
Nikolaus Rath9f96db72017-01-05 09:37:00 -080043endforeach
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',
Nikolaus Rath61c419d2017-01-23 12:06:25 -080052 prefix: include_default,
53 args: args_default))
Nikolaus Rath9f96db72017-01-05 09:37:00 -080054cfg.set('HAVE_STRUCT_STAT_ST_ATIMESPEC',
55 cc.has_member('struct stat', 'st_atimespec',
Nikolaus Rath61c419d2017-01-23 12:06:25 -080056 prefix: include_default,
57 args: args_default))
Nikolaus Rath9f96db72017-01-05 09:37:00 -080058
59# Write the test results into config.h (stored in build directory)
60configure_file(output: 'config.h',
61 configuration : cfg)
62
Nikolaus Rath9f96db72017-01-05 09:37:00 -080063#
64# Compiler configuration
65#
Martin Blanchard52469902018-08-20 20:32:10 +010066add_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 Rath9f96db72017-01-05 09:37:00 -080069
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.
73code = '''
74__attribute__((warn_unused_result)) int get_4() {
75 return 4;
76}
77int main(void) {
78 (void) get_4();
79 return 0;
80}'''
81if not cc.compiles(code, args: [ '-O0', '-Werror=unused-result' ])
82 message('Compiler warns about unused result even when casting to void')
Martin Blanchard52469902018-08-20 20:32:10 +010083 add_project_arguments('-Wno-unused-result', language: 'c')
Nikolaus Rath9f96db72017-01-05 09:37:00 -080084endif
85
Nikolaus Rath4b586352017-03-15 16:52:39 -070086# '.' will refer to current build directory, which contains config.h
87include_dirs = include_directories('include', 'lib', '.')
Nikolaus Rath9f96db72017-01-05 09:37:00 -080088
89# Common dependencies
90thread_dep = dependency('threads')
91
92#
93# Read build files from sub-directories
94#
Martin Blanchard4a6a5da2018-09-07 00:07:19 +010095subdirs = [ 'lib', 'include', 'test' ]
96if get_option('utils') and not platform.endswith('bsd') and platform != 'dragonfly'
97 subdirs += [ 'util', 'doc' ]
Baptiste Daroussin66943702017-08-03 14:04:36 +020098endif
Martin Blanchard4a6a5da2018-09-07 00:07:19 +010099
100if get_option('examples')
101 subdirs += 'example'
102endif
103
Nikolaus Rath9f96db72017-01-05 09:37:00 -0800104foreach n : subdirs
105 subdir(n)
106endforeach