blob: 85fe3d595312e0834ca6ab92395d76fab9622e2e [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
Zhiyi Zhang8617a792017-01-17 16:45:56 -08003VERSION = "0.1.0"
4APPNAME = "ndncert"
Davide Pesavento08994782018-01-22 12:13:41 -05005BUGREPORT = "https://redmine.named-data.net/projects/ndncert"
6GIT_TAG_PREFIX = "ndncert-"
Zhiyi Zhang8617a792017-01-17 16:45:56 -08007
Davide Pesaventoa7fead42019-01-19 21:18:17 -05008from waflib import Context, Utils
Zhiyi Zhang8617a792017-01-17 16:45:56 -08009import os
10
11def options(opt):
12 opt.load(['compiler_cxx', 'gnu_dirs'])
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070013 opt.load(['boost', 'default-compiler-flags', 'sqlite3', 'openssl',
Zhiyi Zhang8617a792017-01-17 16:45:56 -080014 'coverage', 'sanitizers',
Davide Pesavento08994782018-01-22 12:13:41 -050015 'doxygen', 'sphinx_build'],
16 tooldir=['.waf-tools'])
Zhiyi Zhang8617a792017-01-17 16:45:56 -080017
Davide Pesavento08994782018-01-22 12:13:41 -050018 certopt = opt.add_option_group("ndncert options")
Davide Pesaventoa7fead42019-01-19 21:18:17 -050019 certopt.add_option('--with-tests', action='store_true', default=False,
20 help='Build unit tests')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080021
22def configure(conf):
23 conf.load(['compiler_cxx', 'gnu_dirs',
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070024 'boost', 'default-compiler-flags', 'sqlite3', 'openssl',
Zhiyi Zhang8617a792017-01-17 16:45:56 -080025 'doxygen', 'sphinx_build'])
26
27 if 'PKG_CONFIG_PATH' not in os.environ:
Davide Pesavento08994782018-01-22 12:13:41 -050028 os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080029 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
30 uselib_store='NDN_CXX', mandatory=True)
31
32 USED_BOOST_LIBS = ['system', 'filesystem', 'iostreams',
33 'program_options', 'thread', 'log', 'log_setup']
34
35 conf.env['WITH_TESTS'] = conf.options.with_tests
36 if conf.env['WITH_TESTS']:
37 USED_BOOST_LIBS += ['unit_test_framework']
38 conf.define('HAVE_TESTS', 1)
39
40 conf.check_boost(lib=USED_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()
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070047 conf.check_openssl(mandatory=True, atleast_version=0x1000200f) # 1.1.1b
Davide Pesavento08994782018-01-22 12:13:41 -050048
49 # Loading "late" to prevent tests from being compiled with profiling flags
Zhiyi Zhang8617a792017-01-17 16:45:56 -080050 conf.load('coverage')
51
52 conf.load('sanitizers')
Zhiyi Zhang65ba9322017-01-19 14:15:03 -080053
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080054 conf.define('SYSCONFDIR', conf.env['SYSCONFDIR'])
55
Zhiyi Zhang7021a932017-03-17 10:26:51 -070056 # If there happens to be a static library, waf will put the corresponding -L flags
57 # before dynamic library flags. This can result in compilation failure when the
58 # system has a different version of the ndncert library installed.
59 conf.env['STLIBPATH'] = ['.'] + conf.env['STLIBPATH']
60
Zhiyi Zhang8617a792017-01-17 16:45:56 -080061 conf.write_config_header('src/ndncert-config.hpp')
62
63def build(bld):
Davide Pesaventoa7fead42019-01-19 21:18:17 -050064 bld.shlib(target='ndn-cert',
65 source=bld.path.ant_glob('src/**/*.cpp'),
66 vnum=VERSION,
67 cnum=VERSION,
68 use='NDN_CXX BOOST',
69 includes='src',
70 export_includes='src',
71 install_path='${LIBDIR}')
72
73 bld(features='subst',
74 source='libndn-cert.pc.in',
75 target='libndn-cert.pc',
76 install_path = '${LIBDIR}/pkgconfig',
77 PREFIX = bld.env['PREFIX'],
78 INCLUDEDIR = '${INCLUDEDIR}/ndncert',
79 VERSION = VERSION)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080080
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080081 bld.recurse('tools')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080082 bld.recurse('tests')
Zhiyi Zhang7021a932017-03-17 10:26:51 -070083
84 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050085 dest='${INCLUDEDIR}/ndncert',
86 files=bld.path.ant_glob(['src/**/*.hpp', 'src/**/*.h']),
87 cwd=bld.path.find_dir('src'),
88 relative_trick=True)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070089
90 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050091 dest='${INCLUDEDIR}/ndncert',
92 files=bld.path.get_bld().ant_glob(['src/**/*.hpp']),
93 cwd=bld.path.get_bld().find_dir('src'),
94 relative_trick=False)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070095
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080096 bld.install_files("${SYSCONFDIR}/ndncert", "ca.conf.sample")
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080097 bld.install_files("${SYSCONFDIR}/ndncert", "client.conf.sample")
Zhiyi Zhang576aad12017-10-03 15:41:53 -070098 bld.install_files("${SYSCONFDIR}/ndncert", "ndncert-mail.conf.sample")
99
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500100 bld(features='subst',
101 name='ndncert-send-email-challenge',
Zhiyi Zhang576aad12017-10-03 15:41:53 -0700102 source='ndncert-send-email-challenge.py',
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500103 target='bin/ndncert-send-email-challenge',
104 install_path='${BINDIR}',
105 chmod=Utils.O755)
Zhiyi Zhang576aad12017-10-03 15:41:53 -0700106
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500107 if Utils.unversioned_sys_platform() == 'linux':
108 bld(features='subst',
109 name='ndncert-server.service',
110 source='systemd/ndncert-server.service.in',
111 target='systemd/ndncert-server.service')