Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 2 | |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 3 | VERSION = "0.1.0" |
| 4 | APPNAME = "ndncert" |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 5 | BUGREPORT = "https://redmine.named-data.net/projects/ndncert" |
| 6 | GIT_TAG_PREFIX = "ndncert-" |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 7 | |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 8 | from waflib import Context, Utils |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 9 | import os |
| 10 | |
| 11 | def options(opt): |
| 12 | opt.load(['compiler_cxx', 'gnu_dirs']) |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 13 | opt.load(['boost', 'default-compiler-flags', 'sqlite3', 'openssl', |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 14 | 'coverage', 'sanitizers', |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 15 | 'doxygen', 'sphinx_build'], |
| 16 | tooldir=['.waf-tools']) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 17 | |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 18 | certopt = opt.add_option_group("ndncert options") |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 19 | certopt.add_option('--with-tests', action='store_true', default=False, |
| 20 | help='Build unit tests') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 21 | |
| 22 | def configure(conf): |
| 23 | conf.load(['compiler_cxx', 'gnu_dirs', |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 24 | 'boost', 'default-compiler-flags', 'sqlite3', 'openssl', |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 25 | 'doxygen', 'sphinx_build']) |
| 26 | |
| 27 | if 'PKG_CONFIG_PATH' not in os.environ: |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 28 | os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 29 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], |
| 30 | uselib_store='NDN_CXX', mandatory=True) |
| 31 | |
| 32 | USED_BOOST_LIBS = ['system', 'filesystem', 'iostreams', |
| 33 | 'program_options', 'thread', 'log', 'log_setup'] |
| 34 | |
| 35 | conf.env['WITH_TESTS'] = conf.options.with_tests |
| 36 | if conf.env['WITH_TESTS']: |
| 37 | USED_BOOST_LIBS += ['unit_test_framework'] |
| 38 | conf.define('HAVE_TESTS', 1) |
| 39 | |
| 40 | conf.check_boost(lib=USED_BOOST_LIBS, mt=True) |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 41 | if conf.env.BOOST_VERSION_NUMBER < 105800: |
| 42 | conf.fatal('Minimum required Boost version is 1.58.0\n' |
| 43 | 'Please upgrade your distribution or manually install a newer version of Boost' |
| 44 | ' (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 45 | |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 46 | conf.check_compiler_flags() |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 47 | conf.check_openssl(mandatory=True, atleast_version=0x1000200f) # 1.1.1b |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 48 | |
| 49 | # Loading "late" to prevent tests from being compiled with profiling flags |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 50 | conf.load('coverage') |
| 51 | |
| 52 | conf.load('sanitizers') |
Zhiyi Zhang | 65ba932 | 2017-01-19 14:15:03 -0800 | [diff] [blame] | 53 | |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 54 | conf.define('SYSCONFDIR', conf.env['SYSCONFDIR']) |
| 55 | |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 56 | # If there happens to be a static library, waf will put the corresponding -L flags |
| 57 | # before dynamic library flags. This can result in compilation failure when the |
| 58 | # system has a different version of the ndncert library installed. |
| 59 | conf.env['STLIBPATH'] = ['.'] + conf.env['STLIBPATH'] |
| 60 | |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 61 | conf.write_config_header('src/ndncert-config.hpp') |
| 62 | |
| 63 | def build(bld): |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 64 | bld.shlib(target='ndn-cert', |
| 65 | source=bld.path.ant_glob('src/**/*.cpp'), |
| 66 | vnum=VERSION, |
| 67 | cnum=VERSION, |
| 68 | use='NDN_CXX BOOST', |
| 69 | includes='src', |
| 70 | export_includes='src', |
| 71 | install_path='${LIBDIR}') |
| 72 | |
| 73 | bld(features='subst', |
| 74 | source='libndn-cert.pc.in', |
| 75 | target='libndn-cert.pc', |
| 76 | install_path = '${LIBDIR}/pkgconfig', |
| 77 | PREFIX = bld.env['PREFIX'], |
| 78 | INCLUDEDIR = '${INCLUDEDIR}/ndncert', |
| 79 | VERSION = VERSION) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 80 | |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 81 | bld.recurse('tools') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 82 | bld.recurse('tests') |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 83 | |
| 84 | bld.install_files( |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 85 | dest='${INCLUDEDIR}/ndncert', |
| 86 | files=bld.path.ant_glob(['src/**/*.hpp', 'src/**/*.h']), |
| 87 | cwd=bld.path.find_dir('src'), |
| 88 | relative_trick=True) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 89 | |
| 90 | bld.install_files( |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 91 | dest='${INCLUDEDIR}/ndncert', |
| 92 | files=bld.path.get_bld().ant_glob(['src/**/*.hpp']), |
| 93 | cwd=bld.path.get_bld().find_dir('src'), |
| 94 | relative_trick=False) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 95 | |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 96 | bld.install_files("${SYSCONFDIR}/ndncert", "ca.conf.sample") |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 97 | bld.install_files("${SYSCONFDIR}/ndncert", "client.conf.sample") |
Zhiyi Zhang | 576aad1 | 2017-10-03 15:41:53 -0700 | [diff] [blame] | 98 | bld.install_files("${SYSCONFDIR}/ndncert", "ndncert-mail.conf.sample") |
| 99 | |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 100 | bld(features='subst', |
| 101 | name='ndncert-send-email-challenge', |
Zhiyi Zhang | 576aad1 | 2017-10-03 15:41:53 -0700 | [diff] [blame] | 102 | source='ndncert-send-email-challenge.py', |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 103 | target='bin/ndncert-send-email-challenge', |
| 104 | install_path='${BINDIR}', |
| 105 | chmod=Utils.O755) |
Zhiyi Zhang | 576aad1 | 2017-10-03 15:41:53 -0700 | [diff] [blame] | 106 | |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 107 | if Utils.unversioned_sys_platform() == 'linux': |
| 108 | bld(features='subst', |
| 109 | name='ndncert-server.service', |
| 110 | source='systemd/ndncert-server.service.in', |
| 111 | target='systemd/ndncert-server.service') |