######################################################
#This make file was created by Micheal Nooner
#
#This file is meant to be run by the installer batch
#file. To install the the library and documentation
#run the install.bat file in the bin directory.
#Similiarly you should uninstall the library using
#the unistall.bat file in the bin directory. You may
#need to adjust the path found in vars.bat if your
#Visual Studio installation is in a non-standard place.
#
#Use the information below if you wish to make the
#project without using the batch file.
#
#To make the library simply type make at the prompt
#
#  -The documentation for this project needs to be
#   compiled by Doxygen if you do not have
#   this program then do not run 'make doc'
# 
#To make tester for the library use "make test"
#
#  -The tester will be a file called main
#  -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 can turn debuging off by removing the
#   value from the DEBUG variable.
#
#To uninstall the library use "make uninstall"
#
######################################################

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

#Delete these flags if you do not want debuging information
DEBUG = /Zi /Yd

#These flags perform optimizations, remove them for a 
#smaller executable
OPT = /Ox

#End Configuration Section
######################################################


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

#Intall Directory for intblas.lib
INSTLIB	= "%MSVCDir%\lib"

#Install Directory for IntBLAS.h
INSTHEAD = "%MSVCDir%\include"

#Install Directory for the documentation
INSTDOC = "%MSVCDir%\IntBLAS-1.0"

CPPOP  = /EHsc /nologo /c

CPP = $(INSTDOC)\src\interval_class.cpp \
      $(INSTDOC)\src\interval_vector.cpp \
      $(INSTDOC)\src\interval_matrix.cpp

OBJS   = interval_class.obj interval_vector.obj interval_matrix.obj

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

TOBJS  = test.obj test_interval.obj test_vector.obj test_matrix.obj test_correctness.obj

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

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

all : build
	
build: $(OBJS) 
	
test :	intblas.lib $(TOBJS)
	link /nologo /OUT:test.exe $(TOBJS) intblas.lib

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

install:	
	copy /Y intblas_d.lib $(INSTLIB)
	copy /Y intblas.lib $(INSTLIB)
	copy /Y intblas.pdb $(INSTLIB)
	copy /Y ..\src\IntBLAS.h $(INSTHEAD)
	IF NOT EXIST $(INSTDOC)\html mkdir $(INSTDOC)\html
	copy /Y ..\doc\* $(INSTDOC)
	copy /Y test.exe $(INSTDOC)
	copy /Y Makefile $(INSTDOC)
	copy /Y bin\uninstall.bat $(INSTDOC)
	copy /Y bin\var.bat $(INSTDOC)
	copy /Y ..\doc\html\* $(INSTDOC)\html

doc:
	echo ######################################################
	echo ######        Building Documentation            ######
	echo ######################################################
	cd ..\src
	doxygen ..\Doxyfile

clean:
	del /F /Q *.obj
	del /F /Q *.pdb
	del /F /Q *.lib
	del /F /Q test.exe

uninstall:
	del /F /Q $(INSTLIB)\intblas.lib
	del /F /Q $(INSTLIB)\intblas_d.lib
	del /F /Q $(INSTLIB)\intblas.pdb
	del /F /Q $(INSTHEAD)\IntBLAS.h
	cd ..
	rmdir /Q /S $(INSTDOC)

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

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

#library files
$(OBJS):
	IF NOT EXIST $(INSTDOC)\src mkdir $(INSTDOC)\src
	copy ..\src $(INSTDOC)\src
	cl $(CPPOP) $(DEBUG) /Fdintblas.pdb $(CPP)
	lib /nologo /OUT:intblas_d.lib $(OBJS)
	
	cl $(CPPOP) $(OPT) $(CPP)
	lib /nologo /OUT:intblas.lib $(OBJS)

#test files
$(TOBJS) : $(TFILES) ..\src\IntBLAS.h
	cl $(CPPOP) $(DEBUG) $(TFILES)

intblas.lib:    build
	
#End file targets
######################################################
