BASEDIR = $(shell cat ../../.BASEDIR)
include $(BASEDIR)/rules.mk

INCLUDES  += -I../../src

LDFLAGS   += -L../../src/.libs -lvitooki-base -lvitooki-adaptors 
LDFLAGS   += -lvitooki-cache -lvitooki-container -lvitooki-io
LDFLAGS   += -lvitooki-metadata -lvitooki-net

OBJECTS=RequestIterator.o \
	UserPrefGenerator.o \
	bm.o \
	bmjob.o \
	bmjoblist.o \
	UPContainer.o \
	muvimark.o

all: muvimark.o RequestIterator.o UserPrefGenerator.o bm.o bmjob.o bmjoblist.o UPContainer.o muvimark jl_interface2 upgui

muvimark.o: muvimark.cpp
	 @(mkdir .obj .moc .ui || echo "")
	@(echo -en "compiling muvimark.cpp... \E[33;31m" && ($(CPP) $(CPPFLAGS) $(INCLUDES) -c muvimark.cpp ) > /dev/null && echo -en "\E[33;32mOK\n\E[33;0m") ;

RequestIterator.o: RequestIterator.cpp RequestIterator.hpp UserPrefGenerator.hpp utils.hpp markglobal.hpp
	@(echo -en "compiling RequestIterator.cpp... \E[33;31m" && ($(CPP) $(CPPFLAGS) $(INCLUDES) -c RequestIterator.cpp ) > /dev/null && echo -en "\E[33;32mOK\n\E[33;0m") ;

UserPrefGenerator.o: ../../src/metadata/UserPreferences.hpp ../../src/metadata/UserPreferences.cpp UserPrefGenerator.hpp UserPrefGenerator.cpp
	@(echo -en "compiling UserPrefGenerator.cpp... \E[33;31m" && ($(CPP) $(CPPFLAGS) $(INCLUDES) -c UserPrefGenerator.cpp ) > /dev/null && echo -en "\E[33;32mOK\n\E[33;0m") ;

bm.o: bm.cpp bm.hpp
	@(echo -en "compiling bm.cpp... \E[33;31m" && ($(CXX) $(CPPFLAGS) $(INCLUDES) -c bm.cpp ) > /dev/null && echo -en "\E[33;32mOK\n\E[33;0m") ;

bmjob.o: bmjob.cpp bmjob.hpp
	@(echo -en "compiling bmjob.cpp... \E[33;31m" && ($(CXX) $(CPPFLAGS) $(INCLUDES) -c bmjob.cpp ) > /dev/null && echo -en "\E[33;32mOK\n\E[33;0m") ;

bmjoblist.o: bmjoblist.cpp bmjoblist.hpp bmjob.cpp bmjob.hpp
	@(echo -en "compiling bmjoblist.cpp... \E[33;31m" && ($(CXX) $(CPPFLAGS) $(INCLUDES) -c bmjoblist.cpp ) > /dev/null && echo -en "\E[33;32mOK\n\E[33;0m") ;

UPContainer.o: UPContainer.cpp UPContainer.hpp
	@(echo -en "compiling UPContainer... \E[33;31m" && ($(CXX) $(CPPFLAGS) $(INCLUDES) -c UPContainer.cpp ) > /dev/null && echo -en "\E[33;32mOK\n\E[33;0m") ;

muvimark: $(OBJECTS)
	$(CPP) -g $(LDFLAGS) -o muvimark $(LIBS) *.o

JobListCreator.o: JobListCreator.cpp JobListCreator.hpp
	$(CPP) $(CPPFLAGS) $(INCLUDES) -c JobListCreator.cpp

JobListCreator-main.o: JobListCreator-main.cpp
	$(CPP) $(CPPFLAGS) $(INCLUDES) -c -o JobListCreator-main.o JobListCreator-main.cpp

jlc: JobListCreator.o JobListCreator-main.o
	$(CPP) $(SORDLIB) -g $(LDFLAGS) -o jlc JobListCreator.o JobListCreator-main.o

plotgenerator: PFGenerator.cpp
	$(CPP) $(SORDLIB) -g $(CPPFLAGS) $(INCLUDES) -o plotgenerator PFGenerator.cpp

jl_interface2:
	make -f Makefile.jl2

upgui: UPContainer.o upgui.ui upgui.ui.h
	make -f upgui.mk

install: muvimark
	@(echo "Nothing to install yet")

clean:
	rm -f muvimark upgui cg_interface *.o
	make -f Makefile.jl2 clean

