--- R-2.10.1/src/scripts/javareconf.orig	Fri Mar 20 00:05:30 2009
+++ R-2.10.1/src/scripts/javareconf	Wed Jan  6 23:01:51 2010
@@ -1,3 +1,4 @@
+[ -z "$MEM_MODEL" ] && MEM_MODEL=64
 if test -z "${R_HOME}"; then
     echo "This command can be executed via R CMD only!"
     exit 1
@@ -84,8 +85,8 @@
 if test -z "$JAVA"; then
     save_IFS=$IFS; IFS=:
     for dir in ${JAVA_PATH}; do
-	if test -f "$dir/java"; then
-	    JAVA="$dir/java"
+	if test -x "$dir/java"; then
+	    JAVA=$(readlink -f $dir/java)
 	    break
 	fi
     done
@@ -105,9 +106,8 @@
     exit 1
 fi
 
-if test -z "${JAVA_HOME}"; then
-    JAVA_HOME=`$JAVA -classpath ${tools_classpath} getsp java.home`
-fi
+# resolve possible links
+JAVA_HOME=`$JAVA -classpath ${tools_classpath} getsp java.home | ${SED-sed} -e 's,/jre$,,'`
 
 if test -z "${JAVA_HOME}"; then
     echo "~*** Cannot find Java environemnt.~*** Please set JAVA_HOME correspondingly.~"|${SED-sed} -e 'y/~/\n/' >&2
@@ -122,7 +122,7 @@
     save_IFS=$IFS; IFS=:
     for dir in ${JAVA_PATH}; do
 	if test -f "$dir/javac"; then
-	    JAVAC="$dir/javac"
+	    JAVAC=$(readlink -f $dir/javac)
 	    break
 	fi
     done
@@ -166,7 +166,7 @@
     save_IFS=$IFS; IFS=:
     for dir in ${JAVA_PATH}; do
 	if test -f "$dir/javah"; then
-	    JAVAH="$dir/javah"
+	    JAVAH=$(readlink -f $dir/javah)
 	    break
 	fi
     done
@@ -178,7 +178,7 @@
     save_IFS=$IFS; IFS=:
     for dir in ${JAVA_PATH}; do
 	if test -f "$dir/jar"; then
-	    JAR="$dir/jar"
+	    JAR=$(readlink -f $dir/jar)
 	    break
 	fi
     done
@@ -206,13 +206,16 @@
 	## we need to reset LD_LIBRARY_PATH, because Java automatically
 	## adds all LD_LIBRARY_PATH to Java path
 	save_LDLP=${LD_LIBRARY_PATH}
-	LD_LIBRARY_PATH=
-	export LD_LIBRARY_PATH
+	save_LDLP64=${LD_LIBRARY_PATH_64}
+	unset LD_LIBRARY_PATH
+	unset LD_LIBRARY_PATH_64
+	[ "$MEM_MODEL" = "64" ] && PARAM="-64"
+	CRLEP=$(crle ${PARAM} | grep crle | awk '{ print $NF }')
 	# remove trailing : (if any) and replace occurrences of JAVA_HOME
 	# with $(JAVA_HOME)
-	JAVA_LD_LIBRARY_PATH=`$JAVA -classpath ${tools_classpath} getsp java.library.path| ${SED-sed} -e s:${JAVA_HOME}:\$\(JAVA_HOME\):g -e 's/:$//'`
-	LD_LIBRARY_PATH=${save_LDLP}
-	export LD_LIBRARY_PATH
+	JAVA_LD_LIBRARY_PATH=`$JAVA -d${MEM_MODEL} -classpath ${tools_classpath} getsp java.library.path| ${SED-sed} -e "s,$CRLEP,," -e s:${JAVA_HOME}:\$\(JAVA_HOME\):g -e 's/:$//'`
+	[ -n "$save_LDLP64" ] && export LD_LIBRARY_PATH_64=${save_LDLP64}
+	[ -n "$save_LDLP" ] && export LD_LIBRARY_PATH=${save_LDLP}
 	# build JAVA_LIBS from the detected path
 	JAVA_LIBS=`echo ${JAVA_LD_LIBRARY_PATH}|${SED-sed} -e 's|:| -L|g'`
 	if test -n "${JAVA_LIBS}"; then JAVA_LIBS="-L${JAVA_LIBS}"; fi
@@ -316,7 +319,21 @@
 
 files="${R_HOME}/etc${R_ARCH}/Makeconf ${R_HOME}/etc${R_ARCH}/ldpaths"
 for file in $files; do
-    ${SED-sed} -e "s|JAVA =.\{0,\}|JAVA = $JAVA|" -e "s|JAVA_HOME =.\{0,\}|JAVA_HOME = ${JAVA_HOME}|" -e "s|: \${JAVA_HOME=.\{1,\}|: \${JAVA_HOME=${JAVA_HOME}}|" -e "s|: \${R_JAVA_LD_LIBRARY_PATH=.\{1,\}|: \${R_JAVA_LD_LIBRARY_PATH=${JAVA_LD_LIBRARY_PATH_SH}}|" -e "s|JAVA_LIBS =.\{0,\}|JAVA_LIBS = ${JAVA_LIBS}|g" -e "s|JAVA_LD_LIBRARY_PATH =.\{0,\}|JAVA_LD_LIBRARY_PATH = ${JAVA_LD_LIBRARY_PATH}|" -e "s|JAVAC =.\{0,\}|JAVAC = $JAVAC|" -e "s|JAVAH =.\{0,\}|JAVAH = $JAVAH|" -e "s|JAR =.\{0,\}|JAR = $JAR|" "${file}" -e "s|JAVA_CPPFLAGS =.\{0,\}|JAVA_CPPFLAGS = ${JAVA_CPPFLAGS}|g"> "${file}.new"
+    ${SED-sed} -e "/^JAVA =/ s,=.*,= $JAVA," \
+		-e "/^JAVA_HOME =/ s,=.*,= ${JAVA_HOME}," \
+		-e "/^: \${JAVA_HOME=/ s,=.*,=${JAVA_HOME}}," \
+		-e "/^: \${R_JAVA_LD_LIBRARY_PATH=/ s,=.*,=${JAVA_LD_LIBRARY_PATH_SH}}," \
+		-e "/^JAVA_LIBS =/ s,=.*,= ${JAVA_LIBS}," \
+		-e "/^JAVA_LD_LIBRARY_PATH =/ s,=.*,= ${JAVA_LD_LIBRARY_PATH}," \
+		-e "/^JAVAC =/ s,=.*,= $JAVAC," \
+		-e "/^JAVAH =/ s,=.*,= $JAVAH," \
+		-e "/^JAR =/ s,=.*,= $JAR," \
+		-e "/^JAVA_CPPFLAGS =/ s,=.*,= ${JAVA_CPPFLAGS}," \
+		-e "/^JAR =/ s,$JAVA_HOME,\$(JAVA_HOME\)," \
+		-e "/^JAVA =/ s,$JAVA_HOME,\$(JAVA_HOME\)," \
+		-e "/^JAVAC =/ s,$JAVA_HOME,\$(JAVA_HOME\)," \
+		-e "/^JAVAH =/ s,$JAVA_HOME,\$(JAVA_HOME\)," \
+		"${file}" > "${file}.new"
     if test -f "${file}.new"; then
 	mv "${file}" "${file}.old"
 	mv "${file}.new" "${file}"
--- R-2.10.1/etc/Makeconf.in.orig	Fri Mar 20 00:05:35 2009
+++ R-2.10.1/etc/Makeconf.in	Thu Jan  7 04:20:46 2010
@@ -4,6 +4,8 @@
 
 include $(R_SHARE_DIR)/make/vars.mk
 
+STUDIO_HOME = @STUDIO_HOME@
+JAVA_HOME = @JAVA_HOME@
 AR = @AR@
 BLAS_LIBS = @BLAS_LIBS@
 C_VISIBILITY = @C_VISIBILITY@
@@ -37,7 +39,6 @@
 JAVA = @JAVA@
 JAVAC = @JAVAC@
 JAVAH = @JAVAH@
-JAVA_HOME = @JAVA_HOME@
 JAVA_LD_LIBRARY_PATH = @JAVA_LD_LIBRARY_PATH@
 JAVA_LIBS = @JAVA_LIBS0@
 JAVA_CPPFLAGS = @JAVA_CPPFLAGS0@
--- R-2.10.1/m4/java.m4.orig	Wed Nov 12 10:23:33 2008
+++ R-2.10.1/m4/java.m4	Wed Jan  6 04:23:10 2010
@@ -58,6 +58,7 @@
 AC_DEFUN([R_JAVA],
 [
 have_java=no
+MEM_MODEL=${MEM_MODEL:-64}
 
 ## find java compiler binaries
 if test -z "${JAVA_HOME}" ; then
@@ -82,7 +83,7 @@
 if test -n "${JAVAC}"; then
   rm -f A.java A.class
   echo "public class A { }" > A.java
-  if "${JAVAC}" A.java 2>&AS_MESSAGE_LOG_FD; then
+  if "${JAVAC}" -d$MEM_MODEL A.java 2>&AS_MESSAGE_LOG_FD; then
     if test -e A.class; then
       r_cv_javac_works=yes
     fi
@@ -95,7 +96,7 @@
 if test "${r_cv_javac_works}" = yes; then
   rm -f A.java A.class
   echo "public class A { }" > A.java
-  if "${JAVAC}" -source 1.4 -target 1.4 A.java 2>&AS_MESSAGE_LOG_FD; then
+  if "${JAVAC}" -d$MEM_MODEL -source 1.4 -target 1.4 A.java 2>&AS_MESSAGE_LOG_FD; then
     if test -e A.class; then
       r_cv_javac14_works=yes
     fi
@@ -105,7 +106,7 @@
 ])
 
 if test "${r_cv_javac14_works}" = yes; then
-  JAVAC14="${JAVAC} -source 1.4 -target 1.4"
+  JAVAC14="${JAVAC} -d$MEM_MODEL -source 1.4 -target 1.4"
 fi
 AM_CONDITIONAL(BUILD_JAVA14, [test "x${r_cv_javac14_works}" = xyes])
 
@@ -115,7 +116,7 @@
 AC_CACHE_CHECK([whether Java interpreter works], [r_cv_java_works],
 [r_cv_java_works=no
 if test -n "${JAVA}" ; then
-  R_RUN_JAVA(acx_jc_result,[-classpath ${getsp_cp} getsp -test])
+  R_RUN_JAVA(acx_jc_result,[-d$MEM_MODEL -classpath ${getsp_cp} getsp -test])
   if test "${acx_jc_result}" = "Test1234OK"; then
     r_cv_java_works=yes
   fi
@@ -125,10 +126,8 @@
 if test ${r_cv_java_works} = yes; then
   AC_CACHE_CHECK([Java environment], [r_cv_java_home], [
     ## find JAVA_HOME from Java itself unless specified
-    if test -z "${JAVA_HOME}" ; then
-      R_RUN_JAVA(JAVA_HOME,[-classpath ${getsp_cp} getsp java.home])
-    fi
-    r_cv_java_home="${JAVA_HOME}"
+    R_RUN_JAVA(JAVA_HOME,[-d$MEM_MODEL -classpath ${getsp_cp} getsp java.home])
+    r_cv_java_home=$(echo ${JAVA_HOME} | $SED -e 's,/jre$,,')
   ])
   JAVA_HOME="${r_cv_java_home}"
 
@@ -168,9 +167,9 @@
         JAVA_LD_LIBRARY_PATH=
         ;;
       *)
-        R_RUN_JAVA(JAVA_LIBS, [-classpath ${getsp_cp} getsp -libs])
+        R_RUN_JAVA(JAVA_LIBS, [-d$MEM_MODEL -classpath ${getsp_cp} getsp -libs])
         JAVA_LIBS="${JAVA_LIBS} -ljvm"
-        R_RUN_JAVA(JAVA_LD_LIBRARY_PATH, [-classpath ${getsp_cp} getsp java.library.path])
+        R_RUN_JAVA(JAVA_LD_LIBRARY_PATH, [-d$MEM_MODEL -classpath ${getsp_cp} getsp java.library.path])
 
 	JAVA_LIBS0=`echo ${JAVA_LIBS} | sed -e s:${JAVA_HOME}:\$\(JAVA_HOME\):g`
 	JAVA_LD_LIBRARY_PATH=`echo ${JAVA_LD_LIBRARY_PATH} | sed -e s:${JAVA_HOME}:\$\(JAVA_HOME\):g`
