# the makefile to compile the C++ module for use by python (as well as creating the relevant shadow class file)
# may need tweaking to make it work - mainly for webcam support, but locations of some files may differ.

CC = g++

# requires SWIG 1.3 (bham has 1.1 installed)
SWIG = swig
#SWIG = ../SWIG/swig -I../SWIG/Lib -I../SWIG/Lib/python

# location of python include files
#PY = /usr/include/python
PY = /usr/include/python2.2

RUNSWIG = $(SWIG) -c++ -python -shadow -o Project_wrap.c Project.i 
SWIGDEP = Image.h CVWindow.h RatioTemplate.h DataSet.h Detector.h

LIBS = -lopencv -lhighgui -lcvaux
#FLAGS = -O0 -g
#FLAGS = -pg #profile
FLAGS = -O3

# this will change depending on whether the PhilipsCamera class is available
#OBJS = Project_wrap.o Image.o rand-util.o CVWindow.o RatioTemplate.o DataSet.o Detector.o
OBJS = Project_wrap.o Image.o rand-util.o CVWindow.o RatioTemplate.o DataSet.o Detector.o Camera.o

# files needed for webcam support, leave empty if we do not want to include webcam support
#CAMERA = 
# local copies of file
#CAMERA = PhilipsCamera.cc ccvt_c1.cc
# when at uni with ROBOTICS support
CAMERA = $(ROBOTICS)/src/PhilipsCamera.cc $(ROBOTICS)/src/ccvt_c1.cc

LIBNAME = _Project.so # swig 1.3 name
#LIBNAME = Projectc.so # swig 1.1 name

all: $(LIBNAME) Project.py

$(LIBNAME): $(OBJS)
	$(CC) -Wall $(FLAGS) -shared $(LIBS) $(OBJS) -o $(LIBNAME) $(CAMERA)

Project_wrap.o: Project_wrap.c
	$(CC) -Wall $(FLAGS) -c -I$(PY)/Include -I$(PY) Project_wrap.c
	
Project_wrap.c: Project.i $(SWIGDEP)
	$(RUNSWIG)

Project.py: Project.i $(SWIGDEP)
	$(RUNSWIG)

Project.i: $(SWIGDEP)

Image.o: Image.h Image.cpp
	$(CC) -Wall $(FLAGS) -c Image.cpp

rand-util.o: rand-util.h rand-util.cpp
	$(CC) -Wall $(FLAGS) -c rand-util.cpp

CVWindow.o: CVWindow.h CVWindow.cpp
	$(CC) -Wall $(FLAGS) -c CVWindow.cpp

RatioTemplate.o: RatioTemplate.h RatioTemplate.cpp
	$(CC) -Wall $(FLAGS) -c RatioTemplate.cpp

DataSet.o: DataSet.h DataSet.cpp
	$(CC) -Wall $(FLAGS) -c DataSet.cpp

Detector.o: Detector.h Detector.cpp
	$(CC) -Wall $(FLAGS) -c Detector.cpp

Camera.o: Camera.h Camera.cpp
	$(CC) -Wall $(FLAGS) -c Camera.cpp

clean:
	rm -f $(TARGET) $(OBJS) Project.py Project_wrap.c
