blob: 40e060268e8429f53ea7961bd89457f5b7bf084b [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 Pesavento55d98602019-10-15 22:40:05 -040012 opt.load(['default-compiler-flags', 'coverage', 'sanitizers',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050013 'boost', 'openssl', 'sqlite3'],
Davide Pesavento08994782018-01-22 12:13:41 -050014 tooldir=['.waf-tools'])
Zhiyi Zhang8617a792017-01-17 16:45:56 -080015
Davide Pesaventoaae119a2019-11-09 18:30:03 -050016 optgrp = opt.add_option_group('ndncert Options')
17 optgrp.add_option('--with-tests', action='store_true', default=False,
18 help='Build unit tests')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080019
20def configure(conf):
21 conf.load(['compiler_cxx', 'gnu_dirs',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050022 'default-compiler-flags', 'boost', 'openssl', 'sqlite3'])
Zhiyi Zhang8617a792017-01-17 16:45:56 -080023
Davide Pesavento55d98602019-10-15 22:40:05 -040024 conf.env.WITH_TESTS = conf.options.with_tests
25
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -040026 pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig')
27 conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.0', '--cflags', '--libs'],
28 uselib_store='NDN_CXX', pkg_config_path=pkg_config_path)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080029
Davide Pesavento55d98602019-10-15 22:40:05 -040030 conf.check_sqlite3()
Davide Pesavento5672d292021-11-19 18:19:25 -050031 conf.check_openssl(lib='crypto', atleast_version='1.1.1')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080032
Davide Pesavento55d98602019-10-15 22:40:05 -040033 boost_libs = ['system', 'program_options', 'filesystem']
34 if conf.env.WITH_TESTS:
35 boost_libs.append('unit_test_framework')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080036
Davide Pesavento55d98602019-10-15 22:40:05 -040037 conf.check_boost(lib=boost_libs, mt=True)
Davide Pesaventoa34d6de2021-11-18 22:16:04 -050038 if conf.env.BOOST_VERSION_NUMBER < 106501:
39 conf.fatal('The minimum supported version of Boost is 1.65.1.\n'
40 'Please upgrade your distribution or manually install a newer version of Boost.\n'
41 'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080042
Davide Pesavento08994782018-01-22 12:13:41 -050043 conf.check_compiler_flags()
44
45 # Loading "late" to prevent tests from being compiled with profiling flags
Zhiyi Zhang8617a792017-01-17 16:45:56 -080046 conf.load('coverage')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080047 conf.load('sanitizers')
Zhiyi Zhang65ba9322017-01-19 14:15:03 -080048
Zhiyi Zhang7021a932017-03-17 10:26:51 -070049 # If there happens to be a static library, waf will put the corresponding -L flags
50 # before dynamic library flags. This can result in compilation failure when the
51 # system has a different version of the ndncert library installed.
Davide Pesavento55d98602019-10-15 22:40:05 -040052 conf.env.prepend_value('STLIBPATH', ['.'])
Zhiyi Zhang7021a932017-03-17 10:26:51 -070053
Zhiyi Zhang199508a2020-10-21 10:45:50 -070054 conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS)
Davide Pesavento55d98602019-10-15 22:40:05 -040055 conf.define('SYSCONFDIR', conf.env.SYSCONFDIR)
56 # The config header will contain all defines that were added using conf.define()
57 # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES
58 # will not appear in the config header, but will instead be passed directly to the
59 # compiler on the command line.
Zhiyi Zhang199508a2020-10-21 10:45:50 -070060 conf.write_config_header('src/detail/ndncert-config.hpp', define_prefix='NDNCERT_')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080061
62def build(bld):
Davide Pesaventoa7fead42019-01-19 21:18:17 -050063 bld.shlib(target='ndn-cert',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050064 vnum=VERSION,
65 cnum=VERSION,
Davide Pesaventoaae119a2019-11-09 18:30:03 -050066 source=bld.path.ant_glob('src/**/*.cpp'),
Davide Pesavento55d98602019-10-15 22:40:05 -040067 use='NDN_CXX BOOST OPENSSL SQLITE3',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050068 includes='src',
Davide Pesavento829aff62022-05-15 20:30:34 -040069 export_includes='src .')
Davide Pesaventoa7fead42019-01-19 21:18:17 -050070
71 bld(features='subst',
72 source='libndn-cert.pc.in',
73 target='libndn-cert.pc',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050074 install_path='${LIBDIR}/pkgconfig',
75 VERSION=VERSION)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080076
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080077 bld.recurse('tools')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080078 bld.recurse('tests')
Zhiyi Zhang7021a932017-03-17 10:26:51 -070079
80 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050081 dest='${INCLUDEDIR}/ndncert',
Davide Pesavento55d98602019-10-15 22:40:05 -040082 files=bld.path.ant_glob('src/**/*.hpp'),
Davide Pesaventoa7fead42019-01-19 21:18:17 -050083 cwd=bld.path.find_dir('src'),
84 relative_trick=True)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070085
Davide Pesavento725d3fc2021-11-19 23:37:03 -050086 bld.install_files('${INCLUDEDIR}/ndncert/detail',
87 bld.path.find_resource('src/detail/ndncert-config.hpp'))
Zhiyi Zhang7021a932017-03-17 10:26:51 -070088
Davide Pesavento725d3fc2021-11-19 23:37:03 -050089 bld.install_files('${SYSCONFDIR}/ndncert',
90 ['ca.conf.sample',
91 'client.conf.sample',
92 'ndncert-mail.conf.sample'])
Zhiyi Zhang576aad12017-10-03 15:41:53 -070093
Davide Pesaventoa7fead42019-01-19 21:18:17 -050094 bld(features='subst',
95 name='ndncert-send-email-challenge',
Zhiyi Zhang576aad12017-10-03 15:41:53 -070096 source='ndncert-send-email-challenge.py',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050097 target='bin/ndncert-send-email-challenge',
98 install_path='${BINDIR}',
99 chmod=Utils.O755)
Zhiyi Zhang1dab2dc2020-10-17 15:39:22 -0700100
Davide Pesavento725d3fc2021-11-19 23:37:03 -0500101 if Utils.unversioned_sys_platform() == 'linux':
102 bld(features='subst',
103 name='ndncert-ca.service',
104 source='systemd/ndncert-ca.service.in',
105 target='systemd/ndncert-ca.service')