#!/bin/sh
# configure.win — auto-vendor tdc before compilation (Windows / Rtools)
#
# Same resolution order as configure. Rtools provides sh via MSYS2.

set -eu

PKG_ROOT=`cd "\`dirname "$0"\`" && pwd`
TDC=${TDC-"$PKG_ROOT/../tdc"}

if [ -f "$PKG_ROOT/tools/vendor_tdc.sh" ] \
   && [ -d "$TDC/include/tdc" ] && [ -d "$TDC/src" ]; then
  sh "$PKG_ROOT/tools/vendor_tdc.sh"
elif [ -d "$PKG_ROOT/src/tdc/include/tdc" ]; then
  echo "configure.win: using pre-vendored src/tdc/"
else
  echo "configure.win: ERROR - no tdc source found" >&2
  echo "  expected sibling repo at $TDC" >&2
  echo "  or pre-vendored copy at src/tdc/" >&2
  exit 1
fi
