blob: 348c2d434953fa89650cac8b22b849ae812dc0b2 [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 Afanasyev97e4cac2014-03-28 10:55:11 -07002#
3# Copyright (c) 2014, Regents of the University of California
4#
5# GPL 3.0 license, see the COPYING.md file for more information
6#
Alexander Afanasyev2aa39622014-01-22 11:51:11 -08007
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -07008VERSION = '0.1.0'
9APPNAME = "nfd"
10BUGREPORT = "http://redmine.named-data.net/projects/nfd"
11URL = "https://github.com/named-data/NFD"
12
13from waflib import Logs
hilata198cadb2014-02-15 23:46:19 -060014import os
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080015
16def options(opt):
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070017 opt.load('compiler_cxx gnu_dirs')
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070018 opt.load('boost doxygen coverage unix-socket default-compiler-flags',
19 tooldir=['.waf-tools'])
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080020
21 nfdopt = opt.add_option_group('NFD Options')
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070022 nfdopt.add_option('--with-tests', action='store_true', default=False,
23 dest='with_tests', help='''Build unit tests''')
Steve DiBenedetto84da5bf2014-03-11 14:51:29 -060024
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080025def configure(conf):
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070026 conf.load("compiler_cxx boost gnu_dirs")
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080027
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070028 try: conf.load("doxygen")
29 except: pass
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080030
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070031 conf.load('default-compiler-flags')
Alexander Afanasyevefea8fe2014-03-23 00:00:35 -070032
33 conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'],
34 uselib_store='NDN_CPP', mandatory=True)
Davide Pesavento44deacc2014-02-19 10:48:07 +010035
Alexander Afanasyev82afa1a2014-03-20 16:56:56 -070036 boost_libs = 'system chrono program_options'
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080037 if conf.options.with_tests:
38 conf.env['WITH_TESTS'] = 1
Junxiao Shi88884492014-02-15 15:57:43 -070039 conf.define('WITH_TESTS', 1);
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070040 boost_libs += ' unit_test_framework'
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080041
42 conf.check_boost(lib=boost_libs)
Steve DiBenedetto84da5bf2014-03-11 14:51:29 -060043
Alexander Afanasyeve1724c42014-02-26 22:00:54 -080044 if conf.env.BOOST_VERSION_NUMBER < 104800:
Junxiao Shiea48d8b2014-03-16 13:53:47 -070045 Logs.error("Minimum required boost version is 1.48.0")
46 Logs.error("Please upgrade your distribution or install custom boost libraries" +
47 " (http://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080048 return
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080049
50 conf.load('unix-socket')
Davide Pesavento44deacc2014-02-19 10:48:07 +010051
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070052 conf.check_cxx(lib='rt', uselib_store='RT',
53 define_name='HAVE_RT', mandatory=False)
54
55 if conf.check_cxx(lib='pcap', uselib_store='PCAP',
56 define_name='HAVE_PCAP', mandatory=False):
Davide Pesavento44deacc2014-02-19 10:48:07 +010057 conf.env['HAVE_PCAP'] = True
Alexander Afanasyevefea8fe2014-03-23 00:00:35 -070058
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070059 conf.check_cxx(lib='resolv', uselib_store='RESOLV', mandatory=False)
Alexander Afanasyevefea8fe2014-03-23 00:00:35 -070060
Alexander Afanasyev689569b2014-02-16 20:20:07 -080061 conf.load('coverage')
62
Steve DiBenedettofbb40a82014-03-11 19:40:15 -060063 conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nfd.conf' % conf.env['SYSCONFDIR'])
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070064
Junxiao Shi61c5ef32014-01-24 20:59:30 -070065 conf.write_config_header('daemon/config.hpp')
Alexander Afanasyev2aa39622014-01-22 11:51:11 -080066
Junxiao Shi09bf7c42014-01-31 11:10:25 -070067def build(bld):
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080068 nfd_objects = bld(
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070069 target='nfd-objects',
70 features='cxx',
71 source=bld.path.ant_glob(['daemon/**/*.cpp'],
72 excl=['daemon/face/ethernet-*.cpp',
73 'daemon/face/unix-*.cpp',
74 'daemon/main.cpp']),
75 use='BOOST NDN_CPP RT',
76 includes='. daemon',
Junxiao Shi0fcb41e2014-01-24 10:29:43 -070077 )
78
Davide Pesavento44deacc2014-02-19 10:48:07 +010079 if bld.env['HAVE_PCAP']:
80 nfd_objects.source += bld.path.ant_glob('daemon/face/ethernet-*.cpp')
81 nfd_objects.use += ' PCAP'
82
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080083 if bld.env['HAVE_UNIX_SOCKETS']:
Davide Pesavento44deacc2014-02-19 10:48:07 +010084 nfd_objects.source += bld.path.ant_glob('daemon/face/unix-*.cpp')
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080085
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070086 bld(target='nfd',
87 features='cxx cxxprogram',
88 source='daemon/main.cpp',
89 use='nfd-objects',
90 includes='. daemon',
hilata198cadb2014-02-15 23:46:19 -060091 )
Steve DiBenedetto84da5bf2014-03-11 14:51:29 -060092
hilata198cadb2014-02-15 23:46:19 -060093 for app in bld.path.ant_glob('tools/*.cpp'):
94 bld(features=['cxx', 'cxxprogram'],
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070095 target='bin/%s' % (str(app.change_ext(''))),
96 source=['tools/%s' % (str(app))],
97 includes='. daemon',
98 use='nfd-objects RESOLV',
hilata198cadb2014-02-15 23:46:19 -060099 )
Davide Pesavento44deacc2014-02-19 10:48:07 +0100100
Alexander Afanasyev2aa39622014-01-22 11:51:11 -0800101 # Unit tests
102 if bld.env['WITH_TESTS']:
Junxiao Shiea48d8b2014-03-16 13:53:47 -0700103 unit_tests = bld.program(
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -0700104 target='unit-tests',
105 features='cxx cxxprogram',
106 source=bld.path.ant_glob(['tests/**/*.cpp'],
107 excl=['tests/face/ethernet.cpp',
108 'tests/face/unix-*.cpp']),
109 use='nfd-objects',
110 includes='. daemon',
111 install_prefix=None,
Alexander Afanasyev2aa39622014-01-22 11:51:11 -0800112 )
113
Davide Pesavento44deacc2014-02-19 10:48:07 +0100114 if bld.env['HAVE_PCAP']:
115 unit_tests.source += bld.path.ant_glob('tests/face/ethernet.cpp')
116
Alexander Afanasyevc78b1412014-02-19 14:08:26 -0800117 if bld.env['HAVE_UNIX_SOCKETS']:
Davide Pesavento44deacc2014-02-19 10:48:07 +0100118 unit_tests.source += bld.path.ant_glob('tests/face/unix-*.cpp')
Alexander Afanasyevc78b1412014-02-19 14:08:26 -0800119
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -0700120 bld(features="subst",
121 source='nfd.conf.sample.in',
122 target='nfd.conf.sample',
123 install_path="${SYSCONFDIR}/ndn")
Alexander Afanasyev35fc2b72014-02-13 16:56:21 -0800124
125def doxygen(bld):
126 if not bld.env.DOXYGEN:
127 bld.fatal("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
128 bld(features="doxygen",
129 doxyfile='docs/doxygen.conf')