# StarPU --- Runtime system for heterogeneous multicore architectures.
#
# Copyright (C) 2020-2025   University of Bordeaux, CNRS (LaBRI UMR 5800), Inria
#
# StarPU is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
# StarPU is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See the GNU Lesser General Public License in COPYING.LGPL for more details.
#

PROGNAME=starpu_env

usage()
{
    echo "Tool to set StarPU environment variables"
    echo ""
    echo "Usage: source $PROGNAME"
    echo ""
    echo ""
    echo "Options:"
    echo "	-h, --help          display this help and exit"
    echo "	-v, --version       output version information and exit"
    echo ""
    echo "Report bugs to <starpu-devel@inria.fr>"
}

if [ "$1" = "-v" ] || [ "$1" = "--version" ]
then
    echo "$PROGNAME (StarPU) 1.4.9"
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]
then
    usage
else
    prefix=$(realpath /clang64)
    exec_prefix=$(realpath ${prefix})
    starpu_bindir=$(realpath ${exec_prefix}/bin)
    starpu_libdir=$(realpath ${exec_prefix}/lib)
    starpu_datarootdir=$(realpath ${prefix}/share)
    if test -f $starpu_bindir/starpu_machine_display -a -f $starpu_libdir/pkgconfig/libstarpu.pc
    then
	echo "Setting StarPU environment for $prefix"
	export STARPU_ROOT=$prefix
	export PKG_CONFIG_PATH=$starpu_libdir/pkgconfig:$PKG_CONFIG_PATH
	export LD_LIBRARY_PATH=$starpu_libdir:$LD_LIBRARY_PATH
	export PATH=$starpu_bindir:$PATH
	export MANPATH=$starpu_datarootdir/man:$MANPATH
	if [ -n "" ]
	then
	    for d in $starpu_libdir/*/site-packages ; do export PYTHONPATH=$d:$PYTHONPATH ; done
	fi
    else
	echo "[Error] $prefix is not a valid StarPU installation directory"
    fi
fi

