diff options
-rw-r--r-- | configure.in | 15 | ||||
-rw-r--r-- | src/scalar.c | 2 | ||||
-rw-r--r-- | swig/java/Makefile.am | 65 | ||||
-rw-r--r-- | swig/java/test.java | 24 | ||||
-rw-r--r-- | swig/python/test.py | 15 | ||||
-rw-r--r-- | xtract/xtract_scalar.h | 2 |
6 files changed, 66 insertions, 57 deletions
diff --git a/configure.in b/configure.in index 61e94d5..c82c4de 100644 --- a/configure.in +++ b/configure.in @@ -85,6 +85,15 @@ AC_ARG_WITH(fftw3_dir, echo ]) +dnl set a specific java compiler +AC_ARG_WITH(javac, + [ --with-javac=compiler set a specific java compiler (determined automatically if not set) ], + [JAVAC="$withval" + echo + echo "JAVAC is set to $withval" + echo + ]) + dnl If --enable-swig, make with java bindings AC_ARG_WITH(java, [ --with-java If --enable-swig - make with java bindings (default=no) ], @@ -150,12 +159,14 @@ if [[ "$swig" = "true" ]] ; then fi if [[ "$with_java" = "true" ]] ; then - AC_PROG_JAVAC + if test "$JAVAC" = "" + then + AC_PROG_JAVAC + fi if test "$JAVAC" = "javac" then AC_JNI_INCLUDE_DIR - for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS do CFLAGS="$CFLAGS -I$JNI_INCLUDE_DIR" diff --git a/src/scalar.c b/src/scalar.c index 9be6ec6..f259872 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -36,7 +36,7 @@ #define expf exp #endif -int test(void){ +void test(void){ printf("Hello world"); } diff --git a/swig/java/Makefile.am b/swig/java/Makefile.am index 27a4f93..4ff926d 100644 --- a/swig/java/Makefile.am +++ b/swig/java/Makefile.am @@ -1,22 +1,10 @@ -SWIG_JAVA_DIR = $(top_srcdir)/swig/java - -SWIG_CMD = $(SWIG) -I$(SWIG_JAVA_DIR) -I$(top_srcdir) -java - -swigjavafiles = \ +javasources = \ 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 \ @@ -24,46 +12,29 @@ javaclasses = \ SWIGTYPE_p_float.class \ SWIGTYPE_p_void.class -$(swiggenfiles): ../xtract.i - $(SWIG_CMD) -package xtract.core -o xtractjavac_wrap.c ../xtract.i +MAINTAINERCLEANFILES = $(javasources) Makefile.in -# Must have "exec" in the name. -execjavawrapperdir = ${libdir} +BUILT_SOURCES = $(srcdir)/xtract_wrap.c +SWIG_SOURCES = ../xtract.i -libxtract = $(top_builddir)/src/libxtract$(LIB_TAG).la +lib_LTLIBRARIES = libjxtract.la +libjxtract_la_SOURCES = $(srcdir)/xtract_wrap.c $(SWIG_SOURCES) +libjxtract_la_CFLAGS = $(SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)/src +ibjxtract_la_LDFLAGS = -module -lxtract +libjxtract_la_LIBADD = $(top_srcdir)/src/libxtract.la -AM_CPPFLAGS = -I$(top_srcdir)/include $(INCLTDL) $(JAVAINCCMD) +SWIG_JAVA_OPT = -java -package xtract.core -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) - -noinst_DATA = jar-stamp -# -jar-stamp: $(javaclasses) $(javafiles) +xtract_wrap.c : $(SWIG_SOURCES) + $(SWIG) $(SWIG_JAVA_OPT) -I$(top_srcdir) -o $@ $< + $(JAVAC) $(javasources) mkdir -p xtract/core mkdir -p xtract/core/src - cp $(javafiles) xtract/core/src - cp $(javaclasses) xtract/core - touch jar-stamp -# -execjavawrapper_LTLIBRARIES = xtractjavac_wrap.la - -install-exec-hook: - ( cd $(DESTDIR)$(execjavawrapperdir) ; \ - rm -f *.a *.la ) + mv $(javasources) xtract/core/src + mv $(javaclasses) xtract/core + $(JAVAC) test.java clean-local: - rm -rf xtract - -CLEANFILES = $(javaclasses) jar-stamp + -rm -f libjxtract.so xtract_wrap.c $(javasources) $(javaclasses) test.class + -rm -rf xtract -MAINTAINERCLEANFILES = $(swiggenfiles) Makefile.in diff --git a/swig/java/test.java b/swig/java/test.java index d20461a..8949826 100644 --- a/swig/java/test.java +++ b/swig/java/test.java @@ -3,7 +3,16 @@ import xtract.core.*; public class test { public static void main(String argv[]) { -// System.loadLibrary("xtract"); + + try { + System.loadLibrary("jxtract"); + } + catch (UnsatisfiedLinkError e) { + System.out.println("Failed to load the library \"jxtract\""); + System.out.println(e.toString()); + } + + System.out.println("\nRunning libxtract Java bindings test...\n"); int len = 5; int retval = 0; @@ -13,11 +22,20 @@ public class test { result = new float[1]; - for (int i = 0; i < len; i++) + System.out.print("The mean of: "); + + for (int i = 0; i < len; i++){ + System.out.print(i * 2 + ", "); a.setitem(i, i * 2); + } + + System.out.print("is: "); retval = xtract.xtract_mean(a.cast(), len, myvoid, result); - System.out.println(result); + System.out.print(result[0] + "\n"); + + System.out.println("\nFinished!\n\n"); + } } diff --git a/swig/python/test.py b/swig/python/test.py index f491a39..4d994ac 100644 --- a/swig/python/test.py +++ b/swig/python/test.py @@ -1,15 +1,22 @@ #!/usr/bin/python -import xtract +try: + import xtract +except ImportError: + print 'Failed to load the library "jxtract"' + +print '\nRunning libxtract Python bindings test...\n' len = 5 a = xtract.floatArray(len) +temp = [] for i in range(0, len): a[i] = 2 * i + temp.append(str(a[i])) -retval,result = xtract.xtract_mean(a,len,None) - -print result +print 'The mean of ' + ', '.join(temp) + ' is: %.2f' % \ + xtract.xtract_mean(a,len,None)[1] +print '\nFinished!\n' diff --git a/xtract/xtract_scalar.h b/xtract/xtract_scalar.h index 0496eed..ff844f0 100644 --- a/xtract/xtract_scalar.h +++ b/xtract/xtract_scalar.h @@ -34,6 +34,8 @@ extern "C" { * @{ */ +void test(void); + /** \brief Extract the mean of an input vector * * \param *data: a pointer to the first element |