Fix compiler warning due to missing function prototype.
[svn.git] / build / ac-macros / java.m4
blob56e56c370b7361f846cc1ce17c7652162409c004
1 dnl
2 dnl java.m4: Locates the JDK and its include files and libraries.
3 dnl
5 AC_DEFUN(SVN_CHECK_JDK,
7   JAVA_OLDEST_WORKING_VER="$1"
8   AC_ARG_WITH(jdk,
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.]),
13   [
14     case "$withval" in
15       "no")
16         JDK_SUITABLE=no
17       ;;
18       "yes")
19         SVN_FIND_JDK(check, $JAVA_OLDEST_WORKING_VER)
20       ;;
21       *)
22         SVN_FIND_JDK($withval, $JAVA_OLDEST_WORKING_VER)
23       ;;
24     esac
25   ],
26   [
27     SVN_FIND_JDK(check, $JAVA_OLDEST_WORKING_VER)
28   ])
31 AC_DEFUN(SVN_FIND_JDK,
33   where=$1
34   JAVA_OLDEST_WORKING_VER="$2"
36   JDK=none
37   JAVA_BIN=none
38   JAVADOC=none
39   JAVAC=none
40   JAVAH=none
41   JAR=none
42   JNI_INCLUDES=none
44   JDK_SUITABLE=no
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
50       JDK="$JAVA_HOME"
51     elif test -x "/Library/Java/Home/bin/java"; then
52       JDK="/Library/Java/Home"
53     elif test -x "/usr/bin/java"; then
54       JDK="/usr"
55     elif test -x "/usr/local/bin/java"; then
56       JDK="/usr/local"
57     fi
58   else
59     JDK=$where
60   fi
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
66   os_arch="`uname`"
67   if test "$os_arch" = "Darwin" && test "$JDK" = "/usr" &&
68      test -d "/Library/Java/Home"; then
69       JDK="/Library/Java/Home"
70   fi
71   if test "$os_arch" = "Darwin" && test "$JDK" = "/Library/Java/Home"; then
72       JRE_LIB_DIR="/System/Library/Frameworks/JavaVM.framework/Classes"
73   else
74       JRE_LIB_DIR="$JDK/jre/lib"
75   fi
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"
80     JDK_SUITABLE=yes
81   else
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.])
85     fi
86     JDK_SUITABLE=no
87   fi
88   AC_MSG_RESULT([$JDK_SUITABLE])
90   if test "$JDK_SUITABLE" = "yes"; then
91     JAVA_BIN='$(JDK)/bin'
93     JAVA="$JAVA_BIN/java"
94     JAVAC="$JAVA_BIN/javac"
95     JAVAH="$JAVA_BIN/javah"
96     JAVADOC="$JAVA_BIN/javadoc"
97     JAR="$JAVA_BIN/jar"
99     dnl Prefer Jikes (for speed) if available.
100     jikes_options="/usr/local/bin/jikes /usr/bin/jikes"
101     AC_ARG_WITH(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'.]),
107     [
108         if test "$withval" != "no" && test "$withval" != "yes"; then
109           dnl Assume a path was provided.
110           jikes_options="$withval $jikes_options"
111         fi
112         requested_jikes="$withval"  # will be 'yes' if path unspecified
113     ])
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
118           jikes_found="yes"
119           JAVAC="$jikes"
120           JAVA_CLASSPATH="$JRE_LIB_DIR"
121           for jar in $JRE_LIB_DIR/*.jar; do
122             JAVA_CLASSPATH="$JAVA_CLASSPATH:$jar"
123           done
124         fi
125       done
126     fi
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])
134       fi
135     fi
137     dnl Add javac flags.
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"
143     fi
145     JNI_INCLUDES="-I$JNI_INCLUDEDIR"
146     list="`find "$JNI_INCLUDEDIR" -type d -print`"
147     for dir in $list; do
148       JNI_INCLUDES="$JNI_INCLUDES -I$dir"
149     done
150   fi
152   dnl We use JDK in both the swig.m4 macros and the Makefile
153   AC_SUBST(JDK)
154   AC_SUBST(JAVA)
155   AC_SUBST(JAVAC)
156   AC_SUBST(JAVAC_FLAGS)
157   AC_SUBST(JAVADOC)
158   AC_SUBST(JAVAH)
159   AC_SUBST(JAR)
160   AC_SUBST(JNI_INCLUDES)