blob: d57a36d60c25a9229fe9cb02f5b87f314f9e3bc4 [file] [log] [blame]
Alexander Afanasyev2aa39622014-01-22 11:51:11 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -07002
3"""
4Copyright (c) 2014 Regents of the University of California,
5 Arizona Board of Regents,
6 Colorado State University,
7 University Pierre & Marie Curie, Sorbonne University,
8 Washington University in St. Louis,
9 Beijing Institute of Technology
10
11This file is part of NFD (Named Data Networking Forwarding Daemon).
12See AUTHORS.md for complete list of NFD authors and contributors.
13
14NFD is free software: you can redistribute it and/or modify it under the terms
15of the GNU General Public License as published by the Free Software Foundation,
16either version 3 of the License, or (at your option) any later version.
17
18NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20PURPOSE. See the GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License along with
23NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24"""
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080025
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070026VERSION = '0.1.0'
27APPNAME = "nfd"
28BUGREPORT = "http://redmine.named-data.net/projects/nfd"
29URL = "https://github.com/named-data/NFD"
30
31from waflib import Logs
hilata198cadb2014-02-15 23:46:19 -060032import os
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080033
34def options(opt):
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070035 opt.load('compiler_cxx gnu_dirs')
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070036 opt.load('boost doxygen coverage unix-socket default-compiler-flags',
37 tooldir=['.waf-tools'])
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080038
39 nfdopt = opt.add_option_group('NFD Options')
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070040 nfdopt.add_option('--with-tests', action='store_true', default=False,
41 dest='with_tests', help='''Build unit tests''')
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -040042 nfdopt.add_option('--with-other-tests', action='store_true', default=False,
43 dest='with_other_tests', help='''Build other tests''')
Steve DiBenedetto84da5bf2014-03-11 14:51:29 -060044
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080045def configure(conf):
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070046 conf.load("compiler_cxx boost gnu_dirs")
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080047
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070048 try: conf.load("doxygen")
49 except: pass
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080050
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070051 conf.load('default-compiler-flags')
Alexander Afanasyevefea8fe2014-03-23 00:00:35 -070052
53 conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'],
54 uselib_store='NDN_CPP', mandatory=True)
Davide Pesavento44deacc2014-02-19 10:48:07 +010055
Alexander Afanasyev82afa1a2014-03-20 16:56:56 -070056 boost_libs = 'system chrono program_options'
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080057 if conf.options.with_tests:
58 conf.env['WITH_TESTS'] = 1
Junxiao Shi88884492014-02-15 15:57:43 -070059 conf.define('WITH_TESTS', 1);
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070060 boost_libs += ' unit_test_framework'
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080061
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -040062 if conf.options.with_other_tests:
63 conf.env['WITH_OTHER_TESTS'] = 1
64
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080065 conf.check_boost(lib=boost_libs)
Steve DiBenedetto84da5bf2014-03-11 14:51:29 -060066
Alexander Afanasyeve1724c42014-02-26 22:00:54 -080067 if conf.env.BOOST_VERSION_NUMBER < 104800:
Junxiao Shiea48d8b2014-03-16 13:53:47 -070068 Logs.error("Minimum required boost version is 1.48.0")
69 Logs.error("Please upgrade your distribution or install custom boost libraries" +
70 " (http://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080071 return
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080072
73 conf.load('unix-socket')
Davide Pesavento44deacc2014-02-19 10:48:07 +010074
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070075 conf.check_cxx(lib='rt', uselib_store='RT',
76 define_name='HAVE_RT', mandatory=False)
77
78 if conf.check_cxx(lib='pcap', uselib_store='PCAP',
79 define_name='HAVE_PCAP', mandatory=False):
Davide Pesavento44deacc2014-02-19 10:48:07 +010080 conf.env['HAVE_PCAP'] = True
Alexander Afanasyevefea8fe2014-03-23 00:00:35 -070081
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070082 conf.check_cxx(lib='resolv', uselib_store='RESOLV', mandatory=False)
Alexander Afanasyevefea8fe2014-03-23 00:00:35 -070083
Alexander Afanasyev689569b2014-02-16 20:20:07 -080084 conf.load('coverage')
85
Steve DiBenedettofbb40a82014-03-11 19:40:15 -060086 conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nfd.conf' % conf.env['SYSCONFDIR'])
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070087
Junxiao Shi61c5ef32014-01-24 20:59:30 -070088 conf.write_config_header('daemon/config.hpp')
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080089
Junxiao Shi09bf7c42014-01-31 11:10:25 -070090def build(bld):
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080091 nfd_objects = bld(
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070092 target='nfd-objects',
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -040093 name='nfd-objects',
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070094 features='cxx',
95 source=bld.path.ant_glob(['daemon/**/*.cpp'],
96 excl=['daemon/face/ethernet-*.cpp',
97 'daemon/face/unix-*.cpp',
98 'daemon/main.cpp']),
99 use='BOOST NDN_CPP RT',
100 includes='. daemon',
Junxiao Shi0fcb41e2014-01-24 10:29:43 -0700101 )
102
Davide Pesavento44deacc2014-02-19 10:48:07 +0100103 if bld.env['HAVE_PCAP']:
104 nfd_objects.source += bld.path.ant_glob('daemon/face/ethernet-*.cpp')
105 nfd_objects.use += ' PCAP'
106
Alexander Afanasyevc78b1412014-02-19 14:08:26 -0800107 if bld.env['HAVE_UNIX_SOCKETS']:
Davide Pesavento44deacc2014-02-19 10:48:07 +0100108 nfd_objects.source += bld.path.ant_glob('daemon/face/unix-*.cpp')
Alexander Afanasyevc78b1412014-02-19 14:08:26 -0800109
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -0700110 bld(target='nfd',
111 features='cxx cxxprogram',
112 source='daemon/main.cpp',
113 use='nfd-objects',
114 includes='. daemon',
hilata198cadb2014-02-15 23:46:19 -0600115 )
Steve DiBenedetto84da5bf2014-03-11 14:51:29 -0600116
hilata198cadb2014-02-15 23:46:19 -0600117 for app in bld.path.ant_glob('tools/*.cpp'):
118 bld(features=['cxx', 'cxxprogram'],
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -0700119 target='bin/%s' % (str(app.change_ext(''))),
120 source=['tools/%s' % (str(app))],
121 includes='. daemon',
122 use='nfd-objects RESOLV',
hilata198cadb2014-02-15 23:46:19 -0600123 )
Davide Pesavento44deacc2014-02-19 10:48:07 +0100124
Alexander Afanasyev2aa39622014-01-22 11:51:11 -0800125 # Unit tests
126 if bld.env['WITH_TESTS']:
Junxiao Shiea48d8b2014-03-16 13:53:47 -0700127 unit_tests = bld.program(
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -0700128 target='unit-tests',
129 features='cxx cxxprogram',
130 source=bld.path.ant_glob(['tests/**/*.cpp'],
131 excl=['tests/face/ethernet.cpp',
132 'tests/face/unix-*.cpp']),
133 use='nfd-objects',
134 includes='. daemon',
135 install_prefix=None,
Alexander Afanasyev2aa39622014-01-22 11:51:11 -0800136 )
137
Davide Pesavento44deacc2014-02-19 10:48:07 +0100138 if bld.env['HAVE_PCAP']:
139 unit_tests.source += bld.path.ant_glob('tests/face/ethernet.cpp')
140
Alexander Afanasyevc78b1412014-02-19 14:08:26 -0800141 if bld.env['HAVE_UNIX_SOCKETS']:
Davide Pesavento44deacc2014-02-19 10:48:07 +0100142 unit_tests.source += bld.path.ant_glob('tests/face/unix-*.cpp')
Alexander Afanasyevc78b1412014-02-19 14:08:26 -0800143
Ilya Moiseenko96b80bb2014-04-05 20:53:27 -0400144 if bld.env['WITH_OTHER_TESTS']:
145 bld.recurse("tests-other")
146
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -0700147 bld(features="subst",
148 source='nfd.conf.sample.in',
149 target='nfd.conf.sample',
150 install_path="${SYSCONFDIR}/ndn")
Alexander Afanasyev35fc2b72014-02-13 16:56:21 -0800151
Chengyu Fanb07788a2014-03-31 12:15:36 -0600152 bld(features='subst',
153 source='tools/nfd-status-http-server.py',
154 target='nfd-status-http-server',
155 install_path="${BINDIR}",
156 chmod=0755)
157
Alexander Afanasyev35fc2b72014-02-13 16:56:21 -0800158def doxygen(bld):
159 if not bld.env.DOXYGEN:
160 bld.fatal("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
161 bld(features="doxygen",
162 doxyfile='docs/doxygen.conf')