SRC=./src
INCLUDE=./include
LCLLIB=./lib
BIN=./bin
cc=gcc
Cplus=g++
AR=ar

libraries:
	$(cc) -c $(SRC)/matrixSHENCLASSIC.c -I $(INCLUDE) -o $(SRC)/matrixSHEN_CLASSIC.o
	$(cc) -c $(SRC)/xzdgshennewCLASSIC.c -I $(INCLUDE) -o $(SRC)/xzdgshennewCLASSIC.o 
	$(AR) -r $(LCLLIB)/libmatrixSHEN_CLASSIC.a $(SRC)/matrixSHEN_CLASSIC.o $(SRC)/xzdgshennewCLASSIC.o

	$(cc) -c $(SRC)/matrixSHENdgtools.c -I $(INCLUDE) -o $(SRC)/matrixSHEN_dgtools.o
	$(AR) -rv $(LCLLIB)/libmatrixSHEN_dgtools.a $(SRC)/matrixSHEN_dgtools.o

	$(cc) -c $(SRC)/mvcddgtools.c -I $(INCLUDE) -o $(SRC)/mvcd_dgtools.o
	$(AR) -rv $(LCLLIB)/libmvcd_dgtools.a $(SRC)/mvcd_dgtools.o

	$(Cplus) -c $(SRC)/matrixSHENDRTG.cpp -I $(INCLUDE) -o $(SRC)/matrixSHEN_DTIRegistrationTensorGeometry.o
	$(AR) -rv $(LCLLIB)/libmatrixSHEN_DTIRegistrationTensorGeometry.a $(SRC)/matrixSHEN_DTIRegistrationTensorGeometry.o

	$(Cplus) -c $(SRC)/mvcdDRTG.cpp -I $(INCLUDE) -o $(SRC)/mvcd_DTIRegistrationTensorGeometry.o
	$(AR) -rv $(LCLLIB)/libmvcd_DTIRegistrationTensorGeometry.a $(SRC)/mvcd_DTIRegistrationTensorGeometry.o 


all:libraries
	#Making combinetwodeformationfield
	$(cc) -Wall -I $(INCLUDE) -c $(SRC)/combine_two_deformationfields.c -o $(SRC)/combine_two_deformationfields.o
	#The name of the executable has to be changed here in the orignal program
	#This has to be combinetwodeformationfields
	$(cc) -Wall -o $(BIN)/combinetwodeformationfields  $(SRC)/combine_two_deformationfields.o  -L$(LCLLIB) -lmatrixSHEN_CLASSIC -lm
	#-------------------Done----------------------------------#

	#Making FloatFA2Byte
	$(Cplus) -O2 -I $(INCLUDE) -c $(SRC)/FloatFA2Byte.cpp -o $(SRC)/FloatFA2Byte.o
	$(Cplus)  -O2 -o $(BIN)/FloatFA2Byte -I ./$(INCLUDE)  $(SRC)/FloatFA2Byte.o   -L $(LCLLIB) -lgsl -lgslcblas -lm
	#-------------------Done----------------------------------#

	#Making reversedeformationfield
	$(cc) -I $(INCLUDE) -c $(SRC)/ReverseDeformationField.c -lm -o $(SRC)/ReverseDeformationField.o
	$(cc) -O2 -g -o $(BIN)/reversedeformationfield $(SRC)/ReverseDeformationField.o  -L$(LCLLIB) -lmatrixSHEN_dgtools -lmvcd_dgtools -lm
	#-------------------Done----------------------------------#

	#Making TensorStructRegistration -V2.0
	$(Cplus) -c $(SRC)/RGBAcolorMap.cpp -O2 -I $(INCLUDE) -o $(SRC)/RGBAcolorMap.o 
	$(Cplus) -c $(SRC)/TensorField.cpp -O2 -I $(INCLUDE) -o $(SRC)/TensorField.o
	$(Cplus) -c $(SRC)/TensorStruct-Registration-V2.cpp -O2 -I $(INCLUDE) -o $(SRC)/TensorStruct-Registration-V2.o
	$(Cplus) -o $(BIN)/TensorStructRegistration-V2.0  $(SRC)/TensorStruct-Registration-V2.o $(SRC)/TensorField.o $(SRC)/RGBAcolorMap.o -O2  -L$(LCLLIB) -lgsl -lgslcblas -lmvcd_DTIRegistrationTensorGeometry -lmatrixSHEN_DTIRegistrationTensorGeometry -lm
	mv -f $(BIN)/TensorStructRegistration-V2.0 $(BIN)/LinuxTensorStructRegistration_V2.0
	#-------------------Done----------------------------------#
	#Make dtiFA dtiPD dtiTrace PDcolor Map hammer2xdr xdr2hammer
	$(Cplus) -O2 -I $(INCLUDE) -c $(SRC)/Fields.cpp -o $(SRC)/Fields.o 
	$(Cplus) -O2 -I $(INCLUDE) -c $(SRC)/dtiFA.cpp -o $(SRC)/dtiFA.o
	$(Cplus) -O2 -I $(INCLUDE) -c $(SRC)/dtiPD.cpp -o $(SRC)/dtiPD.o
	$(Cplus) -O2 -I $(INCLUDE) -c $(SRC)/dtiTrace.cpp -o $(SRC)/dtiTrace.o
	$(Cplus) -O2 -o $(BIN)/dtiFA -I $(INCLUDE) $(SRC)/dtiFA.o $(SRC)/Fields.o  -L$(LCLLIB) -lgsl -lgslcblas -lm
	$(Cplus) -O2 -o $(BIN)/dtiPD -I $(INCLUDE) $(SRC)/dtiPD.o $(SRC)/Fields.o  -L$(LCLLIB) -lgsl -lgslcblas -lm
	$(Cplus) -O2 -o $(BIN)/dtiTrace -I $(INCLUDE) $(SRC)/dtiTrace.o $(SRC)/Fields.o  -L$(LCLLIB) -lgsl -lgslcblas -lm
	$(Cplus) -O2 -I $(INCLUDE) -c $(SRC)/RGBAcolorMapDT.cpp -o $(SRC)/RGBAcolorMapDT.o
	$(Cplus) -O2 -I $(INCLUDE) -c $(SRC)/PDcolorMap.cpp -o $(SRC)/PDcolorMap.o
	$(Cplus) -O2 -o $(BIN)/PDcolorMap -I $(INCLUDE) $(SRC)/PDcolorMap.o $(SRC)/RGBAcolorMapDT.o $(SRC)/Fields.o  -L$(LCLLIB) -lgsl -lgslcblas -lm
	$(Cplus) $(SRC)/hammer2xdr.cpp -o $(BIN)/hammer2xdr
	$(Cplus) $(SRC)/xdr2hammer.cpp -o $(BIN)/xdr2hammer
	#---------------Done---------------------------------#

	#Making warpDT.V5 and LnWarpDT	
	$(Cplus) -c $(SRC)/DTVolume.C -I$(INCLUDE)  -O2  -o $(SRC)/DTVolume.o
	$(Cplus) -c $(SRC)/VoxMap.C -I$(INCLUDE)  -O2 -o $(SRC)/VoxMap.o
	$(Cplus) -c $(SRC)/nWarpDTV5.C -I$(INCLUDE)  -O2 -o $(SRC)/nWarpDTV5.o
	$(Cplus) -c $(SRC)/Basics.C -I$(INCLUDE)  -O2 -o $(SRC)/Basics.o
	$(Cplus) -c $(SRC)/WarpVolume.C -I$(INCLUDE)  -O2 -o $(SRC)/WarpVolume.o
	$(Cplus) -c $(SRC)/ImgVol.C -I$(INCLUDE)  -O2 -o $(SRC)/ImgVol.o
	$(Cplus) -c $(SRC)/nrutil.C -I$(INCLUDE)  -O2 -o $(SRC)/nrutil.o
	$(Cplus) -c $(SRC)/svdcmp.C -I$(INCLUDE)  -O2 -o $(SRC)/svdcmp.o
	$(Cplus) -c $(SRC)/mVolume.C -I$(INCLUDE)  -O2 -o $(SRC)/mVolume.o
	$(Cplus) -c $(SRC)/GPrimitive.C -I$(INCLUDE)  -O2 -o $(SRC)/GPrimitive.o
	$(Cplus) -c $(SRC)/eig.C -I$(INCLUDE)  -O2 -o $(SRC)/eig.o
	$(Cplus) -c $(SRC)/Ellipsoid.C -I$(INCLUDE)  -O2 -o $(SRC)/Ellipsoid.o 
	$(Cplus) -c $(SRC)/Utilities.C -I$(INCLUDE)  -O2 -o $(SRC)/Utilities.o
	$(Cplus) -o $(BIN)/warpDT.V5 $(SRC)/nWarpDTV5.o $(SRC)/WarpVolume.o $(SRC)/DTVolume.o $(SRC)/ImgVol.o $(SRC)/svdcmp.o $(SRC)/VoxMap.o $(SRC)/mVolume.o $(SRC)/Basics.o $(SRC)/GPrimitive.o $(SRC)/nrutil.o $(SRC)/eig.o $(SRC)/Ellipsoid.o $(SRC)/Utilities.o   -lm -O2
	$(Cplus) -c $(SRC)/LnWarpDT.C -I$(INCLUDE)  -O2 -o $(SRC)/LnWarpDT.o
	$(Cplus) -o $(BIN)/LnWarpDT $(SRC)/LnWarpDT.o $(SRC)/WarpVolume.o $(SRC)/DTVolume.o $(SRC)/ImgVol.o $(SRC)/svdcmp.o $(SRC)/VoxMap.o $(SRC)/mVolume.o $(SRC)/Basics.o $(SRC)/GPrimitive.o $(SRC)/nrutil.o $(SRC)/eig.o $(SRC)/Ellipsoid.o $(SRC)/Utilities.o   -lm -O2	
clean:
	rm -rf $(SRC)/*.o $(LCLLIB)/*.a $(BIN)/*
