blob: d3c6b31427c4ce54a871313b59b017b816e306df [file] [log] [blame]
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
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
Alexander Afanasyevc78b1412014-02-19 14:08:26 -08006
Alexander Afanasyev885a85b2014-04-12 21:01:13 -07007from waflib import Options
8
Alexander Afanasyevc78b1412014-02-19 14:08:26 -08009BOOST_ASIO_HAS_LOCAL_SOCKETS_CHECK = '''
10#include <iostream>
11#include <boost/asio.hpp>
12int main() {
13#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS
Alexander Afanasyevd0b44912014-02-27 14:44:59 -080014 return 0;
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080015#else
Alexander Afanasyevd0b44912014-02-27 14:44:59 -080016#error "Unix sockets are not available on this platform"
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080017#endif
18 return 0;
19}
20'''
21
Alexander Afanasyev885a85b2014-04-12 21:01:13 -070022def addUnixOptions(self, opt):
Alexander Afanasyevd0b44912014-02-27 14:44:59 -080023 opt.add_option('--force-unix-socket', action='store_true', default=False,
Alexander Afanasyev97e4cac2014-03-28 10:55:11 -070024 dest='force_unix_socket', help='''Forcefully enable UNIX sockets support''')
Alexander Afanasyev885a85b2014-04-12 21:01:13 -070025setattr(Options.OptionsContext, "addUnixOptions", addUnixOptions)
Alexander Afanasyevd0b44912014-02-27 14:44:59 -080026
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080027def configure(conf):
Alexander Afanasyevd0b44912014-02-27 14:44:59 -080028 def boost_asio_has_local_sockets():
29 return conf.check_cxx(msg='Checking if UNIX sockets are supported',
30 fragment=BOOST_ASIO_HAS_LOCAL_SOCKETS_CHECK,
31 use='BOOST NDN_CPP RT', mandatory=False)
32
33 if conf.options.force_unix_socket or boost_asio_has_local_sockets():
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080034 conf.define('HAVE_UNIX_SOCKETS', 1)
35 conf.env['HAVE_UNIX_SOCKETS'] = True