waf: added check_package() function for pkg-config checks
this converts existing pkg-config checks to use check_package, which sets up all the needed variables after a check. This also disables libdl and libiio for static builds, where they make no sense
This commit is contained in:
parent
55e91f0325
commit
2980d47e23
@ -156,27 +156,47 @@ def check_librt(cfg, env):
|
|||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@conf
|
||||||
|
def check_package(cfg, env, libname):
|
||||||
|
'''use pkg-config to look for an installed library that has a LIBNAME.pc file'''
|
||||||
|
cfg.check_cfg(package=libname, mandatory=False, global_define=True,
|
||||||
|
args=['--libs', '--cflags'])
|
||||||
|
capsname = libname.upper()
|
||||||
|
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]
|
||||||
|
|
||||||
@conf
|
@conf
|
||||||
def check_lttng(cfg, env):
|
def check_lttng(cfg, env):
|
||||||
if cfg.options.disable_lttng:
|
if cfg.options.disable_lttng:
|
||||||
cfg.msg("Checking for 'lttng-ust':", 'disabled', color='YELLOW')
|
cfg.msg("Checking for 'lttng-ust':", 'disabled', color='YELLOW')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
cfg.check_cfg(package='lttng-ust', mandatory=False, global_define=True,
|
check_package(cfg, env, 'lttng-ust')
|
||||||
args=['--libs', '--cflags'])
|
|
||||||
env.LIB += cfg.env['LIB_LTTNG-UST']
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@conf
|
@conf
|
||||||
def check_libiio(cfg, env):
|
def check_libiio(cfg, env):
|
||||||
|
if env.STATIC_LINKING:
|
||||||
|
# libiio depends on libdl which means it can't be used in a static build
|
||||||
|
cfg.msg("libiio disabled for static build", 'disabled', color='YELLOW')
|
||||||
|
return False
|
||||||
if cfg.options.disable_libiio:
|
if cfg.options.disable_libiio:
|
||||||
cfg.msg("Checking for 'libiio':", 'disabled', color='YELLOW')
|
cfg.msg("Checking for 'libiio':", 'disabled', color='YELLOW')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
cfg.check_cfg(package='libiio', mandatory=False, global_define=True,
|
check_package(cfg, env, 'libiio')
|
||||||
args=['--libs', '--cflags'])
|
|
||||||
env.LIB += cfg.env['LIB_LIBIIO']
|
|
||||||
# workaround bug in libiio 0.6 not including -ldl
|
|
||||||
if cfg.env['LIB_LIBIIO']:
|
|
||||||
env.LIB += ['dl']
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@conf
|
||||||
|
def check_libdl(cfg, env):
|
||||||
|
if env.STATIC_LINKING:
|
||||||
|
# using loadable modules for a static build is not recommended
|
||||||
|
cfg.msg("libdl disabled for static build", 'disabled', color='YELLOW')
|
||||||
|
return False
|
||||||
|
ret = cfg.check(compiler='cxx', lib='dl', mandatory=False)
|
||||||
|
if ret:
|
||||||
|
env.LIB += cfg.env['LIB_DL']
|
||||||
|
cfg.define('HAVE_LIBDL', 1)
|
||||||
|
return ret
|
||||||
|
Loading…
Reference in New Issue
Block a user