#!/bin/bash
#
# compile and install the fstrack package, by default without tracking and using
# anisotropy stuff alone

compile_flow=${1-0}		# 0: only LPO/anisotropy tools 1: including flow tracker

if [ $compile_flow -eq 0 ];then
    mstring="all"
else
    mstring="really_all"
fi
    
#
# GNU compiler defaults, change if needed
#
export CC=gcc 
export CFLAGS="-O2"

# fortran 77 
export F77=`which gfortran`	# need to specify the full path
export FFLAGS="-ffixed-line-length-132 -x f77-cpp-input -O2" # allow pre-processor directives, and extend lines, just to be on the save side
export FFLAGS_DEBUG="-g -x f77-cpp-input"

# f90
export F90=$F77
export F90FLAGS="-O2 -x f95-cpp-input"
export F90FLAGS_DEBUG="-g -x f95-cpp-input"

export LDFLAGS="-lm"

# compile
echo
echo compiling eispack
echo
cd eispack
make 
cd ..		# eigen vector routines
echo
echo compiling DREX
echo
cd d-rex
make $mstring
cd ..		# DREX routines
cd fstrack
	cd single_layer; make ; cd .. # single layer splitting routines
	cd multi_layer ; make ; cd ..
make $mstring
cd ..
