Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 2 | |
Alexander Afanasyev | cfe0b06 | 2014-05-08 18:26:50 -0700 | [diff] [blame] | 3 | from waflib import Logs, Utils, Context |
| 4 | import os |
Alexander Afanasyev | a06fdda | 2014-04-29 19:15:00 -0700 | [diff] [blame] | 5 | |
Alexander Afanasyev | cfe0b06 | 2014-05-08 18:26:50 -0700 | [diff] [blame] | 6 | VERSION = "0.1.0" |
Alexander Afanasyev | 766cea7 | 2014-04-24 19:16:42 -0700 | [diff] [blame] | 7 | APPNAME = "ndn-cxx" |
| 8 | PACKAGE_BUGREPORT = "http://redmine.named-data.net/projects/ndn-cxx" |
Alexander Afanasyev | cfe0b06 | 2014-05-08 18:26:50 -0700 | [diff] [blame] | 9 | PACKAGE_URL = "http://named-data.net/doc/ndn-cxx/" |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 10 | |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 11 | def options(opt): |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 12 | opt.load(['compiler_cxx', 'gnu_dirs', 'c_osx']) |
| 13 | opt.load(['default-compiler-flags', 'coverage', 'osx-security', 'pch', |
| 14 | 'boost', 'openssl', 'cryptopp', 'sqlite3', |
| 15 | 'doxygen', 'sphinx_build'], |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 16 | tooldir=['.waf-tools']) |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 17 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 18 | opt = opt.add_option_group('Library Options') |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 19 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 20 | opt.add_option('--with-tests', action='store_true', default=False, dest='with_tests', |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 21 | help='''build unit tests''') |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 22 | opt.add_option('--with-log4cxx', action='store_true', default=False, dest='log4cxx', |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 23 | help='''Compile with log4cxx logging support''') |
| 24 | |
Yingdi Yu | e6bfab2 | 2014-02-06 16:01:19 -0800 | [diff] [blame] | 25 | opt.add_option('--without-tools', action='store_false', default=True, dest='with_tools', |
| 26 | help='''Do not build tools''') |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 27 | |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 28 | opt.add_option('--with-examples', action='store_true', default=False, dest='with_examples', |
| 29 | help='''Build examples''') |
| 30 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 31 | opt.add_option('--without-sqlite-locking', action='store_false', default=True, |
| 32 | dest='with_sqlite_locking', |
| 33 | help='''Disable filesystem locking in sqlite3 database ''' |
| 34 | '''(use unix-dot locking mechanism instead). ''' |
Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 35 | '''This option may be necessary if home directory is hosted on NFS.''') |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 36 | opt.add_option('--without-osx-keychain', action='store_false', default=True, |
| 37 | dest='with_osx_keychain', |
Alexander Afanasyev | 3e08d5d | 2014-02-12 19:24:28 -0800 | [diff] [blame] | 38 | help='''On Darwin, do not use OSX keychain as a default TPM''') |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 39 | |
| 40 | def configure(conf): |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 41 | conf.load(['compiler_cxx', 'gnu_dirs', 'c_osx', |
| 42 | 'default-compiler-flags', 'osx-security', 'pch', |
| 43 | 'boost', 'openssl', 'cryptopp', 'sqlite3', |
| 44 | 'doxygen', 'sphinx_build']) |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 45 | |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 46 | conf.env['WITH_TESTS'] = conf.options.with_tests |
| 47 | conf.env['WITH_TOOLS'] = conf.options.with_tools |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 48 | conf.env['WITH_EXAMPLES'] = conf.options.with_examples |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 49 | |
Alexander Afanasyev | 95de62e | 2014-04-11 18:26:33 -0700 | [diff] [blame] | 50 | conf.find_program('sh', var='SH', mandatory=True) |
| 51 | |
Alexander Afanasyev | fff47d6 | 2014-05-11 19:24:46 -0700 | [diff] [blame] | 52 | conf.check_cxx(lib='pthread', uselib_store='PTHREAD', define_name='HAVE_PTHREAD', |
| 53 | mandatory=False) |
| 54 | conf.check_cxx(lib='rt', uselib_store='RT', define_name='HAVE_RT', mandatory=False) |
| 55 | conf.check_cxx(cxxflags=['-fPIC'], uselib_store='cxxstlib', mandatory=False) |
| 56 | |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 57 | conf.check_osx_security(mandatory=False) |
Yingdi Yu | e6bfab2 | 2014-02-06 16:01:19 -0800 | [diff] [blame] | 58 | |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 59 | conf.check_openssl(mandatory=True) |
| 60 | conf.check_sqlite3(mandatory=True) |
Alexander Afanasyev | fff47d6 | 2014-05-11 19:24:46 -0700 | [diff] [blame] | 61 | conf.check_cryptopp(mandatory=True, use='PTHREAD') |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 62 | |
| 63 | if conf.options.log4cxx: |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 64 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', |
| 65 | mandatory=True) |
| 66 | conf.define("HAVE_LOG4CXX", 1) |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 67 | |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 68 | if conf.options.use_cxx11: |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 69 | conf.check(msg='Checking for type std::shared_ptr', |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 70 | type_name="std::shared_ptr<int>", header_name="memory", |
Alexander Afanasyev | b78bc4d | 2014-04-09 21:20:52 -0700 | [diff] [blame] | 71 | define_name='HAVE_STD_SHARED_PTR', mandatory=True) |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 72 | conf.check(msg='Checking for type std::function', |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 73 | type_name="std::function<void()>", header_name="functional", |
Alexander Afanasyev | b78bc4d | 2014-04-09 21:20:52 -0700 | [diff] [blame] | 74 | define_name='HAVE_STD_FUNCTION', mandatory=True) |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 75 | conf.define('HAVE_CXX11', 1) |
Alexander Afanasyev | 1dd95c5 | 2014-03-22 19:11:36 -0700 | [diff] [blame] | 76 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 77 | USED_BOOST_LIBS = ['system', 'filesystem', 'date_time', 'iostreams', |
| 78 | 'regex', 'program_options', 'chrono'] |
Alexander Afanasyev | dafdc37 | 2014-03-03 15:58:44 +0000 | [diff] [blame] | 79 | if conf.env['WITH_TESTS']: |
| 80 | USED_BOOST_LIBS += ['unit_test_framework'] |
Yingdi Yu | f56c68f | 2014-04-24 21:50:13 -0700 | [diff] [blame] | 81 | conf.define('HAVE_TESTS', 1) |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 82 | |
Alexander Afanasyev | dafdc37 | 2014-03-03 15:58:44 +0000 | [diff] [blame] | 83 | conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True) |
| 84 | if conf.env.BOOST_VERSION_NUMBER < 104800: |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 85 | Logs.error("Minimum required boost version is 1.48.0") |
| 86 | Logs.error("Please upgrade your distribution or install custom boost libraries" + |
Alexander Afanasyev | dafdc37 | 2014-03-03 15:58:44 +0000 | [diff] [blame] | 87 | " (http://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)") |
| 88 | return |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 89 | |
Alexander Afanasyev | 5b60f70 | 2014-02-07 12:55:24 -0800 | [diff] [blame] | 90 | if not conf.options.with_sqlite_locking: |
| 91 | conf.define('DISABLE_SQLITE3_FS_LOCKING', 1) |
Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 92 | |
Alexander Afanasyev | 59d67a5 | 2014-04-03 16:09:31 -0700 | [diff] [blame] | 93 | if conf.env['HAVE_OSX_SECURITY']: |
Alexander Afanasyev | 3e08d5d | 2014-02-12 19:24:28 -0800 | [diff] [blame] | 94 | conf.env['WITH_OSX_KEYCHAIN'] = conf.options.with_osx_keychain |
| 95 | if conf.options.with_osx_keychain: |
| 96 | conf.define('WITH_OSX_KEYCHAIN', 1) |
| 97 | else: |
| 98 | conf.env['WITH_OSX_KEYCHAIN'] = False |
Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 99 | |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 100 | # Loading "late" to prevent tests to be compiled with profiling flags |
| 101 | conf.load('coverage') |
Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 102 | |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 103 | conf.define('SYSCONFDIR', conf.env['SYSCONFDIR']) |
| 104 | |
Alexander Afanasyev | 766cea7 | 2014-04-24 19:16:42 -0700 | [diff] [blame] | 105 | conf.write_config_header('src/ndn-cxx-config.hpp', define_prefix='NDN_CXX_') |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 106 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 107 | def build(bld): |
Alexander Afanasyev | cfe0b06 | 2014-05-08 18:26:50 -0700 | [diff] [blame] | 108 | version(bld) |
| 109 | |
| 110 | bld(features="subst", |
| 111 | name='version', |
| 112 | source='src/version.hpp.in', |
| 113 | target='src/version.hpp', |
| 114 | install_path=None, |
| 115 | VERSION_STRING=VERSION_BASE, |
| 116 | VERSION_BUILD=VERSION, |
| 117 | VERSION=int(VERSION_SPLIT[0]) * 1000000 + |
| 118 | int(VERSION_SPLIT[1]) * 1000 + |
| 119 | int(VERSION_SPLIT[2]), |
| 120 | VERSION_MAJOR=VERSION_SPLIT[0], |
| 121 | VERSION_MINOR=VERSION_SPLIT[1], |
| 122 | VERSION_PATCH=VERSION_SPLIT[2], |
| 123 | ) |
| 124 | |
Alexander Afanasyev | 766cea7 | 2014-04-24 19:16:42 -0700 | [diff] [blame] | 125 | libndn_cxx = bld( |
Alexander Afanasyev | 59efe10 | 2014-01-29 15:56:30 -0800 | [diff] [blame] | 126 | features=['cxx', 'cxxstlib'], # 'cxxshlib', |
Alexander Afanasyev | cfe0b06 | 2014-05-08 18:26:50 -0700 | [diff] [blame] | 127 | # vnum=VERSION, |
Alexander Afanasyev | 766cea7 | 2014-04-24 19:16:42 -0700 | [diff] [blame] | 128 | target="ndn-cxx", |
| 129 | name="ndn-cxx", |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 130 | source=bld.path.ant_glob('src/**/*.cpp', |
| 131 | excl=['src/**/*-osx.cpp', 'src/**/*-sqlite3.cpp']), |
Alexander Afanasyev | cfe0b06 | 2014-05-08 18:26:50 -0700 | [diff] [blame] | 132 | use='version BOOST OPENSSL LOG4CXX CRYPTOPP SQLITE3 RT PIC PTHREAD', |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 133 | includes=". src", |
| 134 | export_includes="src", |
| 135 | install_path='${LIBDIR}', |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 136 | ) |
| 137 | |
Alexander Afanasyev | e2dcdfd | 2014-02-07 15:53:28 -0800 | [diff] [blame] | 138 | if bld.env['WITH_PCH']: |
Alexander Afanasyev | 766cea7 | 2014-04-24 19:16:42 -0700 | [diff] [blame] | 139 | libndn_cxx.pch="src/common.hpp" |
Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 140 | |
Alexander Afanasyev | 59d67a5 | 2014-04-03 16:09:31 -0700 | [diff] [blame] | 141 | if bld.env['HAVE_OSX_SECURITY']: |
Alexander Afanasyev | 766cea7 | 2014-04-24 19:16:42 -0700 | [diff] [blame] | 142 | libndn_cxx.source += bld.path.ant_glob('src/**/*-osx.cpp') |
| 143 | libndn_cxx.mac_app = True |
| 144 | libndn_cxx.use += " OSX_COREFOUNDATION OSX_SECURITY" |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 145 | |
Alexander Afanasyev | 1e0a077 | 2014-01-28 20:07:07 -0800 | [diff] [blame] | 146 | # In case we want to make it optional later |
Alexander Afanasyev | 766cea7 | 2014-04-24 19:16:42 -0700 | [diff] [blame] | 147 | libndn_cxx.source += bld.path.ant_glob('src/**/*-sqlite3.cpp') |
Alexander Afanasyev | d409d59 | 2014-01-28 18:36:38 -0800 | [diff] [blame] | 148 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 149 | # Prepare flags that should go to pkgconfig file |
Alexander Afanasyev | 200dd6f | 2014-01-28 19:04:25 -0800 | [diff] [blame] | 150 | pkgconfig_libs = [] |
| 151 | pkgconfig_ldflags = [] |
Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 152 | pkgconfig_linkflags = [] |
Alexander Afanasyev | 200dd6f | 2014-01-28 19:04:25 -0800 | [diff] [blame] | 153 | pkgconfig_includes = [] |
Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 154 | pkgconfig_cxxflags = [] |
Alexander Afanasyev | 766cea7 | 2014-04-24 19:16:42 -0700 | [diff] [blame] | 155 | for lib in Utils.to_list(libndn_cxx.use): |
Alexander Afanasyev | 200dd6f | 2014-01-28 19:04:25 -0800 | [diff] [blame] | 156 | if bld.env['LIB_%s' % lib]: |
| 157 | pkgconfig_libs += Utils.to_list(bld.env['LIB_%s' % lib]) |
| 158 | if bld.env['LIBPATH_%s' % lib]: |
| 159 | pkgconfig_ldflags += Utils.to_list(bld.env['LIBPATH_%s' % lib]) |
| 160 | if bld.env['INCLUDES_%s' % lib]: |
| 161 | pkgconfig_includes += Utils.to_list(bld.env['INCLUDES_%s' % lib]) |
Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 162 | if bld.env['LINKFLAGS_%s' % lib]: |
| 163 | pkgconfig_linkflags += Utils.to_list(bld.env['LINKFLAGS_%s' % lib]) |
| 164 | if bld.env['CXXFLAGS_%s' % lib]: |
| 165 | pkgconfig_cxxflags += Utils.to_list(bld.env['CXXFLAGS_%s' % lib]) |
Alexander Afanasyev | 200dd6f | 2014-01-28 19:04:25 -0800 | [diff] [blame] | 166 | |
Alexander Afanasyev | 84cf429 | 2014-01-29 22:16:27 -0800 | [diff] [blame] | 167 | EXTRA_FRAMEWORKS = ""; |
Alexander Afanasyev | 59d67a5 | 2014-04-03 16:09:31 -0700 | [diff] [blame] | 168 | if bld.env['HAVE_OSX_SECURITY']: |
Alexander Afanasyev | 84cf429 | 2014-01-29 22:16:27 -0800 | [diff] [blame] | 169 | EXTRA_FRAMEWORKS = "-framework CoreFoundation -framework Security" |
Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 170 | |
Alexander Afanasyev | 200dd6f | 2014-01-28 19:04:25 -0800 | [diff] [blame] | 171 | def uniq(alist): |
| 172 | set = {} |
| 173 | return [set.setdefault(e,e) for e in alist if e not in set] |
Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 174 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 175 | pkconfig = bld(features="subst", |
Alexander Afanasyev | 766cea7 | 2014-04-24 19:16:42 -0700 | [diff] [blame] | 176 | source="libndn-cxx.pc.in", |
| 177 | target="libndn-cxx.pc", |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 178 | install_path="${LIBDIR}/pkgconfig", |
Alexander Afanasyev | cfe0b06 | 2014-05-08 18:26:50 -0700 | [diff] [blame] | 179 | VERSION=VERSION_BASE, |
Alexander Afanasyev | 200dd6f | 2014-01-28 19:04:25 -0800 | [diff] [blame] | 180 | |
| 181 | # This probably not the right thing to do, but to simplify life of apps |
| 182 | # that use the library |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 183 | EXTRA_LIBS=" ".join([('-l%s' % i) for i in uniq(pkgconfig_libs)]), |
| 184 | EXTRA_LDFLAGS=" ".join([('-L%s' % i) for i in uniq(pkgconfig_ldflags)]), |
| 185 | EXTRA_LINKFLAGS=" ".join(uniq(pkgconfig_linkflags)), |
| 186 | EXTRA_INCLUDES=" ".join([('-I%s' % i) for i in uniq(pkgconfig_includes)]), |
| 187 | EXTRA_CXXFLAGS=" ".join(uniq(pkgconfig_cxxflags)), |
| 188 | EXTRA_FRAMEWORKS=EXTRA_FRAMEWORKS, |
Alexander Afanasyev | d409d59 | 2014-01-28 18:36:38 -0800 | [diff] [blame] | 189 | ) |
Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 190 | |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 191 | # Unit tests |
| 192 | if bld.env['WITH_TESTS']: |
Alexander Afanasyev | d409d59 | 2014-01-28 18:36:38 -0800 | [diff] [blame] | 193 | bld.recurse('tests') |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 194 | bld.recurse('tests-integrated') |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 195 | |
Yingdi Yu | e6bfab2 | 2014-02-06 16:01:19 -0800 | [diff] [blame] | 196 | if bld.env['WITH_TOOLS']: |
Alexander Afanasyev | c8bcd45 | 2014-05-12 17:58:47 -0700 | [diff] [blame] | 197 | bld.recurse("tools") |
| 198 | |
| 199 | if bld.env['WITH_EXAMPLES']: |
Yingdi Yu | e6bfab2 | 2014-02-06 16:01:19 -0800 | [diff] [blame] | 200 | bld.recurse("examples") |
Alexander Afanasyev | f5df8e6 | 2014-02-16 19:56:21 -0800 | [diff] [blame] | 201 | |
Alexander Afanasyev | 1950885 | 2014-01-29 01:01:51 -0800 | [diff] [blame] | 202 | headers = bld.path.ant_glob(['src/**/*.hpp']) |
Alexander Afanasyev | 766cea7 | 2014-04-24 19:16:42 -0700 | [diff] [blame] | 203 | bld.install_files("%s/ndn-cxx" % bld.env['INCLUDEDIR'], headers, |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 204 | relative_trick=True, cwd=bld.path.find_node('src')) |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 205 | |
Alexander Afanasyev | 766cea7 | 2014-04-24 19:16:42 -0700 | [diff] [blame] | 206 | bld.install_files("%s/ndn-cxx" % bld.env['INCLUDEDIR'], |
| 207 | bld.path.find_resource('src/ndn-cxx-config.hpp')) |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 208 | |
Alexander Afanasyev | cfe0b06 | 2014-05-08 18:26:50 -0700 | [diff] [blame] | 209 | bld.install_files("%s/ndn-cxx" % bld.env['INCLUDEDIR'], |
| 210 | bld.path.find_resource('src/version.hpp')) |
| 211 | |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 212 | bld.install_files("${SYSCONFDIR}/ndn", "client.conf.sample") |
| 213 | |
Alexander Afanasyev | 7c6aeb0 | 2014-04-10 19:59:19 -0700 | [diff] [blame] | 214 | if bld.env['SPHINX_BUILD']: |
| 215 | bld(features="sphinx", |
| 216 | builder="man", |
| 217 | outdir="docs/manpages", |
| 218 | config="docs/conf.py", |
| 219 | source=bld.path.ant_glob('docs/manpages/**/*.rst'), |
Alexander Afanasyev | a06fdda | 2014-04-29 19:15:00 -0700 | [diff] [blame] | 220 | install_path="${MANDIR}/", |
| 221 | VERSION=VERSION) |
Alexander Afanasyev | 7c6aeb0 | 2014-04-10 19:59:19 -0700 | [diff] [blame] | 222 | |
| 223 | def docs(bld): |
| 224 | from waflib import Options |
| 225 | Options.commands = ['doxygen', 'sphinx'] + Options.commands |
| 226 | |
Alexander Afanasyev | 401a236 | 2014-03-02 00:03:11 +0000 | [diff] [blame] | 227 | def doxygen(bld): |
Alexander Afanasyev | cfe0b06 | 2014-05-08 18:26:50 -0700 | [diff] [blame] | 228 | version(bld) |
| 229 | |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 230 | if not bld.env.DOXYGEN: |
Alexander Afanasyev | 7c6aeb0 | 2014-04-10 19:59:19 -0700 | [diff] [blame] | 231 | Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)") |
| 232 | else: |
Alexander Afanasyev | a06fdda | 2014-04-29 19:15:00 -0700 | [diff] [blame] | 233 | bld(features="subst", |
| 234 | name="doxygen-conf", |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 235 | source=["docs/doxygen.conf.in", |
| 236 | "docs/named_data_theme/named_data_footer-with-analytics.html.in"], |
| 237 | target=["docs/doxygen.conf", |
| 238 | "docs/named_data_theme/named_data_footer-with-analytics.html"], |
Alexander Afanasyev | a06fdda | 2014-04-29 19:15:00 -0700 | [diff] [blame] | 239 | VERSION=VERSION, |
Alexander Afanasyev | 9b0e114 | 2014-05-08 00:17:34 -0700 | [diff] [blame] | 240 | HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \ |
| 241 | if os.getenv('GOOGLE_ANALYTICS', None) \ |
| 242 | else "../docs/named_data_theme/named_data_footer.html", |
| 243 | GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""), |
Alexander Afanasyev | a06fdda | 2014-04-29 19:15:00 -0700 | [diff] [blame] | 244 | ) |
| 245 | |
Alexander Afanasyev | 7c6aeb0 | 2014-04-10 19:59:19 -0700 | [diff] [blame] | 246 | bld(features="doxygen", |
Alexander Afanasyev | a06fdda | 2014-04-29 19:15:00 -0700 | [diff] [blame] | 247 | doxyfile='docs/doxygen.conf', |
| 248 | use="doxygen-conf") |
Alexander Afanasyev | a1ae0a1 | 2014-01-28 15:21:02 -0800 | [diff] [blame] | 249 | |
Alexander Afanasyev | 5e1288e | 2014-03-28 11:11:48 -0700 | [diff] [blame] | 250 | def sphinx(bld): |
Alexander Afanasyev | cfe0b06 | 2014-05-08 18:26:50 -0700 | [diff] [blame] | 251 | version(bld) |
| 252 | |
Alexander Afanasyev | 1160baa | 2014-04-10 18:50:29 -0700 | [diff] [blame] | 253 | if not bld.env.SPHINX_BUILD: |
| 254 | bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)") |
Alexander Afanasyev | 7c6aeb0 | 2014-04-10 19:59:19 -0700 | [diff] [blame] | 255 | else: |
| 256 | bld(features="sphinx", |
| 257 | outdir="docs", |
| 258 | source=bld.path.ant_glob("docs/**/*.rst"), |
Alexander Afanasyev | a06fdda | 2014-04-29 19:15:00 -0700 | [diff] [blame] | 259 | config="docs/conf.py", |
| 260 | VERSION=VERSION) |
Alexander Afanasyev | cfe0b06 | 2014-05-08 18:26:50 -0700 | [diff] [blame] | 261 | |
| 262 | |
| 263 | def version(ctx): |
| 264 | if getattr(Context.g_module, 'VERSION_BASE', None): |
| 265 | return |
| 266 | |
| 267 | Context.g_module.VERSION_BASE = Context.g_module.VERSION |
| 268 | Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')] |
| 269 | |
| 270 | try: |
| 271 | cmd = ['git', 'describe', '--match', 'ndn-cxx-*'] |
| 272 | p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE, |
| 273 | stderr=None, stdin=None) |
| 274 | out = p.communicate()[0].strip() |
| 275 | if p.returncode == 0 and out != "": |
| 276 | Context.g_module.VERSION = out[8:] |
| 277 | except: |
| 278 | pass |
| 279 | |
| 280 | def dist(ctx): |
| 281 | version(ctx) |
| 282 | |
| 283 | def distcheck(ctx): |
| 284 | version(ctx) |