2016-05-19 16:50:27 -03:00
|
|
|
# Copyright (C) 2016 Intel Corporation. All rights reserved.
|
|
|
|
#
|
|
|
|
# This file is free software: you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by the
|
|
|
|
# Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This file is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-04-05 17:09:48 -03:00
|
|
|
"""
|
2016-04-06 00:45:43 -03:00
|
|
|
WAF Tool that checks cxx parameters, creating the ap_config.h
|
2016-04-05 17:09:48 -03:00
|
|
|
header file.
|
|
|
|
|
|
|
|
This tool needs compiler_cxx to be loaded, make sure you
|
|
|
|
load them before this tool.
|
|
|
|
|
|
|
|
Example::
|
|
|
|
def configure(cfg):
|
|
|
|
cfg.load('cxx_checks')
|
|
|
|
"""
|
|
|
|
|
2016-05-19 17:00:29 -03:00
|
|
|
from waflib.Configure import conf
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def ap_common_checks(cfg):
|
2016-05-19 16:37:34 -03:00
|
|
|
cfg.check(
|
|
|
|
compiler='cxx',
|
|
|
|
fragment='''
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
return std::isfinite(1.0f);
|
|
|
|
}''',
|
|
|
|
define_name="HAVE_CMATH_ISFINITE",
|
|
|
|
msg="Checking for HAVE_CMATH_ISFINITE",
|
|
|
|
mandatory=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
cfg.check(
|
|
|
|
compiler='cxx',
|
|
|
|
fragment='''
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
return std::isinf(1.0f);
|
|
|
|
}''',
|
|
|
|
define_name="HAVE_CMATH_ISINF",
|
|
|
|
msg="Checking for HAVE_CMATH_ISINF",
|
|
|
|
mandatory=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
cfg.check(
|
|
|
|
compiler='cxx',
|
|
|
|
fragment='''
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
return std::isnan(1.0f);
|
|
|
|
}''',
|
|
|
|
define_name="HAVE_CMATH_ISNAN",
|
|
|
|
msg="Checking for HAVE_CMATH_ISNAN",
|
|
|
|
mandatory=False,
|
|
|
|
)
|
2016-04-05 17:09:48 -03:00
|
|
|
|
|
|
|
# NEED_CMATH_FUNCTION_STD_NAMESPACE checks are needed due to
|
|
|
|
# new gcc versions being more restrictive.
|
|
|
|
#
|
|
|
|
# Here we check if we need to add 'using std::function' to
|
|
|
|
# the function.
|
|
|
|
#
|
|
|
|
# Without these checks, in some cases, gcc points this as
|
|
|
|
# overloads or function duplication in scope.
|
|
|
|
|
2016-05-19 16:37:34 -03:00
|
|
|
cfg.check(
|
|
|
|
compiler='cxx',
|
|
|
|
fragment='''
|
|
|
|
#include <math.h>
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
using std::isfinite;
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
return isfinite((double)1);
|
|
|
|
}''',
|
|
|
|
define_name="NEED_CMATH_ISFINITE_STD_NAMESPACE",
|
|
|
|
msg="Checking for NEED_CMATH_ISFINITE_STD_NAMESPACE",
|
|
|
|
mandatory=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
cfg.check(
|
|
|
|
compiler='cxx',
|
|
|
|
fragment='''
|
|
|
|
#include <math.h>
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
using std::isinf;
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
return isinf((double)1);
|
|
|
|
}''',
|
|
|
|
define_name="NEED_CMATH_ISINF_STD_NAMESPACE",
|
|
|
|
msg="Checking for NEED_CMATH_ISINF_STD_NAMESPACE",
|
|
|
|
mandatory=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
cfg.check(
|
|
|
|
compiler='cxx',
|
|
|
|
fragment='''
|
|
|
|
#include <math.h>
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
using std::isnan;
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
return isnan((double)1);
|
|
|
|
}''',
|
|
|
|
define_name="NEED_CMATH_ISNAN_STD_NAMESPACE",
|
|
|
|
msg="Checking for NEED_CMATH_ISNAN_STD_NAMESPACE",
|
|
|
|
mandatory=False,
|
|
|
|
)
|
2016-05-19 17:24:12 -03:00
|
|
|
|
2016-07-08 11:05:17 -03:00
|
|
|
cfg.check(header_name='endian.h', mandatory=False)
|
|
|
|
|
|
|
|
cfg.check(header_name='byteswap.h', mandatory=False)
|
|
|
|
|
2016-05-19 17:24:12 -03:00
|
|
|
@conf
|
2016-05-21 12:11:48 -03:00
|
|
|
def check_librt(cfg, env):
|
2016-06-21 11:26:18 -03:00
|
|
|
if cfg.env.DEST_OS == 'darwin':
|
|
|
|
return True
|
|
|
|
|
2016-05-21 12:11:48 -03:00
|
|
|
ret = cfg.check(
|
2016-05-19 17:24:12 -03:00
|
|
|
compiler='cxx',
|
|
|
|
fragment='''
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
clock_gettime(CLOCK_REALTIME, NULL);
|
|
|
|
}''',
|
|
|
|
msg='Checking for need to link with librt',
|
|
|
|
okmsg='not necessary',
|
|
|
|
errmsg='necessary',
|
|
|
|
mandatory=False,
|
|
|
|
)
|
|
|
|
|
2016-05-21 12:11:48 -03:00
|
|
|
if ret:
|
|
|
|
return ret
|
2016-05-19 17:24:12 -03:00
|
|
|
|
2016-05-21 12:11:48 -03:00
|
|
|
ret = cfg.check(compiler='cxx', lib='rt')
|
|
|
|
if ret:
|
|
|
|
env.LIB += cfg.env['LIB_RT']
|
|
|
|
|
|
|
|
return ret
|
2016-05-21 12:16:11 -03:00
|
|
|
|
2016-07-12 23:27:39 -03:00
|
|
|
@conf
|
|
|
|
def check_package(cfg, env, libname):
|
|
|
|
'''use pkg-config to look for an installed library that has a LIBNAME.pc file'''
|
|
|
|
capsname = libname.upper()
|
2017-01-20 06:18:57 -04:00
|
|
|
|
|
|
|
cfg.env.stash()
|
|
|
|
|
2017-08-07 14:05:00 -03:00
|
|
|
if not cfg.check_cfg(package=libname, mandatory=False, global_define=True,
|
|
|
|
args=['--libs', '--cflags'], uselib_store=capsname):
|
|
|
|
# Don't even try to link if check_cfg fails
|
|
|
|
cfg.env.revert()
|
|
|
|
return False
|
2017-01-20 06:18:57 -04:00
|
|
|
|
2017-08-07 14:05:00 -03:00
|
|
|
if not cfg.check(compiler='cxx',
|
|
|
|
fragment='''int main() { return 0; }''',
|
|
|
|
msg='Checking link with %s' % libname,
|
|
|
|
mandatory=False,
|
|
|
|
lib=libname,
|
|
|
|
use=capsname):
|
|
|
|
cfg.env.revert()
|
|
|
|
return False
|
2017-01-20 06:18:57 -04:00
|
|
|
|
2017-08-07 14:05:00 -03:00
|
|
|
cfg.env.commit()
|
2017-01-20 06:18:57 -04:00
|
|
|
|
2017-08-07 14:05:00 -03:00
|
|
|
# Add to global environment:
|
|
|
|
# we always want to use the library for all targets
|
|
|
|
env.LIB += cfg.env['LIB_%s' % capsname]
|
|
|
|
env.INCLUDES += cfg.env['INCLUDES_%s' % capsname]
|
|
|
|
env.CFLAGS += cfg.env['CFLAGS_%s' % capsname]
|
|
|
|
env.LIBPATH += cfg.env['LIBPATH_%s' % capsname]
|
2016-07-12 23:27:39 -03:00
|
|
|
|
2017-08-07 14:05:00 -03:00
|
|
|
return True
|
2017-07-10 17:31:09 -03:00
|
|
|
|
2016-05-21 12:16:11 -03:00
|
|
|
@conf
|
|
|
|
def check_lttng(cfg, env):
|
2018-03-27 04:21:33 -03:00
|
|
|
if not cfg.options.enable_lttng:
|
|
|
|
cfg.msg("Checking for 'lttng-ust':", 'disabled', color='YELLOW')
|
|
|
|
return False
|
2016-11-14 11:52:54 -04:00
|
|
|
if cfg.env.STATIC_LINKING:
|
|
|
|
# lttng-ust depends on libdl which means it can't be used in a static build
|
|
|
|
cfg.msg("Checking for 'lttng-ust':", 'disabled for static build', color='YELLOW')
|
|
|
|
return False
|
2016-05-25 23:06:19 -03:00
|
|
|
|
2017-08-07 14:05:00 -03:00
|
|
|
return check_package(cfg, env, 'lttng-ust')
|
2016-05-21 12:17:56 -03:00
|
|
|
|
|
|
|
@conf
|
|
|
|
def check_libiio(cfg, env):
|
2016-07-19 12:10:21 -03:00
|
|
|
if cfg.env.STATIC_LINKING:
|
2016-07-12 23:27:39 -03:00
|
|
|
# libiio depends on libdl which means it can't be used in a static build
|
2016-07-19 12:10:21 -03:00
|
|
|
cfg.msg("Checking for 'libiio':", 'disabled for static build', color='YELLOW')
|
2016-07-12 23:27:39 -03:00
|
|
|
return False
|
2016-05-27 08:21:20 -03:00
|
|
|
if cfg.options.disable_libiio:
|
|
|
|
cfg.msg("Checking for 'libiio':", 'disabled', color='YELLOW')
|
|
|
|
return False
|
|
|
|
|
2017-08-07 14:05:00 -03:00
|
|
|
return check_package(cfg, env, 'libiio')
|
2016-07-12 23:27:39 -03:00
|
|
|
|
|
|
|
@conf
|
|
|
|
def check_libdl(cfg, env):
|
2016-07-19 12:10:21 -03:00
|
|
|
if cfg.env.STATIC_LINKING:
|
2016-07-12 23:27:39 -03:00
|
|
|
# using loadable modules for a static build is not recommended
|
2016-07-19 12:10:21 -03:00
|
|
|
cfg.msg("Checking for 'libdl':", 'disabled for static build', color='YELLOW')
|
2016-07-12 23:27:39 -03:00
|
|
|
return False
|
2016-07-13 01:04:02 -03:00
|
|
|
ret = cfg.check(compiler='cxx', lib='dl', mandatory=False, global_define=True, define_name='HAVE_LIBDL')
|
2016-07-12 23:27:39 -03:00
|
|
|
if ret:
|
|
|
|
env.LIB += cfg.env['LIB_DL']
|
|
|
|
return ret
|