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