| 35523 |
urbaneks |
1 |
### java.m4 -- macros for Java environment detection -*- Autoconf -*-
|
|
|
2 |
###
|
|
|
3 |
### Copyright (C) 2005 R Core Team
|
|
|
4 |
###
|
|
|
5 |
### This file is part of R.
|
|
|
6 |
###
|
|
|
7 |
### R is free software; you can redistribute it and/or modify it under
|
|
|
8 |
### the terms of the GNU General Public License as published by the Free
|
|
|
9 |
### Software Foundation; either version 2 of the License, or (at your
|
|
|
10 |
### option) any later version.
|
|
|
11 |
###
|
|
|
12 |
### R is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
13 |
### WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
14 |
### FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
|
15 |
### License for more details.
|
|
|
16 |
###
|
|
|
17 |
### You should have received a copy of the GNU General Public License
|
|
|
18 |
### along with R; if not, you can obtain it via the World Wide Web at
|
|
|
19 |
### `http://www.gnu.org/copyleft/gpl.html', or by writing to the Free
|
|
|
20 |
### Software Foundation, 59 Temple Place -- Suite 330, Boston, MA
|
|
|
21 |
### 02111-3307, USA.
|
|
|
22 |
|
| 35572 |
urbaneks |
23 |
|
|
|
24 |
## R_RUN_JAVA(variable for the result, parameters)
|
|
|
25 |
## ----------
|
|
|
26 |
## runs the java interpreter ${JAVA_PROG} with specified parameters and
|
|
|
27 |
## saves the output to the supplied variable. The exit value is ignored.
|
|
|
28 |
AC_DEFUN([R_RUN_JAVA],
|
|
|
29 |
[
|
|
|
30 |
acx_java_result=
|
|
|
31 |
if test -z "${JAVA_PROG}"; then
|
|
|
32 |
echo "$as_me:$LINENO: JAVA_PROG is not set, cannot run java $2" >&AS_MESSAGE_LOG_FD
|
|
|
33 |
else
|
|
|
34 |
echo "$as_me:$LINENO: running ${JAVA_PROG} $2" >&AS_MESSAGE_LOG_FD
|
|
|
35 |
acx_java_result=`${JAVA_PROG} $2 2>&AS_MESSAGE_LOG_FD`
|
|
|
36 |
echo "$as_me:$LINENO: output: '$acx_java_result'" >&AS_MESSAGE_LOG_FD
|
|
|
37 |
fi
|
| 35586 |
urbaneks |
38 |
$1=$acx_java_result
|
| 35572 |
urbaneks |
39 |
])
|
|
|
40 |
|
|
|
41 |
|
| 35543 |
urbaneks |
42 |
## R_JAVA
|
| 35523 |
urbaneks |
43 |
## -----------
|
|
|
44 |
## Looks for Java JRE/JDK and sets:
|
|
|
45 |
## have_java to yes/no; if it is yes then also sets:
|
|
|
46 |
## JAVA_PROG to Java interpreter path
|
|
|
47 |
## JAVA_HOME to the home directory of the Java runtime/jdk
|
|
|
48 |
## JAVA_LD_PATH to the path necessary for Java runtime
|
| 35543 |
urbaneks |
49 |
## JAVA_LIBS to flags necessary to link JNI programs (*)
|
| 35523 |
urbaneks |
50 |
##
|
|
|
51 |
## JAVA_HOME env var is honored during the search and the search
|
|
|
52 |
## will fail if it is set incorrectly.
|
| 35543 |
urbaneks |
53 |
AC_DEFUN([R_JAVA],
|
| 35523 |
urbaneks |
54 |
[
|
|
|
55 |
have_java=no
|
|
|
56 |
|
|
|
57 |
## find java compiler binaries
|
|
|
58 |
if test -z "${JAVA_HOME}" ; then
|
|
|
59 |
JAVA_PATH=${PATH}
|
|
|
60 |
else
|
|
|
61 |
JAVA_PATH=${JAVA_HOME}:${JAVA_HOME}/bin:${PATH}
|
|
|
62 |
fi
|
|
|
63 |
## if 'java' is not on the PATH or JAVA_HOME, add some guesses as of
|
|
|
64 |
## where java could live
|
|
|
65 |
JAVA_PATH=${JAVA_PATH}:/usr/java/bin:/usr/jdk/bin:/usr/lib/java/bin:/usr/lib/jdk/bin:/usr/local/java/bin:/usr/local/jdk/bin:/usr/local/lib/java/bin:/usr/local/lib/jdk/bin
|
|
|
66 |
AC_PATH_PROGS(JAVA_PROG,java,,${JAVA_PATH})
|
| 35543 |
urbaneks |
67 |
## FIXME: we may want to check for jikes, kaffe and others...
|
|
|
68 |
AC_PATH_PROGS(JAVAC,javac,,${JAVA_PATH})
|
| 35523 |
urbaneks |
69 |
|
|
|
70 |
## this is where our test-class lives (in tools directory)
|
|
|
71 |
getsp_cp=${ac_aux_dir}
|
|
|
72 |
|
| 35572 |
urbaneks |
73 |
AC_MSG_CHECKING([whether Java interpreter works])
|
|
|
74 |
acx_java_works=no
|
| 35543 |
urbaneks |
75 |
if test -n "${JAVA_PROG}" ; then
|
| 35586 |
urbaneks |
76 |
R_RUN_JAVA(acx_jc_result,[-classpath ${getsp_cp} getsp -test])
|
|
|
77 |
if test "${acx_jc_result}" = "Test1234OK"; then
|
| 35572 |
urbaneks |
78 |
acx_java_works=yes
|
| 35523 |
urbaneks |
79 |
fi
|
| 35586 |
urbaneks |
80 |
acx_jc_result=
|
| 35523 |
urbaneks |
81 |
fi
|
|
|
82 |
|
| 35572 |
urbaneks |
83 |
if test ${acx_java_works} = yes; then
|
|
|
84 |
AC_MSG_RESULT([yes])
|
| 35523 |
urbaneks |
85 |
|
| 35572 |
urbaneks |
86 |
AC_MSG_CHECKING([for Java environment])
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
## retrieve JAVA_HOME from Java itself if not set
|
|
|
90 |
if test -z "${JAVA_HOME}" ; then
|
|
|
91 |
R_RUN_JAVA(JAVA_HOME,[-classpath ${getsp_cp} getsp java.home])
|
|
|
92 |
fi
|
|
|
93 |
|
|
|
94 |
## the availability of JAVA_HOME will tell us whether it's supported
|
|
|
95 |
if test -z "${JAVA_HOME}" ; then
|
|
|
96 |
if test x$acx_java_env_msg != xyes; then
|
|
|
97 |
AC_MSG_RESULT([not found])
|
|
|
98 |
fi
|
|
|
99 |
else
|
|
|
100 |
AC_MSG_RESULT([in ${JAVA_HOME}])
|
|
|
101 |
|
|
|
102 |
case "${host_os}" in
|
|
|
103 |
darwin*)
|
|
|
104 |
JAVA_LIBS="-framework JavaVM"
|
|
|
105 |
JAVA_LD_PATH=
|
|
|
106 |
;;
|
|
|
107 |
*)
|
|
|
108 |
R_RUN_JAVA(JAVA_LIBS, [-classpath ${getsp_cp} getsp -libs])
|
|
|
109 |
JAVA_LIBS="${JAVA_LIBS} -ljvm"
|
|
|
110 |
R_RUN_JAVA(JAVA_LD_PATH, [-classpath ${getsp_cp} getsp java.library.path])
|
|
|
111 |
;;
|
|
|
112 |
esac
|
| 35543 |
urbaneks |
113 |
|
| 35572 |
urbaneks |
114 |
## note that we actually don't test JAVA_LIBS - we hope that the detection
|
|
|
115 |
## was correct. We should also test the functionality for javac.
|
| 35543 |
urbaneks |
116 |
|
| 35572 |
urbaneks |
117 |
have_java=yes
|
|
|
118 |
fi
|
|
|
119 |
else
|
|
|
120 |
AC_MSG_RESULT([no])
|
|
|
121 |
JAVA_PROG=
|
|
|
122 |
JAVAC=
|
|
|
123 |
JAVA_HOME=
|
| 35523 |
urbaneks |
124 |
fi
|
| 35572 |
urbaneks |
125 |
|
| 35523 |
urbaneks |
126 |
AC_SUBST(JAVA_HOME)
|
|
|
127 |
AC_SUBST(JAVA_PROG)
|
|
|
128 |
AC_SUBST(JAVA_LD_PATH)
|
| 35543 |
urbaneks |
129 |
AC_SUBST(JAVA_LIBS)
|
| 35523 |
urbaneks |
130 |
])
|