mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-02 05:58:30 -04:00
build: generalize link fix
This commit is contained in:
parent
a2f327678b
commit
8a9a08ed9b
@ -161,39 +161,33 @@ def check_package(cfg, env, libname):
|
|||||||
'''use pkg-config to look for an installed library that has a LIBNAME.pc file'''
|
'''use pkg-config to look for an installed library that has a LIBNAME.pc file'''
|
||||||
capsname = libname.upper()
|
capsname = libname.upper()
|
||||||
|
|
||||||
# we don't want check_cfg() changing the global environment during
|
|
||||||
# this test, in case it fails in the 2nd link step
|
|
||||||
cfg.env.stash()
|
cfg.env.stash()
|
||||||
|
|
||||||
cfg.check_cfg(package=libname, mandatory=False, global_define=True,
|
if not cfg.check_cfg(package=libname, mandatory=False, global_define=True,
|
||||||
args=['--libs', '--cflags'], uselib_store=capsname)
|
args=['--libs', '--cflags'], uselib_store=capsname):
|
||||||
|
# Don't even try to link if check_cfg fails
|
||||||
|
cfg.env.revert()
|
||||||
|
return False
|
||||||
|
|
||||||
# we need to also check that we can link against the lib. We may
|
if not cfg.check(compiler='cxx',
|
||||||
# have a pc file for the package, but its the wrong
|
fragment='''int main() { return 0; }''',
|
||||||
# architecture. This can happen as PKG_CONFIG_PATH is not
|
msg='Checking link with %s' % libname,
|
||||||
# architecture specific
|
mandatory=False,
|
||||||
cfg.env.LIB += cfg.env['LIB_%s' % capsname]
|
lib=libname,
|
||||||
cfg.env.INCLUDES += cfg.env['INCLUDES_%s' % capsname]
|
use=capsname):
|
||||||
cfg.env.CFLAGS += cfg.env['CFLAGS_%s' % capsname]
|
cfg.env.revert()
|
||||||
cfg.env.LIBPATH += cfg.env['LIBPATH_%s' % capsname]
|
return False
|
||||||
|
|
||||||
ret = cfg.check(
|
cfg.env.commit()
|
||||||
compiler='cxx',
|
|
||||||
fragment='''int main() { return 0; }''',
|
|
||||||
msg='Testing link with %s' % libname,
|
|
||||||
mandatory=False,
|
|
||||||
lib=libname
|
|
||||||
)
|
|
||||||
|
|
||||||
if ret:
|
# Add to global environment:
|
||||||
env.LIB += cfg.env['LIB_%s' % capsname]
|
# we always want to use the library for all targets
|
||||||
env.INCLUDES += cfg.env['INCLUDES_%s' % capsname]
|
env.LIB += cfg.env['LIB_%s' % capsname]
|
||||||
env.CFLAGS += cfg.env['CFLAGS_%s' % capsname]
|
env.INCLUDES += cfg.env['INCLUDES_%s' % capsname]
|
||||||
env.LIBPATH += cfg.env['LIBPATH_%s' % capsname]
|
env.CFLAGS += cfg.env['CFLAGS_%s' % capsname]
|
||||||
|
env.LIBPATH += cfg.env['LIBPATH_%s' % capsname]
|
||||||
|
|
||||||
cfg.env.revert()
|
return True
|
||||||
|
|
||||||
return ret
|
|
||||||
|
|
||||||
@conf
|
@conf
|
||||||
def check_lttng(cfg, env):
|
def check_lttng(cfg, env):
|
||||||
@ -205,12 +199,7 @@ def check_lttng(cfg, env):
|
|||||||
cfg.msg("Checking for 'lttng-ust':", 'disabled', color='YELLOW')
|
cfg.msg("Checking for 'lttng-ust':", 'disabled', color='YELLOW')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
ret = check_package(cfg, env, 'lttng-ust')
|
return check_package(cfg, env, 'lttng-ust')
|
||||||
if ret:
|
|
||||||
cfg.define('HAVE_LTTNG_UST', 1)
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
@conf
|
@conf
|
||||||
def check_libiio(cfg, env):
|
def check_libiio(cfg, env):
|
||||||
@ -222,8 +211,7 @@ def check_libiio(cfg, env):
|
|||||||
cfg.msg("Checking for 'libiio':", 'disabled', color='YELLOW')
|
cfg.msg("Checking for 'libiio':", 'disabled', color='YELLOW')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
check_package(cfg, env, 'libiio')
|
return check_package(cfg, env, 'libiio')
|
||||||
return True
|
|
||||||
|
|
||||||
@conf
|
@conf
|
||||||
def check_libdl(cfg, env):
|
def check_libdl(cfg, env):
|
||||||
|
Loading…
Reference in New Issue
Block a user