Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 2 | # |
| 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 Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 7 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 8 | VERSION = '0.1.0' |
| 9 | APPNAME = "nfd" |
| 10 | BUGREPORT = "http://redmine.named-data.net/projects/nfd" |
| 11 | URL = "https://github.com/named-data/NFD" |
| 12 | |
| 13 | from waflib import Logs |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 14 | import os |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 15 | |
| 16 | def options(opt): |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 17 | opt.load('compiler_cxx gnu_dirs') |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 18 | opt.load('boost doxygen coverage unix-socket default-compiler-flags', |
| 19 | tooldir=['.waf-tools']) |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 20 | |
| 21 | nfdopt = opt.add_option_group('NFD Options') |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 22 | nfdopt.add_option('--with-tests', action='store_true', default=False, |
| 23 | dest='with_tests', help='''Build unit tests''') |
Steve DiBenedetto | 84da5bf | 2014-03-11 14:51:29 -0600 | [diff] [blame] | 24 | |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 25 | def configure(conf): |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 26 | conf.load("compiler_cxx boost gnu_dirs") |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 27 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 28 | try: conf.load("doxygen") |
| 29 | except: pass |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 30 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 31 | conf.load('default-compiler-flags') |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 32 | |
| 33 | conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'], |
| 34 | uselib_store='NDN_CPP', mandatory=True) |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 35 | |
Alexander Afanasyev | 82afa1a | 2014-03-20 16:56:56 -0700 | [diff] [blame] | 36 | boost_libs = 'system chrono program_options' |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 37 | if conf.options.with_tests: |
| 38 | conf.env['WITH_TESTS'] = 1 |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 39 | conf.define('WITH_TESTS', 1); |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 40 | boost_libs += ' unit_test_framework' |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 41 | |
| 42 | conf.check_boost(lib=boost_libs) |
Steve DiBenedetto | 84da5bf | 2014-03-11 14:51:29 -0600 | [diff] [blame] | 43 | |
Alexander Afanasyev | e1724c4 | 2014-02-26 22:00:54 -0800 | [diff] [blame] | 44 | if conf.env.BOOST_VERSION_NUMBER < 104800: |
Junxiao Shi | ea48d8b | 2014-03-16 13:53:47 -0700 | [diff] [blame] | 45 | 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 Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 48 | return |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 49 | |
| 50 | conf.load('unix-socket') |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 51 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 52 | 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 Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 57 | conf.env['HAVE_PCAP'] = True |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 58 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 59 | conf.check_cxx(lib='resolv', uselib_store='RESOLV', mandatory=False) |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 60 | |
Alexander Afanasyev | 689569b | 2014-02-16 20:20:07 -0800 | [diff] [blame] | 61 | conf.load('coverage') |
| 62 | |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 63 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nfd.conf' % conf.env['SYSCONFDIR']) |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 64 | |
Junxiao Shi | 61c5ef3 | 2014-01-24 20:59:30 -0700 | [diff] [blame] | 65 | conf.write_config_header('daemon/config.hpp') |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 66 | |
Junxiao Shi | 09bf7c4 | 2014-01-31 11:10:25 -0700 | [diff] [blame] | 67 | def build(bld): |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 68 | nfd_objects = bld( |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 69 | 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 Shi | 0fcb41e | 2014-01-24 10:29:43 -0700 | [diff] [blame] | 77 | ) |
| 78 | |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 79 | if bld.env['HAVE_PCAP']: |
| 80 | nfd_objects.source += bld.path.ant_glob('daemon/face/ethernet-*.cpp') |
| 81 | nfd_objects.use += ' PCAP' |
| 82 | |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 83 | if bld.env['HAVE_UNIX_SOCKETS']: |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 84 | nfd_objects.source += bld.path.ant_glob('daemon/face/unix-*.cpp') |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 85 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 86 | bld(target='nfd', |
| 87 | features='cxx cxxprogram', |
| 88 | source='daemon/main.cpp', |
| 89 | use='nfd-objects', |
| 90 | includes='. daemon', |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 91 | ) |
Steve DiBenedetto | 84da5bf | 2014-03-11 14:51:29 -0600 | [diff] [blame] | 92 | |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 93 | for app in bld.path.ant_glob('tools/*.cpp'): |
| 94 | bld(features=['cxx', 'cxxprogram'], |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 95 | target='bin/%s' % (str(app.change_ext(''))), |
| 96 | source=['tools/%s' % (str(app))], |
| 97 | includes='. daemon', |
| 98 | use='nfd-objects RESOLV', |
hilata | 198cadb | 2014-02-15 23:46:19 -0600 | [diff] [blame] | 99 | ) |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 100 | |
Alexander Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 101 | # Unit tests |
| 102 | if bld.env['WITH_TESTS']: |
Junxiao Shi | ea48d8b | 2014-03-16 13:53:47 -0700 | [diff] [blame] | 103 | unit_tests = bld.program( |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 104 | 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 Afanasyev | 2aa3962 | 2014-01-22 11:51:11 -0800 | [diff] [blame] | 112 | ) |
| 113 | |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 114 | if bld.env['HAVE_PCAP']: |
| 115 | unit_tests.source += bld.path.ant_glob('tests/face/ethernet.cpp') |
| 116 | |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 117 | if bld.env['HAVE_UNIX_SOCKETS']: |
Davide Pesavento | 44deacc | 2014-02-19 10:48:07 +0100 | [diff] [blame] | 118 | unit_tests.source += bld.path.ant_glob('tests/face/unix-*.cpp') |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 119 | |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 120 | bld(features="subst", |
| 121 | source='nfd.conf.sample.in', |
| 122 | target='nfd.conf.sample', |
| 123 | install_path="${SYSCONFDIR}/ndn") |
Alexander Afanasyev | 35fc2b7 | 2014-02-13 16:56:21 -0800 | [diff] [blame] | 124 | |
| 125 | def 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') |