diff --git a/.waf-tools/boost.py b/.waf-tools/boost.py index 4eddec7a..4b2ede53 100644 --- a/.waf-tools/boost.py +++ b/.waf-tools/boost.py @@ -56,6 +56,7 @@ from waflib.TaskGen import feature, after_method BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib'] BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include'] + BOOST_VERSION_FILE = 'boost/version.hpp' BOOST_VERSION_CODE = ''' #include @@ -90,13 +91,18 @@ int main() { boost::thread t; } BOOST_LOG_CODE = ''' #include +int main() { BOOST_LOG_TRIVIAL(info) << "boost_log is working"; } +''' + +BOOST_LOG_SETUP_CODE = ''' +#include #include #include int main() { using namespace boost::log; add_common_attributes(); add_console_log(std::clog, keywords::format = "%Message%"); - BOOST_LOG_TRIVIAL(debug) << "log is working" << std::endl; + BOOST_LOG_TRIVIAL(info) << "boost_log_setup is working"; } ''' @@ -452,12 +458,15 @@ def check_boost(self, *k, **kw): self.check_cxx(fragment=BOOST_ERROR_CODE, use=var, execute=False) if has_lib('thread'): self.check_cxx(fragment=BOOST_THREAD_CODE, use=var, execute=False) - if has_lib('log'): + if has_lib('log') or has_lib('log_setup'): if not has_lib('thread'): self.env['DEFINES_%s' % var] += ['BOOST_LOG_NO_THREADS'] - if has_shlib('log'): + if has_shlib('log') or has_shlib('log_setup'): self.env['DEFINES_%s' % var] += ['BOOST_LOG_DYN_LINK'] - self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False) + if has_lib('log_setup'): + self.check_cxx(fragment=BOOST_LOG_SETUP_CODE, use=var, execute=False) + else: + self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False) if params.get('linkage_autodetect', False): self.start_msg('Attempting to detect boost linkage flags') diff --git a/.waf-tools/openssl.py b/.waf-tools/openssl.py index de0f9dc5..b35795f5 100644 --- a/.waf-tools/openssl.py +++ b/.waf-tools/openssl.py @@ -19,23 +19,20 @@ When using this tool, the wscript will look like: ''' import re -from waflib import Utils, Logs +from waflib import Utils from waflib.Configure import conf -OPENSSL_VERSION_FILE = 'opensslv.h' OPENSSL_DIR_OSX = ['/usr/local', '/opt/local', '/usr/local/opt/openssl'] OPENSSL_DIR = ['/usr', '/usr/local', '/opt/local', '/sw'] def options(opt): opt.add_option('--with-openssl', type='string', default=None, dest='openssl_dir', - help='''Path to where OpenSSL is installed, e.g., /usr/local''') - + help='directory where OpenSSL is installed, e.g., /usr/local') @conf def __openssl_get_version_file(self, dir): try: - return self.root.find_dir(dir).find_node('%s/%s' % ('include/openssl', - OPENSSL_VERSION_FILE)) + return self.root.find_dir(dir).find_node('include/openssl/opensslv.h') except: return None @@ -47,8 +44,8 @@ def __openssl_find_root_and_version_file(self, *k, **kw): if root and file: return (root, file) - openssl_dir = []; - if Utils.unversioned_sys_platform() == "darwin": + openssl_dir = [] + if Utils.unversioned_sys_platform() == 'darwin': openssl_dir = OPENSSL_DIR_OSX else: openssl_dir = OPENSSL_DIR @@ -66,10 +63,7 @@ def __openssl_find_root_and_version_file(self, *k, **kw): @conf def check_openssl(self, *k, **kw): - atleast_version = kw.get('atleast_version', 0) - var = kw.get('uselib_store', 'OPENSSL') - - self.start_msg('Checking for OpenSSL lib') + self.start_msg('Checking for OpenSSL version') (root, file) = self.__openssl_find_root_and_version_file(*k, **kw) try: @@ -88,18 +82,21 @@ def check_openssl(self, *k, **kw): except: self.fatal('OpenSSL version file is not found or is not usable') + atleast_version = kw.get('atleast_version', 0) if int(version, 16) < atleast_version: - self.fatal("The version of OpenSSL is too old\n" + - "Please upgrade your distribution or install newer version of OpenSSL library") + self.fatal('The version of OpenSSL is too old\n' + 'Please upgrade your distribution or manually install a newer version of OpenSSL') - kwargs = {} + if 'msg' not in kw: + kw['msg'] = 'Checking if OpenSSL library works' + if 'lib' not in kw: + kw['lib'] = ['ssl', 'crypto'] + if 'uselib_store' not in kw: + kw['uselib_store'] = 'OPENSSL' + if 'define_name' not in kw: + kw['define_name'] = 'HAVE_%s' % kw['uselib_store'] if root: - kwargs['includes'] = "%s/include" % root - kwargs['libpath'] = "%s/lib" % root + kw['includes'] = '%s/include' % root + kw['libpath'] = '%s/lib' % root - libcrypto = self.check_cxx(lib=['ssl', 'crypto'], - msg='Checking if OpenSSL library works', - define_name='HAVE_%s' % var, - uselib_store=var, - mandatory=True, - **kwargs) + self.check_cxx(**kw) diff --git a/.waf-tools/sqlite3.py b/.waf-tools/sqlite3.py index 3d4e46ed..4f2c0169 100644 --- a/.waf-tools/sqlite3.py +++ b/.waf-tools/sqlite3.py @@ -1,16 +1,15 @@ #! /usr/bin/env python # encoding: utf-8 -from waflib import Options, Logs from waflib.Configure import conf def options(opt): - opt.add_option('--with-sqlite3', type='string', default=None, - dest='with_sqlite3', help='''Path to SQLite3, e.g., /usr/local''') + opt.add_option('--with-sqlite3', type='string', default=None, dest='sqlite3_dir', + help='directory where SQLite3 is installed, e.g., /usr/local') @conf def check_sqlite3(self, *k, **kw): - root = k and k[0] or kw.get('path', None) or Options.options.with_sqlite3 + root = k and k[0] or kw.get('path', self.options.sqlite3_dir) mandatory = kw.get('mandatory', True) var = kw.get('uselib_store', 'SQLITE3') @@ -20,8 +19,8 @@ def check_sqlite3(self, *k, **kw): define_name='HAVE_%s' % var, uselib_store=var, mandatory=mandatory, - includes="%s/include" % root, - libpath="%s/lib" % root) + includes='%s/include' % root, + libpath='%s/lib' % root) else: try: self.check_cfg(package='sqlite3', diff --git a/wscript b/wscript index 126ec40c..a781d66c 100644 --- a/wscript +++ b/wscript @@ -17,31 +17,7 @@ def options(opt): 'doxygen', 'sphinx_build'], tooldir=['.waf-tools']) - opt = opt.add_option_group('Library Options') - - opt.add_option('--with-examples', action='store_true', default=False, - help='Build examples') - - opt.add_option('--with-tests', action='store_true', default=False, - help='Build tests') - - opt.add_option('--without-tools', action='store_false', default=True, dest='with_tools', - help='Do not build tools') - - stacktrace_choices = ['backtrace', 'addr2line', 'basic', 'noop'] - opt.add_option('--with-stacktrace', action='store', default=None, choices=stacktrace_choices, - help='Select the stacktrace backend implementation: ' - '%s [default=auto-detect]' % ', '.join(stacktrace_choices)) - opt.add_option('--without-stacktrace', action='store_const', const='', dest='with_stacktrace', - help='Disable stacktrace support') - - opt.add_option('--without-sqlite-locking', action='store_false', default=True, dest='with_sqlite_locking', - help='Disable filesystem locking in sqlite3 database ' - '(use unix-dot locking mechanism instead). ' - 'This option may be necessary if the home directory is hosted on NFS.') - - opt.add_option('--without-osx-keychain', action='store_false', default=True, - dest='with_osx_keychain', help='Do not use macOS Keychain as default TPM (macOS only)') + opt = opt.add_option_group('ndn-cxx Options') opt.add_option('--enable-static', action='store_true', default=False, dest='enable_static', help='Build static library (disabled by default)') @@ -53,6 +29,30 @@ def options(opt): opt.add_option('--disable-shared', action='store_false', default=True, dest='enable_shared', help='Do not build shared library (enabled by default)') + opt.add_option('--without-osx-keychain', action='store_false', default=True, + dest='with_osx_keychain', help='Do not use macOS Keychain as default TPM (macOS only)') + + opt.add_option('--without-sqlite-locking', action='store_false', default=True, dest='with_sqlite_locking', + help='Disable filesystem locking in sqlite3 database ' + '(use unix-dot locking mechanism instead). ' + 'This option may be necessary if the home directory is hosted on NFS.') + + stacktrace_choices = ['backtrace', 'addr2line', 'basic', 'noop'] + opt.add_option('--with-stacktrace', action='store', default=None, choices=stacktrace_choices, + help='Select the stacktrace backend implementation: ' + '%s [default=auto-detect]' % ', '.join(stacktrace_choices)) + opt.add_option('--without-stacktrace', action='store_const', const='', dest='with_stacktrace', + help='Disable stacktrace support') + + opt.add_option('--with-examples', action='store_true', default=False, + help='Build examples') + + opt.add_option('--with-tests', action='store_true', default=False, + help='Build tests') + + opt.add_option('--without-tools', action='store_false', default=True, dest='with_tools', + help='Do not build tools') + def configure(conf): conf.start_msg('Building static library') if conf.options.enable_static: @@ -80,7 +80,7 @@ def configure(conf): conf.env.WITH_TOOLS = conf.options.with_tools conf.env.WITH_EXAMPLES = conf.options.with_examples - conf.find_program('sh', var='SH', mandatory=True) + conf.find_program('sh', var='SH') conf.check_cxx(lib='pthread', uselib_store='PTHREAD', define_name='HAVE_PTHREAD', mandatory=False) conf.check_cxx(lib='rt', uselib_store='RT', define_name='HAVE_RT', mandatory=False) @@ -100,12 +100,10 @@ def configure(conf): int main() { return IFA_FLAGS; }''') conf.check_osx_frameworks() + conf.check_sqlite3() + conf.check_openssl(lib='crypto', atleast_version=0x1000200f) # 1.0.2 - conf.check_sqlite3(mandatory=True) - conf.check_openssl(mandatory=True, atleast_version=0x1000200f) # 1.0.2 - - boost_libs = ['system', 'filesystem', 'date_time', 'iostreams', - 'program_options', 'chrono', 'thread', 'log', 'log_setup'] + boost_libs = ['system', 'program_options', 'chrono', 'date_time', 'filesystem', 'thread', 'log'] stacktrace_backend = conf.options.with_stacktrace if stacktrace_backend is None: