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


MODULES := 

CC := g++
# CC = g++-3.2

DEF :=
BIN := bin

INCLUDES :=

CCFLAGS := -DPLATFORM_LINUX -DVIS_NO_LIBS -Wall -Wstrict-prototypes $(INCLUDES)
#CCFLAGS += -O2 -ffast-math -march=pentium
CCFLAGS += -g
# CCFLAGS += -pg

# Each module will add to this
ALL_SRCS :=
ALL_TARGETS :=

all: all_real

# Include the description for each module
#include $(patsubst %,%/Makefile.sub,$(MODULES))

GEN_HS :=
DEP_PROCESS := dep_process

#==== mot_cal =========================================================#

SRCS := \
	motion_calibrate.cc \

MOTCAL_LFLAGS := -lgsl -lgslcblas

MOTCAL_OBJS := $(SRCS:.cc=.o)

TARGET := mot_cal

ALL_TARGETS += $(TARGET)
ALL_SRCS += $(SRCS)

$(TARGET): $(MOTCAL_OBJS)
	$(CC) -o $@ $(CCFLAGS) $^ $(MOTCAL_LFLAGS)

#==== vis_cal =========================================================#

SRCS := \
	vision_calibrate.cc \
	../log_processing/shared/LogReader.cc \
	../log_processing/shared/PacketDecoder.cc \
	../log_processing/shared/VisionRawPacketDecoder.cc \
	../shared/image.cc \
	../../agent/Main/Events.cc \
	../../agent/Motion/Kinematics.cc \
	../../agent/Vision/BWBallDetector.cc \
	../../agent/Vision/DetectBall.cc \
	../../agent/Vision/Radial.cc \
	../../agent/Vision/Vision.cc \
	../../agent/shared_code/CircBufPacket.cc \
	../../agent/shared_code/Dictionary.cc \
	../../agent/shared_code/FileSystem.cc \
	../../agent/shared_code/random.cc \

VISCAL_LFLAGS := \
	-lMagick++ \
	-lMagick \

VISCAL_OBJS := $(SRCS:.cc=.o)

TARGET := vis_cal

ALL_TARGETS += $(TARGET)
ALL_SRCS += $(SRCS)

$(TARGET): $(VISCAL_OBJS)
	$(CC) -o $@ $(CCFLAGS) $^ $(VISCAL_LFLAGS)

#==== General makefile stuff ==========================================#

# Determine the object files
ALL_OBJS := \
        $(patsubst %.cc,%.o,$(filter %.cc,$(ALL_SRCS))) \
        $(patsubst %.c,%.o,$(filter %.c,$(ALL_SRCS)))

ALL_DEPENDS := $(ALL_SRCS:%.cc=%.d)

# Include the dependencies
include $(ALL_DEPENDS)

.SUFFIXES:

%.o: %.cc
	$(CC) $(CCFLAGS) $(DEF) $(INC) -c $< -o $@

# Calculate dependencies
%.d: %.cc $(GEN_HS)
	$(CXX) -M $(CCFLAGS) $< >$@.tmp
	$(DEP_PROCESS) $@.tmp $(basename $@).o $(GEN_HS) >$@
	rm $@.tmp

all_real: $(ALL_TARGETS)
	@for t in $(ALL_TARGETS); do\
		(cd ../bin;\rm -rf $$t;ln -s ../calibrate/$$t);\
	done

clean:
	rm -f $(ALL_OBJS)
	rm -f $(ALL_TARGETS)
	rm -f $(ALL_DEPENDS)
	(cd ../bin;rm -f $(ALL_TARGETS))

dep: depend

depend:
	rm -f $(ALL_DEPENDS)
