Newer
Older
Handbook / configuration / include / ac_check_class.m4
  1. dnl @synopsis AC_CHECK_CLASS
  2. dnl
  3. dnl AC_CHECK_CLASS tests the existence of a given Java class, either in
  4. dnl a jar or in a '.class' file.
  5. dnl
  6. dnl *Warning*: its success or failure can depend on a proper setting of
  7. dnl the CLASSPATH env. variable.
  8. dnl
  9. dnl Note: This is part of the set of autoconf M4 macros for Java
  10. dnl programs. It is VERY IMPORTANT that you download the whole set,
  11. dnl some macros depend on other. Unfortunately, the autoconf archive
  12. dnl does not support the concept of set of macros, so I had to break it
  13. dnl for submission. The general documentation, as well as the sample
  14. dnl configure.in, is included in the AC_PROG_JAVA macro.
  15. dnl
  16. dnl @category Java
  17. dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
  18. dnl @version 2000-07-19
  19. dnl @license GPLWithACException
  20.  
  21. AC_DEFUN([AC_CHECK_CLASS],[
  22. AC_REQUIRE([AC_PROG_JAVA])
  23. ac_var_name=`echo $1 | sed 's/\./_/g'`
  24. dnl Normaly I'd use a AC_CACHE_CHECK here but since the variable name is
  25. dnl dynamic I need an extra level of extraction
  26. AC_MSG_CHECKING([for $1 class])
  27. AC_CACHE_VAL(ac_cv_class_$ac_var_name, [
  28. if test x$ac_cv_prog_uudecode_base64 = xyes; then
  29. dnl /**
  30. dnl * Test.java: used to test dynamicaly if a class exists.
  31. dnl */
  32. dnl public class Test
  33. dnl {
  34. dnl
  35. dnl public static void
  36. dnl main( String[] argv )
  37. dnl {
  38. dnl Class lib;
  39. dnl if (argv.length < 1)
  40. dnl {
  41. dnl System.err.println ("Missing argument");
  42. dnl System.exit (77);
  43. dnl }
  44. dnl try
  45. dnl {
  46. dnl lib = Class.forName (argv[0]);
  47. dnl }
  48. dnl catch (ClassNotFoundException e)
  49. dnl {
  50. dnl System.exit (1);
  51. dnl }
  52. dnl lib = null;
  53. dnl System.exit (0);
  54. dnl }
  55. dnl
  56. dnl }
  57. cat << \EOF > Test.uue
  58. begin-base64 644 Test.class
  59. yv66vgADAC0AKQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
  60. bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
  61. bWJlclRhYmxlDAAKAAsBAANlcnIBABVMamF2YS9pby9QcmludFN0cmVhbTsJ
  62. AA0ACQcADgEAEGphdmEvbGFuZy9TeXN0ZW0IABABABBNaXNzaW5nIGFyZ3Vt
  63. ZW50DAASABMBAAdwcmludGxuAQAVKExqYXZhL2xhbmcvU3RyaW5nOylWCgAV
  64. ABEHABYBABNqYXZhL2lvL1ByaW50U3RyZWFtDAAYABkBAARleGl0AQAEKEkp
  65. VgoADQAXDAAcAB0BAAdmb3JOYW1lAQAlKExqYXZhL2xhbmcvU3RyaW5nOylM
  66. amF2YS9sYW5nL0NsYXNzOwoAHwAbBwAgAQAPamF2YS9sYW5nL0NsYXNzBwAi
  67. AQAgamF2YS9sYW5nL0NsYXNzTm90Rm91bmRFeGNlcHRpb24BAAY8aW5pdD4B
  68. AAMoKVYMACMAJAoAAwAlAQAKU291cmNlRmlsZQEACVRlc3QuamF2YQAhAAEA
  69. AwAAAAAAAgAJAAUABgABAAcAAABtAAMAAwAAACkqvgSiABCyAAwSD7YAFBBN
  70. uAAaKgMyuAAeTKcACE0EuAAaAUwDuAAasQABABMAGgAdACEAAQAIAAAAKgAK
  71. AAAACgAAAAsABgANAA4ADgATABAAEwASAB4AFgAiABgAJAAZACgAGgABACMA
  72. JAABAAcAAAAhAAEAAQAAAAUqtwAmsQAAAAEACAAAAAoAAgAAAAQABAAEAAEA
  73. JwAAAAIAKA==
  74. ====
  75. EOF
  76. if uudecode$EXEEXT Test.uue; then
  77. :
  78. else
  79. echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
  80. echo "configure: failed file was:" >&AC_FD_CC
  81. cat Test.uue >&AC_FD_CC
  82. ac_cv_prog_uudecode_base64=no
  83. fi
  84. rm -f Test.uue
  85. if AC_TRY_COMMAND($JAVA $JAVAFLAGS Test $1) >/dev/null 2>&1; then
  86. eval "ac_cv_class_$ac_var_name=yes"
  87. else
  88. eval "ac_cv_class_$ac_var_name=no"
  89. fi
  90. rm -f Test.class
  91. else
  92. AC_TRY_COMPILE_JAVA([$1], , [eval "ac_cv_class_$ac_var_name=yes"],
  93. [eval "ac_cv_class_$ac_var_name=no"])
  94. fi
  95. eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`"
  96. eval "HAVE_$ac_var_name=$`echo ac_cv_class_$ac_var_val`"
  97. HAVE_LAST_CLASS=$ac_var_val
  98. if test x$ac_var_val = xyes; then
  99. ifelse([$2], , :, [$2])
  100. else
  101. ifelse([$3], , :, [$3])
  102. fi
  103. ])
  104. dnl for some reason the above statment didn't fall though here?
  105. dnl do scripts have variable scoping?
  106. eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`"
  107. AC_MSG_RESULT($ac_var_val)
  108. ])