meson.build (8059B)
1 project( 2 'paivana', 3 'c', 4 license: 'AGPL-3.0-or-later', 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 paivana_config.h 13 private_config = configuration_data() 14 15 docdir = get_option('datadir') / 'doc' / 'paivana' 16 17 if get_option('install-rpath') 18 rpath_option = get_option('prefix') / get_option('libdir') 19 else 20 rpath_option = '' 21 endif 22 23 install_emptydir(docdir) 24 install_data('README', 'COPYING', install_dir: docdir) 25 26 if not get_option('only-doc') 27 add_project_arguments( 28 '-Wall', 29 '-Wno-address-of-packed-member', 30 language: 'c', 31 ) 32 33 # Every header that src/include/platform.h includes behind a 34 # `#if HAVE_..._H' guard has to be probed here. A guard whose macro 35 # is never defined is silently false, so the #include simply does not 36 # happen; keep this list and the guards in platform.h in sync. 37 check_headers = [ 38 'endian.h', 39 'ifaddrs.h', 40 'malloc.h', 41 'netinet/in.h', 42 'netinet/in_systm.h', 43 'netinet/ip.h', 44 'stdint.h', 45 'stdlib.h', 46 'string.h', 47 'sys/endian.h', 48 'sys/param.h', 49 'sys/resource.h', 50 'sys/time.h', 51 'sys/types.h', 52 'sys/ucred.h', 53 'ucred.h', 54 'unistd.h', 55 'vfork.h', 56 ] 57 58 foreach h : check_headers 59 if cc.check_header(h) 60 private_config.set('HAVE_' + h.underscorify().to_upper(), 1) 61 endif 62 endforeach 63 64 # platform.h declares atoll() itself when this is missing. 65 if cc.has_function('atoll', prefix: '#include <stdlib.h>') 66 private_config.set('HAVE_ATOLL', 1) 67 endif 68 69 mhd_dep = dependency('libmicrohttpd', required: false) 70 if not mhd_dep.found() 71 mhd_dep = cc.find_library('microhttpd', required: true) 72 endif 73 74 json_dep = dependency('jansson', required: false) 75 if not json_dep.found() 76 json_dep = cc.find_library('jansson', required: true) 77 endif 78 79 gcrypt_dep = dependency('libgcrypt', version: '>=1.6.1', required: false) 80 if not gcrypt_dep.found() 81 gcrypt_dep = cc.find_library('gcrypt', required: true) 82 gcrypt_version_check = '''#include <gcrypt.h> 83 int main(int argc, char **argv) { 84 #if GCRYPT_VERSION_NUMBER < 0x010601 85 #error "libgcrypt version >= 1.6.1 required" 86 #endif 87 return 0; 88 } 89 ''' 90 if not cc.compiles( 91 gcrypt_version_check, 92 name: 'libgcrypt version check', 93 dependencies: gcrypt_dep, 94 ) 95 error('libgcrypt version >=1.6.1 required') 96 endif 97 endif 98 99 gnunetutil_dep = dependency('gnunetutil', required: false) 100 if not gnunetutil_dep.found() 101 gnunetutil_dep = cc.find_library('gnunetutil', required: true) 102 endif 103 104 cc.has_header_symbol( 105 'gnunet/gnunet_util_lib.h', 106 'GNUNET_TIME_round_up', 107 dependencies: [gnunetutil_dep], 108 required: true, 109 ) 110 111 gnunetjson_dep = dependency('gnunetjson', required: false) 112 if not gnunetjson_dep.found() 113 gnunetjson_dep = cc.find_library('gnunetjson', required: true) 114 endif 115 116 # 7.62.0 is where the curl_url_*() parser appeared; we use it to 117 # derive the upstream Host header. 118 curl_dep = dependency('libcurl', version: '>=7.62.0', required: false) 119 if not curl_dep.found() 120 curl_dep = cc.find_library('curl', required: true) 121 curl_version_check = '''#include <curl/curl.h> 122 int main(int argc, char **argv) { 123 #if LIBCURL_VERSION_NUM < 0x073e00 124 #error "cURL version >= 7.62.0 required" 125 #endif 126 return 0; 127 } 128 ''' 129 if not cc.compiles( 130 curl_version_check, 131 name: 'cURL version check', 132 dependencies: curl_dep, 133 ) 134 error('cURL version >=7.62.0 required') 135 endif 136 endif 137 138 gnunetcurl_dep = dependency('gnunetcurl', required: false) 139 if not gnunetcurl_dep.found() 140 gnunetcurl_dep = cc.find_library('gnunetcurl', required: true) 141 endif 142 cc.has_header_symbol( 143 'gnunet/gnunet_curl_lib.h', 144 'GNUNET_CURL_get_select_info', 145 dependencies: [gnunetcurl_dep], 146 required: true, 147 ) 148 # The streaming download API, without which a proxied response 149 # would have to be assembled in memory before any of it could be 150 # forwarded -- and could not exceed GNUNET_MAX_MALLOC_CHECKED at 151 # all. New in GNUnet 0.29.0. 152 if not cc.has_function( 153 'GNUNET_CURL_job_set_paused', 154 prefix: '#include <gnunet/gnunet_curl_lib.h>', 155 dependencies: [gnunetcurl_dep], 156 ) 157 error('libgnunetcurl is too old: GNUNET_CURL_job_add_stream() and ' 158 + 'GNUNET_CURL_job_set_paused() are required (GNUnet >= 0.29.0)') 159 endif 160 161 talerutil_dep = dependency('talerutil', required: false) 162 if not talerutil_dep.found() 163 talerutil_dep = cc.find_library('talerutil', required: true) 164 endif 165 cc.has_header_symbol( 166 'taler/taler_util.h', 167 'TALER_merchant_instance_auth_hash_with_salt', 168 required: true, 169 dependencies: [talerutil_dep], 170 ) 171 talertemplating_dep = dependency('talertemplating', required: false) 172 if not talertemplating_dep.found() 173 talertemplating_dep = cc.find_library('talertemplating', required: true) 174 endif 175 talermhd_dep = dependency('talermhd', required: false) 176 if not talermhd_dep.found() 177 talermhd_dep = cc.find_library('talermhd', required: true) 178 endif 179 cc.has_header_symbol( 180 'taler/taler_mhd_lib.h', 181 'TALER_MHD_parse_request_arg_rel_time', 182 required: true, 183 dependencies: [talermhd_dep], 184 ) 185 186 talerjson_dep = dependency('talerjson', required: false) 187 if not talerjson_dep.found() 188 talerjson_dep = cc.find_library('talerjson', required: true) 189 endif 190 cc.has_header_symbol( 191 'taler/taler_json_lib.h', 192 'TALER_JSON_spec_slug', 193 required: true, 194 dependencies: [talerjson_dep], 195 ) 196 197 talermerchant_dep = dependency('talermerchant', required: false) 198 if not talermerchant_dep.found() 199 talermerchant_dep = cc.find_library('talermerchant', required: true) 200 endif 201 cc.has_header_symbol( 202 'taler/taler_merchant_service.h', 203 'TALER_MERCHANT_parse_pay_uri', 204 required: true, 205 dependencies: [talermerchant_dep], 206 ) 207 208 # GNUNET_CULL_LOGGING removes every log statement at compile time; 209 # GNUNET_EXTRA_LOGGING gates the GNUNET_log_from() DEBUG level, with 210 # the same 0/1/2 scale GNUnet itself uses. Both have to be handed to 211 # the compiler -- computing a verbosity and never passing it on left 212 # 'verbose' and 'veryverbose' doing nothing at all. 213 logging_opt = get_option('logging') 214 215 if logging_opt == 'no' 216 add_project_arguments('-DGNUNET_CULL_LOGGING=1', language: 'c') 217 else 218 logging_verbosity = {'yes': 0, 'verbose': 1, 'veryverbose': 2}[logging_opt] 219 add_project_arguments( 220 '-DGNUNET_EXTRA_LOGGING=@0@'.format(logging_verbosity), 221 language: 'c', 222 ) 223 endif 224 summary({'logging': logging_opt}, section: 'Configuration') 225 226 private_config.set_quoted('PACKAGE_VERSION', meson.project_version()) 227 configure_file(output: 'paivana_config.h', configuration: private_config) 228 configuration_inc = include_directories('.') 229 230 add_project_arguments('-DHAVE_CONFIG_H', language: 'c') 231 232 subdir('contrib') 233 subdir('src') 234 if not get_option('disable-doc') 235 subdir('doc') 236 endif 237 238 taler_prefix = get_option('prefix') / get_option('libdir') 239 240 add_test_setup( 241 'default', 242 env: ['PAIVANA_PREFIX=' + taler_prefix], 243 exclude_suites: ['perf', 'installcheck', 'integrationtests'], 244 is_default: true, 245 ) 246 else 247 subdir('contrib') 248 if not get_option('disable-doc') 249 subdir('doc') 250 endif 251 endif 252 253 meson.add_dist_script('meson-dist-script')