The R Project SVN R

Rev

Rev 35572 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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