#!/usr/bin/env bash
# @(#) $Id: mpscan,v 1.8 2025/02/16 23:26:17 ralph Exp $
# Wrapper for the various platforms we support. Requires BASH
# -------------------------------------------------------------------------
# $Header: /home/cvs/src/prj/mpscan/mpscan,v 1.8 2025/02/16 23:26:17 ralph Exp $
# vim:ts=8:sw=4:sts=4
# coding: utf-8 -*- http://rose.rult.at/ - (c) by Ralph Roth, ROSE SWE
# -------------------------------------------------------------------------


# try to get absolute path and name of myself. Should work with symlinks and directories starting with "-"
# SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

SCRIPTPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/Linux/$(basename "${BASH_SOURCE[0]}")"

export ARCH=$(arch)
ARCHUPPER=$(echo ${ARCH}| tr '[:lower:]' '[:upper:]')

# As MPScan 3.00 has now documented the environment variable "MPSCAN" we need to adapt and export it
set MPSCAN_${ARCHUPPER}="${MPSCAN}"

# NOTE:  cygwin[unsupported]: i686(32bit)
case ${ARCH} in

  i686|x86_64|aarch64|armv6l)    "${SCRIPTPATH}_${ARCH}" "${*}"  ;;
  *)                      echo "Yet unsupported platform $ARCH. If you have a business use case for this platform please contact ROSE SWE!"  ;;

esac

RC=$?
echo "## RC=${RC}"
exit ${RC}  ## hopefully we get the return code from mpscan itself... :-)
