blob: 65ffe3b5f808115bf69b496a6818ea7f037286fd [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 Pesaventod78e77e2022-12-31 17:01:32 -05006VERSION = '0.1.0'
Davide Pesavento55d98602019-10-15 22:40:05 -04007APPNAME = 'ndncert'
Davide Pesavento55d98602019-10-15 22:40:05 -04008
Zhiyi Zhang8617a792017-01-17 16:45:56 -08009def options(opt):
10 opt.load(['compiler_cxx', 'gnu_dirs'])
Davide Pesavento573a6212022-07-09 21:56:41 -040011 opt.load(['default-compiler-flags',
12 '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 Pesavento573a6212022-07-09 21:56:41 -040022 'default-compiler-flags',
23 'boost', 'openssl', 'sqlite3'])
Zhiyi Zhang8617a792017-01-17 16:45:56 -080024
Davide Pesavento55d98602019-10-15 22:40:05 -040025 conf.env.WITH_TESTS = conf.options.with_tests
26
Davide Pesavento573a6212022-07-09 21:56:41 -040027 # Prefer pkgconf if it's installed, because it gives more correct results
28 # on Fedora/CentOS/RHEL/etc. See https://bugzilla.redhat.com/show_bug.cgi?id=1953348
29 # Store the result in env.PKGCONFIG, which is the variable used inside check_cfg()
30 conf.find_program(['pkgconf', 'pkg-config'], var='PKGCONFIG')
31
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -040032 pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig')
Davide Pesaventod78e77e2022-12-31 17:01:32 -050033 conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.1', '--cflags', '--libs'],
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -040034 uselib_store='NDN_CXX', pkg_config_path=pkg_config_path)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080035
Davide Pesavento55d98602019-10-15 22:40:05 -040036 conf.check_sqlite3()
Davide Pesavento5672d292021-11-19 18:19:25 -050037 conf.check_openssl(lib='crypto', atleast_version='1.1.1')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080038
Davide Pesavento55d98602019-10-15 22:40:05 -040039 boost_libs = ['system', 'program_options', 'filesystem']
40 if conf.env.WITH_TESTS:
41 boost_libs.append('unit_test_framework')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080042
Davide Pesavento55d98602019-10-15 22:40:05 -040043 conf.check_boost(lib=boost_libs, mt=True)
Davide Pesaventoa34d6de2021-11-18 22:16:04 -050044 if conf.env.BOOST_VERSION_NUMBER < 106501:
45 conf.fatal('The minimum supported version of Boost is 1.65.1.\n'
46 'Please upgrade your distribution or manually install a newer version of Boost.\n'
47 'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080048
Davide Pesavento08994782018-01-22 12:13:41 -050049 conf.check_compiler_flags()
50
51 # Loading "late" to prevent tests from being compiled with profiling flags
Zhiyi Zhang8617a792017-01-17 16:45:56 -080052 conf.load('coverage')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080053 conf.load('sanitizers')
Zhiyi Zhang65ba9322017-01-19 14:15:03 -080054
Zhiyi Zhang7021a932017-03-17 10:26:51 -070055 # 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.
Davide Pesavento55d98602019-10-15 22:40:05 -040058 conf.env.prepend_value('STLIBPATH', ['.'])
Zhiyi Zhang7021a932017-03-17 10:26:51 -070059
Zhiyi Zhang199508a2020-10-21 10:45:50 -070060 conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS)
Davide Pesavento55d98602019-10-15 22:40:05 -040061 conf.define('SYSCONFDIR', conf.env.SYSCONFDIR)
62 # The config header will contain all defines that were added using conf.define()
63 # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES
64 # will not appear in the config header, but will instead be passed directly to the
65 # compiler on the command line.
Zhiyi Zhang199508a2020-10-21 10:45:50 -070066 conf.write_config_header('src/detail/ndncert-config.hpp', define_prefix='NDNCERT_')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080067
68def build(bld):
Davide Pesaventoa7fead42019-01-19 21:18:17 -050069 bld.shlib(target='ndn-cert',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050070 vnum=VERSION,
71 cnum=VERSION,
Davide Pesaventoaae119a2019-11-09 18:30:03 -050072 source=bld.path.ant_glob('src/**/*.cpp'),
Davide Pesavento55d98602019-10-15 22:40:05 -040073 use='NDN_CXX BOOST OPENSSL SQLITE3',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050074 includes='src',
Davide Pesavento829aff62022-05-15 20:30:34 -040075 export_includes='src .')
Davide Pesaventoa7fead42019-01-19 21:18:17 -050076
77 bld(features='subst',
78 source='libndn-cert.pc.in',
79 target='libndn-cert.pc',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050080 install_path='${LIBDIR}/pkgconfig',
81 VERSION=VERSION)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080082
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080083 bld.recurse('tools')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080084 bld.recurse('tests')
Zhiyi Zhang7021a932017-03-17 10:26:51 -070085
86 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050087 dest='${INCLUDEDIR}/ndncert',
Davide Pesavento55d98602019-10-15 22:40:05 -040088 files=bld.path.ant_glob('src/**/*.hpp'),
Davide Pesaventoa7fead42019-01-19 21:18:17 -050089 cwd=bld.path.find_dir('src'),
90 relative_trick=True)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070091
Davide Pesavento725d3fc2021-11-19 23:37:03 -050092 bld.install_files('${INCLUDEDIR}/ndncert/detail',
93 bld.path.find_resource('src/detail/ndncert-config.hpp'))
Zhiyi Zhang7021a932017-03-17 10:26:51 -070094
Davide Pesavento725d3fc2021-11-19 23:37:03 -050095 bld.install_files('${SYSCONFDIR}/ndncert',
96 ['ca.conf.sample',
97 'client.conf.sample',
98 'ndncert-mail.conf.sample'])
Zhiyi Zhang576aad12017-10-03 15:41:53 -070099
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500100 bld(features='subst',
101 name='ndncert-send-email-challenge',
Zhiyi Zhang576aad12017-10-03 15:41:53 -0700102 source='ndncert-send-email-challenge.py',
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500103 target='bin/ndncert-send-email-challenge',
104 install_path='${BINDIR}',
105 chmod=Utils.O755)
Zhiyi Zhang1dab2dc2020-10-17 15:39:22 -0700106
Davide Pesavento725d3fc2021-11-19 23:37:03 -0500107 if Utils.unversioned_sys_platform() == 'linux':
108 bld(features='subst',
109 name='ndncert-ca.service',
110 source='systemd/ndncert-ca.service.in',
111 target='systemd/ndncert-ca.service')