summaryrefslogtreecommitdiff
path: root/modules/mexlib/examples
diff options
context:
space:
mode:
authorShashank2017-05-29 12:40:26 +0530
committerShashank2017-05-29 12:40:26 +0530
commit0345245e860375a32c9a437c4a9d9cae807134e9 (patch)
treead51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/mexlib/examples
downloadscilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip
CMSCOPE changed
Diffstat (limited to 'modules/mexlib/examples')
-rwxr-xr-xmodules/mexlib/examples/cmex/cmex.sce30
-rwxr-xr-xmodules/mexlib/examples/cmex/readme.txt14
-rwxr-xr-xmodules/mexlib/examples/cppmex/builder.sce50
-rwxr-xr-xmodules/mexlib/examples/cppmex/demo.sce16
-rwxr-xr-xmodules/mexlib/examples/cppmex/libmex.dia.ref21
-rwxr-xr-xmodules/mexlib/examples/cppmex/libmex.tst13
-rwxr-xr-xmodules/mexlib/examples/cppmex/readme.txt15
-rwxr-xr-xmodules/mexlib/examples/cppmex/temptst.cpp38
-rwxr-xr-xmodules/mexlib/examples/cppmex/temptst.h52
-rwxr-xr-xmodules/mexlib/examples/cppmex/temptst2.cpp20
-rwxr-xr-xmodules/mexlib/examples/fmex/builder.sce33
-rwxr-xr-xmodules/mexlib/examples/fmex/demo.sce23
-rwxr-xr-xmodules/mexlib/examples/fmex/mexfunction1.F23
-rwxr-xr-xmodules/mexlib/examples/fmex/readme.txt14
-rwxr-xr-xmodules/mexlib/examples/interface/builder.sce52
-rwxr-xr-xmodules/mexlib/examples/interface/demo.sce27
-rwxr-xr-xmodules/mexlib/examples/interface/f4.c29
-rwxr-xr-xmodules/mexlib/examples/interface/fmex1.c43
-rwxr-xr-xmodules/mexlib/examples/interface/fmex2.c43
-rwxr-xr-xmodules/mexlib/examples/interface/foof.F16
-rwxr-xr-xmodules/mexlib/examples/interface/lib/bar.c18
-rwxr-xr-xmodules/mexlib/examples/interface/lib/builder.sce28
-rwxr-xr-xmodules/mexlib/examples/interface/lib/foo.c18
-rwxr-xr-xmodules/mexlib/examples/interface/lib/pipo.h16
-rwxr-xr-xmodules/mexlib/examples/interface/libmex.dia.ref24
-rwxr-xr-xmodules/mexlib/examples/interface/libmex.tst14
-rwxr-xr-xmodules/mexlib/examples/interface/readme.txt12
-rwxr-xr-xmodules/mexlib/examples/mexdll/Makelib.mak13
-rwxr-xr-xmodules/mexlib/examples/mexdll/demo.sce23
-rwxr-xr-xmodules/mexlib/examples/mexdll/libtst.c25
-rwxr-xr-xmodules/mexlib/examples/mexdll/readme.txt8
-rwxr-xr-xmodules/mexlib/examples/mexdll/xtimesy.def3
-rwxr-xr-xmodules/mexlib/examples/mexdll/xtimesy.dllbin0 -> 40960 bytes
-rwxr-xr-xmodules/mexlib/examples/mexglx/README85
-rwxr-xr-xmodules/mexlib/examples/mexglx/foo.c70
-rwxr-xr-xmodules/mexlib/examples/mexglx/libtst.c25
-rwxr-xr-xmodules/mexlib/examples/mexglx/test.dia.ref102
-rwxr-xr-xmodules/mexlib/examples/mexglx/test.sce53
-rwxr-xr-xmodules/mexlib/examples/mexglx/test1.sce45
39 files changed, 1154 insertions, 0 deletions
diff --git a/modules/mexlib/examples/cmex/cmex.sce b/modules/mexlib/examples/cmex/cmex.sce
new file mode 100755
index 000000000..0cbd0df1c
--- /dev/null
+++ b/modules/mexlib/examples/cmex/cmex.sce
@@ -0,0 +1,30 @@
+
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+mode(-1);
+clear
+D=pwd()
+cd(TMPDIR)
+mputl("ilib_mex_build(''libmex'',[''mexf16'',''mexfunction16'',''cmex''],[],[],'''','''','''','''')","builder.sce")
+
+mputl([
+"#include ""mex.h"""
+"void mexFunction(nlhs, plhs, nrhs, prhs)"
+" int nlhs, nrhs;"
+" mxArray *plhs[]; mxArray *prhs[];"
+"{"
+" int *dims = mxGetDimensions(prhs[0]);"
+" sciprint(""%d %d %d\n"",dims[0],dims[1],dims[2]);"
+"}"
+],"mexfunction16.c")
+exec(TMPDIR+"/builder.sce");
+exec(TMPDIR+"/loader.sce");
+mexf16(rand(2,3,2))
+cd(D)
diff --git a/modules/mexlib/examples/cmex/readme.txt b/modules/mexlib/examples/cmex/readme.txt
new file mode 100755
index 000000000..ebfefc1ef
--- /dev/null
+++ b/modules/mexlib/examples/cmex/readme.txt
@@ -0,0 +1,14 @@
+The purpose of this contribution is to emulate the Matlab mexfile mechanism.
+
+Only the most useful functions have been emulated.
+
+See SCI/modules/mexlib/src/mexlib.c for additional info and
+in particular the list of emulated mx functions.
+
+-------------------------------------------------------
+To build and load the shared library enter
+ --> exec (SCI+'/modules/mexlib/examples/cmex/cmex.sce')
+ at scilab prompt
+
+-------------------------------------------------------
+INRIA 2006
diff --git a/modules/mexlib/examples/cppmex/builder.sce b/modules/mexlib/examples/cppmex/builder.sce
new file mode 100755
index 000000000..458ea69b9
--- /dev/null
+++ b/modules/mexlib/examples/cppmex/builder.sce
@@ -0,0 +1,50 @@
+
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// This is the builder.sce
+// must be run from this directory
+
+// interface library name
+ilib_name = "libmex"
+
+// objects files (but do not give mexfiles here)
+files = ["temptst2.cpp"];
+
+// other libs needed for linking (must be shared library names)
+libs = [];
+
+// table of (scilab_name,interface-name or mexfile-name, type)
+table =["square","temptst","cmex"];
+
+if getos() <> "Windows" then
+ if part(getenv("OSTYPE","no"),1:6)=="darwin" then
+ cflags = ""
+ fflags = "";
+ ldflags= "";
+ cc = "g++";
+ else
+ // Since linking is done by gcc and not g++
+ // we must add the libstdc++ to cflags
+ // an other possibility would be to use cflags="" and cc="
+ cflags = " -lstdc++"
+ fflags = "";
+ ldflags= "";
+ cc="";
+ end
+else
+ cflags = ""
+ fflags = "";
+ ldflags= "";
+ cc = "";
+end
+
+// do not modify below
+// ----------------------------------------------
+ilib_mex_build(ilib_name,table,files,libs,"",ldflags,cflags,fflags)
diff --git a/modules/mexlib/examples/cppmex/demo.sce b/modules/mexlib/examples/cppmex/demo.sce
new file mode 100755
index 000000000..7928d811e
--- /dev/null
+++ b/modules/mexlib/examples/cppmex/demo.sce
@@ -0,0 +1,16 @@
+
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2007-2008 - INRIA - Allan CORNET <allan.cornet@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+exec(SCI+"/modules/mexlib/examples/cppmex/builder.sce");
+exec(SCI+"/modules/mexlib/examples/cppmex/loader.sce");
+
+x=56;
+y = square(x);
+if norm(y-x^2) > %eps then pause,end
diff --git a/modules/mexlib/examples/cppmex/libmex.dia.ref b/modules/mexlib/examples/cppmex/libmex.dia.ref
new file mode 100755
index 000000000..0ddfc113b
--- /dev/null
+++ b/modules/mexlib/examples/cppmex/libmex.dia.ref
@@ -0,0 +1,21 @@
+
+// load the shared library
+
+
+exec loader.sce ;
+shared archive loaded
+
+
+// run tests
+
+
+x=56;
+
+y = square(x);
+
+if norm(y-x^2) > %eps then bugmes();quit;end
+
+
+
+
+
diff --git a/modules/mexlib/examples/cppmex/libmex.tst b/modules/mexlib/examples/cppmex/libmex.tst
new file mode 100755
index 000000000..3b1cba897
--- /dev/null
+++ b/modules/mexlib/examples/cppmex/libmex.tst
@@ -0,0 +1,13 @@
+// load the shared library
+
+exec loader.sce ;
+
+// run tests
+
+x=56;
+y = square(x);
+if norm(y-x^2) > %eps then pause,end
+
+
+
+
diff --git a/modules/mexlib/examples/cppmex/readme.txt b/modules/mexlib/examples/cppmex/readme.txt
new file mode 100755
index 000000000..e1e96b29b
--- /dev/null
+++ b/modules/mexlib/examples/cppmex/readme.txt
@@ -0,0 +1,15 @@
+
+ mexfunctions and c++ code
+
+
+
+See SCI/modules/mexlib/srct/mexlib.c for additional info and
+in particular the list of emulated mx functions.
+
+Usage:
+
+exec (SCI+'/modules/mexlib/examples/cppmex/demo.sce');
+
+-------------------------------------------------------
+
+
diff --git a/modules/mexlib/examples/cppmex/temptst.cpp b/modules/mexlib/examples/cppmex/temptst.cpp
new file mode 100755
index 000000000..52cf052d8
--- /dev/null
+++ b/modules/mexlib/examples/cppmex/temptst.cpp
@@ -0,0 +1,38 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) INRIA
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "mex.h"
+#include "temptst.h"
+
+extern N1<double> callsquare(N1<double> n1);
+
+void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
+{
+ if (nrhs < 1)
+ {
+ mexErrMsgTxt("Need at least one argument");
+ }
+ if (mxGetM(prhs[0]) == 0)
+ {
+ mexErrMsgTxt("First argument must have at least one entry");
+ }
+ double* m = mxGetPr(prhs[0]);
+
+ N1<double> ans = callsquare(N1<double>(*m));
+ mxArray* result = mxCreateDoubleMatrix(1, 1, mxREAL);
+ *mxGetPr(result) = ans.data();
+ plhs[0] = result;
+ return;
+}
+
+
+
diff --git a/modules/mexlib/examples/cppmex/temptst.h b/modules/mexlib/examples/cppmex/temptst.h
new file mode 100755
index 000000000..c5f0fe984
--- /dev/null
+++ b/modules/mexlib/examples/cppmex/temptst.h
@@ -0,0 +1,52 @@
+
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) INRIA
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#ifndef TEMPTST_H
+
+template<class T>
+class N1
+{
+private:
+ T data_;
+public:
+ ~N1() { }
+ T data() const
+ {
+ return data_;
+ }
+ T sqr() const;
+ const N1<T>& operator=(const N1<T>& v);
+ N1(const N1<T>& v)
+ {
+ operator=(v);
+ }
+ N1(T d1): data_(d1) { }
+};
+
+
+template<class T>
+T N1<T>::sqr() const
+{
+ return data_ * data_;
+}
+
+template<class T>
+const N1<T>& N1<T>::operator=(const N1<T>& v)
+{
+ data_ = v.data();
+ return *this;
+}
+
+#endif
+
+#define TEMPTST_H
diff --git a/modules/mexlib/examples/cppmex/temptst2.cpp b/modules/mexlib/examples/cppmex/temptst2.cpp
new file mode 100755
index 000000000..5213de024
--- /dev/null
+++ b/modules/mexlib/examples/cppmex/temptst2.cpp
@@ -0,0 +1,20 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) INRIA
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "temptst.h"
+
+N1<double> callsquare(N1<double> n1)
+{
+ double x = n1.sqr();
+ return N1<double>(x);
+}
+
diff --git a/modules/mexlib/examples/fmex/builder.sce b/modules/mexlib/examples/fmex/builder.sce
new file mode 100755
index 000000000..1e66fba22
--- /dev/null
+++ b/modules/mexlib/examples/fmex/builder.sce
@@ -0,0 +1,33 @@
+
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// This is the builder.sce
+// must be run from this directory
+
+// interface library name
+ilib_name = "libmex"
+
+// objects files (but do not give mexfiles here)
+files = [];
+
+// other libs needed for linking (must be shared library names)
+libs = [];
+
+// table of (scilab_name,interface-name or mexfile-name, type)
+
+table =["mexf1","mexfunction1","fmex"];
+
+ldflags = "";
+cflags = "";
+fflags = "";
+
+// do not modify below
+// ----------------------------------------------
+ilib_mex_build(ilib_name,table,files,libs,"",ldflags,cflags,fflags)
diff --git a/modules/mexlib/examples/fmex/demo.sce b/modules/mexlib/examples/fmex/demo.sce
new file mode 100755
index 000000000..c5da3deaf
--- /dev/null
+++ b/modules/mexlib/examples/fmex/demo.sce
@@ -0,0 +1,23 @@
+
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// Allan CORNET
+// INRIA 2007
+
+exec(SCI+"/modules/mexlib/examples/fmex/builder.sce");
+exec(SCI+"/modules/mexlib/examples/fmex/loader.sce");
+
+[a,b]=mexf1(1,2);
+
+if (b~=2) then
+ disp("problem with this example");
+else
+ disp("ok");
+end
diff --git a/modules/mexlib/examples/fmex/mexfunction1.F b/modules/mexlib/examples/fmex/mexfunction1.F
new file mode 100755
index 000000000..8501e071a
--- /dev/null
+++ b/modules/mexlib/examples/fmex/mexfunction1.F
@@ -0,0 +1,23 @@
+ subroutine mexfunction(nlhs, plhs, nrhs, prhs)
+c [a,b]=mexf1(1,2) see builder.sce file
+
+ integer*4 plhs(*), prhs(*)
+C Uncomment for 64 bits Dec Alpha machines
+C integer*8 plhs(*), prhs(*)
+C
+ integer nlhs, nrhs
+c
+ if (nrhs.ne.2) then
+ call mexerrmsgtxt('Two inputs needed')
+ endif
+
+ if (nlhs.gt.2) then
+ call mexerrmsgtxt('Two many outputs')
+ endif
+
+ plhs(1)=prhs(1)
+ plhs(2)=prhs(2)
+
+ return
+ end
+
diff --git a/modules/mexlib/examples/fmex/readme.txt b/modules/mexlib/examples/fmex/readme.txt
new file mode 100755
index 000000000..03c362d6b
--- /dev/null
+++ b/modules/mexlib/examples/fmex/readme.txt
@@ -0,0 +1,14 @@
+The purpose of this contribution is to emulate the Matlab mexfile mechanism.
+
+Only the most useful functions have been emulated.
+
+See SCI/modules/mexlib/src/mexlib.c for additional info and
+in particular the list of emulated mx functions.
+
+-------------------------------------------------------
+To build and load the shared library enter
+ --> exec (SCI+'/modules/mexlib/examples/fmex/demo.sce')
+ at scilab prompt
+
+-------------------------------------------------------
+INRIA 2007
diff --git a/modules/mexlib/examples/interface/builder.sce b/modules/mexlib/examples/interface/builder.sce
new file mode 100755
index 000000000..6bcd64d2c
--- /dev/null
+++ b/modules/mexlib/examples/interface/builder.sce
@@ -0,0 +1,52 @@
+
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// This is the builder.sce
+// must be run from this directory
+
+// [1] generate Path.incl
+// here we want SCI to be ../../
+// but in a contrib the next line should be
+// replaced by sci = SCI
+
+sci="../../"
+F=mopen("Path.incl","w");
+mfprintf(F,"SCIDIR="+sci+"\n");
+mfprintf(F,"SCIDIR1="+strsubst(sci,"/","\\")+"\n");
+mclose(F);
+
+// [2] building lib/libutil.xx
+
+chdir lib
+exec builder.sce
+chdir ../
+
+// [3] the part devoted to shared lib generation
+
+ilib_name = "libmex" // interface library name
+
+// objects files (but do not give mexfiles here)
+
+files = ["f4.o"];
+
+// other libs needed for linking (must be shared library names)
+
+libs = ["lib/libutil"];
+
+// table of (scilab_name,interface-name or mexfile-name, type)
+
+table =["f1", "fmex1", "cmex";
+"f2", "fmex2", "cmex";
+"f3", "foof", "Fmex";
+"f4", "int_f4" "csci"];
+
+// do not modify below
+// ----------------------------------------------
+ilib_build(ilib_name,table,files,libs)
diff --git a/modules/mexlib/examples/interface/demo.sce b/modules/mexlib/examples/interface/demo.sce
new file mode 100755
index 000000000..8f6028bbe
--- /dev/null
+++ b/modules/mexlib/examples/interface/demo.sce
@@ -0,0 +1,27 @@
+
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+currentdir=pwd();
+cd SCI+"/modules/mexlib/examples/interface/lib"
+
+exec("builder.sce");
+
+cd SCI+"/modules/mexlib/examples/interface"
+exec("builder.sce");
+
+exec(SCI+"/modules/mexlib/examples/interface/loader.sce");
+
+
+if f1(89)<>89+2 then pause,end
+if f2(89)<>89+3 then pause,end
+if f3(89)<>89 then pause,end
+if f4(89)<>89+5 then pause,end
+
+cd currentdir
diff --git a/modules/mexlib/examples/interface/f4.c b/modules/mexlib/examples/interface/f4.c
new file mode 100755
index 000000000..c7d924aec
--- /dev/null
+++ b/modules/mexlib/examples/interface/f4.c
@@ -0,0 +1,29 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) INRIA
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include "stack-c.h"
+#include "lib/pipo.h"
+
+int int_f4(char *fname)
+{
+ static int l1, m1, n1;
+ CheckRhs(1, 1);
+ CheckLhs(1, 1);
+ GetRhsVar(1, MATRIX_OF_INTEGER_DATATYPE, &m1, &n1, &l1);
+ CheckScalar(1, m1, n1);
+ *istk(l1) = foo(*istk(l1));
+ *istk(l1) = bar(*istk(l1));
+ LhsVar(1) = 1;
+ return 0;
+}
diff --git a/modules/mexlib/examples/interface/fmex1.c b/modules/mexlib/examples/interface/fmex1.c
new file mode 100755
index 000000000..e9c2e8911
--- /dev/null
+++ b/modules/mexlib/examples/interface/fmex1.c
@@ -0,0 +1,43 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) INRIA
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include <stdio.h>
+#include "mex.h"
+#include "lib/pipo.h"
+
+void mexFunction(nlhs, plhs, nrhs, prhs)
+int nlhs, nrhs;
+Matrix *plhs[];
+Matrix *prhs[];
+{
+ Matrix *ptrA;
+ double *A;
+ int m, n;
+ if (nrhs != 1)
+ {
+ mexErrMsgTxt("This function requires 1 input!");
+ }
+ if (nlhs > 1)
+ {
+ mexErrMsgTxt("This function requires at most 1 output !");
+ }
+ ptrA = prhs[0];
+ if (! mxIsNumeric(prhs[0]))
+ {
+ mexErrMsgTxt("First argument must be numeric matrix.");
+ }
+ m = mxGetM(ptrA);
+ n = mxGetN(ptrA);
+ A = mxGetPr(ptrA);
+ A[0] = foo( (int) A[0]);
+ plhs[0] = prhs[0];
+}
diff --git a/modules/mexlib/examples/interface/fmex2.c b/modules/mexlib/examples/interface/fmex2.c
new file mode 100755
index 000000000..ff81d2d21
--- /dev/null
+++ b/modules/mexlib/examples/interface/fmex2.c
@@ -0,0 +1,43 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) INRIA
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include <stdio.h>
+#include "mex.h"
+#include "lib/pipo.h"
+
+void mexFunction(nlhs, plhs, nrhs, prhs)
+int nlhs, nrhs;
+Matrix *plhs[];
+Matrix *prhs[];
+{
+ Matrix *ptrA;
+ double *A;
+ int m, n;
+ if (nrhs != 1)
+ {
+ mexErrMsgTxt("This function requires 1 input!");
+ }
+ if (nlhs > 1)
+ {
+ mexErrMsgTxt("This function requires at most 1 output !");
+ }
+ ptrA = prhs[0];
+ if (! mxIsNumeric(prhs[0]))
+ {
+ mexErrMsgTxt("First argument must be numeric matrix.");
+ }
+ m = mxGetM(ptrA);
+ n = mxGetN(ptrA);
+ A = mxGetPr(ptrA);
+ A[0] = bar( (int) A[0]);
+ plhs[0] = prhs[0];
+}
diff --git a/modules/mexlib/examples/interface/foof.F b/modules/mexlib/examples/interface/foof.F
new file mode 100755
index 000000000..653b7118b
--- /dev/null
+++ b/modules/mexlib/examples/interface/foof.F
@@ -0,0 +1,16 @@
+ subroutine mexfunction(nlhs,plhs,nrhs,prhs)
+c simple example of fortran mex.
+c usage a=pipo3(2)
+ integer*4 plhs(*), prhs(*)
+c FOR 64 bits MACHINES SHOULD BE integer*8
+ integer nlhs, nrhs
+c
+ if (nrhs.ne.1) then
+ call mexerrmsgtxt('Requires ONE input')
+ endif
+ if (nlhs.ne.1) then
+ call mexerrmsgtxt('Requires ONE output!')
+ endif
+ plhs(1)=prhs(1)
+ return
+ end
diff --git a/modules/mexlib/examples/interface/lib/bar.c b/modules/mexlib/examples/interface/lib/bar.c
new file mode 100755
index 000000000..5955e742f
--- /dev/null
+++ b/modules/mexlib/examples/interface/lib/bar.c
@@ -0,0 +1,18 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) INRIA
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "pipo.h"
+
+int bar(int x)
+{
+ return x + 3;
+}
diff --git a/modules/mexlib/examples/interface/lib/builder.sce b/modules/mexlib/examples/interface/lib/builder.sce
new file mode 100755
index 000000000..3e9a46791
--- /dev/null
+++ b/modules/mexlib/examples/interface/lib/builder.sce
@@ -0,0 +1,28 @@
+
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// Demo file for ext1c example
+
+// builder code for ext1c.c
+link_name = "util" ; // functions to be added to the call table
+// the first entry point gives the name of the library
+// note here that util is not an entry point
+// thus the generated loader.sce will not work
+// but it does not matter since we will use an other
+// loader.sce (../lib/loader.sce)
+
+flag = "c"; // ext1c is a C function
+files = ["foo.o";"bar.o" ]; // objects files for ext1c
+libs = []; // other libs needed for linking
+
+// the next call generates files (Makelib,loader.sce) used
+// for compiling and loading ext1c and performs the compilation
+
+ilib_for_link(link_name,files,libs,flag);
diff --git a/modules/mexlib/examples/interface/lib/foo.c b/modules/mexlib/examples/interface/lib/foo.c
new file mode 100755
index 000000000..ac2c065de
--- /dev/null
+++ b/modules/mexlib/examples/interface/lib/foo.c
@@ -0,0 +1,18 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) INRIA
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "pipo.h"
+
+int foo(int x)
+{
+ return x + 2;
+}
diff --git a/modules/mexlib/examples/interface/lib/pipo.h b/modules/mexlib/examples/interface/lib/pipo.h
new file mode 100755
index 000000000..9568313e3
--- /dev/null
+++ b/modules/mexlib/examples/interface/lib/pipo.h
@@ -0,0 +1,16 @@
+
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) INRIA
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+extern int foo(int x) ;
+extern int bar(int x) ;
+
diff --git a/modules/mexlib/examples/interface/libmex.dia.ref b/modules/mexlib/examples/interface/libmex.dia.ref
new file mode 100755
index 000000000..6843699b4
--- /dev/null
+++ b/modules/mexlib/examples/interface/libmex.dia.ref
@@ -0,0 +1,24 @@
+
+// load the shared library
+
+
+exec loader.sce ;
+shared archive loaded
+Link done
+shared archive loaded
+
+
+if f1(89)<>89+2 then bugmes();quit;end
+
+if f2(89)<>89+3 then bugmes();quit;end
+
+if f3(89)<>89 then bugmes();quit;end
+
+if f4(89)<>89+5 then bugmes();quit;end
+
+
+
+
+
+
+
diff --git a/modules/mexlib/examples/interface/libmex.tst b/modules/mexlib/examples/interface/libmex.tst
new file mode 100755
index 000000000..660027d25
--- /dev/null
+++ b/modules/mexlib/examples/interface/libmex.tst
@@ -0,0 +1,14 @@
+// load the shared library
+
+exec loader.sce ;
+
+if f1(89)<>89+2 then pause,end
+if f2(89)<>89+3 then pause,end
+if f3(89)<>89 then pause,end
+if f4(89)<>89+5 then pause,end
+
+
+
+
+
+
diff --git a/modules/mexlib/examples/interface/readme.txt b/modules/mexlib/examples/interface/readme.txt
new file mode 100755
index 000000000..0c01277aa
--- /dev/null
+++ b/modules/mexlib/examples/interface/readme.txt
@@ -0,0 +1,12 @@
+Copyright Jean-Philippe Chancelier/Cermics Enpc
+
+This directory contains example of a mix of C interface routines and
+C and Fortran mex files. More over the interfaces and mex functions
+use symbols defined in a shared library lib/libutil.so (or .dll) defined
+in the lib subdirectory.
+
+Jean-Philipppe Chancelier
+
+exec(SCI+'/modules/mexlib/examples/interface/demo.sce');
+
+
diff --git a/modules/mexlib/examples/mexdll/Makelib.mak b/modules/mexlib/examples/mexdll/Makelib.mak
new file mode 100755
index 000000000..52c4079ce
--- /dev/null
+++ b/modules/mexlib/examples/mexdll/Makelib.mak
@@ -0,0 +1,13 @@
+SCIDIR =../../../..
+SCIDIR1 =..\..\..\..
+# name of the dll to be built
+LIBRARY = libtst
+# list of objects file
+OBJS = libtst.obj
+# added libraries
+OTHERLIBS = xtimesy.lib
+!include $(SCIDIR)/Makefile.incl.mak
+CFLAGS = $(CC_OPTIONS) -DFORDLL -I"$(SCIDIR)\libs\MALLOC\includes" -I"$(SCIDIR)\modules\core\includes" -I"$(SCIDIR)/libs/f2c" -I"$(SCIDIR)/modules/mexlib/includes"
+FFLAGS = $(FC_OPTIONS) -DFORDLL -I"$(SCIDIR)\libs\MALLOC\includes" -I"$(SCIDIR)\modules\core\includes" -I"$(SCIDIR)/libs/f2c" -I"$(SCIDIR)/modules/mexlib/includes"
+EXTRA_LDFLAGS =
+!include $(SCIDIR1)\modules\dynamic_link\src\scripts\Makedll.incl
diff --git a/modules/mexlib/examples/mexdll/demo.sce b/modules/mexlib/examples/mexdll/demo.sce
new file mode 100755
index 000000000..4a81d2ef1
--- /dev/null
+++ b/modules/mexlib/examples/mexdll/demo.sce
@@ -0,0 +1,23 @@
+
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// Allan CORNET
+// INRIA 2007
+
+cd "SCI/modules/mexlib/examples/mexdll"
+
+if (findmsvccompiler() <> "unknown") then
+ unix_w("lib /def:xtimesy.def");
+ unix_w("nmake /f makelib.mak all");
+
+ addinter("libtst.dll","libtst","xtimesy")
+ xtimesy(2,3)
+
+end
diff --git a/modules/mexlib/examples/mexdll/libtst.c b/modules/mexlib/examples/mexdll/libtst.c
new file mode 100755
index 000000000..0a19c7a38
--- /dev/null
+++ b/modules/mexlib/examples/mexdll/libtst.c
@@ -0,0 +1,25 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) INRIA
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include <mex.h>
+extern Gatefunc mexFunction;
+static GenericTable Tab[] =
+{
+ {mex_gateway, mexFunction, "errmsg"},
+};
+
+int C2F(libtst)()
+{
+ Rhs = Max(0, Rhs);
+ (*(Tab[Fin - 1].f))(Tab[Fin - 1].name, Tab[Fin - 1].F);
+ return 0;
+}
diff --git a/modules/mexlib/examples/mexdll/readme.txt b/modules/mexlib/examples/mexdll/readme.txt
new file mode 100755
index 000000000..80d46e1d4
--- /dev/null
+++ b/modules/mexlib/examples/mexdll/readme.txt
@@ -0,0 +1,8 @@
+Linking a .mexglx, say xtimesy.mexglx, file with Scilab.
+VISUAL C++ environment.
+
+exec(SCI+'/modules/mexlib/examples/mexdll/demo.sce');
+
+Note that for each mex .dll file a second .dll file must be
+constructed. It is not possible to call several mex .dll
+files by a unique gateway (such as libtst).
diff --git a/modules/mexlib/examples/mexdll/xtimesy.def b/modules/mexlib/examples/mexdll/xtimesy.def
new file mode 100755
index 000000000..54b598032
--- /dev/null
+++ b/modules/mexlib/examples/mexdll/xtimesy.def
@@ -0,0 +1,3 @@
+LIBRARY xtimesy.dll
+EXPORTS
+ mexFunction
diff --git a/modules/mexlib/examples/mexdll/xtimesy.dll b/modules/mexlib/examples/mexdll/xtimesy.dll
new file mode 100755
index 000000000..58fbedc37
--- /dev/null
+++ b/modules/mexlib/examples/mexdll/xtimesy.dll
Binary files differ
diff --git a/modules/mexlib/examples/mexglx/README b/modules/mexlib/examples/mexglx/README
new file mode 100755
index 000000000..320fab67e
--- /dev/null
+++ b/modules/mexlib/examples/mexglx/README
@@ -0,0 +1,85 @@
+Linking a .mexglx, say foo.mexglx, file with Scilab.
+(Assuming foo.mexglx has been created by the Matlab's mex script).
+
+0/ Here I create the file foo.mexglx using Scilab, just to have a
+ proper foo.mexglx for testing (note that I copy libfoo.so to foo.mexglx
+ but internally the name libfoo.so is contained in foo.mexglx and
+ the dynamic loader will search libfoo.so (see below)).
+
+-->ilib_for_link("foo",['foo.o'],[],"c");
+-->host('cp libfoo.so foo.mexglx');
+
+ If I have matlab
+
+-->host('mex -V4 foo.c');
+
+1/ If necessary, create empty libmx.so libmex.so and libmat.so which
+ could be required by the .mexglx file.
+ (If "ldd foo.mexglx" shows a dependency).
+
+This is done by the following commands:
+
+-->ilib_for_link("mx",[],[],"c");
+-->ilib_for_link("mex",[],[],"c");
+-->ilib_for_link("mat",[],[],"c");
+
+2/link the (almost empty) .so files with Scilab
+
+// Note that this is not really usefull
+//-->link ./libmx.so;
+//-->link ./libmex.so;
+//-->link ./libmat.so;
+
+3/link foo.mexglx with Scilab
+-->link ./foo.mexglx;
+
+4/ Make a dynamic library with the provided C routine (libtst.c file).
+ Note that you can use libtst.c file as is and that the entrypoint
+ MUST BE mexFunction. If you have more than one mexglx files you
+ will need to copy libtst.c and change only the function name
+ (this is described below)
+
+-->ilib_for_link("tst",['libtst.o'],[],"c");
+
+5/At Scilab prompt enter:
+
+-->addinter('./libtst.so','libtst','foo');
+OR addinter ./libtst.so libtst foo to link libtst.so with Scilab.
+Note that foo is the name of the Scilab function.
+
+6/call the mexfunction:
+-->foo(5,'foo')
+
+Note that the mexfunction is called through the libtst function
+using the entrypoint 'libtst' (not mexFunction!).
+If several mexFunction are used, one should build several
+libtst.c file, one for each mexfunction, using a different name
+e.g. libtst1.c libtst2.c ... Each mexFunction must be called through a
+different entrypoint.
+
+Here Makelib and libtst.c are generic files while
+Makextimesy and libxtimesy.c are adapted to xtimesy.mexglx.
+
+*********************************************
+
+OR ...
+ld -shared -o foo.so libtst.so foo.mexglx -rpath `pwd`
+addinter('./foo.so','libtst','foo');
+
+EXAMPLE:
+mexname='xtimesy';
+mputl(strsubst(mgetl('libtst.c'),'libtst',mexname),'lib'+mexname+'.c');
+mputl(strsubst(mgetl('Makelib'),'libtst','lib'+mexname),'Make'+mexname);
+//make -f Makextimesy
+// ld -shared -o xtimesy.so libxtimesy.o xtimesy.mexglx -rpath `pwd`
+//OR :
+link ./libmx.so;
+link ./libmex.so;
+link ./libmat.so;
+link ./xtimesy.mexglx;
+addinter('./libxtimesy.so','xtimesy','xtimesy')
+xtimesy(2,3)
+
+
+
+
diff --git a/modules/mexlib/examples/mexglx/foo.c b/modules/mexlib/examples/mexglx/foo.c
new file mode 100755
index 000000000..025b29557
--- /dev/null
+++ b/modules/mexlib/examples/mexglx/foo.c
@@ -0,0 +1,70 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) INRIA
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include <stdio.h>
+#include "mex.h"
+
+#define STRING "hello world"
+
+void ABcopy (double *a, double *b, int mn);
+
+void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
+{
+ mxArray *ptrB;
+ double *A, *B;
+ int m, n, it, strl;
+ char *str;
+ if (nrhs != 2)
+ {
+ mexErrMsgTxt("This function requires 2 inputs!");
+ }
+ if (nlhs > 3)
+ {
+ mexErrMsgTxt("This function requires at most 3 outputs!");
+ }
+ if (! mxIsNumeric(prhs[0]))
+ {
+ mexErrMsgTxt("First argument must be numeric matrix.");
+ }
+ if (! mxIsChar(prhs[1]))
+ {
+ mexErrMsgTxt("Second argument must be a string.");
+ }
+ m = mxGetM(prhs[0]);
+ n = mxGetN(prhs[0]);
+ A = mxGetPr(prhs[0]);
+ it = 0;
+ ptrB = mxCreateDoubleMatrix(n, m, it);
+ m = mxGetM(ptrB);
+ n = mxGetN(ptrB);
+ B = mxGetPr(ptrB);
+ ABcopy(A, B, m * n);
+ plhs[0] = prhs[0];
+ plhs[1] = ptrB;
+ m = mxGetM(prhs[1]);
+ strl = mxGetN(prhs[1]);
+ str = mxCalloc(m * strl + 1, sizeof(char));
+ mxGetString(prhs[1], str, m * strl);
+ plhs[2] = mxCreateString(str);
+}
+
+void ABcopy(a, b, mn)
+double *a;
+double *b;
+int mn;
+{
+ int i;
+ for ( i = 0 ; i < mn ; i++)
+ {
+ b[i] = a[i] + 33.0 + i;
+ }
+}
diff --git a/modules/mexlib/examples/mexglx/libtst.c b/modules/mexlib/examples/mexglx/libtst.c
new file mode 100755
index 000000000..0a19c7a38
--- /dev/null
+++ b/modules/mexlib/examples/mexglx/libtst.c
@@ -0,0 +1,25 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) INRIA
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include <mex.h>
+extern Gatefunc mexFunction;
+static GenericTable Tab[] =
+{
+ {mex_gateway, mexFunction, "errmsg"},
+};
+
+int C2F(libtst)()
+{
+ Rhs = Max(0, Rhs);
+ (*(Tab[Fin - 1].f))(Tab[Fin - 1].name, Tab[Fin - 1].F);
+ return 0;
+}
diff --git a/modules/mexlib/examples/mexglx/test.dia.ref b/modules/mexlib/examples/mexglx/test.dia.ref
new file mode 100755
index 000000000..3b4cd1e7c
--- /dev/null
+++ b/modules/mexlib/examples/mexglx/test.dia.ref
@@ -0,0 +1,102 @@
+
+// Linking a0.mexglx, say foo.mexglx, file with Scilab.
+
+// (Assuming foo.mexglx has been created by the Matlab's mex script).
+
+// 0/ Here I create the file foo.mexglx using Scilab, just to have a
+
+// proper foo.mexglx for testing
+
+
+ilib_for_link("foo",['foo.o'],[],"c");
+ generate a loader file
+ generate a Makefile
+ running the makefile
+ compilation of foo
+ building shared library (be patient)
+
+host('cp libfoo.so foo.mexglx');
+
+
+// 1/ If necessary, create empty libmx.so libmex.so and libmat.so which
+
+// could be required by the0.mexglx file.
+
+// (If "ldd foo.mexglx" shows a dependency).
+
+// This is done by the following commands:
+
+
+ilib_for_link("mx",[],[],"c");
+ generate a loader file
+ generate a Makefile
+ running the makefile
+ building shared library (be patient)
+
+ilib_for_link("mex",[],[],"c");
+ generate a loader file
+ generate a Makefile
+ running the makefile
+ building shared library (be patient)
+
+ilib_for_link("mat",[],[],"c");
+ generate a loader file
+ generate a Makefile
+ running the makefile
+ building shared library (be patient)
+
+
+// 2/link the (almost empty)0.so files with Scilab
+
+// Note that this is not really usefull
+
+
+//link0./libmx.so;
+
+//link0./libmex.so;
+
+//link0./libmat.so;
+
+
+// 3/link foo.mexglx with Scilab
+
+link0./foo.mexglx;
+shared archive loaded
+Link done
+
+
+// 4/ Make a dynamic library with the provided C routine (libtst.c file).
+
+// Note that you can use libtst.c file as is and that the entrypoint
+
+// MUST BE mexFunction. If you have more than one mexglx files you
+
+// will need to copy libtst.c and change only the function name
+
+// (this is described below)
+
+
+ilib_for_link("tst",['libtst.o'],[],"c");
+ generate a loader file
+ generate a Makefile
+ running the makefile
+ compilation of libtst
+ building shared library (be patient)
+
+
+//5/At Scilab prompt enter:
+
+
+addinter('./libtst.so','libtst','foo');
+shared archive loaded
+
+
+// 6/call the mexfunction:
+
+
+foo(5,'test string')
+ ans =
+
+ 5.
+
+
diff --git a/modules/mexlib/examples/mexglx/test.sce b/modules/mexlib/examples/mexglx/test.sce
new file mode 100755
index 000000000..2a81e22e0
--- /dev/null
+++ b/modules/mexlib/examples/mexglx/test.sce
@@ -0,0 +1,53 @@
+
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// Linking a .mexglx, say foo.mexglx, file with Scilab.
+// (Assuming foo.mexglx has been created by the Matlab's mex script).
+// 0/ Here I create the file foo.mexglx using Scilab, just to have a
+// proper foo.mexglx for testing
+
+ilib_for_link("foo",["foo.o"],[],"c");
+host("cp libfoo.so foo.mexglx");
+
+// 1/ If necessary, create empty libmx.so libmex.so and libmat.so which
+// could be required by the .mexglx file.
+// (If "ldd foo.mexglx" shows a dependency).
+// This is done by the following commands:
+
+ilib_for_link("mx",[],[],"c");
+ilib_for_link("mex",[],[],"c");
+ilib_for_link("mat",[],[],"c");
+
+// 2/link the (almost empty) .so files with Scilab
+// Note that this is not really usefull
+
+//link ./libmx.so;
+//link ./libmex.so;
+//link ./libmat.so;
+
+// 3/link foo.mexglx with Scilab
+link ./foo.mexglx;
+
+// 4/ Make a dynamic library with the provided C routine (libtst.c file).
+// Note that you can use libtst.c file as is and that the entrypoint
+// MUST BE mexFunction. If you have more than one mexglx files you
+// will need to copy libtst.c and change only the function name
+// (this is described below)
+
+ilib_for_link("tst",["libtst.o"],[],"c");
+
+//5/At Scilab prompt enter:
+
+addinter("./libtst.so","libtst","foo");
+
+// 6/call the mexfunction:
+
+foo(5,"test string")
+
diff --git a/modules/mexlib/examples/mexglx/test1.sce b/modules/mexlib/examples/mexglx/test1.sce
new file mode 100755
index 000000000..41c2eb46f
--- /dev/null
+++ b/modules/mexlib/examples/mexglx/test1.sce
@@ -0,0 +1,45 @@
+
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) INRIA
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// Linking a .mexglx, say foo.mexglx, file with Scilab.
+// (Assuming foo.mexglx has been created by the Matlab's mex script).
+// 0/ Here I create the file foo.mexglx using Scilab, just to have a
+// proper foo.mexglx for testing
+
+ilib_for_link("foo",["foo.o"],[],"c");
+host("cp libfoo.so foo.mexglx");
+
+// 1/ If necessary, create empty libmx.so libmex.so and libmat.so which
+// could be required by the .mexglx file.
+// (If "ldd foo.mexglx" shows a dependency).
+// This is done by the following commands:
+
+ilib_for_link("mx",[],[],"c");
+ilib_for_link("mex",[],[],"c");
+ilib_for_link("mat",[],[],"c");
+
+// 4/ Make a dynamic library with the provided C routine (libtst.c file).
+// Note that you can use libtst.c file as is and that the entrypoint
+// MUST BE mexFunction. If you have more than one mexglx files you
+// will need to copy libtst.c and change only the function name
+// (this is described below)
+
+// just make a lib*.so from ./foo.mexglx or else libtool will ignore ./foo.mexglx
+
+host("cp ./foo.mexglx libfoo_mex.so")
+ilib_for_link("tst",["libtst.o"]," -R`pwd` -L`pwd` -lfoo_mex -lmx -lmex -lmat","c");
+
+//5/At Scilab prompt enter:
+
+addinter("./libtst.so","libtst","foo");
+
+// 6/call the mexfunction:
+
+foo(5,"test string")