blob: 67ece59c3cbc2efe1ea3859dc48ac5345dac5c6f [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
Zhiyi Zhang8617a792017-01-17 16:45:56 -08003import os
Davide Pesavento4ffe19d2023-09-16 21:30:36 -04004from waflib import Utils
Zhiyi Zhang8617a792017-01-17 16:45:56 -08005
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')
Davide Pesavento4ffe19d2023-09-16 21:30:36 -040019 optgrp.add_option('--without-tools', action='store_false', default=True, dest='with_tools',
20 help='Do not build tools')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080021
22def configure(conf):
23 conf.load(['compiler_cxx', 'gnu_dirs',
Davide Pesavento573a6212022-07-09 21:56:41 -040024 'default-compiler-flags',
25 'boost', 'openssl', 'sqlite3'])
Zhiyi Zhang8617a792017-01-17 16:45:56 -080026
Davide Pesavento55d98602019-10-15 22:40:05 -040027 conf.env.WITH_TESTS = conf.options.with_tests
Davide Pesavento4ffe19d2023-09-16 21:30:36 -040028 conf.env.WITH_TOOLS = conf.options.with_tools
Davide Pesavento55d98602019-10-15 22:40:05 -040029
Davide Pesavento573a6212022-07-09 21:56:41 -040030 # Prefer pkgconf if it's installed, because it gives more correct results
31 # on Fedora/CentOS/RHEL/etc. See https://bugzilla.redhat.com/show_bug.cgi?id=1953348
32 # Store the result in env.PKGCONFIG, which is the variable used inside check_cfg()
33 conf.find_program(['pkgconf', 'pkg-config'], var='PKGCONFIG')
34
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -040035 pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig')
Davide Pesaventod78e77e2022-12-31 17:01:32 -050036 conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.1', '--cflags', '--libs'],
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -040037 uselib_store='NDN_CXX', pkg_config_path=pkg_config_path)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080038
Davide Pesavento55d98602019-10-15 22:40:05 -040039 conf.check_sqlite3()
Davide Pesavento5672d292021-11-19 18:19:25 -050040 conf.check_openssl(lib='crypto', atleast_version='1.1.1')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080041
Davide Pesaventofd194852023-09-16 21:48:21 -040042 conf.check_boost(lib='filesystem', mt=True)
Davide Pesaventoa3dbb942023-09-16 22:30:35 -040043 if conf.env.BOOST_VERSION_NUMBER < 107100:
44 conf.fatal('The minimum supported version of Boost is 1.71.0.\n'
Davide Pesaventoa34d6de2021-11-18 22:16:04 -050045 'Please upgrade your distribution or manually install a newer version of Boost.\n'
46 'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080047
Davide Pesaventofd194852023-09-16 21:48:21 -040048 if conf.env.WITH_TESTS:
Davide Pesavento3e481842023-11-11 18:01:32 -050049 conf.check_boost(lib='unit_test_framework', mt=True, uselib_store='BOOST_TESTS')
Davide Pesaventofd194852023-09-16 21:48:21 -040050
51 if conf.env.WITH_TOOLS:
52 conf.check_boost(lib='program_options', mt=True, uselib_store='BOOST_TOOLS')
53
Davide Pesavento08994782018-01-22 12:13:41 -050054 conf.check_compiler_flags()
55
56 # Loading "late" to prevent tests from being compiled with profiling flags
Zhiyi Zhang8617a792017-01-17 16:45:56 -080057 conf.load('coverage')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080058 conf.load('sanitizers')
Zhiyi Zhang65ba9322017-01-19 14:15:03 -080059
Zhiyi Zhang7021a932017-03-17 10:26:51 -070060 # If there happens to be a static library, waf will put the corresponding -L flags
61 # before dynamic library flags. This can result in compilation failure when the
62 # system has a different version of the ndncert library installed.
Davide Pesavento55d98602019-10-15 22:40:05 -040063 conf.env.prepend_value('STLIBPATH', ['.'])
Zhiyi Zhang7021a932017-03-17 10:26:51 -070064
Davide Pesavento9510c912024-02-25 17:50:05 -050065 conf.define_cond('WITH_TESTS', conf.env.WITH_TESTS)
Davide Pesavento55d98602019-10-15 22:40:05 -040066 conf.define('SYSCONFDIR', conf.env.SYSCONFDIR)
67 # The config header will contain all defines that were added using conf.define()
68 # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES
69 # will not appear in the config header, but will instead be passed directly to the
70 # compiler on the command line.
Zhiyi Zhang199508a2020-10-21 10:45:50 -070071 conf.write_config_header('src/detail/ndncert-config.hpp', define_prefix='NDNCERT_')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080072
73def build(bld):
Davide Pesaventofd194852023-09-16 21:48:21 -040074 bld.shlib(
75 target='ndn-cert',
76 name='libndn-cert',
77 vnum=VERSION,
78 cnum=VERSION,
79 source=bld.path.ant_glob('src/**/*.cpp'),
80 use='BOOST NDN_CXX OPENSSL SQLITE3',
81 includes='src',
82 export_includes='src')
Davide Pesavento4ffe19d2023-09-16 21:30:36 -040083
84 if bld.env.WITH_TESTS:
85 bld.recurse('tests')
86
87 if bld.env.WITH_TOOLS:
88 bld.recurse('tools')
89
90 # Install header files
91 srcdir = bld.path.find_dir('src')
92 bld.install_files('${INCLUDEDIR}/ndncert',
93 srcdir.ant_glob('**/*.hpp'),
94 cwd=srcdir,
95 relative_trick=True)
96 bld.install_files('${INCLUDEDIR}/ndncert/detail', 'src/detail/ndncert-config.hpp')
97
98 # Install sample configs
99 bld.install_files('${SYSCONFDIR}/ndncert',
100 ['ca.conf.sample',
101 'client.conf.sample',
102 'ndncert-mail.conf.sample'])
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500103
104 bld(features='subst',
105 source='libndn-cert.pc.in',
106 target='libndn-cert.pc',
Davide Pesaventoaae119a2019-11-09 18:30:03 -0500107 install_path='${LIBDIR}/pkgconfig',
108 VERSION=VERSION)
Zhiyi Zhang8617a792017-01-17 16:45:56 -0800109
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500110 bld(features='subst',
111 name='ndncert-send-email-challenge',
Zhiyi Zhang576aad12017-10-03 15:41:53 -0700112 source='ndncert-send-email-challenge.py',
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500113 target='bin/ndncert-send-email-challenge',
114 install_path='${BINDIR}',
115 chmod=Utils.O755)
Zhiyi Zhang1dab2dc2020-10-17 15:39:22 -0700116
Davide Pesavento725d3fc2021-11-19 23:37:03 -0500117 if Utils.unversioned_sys_platform() == 'linux':
118 bld(features='subst',
Davide Pesavento4ffe19d2023-09-16 21:30:36 -0400119 name='systemd-units',
Davide Pesavento725d3fc2021-11-19 23:37:03 -0500120 source='systemd/ndncert-ca.service.in',
121 target='systemd/ndncert-ca.service')
Davide Pesaventoc2fedec2023-09-19 16:30:30 -0400122
123def dist(ctx):
124 ctx.algo = 'tar.xz'
125
126def distcheck(ctx):
127 ctx.algo = 'tar.xz'