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" |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 4 | BUGREPORT = "https://redmine.named-data.net/projects/ndncert" |
| 5 | GIT_TAG_PREFIX = "ndncert-" |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 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', |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 14 | 'doxygen', 'sphinx_build'], |
| 15 | tooldir=['.waf-tools']) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 16 | |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 17 | 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 Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 20 | |
| 21 | def 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 Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 27 | os.environ['PKG_CONFIG_PATH'] = Utils.subst_vars('${LIBDIR}/pkgconfig', conf.env) |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 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" + |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 43 | " (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)") |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 44 | return |
| 45 | |
Davide Pesavento | 0899478 | 2018-01-22 12:13:41 -0500 | [diff] [blame] | 46 | conf.check_compiler_flags() |
| 47 | |
| 48 | # Loading "late" to prevent tests from being compiled with profiling flags |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 49 | conf.load('coverage') |
| 50 | |
| 51 | conf.load('sanitizers') |
Zhiyi Zhang | 65ba932 | 2017-01-19 14:15:03 -0800 | [diff] [blame] | 52 | |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 53 | conf.define('SYSCONFDIR', conf.env['SYSCONFDIR']) |
| 54 | |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 55 | # 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 Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 60 | conf.write_config_header('src/ndncert-config.hpp') |
| 61 | |
| 62 | def build(bld): |
| 63 | core = bld( |
Zhiyi Zhang | ac42185 | 2017-04-09 11:24:33 -0700 | [diff] [blame] | 64 | target = "ndn-cert", |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 65 | features=['cxx', 'cxxshlib'], |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 66 | source = bld.path.ant_glob(['src/**/*.cpp']), |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 67 | vnum = VERSION, |
| 68 | cnum = VERSION, |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 69 | use = 'NDN_CXX BOOST', |
| 70 | includes = ['src'], |
| 71 | export_includes=['src'], |
| 72 | ) |
| 73 | |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 74 | bld.recurse('tools') |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 75 | bld.recurse('tests') |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 76 | |
| 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 Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 91 | bld.install_files("${SYSCONFDIR}/ndncert", "ca.conf.sample") |
Zhiyi Zhang | 08e0e98 | 2017-03-01 10:10:42 -0800 | [diff] [blame] | 92 | bld.install_files("${SYSCONFDIR}/ndncert", "client.conf.sample") |
Zhiyi Zhang | 576aad1 | 2017-10-03 15:41:53 -0700 | [diff] [blame] | 93 | 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 Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 102 | bld(features = "subst", |
Zhiyi Zhang | ac42185 | 2017-04-09 11:24:33 -0700 | [diff] [blame] | 103 | source='libndn-cert.pc.in', |
| 104 | target='libndn-cert.pc', |
Zhiyi Zhang | 7021a93 | 2017-03-17 10:26:51 -0700 | [diff] [blame] | 105 | install_path = '${LIBDIR}/pkgconfig', |
| 106 | PREFIX = bld.env['PREFIX'], |
| 107 | INCLUDEDIR = "%s/ndncert" % bld.env['INCLUDEDIR'], |
| 108 | VERSION = VERSION, |
| 109 | ) |