Mercurial > hg > octave-lyh
changeset 15766:fafd51a1b0f0
build: Add more searching for Java libjvm.so.
On Macs, look for jni.h in a list of possible directories.
* configure.ac: Search for libjvm in JAVA_LDPATH, JAVA_BOOTPATH, and heuristic
list of directories. Search for jni.h in possible list of directories on Mac
platforms.
* build-aux/OctJavaQry.java: Add JAVA_BOOTPATH query option.
* build-aux/OctJavaQry.class: Add JAVA_BOOTPATH query option.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 11 Dec 2012 14:06:09 -0800 |
parents | 70bf9b6d47af |
children | e665645fb402 |
files | build-aux/OctJavaQry.class build-aux/OctJavaQry.java configure.ac |
diffstat | 3 files changed, 57 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
index 0aac42d91bb14a9c30c629e5460496ca31c8ea6e..f165d7eafe3c6b3523e8a822fa1862aed5119b07 GIT binary patch literal 774 zc${rg%Wl&^6g|^C>^N?drX;jL11(UT010HnA_ytvp{gWxP@*nifyQB!x;S=l#z_4L zK7b8d)@4x;i+%tfg}CDsqK0}g*K^M~ch0>tzkdHb1<*jlz#=Z|ST(SQD;ZqHH67~) z#j=6xxS?Z1$EJ>(I&NvWtznBH{n+(g`Gg^1RrVQ@PlI=YA=h?&u@{XT5%#&`Q6@R! zuFp`i-n0+-M_%{1Kdkp;==#H^5-#>6AH47I@fqLf1yMK<FI=_B*#o&ts#oDrO{q;R zA;*x}ZSA+-?%18@8t#~|P|;8|aToUpQ@q+iFcK#2qo$#5;sG8qWMfhLS+~{SVOWl7 zp6i61YLB@*AS*Fr+qU~tPH__XH75w<9M71!V#v?BvYkUQkmpj<Mrm5&L&Uua)wJ64 zf@bCQdCk#8iV+Pqh^Sa`%6Ef$mr6-0DEO#J?F@zNhQU~bl3Z+A7fkp66vN5|)flv~ z+Ijw*zkk<+4Vd&q)VBbpE`ioO?bazWimB>%uw(k6$<msRlL=%{z{(l*Q!EAcs;6J@ zvYKcV7EX}(jOA}g7E(WuK7sZX4F%{kAoCYkQ-BczOA5$Nf#cYcI&%{`tr}8vY93jX c$#8{?J|c9RTy#*vC1n+f@@kQ+6k}=W4~M0zR{#J2
--- a/build-aux/OctJavaQry.java +++ b/build-aux/OctJavaQry.java @@ -14,6 +14,10 @@ { System.out.println (System.getProperty ("java.library.path")); } + else if (args[0].equals ("JAVA_BOOTPATH")) + { + System.out.println (System.getProperty ("sun.boot.library.path")); + } } } }
--- a/configure.ac +++ b/configure.ac @@ -2254,7 +2254,7 @@ ## Find JAVA_HOME for JRE by running java and querying properties JAVA_TMP_HOME=`$JAVA -classpath ${srcdir}/build-aux OctJavaQry JAVA_HOME` ## Strip directory back to top-level installation dir (JAVA_HOME for JDK) - JAVA_HOME=`echo $JAVA_TMP_HOME | sed -e "s|/bin/\?$||" -e "s|/jre/\?$||"` + JAVA_HOME=`echo $JAVA_TMP_HOME | sed -e 's|/bin/\?$||' | sed -e 's|/jre/\?$||'` fi ## Amend search path for JAVAC and JAR. @@ -2296,28 +2296,60 @@ ;; esac + ## Determine Shared Library Extension + ## FIXME: May need dll extension for cygwin, mingw. + case $canonical_host_type in + *-*-darwin*) + shlext=dylib + ;; + *) + shlext=so + ;; + esac + + AC_MSG_CHECKING([for libjvm.${shlext}]) + ## Run Java to try and determine library path to libjvm.so. JAVA_TMP_LDPATH=`$JAVA -classpath ${srcdir}/build-aux OctJavaQry JAVA_LDPATH` - JAVA_TMP_LDPATH=`echo $JAVA_TMP_LDPATH | sed -e 's/^://' -e 's/:$//' -e 's/:/ /g'` + JAVA_TMP_LDPATH=`echo $JAVA_TMP_LDPATH | sed -e 's/:/ /g'` for dir in $JAVA_TMP_LDPATH; do - case $canonical_host_type in - *-*-darwin*) - if test -f "$dir/libjvm.dylib"; then - JAVA_LDPATH=$dir - break - fi - ;; - *) - if test -f "$dir/libjvm.so"; then - JAVA_LDPATH=$dir - break - fi - ;; - esac + if test -f "$dir/libjvm.${shlext}"; then + JAVA_LDPATH=$dir + break + fi done + if test -z "$JAVA_LDPATH"; then + ## Nothing found. Try Java again using bootpath argument. + JAVA_TMP_LDPATH=`$JAVA -classpath ${srcdir}/build-aux OctJavaQry JAVA_BOOTPATH` + JAVA_TMP_LDPATH="${JAVA_TMP_LDPATH} ${JAVA_TMP_LDPATH}/server" + for dir in $JAVA_TMP_LDPATH; do + if test -f "$dir/libjvm.${shlext}"; then + JAVA_LDPATH=$dir + break + fi + done + fi + + if test -z "$JAVA_LDPATH"; then + ## Java failed to find it's own library path. Guess wildly. + JAVA_TMP_LDPATH=`ls -d $JAVA_HOME/jre/lib/*/server` + ## Add some paths that might work on Macs. + JAVA_TMP_LDPATH="${JAVA_TMP_LDPATH} ${JAVA_HOME}/../Libraries ${JAVA_HOME}/Libraries" + for dir in $JAVA_TMP_LDPATH; do + if test -f "$dir/libjvm.${shlext}"; then + JAVA_LDPATH=$dir + break + fi + done + fi + + if test -z "$JAVA_LDPATH"; then + AC_MSG_RESULT([not found]) AC_MSG_WARN([Library libjvm not found. Octave will not be able to call Java methods.]) break + else + AC_MSG_RESULT([$JAVA_LDPATH]) fi ## Java and JVM found. Set up flags. @@ -2326,8 +2358,9 @@ ## Sneak the -framework flag into mkoctfile via LFLAGS LFLAGS="$LFLAGS -framework JavaVM" ## According to: http://developer.apple.com/unix/crossplatform.html - ## one must explicitly set the include path - JAVA_CPPFLAGS="-I${JAVA_HOME}/include" + ## one must explicitly set the include path. + ## Unfortunately, the include path keeps moving around. + JAVA_CPPFLAGS="-I${JAVA_HOME}/include -I/System/Library/Frameworks/JavaVM.framework/Home/include -I/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers -I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers" JAVA_LIBS="-framework JavaVM" ;; *-mingw* | *-cygwin*) @@ -2339,8 +2372,8 @@ ;; esac - ## Search for jni.h include file. - JNI_PATH=`echo $JAVA_CPPFLAGS | sed -e "s/-I//g"` + ## Verify jni.h include file exists. + JNI_PATH=`echo $JAVA_CPPFLAGS | sed -e 's/-I//g'` have_jni=false for dir in $JNI_PATH; do if test -f "${dir}/jni.h"; then have_jni=true; break; fi