Blame m4/ac_check_class.m4

Packit 228f82
##### http://autoconf-archive.cryp.to/ac_check_class.html
Packit 228f82
#
Packit 228f82
# SYNOPSIS
Packit 228f82
#
Packit 228f82
#   AC_CHECK_CLASS
Packit 228f82
#
Packit 228f82
# DESCRIPTION
Packit 228f82
#
Packit 228f82
#   AC_CHECK_CLASS tests the existence of a given Java class, either in
Packit 228f82
#   a jar or in a '.class' file.
Packit 228f82
#
Packit 228f82
#   *Warning*: its success or failure can depend on a proper setting of
Packit 228f82
#   the CLASSPATH env. variable.
Packit 228f82
#
Packit 228f82
#   Note: This is part of the set of autoconf M4 macros for Java
Packit 228f82
#   programs. It is VERY IMPORTANT that you download the whole set,
Packit 228f82
#   some macros depend on other. Unfortunately, the autoconf archive
Packit 228f82
#   does not support the concept of set of macros, so I had to break it
Packit 228f82
#   for submission. The general documentation, as well as the sample
Packit 228f82
#   configure.in, is included in the AC_PROG_JAVA macro.
Packit 228f82
#
Packit 228f82
# LAST MODIFICATION
Packit 228f82
#
Packit 228f82
#   2000-07-19
Packit 228f82
#
Packit 228f82
# COPYLEFT
Packit 228f82
#
Packit 228f82
#   Copyright (c) 2000 Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
Packit 228f82
#
Packit 228f82
#   This program is free software; you can redistribute it and/or
Packit 228f82
#   modify it under the terms of the GNU General Public License as
Packit 228f82
#   published by the Free Software Foundation; either version 2 of the
Packit 228f82
#   License, or (at your option) any later version.
Packit 228f82
#
Packit 228f82
#   This program is distributed in the hope that it will be useful, but
Packit 228f82
#   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 228f82
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Packit 228f82
#   General Public License for more details.
Packit 228f82
#
Packit 228f82
#   You should have received a copy of the GNU General Public License
Packit 228f82
#   along with this program; if not, see <http://www.gnu.org/licenses/>.
Packit 228f82
#
Packit 228f82
#   As a special exception, the respective Autoconf Macro's copyright
Packit 228f82
#   owner gives unlimited permission to copy, distribute and modify the
Packit 228f82
#   configure scripts that are the output of Autoconf when processing
Packit 228f82
#   the Macro. You need not follow the terms of the GNU General Public
Packit 228f82
#   License when using or distributing such scripts, even though
Packit 228f82
#   portions of the text of the Macro appear in them. The GNU General
Packit 228f82
#   Public License (GPL) does govern all other use of the material that
Packit 228f82
#   constitutes the Autoconf Macro.
Packit 228f82
#
Packit 228f82
#   This special exception to the GPL applies to versions of the
Packit 228f82
#   Autoconf Macro released by the Autoconf Macro Archive. When you
Packit 228f82
#   make and distribute a modified version of the Autoconf Macro, you
Packit 228f82
#   may extend this special exception to the GPL to apply to your
Packit 228f82
#   modified version as well.
Packit 228f82
Packit 228f82
AC_DEFUN([AC_CHECK_CLASS],[
Packit 228f82
AC_REQUIRE([AC_PROG_JAVA])
Packit 228f82
ac_var_name=`echo $1 | sed 's/\./_/g'`
Packit 228f82
dnl Normaly I'd use a AC_CACHE_CHECK here but since the variable name is
Packit 228f82
dnl dynamic I need an extra level of extraction
Packit 228f82
AC_MSG_CHECKING([for $1 class])
Packit 228f82
AC_CACHE_VAL(ac_cv_class_$ac_var_name, [
Packit 228f82
if test x$ac_cv_prog_uudecode_base64 = xyes; then
Packit 228f82
dnl /**
Packit 228f82
dnl  * Test.java: used to test dynamicaly if a class exists.
Packit 228f82
dnl  */
Packit 228f82
dnl public class Test
Packit 228f82
dnl {
Packit 228f82
dnl
Packit 228f82
dnl public static void
Packit 228f82
dnl main( String[] argv )
Packit 228f82
dnl {
Packit 228f82
dnl     Class lib;
Packit 228f82
dnl     if (argv.length < 1)
Packit 228f82
dnl      {
Packit 228f82
dnl             System.err.println ("Missing argument");
Packit 228f82
dnl             System.exit (77);
Packit 228f82
dnl      }
Packit 228f82
dnl     try
Packit 228f82
dnl      {
Packit 228f82
dnl             lib = Class.forName (argv[0]);
Packit 228f82
dnl      }
Packit 228f82
dnl     catch (ClassNotFoundException e)
Packit 228f82
dnl      {
Packit 228f82
dnl             System.exit (1);
Packit 228f82
dnl      }
Packit 228f82
dnl     lib = null;
Packit 228f82
dnl     System.exit (0);
Packit 228f82
dnl }
Packit 228f82
dnl
Packit 228f82
dnl }
Packit 228f82
cat << \EOF > Test.uue
Packit 228f82
begin-base64 644 Test.class
Packit 228f82
yv66vgADAC0AKQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
Packit 228f82
bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
Packit 228f82
bWJlclRhYmxlDAAKAAsBAANlcnIBABVMamF2YS9pby9QcmludFN0cmVhbTsJ
Packit 228f82
AA0ACQcADgEAEGphdmEvbGFuZy9TeXN0ZW0IABABABBNaXNzaW5nIGFyZ3Vt
Packit 228f82
ZW50DAASABMBAAdwcmludGxuAQAVKExqYXZhL2xhbmcvU3RyaW5nOylWCgAV
Packit 228f82
ABEHABYBABNqYXZhL2lvL1ByaW50U3RyZWFtDAAYABkBAARleGl0AQAEKEkp
Packit 228f82
VgoADQAXDAAcAB0BAAdmb3JOYW1lAQAlKExqYXZhL2xhbmcvU3RyaW5nOylM
Packit 228f82
amF2YS9sYW5nL0NsYXNzOwoAHwAbBwAgAQAPamF2YS9sYW5nL0NsYXNzBwAi
Packit 228f82
AQAgamF2YS9sYW5nL0NsYXNzTm90Rm91bmRFeGNlcHRpb24BAAY8aW5pdD4B
Packit 228f82
AAMoKVYMACMAJAoAAwAlAQAKU291cmNlRmlsZQEACVRlc3QuamF2YQAhAAEA
Packit 228f82
AwAAAAAAAgAJAAUABgABAAcAAABtAAMAAwAAACkqvgSiABCyAAwSD7YAFBBN
Packit 228f82
uAAaKgMyuAAeTKcACE0EuAAaAUwDuAAasQABABMAGgAdACEAAQAIAAAAKgAK
Packit 228f82
AAAACgAAAAsABgANAA4ADgATABAAEwASAB4AFgAiABgAJAAZACgAGgABACMA
Packit 228f82
JAABAAcAAAAhAAEAAQAAAAUqtwAmsQAAAAEACAAAAAoAAgAAAAQABAAEAAEA
Packit 228f82
JwAAAAIAKA==
Packit 228f82
====
Packit 228f82
EOF
Packit 228f82
                if uudecode$EXEEXT Test.uue; then
Packit 228f82
                        :
Packit 228f82
                else
Packit 228f82
                        echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
Packit 228f82
                        echo "configure: failed file was:" >&AC_FD_CC
Packit 228f82
                        cat Test.uue >&AC_FD_CC
Packit 228f82
                        ac_cv_prog_uudecode_base64=no
Packit 228f82
                fi
Packit 228f82
        rm -f Test.uue
Packit 228f82
        if AC_TRY_COMMAND($JAVA $JAVAFLAGS Test $1) >/dev/null 2>&1; then
Packit 228f82
                eval "ac_cv_class_$ac_var_name=yes"
Packit 228f82
        else
Packit 228f82
                eval "ac_cv_class_$ac_var_name=no"
Packit 228f82
        fi
Packit 228f82
        rm -f Test.class
Packit 228f82
else
Packit 228f82
        AC_TRY_COMPILE_JAVA([$1], , [eval "ac_cv_class_$ac_var_name=yes"],
Packit 228f82
                [eval "ac_cv_class_$ac_var_name=no"])
Packit 228f82
fi
Packit 228f82
eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`"
Packit 228f82
eval "HAVE_$ac_var_name=$`echo ac_cv_class_$ac_var_val`"
Packit 228f82
HAVE_LAST_CLASS=$ac_var_val
Packit 228f82
if test x$ac_var_val = xyes; then
Packit 228f82
        ifelse([$2], , :, [$2])
Packit 228f82
else
Packit 228f82
        ifelse([$3], , :, [$3])
Packit 228f82
fi
Packit 228f82
])
Packit 228f82
dnl for some reason the above statment didn't fall though here?
Packit 228f82
dnl do scripts have variable scoping?
Packit 228f82
eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`"
Packit 228f82
AC_MSG_RESULT($ac_var_val)
Packit 228f82
])