exchange

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

meson.build (10505B)


      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     json_dep = dependency('jansson', required: false)
    110     if not json_dep.found()
    111         json_dep = cc.find_library('jansson', required: true)
    112     endif
    113 
    114     gcrypt_dep = dependency('libgcrypt', required: false)
    115     if not gcrypt_dep.found()
    116         gcrypt_dep = cc.find_library('gcrypt', required: true)
    117     endif
    118 
    119     private_config.set_quoted('NEED_LIBGCRYPT_VERSION', '1.6.0')
    120     #add_project_arguments('-DNEED_LIBGCRYPT_VERSION="1.6.0"', language: 'c')
    121 
    122     gnunetutil_dep = dependency('gnunetutil', required: false)
    123     if not gnunetutil_dep.found()
    124         gnunetutil_dep = cc.find_library('gnunetutil', required: true)
    125     endif
    126 
    127     gnunetjson_dep = dependency('gnunetjson', required: false)
    128     if not gnunetjson_dep.found()
    129         gnunetjson_dep = cc.find_library('gnunetjson', required: true)
    130     endif
    131     cc.has_header_symbol(
    132         'gnunet/gnunet_json_lib.h',
    133         'GNUNET_JSON_spec_string',
    134         dependencies: [gnunetjson_dep],
    135         required: true,
    136     )
    137 
    138     gnunetmhd_dep = dependency('gnunetmhd', required: false)
    139     if not gnunetmhd_dep.found()
    140         gnunetmhd_dep = cc.find_library('gnunetmhd', required: true)
    141     endif
    142     cc.has_header_symbol(
    143         'gnunet/gnunet_mhd_lib.h',
    144         'GNUNET_MHD_post_parser',
    145         dependencies: [gnunetmhd_dep],
    146         required: true,
    147     )
    148 
    149     sodium_dep = dependency('libsodium', required: false, version: '>=1.0.18')
    150     if not sodium_dep.found()
    151         sodium_dep = cc.find_library('sodium', required: true)
    152         sodium_version_check = '''#include <sodium.h>
    153   int main(int argc, char **argv) {
    154     #if !((SODIUM_LIBRARY_VERSION_MAJOR > 10) || \
    155          ((SODIUM_LIBRARY_VERSION_MAJOR == 10) && \
    156          (SODIUM_LIBRARY_VERSION_MINOR >= 3)))
    157       #error "libsodium version >= 1.0.18 required"
    158     #endif
    159     return 0
    160     }
    161   '''
    162         if not cc.compiles(
    163             sodium_version_check,
    164             name: 'sodium version check',
    165             dependencies: sodium_dep,
    166         )
    167             error('libsodium version >=1.0.18 required')
    168         endif
    169     endif
    170     unistr_dep = dependency('libunistring', required: false)
    171     if not unistr_dep.found()
    172         unistr_dep = cc.find_library('unistring', required: true)
    173     endif
    174     zlib_dep = dependency('zlib', required: false)
    175     if not zlib_dep.found()
    176         zlib_dep = cc.find_library('zlib', required: true)
    177     endif
    178     m_dep = cc.find_library('m', required: false)
    179     if m_dep.found()
    180         private_config.set('HAVE_LIBM', 1)
    181     endif
    182 
    183 
    184     curl_dep = dependency('libcurl', version: '>=7.34.0', required: false)
    185     if not curl_dep.found()
    186         curl_dep = cc.find_library('curl', required: true)
    187         curl_version_check = '''#include <curl/curl.h>
    188   int main(int argc, char **argv) {
    189     #if LIBCURL_VERSION_NUM < 0x073400
    190       #error "cURL version >= 7.34.0 required"
    191     #endif
    192     return 0;
    193     }
    194   '''
    195         if not cc.compiles(
    196             curl_version_check,
    197             name: 'cURL version check',
    198             dependencies: curl_dep,
    199         )
    200             error('cURL version >=7.34.0 required')
    201         endif
    202     endif
    203 
    204     gnunetcurl_dep = dependency('gnunetcurl', required: false)
    205     if not gnunetcurl_dep.found()
    206         gnunetcurl_dep = cc.find_library('gnunetcurl', required: true)
    207     endif
    208     cc.has_header_symbol(
    209         'gnunet/gnunet_curl_lib.h',
    210         'GNUNET_CURL_get_select_info',
    211         dependencies: [gnunetcurl_dep],
    212         required: true,
    213     )
    214 
    215     pq_dep = dependency('libpq', required: false)
    216     if not pq_dep.found()
    217         pq_dep = cc.find_library('pq', required: true)
    218     endif
    219 
    220     gnunetpq_dep = dependency('gnunetpq', required: false)
    221     if not gnunetpq_dep.found()
    222         gnunetpq_dep = cc.find_library('gnunetpq', required: true)
    223     endif
    224     cc.has_header_symbol(
    225         'gnunet/gnunet_pq_lib.h',
    226         'GNUNET_PQ_result_spec_blinded_sig',
    227         required: true,
    228         dependencies: [pq_dep, gnunetpq_dep],
    229     )
    230 
    231     gnunetsq_dep = dependency('gnunetsq', required: false)
    232     if not gnunetsq_dep.found()
    233         gnunetsq_dep = cc.find_library('gnunetsq', required: true)
    234     endif
    235     have_gnunetsq = cc.has_header_symbol(
    236         'gnunet/gnunet_sq_lib.h',
    237         'GNUNET_PQ_result_spec_string',
    238         dependencies: [gnunetsq_dep],
    239         required: false,
    240     )
    241 
    242     # todo talertwister optional
    243     twister_dep = cc.find_library('talertwister', required: false)
    244     if twister_dep.found()
    245         private_config.set10(
    246             'HAVE_TWISTER',
    247             cc.has_header_symbol(
    248                 'taler/taler_twister_service.h',
    249                 'TALER_TWISTER_connect',
    250                 dependencies: [twister_dep],
    251             ),
    252         )
    253     endif
    254 
    255     logging_opt = get_option('logging')
    256     logging_verbosity = 0
    257 
    258     if logging_opt == 'yes'
    259         logging_verbosity = 1
    260     endif
    261     if logging_opt == 'no'
    262         add_project_arguments('-DGNUNET_CULL_LOGGING=1', language: 'c')
    263     endif
    264     if logging_opt == 'verbose'
    265         logging_verbosity = 2
    266     endif
    267     if logging_opt == 'veryverbose'
    268         logging_verbosity = 3
    269     endif
    270 
    271     #add_project_arguments('-DGNUNET_EXTRA_LOGGING=@0@'.format(logging_verbosity), language: 'c')
    272 
    273 
    274     # todo gcov has meson builtin
    275 
    276     # Used to populate configuration file and script templates
    277 
    278 
    279     libltversions = [
    280         ['libtalerutil', '17:0:3'],
    281         ['libtalerjson', '10:0:6'],
    282         ['libtalercurl', '1:0:1'],
    283         ['libtalerpq', '1:0:0'],
    284         ['libtalermhd', '8:0:1'],
    285         ['libtalertemplating', '1:1:1'],
    286         ['libtalerbank', '6:0:0'],
    287         ['libtalerkyclogic', '3:0:0'],
    288         ['libtalerexchangedb', '3:0:0'],
    289         ['libtalerauditordb', '1:0:0'],
    290         ['libtalerexchange', '24:0:2'],
    291         ['libtalerauditor', '1:0:1'],
    292         ['libtalertesting', '4:0:0'],
    293         ['libtalertwistertesting', '0:1:0'],
    294     ]
    295 
    296     solibversions = {}
    297 
    298     foreach libversion : libltversions
    299         ltversion = libversion[1].split(':')
    300         current = ltversion[0].to_int()
    301         revision = ltversion[1].to_int()
    302         age = ltversion[2].to_int()
    303         soversion_str = '@0@'.format(current - age)
    304         ltversion_str = '@0@.@1@.@2@'.format(current - age, age, revision)
    305         solibversions = solibversions + {
    306             libversion[0]: {
    307                 'soversion': soversion_str,
    308                 'version': ltversion_str,
    309             },
    310         }
    311     endforeach
    312 
    313     private_config.set_quoted('PACKAGE_VERSION', meson.project_version())
    314     # Compatibility. Used in source.
    315     private_config.set_quoted('VERSION', meson.project_version())
    316     private_config.set_quoted('PACKAGE_BUGREPORT', 'taler@gnu.org')
    317     configure_file(output: 'taler_config.h', configuration: private_config)
    318     configuration_inc = include_directories('.')
    319 
    320     cdata.merge_from(private_config)
    321     add_project_arguments('-DHAVE_CONFIG_H', language: 'c')
    322 
    323     pkg = import('pkgconfig')
    324     subdir('contrib')
    325     subdir('src')
    326     if not get_option('disable-doc')
    327         subdir('doc')
    328     endif
    329 
    330     taler_prefix = get_option('prefix') / get_option('libdir')
    331 
    332     # Default setup only does unit tests
    333     add_test_setup(
    334         'default',
    335         env: [
    336             'TALER_EXCHANGE_PREFIX=' + taler_prefix,
    337             'TALER_AUDITOR_PREFIX=' + taler_prefix,
    338         ],
    339         exclude_suites: ['perf', 'installcheck', 'integrationtests'],
    340         is_default: true,
    341     )
    342     add_test_setup(
    343         'all',
    344         env: [
    345             'TALER_EXCHANGE_PREFIX=' + taler_prefix,
    346             'TALER_AUDITOR_PREFIX=' + taler_prefix,
    347         ],
    348     )
    349 else
    350     subdir('contrib')
    351     if not get_option('disable-doc')
    352         subdir('doc')
    353     endif
    354 endif
    355 
    356 run_target(
    357     'doxygen',
    358     command: 'scripts/doxygen.meson.sh',
    359     env: {'PACKAGE_VERSION': meson.project_version()},
    360 )
    361 meson.add_dist_script('meson-dist-script')