# Trampoline symbols live in the utility library, not liba{}/libs{}. libul{}
# sidesteps bin.lib (which disables liba{vulkan} on Windows) and isn't
# installed, so import? nulls cleanly under test-installed.
#
# Match basics/live's target spelling per platform: a mismatched spelling
# for the same lib{} group within one tests/ configure hits build2 issue
# #561 (second pkgconfig_load on the same group asserts).
#
if ($c.target.system == 'mingw32')
  import? [metadata, rule_hint=c.link] vulkan = libvulkan-loader%libs{vulkan}
else
  import? [metadata, rule_hint=c.link] vulkan = libvulkan-loader%lib{vulkan}

unknown_functions = [bool] false
if ($vulkan != [null])
  unknown_functions = $($vulkan: libvulkan_loader.unknown_functions)

libs =
if $unknown_functions
{
  import? libs = libvulkan-loader%libul{vulkan}
  unknown_functions = ($libs != [null])

  # libul{} is the internal utility library: unlike lib{}, it does not
  # carry -ldl/-lm/-pthread (loader/buildfile scopes those to lib{vulkan}
  # only, to avoid duplicating them when libul{} feeds into liba{}/libs{}
  # there). Bypassing lib{} for the trampoline symbols means supplying
  # them here too.
  #
  if ($unknown_functions && $c.target.class != 'windows')
  {
    c.libs += -ldl -lm
    c.loptions += -pthread
  }
}

./: exe{driver}: include = $unknown_functions
exe{driver}: c{driver} $libs
