blob: 52e038a1221fd8bd386af4a4bfede9d9f52fa723 [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 = '''
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080010#include <boost/asio.hpp>
Davide Pesaventoa4e71b42014-05-05 19:57:12 +020011#ifndef BOOST_ASIO_HAS_LOCAL_SOCKETS
Alexander Afanasyevd0b44912014-02-27 14:44:59 -080012#error "Unix sockets are not available on this platform"
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080013#endif
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080014'''
15
Alexander Afanasyev885a85b2014-04-12 21:01:13 -070016def addUnixOptions(self, opt):
Alexander Afanasyevd0b44912014-02-27 14:44:59 -080017 opt.add_option('--force-unix-socket', action='store_true', default=False,
Davide Pesaventoa4e71b42014-05-05 19:57:12 +020018 dest='force_unix_socket', help='''Forcefully enable Unix sockets support''')
Alexander Afanasyev885a85b2014-04-12 21:01:13 -070019setattr(Options.OptionsContext, "addUnixOptions", addUnixOptions)
Alexander Afanasyevd0b44912014-02-27 14:44:59 -080020
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080021def configure(conf):
Alexander Afanasyevd0b44912014-02-27 14:44:59 -080022 def boost_asio_has_local_sockets():
Davide Pesaventoa4e71b42014-05-05 19:57:12 +020023 return conf.check_cxx(msg='Checking if Unix sockets are supported',
Alexander Afanasyevd0b44912014-02-27 14:44:59 -080024 fragment=BOOST_ASIO_HAS_LOCAL_SOCKETS_CHECK,
Davide Pesaventoa4e71b42014-05-05 19:57:12 +020025 features='cxx', use='BOOST', mandatory=False)
Alexander Afanasyevd0b44912014-02-27 14:44:59 -080026
27 if conf.options.force_unix_socket or boost_asio_has_local_sockets():
Alexander Afanasyevc78b1412014-02-19 14:08:26 -080028 conf.define('HAVE_UNIX_SOCKETS', 1)
29 conf.env['HAVE_UNIX_SOCKETS'] = True