blob: f5a330e39968b447cd7edcb0c99bfa28f179e71c [file] [log] [blame]
Zhiyi Zhang8617a792017-01-17 16:45:56 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Davide Pesaventoa7fead42019-01-19 21:18:17 -05002
Davide Pesaventoaae119a2019-11-09 18:30:03 -05003from waflib import Utils
Zhiyi Zhang8617a792017-01-17 16:45:56 -08004import os
5
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -04006VERSION = '0.1'
Davide Pesavento55d98602019-10-15 22:40:05 -04007APPNAME = 'ndncert'
8GIT_TAG_PREFIX = 'ndncert-'
9
Zhiyi Zhang8617a792017-01-17 16:45:56 -080010def options(opt):
11 opt.load(['compiler_cxx', 'gnu_dirs'])
Davide Pesavento573a6212022-07-09 21:56:41 -040012 opt.load(['default-compiler-flags',
13 'coverage', 'sanitizers',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050014 'boost', 'openssl', 'sqlite3'],
Davide Pesavento08994782018-01-22 12:13:41 -050015 tooldir=['.waf-tools'])
Zhiyi Zhang8617a792017-01-17 16:45:56 -080016
Davide Pesaventoaae119a2019-11-09 18:30:03 -050017 optgrp = opt.add_option_group('ndncert Options')
18 optgrp.add_option('--with-tests', action='store_true', default=False,
19 help='Build unit tests')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080020
21def configure(conf):
22 conf.load(['compiler_cxx', 'gnu_dirs',
Davide Pesavento573a6212022-07-09 21:56:41 -040023 'default-compiler-flags',
24 'boost', 'openssl', 'sqlite3'])
Zhiyi Zhang8617a792017-01-17 16:45:56 -080025
Davide Pesavento55d98602019-10-15 22:40:05 -040026 conf.env.WITH_TESTS = conf.options.with_tests
27
Davide Pesavento573a6212022-07-09 21:56:41 -040028 # Prefer pkgconf if it's installed, because it gives more correct results
29 # on Fedora/CentOS/RHEL/etc. See https://bugzilla.redhat.com/show_bug.cgi?id=1953348
30 # Store the result in env.PKGCONFIG, which is the variable used inside check_cfg()
31 conf.find_program(['pkgconf', 'pkg-config'], var='PKGCONFIG')
32
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -040033 pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig')
34 conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.0', '--cflags', '--libs'],
35 uselib_store='NDN_CXX', pkg_config_path=pkg_config_path)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080036
Davide Pesavento55d98602019-10-15 22:40:05 -040037 conf.check_sqlite3()
Davide Pesavento5672d292021-11-19 18:19:25 -050038 conf.check_openssl(lib='crypto', atleast_version='1.1.1')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080039
Davide Pesavento55d98602019-10-15 22:40:05 -040040 boost_libs = ['system', 'program_options', 'filesystem']
41 if conf.env.WITH_TESTS:
42 boost_libs.append('unit_test_framework')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080043
Davide Pesavento55d98602019-10-15 22:40:05 -040044 conf.check_boost(lib=boost_libs, mt=True)
Davide Pesaventoa34d6de2021-11-18 22:16:04 -050045 if conf.env.BOOST_VERSION_NUMBER < 106501:
46 conf.fatal('The minimum supported version of Boost is 1.65.1.\n'
47 'Please upgrade your distribution or manually install a newer version of Boost.\n'
48 'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080049
Davide Pesavento08994782018-01-22 12:13:41 -050050 conf.check_compiler_flags()
51
52 # Loading "late" to prevent tests from being compiled with profiling flags
Zhiyi Zhang8617a792017-01-17 16:45:56 -080053 conf.load('coverage')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080054 conf.load('sanitizers')
Zhiyi Zhang65ba9322017-01-19 14:15:03 -080055
Zhiyi Zhang7021a932017-03-17 10:26:51 -070056 # If there happens to be a static library, waf will put the corresponding -L flags
57 # before dynamic library flags. This can result in compilation failure when the
58 # system has a different version of the ndncert library installed.
Davide Pesavento55d98602019-10-15 22:40:05 -040059 conf.env.prepend_value('STLIBPATH', ['.'])
Zhiyi Zhang7021a932017-03-17 10:26:51 -070060
Zhiyi Zhang199508a2020-10-21 10:45:50 -070061 conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS)
Davide Pesavento55d98602019-10-15 22:40:05 -040062 conf.define('SYSCONFDIR', conf.env.SYSCONFDIR)
63 # The config header will contain all defines that were added using conf.define()
64 # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES
65 # will not appear in the config header, but will instead be passed directly to the
66 # compiler on the command line.
Zhiyi Zhang199508a2020-10-21 10:45:50 -070067 conf.write_config_header('src/detail/ndncert-config.hpp', define_prefix='NDNCERT_')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080068
69def build(bld):
Davide Pesaventoa7fead42019-01-19 21:18:17 -050070 bld.shlib(target='ndn-cert',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050071 vnum=VERSION,
72 cnum=VERSION,
Davide Pesaventoaae119a2019-11-09 18:30:03 -050073 source=bld.path.ant_glob('src/**/*.cpp'),
Davide Pesavento55d98602019-10-15 22:40:05 -040074 use='NDN_CXX BOOST OPENSSL SQLITE3',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050075 includes='src',
Davide Pesavento829aff62022-05-15 20:30:34 -040076 export_includes='src .')
Davide Pesaventoa7fead42019-01-19 21:18:17 -050077
78 bld(features='subst',
79 source='libndn-cert.pc.in',
80 target='libndn-cert.pc',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050081 install_path='${LIBDIR}/pkgconfig',
82 VERSION=VERSION)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080083
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080084 bld.recurse('tools')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080085 bld.recurse('tests')
Zhiyi Zhang7021a932017-03-17 10:26:51 -070086
87 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050088 dest='${INCLUDEDIR}/ndncert',
Davide Pesavento55d98602019-10-15 22:40:05 -040089 files=bld.path.ant_glob('src/**/*.hpp'),
Davide Pesaventoa7fead42019-01-19 21:18:17 -050090 cwd=bld.path.find_dir('src'),
91 relative_trick=True)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070092
Davide Pesavento725d3fc2021-11-19 23:37:03 -050093 bld.install_files('${INCLUDEDIR}/ndncert/detail',
94 bld.path.find_resource('src/detail/ndncert-config.hpp'))
Zhiyi Zhang7021a932017-03-17 10:26:51 -070095
Davide Pesavento725d3fc2021-11-19 23:37:03 -050096 bld.install_files('${SYSCONFDIR}/ndncert',
97 ['ca.conf.sample',
98 'client.conf.sample',
99 'ndncert-mail.conf.sample'])
Zhiyi Zhang576aad12017-10-03 15:41:53 -0700100
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500101 bld(features='subst',
102 name='ndncert-send-email-challenge',
Zhiyi Zhang576aad12017-10-03 15:41:53 -0700103 source='ndncert-send-email-challenge.py',
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500104 target='bin/ndncert-send-email-challenge',
105 install_path='${BINDIR}',
106 chmod=Utils.O755)
Zhiyi Zhang1dab2dc2020-10-17 15:39:22 -0700107
Davide Pesavento725d3fc2021-11-19 23:37:03 -0500108 if Utils.unversioned_sys_platform() == 'linux':
109 bld(features='subst',
110 name='ndncert-ca.service',
111 source='systemd/ndncert-ca.service.in',
112 target='systemd/ndncert-ca.service')