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 | d78e77e | 2022-12-31 17:01:32 -0500 | [diff] [blame^] | 6 | VERSION = '0.1.0' |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 7 | APPNAME = 'ndncert' |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 8 | |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 9 | def options(opt): |
| 10 | opt.load(['compiler_cxx', 'gnu_dirs']) |
Davide Pesavento | 573a621 | 2022-07-09 21:56:41 -0400 | [diff] [blame] | 11 | opt.load(['default-compiler-flags', |
| 12 | '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 | 573a621 | 2022-07-09 21:56:41 -0400 | [diff] [blame] | 22 | 'default-compiler-flags', |
| 23 | 'boost', 'openssl', 'sqlite3']) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 24 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 25 | conf.env.WITH_TESTS = conf.options.with_tests |
| 26 | |
Davide Pesavento | 573a621 | 2022-07-09 21:56:41 -0400 | [diff] [blame] | 27 | # Prefer pkgconf if it's installed, because it gives more correct results |
| 28 | # on Fedora/CentOS/RHEL/etc. See https://bugzilla.redhat.com/show_bug.cgi?id=1953348 |
| 29 | # Store the result in env.PKGCONFIG, which is the variable used inside check_cfg() |
| 30 | conf.find_program(['pkgconf', 'pkg-config'], var='PKGCONFIG') |
| 31 | |
Davide Pesavento | 6f1a2ab | 2022-03-17 03:57:21 -0400 | [diff] [blame] | 32 | pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig') |
Davide Pesavento | d78e77e | 2022-12-31 17:01:32 -0500 | [diff] [blame^] | 33 | conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.1', '--cflags', '--libs'], |
Davide Pesavento | 6f1a2ab | 2022-03-17 03:57:21 -0400 | [diff] [blame] | 34 | uselib_store='NDN_CXX', pkg_config_path=pkg_config_path) |
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_sqlite3() |
Davide Pesavento | 5672d29 | 2021-11-19 18:19:25 -0500 | [diff] [blame] | 37 | conf.check_openssl(lib='crypto', atleast_version='1.1.1') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 38 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 39 | boost_libs = ['system', 'program_options', 'filesystem'] |
| 40 | if conf.env.WITH_TESTS: |
| 41 | boost_libs.append('unit_test_framework') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 42 | |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 43 | conf.check_boost(lib=boost_libs, mt=True) |
Davide Pesavento | a34d6de | 2021-11-18 22:16:04 -0500 | [diff] [blame] | 44 | if conf.env.BOOST_VERSION_NUMBER < 106501: |
| 45 | conf.fatal('The minimum supported version of Boost is 1.65.1.\n' |
| 46 | 'Please upgrade your distribution or manually install a newer version of Boost.\n' |
| 47 | '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] | 48 | |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 49 | conf.check_compiler_flags() |
| 50 | |
| 51 | # Loading "late" to prevent tests from being compiled with profiling flags |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 52 | conf.load('coverage') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 53 | conf.load('sanitizers') |
Zhiyi Zhang | 65ba932 | 2017-01-19 14:15:03 -0800 | [diff] [blame] | 54 | |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 55 | # If there happens to be a static library, waf will put the corresponding -L flags |
| 56 | # before dynamic library flags. This can result in compilation failure when the |
| 57 | # system has a different version of the ndncert library installed. |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 58 | conf.env.prepend_value('STLIBPATH', ['.']) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 59 | |
Zhiyi Zhang | 199508a | 2020-10-21 10:45:50 -0700 | [diff] [blame] | 60 | conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS) |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 61 | conf.define('SYSCONFDIR', conf.env.SYSCONFDIR) |
| 62 | # The config header will contain all defines that were added using conf.define() |
| 63 | # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES |
| 64 | # will not appear in the config header, but will instead be passed directly to the |
| 65 | # compiler on the command line. |
Zhiyi Zhang | 199508a | 2020-10-21 10:45:50 -0700 | [diff] [blame] | 66 | conf.write_config_header('src/detail/ndncert-config.hpp', define_prefix='NDNCERT_') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 67 | |
| 68 | def build(bld): |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 69 | bld.shlib(target='ndn-cert', |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 70 | vnum=VERSION, |
| 71 | cnum=VERSION, |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 72 | source=bld.path.ant_glob('src/**/*.cpp'), |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 73 | use='NDN_CXX BOOST OPENSSL SQLITE3', |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 74 | includes='src', |
Davide Pesavento | 829aff6 | 2022-05-15 20:30:34 -0400 | [diff] [blame] | 75 | export_includes='src .') |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 76 | |
| 77 | bld(features='subst', |
| 78 | source='libndn-cert.pc.in', |
| 79 | target='libndn-cert.pc', |
Davide Pesavento | aae119a | 2019-11-09 18:30:03 -0500 | [diff] [blame] | 80 | install_path='${LIBDIR}/pkgconfig', |
| 81 | VERSION=VERSION) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 82 | |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 83 | bld.recurse('tools') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 84 | bld.recurse('tests') |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 85 | |
| 86 | bld.install_files( |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 87 | dest='${INCLUDEDIR}/ndncert', |
Davide Pesavento | 55d9860 | 2019-10-15 22:40:05 -0400 | [diff] [blame] | 88 | files=bld.path.ant_glob('src/**/*.hpp'), |
Davide Pesavento | a7fead4 | 2019-01-19 21:18:17 -0500 | [diff] [blame] | 89 | cwd=bld.path.find_dir('src'), |
| 90 | relative_trick=True) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 91 | |
Davide Pesavento | 725d3fc | 2021-11-19 23:37:03 -0500 | [diff] [blame] | 92 | bld.install_files('${INCLUDEDIR}/ndncert/detail', |
| 93 | bld.path.find_resource('src/detail/ndncert-config.hpp')) |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 94 | |
Davide Pesavento | 725d3fc | 2021-11-19 23:37:03 -0500 | [diff] [blame] | 95 | bld.install_files('${SYSCONFDIR}/ndncert', |
| 96 | ['ca.conf.sample', |
| 97 | 'client.conf.sample', |
| 98 | 'ndncert-mail.conf.sample']) |
Zhiyi Zhang | 576aad1 | 2017-10-03 15:41:53 -0700 | [diff] [blame] | 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 | 1dab2dc | 2020-10-17 15:39:22 -0700 | [diff] [blame] | 106 | |
Davide Pesavento | 725d3fc | 2021-11-19 23:37:03 -0500 | [diff] [blame] | 107 | if Utils.unversioned_sys_platform() == 'linux': |
| 108 | bld(features='subst', |
| 109 | name='ndncert-ca.service', |
| 110 | source='systemd/ndncert-ca.service.in', |
| 111 | target='systemd/ndncert-ca.service') |