meson.build (10707B)
1 project( 2 'taler-exchange', 3 'c', 4 license: 'AGPLv3', 5 meson_version: '>=1.1.0', 6 version: run_command('sh', 'scripts/get_version.sh', check: true).stdout().strip(), 7 ) 8 9 cc = meson.get_compiler('c') 10 incdir = include_directories('src/include') 11 12 # Used to populate gnunet_private_config.h 13 private_config = configuration_data() 14 cdata = configuration_data() 15 16 pkgcfgdir = get_option('datadir') / 'taler-exchange' / 'config.d' 17 docdir = get_option('datadir') / 'doc' / 'taler-exchange' 18 19 if get_option('install-rpath') 20 rpath_option = get_option('prefix') / get_option('libdir') 21 else 22 rpath_option = '' 23 endif 24 25 install_emptydir(docdir) 26 install_data('README', 'COPYING', install_dir: docdir) 27 28 gnunet_user = false 29 dpkg_architecture_bin = find_program( 30 'dpkg-architecture', 31 '/usr/bin/getent', 32 required: false, 33 ) 34 if dpkg_architecture_bin.found() 35 private_config.set( 36 'MULTIARCH', 37 dpkg_architecture_bin.full_path() + ' -qDEB_HOST_MULTIARCH', 38 ) 39 endif 40 41 TALER_PLUGIN_LDFLAGS = [ 42 '-export-dynamic', 43 '-avoid-version', 44 '-module', 45 '--no-undefined', 46 ] 47 48 if not get_option('only-doc') 49 add_project_arguments( 50 '-Wall', 51 '-Wno-address-of-packed-member', 52 language: 'c', 53 ) 54 taler_lib_ldflags = '-export-dynamic -no-undefined' 55 56 check_headers = [ 57 'stdint.h', 58 'stdlib.h', 59 'string.h', 60 'unistd.h', 61 'sys/socket.h', 62 'sys/un.h', 63 'netinet/in.h', 64 'netinet/ip.h', 65 ] 66 67 foreach h : check_headers 68 if cc.check_header(h) 69 define = 'HAVE_' + h.underscorify().to_upper() 70 message(define) 71 private_config.set(define, 1) 72 endif 73 endforeach 74 75 76 py_mod = import('python') 77 py3 = py_mod.find_installation('python3') 78 run_command( 79 py3.full_path(), 80 '-c', 81 'import jinja2', 82 capture: false, 83 check: true, 84 ) 85 86 private_config.set10('HAVE_EXPENSIVE_TESTS', get_option('expensivetests')) 87 88 have_epoll = false 89 if get_option('enable-epoll') != 'no' 90 have_epoll = cc.has_header('sys/epoll.h') 91 endif 92 private_config.set10('EPOLL_SUPPORT', have_epoll) 93 if have_epoll 94 private_config.set10( 95 'HAVE_EPOLL_CREATE1', 96 cc.has_header_symbol('sys/epoll.h', 'epoll_create1'), 97 ) 98 elif get_option('enable-epoll') == 'yes' 99 error( 100 'Support for epoll was explicitly requested but cannot be enabled on this platform.', 101 ) 102 endif 103 104 mhd_dep = dependency('libmicrohttpd', required: false) 105 if not mhd_dep.found() 106 mhd_dep = cc.find_library('microhttpd', required: true) 107 endif 108 109 mhd2_dep = dependency('libmicrohttpd2', required: false) 110 if not mhd2_dep.found() 111 mhd_dep2 = cc.find_library('microhttpd2', required: false) 112 endif 113 114 json_dep = dependency('jansson', required: false) 115 if not json_dep.found() 116 json_dep = cc.find_library('jansson', required: true) 117 endif 118 119 gcrypt_dep = dependency('libgcrypt', required: false) 120 if not gcrypt_dep.found() 121 gcrypt_dep = cc.find_library('gcrypt', required: true) 122 endif 123 124 private_config.set_quoted('NEED_LIBGCRYPT_VERSION', '1.6.0') 125 #add_project_arguments('-DNEED_LIBGCRYPT_VERSION="1.6.0"', language: 'c') 126 127 gnunetutil_dep = dependency('gnunetutil', required: false) 128 if not gnunetutil_dep.found() 129 gnunetutil_dep = cc.find_library('gnunetutil', required: true) 130 endif 131 132 gnunetjson_dep = dependency('gnunetjson', required: false) 133 if not gnunetjson_dep.found() 134 gnunetjson_dep = cc.find_library('gnunetjson', required: true) 135 endif 136 cc.has_header_symbol( 137 'gnunet/gnunet_json_lib.h', 138 'GNUNET_JSON_spec_string', 139 dependencies: [gnunetjson_dep], 140 required: true, 141 ) 142 143 gnunetmhd_dep = dependency('gnunetmhd', required: false) 144 if not gnunetmhd_dep.found() 145 gnunetmhd_dep = cc.find_library('gnunetmhd', required: true) 146 endif 147 cc.has_header_symbol( 148 'gnunet/gnunet_mhd_lib.h', 149 'GNUNET_MHD_post_parser', 150 dependencies: [gnunetmhd_dep], 151 required: true, 152 ) 153 154 sodium_dep = dependency('libsodium', required: false, version: '>=1.0.18') 155 if not sodium_dep.found() 156 sodium_dep = cc.find_library('sodium', required: true) 157 sodium_version_check = '''#include <sodium.h> 158 int main(int argc, char **argv) { 159 #if !((SODIUM_LIBRARY_VERSION_MAJOR > 10) || \ 160 ((SODIUM_LIBRARY_VERSION_MAJOR == 10) && \ 161 (SODIUM_LIBRARY_VERSION_MINOR >= 3))) 162 #error "libsodium version >= 1.0.18 required" 163 #endif 164 return 0 165 } 166 ''' 167 if not cc.compiles( 168 sodium_version_check, 169 name: 'sodium version check', 170 dependencies: sodium_dep, 171 ) 172 error('libsodium version >=1.0.18 required') 173 endif 174 endif 175 unistr_dep = dependency('libunistring', required: false) 176 if not unistr_dep.found() 177 unistr_dep = cc.find_library('unistring', required: true) 178 endif 179 zlib_dep = dependency('zlib', required: false) 180 if not zlib_dep.found() 181 zlib_dep = cc.find_library('zlib', required: true) 182 endif 183 m_dep = cc.find_library('m', required: false) 184 if m_dep.found() 185 private_config.set('HAVE_LIBM', 1) 186 endif 187 188 189 curl_dep = dependency('libcurl', version: '>=7.34.0', required: false) 190 if not curl_dep.found() 191 curl_dep = cc.find_library('curl', required: true) 192 curl_version_check = '''#include <curl/curl.h> 193 int main(int argc, char **argv) { 194 #if LIBCURL_VERSION_NUM < 0x073400 195 #error "cURL version >= 7.34.0 required" 196 #endif 197 return 0; 198 } 199 ''' 200 if not cc.compiles( 201 curl_version_check, 202 name: 'cURL version check', 203 dependencies: curl_dep, 204 ) 205 error('cURL version >=7.34.0 required') 206 endif 207 endif 208 209 gnunetcurl_dep = dependency('gnunetcurl', required: false) 210 if not gnunetcurl_dep.found() 211 gnunetcurl_dep = cc.find_library('gnunetcurl', required: true) 212 endif 213 cc.has_header_symbol( 214 'gnunet/gnunet_curl_lib.h', 215 'GNUNET_CURL_get_select_info', 216 dependencies: [gnunetcurl_dep], 217 required: true, 218 ) 219 220 pq_dep = dependency('libpq', required: false) 221 if not pq_dep.found() 222 pq_dep = cc.find_library('pq', required: true) 223 endif 224 225 gnunetpq_dep = dependency('gnunetpq', required: false) 226 if not gnunetpq_dep.found() 227 gnunetpq_dep = cc.find_library('gnunetpq', required: true) 228 endif 229 cc.has_header_symbol( 230 'gnunet/gnunet_pq_lib.h', 231 'GNUNET_PQ_result_spec_blinded_sig', 232 required: true, 233 dependencies: [pq_dep, gnunetpq_dep], 234 ) 235 236 gnunetsq_dep = dependency('gnunetsq', required: false) 237 if not gnunetsq_dep.found() 238 gnunetsq_dep = cc.find_library('gnunetsq', required: true) 239 endif 240 have_gnunetsq = cc.has_header_symbol( 241 'gnunet/gnunet_sq_lib.h', 242 'GNUNET_PQ_result_spec_string', 243 dependencies: [gnunetsq_dep], 244 required: false, 245 ) 246 247 # todo talertwister optional 248 twister_dep = cc.find_library('talertwister', required: false) 249 if twister_dep.found() 250 private_config.set10( 251 'HAVE_TWISTER', 252 cc.has_header_symbol( 253 'taler/taler_twister_service.h', 254 'TALER_TWISTER_connect', 255 dependencies: [twister_dep], 256 ), 257 ) 258 endif 259 260 logging_opt = get_option('logging') 261 logging_verbosity = 0 262 263 if logging_opt == 'yes' 264 logging_verbosity = 1 265 endif 266 if logging_opt == 'no' 267 add_project_arguments('-DGNUNET_CULL_LOGGING=1', language: 'c') 268 endif 269 if logging_opt == 'verbose' 270 logging_verbosity = 2 271 endif 272 if logging_opt == 'veryverbose' 273 logging_verbosity = 3 274 endif 275 276 #add_project_arguments('-DGNUNET_EXTRA_LOGGING=@0@'.format(logging_verbosity), language: 'c') 277 278 279 # todo gcov has meson builtin 280 281 # Used to populate configuration file and script templates 282 283 284 libltversions = [ 285 ['libtalerutil', '17:0:3'], 286 ['libtalerjson', '10:0:6'], 287 ['libtalercurl', '1:0:1'], 288 ['libtalerpq', '1:0:0'], 289 ['libtalermhd', '8:0:1'], 290 ['libtalermhd2', '0:0:0'], 291 ['libtalertemplating', '1:1:1'], 292 ['libtalerbank', '6:0:0'], 293 ['libtalerkyclogic', '3:0:0'], 294 ['libtalerexchangedb', '3:0:0'], 295 ['libtalerauditordb', '1:0:0'], 296 ['libtalerexchange', '24:0:2'], 297 ['libtalerauditor', '1:0:1'], 298 ['libtalertesting', '4:0:0'], 299 ['libtalertwistertesting', '0:1:0'], 300 ] 301 302 solibversions = {} 303 304 foreach libversion : libltversions 305 ltversion = libversion[1].split(':') 306 current = ltversion[0].to_int() 307 revision = ltversion[1].to_int() 308 age = ltversion[2].to_int() 309 soversion_str = '@0@'.format(current - age) 310 ltversion_str = '@0@.@1@.@2@'.format(current - age, age, revision) 311 solibversions = solibversions + { 312 libversion[0]: { 313 'soversion': soversion_str, 314 'version': ltversion_str, 315 }, 316 } 317 endforeach 318 319 private_config.set_quoted('PACKAGE_VERSION', meson.project_version()) 320 # Compatibility. Used in source. 321 private_config.set_quoted('VERSION', meson.project_version()) 322 private_config.set_quoted('PACKAGE_BUGREPORT', 'taler@gnu.org') 323 configure_file(output: 'taler_config.h', configuration: private_config) 324 configuration_inc = include_directories('.') 325 326 cdata.merge_from(private_config) 327 add_project_arguments('-DHAVE_CONFIG_H', language: 'c') 328 329 pkg = import('pkgconfig') 330 subdir('contrib') 331 subdir('src') 332 if not get_option('disable-doc') 333 subdir('doc') 334 endif 335 336 taler_prefix = get_option('prefix') / get_option('libdir') 337 338 # Default setup only does unit tests 339 add_test_setup( 340 'default', 341 env: [ 342 'TALER_EXCHANGE_PREFIX=' + taler_prefix, 343 'TALER_AUDITOR_PREFIX=' + taler_prefix, 344 ], 345 exclude_suites: ['perf', 'installcheck', 'integrationtests'], 346 is_default: true, 347 ) 348 add_test_setup( 349 'all', 350 env: [ 351 'TALER_EXCHANGE_PREFIX=' + taler_prefix, 352 'TALER_AUDITOR_PREFIX=' + taler_prefix, 353 ], 354 ) 355 else 356 subdir('contrib') 357 if not get_option('disable-doc') 358 subdir('doc') 359 endif 360 endif 361 362 run_target( 363 'doxygen', 364 command: 'scripts/doxygen.meson.sh', 365 env: {'PACKAGE_VERSION': meson.project_version()}, 366 ) 367 meson.add_dist_script('meson-dist-script')