2 dnl java.m4: Locates the JDK and its include files and libraries.
5 AC_DEFUN(SVN_CHECK_JDK,
7 JAVA_OLDEST_WORKING_VER="$1"
9 AS_HELP_STRING([--with-jdk=PATH],
10 [Try to use 'PATH/include' to find the JNI
11 headers. If PATH is not specified, look
12 for a Java Development Kit at JAVA_HOME.]),
19 SVN_FIND_JDK(check, $JAVA_OLDEST_WORKING_VER)
22 SVN_FIND_JDK($withval, $JAVA_OLDEST_WORKING_VER)
27 SVN_FIND_JDK(check, $JAVA_OLDEST_WORKING_VER)
31 AC_DEFUN(SVN_FIND_JDK,
34 JAVA_OLDEST_WORKING_VER="$2"
45 AC_MSG_CHECKING([for JDK])
46 if test $where = check; then
47 dnl Prefer /Library/Java/Home first to try to be nice on Darwin.
48 dnl We'll correct later if we get caught in the tangled web of JAVA_HOME.
49 if test -x "$JAVA_HOME/bin/java"; then
51 elif test -x "/Library/Java/Home/bin/java"; then
52 JDK="/Library/Java/Home"
53 elif test -x "/usr/bin/java"; then
55 elif test -x "/usr/local/bin/java"; then
62 dnl Correct for Darwin's odd JVM layout. Ideally, we should use realpath,
63 dnl but Darwin doesn't have that utility. /usr/bin/java is a symlink into
64 dnl /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands
65 dnl See http://developer.apple.com/qa/qa2001/qa1170.html
67 if test "$os_arch" = "Darwin" && test "$JDK" = "/usr" &&
68 test -d "/Library/Java/Home"; then
69 JDK="/Library/Java/Home"
71 if test "$os_arch" = "Darwin" && test "$JDK" = "/Library/Java/Home"; then
72 JRE_LIB_DIR="/System/Library/Frameworks/JavaVM.framework/Classes"
74 JRE_LIB_DIR="$JDK/jre/lib"
77 if test -f "$JDK/include/jni.h"; then
78 dnl This *must* be fully expanded, or we'll have problems later in find.
79 JNI_INCLUDEDIR="$JDK/include"
82 AC_MSG_WARN([no JNI header files found.])
83 if test "$os_arch" = "Darwin"; then
84 AC_MSG_WARN([You may need to install the latest Java Development package from http://connect.apple.com/. Apple no longer includes the JNI header files by default on Java updates.])
88 AC_MSG_RESULT([$JDK_SUITABLE])
90 if test "$JDK_SUITABLE" = "yes"; then
94 JAVAC="$JAVA_BIN/javac"
95 JAVAH="$JAVA_BIN/javah"
96 JAVADOC="$JAVA_BIN/javadoc"
99 dnl Prefer Jikes (for speed) if available.
100 jikes_options="/usr/local/bin/jikes /usr/bin/jikes"
102 AS_HELP_STRING([--with-jikes=PATH],
103 [Specify the path to a jikes binary to use
104 it as your Java compiler. The default is to
105 look for jikes (PATH optional). This behavior
106 can be switched off by supplying 'no'.]),
108 if test "$withval" != "no" && test "$withval" != "yes"; then
109 dnl Assume a path was provided.
110 jikes_options="$withval $jikes_options"
112 requested_jikes="$withval" # will be 'yes' if path unspecified
114 if test "$requested_jikes" != "no"; then
115 dnl Look for a usable jikes binary.
116 for jikes in $jikes_options; do
117 if test -z "$jikes_found" && test -x "$jikes"; then
120 JAVA_CLASSPATH="$JRE_LIB_DIR"
121 for jar in $JRE_LIB_DIR/*.jar; do
122 JAVA_CLASSPATH="$JAVA_CLASSPATH:$jar"
127 if test -n "$requested_jikes" && test "$requested_jikes" != "no"; then
128 dnl Jikes was explicitly requested. Verify that it was provided.
129 if test -z "$jikes_found"; then
130 AC_MSG_ERROR([Could not find a usable version of Jikes])
131 elif test -n "$jikes_found" && test "$requested_jikes" != "yes" &&
132 test "$JAVAC" != "$requested_jikes"; then
133 AC_MSG_WARN([--with-jikes PATH was invalid, substitute found])
138 # The release for "-source" could actually be greater than that
139 # of "-target", if we want to cross-compile for lesser JVMs.
140 JAVAC_FLAGS="-target $JAVA_OLDEST_WORKING_VER -source 1.3"
141 if test "$enable_debugging" = "yes"; then
142 JAVAC_FLAGS="-g $JAVAC_FLAGS"
145 JNI_INCLUDES="-I$JNI_INCLUDEDIR"
146 list="`find "$JNI_INCLUDEDIR" -type d -print`"
148 JNI_INCLUDES="$JNI_INCLUDES -I$dir"
152 dnl We use JDK in both the swig.m4 macros and the Makefile
156 AC_SUBST(JAVAC_FLAGS)
160 AC_SUBST(JNI_INCLUDES)