blob: c5df199a2554ab963c624c7f983a52bdea8f4a71 [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')
Zhiyi Zhang91e2b0f2020-10-17 15:55:57 -070019 optgrp.add_option('--with-systemd', action='store_true', default=False,
20 help='Enable systemd service file compilation')
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
Davide Pesavento55d98602019-10-15 22:40:05 -040031 conf.check_sqlite3()
Zhiyi Zhang0937d402020-10-16 17:05:31 -070032 conf.check_openssl(lib='crypto', atleast_version=0x1010100f) # 1.1.1
Zhiyi Zhang8617a792017-01-17 16:45:56 -080033
Davide Pesavento55d98602019-10-15 22:40:05 -040034 boost_libs = ['system', 'program_options', 'filesystem']
35 if conf.env.WITH_TESTS:
36 boost_libs.append('unit_test_framework')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080037
Davide Pesavento55d98602019-10-15 22:40:05 -040038 conf.check_boost(lib=boost_libs, mt=True)
Davide Pesaventoa7fead42019-01-19 21:18:17 -050039 if conf.env.BOOST_VERSION_NUMBER < 105800:
40 conf.fatal('Minimum required Boost version is 1.58.0\n'
41 'Please upgrade your distribution or manually install a newer version of Boost'
42 ' (https://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080043
Davide Pesavento08994782018-01-22 12:13:41 -050044 conf.check_compiler_flags()
45
46 # Loading "late" to prevent tests from being compiled with profiling flags
Zhiyi Zhang8617a792017-01-17 16:45:56 -080047 conf.load('coverage')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080048 conf.load('sanitizers')
Zhiyi Zhang65ba9322017-01-19 14:15:03 -080049
Zhiyi Zhang7021a932017-03-17 10:26:51 -070050 # If there happens to be a static library, waf will put the corresponding -L flags
51 # before dynamic library flags. This can result in compilation failure when the
52 # system has a different version of the ndncert library installed.
Davide Pesavento55d98602019-10-15 22:40:05 -040053 conf.env.prepend_value('STLIBPATH', ['.'])
Zhiyi Zhang7021a932017-03-17 10:26:51 -070054
tylerliudd359912020-10-20 13:05:22 -070055 conf.define_cond('NDNCERT_HAVE_TESTS', conf.env.WITH_TESTS)
Davide Pesavento55d98602019-10-15 22:40:05 -040056 conf.define('SYSCONFDIR', conf.env.SYSCONFDIR)
57 # The config header will contain all defines that were added using conf.define()
58 # or conf.define_cond(). Everything that was added directly to conf.env.DEFINES
59 # will not appear in the config header, but will instead be passed directly to the
60 # compiler on the command line.
Zhiyi Zhang8617a792017-01-17 16:45:56 -080061 conf.write_config_header('src/ndncert-config.hpp')
62
Zhiyi Zhang91e2b0f2020-10-17 15:55:57 -070063 conf.define_cond('WITH_SYSTEMD', conf.options.with_systemd)
64
Zhiyi Zhang8617a792017-01-17 16:45:56 -080065def build(bld):
Davide Pesaventoa7fead42019-01-19 21:18:17 -050066 bld.shlib(target='ndn-cert',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050067 vnum=VERSION,
68 cnum=VERSION,
Davide Pesaventoaae119a2019-11-09 18:30:03 -050069 source=bld.path.ant_glob('src/**/*.cpp'),
Davide Pesavento55d98602019-10-15 22:40:05 -040070 use='NDN_CXX BOOST OPENSSL SQLITE3',
Davide Pesaventoa7fead42019-01-19 21:18:17 -050071 includes='src',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050072 export_includes='src')
Davide Pesaventoa7fead42019-01-19 21:18:17 -050073
74 bld(features='subst',
75 source='libndn-cert.pc.in',
76 target='libndn-cert.pc',
Davide Pesaventoaae119a2019-11-09 18:30:03 -050077 install_path='${LIBDIR}/pkgconfig',
78 VERSION=VERSION)
Zhiyi Zhang8617a792017-01-17 16:45:56 -080079
Zhiyi Zhang08e0e982017-03-01 10:10:42 -080080 bld.recurse('tools')
Zhiyi Zhang8617a792017-01-17 16:45:56 -080081 bld.recurse('tests')
Zhiyi Zhang7021a932017-03-17 10:26:51 -070082
83 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050084 dest='${INCLUDEDIR}/ndncert',
Davide Pesavento55d98602019-10-15 22:40:05 -040085 files=bld.path.ant_glob('src/**/*.hpp'),
Davide Pesaventoa7fead42019-01-19 21:18:17 -050086 cwd=bld.path.find_dir('src'),
87 relative_trick=True)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070088
89 bld.install_files(
Davide Pesaventoa7fead42019-01-19 21:18:17 -050090 dest='${INCLUDEDIR}/ndncert',
Davide Pesavento55d98602019-10-15 22:40:05 -040091 files=bld.path.get_bld().ant_glob('src/**/*.hpp'),
Davide Pesaventoa7fead42019-01-19 21:18:17 -050092 cwd=bld.path.get_bld().find_dir('src'),
93 relative_trick=False)
Zhiyi Zhang7021a932017-03-17 10:26:51 -070094
Davide Pesavento55d98602019-10-15 22:40:05 -040095 bld.install_files('${SYSCONFDIR}/ndncert', ['ca.conf.sample',
96 'client.conf.sample',
97 'ndncert-mail.conf.sample'])
Zhiyi Zhang576aad12017-10-03 15:41:53 -070098
Davide Pesaventoa7fead42019-01-19 21:18:17 -050099 bld(features='subst',
100 name='ndncert-send-email-challenge',
Zhiyi Zhang576aad12017-10-03 15:41:53 -0700101 source='ndncert-send-email-challenge.py',
Davide Pesaventoa7fead42019-01-19 21:18:17 -0500102 target='bin/ndncert-send-email-challenge',
103 install_path='${BINDIR}',
104 chmod=Utils.O755)
Zhiyi Zhang1dab2dc2020-10-17 15:39:22 -0700105
Zhiyi Zhang91e2b0f2020-10-17 15:55:57 -0700106 bld(features='subst',
107 name='ndncert-server.service',
Zhiyi Zhang91e2b0f2020-10-17 15:55:57 -0700108 source='systemd/ndncert-ca.service.in',
109 target='systemd/ndncert-ca.service')