From 83c3023274905fc2052928cb0be8c0a680eb4390 Mon Sep 17 00:00:00 2001 From: sebastien Date: Wed, 16 Sep 2009 13:49:47 +0000 Subject: [PATCH] Added build system for Octave MEX files git-svn-id: https://www.dynare.org/svn/dynare/trunk@2932 ac1d8469-bf42-47a9-8791-bf33cf982152 --- Makefile.am | 2 +- configure.ac | 16 +++++++++ mex/build/Makefile.am | 11 ++++++ mex/build/bytecode.am | 16 +++++++++ mex/build/bytecode/octave/Makefile.am | 2 ++ mex/build/gensylv.am | 47 ++++++++++++++++++++++++++ mex/build/gensylv/octave/Makefile.am | 2 ++ mex/build/kronecker.am | 6 ++++ mex/build/kronecker/octave/Makefile.am | 2 ++ mex/build/mjdgges.am | 5 +++ mex/build/mjdgges/octave/Makefile.am | 2 ++ mex/build/mkoctfile.am | 32 ++++++++++++++++++ 12 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 mex/build/Makefile.am create mode 100644 mex/build/bytecode.am create mode 100644 mex/build/bytecode/octave/Makefile.am create mode 100644 mex/build/gensylv.am create mode 100644 mex/build/gensylv/octave/Makefile.am create mode 100644 mex/build/kronecker.am create mode 100644 mex/build/kronecker/octave/Makefile.am create mode 100644 mex/build/mjdgges.am create mode 100644 mex/build/mjdgges/octave/Makefile.am create mode 100644 mex/build/mkoctfile.am diff --git a/Makefile.am b/Makefile.am index 740c680ca..e49c19011 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = preprocessor doc tests +SUBDIRS = preprocessor doc tests mex/build if HAVE_CTANGLE if HAVE_BLAS diff --git a/configure.ac b/configure.ac index 56b388ece..10c03a2f2 100644 --- a/configure.ac +++ b/configure.ac @@ -30,6 +30,7 @@ AC_LANG([C++]) CXXFLAGS="$CXXFLAGS -Wall" AC_PROG_RANLIB +AC_PROG_LN_S AM_PROG_LEX AX_PROG_FLEX([], AC_MSG_ERROR([No suitable flex found.])) @@ -71,6 +72,9 @@ AM_CONDITIONAL([HAVE_DOXYGEN], [test "x$DOXYGEN" != "x"]) AC_CHECK_PROG([OCTAVE], [octave], [octave]) AM_CONDITIONAL([HAVE_OCTAVE], [test "x$OCTAVE" != "x"]) +AC_CHECK_PROG([MKOCTFILE], [mkoctfile], [mkoctfile]) +AM_CONDITIONAL([HAVE_MKOCTFILE], [test "x$MKOCTFILE" != "x"]) + AC_CHECK_PROG([CTANGLE], [ctangle], [ctangle]) AM_CONDITIONAL([HAVE_CTANGLE], [test "x$CTANGLE" != "x"]) @@ -121,6 +125,11 @@ AC_CONFIG_FILES([Makefile dynare++/integ/testing/Makefile dynare++/kord/Makefile dynare++/src/Makefile + mex/build/Makefile + mex/build/mjdgges/octave/Makefile + mex/build/kronecker/octave/Makefile + mex/build/gensylv/octave/Makefile + mex/build/bytecode/octave/Makefile ]) # Construct final output message @@ -169,6 +178,12 @@ else BUILD_DYNARE_PREPROC_DOC="no (missing doxygen)" fi +if test "x$MKOCTFILE" != "x"; then + BUILD_MEX_OCTAVE="yes" +else + BUILD_MEX_OCTAVE="no (missing mkoctfile)" +fi + if test "x$OCTAVE" != "x"; then TESTSUITE_OCTAVE="yes" else @@ -187,6 +202,7 @@ Dynare is now configured for building the following components... Binaries (with "make"): Dynare preprocessor: $BUILD_PREPROCESSOR + MEX files for Octave: $BUILD_MEX_OCTAVE Dynare++: $BUILD_DYNAREPLUSPLUS PDF documentation (with "make pdf"): diff --git a/mex/build/Makefile.am b/mex/build/Makefile.am new file mode 100644 index 000000000..a1a2871b6 --- /dev/null +++ b/mex/build/Makefile.am @@ -0,0 +1,11 @@ +SUBDIRS = + +if HAVE_MKOCTFILE +SUBDIRS += mjdgges/octave kronecker/octave gensylv/octave bytecode/octave +endif + +EXTRA_DIST = \ + ../sources/matlab_versions_compatibility.h \ + ../sources/build_matlab.m \ + ../sources/build_matlab_multithread.m \ + ../sources/build_octave.m diff --git a/mex/build/bytecode.am b/mex/build/bytecode.am new file mode 100644 index 000000000..4b8effa9d --- /dev/null +++ b/mex/build/bytecode.am @@ -0,0 +1,16 @@ +VPATH = $(top_srcdir)/mex/sources/bytecode + +noinst_PROGRAMS = bytecode + +# bytecode_CPPFLAGS interacts badly with VPATH +CPPFLAGS += -I$(top_srcdir)/mex/sources/bytecode -I$(top_srcdir)/preprocessor + +bytecode_SOURCES = \ + bytecode.cc \ + Interpreter.cc \ + Mem_Mngr.cc \ + SparseMatrix.cc \ + bytecode.hh \ + Interpreter.hh \ + Mem_Mngr.hh \ + SparseMatrix.hh diff --git a/mex/build/bytecode/octave/Makefile.am b/mex/build/bytecode/octave/Makefile.am new file mode 100644 index 000000000..a88fd00d9 --- /dev/null +++ b/mex/build/bytecode/octave/Makefile.am @@ -0,0 +1,2 @@ +include ../../mkoctfile.am +include ../../bytecode.am diff --git a/mex/build/gensylv.am b/mex/build/gensylv.am new file mode 100644 index 000000000..43437fa98 --- /dev/null +++ b/mex/build/gensylv.am @@ -0,0 +1,47 @@ +VPATH = $(top_srcdir)/mex/sources/gensylv/cc:$(top_srcdir)/mex/sources/gensylv/matlab + +noinst_PROGRAMS = gensylv + +# Can't use gensylv_CPPFLAGS, because it interacts badly with VPATH +CPPFLAGS += -DMATLAB -I$(top_srcdir)/mex/sources/gensylv/cc + +gensylv_SOURCES = \ + gensylv.cpp \ + BlockDiagonal.cpp \ + GeneralMatrix.cpp \ + GeneralSylvester.cpp \ + IterativeSylvester.cpp \ + KronUtils.cpp \ + KronVector.cpp \ + QuasiTriangular.cpp \ + QuasiTriangularZero.cpp \ + SchurDecomp.cpp \ + SchurDecompEig.cpp \ + SimilarityDecomp.cpp \ + SylvException.cpp \ + SylvMatrix.cpp \ + SylvMemory.cpp \ + SylvParams.cpp \ + TriangularSylvester.cpp \ + Vector.cpp \ + BlockDiagonal.h \ + GeneralMatrix.h \ + GeneralSylvester.h \ + IterativeSylvester.h \ + KronUtils.h \ + KronVector.h \ + QuasiTriangular.h \ + QuasiTriangularZero.h \ + SchurDecomp.h \ + SchurDecompEig.h \ + SimilarityDecomp.h \ + SylvException.h \ + SylvMatrix.h \ + SylvMemory.h \ + SylvParams.h \ + TriangularSylvester.h \ + Vector.h \ + cppblas.h \ + cpplapack.h \ + SylvesterSolver.h + diff --git a/mex/build/gensylv/octave/Makefile.am b/mex/build/gensylv/octave/Makefile.am new file mode 100644 index 000000000..743248cc1 --- /dev/null +++ b/mex/build/gensylv/octave/Makefile.am @@ -0,0 +1,2 @@ +include ../../mkoctfile.am +include ../../gensylv.am diff --git a/mex/build/kronecker.am b/mex/build/kronecker.am new file mode 100644 index 000000000..e9d4514a7 --- /dev/null +++ b/mex/build/kronecker.am @@ -0,0 +1,6 @@ +VPATH = $(top_srcdir)/mex/sources/kronecker + +noinst_PROGRAMS = sparse_hessian_times_B_kronecker_C A_times_B_kronecker_C + +sparse_hessian_times_B_kronecker_C_SOURCES = sparse_hessian_times_B_kronecker_C.cc +A_times_B_kronecker_C_SOURCES = A_times_B_kronecker_C.cc diff --git a/mex/build/kronecker/octave/Makefile.am b/mex/build/kronecker/octave/Makefile.am new file mode 100644 index 000000000..ca54e6c9b --- /dev/null +++ b/mex/build/kronecker/octave/Makefile.am @@ -0,0 +1,2 @@ +include ../../mkoctfile.am +include ../../kronecker.am diff --git a/mex/build/mjdgges.am b/mex/build/mjdgges.am new file mode 100644 index 000000000..4d5af3f86 --- /dev/null +++ b/mex/build/mjdgges.am @@ -0,0 +1,5 @@ +VPATH = $(top_srcdir)/mex/sources/mjdgges + +noinst_PROGRAMS = mjdgges + +mjdgges_SOURCES = mjdgges.c diff --git a/mex/build/mjdgges/octave/Makefile.am b/mex/build/mjdgges/octave/Makefile.am new file mode 100644 index 000000000..ca79a376a --- /dev/null +++ b/mex/build/mjdgges/octave/Makefile.am @@ -0,0 +1,2 @@ +include ../../mkoctfile.am +include ../../mjdgges.am diff --git a/mex/build/mkoctfile.am b/mex/build/mkoctfile.am new file mode 100644 index 000000000..bc7fd7c12 --- /dev/null +++ b/mex/build/mkoctfile.am @@ -0,0 +1,32 @@ +EXEEXT = .mex + +CPPFLAGS = $(shell $(MKOCTFILE) -p CPPFLAGS) + +DEFS = -DNO_BLAS_H -DNO_LAPACK_H -DOCTAVE + +CC = $(shell $(MKOCTFILE) -p CC) +CFLAGS = $(shell $(MKOCTFILE) -p CPICFLAG) +CFLAGS += $(shell $(MKOCTFILE) -p ALL_CFLAGS) + +CXX = $(shell $(MKOCTFILE) -p CXX) +CXXFLAGS = $(shell $(MKOCTFILE) -p CXXPICFLAG) +CXXFLAGS += $(shell $(MKOCTFILE) -p ALL_CXXFLAGS) + +LDFLAGS = $(shell $(MKOCTFILE) -p DL_LDFLAGS) +LDFLAGS += $(shell $(MKOCTFILE) -p LFLAGS) +LDFLAGS += $(shell $(MKOCTFILE) -p LDFLAGS) + +LIBS = $(shell $(MKOCTFILE) -p OCTAVE_LIBS) +LIBS += $(shell $(MKOCTFILE) -p BLAS_LIBS) +LIBS += $(shell $(MKOCTFILE) -p FFTW_LIBS) +LIBS += $(shell $(MKOCTFILE) -p LIBS) +LIBS += $(shell $(MKOCTFILE) -p FLIBS) + +all-local: + cd $(top_srcdir)/mex/octave && \ + for p in $(PROGRAMS); do \ + $(LN_S) -f $(abs_srcdir)/$$p $$p; \ + done + +clean-local: + cd $(top_srcdir)/mex/octave && rm -f $(PROGRAMS)