blob: 438b03f63a6135a64550ee8e26278f8ecac1ab51 [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"
4BUGREPORT = "http://redmine.named-data.net/projects/ndncert"
5GIT_TAG_PREFIX = "ndncert"
6
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',
14 'doxygen', 'sphinx_build'], tooldir=['.waf-tools'])
15
16 syncopt = opt.add_option_group ("ndncert options")
17 syncopt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
18 help='''build unit tests''')
19
20def configure(conf):
21 conf.load(['compiler_cxx', 'gnu_dirs',
22 'boost', 'default-compiler-flags', 'sqlite3',
23 'doxygen', 'sphinx_build'])
24
25 if 'PKG_CONFIG_PATH' not in os.environ:
26 os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env)
27
28 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" +
43 " (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
44 return
45
46 # Loading "late" to prevent tests to be compiled with profiling flags
47 conf.load('coverage')
48
49 conf.load('sanitizers')
Zhiyi Zhang65ba9322017-01-19 14:15:03 -080050
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080051 conf.define('SYSCONFDIR', conf.env['SYSCONFDIR'])
52
Zhiyi Zhang7021a932017-03-17 10:26:51 -070053 # If there happens to be a static library, waf will put the corresponding -L flags
54 # before dynamic library flags. This can result in compilation failure when the
55 # system has a different version of the ndncert library installed.
56 conf.env['STLIBPATH'] = ['.'] + conf.env['STLIBPATH']
57
Zhiyi Zhang8617a792017-01-17 16:45:56 -080058 conf.write_config_header('src/ndncert-config.hpp')
59
60def build(bld):
61 core = bld(
Zhiyi Zhangac421852017-04-09 11:24:33 -070062 target = "ndn-cert",
Zhiyi Zhang7021a932017-03-17 10:26:51 -070063 features=['cxx', 'cxxshlib'],
Zhiyi Zhang8617a792017-01-17 16:45:56 -080064 source = bld.path.ant_glob(['src/**/*.cpp']),
Zhiyi Zhang7021a932017-03-17 10:26:51 -070065 vnum = VERSION,
66 cnum = VERSION,
Zhiyi Zhang8617a792017-01-17 16:45:56 -080067 use = 'NDN_CXX BOOST',
68 includes = ['src'],
69 export_includes=['src'],
70 )
71
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080072 bld.recurse('tools')
73
Zhiyi Zhang8617a792017-01-17 16:45:56 -080074 bld.recurse('tests')
Zhiyi Zhang7021a932017-03-17 10:26:51 -070075
76 bld.install_files(
77 dest = "%s/ndncert" % bld.env['INCLUDEDIR'],
78 files = bld.path.ant_glob(['src/**/*.hpp', 'src/**/*.h']),
79 cwd = bld.path.find_dir("src"),
80 relative_trick = True,
81 )
82
83 bld.install_files(
84 dest = "%s/ndncert" % bld.env['INCLUDEDIR'],
85 files = bld.path.get_bld().ant_glob(['src/**/*.hpp']),
86 cwd = bld.path.get_bld().find_dir("src"),
87 relative_trick = False,
88 )
89
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080090 bld.install_files("${SYSCONFDIR}/ndncert", "ca.conf.sample")
91
92 bld.install_files("${SYSCONFDIR}/ndncert", "client.conf.sample")
93
Zhiyi Zhang576aad12017-10-03 15:41:53 -070094 bld.install_files("${SYSCONFDIR}/ndncert", "ndncert-mail.conf.sample")
95
96 bld(features="subst",
97 source='ndncert-send-email-challenge.py',
98 target='ndncert-send-email-challenge',
99 install_path="${BINDIR}",
100 chmod=Utils.O755,
101 )
102
Zhiyi Zhang7021a932017-03-17 10:26:51 -0700103 bld(features = "subst",
Zhiyi Zhangac421852017-04-09 11:24:33 -0700104 source='libndn-cert.pc.in',
105 target='libndn-cert.pc',
Zhiyi Zhang7021a932017-03-17 10:26:51 -0700106 install_path = '${LIBDIR}/pkgconfig',
107 PREFIX = bld.env['PREFIX'],
108 INCLUDEDIR = "%s/ndncert" % bld.env['INCLUDEDIR'],
109 VERSION = VERSION,
110 )