OSDN Git Service

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