blob: d1f7740427c45713d6f9d6f8a6849bd7d381ac43 [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 Pesaventoa7fead42019-01-19 21:18:17 -05003from waflib import Context, 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',
13 'boost', 'openssl', 'sqlite3',
Davide Pesavento08994782018-01-22 12:13:41 -050014 'doxygen', 'sphinx_build'],
15 tooldir=['.waf-tools'])
Zhiyi Zhang8617a792017-01-17 16:45:56 -080016
Davide Pesavento55d98602019-10-15 22:40:05 -040017 opt_group = opt.add_option_group('ndncert Options')
18 opt_group.add_option('--with-tests', action='store_true', default=False,
19 help='Build unit tests')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080020
21def configure(conf):
22 conf.load(['compiler_cxx', 'gnu_dirs',
Davide Pesavento55d98602019-10-15 22:40:05 -040023 'default-compiler-flags',
24 'boost', 'openssl', 'sqlite3',
Zhiyi Zhang8617a792017-01-17 16:45:56 -080025 'doxygen', 'sphinx_build'])
26
Davide Pesavento55d98602019-10-15 22:40:05 -040027 conf.env.WITH_TESTS = conf.options.with_tests
28
Zhiyi Zhang8617a792017-01-17 16:45:56 -080029 if 'PKG_CONFIG_PATH' not in os.environ:
Davide Pesavento08994782018-01-22 12:13:41 -050030 os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
Davide Pesavento55d98602019-10-15 22:40:05 -040031 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], uselib_store='NDN_CXX')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080032
Davide Pesavento55d98602019-10-15 22:40:05 -040033 conf.check_sqlite3()
34 conf.check_openssl(lib='crypto', atleast_version=0x1000200f) # 1.0.2
Zhiyi Zhang8617a792017-01-17 16:45:56 -080035
Davide Pesavento55d98602019-10-15 22:40:05 -040036 boost_libs = ['system', 'program_options', 'filesystem']
37 if conf.env.WITH_TESTS:
38 boost_libs.append('unit_test_framework')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080039
Davide Pesavento55d98602019-10-15 22:40:05 -040040 conf.check_boost(lib=boost_libs, mt=True)
Davide Pesaventoa7fead42019-01-19 21:18:17 -050041 if conf.env.BOOST_VERSION_NUMBER < 105800:
42 conf.fatal('Minimum required Boost version is 1.58.0\n'
43 'Please upgrade your distribution or manually install a newer version of Boost'
44 ' (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080045
Davide Pesavento08994782018-01-22 12:13:41 -050046 conf.check_compiler_flags()
47
48 # Loading "late" to prevent tests from being compiled with profiling flags
Zhiyi Zhang8617a792017-01-17 16:45:56 -080049 conf.load('coverage')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080050 conf.load('sanitizers')
Zhiyi Zhang65ba9322017-01-19 14:15:03 -080051
Zhiyi Zhang7021a932017-03-17 10:26:51 -070052 # If there happens to be a static library, waf will put the corresponding -L flags
53 # before dynamic library flags. This can result in compilation failure when the
54 # system has a different version of the ndncert library installed.
Davide Pesavento55d98602019-10-15 22:40:05 -040055 conf.env.prepend_value('STLIBPATH', ['.'])
Zhiyi Zhang7021a932017-03-17 10:26:51 -070056
Davide Pesavento55d98602019-10-15 22:40:05 -040057 conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS)
58 conf.define('SYSCONFDIR', conf.env.SYSCONFDIR)
59 # The config header will contain all defines that were added using conf.define()
60 # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES
61 # will not appear in the config header, but will instead be passed directly to the
62 # compiler on the command line.
Zhiyi Zhang8617a792017-01-17 16:45:56 -080063 conf.write_config_header('src/ndncert-config.hpp')
64
65def build(bld):
Davide Pesaventoa7fead42019-01-19 21:18:17 -050066 bld.shlib(target='ndn-cert',
67 source=bld.path.ant_glob('src/**/*.cpp'),
68 vnum=VERSION,
69 cnum=VERSION,
Davide Pesavento55d98602019-10-15 22:40:05 -040070 use='NDN_CXX BOOST OPENSSL SQLITE3',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050071 includes='src',
72 export_includes='src',
73 install_path='${LIBDIR}')
74
75 bld(features='subst',
76 source='libndn-cert.pc.in',
77 target='libndn-cert.pc',
78 install_path = '${LIBDIR}/pkgconfig',
79 PREFIX = bld.env['PREFIX'],
80 INCLUDEDIR = '${INCLUDEDIR}/ndncert',
81 VERSION = VERSION)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080082
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080083 bld.recurse('tools')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080084 bld.recurse('tests')
Zhiyi Zhang7021a932017-03-17 10:26:51 -070085
86 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050087 dest='${INCLUDEDIR}/ndncert',
Davide Pesavento55d98602019-10-15 22:40:05 -040088 files=bld.path.ant_glob('src/**/*.hpp'),
Davide Pesaventoa7fead42019-01-19 21:18:17 -050089 cwd=bld.path.find_dir('src'),
90 relative_trick=True)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070091
92 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050093 dest='${INCLUDEDIR}/ndncert',
Davide Pesavento55d98602019-10-15 22:40:05 -040094 files=bld.path.get_bld().ant_glob('src/**/*.hpp'),
Davide Pesaventoa7fead42019-01-19 21:18:17 -050095 cwd=bld.path.get_bld().find_dir('src'),
96 relative_trick=False)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070097
Davide Pesavento55d98602019-10-15 22:40:05 -040098 bld.install_files('${SYSCONFDIR}/ndncert', ['ca.conf.sample',
99 'client.conf.sample',
100 'ndncert-mail.conf.sample'])
Zhiyi Zhang576aad12017-10-03 15:41:53 -0700101
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500102 bld(features='subst',
103 name='ndncert-send-email-challenge',
Zhiyi Zhang576aad12017-10-03 15:41:53 -0700104 source='ndncert-send-email-challenge.py',
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500105 target='bin/ndncert-send-email-challenge',
106 install_path='${BINDIR}',
107 chmod=Utils.O755)
Zhiyi Zhang576aad12017-10-03 15:41:53 -0700108
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500109 if Utils.unversioned_sys_platform() == 'linux':
110 bld(features='subst',
111 name='ndncert-server.service',
112 source='systemd/ndncert-server.service.in',
113 target='systemd/ndncert-server.service')