blob: b49d1242558711699f4bc861cd2a51c8d3d6b233 [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 Pesavento55d98602019-10-15 22:40:05 -04006VERSION = '0.1.0'
7APPNAME = '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')
tylerliuf53ef0d2020-10-17 14:56:45 -070019 optgrp.add_option('--without-systemd', action='store_true', default=False,
20 help='Disable systemd integration')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080021
22def configure(conf):
23 conf.load(['compiler_cxx', 'gnu_dirs',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050024 'default-compiler-flags', '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 Pesaventoaae119a2019-11-09 18:30:03 -050028 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], uselib_store='NDN_CXX',
29 pkg_config_path=os.environ.get('PKG_CONFIG_PATH', '%s/pkgconfig' % conf.env.LIBDIR))
Zhiyi Zhang8617a792017-01-17 16:45:56 -080030
tylerliuf53ef0d2020-10-17 14:56:45 -070031 if not conf.options.without_systemd:
32 conf.check_cfg(package='libsystemd', args=['--cflags', '--libs'],
33 uselib_store='SYSTEMD', mandatory=False)
34
Davide Pesavento55d98602019-10-15 22:40:05 -040035 conf.check_sqlite3()
Zhiyi Zhang0937d402020-10-16 17:05:31 -070036 conf.check_openssl(lib='crypto', atleast_version=0x1010100f) # 1.1.1
Zhiyi Zhang8617a792017-01-17 16:45:56 -080037
Davide Pesavento55d98602019-10-15 22:40:05 -040038 boost_libs = ['system', 'program_options', 'filesystem']
39 if conf.env.WITH_TESTS:
40 boost_libs.append('unit_test_framework')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080041
Davide Pesavento55d98602019-10-15 22:40:05 -040042 conf.check_boost(lib=boost_libs, mt=True)
Davide Pesaventoa7fead42019-01-19 21:18:17 -050043 if conf.env.BOOST_VERSION_NUMBER < 105800:
44 conf.fatal('Minimum required Boost version is 1.58.0\n'
45 'Please upgrade your distribution or manually install a newer version of Boost'
46 ' (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080047
Davide Pesavento08994782018-01-22 12:13:41 -050048 conf.check_compiler_flags()
49
50 # Loading "late" to prevent tests from being compiled with profiling flags
Zhiyi Zhang8617a792017-01-17 16:45:56 -080051 conf.load('coverage')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080052 conf.load('sanitizers')
Zhiyi Zhang65ba9322017-01-19 14:15:03 -080053
Zhiyi Zhang7021a932017-03-17 10:26:51 -070054 # If there happens to be a static library, waf will put the corresponding -L flags
55 # before dynamic library flags. This can result in compilation failure when the
56 # system has a different version of the ndncert library installed.
Davide Pesavento55d98602019-10-15 22:40:05 -040057 conf.env.prepend_value('STLIBPATH', ['.'])
Zhiyi Zhang7021a932017-03-17 10:26:51 -070058
Davide Pesavento55d98602019-10-15 22:40:05 -040059 conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS)
60 conf.define('SYSCONFDIR', conf.env.SYSCONFDIR)
61 # The config header will contain all defines that were added using conf.define()
62 # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES
63 # will not appear in the config header, but will instead be passed directly to the
64 # compiler on the command line.
Zhiyi Zhang8617a792017-01-17 16:45:56 -080065 conf.write_config_header('src/ndncert-config.hpp')
66
67def build(bld):
Davide Pesaventoa7fead42019-01-19 21:18:17 -050068 bld.shlib(target='ndn-cert',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050069 vnum=VERSION,
70 cnum=VERSION,
Davide Pesaventoaae119a2019-11-09 18:30:03 -050071 source=bld.path.ant_glob('src/**/*.cpp'),
Davide Pesavento55d98602019-10-15 22:40:05 -040072 use='NDN_CXX BOOST OPENSSL SQLITE3',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050073 includes='src',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050074 export_includes='src')
Davide Pesaventoa7fead42019-01-19 21:18:17 -050075
76 bld(features='subst',
77 source='libndn-cert.pc.in',
78 target='libndn-cert.pc',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050079 install_path='${LIBDIR}/pkgconfig',
80 VERSION=VERSION)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080081
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080082 bld.recurse('tools')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080083 bld.recurse('tests')
Zhiyi Zhang7021a932017-03-17 10:26:51 -070084
85 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050086 dest='${INCLUDEDIR}/ndncert',
Davide Pesavento55d98602019-10-15 22:40:05 -040087 files=bld.path.ant_glob('src/**/*.hpp'),
Davide Pesaventoa7fead42019-01-19 21:18:17 -050088 cwd=bld.path.find_dir('src'),
89 relative_trick=True)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070090
91 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050092 dest='${INCLUDEDIR}/ndncert',
Davide Pesavento55d98602019-10-15 22:40:05 -040093 files=bld.path.get_bld().ant_glob('src/**/*.hpp'),
Davide Pesaventoa7fead42019-01-19 21:18:17 -050094 cwd=bld.path.get_bld().find_dir('src'),
95 relative_trick=False)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070096
Davide Pesavento55d98602019-10-15 22:40:05 -040097 bld.install_files('${SYSCONFDIR}/ndncert', ['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
108 if bld.env.HAVE_SYSTEMD:
109
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500110 bld(features='subst',
111 name='ndncert-server.service',
112 source='systemd/ndncert-server.service.in',
113 target='systemd/ndncert-server.service')
Zhiyi Zhang79ee9442020-10-17 15:35:56 -0700114
115 bld(features='subst',
116 name='ndncert-server.service',
117 source='systemd/ndncert-ca.service.in',
118 target='systemd/ndncert-ca.service')