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 | 793401d | 2014-02-27 19:13:49 -0600 | [diff] [blame] | 42 | conf.write_config_header('src/config.hpp') |
Obaid | 2ea377f | 2014-02-27 19:45:15 -0600 | [diff] [blame] | 43 | |
| 44 | def build (bld): |
Obaid | 793401d | 2014-02-27 19:13:49 -0600 | [diff] [blame] | 45 | bld( |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 46 | features='cxx', |
| 47 | name='nrd-objects', |
| 48 | source=bld.path.ant_glob('src/*.cpp', |
| 49 | excl='src/main.cpp'), |
| 50 | use='NDN_CPP BOOST', |
Obaid | 2ea377f | 2014-02-27 19:45:15 -0600 | [diff] [blame] | 51 | ) |
| 52 | |
Obaid | 793401d | 2014-02-27 19:13:49 -0600 | [diff] [blame] | 53 | bld.program( |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 54 | target='nrd', |
| 55 | source='src/main.cpp', |
| 56 | use='nrd-objects' |
Obaid | 793401d | 2014-02-27 19:13:49 -0600 | [diff] [blame] | 57 | ) |
| 58 | |
| 59 | # Unit tests |
| 60 | if bld.env['WITH_TESTS']: |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 61 | unit_tests = bld.program( |
Obaid | 793401d | 2014-02-27 19:13:49 -0600 | [diff] [blame] | 62 | target='unit-tests', |
Alexander Afanasyev | 80f06a5 | 2014-03-27 14:40:00 -0700 | [diff] [blame] | 63 | features='cxx cxxprogram', |
| 64 | source=bld.path.ant_glob(['tests/**/*.cpp']), |
| 65 | use='nrd-objects', |
| 66 | includes=['.', 'src'], |
| 67 | install_prefix=None, |
Obaid | 793401d | 2014-02-27 19:13:49 -0600 | [diff] [blame] | 68 | ) |