blob: 45fa3cecadd7c1c287b70d7f973332fb55e20688 [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()
30 conf.check_openssl(lib='crypto', atleast_version=0x1000200f) # 1.0.2
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 Pesaventoa7fead42019-01-19 21:18:17 -050037 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 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
Davide Pesavento55d98602019-10-15 22:40:05 -040053 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 Zhang8617a792017-01-17 16:45:56 -080059 conf.write_config_header('src/ndncert-config.hpp')
60
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
85 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050086 dest='${INCLUDEDIR}/ndncert',
Davide Pesavento55d98602019-10-15 22:40:05 -040087 files=bld.path.get_bld().ant_glob('src/**/*.hpp'),
Davide Pesaventoa7fead42019-01-19 21:18:17 -050088 cwd=bld.path.get_bld().find_dir('src'),
89 relative_trick=False)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070090
Davide Pesavento55d98602019-10-15 22:40:05 -040091 bld.install_files('${SYSCONFDIR}/ndncert', ['ca.conf.sample',
92 'client.conf.sample',
93 'ndncert-mail.conf.sample'])
Zhiyi Zhang576aad12017-10-03 15:41:53 -070094
Davide Pesaventoa7fead42019-01-19 21:18:17 -050095 bld(features='subst',
96 name='ndncert-send-email-challenge',
Zhiyi Zhang576aad12017-10-03 15:41:53 -070097 source='ndncert-send-email-challenge.py',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050098 target='bin/ndncert-send-email-challenge',
99 install_path='${BINDIR}',
100 chmod=Utils.O755)
Zhiyi Zhang576aad12017-10-03 15:41:53 -0700101
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500102 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')