blob: 0333e48e579d3342c5b5ae3d41cdb9922a8c4d13 [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 Zhang7021a932017-03-17 10:26:51 -070051 # If there happens to be a static library, waf will put the corresponding -L flags
52 # before dynamic library flags. This can result in compilation failure when the
53 # system has a different version of the ndncert library installed.
54 conf.env['STLIBPATH'] = ['.'] + conf.env['STLIBPATH']
55
Zhiyi Zhang8617a792017-01-17 16:45:56 -080056 conf.write_config_header('src/ndncert-config.hpp')
57
58def build(bld):
59 core = bld(
Zhiyi Zhangac421852017-04-09 11:24:33 -070060 target = "ndn-cert",
Zhiyi Zhang7021a932017-03-17 10:26:51 -070061 features=['cxx', 'cxxshlib'],
Zhiyi Zhang8617a792017-01-17 16:45:56 -080062 source = bld.path.ant_glob(['src/**/*.cpp']),
Zhiyi Zhang7021a932017-03-17 10:26:51 -070063 vnum = VERSION,
64 cnum = VERSION,
Zhiyi Zhang8617a792017-01-17 16:45:56 -080065 use = 'NDN_CXX BOOST',
66 includes = ['src'],
67 export_includes=['src'],
68 )
69
70 bld.recurse('tests')
Zhiyi Zhang7021a932017-03-17 10:26:51 -070071
72 bld.install_files(
73 dest = "%s/ndncert" % bld.env['INCLUDEDIR'],
74 files = bld.path.ant_glob(['src/**/*.hpp', 'src/**/*.h']),
75 cwd = bld.path.find_dir("src"),
76 relative_trick = True,
77 )
78
79 bld.install_files(
80 dest = "%s/ndncert" % bld.env['INCLUDEDIR'],
81 files = bld.path.get_bld().ant_glob(['src/**/*.hpp']),
82 cwd = bld.path.get_bld().find_dir("src"),
83 relative_trick = False,
84 )
85
86 bld(features = "subst",
Zhiyi Zhangac421852017-04-09 11:24:33 -070087 source='libndn-cert.pc.in',
88 target='libndn-cert.pc',
Zhiyi Zhang7021a932017-03-17 10:26:51 -070089 install_path = '${LIBDIR}/pkgconfig',
90 PREFIX = bld.env['PREFIX'],
91 INCLUDEDIR = "%s/ndncert" % bld.env['INCLUDEDIR'],
92 VERSION = VERSION,
93 )