* configure.in: Check for the readline library, and the termcap
[bpt/guile.git] / configure.in
1 dnl Process this file with autoconf to produce configure.
2 AC_INIT(Makefile.in)
3 . $srcdir/GUILE-VERSION
4 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
5 AM_MAINTAINER_MODE
6 AM_CONFIG_HEADER(libguile/scmconfig.h)
7
8 #--------------------------------------------------------------------
9 #
10 # User options
11 #
12 #--------------------------------------------------------------------
13
14 AC_ARG_ENABLE(debug,
15 [ --disable-debug Don't include debugging support])
16 if test "$enableval" != n && test "$enableval" != no; then
17 AC_DEFINE(DEBUG_EXTENSIONS)
18 AC_DEFINE(READER_EXTENSIONS)
19 LIBOBJS="backtrace.o stacks.o debug.o srcprop.o $LIBOBJS"
20 fi
21
22 AC_ARG_ENABLE(dynamic-linking,
23 [ --enable-dynamic-linking Include support for dynamic linking],,
24 enable_dynamic_linking=yes)
25
26 AC_ARG_ENABLE(guile-debug,
27 [ --enable-guile-debug Include internal debugging functions])
28 if test "$enableval" = y || test "$enableval" = yes; then
29 AC_DEFINE(GUILE_DEBUG)
30 fi
31
32 #--------------------------------------------------------------------
33
34 AC_PROG_CC
35 AC_PROG_CPP
36 AM_PROG_LIBTOOL
37
38 AC_AIX
39 AC_ISC_POSIX
40 AC_MINIX
41
42 AC_C_CONST
43
44 AC_HEADER_STDC
45 AC_HEADER_DIRENT
46 AC_HEADER_TIME
47 AC_HEADER_SYS_WAIT
48 AC_CHECK_HEADERS(libc.h limits.h malloc.h memory.h string.h regex.h rxposix.h rx/rxposix.h sys/ioctl.h sys/select.h sys/time.h sys/timeb.h sys/times.h sys/types.h sys/utime.h time.h unistd.h utime.h)
49 GUILE_HEADER_LIBC_WITH_UNISTD
50
51 AC_TYPE_GETGROUPS
52 AC_TYPE_SIGNAL
53 AC_TYPE_MODE_T
54
55 AC_CHECK_LIB(m, main)
56 AC_CHECK_FUNC(gethostbyname)
57 if test $ac_cv_func_gethostbyname = no; then
58 AC_CHECK_LIB(nsl, gethostbyname)
59 fi
60 AC_CHECK_FUNC(connect)
61 if test $ac_cv_func_connect = no; then
62 AC_CHECK_LIB(socket, connect)
63 fi
64 AC_CHECK_LIB(termcap, tgoto)
65 AC_CHECK_LIB(readline, readline)
66
67 # Checks for dynamic linking
68
69 if test "$enable_dynamic_linking" = "yes"; then
70
71 AC_CHECK_LIB(dl,dlopen)
72 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
73 AC_DEFINE(DYNAMIC_LINKING)
74 else
75 AC_CHECK_LIB(dld,dld_link)
76 if test "$ac_cv_lib_dld_dld_link" = "yes"; then
77 AC_DEFINE(DYNAMIC_LINKING)
78 else
79 AC_CHECK_FUNCS(shl_load)
80 if test "$ac_cv_func_shl_load" = "yes"; then
81 AC_DEFINE(DYNAMIC_LINKING)
82 else
83 AC_CHECK_FUNCS(dlopen)
84 if test "$ac_cv_func_dlopen" = "yes"; then
85 AC_DEFINE(DYNAMIC_LINKING)
86 fi
87 fi
88 fi
89 fi
90
91 fi
92
93
94 AC_CHECK_FUNCS(ctermid ftime getcwd geteuid gethostent gettimeofday lstat mkdir mknod nice readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction strftime strptime symlink sync tcgetpgrp tcsetpgrp times uname waitpid)
95
96 dnl <GNU-WIN32 hacks>
97
98 AC_CHECK_HEADER(sys/un.h, have_sys_un_h=1)
99 if test -n "$have_sys_un_h" ; then
100 AC_DEFINE(HAVE_UNIX_DOMAIN_SOCKETS)
101 fi
102
103 AC_CHECK_FUNCS(socketpair getgroups setpwent pause tzset)
104
105 dnl I don't know what this prefixing of cygwin32_ is for.
106 dnl scmconfig.h wasn't updated with the test results.
107 dnl so use AC_CHECK_FUNCS for now.
108
109 dnl how about:
110 dnl save confdefs.h
111 dnl if test $ac_cv_cigwin = yes; then
112 dnl modify confdefs.h
113 dnl fi
114 dnl AC_CHECK_FUNCS...
115 dnl restore confdefs.h
116
117 dnl cp confdefs.h confdefs.h.bak
118 dnl for func in sethostent endhostent getnetent setnetent endnetent getprotoent endprotoent getservent endservent getnetbyaddr getnetbyname inet_lnaof inet_makeaddr inet_netof ; do
119 dnl cp confdefs.h.bak confdefs.h
120 dnl cat >> confdefs.h << EOF
121 dnl #ifdef __CYGWIN32__
122 dnl #define $func cygwin32_$func
123 dnl #endif
124 dnl EOF
125 dnl AC_CHECK_FUNC($func)
126 dnl done
127 dnl cp confdefs.h.bak confdefs.h
128
129 AC_CHECK_FUNCS(sethostent endhostent getnetent setnetent endnetent getprotoent endprotoent getservent endservent getnetbyaddr getnetbyname inet_lnaof inet_makeaddr inet_netof)
130
131 dnl </GNU-WIN32 hacks>
132
133 AC_CACHE_CHECK([for restartable system calls], scm_cv_restarts,
134 if test $ac_cv_func_sigaction = yes; then
135 [AC_TRY_COMPILE([#include <signal.h>],
136 [int a = SA_RESTART],
137 scm_cv_restarts=yes,
138 scm_cv_restarts=no)]
139 else
140 scm_cv_restarts=no
141 fi)
142 if test $scm_cv_restarts = yes; then
143 AC_DEFINE(HAVE_RESTARTS)
144 fi
145
146 if test "$ac_cv_header_regex_h" = yes ||
147 test "$ac_cv_header_rxposix_h" = yes ||
148 test "$ac_cv_header_rx_rxposix_h" = yes; then
149 GUILE_NAMED_CHECK_FUNC(regcomp, norx, [LIBOBJS="regex-posix.o $LIBOBJS"],
150 [AC_CHECK_LIB(rx, main)
151 GUILE_NAMED_CHECK_FUNC(regcomp, rx, [LIBOBJS="regex-posix.o $LIBOBJS"])]
152 )
153 dnl The following should not be necessary, but for some reason
154 dnl autoheader misses it if we don't include it!
155 if test "$ac_cv_func_regcomp_norx" = yes ||
156 test "$ac_cv_func_regcomp_rx" = yes; then
157 AC_DEFINE(HAVE_REGCOMP)
158 fi
159 fi
160
161 AC_REPLACE_FUNCS(inet_aton putenv strerror)
162
163 # When testing for the presence of alloca, we need to add alloca.o
164 # explicitly to LIBOBJS to make sure that it is translated to
165 # `alloca.lo' for libtool later on. This can and should be done more cleanly.
166 AC_FUNC_ALLOCA
167 if test "$ALLOCA" = "alloca.o"; then LIBOBJS="alloca.o $LIBOBJS"; fi
168
169 AC_STRUCT_ST_RDEV
170 AC_STRUCT_ST_BLKSIZE
171
172 # We could use AC_STRUCT_ST_BLOCKS here, but that adds fileblocks.o to
173 # LIBOBJS, which we don't need. This seems more direct.
174 AC_CACHE_CHECK([for st_blocks in struct stat], ac_cv_struct_st_blocks,
175 [AC_TRY_COMPILE([#include <sys/types.h>
176 #include <sys/stat.h>], [struct stat s; s.st_blocks;],
177 ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)])
178 if test $ac_cv_struct_st_blocks = yes; then
179 AC_DEFINE(HAVE_ST_BLOCKS)
180 fi
181
182 AC_STRUCT_TIMEZONE
183 GUILE_STRUCT_UTIMBUF
184
185 #--------------------------------------------------------------------
186 #
187 # Which way does the stack grow?
188 #
189 #--------------------------------------------------------------------
190
191 AC_TRY_RUN(aux (l) unsigned long l;
192 { int x; exit (l >= ((unsigned long)&x)); }
193 main () { int q; aux((unsigned long)&q); },
194 AC_DEFINE(SCM_STACK_GROWS_UP),,AC_MSG_WARN(Guessing that stack grows down -- see scmconfig.h.in))
195
196
197 AC_TRY_RUN(main () { exit (sizeof(float) != sizeof(long)); },
198 AC_DEFINE(SCM_SINGLES),,AC_DEFINE(SCM_SINGLES)
199 AC_MSG_WARN(Guessing that sizeof(long) == sizeof(float) -- see scmconfig.h.in))
200
201 AC_MSG_CHECKING(for struct linger)
202 AC_CACHE_VAL(scm_cv_struct_linger,
203 AC_TRY_COMPILE([
204 #include <sys/types.h>
205 #include <sys/socket.h>],
206 [struct linger lgr; lgr.l_linger = 100],
207 scm_cv_struct_linger="yes",
208 scm_cv_struct_linger="no"))
209 AC_MSG_RESULT($scm_cv_struct_linger)
210 if test $scm_cv_struct_linger = yes; then
211 AC_DEFINE(HAVE_STRUCT_LINGER)
212 fi
213
214 #--------------------------------------------------------------------
215 #
216 # How can you violate a stdio abstraction by setting a stream's fd?
217 #
218 #--------------------------------------------------------------------
219
220 AC_MSG_CHECKING(how to set a stream file descriptor)
221 AC_CACHE_VAL(scm_cv_fd_setter,
222 AC_TRY_COMPILE([#include <stdio.h>],
223 [stdout->_file = 1],
224 scm_cv_fd_setter="_file",
225 AC_TRY_COMPILE([#include <stdio.h>],
226 [stdout->_fileno = 1],
227 scm_cv_fd_setter="_fileno",
228 scm_cv_fd_setter="")))
229
230 if test "$scm_cv_fd_setter"; then
231 AC_MSG_RESULT($scm_cv_fd_setter)
232 AC_DEFINE_UNQUOTED(FD_SETTER, $scm_cv_fd_setter)
233 else
234 AC_MSG_RESULT(we couldn't do it!)
235 fi
236
237 #--------------------------------------------------------------------
238 # How to find out whether a FILE structure contains buffered data.
239 # From Tk we have the following list:
240 # _cnt: Most UNIX systems
241 # __cnt: HPUX
242 # _r: BSD
243 # readCount: Sprite
244 # Or, in GNU libc there are two fields, _gptr and _egptr, which
245 # have to be compared.
246 # These can also be known as _IO_read_ptr and _IO_read_end.
247 #--------------------------------------------------------------------
248
249 AC_MSG_CHECKING(how to get buffer char count from FILE structure)
250 AC_CACHE_VAL(scm_cv_struct_file_count,
251 AC_TRY_COMPILE([#include <stdio.h>],
252 [FILE *f = stdin; f->_cnt = 0],
253 scm_cv_struct_file_count="_cnt",
254 AC_TRY_COMPILE([#include <stdio.h>],
255 [FILE *f = stdin; f->_r = 0],
256 scm_cv_struct_file_count="_r",
257 AC_TRY_COMPILE([#include <stdio.h>],
258 [FILE *f = stdin; f->readCount = 0],
259 scm_cv_struct_file_count="readCount",
260 scm_cv_struct_file_count=""))))
261 if test "$scm_cv_struct_file_count"; then
262 AC_MSG_RESULT($scm_cv_struct_file_count)
263 AC_DEFINE_UNQUOTED(FILE_CNT_FIELD, $scm_cv_struct_file_count)
264 else
265 AC_CACHE_VAL(scm_cv_struct_file_gptr,
266 AC_TRY_COMPILE([#include <stdio.h>],
267 [FILE *f = stdin; f->_gptr = f->egptr;],
268 scm_cv_struct_file_gptr=1,
269 scm_cv_struct_file_gptr=""))
270 if test "$scm_cv_struct_gptr"; then
271 AC_MSG_RESULT(gptr)
272 AC_DEFINE_UNQUOTED(FILE_CNT_GPTR, $scm_cv_struct_file_gptr)
273 else
274 AC_CACHE_VAL(scm_cv_struct_file_readptr,
275 AC_TRY_COMPILE([#include <stdio.h>],
276 [FILE *f = stdin; f->_IO_read_ptr = f->_IO_read_end;],
277 scm_cv_struct_file_readptr=1))
278 if test "$scm_cv_struct_file_readptr"; then
279 AC_MSG_RESULT(read_ptr)
280 AC_DEFINE_UNQUOTED(FILE_CNT_READPTR, $scm_cv_struct_file_readptr)
281 else
282 AC_MSG_RESULT(we couldn't do it!)
283 fi
284 fi
285 fi
286
287 #--------------------------------------------------------------------
288 #
289 # Flags for thread support
290 #
291 #--------------------------------------------------------------------
292
293 CY_AC_WITH_THREADS
294 CFLAGS="$CFLAGS $cy_cv_threads_cflags"
295 THREAD_LIBS="$cy_cv_threads_libs"
296 AC_SUBST(THREAD_LIBS)
297
298 dnl
299 dnl Set the appropriate flags!
300 dnl
301 if test "$cy_cv_threads_package" = FSU; then
302 AC_DEFINE(USE_FSU_PTHREADS, 1)
303 else if test "$cy_cv_threads_package" = COOP; then
304 AC_DEFINE(USE_COOP_THREADS, 1)
305 else if test "$cy_cv_threads_package" = MIT; then
306 AC_DEFINE(USE_MIT_PTHREADS, 1)
307 else if test "$cy_cv_threads_package" = PCthreads; then
308 AC_DEFINE(USE_PCTHREADS_PTHREADS, 1)
309 else if test "$cy_cv_threads_package" = unknown; then
310 AC_MSG_ERROR("cannot find threads installation")
311 fi
312 fi
313 fi
314 fi
315 fi
316
317 if test "$cy_cv_threads_package" != ""; then
318 AC_DEFINE(USE_THREADS)
319 LIBOBJS="$LIBOBJS threads.o"
320 fi
321
322 ## If we're using GCC, ask for aggressive warnings.
323 case "$GCC" in
324 yes ) CFLAGS="$CFLAGS -Wall -Wpointer-arith" ;;
325 esac
326
327 AC_PROG_AWK
328
329 ## If we're creating a shared library (using libtool!), then we'll
330 ## need to generate a list of .lo files corresponding to the .o files
331 ## given in LIBOBJS. We'll call it LIBLOBJS.
332 LIBLOBJS="`echo ${LIBOBJS} | sed 's/\.o/.lo/g'`"
333
334 AC_SUBST(GUILE_MAJOR_VERSION)
335 AC_SUBST(GUILE_MINOR_VERSION)
336 AC_SUBST(GUILE_VERSION)
337
338 dnl timestamping the interpreter and scheme libraries:
339 dnl
340 dnl Help us notice when we're running one version of the Guile
341 dnl interpreter against a different version of the ice-9 Scheme code.
342 dnl This will definitely detect version skew due to differing
343 dnl snapshots and releases, but may not catch skew for the developers.
344 dnl Hopefully it will not detect skew when there is none; if that
345 dnl happens, the warnings will be useless, and we should remove this.
346 GUILE_STAMP="`date`"
347 AC_SUBST(GUILE_STAMP)
348
349 AC_SUBST(AWK)
350 AC_SUBST(LIBLOBJS)
351
352
353 dnl ======================================================================
354 dnl configuration for the Qt package
355 dnl ======================================================================
356
357 threads_enabled=false
358 if test "$cy_cv_threads_package" = COOP; then
359 threads_enabled=true
360 fi
361
362 # Determine the host we are working on
363 AC_CANONICAL_HOST
364
365 # How can we refer to the qt source directory from within the qt build
366 # directory? For headers, we can rely on the fact that the qt src
367 # directory appears in the #include path.
368
369 qtsrcdir="`(cd $srcdir; pwd)`/qt"
370
371 changequote(,)dnl We use [ and ] in a regexp in the case
372 case "$host" in
373 i[3456]86-*-*)
374 qtmds_s=$qtsrcdir/md/i386.s
375 qtmd_h=md/i386.h
376 qtmdc_c=$qtsrcdir/md/null.c
377 ;;
378 mips-sgi-irix[56]*)
379 qtmds_s=$qtsrcdir/md/mips-irix5.s
380 qtmd_h=md/mips.h
381 qtmdc_c=$qtsrcdir/md/null.c
382 qtdmdb_s=$qtsrcdir/md/mips_b.s
383 ;;
384 mips-*-*)
385 qtmds_s=$qtsrcdir/md/mips.s
386 qtmd_h=md/mips.h
387 qtmdc_c=$qtsrcdir/md/null.c
388 qtdmdb_s=$qtsrcdir/md/mips_b.s
389 ;;
390 sparc-*-sunos*)
391 qtmd_h=md/sparc.h
392 qtmdc_c=$qtsrcdir/md/null.c
393 qtmds_s=$qtsrcdir/md/_sparc.s
394 qtdmdb_s=$qtsrcdir/md/_sparc_b.s
395 ;;
396 sparc-*-*)
397 qtmd_h=md/sparc.h
398 qtmdc_c=$qtsrcdir/md/null.c
399 qtmds_s=$qtsrcdir/md/sparc.s
400 qtdmdb_s=$qtsrcdir/md/sparc_b.s
401 ;;
402 alpha-*-*)
403 qtmd_h=md/axp.h
404 qtmdc_c=$qtsrcdir/md/null.c
405 qtmds_s=$qtsrcdir/md/axp.s
406 qtdmdb_s=$qtsrcdir/md/axp_b.s
407 ;;
408 *)
409 echo "Unknown configuration; threads package disabled"
410 threads_enabled=false
411 ;;
412 esac
413 changequote([, ])
414
415
416 if $threads_enabled; then
417 target_libs=libqt.a
418 else
419 target_libs=
420 fi
421
422 # Give the Makefile the names of the object files that will be
423 # generated by compiling $qtmdc_c and $qtmds_s.
424 qtmdc_o="`echo ${qtmdc_c} | sed -e 's:^.*/::' | sed -e 's:\.c$:\.o:'`"
425 qtmds_o="`echo ${qtmds_s} | sed -e 's:^.*/::' | sed -e 's:\.s$:\.o:'`"
426
427 AC_SUBST(target_libs)
428 AC_SUBST(qtmd_h)
429 AC_SUBST(qtmdc_c)
430 AC_SUBST(qtmdc_o)
431 AC_SUBST(qtmds_s)
432 AC_SUBST(qtmds_o)
433 AC_SUBST(qtmdb_s)
434
435 AC_OUTPUT([Makefile libguile/Makefile libguile/guile-snarf ice-9/Makefile ice-9/version.scm qt/Makefile qt/qt.h qt/md/Makefile qt/time/Makefile build/Makefile], [chmod +x libguile/guile-snarf])
436
437 dnl Local Variables:
438 dnl comment-start: "dnl "
439 dnl comment-end: ""
440 dnl comment-start-skip: "\\bdnl\\b\\s *"
441 dnl End: