blob: 286c28a81337964057add5affcc94f612b3eccfa [file] [log] [blame]
Zhiyi Zhang63589b82020-10-10 10:27:09 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
3from waflib import Utils
4import os
5
6VERSION = '0.1.0'
7APPNAME = 'ndncert'
8GIT_TAG_PREFIX = 'ndncert-'
9
10def options(opt):
11 opt.load(['compiler_cxx', 'gnu_dirs'])
12 opt.load(['default-compiler-flags', 'coverage', 'sanitizers',
13 'boost', 'openssl', 'sqlite3'],
14 tooldir=['.waf-tools'])
15
16 optgrp = opt.add_option_group('ndncert Options')
17 optgrp.add_option('--with-tests', action='store_true', default=False,
18 help='Build unit tests')
19
20def configure(conf):
21 conf.load(['compiler_cxx', 'gnu_dirs',
22 'default-compiler-flags', 'boost', 'openssl', 'sqlite3'])
23
24 conf.env.WITH_TESTS = conf.options.with_tests
25
26 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], uselib_store='NDN_CXX',
27 pkg_config_path=os.environ.get('PKG_CONFIG_PATH', '%s/pkgconfig' % conf.env.LIBDIR))
28
29 conf.check_sqlite3()
30 conf.check_openssl(lib='crypto', atleast_version=0x1010100f) # 1.1.1
31
32 boost_libs = ['system', 'program_options', 'filesystem']
33 if conf.env.WITH_TESTS:
34 boost_libs.append('unit_test_framework')
35
36 conf.check_boost(lib=boost_libs, mt=True)
37 if conf.env.BOOST_VERSION_NUMBER < 105800:
38 conf.fatal('Minimum required Boost version is 1.58.0\n'
39 'Please upgrade your distribution or manually install a newer version of Boost'
40 ' (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)')
41
42 conf.check_compiler_flags()
43
44 # Loading "late" to prevent tests from being compiled with profiling flags
45 conf.load('coverage')
46 conf.load('sanitizers')
47
48 # If there happens to be a static library, waf will put the corresponding -L flags
49 # before dynamic library flags. This can result in compilation failure when the
50 # system has a different version of the ndncert library installed.
51 conf.env.prepend_value('STLIBPATH', ['.'])
52
53 conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS)
54 conf.define('SYSCONFDIR', conf.env.SYSCONFDIR)
55 # The config header will contain all defines that were added using conf.define()
56 # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES
57 # will not appear in the config header, but will instead be passed directly to the
58 # compiler on the command line.
59 conf.write_config_header('src/detail/ndncert-config.hpp', define_prefix='NDNCERT_')
60
61def build(bld):
62 bld.shlib(target='ndn-cert',
63 vnum=VERSION,
64 cnum=VERSION,
65 source=bld.path.ant_glob('src/**/*.cpp'),
66 use='NDN_CXX BOOST OPENSSL SQLITE3',
67 includes='src',
68 export_includes='src')
69
70 bld(features='subst',
71 source='libndn-cert.pc.in',
72 target='libndn-cert.pc',
73 install_path='${LIBDIR}/pkgconfig',
74 VERSION=VERSION)
75
76 bld.recurse('tests')
77
78 bld.install_files(
79 dest='${INCLUDEDIR}/ndncert',
80 files=bld.path.ant_glob('src/**/*.hpp'),
81 cwd=bld.path.find_dir('src'),
82 relative_trick=True)
83
84 bld.install_files(
85 dest='${INCLUDEDIR}/ndncert',
86 files=bld.path.get_bld().ant_glob('src/**/*.hpp'),
87 cwd=bld.path.get_bld().find_dir('src'),
88 relative_trick=False)