blob: dab4d7a1e353d4947a9b935ccb8c86e3b7cbfce1 [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'])
13 opt.load(['boost', 'default-compiler-flags', 'sqlite3',
14 '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',
24 'boost', 'default-compiler-flags', 'sqlite3',
25 '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()
47
48 # Loading "late" to prevent tests from being compiled with profiling flags
Zhiyi Zhang8617a792017-01-17 16:45:56 -080049 conf.load('coverage')
50
51 conf.load('sanitizers')
Zhiyi Zhang65ba9322017-01-19 14:15:03 -080052
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080053 conf.define('SYSCONFDIR', conf.env['SYSCONFDIR'])
54
Zhiyi Zhang7021a932017-03-17 10:26:51 -070055 # 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.
58 conf.env['STLIBPATH'] = ['.'] + conf.env['STLIBPATH']
59
Zhiyi Zhang8617a792017-01-17 16:45:56 -080060 conf.write_config_header('src/ndncert-config.hpp')
61
62def build(bld):
Davide Pesaventoa7fead42019-01-19 21:18:17 -050063 bld.shlib(target='ndn-cert',
64 source=bld.path.ant_glob('src/**/*.cpp'),
65 vnum=VERSION,
66 cnum=VERSION,
67 use='NDN_CXX BOOST',
68 includes='src',
69 export_includes='src',
70 install_path='${LIBDIR}')
71
72 bld(features='subst',
73 source='libndn-cert.pc.in',
74 target='libndn-cert.pc',
75 install_path = '${LIBDIR}/pkgconfig',
76 PREFIX = bld.env['PREFIX'],
77 INCLUDEDIR = '${INCLUDEDIR}/ndncert',
78 VERSION = VERSION)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080079
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080080 bld.recurse('tools')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080081 bld.recurse('tests')
Zhiyi Zhang7021a932017-03-17 10:26:51 -070082
83 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050084 dest='${INCLUDEDIR}/ndncert',
85 files=bld.path.ant_glob(['src/**/*.hpp', 'src/**/*.h']),
86 cwd=bld.path.find_dir('src'),
87 relative_trick=True)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070088
89 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050090 dest='${INCLUDEDIR}/ndncert',
91 files=bld.path.get_bld().ant_glob(['src/**/*.hpp']),
92 cwd=bld.path.get_bld().find_dir('src'),
93 relative_trick=False)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070094
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080095 bld.install_files("${SYSCONFDIR}/ndncert", "ca.conf.sample")
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080096 bld.install_files("${SYSCONFDIR}/ndncert", "client.conf.sample")
Zhiyi Zhang576aad12017-10-03 15:41:53 -070097 bld.install_files("${SYSCONFDIR}/ndncert", "ndncert-mail.conf.sample")
98
Davide Pesaventoa7fead42019-01-19 21:18:17 -050099 bld(features='subst',
100 name='ndncert-send-email-challenge',
Zhiyi Zhang576aad12017-10-03 15:41:53 -0700101 source='ndncert-send-email-challenge.py',
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500102 target='bin/ndncert-send-email-challenge',
103 install_path='${BINDIR}',
104 chmod=Utils.O755)
Zhiyi Zhang576aad12017-10-03 15:41:53 -0700105
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500106 if Utils.unversioned_sys_platform() == 'linux':
107 bld(features='subst',
108 name='ndncert-server.service',
109 source='systemd/ndncert-server.service.in',
110 target='systemd/ndncert-server.service')