install -vd "$INSTALL_ROOT/opt/watcom" &&
cp -r "$SOURCE_DIRECTORY"/rel/. "$INSTALL_ROOT/opt/watcom/" &&

install -vm 555 "$SCRIPT_DIRECTORY/owwrapper" \
                "$INSTALL_ROOT/opt/watcom/owwrapper" &&

install -vd "$INSTALL_ROOT/usr/bin" &&

# Expose the Linux-hosted tools through the wrapper. vi and ctags are held back
# because they would shadow other spells; wrc is renamed instead of dropped,
# since Wine's wrc of the same name does a related but not interchangeable job.
find "$SOURCE_DIRECTORY"/rel/binl64 ! -name \*.so ! -name \*.exe \
     ! -name vi ! -name ctags -type f -executable -printf %f\\n |
while read f; do
  case $f in
    (wrc) f=watcom-$f ;;
  esac
  ln -vrsf "$INSTALL_ROOT"/opt/watcom/owwrapper "$INSTALL_ROOT/usr/bin/$f" || return 1
done
