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 | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 6 | VERSION = '0.1.0' |
| 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 | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 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)) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 28 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 29 | conf.check_sqlite3() |
| 30 | conf.check_openssl(lib='crypto', atleast_version=0x1000200f) # 1.0.2 |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 31 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 32 | boost_libs = ['system', 'program_options', 'filesystem'] |
| 33 | if conf.env.WITH_TESTS: |
| 34 | boost_libs.append('unit_test_framework') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 35 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 36 | conf.check_boost(lib=boost_libs, mt=True) |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 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)') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 41 | |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 42 | conf.check_compiler_flags() |
| 43 | |
| 44 | # Loading "late" to prevent tests from being compiled with profiling flags |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 45 | conf.load('coverage') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 46 | conf.load('sanitizers') |
Zhiyi Zhang | 65ba932 | 2017-01-19 14:15:03 -0800 | [diff] [blame] | 47 | |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 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. |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 51 | conf.env.prepend_value('STLIBPATH', ['.']) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 52 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 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. |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 59 | conf.write_config_header('src/ndncert-config.hpp') |
| 60 | |
| 61 | def build(bld): |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 62 | bld.shlib(target='ndn-cert', |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 63 | vnum=VERSION, |
| 64 | cnum=VERSION, |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 65 | source=bld.path.ant_glob('src/**/*.cpp'), |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 66 | use='NDN_CXX BOOST OPENSSL SQLITE3', |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 67 | includes='src', |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 68 | export_includes='src') |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 69 | |
| 70 | bld(features='subst', |
| 71 | source='libndn-cert.pc.in', |
| 72 | target='libndn-cert.pc', |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 73 | install_path='${LIBDIR}/pkgconfig', |
| 74 | VERSION=VERSION) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 75 | |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 76 | bld.recurse('tools') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 77 | bld.recurse('tests') |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 78 | |
| 79 | bld.install_files( |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 80 | dest='${INCLUDEDIR}/ndncert', |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 81 | files=bld.path.ant_glob('src/**/*.hpp'), |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 82 | cwd=bld.path.find_dir('src'), |
| 83 | relative_trick=True) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 84 | |
| 85 | bld.install_files( |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 86 | dest='${INCLUDEDIR}/ndncert', |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 87 | files=bld.path.get_bld().ant_glob('src/**/*.hpp'), |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 88 | cwd=bld.path.get_bld().find_dir('src'), |
| 89 | relative_trick=False) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 90 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 91 | bld.install_files('${SYSCONFDIR}/ndncert', ['ca.conf.sample', |
| 92 | 'client.conf.sample', |
| 93 | 'ndncert-mail.conf.sample']) |
Zhiyi Zhang | 576aad1 | 2017-10-03 15:41:53 -0700 | [diff] [blame] | 94 | |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 95 | bld(features='subst', |
| 96 | name='ndncert-send-email-challenge', |
Zhiyi Zhang | 576aad1 | 2017-10-03 15:41:53 -0700 | [diff] [blame] | 97 | source='ndncert-send-email-challenge.py', |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 98 | target='bin/ndncert-send-email-challenge', |
| 99 | install_path='${BINDIR}', |
| 100 | chmod=Utils.O755) |
Zhiyi Zhang | 576aad1 | 2017-10-03 15:41:53 -0700 | [diff] [blame] | 101 | |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 102 | if Utils.unversioned_sys_platform() == 'linux': |
| 103 | bld(features='subst', |
| 104 | name='ndncert-server.service', |
| 105 | source='systemd/ndncert-server.service.in', |
| 106 | target='systemd/ndncert-server.service') |