| 39282 |
urbaneks |
1 |
if test -z "${R_HOME}"; then
|
| 61924 |
ripley |
2 |
echo "This command can be only executed via R CMD!"
|
| 39282 |
urbaneks |
3 |
exit 1
|
|
|
4 |
fi
|
|
|
5 |
|
| 61911 |
ripley |
6 |
## pick up configure-time settings
|
| 61924 |
ripley |
7 |
. "${R_HOME}/etc${R_ARCH}/javaconf"
|
| 61911 |
ripley |
8 |
|
| 61888 |
ripley |
9 |
DYLIB_EXT=`${R_HOME}/bin/R CMD config DYLIB_EXT`
|
| 39282 |
urbaneks |
10 |
tools_classpath=${R_SHARE_DIR}/java
|
|
|
11 |
|
| 47443 |
hornik |
12 |
revision='$Rev: 77228 $'
|
| 47442 |
hornik |
13 |
version=`set - ${revision}; echo ${2}`
|
| 47522 |
ripley |
14 |
version="R Java configurator: ${R_VERSION} (r${version})
|
| 47442 |
hornik |
15 |
|
| 74000 |
ripley |
16 |
Copyright (C) 2002-2018 The R Core Team.
|
| 47442 |
hornik |
17 |
This is free software; see the GNU General Public License version 2
|
|
|
18 |
or later for copying conditions. There is NO warranty."
|
|
|
19 |
|
| 39282 |
urbaneks |
20 |
usage="
|
|
|
21 |
Usage: R CMD javareconf [options]
|
|
|
22 |
|
|
|
23 |
Detect current Java setup and update the corresponding configuration in R.
|
|
|
24 |
|
|
|
25 |
Options:
|
| 41185 |
urbaneks |
26 |
-h, --help print this help message and exit
|
| 47442 |
hornik |
27 |
-v, --version print version info and exit
|
| 39282 |
urbaneks |
28 |
-n, --dry-run perform Java detection, but don't touch any
|
| 61924 |
ripley |
29 |
configuration files
|
| 41185 |
urbaneks |
30 |
-e <prog> same as -n but exports all detected variables
|
|
|
31 |
and runs <prog>. If -e is the last argument
|
|
|
32 |
or <prog> is '' then a shell is used instead
|
| 39282 |
urbaneks |
33 |
xxx=yyy evaluate the corresponding expression
|
|
|
34 |
(e.g. JAVA_HOME=/usr/lib/java)
|
|
|
35 |
|
|
|
36 |
Environment variables that can be used to influence the detection:
|
|
|
37 |
JAVA path to a Java interpreter executable
|
|
|
38 |
By default first 'java' command found on the PATH
|
|
|
39 |
is taken (unless JAVA_HOME is also specified).
|
|
|
40 |
JAVA_HOME home of the Java environment. If not specified,
|
|
|
41 |
it will be detected automatically from the Java
|
|
|
42 |
interpreter.
|
| 39782 |
urbaneks |
43 |
JAVAC path to a Java compiler
|
|
|
44 |
JAVAH path to a Java header/stub generator
|
|
|
45 |
JAR path to a Java archive tool
|
| 73549 |
ripley |
46 |
Values specified when R was configured will be used unless overridden.
|
| 39282 |
urbaneks |
47 |
|
| 41169 |
urbaneks |
48 |
The following variables should be used with extreme caution. They
|
|
|
49 |
must all match, so use only if you have a very special setup that
|
|
|
50 |
javareconf cannot detect automatically:
|
|
|
51 |
JAVA_LD_LIBRARY_PATH library path necessary at run-time
|
| 41185 |
urbaneks |
52 |
JAVA_CPPFLAGS C preprocessor flags necessary to compile JNI programs
|
| 41169 |
urbaneks |
53 |
JAVA_LIBS libraries (as linker flags) necessary to compile
|
|
|
54 |
JNI programs
|
|
|
55 |
|
| 71736 |
hornik |
56 |
Report bugs at <https://bugs.R-project.org>."
|
| 39282 |
urbaneks |
57 |
|
|
|
58 |
|
|
|
59 |
dry_run=no
|
| 41185 |
urbaneks |
60 |
export_vars=no
|
| 39282 |
urbaneks |
61 |
while test -n "${1}"; do
|
|
|
62 |
case ${1} in
|
|
|
63 |
-help | --help | -h) echo "${usage}"; exit 0 ;;
|
| 47442 |
hornik |
64 |
-v | --version) echo "${version}"; exit 0 ;;
|
| 39282 |
urbaneks |
65 |
-n | --dry-run) dry_run=yes ;;
|
| 57430 |
urbaneks |
66 |
-e) dry_run=yes; export_vars=yes; run_prog="${2}"; if test "$#" != 1; then shift; fi ;;
|
| 39282 |
urbaneks |
67 |
*=*) eval ${1} ;;
|
|
|
68 |
esac
|
|
|
69 |
shift
|
|
|
70 |
done
|
|
|
71 |
|
|
|
72 |
## find java compiler binaries
|
|
|
73 |
if test -z "${JAVA_HOME}" ; then
|
|
|
74 |
JAVA_PATH=${PATH}
|
|
|
75 |
else
|
| 52710 |
ripley |
76 |
if test ! -d "${JAVA_HOME}"; then
|
| 39282 |
urbaneks |
77 |
echo "*** JAVA_HOME is not a valid path, ignoring"
|
|
|
78 |
JAVA_HOME=
|
| 43163 |
urbaneks |
79 |
JAVA_PATH=${PATH}
|
|
|
80 |
else
|
|
|
81 |
## try jre/bin first just in case we don't have full JDK
|
|
|
82 |
JAVA_PATH=${JAVA_HOME}:${JAVA_HOME}/jre/bin:${JAVA_HOME}/bin:${JAVA_HOME}/../bin:${PATH}
|
| 39282 |
urbaneks |
83 |
fi
|
|
|
84 |
fi
|
|
|
85 |
## if 'java' is not on the PATH or JAVA_HOME, add some guesses as of
|
|
|
86 |
## where java could live
|
| 43163 |
urbaneks |
87 |
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
|
| 39282 |
urbaneks |
88 |
|
|
|
89 |
if test -z "$JAVA"; then
|
|
|
90 |
save_IFS=$IFS; IFS=:
|
|
|
91 |
for dir in ${JAVA_PATH}; do
|
|
|
92 |
if test -f "$dir/java"; then
|
|
|
93 |
JAVA="$dir/java"
|
| 39285 |
urbaneks |
94 |
break
|
| 39282 |
urbaneks |
95 |
fi
|
|
|
96 |
done
|
| 39285 |
urbaneks |
97 |
IFS=${save_IFS}
|
| 39282 |
urbaneks |
98 |
fi
|
|
|
99 |
|
|
|
100 |
if test -z "$JAVA"; then
|
| 43235 |
ripley |
101 |
echo "~*** Cannot find any Java interpreter~*** Please make sure 'java' is on your PATH or set JAVA_HOME correspondingly"|${SED-sed} -e 'y/~/\n/' >&2
|
| 39282 |
urbaneks |
102 |
exit 1
|
|
|
103 |
fi
|
|
|
104 |
|
|
|
105 |
echo "Java interpreter : $JAVA"
|
|
|
106 |
jires=`$JAVA -classpath ${tools_classpath} getsp -test`
|
|
|
107 |
if test "$jires" != "Test1234OK"; then
|
|
|
108 |
echo "$jires"
|
| 43235 |
ripley |
109 |
echo "~*** Java interpreter doesn't work properly.~"|${SED-sed} -e 'y/~/\n/' >&2
|
| 39282 |
urbaneks |
110 |
exit 1
|
|
|
111 |
fi
|
|
|
112 |
|
|
|
113 |
if test -z "${JAVA_HOME}"; then
|
|
|
114 |
JAVA_HOME=`$JAVA -classpath ${tools_classpath} getsp java.home`
|
|
|
115 |
fi
|
|
|
116 |
|
|
|
117 |
if test -z "${JAVA_HOME}"; then
|
| 43235 |
ripley |
118 |
echo "~*** Cannot find Java environemnt.~*** Please set JAVA_HOME correspondingly.~"|${SED-sed} -e 'y/~/\n/' >&2
|
| 39282 |
urbaneks |
119 |
exit 1
|
|
|
120 |
fi
|
|
|
121 |
|
|
|
122 |
echo "Java version : `$JAVA -classpath ${tools_classpath} getsp java.version 2>/dev/null`"
|
|
|
123 |
echo "Java home path : ${JAVA_HOME}"
|
|
|
124 |
|
| 39782 |
urbaneks |
125 |
# optional parts - compiler, javah and jar
|
|
|
126 |
if test -z "$JAVAC"; then
|
|
|
127 |
save_IFS=$IFS; IFS=:
|
|
|
128 |
for dir in ${JAVA_PATH}; do
|
|
|
129 |
if test -f "$dir/javac"; then
|
|
|
130 |
JAVAC="$dir/javac"
|
|
|
131 |
break
|
|
|
132 |
fi
|
|
|
133 |
done
|
|
|
134 |
IFS=${save_IFS}
|
|
|
135 |
fi
|
|
|
136 |
|
| 61937 |
ripley |
137 |
: ${TMPDIR=/tmp}
|
| 62851 |
ripley |
138 |
{ tempdir=`(mktemp -d -q "${TMPDIR}/Rjavareconf.XXXXXX") 2>/dev/null` \
|
| 46462 |
pd |
139 |
&& test -n "${tempdir}" && test -d "${tempdir}" ; } ||
|
| 62851 |
ripley |
140 |
{ test -n "${RANDOM}" && tempdir=${TMPDIR}/Rjavareconf.$$-${RANDOM} \
|
| 46462 |
pd |
141 |
&& (mkdir "${tempdir}") ; } ||
|
| 62851 |
ripley |
142 |
{ tempdir=${TMPDIR}/Rjavareconf.$$-`date +%m%d%H%M%S` \
|
| 46462 |
pd |
143 |
&& (mkdir "${tempdir}"); } ||
|
| 62851 |
ripley |
144 |
{ tempdir=${TMPDIR}/Rjavareconf.$$ && (mkdir "${tempdir}") ; } ||
|
| 46462 |
pd |
145 |
(error "cannot create temporary directory" && exit 1)
|
|
|
146 |
|
| 61937 |
ripley |
147 |
# test functionality of the compiler
|
|
|
148 |
javac_works='not present'
|
|
|
149 |
if test -n "$JAVAC"; then
|
|
|
150 |
javac_works='not functional'
|
| 63550 |
ripley |
151 |
echo "public class A { }" > "${tempdir}/A.java"
|
|
|
152 |
if test -f "${tempdir}/A.java"; then
|
|
|
153 |
if "${JAVAC}" "${tempdir}/A.java" >/dev/null; then
|
|
|
154 |
if test -f "${tempdir}/A.class"; then
|
| 39782 |
urbaneks |
155 |
javac_works=yes
|
|
|
156 |
fi
|
|
|
157 |
fi
|
|
|
158 |
fi
|
|
|
159 |
fi
|
|
|
160 |
if test "${javac_works}" = yes; then
|
|
|
161 |
echo "Java compiler : ${JAVAC}"
|
|
|
162 |
else
|
|
|
163 |
echo "Java compiler : ${javac_works}"
|
|
|
164 |
fi
|
|
|
165 |
|
| 74361 |
ripley |
166 |
## FIXME:
|
|
|
167 |
## javah is deprecated in Java 9 and removed in 2018-03 snapshots.
|
|
|
168 |
## Worse, on macOS /usr/bin/javah still exists but links to a non-existent file
|
|
|
169 |
##'javac -h' replaces 'javah -d' so this needs changes in e.g. rJava.
|
| 39782 |
urbaneks |
170 |
if test -z "$JAVAH"; then
|
|
|
171 |
save_IFS=$IFS; IFS=:
|
|
|
172 |
for dir in ${JAVA_PATH}; do
|
|
|
173 |
if test -f "$dir/javah"; then
|
|
|
174 |
JAVAH="$dir/javah"
|
|
|
175 |
break
|
|
|
176 |
fi
|
|
|
177 |
done
|
|
|
178 |
IFS=${save_IFS}
|
|
|
179 |
fi
|
|
|
180 |
echo "Java headers gen.: ${JAVAH}"
|
|
|
181 |
|
|
|
182 |
if test -z "$JAR"; then
|
|
|
183 |
save_IFS=$IFS; IFS=:
|
|
|
184 |
for dir in ${JAVA_PATH}; do
|
|
|
185 |
if test -f "$dir/jar"; then
|
|
|
186 |
JAR="$dir/jar"
|
|
|
187 |
break
|
|
|
188 |
fi
|
|
|
189 |
done
|
|
|
190 |
IFS=${save_IFS}
|
|
|
191 |
fi
|
|
|
192 |
echo "Java archive tool: ${JAR}"
|
|
|
193 |
|
| 41169 |
urbaneks |
194 |
: ${JAVA_LIBS=~autodetect~}
|
|
|
195 |
: ${JAVA_CPPFLAGS=~autodetect~}
|
|
|
196 |
: ${JAVA_LD_LIBRARY_PATH=~autodetect~}
|
|
|
197 |
custom_JAVA_LIBS="${JAVA_LIBS}"
|
|
|
198 |
custom_JAVA_CPPFLAGS="${JAVA_CPPFLAGS}"
|
|
|
199 |
custom_JAVA_LD_LIBRARY_PATH="${JAVA_LD_LIBRARY_PATH}"
|
| 39782 |
urbaneks |
200 |
|
| 41169 |
urbaneks |
201 |
|
| 73541 |
ripley |
202 |
# sys-dependent tweaks to JNI flags -- Darwin ones removed for R 3.5
|
|
|
203 |
|
| 61930 |
ripley |
204 |
## we now look for a path to put in R_LD_LIBRARY_PATH which will
|
|
|
205 |
## enable libjvm to be found at run time. This should not be needed,
|
|
|
206 |
## but it seems that libjvm is often not in the ld.so cache.
|
| 61924 |
ripley |
207 |
if test "${JAVA_LIBS}" = "~autodetect~"; then
|
| 39282 |
urbaneks |
208 |
## we need to reset LD_LIBRARY_PATH, because Java automatically
|
|
|
209 |
## adds all LD_LIBRARY_PATH to Java path
|
|
|
210 |
save_LDLP=${LD_LIBRARY_PATH}
|
|
|
211 |
LD_LIBRARY_PATH=
|
|
|
212 |
export LD_LIBRARY_PATH
|
| 57316 |
urbaneks |
213 |
# remove trailing/leading : (if any)
|
|
|
214 |
java_library_path=`"$JAVA" -classpath "${tools_classpath}" getsp java.library.path| ${SED-sed} -e 's/:$//' -e 's/^://'`
|
| 61930 |
ripley |
215 |
## see if libjvm is on this path: it is not for recent Oracle Java
|
| 57316 |
urbaneks |
216 |
has_libjvm=no
|
|
|
217 |
save_IFS=$IFS; IFS=:
|
|
|
218 |
for dir in ${java_library_path}; do
|
| 61888 |
ripley |
219 |
if test -f "$dir/libjvm${DYLIB_EXT}"; then
|
| 57316 |
urbaneks |
220 |
has_libjvm=yes
|
| 61930 |
ripley |
221 |
java_library_path="${dir}"
|
| 57316 |
urbaneks |
222 |
break
|
|
|
223 |
fi
|
|
|
224 |
done
|
| 61930 |
ripley |
225 |
# Then try some heuristics using sun.boot.library.path
|
| 57316 |
urbaneks |
226 |
if test ${has_libjvm} = no; then
|
|
|
227 |
boot_path=`"$JAVA" -classpath "${tools_classpath}" getsp sun.boot.library.path| ${SED-sed} -e 's/:$//' -e 's/^://'`
|
|
|
228 |
if test -n "${boot_path}"; then
|
|
|
229 |
for dir in "${boot_path}" "${boot_path}/client" "${boot_path}/server"; do
|
| 61888 |
ripley |
230 |
if test -f "$dir/libjvm${DYLIB_EXT}"; then
|
| 57316 |
urbaneks |
231 |
has_libjvm=yes
|
| 61930 |
ripley |
232 |
java_library_path="${dir}"
|
| 57316 |
urbaneks |
233 |
break
|
|
|
234 |
fi
|
|
|
235 |
done
|
|
|
236 |
fi
|
|
|
237 |
fi
|
|
|
238 |
IFS=${save_IFS}
|
|
|
239 |
# replace occurrences of JAVA_HOME with $(JAVA_HOME)
|
| 63253 |
ripley |
240 |
# If JAVA_HOME was a link, it will be the canonical path we
|
|
|
241 |
# want to replace. We need realpath to determine what that is.
|
|
|
242 |
if test "@REALPATH@" != "false"; then
|
|
|
243 |
java_home=`@REALPATH@ "${JAVA_HOME}"`
|
|
|
244 |
else
|
| 63245 |
ripley |
245 |
java_home="${JAVA_HOME}"
|
|
|
246 |
fi
|
|
|
247 |
JAVA_LD_LIBRARY_PATH=`echo "${java_library_path}" | ${SED-sed} -e" s:${java_home}:\$\(JAVA_HOME\):g"`
|
|
|
248 |
|
| 39282 |
urbaneks |
249 |
LD_LIBRARY_PATH=${save_LDLP}
|
|
|
250 |
export LD_LIBRARY_PATH
|
|
|
251 |
# build JAVA_LIBS from the detected path
|
| 43235 |
ripley |
252 |
JAVA_LIBS=`echo ${JAVA_LD_LIBRARY_PATH}|${SED-sed} -e 's|:| -L|g'`
|
| 39282 |
urbaneks |
253 |
if test -n "${JAVA_LIBS}"; then JAVA_LIBS="-L${JAVA_LIBS}"; fi
|
|
|
254 |
JAVA_LIBS="${JAVA_LIBS} -ljvm"
|
|
|
255 |
# create shell-version to be used in scripts
|
| 43235 |
ripley |
256 |
JAVA_LD_LIBRARY_PATH_SH=`echo ${JAVA_LD_LIBRARY_PATH}|${SED-sed} -e 's:$(JAVA_HOME):\$\{JAVA_HOME\}:g'`
|
| 41169 |
urbaneks |
257 |
|
|
|
258 |
## includes consist of two parts - jni.h and machine-dependent jni_md.h
|
|
|
259 |
jinc=''
|
| 43163 |
urbaneks |
260 |
JAVA_CPPFLAGS=''
|
| 41169 |
urbaneks |
261 |
for pinc in include ../include jre/include; do
|
| 51821 |
ripley |
262 |
if test -f "${JAVA_HOME}/${pinc}/jni.h"; then jinc="${JAVA_HOME}/${pinc}"; break; fi
|
| 41169 |
urbaneks |
263 |
done
|
|
|
264 |
## only if we get jni.h we can try to find jni_md.h
|
|
|
265 |
if test -n "${jinc}"; then
|
|
|
266 |
JAVA_CPPFLAGS="-I${jinc}"
|
| 43163 |
urbaneks |
267 |
jmdinc=''
|
| 41169 |
urbaneks |
268 |
jmdirs=''
|
|
|
269 |
## we are not in configure, so we need to find the OS from R
|
| 77228 |
maechler |
270 |
host_os=`echo 'cat(R.version$os)'|${R_HOME}/bin/R --vanilla --no-echo 2>/dev/null`
|
| 41169 |
urbaneks |
271 |
## put the most probable locations for each system in the first place
|
|
|
272 |
case "${host_os}" in
|
| 62022 |
ripley |
273 |
darwin*) jmdirs=darwin;;
|
|
|
274 |
linux*) jmdirs=linux;;
|
| 41169 |
urbaneks |
275 |
bsdi*) jmdirs=bsdos;;
|
|
|
276 |
osf*) jmdirs=alpha;;
|
| 62022 |
ripley |
277 |
solaris*) jmdirs=solaris;;
|
| 41169 |
urbaneks |
278 |
freebsd*) jmdirs=freebsd; add_java_libs='-lpthread';;
|
|
|
279 |
esac
|
|
|
280 |
## in case host_os detection failed, add all candidates
|
|
|
281 |
if test -z "${jmdirs}"; then jmdirs='linux solaris freebsd alpha bsdos'; fi
|
|
|
282 |
## prepend . and append less-likely ones
|
|
|
283 |
jmdirs=". ${jmdirs} genunix ppc x86 iris hp-ux aix win32 cygwin openbsd"
|
|
|
284 |
for pimd in ${jmdirs}; do
|
| 51821 |
ripley |
285 |
if test -f "${jinc}/${pimd}/jni_md.h"; then jmdinc="${jinc}/${pimd}"; break; fi
|
| 41169 |
urbaneks |
286 |
done
|
|
|
287 |
if test -z "${jmdinc}"; then
|
|
|
288 |
# ultima-ratio: use find and pray that it works
|
| 44692 |
ripley |
289 |
jmdinc=`find "${jinc}/" -name jni_md.h 2> /dev/null |head -n 1 2>/dev/null`
|
| 41169 |
urbaneks |
290 |
if test -n "${jmdinc}"; then jmdinc=`dirname "${jmdinc}"`; fi
|
|
|
291 |
fi
|
|
|
292 |
if test -n "${jmdinc}"; then
|
|
|
293 |
if test "${jmdinc}" != "${jinc}/."; then
|
|
|
294 |
JAVA_CPPFLAGS="${JAVA_CPPFLAGS} -I${jmdinc}"
|
|
|
295 |
fi
|
|
|
296 |
fi
|
| 43235 |
ripley |
297 |
JAVA_CPPFLAGS=`echo ${JAVA_CPPFLAGS} | ${SED-sed} -e s:${JAVA_HOME}:\$\(JAVA_HOME\):g`
|
| 41169 |
urbaneks |
298 |
fi
|
| 61924 |
ripley |
299 |
fi
|
| 39282 |
urbaneks |
300 |
|
| 41169 |
urbaneks |
301 |
if test -n "${add_java_libs}"; then JAVA_LIBS="${JAVA_LIBS} ${add_java_libs}"; fi
|
|
|
302 |
|
|
|
303 |
## honor user overrides
|
|
|
304 |
acx_custom_java_libs=no
|
|
|
305 |
if test "${custom_JAVA_LIBS}" != '~autodetect~'; then
|
|
|
306 |
JAVA_LIBS="${custom_JAVA_LIBS}"
|
| 43235 |
ripley |
307 |
JAVA_LIBS0=`echo ${JAVA_LIBS} | ${SED-sed} -e s:${JAVA_HOME}:\$\(JAVA_HOME\):g`
|
| 41169 |
urbaneks |
308 |
acx_custom_java_libs=yes
|
|
|
309 |
fi
|
|
|
310 |
if test "${custom_JAVA_CPPFLAGS}" != '~autodetect~'; then
|
|
|
311 |
JAVA_CPPFLAGS="${custom_JAVA_CPPFLAGS}"
|
|
|
312 |
fi
|
|
|
313 |
if test "${custom_JAVA_LD_LIBRARY_PATH}" != '~autodetect~'; then
|
|
|
314 |
JAVA_LD_LIBRARY_PATH="${custom_JAVA_LD_LIBRARY_PATH}"
|
| 43235 |
ripley |
315 |
JAVA_LD_LIBRARY_PATH_SH=`echo ${JAVA_LD_LIBRARY_PATH}|${SED-sed} -e 's:$(JAVA_HOME):\$\{JAVA_HOME\}:g'`
|
| 41169 |
urbaneks |
316 |
fi
|
|
|
317 |
|
| 61937 |
ripley |
318 |
## Do cpmpile test in the temporary dir
|
|
|
319 |
wd=${PWD}
|
| 63550 |
ripley |
320 |
cd "${tempdir}"
|
| 61937 |
ripley |
321 |
|
| 61911 |
ripley |
322 |
echo
|
| 67942 |
ripley |
323 |
echo "trying to compile and link a JNI program "
|
| 61911 |
ripley |
324 |
echo "detected JNI cpp flags : ${JAVA_CPPFLAGS}"
|
|
|
325 |
echo "detected JNI linker flags : ${JAVA_LIBS}"
|
| 39282 |
urbaneks |
326 |
|
| 61911 |
ripley |
327 |
cat <<_ACEOF >conftest.c
|
|
|
328 |
#include <jni.h>
|
|
|
329 |
|
|
|
330 |
int main(void) {
|
|
|
331 |
JNI_CreateJavaVM(0, 0, 0);
|
|
|
332 |
return 0;
|
|
|
333 |
}
|
|
|
334 |
_ACEOF
|
|
|
335 |
|
|
|
336 |
JAVA_CPPFLAGS1=`echo ${JAVA_CPPFLAGS}|${SED-sed} -e 's:$(JAVA_HOME):'"${JAVA_HOME}:g"`
|
|
|
337 |
JAVA_LIBS1=`echo ${JAVA_LIBS}|${SED-sed} -e 's:$(JAVA_HOME):'"${JAVA_HOME}:g"`
|
|
|
338 |
cat <<_ACEOF >Makevars
|
|
|
339 |
PKG_CPPFLAGS = ${JAVA_CPPFLAGS1}
|
|
|
340 |
PKG_LIBS = ${JAVA_LIBS1}
|
|
|
341 |
_ACEOF
|
|
|
342 |
|
| 61970 |
ripley |
343 |
## in case e.g. -k was passed in the environment
|
| 67462 |
ripley |
344 |
MAKEFLAGS=
|
|
|
345 |
export MAKEFLAGS
|
| 61911 |
ripley |
346 |
${R_HOME}/bin/R CMD SHLIB conftest.c
|
|
|
347 |
ac_status=$?
|
|
|
348 |
|
|
|
349 |
if test $ac_status != 0; then
|
|
|
350 |
echo "Unable to compile a JNI program"
|
|
|
351 |
JAVA_LD_LIBRARY_PATH=
|
|
|
352 |
JAVA_LIBS=
|
|
|
353 |
JAVA_CPPFLAGS=
|
|
|
354 |
fi
|
|
|
355 |
|
| 61937 |
ripley |
356 |
rm -f conftest.c conftest.o conftest.so Makevars
|
|
|
357 |
cd ${wd}
|
| 74046 |
ripley |
358 |
rm -Rf "${tempdir}"
|
| 61911 |
ripley |
359 |
|
|
|
360 |
|
| 39282 |
urbaneks |
361 |
echo ""
|
|
|
362 |
|
| 41185 |
urbaneks |
363 |
if test "${export_vars}" = yes; then
|
| 63249 |
ripley |
364 |
## we have to re-substitute $(JAVA_HOME),
|
|
|
365 |
## otherwise it will be replaced by R's Makeconf setting
|
|
|
366 |
## which is highly likely different and thus not intended
|
| 57430 |
urbaneks |
367 |
JAVA_LD_LIBRARY_PATH=`echo ${JAVA_LD_LIBRARY_PATH}|${SED-sed} -e 's:$(JAVA_HOME):'"${JAVA_HOME}:g"`
|
|
|
368 |
JAVA_CPPFLAGS=`echo ${JAVA_CPPFLAGS}|${SED-sed} -e 's:$(JAVA_HOME):'"${JAVA_HOME}:g"`
|
|
|
369 |
JAVA_LIBS=`echo ${JAVA_LIBS}|${SED-sed} -e 's:$(JAVA_HOME):'"${JAVA_HOME}:g"`
|
|
|
370 |
|
| 41185 |
urbaneks |
371 |
export JAVA_HOME JAVA JAVAC JAVAH JAR JAVA_LIBS JAVA_CPPFLAGS JAVA_LD_LIBRARY_PATH
|
|
|
372 |
echo "The following Java variables have been exported:"
|
|
|
373 |
echo "JAVA_HOME JAVA JAVAC JAVAH JAR JAVA_LIBS JAVA_CPPFLAGS JAVA_LD_LIBRARY_PATH"
|
|
|
374 |
test -z "${run_prog}" && test -n "${SHELL}" && run_prog="${SHELL}"
|
|
|
375 |
test -z "${run_prog}" && run_prog=/bin/sh
|
| 57430 |
urbaneks |
376 |
echo "Running: ${run_prog}"
|
| 41185 |
urbaneks |
377 |
${run_prog}
|
|
|
378 |
exit 0
|
|
|
379 |
fi
|
|
|
380 |
|
| 61911 |
ripley |
381 |
echo ""
|
| 63249 |
ripley |
382 |
echo "JAVA_HOME : ${JAVA_HOME}"
|
| 61911 |
ripley |
383 |
echo "Java library path: ${JAVA_LD_LIBRARY_PATH}"
|
|
|
384 |
echo "JNI cpp flags : ${JAVA_CPPFLAGS}"
|
|
|
385 |
echo "JNI linker flags : ${JAVA_LIBS}"
|
|
|
386 |
|
| 41169 |
urbaneks |
387 |
test "${dry_run}" = yes && exit 0
|
| 39282 |
urbaneks |
388 |
|
|
|
389 |
echo "Updating Java configuration in ${R_HOME}"
|
|
|
390 |
|
| 61945 |
ripley |
391 |
## We update both the base and arch-specific versions as etc/Makefile
|
| 61947 |
ripley |
392 |
## copies the first to the second (only the second is used).
|
| 61945 |
ripley |
393 |
if test -n "${R_ARCH}"; then
|
|
|
394 |
files="${R_HOME}/etc/Makeconf ${R_HOME}/etc/ldpaths ${R_HOME}/etc${R_ARCH}/Makeconf ${R_HOME}/etc${R_ARCH}/ldpaths"
|
|
|
395 |
else
|
|
|
396 |
files="${R_HOME}/etc/Makeconf ${R_HOME}/etc/ldpaths"
|
|
|
397 |
fi
|
| 39282 |
urbaneks |
398 |
for file in $files; do
|
| 51642 |
ripley |
399 |
${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|" -e "s|JAVA_CPPFLAGS =.\{0,\}|JAVA_CPPFLAGS = ${JAVA_CPPFLAGS}|g" "${file}" > "${file}.new"
|
| 39282 |
urbaneks |
400 |
if test -f "${file}.new"; then
|
| 63871 |
ripley |
401 |
mv "${file}.new" "${file}"
|
| 39284 |
urbaneks |
402 |
else
|
| 43235 |
ripley |
403 |
echo "*** cannot create ${file}.new~*** Please run as root if required.~" | ${SED-sed} -e 'y/~/\n/' >&2
|
| 39284 |
urbaneks |
404 |
exit 1
|
| 39282 |
urbaneks |
405 |
fi
|
|
|
406 |
done
|
|
|
407 |
|
|
|
408 |
echo "Done."
|
| 41169 |
urbaneks |
409 |
echo ''
|
| 63241 |
ripley |
410 |
|
|
|
411 |
### Local Variables: ***
|
|
|
412 |
### mode: sh ***
|
|
|
413 |
### sh-indentation: 2 ***
|
|
|
414 |
### End: ***
|