# /* LICENSE:
#   =========================================================================
#     CMPack'03 Source Code Release for OPEN-R SDK v1.0
#     Copyright (C) 2003 Multirobot Lab [Project Head: Manuela Veloso]
#     School of Computer Science, Carnegie Mellon University
#     All rights reserved.
#   ========================================================================= */

C++ := g++

IFLAGS := -I../..

LIBS := 

LFLAGS := `fltk-config --ldflags` -L/usr/X11R6/lib -lX11 -lMagick++ -lMagick

# -Wshadow  -Woverloaded-virtual
#OPT := -O2
DEBUG := -g #-DKALMAN_DEBUG
#PROFILE :=-pg
CFLAGS := $(DEBUG) $(OPT) $(PROFILE) `fltk-config --cxxflags` -march=pentium -ffast-math -DPLATFORM_LINUX -DVIS_NO_LIBS -Wall -Wstrict-prototypes $(IFLAGS)

SRCS := \
	TrackerTest.cc \
	../../agent/shared_code/Gaussian2.cc \
	../../agent/shared_code/kalman.cc \
	../../agent/shared_code/matrix.cc \
	../../agent/WorldModel/BallTracker.cc \
	../../agent/WorldModel/BallKFPos.cc \
	../../agent/WorldModel/MultiBallKFPos.cc

OBJS := $(SRCS:.cc=.o)
OBJS_PROF := $(SRCS:.cc=_prof.o)

DEPENDS := $(SRCS:%.cc=%.dep)

TARGET := tracker_test
TARGET_PROF := tracker_test_prof

$(TARGET_PROF) : CFLAGS := $(CFLAGS_PROFILE)
$(OBJS_PROF) : CFLAGS := $(CFLAGS_PROFILE)

all: $(TARGET)
	(cd ../bin; \rm -rf $(TARGET);ln -s ../tracker_test/$(TARGET))

profile: $(TARGET_PROF)

$(TARGET): $(OBJS) $(LIBS)
	$(C++) -o $@ $(CFLAGS) $^ $(LFLAGS)

$(TARGET_PROF): $(OBJS_PROF) $(LIBS)
	$(C++) -o $@ $(CFLAGS) $^ $(LFLAGS)

clean:
	rm -f $(OBJS)
	rm -f $(TARGET)
	rm -f $(DEPENDS)
	rm -f ../bin/$(TARGET)

dep: depend

depend:
	rm -f $(DEPENDS)

include $(DEPENDS)

%.o: %.cc
	$(C++) -c -o $@ $< $(CFLAGS)

%_prof.o: %.cc
	$(C++) -c -o $@ $< $(CFLAGS)

%.dep: %.cc
	$(C++) -M $(CFLAGS) $< > $@.tmp
	echo -n "$@ $(<:.cc=_prof.o) " >$@
	perl -pe 's&$(<F:.cc=.o)&$(<:.cc=.o)&' $@.tmp >>$@
	rm $@.tmp
