Fix: java class check when uudecode is not present
[lttng-ust.git] / config / ax_check_class.m4
1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_check_class.html
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 # AX_CHECK_CLASS
8 #
9 # DESCRIPTION
10 #
11 # AX_CHECK_CLASS tests the existence of a given Java class, either in a
12 # jar or in a '.class' file.
13 #
14 # *Warning*: its success or failure can depend on a proper setting of the
15 # CLASSPATH env. variable.
16 #
17 # Note: This is part of the set of autoconf M4 macros for Java programs.
18 # It is VERY IMPORTANT that you download the whole set, some macros depend
19 # on other. Unfortunately, the autoconf archive does not support the
20 # concept of set of macros, so I had to break it for submission. The
21 # general documentation, as well as the sample configure.in, is included
22 # in the AX_PROG_JAVA macro.
23 #
24 # LICENSE
25 #
26 # Copyright (c) 2008 Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
27 #
28 # This program is free software; you can redistribute it and/or modify it
29 # under the terms of the GNU General Public License as published by the
30 # Free Software Foundation; either version 2 of the License, or (at your
31 # option) any later version.
32 #
33 # This program is distributed in the hope that it will be useful, but
34 # WITHOUT ANY WARRANTY; without even the implied warranty of
35 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
36 # Public License for more details.
37 #
38 # You should have received a copy of the GNU General Public License along
39 # with this program. If not, see <http://www.gnu.org/licenses/>.
40 #
41 # As a special exception, the respective Autoconf Macro's copyright owner
42 # gives unlimited permission to copy, distribute and modify the configure
43 # scripts that are the output of Autoconf when processing the Macro. You
44 # need not follow the terms of the GNU General Public License when using
45 # or distributing such scripts, even though portions of the text of the
46 # Macro appear in them. The GNU General Public License (GPL) does govern
47 # all other use of the material that constitutes the Autoconf Macro.
48 #
49 # This special exception to the GPL applies to versions of the Autoconf
50 # Macro released by the Autoconf Archive. When you make and distribute a
51 # modified version of the Autoconf Macro, you may extend this special
52 # exception to the GPL to apply to your modified version as well.
53
54 #serial 7
55
56 AU_ALIAS([AC_CHECK_CLASS], [AX_CHECK_CLASS])
57 AC_DEFUN([AX_CHECK_CLASS],[
58 AC_REQUIRE([AX_PROG_JAVA])
59 ac_var_name=`echo $1 | sed 's/\./_/g'`
60 dnl Normaly I'd use a AC_CACHE_CHECK here but since the variable name is
61 dnl dynamic I need an extra level of extraction
62 AC_MSG_CHECKING([for $1 class])
63 AC_CACHE_VAL(ax_cv_class_$ac_var_name, [
64 if test x$ac_cv_prog_uudecode_base64 = xyes; then
65 dnl /**
66 dnl * Test.java: used to test dynamicaly if a class exists.
67 dnl */
68 dnl public class Test
69 dnl {
70 dnl
71 dnl public static void
72 dnl main( String[] argv )
73 dnl {
74 dnl Class lib;
75 dnl if (argv.length < 1)
76 dnl {
77 dnl System.err.println ("Missing argument");
78 dnl System.exit (77);
79 dnl }
80 dnl try
81 dnl {
82 dnl lib = Class.forName (argv[0]);
83 dnl }
84 dnl catch (ClassNotFoundException e)
85 dnl {
86 dnl System.exit (1);
87 dnl }
88 dnl lib = null;
89 dnl System.exit (0);
90 dnl }
91 dnl
92 dnl }
93 cat << \EOF > Test.uue
94 begin-base64 644 Test.class
95 yv66vgADAC0AKQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
96 bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
97 bWJlclRhYmxlDAAKAAsBAANlcnIBABVMamF2YS9pby9QcmludFN0cmVhbTsJ
98 AA0ACQcADgEAEGphdmEvbGFuZy9TeXN0ZW0IABABABBNaXNzaW5nIGFyZ3Vt
99 ZW50DAASABMBAAdwcmludGxuAQAVKExqYXZhL2xhbmcvU3RyaW5nOylWCgAV
100 ABEHABYBABNqYXZhL2lvL1ByaW50U3RyZWFtDAAYABkBAARleGl0AQAEKEkp
101 VgoADQAXDAAcAB0BAAdmb3JOYW1lAQAlKExqYXZhL2xhbmcvU3RyaW5nOylM
102 amF2YS9sYW5nL0NsYXNzOwoAHwAbBwAgAQAPamF2YS9sYW5nL0NsYXNzBwAi
103 AQAgamF2YS9sYW5nL0NsYXNzTm90Rm91bmRFeGNlcHRpb24BAAY8aW5pdD4B
104 AAMoKVYMACMAJAoAAwAlAQAKU291cmNlRmlsZQEACVRlc3QuamF2YQAhAAEA
105 AwAAAAAAAgAJAAUABgABAAcAAABtAAMAAwAAACkqvgSiABCyAAwSD7YAFBBN
106 uAAaKgMyuAAeTKcACE0EuAAaAUwDuAAasQABABMAGgAdACEAAQAIAAAAKgAK
107 AAAACgAAAAsABgANAA4ADgATABAAEwASAB4AFgAiABgAJAAZACgAGgABACMA
108 JAABAAcAAAAhAAEAAQAAAAUqtwAmsQAAAAEACAAAAAoAAgAAAAQABAAEAAEA
109 JwAAAAIAKA==
110 ====
111 EOF
112 if $UUDECODE Test.uue; then
113 :
114 else
115 echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AS_MESSAGE_LOG_FD
116 echo "configure: failed file was:" >&AS_MESSAGE_LOG_FD
117 cat Test.uue >&AS_MESSAGE_LOG_FD
118 ac_cv_prog_uudecode_base64=no
119 fi
120 rm -f Test.uue
121 if AC_TRY_COMMAND($JAVA -classpath ".:$CLASSPATH" $JAVAFLAGS Test $1) >/dev/null 2>&1; then
122 eval "ac_cv_class_$ac_var_name=yes"
123 else
124 eval "ac_cv_class_$ac_var_name=no"
125 fi
126 rm -f Test.class
127 else
128 AX_TRY_COMPILE_JAVA([$1], , [eval "ac_cv_class_$ac_var_name=yes"],
129 [eval "ac_cv_class_$ac_var_name=no"])
130 fi
131 eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`"
132 eval "HAVE_$ac_var_name=$`echo ac_cv_class_$ac_var_val`"
133 HAVE_LAST_CLASS=$ac_var_val
134 if test x$ac_var_val = xyes; then
135 ifelse([$2], , :, [$2])
136 else
137 ifelse([$3], , :, [$3])
138 fi
139 ])
140 dnl for some reason the above statment didn't fall though here?
141 dnl do scripts have variable scoping?
142 eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`"
143 AC_MSG_RESULT($ac_var_val)
144 ])
This page took 0.034539 seconds and 5 git commands to generate.