blob: 13c1432fb15f53cae9a8a8bd72e25bd1ae40e14c [file] [log] [blame]
Yingdi Yuc9843cf2014-08-04 17:52:19 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
3"""
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -07004Copyright (c) 2014-2017, Regents of the University of California
Yingdi Yuc9843cf2014-08-04 17:52:19 -07005
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -07006This file is part of NDN DeLorean, An Authentication System for Data Archives in
7Named Data Networking. See AUTHORS.md for complete list of NDN DeLorean authors
8and contributors.
Yingdi Yuc9843cf2014-08-04 17:52:19 -07009
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070010NDN DeLorean is free software: you can redistribute it and/or modify it under
11the terms of the GNU General Public License as published by the Free Software
12Foundation, either version 3 of the License, or (at your option) any later
13version.
Yingdi Yuc9843cf2014-08-04 17:52:19 -070014
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070015NDN DeLorean is distributed in the hope that it will be useful, but WITHOUT ANY
16WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
17PARTICULAR PURPOSE. See the GNU General Public License for more details.
Yingdi Yuc9843cf2014-08-04 17:52:19 -070018
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070019You should have received a copy of the GNU General Public License along with NDN
20DeLorean, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Yingdi Yuc9843cf2014-08-04 17:52:19 -070021"""
22
23from waflib import Logs, Utils, Context
24import os
25
26VERSION = "0.1.0"
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070027APPNAME = "ndn-delorean"
Yingdi Yuc9843cf2014-08-04 17:52:19 -070028
29def options(opt):
30 opt.load(['compiler_cxx', 'gnu_dirs', 'c_osx'])
31 opt.load(['default-compiler-flags', 'boost', 'cryptopp',
32 'sqlite3', 'doxygen', 'sphinx_build'],
33 tooldir=['.waf-tools'])
34
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070035 opt = opt.add_option_group('NDN DeLorean Options')
Yingdi Yuc9843cf2014-08-04 17:52:19 -070036
37 opt.add_option('--with-tests', action='store_true', default=False, dest='with_tests',
38 help='''build unit tests''')
39
40 opt.add_option('--without-tools', action='store_false', default=True, dest='with_tools',
41 help='''Do not build tools''')
42
43 opt.add_option('--without-sqlite-locking', action='store_false', default=True,
44 dest='with_sqlite_locking',
45 help='''Disable filesystem locking in sqlite3 database '''
46 '''(use unix-dot locking mechanism instead). '''
47 '''This option may be necessary if home directory is hosted on NFS.''')
48
49def configure(conf):
50 conf.load(['compiler_cxx', 'gnu_dirs', 'c_osx',
51 'default-compiler-flags', 'boost', 'cryptopp',
52 'sqlite3', 'doxygen', 'sphinx_build'])
53
54 conf.env['WITH_TESTS'] = conf.options.with_tests
55 conf.env['WITH_TOOLS'] = conf.options.with_tools
56
57 conf.find_program('sh', var='SH', mandatory=True)
58
59 conf.check_cxx(lib='pthread', uselib_store='PTHREAD', define_name='HAVE_PTHREAD',
60 mandatory=False)
61 conf.check_sqlite3(mandatory=True)
62 conf.check_cryptopp(mandatory=True, use='PTHREAD')
63
64 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
65 uselib_store='NDN_CXX', mandatory=True)
66
67 USED_BOOST_LIBS = ['system', 'filesystem', 'date_time', 'iostreams',
68 'program_options', 'chrono']
69 if conf.env['WITH_TESTS']:
70 USED_BOOST_LIBS += ['unit_test_framework']
71 conf.define('HAVE_TESTS', 1)
72
73 conf.check_boost(lib=USED_BOOST_LIBS, mandatory=True)
74 if conf.env.BOOST_VERSION_NUMBER < 104800:
75 Logs.error("Minimum required boost version is 1.48.0")
76 Logs.error("Please upgrade your distribution or install custom boost libraries" +
77 " (http://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
78 return
79
80 if not conf.options.with_sqlite_locking:
81 conf.define('DISABLE_SQLITE3_FS_LOCKING', 1)
82
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070083 conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/ndn-delorean.conf' % conf.env['SYSCONFDIR'])
Yingdi Yuc9843cf2014-08-04 17:52:19 -070084
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -070085 conf.write_config_header('config.hpp', define_prefix='NDN_DELOREAN_')
Yingdi Yuc9843cf2014-08-04 17:52:19 -070086
87def build(bld):
88 version(bld)
89
90 bld(features="subst",
91 name='version',
92 source='version.hpp.in',
93 target='version.hpp',
94 install_path=None,
95 VERSION_STRING=VERSION_BASE,
96 VERSION_BUILD=VERSION,
97 VERSION=int(VERSION_SPLIT[0]) * 1000000 +
98 int(VERSION_SPLIT[1]) * 1000 +
99 int(VERSION_SPLIT[2]),
100 VERSION_MAJOR=VERSION_SPLIT[0],
101 VERSION_MINOR=VERSION_SPLIT[1],
102 VERSION_PATCH=VERSION_SPLIT[2],
103 )
104
105 core = bld(
106 target='core-objects',
107 name='core-objects',
108 features='cxx',
109 source=bld.path.ant_glob(['core/**/*.cpp']),
110 use='version BOOST NDN_CXX CRYPTOPP SQLITE3',
111 includes='. core',
112 export_includes='. core',
113 headers='common.hpp',
114 )
115
116 logger_objects = bld(
117 target='daemon-objects',
118 name='daemon-objects',
119 features='cxx',
120 source=bld.path.ant_glob(['daemon/**/*.cpp'],
121 excl=['daemon/main.cpp']),
122 use='core-objects',
123 includes='daemon',
124 export_includes='daemon',
125 )
126
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -0700127 bld(target='bin/ndn-delorean',
Yingdi Yuc9843cf2014-08-04 17:52:19 -0700128 features='cxx cxxprogram',
129 source='daemon/main.cpp',
130 use='daemon-objects',
131 )
132
133 if bld.env['WITH_TESTS']:
134 bld.recurse('tests')
135
136 if bld.env['WITH_TOOLS']:
137 bld.recurse("tools")
138
139 bld(features="subst",
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -0700140 source='ndn-delorean.conf.sample.in',
141 target='ndn-delorean.conf.sample',
Yingdi Yuc9843cf2014-08-04 17:52:19 -0700142 install_path="${SYSCONFDIR}/ndn",
143 )
144
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -0700145 # if bld.env['SPHINX_BUILD']:
146 # bld(features="sphinx",
147 # builder="man",
148 # outdir="docs/manpages",
149 # config="docs/conf.py",
150 # source=bld.path.ant_glob('docs/manpages/**/*.rst'),
151 # install_path="${MANDIR}/",
152 # VERSION=VERSION)
Yingdi Yuc9843cf2014-08-04 17:52:19 -0700153
154def docs(bld):
155 from waflib import Options
156 Options.commands = ['doxygen', 'sphinx'] + Options.commands
157
158def doxygen(bld):
159 version(bld)
160
161 if not bld.env.DOXYGEN:
162 Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
163 else:
164 bld(features="subst",
165 name="doxygen-conf",
166 source=["docs/doxygen.conf.in",
167 "docs/named_data_theme/named_data_footer-with-analytics.html.in"],
168 target=["docs/doxygen.conf",
169 "docs/named_data_theme/named_data_footer-with-analytics.html"],
170 VERSION=VERSION,
171 HTML_FOOTER="../build/docs/named_data_theme/named_data_footer-with-analytics.html" \
172 if os.getenv('GOOGLE_ANALYTICS', None) \
173 else "../docs/named_data_theme/named_data_footer.html",
174 GOOGLE_ANALYTICS=os.getenv('GOOGLE_ANALYTICS', ""),
175 )
176
177 bld(features="doxygen",
178 doxyfile='docs/doxygen.conf',
179 use="doxygen-conf")
180
181def sphinx(bld):
182 version(bld)
183
184 if not bld.env.SPHINX_BUILD:
185 bld.fatal("ERROR: cannot build documentation (`sphinx-build' is not found in $PATH)")
186 else:
187 bld(features="sphinx",
188 outdir="docs",
189 source=bld.path.ant_glob("docs/**/*.rst"),
190 config="docs/conf.py",
191 VERSION=VERSION)
192
193
194def version(ctx):
195 if getattr(Context.g_module, 'VERSION_BASE', None):
196 return
197
198 Context.g_module.VERSION_BASE = Context.g_module.VERSION
199 Context.g_module.VERSION_SPLIT = [v for v in VERSION_BASE.split('.')]
200
201 try:
Alexander Afanasyevbe998ac2017-05-06 13:11:42 -0700202 cmd = ['git', 'describe', '--match', 'ndn-delorean-*']
Yingdi Yuc9843cf2014-08-04 17:52:19 -0700203 p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE,
204 stderr=None, stdin=None)
205 out = p.communicate()[0].strip()
206 if p.returncode == 0 and out != "":
207 Context.g_module.VERSION = out[8:]
208 except:
209 pass