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 | |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 3 | from waflib import Utils |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 4 | import os |
| 5 | |
Davide Pesavento | 6f1a2ab | 2022-03-17 03:57:21 -0400 | [diff] [blame] | 6 | VERSION = '0.1' |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 7 | APPNAME = 'ndncert' |
| 8 | GIT_TAG_PREFIX = 'ndncert-' |
| 9 | |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 10 | def options(opt): |
| 11 | opt.load(['compiler_cxx', 'gnu_dirs']) |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 12 | opt.load(['default-compiler-flags', 'coverage', 'sanitizers', |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 13 | 'boost', 'openssl', 'sqlite3'], |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 14 | tooldir=['.waf-tools']) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 15 | |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 16 | optgrp = opt.add_option_group('ndncert Options') |
| 17 | optgrp.add_option('--with-tests', action='store_true', default=False, |
| 18 | help='Build unit tests') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 19 | |
| 20 | def configure(conf): |
| 21 | conf.load(['compiler_cxx', 'gnu_dirs', |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 22 | 'default-compiler-flags', 'boost', 'openssl', 'sqlite3']) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 23 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 24 | conf.env.WITH_TESTS = conf.options.with_tests |
| 25 | |
Davide Pesavento | 6f1a2ab | 2022-03-17 03:57:21 -0400 | [diff] [blame] | 26 | pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig') |
| 27 | conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.0', '--cflags', '--libs'], |
| 28 | uselib_store='NDN_CXX', pkg_config_path=pkg_config_path) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 29 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 30 | conf.check_sqlite3() |
Davide Pesavento | 5672d29 | 2021-11-19 18:19:25 -0500 | [diff] [blame] | 31 | conf.check_openssl(lib='crypto', atleast_version='1.1.1') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 32 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 33 | boost_libs = ['system', 'program_options', 'filesystem'] |
| 34 | if conf.env.WITH_TESTS: |
| 35 | boost_libs.append('unit_test_framework') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 36 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 37 | conf.check_boost(lib=boost_libs, mt=True) |
Davide Pesavento | a34d6de | 2021-11-18 22:16:04 -0500 | [diff] [blame] | 38 | if conf.env.BOOST_VERSION_NUMBER < 106501: |
| 39 | conf.fatal('The minimum supported version of Boost is 1.65.1.\n' |
| 40 | 'Please upgrade your distribution or manually install a newer version of Boost.\n' |
| 41 | 'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 42 | |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 43 | conf.check_compiler_flags() |
| 44 | |
| 45 | # Loading "late" to prevent tests from being compiled with profiling flags |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 46 | conf.load('coverage') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 47 | conf.load('sanitizers') |
Zhiyi Zhang | 65ba932 | 2017-01-19 14:15:03 -0800 | [diff] [blame] | 48 | |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 49 | # If there happens to be a static library, waf will put the corresponding -L flags |
| 50 | # before dynamic library flags. This can result in compilation failure when the |
| 51 | # system has a different version of the ndncert library installed. |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 52 | conf.env.prepend_value('STLIBPATH', ['.']) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 53 | |
Zhiyi Zhang | 199508a | 2020-10-21 10:45:50 -0700 | [diff] [blame] | 54 | conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS) |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 55 | conf.define('SYSCONFDIR', conf.env.SYSCONFDIR) |
| 56 | # The config header will contain all defines that were added using conf.define() |
| 57 | # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES |
| 58 | # will not appear in the config header, but will instead be passed directly to the |
| 59 | # compiler on the command line. |
Zhiyi Zhang | 199508a | 2020-10-21 10:45:50 -0700 | [diff] [blame] | 60 | conf.write_config_header('src/detail/ndncert-config.hpp', define_prefix='NDNCERT_') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 61 | |
| 62 | def build(bld): |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 63 | bld.shlib(target='ndn-cert', |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 64 | vnum=VERSION, |
| 65 | cnum=VERSION, |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 66 | source=bld.path.ant_glob('src/**/*.cpp'), |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 67 | use='NDN_CXX BOOST OPENSSL SQLITE3', |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 68 | includes='src', |
Davide Pesavento | 829aff6 | 2022-05-15 20:30:34 -0400 | [diff] [blame] | 69 | export_includes='src .') |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 70 | |
| 71 | bld(features='subst', |
| 72 | source='libndn-cert.pc.in', |
| 73 | target='libndn-cert.pc', |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 74 | install_path='${LIBDIR}/pkgconfig', |
| 75 | VERSION=VERSION) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 76 | |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 77 | bld.recurse('tools') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 78 | bld.recurse('tests') |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 79 | |
| 80 | bld.install_files( |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 81 | dest='${INCLUDEDIR}/ndncert', |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 82 | files=bld.path.ant_glob('src/**/*.hpp'), |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 83 | cwd=bld.path.find_dir('src'), |
| 84 | relative_trick=True) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 85 | |
Davide Pesavento | 725d3fc | 2021-11-19 23:37:03 -0500 | [diff] [blame] | 86 | bld.install_files('${INCLUDEDIR}/ndncert/detail', |
| 87 | bld.path.find_resource('src/detail/ndncert-config.hpp')) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 88 | |
Davide Pesavento | 725d3fc | 2021-11-19 23:37:03 -0500 | [diff] [blame] | 89 | bld.install_files('${SYSCONFDIR}/ndncert', |
| 90 | ['ca.conf.sample', |
| 91 | 'client.conf.sample', |
| 92 | 'ndncert-mail.conf.sample']) |
Zhiyi Zhang | 576aad1 | 2017-10-03 15:41:53 -0700 | [diff] [blame] | 93 | |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 94 | bld(features='subst', |
| 95 | name='ndncert-send-email-challenge', |
Zhiyi Zhang | 576aad1 | 2017-10-03 15:41:53 -0700 | [diff] [blame] | 96 | source='ndncert-send-email-challenge.py', |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 97 | target='bin/ndncert-send-email-challenge', |
| 98 | install_path='${BINDIR}', |
| 99 | chmod=Utils.O755) |
Zhiyi Zhang | 1dab2dc | 2020-10-17 15:39:22 -0700 | [diff] [blame] | 100 | |
Davide Pesavento | 725d3fc | 2021-11-19 23:37:03 -0500 | [diff] [blame] | 101 | if Utils.unversioned_sys_platform() == 'linux': |
| 102 | bld(features='subst', |
| 103 | name='ndncert-ca.service', |
| 104 | source='systemd/ndncert-ca.service.in', |
| 105 | target='systemd/ndncert-ca.service') |