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') |
tylerliu | f53ef0d | 2020-10-17 14:56:45 -0700 | [diff] [blame] | 19 | optgrp.add_option('--without-systemd', action='store_true', default=False, |
| 20 | help='Disable systemd integration') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 21 | |
| 22 | def configure(conf): |
| 23 | conf.load(['compiler_cxx', 'gnu_dirs', |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 24 | 'default-compiler-flags', 'boost', 'openssl', 'sqlite3']) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 25 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 26 | conf.env.WITH_TESTS = conf.options.with_tests |
| 27 | |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 28 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], uselib_store='NDN_CXX', |
| 29 | 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] | 30 | |
tylerliu | f53ef0d | 2020-10-17 14:56:45 -0700 | [diff] [blame] | 31 | if not conf.options.without_systemd: |
| 32 | conf.check_cfg(package='libsystemd', args=['--cflags', '--libs'], |
| 33 | uselib_store='SYSTEMD', mandatory=False) |
| 34 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 35 | conf.check_sqlite3() |
Zhiyi Zhang | 0937d40 | 2020-10-16 17:05:31 -0700 | [diff] [blame] | 36 | conf.check_openssl(lib='crypto', atleast_version=0x1010100f) # 1.1.1 |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 37 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 38 | boost_libs = ['system', 'program_options', 'filesystem'] |
| 39 | if conf.env.WITH_TESTS: |
| 40 | boost_libs.append('unit_test_framework') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 41 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 42 | conf.check_boost(lib=boost_libs, mt=True) |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 43 | if conf.env.BOOST_VERSION_NUMBER < 105800: |
| 44 | conf.fatal('Minimum required Boost version is 1.58.0\n' |
| 45 | 'Please upgrade your distribution or manually install a newer version of Boost' |
| 46 | ' (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 47 | |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 48 | conf.check_compiler_flags() |
| 49 | |
| 50 | # Loading "late" to prevent tests from being compiled with profiling flags |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 51 | conf.load('coverage') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 52 | conf.load('sanitizers') |
Zhiyi Zhang | 65ba932 | 2017-01-19 14:15:03 -0800 | [diff] [blame] | 53 | |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 54 | # If there happens to be a static library, waf will put the corresponding -L flags |
| 55 | # before dynamic library flags. This can result in compilation failure when the |
| 56 | # system has a different version of the ndncert library installed. |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 57 | conf.env.prepend_value('STLIBPATH', ['.']) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 58 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 59 | conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS) |
| 60 | conf.define('SYSCONFDIR', conf.env.SYSCONFDIR) |
| 61 | # The config header will contain all defines that were added using conf.define() |
| 62 | # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES |
| 63 | # will not appear in the config header, but will instead be passed directly to the |
| 64 | # compiler on the command line. |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 65 | conf.write_config_header('src/ndncert-config.hpp') |
| 66 | |
| 67 | def build(bld): |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 68 | bld.shlib(target='ndn-cert', |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 69 | vnum=VERSION, |
| 70 | cnum=VERSION, |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 71 | source=bld.path.ant_glob('src/**/*.cpp'), |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 72 | use='NDN_CXX BOOST OPENSSL SQLITE3', |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 73 | includes='src', |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 74 | export_includes='src') |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 75 | |
| 76 | bld(features='subst', |
| 77 | source='libndn-cert.pc.in', |
| 78 | target='libndn-cert.pc', |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 79 | install_path='${LIBDIR}/pkgconfig', |
| 80 | VERSION=VERSION) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 81 | |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 82 | bld.recurse('tools') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 83 | bld.recurse('tests') |
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.ant_glob('src/**/*.hpp'), |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 88 | cwd=bld.path.find_dir('src'), |
| 89 | relative_trick=True) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 90 | |
| 91 | bld.install_files( |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 92 | dest='${INCLUDEDIR}/ndncert', |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 93 | files=bld.path.get_bld().ant_glob('src/**/*.hpp'), |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 94 | cwd=bld.path.get_bld().find_dir('src'), |
| 95 | relative_trick=False) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 96 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 97 | bld.install_files('${SYSCONFDIR}/ndncert', ['ca.conf.sample', |
| 98 | 'client.conf.sample', |
| 99 | 'ndncert-mail.conf.sample']) |
Zhiyi Zhang | 576aad1 | 2017-10-03 15:41:53 -0700 | [diff] [blame] | 100 | |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 101 | bld(features='subst', |
| 102 | name='ndncert-send-email-challenge', |
Zhiyi Zhang | 576aad1 | 2017-10-03 15:41:53 -0700 | [diff] [blame] | 103 | source='ndncert-send-email-challenge.py', |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 104 | target='bin/ndncert-send-email-challenge', |
| 105 | install_path='${BINDIR}', |
| 106 | chmod=Utils.O755) |
Zhiyi Zhang | 1dab2dc | 2020-10-17 15:39:22 -0700 | [diff] [blame^] | 107 | |
| 108 | if bld.env.HAVE_SYSTEMD: |
| 109 | |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 110 | bld(features='subst', |
| 111 | name='ndncert-server.service', |
| 112 | source='systemd/ndncert-server.service.in', |
| 113 | target='systemd/ndncert-server.service') |
Zhiyi Zhang | 79ee944 | 2020-10-17 15:35:56 -0700 | [diff] [blame] | 114 | |
| 115 | bld(features='subst', |
| 116 | name='ndncert-server.service', |
| 117 | source='systemd/ndncert-ca.service.in', |
| 118 | target='systemd/ndncert-ca.service') |