#########################################################################
#/* 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.
#  ========================================================================= */
#########################################################################

CC = g++
CFLAGS = -DPLATFORM_LINUX -march=pentium -ffast-math -Wall
# takes _much_ longer if you turn this on and genmot is fast anyway
#CFLAGS += -O2
CFLAGS += -g
# CFLAGS += -pg

MSOURCES = \
	../Kinematics.cc \
	../Motion.cc \
	../MotionFile.cc \
	../Sound.cc \
	../../shared_code/FileSystem.cc \
	../../shared_code/CircBufPacket.cc \

TARGET = genmot
SOURCES = $(MSOURCES) \
	genmisc.cc \
	genmot.cc \
	genkicks.cc \
	genkicks_ers7.cc \
	genkicks_de.cc \
	genkicks_unsw.cc \
	genwalk.cc \


OBJ = $(SOURCES:%.cc=%.o)
DEPS := $(SOURCES:%.cc=%.dep)
DEPENDS := $(join $(dir $(DEPS)),$(addprefix .,$(notdir $(DEPS))))
#DEPENDS := $(addprefix .,$(notdir $(DEPS)))
LIB = -L/usr/X11R6/lib -lX11 -lm -lstdc++
INC = -I/usr/include/X11

KIN_TARGET = test_kin
KIN_SOURCES = ../TestKinematics.cc ../Kinematics.cc
KIN_OBJ = $(KIN_SOURCES:%.cc=%.o)
KIN_DEPS := $(SOURCES:%.cc=%.dep)
KIN_DEPENDS := $(join $(dir $(KIN_DEPS)),$(addprefix .,$(notdir $(KIN_DEPS))))
#KIN_DEPENDS := $(addprefix .,$(notdir $(KIN_DEPS)))


all: $(TARGET) $(KIN_TARGET)

.SUFFIXES: .cc
%.o: %.cc
	$(CC) $(CFLAGS) $(INC) -c $< -o $@

.SUFFIXES: .cc
.%.dep: %.cc
	@echo "Generating dependencies for: " $<
	@$(CC) -M $(CFLAGS) $< > $@.tmp
	@echo -n "$@ " >$@
	@cat $@.tmp >>$@
	@rm $@.tmp

$(KIN_TARGET): $(KIN_OBJ)
	$(CC) $(CFLAGS) -o $@ $(KIN_OBJ) $(LIB)

$(TARGET): $(OBJ)
	$(CC) $(CFLAGS) -o $@ $(OBJ) $(LIB)

motions: $(TARGET)
	(mkdir -p mot; cd mot; ../$(TARGET))

clean: depend
	-rm -f core *.o *~ "#"*"#" $(OBJ) $(KIN_OBJ) Makefile.bak $(TARGET) $(KIN_TARGET)

dep: depend

depend:
	rm -f $(DEPENDS) $(KIN_DEPENDS)

include $(DEPENDS) $(KIN_DEPENDS)
