# StarPU --- Runtime system for heterogeneous multicore architectures.
#
# Copyright (C) 2020  Université de 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.3.8"
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]
then
    usage
else
    starpu_prefix=$(realpath /mnt/scratch/buildbot/starpu//conan-starpu-1_3_8-release-tarball/install)
    if test -f $starpu_prefix/bin/starpu_machine_display -a -f $starpu_prefix/lib/pkgconfig/libstarpu.pc
    then
	echo "Setting StarPU environment for $starpu_prefix"
	export PKG_CONFIG_PATH=$starpu_prefix/lib/pkgconfig:$PKG_CONFIG_PATH
	export LD_LIBRARY_PATH=$starpu_prefix/lib:$LD_LIBRARY_PATH
	export PATH=$starpu_prefix/bin:$PATH
	export MANPATH=$starpu_prefix/share/man:$MANPATH
    else
	echo "[Error] $starpu_prefix is not a valid StarPU installation directory"
    fi
fi

