exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

meson.build (10743B)


      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 
     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     # todo talertwister optional
    247     twister_dep = cc.find_library('talertwister', required: false)
    248     if twister_dep.found()
    249         private_config.set10(
    250             'HAVE_TWISTER',
    251             cc.has_header_symbol(
    252                 'taler/taler_twister_service.h',
    253                 'TALER_TWISTER_connect',
    254                 dependencies: [twister_dep],
    255             ),
    256         )
    257     endif
    258 
    259     logging_opt = get_option('logging')
    260     logging_verbosity = 0
    261 
    262     if logging_opt == 'yes'
    263         logging_verbosity = 1
    264     endif
    265     if logging_opt == 'no'
    266         add_project_arguments('-DGNUNET_CULL_LOGGING=1', language: 'c')
    267     endif
    268     if logging_opt == 'verbose'
    269         logging_verbosity = 2
    270     endif
    271     if logging_opt == 'veryverbose'
    272         logging_verbosity = 3
    273     endif
    274 
    275     #add_project_arguments('-DGNUNET_EXTRA_LOGGING=@0@'.format(logging_verbosity), language: 'c')
    276 
    277 
    278     # todo gcov has meson builtin
    279 
    280     # Used to populate configuration file and script templates
    281 
    282 
    283     libltversions = [
    284         ['libtalerutil', '13:0:0'],
    285         ['libtalerjson', '7:0:3'],
    286         ['libtalercurl', '0:1:0'],
    287         ['libtalerpq', '1:0:0'],
    288         ['libtalersq', '0:0:0'],
    289         ['libtalermhd', '8:0:1'],
    290         ['libtalermhd2', '0:0:0'],
    291         ['libtalertemplating', '1:1:1'],
    292         ['libtalerbank', '5:0:1'],
    293         ['libtalerkyclogic', '3:0:0'],
    294         ['libtalerexchangedb', '1:1:0'],
    295         ['libtalerauditordb', '0:1:0'],
    296         ['libtalerexchange', '21:0:0'],
    297         ['libtalerauditor', '0:0:0'],
    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 = configuration_data()
    327     cdata.merge_from(private_config)
    328     add_project_arguments('-DHAVE_CONFIG_H', language: 'c')
    329 
    330     pkg = import('pkgconfig')
    331     subdir('contrib')
    332     subdir('src')
    333     if not get_option('disable-doc')
    334         subdir('doc')
    335     endif
    336 
    337     taler_prefix = get_option('prefix') / get_option('libdir')
    338 
    339     # Default setup only does unit tests
    340     add_test_setup(
    341         'default',
    342         env: [
    343             'TALER_EXCHANGE_PREFIX=' + taler_prefix,
    344             'TALER_AUDITOR_PREFIX=' + taler_prefix,
    345         ],
    346         exclude_suites: ['perf', 'installcheck', 'integrationtests'],
    347         is_default: true,
    348     )
    349     add_test_setup(
    350         'all',
    351         env: [
    352             'TALER_EXCHANGE_PREFIX=' + taler_prefix,
    353             'TALER_AUDITOR_PREFIX=' + taler_prefix,
    354         ],
    355     )
    356 else
    357     subdir('contrib')
    358     if not get_option('disable-doc')
    359         subdir('doc')
    360     endif
    361 endif
    362 
    363 run_target(
    364     'doxygen',
    365     command: 'scripts/doxygen.meson.sh',
    366     env: {'PACKAGE_VERSION': meson.project_version()},
    367 )
    368 meson.add_dist_script('meson-dist-script')