1# 2# project definition 3# 4project('spice-common', 'c', 5 meson_version : '>= 0.48.0', 6 license : 'LGPLv2.1', 7 default_options : ['warning_level=2']) 8 9if not meson.is_subproject() 10 warning('This project is only intended to be used as a subproject!') 11endif 12 13# some global vars 14spice_common_global_cflags = ['-DG_LOG_DOMAIN="Spice"', 15 '-Wno-unused-parameter'] 16 17if get_option('alignment-checks') 18 spice_common_global_cflags += ['-DSPICE_DEBUG_ALIGNMENT'] 19endif 20 21spice_common_deps = [] 22spice_common_include = include_directories('.') 23 24spice_proto = files('spice.proto') 25spice_codegen = files('spice_codegen.py') 26spice_codegen_files = [spice_codegen] 27 28compiler = meson.get_compiler('c') 29spice_common_config_data = configuration_data() 30if get_option('extra-checks') 31 spice_common_config_data.set('ENABLE_EXTRA_CHECKS', '1') 32endif 33if host_machine.endian() == 'big' 34 spice_common_config_data.set('WORDS_BIGENDIAN', '1') 35endif 36 37if get_option('instrumentation') == 'recorder' 38 spice_common_config_data.set('ENABLE_RECORDER', '1') 39endif 40if get_option('instrumentation') == 'agent' 41 spice_common_config_data.set('ENABLE_AGENT_INTERFACE', '1') 42endif 43 44spice_common_generate_code = get_option('generate-code') 45spice_common_generate_client_code = spice_common_generate_code == 'all' or spice_common_generate_code == 'client' 46spice_common_generate_server_code = spice_common_generate_code == 'all' or spice_common_generate_code == 'server' 47 48# 49# check for system headers 50# 51headers = ['alloca.h', 52 'arpa/inet.h', 53 'dlfcn.h', 54 'inttypes.h', 55 'netinet/in.h', 56 'stdlib.h', 57 'sys/socket.h', 58 'sys/stat.h', 59 'sys/types.h', 60 'unistd.h', 61 'regex.h', 62 'sys/mman.h'] 63 64foreach header : headers 65 if compiler.has_header(header) 66 spice_common_config_data.set('HAVE_@0@'.format(header.underscorify().to_upper()), '1') 67 endif 68endforeach 69 70# 71# check for system functions 72# 73functions = ['alloca', 74 'sigaction', 75 'drand48', 76 'setlinebuf'] 77 78foreach func : functions 79 if compiler.has_function(func) 80 spice_common_config_data.set('HAVE_@0@'.format(func.underscorify().to_upper()), '1') 81 endif 82endforeach 83 84# FIXME 85# check for libm, as workaround for https://github.com/mesonbuild/meson/issues/3740 86libm = compiler.find_library('m', required : false) 87if libm.found() 88 spice_common_deps += libm 89endif 90 91# 92# check for mandatory dependencies 93# 94glib_version = '2.38' 95glib_version_info = '>= @0@'.format(glib_version) 96 97spice_protocol_version = '0.14.2' 98 99spice_protocol_version_req = get_option('spice-protocol-version') 100if spice_protocol_version_req.version_compare('> @0@'.format(spice_protocol_version)) 101 spice_protocol_version = spice_protocol_version_req 102endif 103 104deps = {'spice-protocol' : '>= @0@'.format(spice_protocol_version), 105 'glib-2.0' : glib_version_info, 106 'pixman-1' : '>= 0.17.7', 107 'openssl' : '>= 1.0.0'} 108 109foreach dep, version : deps 110 spice_common_deps += dependency(dep, version : version) 111endforeach 112 113gio2_deps = dependency('gio-2.0', version : glib_version_info) 114 115# 116# Non-mandatory/optional dependencies 117# 118optional_deps = {'opus' : '>= 0.9.14'} 119foreach dep, version : optional_deps 120 d = dependency(dep, required : get_option(dep), version : version) 121 if d.found() 122 spice_common_deps += d 123 spice_common_config_data.set('HAVE_@0@'.format(dep.underscorify().to_upper()), '1') 124 endif 125endforeach 126 127# Python 128if spice_common_generate_client_code or spice_common_generate_server_code 129 py_module = import('python') 130 python = py_module.find_installation() 131 132 if get_option('python-checks') 133 foreach module : ['six', 'pyparsing'] 134 message('Checking for python module @0@'.format(module)) 135 cmd = run_command(python, '-m', module) 136 if cmd.returncode() != 0 137 error('Python module @0@ not found'.format(module)) 138 endif 139 endforeach 140 endif 141endif 142 143# smartcard check 144smartcard_dep = dependency('libcacard', required : get_option('smartcard'), version : '>= 2.5.1') 145if smartcard_dep.found() 146 spice_common_deps += smartcard_dep 147 spice_common_config_data.set('USE_SMARTCARD', '1') 148endif 149 150# 151# global C defines 152# 153glib_encoded_version = 'GLIB_VERSION_@0@'.format(glib_version.underscorify()) 154spice_common_global_cflags += ['-DGLIB_VERSION_MIN_REQUIRED=@0@'.format(glib_encoded_version), 155 '-DGLIB_VERSION_MAX_ALLOWED=@0@'.format(glib_encoded_version)] 156 157add_project_arguments(compiler.get_supported_arguments(spice_common_global_cflags), 158 language : 'c') 159 160# 161# Subdirectories 162# 163subdir('python_modules') 164subdir('common') 165if get_option('tests') 166 subdir('tests') 167endif 168subdir('docs') 169 170# 171# write config.h 172# 173configure_file(output : 'config.h', 174 configuration : spice_common_config_data) 175