Obaid | 2ea377f | 2014-02-27 19:45:15 -0600 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 3 | from waflib import Logs |
Obaid | 2ea377f | 2014-02-27 19:45:15 -0600 | [diff] [blame] | 4 | |
| 5 | def options(opt): |
| 6 | opt.load('compiler_cxx gnu_dirs') |
| 7 | opt.load('flags boost doxygen coverage', tooldir=['.waf-tools']) |
Obaid | 793401d | 2014-02-27 19:13:49 -0600 | [diff] [blame] | 8 | |
Obaid | 2ea377f | 2014-02-27 19:45:15 -0600 | [diff] [blame] | 9 | nrdopt = opt.add_option_group('NRD Options') |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 10 | nrdopt.add_option('--debug', action='store_true', default=False, |
| 11 | dest='debug', |
| 12 | help='''Compile library debugging mode without all optimizations (-O0)''') |
| 13 | nrdopt.add_option('--with-tests', action='store_true', |
| 14 | default=False, dest='with_tests', help='''Build unit tests''') |
Obaid | 2ea377f | 2014-02-27 19:45:15 -0600 | [diff] [blame] | 15 | |
| 16 | def configure(conf): |
| 17 | conf.load("compiler_cxx gnu_dirs boost flags") |
| 18 | |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 19 | conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'], |
| 20 | uselib_store='NDN_CPP', mandatory=True) |
Obaid | 2ea377f | 2014-02-27 19:45:15 -0600 | [diff] [blame] | 21 | |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 22 | boost_libs = 'system' |
Obaid | 2ea377f | 2014-02-27 19:45:15 -0600 | [diff] [blame] | 23 | if conf.options.with_tests: |
| 24 | conf.env['WITH_TESTS'] = 1 |
| 25 | conf.define('WITH_TESTS', 1); |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 26 | boost_libs += ' unit_test_framework' |
Obaid | 2ea377f | 2014-02-27 19:45:15 -0600 | [diff] [blame] | 27 | |
| 28 | conf.check_boost(lib=boost_libs) |
| 29 | if conf.env.BOOST_VERSION_NUMBER < 104800: |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 30 | Logs.error("Minimum required boost version is 1.48") |
| 31 | Logs.error("Please upgrade your distribution or install custom boost libraries" + |
| 32 | " (http://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)") |
Obaid | 2ea377f | 2014-02-27 19:45:15 -0600 | [diff] [blame] | 33 | return |
| 34 | |
| 35 | # conf.load('coverage') |
| 36 | |
| 37 | # try: |
| 38 | # conf.load('doxygen') |
| 39 | # except: |
| 40 | # pass |
| 41 | |
Obaid | 5748c0c | 2014-04-09 18:00:42 -0500 | [diff] [blame^] | 42 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nrd.conf' % conf.env['SYSCONFDIR']) |
Obaid | 793401d | 2014-02-27 19:13:49 -0600 | [diff] [blame] | 43 | conf.write_config_header('src/config.hpp') |
Obaid | 2ea377f | 2014-02-27 19:45:15 -0600 | [diff] [blame] | 44 | |
| 45 | def build (bld): |
Obaid | 793401d | 2014-02-27 19:13:49 -0600 | [diff] [blame] | 46 | bld( |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 47 | features='cxx', |
| 48 | name='nrd-objects', |
| 49 | source=bld.path.ant_glob('src/*.cpp', |
| 50 | excl='src/main.cpp'), |
| 51 | use='NDN_CPP BOOST', |
Obaid | 2ea377f | 2014-02-27 19:45:15 -0600 | [diff] [blame] | 52 | ) |
| 53 | |
Obaid | 793401d | 2014-02-27 19:13:49 -0600 | [diff] [blame] | 54 | bld.program( |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 55 | target='nrd', |
| 56 | source='src/main.cpp', |
| 57 | use='nrd-objects' |
Obaid | 793401d | 2014-02-27 19:13:49 -0600 | [diff] [blame] | 58 | ) |
| 59 | |
| 60 | # Unit tests |
| 61 | if bld.env['WITH_TESTS']: |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 62 | unit_tests = bld.program( |
Obaid | 793401d | 2014-02-27 19:13:49 -0600 | [diff] [blame] | 63 | target='unit-tests', |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 64 | features='cxx cxxprogram', |
| 65 | source=bld.path.ant_glob(['tests/**/*.cpp']), |
| 66 | use='nrd-objects', |
| 67 | includes=['.', 'src'], |
| 68 | install_prefix=None, |
Obaid | 5748c0c | 2014-04-09 18:00:42 -0500 | [diff] [blame^] | 69 | ) |
| 70 | |
| 71 | bld.install_files('${SYSCONFDIR}/ndn', 'nrd.conf.sample') |
| 72 | |