[Libxtract-commits] SF.net SVN: libxtract: [91] trunk
Status: Alpha
Brought to you by:
postlude
From: <pos...@us...> - 2007-09-05 14:32:22
|
Revision: 91 http://libxtract.svn.sourceforge.net/libxtract/?rev=91&view=rev Author: postlude Date: 2007-09-05 07:32:17 -0700 (Wed, 05 Sep 2007) Log Message: ----------- Added java bindings. Everything seems to work OK, except test.java won't compile. Some kind of path error, but I can't work out how to fix it. Modified Paths: -------------- trunk/configure.in trunk/src/scalar.c Added Paths: ----------- trunk/swig/Makefile.am trunk/swig/java/ trunk/swig/java/Makefile.am trunk/swig/java/test.java trunk/swig/python/ trunk/swig/python/Makefile.am trunk/swig/python/test.py trunk/swig/python/xtract.i trunk/swig/xtract.i Removed Paths: ------------- trunk/swig/Makefile.am trunk/swig/test.py trunk/swig/xtract.i Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2007-09-04 19:07:55 UTC (rev 90) +++ trunk/configure.in 2007-09-05 14:32:17 UTC (rev 91) @@ -85,6 +85,19 @@ echo ]) +dnl If --enable-swig, make with java bindings +AC_ARG_WITH(java, + [ --with-java If --enable-swig - make with java bindings (default=no) ], + [with_java=true]) + +AM_CONDITIONAL(BUILD_JAVA, test "x${with_java}" = 'xtrue') + +dnl If --enable-swig, make with java bindings +AC_ARG_WITH(python, + [ --with-python If --enable-swig - make with python bindings (default=no) ], [with_python=true]) + +AM_CONDITIONAL(BUILD_PYTHON, test "x${with_python}" = 'xtrue') + dnl Are we building with fftw? if [[ "$fft" = "true" ]] ; then LDFLAGS="$LDFLAGS -lfftw3f" @@ -148,11 +161,27 @@ dnl SWIG stuff if [[ "$swig" = "true" ]] ; then AC_PROG_SWIG(1.3.21) + AC_DEFINE([BUILD_SWIG], [1], [Build the swig bindings]) +fi + +if [[ "$with_java" = "true" ]] ; then + AC_PROG_JAVAC + AC_JNI_INCLUDE_DIR + + for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS + do + CFLAGS="$CFLAGS -I$JNI_INCLUDE_DIR" + done + dnl AC_PROG_JAVAH + dnl AC_PATH_PROG(JAVAH,javah) +fi + +if [[ "$with_python" = "true" ]] ; then AM_PATH_PYTHON SWIG_PYTHON - AC_DEFINE([BUILD_SWIG], [1], [Build the swig bindings]) fi + AM_CONDITIONAL(BUILD_SWIG, test "x${swig}" = 'xtrue') dnl ------------------------------------------ @@ -232,7 +261,8 @@ AC_CONFIG_FILES([doc/documentation.doxygen libxtract.pc]) -AC_OUTPUT(Makefile src/Makefile xtract/Makefile doc/Makefile examples/Makefile examples/puredata/Makefile examples/simpletest/Makefile swig/Makefile) +dnl There must be a better way to do this... +AC_OUTPUT(Makefile src/Makefile xtract/Makefile doc/Makefile examples/Makefile examples/puredata/Makefile examples/simpletest/Makefile swig/Makefile swig/python/Makefile swig/java/Makefile) echo echo "**************************************************************" @@ -261,10 +291,15 @@ echo "PD external: no" fi if test "$swig" == "true"; then - echo "SWIG Python bindings: yes" + echo "SWIG bindings: yes" else - echo "SWIG Python bindings: no" + echo "SWIG bindings: no" fi +if test "$with_java" == "true"; then + echo "with JAVA module: yes" +else + echo "with JAVA module: no" +fi echo echo "**************************************************************" echo Modified: trunk/src/scalar.c =================================================================== --- trunk/src/scalar.c 2007-09-04 19:07:55 UTC (rev 90) +++ trunk/src/scalar.c 2007-09-05 14:32:17 UTC (rev 91) @@ -36,6 +36,10 @@ #define expf exp #endif +int test(void){ + printf("Hello world"); +} + int xtract_mean(const float *data, const int N, const void *argv, float *result){ int n = N; Deleted: trunk/swig/Makefile.am =================================================================== --- trunk/swig/Makefile.am 2007-09-04 19:07:55 UTC (rev 90) +++ trunk/swig/Makefile.am 2007-09-05 14:32:17 UTC (rev 91) @@ -1,18 +0,0 @@ -MAINTAINERCLEANFILES = xtract.py xtract_wrap.c Makefile.in _xtract.so - -BUILT_SOURCES = $(srcdir)/xtract_wrap.c -SWIG_SOURCES = xtract.i - -pkgpython_PYTHON = xtract.py -pkgpyexec_LTLIBRARIES = _xtract.la -_xtract_la_SOURCES = $(srcdir)/xtract_wrap.c $(SWIG_SOURCES) -_xtract_la_CFLAGS = $(SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)/src -_xtract_la_LDFLAGS = -module -lxtract -_xtract_la_LIBADD = ../src/libxtract.la - -xtract_wrap.c : $(SWIG_SOURCES) - $(SWIG) $(SWIG_PYTHON_OPT) -I$(top_srcdir) -o $@ $< - -clean-local: - -rm -f _xtract.so xtract.py xtract_wrap.c xtract.pyc - Added: trunk/swig/Makefile.am =================================================================== --- trunk/swig/Makefile.am (rev 0) +++ trunk/swig/Makefile.am 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,11 @@ +MAINTAINERCLEANFILES = Makefile.in + +if BUILD_JAVA +JAVA_BUILD_DIR = java +endif + +if BUILD_PYTHON +PYTHON_BUILD_DIR = python +endif + +SUBDIRS = $(JAVA_BUILD_DIR) $(PYTHON_BUILD_DIR) Added: trunk/swig/java/Makefile.am =================================================================== --- trunk/swig/java/Makefile.am (rev 0) +++ trunk/swig/java/Makefile.am 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,69 @@ +SWIG_JAVA_DIR = $(top_srcdir)/swig/java + +SWIG_CMD = $(SWIG) -I$(SWIG_JAVA_DIR) -I$(top_srcdir) -java + +swigjavafiles = \ + xtractJNI.java \ + xtract.java \ + floatArray.java \ + SWIGTYPE_p_float.java \ + SWIGTYPE_p_void.java + +swigcfiles = xtractjavac_wrap.c + +swiggenfiles = $(swigjavafiles) $(swigcfiles) + +javafiles = $(swigjavafiles) + +# Note : the order of these is important since there is no formal +# dependency checking. +javaclasses = \ + xtractJNI.class \ + xtract.class \ + floatArray.class \ + SWIGTYPE_p_float.class \ + SWIGTYPE_p_void.class + +$(swiggenfiles): ../xtract.i + $(SWIG_CMD) -package xtract.core -o xtractjavac_wrap.c ../xtract.i + +# Must have "exec" in the name. +execjavawrapperdir = ${libdir} + +libxtract = $(top_builddir)/src/libxtract$(LIB_TAG).la + +AM_CPPFLAGS = -I$(top_srcdir)/include $(INCLTDL) $(JAVAINCCMD) + +nodist_xtractjavac_wrap_la_SOURCES = xtractjavac_wrap.c + +xtractjavac_wrap_la_LDFLAGS = \ + -rpath $(execjavawrapperdir) \ + -module \ + -avoid-version \ + -no-undefined \ + $(libxtract) + +.java.class: + $(JAVAC) $(AM_JAVACFLAGS) $(JAVACFLAGS) $(swigjavafiles) -d . -classpath . + cp xtract/core/$@ . + +noinst_DATA = jar-stamp +# +jar-stamp: $(javaclasses) $(javafiles) + $(mkdir_p) xtract/core + $(mkdir_p) xtract/core/src + cp $(javafiles) xtract/core/src + touch jar-stamp +# +execjavawrapper_LTLIBRARIES = xtractjavac_wrap.la + +install-exec-hook: + ( cd $(DESTDIR)$(execjavawrapperdir) ; \ + rm -f *.a *.la ) + +clean-local: + rm -rf xtract + +CLEANFILES = $(javaclasses) jar-stamp + +MAINTAINERCLEANFILES = $(swiggenfiles) Makefile.in Added: trunk/swig/java/test.java =================================================================== --- trunk/swig/java/test.java (rev 0) +++ trunk/swig/java/test.java 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,23 @@ + +import xtract.core.*; + +public class test { + public static void main(String argv[]) { +// System.loadLibrary("xtract"); + + int len = 5; + int retval = 0; + float result[]; + floatArray a = new floatArray(len); + SWIGTYPE_p_void myvoid = null; + + result = new float[1]; + + for (int i = 0; i < len; i++) + a.setitem(i, i * 2); + + retval = xtract.xtract_mean(a.cast(), len, myvoid, result); + + System.out.println(result); + } +} Copied: trunk/swig/python/Makefile.am (from rev 90, trunk/swig/Makefile.am) =================================================================== --- trunk/swig/python/Makefile.am (rev 0) +++ trunk/swig/python/Makefile.am 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,18 @@ +MAINTAINERCLEANFILES = xtract.py xtract_wrap.c Makefile.in _xtract.so + +BUILT_SOURCES = $(srcdir)/xtract_wrap.c +SWIG_SOURCES = ../xtract.i + +pkgpython_PYTHON = xtract.py +pkgpyexec_LTLIBRARIES = _xtract.la +_xtract_la_SOURCES = $(srcdir)/xtract_wrap.c $(SWIG_SOURCES) +_xtract_la_CFLAGS = $(SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)/src +_xtract_la_LDFLAGS = -module -lxtract +_xtract_la_LIBADD = $(top_srcdir)/src/libxtract.la + +xtract_wrap.c : $(SWIG_SOURCES) + $(SWIG) $(SWIG_PYTHON_OPT) -I$(top_srcdir) -o $@ $< + +clean-local: + -rm -f _xtract.so xtract.py xtract_wrap.c xtract.pyc + Copied: trunk/swig/python/test.py (from rev 90, trunk/swig/test.py) =================================================================== --- trunk/swig/python/test.py (rev 0) +++ trunk/swig/python/test.py 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,15 @@ +#!/usr/bin/python + +import xtract + +len = 5 + +a = xtract.floatArray(len) + +for i in range(0, len): + a[i] = 2 * i + +retval,result = xtract.xtract_mean(a,len,None) + +print result + Copied: trunk/swig/python/xtract.i (from rev 90, trunk/swig/xtract.i) =================================================================== --- trunk/swig/python/xtract.i (rev 0) +++ trunk/swig/python/xtract.i 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,12 @@ +%module xtract +%include carrays.i +%include typemaps.i + +%{ +#include "xtract/xtract_scalar.h" +%} + +%array_functions(float, floatArray); +%apply float *OUTPUT { float *result }; + +%include "xtract/xtract_scalar.h" Deleted: trunk/swig/test.py =================================================================== --- trunk/swig/test.py 2007-09-04 19:07:55 UTC (rev 90) +++ trunk/swig/test.py 2007-09-05 14:32:17 UTC (rev 91) @@ -1,18 +0,0 @@ -#!/usr/bin/python - -import xtract - -len = 5 - -a = xtract.new_floatArray(len) - -for i in range(0, len): - xtract.floatArray_setitem(a, i, 2*i) - -retval,result = xtract.xtract_mean(a,len,None) - -print result - - - - Deleted: trunk/swig/xtract.i =================================================================== --- trunk/swig/xtract.i 2007-09-04 19:07:55 UTC (rev 90) +++ trunk/swig/xtract.i 2007-09-05 14:32:17 UTC (rev 91) @@ -1,12 +0,0 @@ -%module xtract -%include carrays.i -%include typemaps.i - -%{ -#include "xtract/xtract_scalar.h" -%} - -%array_functions(float, floatArray); -%apply float *OUTPUT { float *result }; - -%include "xtract/xtract_scalar.h" Added: trunk/swig/xtract.i =================================================================== --- trunk/swig/xtract.i (rev 0) +++ trunk/swig/xtract.i 2007-09-05 14:32:17 UTC (rev 91) @@ -0,0 +1,13 @@ +%module xtract +%include carrays.i +%include typemaps.i + +%{ +#include "xtract/xtract_scalar.h" +%} + +%array_class(float, floatArray); +%apply float *OUTPUT { float *result }; +/* %apply float *INPUT { float *data }; */ + +%include "xtract/xtract_scalar.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |