#!/bin/bash

LIBS="-L/usr/src/tmp/pastix-buildroot/usr/lib -lpastix -lgfortran -lm -lrt -Wl,-R/usr/lib/openmpi/lib -L/usr/lib/metis/lib -lmetis  -L/usr/lib -lscotch -lscotcherrexit    -L/usr/lib -lptscotch -lscotcherrexit -lpthread";
INC="-I/usr/include -I/usr/lib/pastix/include"
CC="mpicc -Wall -g";
CL="mpicc -Wall -g";
FC="mpif90 -g -ffree-form -x f95-cpp-input -pipe -Wall -fPIC -DPIC";
FL="mpif90 -g ";
OPTS="-DFORCE_LONG -DLONG -DFORCE_DOUBLE -DPREC_DOUBLE   -DTHREAD_COMM -DNUMA_ALLOC -DMETIS -DWITH_SCOTCH -I/usr/lib/metis/include/metis -I/usr/include			      -I/usr/include -DDISTRIBUTED	     ";
BLAS="-lblas";
VERSION="3184";
LIBS_MURGE=`echo $LIBS | sed -e 's/-lpastix/-lpastix_murge -lpastix/g'`

echo $OPTS | grep \\\-DDISTRIBUTED >/dev/null

if [ $? -ne 0 ]
then
    LIBS_MURGE="To use Murge interface compile with -DDISTRIBUTED";
fi
    

usage="usage : $0 [options] - Shows PaStiX libs, includes and compiler\n";
usage="$usage\toptions : \n";
usage="$usage\t\t--libs\t\t       - prints librairies\n";
usage="$usage\t\t--libs_murge\t   - prints librairies\n";
usage="$usage\t\t--incs\t\t       - prints includes\n";
usage="$usage\t\t--cc\t\t         - prints C compiler\n";
usage="$usage\t\t--cl\t\t         - prints C linker\n";
usage="$usage\t\t--fc\t\t         - prints fortran compiler\n";
usage="$usage\t\t--fl\t\t         - prints fortran linker\n";
usage="$usage\t\t--opts\t\t       - prints PaStiX compiling options\n";
usage="$usage\t\t--vers\t\t       - prints PaStiX version\n";
usage="$usage\t\t--blas\t\t       - prints blas choosen in config.in\n";

if [ $# = 0 ]
then
    echo -n "Librairies            : " ;
    echo $LIBS;
    echo -n "Librairies with murge : ";
    echo $LIBS_MURGE
    echo -n "Incs                  : " ;
    echo $INC;		           
    echo -n "C Compiler            : " ;
    echo $CC;		           
    echo -n "Fortran Compiler      : " ;
    echo $FC;		           
    echo -n "C Linker              : " ;
    echo $CL;		           
    echo -n "Fortran Linker        : " ;
    echo $FL;		           
    echo -n "Options               : " ;
    echo $OPTS;		           
    echo -n "Version               : " ;
    echo $VERSION;	           
    echo -n "Blas                  : " ;
    echo $BLAS;
elif [ $# = 1 ]
then
    case $1 in
	--libs)
	    echo $LIBS;;
	--libs_murge)
	    echo $LIBS_MURGE;;
	--incs)
	    echo $INC;;
	--cc)
	    echo $CC;;
	--fc)
	    echo $FC;;
	--cl)
	    echo $CL;;
	--fl)
	    echo $FL;;	
	--opts)
	    echo $OPTS;;
	--blas)
	    echo $BLAS;;
	--vers) 
	    echo $VERSION;;

	*)
	    echo -e $usage
    esac;
else
    echo -e $usage
fi;
