OSDN Git Service

9be0d874d3c4c8be929888ab833a8df22708c560
[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
9 dnl We use these options to decide which functions to include.
10 AC_ARG_WITH(target-subdir,
11 [  --with-target-subdir=SUBDIR      Configuring in a subdirectory])
12 AC_ARG_WITH(cross-host,
13 [  --with-cross-host=HOST           Configuring with a cross compiler])
14
15 LIBGCJ_CONFIGURE(.)
16
17 AM_CONFIG_HEADER(include/config.h)
18
19 AM_PROG_LIBTOOL
20
21 if test -z "$with_target_subdir" || test "$with_target_subdir" = "."; then
22    COMPPATH=.
23 else
24    COMPPATH=..
25 fi
26 AC_SUBST(COMPPATH)
27
28 dnl The -no-testsuite modules omit the test subdir.
29 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
30
31 dnl See whether the user prefers size or speed for Character.
32 dnl The default is size.
33 AC_ARG_ENABLE(fast-character,
34 [  --enable-fast-character          Prefer speed over size for Character],
35 # Nothing
36 , AC_DEFINE(COMPACT_CHARACTER))
37
38 dnl See if the user has requested runtime debugging.
39 AC_ARG_ENABLE(libgcj-debug,
40 [  --enable-libgcj-debug           Enable runtime debugging code],
41   if test "$enable_libgcj_debug" = yes; then
42      AC_DEFINE(DEBUG)
43   fi)
44
45 dnl If the target is an eCos system, use the appropriate eCos
46 dnl I/O routines.
47 dnl FIXME: this should not be a local option but a global target
48 dnl system; at present there is no eCos target.
49 TARGET_ECOS="no"
50 AC_ARG_WITH(ecos,
51 [  --with-ecos      Enable runtime eCos target support.],
52 TARGET_ECOS="$with_ecos"
53 )
54
55 case "$TARGET_ECOS" in
56    no)
57       FILE_DESCRIPTOR=natFileDescriptorPosix.cc
58       ;;
59    *)
60       FILE_DESCRIPTOR=natFileDescriptorEcos.cc
61       AC_DEFINE(ECOS)
62       ;;
63 esac
64
65 AC_EGREP_HEADER(__uint32_t, sys/types.h, AC_DEFINE(HAVE_INT32_DEFINED))
66 AC_EGREP_HEADER(__uint32_t, sys/config.h, AC_DEFINE(HAVE_INT32_DEFINED))
67
68 dnl These may not be defined in a non-ANS conformant embedded system.
69 dnl FIXME: Should these case a runtime exception in that case?
70 AC_EGREP_HEADER(mktime, time.h, AC_DEFINE(HAVE_MKTIME))
71 AC_EGREP_HEADER(localtime, time.h, AC_DEFINE(HAVE_LOCALTIME))
72
73 dnl Create the subdirectory for natFileDescriptor.cc, or the attempt
74 dnl to create the link will fail.
75 test -d java || mkdir java
76 test -d java/io || mkdir java/io
77 AC_LINK_FILES(java/io/$FILE_DESCRIPTOR, java/io/natFileDescriptor.cc)
78
79 dnl Allow the GC to be disabled.  Can be useful when debugging.
80 AC_MSG_CHECKING([for garbage collector to use])
81 AC_ARG_ENABLE(java-gc,
82 changequote(<<,>>)dnl
83 <<  --enable-java-gc=TYPE    choose garbage collector [boehm]>>,
84 changequote([,])
85   GC=$enableval,
86   GC=boehm)
87 GCLIBS=
88 GCINCS=
89 GCDEPS=
90 GCOBJS=
91 case "$GC" in
92  boehm)
93     AC_MSG_RESULT(boehm)
94     GCDEPS='$(top_builddir)/../boehm-gc/libgcjgc.la'
95     GCLIBS="$GCDEPS"
96     GCINCS='-I$(top_srcdir)/../boehm-gc -I$(top_builddir)/../boehm-gc'
97     dnl We also want to pick up some cpp flags required when including
98     dnl boehm-config.h.  Yuck.
99     GCINCS="$GCINCS `cat ../boehm-gc/boehm-cflags`"
100     GCOBJS=boehm.lo
101     GCHDR=boehm-gc.h
102     dnl The POSIX thread support needs to know this.
103     AC_DEFINE(HAVE_BOEHM_GC)
104     ;;
105  no)
106     AC_MSG_RESULT(none)
107     GCOBJS=nogc.lo
108     GCHDR=no-gc.h
109     ;;
110  *)
111     AC_MSG_ERROR(unrecognized collector \"$GC\")
112     ;;
113 esac
114 AC_SUBST(GCLIBS)
115 AC_SUBST(GCINCS)
116 AC_SUBST(GCDEPS)
117 AC_SUBST(GCOBJS)
118 AC_LINK_FILES(include/$GCHDR, include/java-gc.h)
119
120
121 dnl Note that this code is kept in sync with similar code in gcc/configure.in.
122 dnl In particular both packages must make the same decision about which
123 dnl thread package to use.
124 AC_MSG_CHECKING([for threads package to use])
125 AC_ARG_ENABLE(threads, [  --enable-threads=TYPE    choose threading package],
126   THREADS=$enableval,
127   dnl FIXME: figure out native threads to use here.
128   THREADS=no)
129
130 if test "$THREADS" = yes; then
131    case "$host" in
132     *-*-vxworks*)
133        THREADS=vxworks
134        ;;
135     *-*-linux*)
136        # FIXME: this isn't correct in all cases.
137        THREADS=posix
138        ;;
139     *-*-win*)
140        THREADS=win32
141        ;;
142     *-*-irix*)
143        # FIXME: for now, choose POSIX, because we implement that.
144        # Later, choose irix threads.
145        THREADS=posix
146        ;;
147     *-*-solaris*)
148        # FIXME: for now, choose POSIX, because we implement that.
149        # Later, choose solaris threads.
150        THREADS=posix
151        ;;
152     *)
153        # For now.
154        THREADS=none
155        ;;
156    esac
157 fi
158
159 case "$THREADS" in
160  no | none | single)
161     THREADS=none
162     ;;
163  posix | pthreads)
164     THREADS=posix
165     case "$host" in
166      *-*-linux*)
167         AC_DEFINE(LINUX_THREADS)
168         ;;
169     esac
170     ;;
171  qt)
172     ;;
173  decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
174     AC_MSG_ERROR(thread package $THREADS not yet supported)
175     ;;
176  *)
177     AC_MSG_ERROR($THREADS is an unknown thread package)
178     ;;
179 esac
180 AC_MSG_RESULT($THREADS)
181
182 THREADLIBS=
183 THREADINCS=
184 THREADDEPS=
185 THREADOBJS=
186 THREADH=
187 case "$THREADS" in
188  posix)
189     THREADLIBS=-lpthread
190     THREADOBJS=posix-threads.lo
191     THREADH=posix-threads.h
192     # MIT pthreads doesn't seem to have the mutexattr functions.
193     # But for now we don't check for it.  We just assume you aren't
194     # using MIT pthreads.
195     AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT)
196     ;;
197
198  qt)
199     THREADDEPS='$(top_builddir)/../qthreads/libgcjcoop.la'
200     THREADLIBS="$THREADDEPS"
201     THREADOBJS=quick-threads.lo
202     THREADINCS='-I$(top_srcdir)/../qthreads'
203     THREADH=quick-threads.h
204     ;;
205
206  none)
207     THREADOBJS=no-threads.lo
208     THREADH=no-threads.h
209     ;;
210 esac
211 AC_LINK_FILES(include/$THREADH, include/java-threads.h)
212 AC_SUBST(THREADLIBS)
213 AC_SUBST(THREADINCS)
214 AC_SUBST(THREADDEPS)
215 AC_SUBST(THREADOBJS)
216
217 AM_CONDITIONAL(USING_GCC, test "$GCC" = yes)
218
219 CANADIAN=no
220 NULL_TARGET=no
221
222 # Find eh-common.h and support headers.  If we're in the tree with
223 # gcc, then look there.  Otherwise look in compat-include.  If all else
224 # fails, just hope the user has set things up somehow.
225 if test -r $srcdir/../gcc/eh-common.h; then
226    EH_COMMON_INCLUDE='-I$(top_srcdir)/../gcc -I$(top_srcdir)/../include'
227 else
228    if test -d $srcdir/../compat-include; then
229       EH_COMMON_INCLUDE='-I$(top_srcdir)/../compat-include'
230    else
231       EH_COMMON_INCLUDE=
232    fi
233 fi
234
235 if test -n "${with_cross_host}"; then
236    # We are being configured with a cross compiler.  AC_REPLACE_FUNCS
237    # may not work correctly, because the compiler may not be able to
238    # link executables.
239
240    # We assume newlib.  This lets us hard-code the functions we know
241    # we'll have.
242    AC_DEFINE(HAVE_MEMMOVE)
243    AC_DEFINE(HAVE_MEMCPY)
244    AC_DEFINE(HAVE_STRERROR)
245    AC_DEFINE(HAVE_CTIME_R)
246    AC_DEFINE(HAVE_GMTIME_R)
247    AC_DEFINE(HAVE_LOCALTIME_R)
248    dnl This is only for POSIX threads.
249    AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT)
250    dnl We also assume we are using gcc, which provides alloca.
251    AC_DEFINE(HAVE_ALLOCA)
252
253    # If Canadian cross, then don't pick up tools from the build
254    # directory.
255    if test "$build" != "$with_cross_host"; then
256       CANADIAN=yes
257       EH_COMMON_INCLUDE=
258    fi
259 else
260    # Some POSIX thread systems don't have pthread_mutexattr_settype.
261    # E.g., Solaris.
262    AC_CHECK_FUNCS(strerror ioctl select open fsync sleep)
263    AC_CHECK_FUNCS(ctime_r ctime, break)
264    AC_CHECK_FUNCS(gmtime_r localtime_r readdir_r getpwuid_r)
265    AC_CHECK_FUNCS(access stat mkdir rename rmdir unlink realpath)
266    AC_CHECK_FUNCS(inet_aton inet_addr, break)
267    AC_CHECK_FUNCS(inet_pton uname)
268
269    AC_CHECK_FUNCS(gethostbyname_r, [
270      AC_DEFINE(HAVE_GETHOSTBYNAME_R)
271      # There are two different kinds of gethostbyname_r.
272      # We look for the one that returns `int'.
273      # Hopefully this check is robust enough.
274      AC_EGREP_HEADER(int.*gethostbyname_r, netdb.h, [
275        AC_DEFINE(GETHOSTBYNAME_R_RETURNS_INT)])])
276
277    AC_CHECK_FUNCS(gethostbyaddr_r, [
278      AC_DEFINE(HAVE_GETHOSTBYADDR_R)
279      # There are two different kinds of gethostbyaddr_r.
280      # We look for the one that returns `int'.
281      # Hopefully this check is robust enough.
282      AC_EGREP_HEADER(int.*gethostbyaddr_r, netdb.h, [
283        AC_DEFINE(GETHOSTBYADDR_R_RETURNS_INT)])])
284
285    AC_CHECK_FUNCS(gethostname, [
286      AC_DEFINE(HAVE_GETHOSTNAME)
287      AC_EGREP_HEADER(gethostname, unistd.h, [
288        AC_DEFINE(HAVE_GETHOSTNAME_DECL)])])
289
290    # Look for these functions in the thread library.
291    save_LIBS="$LIBS"
292    LIBS="$LIBS $THREADLIBS"
293    AC_CHECK_FUNCS(pthread_mutexattr_settype pthread_mutexattr_setkind_np sched_yield)
294    LIBS="$save_LIBS"
295
296    # We require a way to get the time.
297    time_found=no
298    AC_CHECK_FUNCS(gettimeofday time ftime, time_found=yes)
299    if test "$time_found" = no; then
300       AC_MSG_ERROR([no function found to get the time])
301    fi
302
303    # We require memmove.
304    memmove_found=no
305    AC_CHECK_FUNCS(memmove, memmove_found=yes)
306    if test "$memmove_found" = no; then
307       AC_MSG_ERROR([memmove is required])
308    fi
309
310    # We require memcpy.
311    memcpy_found=no
312    AC_CHECK_FUNCS(memcpy, memcpy_found=yes)
313    if test "$memcpy_found" = no; then
314       AC_MSG_ERROR([memcpy is required])
315    fi
316
317    test -d "$libgcj_basedir/../gcc/java" || {
318       CANADIAN=yes
319       NULL_TARGET=yes
320    }
321 fi
322
323 AM_CONDITIONAL(CANADIAN, test "$CANADIAN" = yes)
324 AM_CONDITIONAL(NULL_TARGET, test "$NULL_TARGET" = yes)
325 AM_CONDITIONAL(NATIVE, test "$CANADIAN" = no || test "$NULL_TARGET" = yes)
326
327 AC_SUBST(EH_COMMON_INCLUDE)
328
329 AC_SUBST(AM_RUNTESTFLAGS)
330
331 dnl We check for sys/filio.h because Solaris 2.5 defines FIONREAD there.
332 dnl On that system, sys/ioctl.h will not include sys/filio.h unless
333 dnl BSD_COMP is defined; just including sys/filio.h is simpler.
334 AC_CHECK_HEADERS(unistd.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)
335 dnl We avoid AC_HEADER_DIRENT since we really only care about dirent.h
336 dnl for now.  If you change this, you also must update natFile.cc.
337 AC_CHECK_HEADERS(dirent.h)
338
339 AC_MSG_CHECKING([whether struct sockaddr_in6 is in netinet/in.h])
340 AC_TRY_COMPILE([#include <netinet/in.h>], [struct sockaddr_in6 addr6;],
341   [AC_DEFINE(HAVE_INET6)
342    AC_MSG_RESULT(yes)],
343   [AC_MSG_RESULT(no)])
344
345 AC_MSG_CHECKING([for socklen_t in sys/socket.h])
346 AC_TRY_COMPILE([#include <sys/socket.h>], [socklen_t x = 5;],
347   [AC_DEFINE(HAVE_SOCKLEN_T)
348    AC_MSG_RESULT(yes)],
349   [AC_MSG_RESULT(no)])
350
351 AC_MSG_CHECKING([for tm_gmtoff in struct tm])
352 AC_TRY_COMPILE([#include <time.h>], [struct tm tim; tim.tm_gmtoff = 0;],
353   [AC_DEFINE(STRUCT_TM_HAS_GMTOFF)
354    AC_MSG_RESULT(yes)],
355   [AC_MSG_RESULT(no)
356    AC_MSG_CHECKING([for global timezone variable])
357    dnl FIXME: we don't want a link check here because that won't work
358    dnl when cross-compiling.  So instead we make an assumption that
359    dnl the header file will mention timezone if it exists.
360    AC_TRY_COMPILE([#include <time.h>], [long z2 = timezone;],
361      [AC_DEFINE(HAVE_TIMEZONE)
362       AC_MSG_RESULT(yes)],
363      [AC_MSG_RESULT(no)])])
364
365 AC_FUNC_ALLOCA
366
367 AC_CHECK_PROGS(PERL, perl, false)
368
369 case "${host}" in
370   i?86-*-linux*)
371     SIGNAL_HANDLER=include/i386-signal.h
372         ;;
373   sparc-sun-solaris*)
374     SIGNAL_HANDLER=include/sparc-signal.h
375         ;;
376   *)
377     SIGNAL_HANDLER=include/default-signal.h
378         ;;
379 esac
380
381 AC_LINK_FILES($SIGNAL_HANDLER, include/java-signal.h)
382
383 if test "${multilib}" = "yes"; then
384   multilib_arg="--enable-multilib"
385 else
386   multilib_arg=
387 fi
388
389 here=`pwd`
390 AC_SUBST(here)
391
392 AC_OUTPUT(Makefile testsuite/Makefile,
393 [if test -n "$CONFIG_FILES"; then
394   ac_file=Makefile . ${libgcj_basedir}/../config-ml.in
395 fi],
396 srcdir=${srcdir}
397 host=${host}
398 target=${target}
399 with_multisubdir=${with_multisubdir}
400 ac_configure_args="${multilib_arg} ${ac_configure_args}"
401 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
402 libgcj_basedir=${libgcj_basedir}
403 CC="${CC}"
404 CXX="${CXX}"
405 )