#
# Makefile for octave's liboctave directory
#
# John W. Eaton
# jwe@che.utexas.edu
# Department of Chemical Engineering
# The University of Texas at Austin

TOPDIR = ..

srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@

include $(TOPDIR)/Makeconf

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

MATRIX_INC = Array.h MArray.h Matrix.h mx-base.h mx-defs.h mx-ext.h \
	mx-kludge.h CColVector.h CDiagMatrix.h CMatrix.h CRowVector.h \
	CmplxAEPBAL.h CmplxCHOL.h CmplxDET.h CmplxHESS.h CmplxLU.h \
	CmplxQR.h CmplxQRP.h CmplxSCHUR.h CmplxSVD.h EIG.h \
	dColVector.h dDiagMatrix.h dMatrix.h dRowVector.h dbleAEPBAL.h \
	dbleCHOL.h dbleDET.h dbleGEPBAL.h dbleHESS.h dbleLU.h dbleQR.h \
	dbleQRP.h dbleSCHUR.h dbleSVD.h

INCLUDES = Bounds.h CollocWt.h DAE.h DAEFunc.h FEGrid.h	FSQP.h \
	LinConst.h LP.h LPsolve.h NLConst.h NLEqn.h NLFunc.h NLP.h \
	NPSOL.h ODE.h ODEFunc.h Objective.h QLD.h QP.h QPSOL.h \
	Quad.h Range.h lo-error.h f77-uscore.h sun-utils.h \
	$(MATRIX_INC)

TEMPLATE_SRC = Array.cc

TI_SRC = Array-C.cc Array-d.cc

MATRIX_SRC = CColVector.cc CDiagMatrix.cc CMatrix.cc CRowVector.cc \
	CmplxAEPBAL.cc CmplxCHOL.cc CmplxDET.cc CmplxHESS.cc CmplxLU.cc \
	CmplxQR.cc CmplxQRP.cc CmplxSCHUR.cc CmplxSVD.cc EIG.cc \
	dColVector.cc dDiagMatrix.cc dMatrix.cc dRowVector.cc \
	dbleAEPBAL.cc dbleCHOL.cc dbleDET.cc dbleGEPBAL.cc dbleHESS.cc \
	dbleLU.cc dbleQR.cc dbleQRP.cc dbleSCHUR.cc dbleSVD.cc

SOURCES = Bounds.cc CollocWt.cc DAE.cc DAEFunc.cc FEGrid.cc FSQP.cc \
	LinConst.cc LP.cc LPsolve.cc NLConst.cc NLEqn.cc NLFunc.cc \
	NPSOL.cc Objective.cc ODE.cc ODEFunc.cc QLD.cc QP.cc QPSOL.cc \
	Quad.cc Range.cc lo-error.cc sun-utils.cc $(TEMPLATE_SRC) \
	$(TI_SRC) $(MATRIX_SRC)

EXTRAS = MArray.cc mx-kludge.cc mx-inlines.cc

DISTFILES = Makefile.in $(SOURCES) $(INCLUDES) $(EXTRAS)

MAKEDEPS = $(patsubst %.cc, %.d, $(SOURCES))

OBJECTS = $(patsubst %.cc, %.o, $(SOURCES))

LIBOCTAVE_DEPEND := $(patsubst %, liboctave.a(%), $(OBJECTS))

all: liboctave.a
.PHONY: all

liboctave.a: $(OBJECTS)
	$(AR) $(ARFLAGS) liboctave.a $(OBJECTS)
	$(RANLIB) liboctave.a

check: all
.PHONY: check

install: all
	$(top_srcdir)/mkinstalldirs $(libdir) $(includedir)
	rm -f $(libdir)/liboctave.a
	$(INSTALL_DATA) liboctave.a $(libdir)/liboctave.a
	$(RANLIB) $(libdir)/liboctave.a
	for f in $(INCLUDES) $(TEMPLATE_SRC) ; do \
	  rm -f $(includedir)/$$f ; \
	  $(INSTALL_DATA) $(srcdir)/$$f $(includedir)/$$f ; \
	done
.PHONY: install

uninstall:
	rm -f $(libdir)/liboctave.a
	for f in $(INCLUDES) ; do rm -f $(includedir)/$$f ; done
.PHONY: uninstall

tags: $(SOURCES)
	ctags $(SOURCES)

TAGS: $(SOURCES)
	etags $(SOURCES)

clean:
	rm -f *.a *.o
.PHONY: clean

mostlyclean: clean
.PHONY: mostlyclean

distclean: clean
	rm -f Makefile  *.a $(TMPSRC) $(TMPINC) *.d
.PHONY: distclean

realclean: distclean
	rm -f tags TAGS *.d
.PHONY: realclean

local-dist:
	ln $(DISTFILES) ../`cat ../.fname`/liboctave
.PHONY: local-dist

dist:
	ln $(DISTFILES) ../`cat ../.fname`/liboctave
.PHONY: dist

-include $(MAKEDEPS)
