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