Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 1 | # -*- 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 Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 6 | |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame^] | 7 | from waflib import Options |
| 8 | |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 9 | BOOST_ASIO_HAS_LOCAL_SOCKETS_CHECK = ''' |
| 10 | #include <iostream> |
| 11 | #include <boost/asio.hpp> |
| 12 | int main() { |
| 13 | #ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS |
Alexander Afanasyev | d0b4491 | 2014-02-27 14:44:59 -0800 | [diff] [blame] | 14 | return 0; |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 15 | #else |
Alexander Afanasyev | d0b4491 | 2014-02-27 14:44:59 -0800 | [diff] [blame] | 16 | #error "Unix sockets are not available on this platform" |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 17 | #endif |
| 18 | return 0; |
| 19 | } |
| 20 | ''' |
| 21 | |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame^] | 22 | def addUnixOptions(self, opt): |
Alexander Afanasyev | d0b4491 | 2014-02-27 14:44:59 -0800 | [diff] [blame] | 23 | opt.add_option('--force-unix-socket', action='store_true', default=False, |
Alexander Afanasyev | 97e4cac | 2014-03-28 10:55:11 -0700 | [diff] [blame] | 24 | dest='force_unix_socket', help='''Forcefully enable UNIX sockets support''') |
Alexander Afanasyev | 885a85b | 2014-04-12 21:01:13 -0700 | [diff] [blame^] | 25 | setattr(Options.OptionsContext, "addUnixOptions", addUnixOptions) |
Alexander Afanasyev | d0b4491 | 2014-02-27 14:44:59 -0800 | [diff] [blame] | 26 | |
Alexander Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 27 | def configure(conf): |
Alexander Afanasyev | d0b4491 | 2014-02-27 14:44:59 -0800 | [diff] [blame] | 28 | 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 Afanasyev | c78b141 | 2014-02-19 14:08:26 -0800 | [diff] [blame] | 34 | conf.define('HAVE_UNIX_SOCKETS', 1) |
| 35 | conf.env['HAVE_UNIX_SOCKETS'] = True |