]> git.sesse.net Git - vlc/blob - m4/ac_prog_java_works.m4
Avoid flags duplication when configure cache not present
[vlc] / m4 / ac_prog_java_works.m4
1 dnl @synopsis AC_PROG_JAVA_WORKS
2 dnl
3 dnl Internal use ONLY.
4 dnl
5 dnl Note: This is part of the set of autoconf M4 macros for Java
6 dnl programs. It is VERY IMPORTANT that you download the whole set,
7 dnl some macros depend on other. Unfortunately, the autoconf archive
8 dnl does not support the concept of set of macros, so I had to break it
9 dnl for submission. The general documentation, as well as the sample
10 dnl configure.in, is included in the AC_PROG_JAVA macro.
11 dnl
12 dnl @category Java
13 dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
14 dnl @version 2000-07-19
15 dnl @license GPLWithACException
16
17 AC_DEFUN([AC_PROG_JAVA_WORKS], [
18 AC_CHECK_PROG(uudecode, uudecode$EXEEXT, yes)
19 if test x$uudecode = xyes; then
20 AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [
21 dnl /**
22 dnl  * Test.java: used to test if java compiler works.
23 dnl  */
24 dnl public class Test
25 dnl {
26 dnl
27 dnl public static void
28 dnl main( String[] argv )
29 dnl {
30 dnl     System.exit (0);
31 dnl }
32 dnl
33 dnl }
34 cat << \EOF > Test.uue
35 begin-base64 644 Test.class
36 yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
37 bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
38 bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s
39 YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG
40 aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB
41 AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB
42 AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ=
43 ====
44 EOF
45 if uudecode$EXEEXT Test.uue; then
46         ac_cv_prog_uudecode_base64=yes
47 else
48         echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
49         echo "configure: failed file was:" >&AC_FD_CC
50         cat Test.uue >&AC_FD_CC
51         ac_cv_prog_uudecode_base64=no
52 fi
53 rm -f Test.uue])
54 fi
55 if test x$ac_cv_prog_uudecode_base64 != xyes; then
56         rm -f Test.class
57         AC_MSG_WARN([I have to compile Test.class from scratch])
58         if test x$ac_cv_prog_javac_works = xno; then
59                 AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly])
60         fi
61         if test x$ac_cv_prog_javac_works = x; then
62                 AC_PROG_JAVAC
63         fi
64 fi
65 AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [
66 JAVA_TEST=Test.java
67 CLASS_TEST=Test.class
68 TEST=Test
69 changequote(, )dnl
70 cat << \EOF > $JAVA_TEST
71 /* [#]line __oline__ "configure" */
72 public class Test {
73 public static void main (String args[]) {
74         System.exit (0);
75 } }
76 EOF
77 changequote([, ])dnl
78 if test x$ac_cv_prog_uudecode_base64 != xyes; then
79         if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then
80                 :
81         else
82           echo "configure: failed program was:" >&AC_FD_CC
83           cat $JAVA_TEST >&AC_FD_CC
84           AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?))
85         fi
86 fi
87 if AC_TRY_COMMAND($JAVA $JAVAFLAGS $TEST) >/dev/null 2>&1; then
88   ac_cv_prog_java_works=yes
89 else
90   echo "configure: failed program was:" >&AC_FD_CC
91   cat $JAVA_TEST >&AC_FD_CC
92   AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?))
93 fi
94 rm -fr $JAVA_TEST $CLASS_TEST Test.uue
95 ])
96 AC_PROVIDE([$0])dnl
97 ]
98 )