########## Makefile - makefile for diver tracking  ##########

# compiler
#CC = ../ccmalloc-0.3.9/bin/ccmalloc g++
CC = g++

# flags
CFLAGS = -g -Wall -Wno-unused

# Definition of directories

PROJECTDIR = /afs/ir.stanford.edu/users/b/i/billyc/WWW/cs223b/project/code

CVINCDIR = $(PROJECTDIR)/include
CVLIBDIR = $(PROJECTDIR)/lib

LIBS = -L$(CVLIBDIR)
INCLS= -I$(CVINCDIR)

# Definition of libraries

MYLIBS=
CVLIBS=		-lopencv -lhighgui -lipla6 -liplm6 -liplpx
SYSLIBS=	-ltiff

# Definition of source files

CFILES=		\
		mytiff.c
# Compilation rule

all: mytiff.o motionflow.o leastsquare.o synch.o testmotionflow testmytiff testsynch mask.o

all-tests: test-motionflow test-mytiff

mytiff.o: 	mytiff.c
	$(CC) -c $(CFLAGS) $(INCLS) mytiff.c

motionflow.o:	motionflow.c motionflow.h
	$(CC) -c $(CFLAGS) $(INCLS) $(INCLDIR) motionflow.c

testmotionflowtrack.o: motionflow.c motionflow.h
	$(CC) $(CFLAGS) $(INCLS) $(INCLDIR) -o testmotionflowtrack.o -c -DLESLIE motionflow.c

synch.o: synch.h synch.c motionflow.h leastsquare.h synch_centroid.c synch_gvector.c synch_cardboard.c synch_constants.h mask.h synch_util.c
	$(CC) -c $(CFLAGS) $(INCLS) $(INCLDIR) synch.c -O2

mask.o: constants.h mask.h mask.c synch_constants.h
	$(CC) -c $(CFLAGS) $(INCLS) $(INCLDIR) mask.c -O2

leastsquare.o: leastsquare.h leastsquare.c
	$(CC) -c $(CFLAGS) $(INCLS) $(INCLDIR) leastsquare.c

tracker.o: tracker.c tracker.h
	$(CC) -c $(CFLAGS) $(INCLS) $(INCLDIR) tracker.c

filter.o: filter.c filter.h
	$(CC) -c $(CFLAGS) $(INCLS) $(INCLDIR) filter.c

# Linking rule (none yet)

clean: 
	rm -f mytiff.o synch.o leastsquare.o motionflow.o filter.o \
testmytiff testsynch core mask.o testmotionflowtrack.o tracker.o *~

# various tests for each module

testmotionflow:	motionflow.c motionflow.h mytiff.o mytypes.h tracker.o 
	$(CC) -o testmotionflow mytiff.o tracker.o -DTESTMFLOW motionflow.c $(INCLS) $(INCLDIR) $(LIBS) $(SYSLIBS) $(CVLIBS) $(CFLAGS)

testmotionflowtrack:	motionflow.c motionflow.h mytiff.o mytypes.h \
testtracker.c testmotionflowtrack.o tracker.o
	$(CC) -o testmotionflowtrack testtracker.c mytiff.o \
testmotionflowtrack.o tracker.o $(INCLS) $(INCLDIR) $(LIBS) $(SYSLIBS) $(CVLIBS) $(CFLAGS)

testmytiff:	mytiff.c
	$(CC) -o testmytiff -DTESTTIFF mytiff.c $(LIBS) $(INCLS) $(SYSLIBS) $(CVLIBS) $(CFLAGS) $(INCLDIR)

testsynch:	testsynch.c synch.o leastsquare.o motionflow.o mytiff.o tracker.o mask.o
	$(CC) -o testsynch testsynch.c mytiff.o leastsquare.o synch.o motionflow.o tracker.o mask.o $(LIBS) $(INCLS) $(SYSLIBS) $(CVLIBS) $(CFLAGS)
