#
.SUFFIXES:
#
.SUFFIXES: .cpp .o .c .h
#
#

VPATH = ../lemurcore:../parser

DEBUGFLAGS =  -g3 -Wall -I../ #-O2

RELEASEFLAGS = -O3 -Wall -I../  -DNDEBUG

HEADERS = functional.h  graphs.h  holaputil.h  normalizationscommon.h  normalizations.h  normalutil.h  permutationutil.h pearsonnormalization.h  slicesortingnormalization.h perlc-interface.h greedyfrequencysort.h multinormalizations.h matching.h cubestatistics.h pngimage.h

%.o : %.cpp %.h $(HEADERS)
	g++ -c $(DEBUGFLAGS)  $< 


all: normalizer tags TAGS

release: main.o graphs.o $(HEADERS) # fast version, not recommended
	g++ $(RELEASEFLAGS) -o profile main.o graphs.o ../lemurcore/lemurcore.a  

profile: main.o graphs.o $(HEADERS) # profiler
	g++ $(DEBUGFLAGS) -o profile main.o graphs.o ../lemurcore/lemurcore.a -pg 

small : testsonsmallcubes.cpp graphs.o $(HEADERS) perfectnormalization.h
	g++ $(DEBUGFLAGS) -o small  testsonsmallcubes.cpp graphs.o  ../lemurcore/lemurcore.a -lpng

small3 : testsonsmall3dcubes.cpp graphs.o $(HEADERS) perfectnormalization.h 
	g++ $(DEBUGFLAGS) -o small3  testsonsmall3dcubes.cpp graphs.o  ../lemurcore/lemurcore.a -lpng

#emacs-style tags	
TAGS:	$(HEADERS) main.cpp graphs.cpp
	rm -f TAGS
	find .. \( -name "*.cc" -o -name "*.cpp" -o -name "*.h" -o -name "*.c" \) -print | xargs etags -aR
	# find /usr/include/g++-3 -type f | xargs etags -aR 

tags: 
	rm -f tags
	ls ../* -1d | xargs ctags -aR
	ctags -aR /usr/include/g++-3/*

main.o : main.cpp datacube.h chunkeddatacube.h pyrps.h OwenParser.h $(HEADERS) makefile
	cd ../lemurcore; make
	g++ $(DEBUGFLAGS) -c main.cpp -I../ 

pngimage.o : pngimage.cpp pngimage.h
	g++ $(DEBUGFLAGS) -c pngimage.cpp 

normalizer: main.o graphs.o pngimage.o $(HEADERS)
	g++ $(DEBUGFLAGS )-o normalizer main.o graphs.o pngimage.o ../lemurcore/lemurcore.a -lpng 


.PHONY : clean tags 


clean :
	rm -f *.o
	rm -f normalizer
	rm -f *.a
	rm -f *Temp*.bin
	rm -f tags
	rm -f sanity*.bin
	rm -f profile
	rm -f small
