1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
124
  
125
  
126
  
127
  
128
  
129
  
130
  
131
  
132
  
133
  
134
  
135
  
136
  
137
  
138
  
139
  
140
  
141
  
142
  
143
  
144
  
145
  
146
  
147
  
148
  
149
  
150
  
151
  
152
  
153
  
154
  
155
  
156
  
157
  
158
  
159
  
160
  
161
  
162
  
163
  
164
  
165
  
166
  
167
  
168
  
169
  
170
  
171
  
172
  
173
  
174
  
175
  
176
  
177
  
178
  
179
  
180
  
181
  
182
  
183
  
184
  
185
  
186
  
187
  
188
  
189
  
190
  
191
  
192
  
193
  
194
  
195
  
196
  
197
  
198
  
199
  
200
  
201
  
202
  
203
  
204
  
205
  
206
  
207
  
208
  
209
  
210
  
211
  
212
  
213
  
214
  
215
  
216
  
217
  
218
  
219
  
220
  
221
  
222
  
223
  
224
  
225
  
226
  
227
  
228
  
229
  
230
  
231
  
232
  
233
  
234
  
235
  
236
  
237
  
238
  
239
  
240
  
241
  
242
  
243
  
244
  
245
  
246
  
247
  
248
  
249
  
250
  
251
  
252
  
253
  
254
  
255
  
256
  
257
  
258
  
259
  
260
  
261
  
262
  
263
  
264
  
265
  
266
  
267
  
268
  
269
  
270
  
271
  
272
  
273
  
274
  
275
  
276
  
277
  
278
  
279
  
280
  
281
  
282
  
283
  
284
  
285
  
286
  
287
  
288
  
289
  
290
  
291
  
292
  
293
  
294
  
295
  
296
  
297
  
298
  
299
  
300
  
301
  
302
  
303
  
304
  
305
  
306
  
307
  
308
  
309
  
310
  
311
  
312
  
313
  
314
  
315
  
316
  
317
  
318
  
319
  
320
  
321
  
322
  
323
  
324
  
325
  
326
  
327
  
328
  
329
  
330
  
331
  
332
  
333
  
334
  
335
  
336
  
337
  
338
  
339
  
340
  
341
  
342
  
343
  
344
  
345
  
346
  
347
  
348
  
349
  
350
  
351
  
352
  
353
  
354
  
355
  
356
  
357
  
358
  
359
  
360
  
361
  
362
  
363
  
364
  
365
  
366
  
367
  
368
  
369
  
370
  
371
  
372
  
373
  
374
  
375
  
376
  
377
  
378
  
379
  
380
  
381
  
382
  
383
  
384
  
385
  
386
  
387
  
388
  
389
  
390
  
391
  
392
  
393
  
394
  
395
  
396
  
397
  
398
  
399
  
400
  
401
  
402
  
403
  
404
  
405
  
406
  
407
  
408
  
409
  
410
  
411
  
412
  
413
  
414
  
415
  
416
  
417
  
418
  
419
  
420
  
421
  
422
  
423
  
424
  
425
  
426
  
427
  
428
  
429
  
430
  
431
  
432
  
433
  
434
  
435
  
436
  
437
  
438
  
439
  
440
  
441
  
442
  
443
  
444
  
445
  
446
  
447
  
448
  
449
  
450
  
451
  
452
  
453
  
454
  
455
  
456
  
457
  
458
  
459
  
460
  
461
  
462
  
463
  
464
  
465
  
466
  
467
  
468
  
469
  
470
  
471
  
472
  
473
  
474
  
475
  
476
  
477
  
478
  
479
  
480
  
481
  
482
  
483
  
484
  
485
  
486
  
487
  
488
  
489
  
490
  
491
  
492
  
493
  
494
  
495
  
496
  
497
  
498
  
499
  
500
  
501
  
502
  
503
  
504
  
505
  
506
  
507
  
508
  
509
  
510
  
511
  
512
  
513
  
514
  
515
  
516
  
517
  
518
  
519
  
520
  
521
  
522
  
523
  
524
  
525
  
526
  
527
  
528
  
529
  
530
  
531
  
532
  
533
  
534
  
535
  
536
  
537
  
538
  
539
  
540
  
541
  
542
  
543
  
544
  
545
  
546
  
547
  
548
  
549
  
550
  
551
  
552
  
553
  
554
  
555
  
556
  
557
  
558
  
559
  
560
  
561
  
562
  
563
  
564
  
565
  
566
  
567
  
568
  
569
  
570
  
571
  
572
  
573
  
574
  
575
  
576
  
577
  
578
  
579
  
580
  
581
  
582
  
583
  
584
  
585
  
586
  
587
  
588
  
589
  
590
  
591
  
592
  
593
  
594
  
595
  
596
  
597
  
598
  
599
  
600
  
601
  
602
  
603
  
604
  
605
  
606
  
607
  
608
  
609
  
610
  
611
  
612
  
613
  
614
  
615
  
AC_INIT(jvm.c) 
AC_CONFIG_HEADER(config.h) 
 
AC_MODULE_INIT() 
 
OLD_LIBS=$LIBS 
OLD_LDFLAGS=$LDFLAGS 
OLD_CPPFLAGS=$CPPFLAGS 
OLD_LIBPATH=$LIBPATH 
JAVA_LIBS="" 
JAVA_LIBPATH="" 
JAVA_AVAILABLE=0 
LINKER_OPTIONS="" 
 
AC_ARG_WITH(java,  [  --without-java       no support for Java],[],[with_java=yes]) 
AC_ARG_WITH(java-include-dir,  
        [  --with-java-include-dir=dir    look for header-files in dir], 
        [pike_java_user_include_directory=$withval]) 
AC_ARG_WITH(java-lib-dir,  
        [  --with-java-lib-dir=dir    look for JRE libs in dir], 
        [pike_java_user_lib_directory=$withval]) 
 
PIKE_FEATURE_WITHOUT(Java) 
 
if test "x$with_java" = xyes; then 
 
  PIKE_FEATURE_NODEP(Java) 
 
  AC_MSG_CHECKING(which operating system we are using) 
  AC_CACHE_VAL(pike_cv_java_sysos, [ 
    pike_cv_java_sysos="`uname | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`" 
    case "$pike_cv_java_sysos" in 
      sunos) 
        case "`uname -r`" in 
          5.*|6.*|7.*) pike_cv_java_sysos="solaris"; 
        esac 
      ;; 
      *windows*) 
        pike_cv_java_sysos=windows_nt 
      ;; 
    esac 
  ]) 
  AC_MSG_RESULT($pike_cv_java_sysos) 
 
  PIKE_SELECT_ABI 
 
  AC_MSG_CHECKING(which architecture we are using) 
  AC_CACHE_VAL(pike_cv_java_arch, [ 
    if test "x$pike_cv_java_sysos" = xwindows_nt; then 
      uname=uname 
    elif test -f "/usr/bin/uname"; then 
      uname=/usr/bin/uname 
    else 
      uname=/bin/uname 
    fi 
    if test aix = "$pike_cv_java_sysos" && aix_cputype=`/usr/sbin/lsattr -El proc0 | awk '$1=="type" { print $2; ok=1; exit } END { exit !ok }'`; then 
      case "$aix_cputype" in 
        PowerPC*) pike_cv_java_arch=powerpc;; 
        POWER*) pike_cv_java_arch=rs6000;; 
        *) pike_cv_java_arch="`echo $aix_cputype | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`";; 
      esac 
    else 
      if pike_cv_java_arch="`$uname -p || uname -p 2>/dev/null`"; then 
        # On some linuxen the output of uname -p is much too verbose 
        # eg "Intel(R) Core(TM)2 Duo CPU T7500 @ 2.20GHz" 
        # This is not useable... 
        # Let the fallback below handle it instead. 
        if test `echo "$pike_cv_java_arch"| wc -c` -gt 10; then 
          pike_cv_java_arch=no 
        fi 
      else pike_cv_java_arch=no; fi 
    fi 
 
    dnl Linux kluge 
    dnl FIXME: Enable for other OSes as well? 
    if test x"$pike_cv_java_arch":"$pike_cv_java_sysos" = xunknown:linux -o \ 
            x"$pike_cv_java_arch":"$pike_cv_java_sysos" = xno:linux; then 
      pike_cv_java_arch="`uname -m`" 
    fi 
    pike_cv_java_arch="`echo $pike_cv_java_arch|sed -e 's/^i[[4-9]]86/i386/'`" 
    pike_cv_java_arch="`echo $pike_cv_java_arch|sed -e 's/athlon/i386/'`" 
 
    # Adjust according to the ABI 
    case "x$pike_cv_java_arch:$pike_cv_abi" in 
      xi386:64) 
        # uname -p on Solaris/x86 returns i386 even when running a 64-bit 
        # kernel. 
        pike_cv_java_arch="x86_64" 
      ;; 
      xx86_64:32) 
        # 32-bit binary on a 64-bit OS. 
        pike_cv_java_arch="i386" 
      ;; 
      xsparc:64) 
        pike_cv_java_arch="sparcv9" 
      ;; 
    esac 
  ]) 
  AC_MSG_RESULT($pike_cv_java_arch) 
 
  java_arch_dirs=$pike_cv_java_arch 
  case "x$java_arch_dirs" in 
    xx86_64) 
      # Some dists (e.g. Ubuntu and Solaris) have decided to use "amd64" 
      # as arch specifier in dirs etc even though uname -m returns "x86_64". 
      java_arch_dirs="x86_64 amd64" 
    ;; 
    xsparcv9) 
      # FIXME: Is this needed? 
      java_arch_dirs="sparcv9 sparc" 
    ;; 
  esac 
 
  AC_MSG_CHECKING(what kind of threads to use) 
  AC_CACHE_VAL(pike_cv_java_threads_type, [ 
    if test "x$THREADS_FLAG" = x; then 
      pike_cv_java_threads_type=native_threads 
    else 
      pike_cv_java_threads_type="${THREADS_FLAG}_threads" 
    fi 
  ]) 
  AC_MSG_RESULT($pike_cv_java_threads_type) 
 
  if test x"$pike_cv_java_threads_type" = xnative_threads; then 
    : 
  else 
    AC_MSG_WARN([Only native_threads are known to work.]) 
    AC_MSG_WARN([If you are unsure, please unset \$THREADS_FLAG and rerun configure.]) 
  fi 
 
  # Ugly hack to cut out all the library search stuff if we're 
  # remote compiling. 
  if test x"$CC" != xrntcl; then 
 
  AC_MSG_CHECKING(for working ls) 
  AC_CACHE_VAL(pike_cv_ls, [ 
    pike_cv_ls=no 
    IFS="${IFS=         }"; ac_save_ifs="$IFS"; IFS=":" 
    for ac_dir in $PATH; do 
      if test -x "$ac_dir"/ls && "$ac_dir"/ls . >/dev/null 2>&1; then 
        if "$ac_dir"/ls ./fnord/fnord/fnord/fnurkelfoo 2>/dev/null; then 
          : 
        else 
          pike_cv_ls="$ac_dir"/ls 
        fi 
      else 
        : 
      fi 
    done 
    IFS="$ac_save_ifs" 
  ]) 
  AC_MSG_RESULT($pike_cv_ls) 
  if test no = "$pike_cv_ls"; then 
    AC_MSG_WARN([no working ls found!  Java configure will almost certainly fail.]) 
    LS="false" 
  else 
    LS="$pike_cv_ls" 
  fi 
 
  AC_MSG_CHECKING(for JAVA_HOME) 
 
  AC_CACHE_VAL(pike_cv_java_java_home, [ 
    if test "x$JAVA_HOME" = x; then 
      pike_cv_java_java_home=no 
      java_home_guess=`"$srcdir/find_java_home.sh"` 
      for tmp_java_home in /usr/java /usr/local/java /usr/local/jdk* /usr/java*/jre /usr/java/jdk*/jre /usr/java/j2sdk*/jre /usr/local/java*/jre /usr/local/jdk*/jre /usr/local/jre* /usr/local/j2sdk*/jre /usr/local/j2re* /usr/lib/j2se/*/jre /usr/lib/jvm/*/jre "$java_home_guess" "$pike_java_user_lib_directory"/..; do 
        if test -d $tmp_java_home/.; then 
          tmp_arch_dir=nowhere 
          for ad in $java_arch_dirs; do 
            if test -d "$tmp_java_home/lib/$ad/."; then 
              tmp_arch_dir="$tmp_java_home/lib/$ad" 
              tmp_arch="$ad" 
              break 
            fi 
          done 
          if "$LS" "$tmp_arch_dir/$pike_cv_java_threads_type"/libjvm* >/dev/null 2>&1 || \ 
            "$LS" "$tmp_arch_dir"/libjvm* >/dev/null 2>&1 || \ 
            "$LS" "$tmp_arch_dir"/classic/libjvm* >/dev/null 2>&1 || \ 
            "$LS" "$tmp_java_home/bin"/classic/libjvm* >/dev/null 2>&1 || \ 
            "$LS" "$tmp_arch_dir"/client/libjvm* >/dev/null 2>&1 || \ 
            "$LS" "$tmp_java_home/bin"/client/libjvm* >/dev/null 2>&1 || \ 
            "$LS" "$tmp_arch_dir"/server/libjvm* >/dev/null 2>&1 || \ 
            "$LS" "$tmp_java_home/bin"/server/libjvm* >/dev/null 2>&1 || \ 
            "$LS" "$tmp_java_home/Libraries"/libjvm* >/dev/null 2>&1; then 
              pike_cv_java_java_home="$tmp_java_home" 
              java_arch_dir=$tmp_arch 
          else 
            : 
          fi 
        else 
          : 
        fi 
      done 
    else 
      if test -d "$JAVA_HOME"/jre/lib; then 
        pike_cv_java_java_home="$JAVA_HOME"/jre 
      else 
        pike_cv_java_java_home="$JAVA_HOME" 
      fi 
      for ad in $java_arch_dirs ""; do 
        if test -d "$pike_cv_java_java_home/lib/$ad/."; then 
          java_arch_dir="$ad" 
          break 
        fi 
      done 
    fi 
  ]) 
  AC_MSG_RESULT($pike_cv_java_java_home) 
  AC_MSG_CHECKING([for Java architecture directory name]) 
  AC_MSG_RESULT([$java_arch_dir]) 
 
  # Known buglet: $java_arch_dir isn't cached, so the following must 
  # also be cached when $pike_cv_java_java_home is. 
  AC_MSG_CHECKING(for Java libraries) 
  AC_CACHE_VAL(pike_cv_java_lib_dir, [ 
    pike_cv_java_lib_dir="" 
    if test -z "$pike_java_user_lib_directory"; then 
      tmp_java_lib_dir="$pike_cv_java_java_home/lib" 
    else 
      tmp_java_lib_dir="$pike_java_user_lib_directory" 
    fi 
    # NOTE: Loops in reverse priority order. 
    for i in "$java_arch_dir/client" "../bin/client" \ 
             "$java_arch_dir/server" "../bin/server" \ 
             "$java_arch_dir/$pike_cv_java_threads_type" \ 
             "$java_arch_dir/classic" "$java_arch_dir" \ 
             "." "../bin" "../bin/classic"; do 
      if test -d "$tmp_java_lib_dir/$i/." && "$LS" $tmp_java_lib_dir/$i/lib* >/dev/null 2>&1; then 
        pike_cv_java_lib_dir="$pike_cv_java_lib_dir$tmp_java_lib_dir/$i " 
      else 
        : 
      fi 
    done 
    if test -z "$pike_cv_java_lib_dir" ; then pike_cv_java_lib_dir=no; else 
      : 
    fi 
  ]) 
  AC_MSG_RESULT($pike_cv_java_lib_dir) 
 
  if test "x$pike_cv_java_lib_dir" = xno; then :; else 
    echo Adding $pike_cv_java_lib_dir to the library search path. 
    for i in $pike_cv_java_lib_dir; do 
      LDFLAGS="-L$i -R$i ${LDFLAGS}" 
      LINKER_OPTIONS="-L$i -R$i ${LINKER_OPTIONS}" 
      JAVA_LIBPATH="${JAVA_LIBPATH}${JAVA_LIBPATH:+:}$i" 
      LIBPATH="${LIBPATH}${LIBPATH:+:}$i" 
    done 
    export LIBPATH 
  fi 
 
  # FIXME: If several jvm's are installed then we can find the include 
  # files for a different one from the JAVA_HOME search above. This is 
  # not only a matter of having paths in the same order; e.g. 
  # /usr/lib/jvm/* can match more than one viable jvm's. 
 
  AC_MSG_CHECKING(for the Java include directory) 
  AC_CACHE_VAL(pike_cv_java_include_dir, [ 
    pike_cv_java_include_dir=no 
    for tmp_java_incdir in /usr/java*  /usr/local/java* /usr/local/jdk* /usr/local/jre* /usr/java/j2sdk* /usr/local/j2sdk* /usr/lib/jvm/* "$pike_cv_java_java_home"/../.. "$pike_cv_java_java_home"/.. "$pike_cv_java_java_home" "$pike_java_user_include_directory"; do 
      if test -d $tmp_java_incdir/. && "$LS" "$tmp_java_incdir/include/jni.h" >/dev/null 2>&1 ; then 
         pike_cv_java_include_dir="$tmp_java_incdir/include" 
      else 
        if test -d $tmp_java_incdir/. -a -d $tmp_java_incdir/Headers/. &&\ 
                  "$LS" "$tmp_java_incdir/Headers/jni.h" >/dev/null 2>&1 ; then 
          pike_cv_java_include_dir="$tmp_java_incdir/Headers" 
        else 
          : 
        fi 
      fi 
    done 
  ]) 
  AC_MSG_RESULT($pike_cv_java_include_dir) 
 
  if test "x$pike_cv_java_include_dir" = xno; then :; else 
    echo "Adding $pike_cv_java_include_dir to the include search path." 
    CPPFLAGS="-I$pike_cv_java_include_dir ${CPPFLAGS}" 
    if test -d "$pike_cv_java_include_dir/$pike_cv_java_sysos/."; then 
      echo "Adding $pike_cv_java_include_dir/$pike_cv_java_sysos to the include search path." 
      CPPFLAGS="-I$pike_cv_java_include_dir/$pike_cv_java_sysos ${CPPFLAGS}" 
    else 
      : 
    fi 
    for d in "$pike_cv_java_include_dir/$java_arch_dir/."; do 
      if test -d "$d"; then 
        echo "Adding $d to the include search path." 
        CPPFLAGS="-I$d ${CPPFLAGS}" 
      fi 
    done 
  fi 
 
  AC_MSG_CHECKING([for JavaVM (MacOS X)]) 
  AC_CACHE_VAL(pike_cv_java_javavm, [ 
    pike_cv_java_javavm=no; 
    for tmp_java_javavm in ../.. .. . ../../../../Frameworks/JavaVM.framework/; do 
      if test -f "$pike_cv_java_java_home"/"$tmp_java_javavm"/JavaVM; then 
        pike_cv_java_javavm="$pike_cv_java_java_home"/"$tmp_java_javavm"/JavaVM 
      else 
        : 
      fi 
    done 
  ]) 
  AC_MSG_RESULT($pike_cv_java_javavm) 
 
  if test osf1 = "$pike_cv_java_sysos"; then 
    CPPFLAGS="-D_REENTRANT $CPPFLAGS" 
  else 
    : 
  fi 
 
  else # if test x"$CC" = xrntcl 
    pike_cv_java_javavm=no 
  fi 
 
  PIKE_PKG_CONFIG(libffi) 
 
  # FFI on OS X (10.5 or newer) expects MACOSX defined 
  DO_IF_OS(Darwin, 
  [ 
    AC_SYS_COMPILER_FLAG(-DMACOSX, define_macosx, CPPFLAGS) 
  ]) 
 
  AC_CHECK_HEADERS(jni.h winbase.h setjmp.h ffi.h ffi/ffi.h libffi/ffi.h) 
  AC_CHECK_TYPES([ffi_arg, ffi_sarg],,,[#ifdef HAVE_FFI_H 
#include <ffi.h> 
#else 
#ifdef HAVE_FFI_FFI_H 
#include <ffi/ffi.h> 
#else 
#ifdef HAVE_LIBFFI_FFI_H 
#include <libffi/ffi.h> 
#endif 
#endif 
#endif]) 
 
  pike_cv_java=no 
 
  if test "$ac_cv_header_jni_h" = yes; then 
 
    AC_CHECK_LIB(hpi, sysOpen, [ 
      LIBS="$LIBS -lhpi" 
      JAVA_LIBS="${JAVA_LIBS} -lhpi" 
    ], []) 
 
    if test x"$pike_cv_java_javavm" = xno; then 
      : 
    else 
      AC_MSG_CHECKING([for JNI_CreateJavaVM in "$pike_cv_java_javavm"]) 
      AC_CACHE_VAL(ac_cv_lib_javavm_JNI_CreateJavaVM, [ 
        ac_save_LIBS="$LIBS" 
        LIBS="$pike_cv_java_javavm $LIBS" 
        AC_TRY_LINK([#include <jni.h>], dnl 
          [JNI_CreateJavaVM((JavaVM**)0,(void**)0,(void*)0);], dnl 
          [ac_cv_lib_javavm_JNI_CreateJavaVM=yes], dnl 
          [ac_cv_lib_javavm_JNI_CreateJavaVM=no]) 
        LIBS="$ac_save_LIBS" 
      ]) 
      if test x"$ac_cv_lib_javavm_JNI_CreateJavaVM" = xyes; then 
        LIBS="$pike_cv_java_javavm $LIBS" 
        JAVA_LIBS="$pike_cv_java_javavm ${JAVA_LIBS}" 
        pike_cv_java=yes; 
        AC_MSG_RESULT(yes) 
      else 
        AC_MSG_RESULT(no) 
      fi       
    fi 
 
    if test x"$pike_cv_java" = xyes; then 
      : 
    else 
 
      AC_MSG_CHECKING([for JNI_CreateJavaVM in -ljvm]) 
      AC_CACHE_VAL(ac_cv_lib_jvm_JNI_CreateJavaVM, [ 
        ac_save_LIBS="$LIBS" 
        LIBS="-ljvm $LIBS" 
        AC_TRY_LINK([#include <jni.h>], dnl 
          [JNI_CreateJavaVM((JavaVM**)0,(void**)0,(void*)0);], dnl 
          [ac_cv_lib_jvm_JNI_CreateJavaVM=yes], dnl 
          [ac_cv_lib_jvm_JNI_CreateJavaVM=no]) 
        LIBS="$ac_save_LIBS" 
      ]) 
      if test x"$ac_cv_lib_jvm_JNI_CreateJavaVM" = xyes; then 
        LIBS="-ljvm $LIBS" 
        JAVA_LIBS="-ljvm ${JAVA_LIBS}" 
        pike_cv_java=yes; 
        AC_MSG_RESULT(yes) 
      else 
        AC_MSG_RESULT(no) 
        AC_MSG_CHECKING([for JNI_CreateJavaVM in -lgcj]) 
        AC_CACHE_VAL(ac_cv_lib_gcj_JNI_CreateJavaVM, [ 
          ac_save_LIBS="$LIBS" 
          LIBS="-lgcj $LIBS" 
          AC_TRY_LINK([#include <jni.h>], dnl 
            [JNI_CreateJavaVM((JavaVM**)0,(void**)0,(void*)0);], dnl 
            [ac_cv_lib_gcj_JNI_CreateJavaVM=yes], dnl 
            [ac_cv_lib_gcj_JNI_CreateJavaVM=no]) 
          LIBS="$ac_save_LIBS" 
        ]) 
        if test x"$ac_cv_lib_gcj_JNI_CreateJavaVM" = xyes; then 
          LIBS="-lgcj $LIBS" 
          JAVA_LIBS="-lgcj ${JAVA_LIBS}" 
          pike_cv_java=yes; 
          AC_MSG_RESULT(yes) 
        else 
          AC_MSG_RESULT(no) 
        fi 
      fi 
 
    fi 
 
    if test "$pike_cv_java" = yes; then 
 
      AC_CHECK_LIB(java, Java_java_lang_Class_isInstance, [ 
        LIBS="-ljava $LIBS" 
        JAVA_LIBS="-ljava ${JAVA_LIBS}" 
      ], []) 
 
      AC_CHECK_LIB(zip, Java_java_util_zip_Inflater_inflateBytes, [ 
        LIBS="-lzip $LIBS" 
        JAVA_LIBS="-lzip ${JAVA_LIBS}" 
      ], []) 
 
      AC_CHECK_LIB(thread, thr_create, [ 
        LIBS="$LIBS -lthread" 
        JAVA_LIBS="${JAVA_LIBS} -lthread" 
        LINKER_OPTIONS="${LINKER_OPTIONS} -lthread" 
      ], []) 
 
      pike_java_ffi=no 
      AC_CHECK_LIB(ffi, ffi_prep_closure, [ 
        if test "$ac_cv_header_ffi_h" = yes \ 
             -o "$ac_cv_header_ffi_ffi_h" = yes \ 
             -o "$ac_cv_header_libffi_ffi_h" = yes; then 
          LIBS="-lffi $LIBS" 
          JAVA_LIBS="-lffi ${JAVA_LIBS}" 
          AC_DEFINE(HAVE_FFI) 
          pike_java_ffi=yes 
        else 
          : 
        fi 
      ], []) 
 
      # Java/AIX has this. For debug... 
      AC_CHECK_LIB(java, ibmFindDLL, [ 
        AC_DEFINE(HAVE_IBMFINDDLL) 
      ]) 
    else 
      : 
    fi 
  else 
    : 
  fi 
 
  PIKE_FEATURE(Java,[no (no known JVM found)]) 
 
  if test "$pike_cv_java" = yes; then 
    AC_MSG_CHECKING(if the JVM really works) 
    AC_CACHE_VAL(pike_cv_java_working, [ 
      OLD_CPPFLAGS="$CPPFLAGS" 
      CPPFLAGS="-I$srcdir $OLD_CPPFLAGS" 
      AC_TRY_RUN([#ifdef HAVE_JNI_H 
#include <jni.h> 
#endif 
#ifdef HAVE_SETJMP_H 
#include <setjmp.h> 
#endif 
#include <stdio.h> 
#ifdef __NT__ 
#include <windows.h> 
#include "ntdl.c" 
#endif 
        int main(int argc, char *argv[]) 
        { 
          JavaVM *jvm; 
          JNIEnv *env; 
          JavaVMInitArgs vm_args; 
          JavaVMOption vm_options[2]; 
          jint res; 
          jmp_buf jbuf; 
#ifndef __NT__ 
          alarm(50); 
#endif 
#ifdef __NT__ 
          switch(open_nt_dll()) { 
            case -1: 
              fprintf(stderr, "Can't load DLL\\n"); 
              exit(1); 
            case -2: 
              fprintf(stderr, "Can't GetProcAddress %s\\n", "JNI_CreateJavaVM"); 
            default: 
              exit(1); 
            case 0: 
              ; 
          } 
#endif 
          vm_args.version = 0x00010002; 
          vm_args.nOptions = 0; 
          vm_args.options = vm_options; 
          vm_args.ignoreUnrecognized = JNI_TRUE; 
#ifndef __NT__ 
          vm_options[0].optionString = "-Djava.library.path=$JAVA_LIBPATH"; 
          vm_options[0].extraInfo = NULL; 
          vm_args.nOptions++; 
#endif 
          if((res=JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args))) { 
            fprintf(stderr, "JNI_CreateJavaVM failed code %d\\n", (int)res); 
            exit(1); 
          } 
          if(!setjmp(jbuf)) 
            longjmp(jbuf,1); 
#ifdef HAVE_IBMFINDDLL 
          { 
            /* Debug... */ 
            extern char *ibmFindDLL(void); 
            fprintf(stderr, "ibmFindDLL: \"%s\"\n", ibmFindDLL()); 
          } 
#endif 
          if (!env) { 
            /* NOT_REACHED */ 
            /* Check that the headerfiles are reasonable... */ 
            /* Some versions of GCJ jni.h 
             * lack the name parameter to DefineClass() 
             * FIXME: Check if GCJ has some non-sun compat method. 
             */ 
            jbyte code[] = { 0 }; 
            jobject jobj; 
            jclass c = 
              (*env)->DefineClass(env, "foo", jobj, code, sizeof(code)); 
          } 
          return 0; 
        }; 
      ], [pike_cv_java_working=yes], [pike_cv_java_working=no]) 
      CPPFLAGS="$OLD_CPPFLAGS" 
    ]) 
    AC_MSG_RESULT($pike_cv_java_working) 
 
    AC_MSG_CHECKING(for known machine language) 
    AC_CACHE_VAL(pike_cv_java_cpu, [ 
      case $pike_cv_java_arch  in 
        sparc) pike_cv_java_cpu=sparc;; 
        i386|x86) pike_cv_java_cpu=x86;; 
        x86_64) pike_cv_java_cpu=x86_64;; 
        powerpc|ppc) pike_cv_java_cpu=ppc;; 
        alpha) pike_cv_java_cpu=alpha;; 
        *) pike_cv_java_cpu=no;; 
      esac 
    ]) 
    AC_MSG_RESULT($pike_cv_java_cpu) 
 
    case $pike_cv_java_cpu in 
      sparc) AC_DEFINE(HAVE_SPARC_CPU);; 
      x86) AC_DEFINE(HAVE_X86_CPU);; 
      x86_64) AC_DEFINE(HAVE_X86_64_CPU);; 
      ppc) AC_DEFINE(HAVE_PPC_CPU);; 
      alpha) AC_DEFINE(HAVE_ALPHA_CPU);; 
    esac 
 
    if test "x$pike_cv_sys_os" = xWindows_NT ; then 
      # We'll do LoadLibrary ourselves instead of relying on jvm.lib to 
      # do it for us.  That way we'll avoid nasty popup dialogs... 
      JAVA_LIBS="-lkernel32 -lws2_32 -ladvapi32" 
    else 
      : 
    fi 
 
    if test "$pike_cv_java_working" = no; then 
      pike_cv_java=no; 
      PIKE_FEATURE(Java,[no (JVM does not work)]) 
    else 
      PIKE_FEATURE(Java,[yes ($JAVA_LIBS)]) 
 
      if test "$pike_java_ffi" = no; then 
        if test "$pike_cv_java_cpu" = no -o "$pike_cv_java_cpu" = x86_64; then 
          PIKE_FEATURE(Java,[yes ($JAVA_LIBS) (no native methods)]) 
        else 
          : 
        fi 
      else 
        : 
      fi 
    fi 
  else 
    : 
  fi 
 
  if test "x$pike_cv_java" = xno; then 
    LIBS="$OLD_LIBS" 
    CPPFLAGS="$OLD_CPPFLAGS" 
    LDFLAGS="$OLD_LDFLAGS" 
    JAVA_LIBS="" 
    LINKER_OPTIONS="" 
  else 
    AC_DEFINE(HAVE_JAVA) 
    JAVA_AVAILABLE=1 
    if test "x$pike_cv_java_java_home" = xno; then :; else 
      AC_DEFINE_UNQUOTED(JAVA_HOME, "${pike_cv_java_java_home}") 
    fi 
  fi 
 
  if test "x$JAVA_LIBPATH" = x; then :; else 
    AC_DEFINE_UNQUOTED(JAVA_LIBPATH, "${JAVA_LIBPATH}") 
  fi 
 
  true 
else 
  : 
fi 
 
LIBPATH="$OLD_LIBPATH" 
 
AC_SUBST(LINKER_OPTIONS) 
AC_SUBST(JAVA_LIBS) 
AC_SUBST(JAVA_AVAILABLE) 
 
AC_OUTPUT(Makefile,echo FOO >stamp-h )