blob: 2eea4c22bc424f572c1e51d6e2eb2fa179699aad [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():
Alexander Afanasyevdc9c8112014-04-25 17:47:18 -070029 return conf.check_cxx(features="cxx",
30 msg='Checking if UNIX sockets are supported',
Alexander Afanasyevd0b44912014-02-27 14:44:59 -080031 fragment=BOOST_ASIO_HAS_LOCAL_SOCKETS_CHECK,
Alexander Afanasyev07c10572014-04-25 13:27:32 -070032 use='BOOST', mandatory=False)
Alexander Afanasyevd0b44912014-02-27 14:44:59 -080033
34 if conf.options.force_unix_socket or boost_asio_has_local_sockets():
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080035 conf.define('HAVE_UNIX_SOCKETS', 1)
36 conf.env['HAVE_UNIX_SOCKETS'] = True