LINKOPT2 = -lm -L.
CompilerParam = -O3 -felide-constructors -funroll-loops -Wall
RLANG=/usr/lib/R

#LIBS=$(RLANG)/include/Rmath.h

# C++ source files
CPPSRC = $(shell  ls *.cpp 2> /dev/null)
CPPSRC1= $(shell  ls kNNcompute.cpp 2> /dev/null)
CPPSRC2= $(shell  ls makeTests.cpp 2> /dev/null)
CPPSRC3= $(shell  ls kNNclassify.cpp 2> /dev/null)
CPPSRC4= $(shell  ls InvertedModels.cpp 2> /dev/null)

# C++ objects
CPPOBJ = $(CPPSRC:.cpp=.o)
CPPOBJ1= $(CPPSRC1:.cpp=.o)
CPPOBJ2= $(CPPSRC2:.cpp=.o)
CPPOBJ3= $(CPPSRC3:.cpp=.o)
CPPOBJ4= $(CPPSRC4:.cpp=.o)


%.o : %.cpp
	g++ $(CompilerParam) -c $(CPPSRC) 


kNNcompute: kNNcompute.o LabelledVector.h readUtils.h
	  g++ $(CompilerParam) -o $@ $(LINKOPT2) kNNcompute.o LabelledVector.o

makeTests: makeTests.o LabelledVector.h readUtils.h
	  g++ $(CompilerParam) -o $@ $(LINKOPT2) makeTests.o LabelledVector.o

kNNclassify: kNNclassify.o LabelledVector.h readUtils.h
	  g++ $(CompilerParam) -o $@ $(LINKOPT2) kNNclassify.o LabelledVector.o

InvertedModels: InvertedModels.o 
	  g++ $(CompilerParam) -o $@ $(LINKOPT2) InvertedModels.o 

all: kNNcompute makeTests kNNclassify InvertedModels

.PHONY: all

clean: 
	rm -f *.o 
	rm -f kNNcompute
	rm -f makeTests
	rm -f kNNclassify
	rm -f InvertedModels
