#!/usr/bin/env bash
# @(#) $Id: rms,v 1.3 2025/03/28 23:04:13 ralph Exp $
# Wrapper for the various platforms we support. Requires BASH, tr
# -------------------------------------------------------------------------
# $Header: /home/cvs/src/prj/rms/rms,v 1.3 2025/03/28 23:04:13 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:]')

# The environment variable "RMS" we need to adapt and export
set RMS_${ARCHUPPER}="${RMS}"

# 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 rms itself... :-)
