#!/bin/sh

# A simple script to facilitate the use of the OSS compatibility library.
# Usage:
#	aoss [-32] <command> <command options and arguments>

if [ -f /usr/lib64/libaoss.so.0 ]
then
  AOSS_LIBDIR=/usr/lib64
else
  AOSS_LIBDIR=/usr/lib
fi

if [ "$1" = "-32" ]
then
  if [ -f /usr/lib/libaoss.so.0 ]
  then
    AOSS_LIBDIR=/usr/lib
    shift
  else
    echo "$0 -32 called, but 32-bit alsa-oss-libs not found! Exiting..."
    exit 2
  fi
fi

if [ -d /proc/asound ]; then
  LD_PRELOAD=${AOSS_LIBDIR}/libaoss.so.0${LD_PRELOAD:+:$LD_PRELOAD} exec "$@"
else
  exec "$@"
fi
exit 1
