Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | VERSION = "0.1.0" |
| 3 | APPNAME = "ndncert" |
| 4 | BUGREPORT = "http://redmine.named-data.net/projects/ndncert" |
| 5 | GIT_TAG_PREFIX = "ndncert" |
| 6 | |
| 7 | from waflib import Logs, Utils, Context |
| 8 | import os |
| 9 | |
| 10 | def 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 | |
| 20 | def 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 Zhang | 65ba932 | 2017-01-19 14:15:03 -0800 | [diff] [blame] | 50 | |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 51 | # 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 Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 56 | conf.write_config_header('src/ndncert-config.hpp') |
| 57 | |
| 58 | def build(bld): |
| 59 | core = bld( |
Zhiyi Zhang | ac42185 | 2017-04-09 11:24:33 -0700 | [diff] [blame] | 60 | target = "ndn-cert", |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 61 | features=['cxx', 'cxxshlib'], |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 62 | source = bld.path.ant_glob(['src/**/*.cpp']), |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 63 | vnum = VERSION, |
| 64 | cnum = VERSION, |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 65 | use = 'NDN_CXX BOOST', |
| 66 | includes = ['src'], |
| 67 | export_includes=['src'], |
| 68 | ) |
| 69 | |
| 70 | bld.recurse('tests') |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 71 | |
| 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 Zhang | ac42185 | 2017-04-09 11:24:33 -0700 | [diff] [blame] | 87 | source='libndn-cert.pc.in', |
| 88 | target='libndn-cert.pc', |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 89 | install_path = '${LIBDIR}/pkgconfig', |
| 90 | PREFIX = bld.env['PREFIX'], |
| 91 | INCLUDEDIR = "%s/ndncert" % bld.env['INCLUDEDIR'], |
| 92 | VERSION = VERSION, |
| 93 | ) |