"Fossies" - the Fresh Open Source Software Archive

Member "fuse-3.10.4/meson.build" (9 Jun 2021, 4568 Bytes) of package /linux/misc/fuse-3.10.4.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "meson.build": 3.10.3_vs_3.10.4.

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