#-----------------------------------------------------------------------
# This is the Makefile for the Adaptive Filtering Software.
#
# You use this file to build the software by typing "make". Before using it,
# make sure that the environment variable LIB_LEMUR is properly set
#-----------------------------------------------------------------------

#-- On any machine where LIB_LEMUR is properly set (e.g to /usr/local/lemur):
LEMUR=$(LIB_LEMUR)

#-----------------------------------------------------------------------
#-- If you want, you can specify the location of LEMUR directly instead
#-----------------------------------------------------------------------
# LEMUR=Source/C++/lemur
# LEMUR=/usr/local/lemur

# The C++ compiler. You should use g++ on most machines. If the
# default GCC 3 does not work right, you try to use g++2
# instead... 
CPP=g++
# CPP=g++2

# Compiler options
COPT = -O3 -g 
# COPT = -O3 -g -Wno-deprecated   -w
# COPT = -O0 -g -Wall

# Include directory
INC = -I$(LEMUR)/include -I../include

# Additional include directories on some MacOS machines:
# -I/usr/include/gcc/darwin/3.1/g++-v3 -I/usr/include/gcc/darwin/3.1/g++-v3/ext


# Libraries for Lemur 1.1 (which has a weird library layout)
# LS = $(LEMUR)/lib-split
# LIBS = $(LS)/libretrieval.a  $(LS)/liblangmod.a $(LS)/libindex.a $(LS)/libutility.a

# Libraries for Lemur 2.0 (Sep 2002):
LS = $(LEMUR)/lib
LIBS = $(LS)/liblemur.a

LINKOPT2 = -lm

# Directory where binaries can be installed
DESTBIN = /home/vmenkov/bin

# The list of C++ source files in the main directory. (Excludes
# main files of individual applications, because we don't want to
# link them all together!)
CPPSRC = $(shell  ls *.cpp 2> /dev/null)
UTIL_CPPSRC = $(shell  ls util/*.cpp 2> /dev/null)

# C++ objects
CPPOBJ = $(CPPSRC:.cpp=.o) 

#-------------------------------------------------------------

default: AdaptFilter

%.o : %.cpp
	$(CPP) $(COPT)  -c  $(INC)  $<   

# Source files for the "main program" of each application are compiled
# separately, because they are not included into CPPSRC

AdaptFilter.o : af/AdaptFilter.cpp
	$(CPP) $(COPT)  -c  $(INC)  $<   

Tani2.o : tanimoto/Tani2.cpp
	$(CPP) $(COPT)  -c  $(INC)  $<   

FindDup.o : util/FindDup.cpp
	$(CPP) $(COPT)  -c  $(INC)  $<   

ProjTest1.o : util/ProjTest1.cpp
	$(CPP) $(COPT)  -c  $(INC)  $<   


DescribeIndex.o : util/DescribeIndex.cpp
	$(CPP) $(COPT)  -c  $(INC)  $<   

Index2SVM.o : util/Index2SVM.cpp
	$(CPP) $(COPT)  -c  $(INC)  $<   

MkPrior.o : util/MkPrior.cpp
	$(CPP) $(COPT)  -c  $(INC)  $<   

MkDic.o : util/MkDic.cpp
	$(CPP) $(COPT)  -c  $(INC)  $<   


# Linking applications

AdaptFilter:  AdaptFilter.o $(CPPOBJ)
	$(CPP) $(COPT) -o $@ $(INC) $^ $(LIBS)

Tani2:  Tani2.o $(CPPOBJ)
	$(CPP) $(COPT) -o $@ $(INC) $^ $(LIBS)

FindDup:  FindDup.o $(CPPOBJ)
	$(CPP) $(COPT) -o $@ $(INC) $^ $(LIBS)

ProjTest1:  ProjTest1.o $(CPPOBJ)
	$(CPP) $(COPT) -o $@ $(INC) $^ $(LIBS)

ProjTest2:  ProjTest2.o $(CPPOBJ)
	$(CPP) $(COPT) -o $@ $(INC) $^ $(LIBS)

DescribeIndex:  DescribeIndex.o $(CPPOBJ)
	$(CPP) $(COPT) -o $@ $(INC) $^ $(LIBS)

Index2SVM:  Index2SVM.o $(CPPOBJ)
	$(CPP) $(COPT) -o $@ $(INC) $^ $(LIBS)

MkPrior:  MkPrior.o $(CPPOBJ)
	$(CPP) $(COPT) -o $@ $(INC) $^ $(LIBS)

MkDic:  MkDic.o $(CPPOBJ)
	$(CPP) $(COPT) -o $@ $(INC) $^ $(LIBS)


# Convenience target for quick testing in the development environment
$(DESTBIN)/AdaptFilter: AdaptFilter
	mv AdaptFilter $(DESTBIN)


install: AdaptFilter ProjTest1 Index2SVM
	cp AdaptFilter $(DESTBIN)
	cp ProjTest1 $(DESTBIN)
	cp Index2SVM $(DESTBIN)

#	cp ProjTest2 $(DESTBIN)

clean: 
	rm *.o 
	rm AdaptFilter
	rm ProjTest1
	rm Index2SVM
	rm MkPrior
