#!/usr/bin/env bash
set -e

ARCH=x86_64
MODSUBDIR=x86_64

if test "x${NRNHOME}" = x ; then
        prefix="/var/folders/vk/nx37ffx50hv5djclhltc26vw0000gn/T/tmpdls_5413/wheel/platlib"
	exec_prefix=/var/folders/vk/nx37ffx50hv5djclhltc26vw0000gn/T/tmpdls_5413/wheel/platlib
	NRNBIN=${exec_prefix}/bin/
	NRNDEMO=/var/folders/vk/nx37ffx50hv5djclhltc26vw0000gn/T/tmpdls_5413/wheel/platlib/share/"nrn"/demo/
else
    prefix="$NRNHOME"
    exec_prefix="${prefix}"
	NRNBIN="${exec_prefix}/bin/"
	NRNDEMO="${prefix}/share/"nrn"/demo/"
fi

if test "${NRNHOME_EXEC}" != "" ; then
	exec_prefix="${NRNHOME_EXEC}"
	NRNBIN="${exec_prefix}/bin/"
fi

export NRNDEMO

if [ ! -f "${NRNDEMO}neuron" ] ; then
	(cd "${NRNDEMO}release" ; "${NRNBIN}nrnivmodl" ; cd .. ; rm -f neuron ; touch neuron)
fi

if [ "ON" = "ON" ]; then
    ${NRNBIN}nrniv -dll "${NRNDEMO}release/${MODSUBDIR}/libnrnmech.dylib" "${NRNDEMO}demo.hoc" "$@" -
else
    "${NRNDEMO}release/${MODSUBDIR}/special" "${NRNDEMO}demo.hoc" "$@" -
fi
