##makefile to build shi program

##configure options to consider are:
##
##  -fomp           : this flag is also required for omp. If it doesn't work, try "-fopenmp" instead
##  -DMAX_MEM_BYTES : set this to some large number; if you find that your trajectory fragments are overflowing memory
##                    then it is possible to save states using memory over this value to disc instead.
##                    for most uses, you shouldn't have to worry about this.


_PARALLEL_FLAGS = -fopenmp

FLAGS    = -O4 -DFILES_HEX -Wall   

CC       = g++

OBJECTS  = clusters.o inout.o largestCluster.o main.o numberBuried.o ran2.o setup.o shi.o shiStats.o structureFactor.o

INCLUDES = shi.h ran2.h shiStats.h ../../spres/src/spres.h  

##order of appearance of libraries MATTERS, 
##if a function from a lib is not called by 
##one included before it, then it will not be linked.
MYLIBS = ../../spres/lib/libspres.a   

##../../gsl/eigen/.libs/libgsleigen.a ../../gsl/.libs/libgsl.a ../../gsl/cblas/.libs/libgslcblas.a 

shi.exe: spres $(OBJECTS)
	$(CC) $(FLAGS) $(PARALLEL_FLAGS) $(OBJECTS) $(MYLIBS) -lm -o shi.exe


# -----------------:q:--------
#
spres:
	$(MAKE) -C ../../spres/src spres

%.o: %.C $(INCLUDES)
	$(CC) $(FLAGS) -c $< -o $@   

doc:
	mkdir -p ../docs 
	doxygen ../docs/doxygen.conf
	$(MAKE) -C ../docs/latex

clean: 
	$(MAKE) -C ../../spres/src clean
	rm -f *.o *~ \#* ../test/log  ../test/shortTest.log ../test/shortTest.etj

clobber: clean
	$(MAKE) -C ../../spres/src clobber
	rm -Rf ../docs/html/* ../docs/latex/* ../docs/*~ ../docs/\#* shi.exe 
	rm -f ../lib/*.a


