blob: 6b3c33aaf951033d7e3caf0b617f379ffa25885d [file] [log] [blame]
Chengyu Faneb0422c2015-03-04 16:34:14 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
3"""
4Copyright (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
11This file is part of NFD (Named Data Networking Forwarding Daemon).
12See AUTHORS.md for complete list of NFD authors and contributors.
13
14NFD is free software: you can redistribute it and/or modify it under the terms
15of the GNU General Public License as published by the Free Software Foundation,
16either version 3 of the License, or (at your option) any later version.
17
18NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20PURPOSE. See the GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License along with
23NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24"""
25
26
27VERSION='0.1'
28APPNAME='ndn-atmos'
29
30from waflib import Configure, Utils, Logs, Context
31import os
32
33def options(opt):
34 opt.load(['compiler_cxx', 'gnu_dirs'])
35
Chengyu Fan71b712b2015-09-09 22:13:56 -060036 opt.load(['default-compiler-flags', 'boost', 'coverage'],
Chengyu Faneb0422c2015-03-04 16:34:14 -070037 tooldir=['.waf-tools'])
38
39 opt = opt.add_option_group('ndn-atmos Options')
40
Chengyu Fan71b712b2015-09-09 22:13:56 -060041 opt.add_option('--with-log4cxx', action='store_true', default=False, dest='log4cxx',
42 help='''Compile with log4cxx''')
43
Chengyu Faneb0422c2015-03-04 16:34:14 -070044 opt.add_option('--with-tests', action='store_true', default=False,
45 dest='with_tests', help='''build unit tests''')
46
47def 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 Fan27887552015-03-26 17:12:00 -060055 '/usr/local/lib32/pkgconfig',
56 '/usr/local/lib64/pkgconfig',
Chengyu Faneb0422c2015-03-04 16:34:14 -070057 '/opt/local/lib/pkgconfig'])
58
59 conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
60 uselib_store='NDN_CXX', mandatory=True)
61
Chengyu Fan8b92f122015-03-09 22:13:36 -060062 conf.check_cfg(package='ChronoSync', args=['ChronoSync >= 0.1', '--cflags', '--libs'],
63 uselib_store='SYNC', mandatory=True)
64
65 conf.check_cfg(package='jsoncpp', args=['--cflags', '--libs'],
66 uselib_store='JSON', mandatory=True)
67
Chengyu Fan27887552015-03-26 17:12:00 -060068 conf.check_cfg(path='mysql_config', args=['--cflags', '--libs'], package='',
69 uselib_store='MYSQL', mandatory=True)
Chengyu Faneb0422c2015-03-04 16:34:14 -070070
Chengyu Fan71b712b2015-09-09 22:13:56 -060071
72 if conf.options.log4cxx:
73 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX',
74 mandatory=True)
75
Chengyu Faneb0422c2015-03-04 16:34:14 -070076 boost_libs = 'system random thread filesystem'
77
78 if conf.options.with_tests:
79 conf.env['WITH_TESTS'] = 1
80 conf.define('WITH_TESTS', 1);
81 boost_libs += ' unit_test_framework'
82
83 conf.check_boost(lib=boost_libs, mandatory=True)
84 if conf.env.BOOST_VERSION_NUMBER < 104800:
85 Logs.error("Minimum required boost version is 1.48.0")
86 Logs.error("Please upgrade your distribution or install custom boost libraries" +
87 " (http://redmine.named-data.net/projects/nfd/wiki/Boost_FAQ)")
88 return
89
Chengyu Fan71b712b2015-09-09 22:13:56 -060090 conf.load('coverage')
91
Chengyu Fanb25835b2015-04-28 17:09:35 -060092 conf.define('DEFAULT_CONFIG_FILE', '%s/ndn-atmos/catalog.conf' % conf.env['SYSCONFDIR'])
Chengyu Fan71b712b2015-09-09 22:13:56 -060093 conf.define('LOG4CXX_CONFIG_FILE', '%s/ndn-atmos/log4cxx.properties' % conf.env['SYSCONFDIR'])
Chengyu Fanb25835b2015-04-28 17:09:35 -060094
95 conf.write_config_header('config.hpp')
Chengyu Faneb0422c2015-03-04 16:34:14 -070096
97def build (bld):
Chengyu Fan8b92f122015-03-09 22:13:36 -060098 ndn_atmos_objects = bld(
99 target='ndn_atmos_objects',
100 name='ndn_atmos_objects',
101 features='cxx',
Chengyu Fan27887552015-03-26 17:12:00 -0600102 source=bld.path.ant_glob(['catalog/src/**/*.cpp'],
Chengyu Fan8b92f122015-03-09 22:13:36 -0600103 excl=['catalog/src/main.cpp']),
Chengyu Fan71b712b2015-09-09 22:13:56 -0600104 use='NDN_CXX BOOST JSON MYSQL SYNC LOG4CXX',
Chengyu Fan8b92f122015-03-09 22:13:36 -0600105 includes='catalog/src .',
106 export_includes='catalog/src .'
107 )
108
Chengyu Faneb0422c2015-03-04 16:34:14 -0700109 bld(
Chengyu Fanb25835b2015-04-28 17:09:35 -0600110 target='bin/atmos-catalog',
Chengyu Fan8b92f122015-03-09 22:13:36 -0600111 features='cxx cxxprogram',
112 source='catalog/src/main.cpp',
113 use='ndn_atmos_objects'
Chengyu Faneb0422c2015-03-04 16:34:14 -0700114 )
115
Chengyu Fanb25835b2015-04-28 17:09:35 -0600116 bld.recurse('tools')
117
Chengyu Faneb0422c2015-03-04 16:34:14 -0700118 # Catalog unit tests
119 if bld.env['WITH_TESTS']:
120 bld.recurse('catalog/tests')
Chengyu Fanb25835b2015-04-28 17:09:35 -0600121
122 bld(
123 features="subst",
124 source='catalog.conf.sample.in',
125 target='catalog.conf.sample',
126 install_path="${SYSCONFDIR}/ndn-atmos"
127 )
Chengyu Fan71b712b2015-09-09 22:13:56 -0600128
129 bld(
130 features="subst",
131 source='log4cxx.properties',
132 target='log4cxx.properties',
133 install_path="${SYSCONFDIR}/ndn-atmos"
134 )