summaryrefslogtreecommitdiffstats
path: root/scilab/configure
diff options
context:
space:
mode:
authorClément DAVID <clement.david@scilab-enterprises.com>2015-11-13 09:36:45 +0100
committerClément DAVID <clement.david@scilab-enterprises.com>2015-11-13 17:25:54 +0100
commitf322da862f438d3ebbae25012f5f5dc96a374694 (patch)
tree485f97f522599aa9e1b9806f667b3724cfd155ec /scilab/configure
parent656187f3bf8f1dd9294ad81413ed4ca0c4101354 (diff)
downloadscilab-f322da862f438d3ebbae25012f5f5dc96a374694.zip
scilab-f322da862f438d3ebbae25012f5f5dc96a374694.tar.gz
Configure: reuse the same Java class to check
This avoid the compilation time + execution foreach (java class * classpath dir). It slightly improves the configure time for JAR dependencies. On my machine, `time ./configure` returns : 1m22.301s before 0m29.333s after Change-Id: I5ad28debb9d608367b9635f87ad613cded87ccdd
Diffstat (limited to 'scilab/configure')
-rwxr-xr-xscilab/configure11128
1 files changed, 7438 insertions, 3690 deletions
diff --git a/scilab/configure b/scilab/configure
index 9619768..3470ea1 100755
--- a/scilab/configure
+++ b/scilab/configure
@@ -804,8 +804,8 @@ COMMONS_IO
804BATIK 804BATIK
805FREEHEP_UTIL 805FREEHEP_UTIL
806FREEHEP_IO 806FREEHEP_IO
807FREEHEP_GRAPHICSIO
808FREEHEP_GRAPHICSIO_EMF 807FREEHEP_GRAPHICSIO_EMF
808FREEHEP_GRAPHICSIO
809FREEHEP_GRAPHICS2D 809FREEHEP_GRAPHICS2D
810FOP 810FOP
811JEUCLID_CORE 811JEUCLID_CORE
@@ -13571,148 +13571,153 @@ fi
13571 if test "$with_xcos" != no; then 13571 if test "$with_xcos" != no; then
13572 # jgraphx 13572 # jgraphx
13573 13573
13574 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jgraphx" >&5 13574 cat << \EOF > conftestSharedChecker.java
13575$as_echo_n "checking jgraphx... " >&6; } 13575// #line 13575 "configure"
13576 PACKAGE_JAR_FILE=
13577 found_jar=no
13578 saved_ac_java_classpath=$ac_java_classpath
13579 DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null)"
13580 for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR; do
13581 for jar in "$jardir/jgraphx.jar" "$jardir/libjgraphx.jar" "$jardir/libjgraphx-java.jar" "$jardir/jgraphx*.jar"; do
13582
13583# TODO check the behaviour when spaces
13584 jars_resolved=`ls $jar 2>/dev/null`
13585 for jar_resolved in $jars_resolved; do # If several jars matches
13586 if test -e "$jar_resolved"; then
13587 export ac_java_classpath="$jar_resolved:$ac_java_classpath"
13588
13589 cat << \EOF > conftest.java
13590// #line 13590 "configure"
13591import java.util.regex.Pattern; 13576import java.util.regex.Pattern;
13592 13577import java.io.File;
13593import com.mxgraph.model.mxCell; 13578import java.io.IOException;
13594 13579import java.lang.reflect.Field;
13595public class conftest { 13580import java.lang.reflect.InvocationTargetException;
13581import java.lang.reflect.Method;
13582import java.net.URL;
13583import java.net.URLClassLoader;
13584import java.util.ArrayList;
13585
13586public class conftestSharedChecker {
13587
13588 /**
13589 * Required arguments :
13590 * argv[0]: name of the jar package
13591 * argv[1]: name of the class (with the package prefix)
13592 * argv[2]: possible paths of the jar package (separated by ':')
13593 *
13594 * Optional arguments:
13595 * argv[3]: field or method used to retrieve the version
13596 * argv[4]: expected version
13597 * argv[5]: String comparator :
13598 * "=" for exact version
13599 */
13596 public static void main(String[] argv) { 13600 public static void main(String[] argv) {
13601 final String packageName = argv[0];
13602 final String className = argv[1];
13603 final String[] jarList = argv[2].split(":");
13597 13604
13598 } 13605 ArrayList<URL> found = new ArrayList<>();
13599 13606 for(String jar : jarList)
13600 private static int compare(String v1, String v2) { 13607 {
13601 String s1 = normalisedVersion(v1); 13608 try {
13602 String s2 = normalisedVersion(v2); 13609 File f = new File(jar);
13603 return s1.compareTo(s2); 13610 if (f.exists()) {
13604 } 13611 found.add(f.toURI().toURL());
13605 13612 }
13606 private static String normalisedVersion(String version) { 13613 } catch (IOException ex) {
13607 return normalisedVersion(version, ".", 4); 13614 System.err.println(ex.toString());
13608 } 13615 }
13609
13610 private static String normalisedVersion(String version, String sep, int maxWidth) {
13611 String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version);
13612 StringBuilder sb = new StringBuilder();
13613 for (String s : split) {
13614 sb.append(String.format("%" + maxWidth + 's', s));
13615 } 13616 }
13616 return sb.toString();
13617 }
13618}
13619EOF
13620
13621 CLASSPATH=$ac_java_classpath
13622 export CLASSPATH
13623 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java"
13624 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then
13625 if test ""no"" = "no"; then
13626 echo "yes" >&5
13627
13628 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
13629$as_echo "$jar_resolved" >&6; }
13630 found_jar=yes
13631 PACKAGE_JAR_FILE=$jar_resolved
13632 break 3
13633
13634 else
13635 cmd="$JAVA conftest"
13636 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
13637 echo "yes" >&5
13638
13639 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
13640$as_echo "$jar_resolved" >&6; }
13641 found_jar=yes
13642 PACKAGE_JAR_FILE=$jar_resolved
13643 break 3
13644
13645 else
13646 echo "configure: failed program was:" >&5
13647 cat conftest.java >&5
13648 if test -s conftest.java.output; then
13649 STDOUT=`cat conftest.java.output`
13650 fi
13651 echo "configure: CLASSPATH was $CLASSPATH" >&5
13652
13653 ac_java_classpath=$saved_ac_java_classpath
13654
13655
13656 fi
13657 fi
13658 if test -f conftest.java.output; then
13659 rm conftest.java.output
13660 fi
13661 else
13662 echo "configure: failed program was:" >&5
13663 cat conftest.java >&5
13664 echo "configure: CLASSPATH was $CLASSPATH" >&5
13665
13666 ac_java_classpath=$saved_ac_java_classpath
13667
13668
13669 fi
13670
13671 fi
13672 done
13673 done
13674 done
13675 if test "$found_jar" = "no"; then
13676 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
13677$as_echo "no" >&6; }
13678 if test "" = "yes"; then
13679 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find or use the Java package/jar jgraphx used by Diagram design (looking for package com.mxgraph.model.mxCell)" >&5
13680$as_echo "$as_me: WARNING: Could not find or use the Java package/jar jgraphx used by Diagram design (looking for package com.mxgraph.model.mxCell)" >&2;}
13681 else
13682 as_fn_error $? "Could not find or use the Java package/jar jgraphx used by Diagram design (looking for package com.mxgraph.model.mxCell)" "$LINENO" 5
13683 fi
13684 fi
13685
13686 JGRAPHX=$PACKAGE_JAR_FILE
13687
13688 13617
13618 URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()]));
13619 URL klassURL = null;
13620 Class<?> klass = null;
13621 try {
13622 String resourceName = className.replace(".", "/") + ".class";
13623 klassURL = localClassLoader.getResource(resourceName);
13624 klass = localClassLoader.loadClass(className);
13625 } catch (ClassNotFoundException ex) {
13626 System.err.println(className + " not found");
13627 System.exit(-1);
13628 }
13689 13629
13690 { $as_echo "$as_me:${as_lineno-$LINENO}: checking minimal version (2.0.0.1) of jgraphx" >&5 13630 String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!'));
13691$as_echo_n "checking minimal version (2.0.0.1) of jgraphx... " >&6; } 13631 String path = pathURL.substring(pathURL.indexOf(':') + 1);
13692 saved_ac_java_classpath=$ac_java_classpath 13632 System.err.println("found: " + path);
13693 export ac_java_classpath="$JGRAPHX:$ac_java_classpath"
13694 if test "x" == "x"; then
13695 13633
13696 cat << \EOF > conftest.java 13634 if (argv.length > 3) {
13697// #line 13697 "configure" 13635 checkVersion(klass, argv);
13698import java.util.regex.Pattern; 13636 }
13699 13637
13700import com.mxgraph.view.mxGraph; 13638 System.out.println(path);
13639 }
13701 13640
13702public class conftest { 13641 private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException {
13703 public static void main(String[] argv) { 13642 final String versionMethod = argv[3];
13704 String minVersion="2.0.0.1"; 13643 final String expected = argv[4];
13644 final String atLeastOrEqual;
13645 if (argv.length > 5)
13646 atLeastOrEqual = argv[5];
13647 else
13648 atLeastOrEqual = "<=";
13705 13649
13706 System.out.println(mxGraph.VERSION); 13650 try {
13707 if (compare(minVersion, mxGraph.VERSION) > 0) { 13651 try {
13708 System.exit(-1); 13652 Field field = klass.getField(versionMethod);
13709 } 13653 Object value = field.get(null);
13654 compareAndDisplay(atLeastOrEqual, expected, value);
13655 } catch (NoSuchFieldException fe) {
13656 Method method = null;
13657 try {
13658 method = klass.getMethod(versionMethod);
13659 } catch (NoSuchMethodException ex) {
13660 System.err.println(ex.toString());
13661 System.exit(-3);
13662 }
13663
13664 try {
13665 Object value = method.invoke(null);
13666 compareAndDisplay(atLeastOrEqual, expected, value);
13667 } catch (NullPointerException ex) {
13668 Object value = method.invoke(klass.newInstance());
13669 compareAndDisplay(atLeastOrEqual, expected, value);
13670 }
13671 }
13672 } catch (IllegalAccessException ex) {
13673 System.err.println(ex);
13674 System.exit(-2);
13675 } catch (InvocationTargetException ex) {
13676 System.err.println(ex);
13677 System.exit(-2);
13678 } catch (InstantiationException ex) {
13679 System.err.println(ex);
13680 System.exit(-2);
13681 }
13682 }
13710 13683
13684 private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) {
13685 int cmp = compare(expected, value.toString());
13686
13687 switch(atLeastOrEqual) {
13688 case ">":
13689 if (cmp > 0) {
13690 return;
13691 } else {
13692 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
13693 System.exit(-4);
13694 }
13695 case "==":
13696 if (cmp == 0) {
13697 return;
13698 } else {
13699 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
13700 System.exit(-4);
13701 }
13702 case "<=":
13703 if (cmp <= 0) {
13704 return;
13705 } else {
13706 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
13707 System.exit(-4);
13708 }
13709 default:
13710 System.err.println("unable to compare with "+atLeastOrEqual);
13711 System.exit(-4);
13712 }
13711 } 13713 }
13712 13714
13713 private static int compare(String v1, String v2) { 13715 private static int compare(String v1, String v2) {
13714 String s1 = normalisedVersion(v1); 13716 String s1 = normalisedVersion(v1);
13715 String s2 = normalisedVersion(v2); 13717 String s2 = normalisedVersion(v2);
13718
13719 System.err.println("compare: " + v1 + " normalised to " + s1);
13720 System.err.println("compare: " + v2 + " normalised to " + s2);
13716 return s1.compareTo(s2); 13721 return s1.compareTo(s2);
13717 } 13722 }
13718 13723
@@ -13733,146 +13738,175 @@ EOF
13733 13738
13734 CLASSPATH=$ac_java_classpath 13739 CLASSPATH=$ac_java_classpath
13735 export CLASSPATH 13740 export CLASSPATH
13736 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 13741 cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java"
13737 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 13742 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then
13738 if test ""yes"" = "no"; then 13743 echo "configure: conftestSharedChecker.class available" >&5
13739 echo "yes" >&5
13740 echo "yes"
13741 else
13742 cmd="$JAVA conftest"
13743 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
13744 echo "yes" >&5
13745 echo "yes"
13746 else
13747 echo "configure: failed program was:" >&5
13748 cat conftest.java >&5
13749 if test -s conftest.java.output; then
13750 STDOUT=`cat conftest.java.output`
13751 fi
13752 echo "configure: CLASSPATH was $CLASSPATH" >&5
13753 as_fn_error $? "Wrong version of jgraphx. Expected at least 2.0.0.1. Found $STDOUT" "$LINENO" 5
13754 fi
13755 fi
13756 if test -f conftest.java.output; then
13757 rm conftest.java.output
13758 fi
13759 else 13744 else
13760 echo "configure: failed program was:" >&5 13745 echo "configure: failed program was:" >&5
13761 cat conftest.java >&5 13746 cat conftestSharedChecker.java >&5
13762 echo "configure: CLASSPATH was $CLASSPATH" >&5 13747 echo "configure: CLASSPATH was $CLASSPATH" >&5
13763 as_fn_error $? "Wrong version of jgraphx. Expected at least 2.0.0.1. Found $STDOUT" "$LINENO" 5 13748 fi
13764 fi
13765 13749
13766 else
13767 13750
13768 cat << \EOF > conftest.java
13769// #line 13769 "configure"
13770import java.util.regex.Pattern;
13771 13751
13772import com.mxgraph.view.mxGraph;
13773 13752
13774public class conftest { 13753 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jgraphx" >&5
13775 public static void main(String[] argv) { 13754$as_echo_n "checking jgraphx... " >&6; }
13776 String minVersion="2.0.0.1"; 13755 PACKAGE_JAR_FILE=
13777 13756
13778 System.out.println(mxGraph.VERSION); 13757 DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
13779 if (compare(minVersion, mxGraph.VERSION) != 0) {
13780 System.exit(-1);
13781 }
13782 13758
13783 } 13759 jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'jgraphx.jar' -or -name 'libjgraphx.jar' -or -name 'libjgraphx-java.jar' -or -name 'jgraphx*.jar' \) -printf '%p:' 2>/dev/null)."
13784 13760
13785 private static int compare(String v1, String v2) { 13761 if test ! -f conftestSharedChecker.class ; then
13786 String s1 = normalisedVersion(v1);
13787 String s2 = normalisedVersion(v2);
13788 return s1.compareTo(s2);
13789 }
13790 13762
13791 private static String normalisedVersion(String version) { 13763 cat << \EOF > conftestSharedChecker.java
13792 return normalisedVersion(version, ".", 4); 13764// #line 13764 "configure"
13793 } 13765import java.util.regex.Pattern;
13766import java.io.File;
13767import java.io.IOException;
13768import java.lang.reflect.Field;
13769import java.lang.reflect.InvocationTargetException;
13770import java.lang.reflect.Method;
13771import java.net.URL;
13772import java.net.URLClassLoader;
13773import java.util.ArrayList;
13774
13775public class conftestSharedChecker {
13776
13777 /**
13778 * Required arguments :
13779 * argv[0]: name of the jar package
13780 * argv[1]: name of the class (with the package prefix)
13781 * argv[2]: possible paths of the jar package (separated by ':')
13782 *
13783 * Optional arguments:
13784 * argv[3]: field or method used to retrieve the version
13785 * argv[4]: expected version
13786 * argv[5]: String comparator :
13787 * "=" for exact version
13788 */
13789 public static void main(String[] argv) {
13790 final String packageName = argv[0];
13791 final String className = argv[1];
13792 final String[] jarList = argv[2].split(":");
13794 13793
13795 private static String normalisedVersion(String version, String sep, int maxWidth) { 13794 ArrayList<URL> found = new ArrayList<>();
13796 String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version); 13795 for(String jar : jarList)
13797 StringBuilder sb = new StringBuilder(); 13796 {
13798 for (String s : split) { 13797 try {
13799 sb.append(String.format("%" + maxWidth + 's', s)); 13798 File f = new File(jar);
13799 if (f.exists()) {
13800 found.add(f.toURI().toURL());
13801 }
13802 } catch (IOException ex) {
13803 System.err.println(ex.toString());
13804 }
13800 } 13805 }
13801 return sb.toString();
13802 }
13803}
13804EOF
13805
13806 CLASSPATH=$ac_java_classpath
13807 export CLASSPATH
13808 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java"
13809 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then
13810 if test ""yes"" = "no"; then
13811 echo "yes" >&5
13812 echo "yes"
13813 else
13814 cmd="$JAVA conftest"
13815 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
13816 echo "yes" >&5
13817 echo "yes"
13818 else
13819 echo "configure: failed program was:" >&5
13820 cat conftest.java >&5
13821 if test -s conftest.java.output; then
13822 STDOUT=`cat conftest.java.output`
13823 fi
13824 echo "configure: CLASSPATH was $CLASSPATH" >&5
13825 as_fn_error $? "Wrong version of jgraphx. Expected exact version 2.0.0.1. Found $STDOUT" "$LINENO" 5
13826 fi
13827 fi
13828 if test -f conftest.java.output; then
13829 rm conftest.java.output
13830 fi
13831 else
13832 echo "configure: failed program was:" >&5
13833 cat conftest.java >&5
13834 echo "configure: CLASSPATH was $CLASSPATH" >&5
13835 as_fn_error $? "Wrong version of jgraphx. Expected exact version 2.0.0.1. Found $STDOUT" "$LINENO" 5
13836 fi
13837
13838 fi
13839 ac_java_classpath=$saved_ac_java_classpath
13840
13841 13806
13842 fi 13807 URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()]));
13808 URL klassURL = null;
13809 Class<?> klass = null;
13810 try {
13811 String resourceName = className.replace(".", "/") + ".class";
13812 klassURL = localClassLoader.getResource(resourceName);
13813 klass = localClassLoader.loadClass(className);
13814 } catch (ClassNotFoundException ex) {
13815 System.err.println(className + " not found");
13816 System.exit(-1);
13817 }
13843 13818
13844 if test "$with_external_scirenderer" = yes; then 13819 String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!'));
13845 # scirenderer 13820 String path = pathURL.substring(pathURL.indexOf(':') + 1);
13821 System.err.println("found: " + path);
13846 13822
13847 { $as_echo "$as_me:${as_lineno-$LINENO}: checking scirenderer" >&5 13823 if (argv.length > 3) {
13848$as_echo_n "checking scirenderer... " >&6; } 13824 checkVersion(klass, argv);
13849 PACKAGE_JAR_FILE= 13825 }
13850 found_jar=no
13851 saved_ac_java_classpath=$ac_java_classpath
13852 DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null)"
13853 for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR; do
13854 for jar in "$jardir/scirenderer.jar" "$jardir/libscirenderer.jar" "$jardir/libscirenderer-java.jar" "$jardir/scirenderer*.jar"; do
13855
13856# TODO check the behaviour when spaces
13857 jars_resolved=`ls $jar 2>/dev/null`
13858 for jar_resolved in $jars_resolved; do # If several jars matches
13859 if test -e "$jar_resolved"; then
13860 export ac_java_classpath="$jar_resolved:$ac_java_classpath"
13861 13826
13862 cat << \EOF > conftest.java 13827 System.out.println(path);
13863// #line 13863 "configure" 13828 }
13864import java.util.regex.Pattern;
13865 13829
13866import org.scilab.forge.scirenderer.PackageInfo; 13830 private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException {
13831 final String versionMethod = argv[3];
13832 final String expected = argv[4];
13833 final String atLeastOrEqual;
13834 if (argv.length > 5)
13835 atLeastOrEqual = argv[5];
13836 else
13837 atLeastOrEqual = "<=";
13867 13838
13868public class conftest { 13839 try {
13869 public static void main(String[] argv) { 13840 try {
13841 Field field = klass.getField(versionMethod);
13842 Object value = field.get(null);
13843 compareAndDisplay(atLeastOrEqual, expected, value);
13844 } catch (NoSuchFieldException fe) {
13845 Method method = null;
13846 try {
13847 method = klass.getMethod(versionMethod);
13848 } catch (NoSuchMethodException ex) {
13849 System.err.println(ex.toString());
13850 System.exit(-3);
13851 }
13852
13853 try {
13854 Object value = method.invoke(null);
13855 compareAndDisplay(atLeastOrEqual, expected, value);
13856 } catch (NullPointerException ex) {
13857 Object value = method.invoke(klass.newInstance());
13858 compareAndDisplay(atLeastOrEqual, expected, value);
13859 }
13860 }
13861 } catch (IllegalAccessException ex) {
13862 System.err.println(ex);
13863 System.exit(-2);
13864 } catch (InvocationTargetException ex) {
13865 System.err.println(ex);
13866 System.exit(-2);
13867 } catch (InstantiationException ex) {
13868 System.err.println(ex);
13869 System.exit(-2);
13870 }
13871 }
13870 13872
13873 private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) {
13874 int cmp = compare(expected, value.toString());
13875
13876 switch(atLeastOrEqual) {
13877 case ">":
13878 if (cmp > 0) {
13879 return;
13880 } else {
13881 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
13882 System.exit(-4);
13883 }
13884 case "==":
13885 if (cmp == 0) {
13886 return;
13887 } else {
13888 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
13889 System.exit(-4);
13890 }
13891 case "<=":
13892 if (cmp <= 0) {
13893 return;
13894 } else {
13895 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
13896 System.exit(-4);
13897 }
13898 default:
13899 System.err.println("unable to compare with "+atLeastOrEqual);
13900 System.exit(-4);
13901 }
13871 } 13902 }
13872 13903
13873 private static int compare(String v1, String v2) { 13904 private static int compare(String v1, String v2) {
13874 String s1 = normalisedVersion(v1); 13905 String s1 = normalisedVersion(v1);
13875 String s2 = normalisedVersion(v2); 13906 String s2 = normalisedVersion(v2);
13907
13908 System.err.println("compare: " + v1 + " normalised to " + s1);
13909 System.err.println("compare: " + v2 + " normalised to " + s2);
13876 return s1.compareTo(s2); 13910 return s1.compareTo(s2);
13877 } 13911 }
13878 13912
@@ -13893,171 +13927,207 @@ EOF
13893 13927
13894 CLASSPATH=$ac_java_classpath 13928 CLASSPATH=$ac_java_classpath
13895 export CLASSPATH 13929 export CLASSPATH
13896 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 13930 cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java"
13897 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 13931 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then
13898 if test ""no"" = "no"; then 13932 echo "configure: conftestSharedChecker.class available" >&5
13899 echo "yes" >&5
13900
13901 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
13902$as_echo "$jar_resolved" >&6; }
13903 found_jar=yes
13904 PACKAGE_JAR_FILE=$jar_resolved
13905 break 3
13906
13907 else
13908 cmd="$JAVA conftest"
13909 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
13910 echo "yes" >&5
13911
13912 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
13913$as_echo "$jar_resolved" >&6; }
13914 found_jar=yes
13915 PACKAGE_JAR_FILE=$jar_resolved
13916 break 3
13917
13918 else
13919 echo "configure: failed program was:" >&5
13920 cat conftest.java >&5
13921 if test -s conftest.java.output; then
13922 STDOUT=`cat conftest.java.output`
13923 fi
13924 echo "configure: CLASSPATH was $CLASSPATH" >&5
13925
13926 ac_java_classpath=$saved_ac_java_classpath
13927
13928
13929 fi
13930 fi
13931 if test -f conftest.java.output; then
13932 rm conftest.java.output
13933 fi
13934 else 13933 else
13935 echo "configure: failed program was:" >&5 13934 echo "configure: failed program was:" >&5
13936 cat conftest.java >&5 13935 cat conftestSharedChecker.java >&5
13937 echo "configure: CLASSPATH was $CLASSPATH" >&5 13936 echo "configure: CLASSPATH was $CLASSPATH" >&5
13937 fi
13938 13938
13939 ac_java_classpath=$saved_ac_java_classpath 13939 fi
13940
13941
13942 fi
13943 13940
13944 fi 13941 CLASSPATH=$ac_java_classpath
13945 done 13942 export CLASSPATH
13946 done 13943 cmd="$JAVA conftestSharedChecker jgraphx com.mxgraph.view.mxGraph $jar_resolved VERSION 2.0.0.1 "
13947 done 13944 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5); then
13948 if test "$found_jar" = "no"; then 13945 PACKAGE_JAR_FILE=$(tail -n 1 conftestSharedChecker.java.output);
13946 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PACKAGE_JAR_FILE" >&5
13947$as_echo "$PACKAGE_JAR_FILE" >&6; }
13948 echo "yes" >&5
13949 # append the found file to the classpath to manage jar dependency
13950 ac_java_classpath="$ac_java_classpath:$PACKAGE_JAR_FILE"
13951 else
13949 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 13952 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
13950$as_echo "no" >&6; } 13953$as_echo "no" >&6; }
13951 if test "" = "yes"; then 13954 if test "" = "yes"; then
13952 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find or use the Java package/jar scirenderer used by Scilab Renderer (looking for package org.scilab.forge.scirenderer.PackageInfo)" >&5 13955 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find or use the Java package/jar jgraphx used by Diagram design (looking for package com.mxgraph.view.mxGraph)" >&5
13953$as_echo "$as_me: WARNING: Could not find or use the Java package/jar scirenderer used by Scilab Renderer (looking for package org.scilab.forge.scirenderer.PackageInfo)" >&2;} 13956$as_echo "$as_me: WARNING: Could not find or use the Java package/jar jgraphx used by Diagram design (looking for package com.mxgraph.view.mxGraph)" >&2;}
13954 else 13957 else
13955 as_fn_error $? "Could not find or use the Java package/jar scirenderer used by Scilab Renderer (looking for package org.scilab.forge.scirenderer.PackageInfo)" "$LINENO" 5 13958 as_fn_error $? "Could not find or use the Java package/jar jgraphx used by Diagram design (looking for package com.mxgraph.view.mxGraph)" "$LINENO" 5
13956 fi 13959 fi
13957 fi 13960 fi
13961 if test -f conftestSharedChecker.java.output; then
13962 rm conftestSharedChecker.java.output
13963 fi
13958 13964
13959 SCIRENDERER=$PACKAGE_JAR_FILE 13965 JGRAPHX=$PACKAGE_JAR_FILE
13960 SCIRENDERER_CP=$PACKAGE_JAR_FILE
13961 13966
13967 fi
13962 13968
13963 { $as_echo "$as_me:${as_lineno-$LINENO}: checking minimal version (1.1.0) of scirenderer" >&5 13969 if test "$with_external_scirenderer" = yes; then
13964$as_echo_n "checking minimal version (1.1.0) of scirenderer... " >&6; } 13970 # scirenderer
13965 saved_ac_java_classpath=$ac_java_classpath
13966 export ac_java_classpath="$SCIRENDERER:$ac_java_classpath"
13967 if test "x" == "x"; then
13968 13971
13969 cat << \EOF > conftest.java
13970// #line 13970 "configure"
13971import java.util.regex.Pattern;
13972 13972
13973import org.scilab.forge.scirenderer.PackageInfo;
13974 13973
13975public class conftest { 13974 { $as_echo "$as_me:${as_lineno-$LINENO}: checking scirenderer" >&5
13976 public static void main(String[] argv) { 13975$as_echo_n "checking scirenderer... " >&6; }
13977 String minVersion="1.1.0"; 13976 PACKAGE_JAR_FILE=
13978 13977
13979 System.out.println(PackageInfo.VERSION); 13978 DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
13980 if (compare(minVersion, PackageInfo.VERSION) > 0) {
13981 System.exit(-1);
13982 }
13983 13979
13984 } 13980 jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'scirenderer.jar' -or -name 'libscirenderer.jar' -or -name 'libscirenderer-java.jar' -or -name 'scirenderer*.jar' \) -printf '%p:' 2>/dev/null)."
13985 13981
13986 private static int compare(String v1, String v2) { 13982 if test ! -f conftestSharedChecker.class ; then
13987 String s1 = normalisedVersion(v1);
13988 String s2 = normalisedVersion(v2);
13989 return s1.compareTo(s2);
13990 }
13991 13983
13992 private static String normalisedVersion(String version) { 13984 cat << \EOF > conftestSharedChecker.java
13993 return normalisedVersion(version, ".", 4); 13985// #line 13985 "configure"
13994 } 13986import java.util.regex.Pattern;
13987import java.io.File;
13988import java.io.IOException;
13989import java.lang.reflect.Field;
13990import java.lang.reflect.InvocationTargetException;
13991import java.lang.reflect.Method;
13992import java.net.URL;
13993import java.net.URLClassLoader;
13994import java.util.ArrayList;
13995
13996public class conftestSharedChecker {
13997
13998 /**
13999 * Required arguments :
14000 * argv[0]: name of the jar package
14001 * argv[1]: name of the class (with the package prefix)
14002 * argv[2]: possible paths of the jar package (separated by ':')
14003 *
14004 * Optional arguments:
14005 * argv[3]: field or method used to retrieve the version
14006 * argv[4]: expected version
14007 * argv[5]: String comparator :
14008 * "=" for exact version
14009 */
14010 public static void main(String[] argv) {
14011 final String packageName = argv[0];
14012 final String className = argv[1];
14013 final String[] jarList = argv[2].split(":");
13995 14014
13996 private static String normalisedVersion(String version, String sep, int maxWidth) { 14015 ArrayList<URL> found = new ArrayList<>();
13997 String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version); 14016 for(String jar : jarList)
13998 StringBuilder sb = new StringBuilder(); 14017 {
13999 for (String s : split) { 14018 try {
14000 sb.append(String.format("%" + maxWidth + 's', s)); 14019 File f = new File(jar);
14020 if (f.exists()) {
14021 found.add(f.toURI().toURL());
14022 }
14023 } catch (IOException ex) {
14024 System.err.println(ex.toString());
14025 }
14001 } 14026 }
14002 return sb.toString();
14003 }
14004}
14005EOF
14006 14027
14007 CLASSPATH=$ac_java_classpath 14028 URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()]));
14008 export CLASSPATH 14029 URL klassURL = null;
14009 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 14030 Class<?> klass = null;
14010 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 14031 try {
14011 if test ""yes"" = "no"; then 14032 String resourceName = className.replace(".", "/") + ".class";
14012 echo "yes" >&5 14033 klassURL = localClassLoader.getResource(resourceName);
14013 echo "yes" 14034 klass = localClassLoader.loadClass(className);
14014 else 14035 } catch (ClassNotFoundException ex) {
14015 cmd="$JAVA conftest" 14036 System.err.println(className + " not found");
14016 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then 14037 System.exit(-1);
14017 echo "yes" >&5 14038 }
14018 echo "yes"
14019 else
14020 echo "configure: failed program was:" >&5
14021 cat conftest.java >&5
14022 if test -s conftest.java.output; then
14023 STDOUT=`cat conftest.java.output`
14024 fi
14025 echo "configure: CLASSPATH was $CLASSPATH" >&5
14026 as_fn_error $? "Wrong version of scirenderer. Expected at least 1.1.0. Found $STDOUT" "$LINENO" 5
14027 fi
14028 fi
14029 if test -f conftest.java.output; then
14030 rm conftest.java.output
14031 fi
14032 else
14033 echo "configure: failed program was:" >&5
14034 cat conftest.java >&5
14035 echo "configure: CLASSPATH was $CLASSPATH" >&5
14036 as_fn_error $? "Wrong version of scirenderer. Expected at least 1.1.0. Found $STDOUT" "$LINENO" 5
14037 fi
14038 14039
14039 else 14040 String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!'));
14041 String path = pathURL.substring(pathURL.indexOf(':') + 1);
14042 System.err.println("found: " + path);
14040 14043
14041 cat << \EOF > conftest.java 14044 if (argv.length > 3) {
14042// #line 14042 "configure" 14045 checkVersion(klass, argv);
14043import java.util.regex.Pattern; 14046 }
14044 14047
14045import org.scilab.forge.scirenderer.PackageInfo; 14048 System.out.println(path);
14049 }
14046 14050
14047public class conftest { 14051 private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException {
14048 public static void main(String[] argv) { 14052 final String versionMethod = argv[3];
14049 String minVersion="1.1.0"; 14053 final String expected = argv[4];
14054 final String atLeastOrEqual;
14055 if (argv.length > 5)
14056 atLeastOrEqual = argv[5];
14057 else
14058 atLeastOrEqual = "<=";
14050 14059
14051 System.out.println(PackageInfo.VERSION); 14060 try {
14052 if (compare(minVersion, PackageInfo.VERSION) != 0) { 14061 try {
14053 System.exit(-1); 14062 Field field = klass.getField(versionMethod);
14054 } 14063 Object value = field.get(null);
14064 compareAndDisplay(atLeastOrEqual, expected, value);
14065 } catch (NoSuchFieldException fe) {
14066 Method method = null;
14067 try {
14068 method = klass.getMethod(versionMethod);
14069 } catch (NoSuchMethodException ex) {
14070 System.err.println(ex.toString());
14071 System.exit(-3);
14072 }
14073
14074 try {
14075 Object value = method.invoke(null);
14076 compareAndDisplay(atLeastOrEqual, expected, value);
14077 } catch (NullPointerException ex) {
14078 Object value = method.invoke(klass.newInstance());
14079 compareAndDisplay(atLeastOrEqual, expected, value);
14080 }
14081 }
14082 } catch (IllegalAccessException ex) {
14083 System.err.println(ex);
14084 System.exit(-2);
14085 } catch (InvocationTargetException ex) {
14086 System.err.println(ex);
14087 System.exit(-2);
14088 } catch (InstantiationException ex) {
14089 System.err.println(ex);
14090 System.exit(-2);
14091 }
14092 }
14055 14093
14094 private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) {
14095 int cmp = compare(expected, value.toString());
14096
14097 switch(atLeastOrEqual) {
14098 case ">":
14099 if (cmp > 0) {
14100 return;
14101 } else {
14102 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14103 System.exit(-4);
14104 }
14105 case "==":
14106 if (cmp == 0) {
14107 return;
14108 } else {
14109 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14110 System.exit(-4);
14111 }
14112 case "<=":
14113 if (cmp <= 0) {
14114 return;
14115 } else {
14116 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14117 System.exit(-4);
14118 }
14119 default:
14120 System.err.println("unable to compare with "+atLeastOrEqual);
14121 System.exit(-4);
14122 }
14056 } 14123 }
14057 14124
14058 private static int compare(String v1, String v2) { 14125 private static int compare(String v1, String v2) {
14059 String s1 = normalisedVersion(v1); 14126 String s1 = normalisedVersion(v1);
14060 String s2 = normalisedVersion(v2); 14127 String s2 = normalisedVersion(v2);
14128
14129 System.err.println("compare: " + v1 + " normalised to " + s1);
14130 System.err.println("compare: " + v2 + " normalised to " + s2);
14061 return s1.compareTo(s2); 14131 return s1.compareTo(s2);
14062 } 14132 }
14063 14133
@@ -14078,39 +14148,43 @@ EOF
14078 14148
14079 CLASSPATH=$ac_java_classpath 14149 CLASSPATH=$ac_java_classpath
14080 export CLASSPATH 14150 export CLASSPATH
14081 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 14151 cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java"
14082 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 14152 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then
14083 if test ""yes"" = "no"; then 14153 echo "configure: conftestSharedChecker.class available" >&5
14084 echo "yes" >&5
14085 echo "yes"
14086 else
14087 cmd="$JAVA conftest"
14088 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
14089 echo "yes" >&5
14090 echo "yes"
14091 else
14092 echo "configure: failed program was:" >&5
14093 cat conftest.java >&5
14094 if test -s conftest.java.output; then
14095 STDOUT=`cat conftest.java.output`
14096 fi
14097 echo "configure: CLASSPATH was $CLASSPATH" >&5
14098 as_fn_error $? "Wrong version of scirenderer. Expected exact version 1.1.0. Found $STDOUT" "$LINENO" 5
14099 fi
14100 fi
14101 if test -f conftest.java.output; then
14102 rm conftest.java.output
14103 fi
14104 else 14154 else
14105 echo "configure: failed program was:" >&5 14155 echo "configure: failed program was:" >&5
14106 cat conftest.java >&5 14156 cat conftestSharedChecker.java >&5
14107 echo "configure: CLASSPATH was $CLASSPATH" >&5 14157 echo "configure: CLASSPATH was $CLASSPATH" >&5
14108 as_fn_error $? "Wrong version of scirenderer. Expected exact version 1.1.0. Found $STDOUT" "$LINENO" 5 14158 fi
14109 fi 14159
14160 fi
14110 14161
14162 CLASSPATH=$ac_java_classpath
14163 export CLASSPATH
14164 cmd="$JAVA conftestSharedChecker scirenderer org.scilab.forge.scirenderer.PackageInfo $jar_resolved VERSION 1.1.0 "
14165 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5); then
14166 PACKAGE_JAR_FILE=$(tail -n 1 conftestSharedChecker.java.output);
14167 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PACKAGE_JAR_FILE" >&5
14168$as_echo "$PACKAGE_JAR_FILE" >&6; }
14169 echo "yes" >&5
14170 # append the found file to the classpath to manage jar dependency
14171 ac_java_classpath="$ac_java_classpath:$PACKAGE_JAR_FILE"
14172 else
14173 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14174$as_echo "no" >&6; }
14175 if test "" = "yes"; then
14176 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find or use the Java package/jar scirenderer used by Scilab Renderer (looking for package org.scilab.forge.scirenderer.PackageInfo)" >&5
14177$as_echo "$as_me: WARNING: Could not find or use the Java package/jar scirenderer used by Scilab Renderer (looking for package org.scilab.forge.scirenderer.PackageInfo)" >&2;}
14178 else
14179 as_fn_error $? "Could not find or use the Java package/jar scirenderer used by Scilab Renderer (looking for package org.scilab.forge.scirenderer.PackageInfo)" "$LINENO" 5
14180 fi
14181 fi
14182 if test -f conftestSharedChecker.java.output; then
14183 rm conftestSharedChecker.java.output
14111 fi 14184 fi
14112 ac_java_classpath=$saved_ac_java_classpath
14113 14185
14186 SCIRENDERER=$PACKAGE_JAR_FILE
14187 SCIRENDERER_CP=$PACKAGE_JAR_FILE
14114 else 14188 else
14115 echo "Use external version of scirenderer" 14189 echo "Use external version of scirenderer"
14116 # Use the scirenderer in Scilab sources 14190 # Use the scirenderer in Scilab sources
@@ -14122,35 +14196,165 @@ EOF
14122 14196
14123 # Docking system 14197 # Docking system
14124 14198
14199
14200
14125 { $as_echo "$as_me:${as_lineno-$LINENO}: checking flexdock" >&5 14201 { $as_echo "$as_me:${as_lineno-$LINENO}: checking flexdock" >&5
14126$as_echo_n "checking flexdock... " >&6; } 14202$as_echo_n "checking flexdock... " >&6; }
14127 PACKAGE_JAR_FILE= 14203 PACKAGE_JAR_FILE=
14128 found_jar=no
14129 saved_ac_java_classpath=$ac_java_classpath
14130 DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null)"
14131 for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR; do
14132 for jar in "$jardir/flexdock.jar" "$jardir/libflexdock.jar" "$jardir/libflexdock-java.jar" "$jardir/flexdock*.jar"; do
14133
14134# TODO check the behaviour when spaces
14135 jars_resolved=`ls $jar 2>/dev/null`
14136 for jar_resolved in $jars_resolved; do # If several jars matches
14137 if test -e "$jar_resolved"; then
14138 export ac_java_classpath="$jar_resolved:$ac_java_classpath"
14139 14204
14140 cat << \EOF > conftest.java 14205 DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
14141// #line 14141 "configure"
14142import java.util.regex.Pattern;
14143 14206
14144import org.flexdock.docking.DockingManager; 14207 jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'flexdock.jar' -or -name 'libflexdock.jar' -or -name 'libflexdock-java.jar' -or -name 'flexdock*.jar' \) -printf '%p:' 2>/dev/null)."
14145 14208
14146public class conftest { 14209 if test ! -f conftestSharedChecker.class ; then
14210
14211 cat << \EOF > conftestSharedChecker.java
14212// #line 14212 "configure"
14213import java.util.regex.Pattern;
14214import java.io.File;
14215import java.io.IOException;
14216import java.lang.reflect.Field;
14217import java.lang.reflect.InvocationTargetException;
14218import java.lang.reflect.Method;
14219import java.net.URL;
14220import java.net.URLClassLoader;
14221import java.util.ArrayList;
14222
14223public class conftestSharedChecker {
14224
14225 /**
14226 * Required arguments :
14227 * argv[0]: name of the jar package
14228 * argv[1]: name of the class (with the package prefix)
14229 * argv[2]: possible paths of the jar package (separated by ':')
14230 *
14231 * Optional arguments:
14232 * argv[3]: field or method used to retrieve the version
14233 * argv[4]: expected version
14234 * argv[5]: String comparator :
14235 * "=" for exact version
14236 */
14147 public static void main(String[] argv) { 14237 public static void main(String[] argv) {
14238 final String packageName = argv[0];
14239 final String className = argv[1];
14240 final String[] jarList = argv[2].split(":");
14148 14241
14242 ArrayList<URL> found = new ArrayList<>();
14243 for(String jar : jarList)
14244 {
14245 try {
14246 File f = new File(jar);
14247 if (f.exists()) {
14248 found.add(f.toURI().toURL());
14249 }
14250 } catch (IOException ex) {
14251 System.err.println(ex.toString());
14252 }
14253 }
14254
14255 URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()]));
14256 URL klassURL = null;
14257 Class<?> klass = null;
14258 try {
14259 String resourceName = className.replace(".", "/") + ".class";
14260 klassURL = localClassLoader.getResource(resourceName);
14261 klass = localClassLoader.loadClass(className);
14262 } catch (ClassNotFoundException ex) {
14263 System.err.println(className + " not found");
14264 System.exit(-1);
14265 }
14266
14267 String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!'));
14268 String path = pathURL.substring(pathURL.indexOf(':') + 1);
14269 System.err.println("found: " + path);
14270
14271 if (argv.length > 3) {
14272 checkVersion(klass, argv);
14273 }
14274
14275 System.out.println(path);
14276 }
14277
14278 private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException {
14279 final String versionMethod = argv[3];
14280 final String expected = argv[4];
14281 final String atLeastOrEqual;
14282 if (argv.length > 5)
14283 atLeastOrEqual = argv[5];
14284 else
14285 atLeastOrEqual = "<=";
14286
14287 try {
14288 try {
14289 Field field = klass.getField(versionMethod);
14290 Object value = field.get(null);
14291 compareAndDisplay(atLeastOrEqual, expected, value);
14292 } catch (NoSuchFieldException fe) {
14293 Method method = null;
14294 try {
14295 method = klass.getMethod(versionMethod);
14296 } catch (NoSuchMethodException ex) {
14297 System.err.println(ex.toString());
14298 System.exit(-3);
14299 }
14300
14301 try {
14302 Object value = method.invoke(null);
14303 compareAndDisplay(atLeastOrEqual, expected, value);
14304 } catch (NullPointerException ex) {
14305 Object value = method.invoke(klass.newInstance());
14306 compareAndDisplay(atLeastOrEqual, expected, value);
14307 }
14308 }
14309 } catch (IllegalAccessException ex) {
14310 System.err.println(ex);
14311 System.exit(-2);
14312 } catch (InvocationTargetException ex) {
14313 System.err.println(ex);
14314 System.exit(-2);
14315 } catch (InstantiationException ex) {
14316 System.err.println(ex);
14317 System.exit(-2);
14318 }
14319 }
14320
14321 private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) {
14322 int cmp = compare(expected, value.toString());
14323
14324 switch(atLeastOrEqual) {
14325 case ">":
14326 if (cmp > 0) {
14327 return;
14328 } else {
14329 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14330 System.exit(-4);
14331 }
14332 case "==":
14333 if (cmp == 0) {
14334 return;
14335 } else {
14336 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14337 System.exit(-4);
14338 }
14339 case "<=":
14340 if (cmp <= 0) {
14341 return;
14342 } else {
14343 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14344 System.exit(-4);
14345 }
14346 default:
14347 System.err.println("unable to compare with "+atLeastOrEqual);
14348 System.exit(-4);
14349 }
14149 } 14350 }
14150 14351
14151 private static int compare(String v1, String v2) { 14352 private static int compare(String v1, String v2) {
14152 String s1 = normalisedVersion(v1); 14353 String s1 = normalisedVersion(v1);
14153 String s2 = normalisedVersion(v2); 14354 String s2 = normalisedVersion(v2);
14355
14356 System.err.println("compare: " + v1 + " normalised to " + s1);
14357 System.err.println("compare: " + v2 + " normalised to " + s2);
14154 return s1.compareTo(s2); 14358 return s1.compareTo(s2);
14155 } 14359 }
14156 14360
@@ -14171,171 +14375,205 @@ EOF
14171 14375
14172 CLASSPATH=$ac_java_classpath 14376 CLASSPATH=$ac_java_classpath
14173 export CLASSPATH 14377 export CLASSPATH
14174 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 14378 cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java"
14175 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 14379 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then
14176 if test ""no"" = "no"; then 14380 echo "configure: conftestSharedChecker.class available" >&5
14177 echo "yes" >&5
14178
14179 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
14180$as_echo "$jar_resolved" >&6; }
14181 found_jar=yes
14182 PACKAGE_JAR_FILE=$jar_resolved
14183 break 3
14184
14185 else
14186 cmd="$JAVA conftest"
14187 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
14188 echo "yes" >&5
14189
14190 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
14191$as_echo "$jar_resolved" >&6; }
14192 found_jar=yes
14193 PACKAGE_JAR_FILE=$jar_resolved
14194 break 3
14195
14196 else
14197 echo "configure: failed program was:" >&5
14198 cat conftest.java >&5
14199 if test -s conftest.java.output; then
14200 STDOUT=`cat conftest.java.output`
14201 fi
14202 echo "configure: CLASSPATH was $CLASSPATH" >&5
14203
14204 ac_java_classpath=$saved_ac_java_classpath
14205
14206
14207 fi
14208 fi
14209 if test -f conftest.java.output; then
14210 rm conftest.java.output
14211 fi
14212 else 14381 else
14213 echo "configure: failed program was:" >&5 14382 echo "configure: failed program was:" >&5
14214 cat conftest.java >&5 14383 cat conftestSharedChecker.java >&5
14215 echo "configure: CLASSPATH was $CLASSPATH" >&5 14384 echo "configure: CLASSPATH was $CLASSPATH" >&5
14385 fi
14216 14386
14217 ac_java_classpath=$saved_ac_java_classpath 14387 fi
14218
14219
14220 fi
14221 14388
14222 fi 14389 CLASSPATH=$ac_java_classpath
14223 done 14390 export CLASSPATH
14224 done 14391 cmd="$JAVA conftestSharedChecker flexdock org.flexdock.util.Utilities $jar_resolved VERSION 1.2.4 "
14225 done 14392 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5); then
14226 if test "$found_jar" = "no"; then 14393 PACKAGE_JAR_FILE=$(tail -n 1 conftestSharedChecker.java.output);
14394 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PACKAGE_JAR_FILE" >&5
14395$as_echo "$PACKAGE_JAR_FILE" >&6; }
14396 echo "yes" >&5
14397 # append the found file to the classpath to manage jar dependency
14398 ac_java_classpath="$ac_java_classpath:$PACKAGE_JAR_FILE"
14399 else
14227 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 14400 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14228$as_echo "no" >&6; } 14401$as_echo "no" >&6; }
14229 if test "" = "yes"; then 14402 if test "" = "yes"; then
14230 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find or use the Java package/jar flexdock used by Scilab Gui (looking for package org.flexdock.docking.DockingManager)" >&5 14403 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find or use the Java package/jar flexdock used by Scilab Gui (looking for package org.flexdock.util.Utilities)" >&5
14231$as_echo "$as_me: WARNING: Could not find or use the Java package/jar flexdock used by Scilab Gui (looking for package org.flexdock.docking.DockingManager)" >&2;} 14404$as_echo "$as_me: WARNING: Could not find or use the Java package/jar flexdock used by Scilab Gui (looking for package org.flexdock.util.Utilities)" >&2;}
14232 else 14405 else
14233 as_fn_error $? "Could not find or use the Java package/jar flexdock used by Scilab Gui (looking for package org.flexdock.docking.DockingManager)" "$LINENO" 5 14406 as_fn_error $? "Could not find or use the Java package/jar flexdock used by Scilab Gui (looking for package org.flexdock.util.Utilities)" "$LINENO" 5
14234 fi 14407 fi
14235 fi 14408 fi
14409 if test -f conftestSharedChecker.java.output; then
14410 rm conftestSharedChecker.java.output
14411 fi
14236 14412
14237 FLEXDOCK=$PACKAGE_JAR_FILE 14413 FLEXDOCK=$PACKAGE_JAR_FILE
14238 14414
14239 14415
14416 # Swing look&feel implementations
14240 14417
14241 { $as_echo "$as_me:${as_lineno-$LINENO}: checking minimal version (1.2.4) of flexdock" >&5
14242$as_echo_n "checking minimal version (1.2.4) of flexdock... " >&6; }
14243 saved_ac_java_classpath=$ac_java_classpath
14244 export ac_java_classpath="$FLEXDOCK:$ac_java_classpath"
14245 if test "x" == "x"; then
14246 14418
14247 cat << \EOF > conftest.java
14248// #line 14248 "configure"
14249import java.util.regex.Pattern;
14250 14419
14251import org.flexdock.util.Utilities; 14420 { $as_echo "$as_me:${as_lineno-$LINENO}: checking looks" >&5
14421$as_echo_n "checking looks... " >&6; }
14422 PACKAGE_JAR_FILE=
14252 14423
14253public class conftest { 14424 DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
14254 public static void main(String[] argv) {
14255 String minVersion="1.2.4";
14256 14425
14257 System.out.println(Utilities.VERSION); 14426 jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'looks.jar' -or -name 'liblooks.jar' -or -name 'liblooks-java.jar' -or -name 'looks*.jar' \) -printf '%p:' 2>/dev/null)."
14258 if (compare(minVersion, Utilities.VERSION) > 0) {
14259 System.exit(-1);
14260 }
14261 14427
14262 } 14428 if test ! -f conftestSharedChecker.class ; then
14263 14429
14264 private static int compare(String v1, String v2) { 14430 cat << \EOF > conftestSharedChecker.java
14265 String s1 = normalisedVersion(v1); 14431// #line 14431 "configure"
14266 String s2 = normalisedVersion(v2); 14432import java.util.regex.Pattern;
14267 return s1.compareTo(s2); 14433import java.io.File;
14268 } 14434import java.io.IOException;
14269 14435import java.lang.reflect.Field;
14270 private static String normalisedVersion(String version) { 14436import java.lang.reflect.InvocationTargetException;
14271 return normalisedVersion(version, ".", 4); 14437import java.lang.reflect.Method;
14272 } 14438import java.net.URL;
14439import java.net.URLClassLoader;
14440import java.util.ArrayList;
14441
14442public class conftestSharedChecker {
14443
14444 /**
14445 * Required arguments :
14446 * argv[0]: name of the jar package
14447 * argv[1]: name of the class (with the package prefix)
14448 * argv[2]: possible paths of the jar package (separated by ':')
14449 *
14450 * Optional arguments:
14451 * argv[3]: field or method used to retrieve the version
14452 * argv[4]: expected version
14453 * argv[5]: String comparator :
14454 * "=" for exact version
14455 */
14456 public static void main(String[] argv) {
14457 final String packageName = argv[0];
14458 final String className = argv[1];
14459 final String[] jarList = argv[2].split(":");
14273 14460
14274 private static String normalisedVersion(String version, String sep, int maxWidth) { 14461 ArrayList<URL> found = new ArrayList<>();
14275 String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version); 14462 for(String jar : jarList)
14276 StringBuilder sb = new StringBuilder(); 14463 {
14277 for (String s : split) { 14464 try {
14278 sb.append(String.format("%" + maxWidth + 's', s)); 14465 File f = new File(jar);
14466 if (f.exists()) {
14467 found.add(f.toURI().toURL());
14468 }
14469 } catch (IOException ex) {
14470 System.err.println(ex.toString());
14471 }
14279 } 14472 }
14280 return sb.toString();
14281 }
14282}
14283EOF
14284 14473
14285 CLASSPATH=$ac_java_classpath 14474 URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()]));
14286 export CLASSPATH 14475 URL klassURL = null;
14287 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 14476 Class<?> klass = null;
14288 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 14477 try {
14289 if test ""yes"" = "no"; then 14478 String resourceName = className.replace(".", "/") + ".class";
14290 echo "yes" >&5 14479 klassURL = localClassLoader.getResource(resourceName);
14291 echo "yes" 14480 klass = localClassLoader.loadClass(className);
14292 else 14481 } catch (ClassNotFoundException ex) {
14293 cmd="$JAVA conftest" 14482 System.err.println(className + " not found");
14294 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then 14483 System.exit(-1);
14295 echo "yes" >&5 14484 }
14296 echo "yes"
14297 else
14298 echo "configure: failed program was:" >&5
14299 cat conftest.java >&5
14300 if test -s conftest.java.output; then
14301 STDOUT=`cat conftest.java.output`
14302 fi
14303 echo "configure: CLASSPATH was $CLASSPATH" >&5
14304 as_fn_error $? "Wrong version of flexdock. Expected at least 1.2.4. Found $STDOUT" "$LINENO" 5
14305 fi
14306 fi
14307 if test -f conftest.java.output; then
14308 rm conftest.java.output
14309 fi
14310 else
14311 echo "configure: failed program was:" >&5
14312 cat conftest.java >&5
14313 echo "configure: CLASSPATH was $CLASSPATH" >&5
14314 as_fn_error $? "Wrong version of flexdock. Expected at least 1.2.4. Found $STDOUT" "$LINENO" 5
14315 fi
14316 14485
14317 else 14486 String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!'));
14487 String path = pathURL.substring(pathURL.indexOf(':') + 1);
14488 System.err.println("found: " + path);
14318 14489
14319 cat << \EOF > conftest.java 14490 if (argv.length > 3) {
14320// #line 14320 "configure" 14491 checkVersion(klass, argv);
14321import java.util.regex.Pattern; 14492 }
14322 14493
14323import org.flexdock.util.Utilities; 14494 System.out.println(path);
14495 }
14324 14496
14325public class conftest { 14497 private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException {
14326 public static void main(String[] argv) { 14498 final String versionMethod = argv[3];
14327 String minVersion="1.2.4"; 14499 final String expected = argv[4];
14500 final String atLeastOrEqual;
14501 if (argv.length > 5)
14502 atLeastOrEqual = argv[5];
14503 else
14504 atLeastOrEqual = "<=";
14328 14505
14329 System.out.println(Utilities.VERSION); 14506 try {
14330 if (compare(minVersion, Utilities.VERSION) != 0) { 14507 try {
14331 System.exit(-1); 14508 Field field = klass.getField(versionMethod);
14332 } 14509 Object value = field.get(null);
14510 compareAndDisplay(atLeastOrEqual, expected, value);
14511 } catch (NoSuchFieldException fe) {
14512 Method method = null;
14513 try {
14514 method = klass.getMethod(versionMethod);
14515 } catch (NoSuchMethodException ex) {
14516 System.err.println(ex.toString());
14517 System.exit(-3);
14518 }
14519
14520 try {
14521 Object value = method.invoke(null);
14522 compareAndDisplay(atLeastOrEqual, expected, value);
14523 } catch (NullPointerException ex) {
14524 Object value = method.invoke(klass.newInstance());
14525 compareAndDisplay(atLeastOrEqual, expected, value);
14526 }
14527 }
14528 } catch (IllegalAccessException ex) {
14529 System.err.println(ex);
14530 System.exit(-2);
14531 } catch (InvocationTargetException ex) {
14532 System.err.println(ex);
14533 System.exit(-2);
14534 } catch (InstantiationException ex) {
14535 System.err.println(ex);
14536 System.exit(-2);
14537 }
14538 }
14333 14539
14540 private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) {
14541 int cmp = compare(expected, value.toString());
14542
14543 switch(atLeastOrEqual) {
14544 case ">":
14545 if (cmp > 0) {
14546 return;
14547 } else {
14548 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14549 System.exit(-4);
14550 }
14551 case "==":
14552 if (cmp == 0) {
14553 return;
14554 } else {
14555 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14556 System.exit(-4);
14557 }
14558 case "<=":
14559 if (cmp <= 0) {
14560 return;
14561 } else {
14562 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14563 System.exit(-4);
14564 }
14565 default:
14566 System.err.println("unable to compare with "+atLeastOrEqual);
14567 System.exit(-4);
14568 }
14334 } 14569 }
14335 14570
14336 private static int compare(String v1, String v2) { 14571 private static int compare(String v1, String v2) {
14337 String s1 = normalisedVersion(v1); 14572 String s1 = normalisedVersion(v1);
14338 String s2 = normalisedVersion(v2); 14573 String s2 = normalisedVersion(v2);
14574
14575 System.err.println("compare: " + v1 + " normalised to " + s1);
14576 System.err.println("compare: " + v2 + " normalised to " + s2);
14339 return s1.compareTo(s2); 14577 return s1.compareTo(s2);
14340 } 14578 }
14341 14579
@@ -14356,144 +14594,28 @@ EOF
14356 14594
14357 CLASSPATH=$ac_java_classpath 14595 CLASSPATH=$ac_java_classpath
14358 export CLASSPATH 14596 export CLASSPATH
14359 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 14597 cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java"
14360 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 14598 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then
14361 if test ""yes"" = "no"; then 14599 echo "configure: conftestSharedChecker.class available" >&5
14362 echo "yes" >&5
14363 echo "yes"
14364 else
14365 cmd="$JAVA conftest"
14366 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
14367 echo "yes" >&5
14368 echo "yes"
14369 else
14370 echo "configure: failed program was:" >&5
14371 cat conftest.java >&5
14372 if test -s conftest.java.output; then
14373 STDOUT=`cat conftest.java.output`
14374 fi
14375 echo "configure: CLASSPATH was $CLASSPATH" >&5
14376 as_fn_error $? "Wrong version of flexdock. Expected exact version 1.2.4. Found $STDOUT" "$LINENO" 5
14377 fi
14378 fi
14379 if test -f conftest.java.output; then
14380 rm conftest.java.output
14381 fi
14382 else 14600 else
14383 echo "configure: failed program was:" >&5 14601 echo "configure: failed program was:" >&5
14384 cat conftest.java >&5 14602 cat conftestSharedChecker.java >&5
14385 echo "configure: CLASSPATH was $CLASSPATH" >&5 14603 echo "configure: CLASSPATH was $CLASSPATH" >&5
14386 as_fn_error $? "Wrong version of flexdock. Expected exact version 1.2.4. Found $STDOUT" "$LINENO" 5
14387 fi
14388
14389 fi 14604 fi
14390 ac_java_classpath=$saved_ac_java_classpath
14391
14392
14393 # Swing look&feel implementations
14394
14395 { $as_echo "$as_me:${as_lineno-$LINENO}: checking looks" >&5
14396$as_echo_n "checking looks... " >&6; }
14397 PACKAGE_JAR_FILE=
14398 found_jar=no
14399 saved_ac_java_classpath=$ac_java_classpath
14400 DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null)"
14401 for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR; do
14402 for jar in "$jardir/looks.jar" "$jardir/liblooks.jar" "$jardir/liblooks-java.jar" "$jardir/looks*.jar"; do
14403
14404# TODO check the behaviour when spaces
14405 jars_resolved=`ls $jar 2>/dev/null`
14406 for jar_resolved in $jars_resolved; do # If several jars matches
14407 if test -e "$jar_resolved"; then
14408 export ac_java_classpath="$jar_resolved:$ac_java_classpath"
14409
14410 cat << \EOF > conftest.java
14411// #line 14411 "configure"
14412import java.util.regex.Pattern;
14413
14414import com.jgoodies.looks.common.MenuItemRenderer;
14415
14416public class conftest {
14417 public static void main(String[] argv) {
14418 14605
14419 } 14606 fi
14420
14421 private static int compare(String v1, String v2) {
14422 String s1 = normalisedVersion(v1);
14423 String s2 = normalisedVersion(v2);
14424 return s1.compareTo(s2);
14425 }
14426
14427 private static String normalisedVersion(String version) {
14428 return normalisedVersion(version, ".", 4);
14429 }
14430
14431 private static String normalisedVersion(String version, String sep, int maxWidth) {
14432 String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version);
14433 StringBuilder sb = new StringBuilder();
14434 for (String s : split) {
14435 sb.append(String.format("%" + maxWidth + 's', s));
14436 }
14437 return sb.toString();
14438 }
14439}
14440EOF
14441 14607
14442 CLASSPATH=$ac_java_classpath 14608 CLASSPATH=$ac_java_classpath
14443 export CLASSPATH 14609 export CLASSPATH
14444 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 14610 cmd="$JAVA conftestSharedChecker looks com.jgoodies.looks.common.MenuItemRenderer $jar_resolved "
14445 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 14611 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5); then
14446 if test ""no"" = "no"; then 14612 PACKAGE_JAR_FILE=$(tail -n 1 conftestSharedChecker.java.output);
14447 echo "yes" >&5 14613 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PACKAGE_JAR_FILE" >&5
14448 14614$as_echo "$PACKAGE_JAR_FILE" >&6; }
14449 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5 14615 echo "yes" >&5
14450$as_echo "$jar_resolved" >&6; } 14616 # append the found file to the classpath to manage jar dependency
14451 found_jar=yes 14617 ac_java_classpath="$ac_java_classpath:$PACKAGE_JAR_FILE"
14452 PACKAGE_JAR_FILE=$jar_resolved
14453 break 3
14454
14455 else
14456 cmd="$JAVA conftest"
14457 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
14458 echo "yes" >&5
14459
14460 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
14461$as_echo "$jar_resolved" >&6; }
14462 found_jar=yes
14463 PACKAGE_JAR_FILE=$jar_resolved
14464 break 3
14465
14466 else
14467 echo "configure: failed program was:" >&5
14468 cat conftest.java >&5
14469 if test -s conftest.java.output; then
14470 STDOUT=`cat conftest.java.output`
14471 fi
14472 echo "configure: CLASSPATH was $CLASSPATH" >&5
14473
14474 ac_java_classpath=$saved_ac_java_classpath
14475
14476
14477 fi
14478 fi
14479 if test -f conftest.java.output; then
14480 rm conftest.java.output
14481 fi
14482 else 14618 else
14483 echo "configure: failed program was:" >&5
14484 cat conftest.java >&5
14485 echo "configure: CLASSPATH was $CLASSPATH" >&5
14486
14487 ac_java_classpath=$saved_ac_java_classpath
14488
14489
14490 fi
14491
14492 fi
14493 done
14494 done
14495 done
14496 if test "$found_jar" = "no"; then
14497 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 14619 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14498$as_echo "no" >&6; } 14620$as_echo "no" >&6; }
14499 if test ""yes"" = "yes"; then 14621 if test ""yes"" = "yes"; then
@@ -14503,41 +14625,174 @@ $as_echo "$as_me: WARNING: Could not find or use the Java package/jar looks used
14503 as_fn_error $? "Could not find or use the Java package/jar looks used by Scilab Gui - Look and feel (looking for package com.jgoodies.looks.common.MenuItemRenderer)" "$LINENO" 5 14625 as_fn_error $? "Could not find or use the Java package/jar looks used by Scilab Gui - Look and feel (looking for package com.jgoodies.looks.common.MenuItemRenderer)" "$LINENO" 5
14504 fi 14626 fi
14505 fi 14627 fi
14628 if test -f conftestSharedChecker.java.output; then
14629 rm conftestSharedChecker.java.output
14630 fi
14506 14631
14507 LOOKS=$PACKAGE_JAR_FILE 14632 LOOKS=$PACKAGE_JAR_FILE
14508 14633
14509 # Named differently under ArchLinux or Fedora 14634 # Named differently under ArchLinux or Fedora
14510 if test -z "$LOOKS"; then 14635 if test -z "$LOOKS"; then
14511 14636
14637
14638
14512 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jgoodies-looks" >&5 14639 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jgoodies-looks" >&5
14513$as_echo_n "checking jgoodies-looks... " >&6; } 14640$as_echo_n "checking jgoodies-looks... " >&6; }
14514 PACKAGE_JAR_FILE= 14641 PACKAGE_JAR_FILE=
14515 found_jar=no
14516 saved_ac_java_classpath=$ac_java_classpath
14517 DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null)"
14518 for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR; do
14519 for jar in "$jardir/jgoodies-looks.jar" "$jardir/libjgoodies-looks.jar" "$jardir/libjgoodies-looks-java.jar" "$jardir/jgoodies-looks*.jar"; do
14520
14521# TODO check the behaviour when spaces
14522 jars_resolved=`ls $jar 2>/dev/null`
14523 for jar_resolved in $jars_resolved; do # If several jars matches
14524 if test -e "$jar_resolved"; then
14525 export ac_java_classpath="$jar_resolved:$ac_java_classpath"
14526 14642
14527 cat << \EOF > conftest.java 14643 DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
14528// #line 14528 "configure"
14529import java.util.regex.Pattern;
14530 14644
14531import com.jgoodies.looks.common.MenuItemRenderer; 14645 jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'jgoodies-looks.jar' -or -name 'libjgoodies-looks.jar' -or -name 'libjgoodies-looks-java.jar' -or -name 'jgoodies-looks*.jar' \) -printf '%p:' 2>/dev/null)."
14532 14646
14533public class conftest { 14647 if test ! -f conftestSharedChecker.class ; then
14648
14649 cat << \EOF > conftestSharedChecker.java
14650// #line 14650 "configure"
14651import java.util.regex.Pattern;
14652import java.io.File;
14653import java.io.IOException;
14654import java.lang.reflect.Field;
14655import java.lang.reflect.InvocationTargetException;
14656import java.lang.reflect.Method;
14657import java.net.URL;
14658import java.net.URLClassLoader;
14659import java.util.ArrayList;
14660
14661public class conftestSharedChecker {
14662
14663 /**
14664 * Required arguments :
14665 * argv[0]: name of the jar package
14666 * argv[1]: name of the class (with the package prefix)
14667 * argv[2]: possible paths of the jar package (separated by ':')
14668 *
14669 * Optional arguments:
14670 * argv[3]: field or method used to retrieve the version
14671 * argv[4]: expected version
14672 * argv[5]: String comparator :
14673 * "=" for exact version
14674 */
14534 public static void main(String[] argv) { 14675 public static void main(String[] argv) {
14676 final String packageName = argv[0];
14677 final String className = argv[1];
14678 final String[] jarList = argv[2].split(":");
14679
14680 ArrayList<URL> found = new ArrayList<>();
14681 for(String jar : jarList)
14682 {
14683 try {
14684 File f = new File(jar);
14685 if (f.exists()) {
14686 found.add(f.toURI().toURL());
14687 }
14688 } catch (IOException ex) {
14689 System.err.println(ex.toString());
14690 }
14691 }
14692
14693 URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()]));
14694 URL klassURL = null;
14695 Class<?> klass = null;
14696 try {
14697 String resourceName = className.replace(".", "/") + ".class";
14698 klassURL = localClassLoader.getResource(resourceName);
14699 klass = localClassLoader.loadClass(className);
14700 } catch (ClassNotFoundException ex) {
14701 System.err.println(className + " not found");
14702 System.exit(-1);
14703 }
14704
14705 String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!'));
14706 String path = pathURL.substring(pathURL.indexOf(':') + 1);
14707 System.err.println("found: " + path);
14708
14709 if (argv.length > 3) {
14710 checkVersion(klass, argv);
14711 }
14712
14713 System.out.println(path);
14714 }
14715
14716 private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException {
14717 final String versionMethod = argv[3];
14718 final String expected = argv[4];
14719 final String atLeastOrEqual;
14720 if (argv.length > 5)
14721 atLeastOrEqual = argv[5];
14722 else
14723 atLeastOrEqual = "<=";
14724
14725 try {
14726 try {
14727 Field field = klass.getField(versionMethod);
14728 Object value = field.get(null);
14729 compareAndDisplay(atLeastOrEqual, expected, value);
14730 } catch (NoSuchFieldException fe) {
14731 Method method = null;
14732 try {
14733 method = klass.getMethod(versionMethod);
14734 } catch (NoSuchMethodException ex) {
14735 System.err.println(ex.toString());
14736 System.exit(-3);
14737 }
14738
14739 try {
14740 Object value = method.invoke(null);
14741 compareAndDisplay(atLeastOrEqual, expected, value);
14742 } catch (NullPointerException ex) {
14743 Object value = method.invoke(klass.newInstance());
14744 compareAndDisplay(atLeastOrEqual, expected, value);
14745 }
14746 }
14747 } catch (IllegalAccessException ex) {
14748 System.err.println(ex);
14749 System.exit(-2);
14750 } catch (InvocationTargetException ex) {
14751 System.err.println(ex);
14752 System.exit(-2);
14753 } catch (InstantiationException ex) {
14754 System.err.println(ex);
14755 System.exit(-2);
14756 }
14757 }
14535 14758
14759 private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) {
14760 int cmp = compare(expected, value.toString());
14761
14762 switch(atLeastOrEqual) {
14763 case ">":
14764 if (cmp > 0) {
14765 return;
14766 } else {
14767 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14768 System.exit(-4);
14769 }
14770 case "==":
14771 if (cmp == 0) {
14772 return;
14773 } else {
14774 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14775 System.exit(-4);
14776 }
14777 case "<=":
14778 if (cmp <= 0) {
14779 return;
14780 } else {
14781 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14782 System.exit(-4);
14783 }
14784 default:
14785 System.err.println("unable to compare with "+atLeastOrEqual);
14786 System.exit(-4);
14787 }
14536 } 14788 }
14537 14789
14538 private static int compare(String v1, String v2) { 14790 private static int compare(String v1, String v2) {
14539 String s1 = normalisedVersion(v1); 14791 String s1 = normalisedVersion(v1);
14540 String s2 = normalisedVersion(v2); 14792 String s2 = normalisedVersion(v2);
14793
14794 System.err.println("compare: " + v1 + " normalised to " + s1);
14795 System.err.println("compare: " + v2 + " normalised to " + s2);
14541 return s1.compareTo(s2); 14796 return s1.compareTo(s2);
14542 } 14797 }
14543 14798
@@ -14558,59 +14813,28 @@ EOF
14558 14813
14559 CLASSPATH=$ac_java_classpath 14814 CLASSPATH=$ac_java_classpath
14560 export CLASSPATH 14815 export CLASSPATH
14561 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 14816 cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java"
14562 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 14817 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then
14563 if test ""no"" = "no"; then 14818 echo "configure: conftestSharedChecker.class available" >&5
14564 echo "yes" >&5
14565
14566 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
14567$as_echo "$jar_resolved" >&6; }
14568 found_jar=yes
14569 PACKAGE_JAR_FILE=$jar_resolved
14570 break 3
14571
14572 else
14573 cmd="$JAVA conftest"
14574 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
14575 echo "yes" >&5
14576
14577 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
14578$as_echo "$jar_resolved" >&6; }
14579 found_jar=yes
14580 PACKAGE_JAR_FILE=$jar_resolved
14581 break 3
14582
14583 else
14584 echo "configure: failed program was:" >&5
14585 cat conftest.java >&5
14586 if test -s conftest.java.output; then
14587 STDOUT=`cat conftest.java.output`
14588 fi
14589 echo "configure: CLASSPATH was $CLASSPATH" >&5
14590
14591 ac_java_classpath=$saved_ac_java_classpath
14592
14593
14594 fi
14595 fi
14596 if test -f conftest.java.output; then
14597 rm conftest.java.output
14598 fi
14599 else 14819 else
14600 echo "configure: failed program was:" >&5 14820 echo "configure: failed program was:" >&5
14601 cat conftest.java >&5 14821 cat conftestSharedChecker.java >&5
14602 echo "configure: CLASSPATH was $CLASSPATH" >&5 14822 echo "configure: CLASSPATH was $CLASSPATH" >&5
14823 fi
14603 14824
14604 ac_java_classpath=$saved_ac_java_classpath 14825 fi
14605
14606
14607 fi
14608 14826
14609 fi 14827 CLASSPATH=$ac_java_classpath
14610 done 14828 export CLASSPATH
14611 done 14829 cmd="$JAVA conftestSharedChecker jgoodies-looks com.jgoodies.looks.common.MenuItemRenderer $jar_resolved "
14612 done 14830 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5); then
14613 if test "$found_jar" = "no"; then 14831 PACKAGE_JAR_FILE=$(tail -n 1 conftestSharedChecker.java.output);
14832 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PACKAGE_JAR_FILE" >&5
14833$as_echo "$PACKAGE_JAR_FILE" >&6; }
14834 echo "yes" >&5
14835 # append the found file to the classpath to manage jar dependency
14836 ac_java_classpath="$ac_java_classpath:$PACKAGE_JAR_FILE"
14837 else
14614 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 14838 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14615$as_echo "no" >&6; } 14839$as_echo "no" >&6; }
14616 if test "" = "yes"; then 14840 if test "" = "yes"; then
@@ -14620,6 +14844,9 @@ $as_echo "$as_me: WARNING: Could not find or use the Java package/jar jgoodies-l
14620 as_fn_error $? "Could not find or use the Java package/jar jgoodies-looks used by Scilab Gui - Look and feel (looking for package com.jgoodies.looks.common.MenuItemRenderer)" "$LINENO" 5 14844 as_fn_error $? "Could not find or use the Java package/jar jgoodies-looks used by Scilab Gui - Look and feel (looking for package com.jgoodies.looks.common.MenuItemRenderer)" "$LINENO" 5
14621 fi 14845 fi
14622 fi 14846 fi
14847 if test -f conftestSharedChecker.java.output; then
14848 rm conftestSharedChecker.java.output
14849 fi
14623 14850
14624 LOOKS=$PACKAGE_JAR_FILE 14851 LOOKS=$PACKAGE_JAR_FILE
14625 fi 14852 fi
@@ -14627,35 +14854,165 @@ $as_echo "$as_me: WARNING: Could not find or use the Java package/jar jgoodies-l
14627 14854
14628 # Skin Look and Feel 14855 # Skin Look and Feel
14629 14856
14857
14858
14630 { $as_echo "$as_me:${as_lineno-$LINENO}: checking skinlf" >&5 14859 { $as_echo "$as_me:${as_lineno-$LINENO}: checking skinlf" >&5
14631$as_echo_n "checking skinlf... " >&6; } 14860$as_echo_n "checking skinlf... " >&6; }
14632 PACKAGE_JAR_FILE= 14861 PACKAGE_JAR_FILE=
14633 found_jar=no
14634 saved_ac_java_classpath=$ac_java_classpath
14635 DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null)"
14636 for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR; do
14637 for jar in "$jardir/skinlf.jar" "$jardir/libskinlf.jar" "$jardir/libskinlf-java.jar" "$jardir/skinlf*.jar"; do
14638
14639# TODO check the behaviour when spaces
14640 jars_resolved=`ls $jar 2>/dev/null`
14641 for jar_resolved in $jars_resolved; do # If several jars matches
14642 if test -e "$jar_resolved"; then
14643 export ac_java_classpath="$jar_resolved:$ac_java_classpath"
14644 14862
14645 cat << \EOF > conftest.java 14863 DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
14646// #line 14646 "configure"
14647import java.util.regex.Pattern;
14648 14864
14649import com.l2fprod.util.AccessUtils; 14865 jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'skinlf.jar' -or -name 'libskinlf.jar' -or -name 'libskinlf-java.jar' -or -name 'skinlf*.jar' \) -printf '%p:' 2>/dev/null)."
14650 14866
14651public class conftest { 14867 if test ! -f conftestSharedChecker.class ; then
14868
14869 cat << \EOF > conftestSharedChecker.java
14870// #line 14870 "configure"
14871import java.util.regex.Pattern;
14872import java.io.File;
14873import java.io.IOException;
14874import java.lang.reflect.Field;
14875import java.lang.reflect.InvocationTargetException;
14876import java.lang.reflect.Method;
14877import java.net.URL;
14878import java.net.URLClassLoader;
14879import java.util.ArrayList;
14880
14881public class conftestSharedChecker {
14882
14883 /**
14884 * Required arguments :
14885 * argv[0]: name of the jar package
14886 * argv[1]: name of the class (with the package prefix)
14887 * argv[2]: possible paths of the jar package (separated by ':')
14888 *
14889 * Optional arguments:
14890 * argv[3]: field or method used to retrieve the version
14891 * argv[4]: expected version
14892 * argv[5]: String comparator :
14893 * "=" for exact version
14894 */
14652 public static void main(String[] argv) { 14895 public static void main(String[] argv) {
14896 final String packageName = argv[0];
14897 final String className = argv[1];
14898 final String[] jarList = argv[2].split(":");
14653 14899
14900 ArrayList<URL> found = new ArrayList<>();
14901 for(String jar : jarList)
14902 {
14903 try {
14904 File f = new File(jar);
14905 if (f.exists()) {
14906 found.add(f.toURI().toURL());
14907 }
14908 } catch (IOException ex) {
14909 System.err.println(ex.toString());
14910 }
14911 }
14912
14913 URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()]));
14914 URL klassURL = null;
14915 Class<?> klass = null;
14916 try {
14917 String resourceName = className.replace(".", "/") + ".class";
14918 klassURL = localClassLoader.getResource(resourceName);
14919 klass = localClassLoader.loadClass(className);
14920 } catch (ClassNotFoundException ex) {
14921 System.err.println(className + " not found");
14922 System.exit(-1);
14923 }
14924
14925 String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!'));
14926 String path = pathURL.substring(pathURL.indexOf(':') + 1);
14927 System.err.println("found: " + path);
14928
14929 if (argv.length > 3) {
14930 checkVersion(klass, argv);
14931 }
14932
14933 System.out.println(path);
14934 }
14935
14936 private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException {
14937 final String versionMethod = argv[3];
14938 final String expected = argv[4];
14939 final String atLeastOrEqual;
14940 if (argv.length > 5)
14941 atLeastOrEqual = argv[5];
14942 else
14943 atLeastOrEqual = "<=";
14944
14945 try {
14946 try {
14947 Field field = klass.getField(versionMethod);
14948 Object value = field.get(null);
14949 compareAndDisplay(atLeastOrEqual, expected, value);
14950 } catch (NoSuchFieldException fe) {
14951 Method method = null;
14952 try {
14953 method = klass.getMethod(versionMethod);
14954 } catch (NoSuchMethodException ex) {
14955 System.err.println(ex.toString());
14956 System.exit(-3);
14957 }
14958
14959 try {
14960 Object value = method.invoke(null);
14961 compareAndDisplay(atLeastOrEqual, expected, value);
14962 } catch (NullPointerException ex) {
14963 Object value = method.invoke(klass.newInstance());
14964 compareAndDisplay(atLeastOrEqual, expected, value);
14965 }
14966 }
14967 } catch (IllegalAccessException ex) {
14968 System.err.println(ex);
14969 System.exit(-2);
14970 } catch (InvocationTargetException ex) {
14971 System.err.println(ex);
14972 System.exit(-2);
14973 } catch (InstantiationException ex) {
14974 System.err.println(ex);
14975 System.exit(-2);
14976 }
14977 }
14978
14979 private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) {
14980 int cmp = compare(expected, value.toString());
14981
14982 switch(atLeastOrEqual) {
14983 case ">":
14984 if (cmp > 0) {
14985 return;
14986 } else {
14987 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14988 System.exit(-4);
14989 }
14990 case "==":
14991 if (cmp == 0) {
14992 return;
14993 } else {
14994 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
14995 System.exit(-4);
14996 }
14997 case "<=":
14998 if (cmp <= 0) {
14999 return;
15000 } else {
15001 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
15002 System.exit(-4);
15003 }
15004 default:
15005 System.err.println("unable to compare with "+atLeastOrEqual);
15006 System.exit(-4);
15007 }
14654 } 15008 }
14655 15009
14656 private static int compare(String v1, String v2) { 15010 private static int compare(String v1, String v2) {
14657 String s1 = normalisedVersion(v1); 15011 String s1 = normalisedVersion(v1);
14658 String s2 = normalisedVersion(v2); 15012 String s2 = normalisedVersion(v2);
15013
15014 System.err.println("compare: " + v1 + " normalised to " + s1);
15015 System.err.println("compare: " + v2 + " normalised to " + s2);
14659 return s1.compareTo(s2); 15016 return s1.compareTo(s2);
14660 } 15017 }
14661 15018
@@ -14676,59 +15033,28 @@ EOF
14676 15033
14677 CLASSPATH=$ac_java_classpath 15034 CLASSPATH=$ac_java_classpath
14678 export CLASSPATH 15035 export CLASSPATH
14679 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 15036 cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java"
14680 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 15037 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then
14681 if test ""no"" = "no"; then 15038 echo "configure: conftestSharedChecker.class available" >&5
14682 echo "yes" >&5
14683
14684 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
14685$as_echo "$jar_resolved" >&6; }
14686 found_jar=yes
14687 PACKAGE_JAR_FILE=$jar_resolved
14688 break 3
14689
14690 else
14691 cmd="$JAVA conftest"
14692 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
14693 echo "yes" >&5
14694
14695 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
14696$as_echo "$jar_resolved" >&6; }
14697 found_jar=yes
14698 PACKAGE_JAR_FILE=$jar_resolved
14699 break 3
14700
14701 else
14702 echo "configure: failed program was:" >&5
14703 cat conftest.java >&5
14704 if test -s conftest.java.output; then
14705 STDOUT=`cat conftest.java.output`
14706 fi
14707 echo "configure: CLASSPATH was $CLASSPATH" >&5
14708
14709 ac_java_classpath=$saved_ac_java_classpath
14710
14711
14712 fi
14713 fi
14714 if test -f conftest.java.output; then
14715 rm conftest.java.output
14716 fi
14717 else 15039 else
14718 echo "configure: failed program was:" >&5 15040 echo "configure: failed program was:" >&5
14719 cat conftest.java >&5 15041 cat conftestSharedChecker.java >&5
14720 echo "configure: CLASSPATH was $CLASSPATH" >&5 15042 echo "configure: CLASSPATH was $CLASSPATH" >&5
15043 fi
14721 15044
14722 ac_java_classpath=$saved_ac_java_classpath 15045 fi
14723
14724
14725 fi
14726 15046
14727 fi 15047 CLASSPATH=$ac_java_classpath
14728 done 15048 export CLASSPATH
14729 done 15049 cmd="$JAVA conftestSharedChecker skinlf com.l2fprod.util.AccessUtils $jar_resolved "
14730 done 15050 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5); then
14731 if test "$found_jar" = "no"; then 15051 PACKAGE_JAR_FILE=$(tail -n 1 conftestSharedChecker.java.output);
15052 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PACKAGE_JAR_FILE" >&5
15053$as_echo "$PACKAGE_JAR_FILE" >&6; }
15054 echo "yes" >&5
15055 # append the found file to the classpath to manage jar dependency
15056 ac_java_classpath="$ac_java_classpath:$PACKAGE_JAR_FILE"
15057 else
14732 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 15058 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14733$as_echo "no" >&6; } 15059$as_echo "no" >&6; }
14734 if test "" = "yes"; then 15060 if test "" = "yes"; then
@@ -14738,41 +15064,174 @@ $as_echo "$as_me: WARNING: Could not find or use the Java package/jar skinlf use
14738 as_fn_error $? "Could not find or use the Java package/jar skinlf used by Scilab Gui - Skin Look and Feel (looking for package com.l2fprod.util.AccessUtils)" "$LINENO" 5 15064 as_fn_error $? "Could not find or use the Java package/jar skinlf used by Scilab Gui - Skin Look and Feel (looking for package com.l2fprod.util.AccessUtils)" "$LINENO" 5
14739 fi 15065 fi
14740 fi 15066 fi
15067 if test -f conftestSharedChecker.java.output; then
15068 rm conftestSharedChecker.java.output
15069 fi
14741 15070
14742 SKINLF=$PACKAGE_JAR_FILE 15071 SKINLF=$PACKAGE_JAR_FILE
14743 15072
14744 15073
14745 # JOGL 2 15074 # JOGL 2
14746 15075
15076
15077
14747 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jogl2" >&5 15078 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jogl2" >&5
14748$as_echo_n "checking jogl2... " >&6; } 15079$as_echo_n "checking jogl2... " >&6; }
14749 PACKAGE_JAR_FILE= 15080 PACKAGE_JAR_FILE=
14750 found_jar=no
14751 saved_ac_java_classpath=$ac_java_classpath
14752 DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null)"
14753 for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR; do
14754 for jar in "$jardir/jogl2.jar" "$jardir/libjogl2.jar" "$jardir/libjogl2-java.jar" "$jardir/jogl2*.jar"; do
14755
14756# TODO check the behaviour when spaces
14757 jars_resolved=`ls $jar 2>/dev/null`
14758 for jar_resolved in $jars_resolved; do # If several jars matches
14759 if test -e "$jar_resolved"; then
14760 export ac_java_classpath="$jar_resolved:$ac_java_classpath"
14761 15081
14762 cat << \EOF > conftest.java 15082 DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
14763// #line 14763 "configure"
14764import java.util.regex.Pattern;
14765 15083
14766import javax.media.opengl.glu.GLUnurbs; 15084 jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'jogl2.jar' -or -name 'libjogl2.jar' -or -name 'libjogl2-java.jar' -or -name 'jogl2*.jar' \) -printf '%p:' 2>/dev/null)."
14767 15085
14768public class conftest { 15086 if test ! -f conftestSharedChecker.class ; then
15087
15088 cat << \EOF > conftestSharedChecker.java
15089// #line 15089 "configure"
15090import java.util.regex.Pattern;
15091import java.io.File;
15092import java.io.IOException;
15093import java.lang.reflect.Field;
15094import java.lang.reflect.InvocationTargetException;
15095import java.lang.reflect.Method;
15096import java.net.URL;
15097import java.net.URLClassLoader;
15098import java.util.ArrayList;
15099
15100public class conftestSharedChecker {
15101
15102 /**
15103 * Required arguments :
15104 * argv[0]: name of the jar package
15105 * argv[1]: name of the class (with the package prefix)
15106 * argv[2]: possible paths of the jar package (separated by ':')
15107 *
15108 * Optional arguments:
15109 * argv[3]: field or method used to retrieve the version
15110 * argv[4]: expected version
15111 * argv[5]: String comparator :
15112 * "=" for exact version
15113 */
14769 public static void main(String[] argv) { 15114 public static void main(String[] argv) {
15115 final String packageName = argv[0];
15116 final String className = argv[1];
15117 final String[] jarList = argv[2].split(":");
15118
15119 ArrayList<URL> found = new ArrayList<>();
15120 for(String jar : jarList)
15121 {
15122 try {
15123 File f = new File(jar);
15124 if (f.exists()) {
15125 found.add(f.toURI().toURL());
15126 }
15127 } catch (IOException ex) {
15128 System.err.println(ex.toString());
15129 }
15130 }
15131
15132 URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()]));
15133 URL klassURL = null;
15134 Class<?> klass = null;
15135 try {
15136 String resourceName = className.replace(".", "/") + ".class";
15137 klassURL = localClassLoader.getResource(resourceName);
15138 klass = localClassLoader.loadClass(className);
15139 } catch (ClassNotFoundException ex) {
15140 System.err.println(className + " not found");
15141 System.exit(-1);
15142 }
15143
15144 String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!'));
15145 String path = pathURL.substring(pathURL.indexOf(':') + 1);
15146 System.err.println("found: " + path);
15147
15148 if (argv.length > 3) {
15149 checkVersion(klass, argv);
15150 }
14770 15151
15152 System.out.println(path);
15153 }
15154
15155 private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException {
15156 final String versionMethod = argv[3];
15157 final String expected = argv[4];
15158 final String atLeastOrEqual;
15159 if (argv.length > 5)
15160 atLeastOrEqual = argv[5];
15161 else
15162 atLeastOrEqual = "<=";
15163
15164 try {
15165 try {
15166 Field field = klass.getField(versionMethod);
15167 Object value = field.get(null);
15168 compareAndDisplay(atLeastOrEqual, expected, value);
15169 } catch (NoSuchFieldException fe) {
15170 Method method = null;
15171 try {
15172 method = klass.getMethod(versionMethod);
15173 } catch (NoSuchMethodException ex) {
15174 System.err.println(ex.toString());
15175 System.exit(-3);
15176 }
15177
15178 try {
15179 Object value = method.invoke(null);
15180 compareAndDisplay(atLeastOrEqual, expected, value);
15181 } catch (NullPointerException ex) {
15182 Object value = method.invoke(klass.newInstance());
15183 compareAndDisplay(atLeastOrEqual, expected, value);
15184 }
15185 }
15186 } catch (IllegalAccessException ex) {
15187 System.err.println(ex);
15188 System.exit(-2);
15189 } catch (InvocationTargetException ex) {
15190 System.err.println(ex);
15191 System.exit(-2);
15192 } catch (InstantiationException ex) {
15193 System.err.println(ex);
15194 System.exit(-2);
15195 }
15196 }
15197
15198 private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) {
15199 int cmp = compare(expected, value.toString());
15200
15201 switch(atLeastOrEqual) {
15202 case ">":
15203 if (cmp > 0) {
15204 return;
15205 } else {
15206 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
15207 System.exit(-4);
15208 }
15209 case "==":
15210 if (cmp == 0) {
15211 return;
15212 } else {
15213 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
15214 System.exit(-4);
15215 }
15216 case "<=":
15217 if (cmp <= 0) {
15218 return;
15219 } else {
15220 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
15221 System.exit(-4);
15222 }
15223 default:
15224 System.err.println("unable to compare with "+atLeastOrEqual);
15225 System.exit(-4);
15226 }
14771 } 15227 }
14772 15228
14773 private static int compare(String v1, String v2) { 15229 private static int compare(String v1, String v2) {
14774 String s1 = normalisedVersion(v1); 15230 String s1 = normalisedVersion(v1);
14775 String s2 = normalisedVersion(v2); 15231 String s2 = normalisedVersion(v2);
15232
15233 System.err.println("compare: " + v1 + " normalised to " + s1);
15234 System.err.println("compare: " + v2 + " normalised to " + s2);
14776 return s1.compareTo(s2); 15235 return s1.compareTo(s2);
14777 } 15236 }
14778 15237
@@ -14793,59 +15252,28 @@ EOF
14793 15252
14794 CLASSPATH=$ac_java_classpath 15253 CLASSPATH=$ac_java_classpath
14795 export CLASSPATH 15254 export CLASSPATH
14796 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 15255 cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java"
14797 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 15256 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then
14798 if test ""no"" = "no"; then 15257 echo "configure: conftestSharedChecker.class available" >&5
14799 echo "yes" >&5
14800
14801 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
14802$as_echo "$jar_resolved" >&6; }
14803 found_jar=yes
14804 PACKAGE_JAR_FILE=$jar_resolved
14805 break 3
14806
14807 else
14808 cmd="$JAVA conftest"
14809 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
14810 echo "yes" >&5
14811
14812 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
14813$as_echo "$jar_resolved" >&6; }
14814 found_jar=yes
14815 PACKAGE_JAR_FILE=$jar_resolved
14816 break 3
14817
14818 else
14819 echo "configure: failed program was:" >&5
14820 cat conftest.java >&5
14821 if test -s conftest.java.output; then
14822 STDOUT=`cat conftest.java.output`
14823 fi
14824 echo "configure: CLASSPATH was $CLASSPATH" >&5
14825
14826 ac_java_classpath=$saved_ac_java_classpath
14827
14828
14829 fi
14830 fi
14831 if test -f conftest.java.output; then
14832 rm conftest.java.output
14833 fi
14834 else 15258 else
14835 echo "configure: failed program was:" >&5 15259 echo "configure: failed program was:" >&5
14836 cat conftest.java >&5 15260 cat conftestSharedChecker.java >&5
14837 echo "configure: CLASSPATH was $CLASSPATH" >&5 15261 echo "configure: CLASSPATH was $CLASSPATH" >&5
15262 fi
14838 15263
14839 ac_java_classpath=$saved_ac_java_classpath 15264 fi
14840
14841
14842 fi
14843 15265
14844 fi 15266 CLASSPATH=$ac_java_classpath
14845 done 15267 export CLASSPATH
14846 done 15268 cmd="$JAVA conftestSharedChecker jogl2 javax.media.opengl.glu.GLUnurbs $jar_resolved "
14847 done 15269 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5); then
14848 if test "$found_jar" = "no"; then 15270 PACKAGE_JAR_FILE=$(tail -n 1 conftestSharedChecker.java.output);
15271 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PACKAGE_JAR_FILE" >&5
15272$as_echo "$PACKAGE_JAR_FILE" >&6; }
15273 echo "yes" >&5
15274 # append the found file to the classpath to manage jar dependency
15275 ac_java_classpath="$ac_java_classpath:$PACKAGE_JAR_FILE"
15276 else
14849 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 15277 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
14850$as_echo "no" >&6; } 15278$as_echo "no" >&6; }
14851 if test "" = "yes"; then 15279 if test "" = "yes"; then
@@ -14855,6 +15283,9 @@ $as_echo "$as_me: WARNING: Could not find or use the Java package/jar jogl2 used
14855 as_fn_error $? "Could not find or use the Java package/jar jogl2 used by Scilab 3D rendering - Version 2.0 (looking for package javax.media.opengl.glu.GLUnurbs)" "$LINENO" 5 15283 as_fn_error $? "Could not find or use the Java package/jar jogl2 used by Scilab 3D rendering - Version 2.0 (looking for package javax.media.opengl.glu.GLUnurbs)" "$LINENO" 5
14856 fi 15284 fi
14857 fi 15285 fi
15286 if test -f conftestSharedChecker.java.output; then
15287 rm conftestSharedChecker.java.output
15288 fi
14858 15289
14859 JOGL2=$PACKAGE_JAR_FILE 15290 JOGL2=$PACKAGE_JAR_FILE
14860 15291
@@ -14866,7 +15297,7 @@ $as_echo_n "checking minimal version (Specification-Version 2.2) of jogl2... " >
14866 if test "x" == "x"; then 15297 if test "x" == "x"; then
14867 15298
14868 cat << \EOF > conftest.java 15299 cat << \EOF > conftest.java
14869// #line 14869 "configure" 15300// #line 15300 "configure"
14870import java.util.regex.Pattern; 15301import java.util.regex.Pattern;
14871 15302
14872import java.io.IOException; 15303import java.io.IOException;
@@ -14943,7 +15374,7 @@ EOF
14943 else 15374 else
14944 15375
14945 cat << \EOF > conftest.java 15376 cat << \EOF > conftest.java
14946// #line 14946 "configure" 15377// #line 15377 "configure"
14947import java.util.regex.Pattern; 15378import java.util.regex.Pattern;
14948 15379
14949import java.io.IOException; 15380import java.io.IOException;
@@ -15129,35 +15560,165 @@ fi
15129 15560
15130 # JoGL Native <=> Java connector 15561 # JoGL Native <=> Java connector
15131 15562
15563
15564
15132 { $as_echo "$as_me:${as_lineno-$LINENO}: checking gluegen2-rt" >&5 15565 { $as_echo "$as_me:${as_lineno-$LINENO}: checking gluegen2-rt" >&5
15133$as_echo_n "checking gluegen2-rt... " >&6; } 15566$as_echo_n "checking gluegen2-rt... " >&6; }
15134 PACKAGE_JAR_FILE= 15567 PACKAGE_JAR_FILE=
15135 found_jar=no
15136 saved_ac_java_classpath=$ac_java_classpath
15137 DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null)"
15138 for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR; do
15139 for jar in "$jardir/gluegen2-rt.jar" "$jardir/libgluegen2-rt.jar" "$jardir/libgluegen2-rt-java.jar" "$jardir/gluegen2-rt*.jar"; do
15140
15141# TODO check the behaviour when spaces
15142 jars_resolved=`ls $jar 2>/dev/null`
15143 for jar_resolved in $jars_resolved; do # If several jars matches
15144 if test -e "$jar_resolved"; then
15145 export ac_java_classpath="$jar_resolved:$ac_java_classpath"
15146 15568
15147 cat << \EOF > conftest.java 15569 DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
15148// #line 15148 "configure"
15149import java.util.regex.Pattern;
15150 15570
15151import jogamp.common.os.MachineDescriptionRuntime; 15571 jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'gluegen2-rt.jar' -or -name 'libgluegen2-rt.jar' -or -name 'libgluegen2-rt-java.jar' -or -name 'gluegen2-rt*.jar' \) -printf '%p:' 2>/dev/null)."
15152 15572
15153public class conftest { 15573 if test ! -f conftestSharedChecker.class ; then
15574
15575 cat << \EOF > conftestSharedChecker.java
15576// #line 15576 "configure"
15577import java.util.regex.Pattern;
15578import java.io.File;
15579import java.io.IOException;
15580import java.lang.reflect.Field;
15581import java.lang.reflect.InvocationTargetException;
15582import java.lang.reflect.Method;
15583import java.net.URL;
15584import java.net.URLClassLoader;
15585import java.util.ArrayList;
15586
15587public class conftestSharedChecker {
15588
15589 /**
15590 * Required arguments :
15591 * argv[0]: name of the jar package
15592 * argv[1]: name of the class (with the package prefix)
15593 * argv[2]: possible paths of the jar package (separated by ':')
15594 *
15595 * Optional arguments:
15596 * argv[3]: field or method used to retrieve the version
15597 * argv[4]: expected version
15598 * argv[5]: String comparator :
15599 * "=" for exact version
15600 */
15154 public static void main(String[] argv) { 15601 public static void main(String[] argv) {
15602 final String packageName = argv[0];
15603 final String className = argv[1];
15604 final String[] jarList = argv[2].split(":");
15605
15606 ArrayList<URL> found = new ArrayList<>();
15607 for(String jar : jarList)
15608 {
15609 try {
15610 File f = new File(jar);
15611 if (f.exists()) {
15612 found.add(f.toURI().toURL());
15613 }
15614 } catch (IOException ex) {
15615 System.err.println(ex.toString());
15616 }
15617 }
15618
15619 URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()]));
15620 URL klassURL = null;
15621 Class<?> klass = null;
15622 try {
15623 String resourceName = className.replace(".", "/") + ".class";
15624 klassURL = localClassLoader.getResource(resourceName);
15625 klass = localClassLoader.loadClass(className);
15626 } catch (ClassNotFoundException ex) {
15627 System.err.println(className + " not found");
15628 System.exit(-1);
15629 }
15155 15630
15631 String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!'));
15632 String path = pathURL.substring(pathURL.indexOf(':') + 1);
15633 System.err.println("found: " + path);
15634
15635 if (argv.length > 3) {
15636 checkVersion(klass, argv);
15637 }
15638
15639 System.out.println(path);
15640 }
15641
15642 private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException {
15643 final String versionMethod = argv[3];
15644 final String expected = argv[4];
15645 final String atLeastOrEqual;
15646 if (argv.length > 5)
15647 atLeastOrEqual = argv[5];
15648 else
15649 atLeastOrEqual = "<=";
15650
15651 try {
15652 try {
15653 Field field = klass.getField(versionMethod);
15654 Object value = field.get(null);
15655 compareAndDisplay(atLeastOrEqual, expected, value);
15656 } catch (NoSuchFieldException fe) {
15657 Method method = null;
15658 try {
15659 method = klass.getMethod(versionMethod);
15660 } catch (NoSuchMethodException ex) {
15661 System.err.println(ex.toString());
15662 System.exit(-3);
15663 }
15664
15665 try {
15666 Object value = method.invoke(null);
15667 compareAndDisplay(atLeastOrEqual, expected, value);
15668 } catch (NullPointerException ex) {
15669 Object value = method.invoke(klass.newInstance());
15670 compareAndDisplay(atLeastOrEqual, expected, value);
15671 }
15672 }
15673 } catch (IllegalAccessException ex) {
15674 System.err.println(ex);
15675 System.exit(-2);
15676 } catch (InvocationTargetException ex) {
15677 System.err.println(ex);
15678 System.exit(-2);
15679 } catch (InstantiationException ex) {
15680 System.err.println(ex);
15681 System.exit(-2);
15682 }
15683 }
15684
15685 private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) {
15686 int cmp = compare(expected, value.toString());
15687
15688 switch(atLeastOrEqual) {
15689 case ">":
15690 if (cmp > 0) {
15691 return;
15692 } else {
15693 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
15694 System.exit(-4);
15695 }
15696 case "==":
15697 if (cmp == 0) {
15698 return;
15699 } else {
15700 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
15701 System.exit(-4);
15702 }
15703 case "<=":
15704 if (cmp <= 0) {
15705 return;
15706 } else {
15707 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
15708 System.exit(-4);
15709 }
15710 default:
15711 System.err.println("unable to compare with "+atLeastOrEqual);
15712 System.exit(-4);
15713 }
15156 } 15714 }
15157 15715
15158 private static int compare(String v1, String v2) { 15716 private static int compare(String v1, String v2) {
15159 String s1 = normalisedVersion(v1); 15717 String s1 = normalisedVersion(v1);
15160 String s2 = normalisedVersion(v2); 15718 String s2 = normalisedVersion(v2);
15719
15720 System.err.println("compare: " + v1 + " normalised to " + s1);
15721 System.err.println("compare: " + v2 + " normalised to " + s2);
15161 return s1.compareTo(s2); 15722 return s1.compareTo(s2);
15162 } 15723 }
15163 15724
@@ -15178,59 +15739,28 @@ EOF
15178 15739
15179 CLASSPATH=$ac_java_classpath 15740 CLASSPATH=$ac_java_classpath
15180 export CLASSPATH 15741 export CLASSPATH
15181 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 15742 cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java"
15182 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 15743 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then
15183 if test ""no"" = "no"; then 15744 echo "configure: conftestSharedChecker.class available" >&5
15184 echo "yes" >&5
15185
15186 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
15187$as_echo "$jar_resolved" >&6; }
15188 found_jar=yes
15189 PACKAGE_JAR_FILE=$jar_resolved
15190 break 3
15191
15192 else
15193 cmd="$JAVA conftest"
15194 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
15195 echo "yes" >&5
15196
15197 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
15198$as_echo "$jar_resolved" >&6; }
15199 found_jar=yes
15200 PACKAGE_JAR_FILE=$jar_resolved
15201 break 3
15202
15203 else
15204 echo "configure: failed program was:" >&5
15205 cat conftest.java >&5
15206 if test -s conftest.java.output; then
15207 STDOUT=`cat conftest.java.output`
15208 fi
15209 echo "configure: CLASSPATH was $CLASSPATH" >&5
15210
15211 ac_java_classpath=$saved_ac_java_classpath
15212
15213
15214 fi
15215 fi
15216 if test -f conftest.java.output; then
15217 rm conftest.java.output
15218 fi
15219 else 15745 else
15220 echo "configure: failed program was:" >&5 15746 echo "configure: failed program was:" >&5
15221 cat conftest.java >&5 15747 cat conftestSharedChecker.java >&5
15222 echo "configure: CLASSPATH was $CLASSPATH" >&5 15748 echo "configure: CLASSPATH was $CLASSPATH" >&5
15749 fi
15223 15750
15224 ac_java_classpath=$saved_ac_java_classpath 15751 fi
15225
15226
15227 fi
15228 15752
15229 fi 15753 CLASSPATH=$ac_java_classpath
15230 done 15754 export CLASSPATH
15231 done 15755 cmd="$JAVA conftestSharedChecker gluegen2-rt jogamp.common.os.MachineDescriptionRuntime $jar_resolved "
15232 done 15756 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5); then
15233 if test "$found_jar" = "no"; then 15757 PACKAGE_JAR_FILE=$(tail -n 1 conftestSharedChecker.java.output);
15758 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PACKAGE_JAR_FILE" >&5
15759$as_echo "$PACKAGE_JAR_FILE" >&6; }
15760 echo "yes" >&5
15761 # append the found file to the classpath to manage jar dependency
15762 ac_java_classpath="$ac_java_classpath:$PACKAGE_JAR_FILE"
15763 else
15234 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 15764 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15235$as_echo "no" >&6; } 15765$as_echo "no" >&6; }
15236 if test "" = "yes"; then 15766 if test "" = "yes"; then
@@ -15240,6 +15770,9 @@ $as_echo "$as_me: WARNING: Could not find or use the Java package/jar gluegen2-r
15240 as_fn_error $? "Could not find or use the Java package/jar gluegen2-rt used by Scilab 3D rendering (looking for package jogamp.common.os.MachineDescriptionRuntime)" "$LINENO" 5 15770 as_fn_error $? "Could not find or use the Java package/jar gluegen2-rt used by Scilab 3D rendering (looking for package jogamp.common.os.MachineDescriptionRuntime)" "$LINENO" 5
15241 fi 15771 fi
15242 fi 15772 fi
15773 if test -f conftestSharedChecker.java.output; then
15774 rm conftestSharedChecker.java.output
15775 fi
15243 15776
15244 GLUEGEN2_RT=$PACKAGE_JAR_FILE 15777 GLUEGEN2_RT=$PACKAGE_JAR_FILE
15245 15778
@@ -15303,35 +15836,165 @@ fi
15303 15836
15304 # Jhall 15837 # Jhall
15305 15838
15839
15840
15306 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jhall" >&5 15841 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jhall" >&5
15307$as_echo_n "checking jhall... " >&6; } 15842$as_echo_n "checking jhall... " >&6; }
15308 PACKAGE_JAR_FILE= 15843 PACKAGE_JAR_FILE=
15309 found_jar=no
15310 saved_ac_java_classpath=$ac_java_classpath
15311 DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null)"
15312 for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR; do
15313 for jar in "$jardir/jhall.jar" "$jardir/libjhall.jar" "$jardir/libjhall-java.jar" "$jardir/jhall*.jar"; do
15314
15315# TODO check the behaviour when spaces
15316 jars_resolved=`ls $jar 2>/dev/null`
15317 for jar_resolved in $jars_resolved; do # If several jars matches
15318 if test -e "$jar_resolved"; then
15319 export ac_java_classpath="$jar_resolved:$ac_java_classpath"
15320 15844
15321 cat << \EOF > conftest.java 15845 DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
15322// #line 15322 "configure"
15323import java.util.regex.Pattern;
15324 15846
15325import javax.help.JHelp; 15847 jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'jhall.jar' -or -name 'libjhall.jar' -or -name 'libjhall-java.jar' -or -name 'jhall*.jar' \) -printf '%p:' 2>/dev/null)."
15326 15848
15327public class conftest { 15849 if test ! -f conftestSharedChecker.class ; then
15850
15851 cat << \EOF > conftestSharedChecker.java
15852// #line 15852 "configure"
15853import java.util.regex.Pattern;
15854import java.io.File;
15855import java.io.IOException;
15856import java.lang.reflect.Field;
15857import java.lang.reflect.InvocationTargetException;
15858import java.lang.reflect.Method;
15859import java.net.URL;
15860import java.net.URLClassLoader;
15861import java.util.ArrayList;
15862
15863public class conftestSharedChecker {
15864
15865 /**
15866 * Required arguments :
15867 * argv[0]: name of the jar package
15868 * argv[1]: name of the class (with the package prefix)
15869 * argv[2]: possible paths of the jar package (separated by ':')
15870 *
15871 * Optional arguments:
15872 * argv[3]: field or method used to retrieve the version
15873 * argv[4]: expected version
15874 * argv[5]: String comparator :
15875 * "=" for exact version
15876 */
15328 public static void main(String[] argv) { 15877 public static void main(String[] argv) {
15878 final String packageName = argv[0];
15879 final String className = argv[1];
15880 final String[] jarList = argv[2].split(":");
15329 15881
15882 ArrayList<URL> found = new ArrayList<>();
15883 for(String jar : jarList)
15884 {
15885 try {
15886 File f = new File(jar);
15887 if (f.exists()) {
15888 found.add(f.toURI().toURL());
15889 }
15890 } catch (IOException ex) {
15891 System.err.println(ex.toString());
15892 }
15893 }
15894
15895 URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()]));
15896 URL klassURL = null;
15897 Class<?> klass = null;
15898 try {
15899 String resourceName = className.replace(".", "/") + ".class";
15900 klassURL = localClassLoader.getResource(resourceName);
15901 klass = localClassLoader.loadClass(className);
15902 } catch (ClassNotFoundException ex) {
15903 System.err.println(className + " not found");
15904 System.exit(-1);
15905 }
15906
15907 String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!'));
15908 String path = pathURL.substring(pathURL.indexOf(':') + 1);
15909 System.err.println("found: " + path);
15910
15911 if (argv.length > 3) {
15912 checkVersion(klass, argv);
15913 }
15914
15915 System.out.println(path);
15916 }
15917
15918 private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException {
15919 final String versionMethod = argv[3];
15920 final String expected = argv[4];
15921 final String atLeastOrEqual;
15922 if (argv.length > 5)
15923 atLeastOrEqual = argv[5];
15924 else
15925 atLeastOrEqual = "<=";
15926
15927 try {
15928 try {
15929 Field field = klass.getField(versionMethod);
15930 Object value = field.get(null);
15931 compareAndDisplay(atLeastOrEqual, expected, value);
15932 } catch (NoSuchFieldException fe) {
15933 Method method = null;
15934 try {
15935 method = klass.getMethod(versionMethod);
15936 } catch (NoSuchMethodException ex) {
15937 System.err.println(ex.toString());
15938 System.exit(-3);
15939 }
15940
15941 try {
15942 Object value = method.invoke(null);
15943 compareAndDisplay(atLeastOrEqual, expected, value);
15944 } catch (NullPointerException ex) {
15945 Object value = method.invoke(klass.newInstance());
15946 compareAndDisplay(atLeastOrEqual, expected, value);
15947 }
15948 }
15949 } catch (IllegalAccessException ex) {
15950 System.err.println(ex);
15951 System.exit(-2);
15952 } catch (InvocationTargetException ex) {
15953 System.err.println(ex);
15954 System.exit(-2);
15955 } catch (InstantiationException ex) {
15956 System.err.println(ex);
15957 System.exit(-2);
15958 }
15959 }
15960
15961 private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) {
15962 int cmp = compare(expected, value.toString());
15963
15964 switch(atLeastOrEqual) {
15965 case ">":
15966 if (cmp > 0) {
15967 return;
15968 } else {
15969 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
15970 System.exit(-4);
15971 }
15972 case "==":
15973 if (cmp == 0) {
15974 return;
15975 } else {
15976 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
15977 System.exit(-4);
15978 }
15979 case "<=":
15980 if (cmp <= 0) {
15981 return;
15982 } else {
15983 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
15984 System.exit(-4);
15985 }
15986 default:
15987 System.err.println("unable to compare with "+atLeastOrEqual);
15988 System.exit(-4);
15989 }
15330 } 15990 }
15331 15991
15332 private static int compare(String v1, String v2) { 15992 private static int compare(String v1, String v2) {
15333 String s1 = normalisedVersion(v1); 15993 String s1 = normalisedVersion(v1);
15334 String s2 = normalisedVersion(v2); 15994 String s2 = normalisedVersion(v2);
15995
15996 System.err.println("compare: " + v1 + " normalised to " + s1);
15997 System.err.println("compare: " + v2 + " normalised to " + s2);
15335 return s1.compareTo(s2); 15998 return s1.compareTo(s2);
15336 } 15999 }
15337 16000
@@ -15352,59 +16015,28 @@ EOF
15352 16015
15353 CLASSPATH=$ac_java_classpath 16016 CLASSPATH=$ac_java_classpath
15354 export CLASSPATH 16017 export CLASSPATH
15355 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 16018 cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java"
15356 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 16019 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then
15357 if test ""no"" = "no"; then 16020 echo "configure: conftestSharedChecker.class available" >&5
15358 echo "yes" >&5
15359
15360 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
15361$as_echo "$jar_resolved" >&6; }
15362 found_jar=yes
15363 PACKAGE_JAR_FILE=$jar_resolved
15364 break 3
15365
15366 else
15367 cmd="$JAVA conftest"
15368 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
15369 echo "yes" >&5
15370
15371 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
15372$as_echo "$jar_resolved" >&6; }
15373 found_jar=yes
15374 PACKAGE_JAR_FILE=$jar_resolved
15375 break 3
15376
15377 else
15378 echo "configure: failed program was:" >&5
15379 cat conftest.java >&5
15380 if test -s conftest.java.output; then
15381 STDOUT=`cat conftest.java.output`
15382 fi
15383 echo "configure: CLASSPATH was $CLASSPATH" >&5
15384
15385 ac_java_classpath=$saved_ac_java_classpath
15386
15387
15388 fi
15389 fi
15390 if test -f conftest.java.output; then
15391 rm conftest.java.output
15392 fi
15393 else 16021 else
15394 echo "configure: failed program was:" >&5 16022 echo "configure: failed program was:" >&5
15395 cat conftest.java >&5 16023 cat conftestSharedChecker.java >&5
15396 echo "configure: CLASSPATH was $CLASSPATH" >&5 16024 echo "configure: CLASSPATH was $CLASSPATH" >&5
16025 fi
15397 16026
15398 ac_java_classpath=$saved_ac_java_classpath 16027 fi
15399
15400
15401 fi
15402 16028
15403 fi 16029 CLASSPATH=$ac_java_classpath
15404 done 16030 export CLASSPATH
15405 done 16031 cmd="$JAVA conftestSharedChecker jhall javax.help.JHelp $jar_resolved "
15406 done 16032 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5); then
15407 if test "$found_jar" = "no"; then 16033 PACKAGE_JAR_FILE=$(tail -n 1 conftestSharedChecker.java.output);
16034 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PACKAGE_JAR_FILE" >&5
16035$as_echo "$PACKAGE_JAR_FILE" >&6; }
16036 echo "yes" >&5
16037 # append the found file to the classpath to manage jar dependency
16038 ac_java_classpath="$ac_java_classpath:$PACKAGE_JAR_FILE"
16039 else
15408 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 16040 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15409$as_echo "no" >&6; } 16041$as_echo "no" >&6; }
15410 if test ""yes"" = "yes"; then 16042 if test ""yes"" = "yes"; then
@@ -15414,39 +16046,172 @@ $as_echo "$as_me: WARNING: Could not find or use the Java package/jar jhall used
15414 as_fn_error $? "Could not find or use the Java package/jar jhall used by Scilab Help Browser (looking for package javax.help.JHelp)" "$LINENO" 5 16046 as_fn_error $? "Could not find or use the Java package/jar jhall used by Scilab Help Browser (looking for package javax.help.JHelp)" "$LINENO" 5
15415 fi 16047 fi
15416 fi 16048 fi
16049 if test -f conftestSharedChecker.java.output; then
16050 rm conftestSharedChecker.java.output
16051 fi
15417 16052
15418 # Named differently under Mandriva or Fedora 16053 # Named differently under Mandriva or Fedora
15419 if test -z "$PACKAGE_JAR_FILE"; then 16054 if test -z "$PACKAGE_JAR_FILE"; then
15420 16055
16056
16057
15421 { $as_echo "$as_me:${as_lineno-$LINENO}: checking javahelp2" >&5 16058 { $as_echo "$as_me:${as_lineno-$LINENO}: checking javahelp2" >&5
15422$as_echo_n "checking javahelp2... " >&6; } 16059$as_echo_n "checking javahelp2... " >&6; }
15423 PACKAGE_JAR_FILE= 16060 PACKAGE_JAR_FILE=
15424 found_jar=no
15425 saved_ac_java_classpath=$ac_java_classpath
15426 DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null)"
15427 for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR; do
15428 for jar in "$jardir/javahelp2.jar" "$jardir/libjavahelp2.jar" "$jardir/libjavahelp2-java.jar" "$jardir/javahelp2*.jar"; do
15429
15430# TODO check the behaviour when spaces
15431 jars_resolved=`ls $jar 2>/dev/null`
15432 for jar_resolved in $jars_resolved; do # If several jars matches
15433 if test -e "$jar_resolved"; then
15434 export ac_java_classpath="$jar_resolved:$ac_java_classpath"
15435 16061
15436 cat << \EOF > conftest.java 16062 DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
15437// #line 15437 "configure"
15438import java.util.regex.Pattern;
15439 16063
15440import javax.help.JHelp; 16064 jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'javahelp2.jar' -or -name 'libjavahelp2.jar' -or -name 'libjavahelp2-java.jar' -or -name 'javahelp2*.jar' \) -printf '%p:' 2>/dev/null)."
15441 16065
15442public class conftest { 16066 if test ! -f conftestSharedChecker.class ; then
16067
16068 cat << \EOF > conftestSharedChecker.java
16069// #line 16069 "configure"
16070import java.util.regex.Pattern;
16071import java.io.File;
16072import java.io.IOException;
16073import java.lang.reflect.Field;
16074import java.lang.reflect.InvocationTargetException;
16075import java.lang.reflect.Method;
16076import java.net.URL;
16077import java.net.URLClassLoader;
16078import java.util.ArrayList;
16079
16080public class conftestSharedChecker {
16081
16082 /**
16083 * Required arguments :
16084 * argv[0]: name of the jar package
16085 * argv[1]: name of the class (with the package prefix)
16086 * argv[2]: possible paths of the jar package (separated by ':')
16087 *
16088 * Optional arguments:
16089 * argv[3]: field or method used to retrieve the version
16090 * argv[4]: expected version
16091 * argv[5]: String comparator :
16092 * "=" for exact version
16093 */
15443 public static void main(String[] argv) { 16094 public static void main(String[] argv) {
16095 final String packageName = argv[0];
16096 final String className = argv[1];
16097 final String[] jarList = argv[2].split(":");
16098
16099 ArrayList<URL> found = new ArrayList<>();
16100 for(String jar : jarList)
16101 {
16102 try {
16103 File f = new File(jar);
16104 if (f.exists()) {
16105 found.add(f.toURI().toURL());
16106 }
16107 } catch (IOException ex) {
16108 System.err.println(ex.toString());
16109 }
16110 }
16111
16112 URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()]));
16113 URL klassURL = null;
16114 Class<?> klass = null;
16115 try {
16116 String resourceName = className.replace(".", "/") + ".class";
16117 klassURL = localClassLoader.getResource(resourceName);
16118 klass = localClassLoader.loadClass(className);
16119 } catch (ClassNotFoundException ex) {
16120 System.err.println(className + " not found");
16121 System.exit(-1);
16122 }
15444 16123
16124 String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!'));
16125 String path = pathURL.substring(pathURL.indexOf(':') + 1);
16126 System.err.println("found: " + path);
16127
16128 if (argv.length > 3) {
16129 checkVersion(klass, argv);
16130 }
16131
16132 System.out.println(path);
16133 }
16134
16135 private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException {
16136 final String versionMethod = argv[3];
16137 final String expected = argv[4];
16138 final String atLeastOrEqual;
16139 if (argv.length > 5)
16140 atLeastOrEqual = argv[5];
16141 else
16142 atLeastOrEqual = "<=";
16143
16144 try {
16145 try {
16146 Field field = klass.getField(versionMethod);
16147 Object value = field.get(null);
16148 compareAndDisplay(atLeastOrEqual, expected, value);
16149 } catch (NoSuchFieldException fe) {
16150 Method method = null;
16151 try {
16152 method = klass.getMethod(versionMethod);
16153 } catch (NoSuchMethodException ex) {
16154 System.err.println(ex.toString());
16155 System.exit(-3);
16156 }
16157
16158 try {
16159 Object value = method.invoke(null);
16160 compareAndDisplay(atLeastOrEqual, expected, value);
16161 } catch (NullPointerException ex) {
16162 Object value = method.invoke(klass.newInstance());
16163 compareAndDisplay(atLeastOrEqual, expected, value);
16164 }
16165 }
16166 } catch (IllegalAccessException ex) {
16167 System.err.println(ex);
16168 System.exit(-2);
16169 } catch (InvocationTargetException ex) {
16170 System.err.println(ex);
16171 System.exit(-2);
16172 } catch (InstantiationException ex) {
16173 System.err.println(ex);
16174 System.exit(-2);
16175 }
16176 }
16177
16178 private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) {
16179 int cmp = compare(expected, value.toString());
16180
16181 switch(atLeastOrEqual) {
16182 case ">":
16183 if (cmp > 0) {
16184 return;
16185 } else {
16186 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
16187 System.exit(-4);
16188 }
16189 case "==":
16190 if (cmp == 0) {
16191 return;
16192 } else {
16193 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
16194 System.exit(-4);
16195 }
16196 case "<=":
16197 if (cmp <= 0) {
16198 return;
16199 } else {
16200 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
16201 System.exit(-4);
16202 }
16203 default:
16204 System.err.println("unable to compare with "+atLeastOrEqual);
16205 System.exit(-4);
16206 }
15445 } 16207 }
15446 16208
15447 private static int compare(String v1, String v2) { 16209 private static int compare(String v1, String v2) {
15448 String s1 = normalisedVersion(v1); 16210 String s1 = normalisedVersion(v1);
15449 String s2 = normalisedVersion(v2); 16211 String s2 = normalisedVersion(v2);
16212
16213 System.err.println("compare: " + v1 + " normalised to " + s1);
16214 System.err.println("compare: " + v2 + " normalised to " + s2);
15450 return s1.compareTo(s2); 16215 return s1.compareTo(s2);
15451 } 16216 }
15452 16217
@@ -15467,59 +16232,28 @@ EOF
15467 16232
15468 CLASSPATH=$ac_java_classpath 16233 CLASSPATH=$ac_java_classpath
15469 export CLASSPATH 16234 export CLASSPATH
15470 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 16235 cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java"
15471 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 16236 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then
15472 if test ""no"" = "no"; then 16237 echo "configure: conftestSharedChecker.class available" >&5
15473 echo "yes" >&5
15474
15475 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
15476$as_echo "$jar_resolved" >&6; }
15477 found_jar=yes
15478 PACKAGE_JAR_FILE=$jar_resolved
15479 break 3
15480
15481 else
15482 cmd="$JAVA conftest"
15483 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
15484 echo "yes" >&5
15485
15486 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
15487$as_echo "$jar_resolved" >&6; }
15488 found_jar=yes
15489 PACKAGE_JAR_FILE=$jar_resolved
15490 break 3
15491
15492 else
15493 echo "configure: failed program was:" >&5
15494 cat conftest.java >&5
15495 if test -s conftest.java.output; then
15496 STDOUT=`cat conftest.java.output`
15497 fi
15498 echo "configure: CLASSPATH was $CLASSPATH" >&5
15499
15500 ac_java_classpath=$saved_ac_java_classpath
15501
15502
15503 fi
15504 fi
15505 if test -f conftest.java.output; then
15506 rm conftest.java.output
15507 fi
15508 else 16238 else
15509 echo "configure: failed program was:" >&5 16239 echo "configure: failed program was:" >&5
15510 cat conftest.java >&5 16240 cat conftestSharedChecker.java >&5
15511 echo "configure: CLASSPATH was $CLASSPATH" >&5 16241 echo "configure: CLASSPATH was $CLASSPATH" >&5
16242 fi
15512 16243
15513 ac_java_classpath=$saved_ac_java_classpath 16244 fi
15514
15515
15516 fi
15517 16245
15518 fi 16246 CLASSPATH=$ac_java_classpath
15519 done 16247 export CLASSPATH
15520 done 16248 cmd="$JAVA conftestSharedChecker javahelp2 javax.help.JHelp $jar_resolved "
15521 done 16249 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5); then
15522 if test "$found_jar" = "no"; then 16250 PACKAGE_JAR_FILE=$(tail -n 1 conftestSharedChecker.java.output);
16251 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PACKAGE_JAR_FILE" >&5
16252$as_echo "$PACKAGE_JAR_FILE" >&6; }
16253 echo "yes" >&5
16254 # append the found file to the classpath to manage jar dependency
16255 ac_java_classpath="$ac_java_classpath:$PACKAGE_JAR_FILE"
16256 else
15523 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 16257 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15524$as_echo "no" >&6; } 16258$as_echo "no" >&6; }
15525 if test "" = "yes"; then 16259 if test "" = "yes"; then
@@ -15529,6 +16263,9 @@ $as_echo "$as_me: WARNING: Could not find or use the Java package/jar javahelp2
15529 as_fn_error $? "Could not find or use the Java package/jar javahelp2 used by Scilab Help Browser (looking for package javax.help.JHelp)" "$LINENO" 5 16263 as_fn_error $? "Could not find or use the Java package/jar javahelp2 used by Scilab Help Browser (looking for package javax.help.JHelp)" "$LINENO" 5
15530 fi 16264 fi
15531 fi 16265 fi
16266 if test -f conftestSharedChecker.java.output; then
16267 rm conftestSharedChecker.java.output
16268 fi
15532 16269
15533 fi 16270 fi
15534 JHALL=$PACKAGE_JAR_FILE 16271 JHALL=$PACKAGE_JAR_FILE
@@ -15536,35 +16273,165 @@ $as_echo "$as_me: WARNING: Could not find or use the Java package/jar javahelp2
15536 16273
15537 # Console API 16274 # Console API
15538 16275
16276
16277
15539 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jrosetta-API" >&5 16278 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jrosetta-API" >&5
15540$as_echo_n "checking jrosetta-API... " >&6; } 16279$as_echo_n "checking jrosetta-API... " >&6; }
15541 PACKAGE_JAR_FILE= 16280 PACKAGE_JAR_FILE=
15542 found_jar=no
15543 saved_ac_java_classpath=$ac_java_classpath
15544 DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null)"
15545 for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR; do
15546 for jar in "$jardir/jrosetta-API.jar" "$jardir/libjrosetta-API.jar" "$jardir/libjrosetta-API-java.jar" "$jardir/jrosetta-API*.jar"; do
15547
15548# TODO check the behaviour when spaces
15549 jars_resolved=`ls $jar 2>/dev/null`
15550 for jar_resolved in $jars_resolved; do # If several jars matches
15551 if test -e "$jar_resolved"; then
15552 export ac_java_classpath="$jar_resolved:$ac_java_classpath"
15553 16281
15554 cat << \EOF > conftest.java 16282 DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
15555// #line 15555 "configure"
15556import java.util.regex.Pattern;
15557 16283
15558import com.artenum.rosetta.interfaces.core.ConsoleConfiguration; 16284 jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'jrosetta-API.jar' -or -name 'libjrosetta-API.jar' -or -name 'libjrosetta-API-java.jar' -or -name 'jrosetta-API*.jar' \) -printf '%p:' 2>/dev/null)."
15559 16285
15560public class conftest { 16286 if test ! -f conftestSharedChecker.class ; then
16287
16288 cat << \EOF > conftestSharedChecker.java
16289// #line 16289 "configure"
16290import java.util.regex.Pattern;
16291import java.io.File;
16292import java.io.IOException;
16293import java.lang.reflect.Field;
16294import java.lang.reflect.InvocationTargetException;
16295import java.lang.reflect.Method;
16296import java.net.URL;
16297import java.net.URLClassLoader;
16298import java.util.ArrayList;
16299
16300public class conftestSharedChecker {
16301
16302 /**
16303 * Required arguments :
16304 * argv[0]: name of the jar package
16305 * argv[1]: name of the class (with the package prefix)
16306 * argv[2]: possible paths of the jar package (separated by ':')
16307 *
16308 * Optional arguments:
16309 * argv[3]: field or method used to retrieve the version
16310 * argv[4]: expected version
16311 * argv[5]: String comparator :
16312 * "=" for exact version
16313 */
15561 public static void main(String[] argv) { 16314 public static void main(String[] argv) {
16315 final String packageName = argv[0];
16316 final String className = argv[1];
16317 final String[] jarList = argv[2].split(":");
16318
16319 ArrayList<URL> found = new ArrayList<>();
16320 for(String jar : jarList)
16321 {
16322 try {
16323 File f = new File(jar);
16324 if (f.exists()) {
16325 found.add(f.toURI().toURL());
16326 }
16327 } catch (IOException ex) {
16328 System.err.println(ex.toString());
16329 }
16330 }
15562 16331
16332 URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()]));
16333 URL klassURL = null;
16334 Class<?> klass = null;
16335 try {
16336 String resourceName = className.replace(".", "/") + ".class";
16337 klassURL = localClassLoader.getResource(resourceName);
16338 klass = localClassLoader.loadClass(className);
16339 } catch (ClassNotFoundException ex) {
16340 System.err.println(className + " not found");
16341 System.exit(-1);
16342 }
16343
16344 String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!'));
16345 String path = pathURL.substring(pathURL.indexOf(':') + 1);
16346 System.err.println("found: " + path);
16347
16348 if (argv.length > 3) {
16349 checkVersion(klass, argv);
16350 }
16351
16352 System.out.println(path);
16353 }
16354
16355 private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException {
16356 final String versionMethod = argv[3];
16357 final String expected = argv[4];
16358 final String atLeastOrEqual;
16359 if (argv.length > 5)
16360 atLeastOrEqual = argv[5];
16361 else
16362 atLeastOrEqual = "<=";
16363
16364 try {
16365 try {
16366 Field field = klass.getField(versionMethod);
16367 Object value = field.get(null);
16368 compareAndDisplay(atLeastOrEqual, expected, value);
16369 } catch (NoSuchFieldException fe) {
16370 Method method = null;
16371 try {
16372 method = klass.getMethod(versionMethod);
16373 } catch (NoSuchMethodException ex) {
16374 System.err.println(ex.toString());
16375 System.exit(-3);
16376 }
16377
16378 try {
16379 Object value = method.invoke(null);
16380 compareAndDisplay(atLeastOrEqual, expected, value);
16381 } catch (NullPointerException ex) {
16382 Object value = method.invoke(klass.newInstance());
16383 compareAndDisplay(atLeastOrEqual, expected, value);
16384 }
16385 }
16386 } catch (IllegalAccessException ex) {
16387 System.err.println(ex);
16388 System.exit(-2);
16389 } catch (InvocationTargetException ex) {
16390 System.err.println(ex);
16391 System.exit(-2);
16392 } catch (InstantiationException ex) {
16393 System.err.println(ex);
16394 System.exit(-2);
16395 }
16396 }
16397
16398 private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) {
16399 int cmp = compare(expected, value.toString());
16400
16401 switch(atLeastOrEqual) {
16402 case ">":
16403 if (cmp > 0) {
16404 return;
16405 } else {
16406 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
16407 System.exit(-4);
16408 }
16409 case "==":
16410 if (cmp == 0) {
16411 return;
16412 } else {
16413 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
16414 System.exit(-4);
16415 }
16416 case "<=":
16417 if (cmp <= 0) {
16418 return;
16419 } else {
16420 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
16421 System.exit(-4);
16422 }
16423 default:
16424 System.err.println("unable to compare with "+atLeastOrEqual);
16425 System.exit(-4);
16426 }
15563 } 16427 }
15564 16428
15565 private static int compare(String v1, String v2) { 16429 private static int compare(String v1, String v2) {
15566 String s1 = normalisedVersion(v1); 16430 String s1 = normalisedVersion(v1);
15567 String s2 = normalisedVersion(v2); 16431 String s2 = normalisedVersion(v2);
16432
16433 System.err.println("compare: " + v1 + " normalised to " + s1);
16434 System.err.println("compare: " + v2 + " normalised to " + s2);
15568 return s1.compareTo(s2); 16435 return s1.compareTo(s2);
15569 } 16436 }
15570 16437
@@ -15585,59 +16452,28 @@ EOF
15585 16452
15586 CLASSPATH=$ac_java_classpath 16453 CLASSPATH=$ac_java_classpath
15587 export CLASSPATH 16454 export CLASSPATH
15588 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 16455 cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java"
15589 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 16456 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then
15590 if test ""no"" = "no"; then 16457 echo "configure: conftestSharedChecker.class available" >&5
15591 echo "yes" >&5
15592
15593 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
15594$as_echo "$jar_resolved" >&6; }
15595 found_jar=yes
15596 PACKAGE_JAR_FILE=$jar_resolved
15597 break 3
15598
15599 else
15600 cmd="$JAVA conftest"
15601 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
15602 echo "yes" >&5
15603
15604 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
15605$as_echo "$jar_resolved" >&6; }
15606 found_jar=yes
15607 PACKAGE_JAR_FILE=$jar_resolved
15608 break 3
15609
15610 else
15611 echo "configure: failed program was:" >&5
15612 cat conftest.java >&5
15613 if test -s conftest.java.output; then
15614 STDOUT=`cat conftest.java.output`
15615 fi
15616 echo "configure: CLASSPATH was $CLASSPATH" >&5
15617
15618 ac_java_classpath=$saved_ac_java_classpath
15619
15620
15621 fi
15622 fi
15623 if test -f conftest.java.output; then
15624 rm conftest.java.output
15625 fi
15626 else 16458 else
15627 echo "configure: failed program was:" >&5 16459 echo "configure: failed program was:" >&5
15628 cat conftest.java >&5 16460 cat conftestSharedChecker.java >&5
15629 echo "configure: CLASSPATH was $CLASSPATH" >&5 16461 echo "configure: CLASSPATH was $CLASSPATH" >&5
16462 fi
15630 16463
15631 ac_java_classpath=$saved_ac_java_classpath 16464 fi
15632
15633
15634 fi
15635 16465
15636 fi 16466 CLASSPATH=$ac_java_classpath
15637 done 16467 export CLASSPATH
15638 done 16468 cmd="$JAVA conftestSharedChecker jrosetta-API com.artenum.rosetta.interfaces.core.ConsoleConfiguration $jar_resolved "
15639 done 16469 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5); then
15640 if test "$found_jar" = "no"; then 16470 PACKAGE_JAR_FILE=$(tail -n 1 conftestSharedChecker.java.output);
16471 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PACKAGE_JAR_FILE" >&5
16472$as_echo "$PACKAGE_JAR_FILE" >&6; }
16473 echo "yes" >&5
16474 # append the found file to the classpath to manage jar dependency
16475 ac_java_classpath="$ac_java_classpath:$PACKAGE_JAR_FILE"
16476 else
15641 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 16477 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15642$as_echo "no" >&6; } 16478$as_echo "no" >&6; }
15643 if test ""yes"" = "yes"; then 16479 if test ""yes"" = "yes"; then
@@ -15647,38 +16483,171 @@ $as_echo "$as_me: WARNING: Could not find or use the Java package/jar jrosetta-A
15647 as_fn_error $? "Could not find or use the Java package/jar jrosetta-API used by JRosetta : Console API Artenum / Scilab (looking for package com.artenum.rosetta.interfaces.core.ConsoleConfiguration)" "$LINENO" 5 16483 as_fn_error $? "Could not find or use the Java package/jar jrosetta-API used by JRosetta : Console API Artenum / Scilab (looking for package com.artenum.rosetta.interfaces.core.ConsoleConfiguration)" "$LINENO" 5
15648 fi 16484 fi
15649 fi 16485 fi
16486 if test -f conftestSharedChecker.java.output; then
16487 rm conftestSharedChecker.java.output
16488 fi
15650 16489
15651 if test -z "$PACKAGE_JAR_FILE"; then 16490 if test -z "$PACKAGE_JAR_FILE"; then
15652 16491
16492
16493
15653 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jrosetta-api" >&5 16494 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jrosetta-api" >&5
15654$as_echo_n "checking jrosetta-api... " >&6; } 16495$as_echo_n "checking jrosetta-api... " >&6; }
15655 PACKAGE_JAR_FILE= 16496 PACKAGE_JAR_FILE=
15656 found_jar=no
15657 saved_ac_java_classpath=$ac_java_classpath
15658 DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null)"
15659 for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR; do
15660 for jar in "$jardir/jrosetta-api.jar" "$jardir/libjrosetta-api.jar" "$jardir/libjrosetta-api-java.jar" "$jardir/jrosetta-api*.jar"; do
15661
15662# TODO check the behaviour when spaces
15663 jars_resolved=`ls $jar 2>/dev/null`
15664 for jar_resolved in $jars_resolved; do # If several jars matches
15665 if test -e "$jar_resolved"; then
15666 export ac_java_classpath="$jar_resolved:$ac_java_classpath"
15667 16497
15668 cat << \EOF > conftest.java 16498 DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
15669// #line 15669 "configure"
15670import java.util.regex.Pattern;
15671 16499
15672import com.artenum.rosetta.interfaces.core.ConsoleConfiguration; 16500 jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'jrosetta-api.jar' -or -name 'libjrosetta-api.jar' -or -name 'libjrosetta-api-java.jar' -or -name 'jrosetta-api*.jar' \) -printf '%p:' 2>/dev/null)."
15673 16501
15674public class conftest { 16502 if test ! -f conftestSharedChecker.class ; then
16503
16504 cat << \EOF > conftestSharedChecker.java
16505// #line 16505 "configure"
16506import java.util.regex.Pattern;
16507import java.io.File;
16508import java.io.IOException;
16509import java.lang.reflect.Field;
16510import java.lang.reflect.InvocationTargetException;
16511import java.lang.reflect.Method;
16512import java.net.URL;
16513import java.net.URLClassLoader;
16514import java.util.ArrayList;
16515
16516public class conftestSharedChecker {
16517
16518 /**
16519 * Required arguments :
16520 * argv[0]: name of the jar package
16521 * argv[1]: name of the class (with the package prefix)
16522 * argv[2]: possible paths of the jar package (separated by ':')
16523 *
16524 * Optional arguments:
16525 * argv[3]: field or method used to retrieve the version
16526 * argv[4]: expected version
16527 * argv[5]: String comparator :
16528 * "=" for exact version
16529 */
15675 public static void main(String[] argv) { 16530 public static void main(String[] argv) {
16531 final String packageName = argv[0];
16532 final String className = argv[1];
16533 final String[] jarList = argv[2].split(":");
15676 16534
16535 ArrayList<URL> found = new ArrayList<>();
16536 for(String jar : jarList)
16537 {
16538 try {
16539 File f = new File(jar);
16540 if (f.exists()) {
16541 found.add(f.toURI().toURL());
16542 }
16543 } catch (IOException ex) {
16544 System.err.println(ex.toString());
16545 }
16546 }
16547
16548 URLClassLoader localClassLoader = new URLClassLoader(found.toArray(new URL[found.size()]));
16549 URL klassURL = null;
16550 Class<?> klass = null;
16551 try {
16552 String resourceName = className.replace(".", "/") + ".class";
16553 klassURL = localClassLoader.getResource(resourceName);
16554 klass = localClassLoader.loadClass(className);
16555 } catch (ClassNotFoundException ex) {
16556 System.err.println(className + " not found");
16557 System.exit(-1);
16558 }
16559
16560 String pathURL = klassURL.getPath().substring(0, klassURL.getPath().indexOf('!'));
16561 String path = pathURL.substring(pathURL.indexOf(':') + 1);
16562 System.err.println("found: " + path);
16563
16564 if (argv.length > 3) {
16565 checkVersion(klass, argv);
16566 }
16567
16568 System.out.println(path);
16569 }
16570
16571 private static void checkVersion(Class<?> klass, String[] argv) throws SecurityException, IllegalArgumentException {
16572 final String versionMethod = argv[3];
16573 final String expected = argv[4];
16574 final String atLeastOrEqual;
16575 if (argv.length > 5)
16576 atLeastOrEqual = argv[5];
16577 else
16578 atLeastOrEqual = "<=";
16579
16580 try {
16581 try {
16582 Field field = klass.getField(versionMethod);
16583 Object value = field.get(null);
16584 compareAndDisplay(atLeastOrEqual, expected, value);
16585 } catch (NoSuchFieldException fe) {
16586 Method method = null;
16587 try {
16588 method = klass.getMethod(versionMethod);
16589 } catch (NoSuchMethodException ex) {
16590 System.err.println(ex.toString());
16591 System.exit(-3);
16592 }
16593
16594 try {
16595 Object value = method.invoke(null);
16596 compareAndDisplay(atLeastOrEqual, expected, value);
16597 } catch (NullPointerException ex) {
16598 Object value = method.invoke(klass.newInstance());
16599 compareAndDisplay(atLeastOrEqual, expected, value);
16600 }
16601 }
16602 } catch (IllegalAccessException ex) {
16603 System.err.println(ex);
16604 System.exit(-2);
16605 } catch (InvocationTargetException ex) {
16606 System.err.println(ex);
16607 System.exit(-2);
16608 } catch (InstantiationException ex) {
16609 System.err.println(ex);
16610 System.exit(-2);
16611 }
16612 }
16613
16614 private static void compareAndDisplay(String atLeastOrEqual, String expected, Object value) {
16615 int cmp = compare(expected, value.toString());
16616
16617 switch(atLeastOrEqual) {
16618 case ">":
16619 if (cmp > 0) {
16620 return;
16621 } else {
16622 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
16623 System.exit(-4);
16624 }
16625 case "==":
16626 if (cmp == 0) {
16627 return;
16628 } else {
16629 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
16630 System.exit(-4);
16631 }
16632 case "<=":
16633 if (cmp <= 0) {
16634 return;
16635 } else {
16636 System.err.println("expected "+atLeastOrEqual+""+expected+" but got "+value);
16637 System.exit(-4);
16638 }
16639 default:
16640 System.err.println("unable to compare with "+atLeastOrEqual);
16641 System.exit(-4);
16642 }
15677 } 16643 }
15678 16644
15679 private static int compare(String v1, String v2) { 16645 private static int compare(String v1, String v2) {
15680 String s1 = normalisedVersion(v1); 16646 String s1 = normalisedVersion(v1);
15681 String s2 = normalisedVersion(v2); 16647 String s2 = normalisedVersion(v2);
16648
16649 System.err.println("compare: " + v1 + " normalised to " + s1);
16650 System.err.println("compare: " + v2 + " normalised to " + s2);
15682 return s1.compareTo(s2); 16651 return s1.compareTo(s2);
15683 } 16652 }
15684 16653
@@ -15699,59 +16668,28 @@ EOF
15699 16668
15700 CLASSPATH=$ac_java_classpath 16669 CLASSPATH=$ac_java_classpath
15701 export CLASSPATH 16670 export CLASSPATH
15702 cmd="$JAVAC ${JAVAC_FLAGS} conftest.java" 16671 cmd="$JAVAC ${JAVAC_FLAGS} conftestSharedChecker.java"
15703 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5) ; then 16672 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5) ; then
15704 if test ""no"" = "no"; then 16673 echo "configure: conftestSharedChecker.class available" >&5
15705 echo "yes" >&5
15706
15707 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
15708$as_echo "$jar_resolved" >&6; }
15709 found_jar=yes
15710 PACKAGE_JAR_FILE=$jar_resolved
15711 break 3
15712
15713 else
15714 cmd="$JAVA conftest"
15715 if (echo $cmd >&5 ; eval $cmd >conftest.java.output 2>&5); then
15716 echo "yes" >&5
15717
15718 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $jar_resolved" >&5
15719$as_echo "$jar_resolved" >&6; }
15720 found_jar=yes
15721 PACKAGE_JAR_FILE=$jar_resolved
15722 break 3
15723
15724 else
15725 echo "configure: failed program was:" >&5
15726 cat conftest.java >&5
15727 if test -s conftest.java.output; then
15728 STDOUT=`cat conftest.java.output`
15729 fi
15730 echo "configure: CLASSPATH was $CLASSPATH" >&5
15731
15732 ac_java_classpath=$saved_ac_java_classpath
15733
15734
15735 fi
15736 fi
15737 if test -f conftest.java.output; then
15738 rm conftest.java.output
15739 fi
15740 else 16674 else
15741 echo "configure: failed program was:" >&5 16675 echo "configure: failed program was:" >&5
15742 cat conftest.java >&5 16676 cat conftestSharedChecker.java >&5
15743 echo "configure: CLASSPATH was $CLASSPATH" >&5 16677 echo "configure: CLASSPATH was $CLASSPATH" >&5
16678 fi
15744 16679
15745 ac_java_classpath=$saved_ac_java_classpath 16680 fi
15746
15747
15748 fi
15749 16681
15750 fi 16682 CLASSPATH=$ac_java_classpath
15751 done 16683 export CLASSPATH
15752 done 16684 cmd="$JAVA conftestSharedChecker jrosetta-api com.artenum.rosetta.interfaces.core.ConsoleConfiguration $jar_resolved "
15753 done 16685 if (echo $cmd >&5 ; eval $cmd >conftestSharedChecker.java.output 2>&5); then
15754 if test "$found_jar" = "no"; then 16686 PACKAGE_JAR_FILE=$(tail -n 1 conftestSharedChecker.java.output);
16687 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PACKAGE_JAR_FILE" >&5
16688$as_echo "$PACKAGE_JAR_FILE" >&6; }
16689 echo "yes" >&5
16690 # append the found file to the classpath to manage jar dependency
16691 ac_java_classpath="$ac_java_classpath:$PACKAGE_JAR_FILE"
16692 else
15755 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 16693 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
15756$as_echo "no" >&6; } 16694$as_echo "no" >&6; }
15757 if test "" = "yes"; then 16695 if test "" = "yes"; then
@@ -15761,6 +16699,9 @@ $as_echo "$as_me: WARNING: Could not find or use the Java package/jar jrosetta-a
15761 as_fn_error $? "Could not find or use the Java package/jar jrosetta-api used by JRosetta : Console API Artenum / Scilab (looking for package com.artenum.rosetta.interfaces.core.ConsoleConfiguration)" "$LINENO" 5 16699 as_fn_error $? "Could not find or use the Java package/jar jrosetta-api used by JRosetta : Console API Artenum / Scilab (looking for package com.artenum.rosetta.interfaces.core.ConsoleConfiguration)" "$LINENO" 5
15762 fi 16700 fi
15763 fi 16701 fi
16702 if test -f conftestSharedChecker.java.output; then
16703 rm conftestSharedChecker.java.output
16704 fi
15764 16705
15765 fi 16706 fi
15766 JROSETTA_API=$PACKAGE_JAR_FILE 16707 JROSETTA_API=$PACKAGE_JAR_FILE
@@ -15768,35 +16709,165 @@ $as_echo "$as_me: WARNING: Could not find or use the Java package/jar jrosetta-a
15768 16709
15769 # Console Core 16710 # Console Core
15770 16711
16712
16713
15771 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jrosetta-engine" >&5 16714 { $as_echo "$as_me:${as_lineno-$LINENO}: checking jrosetta-engine" >&5
15772$as_echo_n "checking jrosetta-engine... " >&6; } 16715$as_echo_n "checking jrosetta-engine... " >&6; }
15773 PACKAGE_JAR_FILE= 16716 PACKAGE_JAR_FILE=
15774 found_jar=no
15775 saved_ac_java_classpath=$ac_java_classpath
15776 DEFAULT_JAR_DIR="/usr/share/java /usr/lib/java /usr/share/java /usr/share/java/jar /opt/java/lib /usr/local/java /usr/local/java/jar /usr/local/share/java /usr/local/share/java/jar /usr/local/lib/java $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null)"
15777 for jardir in "`pwd`/thirdparty" "`pwd`/jar" $DEFAULT_JAR_DIR; do
15778 for jar in "$jardir/jrosetta-engine.jar" "$jardir/libjrosetta-engine.jar" "$jardir/libjrosetta-engine-java.jar" "$jardir/jrosetta-engine*.jar"; do
15779
15780# TODO check the behaviour when spaces
15781 jars_resolved=`ls $jar 2>/dev/null`
15782 for jar_resolved in $jars_resolved; do # If several jars matches
15783 if test -e "$jar_resolved"; then
15784 export ac_java_classpath="$jar_resolved:$ac_java_classpath"
15785 16717
15786 cat << \EOF > conftest.java 16718 DEFAULT_JAR_DIR="$(pwd)/thirdparty/ $(pwd)/jar/ /usr/local/java/ /usr/local/java/jar /usr/local/share/java/ /usr/local/share/java/jar/ /usr/local/lib/java/ $(find /usr/share/java/ -maxdepth 1 -type d 2>/dev/null | sort) $(find /usr/lib64/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/lib/ -maxdepth 1 -type d 2>/dev/null) $(find /usr/share/*/lib -maxdepth 1 -type d 2>/dev/null) /opt/java/lib/"
15787// #line 15787 "configure"
15788import java.util.regex.Pattern;
15789 16719
15790import com.artenum.rosetta.core.action.AbstractConsoleAction; 16720 jar_resolved="$(find $DEFAULT_JAR_DIR -maxdepth 1 \( -type f -name 'jrosetta-engine.jar' -or -name 'libjrosetta-engine.jar' -or -name 'libjrosetta-engine-java.jar' -or -name 'jrosetta-engine*.jar' \) -printf '%p:' 2>/dev/null)."
15791 16721
15792public class conftest { 16722 if test ! -f conftestSharedChecker.class ; then
16723
16724 cat << \EOF > conftestSharedChecker.java
16725// #line 16725 "configure"
16726import java.util.regex.Pattern;
16727import java.io.File;
16728import java.io.IOException;
16729import java.lang.reflect.Field;
16730import java.lang.reflect.InvocationTargetException;
16731import java.lang.reflect.Method;
16732import java.net.URL;
16733import java.net.URLClassLoader;
16734import java.util.ArrayList;
16735
16736public class conftestSharedChecker {
16737