added configure support for java

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@329 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Harco de Hilster 2000-03-05 15:36:29 +00:00
commit 42d2c33bda
6 changed files with 141 additions and 2 deletions

View file

@ -231,6 +231,34 @@ python_static_cpp: $(SRCS)
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
##################################################################
##### JAVA ######
##################################################################
# You need to set this variable to the java directories containing the
# files "jni.h" and "md.h"
# usually something like /usr/java/include and /usr/java/include/<arch-osname>.
JAVA_INCLUDE= @JAVAINC@
# ----------------------------------------------------------------
# Build a java dynamically loadable module (C)
# ----------------------------------------------------------------
java: $(SRCS)
$(SWIG) -java $(SWIGOPT) $(INTERFACE)
$(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDE) $(JAVA_INCLUDE)
$(LDSHARED) $(OBJS) $(IOBJS) $(LIBS) -o $(TARGET)$(SO)
# ----------------------------------------------------------------
# Build a java dynamically loadable module (C++)
# ----------------------------------------------------------------
java_cpp: $(SRCS)
$(SWIG) -java -c++ $(SWIGOPT) $(INTERFACE)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDE) $(JAVA_INCLUDE)
$(CXXSHARED) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(TARGET)$(SO)
##################################################################
##### SWIG ######
##################################################################

View file

@ -0,0 +1,13 @@
TOP = ../..
SWIG = $(TOP)/../swig
SRCS = example.c
TARGET = libexample
INTERFACE = example.i
SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
clean::
rm -f *_wrap* *.o core *~ *.so *.pm myperl

View file

@ -0,0 +1 @@
Simple example from users manual.

View file

@ -0,0 +1,11 @@
/* File : example.i */
%module example
%{
/* Put headers and other declarations here */
%}
extern double My_variable;
extern int fact(int);
%name(mod) extern int my_mod(int n, int m);
extern char *get_time();

View file

@ -0,0 +1,32 @@
import example;
public class main {
static {
try {
System.loadLibrary("example");
} catch (UnsatisfiedLinkError e) {
System.err.println("Cannot load the example native code.\nMake sure your LD_LIBRARY_PATH contains \'.\'\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) {
System.out.println(example.get_time());
System.out.println("My Variable = " + example.get_My_variable());
for(int i=0; i<14; i++) {
System.out.println("" + i + " factorial is " + example.fact(i));
}
for(int i=1; i<100; i++) {
for(int j=1; j<100; j++) {
int n = example.mod(i, j);
example.set_My_variable(example.get_My_variable() + n);
}
}
System.out.println("My_variable = " + example.get_My_variable());
}
}