# Adapted from Makefile for Independent JPEG Group's software

# This makefile is suitable for Unix-like systems with non-ANSI compilers.
# If you have an ANSI compiler, makefile.ansi is a better starting point.

# Read installation instructions before saying "make" !!

# The name of your C compiler:
OPENRSDK_ROOT ?= /usr/local/OPEN_R_SDK
TEKKOTSU_ROOT ?= /usr/local/Tekkotsu
CXX= $(OPENRSDK_ROOT)/bin/mipsel-linux-gcc

# You may need to adjust these cc options:
CXXFLAGS= -I ../../Shared/newmat -fno-inline \
          -Wall -W -Wlarger-than-8192 -Wpointer-arith -Wcast-qual \
          -Woverloaded-virtual -Wdeprecated -Wnon-virtual-dtor \
          -O3 -frename-registers -fomit-frame-pointer -fno-common \

#          -Wshadow -Weffc++

# Link-time cc options:
LDFLAGS=

# To link any special libraries, add the necessary -l commands here.
LDLIBS= 

# miscellaneous OS-dependent stuff
# linker
LN= $(CC)
# file deletion command
RM= rm -f
# file rename command
MV= mv
# library (.a) file creation command
AR= $(OPENRSDK_ROOT)/bin/mipsel-linux-ar rc
# second step in .a creation (use "touch" if not needed)
AR2= $(OPENRSDK_ROOT)/bin/mipsel-linux-ranlib

# End of configurable options.

COLORFILT=$(TEKKOTSU_ROOT)/tools/colorfilt
FILTERSYSWARN=$(TEKKOTSU_ROOT)/tools/filtersyswarn/filtersyswarn $(OPENRSDK_ROOT)

# source files: JPEG library proper
LIBSOURCES:= $(wildcard *.cpp)

SOURCES= $(LIBSOURCES)

LIBOBJECTS= $(LIBSOURCES:.cpp=.o)

all: libroboop.a

.PHONY: all clean

libroboop.a: $(LIBOBJECTS)
	$(RM) $@
	$(AR) $@  $(LIBOBJECTS)
	$(AR2) $@

clean:
	$(RM) *.o *.a *.log core

%.o:
	@echo "Compiling ROBOOP::$<... (Reduced warnings)"; \
	$(CXX) $(CXXFLAGS) -o $@ -c $< > $*.log 2>&1; \
	retval=$$?; \
	cat $*.log | $(FILTERSYSWARN) | $(COLORFILT); \
	test $$retval -eq 0; \

controller.o: controller.cpp controller.h

control_select.o: control_select.cpp control_select.h

dynamics_sim.o: dynamics_sim.cpp dynamics_sim.h

trajectory.o: trajectory.cpp trajectory.h

clik.o :  clik.cpp clik.h utils.h robot.h

robot.o :  robot.cpp utils.h robot.h

config.o : config.cpp config.h

quaternion.o : quaternion.cpp quaternion.h

gnugraph.o :  gnugraph.cpp gnugraph.h utils.h robot.h

comp_dq.o :  comp_dq.cpp utils.h robot.h

comp_dqp.o :  comp_dqp.cpp utils.h robot.h

delta_t.o :  delta_t.cpp utils.h robot.h

dynamics.o :  dynamics.cpp utils.h robot.h

homogen.o :  homogen.cpp utils.h robot.h

invkine.o :  invkine.cpp utils.h robot.h

kinemat.o :  kinemat.cpp utils.h robot.h

sensitiv.o :  sensitiv.cpp utils.h robot.h

utils.o :  utils.cpp utils.h robot.h
