+ Scilab is a scientific software package for numerical computations providing a powerful open computing environment for engineering and scientific applications that is mostly compatible with MATLAB.More information can be found at www.scilab.org.
+
+
+
+ This chapter is intended to give an introduction to using the module. You should also read the SWIG documentation that is not specific to Scilab.Also, there are a dozen or so examples in the Examples/Scilab directory.
+
+
+
36.1 Preliminaries
+
+
+
+The current SWIG implemention is based on Scilab 5.1.1. Support for other higher versions has not been tested, nor has support for any OS other than Linux.
+
+
+
36.2 Running SWIG
+
+
+
+Let's start with a very simple SWIG interface file:
+
+
+
%module example
+%{
+#include "example.h"
+%}
+int gcd(int x, int y);
+extern double Foo;
+
+
+To build an Scilab module, run SWIG using the -scilab option.
+
+
+
$ swig -scilab example.i
+
+
+This creates a C source file example_wrap.cand a interface file builder.sce. The generated C source file contains the low-level wrappers that need to be compiled and linked with the rest of your C application (in this case, the gcd implementation) to create an extension module. And the builder.sce is used to generate the *.so file.
+
+
+
+The swig command line has a number of options you can use, like to redirect it's output. Use swig --help to learn about these.
+
+
+
36.2.1 Compiling a dynamic module
+
+
+
+Scilab modules are shared objects having the ".so" suffix.
+Building such a file is usually done with the "exec" command (within Scilab itself) For example,
+
+
+
+$ ./scilab
+--> exec builder.sce
+
+
+
+ where builder.sce is the interface file generated by the swig. It looks like the following:
+
+"ilib_name" is the name of the lib we want to build. "table" contains the name of the C file and its wrapper file. "files" represent the .o file we want to compile, and"libs" is other libs we want to use.
+
+
+
+ "exec builder.sce" will produce *.so,and a file called "loader.sce" which contains how to load the module. Loading it into Scilab is then a matter of invoking
+
+
+
Scilab:1> exec loader.sce
+
+
36.2.2 Using your module
+
+
+
+Assuming all goes well, you will be able to do this:
+
+
+The SWIG module directive specifies the name of the Scilab module. If you want to load the module, you'll need a file called "loader.sce" which is usually generated by the command "exec builder.sce". The loader.sce looks as following:
+
+
+
+// ------------------------------------------------------
+// generated by builder.sce: Please do not edit this file
+// ------------------------------------------------------
+
+libexamplelib_path = get_file_path('loader.sce');
+list_functions = [ 'gcd';
+ 'Foo_set';
+ 'Foo_get';
+];
+addinter(libexamplelib_path+'/libexamplelib.so','libexamplelib',list_functions);
+// remove temp. variables on stack
+clear libexamplelib_path;
+clear list_functions;
+clear get_file_path;
+// ------------------------------------------------------
+
+
+
+After you run the command "exec loader.sce", you could use the module.
+
+
+
36.3.2 Functions
+
+
+
+Global functions are wrapped as new Scilab built-in functions. For example,
+
+
+
%module example
+int fact(int n);
+
+
+ creates a built-in function fact(n) that works exactly like you think it does:
+
+
+
Scilab:1>fact(4)
+ant=24
+
diff --git a/Examples/scilab/simple/example.c b/Examples/scilab/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/Examples/scilab/simple/example.c
@@ -0,0 +1,18 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+
diff --git a/Examples/scilab/simple/example.i b/Examples/scilab/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/Examples/scilab/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/Examples/scilab/simple/runme.sci b/Examples/scilab/simple/runme.sci
new file mode 100644
index 000000000..1777a7750
--- /dev/null
+++ b/Examples/scilab/simple/runme.sci
@@ -0,0 +1,23 @@
+// builder the *.so
+exec builder.sce;
+
+//loader the *.so
+exec loader.sce;
+
+// Call our gcd() function
+x = 42;
+y = 105;
+g = gcd(x,y);
+printf("The gcd of %d and %d is %d\n",x,y,g);
+
+//Manipulate the Foo global variable
+
+// Output its current value
+Foo_get()
+
+// Change its value
+Foo_set = 3.1415926
+
+//See if the change took effect
+Foo_get
+
diff --git a/Lib/scilab/scifragments.swg b/Lib/scilab/scifragments.swg
new file mode 100644
index 000000000..e69de29bb
diff --git a/Lib/scilab/scilab.swg b/Lib/scilab/scilab.swg
new file mode 100644
index 000000000..0d280f23f
--- /dev/null
+++ b/Lib/scilab/scilab.swg
@@ -0,0 +1,4 @@
+%include
+%include
+%include
+
diff --git a/Lib/scilab/scitypemaps.swg b/Lib/scilab/scitypemaps.swg
new file mode 100644
index 000000000..336af20f3
--- /dev/null
+++ b/Lib/scilab/scitypemaps.swg
@@ -0,0 +1,123 @@
+
+// Include fundamental fragemt definitions
+%include
+
+// Look for user fragments file.
+%include
+
+// Scilab fragments for primitive types
+%include
+
+// Include the unified typemap library
+//%include
+
+
+%typemap(in) char (int m, int n,int l),
+ signed char (int m,int n,int l),
+ unsigned char(int m,int n,int l)
+{
+ if (GetType($argnum) == sci_strings)
+ {
+ GetRhsVar($argnum,STRING_DATATYPE,&m,&n,&l);
+ $1=($1_ltype)(*cstk(l));
+ }
+ else
+ Scierror(999,"error ...\n");
+}
+
+%typemap(in) short (int m, int n,int l),
+ unsigned short (int m,int n,int l),
+ int(int m,int n,int l),
+ unsigned int(int m, int n,int l),
+ long(int m,int n,int l),
+ unsigned long(int m,int n,int l),
+ double(int m,int n,int l)
+
+
+{
+ if (GetType($argnum) == sci_matrix)
+ {
+ GetRhsVar($argnum,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&l);
+ $1=($1_ltype)(*stk(l));
+ }
+ else
+ Scierror(999,"error ...\n");
+}
+
+%typemap(in) float (int m, int n,int l)
+{
+ if (GetType($argnum) == sci_matrix)
+ {
+ GetRhsVar($argnum,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&l);
+ $1=($1_ltype)(*stk(l));
+ }
+ else
+ Scierror(999,"error ...\n");
+}
+
+%typemap(in) char *(int m,int n,int l)
+{
+ if (GetType($argnum) == sci_strings)
+ {
+ GetRhsVar($argnum,STRING_DATATYPE,&m,&n,&l);
+ $1=($1_ltype)strdup(cstk(l));
+ }
+ else
+ Scierror(999,"error ...\n");
+
+}
+
+
+%typemap(out) char (int m, int n,int l),
+ signed char (int m,int n,int l),
+ unsigned char(int m,int n,int l)
+{
+ m=1,n=1;
+ CreateVar(Rhs+1,STRING_DATATYPE,&m,&n,&l);
+ *cstk(l)=$1;
+ LhsVar(1)=Rhs+1;
+}
+
+%typemap(out) short (int m, int n,int l),
+ unsigned short (int m,int n,int l),
+ int(int m,int n,int l),
+ unsigned int(int m, int n,int l),
+ long(int m,int n,int l),
+ unsigned long(int m,int n,int l),
+ double(int m,int n,int l)
+{
+ m=1,n=1;
+ CreateVar(Rhs+1,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&l);
+ *stk(l)=(double)$1;
+ LhsVar(1)=Rhs+1;
+}
+
+%typemap(out) float (int m, int n,int l)
+{
+ m=1,n=1;
+ CreateVar(Rhs+1,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&l);
+ *stk(l)=(double)$1;
+ LhsVar(1)=Rhs+1;
+}
+
+
+%typemap(out) char *(int m,int n, int l)
+{
+ m=1;
+ if ($1)
+ n = (int)strlen($1);
+ else
+ n = (int)strlen("");
+
+ CreateVar(Rhs+1,STRING_DATATYPE ,&m,&n,&l);
+ if ($1) strcpy(cstk(l),$1);
+ else strcpy(cstk(l),"");
+ LhsVar(1) = Rhs+1;
+}
+
+
+%typemap(out,noblock=1) void
+{
+}
+
+
diff --git a/Lib/scilab/std_string.i b/Lib/scilab/std_string.i
new file mode 100644
index 000000000..dc1378ae6
--- /dev/null
+++ b/Lib/scilab/std_string.i
@@ -0,0 +1 @@
+%include
diff --git a/Lib/scilab/std_vector.i b/Lib/scilab/std_vector.i
new file mode 100644
index 000000000..03364822d
--- /dev/null
+++ b/Lib/scilab/std_vector.i
@@ -0,0 +1,10 @@
+%fragment("StdVectorTraits","header")
+%{
+%}
+
+#define %swig_vector_methods(Type...) %swig_sequence_methods(Type)
+#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type);
+
+
+
+%include
\ No newline at end of file
diff --git a/Lib/scilab/stl.i b/Lib/scilab/stl.i
new file mode 100644
index 000000000..9656ee6d4
--- /dev/null
+++ b/Lib/scilab/stl.i
@@ -0,0 +1,8 @@
+/* initial STL definition. extended as needed in each language */
+%include std_common.i
+%include std_vector.i
+%include std_string.i
+
+
+
+
diff --git a/Makefile.in b/Makefile.in
index 42fa935d6..84d327754 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -75,6 +75,7 @@ skip-clisp = test -n "@SKIP_CLISP@"
skip-cffi = test -n "@SKIP_CFFI@"
skip-uffi = test -n "@SKIP_UFFI@"
skip-r = test -n "@SKIP_R@"
+skip-scilab = test -n "@SKIP_SCILAB@"
# Additional dependencies for some tests
skip-gcj = test -n "@SKIP_GCJ@"
@@ -110,7 +111,7 @@ check-aliveness:
@$(skip-modula3) || ./$(TARGET) -modula3 -help
@$(skip-lua) || ./$(TARGET) -lua -help
@$(skip-r) || ./$(TARGET) -r -help
-
+ @$(skip-scilab) || ./$(TARGET) -scilab -help
check-ccache:
test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) check)
@@ -135,8 +136,8 @@ check-examples: \
check-clisp-examples \
check-uffi-examples \
check-cffi-examples \
- check-r-examples
-
+ check-r-examples \
+ check-scilab-examples
tcl_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/tcl/check.list)
perl5_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/perl5/check.list)
python_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/python/check.list)
@@ -157,6 +158,7 @@ clisp_examples :=
uffi_examples :=
cffi_examples :=
r_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/r/check.list)
+scilab_examples :=
# all examples
check-%-examples :
@@ -203,8 +205,8 @@ check-gifplot: \
check-chicken-gifplot \
# check-lua-gifplot \
# check-csharp-gifplot \
-# check-modula3-gifplot
-
+# check-modula3-gifplot \
+ check-scilab-gifplot
check-%-gifplot: gifplot-library
@if test -z "$(skip-$*)"; then \
echo $* unknown; \
@@ -250,8 +252,8 @@ check-test-suite: \
check-uffi-test-suite \
check-cffi-test-suite \
check-chicken-test-suite \
- check-r-test-suite
-
+ check-r-test-suite \
+ check-scilab-test-suite
check-%-test-suite:
@if test -z "$(skip-$*)"; then \
echo $* unknown; \
@@ -301,8 +303,8 @@ all-test-suite: \
all-uffi-test-suite \
all-cffi-test-suite \
all-chicken-test-suite \
- all-r-test-suite
-
+ all-r-test-suite \
+ all-scilab-test-suite
all-%-test-suite:
@$(MAKE) -k -s check-$*-test-suite ACTION=all
@@ -328,7 +330,8 @@ broken-test-suite: \
broken-uffi-test-suite \
broken-cffi-test-suite \
broken-chicken-test-suite \
- broken-r-test-suite
+ broken-r-test-suite \
+ broken-scilab-test-suite
broken-%-test-suite:
@$(MAKE) -k -s check-$*-test-suite ACTION=broken
@@ -442,7 +445,7 @@ install-main:
@$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@
lib-languages = gcj typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \
- pike chicken csharp modula3 allegrocl clisp lua cffi uffi r
+ pike chicken csharp modula3 allegrocl clisp lua cffi uffi r scilab
lib-modules = std
diff --git a/README b/README
index 333efbb6a..92d0591ba 100644
--- a/README
+++ b/README
@@ -59,7 +59,7 @@ Major contributors include:
Martin Froehlich (Guile)
Marcio Luis Teixeira (Guile)
Duncan Temple Lang (R)
- Baozeng Ding (Scilab)
+ Baozeng Ding (Scilab)
Past contributors include:
James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran
diff --git a/Source/Makefile.am b/Source/Makefile.am
index 84c595bc0..829dce85d 100644
--- a/Source/Makefile.am
+++ b/Source/Makefile.am
@@ -63,6 +63,7 @@ eswig_SOURCES = CParse/cscanner.c \
Modules/r.cxx \
Modules/ruby.cxx \
Modules/s-exp.cxx \
+ Modules/scilab.cxx \
Modules/swigmain.cxx \
Modules/tcl8.cxx \
Modules/typepass.cxx \
diff --git a/Source/Modules/scilab.cxx b/Source/Modules/scilab.cxx
new file mode 100644
index 000000000..2f78a4145
--- /dev/null
+++ b/Source/Modules/scilab.cxx
@@ -0,0 +1,288 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * scilab.cxx
+ *
+ * Scilab language module for SWIG.
+ * ----------------------------------------------------------------------------- */
+
+char cvsroot_scilab_cxx[] = "$Id$";
+
+#include "swigmod.h"
+
+static const char *usage = (char *) "\
+Scilab Options (available with -scilab)\n\
+ (none yet)\n\n";
+
+
+class SCILAB:public Language {
+ private:
+ File *f_begin;
+ File *f_runtime;
+ File *f_header;
+ File *f_wrappers;
+ File *f_init;
+ File *f_builder;
+
+ public:
+ SCILAB():f_begin(0), f_runtime(0), f_header(0),f_wrappers(0),
+ f_init(0) {}
+
+
+ /* ------------------------------------------------------------
+ * main()
+ * ------------------------------------------------------------ */
+
+ virtual void main(int argc, char *argv[]) {
+ for (int i = 1; i < argc; i++) {
+ if (argv[i]) {
+ if (strcmp(argv[i], "-help") == 0) {
+ fputs(usage, stderr);
+ }
+ }
+ }
+
+ //Set language-specific subdirectory in SWIG library
+ SWIG_library_directory("scilab");
+
+ // Add a symbol to the parser for conditional compilation
+ Preprocessor_define("SWIGSCILAB 1", 0);
+
+ // Set scilab configuration file
+ SWIG_config_file("scilab.swg");
+
+ //Set typemap for scilab
+ SWIG_typemap_lang("scilab");
+ }
+
+ /* ---------------------------------------------------------------------
+ * top()
+ * --------------------------------------------------------------------- */
+
+ virtual int top(Node *n) {
+
+ Node *mod = Getattr(n, "module");
+
+ /*Get the name of the module*/
+ String *module = Getattr(n, "name");
+
+ /*One output file for as the wrapper file*/
+ String *outfile = Getattr(n, "outfile");
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+
+ /*Another output file to generate the .so or .dll */
+ String *builder = NewString("builder.sce");
+ f_builder=NewFile(builder,"w",SWIG_output_files());
+
+ /* Initialize all of the output files */
+ if (!f_begin) {
+ FileErrorDisplay(outfile);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ f_runtime = NewString("");
+ f_header = NewString("");
+ f_wrappers = NewString("");
+ f_init = NewString("");
+
+ /* Register file targets with the SWIG file handler */
+ Swig_register_filebyname("begin", f_begin);
+ Swig_register_filebyname("runtime", f_runtime);
+ Swig_register_filebyname("header", f_header);
+ Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("init", f_init);
+
+ /*Insert the banner at the beginning */
+ Swig_banner(f_begin);
+
+ /*Include some header file of scilab*/
+ Printf(f_runtime, "#include \"stack-c.h\"\n");
+ Printf(f_runtime, "#include \"sciprint.h\"\n");
+ Printf(f_runtime, "#include \"Scierror.h\"\n");
+
+ /*Initialize the builder.sce file*/
+ Printf(f_builder,"ilib_name = \"%slib\";\n",module);
+ Printf(f_builder,"files = [\"%s\",\"%s.o\"];\n", outfile,module);
+ Printf(f_builder,"libs = [];\n");
+ Printf(f_builder, "table = [");
+
+
+ /*Emit code for children*/
+ Language::top(n);
+
+ /*Finish off the builder.sce file*/
+ Printf(f_builder,"];\n");
+ Printf(f_builder,"ilib_build(ilib_name,table,files,libs);");
+
+ /*Dump out all the files*/
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
+
+ /* Close all of the files */
+ Delete(f_init);
+ Delete(f_wrappers);
+ Delete(f_header);
+ Delete(f_runtime);
+ Close(f_begin);
+ Close(f_builder);
+ Delete(f_begin);
+ Delete(f_builder);
+
+ return SWIG_OK;
+ }
+
+ /* ----------------------------------------------------------------------
+ * functionWrapper()
+ * ---------------------------------------------------------------------- */
+
+ virtual int functionWrapper(Node *n) {
+
+ // A new wrapper function object
+ Wrapper *f = NewWrapper();
+
+ Parm *p;
+ String *tm;
+ int j;
+
+ //Get the useful information from the node
+ String *nodeType = Getattr(n, "nodeType");
+ int constructor = (!Cmp(nodeType, "constructor"));
+ int destructor = (!Cmp(nodeType, "destructor"));
+ String *storage = Getattr(n, "storage");
+
+ bool overloaded = !!Getattr(n, "sym:overloaded");
+ bool last_overload = overloaded && !Getattr(n, "sym:nextSibling");
+ String *iname = Getattr(n, "sym:name");
+ String *wname = Swig_name_wrapper(iname);
+ String *overname = Copy(wname);
+ SwigType *d = Getattr(n, "type");
+ ParmList *l = Getattr(n, "parms");
+
+ if (!overloaded && !addSymbol(iname, n))
+ return SWIG_ERROR;
+
+ if (overloaded)
+ Append(overname, Getattr(n, "sym:overname"));
+
+ Printv(f->def, "int ", overname, " (char *fname){", NIL);
+
+ // Emit all of the local variables for holding arguments
+ emit_parameter_variables(l, f);
+
+ //Attach typemaps to the parameter list
+ emit_attach_parmmaps(l, f);
+ Setattr(n, "wrap:parms", l);
+
+ // Get number of required and total arguments
+ int num_arguments = emit_num_arguments(l);
+ int num_required = emit_num_required(l);
+ int varargs = emit_isvarargs(l);
+
+ if (constructor && num_arguments == 1 && num_required == 1) {
+ if (Cmp(storage, "explicit") == 0) {
+ Node *parent = Swig_methodclass(n);
+ if (GetFlag(parent, "feature:implicitconv")) {
+ String *desc = NewStringf("SWIGTYPE%s", SwigType_manglestr(Getattr(n, "type")));
+ Printf(f->code, "if (SWIG_CheckImplicit(%s)) SWIG_fail;\n", desc);
+ Delete(desc);
+ }
+ }
+ }
+
+ //Walk the function parameter list and generate code to get arguments
+ for (j = 0, p = l; j < num_arguments; ++j) {
+ while (checkAttribute(p, "tmap:in:numinputs", "0")) {
+ p = Getattr(p, "tmap:in:next");
+ }
+
+ SwigType *pt = Getattr(p, "type");
+
+ // Get typemap for this argument
+ String *tm = Getattr(p, "tmap:in");
+
+ if (tm) {
+ if (!tm || checkAttribute(p, "tmap:in:numinputs", "0")) {
+ p = nextSibling(p);
+ continue;
+ }
+ String *getargs = NewString("");
+ Printv(getargs, tm, NIL);
+ Printv(f->code, getargs, "\n", NIL);
+ Delete(getargs);
+ p = Getattr(p, "tmap:in:next");
+ continue;
+ } else {
+ Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
+ break;
+ }
+ }
+
+ Setattr(n, "wrap:name", overname);
+
+ // Now write code to make the function call
+ Swig_director_emit_dynamic_cast(n, f);
+ String *actioncode = emit_action(n);
+
+ //Insert the return variable
+ emit_return_variable(n, d, f);
+
+ if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
+
+ Printf(f->code, "%s\n", tm);
+
+ }
+ else {
+ Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), iname);
+ }
+
+ /* Insert argument output code */
+ String *outarg = NewString("");
+ for (p = l; p;) {
+ if ((tm = Getattr(p, "tmap:argout"))) {
+ Replaceall(tm, "$result", "_outp");
+ //Replaceall(tm, "$arg", Getattr(p, "emit:input"));
+ //Replaceall(tm, "$input", Getattr(p, "emit:input"));
+ Printv(outarg, tm, "\n", NIL);
+ p = Getattr(p, "tmap:argout:next");
+ } else {
+ p = nextSibling(p);
+ }
+ }
+ Printv(f->code, outarg, NIL);
+
+ /* Finish the the code for the function */
+ Printf(f->code, "return 0;\n");
+ Printf(f->code, "}\n");
+
+ Replaceall(f->code, "$symname", iname);
+
+ /* Dump the wrapper function */
+ Wrapper_print(f, f_wrappers);
+ DelWrapper(f);
+ Printf(f_builder, "\"%s\",\"%s\";",iname,wname);
+
+ Delete(overname);
+ Delete(wname);
+ Delete(outarg);
+
+ return SWIG_OK;
+ }
+
+ /* -----------------------------------------------------------------------
+ * variableWrapper()
+ * ----------------------------------------------------------------------- */
+
+ virtual int variableWrapper(Node *n) {
+
+ Language::variableWrapper(n); /* Default to functions */
+
+ return SWIG_OK;
+ }
+
+};
+
+extern "C" Language *swig_scilab(void) {
+ return new SCILAB();
+}
diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx
index 4208a8c6f..e048935d7 100644
--- a/Source/Modules/swigmain.cxx
+++ b/Source/Modules/swigmain.cxx
@@ -47,6 +47,7 @@ extern "C" {
Language *swig_cffi(void);
Language *swig_uffi(void);
Language *swig_r(void);
+ Language *swig_scilab(void);
}
struct swig_module {
@@ -81,6 +82,7 @@ static swig_module modules[] = {
{"-python", swig_python, "Python"},
{"-r", swig_r, "R (aka GNU S)"},
{"-ruby", swig_ruby, "Ruby"},
+ {"-scilab",swig_scilab,"Scilab"},
{"-sexp", swig_sexp, "Lisp S-Expressions"},
{"-tcl", swig_tcl, "Tcl"},
{"-tcl8", swig_tcl, 0},
diff --git a/configure.in b/configure.in
index 4edc8e1ae..f8e782af5 100644
--- a/configure.in
+++ b/configure.in
@@ -915,6 +915,70 @@ AC_SUBST(OCTAVEDYNAMICLINKING)
AC_SUBST(OCTAVELIB)
AC_SUBST(OCTAVECCFLAGS)
+#----------------------------------------------------------------
+# Look for Scilab
+#----------------------------------------------------------------
+
+SCILABBIN=
+SCILABDYNAMICLINKING=
+
+
+AC_ARG_WITH(scilab, AS_HELP_STRING([--without-scilab], [Disable Scilab])
+AS_HELP_STRING([--with-scilab=path], [Set location of Scilab executable]),[SCILABBIN="$withval"], [SCILABBIN=yes])
+
+# First, check for "--without-scilab" or "--with-scilab=no".
+if test x"${SCILABBIN}" = xno -o x"${with_alllang}" = xno ; then
+AC_MSG_NOTICE([Disabling Scilab])
+SCILAB=
+else
+
+# First figure out what the name of Scilab is
+
+if test "x$SCILABBIN" = xyes; then
+AC_CHECK_PROGS(SCILAB, scilab)
+else
+SCILAB="$SCILABBIN"
+fi
+
+
+AC_MSG_CHECKING(for Scilab header files)
+if test -n "$SCILAB"; then
+ SCILABDIR="/usr/include"
+ if test "$SCILABDIR" != ""; then
+ dirs="$SCILABDIR"
+ SCILABEXT=""
+ for i in $dirs; do
+ if test -r $i/scilab/stack.h; then
+ SCILABEXT="$i"
+ break;
+ fi
+ if test -r $i/scilab/scialab/stack.h; then
+ SCILABEXT="$i/scilab"
+ break;
+ fi
+ done
+ if test "$SCILABEXT" = "" ; then
+ AC_MSG_RESULT(not found)
+ else
+ AC_MSG_RESULT($SCILABEXT)
+ fi
+
+ AC_MSG_CHECKING(for Scilab compiler options)
+ SCILABCCFLAGS=""
+ AC_MSG_RESULT($SCILABCCFLAGS)
+ fi
+else
+ AC_MSG_RESULT(could not figure out how to run scilab)
+fi
+
+fi
+
+AC_SUBST(SCILAB)
+AC_SUBST(SCILABEEXT)
+AC_SUBST(SCILABDYNAMICLINKING)
+AC_SUBST(SCILABLIB)
+AC_SUBST(SCILABCCFLAGS)
+
#----------------------------------------------------------------
# Look for java
#----------------------------------------------------------------