# 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= -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= bandmat.cpp cholesky.cpp evalue.cpp fft.cpp hholder.cpp \
            jacobi.cpp myexcept.cpp newfft.cpp newmat1.cpp newmat2.cpp \
            newmat3.cpp newmat4.cpp newmat5.cpp newmat6.cpp newmat7.cpp \
            newmat8.cpp newmat9.cpp newmatex.cpp newmatnl.cpp newmatrm.cpp \
            sort.cpp submat.cpp svd.cpp

SOURCES= $(LIBSOURCES)

# files included by source files
INCLUDES= boolean.h include.h newmatap.h newmatio.h newmatrc.h precisio.h \
          controlw.h myexcept.h newmat.h newmatnl.h newmatrm.h solution.h

LIBOBJECTS= $(LIBSOURCES:.cpp=.o)
# newmat1.o newmat2.o newmat3.o newmat4.o newmat5.o newmat6.o newmat7.o newmat8.o newmat9.o newmatex.o bandmat.o submat.o myexcept.o cholesky.o evalue.o fft.o hholder.o jacobi.o newfft.o sort.o svd.o newmatrm.o newmatnl.o

all: libnewmat.a

.PHONY: all clean

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

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

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

newmat1.o:     	newmat1.cpp newmat.h include.h myexcept.h

newmat2.o:     	newmat2.cpp include.h newmat.h newmatrc.h myexcept.h controlw.h

newmat3.o:     	newmat3.cpp include.h newmat.h newmatrc.h myexcept.h controlw.h

newmat4.o:     	newmat4.cpp include.h newmat.h newmatrc.h myexcept.h controlw.h

newmat5.o:     	newmat5.cpp include.h newmat.h newmatrc.h myexcept.h controlw.h

newmat6.o:     	newmat6.cpp include.h newmat.h newmatrc.h myexcept.h controlw.h

newmat7.o:     	newmat7.cpp include.h newmat.h newmatrc.h myexcept.h controlw.h

newmat8.o:     	newmat8.cpp include.h newmat.h newmatrc.h precisio.h myexcept.h controlw.h

newmat9.o:     	newmat9.cpp include.h newmat.h newmatio.h newmatrc.h myexcept.h controlw.h


newmatex.o:    	newmatex.cpp include.h newmat.h myexcept.h

bandmat.o:     	bandmat.cpp include.h newmat.h newmatrc.h myexcept.h controlw.h

submat.o:      	submat.cpp include.h newmat.h newmatrc.h myexcept.h controlw.h

myexcept.o:    	myexcept.cpp include.h myexcept.h

cholesky.o:    	cholesky.cpp include.h newmat.h myexcept.h

evalue.o:      	evalue.cpp include.h newmatap.h newmatrm.h precisio.h newmat.h myexcept.h

fft.o:         	fft.cpp include.h newmatap.h newmat.h myexcept.h

hholder.o:     	hholder.cpp include.h newmatap.h newmat.h myexcept.h

jacobi.o:      	jacobi.cpp include.h newmatap.h precisio.h newmatrm.h newmat.h myexcept.h

newfft.o:      	newfft.cpp newmatap.h newmat.h include.h myexcept.h

sort.o:        	sort.cpp include.h newmatap.h newmat.h myexcept.h

svd.o:         	svd.cpp include.h newmatap.h newmatrm.h precisio.h newmat.h myexcept.h

newmatrm.o:    	newmatrm.cpp newmat.h newmatrm.h include.h myexcept.h

newmatnl.o:    	newmatnl.cpp newmatap.h newmatnl.h newmat.h include.h myexcept.h
