OSDN Git Service

2004-07-23 Thomas Fitzsimmons <fitzsim@redhat.com>
[pf3gnuchains/gcc-fork.git] / libjava / configure.in
1 dnl Process this with autoconf to create configure
2 AC_PREREQ(2.13)
3 AC_INIT(java/lang/System.java)
4
5 dnl We use these options to decide which functions to include.
6 AC_ARG_WITH(target-subdir,
7 [  --with-target-subdir=SUBDIR
8                            configuring in a subdirectory])
9
10 dnl We may get other options which we don't document:
11 dnl --with-target-subdir, --with-multisrctop, --with-multisubdir
12
13 # When building with srcdir == objdir, links to the source files will
14 # be created in directories within the target_subdir.  We have to
15 # adjust toplevel_srcdir accordingly, so that configure finds
16 # install-sh and other auxiliary files that live in the top-level
17 # source directory.
18 if test "${srcdir}" = "."; then
19   if test -z "${with_target_subdir}"; then
20     toprel=".."
21   else
22     if test "${with_target_subdir}" != "."; then
23       toprel="${with_multisrctop}../.."
24     else
25       toprel="${with_multisrctop}.."
26     fi
27   fi
28 else
29   toprel=".."
30 fi
31
32 libgcj_basedir=$srcdir/$toprel/./libjava
33 AC_SUBST(libgcj_basedir)
34
35 AC_CONFIG_AUX_DIR(${srcdir}/$toprel)
36 if :; then :; else
37   # This overrides the previous occurrence for automake, but not for
38   # autoconf, which is exactly what we want.
39   AC_CONFIG_AUX_DIR(..)
40 fi
41
42 AC_CANONICAL_SYSTEM
43 _GCC_TOPLEV_NONCANONICAL_BUILD
44 _GCC_TOPLEV_NONCANONICAL_TARGET
45
46 AC_SUBST(target_noncanonical)
47
48 # This works around the fact that libtool configuration may change LD
49 # for this particular configuration, but some shells, instead of
50 # keeping the changes in LD private, export them just because LD is
51 # exported.
52 ORIGINAL_LD_FOR_MULTILIBS=$LD
53
54 AC_PROG_LN_S
55
56 # This works around an automake problem.
57 mkinstalldirs="`cd $ac_aux_dir && ${PWDCMD-pwd}`/mkinstalldirs"
58 AC_SUBST(mkinstalldirs)
59
60 AC_ARG_WITH(cross-host,
61 [  --with-cross-host=HOST  configuring with a cross compiler])
62
63 AC_ARG_WITH(newlib,
64 [  --with-newlib           Configuring with newlib])
65
66 AC_ARG_ENABLE(version-specific-runtime-libs,
67 [  --enable-version-specific-runtime-libs    
68    specify that runtime libraries should be installed in a compiler-specific
69    directory ],
70     [case "$enableval" in
71       yes) version_specific_libs=yes ;;
72       no)  version_specific_libs=no ;;
73       *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
74      esac],
75     [version_specific_libs=no]
76 )
77
78 dnl Default to --enable-multilib
79 AC_ARG_ENABLE(multilib,
80 [  --enable-multilib       build many library versions (default)],
81 [case "${enableval}" in
82   yes) multilib=yes ;;
83   no)  multilib=no ;;
84   *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
85  esac], [multilib=yes])dnl
86
87 dnl This shouldn't be needed, as long as top-level dependencies are
88 dnl defined correctly and shared-library paths are set up so that
89 dnl execution tests succeed.  FIXME.
90 define([AC_PROG_CC_WORKS],[])
91 define([AC_PROG_CXX_WORKS],[])
92
93 AC_PROG_CC
94
95 # We use the libstdc++-v3 version of LIB_AC_PROG_CXX, but use
96 # glibjava_CXX instead of glibcpp_CXX.  That's because we're passed a
97 # different definition of CXX than other directories, since we don't
98 # depend on libstdc++-v3 having already been built.
99 AC_DEFUN(LIB_AC_PROG_CXX,
100 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
101 dnl Fool anybody using AC_PROG_CXX.
102 AC_PROVIDE([AC_PROG_CXX])
103 # Use glibjava_CXX so that we do not cause CXX to be cached with the
104 # flags that come in CXX while configuring libjava.  They're different
105 # from those used for all other target libraries.  If CXX is set in
106 # the environment, respect that here.
107 glibjava_CXX=$CXX
108 AC_CHECK_PROGS(glibjava_CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
109 AC_SUBST(CXX)
110 CXX=$glibjava_CXX
111 test -z "$glibjava_CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
112
113 AC_PROG_CXX_GNU
114
115 if test $ac_cv_prog_gxx = yes; then
116   GXX=yes
117 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
118 dnl plays around with CXXFLAGS (such as to build both debugging and
119 dnl normal versions of a library), tasteless as that idea is.
120   ac_test_CXXFLAGS="${CXXFLAGS+set}"
121   ac_save_CXXFLAGS="$CXXFLAGS"
122   CXXFLAGS=
123   AC_PROG_CXX_G
124   if test "$ac_test_CXXFLAGS" = set; then
125     CXXFLAGS="$ac_save_CXXFLAGS"
126   elif test $ac_cv_prog_cxx_g = yes; then
127     CXXFLAGS="-g -O2"
128   else
129     CXXFLAGS="-O2"
130   fi
131 else
132   GXX=
133   test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
134 fi
135 ])
136
137 LIB_AC_PROG_CXX
138
139 dnl version is pulled out to make it a bit easier to change using sed.
140 version=0.0.7
141 dnl Still use "libjava" here to placate dejagnu.
142 AM_INIT_AUTOMAKE(libjava, $version)
143
144 AC_CHECK_TOOL(AS, as)
145 AC_CHECK_TOOL(AR, ar)
146 AC_CHECK_TOOL(RANLIB, ranlib, :)
147
148 AC_PROG_INSTALL
149
150 AM_MAINTAINER_MODE
151
152 AC_EXEEXT
153
154 # configure.host sets the following important variables
155 #       libgcj_cflags    - host specific C compiler flags
156 #       libgcj_cxxflags  - host specific C++ compiler flags
157 #       libgcj_javaflags - host specific Java compiler flags
158
159 libgcj_cflags=
160 libgcj_cxxflags=
161 libgcj_javaflags=
162
163 . [$]{srcdir}/configure.host
164
165 LIBGCJ_CFLAGS="[$]{libgcj_cflags}"
166 LIBGCJ_CXXFLAGS="[$]{libgcj_cxxflags}"
167 LIBGCJ_JAVAFLAGS="[$]{libgcj_javaflags}"
168 AC_SUBST(LIBGCJ_CFLAGS)
169 AC_SUBST(LIBGCJ_CXXFLAGS)
170 AC_SUBST(LIBGCJ_JAVAFLAGS)
171
172 AM_CONFIG_HEADER(include/config.h gcj/libgcj-config.h)
173
174 # Only use libltdl for non-newlib builds.
175 if test "x${with_newlib}" = "x" || test "x${with_newlib}" = "xno"; then
176    AC_LIBLTDL_CONVENIENCE
177    AC_LIBTOOL_DLOPEN
178    DIRLTDL=libltdl
179    AC_DEFINE(USE_LTDL, 1, [Define if libltdl is in use.])
180    # Sigh.  Libtool's macro doesn't do the right thing.
181    INCLTDL="-I\$(top_srcdir)/libltdl $INCLTDL"
182    # FIXME: this is a hack.
183    sub_auxdir="`cd $ac_aux_dir && ${PWDCMD-pwd}`"
184    ac_configure_args="$ac_configure_args --with-auxdir=$sub_auxdir"
185 fi
186 AC_SUBST(INCLTDL)
187 AC_SUBST(LIBLTDL)
188 AC_SUBST(DIRLTDL)
189 AM_PROG_LIBTOOL
190 AC_CONFIG_SUBDIRS($DIRLTDL)
191
192 if test -z "$with_target_subdir" || test "$with_target_subdir" = "."; then
193    COMPPATH=.
194 else
195    COMPPATH=..
196 fi
197 AC_SUBST(COMPPATH)
198
199 dnl The -no-testsuite modules omit the test subdir.
200 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
201
202 dnl Should the runtime set system properties by examining the 
203 dnl environment variable GCJ_PROPERTIES?
204 AC_ARG_ENABLE(getenv-properties,
205 [  --disable-getenv-properties
206                           don't set system properties from GCJ_PROPERTIES])
207
208 dnl Whether GCJ_PROPERTIES is used depends on the target.
209 if test -z "$enable_getenv_properties"; then
210    enable_getenv_properties=${enable_getenv_properties_default-yes}
211 fi
212 if test "$enable_getenv_properties" = no; then
213    AC_DEFINE(DISABLE_GETENV_PROPERTIES, 1,
214      [Define if system properties shouldn't be read from getenv("GCJ_PROPERTIES").])
215 fi
216
217 dnl Whether we should use arguments to main()
218 if test -z "$enable_main_args"; then
219    enable_main_args=${enable_main_args_default-yes}
220 fi
221 if test "$enable_main_args" = no; then
222    AC_DEFINE(DISABLE_MAIN_ARGS, 1, [Define if we should ignore arguments to main().])
223 fi
224
225
226 dnl Should we use hashtable-based synchronization?
227 dnl Currently works only for Linux X86/ia64
228 dnl Typically faster and more space-efficient
229 AC_ARG_ENABLE(hash-synchronization,
230 [  --enable-hash-synchronization
231                           use global hash table for monitor locks])
232
233 if test -z "$enable_hash_synchronization"; then
234    enable_hash_synchronization=$enable_hash_synchronization_default
235 fi
236
237 # Do we allow intermodule optimizations (i.e. compiling many files at once)?
238 AC_ARG_ENABLE(libgcj-multifile,
239 [  --enable-libgcj-multifile
240                           allow compilation of several files at once],
241 [case "${enableval}" in
242   yes) enable_libgcj_multifile=yes ;;
243   no)  enable_libgcj_multifile=no ;;
244   *) AC_MSG_ERROR(bad value ${enableval} for --enable-libgcj-multifile) ;;
245 esac],[enable_libgcj_multifile=no])
246 AM_CONDITIONAL(ONESTEP, test "$enable_libgcj_multifile" = yes)
247
248 # What is the native OS API for MinGW?
249 AC_ARG_WITH(win32-nlsapi,
250 changequote(<<,>>)dnl
251 <<  --with-win32-nlsapi=ansi, unicows or unicode
252                           native MinGW libgcj Win32 OS API [ansi]>>,
253 changequote([,])
254 [case "${withval}" in
255   ansi) with_win32_nlsapi=ansi ;;
256   unicows) with_win32_nlsapi=unicows ;;
257   unicode) with_win32_nlsapi=unicode ;;
258   *) AC_MSG_ERROR(Bad value ${withval} for --with-win32-nlsapi.) ;;
259 esac],[with_win32_nlsapi=ansi])
260
261 case "${with_win32_nlsapi}" in
262   unicows | unicode) 
263     AC_DEFINE(MINGW_LIBGCJ_UNICODE, 1,
264       [Define if MinGW libgcj uses the Windows UNICODE OS API.])
265     ;;
266 esac
267
268 dnl configure.host sets slow_pthread_self if the synchronization code should 
269 dnl try to avoid pthread_self calls by caching thread IDs in a hashtable.
270 if test "${slow_pthread_self}" = "yes"; then
271   AC_DEFINE(SLOW_PTHREAD_SELF, 1,
272     [Define if if the synchronization code should try to avoid pthread_self calls by caching thread IDs in a hashtable.])
273 fi
274
275
276 dnl See if the user has requested runtime debugging.
277 LIBGCJDEBUG="false"
278 AC_SUBST(LIBGCJDEBUG)
279 AC_ARG_ENABLE(libgcj-debug,
280 [  --enable-libgcj-debug   enable runtime debugging code],
281   if test "$enable_libgcj_debug" = yes; then
282     AC_DEFINE(DEBUG, 1, [Define this if you want runtime debugging enabled.])
283     LIBGCJDEBUG="true"
284   fi)
285
286 dnl See if the user has the interpreter included.
287 AC_ARG_ENABLE(interpreter,
288 [  --enable-interpreter    enable interpreter],
289   if test "$enable_interpreter" = yes; then
290     # This can also be set in configure.host.
291     libgcj_interpreter=yes
292   elif test "$enable_interpreter" = no; then
293     libgcj_interpreter=no
294   fi)
295
296 if test "$libgcj_interpreter" = yes; then
297    AC_DEFINE(INTERPRETER, 1, [Define if you want a bytecode interpreter.])
298 fi
299 INTERPRETER="$libgcj_interpreter"
300 AC_SUBST(INTERPRETER)
301
302 AC_MSG_CHECKING([for exception model to use])
303 AC_LANG_SAVE
304 AC_LANG_CPLUSPLUS
305 AC_ARG_ENABLE(sjlj-exceptions,
306 [  --enable-sjlj-exceptions  force use of builtin_setjmp for exceptions],
307 [:],
308 [dnl Botheration.  Now we've got to detect the exception model.
309 dnl Link tests against libgcc.a are problematic since -- at least
310 dnl as of this writing -- we've not been given proper -L bits for
311 dnl single-tree newlib and libgloss.
312 dnl
313 dnl This is what AC_TRY_COMPILE would do if it didn't delete the
314 dnl conftest files before we got a change to grep them first.
315 cat > conftest.$ac_ext << EOF
316 [#]line __oline__ "configure"
317 struct S { ~S(); };
318 void bar();
319 void foo()
320 {
321   S s;
322   bar();
323 }
324 EOF
325 old_CXXFLAGS="$CXXFLAGS"  
326 CXXFLAGS=-S
327 if AC_TRY_EVAL(ac_compile); then
328   if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
329     enable_sjlj_exceptions=yes
330   elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
331     enable_sjlj_exceptions=no
332   fi
333 fi
334 CXXFLAGS="$old_CXXFLAGS"
335 rm -f conftest*])
336 if test x$enable_sjlj_exceptions = xyes; then
337   AC_DEFINE(SJLJ_EXCEPTIONS, 1,
338         [Define if the compiler is configured for setjmp/longjmp exceptions.])
339   ac_exception_model_name=sjlj
340 elif test x$enable_sjlj_exceptions = xno; then
341   ac_exception_model_name="call frame"
342 else
343   AC_MSG_ERROR([unable to detect exception model])
344 fi
345 AC_LANG_RESTORE
346 AC_MSG_RESULT($ac_exception_model_name)
347
348 # If we are non using SJLJ exceptions, and this host does not have support 
349 # for unwinding from a signal handler, enable checked dereferences and divides.
350 if test $can_unwind_signal = no && test $enable_sjlj_exceptions = no; then
351   CHECKREFSPEC=-fcheck-references
352   DIVIDESPEC=-fuse-divide-subroutine
353   EXCEPTIONSPEC=
354 fi
355
356 dnl See if the user wants to disable java.net.  This is the mildly
357 dnl ugly way that we admit that target-side configuration sucks.
358 AC_ARG_ENABLE(java-net,
359 [  --disable-java-net      disable java.net])
360
361 dnl Whether java.net is built by default can depend on the target.
362 if test -z "$enable_java_net"; then
363    enable_java_net=${enable_java_net_default-yes}
364 fi
365 if test "$enable_java_net" = no; then
366    AC_DEFINE(DISABLE_JAVA_NET, 1, [Define if java.net native functions should be stubbed out.])
367 fi
368
369 dnl See if the user wants to configure without libffi.  Some
370 dnl architectures don't support it, and default values are set in 
371 dnl configure.host.
372 AC_ARG_WITH(libffi,
373 [  --without-libffi        don't use libffi],,with_libffi=${with_libffi_default-yes})
374
375 LIBFFI=
376 LIBFFIINCS=
377 if test "$with_libffi" != no; then
378    AC_DEFINE(USE_LIBFFI, 1, [Define if we're to use libffi.])
379    LIBFFI=../libffi/libffi_convenience.la
380    LIBFFIINCS='-I$(top_srcdir)/../libffi/include -I../libffi/include'
381 fi
382 AC_SUBST(LIBFFI)
383 AC_SUBST(LIBFFIINCS)
384
385 dnl See if the user wants to disable JVMPI support.
386 AC_ARG_ENABLE(jvmpi,
387 [  --disable-jvmpi         disable JVMPI support])
388
389 if test "$enable_jvmpi" != no; then
390     AC_DEFINE(ENABLE_JVMPI, 1, [Define if you are using JVMPI.])
391 fi
392
393 dnl If the target is an eCos system, use the appropriate eCos
394 dnl I/O routines.
395 dnl FIXME: this should not be a local option but a global target
396 dnl system; at present there is no eCos target.
397 TARGET_ECOS=${PROCESS-"no"}
398 AC_ARG_WITH(ecos,
399 [  --with-ecos             enable runtime eCos target support],
400 TARGET_ECOS="$with_ecos"
401 )
402
403 EXTRA_CC_FILES=
404 AC_SUBST(EXTRA_CC_FILES)
405
406 PLATFORMOBJS=
407 case "$TARGET_ECOS" in
408    no) case "$host" in
409       *mingw*)
410             PLATFORM=Win32
411             PLATFORMNET=Win32
412             PLATFORMOBJS=win32.lo
413             PLATFORMH=win32.h
414         CHECK_FOR_BROKEN_MINGW_LD
415       ;;
416       *)
417             PLATFORM=Posix
418             PLATFORMNET=Posix
419             PLATFORMOBJS=posix.lo
420             PLATFORMH=posix.h
421       ;;
422       esac
423       ;;
424    *)
425       PLATFORM=Ecos
426       PLATFORMNET=NoNet
427       AC_DEFINE(ECOS, 1, [Define if you're running eCos.])
428       PLATFORMOBJS=posix.lo
429       PLATFORMH=posix.h
430       ;;
431 esac
432 AC_SUBST(PLATFORMOBJS)
433 AC_LINK_FILES(include/$PLATFORMH, include/platform.h)
434
435 AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED, 1,
436                                       [Define if you have int32_t and uint32_t.]))
437 AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED, 1,
438                                         [Define if you have int32_t and uint32_t.]))
439 AC_EGREP_HEADER(u_int32_t, sys/types.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1,
440                                           [Define if you have u_int32_t]))
441 AC_EGREP_HEADER(u_int32_t, sys/config.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1,
442                                            [Define if you have u_int32_t]))
443
444
445 dnl These may not be defined in a non-ANS conformant embedded system.
446 dnl FIXME: Should these case a runtime exception in that case?
447 AC_EGREP_HEADER(mktime, time.h, AC_DEFINE(HAVE_MKTIME, 1,
448                                   [Define is you have 'mktime' in <time.h>]))
449 AC_EGREP_HEADER(localtime, time.h, AC_DEFINE(HAVE_LOCALTIME, 1,
450                                   [Define is you have 'localtime' in <time.h>]))
451
452 dnl Create the subdirectory for natFile.cc, or the attempt
453 dnl to create the link will fail.
454 test -d java || mkdir java
455 test -d java/io || mkdir java/io
456 test -d gnu || mkdir gnu
457 AC_LINK_FILES(java/io/natFile${FILE-${PLATFORM}}.cc, java/io/natFile.cc)
458
459 dnl Likewise for ConcreteProcess.java and natConcreteProcess.cc.
460 test -d java/lang || mkdir java/lang
461 AC_LINK_FILES(java/lang/${PLATFORM}Process.java, java/lang/ConcreteProcess.java)
462 AC_LINK_FILES(java/lang/nat${PLATFORM}Process.cc, java/lang/natConcreteProcess.cc)
463
464 dnl Likewise for natInetAddress.cc and natNetworkInterface.cc.
465 test -d java/net || mkdir java/net
466 AC_LINK_FILES(java/net/natInetAddress${PLATFORMNET}.cc, java/net/natInetAddress.cc)
467 AC_LINK_FILES(java/net/natNetworkInterface${PLATFORMNET}.cc, java/net/natNetworkInterface.cc)
468
469 dnl Likewise for natPlainSocketImpl.cc and natPlainDatagramSocketImpl.cc.
470 test -d gnu/java || mkdir gnu/java
471 test -d gnu/java/net || mkdir gnu/java/net
472 AC_LINK_FILES(gnu/java/net/natPlainSocketImpl${PLATFORMNET}.cc, gnu/java/net/natPlainSocketImpl.cc)
473 AC_LINK_FILES(gnu/java/net/natPlainDatagramSocketImpl${PLATFORMNET}.cc, gnu/java/net/natPlainDatagramSocketImpl.cc)
474
475 dnl Likewise for natPipeImpl.cc and natSelectorImpl.cc.
476 test -d gnu/java/nio || mkdir gnu/java/nio
477 AC_LINK_FILES(gnu/java/nio/natPipeImpl${PLATFORM}.cc, gnu/java/nio/natPipeImpl.cc)
478 AC_LINK_FILES(gnu/java/nio/natSelectorImpl${PLATFORM}.cc, gnu/java/nio/natSelectorImpl.cc)
479 test -d gnu/java/nio/channels || mkdir gnu/java/nio/channels
480 AC_LINK_FILES(gnu/java/nio/channels/natFileChannel${FILE-${PLATFORM}}.cc, gnu/java/nio/channels/natFileChannelImpl.cc)
481
482 case "${host}" in
483     *mingw*)
484       SYSTEMSPEC="-lgdi32 -lwsock32 -lws2_32"
485       if test "${with_win32_nlsapi}" = "unicows"; then
486         SYSTEMSPEC="-lunicows $SYSTEMSPEC"
487       fi
488     ;;
489     *)
490       SYSTEMSPEC=
491     ;;
492 esac
493 AC_SUBST(SYSTEMSPEC)
494
495 LIBGCJTESTSPEC="-L`${PWDCMD-pwd}`/.libs -rpath `${PWDCMD-pwd}`/.libs"
496 AC_SUBST(LIBGCJTESTSPEC)
497
498 AC_ARG_WITH(system-zlib,
499 [  --with-system-zlib      use installed libz])
500 ZLIBSPEC=
501 AC_SUBST(ZLIBSPEC)
502 ZLIBTESTSPEC=
503 AC_SUBST(ZLIBTESTSPEC)
504
505 AC_PATH_XTRA
506
507 dnl Determine which AWT peer libraries to build
508 AC_ARG_ENABLE(java-awt,
509 [  --enable-java-awt       list of AWT peer implementations to be built])
510
511 peerlibs="`echo ${enable_java_awt} | tr ',' ' '`"
512 use_xlib_awt=""
513 use_gtk_awt=""
514 # The default toolkit to use is the first one specified.
515 TOOLKIT=
516 AC_SUBST(TOOLKIT)
517
518 for peer in $peerlibs ; do
519   case $peer in
520     xlib)
521       if test "$no_x" = yes; then
522         echo "*** xlib peers requested but no X library available" 1>&2
523         exit 1
524       else
525         use_xlib_awt="yes"
526         if test -z "$TOOLKIT"; then
527            TOOLKIT=gnu.awt.xlib.XToolkit
528         fi
529       fi
530       ;;
531     gtk)
532       if test "$no_x" = yes; then
533          echo "*** xlib peers requested but no X library available" 1>&2
534          exit 1
535       else
536          use_gtk_awt=yes
537          if test -z "$TOOLKIT"; then
538             TOOLKIT=gnu.java.awt.peer.gtk.GtkToolkit
539          fi
540          test -d jniinclude || mkdir jniinclude
541       fi
542       ;;
543     no)
544       use_xlib_awt=
545       use_gtk_awt=
546       break
547       ;;
548     *)
549       echo "*** unrecognised argument \"${peer}\" for --enable-java-awt" 1>&2
550       exit 1
551   esac
552 done
553
554 AM_CONDITIONAL(XLIB_AWT, test "$use_xlib_awt" = yes)
555 AM_CONDITIONAL(GTK_AWT, test "$use_gtk_awt" = yes)
556
557 dnl determine whether to enable the cairo GTK Graphics2D backend
558 AC_ARG_ENABLE(gtk-cairo, [  --enable-gtk-cairo       build the cairo Graphics2D implementation on GTK])
559 AM_CONDITIONAL(GTK_CAIRO, test "x${enable_gtk_cairo}" = xyes)
560 if test "x${enable_gtk_cairo}" = xyes
561 then
562         PKG_CHECK_MODULES(CAIRO, cairo)
563         PKG_CHECK_MODULES(PANGOFT2, pangoft2)
564 fi
565 AC_SUBST(CAIRO_LIBS)
566 AC_SUBST(CAIRO_CFLAGS)
567 AC_SUBST(PANGOFT2_LIBS)
568 AC_SUBST(PANGOFT2_CFLAGS)
569
570 dnl FIXME: this should be _libs on some hosts.
571 libsubdir=.libs
572
573 dnl Allow the GC to be disabled.  Can be useful when debugging.
574 AC_MSG_CHECKING([for garbage collector to use])
575 AC_ARG_ENABLE(java-gc,
576 changequote(<<,>>)dnl
577 <<  --enable-java-gc=TYPE   choose garbage collector [boehm]>>,
578 changequote([,])
579   GC=$enableval,
580   GC=boehm)
581 GCLIBS=
582 GCINCS=
583 GCDEPS=
584 GCOBJS=
585 GCSPEC=
586 JC1GCSPEC=
587 GCTESTSPEC=
588 case "$GC" in
589  boehm)
590     AC_MSG_RESULT(boehm)
591     GCLIBS=../boehm-gc/libgcjgc_convenience.la
592     JC1GCSPEC='-fuse-boehm-gc'
593     GCTESTSPEC="-L`${PWDCMD-pwd}`/../boehm-gc/.libs -rpath `${PWDCMD-pwd}`/../boehm-gc/.libs"
594
595     dnl We also want to pick up some cpp flags required when including
596     dnl boehm-config.h.  Yuck.
597     GCINCS="`cat ../boehm-gc/boehm-cflags`"
598     GCOBJS=boehm.lo
599     GCHDR=boehm-gc.h
600     dnl The POSIX thread support needs to know this.
601     AC_DEFINE(HAVE_BOEHM_GC, 1, [Define if Boehm GC in use.])
602     ;;
603  no)
604     AC_MSG_RESULT(none)
605     GCOBJS=nogc.lo
606     GCHDR=no-gc.h
607     ;;
608  *)
609     AC_MSG_ERROR(unrecognized collector \"$GC\")
610     ;;
611 esac
612 AC_SUBST(GCLIBS)
613 AC_SUBST(GCINCS)
614 AC_SUBST(GCDEPS)
615 AC_SUBST(GCOBJS)
616 AC_SUBST(GCSPEC)
617 AC_SUBST(JC1GCSPEC)
618 AC_SUBST(GCTESTSPEC)
619 AC_LINK_FILES(include/$GCHDR, include/java-gc.h)
620
621
622 AC_MSG_CHECKING([for thread model used by GCC])
623 THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
624 AC_MSG_RESULT([$THREADS])
625
626 case "$THREADS" in
627  no | none | single)
628     THREADS=none
629     ;;
630  posix | pthreads)
631     THREADS=posix
632     case "$host" in
633      *-*-linux*)
634         AC_DEFINE(LINUX_THREADS, 1, [Define if using POSIX threads on Linux.])
635         ;;
636     esac
637     ;;
638  win32)
639     ;;
640  decosf1 | irix | mach | os2 | solaris | dce | vxworks)
641     AC_MSG_ERROR(thread package $THREADS not yet supported)
642     ;;
643  *)
644     AC_MSG_ERROR($THREADS is an unknown thread package)
645     ;;
646 esac
647
648 THREADCXXFLAGS=
649 THREADLDFLAGS=
650 THREADLIBS=
651 THREADINCS=
652 THREADDEPS=
653 THREADOBJS=
654 THREADH=
655 THREADSPEC=
656 case "$THREADS" in
657  posix)
658     case "$host" in
659      *-*-cygwin*)
660         # Don't set THREADLIBS here.  Cygwin doesn't have -lpthread.
661         ;;
662 changequote(<<,>>)   
663      *-*-freebsd[1234]*)
664 changequote([,])   
665         # Before FreeBSD 5, it didn't have -lpthread (or any library which
666         # merely adds pthread_* functions) but it does have a -pthread switch
667         # which is required at link-time to select -lc_r *instead* of -lc.
668         THREADLDFLAGS=-pthread
669         # Don't set THREADSPEC here as might be expected since -pthread is
670         # not processed when found within a spec file, it must come from
671         # the command line.  For now, the user must provide the -pthread
672         # switch to link code compiled with gcj.  In future, consider adding
673         # support for weak references to pthread_* functions ala gthr.h API.
674         THREADSPEC='%{!pthread: %eUnder this configuration, the user must provide -pthread when linking.}'
675         ;;
676      *-*-freebsd*)
677         # FreeBSD 5 implements a model much closer to other modern UNIX
678         # which support threads.  However, it still does not support
679         # -lpthread.
680         THREADLDFLAGS=-pthread
681         THREADSPEC=-lc_r
682         ;;
683      alpha*-dec-osf*)
684         THREADCXXFLAGS=-pthread
685         # boehm-gc needs some functions from librt, so link that too.
686         THREADLIBS='-lpthread -lrt'
687         THREADSPEC='-lpthread -lrt'
688         ;;
689      *)
690         THREADLIBS=-lpthread
691         THREADSPEC=-lpthread
692         ;;
693     esac
694     THREADOBJS=posix-threads.lo
695     THREADH=posix-threads.h
696     # MIT pthreads doesn't seem to have the mutexattr functions.
697     # But for now we don't check for it.  We just assume you aren't
698     # using MIT pthreads.
699     AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT, 1, [Define if using POSIX threads that have the mutexattr functions.])
700
701     # If we're using the Boehm GC, then we happen to know that it
702     # defines _REENTRANT, so we don't bother.  Eww.
703     if test "$GC" != boehm; then
704        AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads])
705     fi
706     AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Required define if using POSIX threads])
707     ;;
708
709  win32)
710     THREADOBJS=win32-threads.lo
711     THREADH=win32-threads.h
712     ;;
713
714  none)
715     THREADOBJS=no-threads.lo
716     THREADH=no-threads.h
717     ;;
718 esac
719 AC_LINK_FILES(include/$THREADH, include/java-threads.h)
720 AC_SUBST(THREADLIBS)
721 AC_SUBST(THREADINCS)
722 AC_SUBST(THREADDEPS)
723 AC_SUBST(THREADOBJS)
724 AC_SUBST(THREADSPEC)
725 AC_SUBST(THREADLDFLAGS)
726 AC_SUBST(THREADCXXFLAGS)
727
728 if test -d sysdep; then true; else mkdir sysdep; fi
729 AC_LINK_FILES(sysdep/$sysdeps_dir/locks.h, sysdep/locks.h)
730
731 HASH_SYNC_SPEC=
732 # Hash synchronization is only useful with posix threads right now.
733 if test "$enable_hash_synchronization" = yes && test "$THREADS" != "none"; then
734    HASH_SYNC_SPEC=-fhash-synchronization
735    AC_DEFINE(JV_HASH_SYNCHRONIZATION, 1, [Define if hash synchronization is in use])
736 fi
737 AC_SUBST(HASH_SYNC_SPEC)
738
739
740 AM_CONDITIONAL(USING_GCC, test "$GCC" = yes)
741
742 # We're in the tree with gcc, and need to include some of its headers.
743 GCC_UNWIND_INCLUDE='-I$(libgcj_basedir)/../gcc'
744
745 # Figure out where generated headers like libgcj-config.h get installed.
746 changequote(,)dnl
747 gcc_version_trigger=${libgcj_basedir}/../gcc/version.c
748 gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([^\"]*\)\".*/\1/'`
749 gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
750 tool_include_dir='$(libdir)/gcc/$(target_noncanonical)/'${gcc_version}/include
751 changequote([,])dnl
752 AC_SUBST(tool_include_dir)
753 AC_SUBST(gcc_version)
754
755 if test "x${with_newlib}" = "xyes"; then
756    # We are being configured with a cross compiler.  AC_REPLACE_FUNCS
757    # may not work correctly, because the compiler may not be able to
758    # link executables.
759
760    # We assume newlib.  This lets us hard-code the functions we know
761    # we'll have.
762    AC_DEFINE(HAVE_MEMMOVE, 1, [Define if you have memmove.])
763    AC_DEFINE(HAVE_MEMCPY, 1, [Define if you have memcpy.])
764    AC_DEFINE(HAVE_STRERROR, 1, [Define if you have strerror.])
765    AC_DEFINE(HAVE_TIME, 1, [Define if you have time.])
766    AC_DEFINE(HAVE_GMTIME_R, 1, [Define if you have the 'gmtime_r' function])
767    AC_DEFINE(HAVE_LOCALTIME_R, 1, [Define if you have the 'localtime_r' function.])
768    AC_DEFINE(HAVE_USLEEP_DECL, 1, [Define if usleep is declared in <unistd.h>.])
769    dnl This is only for POSIX threads.
770    AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT, 1, [Define if using POSIX threads that have the mutexattr functions.])
771    dnl We also assume we are using gcc, which provides alloca.
772    AC_DEFINE(HAVE_ALLOCA)
773
774    dnl Assume we do not have getuid and friends.
775    AC_DEFINE(NO_GETUID, 1, [Define if getuid() and friends are missing.])
776    PLATFORMNET=NoNet
777 else
778    AC_CHECK_FUNCS(strerror ioctl select fstat open fsync sleep opendir)
779    AC_CHECK_FUNCS(gmtime_r localtime_r readdir_r getpwuid_r getcwd)
780    AC_CHECK_FUNCS(access stat mkdir rename rmdir unlink realpath utime chmod)
781    AC_CHECK_FUNCS(nl_langinfo setlocale)
782    AC_CHECK_FUNCS(inet_aton inet_addr, break)
783    AC_CHECK_FUNCS(inet_pton uname inet_ntoa)
784    AC_CHECK_FUNCS(fork execvp pipe sigaction ftruncate)
785    AC_CHECK_HEADERS(execinfo.h unistd.h dlfcn.h) 
786    AC_CHECK_FUNC(backtrace, [
787      case "$host" in
788        ia64-*-linux*)
789          # Has broken backtrace()
790          ;;
791        mips*-*-linux*)
792          # Has broken backtrace(), but we supply our own.
793          if test -d sysdep; then true; else mkdir -p sysdep; fi
794          EXTRA_CC_FILES="${EXTRA_CC_FILES} sysdep/dwarf2-backtrace.cc"
795          AC_DEFINE(HAVE_BACKTRACE, 1,
796            [Define if your platform has a working backtrace() function.])
797          ;;
798        *)
799          AC_DEFINE(HAVE_BACKTRACE, 1,
800            [Define if your platform has a working backtrace() function.])
801          ;;
802      esac
803    ], [
804      case "$host" in
805        *mingw*)
806          # Has backtrace() defined in libgcj itself
807          AC_DEFINE(HAVE_BACKTRACE, 1,
808            [Define if your platform has a working backtrace() function.])
809          ;;
810      esac
811    ])
812
813    AC_CHECK_LIB(dl, dladdr, [
814      if test "x${disable_dladdr}" = "xyes"; then
815        #Broken dladdr().
816        true
817      else
818        AC_DEFINE(HAVE_DLADDR, 1, [Define if you have dladdr()])
819      fi
820    ])
821    if test x"$build" = x"$host"; then
822      AC_CHECK_FILES(/proc/self/exe, [
823        AC_DEFINE(HAVE_PROC_SELF_EXE, 1, [Define if you have /proc/self/exe])])
824    else
825      case $host in
826      *-linux*)
827        AC_DEFINE(HAVE_PROC_SELF_EXE, 1, [Define if you have /proc/self/exe])
828        ;;
829      esac
830    fi
831
832    AM_ICONV
833    AM_LC_MESSAGES
834    AC_STRUCT_TIMEZONE
835
836    AC_CHECK_FUNCS(gethostbyname_r, [
837      AC_DEFINE(HAVE_GETHOSTBYNAME_R, 1,
838        [Define if you have the 'gethostbyname_r' function.])
839      # There are two different kinds of gethostbyname_r.
840      # We look for the one that returns `int'.
841      # Hopefully this check is robust enough.
842      AC_EGREP_HEADER(int.*gethostbyname_r, netdb.h, [
843        AC_DEFINE(GETHOSTBYNAME_R_RETURNS_INT, 1, [Define if gethostbyname_r returns 'int'.])])
844
845      case " $GCINCS " in
846      *" -D_REENTRANT "*) ;;
847      *)
848         dnl On DU4.0, gethostbyname_r is only declared with -D_REENTRANT
849         AC_CACHE_CHECK([whether gethostbyname_r declaration requires -D_REENTRANT],
850         [libjava_cv_gethostbyname_r_needs_reentrant],
851         [ AC_LANG_SAVE
852           AC_LANG_CPLUSPLUS
853           AC_TRY_COMPILE([#include <netdb.h>],
854             [gethostbyname_r("", 0, 0);],
855             [libjava_cv_gethostbyname_r_needs_reentrant=no], [dnl
856                 CPPFLAGS_SAVE="$CPPFLAGS"
857                 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
858                 AC_TRY_COMPILE([#include <netdb.h>], [gethostbyname_r("", 0, 0);],
859                     [libjava_cv_gethostbyname_r_needs_reentrant=yes],
860                     [libjava_cv_gethostbyname_r_needs_reentrant=fail])
861                 CPPFLAGS="$CPPFLAGS_SAVE"
862           ])
863           AC_LANG_RESTORE
864         ])
865         if test "x$libjava_cv_gethostbyname_r_needs_reentrant" = xyes; then
866           AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads])
867         fi
868      ;;
869      esac
870
871      AC_CACHE_CHECK([for struct hostent_data],
872         [libjava_cv_struct_hostent_data], [dnl
873         AC_TRY_COMPILE([
874 #if GETHOSTBYNAME_R_NEEDS_REENTRANT && !defined(_REENTRANT)
875 # define _REENTRANT 1
876 #endif
877 #include <netdb.h>], [struct hostent_data data;],
878           [libjava_cv_struct_hostent_data=yes],
879           [libjava_cv_struct_hostent_data=no])])
880      if test "x$libjava_cv_struct_hostent_data" = xyes; then
881        AC_DEFINE(HAVE_STRUCT_HOSTENT_DATA, 1,
882          [Define if struct hostent_data is defined in netdb.h])
883      fi
884    ])
885
886    # FIXME: libjava source code expects to find a prototype for
887    # gethostbyaddr_r in netdb.h.  The outer check ensures that
888    # HAVE_GETHOSTBYADDR_R will not be defined if the prototype fails
889    # to exist where expected.  (The root issue: AC_CHECK_FUNCS assumes C
890    # linkage check is enough, yet C++ code requires proper prototypes.)
891    AC_EGREP_HEADER(gethostbyaddr_r, netdb.h, [
892    AC_CHECK_FUNCS(gethostbyaddr_r, [
893      AC_DEFINE(HAVE_GETHOSTBYADDR_R, 1,
894        [Define if you have the 'gethostbyaddr_r' function.])
895      # There are two different kinds of gethostbyaddr_r.
896      # We look for the one that returns `int'.
897      # Hopefully this check is robust enough.
898      AC_EGREP_HEADER(int.*gethostbyaddr_r, netdb.h, [
899        AC_DEFINE(GETHOSTBYADDR_R_RETURNS_INT, 1,
900          [Define if gethostbyaddr_r returns 'int'.])])])])
901
902    AC_CHECK_FUNCS(gethostname, [
903      AC_DEFINE(HAVE_GETHOSTNAME, 1,
904        [Define if you have the 'gethostname' function.])
905      AC_EGREP_HEADER(gethostname, unistd.h, [
906        AC_DEFINE(HAVE_GETHOSTNAME_DECL, 1,
907          [Define if gethostname is declared in <unistd.h>.])])])
908
909    AC_CHECK_FUNCS(usleep, [
910      AC_EGREP_HEADER(usleep, unistd.h, [
911        AC_DEFINE(HAVE_USLEEP_DECL, 1,
912           [Define if usleep is declared in <unistd.h>.])])])
913
914    # Look for these functions in the thread library, but only bother
915    # if using POSIX threads.
916    if test "$THREADS" = posix; then
917       save_LIBS="$LIBS"
918       LIBS="$LIBS $THREADLIBS"
919       # Some POSIX thread systems don't have pthread_mutexattr_settype.
920       # E.g., Solaris.
921       AC_CHECK_FUNCS(pthread_mutexattr_settype pthread_mutexattr_setkind_np)
922
923       # Look for sched_yield.  Up to Solaris 2.6, it is in libposix4, since
924       # Solaris 7 the name librt is preferred.
925       AC_CHECK_FUNCS(sched_yield, , [
926         AC_CHECK_LIB(rt, sched_yield, [
927           AC_DEFINE(HAVE_SCHED_YIELD)
928           THREADLIBS="$THREADLIBS -lrt"
929           THREADSPEC="$THREADSPEC -lrt"], [
930           AC_CHECK_LIB(posix4, sched_yield, [
931             AC_DEFINE(HAVE_SCHED_YIELD)
932             THREADLIBS="$THREADLIBS -lposix4"
933             THREADSPEC="$THREADSPEC -lposix4"])])])
934       LIBS="$save_LIBS"
935
936       # We can save a little space at runtime if the mutex has m_count
937       # or __m_count.  This is a nice hack for Linux.
938       AC_TRY_COMPILE([#include <pthread.h>], [
939           extern pthread_mutex_t *mutex; int q = mutex->m_count;
940         ], AC_DEFINE(PTHREAD_MUTEX_HAVE_M_COUNT, 1,
941              [Define if pthread_mutex_t has m_count member.]), [
942         AC_TRY_COMPILE([#include <pthread.h>], [
943             extern pthread_mutex_t *mutex; int q = mutex->__m_count;
944           ], AC_DEFINE(PTHREAD_MUTEX_HAVE___M_COUNT, 1,
945             [Define if pthread_mutex_t has __m_count member.]))])
946    fi
947
948    # We require a way to get the time.
949    time_found=no
950    AC_CHECK_FUNCS(gettimeofday time ftime, time_found=yes)
951    if test "$time_found" = no; then
952       AC_MSG_ERROR([no function found to get the time])
953    fi
954
955    AC_CHECK_FUNCS(memmove)
956
957    # We require memcpy.
958    memcpy_found=no
959    AC_CHECK_FUNCS(memcpy, memcpy_found=yes)
960    if test "$memcpy_found" = no; then
961       AC_MSG_ERROR([memcpy is required])
962    fi
963
964    AC_CHECK_LIB(dl, dlopen, [
965        AC_DEFINE(HAVE_DLOPEN, 1, [Define if dlopen is available])])
966
967    # Some library-finding code we stole from Tcl.
968    #--------------------------------------------------------------------
969    #    Check for the existence of the -lsocket and -lnsl libraries.
970    #    The order here is important, so that they end up in the right
971    #    order in the command line generated by make.  Here are some
972    #    special considerations:
973    #    1. Use "connect" and "accept" to check for -lsocket, and
974    #       "gethostbyname" to check for -lnsl.
975    #    2. Use each function name only once:  can't redo a check because
976    #       autoconf caches the results of the last check and won't redo it.
977    #    3. Use -lnsl and -lsocket only if they supply procedures that
978    #       aren't already present in the normal libraries.  This is because
979    #       IRIX 5.2 has libraries, but they aren't needed and they're
980    #       bogus:  they goof up name resolution if used.
981    #    4. On some SVR4 systems, can't use -lsocket without -lnsl too.
982    #       To get around this problem, check for both libraries together
983    #       if -lsocket doesn't work by itself.
984    #--------------------------------------------------------------------
985
986    AC_CACHE_CHECK([for socket libraries], gcj_cv_lib_sockets,
987     [gcj_cv_lib_sockets=
988      gcj_checkBoth=0
989      unset ac_cv_func_connect
990      AC_CHECK_FUNC(connect, gcj_checkSocket=0, gcj_checkSocket=1)
991      if test "$gcj_checkSocket" = 1; then
992          unset ac_cv_func_connect
993          AC_CHECK_LIB(socket, main, gcj_cv_lib_sockets="-lsocket",
994                       gcj_checkBoth=1)
995      fi
996      if test "$gcj_checkBoth" = 1; then
997          gcj_oldLibs=$LIBS
998          LIBS="$LIBS -lsocket -lnsl"
999          unset ac_cv_func_accept
1000          AC_CHECK_FUNC(accept,
1001                        [gcj_checkNsl=0
1002                         gcj_cv_lib_sockets="-lsocket -lnsl"])
1003          unset ac_cv_func_accept
1004          LIBS=$gcj_oldLibs
1005      fi
1006      unset ac_cv_func_gethostbyname
1007      gcj_oldLibs=$LIBS
1008      LIBS="$LIBS $gcj_cv_lib_sockets"
1009      AC_CHECK_FUNC(gethostbyname, ,
1010                    [AC_CHECK_LIB(nsl, main,
1011                                  [gcj_cv_lib_sockets="$gcj_cv_lib_sockets -lnsl"])])
1012      unset ac_cv_func_gethostbyname
1013      LIBS=$gcj_oldLIBS
1014    ])
1015    SYSTEMSPEC="$SYSTEMSPEC $gcj_cv_lib_sockets"
1016
1017    if test "$with_system_zlib" = yes; then
1018       AC_CHECK_LIB(z, deflate, ZLIBSPEC=-lz, ZLIBSPEC=)
1019    fi
1020
1021    # Test for Gtk stuff, if asked for.
1022    if test "$use_gtk_awt" = yes; then
1023       PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.2)
1024       AC_SUBST(GTK_CFLAGS)
1025       AC_SUBST(GTK_LIBS)
1026
1027       PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.2 gthread-2.0 >= 2.2)
1028       AC_SUBST(GLIB_CFLAGS)
1029       AC_SUBST(GLIB_LIBS)
1030
1031       PKG_CHECK_MODULES(LIBART, libart-2.0 >= 2.1)
1032       AC_SUBST(LIBART_CFLAGS)
1033       AC_SUBST(LIBART_LIBS)
1034    fi
1035
1036    # On Solaris, and maybe other architectures, the Boehm collector
1037    # requires -ldl.
1038    if test "$GC" = boehm; then
1039       AC_CHECK_LIB(dl, main, SYSTEMSPEC="$SYSTEMSPEC -ldl")
1040    fi
1041 fi
1042
1043 if test -z "${with_multisubdir}"; then
1044    builddotdot=.
1045 else
1046 changequote(<<,>>)
1047    builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`
1048 changequote([,])
1049 fi
1050
1051 NATIVE=yes
1052
1053 # Which gcj do we use?
1054 which_gcj=default
1055 built_gcc_dir="`cd ${builddotdot}/../../gcc && ${PWDCMD-pwd}`"
1056 if test -n "${with_cross_host}"; then
1057   # We are being configured with a cross compiler. We can't
1058   # use ac_exeext, because that is for the target platform.
1059   NATIVE=no
1060   cross_host_exeext=
1061   case "${with_cross_host}" in
1062      *mingw* | *cygwin*)
1063          cross_host_exeext=.exe
1064      ;;
1065   esac
1066   if test -x "${built_gcc_dir}/gcj${cross_host_exeext}"; then
1067      if test x"$build_noncanonical" = x"$with_cross_host"; then
1068         # Ordinary cross (host!=target and host=build)
1069         which_gcj=built
1070      else
1071         # Canadian cross (host!=target and host!=build)
1072         which_gcj=cross
1073      fi
1074   else
1075      which_gcj=cross
1076   fi
1077 else
1078   # We are being configured with a native or crossed-native compiler
1079   if test -x "${built_gcc_dir}/gcj${ac_exeext}"; then
1080      if test x"$build" = x"$host"; then
1081         # True native build (host=target and host=build)
1082         which_gcj=built
1083      else
1084         # Crossed-native build (host=target and host!=build)
1085         which_gcj=cross
1086      fi
1087   else
1088      which_gcj=path
1089   fi
1090 fi
1091 case "${which_gcj}" in
1092    built)
1093       GCJ="$built_gcc_dir/gcj -B`${PWDCMD-pwd}`/ -B$built_gcc_dir/"
1094       GCJH='$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh'
1095       ZIP='$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar'
1096    ;;
1097    cross)
1098       if test "x${with_newlib}" = "xyes"; then
1099          # FIXME (comment): Why is this needed?
1100          GCC_UNWIND_INCLUDE=
1101          GCJ="${target_noncanonical}-gcj"
1102       else
1103          GCJ="${target_noncanonical}-gcj -B`${PWDCMD-pwd}`/"
1104       fi
1105       ZIP=jar
1106       GCJH='$(target_noncanonical)-gcjh'
1107    ;;
1108    path)
1109       GCJ="gcj -B`${PWDCMD-pwd}`/"
1110       ## In this case, gcj is found outside the build tree.  However, zip is
1111       ## found in the build tree.
1112       ZIP='$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/fastjar'
1113       GCJH=gcjh
1114    ;;
1115 esac
1116
1117 AC_SUBST(GCJH)
1118 AC_SUBST(ZIP)
1119
1120 # Create it, so that compile/link tests don't fail
1121 test -f libgcj.spec || touch libgcj.spec
1122
1123 # We must search the source tree for java.lang, since we still don't
1124 # have libgcj.jar nor java/lang/*.class
1125 GCJ_SAVE_CPPFLAGS=$CPPFLAGS
1126 CPPFLAGS="$CPPFLAGS -I`${PWDCMD-pwd}` -I`cd $srcdir && ${PWDCMD-pwd}`"
1127
1128 # Since some classes depend on this one, we need its source available
1129 # before we can do any GCJ compilation test :-(
1130 if test ! -f gnu/classpath/Configuration.java; then
1131   test -d gnu || mkdir gnu
1132   test -d gnu/classpath || mkdir gnu/classpath
1133   sed -e 's,@LIBGCJDEBUG@,$LIBGCJDEBUG,' \
1134       -e 's,@TOOLKIT@,$TOOLKIT,' \
1135         < $srcdir/gnu/classpath/Configuration.java.in \
1136         > gnu/classpath/Configuration.java
1137   # We do not want to redirect the output of the grep below to /dev/null,
1138   # but we add /dev/null to the input list so that grep will print the
1139   # filename of Configuration.java in case it finds any matches.
1140   if grep @ gnu/classpath/Configuration.java /dev/null; then
1141     AC_MSG_ERROR([configure.in is missing the substitutions above])
1142   fi
1143 fi
1144
1145 LT_AC_PROG_GCJ
1146
1147 CPPFLAGS=$GCJ_SAVE_CPPFLAGS
1148
1149 AC_COMPILE_CHECK_SIZEOF(void *)
1150
1151 ZLIBS=
1152 SYS_ZLIBS=
1153 ZINCS=
1154
1155 if test -z "$ZLIBSPEC"; then
1156    # Use zlib from the GCC tree.
1157    ZINCS='-I$(top_srcdir)/../zlib'
1158    ZLIBS=../zlib/libzgcj_convenience.la
1159 else
1160    # System's zlib.
1161    SYS_ZLIBS="$ZLIBSPEC"
1162 fi
1163 AC_SUBST(ZLIBS)
1164 AC_SUBST(SYS_ZLIBS)
1165 AC_SUBST(ZINCS)
1166 AC_SUBST(DIVIDESPEC)
1167 AC_SUBST(CHECKREFSPEC)
1168 AC_SUBST(EXCEPTIONSPEC)
1169 AC_SUBST(IEEESPEC)
1170
1171 AM_CONDITIONAL(NATIVE, test "$NATIVE" = yes)
1172 AM_CONDITIONAL(NEEDS_DATA_START, test "$NEEDS_DATA_START" = yes && test "$NATIVE" = yes)
1173 AC_SUBST(GCC_UNWIND_INCLUDE)
1174
1175 # Process the option "--enable-version-specific-runtime-libs"
1176 # Calculate toolexeclibdir
1177 case ${version_specific_libs} in
1178   yes)
1179     # Need the gcc compiler version to know where to install libraries
1180     # and header files if --enable-version-specific-runtime-libs option
1181     # is selected.
1182     includedir='${libdir}/gcc/${target_noncanonical}/'$gcc_version/include/
1183     toolexecdir='$(libdir)/gcc/$(target_noncanonical)'
1184     toolexecmainlibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
1185     toolexeclibdir=$toolexecmainlibdir
1186     ;;
1187   no)
1188     if test -n "$with_cross_host" &&
1189        test x"$with_cross_host" != x"no"; then
1190       # Install a library built with a cross compiler in tooldir, not libdir.
1191       toolexecdir='$(exec_prefix)/$(target_noncanonical)'
1192       toolexecmainlibdir='$(toolexecdir)/lib'
1193     else
1194       toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
1195       toolexecmainlibdir='$(libdir)'
1196     fi
1197     multi_os_directory=`$CC -print-multi-os-directory`
1198     case $multi_os_directory in
1199       .) toolexeclibdir=$toolexecmainlibdir ;; # Avoid trailing /.
1200       *) toolexeclibdir=$toolexecmainlibdir/$multi_os_directory ;;
1201     esac
1202     ;;
1203 esac
1204 AC_SUBST(toolexecdir)
1205 AC_SUBST(toolexecmainlibdir)
1206 AC_SUBST(toolexeclibdir)
1207
1208 # Determine gcj version number.
1209 changequote(<<,>>)
1210 gcjversion=`$GCJ -v 2>&1 | sed -n 's/^.*version \([^ ]*\).*$/\1/p'`
1211 changequote([,])
1212 GCJVERSION=$gcjversion
1213 AC_SUBST(GCJVERSION)
1214 AC_DEFINE_UNQUOTED(GCJVERSION, "$GCJVERSION", [Short GCJ version ID])
1215
1216 dnl We check for sys/filio.h because Solaris 2.5 defines FIONREAD there.
1217 dnl On that system, sys/ioctl.h will not include sys/filio.h unless
1218 dnl BSD_COMP is defined; just including sys/filio.h is simpler.
1219 AC_CHECK_HEADERS(unistd.h bstring.h sys/time.h sys/types.h fcntl.h sys/ioctl.h sys/filio.h sys/stat.h sys/select.h sys/socket.h netinet/in.h arpa/inet.h netdb.h net/if.h pwd.h sys/config.h stdint.h langinfo.h locale.h)
1220 dnl We avoid AC_HEADER_DIRENT since we really only care about dirent.h
1221 dnl for now.  If you change this, you also must update natFile.cc.
1222 AC_CHECK_HEADERS(dirent.h)
1223 AC_CHECK_HEADERS(inttypes.h, [
1224     AC_DEFINE(HAVE_INTTYPES_H, 1, [Define if <inttypes.h> is available])
1225     AC_DEFINE(JV_HAVE_INTTYPES_H, 1, [Define if <inttypes.h> is available])
1226 ])
1227 AC_HEADER_SYS_WAIT
1228
1229 AC_CHECK_TYPE([ssize_t], [int])
1230
1231 AC_MSG_CHECKING([for in_addr_t])
1232 AC_TRY_COMPILE([#include <sys/types.h>
1233 #if STDC_HEADERS
1234 #include <stdlib.h>
1235 #include <stddef.h>
1236 #endif
1237 #if HAVE_NETINET_IN_H
1238 #include <netinet/in.h>
1239 #endif], [in_addr_t foo;],
1240   [AC_DEFINE(HAVE_IN_ADDR_T, 1,
1241      [Define to 1 if 'in_addr_t' is defined in sys/types.h or netinet/in.h.])
1242    AC_MSG_RESULT(yes)],
1243   [AC_MSG_RESULT(no)])
1244
1245 AC_MSG_CHECKING([whether struct ip_mreq is in netinet/in.h])
1246 AC_TRY_COMPILE([#include <netinet/in.h>], [struct ip_mreq mreq;],
1247   [AC_DEFINE(HAVE_STRUCT_IP_MREQ, 1,
1248      [Define if struct ip_mreq is defined in netinet/in.h.])
1249    AC_MSG_RESULT(yes)],
1250   [AC_MSG_RESULT(no)])
1251
1252 AC_MSG_CHECKING([whether struct ipv6_mreq is in netinet/in.h])
1253 AC_TRY_COMPILE([#include <netinet/in.h>], [struct ipv6_mreq mreq6;],
1254   [AC_DEFINE(HAVE_STRUCT_IPV6_MREQ, 1,
1255      [Define if struct ipv6_mreq is defined in netinet/in.h.])
1256    AC_MSG_RESULT(yes)],
1257   [AC_MSG_RESULT(no)])
1258
1259 AC_MSG_CHECKING([whether struct sockaddr_in6 is in netinet/in.h])
1260 AC_TRY_COMPILE([#include <netinet/in.h>], [struct sockaddr_in6 addr6;],
1261   [AC_DEFINE(HAVE_INET6, 1,
1262      [Define if inet6 structures are defined in netinet/in.h.])
1263    AC_MSG_RESULT(yes)],
1264   [AC_MSG_RESULT(no)])
1265
1266 AC_MSG_CHECKING([for socklen_t in sys/socket.h])
1267 AC_TRY_COMPILE([#define _POSIX_PII_SOCKET
1268 #include <sys/types.h>
1269 #include <sys/socket.h>], [socklen_t x = 5;],
1270   [AC_DEFINE(HAVE_SOCKLEN_T, 1, [Define it socklen_t typedef is in sys/socket.h.])
1271    AC_MSG_RESULT(yes)],
1272   [AC_MSG_RESULT(no)])
1273
1274 AC_MSG_CHECKING([for tm_gmtoff in struct tm])
1275 AC_TRY_COMPILE([#include <time.h>], [struct tm tim; tim.tm_gmtoff = 0;],
1276   [AC_DEFINE(STRUCT_TM_HAS_GMTOFF, 1, [Define if struct tm has tm_gmtoff field.])
1277    AC_MSG_RESULT(yes)],
1278   [AC_MSG_RESULT(no)
1279    AC_MSG_CHECKING([for global timezone variable])
1280    dnl FIXME: we don't want a link check here because that won't work
1281    dnl when cross-compiling.  So instead we make an assumption that
1282    dnl the header file will mention timezone if it exists.
1283    dnl Don't find the win32 function timezone
1284    AC_TRY_COMPILE([#include <time.h>], [void i(){long z2 = 2*timezone;}],
1285      [AC_DEFINE(HAVE_TIMEZONE, 1, [Define if global 'timezone' exists.])
1286       AC_MSG_RESULT(yes)],
1287      [AC_MSG_RESULT(no)
1288        AC_MSG_CHECKING([for global _timezone variable])
1289        dnl FIXME: As above, don't want link check
1290        AC_TRY_COMPILE([#include <time.h>], [long z2 = _timezone;],
1291          [AC_DEFINE(HAVE_UNDERSCORE_TIMEZONE, 1,
1292             [Define if your platform has the global _timezone variable.])
1293           AC_MSG_RESULT(yes)],
1294           [AC_MSG_RESULT(no)])])])
1295
1296 AC_FUNC_ALLOCA
1297 AC_FUNC_MMAP
1298
1299 AC_CHECK_PROGS(PERL, perl, false)
1300
1301 SYSDEP_SOURCES=
1302 SIGNAL_HANDLER_AUX=
1303
1304 case "${host}" in
1305  i?86-*-linux*)
1306     SIGNAL_HANDLER=include/i386-signal.h
1307     ;;
1308  sparc*-sun-solaris*)
1309     SIGNAL_HANDLER=include/sparc-signal.h
1310     ;;
1311 # ia64-*)
1312 #    SYSDEP_SOURCES=sysdep/ia64.c
1313 #    test -d sysdep || mkdir sysdep
1314 #    ;;
1315  hppa*-*-linux*)
1316     SIGNAL_HANDLER=include/pa-signal.h
1317     ;;
1318  ia64-*-linux*)
1319     SIGNAL_HANDLER=include/dwarf2-signal.h
1320     ;;
1321  powerpc*-*-linux*)
1322     SIGNAL_HANDLER=include/powerpc-signal.h
1323     ;;
1324  alpha*-*-linux*)
1325     SIGNAL_HANDLER=include/dwarf2-signal.h
1326     ;;
1327  s390*-*-linux*)
1328     SIGNAL_HANDLER=include/s390-signal.h
1329     ;;
1330  x86_64*-*-linux*)
1331     SIGNAL_HANDLER=include/x86_64-signal.h
1332     SIGNAL_HANDLER_AUX=include/i386-signal.h
1333     ;;
1334  sparc*-*-linux*)
1335     SIGNAL_HANDLER=include/dwarf2-signal.h
1336     ;;
1337  sh-*-linux* | sh[[34]]*-*-linux*)
1338     SIGNAL_HANDLER=include/dwarf2-signal.h
1339     ;;
1340  *mingw*)
1341     SIGNAL_HANDLER=include/win32-signal.h
1342     ;;
1343  mips*-*-linux*)
1344     SIGNAL_HANDLER=include/mips-signal.h
1345     ;;
1346  *-*-darwin*)
1347     SIGNAL_HANDLER=include/darwin-signal.h
1348     ;;
1349  *)
1350     SIGNAL_HANDLER=include/default-signal.h
1351     ;;
1352 esac
1353
1354 # If we're using sjlj exceptions, forget what we just learned.
1355 if test "$enable_sjlj_exceptions" = yes; then
1356    SIGNAL_HANDLER=include/default-signal.h
1357    SIGNAL_HANDLER_AUX=
1358 fi
1359
1360 # Define here any compiler flags that you need in order to make backtrace() work.
1361 BACKTRACESPEC=
1362 case "${host}" in
1363  x86_64*-*-linux*|i?86-*)
1364     BACKTRACESPEC=-fno-omit-frame-pointer
1365     ;;
1366 esac
1367 AC_SUBST(BACKTRACESPEC)
1368
1369 AC_SUBST(SYSDEP_SOURCES)
1370
1371 if test -z "$SIGNAL_HANDLER_AUX"; then
1372   SIGNAL_HANDLER_AUX=$SIGNAL_HANDLER
1373 fi
1374
1375 AC_LINK_FILES($SIGNAL_HANDLER $SIGNAL_HANDLER_AUX,
1376               include/java-signal.h include/java-signal-aux.h)
1377
1378 if test "${multilib}" = "yes"; then
1379   multilib_arg="--enable-multilib"
1380 else
1381   multilib_arg=
1382 fi
1383
1384
1385
1386 here=`${PWDCMD-pwd}`
1387 AC_SUBST(here)
1388
1389 # We get this from the environment.
1390 AC_SUBST(GCJFLAGS)
1391
1392 AC_OUTPUT(Makefile libgcj.pc libgcj.spec libgcj-test.spec gnu/classpath/Configuration.java gcj/Makefile include/Makefile testsuite/Makefile,
1393 [# Only add multilib support code if we just rebuilt top-level Makefile.
1394 case " $CONFIG_FILES " in
1395  *" Makefile "*)
1396    LD="${ORIGINAL_LD_FOR_MULTILIBS}"
1397    ac_file=Makefile . ${libgcj_basedir}/../config-ml.in
1398    ;;
1399 esac
1400
1401 # Make subdirectories and `.d' files.  Look in both srcdir and
1402 # builddir for the .java files.
1403 h=`${PWDCMD-pwd}`
1404 : > deps.mk
1405 ( (cd $srcdir && find . \( -name '*.java' -o -name '*.cc' -o -name '*.c' \) -print) ;
1406   find . \( -name '*.java' -o -name '*.cc' -o -name '*.c' \) -print) | \
1407    fgrep -v testsuite | \
1408    sed -e 's/\.java/.d/'\;'s/\.cc/.d/'\;'s/\.c/.d/' | \
1409    while read f; do
1410       echo "include $f" >> deps.mk
1411       test -f $f || {
1412 changequote(<<,>>)
1413          d=`echo $f | sed -e 's,/[^/]*$,,'`
1414 changequote([,])
1415          if test ! -d $d; then
1416            $libgcj_basedir/../mkinstalldirs $d
1417          fi;
1418          echo > $f
1419       }
1420    done
1421 ],
1422 srcdir=${srcdir}
1423 host=${host}
1424 target=${target}
1425 with_multisubdir=${with_multisubdir}
1426 ac_configure_args="${multilib_arg} ${ac_configure_args}"
1427 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
1428 libgcj_basedir=${libgcj_basedir}
1429 CC="${CC}"
1430 CXX="${CXX}"
1431 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
1432 )