blob: 0f1a77f7f1f02b301e2a5bd0e51b131f525f6961 [file] [log] [blame]
Nikolaus Rath4afe7ca2019-11-03 09:53:39 +00001project('libfuse3', ['cpp', 'c'], version: '3.8.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 Rath055f2722019-05-05 13:11:03 -040069add_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')
Nikolaus Rath9f96db72017-01-05 09:37:00 -080073
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')
Martin Blanchard52469902018-08-20 20:32:10 +010087 add_project_arguments('-Wno-unused-result', language: 'c')
Nikolaus Rath9f96db72017-01-05 09:37:00 -080088endif
89
Nikolaus Rath4b586352017-03-15 16:52:39 -070090# '.' will refer to current build directory, which contains config.h
91include_dirs = include_directories('include', 'lib', '.')
Nikolaus Rath9f96db72017-01-05 09:37:00 -080092
93# Common dependencies
94thread_dep = dependency('threads')
95
96#
97# Read build files from sub-directories
98#
Martin Blanchard4a6a5da2018-09-07 00:07:19 +010099subdirs = [ 'lib', 'include', 'test' ]
100if get_option('utils') and not platform.endswith('bsd') and platform != 'dragonfly'
101 subdirs += [ 'util', 'doc' ]
Baptiste Daroussin66943702017-08-03 14:04:36 +0200102endif
Martin Blanchard4a6a5da2018-09-07 00:07:19 +0100103
104if get_option('examples')
105 subdirs += 'example'
106endif
107
Nikolaus Rath9f96db72017-01-05 09:37:00 -0800108foreach n : subdirs
109 subdir(n)
110endforeach