blob: 1c430b1b5e6e5a435c8fb7d6d0d8b68a941f8415 [file] [log] [blame]
Zhiyi Zhang8617a792017-01-17 16:45:56 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Davide Pesaventoa7fead42019-01-19 21:18:17 -05002
Davide Pesaventoaae119a2019-11-09 18:30:03 -05003from waflib import Utils
Zhiyi Zhang8617a792017-01-17 16:45:56 -08004import os
5
Davide Pesavento55d98602019-10-15 22:40:05 -04006VERSION = '0.1.0'
7APPNAME = 'ndncert'
8GIT_TAG_PREFIX = 'ndncert-'
9
Zhiyi Zhang8617a792017-01-17 16:45:56 -080010def options(opt):
11 opt.load(['compiler_cxx', 'gnu_dirs'])
Davide Pesavento55d98602019-10-15 22:40:05 -040012 opt.load(['default-compiler-flags', 'coverage', 'sanitizers',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050013 'boost', 'openssl', 'sqlite3'],
Davide Pesavento08994782018-01-22 12:13:41 -050014 tooldir=['.waf-tools'])
Zhiyi Zhang8617a792017-01-17 16:45:56 -080015
Davide Pesaventoaae119a2019-11-09 18:30:03 -050016 optgrp = opt.add_option_group('ndncert Options')
17 optgrp.add_option('--with-tests', action='store_true', default=False,
18 help='Build unit tests')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080019
20def configure(conf):
21 conf.load(['compiler_cxx', 'gnu_dirs',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050022 'default-compiler-flags', 'boost', 'openssl', 'sqlite3'])
Zhiyi Zhang8617a792017-01-17 16:45:56 -080023
Davide Pesavento55d98602019-10-15 22:40:05 -040024 conf.env.WITH_TESTS = conf.options.with_tests
25
Davide Pesaventoaae119a2019-11-09 18:30:03 -050026 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 Zhang8617a792017-01-17 16:45:56 -080028
Davide Pesavento55d98602019-10-15 22:40:05 -040029 conf.check_sqlite3()
Davide Pesavento5672d292021-11-19 18:19:25 -050030 conf.check_openssl(lib='crypto', atleast_version='1.1.1')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080031
Davide Pesavento55d98602019-10-15 22:40:05 -040032 boost_libs = ['system', 'program_options', 'filesystem']
33 if conf.env.WITH_TESTS:
34 boost_libs.append('unit_test_framework')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080035
Davide Pesavento55d98602019-10-15 22:40:05 -040036 conf.check_boost(lib=boost_libs, mt=True)
Davide Pesaventoa34d6de2021-11-18 22:16:04 -050037 if conf.env.BOOST_VERSION_NUMBER < 106501:
38 conf.fatal('The minimum supported version of Boost is 1.65.1.\n'
39 'Please upgrade your distribution or manually install a newer version of Boost.\n'
40 'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080041
Davide Pesavento08994782018-01-22 12:13:41 -050042 conf.check_compiler_flags()
43
44 # Loading "late" to prevent tests from being compiled with profiling flags
Zhiyi Zhang8617a792017-01-17 16:45:56 -080045 conf.load('coverage')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080046 conf.load('sanitizers')
Zhiyi Zhang65ba9322017-01-19 14:15:03 -080047
Zhiyi Zhang7021a932017-03-17 10:26:51 -070048 # 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 Pesavento55d98602019-10-15 22:40:05 -040051 conf.env.prepend_value('STLIBPATH', ['.'])
Zhiyi Zhang7021a932017-03-17 10:26:51 -070052
Zhiyi Zhang199508a2020-10-21 10:45:50 -070053 conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS)
Davide Pesavento55d98602019-10-15 22:40:05 -040054 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 Zhang199508a2020-10-21 10:45:50 -070059 conf.write_config_header('src/detail/ndncert-config.hpp', define_prefix='NDNCERT_')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080060
61def build(bld):
Davide Pesaventoa7fead42019-01-19 21:18:17 -050062 bld.shlib(target='ndn-cert',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050063 vnum=VERSION,
64 cnum=VERSION,
Davide Pesaventoaae119a2019-11-09 18:30:03 -050065 source=bld.path.ant_glob('src/**/*.cpp'),
Davide Pesavento55d98602019-10-15 22:40:05 -040066 use='NDN_CXX BOOST OPENSSL SQLITE3',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050067 includes='src',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050068 export_includes='src')
Davide Pesaventoa7fead42019-01-19 21:18:17 -050069
70 bld(features='subst',
71 source='libndn-cert.pc.in',
72 target='libndn-cert.pc',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050073 install_path='${LIBDIR}/pkgconfig',
74 VERSION=VERSION)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080075
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080076 bld.recurse('tools')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080077 bld.recurse('tests')
Zhiyi Zhang7021a932017-03-17 10:26:51 -070078
79 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050080 dest='${INCLUDEDIR}/ndncert',
Davide Pesavento55d98602019-10-15 22:40:05 -040081 files=bld.path.ant_glob('src/**/*.hpp'),
Davide Pesaventoa7fead42019-01-19 21:18:17 -050082 cwd=bld.path.find_dir('src'),
83 relative_trick=True)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070084
Davide Pesavento725d3fc2021-11-19 23:37:03 -050085 bld.install_files('${INCLUDEDIR}/ndncert/detail',
86 bld.path.find_resource('src/detail/ndncert-config.hpp'))
Zhiyi Zhang7021a932017-03-17 10:26:51 -070087
Davide Pesavento725d3fc2021-11-19 23:37:03 -050088 bld.install_files('${SYSCONFDIR}/ndncert',
89 ['ca.conf.sample',
90 'client.conf.sample',
91 'ndncert-mail.conf.sample'])
Zhiyi Zhang576aad12017-10-03 15:41:53 -070092
Davide Pesaventoa7fead42019-01-19 21:18:17 -050093 bld(features='subst',
94 name='ndncert-send-email-challenge',
Zhiyi Zhang576aad12017-10-03 15:41:53 -070095 source='ndncert-send-email-challenge.py',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050096 target='bin/ndncert-send-email-challenge',
97 install_path='${BINDIR}',
98 chmod=Utils.O755)
Zhiyi Zhang1dab2dc2020-10-17 15:39:22 -070099
Davide Pesavento725d3fc2021-11-19 23:37:03 -0500100 if Utils.unversioned_sys_platform() == 'linux':
101 bld(features='subst',
102 name='ndncert-ca.service',
103 source='systemd/ndncert-ca.service.in',
104 target='systemd/ndncert-ca.service')