######################################################
#This make file was created by Micheal Nooner
#
#To make the library simply type make at the prompt
#
#To make tester for the library use "make test"
#
#  -The tester will be a file called test
#  -The tester will output the test results to a
#   file called "dump.txt"
#  -The line in this makefile that builds the tester
#   is approximately what you will need in order to
#   link to the library.
#
#To install this library use "make install"
#
#  -You may need to have super user permissions
#   in order to install this file, depending on
#   where you choose to install it.
#  -You can customize the output directory by
#   changing the $INSTLIB and $INSTHEAD variables'
#   value to the directory of your choosing.
#  -The library will be placed in $INSTLIB
#  -The header file will by placed in $INSTHEAD
#  -The documentation will be placed in $INSTDOC
#
#To clean up the object files use "make clean"
#
#To uninstall the library use "make uninstall"
#
######################################################

######################################################
#Begin Configuration Section

#Intall Directory for intblas.lib
INSTLIB	= /usr/lib/

#Install Directory for IntBLAS.h
INSTHEAD = /usr/include/

#Install Directory for the documentation
INSTDOC = /usr/share/doc/IntBLAS-1.0

#Delete this flag if you do not want debuging information
DEBUG = -g

#Delete flag if you wish to disable optimizations
OPT = -O3
#End Configuration Section
######################################################


######################################################
#Begin variables

OBJS  = interval_class.o interval_vector.o interval_matrix.o
OOBJS = opt_interval_class.o opt_interval_vector.o opt_interval_matrix.o

TFILES = ../test/test.cpp ../test/test_interval.cpp ../test/test_vector.cpp \
         ../test/test_matrix.cpp ../test/test_correctness.cpp
TOBJS  = test.o test_interval.o test_vector.o test_matrix.o test_correctness.o

#End variables
######################################################

######################################################
#Begin make targets

all :	intblas_d.lib

test:	all $(TOBJS) 
	g++ $(DEBUG) -B ../src -o test $(TOBJS) intblas_d.lib

install: intblas_d.lib intblas.lib
	@cp -f intblas_d.lib $(INSTLIB)
	@cp -f intblas.lib $(INSTLIB)
	@echo Installed Library: $(INSTLIB)intblas.lib
	@echo Installed Library: $(INSTLIB)intblas_d.lib
	@cp -f ../src/IntBLAS.h $(INSTHEAD)
	@echo Installed Header: $(INSTHEAD)IntBLAS.h
	@cp -fr ../doc $(INSTDOC)
	@echo Installed Documentation: $(INSTDOC)

uninstall:
	-rm -f $(INSTLIB)/intblas.lib
	-rm -f $(INSTLIB)/intblas_d.lib
	-rm -f $(INSTHEAD)/IntBLAS.h
	-rm -rf $(INSTDOC)

doc:
	@echo ######################################################
	@echo ######        Building Documentation            ######
	@echo ######################################################
	@cd ../src; doxygen ../Doxyfile

clean:
	-rm -f *.o
	-rm -f *.lib
	-rm -f test dump.txt
	-rm -f ../src/*~ ../test/*~ ../sample/*~ ../vs/*~

fresh: clean uninstall
	-rm -rf ../doc/html

#Run test application targets.
test-run:	test
	./test dump.txt

test-interval:	test
	./test -i dump.txt

test-vector:	test
	./test -v dump.txt

test-matrix:	test
	./test -m dump.txt

test-correct:	test
	./test -c dump.txt

#End make targets
######################################################

######################################################
#Begin file targets

#library files
interval_class.o : ../src/interval_class.cpp ../src/IntBLAS.h
	g++ $(DEBUG) -B ../src -c ../src/interval_class.cpp
interval_vector.o: ../src/interval_vector.cpp ../src/IntBLAS.h
	g++ $(DEBUG) -B ../src -c ../src/interval_vector.cpp
interval_matrix.o: ../src/interval_matrix.cpp ../src/IntBLAS.h
	g++ $(DEBUG) -B ../src -c ../src/interval_matrix.cpp

opt_interval_class.o : ../src/interval_class.cpp ../src/IntBLAS.h
	g++ $(OPT) -o opt_interval_class.o  -B ../src -c ../src/interval_class.cpp
opt_interval_vector.o: ../src/interval_vector.cpp ../src/IntBLAS.h
	g++ $(OPT) -o opt_interval_vector.o -B ../src -c ../src/interval_vector.cpp
opt_interval_matrix.o: ../src/interval_matrix.cpp ../src/IntBLAS.h
	g++ $(OPT) -o opt_interval_matrix.o -B ../src -c ../src/interval_matrix.cpp

intblas_d.lib: $(OBJS)
	ar ru intblas_d.lib $(OBJS)

intblas.lib: $(OOBJS)
	ar ru intblas.lib $(OOBJS)

#test files
test.o : ../test/test.cpp ../src/IntBLAS.h ../test/test.h
	g++ $(DEBUG) -B ../src -c ../test/test.cpp
test_interval.o: ../test/test_interval.cpp ../src/IntBLAS.h ../test/test.h
	g++ $(DEBUG) -B ../src -c ../test/test_interval.cpp
test_vector.o: ../test/test_vector.cpp ../src/IntBLAS.h ../test/test.h
	g++ $(DEBUG) -B ../src -c ../test/test_vector.cpp
test_matrix.o: ../test/test_matrix.cpp ../src/IntBLAS.h ../test/test.h
	g++ $(DEBUG) -B ../src -c ../test/test_matrix.cpp
test_correctness.o: ../test/test_correctness.cpp ../src/IntBLAS.h ../test/test.h
	g++ $(DEBUG) -B ../src -c ../test/test_correctness.cpp

#End file targets
######################################################

gmail: move zip unmove 

move:
	-mv ../vs/bin/install.bat ../vs/bin/install.batZ
	-mv ../vs/bin/uninstall.bat ../vs/bin/uninstall.batZ
	-mv ../vs/bin/var.bat ../vs/bin/var.batZ
zip: clean
	-rm ~/intblas.zip
	@cd ~; zip -r intblas.zip intblas/
unmove:
	@mv ../vs/bin/install.batZ ../vs/bin/install.bat
	@mv ../vs/bin/uninstall.batZ ../vs/bin/uninstall.bat
	@mv ../vs/bin/var.batZ ../vs/bin/var.bat
