1# $Id$
2
3AC_INIT(src/main.c)
4
5AC_PREREQ(2.50)
6AC_CONFIG_AUX_DIR(.auto)
7AC_CANONICAL_SYSTEM
8
9AM_INIT_AUTOMAKE(elk, 3.99.8)
10dnl AM_MAINTAINER_MODE
11AM_CONFIG_HEADER(config.h)
12
13AC_PROG_CC
14AM_PROG_CC_C_O
15AC_PROG_CXX
16AC_LIBTOOL_WIN32_DLL
17AC_PROG_LIBTOOL
18AC_STDC_HEADERS
19
20AC_C_CONST
21AC_C_INLINE
22AC_TYPE_SIZE_T
23
24# Check whether we are doing a native build
25AM_CONDITIONAL(NATIVE_BUILD, test "${cross_compiling}" = "no")
26
27AC_CHECK_HEADERS(inttypes.h,
28  [STDINT_HEADER="<inttypes.h>"],
29  [AC_CHECK_HEADERS(sys/inttypes.h,
30    [STDINT_HEADER="<sys/inttypes.h>"],
31    [AC_CHECK_HEADERS(sys/_inttypes.h,
32      [STDINT_HEADER="<sys/_inttypes.h>"],
33      [AC_CHECK_HEADERS(stdint.h,
34        [STDINT_HEADER="<stdint.h>"],
35        [AC_MSG_ERROR([cannot find C99 integer headers])])])])])
36AC_DEFINE_UNQUOTED(STDINT_HEADER, [${STDINT_HEADER}], [Define the C99 integer types header])
37AC_SUBST(STDINT_HEADER)
38
39# $system should contain the name of this file.  It may be used by some
40# of the build scripts to do things that are specific to one single
41# type of system.
42AC_DEFINE_UNQUOTED(SYSTEMTYPE, ["${target_os}"], [Our operating system])
43
44SYSTEM="${target_os}"
45MATH_LIBS="-lm"
46case "${target_os}" in
47  *hpux*)
48    AC_DEFINE(ARRAY_BROKEN, 1, [Define if a-=1000; a[1000] doesn't work])
49    ;;
50  *mingw32*)
51    ELK_CFLAGS="${ELK_CFLAGS} -DELK_BUILD_DLL"
52    ELK_LDFLAGS="${ELK_LDFLAGS} -no-undefined"
53    MATH_LIBS=""
54    SYSTEM="mingw32"
55    ;;
56  *cygwin*)
57    SYSTEM="cygwin"
58    ;;
59  *darwin*)
60    AC_DEFINE(SYS_DARWIN, 1, Define if the system is Darwin)
61    ;;
62esac
63ELK_LIBS="${ELK_LIBS} ${MATH_LIBS}"
64
65# Various required  headers
66AC_CHECK_HEADERS(pwd.h grp.h sys/resource.h)
67
68# The UNIX extension likes to know which of the following system calls,
69# library functions, and include files are supported by the system.
70AC_CHECK_HEADERS(utime.h sys/utime.h sys/wait.h sys/times.h dirent.h netdb.h)
71AC_CHECK_FUNCS(waitpid wait3 wait4 vfork uname gethostname gettimeofday ftime)
72AC_CHECK_FUNCS(mktemp tmpnam tempnam getcwd getwd rename regcomp environ)
73AC_MSG_CHECKING(for __environ in unistd.h)
74AC_EGREP_HEADER(__environ, unistd.h,
75 [AC_MSG_RESULT(yes)
76  AC_DEFINE(__ENVIRON_IN_UNISTD_H, 1, Define if <unistd.h> defines __environ)],
77 [AC_MSG_RESULT(no)])
78AC_MSG_CHECKING(for environ in unistd.h)
79AC_EGREP_HEADER(environ, unistd.h,
80 [AC_MSG_RESULT(yes)
81  AC_DEFINE(ENVIRON_IN_UNISTD_H, 1, Define if <unistd.h> defines environ)],
82 [AC_MSG_RESULT(no)])
83
84# Does the system support the vprintf library function?  If not,
85# availability of the (non-portable) _doprnt function is assumed.
86AC_CHECK_FUNCS(vprintf)
87
88# Does the directory(3) library follow the POSIX conventions (i.e.
89# requires the <dirent.h> include file and uses "struct dirent")?
90# If not, the (obsolete) BSD-style interface with <sys/dir.h> and
91# "struct direct" is assumed.
92AC_CHECK_FUNCS(dirent)
93
94# Does the system have the random/srandom library functions?  If not,
95# rand/srand will be used instead.
96AC_CHECK_FUNCS(random)
97
98# Does the system have the index library function?  If not, strchr
99# will be used.
100AC_CHECK_FUNCS(index)
101
102# Does the system have the bcopy, bzero, and bcmp library functions?
103# If not, memcpy/memset/memcmp will be used.
104dnl FIXME
105
106# Does using the access system call require <unistd.h> to be included?
107# (Look into the manual page for access if in doubt.)
108AC_CHECK_HEADERS(unistd.h)
109
110# If the FIONREAD ioctl command is defined, which file must be included?
111AC_CHECK_HEADERS(termios.h sys/ioctl.h sys/filio.h)
112
113# If getdtablesize() is available to determine the maximum number of open
114# files per process, set getdtablesize=yes.
115# Alternatively, if POSIX-style sysconf() can be called with _SC_OPEN_MAX,
116# set sysconf_open_max=yes.
117# If neither is set to "yes", an educated guess will be made.
118AC_CHECK_FUNCS(getdtablesize)
119
120# If POSIX-style pathconf() can be invoked with _PC_PATH_MAX to determine
121# the maximum pathname length, set pathconf_path_max=yes.
122
123# If the system page size can be determined by calling getpagesize()
124# set getpagesize=yes.
125# Alternatively, if sysconf() can be invoked with _SC_PAGESIZE, set
126# sysconf_pagesize=yes.
127# These two variables are only required if the generational garbage
128# collector is used.
129AC_CHECK_FUNCS(getpagesize)
130
131# Set reliable_signals=bsd if your system supports BSD-style reliable
132# signals (has sigblock and related functions); set reliable_signals=posix
133# for POSIX-style signals (sigprocmask, sigsets); otherwise old V7/SysV
134# signal semantics are assumed.
135AC_CHECK_HEADERS(signal.h)
136AC_CHECK_FUNCS(sigprocmask sigblock)
137
138# To support dynamic loading of object files and "dump", the system's
139# a.out format has to be known.  Choose one of the following:
140#
141#     coff  ecoff  xcoff  elf  macho  hp9k  convex
142#
143# Other values of "aout_format" are interpreted as BSD-style a.out format.
144if false; then
145  AC_DEFINE(COFF, 1, [FIXME HARD])
146fi
147
148if false; then
149  AC_DEFINE(ECOFF, 1, [FIXME HARD])
150fi
151
152if false; then
153  AC_DEFINE(XCOFF, 1, [FIXME HARD])
154fi
155
156AC_CHECK_LIB(elf, elf_begin, ac_cv_my_have_elf=yes, ac_cv_my_have_elf=no)
157AM_CONDITIONAL(HAVE_LIBELF, test "${ac_cv_my_have_elf}" = "yes")
158
159if false; then
160  AC_DEFINE(MACH_O, 1, [FIXME HARD])
161fi
162
163if false; then
164  AC_DEFINE(CONVEX_AOUT, 1, [FIXME HARD])
165fi
166
167if false; then
168  AC_DEFINE(HP9K, 1, [FIXME HARD])
169fi
170
171if test "${ac_cv_my_have_elf}" = "yes"; then
172  AC_DEFINE(HAVE_LIBELF, 1, Define if you have libelf.)
173  ELK_LIBS="${ELK_LIBS} -lelf"
174  ac_cv_my_can_dump=yes
175else
176  ac_cv_my_can_dump=no
177  dnl AC_MSG_ERROR([could not handle the native object format, if you are running Linux please install the libelf development headers])
178fi
179
180# Which mechanism should be used to dynamically load object files?
181ac_cv_my_can_load_lib=no
182
183# OS X style
184AC_CHECK_HEADERS(mach-o/dyld.h,
185  [AC_CHECK_FUNCS(NSLinkModule,
186    [AC_DEFINE(HAVE_DL_DYLD, 1, [Define if you have the Darwin dyld API])
187     AC_DEFINE(SYMS_BEGIN_WITH, ['_'], [Define if symbols start with '_'])
188     ac_cv_my_can_load_lib=yes])])
189
190# HP-UX style
191if test "${ac_cv_my_can_load_lib}" = "no"; then
192  AC_CHECK_HEADERS(dl.h)
193  ac_cv_my_have_shl_load=no
194  AC_CHECK_FUNC(shl_load,
195   [ac_cv_my_have_shl_load=yes,
196    AC_CHECK_LIB(dld, shl_load,
197     [ac_cv_my_have_shl_load=yes
198      ELK_LIBS="${ELK_LIBS} -ldld"])])
199  if test "${ac_cv_my_have_shl_load}" = "yes"; then
200    AC_DEFINE(HAVE_DL_SHL_LOAD, 1, [Define if you have the shl_load API])
201    ac_cv_my_can_load_lib=yes
202  fi
203fi
204
205# Whatever style
206if test "${ac_cv_my_can_load_lib}" = "no"; then
207  AC_CHECK_LIB(dld, dld_link,
208   [ELK_LIBS="${ELK_LIBS} -ldld"
209    AC_DEFINE(HAVE_DL_DLD_LINK, 1, [Define if you have the GNU dld library])
210    ac_cv_my_can_load_lib=yes])
211fi
212
213# BeOS style
214if test "${ac_cv_my_can_load_lib}" = "no"; then
215  AC_CHECK_HEADERS(image.h)
216  AC_CHECK_FUNCS(load_add_on,
217   [AC_DEFINE(HAVE_DL_BEOS, 1, [Define if you have the BeOS dl])
218    ac_cv_my_can_load_lib=yes])
219fi
220
221# Win32 style
222if test "${ac_cv_my_can_load_lib}" = "no"; then
223  if test "${SYSTEM}" = "mingw32" -o "${SYSTEM}" = "cygwin"; then
224    AC_CHECK_LIB(kernel32, main,
225     [ELK_LIBS="${ELK_LIBS} -lkernel32"
226      AC_DEFINE(HAVE_DL_WINDOWS, 1, [Define if you have Windows' LoadLibrary])
227      ac_cv_my_can_load_lib=yes])
228  fi
229fi
230
231AC_CHECK_HEADERS(a.out.h)
232
233# Only test for dlopen() if the others didn't work
234if test "${ac_cv_my_can_load_lib}" = "no"; then
235  AC_CHECK_HEADERS(dlfcn.h sys/dl.h)
236  ac_cv_my_have_dlopen=no
237  AC_CHECK_FUNC(dlopen,
238    ac_cv_my_have_dlopen=yes,
239    AC_CHECK_LIB(dl, dlopen,
240      ac_cv_my_have_dlopen=yes
241      ELK_LIBS="${ELK_LIBS} -ldl",
242      AC_CHECK_LIB(svld, dlopen,
243        ac_cv_my_have_dlopen=yes
244        ELK_LIBS="${ELK_LIBS} -lsvld")))
245  if test "${ac_cv_my_have_dlopen}" = "yes"; then
246    AC_DEFINE(HAVE_DL_DLOPEN, 1, [Define if you have the dlopen API])
247    ac_cv_my_can_load_lib=yes
248  fi
249fi
250
251if test "${ac_cv_my_can_load_lib}" = "yes"; then
252  AC_DEFINE(CAN_LOAD_LIB, 1, [Define if dynamic loading is supported])
253fi
254
255# Systems with "aout_format=ecoff" may require a call to the cacheflush
256# system call after an object file has been loaded.  Which include file
257# has to be included in this case?
258AC_DEFINE(CACHECTL_H, <sys/cachectl.h>, [FIXME HARD])
259
260# Is the ANSI-C atexit function supported to register an exit handler?
261# If not, the exit library function will be redefined and will end in
262# a call to _exit.
263AC_CHECK_FUNCS(atexit)
264
265# The symbol prefixes of extension initialization and finalization
266# functions (without the initial $syms_begin_with).  Do not change
267# these unless the compiler or linker restricts the length of symbols!
268AC_DEFINE(INIT_PREFIX, "elk_init_", [FIXME HARD])
269AC_DEFINE(FINIT_PREFIX, "elk_finit_", [FIXME HARD])
270
271# Is the "dump" function supported?
272if test "${ac_cv_my_can_dump}" = "yes"; then
273  AC_DEFINE(CAN_DUMP, 1, [FIXME HARD])
274fi
275
276    # Is the fchmod system call broken or unavailable?
277    if false; then
278      AC_DEFINE(FCHMOD_BROKEN, 1, [FIXME HARD])
279    fi
280
281    # These four variables are only relevant if the system has the BSD-style
282    # a.out format.
283    # segment_size is the segment size of the system's memory management
284    # unit, i.e. the number to a multiple of which the size of an a.out
285    # segment (e.g. .text) is rounded up.
286    # file_text_start is the file offset at which the text segment starts
287    # in an a.out file.
288    # mem_text_start is the starting address of the text segment in memory.
289    # text_length_adj must be set to "sizeof (struct exec)" if the length of
290    # the text segment stored in the a.out header includes the a.out header
291    # itself.
292    AC_DEFINE(SEG_SIZ, 1024, [FIXME HARD])
293    AC_DEFINE(FILE_TEXT_START, N_TXTOFF(hdr), [FIXME HARD])
294    AC_DEFINE(MEM_TEXT_START, 0, [FIXME HARD])
295    AC_DEFINE(TEXT_LENGTH_ADJ, 0, [FIXME HARD])
296
297    # Only relevant if "aout_format=coff": the system's pagesize.
298    AC_DEFINE(COFF_PAGESIZE, 4096, [FIXME HARD])
299
300    # Only relevant if "aout_format=hp9k" and "load_obj=shl"
301    AC_DEFINE(HPSHLIB, 1, [FIXME HARD])
302
303    # Print debug messages when dumping
304    AC_DEFINE(DEBUG_DUMP, 1, [FIXME HARD])
305
306# Is the "termio" terminal interface supported by the system?  If not,
307# BSD-style tty handling will be used.
308AC_DEFINE(TERMIO, 1, [FIXME HARD])
309
310# flush_stdio and flush_tty indicate how clear-input/output-port can
311# flush (purge) a FILE pointer and a TTY file descriptor.
312# Possible values of flush_stdio:
313#    bsd         assume old BSD-style FILE* (with _cnt, _ptr, _base)
314#    fpurge      use 4.4BSD-style fpurge stdio library function
315# Possible values of flush_tty:
316#    tiocflush   use TIOCFLUSH ioctl from <sys/ioctl.h>
317#    tcflsh      use TCFLSH ioctl from <termio.h>
318# Leave the variable(s) empty if flushing is not supported.
319AC_CHECK_FUNCS(fpurge)
320
321AC_CACHE_CHECK([for BSD-style flushing],
322  [ac_cv_have_bsd_flush],
323  [AC_TRY_COMPILE(
324    [#include <stdio.h>],
325    [FILE *f;
326     f->_cnt = 0;
327     f->_ptr = f->_base;],
328    ac_cv_have_bsd_flush=yes,
329    ac_cv_have_bsd_flush=no)])
330if test "${ac_cv_have_bsd_flush}" = "yes"; then
331  AC_DEFINE(HAVE_BSD_FLUSH, 1, [Define if you have BSD-style flushing])
332fi
333
334AC_CHECK_HEADERS(termio.h termios.h)
335
336# The interpreter uses the getrlimit function to determine the maximum
337# stack size of the running program.  If this function is not supported,
338# set max_stack_size to a (fixed) maximum stack size (in bytes).
339AC_CHECK_FUNCS(getrlimit)
340AC_CACHE_CHECK([for struct rlimit],
341  [ac_cv_have_struct_rlimit],
342  [AC_TRY_COMPILE(
343    [#ifdef HAVE_SYS_TIME_H
344     #   include <sys/time.h>
345     #endif
346     #ifdef HAVE_SYS_RESOURCE_H
347     #   include <sys/resource.h>
348     #endif
349     #ifdef HAVE_UNISTD_H
350     #   include <unistd.h>
351     #endif],
352    [struct rlimit rl;],
353    ac_cv_have_struct_rlimit=yes,
354    ac_cv_have_struct_rlimit=no)])
355if test "${ac_cv_have_struct_rlimit}" = "yes"; then
356  AC_DEFINE(HAVE_STRUCT_RLIMIT, 1, [Define if you have struct rlimit])
357fi
358AC_DEFINE(DEFAULT_MAX_STACK_SIZE, 1024*1024, [Define default max stack size])
359
360# Is the mprotect system call supported?  The generational garbage collector
361# requires mprotect to implement incremental GC.  $mprotect is ignored if
362# generational_gc is set to "no" in the site file.  Set mprotect=mmap if
363# mprotect is supported, but only for mmap()ed memory.
364AC_CHECK_FUNCS(mprotect)
365if false; then
366  AC_DEFINE(MPROTECT_SIG, 1, [FIXME HARD])
367fi
368if false; then
369  AC_DEFINE(MPROTECT_MMAP, 1, [FIXME HARD])
370fi
371
372# How can a SIGSEGV or SIGBUS signal handler find out the address of
373# the faulting memory reference?  This variable is only used if
374# $mprotect is "yes" or "mmap".  Possible values are:
375#
376#   siginfo     handler is called with siginfo_t structure (enabled
377#               by a call to sigaction)
378#   sigcontext  address is in the sigcontext structure (3rd arg, sc_badvaddr)
379#   arg4        address is delivered to handler as argument #4
380#   aix         use an AIX-specific hack to get hold of the bad address
381#   hpux        use a HP-UX-specific hack
382if false; then
383  AC_DEFINE(SIGSEGV_SIGINFO, 1, [FIXME HARD])
384fi
385if false; then
386  AC_DEFINE(SIGSEGV_SIGCONTEXT, 1, [FIXME HARD])
387fi
388if false; then
389  AC_DEFINE(SIGSEGV_ARG4, 1, [FIXME HARD])
390fi
391if false; then
392  AC_DEFINE(SIGSEGV_AIX, 1, [FIXME HARD])
393fi
394if false; then
395  AC_DEFINE(SIGSEGV_HPUX, 1, [FIXME HARD])
396fi
397
398# Does the system support the alloca library function, and does this
399# function actually extend the stack?  If in doubt, extract alloca.o
400# from the C library and check if it contains the symbols malloc and free.
401# If this is the case, forget it.
402AC_FUNC_ALLOCA
403dnl AC_CHECK_FUNCS(alloca)
404
405# Must <alloca.h> be included to use alloca?  Is "#pragma alloca" required?
406AC_CHECK_HEADERS(alloca.h)
407if false; then
408  AC_DEFINE(PRAGMA_ALLOCA, 1, [FIXME HARD])
409fi
410
411# Does the system (or compiler) require certain objects (e.g. doubles)
412# to be aligned at 8-byte boundaries?  If not, 4-byte alignment will
413# be assumed.
414if false; then
415  AC_DEFINE(ALIGN_8BYTE, 1, [FIXME HARD])
416fi
417
418# The name of the linker.  This is usually just "ld", or /usr/ccs/bin/ld
419# in SVR4-based systems.
420AC_DEFINE(LD_NAME, "ld", [FIXME HARD])
421
422# Does your C preprocessor support the ANSI-C ## operator, although
423# __STDC__ is not defined?
424AC_DEFINE(ANSI_CPP, 1, [FIXME HARD])
425
426# Element type of the gidset argument of getgroups(); typically int
427# or gid_t.  Only needed by the UNIX extension.
428AC_DEFINE(GETGROUPS_TYPE, gid_t, [FIXME HARD])
429
430# Do you want to use the generational garbage collector?  If not, the
431# stop-and-copy garbage collector will be used.
432AC_DEFINE(GENERATIONAL_GC, 1, [FIXME HARD])
433
434# The default heap size of the Scheme interpreter in KBytes (if the
435# stop-and-copy garbage collector is used).
436AC_DEFINE(HEAP_SIZE, 1024, [FIXME HARD])
437
438# The directory where all files are installed by running "make install". We
439# cannot use AC_DEFINE_UNQUOTED here because ${prefix} is not set until the
440# end of the configure script. Thanks to Phillip Rulon for spotting that.
441CPPFLAGS="${CPPFLAGS} -DSCM_DIR=\"\\\"\$(prefix)/share/elk\\\"\""
442CPPFLAGS="${CPPFLAGS} -DLIB_DIR=\"\\\"\$(prefix)/lib/elk\\\"\""
443
444#define FIND_AOUT defined(USE_LD) || defined(CAN_DUMP) || defined(INIT_OBJECTS)
445AC_DEFINE(FIND_AOUT, 1, [FIXME HARD])
446
447dnl
448dnl  Check for available compiler features
449dnl
450CFLAGS_save="${CFLAGS}"
451LDFLAGS_save="${LDFLAGS}"
452
453AC_CACHE_CHECK([if \$CXX really works],
454  [ac_cv_my_have_cxx],
455  [AC_LANG_PUSH(C++)
456   AC_TRY_COMPILE([],,ac_cv_my_have_cxx=yes, ac_cv_my_have_cxx=no)
457   AC_LANG_POP(C++)])
458AM_CONDITIONAL(HAVE_CXX, test "${ac_cv_my_have_cxx}" = "yes")
459
460AC_CACHE_CHECK([if \$CC accepts -Wall],
461  [ac_cv_c_Wall],
462  [CFLAGS="-Wall ${CFLAGS_save}"
463   AC_TRY_COMPILE([],,ac_cv_c_Wall=yes, ac_cv_c_Wall=no)])
464if test "x${ac_cv_c_Wall}" != "xno"; then
465  CFLAGS_save="-Wall ${CFLAGS_save}"
466fi
467
468# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
469CFLAGS_warn="-Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wmissing-prototypes -Wnested-externs -Wsign-compare"
470AC_CACHE_CHECK([if \$CC accepts ${CFLAGS_warn}],
471  [ac_cv_c_Wwarn],
472  [CFLAGS="${CFLAGS_warn} ${CFLAGS_save}"
473   AC_TRY_COMPILE([],,ac_cv_c_Wwarn=yes, ac_cv_c_Wwarn=no)])
474if test "x${ac_cv_c_Wwarn}" != "xno"; then
475  CFLAGS_save="${CFLAGS_warn} ${CFLAGS_save}"
476fi
477
478dnl
479dnl  Check for available headers and libraries
480dnl
481CFLAGS="${CFLAGS_save}"
482LDFLAGS="${LDFLAGS_save}"
483
484AM_CONDITIONAL(HAVE_MONITOR, false)
485
486AC_CHECK_LIB(gdbm, gdbm_open, ac_cv_my_have_gdbm=yes, ac_cv_my_have_gdbm=no)
487AM_CONDITIONAL(HAVE_GDBM, test "${ac_cv_my_have_gdbm}" = "yes")
488
489AC_PATH_X
490if test -n "${x_includes}"; then x_cflags="-I${x_includes}"; fi
491if test -n "${x_libraries}"; then x_libs="-I${x_libraries}"; fi
492
493AC_CHECK_LIB(X11, XOpenDisplay,
494 [ac_cv_my_have_x11=yes
495  X_CFLAGS="${x_cflags}"
496  X_LIBS="${x_libs} -lX11"],
497 [ac_cv_my_have_x11=no],
498 [[${x_libs}]])
499AM_CONDITIONAL(HAVE_X11, test "${ac_cv_my_have_x11}" = "yes")
500AC_SUBST(X_CFLAGS)
501AC_SUBST(X_LIBS)
502
503if test "${cross_compiling}" = "no"; then
504  AC_CHECK_LIB(Xt, XtFree,
505   [ac_cv_my_have_xt=yes
506    AC_CHECK_LIB(Xmu, XmuDrawLogo,
507     [XT_CFLAGS="${x_cflags}"
508      XT_LIBS="${x_libs} -lXmu -lXt -lSM -lICE -lXext -lX11"],
509     [XT_CFLAGS="${x_cflags}"
510      XT_LIBS="${x_libs} -lXt -lSM -lICE -lXext -lX11"],
511     [[-lXt -lSM -lICE -lXext -lX11 ${x_libs}]])],
512   [ac_cv_my_have_xt=no],
513   [[-lSM -lICE -lXext -lX11 ${x_libs}]])
514else
515  ac_cv_my_have_xt=no
516fi
517AM_CONDITIONAL(HAVE_XT, test "${ac_cv_my_have_xt}" = "yes")
518AC_SUBST(XT_CFLAGS)
519AC_SUBST(XT_LIBS)
520
521if test "${cross_compiling}" = "no"; then
522  AC_CHECK_LIB(Xaw, XawTextSearch,
523   [ac_cv_my_have_xaw=yes
524    XAW_CFLAGS="${x_cflags}"
525    XAW_LIBS="${x_libs} -lXaw ${XT_LIBS}"],
526   [ac_cv_my_have_xaw=no],
527   [[${XT_LIBS}]])
528else
529  ac_cv_my_have_xaw="no (cross-compiling)"
530fi
531AM_CONDITIONAL(HAVE_XAW, test "${ac_cv_my_have_xaw}" = "yes")
532AC_SUBST(XAW_CFLAGS)
533AC_SUBST(XAW_LIBS)
534
535if test "${cross_compiling}" = "no"; then
536  AC_CHECK_LIB(Xm, XmStringConcat,
537   [ac_cv_my_have_motif=yes
538    MOTIF_CFLAGS="${x_cflags} -I/usr/include/Xm"
539    MOTIF_LIBS="${x_libs} -lXm ${XT_LIBS}"],
540   [ac_cv_my_have_motif=no],
541   [[${XT_LIBS}]])
542else
543  ac_cv_my_have_motif="no (cross-compiling)"
544fi
545AM_CONDITIONAL(HAVE_MOTIF, test "${ac_cv_my_have_motif}" = "yes")
546AC_SUBST(MOTIF_CFLAGS)
547AC_SUBST(MOTIF_LIBS)
548
549INCLUDES="${INCLUDES} -I\$(top_srcdir)/include -I\$(top_builddir)/include"
550AC_SUBST(INCLUDES)
551
552dnl  Export variables
553AC_SUBST(ELK_CFLAGS)
554AC_SUBST(ELK_LDFLAGS)
555AC_SUBST(ELK_LIBS)
556
557dnl
558dnl  Check for available programs
559dnl
560AC_PROG_AWK
561AC_MSG_CHECKING(for groff -ms)
562if echo foo | groff -ms >/dev/null 2>&1; then
563  ac_cv_my_have_groff=yes
564else
565  ac_cv_my_have_groff=no
566fi
567AC_MSG_RESULT([${ac_cv_my_have_groff}])
568AM_CONDITIONAL(HAVE_GROFF, test "${ac_cv_my_have_groff}" = "yes")
569
570
571dnl
572dnl  Finished!
573dnl
574AC_CONFIG_FILES([
575  Makefile
576  doc/Makefile
577  doc/bitstring/Makefile
578  doc/cprog/Makefile
579  doc/kernel/Makefile
580  doc/man/Makefile
581  doc/oops/Makefile
582  doc/record/Makefile
583  doc/regexp/Makefile
584  doc/unix/Makefile
585  doc/usenix/Makefile
586  doc/util/Makefile
587  doc/xlib/Makefile
588  doc/xt/Makefile
589  examples/Makefile
590  include/Makefile
591  lib/Makefile
592  lib/misc/Makefile
593  lib/unix/Makefile
594  lib/xlib/Makefile
595  lib/xwidgets/Makefile
596  lib/xwidgets/xaw/Makefile
597  lib/xwidgets/motif/Makefile
598  scm/Makefile
599  src/Makefile
600  test/Makefile
601])
602AC_CONFIG_FILES([
603  scm/slib.scm
604  include/site.h
605])
606AC_CONFIG_FILES([test/check-gc], [chmod 0755 test/check-gc])
607AC_CONFIG_FILES([test/check-gc2], [chmod 0755 test/check-gc2])
608AC_CONFIG_FILES([test/check-r4rs], [chmod 0755 test/check-r4rs])
609
610AC_OUTPUT
611
612cat << EOF
613
614Elk configuration summary
615-------------------------
616build C++ plugins: ${ac_cv_my_have_cxx}
617libgdbm support: ${ac_cv_my_have_gdbm}
618X11 support: ${ac_cv_my_have_x11}
619Xaw support: ${ac_cv_my_have_xaw}
620Motif support: ${ac_cv_my_have_motif}
621build documentation: ${ac_cv_my_have_groff}
622EOF
623
624