#! /bin/sh
#
# ch_shmem and ch_lfshmem setup
#
# Unpack device_args
#
for arg in $device_args $@; do
    case $arg in 
     -echo) set -x 
       ;;
     -usesysv)
	usesysv=1
       ;;
     -u | -usage | --usage | --usag | --usa | --us | --u | -help | --help )
        cat >&2 <<EOF
--with-device=$DEVICE[:-usesysv]
The option '-usesysv' applies to the ch_shmem device, and causes the device 
to attempt and use System V shared memory and semaphore routines, rather 
than what would be chosen by default (often mmap or a system-specific method).
EOF
	exit 0;
	;;
     *) if test -n "$arg" ; then
	    echo "unrecognized argument $arg"
	    exit 1
	fi
	;;
    esac
done

if [ -z "$top_srcdir" ] ; then 
    top_srcdir="."
fi

DEFAULT_MACHINE="smp"

# Run configure in the device directory
rm -f ${top_srcdir}/mpid/ch_shmem/mpich-mpid.h
( cd mpid/ch_shmem ; export CC ; export CFLAGS ; export usesysv ; \
    $top_srcdir/mpid/ch_shmem/configure $enable_args )
if [ $? != 0 ] ; then
    echo "Aborting device setup because device configure failed"
    exit 1
fi
# Variable assignments from configure are in localdefs
. mpid/ch_shmem/localdefs
LIB_LIST="$LIB_LIST $CHSHMEM_LIBS"
# Look for SIGACTION used
if grep HAVE_SIGACTION mpid/ch_shmem/Makefile >/dev/null 2>&1 ; then
    device_functions="sigaction"
fi
