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