OSDN Git Service

* config/sparc/sparc.c (function_value): Treat all non-record
[pf3gnuchains/gcc-fork.git] / libjava / configure.in
1 dnl Process this with autoconf to create configure
2 AC_INIT(java/lang/System.java)
3
4 dnl Can't be done in LIBGCJ_CONFIGURE because that confuses automake.
5 AC_CONFIG_AUX_DIR(..)
6
7 AC_CANONICAL_SYSTEM
8 AC_PROG_LN_S
9
10 dnl We use these options to decide which functions to include.
11 AC_ARG_WITH(target-subdir,
12 [  --with-target-subdir=SUBDIR
13                            configuring in a subdirectory])
14 AC_ARG_WITH(cross-host,
15 [  --with-cross-host=HOST  configuring with a cross compiler])
16
17 LIBGCJ_CONFIGURE(.)
18
19 AM_CONFIG_HEADER(include/config.h)
20
21 # Only use libltdl for native builds.
22 if test -z "${with_cross_host}"; then
23    AC_LIBLTDL_CONVENIENCE
24    AC_LIBTOOL_DLOPEN
25    DIRLTDL=libltdl
26    AC_DEFINE(USE_LTDL)
27    # Sigh.  Libtool's macro doesn't do the right thing.
28    INCLTDL="-I\$(top_srcdir)/libltdl $INCLTDL"
29 fi
30 AC_SUBST(INCLTDL)
31 AC_SUBST(LIBLTDL)
32 AC_SUBST(DIRLTDL)
33 AM_PROG_LIBTOOL
34 AC_CONFIG_SUBDIRS($DIRLTDL)
35
36 if test -z "$with_target_subdir" || test "$with_target_subdir" = "."; then
37    COMPPATH=.
38 else
39    COMPPATH=..
40 fi
41 AC_SUBST(COMPPATH)
42
43 dnl The -no-testsuite modules omit the test subdir.
44 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
45
46 dnl See whether the user prefers size or speed for Character.
47 dnl The default is size.
48 AC_ARG_ENABLE(fast-character,
49 [  --enable-fast-character prefer speed over size for Character],
50 # Nothing
51 , AC_DEFINE(COMPACT_CHARACTER))
52
53 dnl Should the runtime set system properties by examining the 
54 dnl environment variable GCJ_PROPERTIES?
55 AC_ARG_ENABLE(getenv-properties,
56 [  --disable-getenv-properties
57                           don't set system properties from GCJ_PROPERTIES])
58
59 dnl Whether GCJ_PROPERTIES is used depends on the target.
60 if test -n "$enable_getenv_properties"; then
61    enable_getenv_properties=${enable_getenv_properties_default-yes}
62 fi
63 if test "$enable_getenv_properties" = no; then
64    AC_DEFINE(DISABLE_GETENV_PROPERTIES)
65 fi
66
67 dnl See if the user has requested runtime debugging.
68 LIBGCJDEBUG="false"
69 AC_SUBST(LIBGCJDEBUG)
70 AC_ARG_ENABLE(libgcj-debug,
71 [  --enable-libgcj-debug   enable runtime debugging code],
72   if test "$enable_libgcj_debug" = yes; then
73     AC_DEFINE(DEBUG)
74     LIBGCJDEBUG="true"
75   fi)
76
77 dnl See if the user has the interpreter included.
78 AC_ARG_ENABLE(interpreter,
79 [  --enable-interpreter    enable interpreter],
80   if test "$enable_interpreter" = yes; then
81     # This can also be set in configure.host.
82     libgcj_interpreter=yes
83   elif test "$enable_interpreter" = no; then
84     libgcj_interpreter=no
85   fi)
86
87 if test "$libgcj_interpreter" = yes; then
88    AC_DEFINE(INTERPRETER)
89 fi
90
91 EXCEPTIONSPEC=
92 dnl See if we should use setjmp/longjmp exceptions
93 AC_ARG_ENABLE(sjlj-exceptions,
94 [  --enable-sjlj-exceptions    use setjmp/longjmp exceptions],
95   if test "$enable_sjlj_exceptions" = yes; then
96      # This can be set in configure.host.
97      libgcj_sjlj=yes
98   fi)
99
100 if test "$libgcj_sjlj" = yes; then
101    EXCEPTIONSPEC="-fsjlj-exceptions"
102    AC_DEFINE(SJLJ_EXCEPTIONS)
103 fi
104
105 AC_MSG_CHECKING([for data_start])
106 LIBDATASTARTSPEC=
107 NEEDS_DATA_START=
108 AC_TRY_LINK([extern int data_start;], [return ((int) &data_start);],
109   [AC_MSG_RESULT(found it)],
110   [LIBDATASTARTSPEC="-u data_start libgcjdata.a%s"
111    NEEDS_DATA_START=yes 
112    AC_MSG_RESULT(missing)])
113 AC_SUBST(LIBDATASTARTSPEC)
114
115 dnl See if the user wants to disable java.net.  This is the mildly
116 dnl ugly way that we admit that target-side configuration sucks.
117 AC_ARG_ENABLE(java-net,
118 [  --disable-java-net      disable java.net])
119
120 dnl Whether java.net is built by default can depend on the target.
121 if test -n "$enable_java_net"; then
122    enable_java_net=${enable_java_net_default-yes}
123 fi
124 if test "$enable_java_net" = no; then
125    AC_DEFINE(DISABLE_JAVA_NET)
126 fi
127
128 dnl See if the user wants to disable JVMPI support.
129 AC_ARG_ENABLE(jvmpi,
130 [  --disable-jvmpi         disable JVMPI support])
131
132 if test "$enable_jvmpi" != no; then
133     AC_DEFINE(ENABLE_JVMPI)
134 fi
135
136 dnl If the target is an eCos system, use the appropriate eCos
137 dnl I/O routines.
138 dnl FIXME: this should not be a local option but a global target
139 dnl system; at present there is no eCos target.
140 TARGET_ECOS="no"
141 AC_ARG_WITH(ecos,
142 [  --with-ecos             enable runtime eCos target support],
143 TARGET_ECOS="$with_ecos"
144 )
145
146 case "$TARGET_ECOS" in
147    no)
148       FILE_DESCRIPTOR=natFileDescriptorPosix.cc
149       PROCESS=${PROCESS-Posix}
150       ;;
151    *)
152       FILE_DESCRIPTOR=natFileDescriptorEcos.cc
153       PROCESS=Ecos
154       AC_DEFINE(ECOS)
155       ;;
156 esac
157
158 AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED))
159 AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED))
160 AC_EGREP_HEADER(u_int32_t, sys/types.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED))
161 AC_EGREP_HEADER(u_int32_t, sys/config.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED))
162
163
164 dnl These may not be defined in a non-ANS conformant embedded system.
165 dnl FIXME: Should these case a runtime exception in that case?
166 AC_EGREP_HEADER(mktime, time.h, AC_DEFINE(HAVE_MKTIME))
167 AC_EGREP_HEADER(localtime, time.h, AC_DEFINE(HAVE_LOCALTIME))
168
169 dnl Create the subdirectory for natFileDescriptor.cc, or the attempt
170 dnl to create the link will fail.
171 test -d java || mkdir java
172 test -d java/io || mkdir java/io
173 test -d gnu || mkdir gnu
174 AC_LINK_FILES(java/io/$FILE_DESCRIPTOR, java/io/natFileDescriptor.cc)
175
176 dnl Likewise for ConcreteProcess.java and natConcreteProcess.cc.
177 test -d java/lang || mkdir java/lang
178 AC_LINK_FILES(java/lang/${PROCESS}Process.java, java/lang/ConcreteProcess.java)
179 AC_LINK_FILES(java/lang/nat${PROCESS}Process.cc, java/lang/natConcreteProcess.cc)
180
181 SYSTEMSPEC=
182 AC_SUBST(SYSTEMSPEC)
183
184 LIBGCJTESTSPEC="-L`pwd`/.libs -rpath `pwd`/.libs"
185 AC_SUBST(LIBGCJTESTSPEC)
186
187 AC_ARG_WITH(system-zlib,
188 [  --with-system-zlib      use installed libz])
189 ZLIBSPEC=
190 AC_SUBST(ZLIBSPEC)
191 ZLIBTESTSPEC=
192 AC_SUBST(ZLIBTESTSPEC)
193
194 dnl FIXME: this should be _libs on some hosts.
195 libsubdir=.libs
196
197 dnl Allow the GC to be disabled.  Can be useful when debugging.
198 AC_MSG_CHECKING([for garbage collector to use])
199 AC_ARG_ENABLE(java-gc,
200 changequote(<<,>>)dnl
201 <<  --enable-java-gc=TYPE   choose garbage collector [boehm]>>,
202 changequote([,])
203   GC=$enableval,
204   GC=boehm)
205 GCLIBS=
206 GCINCS=
207 GCDEPS=
208 GCOBJS=
209 GCSPEC=
210 JC1GCSPEC=
211 GCTESTSPEC=
212 case "$GC" in
213  boehm)
214     AC_MSG_RESULT(boehm)
215     GCDEPS='$(top_builddir)/../boehm-gc/libgcjgc.la'
216     # We include the path to the boehm-gc build directory.
217     # See Makefile.am to understand why.
218     GCLIBS="$GCDEPS -L\$(here)/../boehm-gc/$libsubdir"
219     GCINCS='-I$(top_srcdir)/../boehm-gc -I$(top_builddir)/../boehm-gc'
220     GCSPEC='-lgcjgc'
221     JC1GCSPEC='-fuse-boehm-gc'
222     GCTESTSPEC="-L`pwd`/../boehm-gc/.libs -rpath `pwd`/../boehm-gc/.libs"
223     dnl We also want to pick up some cpp flags required when including
224     dnl boehm-config.h.  Yuck.
225     GCINCS="$GCINCS `cat ../boehm-gc/boehm-cflags`"
226     GCOBJS=boehm.lo
227     GCHDR=boehm-gc.h
228     dnl The POSIX thread support needs to know this.
229     AC_DEFINE(HAVE_BOEHM_GC)
230     ;;
231  no)
232     AC_MSG_RESULT(none)
233     GCOBJS=nogc.lo
234     GCHDR=no-gc.h
235     ;;
236  *)
237     AC_MSG_ERROR(unrecognized collector \"$GC\")
238     ;;
239 esac
240 AC_SUBST(GCLIBS)
241 AC_SUBST(GCINCS)
242 AC_SUBST(GCDEPS)
243 AC_SUBST(GCOBJS)
244 AC_SUBST(GCSPEC)
245 AC_SUBST(JC1GCSPEC)
246 AC_SUBST(GCTESTSPEC)
247 AC_LINK_FILES(include/$GCHDR, include/java-gc.h)
248
249
250 dnl Note that this code is kept in sync with similar code in gcc/configure.in.
251 dnl In particular both packages must make the same decision about which
252 dnl thread package to use.
253 AC_MSG_CHECKING([for threads package to use])
254 AC_ARG_ENABLE(threads, [  --enable-threads=TYPE   choose threading package],
255   THREADS=$enableval,
256   dnl FIXME: figure out native threads to use here.
257   THREADS=no)
258
259 if test "$THREADS" = yes; then
260    case "$host" in
261     *-*-vxworks*)
262        THREADS=vxworks
263        ;;
264     *-*-linux*)
265        # FIXME: this isn't correct in all cases.
266        THREADS=posix
267        ;;
268     *-*-win*)
269        THREADS=win32
270        ;;
271     *-*-irix*)
272        # FIXME: for now, choose POSIX, because we implement that.
273        # Later, choose irix threads.
274        THREADS=posix
275        ;;
276     *-*-solaris*)
277        # FIXME: for now, choose POSIX, because we implement that.
278        # Later, choose solaris threads.
279        THREADS=posix
280        ;;
281     *)
282        # For now.
283        THREADS=none
284        ;;
285    esac
286 fi
287
288 case "$THREADS" in
289  no | none | single)
290     THREADS=none
291     ;;
292  posix | pthreads)
293     THREADS=posix
294     case "$host" in
295      *-*-linux*)
296         AC_DEFINE(LINUX_THREADS)
297         ;;
298     esac
299     ;;
300  decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
301     AC_MSG_ERROR(thread package $THREADS not yet supported)
302     ;;
303  *)
304     AC_MSG_ERROR($THREADS is an unknown thread package)
305     ;;
306 esac
307 AC_MSG_RESULT($THREADS)
308
309 THREADLIBS=
310 THREADINCS=
311 THREADDEPS=
312 THREADOBJS=
313 THREADH=
314 THREADSPEC=
315 case "$THREADS" in
316  posix)
317     THREADLIBS=-lpthread
318     THREADSPEC=-lpthread
319     THREADOBJS=posix-threads.lo
320     THREADH=posix-threads.h
321     # MIT pthreads doesn't seem to have the mutexattr functions.
322     # But for now we don't check for it.  We just assume you aren't
323     # using MIT pthreads.
324     AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT)
325
326     # If we're using the Boehm GC, then we happen to know that it
327     # defines _REENTRANT, so we don't bother.  Eww.
328     if test "$GC" != boehm; then
329        AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads])
330     fi
331     AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Required define if using POSIX threads])
332     ;;
333
334  none)
335     THREADOBJS=no-threads.lo
336     THREADH=no-threads.h
337     ;;
338 esac
339 AC_LINK_FILES(include/$THREADH, include/java-threads.h)
340 AC_SUBST(THREADLIBS)
341 AC_SUBST(THREADINCS)
342 AC_SUBST(THREADDEPS)
343 AC_SUBST(THREADOBJS)
344 AC_SUBST(THREADSPEC)
345
346 AM_CONDITIONAL(USING_GCC, test "$GCC" = yes)
347
348 CANADIAN=no
349 NULL_TARGET=no
350 NATIVE=yes
351
352 # Find eh-common.h and support headers.  If we're in the tree with
353 # gcc, then look there.  Otherwise look in compat-include.  If all else
354 # fails, just hope the user has set things up somehow.
355 if test -r $srcdir/../gcc/eh-common.h; then
356    EH_COMMON_INCLUDE='-I$(top_srcdir)/../gcc -I$(top_srcdir)/../include'
357 else
358    if test -d $srcdir/../compat-include; then
359       EH_COMMON_INCLUDE='-I$(top_srcdir)/../compat-include'
360    else
361       EH_COMMON_INCLUDE=
362    fi
363 fi
364
365 if test -n "${with_cross_host}"; then
366    # We are being configured with a cross compiler.  AC_REPLACE_FUNCS
367    # may not work correctly, because the compiler may not be able to
368    # link executables.
369
370    # We assume newlib.  This lets us hard-code the functions we know
371    # we'll have.
372    AC_DEFINE(HAVE_MEMMOVE)
373    AC_DEFINE(HAVE_MEMCPY)
374    AC_DEFINE(HAVE_STRERROR)
375    AC_DEFINE(HAVE_GMTIME_R)
376    AC_DEFINE(HAVE_LOCALTIME_R)
377    dnl This is only for POSIX threads.
378    AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT)
379    dnl We also assume we are using gcc, which provides alloca.
380    AC_DEFINE(HAVE_ALLOCA)
381
382    dnl Assume we do not have getuid and friends.
383    AC_DEFINE(NO_GETUID)
384
385    ZLIBSPEC=-lzgcj
386    ZLIBTESTSPEC="-L`pwd`/../zlib/.libs -rpath `pwd`/../zlib/.libs"
387
388    # If Canadian cross, then don't pick up tools from the build
389    # directory.
390    if test "$build" != "$with_cross_host"; then
391       CANADIAN=yes
392       EH_COMMON_INCLUDE=
393       GCJ="${target_alias}-gcj"
394    else
395       GCJ=
396    fi
397    NATIVE=no
398 else
399    AC_CHECK_FUNCS(strerror ioctl select fstat open fsync sleep)
400    AC_CHECK_FUNCS(gmtime_r localtime_r readdir_r getpwuid_r getcwd)
401    AC_CHECK_FUNCS(access stat mkdir rename rmdir unlink realpath)
402    AC_CHECK_FUNCS(iconv nl_langinfo setlocale)
403    AC_CHECK_FUNCS(inet_aton inet_addr, break)
404    AC_CHECK_FUNCS(inet_pton uname inet_ntoa)
405    AC_CHECK_FUNCS(backtrace fork execvp pipe)
406    AC_CHECK_HEADERS(execinfo.h unistd.h dlfcn.h) 
407    AC_CHECK_LIB(dl, dladdr, [
408      AC_DEFINE(HAVE_DLADDR)])
409    AC_CHECK_FILES(/proc/self/exe, [
410      AC_DEFINE(HAVE_PROC_SELF_EXE)])
411
412    AC_CHECK_FUNCS(gethostbyname_r, [
413      AC_DEFINE(HAVE_GETHOSTBYNAME_R)
414      # There are two different kinds of gethostbyname_r.
415      # We look for the one that returns `int'.
416      # Hopefully this check is robust enough.
417      AC_EGREP_HEADER(int.*gethostbyname_r, netdb.h, [
418        AC_DEFINE(GETHOSTBYNAME_R_RETURNS_INT)])
419
420      case " $GCINCS " in
421      *" -D_REENTRANT "*) ;;
422      *)
423         dnl On DU4.0, gethostbyname_r is only declared with -D_REENTRANT
424         AC_CACHE_CHECK([whether gethostbyname_r declaration requires -D_REENTRANT],
425         [libjava_cv_gethostbyname_r_needs_reentrant],
426         [ AC_LANG_SAVE
427           AC_LANG_CPLUSPLUS
428           AC_TRY_COMPILE([#include <netdb.h>],
429             [gethostbyname_r("", 0, 0);],
430             [libjava_cv_gethostbyname_r_needs_reentrant=no], [dnl
431                 CPPFLAGS_SAVE="$CPPFLAGS"
432                 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
433                 AC_TRY_COMPILE([#include <netdb.h>], [gethostbyname_r("", 0, 0);],
434                     [libjava_cv_gethostbyname_r_needs_reentrant=yes],
435                     [libjava_cv_gethostbyname_r_needs_reentrant=fail])
436                 CPPFLAGS="$CPPFLAGS_SAVE"
437           ])
438           AC_LANG_RESTORE
439         ])
440         if test "x$libjava_cv_gethostbyname_r_needs_reentrant" = xyes; then
441           AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads])
442         fi
443      ;;
444      esac
445
446      AC_CACHE_CHECK([for struct hostent_data],
447         [libjava_cv_struct_hostent_data], [dnl
448         AC_TRY_COMPILE([
449 #if GETHOSTBYNAME_R_NEEDS_REENTRANT && !defined(_REENTRANT)
450 # define _REENTRANT 1
451 #endif
452 #include <netdb.h>], [struct hostent_data data;],
453           [libjava_cv_struct_hostent_data=yes],
454           [libjava_cv_struct_hostent_data=no])])
455      if test "x$libjava_cv_struct_hostent_data" = xyes; then
456        AC_DEFINE(HAVE_STRUCT_HOSTENT_DATA, 1,
457          [Define if struct hostent_data is defined in netdb.h])
458      fi
459    ])
460
461    AC_CHECK_FUNCS(gethostbyaddr_r, [
462      AC_DEFINE(HAVE_GETHOSTBYADDR_R)
463      # There are two different kinds of gethostbyaddr_r.
464      # We look for the one that returns `int'.
465      # Hopefully this check is robust enough.
466      AC_EGREP_HEADER(int.*gethostbyaddr_r, netdb.h, [
467        AC_DEFINE(GETHOSTBYADDR_R_RETURNS_INT)])])
468
469    AC_CHECK_FUNCS(gethostname, [
470      AC_DEFINE(HAVE_GETHOSTNAME)
471      AC_EGREP_HEADER(gethostname, unistd.h, [
472        AC_DEFINE(HAVE_GETHOSTNAME_DECL)])])
473
474    # Look for these functions in the thread library, but only bother
475    # if using POSIX threads.
476    if test "$THREADS" = posix; then
477       save_LIBS="$LIBS"
478       LIBS="$LIBS $THREADLIBS"
479       # Some POSIX thread systems don't have pthread_mutexattr_settype.
480       # E.g., Solaris.
481       AC_CHECK_FUNCS(pthread_mutexattr_settype pthread_mutexattr_setkind_np)
482
483       # Look for sched_yield.  Up to Solaris 2.6, it is in libposix4, since
484       # Solaris 7 the name librt is preferred.
485       AC_CHECK_FUNCS(sched_yield, , [
486         AC_CHECK_LIB(rt, sched_yield, [
487           AC_DEFINE(HAVE_SCHED_YIELD)
488           THREADLIBS="$THREADLIBS -lrt"
489           THREADSPEC="$THREADSPEC -lrt"], [
490           AC_CHECK_LIB(posix4, sched_yield, [
491             AC_DEFINE(HAVE_SCHED_YIELD)
492             THREADLIBS="$THREADLIBS -lposix4"
493             THREADSPEC="$THREADSPEC -lposix4"])])])
494       LIBS="$save_LIBS"
495
496       # We can save a little space at runtime if the mutex has m_count
497       # or __m_count.  This is a nice hack for Linux.
498       AC_TRY_COMPILE([#include <pthread.h>], [
499           extern pthread_mutex_t *mutex; int q = mutex->m_count;
500         ], AC_DEFINE(PTHREAD_MUTEX_HAVE_M_COUNT), [
501         AC_TRY_COMPILE([#include <pthread.h>], [
502             extern pthread_mutex_t *mutex; int q = mutex->__m_count;
503           ], AC_DEFINE(PTHREAD_MUTEX_HAVE___M_COUNT))])
504    fi
505
506    # We require a way to get the time.
507    time_found=no
508    AC_CHECK_FUNCS(gettimeofday time ftime, time_found=yes)
509    if test "$time_found" = no; then
510       AC_MSG_ERROR([no function found to get the time])
511    fi
512
513    AC_CHECK_FUNCS(memmove)
514
515    # We require memcpy.
516    memcpy_found=no
517    AC_CHECK_FUNCS(memcpy, memcpy_found=yes)
518    if test "$memcpy_found" = no; then
519       AC_MSG_ERROR([memcpy is required])
520    fi
521
522    # Some library-finding code we stole from Tcl.
523    #--------------------------------------------------------------------
524    #    Check for the existence of the -lsocket and -lnsl libraries.
525    #    The order here is important, so that they end up in the right
526    #    order in the command line generated by make.  Here are some
527    #    special considerations:
528    #    1. Use "connect" and "accept" to check for -lsocket, and
529    #       "gethostbyname" to check for -lnsl.
530    #    2. Use each function name only once:  can't redo a check because
531    #       autoconf caches the results of the last check and won't redo it.
532    #    3. Use -lnsl and -lsocket only if they supply procedures that
533    #       aren't already present in the normal libraries.  This is because
534    #       IRIX 5.2 has libraries, but they aren't needed and they're
535    #       bogus:  they goof up name resolution if used.
536    #    4. On some SVR4 systems, can't use -lsocket without -lnsl too.
537    #       To get around this problem, check for both libraries together
538    #       if -lsocket doesn't work by itself.
539    #--------------------------------------------------------------------
540
541    AC_CACHE_CHECK([for socket libraries], gcj_cv_lib_sockets,
542     [gcj_cv_lib_sockets=
543      gcj_checkBoth=0
544      unset ac_cv_func_connect
545      AC_CHECK_FUNC(connect, gcj_checkSocket=0, gcj_checkSocket=1)
546      if test "$gcj_checkSocket" = 1; then
547          unset ac_cv_func_connect
548          AC_CHECK_LIB(socket, main, gcj_cv_lib_sockets="-lsocket",
549                       gcj_checkBoth=1)
550      fi
551      if test "$gcj_checkBoth" = 1; then
552          gcj_oldLibs=$LIBS
553          LIBS="$LIBS -lsocket -lnsl"
554          unset ac_cv_func_accept
555          AC_CHECK_FUNC(accept,
556                        [gcj_checkNsl=0
557                         gcj_cv_lib_sockets="-lsocket -lnsl"])
558          unset ac_cv_func_accept
559          LIBS=$gcj_oldLibs
560      fi
561      unset ac_cv_func_gethostbyname
562      gcj_oldLibs=$LIBS
563      LIBS="$LIBS $gcj_cv_lib_sockets"
564      AC_CHECK_FUNC(gethostbyname, ,
565                    [AC_CHECK_LIB(nsl, main,
566                                  [gcj_cv_lib_sockets="$gcj_cv_lib_sockets -lnsl"])])
567      unset ac_cv_func_gethostbyname
568      LIBS=$gcj_oldLIBS
569    ])
570    SYSTEMSPEC="$SYSTEMSPEC $gcj_cv_lib_sockets"
571
572    if test "$with_system_zlib" = yes; then
573       AC_CHECK_LIB(z, deflate, ZLIBSPEC=-lz, ZLIBSPEC=-lzgcj)
574    else
575       ZLIBSPEC=-lzgcj
576       ZLIBTESTSPEC="-L`pwd`/../zlib/.libs -rpath `pwd`/../zlib/.libs"
577    fi
578
579    # On Solaris, and maybe other architectures, the Boehm collector
580    # requires -ldl.
581    if test "$GC" = boehm; then
582       AC_CHECK_LIB(dl, main, SYSTEMSPEC="$SYSTEMSPEC -ldl")
583    fi
584
585    if test -z "${with_multisubdir}"; then
586       builddotdot=.
587    else
588 changequote(<<,>>)
589       builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`
590 changequote([,])
591    fi
592    if test -x "${builddotdot}/../../gcc/gcj"; then
593       dir="`cd ${builddotdot}/../../gcc && pwd`"
594       GCJ="$dir/gcj -B`pwd`/ -B$dir/"
595    else
596       CANADIAN=yes
597       NULL_TARGET=yes
598       GCJ="gcj -B`pwd`/"
599    fi
600 fi
601
602 # Create it, so that compile/link tests don't fail
603 test -f libgcj.spec || touch libgcj.spec
604
605 LT_AC_PROG_GCJ
606
607 dnl FIXME: cross compilation
608 AC_CHECK_SIZEOF(void *)
609
610 ZLIBS=
611 ZDEPS=
612 ZINCS=
613 if test "x$ZLIBSPEC" = "x-lzgcj"; then
614    # We include the path to the zlib build directory.
615    # See Makefile.am to understand why.
616    ZDEPS='$(top_builddir)/../zlib/libzgcj.la'
617    ZLIBS="$ZDEPS -L\$(here)/../zlib/$libsubdir"
618    ZINCS='-I$(top_srcdir)/../zlib'
619 else
620    ZLIBS="$ZLIBSPEC"
621 fi
622 AC_SUBST(ZLIBS)
623 AC_SUBST(ZDEPS)
624 AC_SUBST(ZINCS)
625 AC_SUBST(DIVIDESPEC)
626 AC_SUBST(EXCEPTIONSPEC)
627
628 AM_CONDITIONAL(CANADIAN, test "$CANADIAN" = yes)
629 AM_CONDITIONAL(NULL_TARGET, test "$NULL_TARGET" = yes)
630 AM_CONDITIONAL(NATIVE, test "$NATIVE" = yes || test "$NULL_TARGET" = yes)
631 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
632 AM_CONDITIONAL(NEEDS_DATA_START, test "$NEEDS_DATA_START" = yes && test "$NATIVE" = yes)
633 AC_SUBST(EH_COMMON_INCLUDE)
634
635 # Determine gcj version number.
636 changequote(<<,>>)
637 gcjvers="`$GCJ -v 2>&1 | sed -n 's/^.*version \([^ ]*\).*$/\1/p'`"
638 changequote([,])
639 AC_DEFINE_UNQUOTED(GCJVERSION, "$gcjvers")
640
641 AC_SUBST(AM_RUNTESTFLAGS)
642
643 dnl Work around a g++ bug.  Reported to gcc-bugs@gcc.gnu.org on Jan 22, 2000.
644 AC_MSG_CHECKING([for g++ -ffloat-store bug])
645 save_CFLAGS="$CFLAGS"
646 CFLAGS="-x c++ -O2 -ffloat-store"
647 AC_TRY_COMPILE([#include <math.h>], , 
648   [AC_MSG_RESULT(no)],
649   [AC_DEFINE(__NO_MATH_INLINES)
650    AC_MSG_RESULT(yes)])
651 CFLAGS="$save_CFLAGS"
652
653 dnl We check for sys/filio.h because Solaris 2.5 defines FIONREAD there.
654 dnl On that system, sys/ioctl.h will not include sys/filio.h unless
655 dnl BSD_COMP is defined; just including sys/filio.h is simpler.
656 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 pwd.h sys/config.h inttypes.h stdint.h langinfo.h locale.h)
657 dnl We avoid AC_HEADER_DIRENT since we really only care about dirent.h
658 dnl for now.  If you change this, you also must update natFile.cc.
659 AC_CHECK_HEADERS(dirent.h)
660
661 AC_CHECK_TYPE([ssize_t], [int])
662
663 AC_MSG_CHECKING([for in_addr_t])
664 AC_TRY_COMPILE([#include <sys/types.h>
665 #if STDC_HEADERS
666 #include <stdlib.h>
667 #include <stddef.h>
668 #endif
669 #if HAVE_NETINET_IN_H
670 #include <netinet/in.h>
671 #endif], [in_addr_t foo;],
672   [AC_DEFINE([HAVE_IN_ADDR_T])
673    AC_MSG_RESULT(yes)],
674   [AC_MSG_RESULT(no)])
675
676 AC_MSG_CHECKING([whether struct ip_mreq is in netinet/in.h])
677 AC_TRY_COMPILE([#include <netinet/in.h>], [struct ip_mreq mreq;],
678   [AC_DEFINE(HAVE_STRUCT_IP_MREQ)
679    AC_MSG_RESULT(yes)],
680   [AC_MSG_RESULT(no)])
681
682 AC_MSG_CHECKING([whether struct sockaddr_in6 is in netinet/in.h])
683 AC_TRY_COMPILE([#include <netinet/in.h>], [struct sockaddr_in6 addr6;],
684   [AC_DEFINE(HAVE_INET6)
685    AC_MSG_RESULT(yes)],
686   [AC_MSG_RESULT(no)])
687
688 AC_MSG_CHECKING([for socklen_t in sys/socket.h])
689 AC_TRY_COMPILE([#include <sys/types.h>
690 #include <sys/socket.h>], [socklen_t x = 5;],
691   [AC_DEFINE(HAVE_SOCKLEN_T)
692    AC_MSG_RESULT(yes)],
693   [AC_MSG_RESULT(no)])
694
695 AC_MSG_CHECKING([for tm_gmtoff in struct tm])
696 AC_TRY_COMPILE([#include <time.h>], [struct tm tim; tim.tm_gmtoff = 0;],
697   [AC_DEFINE(STRUCT_TM_HAS_GMTOFF)
698    AC_MSG_RESULT(yes)],
699   [AC_MSG_RESULT(no)
700    AC_MSG_CHECKING([for global timezone variable])
701    dnl FIXME: we don't want a link check here because that won't work
702    dnl when cross-compiling.  So instead we make an assumption that
703    dnl the header file will mention timezone if it exists.
704    AC_TRY_COMPILE([#include <time.h>], [long z2 = timezone;],
705      [AC_DEFINE(HAVE_TIMEZONE)
706       AC_MSG_RESULT(yes)],
707      [AC_MSG_RESULT(no)])])
708
709 AC_FUNC_ALLOCA
710
711 AC_CHECK_PROGS(PERL, perl, false)
712
713 SYSDEP_SOURCES=
714
715 case "${host}" in
716  i?86-*-linux*)
717     SIGNAL_HANDLER=include/i386-signal.h
718     ;;
719  sparc-sun-solaris*)
720     SIGNAL_HANDLER=include/sparc-signal.h
721     ;;
722  ia64-*)
723     SYSDEP_SOURCES=sysdep/ia64.c
724     test -d sysdep || mkdir sysdep
725     ;;
726  *)
727     SIGNAL_HANDLER=include/default-signal.h
728     ;;
729 esac
730
731 # If we're using sjlj exceptions, forget what we just learned.
732 if test "$libgcj_sjlj" = yes; then
733    SIGNAL_HANDLER=include/default-signal.h
734 fi
735
736 AC_SUBST(SYSDEP_SOURCES)
737
738 AC_LINK_FILES($SIGNAL_HANDLER, include/java-signal.h)
739
740 if test "${multilib}" = "yes"; then
741   multilib_arg="--enable-multilib"
742 else
743   multilib_arg=
744 fi
745
746 AC_PATH_XTRA
747
748 AM_CONDITIONAL(NO_X, test "$no_x" = yes)
749
750 here=`pwd`
751 AC_SUBST(here)
752
753
754 AC_OUTPUT(Makefile libgcj.spec libgcj-test.spec gnu/classpath/Configuration.java gcj/Makefile include/Makefile testsuite/Makefile,
755 [if test -n "$CONFIG_FILES"; then
756   ac_file=Makefile . ${libgcj_basedir}/../config-ml.in
757 fi
758
759 # Make subdirectories and `.d' files.  Look in both srcdir and
760 # builddir for the .java files.
761 h=`pwd`
762 : > deps.mk
763 ( (cd $srcdir && find . -name '*.java' -print) ;
764   find . -name '*.java' -print) | \
765    fgrep -v testsuite | \
766    sed -e 's/\.java/.d/' | \
767    while read f; do
768       echo "include $f" >> deps.mk
769       test -f $f || {
770 changequote(<<,>>)
771          d=`echo $f | sed -e 's,/[^/]*$,,'`
772 changequote([,])
773          $srcdir/../mkinstalldirs $d
774          echo > $f
775       }
776    done
777 ],
778 srcdir=${srcdir}
779 host=${host}
780 target=${target}
781 with_multisubdir=${with_multisubdir}
782 ac_configure_args="${multilib_arg} ${ac_configure_args}"
783 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
784 libgcj_basedir=${libgcj_basedir}
785 CC="${CC}"
786 CXX="${CXX}"
787 )