blob: 8cb55dc9a043833b1bb8417baaa020aa1f28fa58 [file] [log] [blame]
Zhiyi Zhang8617a792017-01-17 16:45:56 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2VERSION = "0.1.0"
3APPNAME = "ndncert"
Davide Pesavento08994782018-01-22 12:13:41 -05004BUGREPORT = "https://redmine.named-data.net/projects/ndncert"
5GIT_TAG_PREFIX = "ndncert-"
Zhiyi Zhang8617a792017-01-17 16:45:56 -08006
7from waflib import Logs, Utils, Context
8import os
9
10def options(opt):
11 opt.load(['compiler_cxx', 'gnu_dirs'])
12 opt.load(['boost', 'default-compiler-flags', 'sqlite3',
13 'coverage', 'sanitizers',
Davide Pesavento08994782018-01-22 12:13:41 -050014 'doxygen', 'sphinx_build'],
15 tooldir=['.waf-tools'])
Zhiyi Zhang8617a792017-01-17 16:45:56 -080016
Davide Pesavento08994782018-01-22 12:13:41 -050017 certopt = opt.add_option_group("ndncert options")
18 certopt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
19 help='''Build unit tests''')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080020
21def configure(conf):
22 conf.load(['compiler_cxx', 'gnu_dirs',
23 'boost', 'default-compiler-flags', 'sqlite3',
24 'doxygen', 'sphinx_build'])
25
26 if 'PKG_CONFIG_PATH' not in os.environ:
Davide Pesavento08994782018-01-22 12:13:41 -050027 os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080028 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
29 uselib_store='NDN_CXX', mandatory=True)
30
31 USED_BOOST_LIBS = ['system', 'filesystem', 'iostreams',
32 'program_options', 'thread', 'log', 'log_setup']
33
34 conf.env['WITH_TESTS'] = conf.options.with_tests
35 if conf.env['WITH_TESTS']:
36 USED_BOOST_LIBS += ['unit_test_framework']
37 conf.define('HAVE_TESTS', 1)
38
39 conf.check_boost(lib=USED_BOOST_LIBS, mt=True)
40 if conf.env.BOOST_VERSION_NUMBER < 105400:
41 Logs.error("Minimum required boost version is 1.54.0")
42 Logs.error("Please upgrade your distribution or install custom boost libraries" +
Davide Pesavento08994782018-01-22 12:13:41 -050043 " (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
Zhiyi Zhang8617a792017-01-17 16:45:56 -080044 return
45
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):
63 core = bld(
Zhiyi Zhangac421852017-04-09 11:24:33 -070064 target = "ndn-cert",
Zhiyi Zhang7021a932017-03-17 10:26:51 -070065 features=['cxx', 'cxxshlib'],
Zhiyi Zhang8617a792017-01-17 16:45:56 -080066 source = bld.path.ant_glob(['src/**/*.cpp']),
Zhiyi Zhang7021a932017-03-17 10:26:51 -070067 vnum = VERSION,
68 cnum = VERSION,
Zhiyi Zhang8617a792017-01-17 16:45:56 -080069 use = 'NDN_CXX BOOST',
70 includes = ['src'],
71 export_includes=['src'],
72 )
73
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080074 bld.recurse('tools')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080075 bld.recurse('tests')
Zhiyi Zhang7021a932017-03-17 10:26:51 -070076
77 bld.install_files(
78 dest = "%s/ndncert" % bld.env['INCLUDEDIR'],
79 files = bld.path.ant_glob(['src/**/*.hpp', 'src/**/*.h']),
80 cwd = bld.path.find_dir("src"),
81 relative_trick = True,
82 )
83
84 bld.install_files(
85 dest = "%s/ndncert" % bld.env['INCLUDEDIR'],
86 files = bld.path.get_bld().ant_glob(['src/**/*.hpp']),
87 cwd = bld.path.get_bld().find_dir("src"),
88 relative_trick = False,
89 )
90
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080091 bld.install_files("${SYSCONFDIR}/ndncert", "ca.conf.sample")
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080092 bld.install_files("${SYSCONFDIR}/ndncert", "client.conf.sample")
Zhiyi Zhang576aad12017-10-03 15:41:53 -070093 bld.install_files("${SYSCONFDIR}/ndncert", "ndncert-mail.conf.sample")
94
95 bld(features="subst",
96 source='ndncert-send-email-challenge.py',
97 target='ndncert-send-email-challenge',
98 install_path="${BINDIR}",
99 chmod=Utils.O755,
100 )
101
Zhiyi Zhang7021a932017-03-17 10:26:51 -0700102 bld(features = "subst",
Zhiyi Zhangac421852017-04-09 11:24:33 -0700103 source='libndn-cert.pc.in',
104 target='libndn-cert.pc',
Zhiyi Zhang7021a932017-03-17 10:26:51 -0700105 install_path = '${LIBDIR}/pkgconfig',
106 PREFIX = bld.env['PREFIX'],
107 INCLUDEDIR = "%s/ndncert" % bld.env['INCLUDEDIR'],
108 VERSION = VERSION,
109 )