java configure bug on gentoo

Wols Lists antlists at youngman.org.uk
Tue Mar 1 17:22:49 UTC 2016


Just tried to build lo on my system and it blew up with "can't find java
home" - the worst kind of failure in that it didn't succeed, didn't
fail, but thought it had succeeded.

So I've debugged it successfully in ./configure, but that appears to be
a generated file, so when I went to test it, it seems to have blown my
changes away! How do I fix ./configure so the changes stick?

Basically, what happens - and I believe this is not unique to gentoo -
is that the distro replaces the javac, javadoc, and a bunch of other
commands with a script that chooses which version of java to run. With
the result that configure thinks it's found java_home, but it's actually
pointing to a distro script.

What I've found out is that by looking for this at the appropriate
point, and setting java_home to null, the following test seems to detect
java_home correctly. I attach the modified code so someone else can fix
it if they choose, or point me at what to do.

       else
            # else warn
            { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: JAVA_HOME
is set to /usr - this is very likely to be incorrect" >&5
$as_echo "$as_me: WARNING: JAVA_HOME is set to /usr - this is very
likely to be incorrect" >&2;}
            { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: if this is
the case, please inform the correct JAVA_HOME with --with-jdk-home" >&5
$as_echo "$as_me: WARNING: if this is the case, please inform the
correct JAVA_HOME with --with-jdk-home" >&2;}
            add_warning "JAVA_HOME is set to /usr - this is very likely
to be incorrect"
            add_warning "if this is the case, please inform the correct
JAVA_HOME with --with-jdk-home"
        fi
                if test "$JAVA_HOME" != "/usr"; then
            if test "$_os" = "Darwin" -o "$OS_FOR_BUILD" = MACOSX; then
                                JAVA_HOME=$(echo $JAVA_HOME | $SED -e
s,/Current/Commands/javac$,/CurrentJDK/Home,)
                                JAVA_HOME=$(echo $JAVA_HOME | $SED -e
s,/CurrentJDK/Commands/javac$,/CurrentJDK/Home,)
            else
                JAVA_HOME=$(echo $JAVA_HOME | $SED -e s,/bin/javac$,,)
echo 6 JAVA_HOME $JAVA_HOME
                if test -f "$JAVA_HOME"; then
                    JAVA_HOME=""; # certain distros eg gentoo, javac
points to a script that selects java version
echo 6a JAVA_HOME $JAVA_HOME
                fi
            fi
        fi
    fi


Basically, the fix is the test (after my "echo 6" debug statement :-) to
see if JAVA_HOME is pointing at a file. The preceding sed command fails
on gentoo (and would produce the wrong result anyway) so you need to
throw away the contents of java_home and let the next test succeed.

Cheers,
Wol


More information about the LibreOffice mailing list