tclass = $cxx.target.class
tsys   = $cxx.target.system

# Build a separate driver executable for each library variant. (See
# `downstream/libs/stacktrace/src/buildfile` for an explanation.)
#
variants = driver-noop

if ($tclass == 'windows')
   variants += driver-windbg        \
               driver-windbg_cached
else
  variants += driver-addr2line

if ($tclass != 'windows' || $tsys == 'mingw32')
  variants += driver-basic

# For each variant's driver executable, add the (same) source file and link to
# the corresponding variant of libboost-stacktrace.
#
for d: $variants # d: driver.
{
  ln = $regex.replace($d, 'driver-', 'boost_stacktrace_') # Library name.
  import lib = libboost-stacktrace%lib{$ln}

  ./: exe{$d}: obje{$d} $lib
  obje{$d}: cxx{driver} $lib
}

# Do the same for lib{boost_stacktrace}.
#
import lib = libboost-stacktrace%lib{boost_stacktrace}

./: exe{driver-stacktrace}: obje{driver-stacktrace} $lib
obje{driver-stacktrace}: cxx{driver} $lib
