#  Copyright (c) 1997-2009
#  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Darmstadt, Germany)
#  http://www.polymake.de
#
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the
#  Free Software Foundation; either version 2, or (at your option) any
#  later version: http://www.gnu.org/licenses/gpl.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#-------------------------------------------------------------------------------
#  $Project: polymake $$Id: java_configure 9298 2009-09-02 23:10:56Z gawrilow $

# java interpreter suitable for JavaView and jReality
custom $java;

CONFIGURE {
   my $env_java=exists $ENV{JAVA_HOME} && "$ENV{JAVA_HOME}/bin/java";
   if ($env_java && -x $env_java) {
      $java ||= $env_java;
      enter_executable_path($java, "Please enter the path to the java interpreter", "A") if -t STDIN;
   } else {
      find_via_path($java, "java", "A");
   }

   while (defined($java)) {
      my ($java_version)= `$java -version 2>&1` =~ /version "([\d.]+)/s;
      last if eval("v$java_version") ge v1.5;
      print <<".";
The java interpreter you have just specified tells its version is $java_version.
You need Java 5 (version 1.5.0) or newer in order to use the polymake interface
to JavaView and jReality visualization engines.

.
      enter_executable_path($java, "Please enter the path to the java interpreter v1.5 or newer", "A");
   }

   defined($java) or do {
      warn_print( "Interfaces to JavaView and jReality visualization engines are disabled!" );
      undef;
   }
}


# Local Variables:
# mode: perl
# c-basic-offset:3
# End:
