Chengyu Fan | eb0422c | 2015-03-04 16:34:14 -0700 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
| 3 | """ |
| 4 | Copyright (c) 2014-2015, 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 | |
| 11 | This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | |
| 14 | NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | of the GNU General Public License as published by the Free Software Foundation, |
| 16 | either version 3 of the License, or (at your option) any later version. |
| 17 | |
| 18 | NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | PURPOSE. See the GNU General Public License for more details. |
| 21 | |
| 22 | You should have received a copy of the GNU General Public License along with |
| 23 | NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | """ |
| 25 | |
| 26 | |
| 27 | VERSION='0.1' |
| 28 | APPNAME='ndn-atmos' |
| 29 | |
| 30 | from waflib import Configure, Utils, Logs, Context |
| 31 | import os |
| 32 | |
| 33 | def options(opt): |
| 34 | opt.load(['compiler_cxx', 'gnu_dirs']) |
| 35 | |
Chengyu Fan | 71b712b | 2015-09-09 22:13:56 -0600 | [diff] [blame] | 36 | opt.load(['default-compiler-flags', 'boost', 'coverage'], |
Chengyu Fan | eb0422c | 2015-03-04 16:34:14 -0700 | [diff] [blame] | 37 | tooldir=['.waf-tools']) |
| 38 | |
| 39 | opt = opt.add_option_group('ndn-atmos Options') |
| 40 | |
Chengyu Fan | 71b712b | 2015-09-09 22:13:56 -0600 | [diff] [blame] | 41 | opt.add_option('--with-log4cxx', action='store_true', default=False, dest='log4cxx', |
| 42 | help='''Compile with log4cxx''') |
| 43 | |
Chengyu Fan | eb0422c | 2015-03-04 16:34:14 -0700 | [diff] [blame] | 44 | opt.add_option('--with-tests', action='store_true', default=False, |
| 45 | dest='with_tests', help='''build unit tests''') |
| 46 | |
| 47 | def configure(conf): |
| 48 | conf.load(['compiler_cxx', 'default-compiler-flags', 'boost', 'gnu_dirs']) |
| 49 | |
| 50 | conf.find_program('bash', var='BASH') |
| 51 | |
| 52 | if not os.environ.has_key('PKG_CONFIG_PATH'): |
| 53 | os.environ['PKG_CONFIG_PATH'] = ':'.join([ |
| 54 | '/usr/local/lib/pkgconfig', |
Chengyu Fan | 2788755 | 2015-03-26 17:12:00 -0600 | [diff] [blame] | 55 | '/usr/local/lib32/pkgconfig', |
| 56 | '/usr/local/lib64/pkgconfig', |
Chengyu Fan | eb0422c | 2015-03-04 16:34:14 -0700 | [diff] [blame] | 57 | '/opt/local/lib/pkgconfig']) |
| 58 | |
| 59 | conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], |
| 60 | uselib_store='NDN_CXX', mandatory=True) |
| 61 | |
Chengyu Fan | 31737f1 | 2016-01-12 21:08:50 -0700 | [diff] [blame] | 62 | conf.check_cfg(package='zdb', args=['--cflags', '--libs'], |
| 63 | uselib_store='ZDB', mandatory=True) |
| 64 | |
Chengyu Fan | 8b92f12 | 2015-03-09 22:13:36 -0600 | [diff] [blame] | 65 | conf.check_cfg(package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'], |
| 66 | uselib_store='SYNC', mandatory=True) |
| 67 | |
| 68 | conf.check_cfg(package='jsoncpp', args=['--cflags', '--libs'], |
| 69 | uselib_store='JSON', mandatory=True) |
| 70 | |
Chengyu Fan | 2788755 | 2015-03-26 17:12:00 -0600 | [diff] [blame] | 71 | conf.check_cfg(path='mysql_config', args=['--cflags', '--libs'], package='', |
| 72 | uselib_store='MYSQL', mandatory=True) |
Chengyu Fan | eb0422c | 2015-03-04 16:34:14 -0700 | [diff] [blame] | 73 | |
Chengyu Fan | 71b712b | 2015-09-09 22:13:56 -0600 | [diff] [blame] | 74 | |
| 75 | if conf.options.log4cxx: |
| 76 | conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', |
| 77 | mandatory=True) |
| 78 | |
Chengyu Fan | eb0422c | 2015-03-04 16:34:14 -0700 | [diff] [blame] | 79 | boost_libs = 'system random thread filesystem' |
| 80 | |
| 81 | if conf.options.with_tests: |
| 82 | conf.env['WITH_TESTS'] = 1 |
| 83 | conf.define('WITH_TESTS', 1); |
| 84 | boost_libs += ' unit_test_framework' |
| 85 | |
| 86 | conf.check_boost(lib=boost_libs, mandatory=True) |
| 87 | if conf.env.BOOST_VERSION_NUMBER < 104800: |
| 88 | Logs.error("Minimum required boost version is 1.48.0") |
| 89 | Logs.error("Please upgrade your distribution or install custom boost libraries" + |
| 90 | " (http://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)") |
| 91 | return |
| 92 | |
Chengyu Fan | 71b712b | 2015-09-09 22:13:56 -0600 | [diff] [blame] | 93 | conf.load('coverage') |
| 94 | |
Chengyu Fan | b25835b | 2015-04-28 17:09:35 -0600 | [diff] [blame] | 95 | conf.define('DEFAULT_CONFIG_FILE', '%s/ndn-atmos/catalog.conf' % conf.env['SYSCONFDIR']) |
Chengyu Fan | 71b712b | 2015-09-09 22:13:56 -0600 | [diff] [blame] | 96 | conf.define('LOG4CXX_CONFIG_FILE', '%s/ndn-atmos/log4cxx.properties' % conf.env['SYSCONFDIR']) |
Chengyu Fan | b25835b | 2015-04-28 17:09:35 -0600 | [diff] [blame] | 97 | |
| 98 | conf.write_config_header('config.hpp') |
Chengyu Fan | eb0422c | 2015-03-04 16:34:14 -0700 | [diff] [blame] | 99 | |
| 100 | def build (bld): |
Chengyu Fan | 8b92f12 | 2015-03-09 22:13:36 -0600 | [diff] [blame] | 101 | ndn_atmos_objects = bld( |
| 102 | target='ndn_atmos_objects', |
| 103 | name='ndn_atmos_objects', |
| 104 | features='cxx', |
Chengyu Fan | 2788755 | 2015-03-26 17:12:00 -0600 | [diff] [blame] | 105 | source=bld.path.ant_glob(['catalog/src/**/*.cpp'], |
Chengyu Fan | 8b92f12 | 2015-03-09 22:13:36 -0600 | [diff] [blame] | 106 | excl=['catalog/src/main.cpp']), |
Chengyu Fan | 31737f1 | 2016-01-12 21:08:50 -0700 | [diff] [blame] | 107 | use='NDN_CXX BOOST JSON MYSQL SYNC LOG4CXX ZDB', |
Chengyu Fan | 8b92f12 | 2015-03-09 22:13:36 -0600 | [diff] [blame] | 108 | includes='catalog/src .', |
| 109 | export_includes='catalog/src .' |
| 110 | ) |
| 111 | |
Chengyu Fan | eb0422c | 2015-03-04 16:34:14 -0700 | [diff] [blame] | 112 | bld( |
Chengyu Fan | b25835b | 2015-04-28 17:09:35 -0600 | [diff] [blame] | 113 | target='bin/atmos-catalog', |
Chengyu Fan | 8b92f12 | 2015-03-09 22:13:36 -0600 | [diff] [blame] | 114 | features='cxx cxxprogram', |
| 115 | source='catalog/src/main.cpp', |
| 116 | use='ndn_atmos_objects' |
Chengyu Fan | eb0422c | 2015-03-04 16:34:14 -0700 | [diff] [blame] | 117 | ) |
| 118 | |
Chengyu Fan | b25835b | 2015-04-28 17:09:35 -0600 | [diff] [blame] | 119 | bld.recurse('tools') |
| 120 | |
Chengyu Fan | eb0422c | 2015-03-04 16:34:14 -0700 | [diff] [blame] | 121 | # Catalog unit tests |
| 122 | if bld.env['WITH_TESTS']: |
| 123 | bld.recurse('catalog/tests') |
Chengyu Fan | b25835b | 2015-04-28 17:09:35 -0600 | [diff] [blame] | 124 | |
| 125 | bld( |
| 126 | features="subst", |
| 127 | source='catalog.conf.sample.in', |
| 128 | target='catalog.conf.sample', |
| 129 | install_path="${SYSCONFDIR}/ndn-atmos" |
| 130 | ) |
Chengyu Fan | 71b712b | 2015-09-09 22:13:56 -0600 | [diff] [blame] | 131 | |
| 132 | bld( |
| 133 | features="subst", |
| 134 | source='log4cxx.properties', |
| 135 | target='log4cxx.properties', |
| 136 | install_path="${SYSCONFDIR}/ndn-atmos" |
| 137 | ) |