XEmacs 21.4.20 "Double Solitaire".
[chise/xemacs-chise.git.1] / configure.in
1 dnl Define our own header notice with own copyright
2 define([AC_INIT_NOTICE],
3 [#### Configuration script for XEmacs.  Largely divergent from FSF.
4 #### Guess values for system-dependent variables and create Makefiles.
5 #### Generated automatically using autoconf version] AC_ACVERSION [
6 #### Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
7 #### Copyright (C) 1993-1995 Board of Trustees, University of Illinois.
8 #### Copyright (C) 1996, 1997 Sun Microsystems, Inc.
9 #### Copyright (C) 1995, 1996, 2005 Ben Wing.
10 #### Copyright (C) 2000, 2001 Martin Buchholz.
11 #### Copyright (C) 1998, 1999 J. Kean Johnston.
12
13 ### Don't edit this script!
14 ### This script was automatically generated by the `autoconf' program
15 ### from the file `./configure.in'.
16 ### To rebuild it, execute the command
17 ###     autoconf
18 ### in the this directory.  You must have autoconf version 2.13 or later.
19 ### Note: this script has not yet been ported to autoconf version 2.5x.
20
21 ### This file is part of XEmacs.
22
23 ### XEmacs is free software; you can redistribute it and/or modify it
24 ### under the terms of the GNU General Public License as published by
25 ### the Free Software Foundation; either version 2, or (at your
26 ### option) any later version.
27
28 ### XEmacs is distributed in the hope that it will be useful, but
29 ### WITHOUT ANY WARRANTY; without even the implied warranty of
30 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
31 ### General Public License for more details.
32
33 ### You should have received a copy of the GNU General Public License
34 ### along with XEmacs; see the file COPYING.  If not, write to the Free
35 ### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
36 ### 02111-1307, USA.
37
38 ### For usage, run `./configure --help'
39 ### For more detailed information on building and installing XEmacs,
40 ### read the file `INSTALL'.
41 ###
42 ### If configure succeeds, it leaves its status in config.status.
43 ### A log of configuration tests can be found in config.log.
44 ### If configure fails after disturbing the status quo,
45 ###     config.status is removed.
46 ])
47
48 dnl Since XEmacs has configuration requirements that autoconf cannot
49 dnl meet, this file is an unholy marriage of custom-baked
50 dnl configuration code and autoconf macros.
51
52 dnl We use the m4 quoting characters [ ] (as established by the
53 dnl autoconf system), so quote them like this: [[foo]]
54
55 AC_PREREQ(2.13)dnl
56 dnl Redefine some standard autoconf macros
57 dnl here is how XEmacs is different:
58 dnl - no cache file
59 dnl - non-standard options
60 dnl - support for extra-verbosity
61 dnl - ordinary libs are handled separately from X libs (might be a mistake)
62 dnl - various random kludges (e.g. -with-dnet=no)
63
64 dnl PRINT_VAR(var var ...)  prints values of shell variables
65 define([PRINT_VAR],[for var in patsubst([$1],[[
66 ]+],[ ]); do eval "echo \"$var = '\$$var'\""; done])
67
68 dnl Disable cache files:
69 dnl This is controversial, but I am convinced this is the right way to go,
70 dnl at least by default.  Otherwise there are too many surprises.
71 define([AC_CACHE_LOAD], )dnl
72 define([AC_CACHE_SAVE], )dnl
73 define([AC_CACHE_VAL], [
74 $2
75 ])dnl
76
77 dnl Redefine AC_TRY_RUN_NATIVE to not throw away stderr while running
78 dnl AC_TRY_RUN_NATIVE(PROGRAM, [ACTION-IF-TRUE [, ACTION-IF-FALSE]])
79 define([AC_TRY_RUN_NATIVE],
80 [cat > conftest.$ac_ext <<EOF
81 [#]line __oline__ "configure"
82 #include "confdefs.h"
83 [$1]
84 EOF
85 if AC_TRY_EVAL(ac_link) && test -s conftest && (./conftest; exit $?) 2>&AC_FD_CC
86 then
87 dnl Do not remove the temporary files here, so they can be examined.
88   ifelse([$2], , :, [$2])
89 else
90   conftest_rc="$?"
91   echo "configure: failed program was:" >&AC_FD_CC
92   cat conftest.$ac_ext >&AC_FD_CC
93 ifelse([$3], , , [  rm -fr conftest*
94   $3
95 ])dnl
96 fi
97 rm -fr conftest*])dnl AC_TRY_RUN_NATIVE
98
99
100 dnl Avoid spurious cross-compiling warnings from AC_TRY_RUN
101 dnl XEmacs is unlikely to ever cross-compile
102 define([AC_TRY_RUN],[AC_TRY_RUN_NATIVE([$1], [$2], [$3])])dnl
103
104 dnl Redefine AC_DEFINE* to provide more output if extra_verbose
105 dnl Set VARIABLE to VALUE, verbatim, or 1.
106 dnl AC_DEFINE(VARIABLE [, VALUE])
107 define([AC_DEFINE],
108 [{ test "$extra_verbose" = "yes" && cat << \EOF
109     Defining $1[]ifelse($#, 2, [ = $2],)
110 EOF
111 cat >> confdefs.h <<\EOF
112 [#define] $1 ifelse($#, 2, [$2], 1)
113 EOF
114 }
115 ])dnl AC_DEFINE
116
117 define([AC_DEFINE_UNQUOTED],
118 [{ test "$extra_verbose" = "yes" && cat << EOF
119     Defining $1[]ifelse($#, 2, [ = $2],)
120 EOF
121 cat >> confdefs.h <<EOF
122 [#define] $1 ifelse($#, 2, [$2], 1)
123 EOF
124 }
125 ])dnl AC_DEFINE_UNQUOTED
126
127 dnl redefine AC_CHECK_LIB in accordance with our own value of ac_link
128 dnl Add in extra kludgy check to support with_dnet=no
129 dnl Add in extra LDFLAGS arg, which PRECEDES libs
130 dnl Support --with-dnet=no
131
132 dnl AC_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
133 dnl             [, OTHER-LIBRARIES] [, LDFLAGS]]]])
134 define([AC_CHECK_LIB],
135 [ifelse([$1],dnet, [if test "$with_dnet" = "no" ; then
136 ac_cv_lib_dnet_dnet_ntoa=no
137 ifelse([$4], , , [$4]
138 )dnl
139 else
140 ])]
141 AC_CHECK_LIB_ORIG_HACKED([$1],[$2],[$3],[$4],[$5], [$6])
142 [ifelse([$1],dnet,[fi
143 ])]dnl
144 )dnl AC_CHECK_LIB
145
146 define([AC_CHECK_LIB_ORIG_HACKED],
147 [ifelse([$5],,AC_MSG_CHECKING([for $2 in -l$1]),
148 xe_msg_checking="for [$2] in -l[$1]"
149 test -n "[$5]" && xe_msg_checking="$xe_msg_checking using extra libs [$5]"
150 AC_MSG_CHECKING("$xe_msg_checking"))
151 dnl Use a cache variable name containing both the library and function name,
152 dnl because the test really is for library $1 defining function $2, not
153 dnl just for library $1.  Separate tests with the same $1 and different $2s
154 dnl may have different results.
155 ac_lib_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
156 AC_CACHE_VAL(ac_cv_lib_$ac_lib_var,
157 [xe_check_libs="$6 -l$1 $5"
158 AC_TRY_LINK(dnl
159 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
160 [/* Override any gcc2 internal prototype to avoid an error.  */
161 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
162 extern "C"
163 #endif
164 ])dnl
165 [/* We use char because int might match the return type of a gcc2
166     builtin and then its argument prototype would still apply.  */
167 char $2();
168 ]),
169             [$2()],
170             eval "ac_cv_lib_$ac_lib_var=yes",
171             eval "ac_cv_lib_$ac_lib_var=no")
172 xe_check_libs=""
173 ])dnl
174 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes" ; then
175   AC_MSG_RESULT(yes)
176   ifelse([$3], ,
177 [changequote(, )dnl
178   ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
179     -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
180 changequote([, ])dnl
181   AC_DEFINE_UNQUOTED($ac_tr_lib)
182   XE_PREPEND([-l$1], LIBS)
183 ], [$3])
184 else
185   AC_MSG_RESULT(no)
186 ifelse([$4], , , [$4
187 ])dnl
188 fi
189 ])dnl AC_CHECK_LIB_ORIG_HACKED
190
191
192 dnl AC_LANG_C()
193 define([AC_LANG_C],
194 [define([AC_LANG], [C])dnl
195 ac_ext=c
196 dnl CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
197 dnl ac_cpp='$CPP $CPPFLAGS'
198 dnl ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&AC_FD_CC'
199 dnl ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&AC_FD_CC'
200 xe_cppflags='$CPPFLAGS $c_switch_site $c_switch_machine $c_switch_system $c_switch_x_site $X_CFLAGS'
201 xe_ldflags='$LDFLAGS $ld_switch_site $ld_switch_machine $ld_switch_system $ld_switch_x_site $ld_switch_run'
202 xe_libs='$ld_call_shared $xe_check_libs $X_EXTRA_LIBS $libs_x $libs_gtk $X_PRE_LIBS $LIBS $libs_machine $libs_system $libs_standard'
203 ac_cpp='$CPP '"$xe_cppflags"
204 ac_compile='${CC-cc} -c $CFLAGS '"$xe_cppflags"' conftest.$ac_ext 1>&AC_FD_CC'
205 ac_link='${CC-cc} -o conftest $CFLAGS '"$xe_cppflags $xe_ldflags"' conftest.$ac_ext '"$xe_libs"' 1>&AC_FD_CC'
206 cross_compiling=no
207 ]) dnl AC_LANG_C
208
209 dnl The construct foo=`echo $w1 $w2 $w3` fails on some systems if $w1 = -e or -n
210 dnl So we use the following instead.
211 dnl XE_SPACE(var, words)
212 define([XE_SPACE],[
213 T=""
214 for W in $2; do if test -z "$T"; then T="$W"; else T="$T $W"; fi; done
215 $1="$T"
216 ])dnl XE_SPACE
217
218 dnl XE_ADD_OBJS(foo.o ...)
219 define([XE_ADD_OBJS],
220 [extra_objs="$extra_objs [$1]" && dnl
221  if test "$extra_verbose" = "yes"; then
222    echo "    xemacs will be linked with \"[$1]\""
223  fi])dnl XE_ADD_OBJS
224
225 dnl XE_APPEND(value, varname)
226 define([XE_APPEND],
227 [[$2]="$[$2] [$1]" && dnl
228  if test "$extra_verbose" = "yes"; then echo "    Appending \"[$1]\" to \$[$2]"; fi])
229
230 dnl XE_PREPEND(value, varname)
231 define([XE_PREPEND],
232 [[$2]="[$1] $[$2]" && dnl
233  if test "$extra_verbose" = "yes"; then echo "    Prepending \"[$1]\" to \$[$2]"; fi])
234
235 dnl XE_DIE(message)
236 define([XE_DIE], [{ echo "Error:" $1 >&2; exit 1; }])
237
238 dnl XE_STRIP_4TH_COMPONENT(var)
239 dnl Changes i986-pc-linux-gnu to i986-pc-linux, as God (not RMS) intended.
240 define([XE_STRIP_4TH_COMPONENT],
241 [$1=`echo "$$1" | sed '[s/^\([^-][^-]*-[^-][^-]*-[^-][^-]*\)-.*$/\1/]'`])
242
243 dnl Initialize some variables set by options.
244 dnl The variables have the same names as the options, with
245 dnl dashes changed to underlines.
246
247 define([AC_INIT_PARSE_ARGS],[
248
249 dnl Get sane consistent behavior from various shells
250 dnl Avoid losing with weird user CDPATHs
251
252 if test -n "$ZSH_VERSION"; then
253   dnl zsh's Bourne shell emulation options
254   setopt NO_BAD_PATTERN NO_BANG_HIST NO_BG_NICE NO_EQUALS NO_FUNCTION_ARGZERO
255   setopt GLOB_SUBST NO_HUP INTERACTIVE_COMMENTS KSH_ARRAYS NO_MULTIOS NO_NOMATCH
256   setopt RM_STAR_SILENT POSIX_BUILTINS SH_FILE_EXPANSION SH_GLOB SH_OPTION_LETTERS
257   setopt SH_WORD_SPLIT BSD_ECHO IGNORE_BRACES
258   dnl zsh-3.1-beta drops core on the following
259   dnl unset CDPATH
260   if test -n "$CDPATH"; then CDPATH="."; export CDPATH; fi
261 elif test -n "$BASH_VERSION"; then
262   dnl Use Posix mode with bash
263   set -o posix
264   unset CDPATH
265 else
266   if test -n "$CDPATH"; then CDPATH="."; export CDPATH; fi
267 fi
268
269 dnl Initialize some variables set by options.
270 dnl The variables have the same names as the options, with
271 dnl dashes changed to underlines.
272 exec_prefix=NONE
273 host=NONE
274 no_create=
275 nonopt=NONE
276 no_recursion=
277 prefix=NONE
278 program_prefix=NONE
279 program_suffix=NONE
280 program_transform_name=s,x,x,
281 silent=
282 site=
283 srcdir=
284 target=NONE
285 verbose=
286 x_includes=NONE
287 x_libraries=NONE
288
289 dnl Initialize some other variables.
290 subdirs=
291 MFLAGS= MAKEFLAGS=
292 SHELL=${CONFIG_SHELL-/bin/sh}
293 dnl Maximum number of lines to put in a shell here document.
294 ac_max_here_lines=12
295 ])dnl AC_INIT_PARSE_ARGS
296
297 AC_INIT(src/lisp.h)dnl
298 AC_CONFIG_HEADER(src/config.h lwlib/config.h)
299 dnl Remove any more than one leading "." element from the path name.
300 dnl If we do not remove them, then another "./" will be prepended to
301 dnl the file name each time we use config.status, and the program name
302 dnl will get larger and larger.  This would not be a problem, except
303 dnl that since progname gets recorded in all the Makefiles this script
304 dnl produces, move-if-change thinks they're different when they're
305 dnl not.
306 dnl
307 dnl It would be nice if we could put the ./ in a \( \) group and then
308 dnl apply the * operator to that, so we remove as many leading './././'s
309 dnl as are present, but some seds (like Ultrix's sed) don't allow you to
310 dnl apply * to a \( \) group.  Bleah.
311 progname="`echo $0 | sed 's:^\./\./:\./:'`"
312
313 dnl -----------------------------
314 dnl Establish some default values
315 dnl -----------------------------
316
317 XE_APPEND(lib-src, MAKE_SUBDIR)
318 XE_APPEND(lib-src, INSTALL_ARCH_DEP_SUBDIR)
319
320 prefix='/usr/local'
321 exec_prefix='${prefix}'
322 bindir='${exec_prefix}/bin'
323 dnl FSF 19.29 changes to:
324 dnl datadir='${prefix}/share'
325 dnl sharedstatedir='${prefix}/com'
326 dnl libexecdir='${exec_prefix}/libexec'
327 datadir='${prefix}/lib'
328 statedir='${prefix}/lib'
329 libdir='${exec_prefix}/lib'
330 mandir='${prefix}/man/man1'
331 inststaticdir='${PROGNAME}'
332 instvardir='${PROGNAME}-${version}'
333 infodir='${datadir}/${instvardir}/info'
334 infopath=''
335 install_pp=''
336 lispdir='${datadir}/${instvardir}/lisp'
337 moduledir='${libdir}/${instvardir}/${configuration}/modules'
338 sitelispdir='${datadir}/${inststaticdir}/site-lisp'
339 sitemoduledir='${libdir}/${inststaticdir}/site-modules'
340 pkgdir='${datadir}/${instvardir}/lisp'
341 package_path=''
342 etcdir='${datadir}/${instvardir}/etc'
343 archlibdir='${libdir}/${instvardir}/${configuration}'
344 docdir='${archlibdir}'
345 with_netinstall="no"
346 with_prefix='yes'
347 with_site_lisp='no'
348 with_site_modules='yes'
349 with_menubars=''
350 with_scrollbars=''
351 dnl can't turn off widgets here because of systems where they are demanded
352 with_widgets=''
353 with_dialogs=''
354 with_file_coding=''
355 cpp='' cppflags='' libs='' ldflags=''
356 extra_includes=''
357 dynamic=''
358 with_x11=''
359 with_msw=''
360 rel_alloc='default'
361 with_system_malloc='default'
362 with_dlmalloc='default'
363 use_regex_malloc='yes'
364 dnl ESD is associated with crashes and lockups due to incorrect signal use.
365 with_esd_sound='no'
366 native_sound_lib=''
367 dnl These should be set to the empty string when we want gtk / gnome to
368 dnl be auto-detected instead of manually specified.
369 with_gtk='no'
370 with_gnome='no'
371 dnl use_assertions should be 'yes' by default.  Too many people in this
372 dnl world have core dumps turned off by default or \"cannot find where the
373 dnl core file went\".  At least we should get some useful output ...
374 use_assertions="yes"
375 dnl the following is set to yes or no later.
376 with_toolbars=""
377 with_tty=""
378 use_union_type="no"
379 with_dnet=""
380 dnl pdump now defaults by opsys
381 pdump=''
382 dnl dragndrop is still experimental.  When it is stable, comment out the following line:
383 with_dragndrop="no"
384 dnl Too annoying, even if mandated by IPv6 (and I'm not even sure of that)
385 with_ipv6_cname="no"
386
387 dnl ------------------
388 dnl Options Processing
389 dnl ------------------
390
391 define([USAGE_ERROR],
392 [(echo "$progname: Usage error:"
393 echo " " $1
394 echo "  Use \`$progname --help' to show usage.") >&2 && exit 1])
395
396 dnl Record all the arguments, so we can save them in config.status.
397 arguments="$@"
398
399 dnl Shell Magic: Quote the quoted arguments in ARGUMENTS.  At a later date,
400 dnl in order to get the arguments back in $@, we have to do an
401 dnl 'eval set x "$quoted_arguments"; shift'
402 dnl # We use sed to turn embedded ' into '"'"'.  I truly hate sh quoting.
403 quoted_sed_magic=s/"'"/"'"'"'"'"'"'"'"/g
404 quoted_arguments=
405 for i in "$@"; do
406    case "$i" in
407    -no-create | --no-create | --no-creat | --no-crea | --no-cre \
408    | --no-cr | --no-c) ;;
409    -no-recursion | --no-recursion | --no-recursio | --no-recursi \
410    | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
411    *)
412    quoted_i="`echo '' $i | sed -e 's:^ ::' -e $quoted_sed_magic`"
413    quoted_arguments="$quoted_arguments '$quoted_i'" ;;
414    esac
415 done
416
417 dnl Do not use shift -- that destroys the argument list, which autoconf needs
418 dnl to produce config.status.  It turns out that "set - $arguments" does not
419 dnl work portably.
420 dnl However, it also turns out that many shells cannot expand ${10} at all.
421 dnl So using an index variable does not work either.  It is possible to use
422 dnl some shell magic to make 'set x "$arguments"; shift' work portably.
423 while test $# != 0; do
424   arg="$1"; shift
425   case "$arg" in
426     --no-create|--no-recursion) ;;
427     dnl Anything starting with a hyphen we assume is an option.
428     -* )
429       dnl Separate the switch name from the value it is being given.
430       case "$arg" in
431         -*=*)
432           opt=`echo '' $arg | sed -e 's:^ ::' -e 's:^-*\([[^=]]*\)=.*$:\1:'`
433           val=`echo '' $arg | sed -e 's:^ ::' -e 's:^-*[[^=]]*=\(.*\)$:\1:'`
434           valomitted=no
435         ;;
436            dnl special case these strings since echo may silently eat them:
437            dnl --help ) opt=help val=yes valomitted=yes ;;
438            dnl --version ) opt=version val=yes valomitted=yes ;;
439            dnl -e ) opt=e val=yes valomitted=yes ;;
440            dnl -E ) opt=E val=yes valomitted=yes ;;
441            dnl -n ) opt=n val=yes valomitted=yes ;;
442         -*)
443            dnl If FOO is a boolean argument, --FOO is equivalent to
444            dnl --FOO=yes.  Otherwise, the value comes from the next
445            dnl argument - see below.
446           opt=`echo '' $arg | sed -e 's:^ ::' -e 's:^-*\(.*\)$:\1:'`
447           val="yes" valomitted=yes
448         ;;
449       esac
450
451       dnl translate "-" in option string to "_"
452       optname="$opt"
453       opt="`echo '' $opt | sed -e 's:^ ::' | tr - _`"
454
455       dnl Support --without-FOO as a synonym for --with-FOO=no
456       case "${valomitted}-${opt}" in yes-without_* )
457         opt=`echo $opt | sed 's/without/with/'`
458         valomitted="no" val="no" ;;
459       esac
460
461       dnl Process the option.
462       case "$opt" in
463
464       dnl Process (many) boolean options
465         with_site_lisp  | \
466         with_prefix     | \
467         with_site_modules | \
468         with_x          | \
469         with_x11        | \
470         with_gtk        | \
471         with_gnome      | \
472         with_msw        | \
473         with_gcc        | \
474         dynamic         | \
475         with_ncurses    | \
476         with_dnet       | \
477         with_socks      | \
478         with_dragndrop  | \
479         with_cde        | \
480         with_offix      | \
481         with_gpm        | \
482         with_xpm        | \
483         with_xface      | \
484         with_gif        | \
485         with_jpeg       | \
486         with_png        | \
487         with_tiff       | \
488         with_wmcommand  | \
489         with_xmu        | \
490         with_purify     | \
491         with_quantify   | \
492         with_toolbars   | \
493         with_tty        | \
494         with_xfs        | \
495         with_i18n3      | \
496         with_mule       | \
497         with_file_coding| \
498         with_canna      | \
499         with_wnn        | \
500         with_wnn6       | \
501         with_workshop   | \
502         with_sparcworks | \
503         with_tooltalk   | \
504         with_ldap       | \
505         with_postgresql | \
506         with_pop        | \
507         with_kerberos   | \
508         with_hesiod     | \
509         with_dnet       | \
510         with_infodock   | \
511         with_netinstall | \
512         with_ipv6_cname | \
513         external_widget | \
514         verbose         | \
515         extra_verbose   | \
516         usage_tracking  | \
517         use_union_type  | \
518         pdump           | \
519         debug           | \
520         use_assertions  | \
521         use_regex_malloc | \
522         memory_usage_stats | \
523         with_clash_detection | \
524         with_modules    | \
525         quick_build )
526           dnl Make sure the value given was either "yes" or "no".
527           case "$val" in
528             y | ye | yes )      val=yes ;;
529             n | no )            val=no  ;;
530             * ) USAGE_ERROR("The \`--$optname' option requires a boolean value: \`yes' or \`no'.") ;;
531           esac
532           eval "$opt=\"$val\"" ;;
533
534
535         dnl Options that take a user-supplied value, as in --x-includes=/usr/X11R6/include
536         dnl The cache-file option is ignored (for compatibility with other configures)
537         srcdir          | \
538         compiler        | \
539         cflags          | \
540         cpp             | \
541         cppflags        | \
542         libs            | \
543         ldflags         | \
544         cache_file      | \
545         native_sound_lib| \
546         site_lisp       | \
547         x_includes      | \
548         x_libraries     | \
549         site_includes   | \
550         site_libraries  | \
551         site_prefixes   | \
552         site_runtime_libraries )
553           dnl If the value was omitted, get it from the next argument.
554           if test "$valomitted" = "yes" ; then
555             dnl Get the next argument from the argument list, if there is one.
556             if test "$#" = 0 ; then
557               USAGE_ERROR("The \`--$optname' option requires a value.");
558             fi
559             val="$1"; shift
560           fi
561           eval "$opt=\"$val\""
562         ;;
563
564         dnl Options that take "yes", "no", or "default" values
565         rel_alloc | \
566         with_dlmalloc | \
567         with_debug_malloc  | use_debug_malloc | \
568         with_system_malloc | use_system_malloc )
569           case "$val" in
570             y | ye | yes )      val=yes ;;
571             n | no )            val=no  ;;
572             d | de | def | defa | defau | defaul | default ) val=default ;;
573             * ) USAGE_ERROR(["The \`--$optname' option requires one of these values:
574   \`yes', \`no', or \`default'."]) ;;
575           esac
576           case "$opt" in use_* ) opt="`echo $opt | sed s/use/with/`" ;; esac
577           eval "$opt=\"$val\""
578         ;;
579
580         dnl Has the user requested database support?
581         "with_database" )
582           with_database_berkdb=no
583           with_database_dbm=no
584           with_database_gdbm=no
585           for x in `echo "$val" | sed -e 's/,/ /g'` ; do
586             case "$x" in
587               no ) ;;
588               b | be | ber | berk | berkd | berkdb )       with_database_berkdb=yes ;;
589               d | db | dbm )                               with_database_dbm=yes    ;;
590               g | gn | gnu | gnud | gnudb | gnudbm | gdbm) with_database_gdbm=yes   ;;
591               * ) USAGE_ERROR(["The \`--$optname' option value
592   must be either \`no' or a comma-separated list
593   of one or more of \`berkdb' and either \`dbm' or \`gnudbm'."]) ;;
594             esac
595           done
596           if test "$with_database_dbm"  = "yes" -a \
597                   "$with_database_gdbm" = "yes"; then
598           USAGE_ERROR("Only one of \`dbm' and \`gnudbm' may be specified
599   with the \`--$optname' option.")
600           fi
601         ;;
602
603         dnl Has the user requested sound support?
604         "with_sound" )
605         dnl values is a subset of all,native,nas,esd
606         dnl or their negatives: none,nonative,nonas,noesd
607           for x in `echo "$val" | sed -e 's/,/ /g'` ; do
608             case "$x" in
609               dnl all and none are only permitted as the first in the list.
610               n | no | non | none ) new_sdefault=no ;;
611               a | al | all | both ) new_sdefault=yes ;;
612
613               native )       with_native_sound=yes ;;
614               nonative )     with_native_sound=no ;;
615
616               nas )          with_nas_sound=yes ;;
617               nonas )        with_nas_sound=no ;;
618
619               esd )          with_esd_sound=yes ;;
620               noesd )        with_esd_sound=no ;;
621
622               * ) bogus_sound=yes ;;
623             esac
624             if test "$bogus_sound" -o \
625                  \( -n "$new_sdefault" -a -n "$sound_notfirst" \) ; then
626                 types="\`all', \`none', \`(no)native', \`no(nas)', \`(no)esd'."
627                 USAGE_ERROR(["Valid types for the \`--$optname' option are:
628   $types.
629 Option \`all' or \`none' must be first in the list.
630 The default is to autodetect native and NAS sound support."])
631             elif test -n "$new_sdefault" ; then
632                 with_native_sound=$new_sdefault
633                 with_nas_sound=$new_sdefault
634                 with_esd_sound=$new_sdefault
635                 new_sdefault=   # reset this
636             fi
637             sound_notfirst=true
638           done
639         ;;
640
641         dnl Has the user specified a preferred Athena widget set?
642         dnl This bit expands any alias names out for us...
643         "with_athena" )
644           case "$val" in
645             xa | xaw )                    val=xaw    ;;
646             3 | 3d | xaw3d )              val=3d     ;;
647             dnl No `n' for next, someone may try `no'
648             ne | nex | next | naxtaw)     val=next   ;;
649             dnl Have not tested the next two...
650             9 | 95 | xaw95 )              val=95     ;;
651             xp | xpm | xawxpm )           val=xpm    ;;
652             * ) USAGE_ERROR(["The \`--$optname' option must have one of these values:
653   \`xaw', \`3d', \`next', \`95', or \`xpm'."]) ;;
654           esac
655           eval "$opt=\"$val\""
656         ;;
657
658         dnl Has the user requested XIM support?
659         "with_xim" )
660           case "$val" in
661             y | ye | yes )                val=yes   ;;
662             n | no | non | none )         val=no    ;;
663             x | xl | xli | xlib )         val=xlib  ;;
664             m | mo | mot | moti | motif ) val=motif ;;
665             * ) USAGE_ERROR(["The \`--$optname' option must have one of these values:
666   \`motif', \`xlib', \`yes', or \`no'."]) ;;
667           esac
668           eval "$opt=\"$val\""
669         ;;
670
671         dnl Mail locking specification
672         "mail_locking" )
673           case "$val" in
674             lockf )     val=lockf ;;
675             flock )     val=flock ;;
676             file | dot ) val=file  ;;
677             locking )   val=locking  ;;
678             * ) USAGE_ERROR(["The \`--$optname' option must have one of these values:
679   \`lockf', \`flock', \`file', \`locking', or \`mmdf'."]) ;;
680           esac
681           eval "$opt=\"$val\""
682         ;;
683
684         dnl Has the user requested error-checking?
685         "error_checking" )
686           dnl value can be all, none, and/or a list of categories to check.
687           dnl Example: --error-checking=all,noextents,nobufpos
688           dnl Example: --error-checking=none,malloc,gc
689
690           for x in `echo "$val" | sed -e 's/,/ /g'` ; do
691             case "$x" in
692               dnl all and none are only permitted as the first in the list.
693               n | no | non | none ) new_default=no ;;
694               a | al | all )        new_default=yes ;;
695
696               extents )       error_check_extents=yes ;;
697               noextents )     error_check_extents=no ;;
698
699               typecheck )     error_check_typecheck=yes ;;
700               notypecheck )   error_check_typecheck=no ;;
701
702               bufpos )        error_check_bufpos=yes ;;
703               nobufpos )      error_check_bufpos=no ;;
704
705               gc )            error_check_gc=yes ;;
706               nogc )          error_check_gc=no ;;
707
708               malloc )        error_check_malloc=yes ;;
709               nomalloc )      error_check_malloc=no ;;
710
711               byte_code )     error_check_byte_code=yes ;;
712               nobyte_code )   error_check_byte_code=no ;;
713
714               glyphs )     error_check_glyphs=yes ;;
715               noglyphs )   error_check_glyphs=no ;;
716
717               * ) bogus_error_check=yes ;;
718             esac
719             if test "$bogus_error_check" -o \
720                  \( -n "$new_default" -a -n "$echeck_notfirst" \) ; then
721                 if test "$error_check_default" = yes ; then
722                   types="\`all' (default), \`none', \`noextents', \`notypecheck', \`nobufpos', \`nogc', \`nomalloc', \`noglyphs' and \`nobyte-code'."
723                 else
724                   types="\`all', \`none' (default), \`extents', \`typecheck', \`bufpos', \`gc', \`malloc', \`glyphs' and \`byte-code'."
725                 fi
726                 USAGE_ERROR(["Valid types for the \`--$optname' option are:
727   $types."])
728             elif test -n "$new_default" ; then
729                 error_check_extents=$new_default
730                 error_check_typecheck=$new_default
731                 error_check_bufpos=$new_default
732                 error_check_gc=$new_default
733                 error_check_malloc=$new_default
734                 error_check_byte_code=$new_default
735                 error_check_glyphs=$new_default
736                 new_default=    # reset this
737             fi
738             echeck_notfirst=true
739           done
740         ;;
741
742         dnl Has the user tried to tell us where the X files are?
743         dnl I think these are dopey, but no less than three alpha
744         dnl testers, at large sites, have said they have their X files
745         dnl installed in odd places.
746
747         dnl Has the user specified one of the path options?
748         prefix | exec_prefix | bindir | datadir | statedir | libdir | \
749         mandir | infodir | infopath | lispdir | etcdir | pkgdir | \
750         archlibdir | docdir | package_path | moduledir )
751            dnl If the value was omitted, get it from the next argument.
752            if test "$valomitted" = "yes"; then
753              if test "$#" = 0; then
754                  USAGE_ERROR("The \`--$optname' option requires a value.");
755              fi
756              val="$1"; shift
757            fi
758            eval "$opt=\"$val\""
759
760            dnl You need to synchronize this with the way the
761            dnl default values are built.
762            case "$opt" in
763              dnl prefix is taken care of by --with-prefix
764              exec_prefix ) AC_DEFINE(EXEC_PREFIX_USER_DEFINED) ;;
765              lispdir ) AC_DEFINE(LISPDIR_USER_DEFINED) ;;
766              sitelispdir ) AC_DEFINE(SITELISPDIR_USER_DEFINED) ;;
767              moduledir ) AC_DEFINE(MODULEDIR_USER_DEFINED) ;;
768              etcdir  )  AC_DEFINE(ETCDIR_USER_DEFINED) ;;
769              infodir ) AC_DEFINE(INFODIR_USER_DEFINED) ;;
770              infopath ) AC_DEFINE(INFOPATH_USER_DEFINED) ;;
771              package_path ) AC_DEFINE(PACKAGE_PATH_USER_DEFINED) ;;
772              datadir )
773                 AC_DEFINE(INFODIR_USER_DEFINED)
774                 AC_DEFINE(LISPDIR_USER_DEFINED)
775                 AC_DEFINE(MODULEDIR_USER_DEFINED)
776                 AC_DEFINE(ETCDIR_USER_DEFINED)
777                 AC_DEFINE(DOCDIR_USER_DEFINED)
778                 AC_DEFINE(ARCHLIBDIR_USER_DEFINED) ;;
779              docdir ) AC_DEFINE(DOCDIR_USER_DEFINED) ;;
780              exec_prefix | libdir | archlibdir ) AC_DEFINE(ARCHLIBDIR_USER_DEFINED) ;;
781            esac
782         ;;
783
784         dnl --no-create added by autoconf for use by config.status
785         "no_create" ) ;;
786
787         dnl Has the user asked for some help?
788         "usage" | "help" ) ${PAGER-more} ${srcdir}/configure.usage; exit 0 ;;
789
790         dnl Has the user specified the toolkit(s) to use for GUI elements?
791         "with_menubars"   | \
792         "with_scrollbars" | \
793         "with_dialogs"    | \
794         "with_widgets" )
795           case "$val" in
796             l | lu | luc | luci | lucid )               val=lucid  ;;
797             mo | mot | moti | motif )                   val=motif  ;;
798             a | at | ath | athe | athen | athena )      val=athena ;;
799             n | no | non | none )                       val=no     ;;
800             y | ye | yes )                              val=yes    ;;
801             dnl Explicit --with-widgets on command line means yes.
802             "")                                         val=yes    ;;
803             g | gt | gtk )                              val=gtk    ;;
804             ms | msw )                                  val=msw    ;;
805             * ) USAGE_ERROR(["The \`--$optname' option must have one of these values:
806   \`gtk', \`lucid', \`motif', \`athena', \`yes', or \`no'."]) ;;
807           esac
808           eval "$opt=\"$val\""
809         ;;
810
811         dnl Obsolete legacy argument?  Warn, but otherwise ignore.
812         "use_minimal_tagbits" | \
813         "use_indexed_lrecord_implementation" | \
814         "run_in_place"  | \
815         "const_is_losing" | \
816         "with_gnu_make" )
817           AC_MSG_WARN([Obsolete option \`--$optname' ignored.])
818         ;;
819
820         dnl Unrecognized option?  No mercy for user errors.
821         * ) USAGE_ERROR("Unrecognized option: $arg") ;;
822
823       esac
824     ;;
825
826     dnl Assume anything with multiple hyphens is a configuration name.
827     *-*-*) configuration="$arg" ;;
828
829     dnl Unrecognized argument?  No mercy for user errors.
830     *) USAGE_ERROR("Unrecognized argument: $arg") ;;
831
832   esac
833 done
834
835 dnl -------------------------
836 dnl Finish options processing
837 dnl -------------------------
838
839 dnl Several options are equivalent to, and override, environment variables.
840 test -n "$cpp"      && CPP="$cpp"
841 test -n "$cppflags" && CPPFLAGS="$cppflags"
842 test -n "$libs"     && LIBS="$libs"
843 test -n "$ldflags"  && LDFLAGS="$ldflags"
844
845 dnl Get the arguments back.  See the diatribe on Shell Magic above.
846 eval set x "$quoted_arguments"; shift
847
848 dnl --extra-verbose implies --verbose
849 test "$extra_verbose" = "yes" && verbose=yes
850
851 dnl with_x is an obsolete synonym for with_x11
852 test -n "$with_x" && with_x11="$with_x"
853
854 dnl --with-quantify or --with-purify imply --use-system-malloc
855 if test "$with_purify" = "yes" -o "$with_quantify" = "yes"; then
856   test "$with_system_malloc" = "default" && with_system_malloc=yes
857 fi
858
859 dnl XE_CHECK_FEATURE_DEPENDENCY(feature1, feature2)
860 define([XE_CHECK_FEATURE_DEPENDENCY],
861 [if test "$with_$1 $with_$2" = "yes no"; then
862   USAGE_ERROR("--with-$1 requires --with-$2")
863 elif test "$with_$2" = "no" ; then with_$1=no
864 elif test "$with_$1" = "yes"; then with_$2=yes
865 fi
866 ])
867
868 dnl CDE requires tooltalk
869 XE_CHECK_FEATURE_DEPENDENCY(cde, tooltalk)
870
871 dnl Find the source directory.
872 case "$srcdir" in
873
874   dnl If srcdir is not specified, see if  "." or ".." might work.
875   "" )
876     for dir in "`echo $0 | sed 's|//|/|' | sed 's|/[[^/]]*$||'`" "." ".." ; do
877       if test -f "$dir/src/lisp.h" -a \
878               -f "$dir/lisp/version.el" ; then
879         srcdir="$dir"
880         break
881       fi
882     done
883     if test -z "$srcdir" ; then
884       USAGE_ERROR(["Neither the current directory nor its parent seem to
885   contain the XEmacs sources.  If you do not want to build XEmacs in its
886   source tree, you should run \`$progname' in the directory in which
887   you wish to build XEmacs, using the \`--srcdir' option to say where the
888   sources may be found."])
889     fi
890   ;;
891
892   dnl Otherwise, check if the directory they specified is okay.
893   * )
894     if test ! -f "$srcdir/src/lisp.h" -o \
895             ! -f "$srcdir/lisp/version.el" ; then
896       USAGE_ERROR(["The directory specified with the \`--srcdir' option,
897   \`$srcdir', doesn't seem to contain the XEmacs sources.  You should
898   either run the \`$progname' script at the top of the XEmacs source
899   tree, or use the \`--srcdir' option to specify the XEmacs source directory."])
900     fi
901   ;;
902 esac
903
904 dnl ###########################################################################
905 if test -z "$configuration"; then
906   dnl Guess the configuration
907   configuration=`${CONFIG_SHELL-/bin/sh} $srcdir/config.guess`
908   if test -z "$configuration"; then
909     USAGE_ERROR(["XEmacs has not been ported to this host type.
910 Try explicitly specifying the CONFIGURATION when rerunning configure."])
911   fi
912 fi
913
914 AC_PROG_LN_S
915
916 dnl Make symlinks for etc, lisp, and info directories while the path
917 dnl is still relative.  We do not symlink lock because someone may
918 dnl have stuck the source on a read-only partition.  Instead we
919 dnl create it as an actual directory later on if it does not already
920 dnl exist.
921 for dir in lisp etc man info tests; do
922   if test ! -d "$dir" ; then
923     echo Making symbolic link to "$srcdir/$dir"
924     ${LN_S} "$srcdir/$dir" "$dir"
925   fi
926 done
927
928 dnl Do our best to deal with automounter brokenness
929 dnl CANONICALIZE_PATH(varname)
930 define([CANONICALIZE_PATH],
931 [if test -d "/net"; then
932   if test -d "/tmp_mnt/net"; then tdir="tmp_mnt/net"; else tdir="tmp_mnt"; fi
933   $1=`echo "[$]$1" | \
934    sed -e "s|^${tdir}/|/net/|" -e "s|^/a/|/net/|" -e "s|^/amd/|/net/|"`
935 fi])dnl
936
937 dnl Calculate canonical name for blddir (i.e. current directory).
938 dnl PWD may already be the preferable absolute name for ".",
939 dnl but we can't trust it - it is sometimes inaccurate.
940 absolute_pwd="`pwd`";
941 if test -n "$PWD" -a "`cd $PWD && pwd`" = "$absolute_pwd"
942 then blddir="$PWD"
943 else blddir="$absolute_pwd"; CANONICALIZE_PATH(blddir)
944 fi
945 AC_SUBST(blddir)
946
947 dnl Make srcdir absolute, if not already.  It is important to
948 dnl avoid running the path through pwd unnecessary, since pwd can
949 dnl give you automounter prefixes, which can go away.
950 case "$srcdir" in
951   /* ) ;;
952   .  ) srcdir="$blddir" ;;
953   *  ) srcdir="`cd $srcdir && pwd`"; CANONICALIZE_PATH(srcdir) ;;
954 esac
955
956 dnl Check if the source directory already has a configured system in it.
957 if test `pwd` != `sh -c cd $srcdir && pwd`  \
958    && test -f "$srcdir/src/config.h"; then
959   (echo "$progname: WARNING: The directory tree \`$srcdir' is being used"
960    echo "   as a build directory right now; it has been configured in its own"
961    echo "   right.  To configure in another directory as well, you MUST"
962    echo "   use GNU make.  If you do not have GNU make, then you must"
963    echo "   now do \`make distclean' in $srcdir,"
964    echo "   and then run $progname again.") >&2
965   extrasub='/^VPATH[[    ]]*=/c\
966 vpath %.c $(srcdir)\
967 vpath %.h $(srcdir)\
968 vpath %.y $(srcdir)\
969 vpath %.l $(srcdir)\
970 vpath %.s $(srcdir)\
971 vpath %.in $(srcdir)'
972 fi
973
974 dnl ----------------------------------------
975 dnl Find out which version of XEmacs this is
976 dnl ----------------------------------------
977 . "$srcdir/version.sh" || exit 1;
978 dnl Must do the following first to determine verbosity for AC_DEFINE
979 if test -n "$emacs_is_beta"; then beta=yes; else beta=no; fi
980 : "${extra_verbose=$beta}"
981 version="${emacs_major_version}.${emacs_minor_version}"
982 AC_DEFINE_UNQUOTED(EMACS_MAJOR_VERSION, $emacs_major_version)
983 AC_DEFINE_UNQUOTED(EMACS_MINOR_VERSION, $emacs_minor_version)
984 if test -n "$emacs_beta_version" ; then
985   if test "$beta" = "yes"; then
986         version="${version}-b${emacs_beta_version}"
987         AC_DEFINE_UNQUOTED(EMACS_BETA_VERSION, $emacs_beta_version)
988   else
989         version="${version}.${emacs_beta_version}"
990         AC_DEFINE_UNQUOTED(EMACS_PATCH_LEVEL, $emacs_beta_version)
991   fi
992 fi
993 AC_DEFINE_UNQUOTED(XEMACS_CODENAME, "$xemacs_codename")
994 AC_DEFINE_UNQUOTED(EMACS_VERSION, "$version")
995
996 if test "$with_infodock" = "yes"; then
997   if test ! -f ../../ID-INSTALL; then
998     echo "Cannot build InfoDock without InfoDock sources"
999     with_infodock=no
1000   fi
1001 fi
1002
1003 if test "$with_infodock" = "yes"; then
1004   dnl InfoDock version numbers.  XEmacs will use the same style of numbering
1005   dnl after the release of XEmacs 21.0.
1006   AC_DEFINE_UNQUOTED(INFODOCK_MAJOR_VERSION, $infodock_major_version)
1007   AC_DEFINE_UNQUOTED(INFODOCK_MINOR_VERSION, $infodock_minor_version)
1008   AC_DEFINE_UNQUOTED(INFODOCK_BUILD_VERSION, $infodock_build_version)
1009   version=${infodock_major_version}.${infodock_minor_version}.${infodock_build_version}
1010   PROGNAME=infodock
1011   CPPFLAGS="$CPPFLAGS -DINFODOCK"
1012 else
1013   PROGNAME=xemacs
1014 fi
1015
1016 AC_DEFINE_UNQUOTED(EMACS_PROGNAME, "$PROGNAME")
1017
1018 dnl ----------------------------------
1019 dnl Error checking and debugging flags
1020 dnl ----------------------------------
1021 dnl Error checking default to "yes" in beta versions, to "no" in releases.
1022 dnl Same goes for --debug and --extra-verbosity.
1023 if test -n "$emacs_is_beta"; then beta=yes; else beta=no; fi
1024 test "${error_check_extents=$beta}"   = yes && AC_DEFINE(ERROR_CHECK_EXTENTS)
1025 test "${error_check_typecheck=$beta}" = yes && AC_DEFINE(ERROR_CHECK_TYPECHECK)
1026 test "${error_check_bufpos=$beta}"    = yes && AC_DEFINE(ERROR_CHECK_BUFPOS)
1027 test "${error_check_gc=$beta}"        = yes && AC_DEFINE(ERROR_CHECK_GC)
1028 test "${error_check_malloc=$beta}"    = yes && AC_DEFINE(ERROR_CHECK_MALLOC)
1029 test "${error_check_byte_code=$beta}" = yes && AC_DEFINE(ERROR_CHECK_BYTE_CODE)
1030 test "${error_check_glyphs=$beta}" = yes && AC_DEFINE(ERROR_CHECK_GLYPHS)
1031 dnl debug=yes must be set when error checking is present.  This should be
1032 dnl fixed up.
1033 dnl debug implies other options
1034 if test "${debug:=$beta}" = "yes"; then
1035   use_assertions=yes memory_usage_stats=yes
1036   XE_ADD_OBJS(debug.o)
1037   XE_ADD_OBJS(tests.o)
1038   AC_DEFINE(DEBUG_XEMACS)
1039 fi
1040 test "$use_assertions"     = "yes" && AC_DEFINE(USE_ASSERTIONS)
1041 test "$memory_usage_stats" = "yes" && AC_DEFINE(MEMORY_USAGE_STATS)
1042
1043 dnl ------------------------------
1044 dnl Determine the s&m files to use
1045 dnl ------------------------------
1046 dnl Given the configuration name, set machfile and opsysfile to the
1047 dnl names of the m/*.h and s/*.h files we should use.
1048
1049 dnl Canonicalize the configuration name.
1050 AC_MSG_CHECKING("host system type")
1051 dnl allow -workshop suffix on configuration name
1052 internal_configuration=`echo $configuration | sed 's/-\(workshop\)//'`
1053 canonical=`${CONFIG_SHELL-/bin/sh} $srcdir/config.sub "$internal_configuration"`
1054 XE_STRIP_4TH_COMPONENT(configuration)
1055 XE_STRIP_4TH_COMPONENT(canonical)
1056 AC_MSG_RESULT($configuration)
1057
1058 dnl If you add support for a new configuration, add code to this
1059 dnl switch statement to recognize your configuration name and select
1060 dnl the appropriate operating system and machine description files.
1061
1062 dnl You would hope that you could choose an m/*.h file pretty much
1063 dnl based on the machine portion of the configuration name, and an s-
1064 dnl file based on the operating system portion.  However, it turns out
1065 dnl that each m/*.h file is pretty manufacturer-specific - for
1066 dnl example, apollo.h, hp9000s300.h, mega68k, news.h, and tad68k are
1067 dnl all 68000 machines; mips.h, pmax.h, and news-risc are all MIPS
1068 dnl machines.  So we basically have to have a special case for each
1069 dnl configuration name.
1070
1071 dnl As far as handling version numbers on operating systems is
1072 dnl concerned, make sure things will fail in a fixable way.  If
1073 dnl /etc/MACHINES says nothing about version numbers, be
1074 dnl prepared to handle anything reasonably.  If version numbers
1075 dnl matter, be sure /etc/MACHINES says something about it.
1076
1077 dnl Eric Raymond says we should accept strings like "sysvr4" to mean
1078 dnl "System V Release 4"; he writes, "The old convention encouraged"
1079 dnl "confusion between `system' and `release' levels'."
1080
1081 machine='' opsys=''
1082
1083 dnl Straightforward machine determination
1084 case "$canonical" in
1085   sparc-*-*        ) machine=sparc ;;
1086   alpha*-*-*       ) machine=alpha ;;
1087   vax-*-*          ) machine=vax ;;
1088   mips-dec-*       ) machine=pmax ;;
1089   mips-sgi-irix6*  ) machine=iris6d ;;
1090   mips-sgi-*       ) machine=iris4d ;;
1091   mips*-linux      ) machine=mips ;;
1092   romp-ibm-*       ) machine=ibmrt ;;
1093   rs6000-ibm-aix*  ) machine=ibmrs6000 ;;
1094   powerpc-ibm-aix* ) machine=ibmrs6000 ;;
1095   powerpc*-*       ) machine=powerpc ;;
1096   hppa-*-*         ) machine=hp800 ;;
1097   m88k-dg-*        ) machine=aviion ;;
1098   m68*-sony-*      ) machine=news ;;
1099   mips-sony-*      ) machine=news-risc ;;
1100   clipper-*        ) machine=clipper ;;
1101   arm*             ) machine=arm ;;
1102   ns32k-*          ) machine=ns32000 ;;
1103 esac
1104
1105 dnl Straightforward OS determination
1106 case "$canonical" in
1107   *-*-linux*    ) opsys=linux ;;
1108   *-*-netbsd*   ) opsys=netbsd ;;
1109   *-*-openbsd*  ) opsys=openbsd ;;
1110   *-*-nextstep* ) opsys=nextstep ;;
1111   *-*-vms       ) opsys=vms ;;
1112
1113   dnl DEC OSF
1114   *-dec-osf1.3 | *-dec-osf2* ) opsys=decosf1-3 ;;
1115   *-dec-osf1.2 | *-dec-osf1* ) opsys=decosf1-2 ;;
1116   *-dec-osf3.[[2-9]]         ) opsys=decosf3-2 ;;
1117   *-dec-osf3*                ) opsys=decosf3-1 ;;
1118   *-dec-osf[[4-9]]*          ) opsys=decosf4-0 ;;
1119
1120   dnl DEC Ultrix
1121   *-*-ultrix[[0-3]].* | *-*-ultrix4.0* ) opsys=bsd4-2 ;;
1122   *-*-ultrix4.[[12]]* ) opsys=bsd4-3 ;;
1123   *-*-ultrix* )         opsys=ultrix4-3 ;;
1124
1125   dnl AIX
1126   *-*-aix3.1*     ) opsys=aix3-1   ;;
1127   *-*-aix3.2.5    ) opsys=aix3-2-5 ;;
1128   *-*-aix3*       ) opsys=aix3-2   ;;
1129   *-*-aix4.0*     ) opsys=aix4     ;;
1130   *-*-aix4.1*     ) opsys=aix4-1   ;;
1131   *-*-aix[[4-9]]* ) opsys=aix4-2   ;;
1132
1133   dnl Other generic OSes
1134   *-gnu* )                      opsys=gnu    ;;
1135   *-*-bsd4.[[01]] )             opsys=bsd4-1 ;;
1136   *-*-bsd4.2 )                  opsys=bsd4-2 ;;
1137   *-*-bsd4.3 )                  opsys=bsd4-3 ;;
1138   *-*-aos4.2 )                  opsys=bsd4-2 ;;
1139   *-*-aos*   )                  opsys=bsd4-3 ;;
1140   *-*-sysv0    | *-*-sysvr0 )   opsys=usg5-0 ;;
1141   *-*-sysv2    | *-*-sysvr2 )   opsys=usg5-2 ;;
1142   *-*-sysv2.2  | *-*-sysvr2.2 ) opsys=usg5-2-2 ;;
1143   *-*-sysv3*   | *-*-sysvr3* )  opsys=usg5-3 ;;
1144   *-*-sysv4.1* | *-*-sysvr4.1* )opsys=usg5-4 NON_GNU_CPP=/usr/lib/cpp ;;
1145   *-*-sysv4.[[2-9]]* | *-sysvr4.[[2-9]]* )
1146         if test -z "$NON_GNU_CPP" ; then
1147           for prog in "/usr/ccs/lib/cpp" "/lib/cpp"; do
1148             if test -f "$prog"; then NON_GNU_CPP="$prog"; break; fi
1149           done
1150         fi
1151         opsys=usg5-4-2 ;;
1152     *-sysv4* | *-sysvr4* )      opsys=usg5-4 ;;
1153     *-*-mach_bsd4.3* )          opsys=mach-bsd4-3 ;;
1154 esac
1155
1156 case "$canonical" in
1157
1158   dnl NetBSD ports
1159   *-*-netbsd* )
1160     case "$canonical" in
1161       i[[3-9]]86-*-netbsd*) machine=intel386 ;;
1162       hp300-*-netbsd* | amiga-*-netbsd* | sun3-*-netbsd* | mac68k-*-netbsd* | da30-*-netbsd* | m68k-*-netbsd* )
1163                       dnl Yes, this is somewhat bogus.
1164                       machine=hp9000s300 ;;
1165       pc532-*-netbsd* | ns32k-*-netbsd* )  machine=ns32000 ;;
1166       pmax-*-netbsd*  | mips-*-netbsd*  )  machine=pmax ;;
1167     esac
1168   ;;
1169
1170   dnl OpenBSD ports
1171   *-*-openbsd* )
1172     case "${canonical}" in
1173       i386-*-openbsd*)          machine=intel386 ;;
1174       m68k-*-openbsd*)          machine=hp9000s300 ;;
1175       mipsel-*-openbsd*)        machine=pmax ;;
1176      esac
1177    ;;
1178
1179   dnl Acorn RISCiX:
1180   arm-acorn-riscix1.1* ) machine=acorn opsys=riscix1-1 ;;
1181   arm-acorn-riscix1.2* | arm-acorn-riscix ) machine=acorn opsys=riscix1-2 ;;
1182
1183   dnl Alliant machines
1184   fx80-alliant-* ) machine=alliant4     opsys=bsd4-2 ;;
1185   i860-alliant-* ) machine=alliant-2800 opsys=bsd4-3 ;;
1186
1187   dnl Altos 3068
1188   m68*-altos-sysv* ) machine=altos opsys=usg5-2 ;;
1189
1190   dnl Amdahl UTS
1191   580-amdahl-sysv* ) machine=amdahl opsys=usg5-2-2 ;;
1192
1193   dnl Apollo, Domain/OS
1194   m68*-apollo-* ) machine=apollo opsys=bsd4-3 ;;
1195
1196   dnl AT&T 3b2, 3b5, 3b15, 3b20
1197   we32k-att-sysv* ) machine=att3b opsys=usg5-2-2 ;;
1198
1199   dnl AT&T 3b1 - The Mighty Unix PC!
1200   m68*-att-sysv* ) machine=7300 opsys=usg5-2-2 ;;
1201
1202   dnl Bull machines
1203   rs6000-bull-bosx* ) machine=ibmrs6000 opsys=aix3-2 ;; # dpx20
1204   m68*-bull-sysv3*  ) machine=dpx2      opsys=usg5-3 ;; # dpx2
1205   m68*-bull-sysv2*  ) machine=sps7      opsys=usg5-2 ;; # sps7
1206
1207   dnl CCI 5/32, 6/32 -- see "Tahoe".
1208
1209   dnl Celerity
1210   celerity-celerity-bsd* ) machine=celerity opsys=bsd4-2 ;;
1211
1212   dnl Convex
1213   *-convex-bsd* | *-convex-convexos* )
1214     machine=convex opsys=bsd4-3
1215     NON_GNU_CPP="cc -E -P"
1216   ;;
1217
1218   dnl Cubix QBx/386
1219   i[[3-9]]86-cubix-sysv* ) machine=intel386 opsys=usg5-3 ;;
1220
1221   dnl Darwin, a.k.a. MacOS X (based on Mach and Freebsd)
1222   *-*-darwin*)
1223     opsys=darwin
1224     RANLIB="ranlib -c" dnl Avoids a link error with lwlib-config.c
1225     ;;
1226
1227   dnl Data General AViiON Machines
1228   i586-dg-dgux*R4*   | i586-dg-dgux5.4.4* ) machine=aviion opsys=dgux5-4r4 ;;
1229   m88k-dg-dgux5.4R3* | m88k-dg-dgux5.4.3* ) opsys=dgux5-4r3 ;;
1230   m88k-dg-dgux5.4R2* | m88k-dg-dgux5.4.2* ) opsys=dgux5-4r2 ;;
1231   m88k-dg-dgux*                           ) opsys=dgux     ;;
1232
1233   dnl Motorola Delta machines
1234   m68k-motorola-sysv* | m68000-motorola-sysv* ) machine=delta opsys=usg5-3 ;;
1235   m88k-motorola-sysv4* )
1236     dnl jbotte@bnr.ca says that UNIX_System_V <hostName> 4.0 R40V4.3 m88k mc88110
1237     dnl needs POSIX_SIGNALS and therefore needs usg5-4-2.
1238     dnl I hope there are not other 4.0 versions for this machine
1239     dnl which really need usg5-4 instead.
1240     machine=delta88k opsys=usg5-4-2
1241   ;;
1242   m88k-motorola-sysv* | m88k-motorola-m88kbcs* ) machine=delta88k opsys=usg5-3 ;;
1243
1244   dnl Dual machines
1245   m68*-dual-sysv*    ) machine=dual opsys=usg5-2   ;;
1246   m68*-dual-uniplus* ) machine=dual opsys=unipl5-2 ;;
1247
1248   dnl Encore machines
1249   ns16k-encore-bsd* ) machine=ns16000 opsys=umax ;;
1250
1251   dnl Gould Power Node and NP1
1252   pn-gould-bsd4.2* ) machine=gould     opsys=bsd4-2 ;;
1253   pn-gould-bsd4.3* ) machine=gould     opsys=bsd4-3 ;;
1254   np1-gould-bsd* )   machine=gould-np1 opsys=bsd4-3 ;;
1255
1256   dnl Harris Night Hawk machines running CX/UX (a 5000 looks just like a 4000
1257   dnl as far as XEmacs is concerned).
1258   m88k-harris-cxux* )
1259     dnl Build needs to be different on 7.0 and later releases
1260     case "`uname -r`" in
1261        [[56]].[[0-9]] ) machine=nh4000 opsys=cxux  ;;
1262        [[7]].[[0-9]]  ) machine=nh4000 opsys=cxux7 ;;
1263     esac
1264     NON_GNU_CPP="/lib/cpp"
1265   ;;
1266   dnl Harris ecx or gcx running CX/UX (Series 1200, Series 3000)
1267   m68k-harris-cxux* ) machine=nh3000 opsys=cxux ;;
1268   dnl Harris power pc NightHawk running Power UNIX (Series 6000)
1269   powerpc-harris-powerunix ) machine=nh6000 opsys=powerunix NON_GNU_CPP="cc -Xo -E -P" ;;
1270
1271   dnl Honeywell XPS100
1272   xps*-honeywell-sysv* ) machine=xps100 opsys=usg5-2 ;;
1273
1274   dnl HP 9000 series 200 or 300
1275   m68*-hp-bsd* ) machine=hp9000s300 opsys=bsd4-3 ;;
1276
1277   dnl HP-UX
1278   *-hp-hpux* )
1279     dnl Figure out machine and opsys orthogonally
1280     case "$canonical" in
1281       m68*  ) machine=hp9000s300 ;;
1282       hppa* ) machine=hp800      ;;
1283     esac
1284
1285     case "$canonical" in
1286       *-hp-hpux7*  )  opsys=hpux   ;;
1287       *-hp-hpux8*  )  opsys=hpux8  ;;
1288       *-hp-hpux9*  )  opsys=hpux9  ;;
1289       *-hp-hpux10* )  opsys=hpux10 ;;
1290       *-hp-hpux11* )  opsys=hpux11 ;;
1291       *            )  opsys=hpux   ;;
1292     esac
1293
1294     dnl HP has a broken "strcat"
1295     case "$opsys" in hpux9 | hpux10 ) XE_ADD_OBJS(strcat.o) ;; esac
1296
1297     if test "$opsys" = "hpux10" -o "$opsys" = "hpux11"; then \
1298         ansi_flag="-Ae"; else ansi_flag="-Aa"; fi
1299     NON_GNU_CC="cc $ansi_flag" NON_GNU_CPP="cc $ansi_flag -E"
1300
1301     case "$canonical" in *-hp-hpux*shr* ) opsys="${opsys}-shr" ;; esac
1302   ;;
1303
1304   dnl Orion machines
1305   orion-orion-bsd*   ) machine=orion    opsys=bsd4-2 ;;
1306   clipper-orion-bsd* ) machine=orion105 opsys=bsd4-2 ;;
1307
1308   dnl IBM machines
1309   i[[3-9]]86-ibm-aix1.1* ) machine=ibmps2-aix opsys=usg5-2-2 ;;
1310   i[[3-9]]86-ibm-aix1.[[23]]* | i[[3-9]]86-ibm-aix* ) machine=ibmps2-aix opsys=usg5-3 ;;
1311   i370-ibm-aix*) machine=ibm370aix opsys=usg5-3 ;;
1312   romp-ibm-aos*    ) opsys=bsd4-3 ;;
1313   romp-ibm-bsd*    ) opsys=bsd4-3 ;;
1314   romp-ibm-mach*   ) opsys=mach-bsd4-3 ;;
1315
1316   dnl Integrated Solutions "Optimum V"
1317   m68*-isi-bsd4.2* ) machine=isi-ov opsys=bsd4-2 ;;
1318   m68*-isi-bsd4.3* ) machine=isi-ov opsys=bsd4-3 ;;
1319
1320   dnl Intel 386 machines where we do care about the manufacturer
1321   i[[3-9]]86-intsys-sysv* ) machine=is386 opsys=usg5-2-2 ;;
1322
1323   dnl Prime EXL
1324   i[[3-9]]86-prime-sysv* ) machine=i386 opsys=usg5-3 ;;
1325
1326   dnl Sequent Symmetry running Dynix
1327   i[[3-9]]86-sequent-bsd* ) machine=symmetry opsys=bsd4-3 ;;
1328
1329   dnl Sequent Symmetry running DYNIX/ptx
1330   i[[3-9]]86-sequent-ptx* ) machine=sequent-ptx opsys=ptx NON_GNU_CPP="/lib/cpp" ;;
1331
1332   dnl Unspecified sysv on an ncr machine defaults to svr4.2.
1333   dnl (Plain usg5-4 does not turn on POSIX signals, which we need.)
1334   i[[3-9]]86-ncr-sysv* ) machine=ncr386 opsys=usg5-4-2 ;;
1335
1336   dnl Intel Paragon OSF/1
1337   i860-intel-osf1* ) machine=paragon opsys=osf1 NON_GNU_CPP=/usr/mach/lib/cpp ;;
1338
1339   dnl Intel 860
1340   i860-*-sysv4* ) machine=i860 opsys=usg5-4 NON_GNU_CC="/bin/cc" NON_GNU_CPP="/usr/ccs/lib/cpp" ;;
1341
1342   dnl Masscomp machines
1343   m68*-masscomp-rtu* ) machine=masscomp opsys=rtu ;;
1344
1345   dnl Megatest machines
1346   m68*-megatest-bsd* ) machine=mega68 opsys=bsd4-2 ;;
1347
1348   dnl Workstations sold by MIPS
1349   dnl This is not necessarily all workstations using the MIPS processor -
1350   dnl Irises are produced by SGI, and DECstations by DEC.
1351   mips-mips-usg* ) machine=mips4 ;;
1352   mips-mips-riscos4 )
1353     machine=mips4
1354     NON_GNU_CC="cc -systype bsd43"
1355     NON_GNU_CPP="cc -systype bsd43 -E"
1356     case "$canonical" in
1357       mips-mips-riscos4* ) opsys=bsd4-3  ;;
1358       mips-mips-riscos5* ) opsys=riscos5 ;;
1359     esac
1360   ;;
1361   mips-mips-bsd* ) machine=mips opsys=bsd4-3 ;;
1362   mips-mips-*    ) machine=mips opsys=usg5-2-2 ;;
1363
1364   dnl NeXT
1365   m68*-next-* | m68k-*-nextstep* ) machine=m68k opsys=nextstep ;;
1366
1367   dnl The complete machine from National Semiconductor
1368   ns32k-ns-genix* ) machine=ns32000 opsys=usg5-2 ;;
1369
1370   dnl NCR machines
1371   m68*-ncr-sysv2* | m68*-ncr-sysvr2* ) machine=tower32   opsys=usg5-2-2 ;;
1372   m68*-ncr-sysv3* | m68*-ncr-sysvr3* ) machine=tower32v3 opsys=usg5-3 ;;
1373
1374   dnl Nixdorf Targon 31
1375   m68*-nixdorf-sysv* ) machine=targon31 opsys=usg5-2-2 ;;
1376
1377   dnl Nu (TI or LMI)
1378   m68*-nu-sysv* ) machine=nu opsys=usg5-2 ;;
1379
1380   dnl Plexus
1381   m68*-plexus-sysv* ) machine=plexus opsys=usg5-2 ;;
1382
1383   dnl Pyramid machines
1384   pyramid-pyramid-bsd* ) machine=pyramid opsys=bsd4-2 ;;
1385
1386   dnl Sequent Balance
1387   ns32k-sequent-bsd4.2* ) machine=sequent opsys=bsd4-2 ;;
1388   ns32k-sequent-bsd4.3* ) machine=sequent opsys=bsd4-3 ;;
1389
1390   dnl Siemens Nixdorf
1391   mips-siemens-sysv* | mips-sni-sysv*)
1392     machine=mips-siemens opsys=usg5-4
1393     NON_GNU_CC=/usr/ccs/bin/cc
1394     NON_GNU_CPP=/usr/ccs/lib/cpp
1395   ;;
1396
1397   dnl NEC
1398   mips-nec-sysv*)
1399     machine=mips-nec
1400     NON_GNU_CC=/usr/ccs/bin/cc
1401     NON_GNU_CPP=/usr/ccs/lib/cpp
1402   ;;
1403
1404   dnl Silicon Graphics machines
1405   dnl Iris 2500 and Iris 2500 Turbo (aka the Iris 3030)
1406   m68*-sgi-iris3.5* ) machine=irist opsys=iris3-5 ;;
1407   m68*-sgi-iris3.6* | m68*-sgi-iris*) machine=irist opsys=iris3-6 ;;
1408   dnl Iris 4D
1409   mips-sgi-irix3.*    ) opsys=irix3-3 ;;
1410   mips-sgi-irix4.*    ) opsys=irix4-0 ;;
1411   mips-sgi-irix6*     ) opsys=irix6-0 ;;
1412   mips-sgi-irix5.1*   ) opsys=irix5-1 ;;
1413   mips-sgi-irix5.2*   ) opsys=irix5-2 ;;
1414   mips-sgi-irix5.*    ) opsys=irix5-3 ;;
1415   mips-sgi-irix*      ) opsys=irix5-0 ;;
1416
1417   dnl SONY machines
1418   *-sony-newsos[[34]]* | *-sony-news[[34]]* ) opsys=bsd4-3 ;;
1419   *-sony-news* ) opsys=newsos5 ;;
1420
1421   dnl Stride
1422   m68*-stride-sysv* ) machine=stride opsys=usg5-2 ;;
1423
1424   dnl Suns
1425   *-*-solaris* | *-*-sunos* | *-sun-mach* | *-sun-bsd* )
1426     dnl Hardware type
1427     case "$canonical" in
1428       m68*-sunos1* )             machine=sun1     ;;
1429       m68*-sunos2* )             machine=sun2     ;;
1430       m68* )                     machine=sun3     ;;
1431       i*86*-sun-sunos[[34]]* )   machine=sun386   ;;
1432       i*86-*-* )                 machine=intel386 ;;
1433       rs6000* )                  machine=rs6000   ;;
1434     esac
1435
1436     dnl Make $canonical even more so.
1437     case "$canonical" in *-sunos5*)
1438       canonical=`echo $canonical | sed -e s/sunos5/solaris2/`;;
1439     esac
1440
1441     dnl On SunOS 4, use /usr/lib/cpp, sans dynodump, /bin/ranlib
1442     dnl On SunOS 5, use cc -E,        need dynodump, RANLIB not needed
1443     dnl But, SunOS 5.6 no longer needs dynodump because it has a similar
1444     dnl function integrated.
1445     case "$canonical" in
1446       *-sunos4* )
1447         #test -f /usr/lib/cpp     && NON_GNU_CPP=/usr/lib/cpp ;;
1448         : ;;
1449       *-solaris2* )
1450         #test -f /usr/ccs/lib/cpp && NON_GNU_CPP=/usr/ccs/lib/cpp
1451         RANLIB=':' ;;
1452     esac
1453
1454     case "$canonical" in
1455       *-solaris* )
1456         opsys=sol2
1457         os_release_major=`uname -r | sed -e 's/^\([[0-9]]\{1,\}\)\.\([[0-9]]\{1,\}\).*/\1/'`
1458         os_release_minor=`uname -r | sed -e 's/^\([[0-9]]\{1,\}\)\.\([[0-9]]\{1,\}\).*/\2/'`
1459         case "$os_release_minor" in [[0-9]])
1460           os_release_minor="0${os_release_minor}";;
1461         esac
1462         os_release="${os_release_major}${os_release_minor}"
1463         AC_DEFINE_UNQUOTED(OS_RELEASE, $os_release) ;;
1464
1465       dnl The last Sun386 ran 4.0.
1466       i*86-*-sunos4*      ) opsys=sunos4-0      ;;
1467       *-sunos4.0*         ) opsys=sunos4-0      ;;
1468       *-sunos4.1.2*       ) opsys=sunos4-1-2    ;;
1469       *-sunos4.1.3*       ) opsys=sunos4-1-3    ;;
1470       *-sunos4.1.[[4-9]]* ) opsys=sunos4-1-4    ;;
1471       *-sunos4* | *-sunos ) opsys=sunos4-1      ;;
1472       *-mach*             ) opsys=mach-bsd4-3   ;;
1473       *                   ) opsys=bsd4-2        ;;
1474     esac
1475
1476     case "$canonical" in *-sunos4*shr* ) opsys="${opsys}-shr" ;; esac
1477
1478     dnl Watch out for a compiler guaranteed not to work.
1479     test "$opsys $CC" = "sol2 /usr/ucb/cc" && CC=""
1480   ;;
1481
1482   dnl Tadpole 68k
1483   m68*-tadpole-sysv* ) machine=tad68k opsys=usg5-3 ;;
1484
1485   dnl Tahoe machines
1486   tahoe-tahoe-bsd4.2* ) machine=tahoe opsys=bsd4-2 ;;
1487   tahoe-tahoe-bsd4.3* ) machine=tahoe opsys=bsd4-3 ;;
1488
1489   dnl Tandem Integrity S2
1490   mips-tandem-sysv* ) machine=tandem-s2 opsys=usg5-3 ;;
1491
1492   dnl Tektronix XD88
1493   m88k-tektronix-sysv3* ) machine=tekxd88 opsys=usg5-3 ;;
1494
1495   dnl Tektronix 16000 box (6130?)
1496   ns16k-tektronix-bsd* ) machine=ns16000 opsys=bsd4-2 ;;
1497   dnl Tektronix 4300
1498   dnl src/m/tek4300.h hints that this is a m68k machine.
1499   m68*-tektronix-bsd* ) machine=tek4300 opsys=bsd4-3 ;;
1500
1501   dnl Titan P2 or P3
1502   titan-titan-sysv* ) machine=titan opsys=usg5-3 ;;
1503
1504   dnl Ustation E30 (SS5E)
1505   m68*-unisys-uniplus* ) machine=ustation opsystem=unipl5-2 ;;
1506
1507   dnl Vaxen.
1508   vax-dec-* )
1509     case "$canonical" in
1510       *-sysv[[01]]* | *-sysvr[[01]]* )  opsys=usg5-0 ;;
1511       *-sysv2* | *-sysvr2* )            opsys=usg5-2 ;;
1512       *-mach* )                         opsys=mach-bsd4-3 ;;
1513     esac
1514   ;;
1515
1516   dnl Whitechapel MG1
1517   ns16k-whitechapel-* ) machine=mg1 ;;
1518
1519   dnl Wicat
1520   m68*-wicat-sysv* ) machine=wicat opsys=usg5-2 ;;
1521
1522   dnl Intel 386 machines where we do not care about the manufacturer
1523   i[[3-9]]86-*-* )
1524     machine=intel386
1525     case "$canonical" in
1526       *-isc1.* | *-isc2.[[01]]* ) opsys=386-ix ;;
1527       *-isc2.2* )               opsys=isc2-2 ;;
1528       *-isc4.0* )               opsys=isc4-0 ;;
1529       *-isc4.* )                opsys=isc4-1
1530                                 GCC_TEST_OPTIONS=-posix
1531                                 NON_GCC_TEST_OPTIONS=-Xp
1532                                 ;;
1533       *-isc* )                  opsys=isc3-0 ;;
1534       *-esix5* )                opsys=esix5r4 NON_GNU_CPP=/usr/lib/cpp ;;
1535       *-esix* )                 opsys=esix ;;
1536       *-mach* )                 opsys=mach-bsd4-3 ;;
1537       *-xenix* )                opsys=xenix ;;
1538       *-sco3.2v4* )             opsys=sco4 NON_GNU_CPP=/lib/cpp  ;;
1539       *-bsd386* | *-bsdi1* )    opsys=bsd386 ;;
1540       *-bsdi4* )                opsys=bsdos4 ;;
1541       *-bsdi3* )                opsys=bsdos3 ;;
1542       *-bsdi2.1* )              opsys=bsdos2-1 ;;
1543       *-bsdi2* )                opsys=bsdos2 ;;
1544       *-sco3.2v5* )             opsys=sco5 ;;
1545       *-sysv5* )                opsys=sco7 ;;
1546       *-386bsd* )               opsys=386bsd ;;
1547       *-freebsd* )              opsys=freebsd ;;
1548       *-nextstep* )             opsys=nextstep ;;
1549       *-pc-cygwin* )            opsys=cygwin32 ;;
1550       *-pc-mingw* )             opsys=mingw32 ;
1551                                 test -z "$with_tty" && with_tty="no";;
1552       dnl Otherwise, we fall through to the generic opsys code at the bottom.
1553     esac
1554   ;;
1555
1556   dnl Linux/68k
1557   m68k-*-linux* ) machine=m68k opsys=linux ;;
1558
1559 esac
1560
1561 dnl Initialize machine from $canonical if not in our database above.
1562 test -z "$machine" && machine=`echo $canonical | sed 's/-.*$//'`
1563
1564 dnl Initialize opsys from `uname -s` if not in our database above.
1565 test -z "$opsys"   && opsys=`uname -s | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
1566
1567 dnl Use configure-time autodetection if s&m not available
1568 if test -r "${srcdir}/src/m/${machine}.h"; then
1569   machfile="m/${machine}.h"
1570   AC_DEFINE_UNQUOTED(config_machfile, "$machfile")
1571 else
1572   echo "XEmacs has no builtin knowledge of \`$machine' machines."
1573   echo "Using configure-time autodetection only."
1574 fi
1575
1576 if test -r "${srcdir}/src/s/${opsys}.h"; then
1577   opsysfile="s/${opsys}.h"
1578   AC_DEFINE_UNQUOTED(config_opsysfile, "$opsysfile")
1579 else
1580   echo "XEmacs has no builtin knowledge of \`$opsys' operating systems."
1581   echo "Using configure-time autodetection only."
1582 fi
1583
1584 dnl --------------------------------------------------------------
1585 dnl $opsys detection complete; defaults depending on $opsys follow
1586 dnl --------------------------------------------------------------
1587
1588 if test -z "$pdump"; then
1589   case "$opsys" in
1590     linux* )  pdump=yes ;;    dnl glibc 2.3.1 seems to hose unexec
1591     darwin )  pdump=yes ;;    dnl No "native" working dumper available
1592     cygwin* ) pdump=yes ;;    dnl unexec is broken
1593     *)        pdump=no ;;
1594   esac
1595 fi
1596
1597 if test -z "$dynamic"; then
1598   case "$opsys" in
1599     hpux* | sunos4* ) dynamic=no ;;
1600     *) dynamic=yes ;;
1601   esac
1602 fi
1603 if test "$dynamic" = "yes"; then
1604   case "$opsys" in
1605     hpux* | sunos4* | sco5 ) opsys="${opsys}-shr" ;;
1606     decosf* ) ld_call_shared="-call_shared" ;;
1607     darwin ) AC_DEFINE(DLSYM_NEEDS_UNDERSCORE) ;;
1608   esac
1609 else dnl "$dynamic" = "no"
1610   case "$opsys" in
1611     sol2 )
1612       echo "Static linking is not supported on Solaris 2."
1613       echo "Rerun configure without specifying --dynamic=no."
1614       exit 1 ;;
1615     linux   ) ld_call_shared="-Bstatic" ;;
1616     decosf* ) ld_call_shared="-non_shared" ;;
1617   esac
1618 fi
1619
1620 dnl Use xlc by default on AIX
1621 case "$opsys" in aix*) NON_GNU_CC=xlc ;; esac
1622
1623 stack_trace_eye_catcher=`echo ${PROGNAME}_${version}_${canonical} | sed 'y/.-/__/'`
1624 AC_DEFINE_UNQUOTED(STACK_TRACE_EYE_CATCHER, $stack_trace_eye_catcher)
1625
1626 dnl --------------------------------------------------
1627 dnl Determine the compiler, set up for feature testing
1628 dnl --------------------------------------------------
1629
1630 dnl Sun Development environment support
1631 test "$with_sparcworks" = "yes" && with_workshop=yes # compatibility alias
1632 XE_CHECK_FEATURE_DEPENDENCY(workshop, tooltalk)
1633 if test "$with_workshop" = "yes"; then
1634   AC_DEFINE(SUNPRO)
1635   XE_ADD_OBJS(sunpro.o)
1636 fi
1637
1638 if test "$with_clash_detection" != "no"; then
1639   AC_DEFINE(CLASH_DETECTION)
1640   XE_ADD_OBJS(filelock.o)
1641 fi
1642
1643 dnl Choose a compiler from (in order)
1644 dnl --compiler, env var CC, with_gcc=no && ${NON_GNU_CC:-cc}, AC_PROG_CC
1645 test -n "$compiler" && CC="$compiler"
1646 if test "$with_gcc" = "no"; then dnl Try to find a non-gcc compiler
1647   case "$CC" in "" | *gcc* ) CC="${NON_GNU_CC-cc}" ;; esac
1648 fi
1649
1650 dnl If we don't set CFLAGS here, AC_PROG_CC will set it.
1651 dnl But we know better what's good for us, so we do our own
1652 dnl computation of real CFLAGS later.
1653 dnl --cflags overrides environment variable CFLAGS
1654 test "${cflags-unset}" != unset && CFLAGS="$cflags"
1655 if test "${CFLAGS-unset}" != unset
1656   then cflags_specified=yes;
1657   else cflags_specified=no;
1658 fi
1659
1660 xe_save_CFLAGS="$CFLAGS"
1661
1662 AC_PROG_CC dnl Autoconf has its own magic for compiler autodetection
1663
1664 dnl Retry using random guesswork if AC_PROG_CC got it wrong...
1665 if   test "$with_gcc" = "no"  -a "$GCC" = "yes"; then
1666   CC=${NON_GNU_CC-cc}
1667   AC_PROG_CC
1668 elif test "$with_gcc" = "yes" -a "$GCC" != "yes" ; then
1669   CC=gcc
1670   AC_PROG_CC
1671 fi
1672 CFLAGS="$xe_save_CFLAGS"
1673
1674 dnl Figure out what C preprocessor to use.
1675
1676 dnl On Sun systems, people sometimes set up the variable CPP
1677 dnl with a value that is a directory, not an executable at all.
1678 dnl Detect that case, and ignore that value.
1679 test -n "$CPP" -a -d "$CPP" && CPP=
1680
1681 test -n "$NON_GNU_CPP" -a "$GCC" != "yes" -a -z "$CPP" && CPP="$NON_GNU_CPP"
1682
1683 AC_PROG_CPP
1684
1685 dnl --------------------------------------------------------------------
1686 dnl Compiler feature macros
1687 dnl --------------------------------------------------------------------
1688
1689 AC_AIX dnl Defines _ALL_SOURCE on AIX.
1690
1691 dnl We want feature macros defined here *and* in config.h.in, so that
1692 dnl the compilation environment at configure time and compile time agree.
1693
1694 AC_MSG_CHECKING(for GNU libc)
1695 AC_TRY_COMPILE([#include <features.h>],[
1696 #if ! (defined __GLIBC__ || defined __GNU_LIBRARY__)
1697 #error Not a GNU libc system :-(
1698 ******* ======= ******** &&&&&&&&
1699 #endif
1700 ], have_glibc=yes, have_glibc=no)
1701 AC_MSG_RESULT($have_glibc)
1702 dnl I'm tired of pop being broken with GLIBC -slb
1703 dnl Well. then why not fix fucking pop?
1704 test "$have_glibc" = "yes" && AC_DEFINE(_GNU_SOURCE)
1705
1706 dnl We'd like to use vendor extensions, where available.
1707 dnl We'd like to use functions from the latest Unix98 standards.
1708 dnl See http://www.opengroup.org/onlinepubs/007908799/xsh/compilation.html
1709 case "$opsys" in
1710   sol2)
1711    AC_DEFINE(__EXTENSIONS__)
1712    dnl Solaris 2 before 2.5 had some bugs with feature test macro interaction.
1713    if test "$os_release" -ge 505; then
1714      AC_DEFINE(_XOPEN_SOURCE,500)
1715      AC_DEFINE(_XOPEN_SOURCE_EXTENDED)
1716    fi ;;
1717   linux)
1718     AC_DEFINE(_POSIX_C_SOURCE,199506L)
1719     AC_DEFINE(_XOPEN_SOURCE,500)
1720     AC_DEFINE(_XOPEN_SOURCE_EXTENDED)
1721     ;;
1722 esac
1723
1724 dnl Identify compilers to enable compiler-specific hacks.
1725 dnl Add support for other compilers HERE!
1726 dnl GCC is already identified elsewhere.
1727 AC_TRY_RUN([int main () {
1728 #if defined __SUNPRO_C
1729 return 11;
1730 #elif defined __DECC
1731 return 12;
1732 #elif defined __USLC__ && defined __SCO_VERSION__
1733 return 13;
1734 #elif defined __INTEL_COMPILER
1735 return 14;
1736 #else
1737 return 0;
1738 #endif
1739 }], [],
1740 [case "$conftest_rc" in
1741   11) echo "You appear to be using the SunPro C compiler." ; __SUNPRO_C=yes ;;
1742   12) echo "You appear to be using the DEC C compiler."    ; __DECC=yes ;;
1743   13) echo "You appear to be using the SCO C compiler."    ; __USLC__=yes ;;
1744   14) echo "You appear to be using the Intel C++ compiler."; __ICC=yes
1745       dnl Newer versions of icc claim to be GCC
1746       GCC=no ;;
1747 esac])
1748
1749
1750 dnl case "$canonical" in
1751 dnl   *-sun-sunos* ) test "$CPP" = "acc -E" && CPP="acc -E -Xs" ;;
1752 dnl esac
1753
1754 dnl --------------------------------------------------------------------
1755 dnl Extract some information from the operating system and machine files
1756 dnl --------------------------------------------------------------------
1757
1758 echo "Extracting information from the machine- and system-dependent headers..."
1759
1760 dnl It is not important that this name contain the PID; you cannot run
1761 dnl two configures in the same directory and have anything work
1762 dnl anyway.
1763 tempcname="conftest.c"
1764
1765 dnl CPP_to_sh(CPP_SYMBOL, SH_VAR, DEFAULT_VALUE)
1766 define([CPP_to_sh],
1767 [[#]ifndef [$1]
1768 [#]define [$1]ifelse([$3],,, [ "$3"])
1769 [#]endif
1770 configure___ [$2]=[$1]
1771 ])dnl CPP_to_sh
1772
1773 dnl CPP_boolean_to_sh(CPP_SYMBOL, SH_VAR)
1774 define([CPP_boolean_to_sh],
1775 [[#]ifdef [$1]
1776 configure___ [$2]=yes
1777 [#]else
1778 configure___ [$2]=no
1779 [#]endif
1780 ])dnl CPP_boolean_to_sh
1781
1782 cat > $tempcname < confdefs.h
1783 cat >> $tempcname <<EOF
1784 #define NOT_C_CODE
1785 #define C_SWITCH_SITE
1786 #define C_SWITCH_X_SITE
1787 #define LD_SWITCH_SITE
1788 #define LD_SWITCH_X_SITE
1789 #define LD_SWITCH_X_SITE_AUX
1790 #define OS_RELEASE $os_release
1791
1792 #ifdef config_opsysfile
1793 #include "$srcdir/src/$opsysfile"
1794 #endif
1795
1796 #ifdef config_machfile
1797 #include "$srcdir/src/$machfile"
1798 #endif
1799
1800 CPP_to_sh(LIBS_MACHINE, libs_machine)
1801 CPP_to_sh(LIBS_SYSTEM,  libs_system)
1802 CPP_to_sh(LIBS_TERMCAP, libs_termcap)
1803 CPP_to_sh(LIB_STANDARD, libs_standard)
1804
1805 CPP_to_sh(OBJECTS_MACHINE, objects_machine)
1806 CPP_to_sh(OBJECTS_SYSTEM,  objects_system)
1807
1808 CPP_to_sh(C_SWITCH_MACHINE,   c_switch_machine)
1809 CPP_to_sh(C_SWITCH_SYSTEM,    c_switch_system)
1810
1811 CPP_to_sh(LD_SWITCH_MACHINE,  ld_switch_machine)
1812 CPP_to_sh(LD_SWITCH_SYSTEM,   ld_switch_system)
1813
1814 CPP_to_sh(UNEXEC, unexec, unexec.o)
1815
1816 CPP_to_sh(LD_SWITCH_SHARED, ld_switch_shared, -c)
1817
1818 #define ORDINARY_LD "\$(CC) \$(CFLAGS)"
1819 configure___ ordinary_ld=ORDINARY_LD
1820
1821 #ifdef ORDINARY_LINK
1822 #define LD ORDINARY_LD
1823 #else /* no ORDINARY LINK */
1824 #ifdef COFF_ENCAPSULATE
1825 #define LD "\$(CC) -nostdlib"
1826 #else /* not COFF_ENCAPSULATE */
1827 #ifdef LINKER
1828 #define LD LINKER
1829 #else /* ! defined (LINKER) */
1830 #define LD "ld"
1831 #endif /* ! defined (LINKER) */
1832 #endif /* ! defined (COFF_ENCAPSULATE) */
1833 #endif /* not ORDINARY_LINK */
1834 configure___ ld=LD
1835
1836 CPP_to_sh(LIB_GCC, lib_gcc)
1837 CPP_to_sh(LD_TEXT_START_ADDR, ld_text_start_addr)
1838
1839 #if ! defined (ORDINARY_LINK) && !defined (START_FILES)
1840 #ifdef NO_REMAP
1841 #ifdef COFF_ENCAPSULATE
1842 #define START_FILES "pre-crt0.o /usr/local/lib/gcc-crt0.o"
1843 #else /* ! defined (COFF_ENCAPSULATE) */
1844 #define START_FILES "pre-crt0.o /lib/crt0.o"
1845 #endif /* ! defined (COFF_ENCAPSULATE) */
1846 #else /* ! defined (NO_REMAP) */
1847 #define START_FILES "ecrt0.o"
1848 #endif /* ! defined (NO_REMAP) */
1849 #endif /* no ORDINARY_LINK */
1850 #ifndef START_FILES
1851 #define START_FILES
1852 #endif
1853 configure___ start_files=START_FILES
1854
1855 CPP_boolean_to_sh(ORDINARY_LINK, ordinary_link)
1856 CPP_boolean_to_sh(SYSTEM_MALLOC, system_malloc)
1857 CPP_boolean_to_sh(TERMINFO, have_terminfo)
1858 dnl The MAIL_USE_xxx variables come from the s&m headers
1859 CPP_boolean_to_sh(MAIL_USE_FLOCK, mail_use_flock)
1860 CPP_boolean_to_sh(MAIL_USE_LOCKF, mail_use_lockf)
1861 CPP_boolean_to_sh(MAIL_USE_LOCKING, mail_use_locking)
1862 CPP_boolean_to_sh(HAVE_WIN32_PROCESSES, win32_processes)
1863 EOF
1864
1865 dnl The value of CPP is a quoted variable reference, so we need to do this
1866 dnl to get its actual value...
1867 CPP=`eval "echo $CPP $CPPFLAGS"`
1868 define(TAB, [   ])dnl
1869 changequote(, )dnl
1870 eval `$CPP -Isrc $tempcname \
1871         | sed -n -e "s/[ TAB]*=[ TAB\"]*/='/" -e "s/[ TAB\"]*\$/'/" -e "s/^configure___//p"`
1872 changequote([, ])dnl
1873
1874 rm $tempcname
1875
1876 if test "$pdump" = "yes"; then
1877   ordinary_link="yes"
1878   ld="${ordinary_ld}"
1879   start_files=
1880   libs_standard=
1881   unexec=
1882   lib_gcc=
1883 fi
1884
1885 dnl For debugging...
1886 test "$extra_verbose" = "yes" && \
1887   PRINT_VAR(libs_machine libs_system libs_termcap libs_standard
1888   objects_machine objects_system c_switch_machine c_switch_system
1889   ld_switch_machine ld_switch_system unexec ld_switch_shared
1890   ld lib_gcc ld_text_start_addr start_files ordinary_link
1891   have_terminfo mail_use_flock mail_use_lockf) && echo ""
1892
1893 dnl Pick up mingw include path
1894 dnl We only cope with headers in mingw, not mingw32: no previous version of
1895 dnl XEmacs supported mingw and cygnus have made this incompatible change
1896 dnl so we just go with the flow.
1897 case "$opsys" in mingw* | cygwin*)
1898   cygwin_include=`eval gcc -print-search-dirs | sed -ne s'/install: //p'`
1899   cygwin_include=`eval "cd $cygwin_include/../../../..; pwd"`
1900   cygwin_include="-I$cygwin_include/include" ;
1901   extra_includes="$cygwin_include/mingw $cygwin_include" ;
1902   case "$opsys" in mingw*)
1903     XE_APPEND($extra_includes, c_switch_system) ;;
1904   esac
1905   ;;
1906 esac
1907
1908 dnl Non-ordinary link usually requires -lc
1909 test "$ordinary_link" = "no" -a -z "$libs_standard" && libs_standard="-lc"
1910
1911 dnl -----------------------
1912 dnl Compiler-specific hacks
1913 dnl -----------------------
1914
1915 dnl DEC C `-std1' means ANSI C mode
1916 test "$__DECC" = "yes" && XE_APPEND(-std1, c_switch_site)
1917
1918 dnl Some versions of SCO native compiler need -Kalloca
1919 if test "$__USLC__" = yes; then
1920   AC_MSG_CHECKING(for whether the -Kalloca compiler flag is needed)
1921   need_kalloca=no
1922   AC_TRY_LINK([], [void *x = alloca(4);], [:], [
1923     xe_save_c_switch_system="$c_switch_system"
1924     c_switch_system="$c_switch_system -Kalloca"
1925     AC_TRY_LINK([], [void *x = alloca(4);], [ need_kalloca=yes ])
1926     c_switch_system="$xe_save_c_switch_system"])
1927   AC_MSG_RESULT($need_kalloca)
1928   test "$need_kalloca" = "yes" && XE_APPEND(-Kalloca,c_switch_system)
1929 fi
1930
1931 dnl Calculate value of CFLAGS:
1932 dnl Use either command line flag, environment var, or autodetection
1933 if test "$cflags_specified" = "no"; then
1934   dnl Following values of CFLAGS are known to work well.
1935   dnl Should we take debugging options into consideration?
1936   if   test "$GCC" = "yes"; then
1937     CFLAGS="-g -O3 -Wall -Wno-switch -Winline -Wmissing-prototypes"
1938     dnl Yuck, bad compares have been worth at least 3 crashes!
1939     CFLAGS="$CFLAGS -Wsign-compare"
1940     dnl XEmacs is known not to be strict-aliasing-safe.
1941     case "`gcc -v --help 2>&1`" in
1942       *-fstrict-aliasing* ) CFLAGS="$CFLAGS -fno-strict-aliasing" ;;
1943     esac
1944     dnl You get five zillion shadowing warnings with g++.
1945     dnl Even with gcc, -Wshadow is questionable because of its complaints
1946     dnl about parameters with the same names as global functions.
1947     if test "$xemacs_compiler" != "g++"; then
1948       CFLAGS="$CFLAGS -Wshadow"
1949     fi
1950     dnl glibc is intentionally not `-Wpointer-arith'-clean.
1951     dnl Ulrich Drepper has rejected patches to fix the glibc header files.
1952     test "$have_glibc" != "yes" && CFLAGS="$CFLAGS -Wpointer-arith"
1953     dnl I'm not convinced this is a good idea any more. -sb
1954     dnl test "$opsys $machine" = "linux intel386" && \
1955     dnl CFLAGS="$CFLAGS -fno-strength-reduce -malign-loops=2 -malign-jumps=2 -malign-functions=2"
1956   elif test "$__SUNPRO_C" = "yes"; then
1957     case "$opsys" in
1958       sol2    ) CFLAGS="-v -xO4" ;;
1959       sunos4* ) CFLAGS="-xO2";;
1960     esac
1961   elif test "$__DECC" = "yes"; then
1962     CFLAGS="-O3"
1963   elif test "$CC" = "xlc"; then
1964     CFLAGS="-g -O3 -qstrict -qnoansialias -qlibansi -qinfo -qro -qmaxmem=20000"
1965   elif test "$__ICC" = "yes"; then
1966     CFLAGS="-g -O3 -Ob2 -Wall -W1"
1967   dnl ### Add optimal CFLAGS support for other compilers HERE!
1968   else
1969     CFLAGS="-O" ;dnl The only POSIX-approved flag
1970   fi
1971 fi
1972
1973 dnl Search for GCC specific build problems we know about
1974 if test "$GCC" = "yes"; then
1975 AC_MSG_CHECKING(for buggy gcc versions)
1976 GCC_VERSION=`$CC --version`
1977 case `uname -s`:`uname -m`:$GCC_VERSION in
1978         dnl egcs 2.90.21 (egcs-1.00 release)
1979         dnl egcs 2.90.29 (egcs-1.0.3 release)
1980     *:sun4*:2.8.1|*:sun4*:egcs-2.90.*)
1981         dnl Don't use -O2 with gcc 2.8.1 and egcs 1.0 under SPARC architectures
1982         dnl without also using `-fno-schedule-insns'.
1983         case "$CFLAGS" in
1984             *-O2*|*-O3*)
1985                 case "$CFLAGS" in
1986                     *-fno-schedule-insns*) ;;
1987                     *)
1988                         AC_MSG_RESULT(yes)
1989                         AC_MSG_WARN(Don't use -O2 with gcc 2.8.1 and egcs 1.0 under SPARC architectures)
1990                         AC_MSG_WARN(without also using -fno-schedule-insns.)
1991                         AC_MSG_ERROR(Aborting due to known problem)
1992                         ;;
1993                 esac
1994                 ;;
1995         esac
1996         ;;
1997         dnl egcs-2.91.57 (egcs-1.1 release)
1998         dnl egcs-2.91.66 (egcs-1.1.2 release)
1999     Linux:alpha:egcs-2.91.*)
2000         AC_MSG_RESULT(yes)
2001         AC_MSG_WARN(There have been reports of egcs-1.1 not compiling XEmacs correctly on)
2002         AC_MSG_WARN(Alpha Linux.  There have also been reports that egcs-1.0.3a is O.K.)
2003         AC_MSG_ERROR(Aborting due to known problem)
2004         ;;
2005     *:i*86*:2.7.2*)
2006         case "$CFLAGS" in
2007             *-O2*|*-O3*)
2008                 case "$GCC_VERSION" in
2009                     2.7.2)
2010                         case "$CFLAGS" in
2011                             *-fno-strength-reduce*) ;;
2012                             *)
2013                                 AC_MSG_RESULT(yes)
2014                                 AC_MSG_WARN(Don't use -O2 with gcc 2.7.2 under Intel/XXX without also using)
2015                                 AC_MSG_WARN(-fno-strength-reduce.)
2016                                 AC_MSG_ERROR(Aborting due to known problem)
2017                                 ;;
2018                         esac
2019                         ;;
2020                 esac
2021                 case "$CFLAGS" in
2022                  *-fno-caller-saves*) ;;
2023                  *)
2024                     AC_MSG_RESULT(yes)
2025                     AC_MSG_WARN(Don't use -O2 with gcc 2.7.2 under Intel/XXX without also using)
2026                     AC_MSG_WARN(-fno-caller-saves.)
2027                     AC_MSG_ERROR(Aborting due to known problem)
2028                     ;;
2029                 esac
2030                 ;;
2031         esac
2032         ;;
2033 esac
2034 AC_MSG_RESULT(no)
2035 fi
2036
2037 dnl GNU ld now defaults to combreloc, which screws up unexec, but not pdump.
2038 dnl Note that it's OK if the GNU style long option causes non-GNU ld to barf
2039 dnl a usage message, that's often good enough.  Please report it, though.
2040 dnl #### Should make this Solaris-friendly.
2041 dnl Link with -z nocombreloc for now.
2042 if test "$pdump" != "yes"; then
2043   AC_MSG_CHECKING(for \"-z nocombreloc\" linker flag)
2044   case "`ld --help 2>&1`" in
2045     *-z\ nocombreloc* ) AC_MSG_RESULT(yes)
2046       XE_PREPEND(-z nocombreloc, ld_switch_site) ;;
2047     *) AC_MSG_RESULT(no) ;;
2048   esac
2049 fi
2050
2051
2052 dnl Inform compiler that certain flags are meant for the linker
2053 dnl XE_PROTECT_LINKER_FLAGS(shell_var)
2054 define([XE_PROTECT_LINKER_FLAGS], [
2055 if test "$GCC" = "yes"; then
2056   set x $[$1]; shift; [$1]=""
2057   while test -n "[$]1"; do
2058     case [$]1 in
2059       -L  | -l  | -u               ) [$1]="$[$1] [$]1 [$]2"; shift ;;
2060       -L* | -l* | -u* | -Wl* | -pg ) [$1]="$[$1] [$]1" ;;
2061       -Xlinker* ) ;;
2062       * ) [$1]="$[$1] -Xlinker [$]1" ;;
2063     esac
2064     shift
2065   done
2066 fi])dnl
2067 XE_PROTECT_LINKER_FLAGS(ld_switch_system)
2068 XE_PROTECT_LINKER_FLAGS(ld_switch_machine)
2069 XE_PROTECT_LINKER_FLAGS(ld_switch_site)
2070 XE_PROTECT_LINKER_FLAGS(LDFLAGS)
2071 XE_PROTECT_LINKER_FLAGS(ld_call_shared)
2072
2073 dnl Add s&m-determined objects (including unexec) to link line
2074 test -n "$objects_machine" && XE_ADD_OBJS($objects_machine)
2075 test -n "$objects_system"  && XE_ADD_OBJS($objects_system)
2076 test -n "$unexec"          && test ! "$pdump" = "yes" && XE_ADD_OBJS($unexec)
2077 test "$pdump" = "yes" && XE_ADD_OBJS(dumper.o)
2078
2079 dnl Dynodump (Solaris 2.x, x<6)
2080 AC_MSG_CHECKING(for dynodump)
2081 if test "$unexec" != "unexsol2.o"; then
2082   AC_MSG_RESULT(no)
2083 else
2084   AC_MSG_RESULT(yes)
2085   AC_DEFINE(DYNODUMP)
2086   XE_APPEND(dynodump, MAKE_SUBDIR)
2087   XE_APPEND(dynodump, SRC_SUBDIR_DEPS)
2088   case "$machine" in
2089     sparc   ) dynodump_arch=sparc ;;
2090     *86*    ) dynodump_arch=i386  ;;
2091     powerpc ) dynodump_arch=ppc   ;;
2092   esac
2093 fi
2094
2095 dnl Feed s&m crud to src/Makefile
2096
2097 dnl Linux/powerpc needs the following magic for some reason
2098 dnl [Not needed with YellowDog 2.3 and causes link problems with YellowDog 3.0,
2099 dnl the two most popular PowerPC distributions.]
2100 dnl test "$machine$opsys" = "powerpclinux" && start_flags="-T $srcdir/src/ppc.ldscript"
2101
2102 if test "$unexec" = "unexaix.o"; then
2103 dnl AIX needs various hacks to make static linking work.
2104   if   test "$dynamic" = "no"; then
2105   start_flags="-Wl,-bnso,-bnodelcsect"
2106   test "$GCC" = "yes" && start_flags="-B/bin/ ${start_flags}"
2107   for f in "/lib/syscalls.exp" "/lib/threads.exp"; do
2108     if test -r "$f"; then start_flags="${start_flags},-bI:${f}"; fi
2109   done
2110   for f in "/usr/lpp/X11/bin/smt.exp" "/usr/bin/X11/smt.exp"; do
2111     if test -r "$f"; then start_flags="${start_flags},-bI:${f}"; break; fi
2112   done
2113   AC_CHECK_LIB(C, terminateAndUnload, XE_APPEND(-lC, libs_system))
2114   fi
2115 elif test -n "$ld_text_start_addr"; then
2116   start_flags="-T $ld_text_start_addr -e __start"
2117 fi
2118 AC_SUBST(start_flags)
2119
2120 AC_SUBST(ld_switch_shared)
2121 AC_SUBST(start_files)
2122 if test "$ordinary_link" = "no" -a "$GCC" = "yes"; then
2123  test -z "$linker" &&  linker='$(CC) -nostdlib'
2124  test -z "$lib_gcc" && lib_gcc='`$(CC) -print-libgcc-file-name`'
2125 fi
2126 test "$GCC" != "yes" && lib_gcc=
2127 AC_SUBST(ld)
2128 AC_SUBST(lib_gcc)
2129
2130 dnl ---------------------------------------------------------------
2131 dnl Add site and system specific flags to compile and link commands
2132 dnl ---------------------------------------------------------------
2133
2134 dnl Allow use of either ":" or spaces for lists of directories
2135 define(COLON_TO_SPACE,
2136   [case "$[$1]" in *:* [)] [$1]="`echo '' $[$1] | sed -e 's/^ //' -e 's/:/ /g'`";; esac])dnl
2137
2138 dnl --site-libraries (multiple dirs)
2139 COLON_TO_SPACE(site_libraries)
2140 if test -n "$site_libraries"; then
2141   for arg in $site_libraries; do
2142     case "$arg" in
2143      -* ) ;;
2144      * ) test -d "$arg" || \
2145            XE_DIE("Invalid site library \`$arg': no such directory")
2146        arg="-L${arg}" ;;
2147     esac
2148     XE_APPEND($arg, ld_switch_site)
2149   done
2150 fi
2151
2152 dnl --site-includes (multiple dirs)
2153 COLON_TO_SPACE(site_includes)
2154 if test -n "$site_includes"; then
2155   for arg in $site_includes; do
2156     case "$arg" in
2157       -* ) ;;
2158       * ) test -d "$arg" || \
2159            XE_DIE("Invalid site include \`$arg': no such directory")
2160       arg="-I${arg}" ;;
2161     esac
2162     XE_APPEND($arg, c_switch_site)
2163   done
2164 fi
2165
2166 dnl --site-prefixes (multiple dirs)
2167 dnl --site-prefixes=dir1:dir2 is a convenient shorthand for
2168 dnl --site-libraries=dir1/lib:dir2/lib --site-includes=dir1/include:dir2/include
2169 dnl Site prefixes take precedence over the standard places, but not over
2170 dnl site-includes and site-libraries.
2171 COLON_TO_SPACE(site_prefixes)
2172 if test -n "$site_prefixes"; then
2173   for dir in $site_prefixes; do
2174     lib_dir="${dir}/lib"
2175     inc_dir="${dir}/include"
2176     if test ! -d "$dir"; then
2177       XE_DIE("Invalid site prefix \`$dir': no such directory")
2178     elif test ! -d "$lib_dir"; then
2179       XE_DIE("Invalid site prefix \`$dir': no such directory \`$lib_dir'")
2180     else
2181       if test -d "$inc_dir"; then
2182         XE_APPEND("-I$inc_dir", c_switch_site)
2183       fi
2184       XE_APPEND("-L$lib_dir", ld_switch_site)
2185     fi
2186   done
2187 fi
2188
2189 dnl GNU software installs by default into /usr/local/{include,lib}
2190 dnl if test -d "/usr/local/include" -a -d "/usr/local/lib"; then
2191 dnl   XE_APPEND("-L/usr/local/lib",    ld_switch_site)
2192 dnl   XE_APPEND("-I/usr/local/include", c_switch_site)
2193 dnl fi
2194
2195 dnl Extra system-specific library directories - please add to list
2196 for dir in "/usr/ccs/lib"; do
2197   test -d "$dir" && XE_APPEND(-L${dir}, ld_switch_system)
2198 done
2199
2200 dnl --site-runtime-libraries (multiple dirs)
2201 COLON_TO_SPACE(site_runtime_libraries)
2202 if test -n "$site_runtime_libraries"; then
2203   LD_RUN_PATH="`echo $site_runtime_libraries | sed -e 's/  */:/g'`"
2204   export LD_RUN_PATH
2205 fi
2206
2207 dnl Linux systems have dynamic runtime library directories listed in
2208 dnl /etc/ld.so.conf.  Since those are used at run time, it seems pretty
2209 dnl safe to use them at link time, and less controversial than forcing
2210 dnl the run-time to use the link-time libraries.  This also helps avoid
2211 dnl mismatches between the link-time and run-time libraries.
2212
2213 dnl #### Unfortunately, there are horrible libc4 and libc5 libraries
2214 dnl listed in /etc/ld.so.conf on some systems, and including them on
2215 dnl the link path leads to linking in utterly broken libc's.
2216 dnl There are many clever ways of approaching this problem,
2217 dnl but finding one that actually works...
2218
2219 dnl if test -z "$LD_RUN_PATH" -a -r "/etc/ld.so.conf"; then
2220 dnl   for dir in `cat /etc/ld.so.conf`; do
2221 dnl     test -d "$dir" && XE_APPEND(-L${dir}, ld_switch_system)
2222 dnl   done
2223 dnl   add_runtime_path=no
2224 dnl fi
2225
2226 dnl -------------------------------------
2227 dnl Compute runtime library path
2228 dnl -------------------------------------
2229
2230 if test -n "$add_runtime_path"; then :;
2231 elif test "$dynamic" = "no"; then add_runtime_path=no
2232 elif test -n "$LD_RUN_PATH"; then add_runtime_path=yes
2233 else case "$opsys" in
2234        sol2 | irix* | *bsd* | decosf* ) add_runtime_path=yes ;;
2235        * ) add_runtime_path=no ;;
2236      esac
2237 fi
2238
2239 if test "$add_runtime_path" = "yes"; then
2240   dnl Try to autodetect runtime library flag (usually -R),
2241   dnl and whether it works (or at least does no harm)
2242   AC_MSG_CHECKING("for runtime libraries flag")
2243   case "$opsys" in
2244     sol2 ) dash_r="-R" ;;
2245     decosf* | linux* | irix*) dash_r="-rpath " ;;
2246     *)
2247       dash_r=""
2248       for try_dash_r in "-R" "-R " "-rpath "; do
2249         xe_check_libs="${try_dash_r}/no/such/file-or-directory"
2250         XE_PROTECT_LINKER_FLAGS(xe_check_libs)
2251         AC_TRY_LINK(, , dash_r="$try_dash_r")
2252         xe_check_libs=""
2253         test -n "$dash_r" && break
2254       done ;;
2255   esac
2256   if test -n "$dash_r";
2257     then AC_MSG_RESULT("\"${dash_r}\"")
2258     else AC_MSG_RESULT(NONE)
2259   fi
2260 fi
2261
2262 xe_add_unique_runpath_dir='
2263   xe_add_p=yes
2264   for xe_dir in $runpath_dirs; do   dnl Uniquify
2265     test "$xe_dir" = "$xe_runpath_dir" && xe_add_p=no
2266   done
2267   if test "$xe_add_p" = "yes"; then
2268     test -n "$runpath" && runpath="${runpath}:"
2269     runpath="${runpath}${xe_runpath_dir}"
2270     runpath_dirs="$runpath_dirs $xe_runpath_dir"
2271   fi'
2272
2273
2274 dnl XE_ADD_RUNPATH_DIR(directory)
2275 define([XE_ADD_RUNPATH_DIR],[{
2276 xe_runpath_dir=$1
2277 dnl PRINT_VAR(ld_switch_site ld_switch_x_site runpath xe_runpath_dir LD_RUN_PATH xe_ldflags)
2278   test "$xe_runpath_dir" != "/lib"     -a \
2279         "$xe_runpath_dir" != "/usr/lib" -a \
2280         -n "`ls ${xe_runpath_dir}/*.s[[ol]] 2>/dev/null`" && \
2281   eval "$xe_add_unique_runpath_dir"
2282 }])dnl
2283
2284 dnl XE_COMPUTE_RUNPATH()
2285 define([XE_COMPUTE_RUNPATH],[
2286 if test "$add_runtime_path" = "yes" -a -n "$dash_r"; then
2287   dnl Remove runtime paths from current ld switches
2288   ld_switch_site=`echo   '' $ld_switch_site   | sed -e 's:^ ::' -e "s/$dash_r[[^ ]]*//g"`
2289   ld_switch_x_site=`echo '' $ld_switch_x_site | sed -e 's:^ ::' -e "s/$dash_r[[^ ]]*//g"`
2290   dnl PRINT_VAR(ld_switch_site ld_switch_x_site)
2291
2292   dnl Fix up Runtime path
2293   dnl If LD_RUN_PATH is set in environment, use that.
2294   dnl In this case, assume user has set the right value.
2295   runpath="" runpath_dirs=""
2296   if test -n "$LD_RUN_PATH"; then
2297     runpath="$LD_RUN_PATH"
2298   elif test "$GCC" = "yes"; then
2299     dnl Compute runpath from gcc's -v output
2300     ld_switch_run_save="$ld_switch_run"; ld_switch_run=""
2301     echo "int main(int argc, char *argv[[]]) {return 0;}" > conftest.c
2302     xe_runpath_link='${CC-cc} -o conftest -v $CFLAGS '"$xe_ldflags"' conftest.$ac_ext 2>&1 1>/dev/null'
2303     for arg in `eval "$xe_runpath_link" | grep ' -L'`; do
2304       case "$arg" in P,* | -L* | -R* )
2305         for dir in `echo '' "$arg" | sed -e 's:^ ::' -e 's/^..//' -e 'y/:/ /'`; do
2306           XE_ADD_RUNPATH_DIR("$dir")
2307         done ;;
2308       esac
2309     done
2310     ld_switch_run="$ld_switch_run_save"
2311     rm -f conftest*
2312   else
2313     dnl Add all directories with .so files to runpath
2314     for arg in $ld_switch_site $ld_switch_x_site; do
2315       case "$arg" in -L*) XE_ADD_RUNPATH_DIR(`echo '' "$arg" | sed -e 's:^ ::' -e 's/^-L//'`);; esac
2316     done
2317     dnl Sometimes /opt/SUNWdt/lib is the only installed Motif available
2318     dnl #### this test always fails here as need_motif is null
2319     if test "$opsys $need_motif" = "sol2 yes"; then
2320       xe_runpath_dir="/opt/SUNWdt/lib";
2321       eval "$xe_add_unique_runpath_dir";
2322     fi
2323   fi dnl Compute $runpath
2324
2325   if test -n "$runpath"; then
2326     ld_switch_run="${dash_r}${runpath}"
2327     XE_PROTECT_LINKER_FLAGS(ld_switch_run)
2328     test "$extra_verbose" = "yes" && echo "Setting runpath to $runpath"
2329   fi
2330 fi
2331 ])dnl
2332 XE_COMPUTE_RUNPATH()
2333
2334 dnl -----------------------------------
2335 dnl Do some misc autoconf-special tests
2336 dnl -----------------------------------
2337
2338 dnl Do the opsystem or machine files prohibit the use of the GNU malloc?
2339 dnl Assume not, until told otherwise.
2340 GNU_MALLOC=yes
2341 if test "$with_dlmalloc" != "no"; then
2342         doug_lea_malloc=yes
2343 else
2344         doug_lea_malloc=no
2345 fi
2346 after_morecore_hook_exists=yes
2347 AC_CHECK_FUNC(malloc_set_state, ,doug_lea_malloc=no)
2348 AC_MSG_CHECKING(whether __after_morecore_hook exists)
2349 AC_TRY_LINK([extern void (* __after_morecore_hook)();],[__after_morecore_hook = 0],
2350   [AC_MSG_RESULT(yes)],
2351   [AC_MSG_RESULT(no)
2352    after_morecore_hook_exists=no])
2353 if test "$system_malloc" = "yes" ; then
2354   GNU_MALLOC=no
2355   GNU_MALLOC_reason="
2356     - The GNU allocators don't work with this system configuration."
2357 elif test "$with_system_malloc" = "yes" ; then
2358   GNU_MALLOC=no
2359   GNU_MALLOC_reason="
2360     - User chose not to use GNU allocators."
2361 elif test "$with_debug_malloc" = "yes" ; then
2362   GNU_MALLOC=no
2363   GNU_MALLOC_reason="
2364     - User chose to use Debugging Malloc."
2365 fi
2366
2367 if test "$doug_lea_malloc" = "yes" -a "$GNU_MALLOC" = "yes" ; then
2368   GNU_MALLOC_reason="
2369     - Using Doug Lea's new malloc from the GNU C Library."
2370   AC_DEFINE(DOUG_LEA_MALLOC)
2371   if test "$after_morecore_hook_exists" = "no" ; then
2372     GNU_MALLOC_reason="
2373     - Using Doug Lea's new malloc from the Linux C Library."
2374     AC_DEFINE(_NO_MALLOC_WARNING_)
2375   fi
2376 fi
2377
2378 dnl #### mcheck is broken in all versions of Linux libc and glibc.
2379 dnl Try this again when 2.1 hits the streets.
2380 dnl Avoid using free-hook.c if support exists for malloc debugging in libc
2381 dnl have_libmcheck=no
2382 dnl if test "$error_check_malloc" = "yes" -a \
2383 dnl    "$have_glibc" = "yes" -a \
2384 dnl    "$doug_lea_malloc" = "yes"; then
2385 dnl   AC_CHECK_HEADERS(mcheck.h)
2386 dnl   AC_CHECK_LIB(mcheck, mcheck, have_libmcheck=yes, have_libmcheck=no)
2387 dnl fi
2388
2389 dnl if test "$have_libmcheck" = "yes"; then
2390 dnl   AC_DEFINE(HAVE_LIBMCHECK)
2391 dnl   libmcheck=-lmcheck
2392 dnl   AC_SUBST(libmcheck)
2393 dnl fi
2394
2395 dnl Some other nice autoconf tests.  If you add a test here which
2396 dnl should make an entry in src/config.h, do not forget to add an
2397 dnl #undef clause to src/config.h.in for autoconf to modify.
2398
2399 AC_PROG_RANLIB
2400 AC_PROG_INSTALL
2401 AC_PROG_YACC
2402
2403 dnl checks for header files
2404 AC_CHECK_HEADERS(dnl
2405   a.out.h dnl
2406   elf.h dnl
2407   cygwin/version.h dnl
2408   fcntl.h dnl
2409   inttypes.h dnl
2410   libgen.h dnl
2411   locale.h dnl
2412   mach/mach.h dnl
2413   sys/param.h dnl
2414   sys/pstat.h dnl
2415   sys/time.h dnl
2416   sys/timeb.h dnl
2417   sys/un.h dnl
2418   ulimit.h dnl
2419   unistd.h dnl
2420 )
2421 AC_HEADER_SYS_WAIT
2422 AC_HEADER_STDC
2423 AC_HEADER_TIME
2424 AC_DECL_SYS_SIGLIST
2425
2426
2427 dnl ----------------------------------------------------------------
2428 dnl Checking for utime() or utimes().
2429 dnl We prefer utime, since it is more standard.
2430 dnl Some systems have utime.h but do not declare the struct anyplace,
2431 dnl so we use a more sophisticated test for utime than AC_CHECK_FUNCS.
2432 dnl ----------------------------------------------------------------
2433 AC_MSG_CHECKING(for utime)
2434 AC_TRY_COMPILE([#include <sys/types.h>
2435 #include <utime.h>],
2436 [struct utimbuf x; x.actime = x.modtime = 0; utime ("/", &x);],
2437   [AC_MSG_RESULT(yes)
2438    AC_DEFINE(HAVE_UTIME)],
2439   [AC_MSG_RESULT(no)
2440    dnl We don't have utime(); how about utimes()?
2441    AC_CHECK_FUNCS(utimes)])
2442
2443
2444 dnl checks for typedefs
2445 AC_TYPE_SIGNAL
2446 AC_TYPE_SIZE_T
2447 AC_TYPE_PID_T
2448 AC_TYPE_UID_T
2449 AC_TYPE_MODE_T
2450 AC_TYPE_OFF_T
2451 AC_CHECK_TYPE(ssize_t, int)
2452
2453 dnl check for Unix98 socklen_t
2454 AC_MSG_CHECKING(for socklen_t)
2455 AC_TRY_COMPILE([#include <sys/types.h>
2456 #include <sys/socket.h>
2457 socklen_t x;
2458 ],[],[AC_MSG_RESULT(yes)],[
2459 AC_TRY_COMPILE([#include <sys/types.h>
2460 #include <sys/socket.h>
2461 int accept (int, struct sockaddr *, size_t *);
2462 ],[],[
2463 AC_MSG_RESULT(size_t)
2464 AC_DEFINE(socklen_t,size_t)], [
2465 AC_MSG_RESULT(int)
2466 AC_DEFINE(socklen_t,int)])])
2467
2468 AC_MSG_CHECKING(for struct timeval)
2469 AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
2470 #include <sys/time.h>
2471 #include <time.h>
2472 #else
2473 #ifdef HAVE_SYS_TIME_H
2474 #include <sys/time.h>
2475 #else
2476 #include <time.h>
2477 #endif
2478 #endif], [static struct timeval x; x.tv_sec = x.tv_usec;],
2479   [AC_MSG_RESULT(yes)
2480   HAVE_TIMEVAL=yes
2481   AC_DEFINE(HAVE_TIMEVAL)],
2482   [AC_MSG_RESULT(no)
2483    HAVE_TIMEVAL=no])
2484
2485 dnl checks for structure members
2486 AC_STRUCT_TM
2487 AC_STRUCT_TIMEZONE
2488
2489 dnl checks for compiler characteristics
2490 AC_C_CONST
2491
2492 dnl check for Make feature
2493 AC_PROG_MAKE_SET
2494
2495 dnl check byte order
2496 AC_C_BIGENDIAN
2497
2498 dnl define SIZEOF_TYPE
2499 AC_CHECK_SIZEOF(short)
2500 if test "$ac_cv_sizeof_short" = 0; then
2501   echo ""
2502   echo "*** PANIC *** Configure tests are not working - compiler is broken."
2503   echo "*** PANIC *** Please examine config.log for compilation errors."
2504   exit 1
2505 fi
2506 AC_CHECK_SIZEOF(int)
2507 AC_CHECK_SIZEOF(long)
2508 AC_CHECK_SIZEOF(long long)
2509 AC_CHECK_SIZEOF(void *)
2510
2511 dnl Cygwin from 1003022 has intptr_t, uintptr_t in <cygwin/types.h>
2512 case $opsys in
2513   cygwin* ) AC_EGREP_HEADER([typedef.*intptr_t;], [cygwin/types.h],
2514                             [AC_MSG_RESULT(yes)
2515                              AC_DEFINE(INTPTR_T_IN_CYGWIN_TYPES_H,1)],
2516                             [AC_MSG_RESULT(no)]) ;;
2517 esac
2518
2519 dnl check for long file names
2520 AC_SYS_LONG_FILE_NAMES
2521
2522 dnl -lm is required by LISP_FLOAT_TYPE, among other things
2523 AC_CHECK_FUNC(sin, ,AC_CHECK_LIB(m, sin))
2524
2525 dnl Floating operation support is now unconditional
2526 AC_DEFINE(LISP_FLOAT_TYPE)
2527
2528 AC_TRY_LINK([#include <math.h>],
2529   [return atanh(1.0) + asinh(1.0) + acosh(1.0); ],
2530   AC_DEFINE(HAVE_INVERSE_HYPERBOLIC))
2531
2532 dnl Determine type of mail locking from configure args and s&m headers
2533 AC_CHECKING(type of mail spool file locking)
2534 AC_CHECK_FUNCS(lockf flock)
2535 dnl The mail_use_xxx variables are set according to the s&m headers.
2536 test -z "$mail_locking" -a "$mail_use_flock" = "yes" && mail_locking=flock
2537 test -z "$mail_locking" -a "$mail_use_lockf" = "yes" && mail_locking=lockf
2538 test -z "$mail_locking" -a "$mail_use_locking" = "yes" && mail_locking=locking
2539 if   test -z "$mail_locking"; then
2540   case "$opsys" in cygwin* | mingw*)
2541     mail_locking=pop ;;
2542   esac
2543 fi
2544
2545 if   test "$mail_locking" = "lockf"; then AC_DEFINE(MAIL_LOCK_LOCKF)
2546 elif test "$mail_locking" = "flock"; then AC_DEFINE(MAIL_LOCK_FLOCK)
2547 elif test "$mail_locking" = "locking"; then AC_DEFINE(MAIL_LOCK_LOCKING)
2548 elif test "$mail_locking" = "pop"; then
2549   with_pop=yes
2550   mail_locking=
2551 else mail_locking="dot-locking"; AC_DEFINE(MAIL_LOCK_DOT)
2552 fi
2553 test "$mail_locking" = "lockf" -a "$ac_cv_func_lockf" != "yes" && \
2554   XE_DIE("lockf mail locking requested but not available.")
2555 test "$mail_locking" = "flock" -a "$ac_cv_func_flock" != "yes" && \
2556   XE_DIE("flock mail locking requested but not available.")
2557 test "$mail_locking" = "locking" -a "$ac_cv_func_locking" != "yes" && \
2558   XE_DIE("locking mail locking requested but not available.")
2559
2560 case "$opsys" in decosf*)
2561   AC_CHECK_LIB(pthreads, cma_open)
2562   test "$ac_cv_lib_pthreads_cma_open" = "yes" && \
2563     c_switch_site="$c_switch_site -threads" ;;
2564 esac
2565
2566 dnl ----------------------------------------------------------------
2567 dnl Miscellaneous flags
2568 dnl ----------------------------------------------------------------
2569
2570 AC_MSG_CHECKING(whether the -xildoff compiler flag is required)
2571 if   ${CC-cc} '-###' -xildon  no_such_file.c 2>&1 | grep '^[^ ]*/ild ' > /dev/null ; then
2572   if ${CC-cc} '-###' -xildoff no_such_file.c 2>&1 | grep '^[^ ]*/ild ' > /dev/null ;
2573     then AC_MSG_RESULT(no);
2574     else AC_MSG_RESULT(yes); XE_APPEND(-xildoff, ld_switch_site)
2575   fi
2576   else AC_MSG_RESULT(no)
2577 fi
2578
2579 dnl Link with "-z ignore" on Solaris if supported
2580 if test "$opsys" = "sol2"; then
2581   if test "$os_release" -ge 506; then
2582     AC_MSG_CHECKING(for \"-z ignore\" linker flag)
2583     case "`ld -h 2>&1`" in
2584       *-z\ ignore\|record* ) AC_MSG_RESULT(yes)
2585         XE_PREPEND(-z ignore, ld_switch_site) ;;
2586       *) AC_MSG_RESULT(no) ;;
2587     esac
2588   fi
2589 fi
2590
2591 dnl ----------------------
2592 dnl Choose a window system
2593 dnl ----------------------
2594
2595 AC_CHECKING("for specified window system")
2596
2597 dnl Autodetection of Gdk libraries and includes
2598 dnl -------------------------------------------
2599 dnl On some systems (FreeBSD springs to mind), they use
2600 dnl versions on the utility routines, so instead of gtk-config
2601 dnl you must use gtk12-config, etc, etc.
2602
2603 GNOME_CONFIG=no
2604 GTK_CONFIG=no
2605
2606 if test "$with_gnome" != "no"; then
2607    AC_MSG_CHECKING(for GNOME configuration script)
2608    for possible in gnome-config
2609    do
2610       possible_version=`${possible} --version 2> /dev/null`
2611       if test "x${possible_version}" != "x"; then
2612               GNOME_CONFIG="${possible}"
2613               with_gnome=yes
2614               with_gtk=yes
2615               break
2616       fi
2617    done
2618    AC_MSG_RESULT([${GNOME_CONFIG}])
2619 fi
2620
2621 if test "${GNOME_CONFIG}" != "no"; then
2622       GNOME_LIBS=`${GNOME_CONFIG} --libs gnomeui`
2623       GNOME_CFLAGS=`${GNOME_CONFIG} --cflags gnomeui`
2624       AC_DEFINE(HAVE_GNOME)
2625       XE_APPEND(${GNOME_LIBS}, libs_gtk)
2626       XE_APPEND(${GNOME_CFLAGS}, c_switch_gtk)
2627 fi
2628
2629 if test "$with_gtk" != "no";then
2630    AC_MSG_CHECKING(for GTK configuration script)
2631    for possible in gtk12-config gtk14-config gtk-config
2632    do
2633       possible_version=`${possible} --version 2> /dev/null`
2634       if test "x${possible_version}" != "x"; then
2635               GTK_CONFIG="${possible}"
2636               case "${possible_version}" in
2637                 1.0.*) AC_MSG_WARN([GTK 1.2 is required, please upgrade your version of GTK.]); with_gtk=no;;
2638                 1.3.*) AC_MSG_WARN([GTK 1.3 is not supported right now]); with_gtk=no;;
2639                 1.2.*)
2640                         with_gtk=yes
2641                         break
2642                         ;;
2643                 *)     AC_MSG_WARN([Found unsupported version of GTK: $possible_version]);;
2644               esac
2645       fi
2646    done
2647    AC_MSG_RESULT([${GTK_CONFIG}])
2648 fi
2649
2650 if test "${GTK_CONFIG}" != "no"; then
2651       AC_MSG_CHECKING(gtk version)
2652       GTK_VERSION=`${GTK_CONFIG} --version`
2653       AC_MSG_RESULT(${GTK_VERSION})
2654
2655       AC_MSG_CHECKING(gtk libs)
2656       GTK_LIBS=`${GTK_CONFIG} --libs`
2657       XE_APPEND(${GTK_LIBS}, libs_gtk)
2658       AC_MSG_RESULT(${GTK_LIBS})
2659
2660       AC_MSG_CHECKING(gtk cflags)
2661       GTK_CFLAGS=`${GTK_CONFIG} --cflags`
2662       if test "$GCC" = "yes"; then
2663         GTK_CFLAGS="${GTK_CFLAGS} -Wno-shadow"
2664       fi
2665       XE_APPEND(${GTK_CFLAGS}, c_switch_gtk)
2666       AC_MSG_RESULT(${GTK_CFLAGS})
2667
2668       AC_CHECK_LIB(gdk_imlib, main, XE_PREPEND(-lgdk_imlib, libs_gtk))
2669       AC_CHECK_LIB(Imlib, Imlib_init, XE_APPEND(-lImlib, libs_gtk))
2670       AC_CHECK_FUNCS(gdk_imlib_init)
2671
2672       AC_DEFINE(HAVE_XPM)
2673       AC_DEFINE(HAVE_GTK)
2674       AC_SUBST(GTK_CONFIG)
2675
2676       window_system=gtk
2677       with_gtk=yes
2678       with_x11=no
2679
2680       test "${with_scrollbars}" != "no" && with_scrollbars=gtk
2681       test "${with_toolbars}" != no && with_toolbars=gtk
2682       test "${with_menubars}" != "no" && with_menubars=gtk
2683       test "${with_dialogs}" != "no" && with_dialogs=gtk
2684       test "${with_widgets}" != "no" && with_widgets=gtk
2685
2686       XE_ADD_OBJS(console-gtk.o device-gtk.o event-gtk.o frame-gtk.o)
2687       XE_ADD_OBJS(objects-gtk.o redisplay-gtk.o glyphs-gtk.o)
2688       XE_ADD_OBJS(select-gtk.o gccache-gtk.o)
2689       XE_ADD_OBJS(gtk-xemacs.o ui-gtk.o)
2690
2691       dnl Check for libglade support (it rocks)
2692       OLD_CFLAGS="${CFLAGS}"
2693       OLD_CPPFLAGS="${CPPFLAGS}"
2694       OLD_LDFLAGS="${LDFLAGS}"
2695       CFLAGS="${GTK_CFLAGS} ${CFLAGS}"
2696       CPPFLAGS="${GTK_CFLAGS} ${CFLAGS}"
2697       LDFLAGS="${LDFLAGS} ${GTK_LIBS}"
2698       AC_CHECK_HEADERS(glade/glade.h glade.h)
2699       AC_CHECK_LIB(xml, main, XE_PREPEND(-lxml, libs_gtk))
2700       AC_CHECK_LIB(glade, main, XE_PREPEND(-lglade, libs_gtk))
2701       AC_CHECK_LIB(glade-gnome, main, XE_PREPEND(-lglade-gnome, libs_gtk))
2702       AC_EGREP_HEADER([char \*txtdomain;], [glade/glade-xml.h],
2703                       [AC_MSG_RESULT(yes)
2704                        AC_DEFINE(LIBGLADE_XML_TXTDOMAIN,1)],
2705                       [AC_MSG_RESULT(no)])
2706       CFLAGS="${OLD_CFLAGS}"
2707       CPPFLAGS="${OLD_CPPFLAGS}"
2708       LDFLAGS="${OLD_LDFLAGS}"
2709 fi
2710
2711 dnl We may eventually prefer gtk/gdk over vanilla X11...
2712
2713 if test "$with_x11" != "no"; then
2714   dnl User-specified --x-includes or --x-libraries implies --with-x11.
2715   test "$x_includes $x_libraries" != "NONE NONE" && \
2716    window_system=x11 with_x11=yes
2717
2718   dnl Autodetection of X11 libraries and includes
2719   dnl -------------------------------------------
2720   dnl AC_PATH_XTRA thinks it can find our X headers and includes, but
2721   dnl it often gets it wrong, so we only use it as a last resort.
2722
2723   dnl $OPENWINHOME implies --x-includes and --x-libraries
2724   dnl Not (yet) handled by autoconf2
2725   if test "$x_includes $x_libraries" = "NONE NONE" \
2726     -a -n "$OPENWINHOME" \
2727     -a "$OPENWINHOME" != "/usr/openwin" \
2728     -a -d "$OPENWINHOME"; then
2729       test -d "$OPENWINHOME/lib"           && x_libraries="$OPENWINHOME/lib"
2730       test -d "$OPENWINHOME/include"       && x_includes="$OPENWINHOME/include"
2731       test -d "$OPENWINHOME/share/include" && x_includes="$OPENWINHOME/share/include"
2732   fi
2733
2734   if test "$x_includes" = "NONE"; then
2735     dnl AC_PATH_XTRA often guesses /usr/include, when some other
2736     dnl include directory is a MUCH better guess (Linux, HP-UX 10.20).
2737     dnl This is a workaround for idiot (esp. HP) system vendors, who
2738     dnl provide a /usr/include/X11, but DON'T FULLY POPULATE IT.
2739     for dir in "/usr/X11" "/usr/X11R6"; do
2740       if test -d "$dir/include/X11"; then x_includes="$dir/include"; break; fi
2741     done
2742   fi
2743
2744   if test "$x_libraries" = "NONE"; then
2745     for dir in "/usr/X11/lib" "/usr/X11R6/lib" "/usr/lib/X11R6"; do
2746       if test -r "$dir/libX11.a"; then x_libraries="$dir"; break; fi
2747     done
2748   fi
2749
2750   AC_PATH_XTRA # Autoconf claims to find X library and include dirs for us.
2751   if test "$no_x" = "yes"
2752   then with_x11=no  window_system=none HAVE_X_WINDOWS=no
2753   else with_x11=yes window_system=x11  HAVE_X_WINDOWS=yes
2754   fi
2755 fi
2756
2757 dnl #### wmperry:: !x11 != NONE
2758 dnl case "$with_x11" in
2759 dnl  yes ) window_system=x11  HAVE_X_WINDOWS=yes ;;
2760 dnl  no  ) window_system=none HAVE_X_WINDOWS=no  ;;
2761 dnl esac
2762
2763 if test "$with_x11" = "yes"; then
2764   AC_DEFINE(HAVE_X_WINDOWS)
2765   XE_APPEND(lwlib, MAKE_SUBDIR)
2766   XE_APPEND(lwlib, SRC_SUBDIR_DEPS)
2767
2768
2769   dnl Look for Motif, but only if not found in $x_includes and $x_libraries
2770   AC_CHECK_HEADER(Xm/Xm.h, [AC_CHECK_LIB(Xm, XmStringFree, got_motif=yes)])
2771
2772   if test "$got_motif" != "yes"; then
2773     dnl Try to find Motif/CDE/Tooltalk dirs
2774     dnl These take precedence over other X libs/includes, so PRE-pend
2775     for lib_dir in "/usr/dt/lib" "/usr/lib/Motif2.1" \
2776                    "/usr/lib/Motif1.2" "/usr/lib/Motif1.1"; do
2777       inc_dir=`echo $lib_dir | sed -e 's/lib/include/'`
2778       if test -d "$lib_dir" -a -d "$inc_dir"; then
2779         case "$x_libraries" in *"$lib_dir"* ) ;; *)
2780           x_libraries="$lib_dir $x_libraries"
2781           XE_PREPEND(-L${lib_dir}, X_LIBS) ;;
2782         esac
2783         case "$x_includes" in "$inc_dir"* ) ;; *)
2784           x_includes="$inc_dir $x_includes"
2785           XE_PREPEND(-I${inc_dir}, X_CFLAGS) ;;
2786         esac
2787         break; dnl only need ONE Motif implementation!
2788         fi
2789     done
2790   fi
2791
2792   dnl Contrib X libs/includes do NOT take precedence, so AP-pend
2793   for rel in "X11R6" "X11R5" "X11R4"; do
2794     lib_dir="/usr/contrib/$rel/lib" inc_dir="/usr/contrib/$rel/include"
2795     if test -d "$lib_dir" -a -d "$inc_dir"; then
2796       case "$x_libraries" in *"$lib_dir"* ) ;; *)
2797         x_libraries="$x_libraries $lib_dir"
2798         XE_APPEND(-L${lib_dir}, X_LIBS)
2799       esac
2800       case "$x_includes" in "$inc_dir"* ) ;; *)
2801         x_includes="$x_includes $inc_dir"
2802         XE_APPEND(-I${inc_dir}, X_CFLAGS)
2803       esac
2804       break; dnl Only need ONE X11 implementation !
2805     fi
2806   done
2807
2808   dnl Avoid version mismatch for shared library libXm.so on osf4
2809   case "$opsys" in
2810   decosf*) if test "$GCC" = yes -a -d /usr/shlib; then XE_APPEND(-L/usr/shlib, X_LIBS); fi ;;
2811   esac
2812
2813   ld_switch_x_site="$X_LIBS"
2814
2815   XE_COMPUTE_RUNPATH()
2816
2817   if test "$extra_verbose" = "yes"; then
2818     echo; echo "X11 compilation variables:"
2819     PRINT_VAR(x_libraries x_includes X_CFLAGS X_LIBS X_PRE_LIBS X_EXTRA_LIBS)
2820     echo
2821   fi
2822
2823   dnl Set up bitmaps search path.
2824   dnl The original suggestion was to unconditionally to append X11/bitmaps
2825   dnl to each element of $x_includes, I'm pretty sure this is the wrong
2826   dnl thing to do.  We test for bitmaps and X11/bitmaps directories on each
2827   dnl element and add them to BITMAPDIR if they exist.
2828   bitmapdirs=
2829   if test "$x_includes" != NONE; then
2830     for i in $x_includes; do
2831       if test -d "$i/bitmaps"; then
2832         bitmapdirs="$i/bitmaps:$bitmapdirs"
2833       fi
2834       if test -d "$i/X11/bitmaps"; then
2835         bitmapdirs="$i/X11/bitmaps:$bitmapdirs"
2836       fi
2837     done
2838     bitmapdirs=`echo "$bitmapdirs" | sed s/.$//`
2839   fi
2840   test ! -z "$bitmapdirs" && AC_DEFINE_UNQUOTED(BITMAPDIR, "$bitmapdirs")
2841
2842   dnl Autodetect defines extracted from X config by xmkmf, e.g. NARROWPROTO
2843   AC_CHECKING(for X defines extracted by xmkmf)
2844   rm -fr conftestdir
2845   if mkdir conftestdir; then
2846     cd conftestdir
2847     cat > Imakefile <<'EOF'
2848 xetest:
2849         @echo ${PROTO_DEFINES} ${STD_DEFINES}
2850 EOF
2851     if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2852       # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
2853       xmkmf_defines=`${MAKE-make} xetest 2>/dev/null | grep -v make`
2854     fi
2855     cd ..
2856     rm -fr conftestdir
2857     for word in $xmkmf_defines; do
2858       case "$word" in 
2859       -D__STDC__*) ;;
2860       -D* )
2861         sym=`echo '' $word | sed -e 's:^ *-D::' -e 's:=.*::'`
2862         case "$word" in
2863           -D*=* ) val=`echo '' $word | sed -e 's:^.*=::'` ;;
2864           *     ) val=1 ;;
2865         esac
2866 dnl Avoid re-AC_DEFINE-ing xmkmf symbols we've already defined above.
2867         if grep "^#define $sym " confdefs.h >/dev/null; then :; else
2868           if test "$val" = "1"
2869             then AC_DEFINE_UNQUOTED($sym)
2870             else AC_DEFINE_UNQUOTED($sym,$val)
2871           fi
2872         fi  ;;
2873       esac
2874     done
2875   fi
2876
2877   dnl make sure we can find Intrinsic.h
2878   AC_CHECK_HEADER(X11/Intrinsic.h, ,
2879    [AC_MSG_ERROR("Unable to find X11 header files.")])
2880
2881   dnl -lXt and -lX11 are required
2882   dnl Some broken systems require the magic "-b i486-linuxaout" flag
2883   AC_CHECK_LIB(X11, XOpenDisplay, have_lib_x11=yes)
2884   if test "$have_lib_x11" != "yes"; then
2885     AC_CHECK_LIB(X11, XGetFontProperty,
2886       ld_switch_x_site="-b i486-linuxaout $ld_switch_x_site",
2887       [AC_MSG_ERROR("Unable to find X11 libraries.")],
2888       -b i486-linuxaout)
2889   fi
2890   libs_x="-lX11"
2891   test "$extra_verbose" = "yes" && echo "    Setting libs_x to \"-lX11\""
2892
2893   dnl Autodetect -lXext
2894   AC_CHECK_LIB(Xext, XShapeSelectInput, XE_PREPEND(-lXext, libs_x))
2895
2896   dnl Require -lXt
2897   AC_CHECK_LIB(Xt, XtOpenDisplay, XE_PREPEND(-lXt, libs_x),
2898     AC_MSG_ERROR("Unable to find X11 libraries."))
2899
2900   AC_MSG_CHECKING(the version of X11 being used)
2901   AC_TRY_RUN([#include <X11/Intrinsic.h>
2902     int main(int c, char *v[]) { return c>1 ? XlibSpecificationRelease : 0; }],
2903     [./conftest foobar; x11_release=$?],[x11_release=4],[x11_release=4])
2904   AC_MSG_RESULT(R${x11_release})
2905   AC_DEFINE_UNQUOTED(THIS_IS_X11R${x11_release})
2906
2907   if test "${x11_release}" = "4"; then
2908     case "$with_widgets" in
2909       "" | "no") with_widgets=no ;;
2910       *) XE_DIE("Widget support requires X11R5 or greater") ;;
2911     esac
2912   fi
2913
2914   AC_CHECK_FUNCS(XConvertCase XtRegisterDrawable)
2915
2916   AC_CHECK_HEADERS(X11/Xlocale.h)
2917
2918   dnl XFree86 has a non-standard prototype for this X11R6 function
2919   AC_CHECK_FUNCS(XRegisterIMInstantiateCallback)
2920   AC_MSG_CHECKING(for standard XRegisterIMInstantiateCallback prototype)
2921   AC_TRY_COMPILE([
2922 #define NeedFunctionPrototypes 1
2923 #include <X11/Xlib.h>
2924 extern Bool XRegisterIMInstantiateCallback(
2925    Display*, struct _XrmHashBucketRec*, char*, char*, XIMProc, XPointer*);
2926 ], [], 
2927   [AC_MSG_RESULT(yes)],
2928   [AC_MSG_RESULT(no)
2929    AC_DEFINE(XREGISTERIMINSTANTIATECALLBACK_NONSTANDARD_PROTOTYPE)])
2930
2931   dnl autodetect -lXmu
2932   test -z "$with_xmu" && { AC_CHECK_LIB(Xmu, XmuReadBitmapDataFromFile,
2933                            with_xmu=yes, with_xmu=no) }
2934   if test "$with_xmu" = "no"; then
2935     XE_ADD_OBJS(xmu.o)
2936   else
2937     XE_PREPEND(-lXmu, libs_x)
2938     AC_DEFINE(HAVE_XMU)
2939   fi
2940
2941   dnl Autodetect -lXbsd
2942   dnl #### Someone, please add a better function than main
2943   AC_CHECK_LIB(Xbsd, main, XE_PREPEND(-lXbsd, libs_x))
2944
2945   dnl Problem with the MIT distribution of X on AIX
2946   if test "$unexec" = "unexaix.o" -a "$x11_release" = "6"; then
2947     dnl X11R6 requires thread-safe code on AIX for some reason
2948     if test "$GCC" = "yes"; then
2949       dnl gcc changed the name of the `-mthreads' option to `-pthread'
2950       dnl on 2000-06-12
2951       AC_MSG_CHECKING(for name of AIX gcc threads option)
2952       case `$CC -v --help 2>&1` in
2953         *-mthreads*) aix_threads=-mthreads ;;
2954                   *) aix_threads=-pthread  ;;
2955       esac
2956       AC_MSG_RESULT($aix_threads)
2957       XE_PREPEND($aix_threads, X_CFLAGS)
2958       XE_PREPEND($aix_threads, libs_x)
2959     else
2960       dnl Try to use the thread-safe "_r" versions of xlc
2961       case "$CC" in *_r) : ;;
2962         *)
2963          xe_save_CC="$CC"
2964          CC="${CC}_r"
2965          AC_CHECK_SIZEOF(short)
2966          test "$ac_cv_sizeof_short" = 0 && CC="$xe_save_CC" ;;
2967       esac
2968     fi
2969   fi
2970
2971 fi dnl $with_x11 = yes
2972
2973 if test "$with_msw" != "no"; then
2974   AC_CHECKING(for MS-Windows)
2975   AC_CHECK_LIB(gdi32,main,with_msw=yes)
2976   if test "$with_msw" = "yes"; then
2977     AC_DEFINE(HAVE_MS_WINDOWS)
2978
2979     dnl The net installer only works with MS-Windows currently
2980     if test "$with_netinstall" = "yes"; then
2981       XE_APPEND(netinstall, MAKE_SUBDIR)
2982       XE_APPEND(netinstall, SRC_SUBDIR_DEPS)
2983       XE_APPEND(netinstall, INSTALL_ARCH_DEP_SUBDIR)
2984     fi
2985
2986     install_pp="$srcdir/lib-src/installexe.sh"
2987     XE_APPEND(-lshell32 -lgdi32 -luser32 -lcomdlg32 -lcomctl32 -lkernel32 -lwinspool, libs_system)
2988     test "$with_dragndrop" != no && XE_APPEND(msw, dragndrop_proto)
2989     if test "$window_system" != x11; then
2990         window_system=msw
2991         test "$with_scrollbars" != "no" && with_scrollbars=msw \
2992             && XE_ADD_OBJS(scrollbar-msw.o)
2993         test "$with_menubars"   != "no" && with_menubars=msw \
2994             && XE_ADD_OBJS(menubar-msw.o)
2995         test "$with_toolbars"   != "no" && with_toolbars=msw \
2996             && XE_ADD_OBJS(toolbar-msw.o)
2997         test "$with_dialogs"   != "no" && with_dialogs=msw \
2998             && XE_ADD_OBJS(dialog-msw.o)
2999         test "$with_widgets"   != "no" && with_widgets=msw
3000     else
3001         test "$with_scrollbars" != "no" && XE_ADD_OBJS(scrollbar-msw.o)
3002         test "$with_menubars"   != "no" && XE_ADD_OBJS(menubar-msw.o)
3003         test "$with_toolbars"   != "no" && XE_ADD_OBJS(toolbar-msw.o)
3004         test "$with_dialogs"    != "no" && XE_ADD_OBJS(dialog-msw.o)
3005     fi
3006     dnl check for our special version of select
3007     AC_TRY_RUN([#include <fcntl.h>
3008     int main() { return (open("/dev/windows", O_RDONLY, 0) > 0)? 0 : 1; }],
3009     [need_event_unixoid=yes; AC_DEFINE(HAVE_MSG_SELECT)])
3010     with_file_coding=yes
3011     XE_ADD_OBJS(console-msw.o device-msw.o event-msw.o frame-msw.o objects-msw.o select-msw.o redisplay-msw.o glyphs-msw.o gui-msw.o)
3012   fi
3013 fi
3014
3015 AC_SUBST(install_pp)
3016
3017 test -z "$window_system" && window_system="none"
3018
3019 dnl Test for features that require a window system - ANY window system
3020 if test "$window_system" = "none"; then
3021   for feature in menubars scrollbars toolbars dialogs dragndrop xface
3022   do
3023     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
3024        AC_MSG_WARN([--with-$feature ignored:  Not valid without window system support])
3025     fi
3026     eval "with_${feature}=no"
3027   done
3028 else
3029   test -z "$with_toolbars" && with_toolbars=yes
3030 fi
3031
3032 dnl ### Test for features that require mswindows support - currently none
3033 dnl ### MS-Windows folks: add code here..... (martin)
3034 if test "$with_msw" != "yes"; then
3035   for feature in   MARTIN_IS_CLUELESS_ABOUT_MSW_FEATURES
3036   do
3037     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
3038        AC_MSG_WARN([--with-$feature ignored:  Not valid without MS-Windows support])
3039     fi
3040     eval "with_${feature}=no"
3041   done
3042 else
3043   :
3044 fi
3045
3046 dnl Test for features that require X11 support
3047 if test "$with_x11" != "yes"; then
3048   dnl It ought to be reasonable to have no output device at all, and only use
3049   dnl XEmacs in --batch mode.
3050   dnl if test "$with_tty" = "no" ; then
3051   dnl   AC_MSG_ERROR([No window system support and no TTY support - Unable to proceed.])
3052   dnl fi
3053   for feature in tooltalk cde offix wmcommand xim xmu nas_sound
3054   do
3055     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
3056        AC_MSG_WARN([--with-$feature ignored:  Not valid without X support])
3057     fi
3058     eval "with_${feature}=no"
3059   done
3060 fi
3061
3062 dnl Balloon Help requires the Shape extension, not available everywhere,
3063 dnl for example not on AIX 4.3.
3064 if test "$with_x11" = "yes"; then
3065   AC_CHECK_HEADER(X11/extensions/shape.h, [
3066    AC_DEFINE(HAVE_BALLOON_HELP)
3067    XE_ADD_OBJS(balloon_help.o balloon-x.o)])
3068 fi
3069
3070 dnl FSF 19.29 has some bitmapdir stuff here.
3071 bitmapdir=
3072
3073 case "$window_system" in
3074   x11  ) HAVE_X_WINDOWS=yes; echo "  Using X11." ;;
3075   msw  ) HAVE_X_WINDOWS=no ; echo "  Using MS-Windows." ;;
3076   gtk  )
3077        HAVE_X_WINDOWS=no
3078        test "$with_gnome" = "yes" && echo "  Using GNOME."
3079        test "$with_gnome" = "no" && echo "  Using GTK."
3080        ;;
3081   none ) HAVE_X_WINDOWS=no ; echo "  Using no window system." ;;
3082 esac
3083
3084 case "$x_libraries" in *X11R4* )
3085   test "$opsys" = "hpux9"     && opsysfile="s/hpux9-x11r4.h"
3086   test "$opsys" = "hpux9-shr" && opsysfile="s/hpux9shxr4.h"
3087 esac
3088
3089 dnl Enable or disable proper handling of WM_COMMAND
3090 AC_CHECKING(for WM_COMMAND option);
3091 dnl if test "$with_wmcommand" = "yes"; then
3092 if test "$with_wmcommand" != "no"; then
3093   AC_DEFINE(HAVE_WMCOMMAND)
3094 fi
3095
3096 dnl Autodetect Xauth
3097 dnl -lXau is only used by gnuclient, so use a special variable for Xauth X libs
3098 test -z "$with_xauth" && test "$window_system" = "none" && with_xauth=no
3099 test -z "$with_xauth" && { AC_CHECK_HEADER(X11/Xauth.h,          ,with_xauth=no) }
3100 test -z "$with_xauth" && { AC_CHECK_LIB(Xau, XauGetAuthByAddr,[:],with_xauth=no) }
3101 test -z "$with_xauth" && with_xauth=yes
3102 if test "$with_xauth" = "yes"; then
3103   AC_DEFINE(HAVE_XAUTH)
3104   XE_SPACE(libs_xauth, $GTK_LIBS $X_EXTRA_LIBS -lXau $libs_x $X_PRE_LIBS)
3105 fi
3106 AC_SUBST(libs_xauth)
3107
3108 dnl This one is for the static initializeds variables in
3109 dnl offix.c, so that the thing is dumped after lastfile.o
3110 AC_SUBST(dnd_objs)
3111
3112 dnl Autodetect tooltalk
3113 if test "$with_tooltalk" != "no" ; then
3114   dnl autodetect the location of tt_c.h
3115   dnl tt_c.h might be in Tt or desktop include directories
3116   for dir in "" "Tt/" "desktop/" ; do
3117     AC_CHECK_HEADER(${dir}tt_c.h, tt_c_h_file="${dir}tt_c.h"; break)
3118   done
3119   if test -z "$tt_c_h_file"; then
3120     if test "$with_tooltalk" = "yes"; then
3121       USAGE_ERROR("Unable to find required tooltalk header files.")
3122     fi
3123     with_tooltalk=no
3124   fi
3125 fi
3126 if test "$with_tooltalk" != "no" ; then
3127   for extra_libs in "" "-lI18N -lce" "-lcxx"; do
3128     AC_CHECK_LIB(tt, tt_message_create,
3129       tt_libs="-ltt $extra_libs"; break, [:],$extra_libs)
3130   done
3131   if test -z "$tt_libs"; then
3132     if test "$with_tooltalk" = "yes"; then
3133       USAGE_ERROR("Unable to find required tooltalk libraries.")
3134     fi
3135     with_tooltalk=no
3136   fi
3137 fi
3138 test -z "$with_tooltalk" && with_tooltalk=yes
3139 if test "$with_tooltalk" = "yes"; then
3140   AC_DEFINE(TOOLTALK)
3141   AC_DEFINE_UNQUOTED(TT_C_H_FILE, "$tt_c_h_file")
3142   XE_PREPEND($tt_libs, libs_x)
3143   XE_ADD_OBJS(tooltalk.o)
3144 fi
3145
3146 dnl Autodetect CDE
3147 test -z "$with_cde" && { AC_CHECK_HEADER(Dt/Dt.h,               , with_cde=no) }
3148 test -z "$with_cde" && { AC_CHECK_LIB(DtSvc, DtDndDragStart, [:], with_cde=no) }
3149 test -z "$with_cde" && with_cde=yes
3150 if test "$with_dragndrop" = no; then
3151   AC_MSG_WARN([No CDE without generic Drag'n'Drop support])
3152   with_cde=no
3153 fi
3154 if test "$with_cde" = "yes" ; then
3155   AC_DEFINE(HAVE_CDE)
3156   XE_PREPEND(-lDtSvc, libs_x)
3157   XE_APPEND(CDE, dragndrop_proto)
3158   with_tooltalk=yes # CDE requires Tooltalk
3159   need_motif=yes    # CDE requires Motif
3160 fi
3161
3162 dnl Always compile OffiX unless --without-offix is given, no
3163 dnl X11 support is compiled in, no standard Xmu is available,
3164 dnl or dragndrop support is disabled
3165 dnl Because OffiX support currently loses when more than one display
3166 dnl is in use, we now disable it by default -slb 07/10/1998.
3167 test "$window_system" != "x11" && with_offix=no
3168 if test "$with_xmu" != yes -a "$with_x11" = yes; then
3169   AC_MSG_WARN([No OffiX without real Xmu support])
3170   with_offix=no
3171 fi
3172 if test "$with_dragndrop" = no; then
3173   AC_MSG_WARN([No OffiX without generic Drag'n'Drop support])
3174   with_offix=no
3175 fi
3176 if test "$with_cde" = yes; then
3177   AC_MSG_WARN([CDE already found, disabling OffiX support])
3178   with_offix=no
3179 fi
3180 test -z "$with_offix" && with_offix=no
3181 if test "$with_offix" = "yes"; then
3182   AC_DEFINE(HAVE_OFFIX_DND)
3183   XE_APPEND(offix.o, dnd_objs)
3184   XE_APPEND(OffiX, dragndrop_proto)
3185 fi
3186 if test "$with_gtk" = "yes"; then
3187    XE_APPEND(GTK, dragndrop_proto)
3188 fi
3189
3190 dnl Autodetect Drag'n'Drop support
3191 dnl always included if CDE, Offix, or MSWindows are defined
3192 if test "$with_dragndrop" != "no" ; then
3193   AC_MSG_CHECKING(if drag and drop API is needed)
3194   if test -n "$dragndrop_proto" ; then
3195     with_dragndrop=yes
3196     AC_MSG_RESULT([yes (${dragndrop_proto} )])
3197     AC_DEFINE(HAVE_DRAGNDROP)
3198     XE_APPEND(dragdrop.o, extra_objs)
3199   else
3200     with_dragndrop=no
3201     AC_MSG_RESULT(no)
3202   fi
3203 fi
3204
3205 dnl Autodetect LDAP
3206 AC_CHECKING(for LDAP)
3207 test -z "$with_ldap" && { AC_CHECK_HEADER(ldap.h, ,with_ldap=no) }
3208 test -z "$with_ldap" && { AC_CHECK_HEADER(lber.h, ,with_ldap=no) }
3209 if test no != "$with_ldap";then
3210   if test . != "${ldap_libs+.}";then
3211     ldap_libs=
3212     AC_CHECK_FUNC(ldap_open,dnl Allow it to be in generic "$LIBS"
3213       [with_ldap=yes
3214       test yes = "$extra_verbose" &&
3215         echo "Setting ldap_libs to $ldap_libs"],dnl
3216       [AC_CHECK_LIB(ldap, ldap_open,dnl
3217         [with_ldap=yes],dnl
3218 dnl If logic of setting these vars change, change it the same way below.
3219         [ldap_needs_lber=yes ldap_other_libs=-llber
3220 dnl This requires `AC_CACHE_VAL' (which is called by `AC_CHECK_LIB')
3221 dnl to be redefined to ignore cached (shell variable) value, as it is
3222 dnl done above, because the same variable is used in all
3223 dnl `AC_CHECK_LIB' expansions in macro invocation below.  Worse, if it
3224 dnl is not done, there is no portable way to compensate for this
3225 dnl locally since `unset' command is not supported by all shells.  The
3226 dnl other solution would be changing `AC_CHECK_LIB' so that cache
3227 dnl variable name depends on the macro OTHER-LIBRARIES argument.
3228         AC_CHECK_LIB(ldap, ldap_open,dnl
3229           [with_ldap=yes],dnl
3230           [ldap_needs_krb=yes ldap_other_libs="$ldap_other_libs -lkrb"
3231           AC_CHECK_LIB(ldap, ldap_open,dnl
3232             [with_ldap=yes],dnl
3233             [ldap_needs_des=yes ldap_other_libs="$ldap_other_libs -ldes"
3234             AC_CHECK_LIB(ldap, ldap_open,dnl
3235               [with_ldap=yes],dnl
3236               [with_ldap=no],dnl
3237               $ldap_other_libs)],dnl
3238             $ldap_other_libs)],dnl
3239           $ldap_other_libs)])
3240       if test yes = "$with_ldap" -a yes != "$ldap_needs_lber";then
3241 dnl Need this check since `LDAP_OPT_ON' is (currently) used only with
3242 dnl `ldap_set_option', and the latter may not exist at all, for which
3243 dnl is testing later.  So `LDAP_OPT_ON' is not necessarily defined.
3244         AC_CACHE_CHECK([for LDAP_OPT_ON definition],xe_cv_have_LDAP_OPT_ON,
3245           [AC_TRY_COMPILE(
3246 [#include <lber.h>
3247 #include <ldap.h>
3248 #ifdef LDAP_OPT_ON
3249 /* Relying on const defined by ac_c_const (upper case). */
3250 const void *const v = LDAP_OPT_ON;
3251 #else /* !defined (LDAP_OPT_ON) */
3252 choke me
3253 #endif /* !defined (LDAP_OPT_ON) */],[],
3254             [xe_cv_have_LDAP_OPT_ON=yes],
3255             [xe_cv_have_LDAP_OPT_ON=no])])
3256         if test yes = "$xe_cv_have_LDAP_OPT_ON";then
3257           AC_CACHE_CHECK([LDAP_OPT_ON linking],
3258             xe_cv_LDAP_OPT_ON_links,
3259             [xe_save_LIBS="$LIBS"
3260             LIBS="-lldap $LIBS"
3261 AC_TRY_LINK(
3262 [#include <lber.h>
3263 #include <ldap.h>
3264 const void *const v = LDAP_OPT_ON;],[],
3265               xe_cv_LDAP_OPT_ON_links=yes,
3266               xe_cv_LDAP_OPT_ON_links=no)
3267             LIBS="$xe_save_LIBS"])
3268 dnl In some openldap installations other `ldap_*' functions link with
3269 dnl `-lldap' alone, but `LDAP_OPT_ON' requires `-llber'.
3270           if test yes != "$xe_cv_LDAP_OPT_ON_links";then
3271             ldap_needs_lber=yes ldap_other_libs=-llber
3272             AC_CACHE_CHECK([LDAP_OPT_ON linking with -llber],
3273               xe_cv_LDAP_OPT_ON_links_w_lber,
3274               [xe_save_LIBS="$LIBS"
3275               LIBS="-lldap $ldap_other_libs $LIBS"
3276 AC_TRY_LINK(
3277 [#include <lber.h>
3278 #include <ldap.h>
3279 const void *const v = LDAP_OPT_ON;],[],
3280               xe_cv_LDAP_OPT_ON_links_w_lber=yes,
3281               xe_cv_LDAP_OPT_ON_links_w_lber=no)
3282               LIBS="$xe_save_LIBS"])
3283             if test yes != "$xe_cv_LDAP_OPT_ON_links_w_lber";then
3284               with_ldap=no
3285             fi
3286           fi
3287         fi
3288       fi
3289       if test yes = "$with_ldap";then
3290         if test yes = "$ldap_needs_des";then
3291           XE_PREPEND(-ldes, ldap_libs)
3292         fi
3293         if test yes = "$ldap_needs_krb";then
3294           XE_PREPEND(-lkrb, ldap_libs)
3295         fi
3296         if test yes = "$ldap_needs_lber";then
3297           XE_PREPEND(-llber, ldap_libs)
3298         fi
3299         XE_PREPEND(-lldap, ldap_libs)
3300       fi])
3301   else
3302 dnl Allow builder to override "$ldap_libs".
3303     save_LIBS="$LIBS" LIBS="$ldap_libs $LIBS"
3304     AC_CHECK_FUNC(ldap_open,dnl
3305       [with_ldap=yes
3306       test yes = "$extra_verbose" &&
3307         echo "Setting ldap_libs to $ldap_libs"],dnl
3308       [with_ldap=no])
3309     LIBS="$save_LIBS"
3310   fi
3311 fi
3312 if test "$with_ldap" = "yes"; then
3313   AC_DEFINE(HAVE_LDAP)
3314   XE_ADD_OBJS(eldap.o)
3315   LIBS="$ldap_libs $LIBS"
3316   AC_CHECK_FUNCS(ldap_set_option ldap_get_lderrno ldap_result2error ldap_parse_result)
3317 fi
3318
3319 dnl Autodetect PostgreSQL
3320 dnl On many Linux systems, PostgreSQL is packaged to be installed in /usr;
3321 dnl in this case, configure will easily detect it there.
3322 dnl
3323 dnl If PostgreSQL is installed into a different prefix,
3324 dnl (such as the default /usr/local/pgsql when building from source),
3325 dnl that prefix must be specified using the --site-prefixes flag.
3326 if test "$with_postgresql" != "no"; then
3327   AC_CHECKING(for PostgreSQL)
3328
3329 dnl Look for these standard header file locations, known to be used on Linux
3330   for header_dir in "" "pgsql/" "postgresql/"; do
3331     AC_CHECK_HEADER(${header_dir}libpq-fe.h,
3332                     libpq_fe_h_file=${header_dir}libpq-fe.h; break)
3333   done
3334
3335   test -n "$libpq_fe_h_file" && { AC_CHECK_LIB(pq,PQconnectdb,have_libpq=yes) }
3336
3337   if test -n "$libpq_fe_h_file" -a "$have_libpq" = "yes"; then
3338     with_postgresql=yes
3339     AC_DEFINE(HAVE_POSTGRESQL)
3340     AC_CHECK_LIB(pq,PQconnectStart, [
3341                  with_postgresqlv7=yes;
3342                  AC_DEFINE(HAVE_POSTGRESQLV7)])
3343     AC_DEFINE_UNQUOTED(LIBPQ_FE_H_FILE, "$libpq_fe_h_file")
3344     XE_PREPEND(-lpq, LIBS)
3345     XE_ADD_OBJS(postgresql.o)
3346   elif test "$with_postgresql" = "yes"; then
3347     XE_DIE("Required PostgreSQL support cannot be provided.  Check --site-prefixes.")
3348   fi
3349 fi
3350
3351 dnl ----------------------
3352 dnl Graphics libraries
3353 dnl ----------------------
3354
3355 if test "$window_system" != "none"; then
3356   AC_CHECKING(for graphics libraries)
3357
3358   dnl add special code to handle xpm-nox on Cygwin (csw)
3359   dnl   -- should only happen if CYGWIN && WITH_XPM && WITH_MSW && !WITH_X
3360   libpath_xpm=
3361   incpath_xpm=
3362   libname_xpm="-lXpm"
3363   case "$opsys" in 
3364     cygwin*)
3365       cygwin_top=`eval gcc -print-search-dirs | sed -ne s'/install: //p'`
3366       cygwin_top=`eval "cd $cygwin_top/../../../..; pwd"`
3367       case "$window_system" in
3368         dnl use "standard" search pattern
3369         x11)  ;;
3370         dnl hardcode "standard" non-X11 xpm lib/inc dirs
3371         msw) libpath_xpm="-L${cygwin_top}/lib/noX"
3372              incpath_xpm="-I${cygwin_top}/include/noX"
3373              libname_xpm="-lXpm-noX"
3374               ;;
3375         dnl not supported on cygwin (yet?)
3376         gtk)  ;;
3377         dnl probably not reached...
3378         none) ;;
3379         dnl ditto
3380         *)    ;;
3381       esac
3382       ;;
3383     dnl use "standard" search pattern for all other OS's
3384     *) ;;
3385   esac
3386   dnl Autodetect Xpm
3387   xpm_problem=""
3388   if test -z "$with_xpm"; then
3389     XE_PREPEND("$incpath_xpm", CFLAGS)
3390     XE_PREPEND("$libpath_xpm", LDFLAGS)
3391     AC_MSG_CHECKING(for Xpm - no older than 3.4f)
3392     xe_check_libs="$libname_xpm"
3393     AC_TRY_RUN([#define XPM_NUMBERS
3394 #include <X11/xpm.h>
3395     int main(int c, char **v) {
3396     return c == 1 ? 0 :
3397       XpmIncludeVersion != XpmLibraryVersion() ? 1 :
3398       XpmIncludeVersion < 30406 ? 2 : 0 ;}],
3399     [./conftest dummy_arg; xpm_status=$?;
3400       if test "$xpm_status" = "0"; then
3401         with_xpm=yes;
3402       else
3403         with_xpm=no;
3404         if test "$xpm_status" = "1"; then
3405           xpm_problem="Xpm library version and header file version don't match!"
3406         elif test "$xpm_status" = "2"; then
3407           xpm_problem="Xpm library version is too old!"
3408         else
3409           xpm_problem="Internal xpm detection logic error!"
3410         fi
3411         echo "
3412 *** WARNING *** $xpm_problem
3413   I'm not touching that with a 10-foot pole!
3414   If you really want to use the installed version of Xpm, rerun
3415   configure and add '--with-xpm=yes', but don't blame me if XEmacs crashes!"
3416     fi],
3417     [with_xpm=no])
3418     xe_check_libs=
3419     AC_MSG_RESULT($with_xpm)
3420   fi
3421   if test "$with_xpm" = "yes"; then
3422     dnl #### This code assumes that if AC_CHECK_LIB fails,
3423     dnl #### then it will succeed if FOR_MSW is defined,
3424     dnl #### but doesn't actually verify this assumption.
3425     AC_DEFINE(HAVE_XPM)
3426     XE_PREPEND("$libpath_xpm", LDFLAGS)
3427     XE_PREPEND("$libname_xpm", libs_x)
3428     XE_PREPEND("$incpath_xpm", CFLAGS)
3429     AC_MSG_CHECKING(for \"FOR_MSW\" xpm)
3430     xe_check_libs="$libname_xpm"
3431     AC_TRY_LINK(, [XpmCreatePixmapFromData()],
3432     [xpm_for_msw=no],
3433     [xpm_for_msw=yes])
3434     xe_check_libs=
3435     AC_MSG_RESULT($xpm_for_msw)
3436     if test "$xpm_for_msw" = "yes"; then
3437       AC_DEFINE(FOR_MSW)
3438     fi
3439   fi
3440
3441   dnl Autodetect XFACE
3442   test -z "$with_xface" && { AC_CHECK_HEADER(compface.h,          ,with_xface=no) }
3443   test -z "$with_xface" && { AC_CHECK_LIB(compface, UnGenFace,[:] ,with_xface=no) }
3444   test -z "$with_xface" && with_xface=yes
3445   if test "$with_xface" = "yes"; then
3446     AC_DEFINE(HAVE_XFACE)
3447     XE_PREPEND(-lcompface, libs_x)
3448   fi
3449
3450   dnl For a brief period we had the GIF code split out into a separate library,
3451   dnl but patent problems, etc. sort of squashed that idea.
3452   dnl We default to building with builtin GIF decoding
3453   if test "$with_gif" != "no"; then
3454     with_gif="yes"
3455     AC_DEFINE(HAVE_GIF)
3456     XE_ADD_OBJS(dgif_lib.o gif_io.o)
3457   fi
3458
3459   dnl Too many stupid linkers can't detect cascaded lib dependencies until runtime
3460   dnl So we always search for libz compression support.
3461   if test "$with_png $with_tiff" != "no no"; then
3462     AC_CHECK_LIB(c,  inflate, [:], [
3463     AC_CHECK_LIB(z,  inflate, [XE_PREPEND(-lz,  libs_x)],[
3464     AC_CHECK_LIB(gz, inflate, [XE_PREPEND(-lgz, libs_x)])])])
3465   fi
3466
3467   dnl autodetect JPEG
3468   test -z "$with_jpeg" && { AC_CHECK_HEADER(jpeglib.h,                    ,with_jpeg=no) }
3469   test -z "$with_jpeg" && { AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,[:],with_jpeg=no) }
3470   test -z "$with_jpeg" && with_jpeg=yes
3471   if test "$with_jpeg" = "yes"; then
3472     AC_DEFINE(HAVE_JPEG)
3473     XE_PREPEND(-ljpeg, libs_x)
3474   fi
3475
3476   dnl autodetect PNG
3477   png_problem=""
3478   test -z "$with_png" && { AC_CHECK_FUNC(pow,                  ,with_png=no) }
3479   test -z "$with_png" && { AC_CHECK_HEADER(png.h,              ,with_png=no) }
3480   test -z "$with_png" && { AC_CHECK_LIB(png, png_read_image,[:],with_png=no) }
3481   if test -z "$with_png"; then
3482     AC_MSG_CHECKING(for workable png version information)
3483     xe_check_libs="-lpng -lz"
3484     AC_TRY_RUN([#include <png.h>
3485     int main(int c, char **v) {
3486     if (c == 1) return 0;
3487     if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING) != 0) return 1;
3488     return (PNG_LIBPNG_VER < 10002) ? 2 : 0 ;}],
3489     [./conftest dummy_arg; png_status=$?;
3490       if test "$png_status" = "0"; then
3491         with_png=yes;
3492       else
3493         with_png=no;
3494         if test "$png_status" = "1"; then
3495           png_problem="PNG library version and header file don't match!"
3496         elif test "$png_status" = "2"; then
3497           png_problem="PNG library version too old (pre 1.0.2)!"
3498         fi
3499         echo "
3500 *** WARNING *** $png_problem
3501   I'm not touching that with a 10-foot pole!
3502   If you really want to use the installed version of libPNG, rerun
3503   configure and add '--with-png=yes', but don't blame me if XEmacs crashes!"
3504     fi],
3505     [with_png=no])
3506     xe_check_libs=
3507     AC_MSG_RESULT($with_png)
3508   fi
3509   if test "$with_png" = "yes"; then
3510     AC_DEFINE(HAVE_PNG)
3511     XE_PREPEND(-lpng, libs_x)
3512   fi
3513
3514   dnl autodetect TIFF
3515   test -z "$with_tiff" && { AC_CHECK_HEADER(tiffio.h,            ,with_tiff=no) }
3516   test -z "$with_tiff" && { AC_CHECK_LIB(tiff, TIFFClientOpen,[:],with_tiff=no) }
3517   test -z "$with_tiff" && with_tiff=yes
3518   if test "$with_tiff" = "yes"; then
3519     AC_DEFINE(HAVE_TIFF)
3520     XE_PREPEND(-ltiff, libs_x)
3521   fi
3522 fi
3523
3524 dnl ----------------------
3525 dnl GTK-Specific Graphics libraries
3526 dnl ----------------------
3527
3528 if test "$with_gtk" = "yes"; then
3529   dnl Autodetect XFACE
3530   test -z "$with_xface" && { AC_CHECK_HEADER(compface.h,          ,with_xface=no) }
3531   test -z "$with_xface" && { AC_CHECK_LIB(compface, UnGenFace,[:] ,with_xface=no) }
3532   test -z "$with_xface" && with_xface=yes
3533   if test "$with_xface" = "yes"; then
3534     AC_DEFINE(HAVE_XFACE)
3535     XE_PREPEND(-lcompface, libs_gtk)
3536   fi
3537 fi
3538
3539
3540 dnl ----------------------
3541 dnl X-Specific Graphics libraries
3542 dnl ----------------------
3543
3544 if test "$with_x11" = "yes"; then
3545   AC_CHECKING(for X11 graphics libraries)
3546 fi
3547
3548 if test "$with_x11" = "yes"; then
3549   AC_CHECKING(for the Athena widgets)
3550
3551   dnl What in heck did the user actually want?
3552   case "$with_athena" in
3553     dnl This is the default, old fashioned flat Athena.
3554     "xaw" | "") athena_variant=Xaw      athena_3d=no  ;;
3555     "3d")       athena_variant=Xaw3d    athena_3d=yes ;;
3556     "next")     athena_variant=neXtaw   athena_3d=yes ;;
3557     "95")       athena_variant=Xaw95    athena_3d=yes ;;
3558     "xpm")      athena_variant=XawXpm   athena_3d=yes ;;
3559     *)          XE_DIE("Unknown Athena widget set \`$with_athena'. This should not happen.") ;;
3560   esac
3561
3562   athena_3d_function=Xaw3dComputeBottomShadowRGB
3563
3564   dnl Search for the Athena library...
3565   if test "$athena_3d" = "no"; then
3566     AC_CHECK_LIB($athena_variant, XawScrollbarSetThumb,
3567       [
3568         dnl Must not be a 3d library...
3569         AC_CHECK_LIB($athena_variant, $athena_3d_function,
3570           AC_MSG_WARN("Could not find a non-3d Athena widget library."),
3571           athena_lib=$athena_variant)
3572       ],
3573       AC_MSG_WARN("Could not find an Athena widget library."))
3574   else
3575     dnl The real configuration, need 3d library
3576     AC_CHECK_LIB($athena_variant, $athena_3d_function, athena_lib=$athena_variant,
3577       dnl OK, couldn't find it with a proper name, try the standard Athena lib
3578       dnl If that is 3d, presume the user asked for what they have installed.
3579       AC_CHECK_LIB(Xaw, $athena_3d_function,
3580         [
3581           athena_lib=Xaw;
3582           AC_MSG_WARN("Assuming that libXaw is actually $athena_variant.");
3583         ],
3584         AC_MSG_WARN("Could not find a 3d Athena widget library that looked like $athena_variant.")))
3585   fi
3586
3587   dnl Now we locate the Athena headers that we need.
3588   if test "$athena_3d" = "no"; then
3589     AC_CHECK_HEADER(X11/Xaw/ThreeD.h,
3590       AC_MSG_WARN("Could not find a non-3d Athena header set."),
3591       AC_CHECK_HEADER(X11/Xaw/XawInit.h,
3592         athena_h_path=X11/Xaw,
3593         AC_MSG_WARN("Could not find a non-3d Athena header set.")))
3594   else
3595     dnl The three-d Athena headers are so much more slippery.
3596     dnl Curse this `Lets replace standard libraries' thing that they did. :/
3597     AC_CHECK_HEADER(X11/$athena_variant/XawInit.h,
3598       AC_CHECK_HEADER(X11/$athena_variant/ThreeD.h,
3599         athena_h_path=X11/$athena_variant,))
3600
3601     dnl Is the variant specific header directory directly under include?
3602     if test -z "$athena_h_path"; then
3603       AC_CHECK_HEADER($athena_variant/XawInit.h,
3604         AC_CHECK_HEADER($athena_variant/ThreeD.h,
3605           athena_h_path=$athena_variant,))
3606     fi
3607
3608     dnl If we couldn't find the specific variant, try the generic Athena 3d headers
3609     if test -z "$athena_h_path" -a "$athena_variant" != "Xaw3d"; then
3610       AC_CHECK_HEADER(X11/Xaw3d/XawInit.h,
3611         AC_CHECK_HEADER(X11/Xaw3d/ThreeD.h,
3612           [
3613             AC_MSG_WARN("Assuming that X11/Xaw3d headers are suitable for $athena_variant.")
3614             athena_h_path=X11/Xaw3d
3615           ],))
3616     fi
3617
3618     dnl Also generic 3d headers directly under include dir
3619     if test -z "$athena_h_path" -a "$athena_variant" != "Xaw3d"; then
3620       AC_CHECK_HEADER(Xaw3d/XawInit.h,
3621         AC_CHECK_HEADER(Xaw3d/ThreeD.h,
3622           [
3623             AC_MSG_WARN("Assuming that Xaw3d headers are suitable for $athena_variant.")
3624             athena_h_path=Xaw3d
3625           ],))
3626     fi
3627
3628     dnl If nothing yet found, see if Xaw is a 3d header set...
3629     dnl We AC_MSG_WARN if we fail because I am all out of ideas...
3630     if test -z "$athena_h_path"; then
3631       AC_CHECK_HEADER(X11/Xaw/ThreeD.h,
3632         [
3633           AC_MSG_WARN("Assuming that X11/Xaw headers are suitable for $athena_variant.")
3634           athena_h_path=X11/Xaw
3635         ],
3636         AC_MSG_WARN("Could not find a suitable 3d Athena header set."))
3637     fi
3638   fi
3639
3640   dnl Do we actually have a usable Athena widget set? Please?
3641   if test -n "$athena_lib" -a -n "$athena_h_path"; then
3642     have_xaw=yes
3643   else
3644     have_xaw=no
3645   fi
3646
3647 else
3648   have_xaw=no
3649 fi dnl "$with_x11" = "yes"
3650
3651 if test "$with_x11" = "yes"; then
3652   dnl autodetect Motif - but only add to libs_x later (if necessary)
3653   AC_CHECK_HEADER(Xm/Xm.h,
3654    [AC_CHECK_LIB(Xm, XmStringFree, have_motif=yes, have_motif=no)],
3655    have_motif=no)
3656
3657   if test "$have_motif" = "yes"; then
3658     dnl autodetect lesstif
3659     AC_MSG_CHECKING(for Lesstif)
3660     AC_EGREP_CPP(yes,
3661 [#include <Xm/Xm.h>
3662 #ifdef LESSTIF_VERSION
3663 yes
3664 #endif
3665 ], have_lesstif=yes, have_lesstif=no)
3666   AC_MSG_RESULT($have_lesstif)
3667   fi
3668
3669 fi dnl "$with_x11" = "yes"
3670
3671 dnl Finish ensuring that we have values for the various toolkit items.
3672 dnl Not all toolkits support all widgets
3673
3674 dnl Avoid using Motif :-(
3675 case "$opsys" in
3676   *linux* | cygwin* )  lucid_prefers_motif="no"  ;;
3677   * )        lucid_prefers_motif="yes" ;;
3678 esac
3679
3680 case "$with_menubars" in "" | "yes" | "athena" )
3681   with_menubars="lucid" ;;
3682 esac
3683 case "$with_dialogs" in "" | "yes" | "lucid" )
3684   if test "$lucid_prefers_motif" = "yes"; then
3685     if   test "$have_motif"     = "yes"; then with_dialogs="motif"
3686     elif test "$have_xaw"       = "yes"; then with_dialogs="athena"
3687     else with_dialogs=no
3688     fi
3689   else
3690     if   test "$have_xaw"       = "yes"; then with_dialogs="athena"
3691     elif test "$have_motif"     = "yes"; then with_dialogs="motif"
3692     else with_dialogs=no
3693     fi
3694   fi ;;
3695 esac
3696 case "$with_scrollbars" in "" | "yes" )
3697   with_scrollbars="lucid" ;;
3698 esac
3699 case "$with_widgets" in
3700   "yes" | "lucid")
3701     if test "$lucid_prefers_motif" = "yes"; then
3702       if   test "$have_motif" = "yes"; then with_widgets="motif"
3703       elif test "$have_xaw"   = "yes"; then with_widgets="athena"
3704       else with_widgets=no
3705       fi
3706     else
3707       if   test "$have_xaw"   = "yes"; then with_widgets="athena"
3708       elif test "$have_motif" = "yes"; then with_widgets="motif"
3709       else with_widgets=no
3710       fi
3711     fi ;;
3712   "" )
3713     with_widgets=no ;;
3714 esac
3715
3716 all_widgets="$with_menubars $with_scrollbars $with_dialogs $with_toolbars $with_widgets"
3717
3718 case "$all_widgets" in
3719   *athena* )
3720     if test "$have_xaw" != "yes"; then
3721       XE_DIE("Could not find a suitable Athena library to build with.")
3722     fi
3723
3724     dnl Add the Lucid widget Athena code
3725     XE_APPEND(lwlib-Xaw.o, lwlib_objs)
3726
3727     dnl Add the Athena widget library we located earlier
3728     XE_PREPEND(-l$athena_lib, libs_x)
3729
3730     dnl Tell lwlib where to find the Athena header files.
3731     dnl Many people have tried to create a `smart' way of doing this,
3732     dnl but all have failed.  Before changing the following ugly definitions,
3733     dnl consult the veterans of many a battle.
3734     AC_DEFINE_UNQUOTED(ATHENA_Scrollbar_h_,"$athena_h_path/Scrollbar.h")
3735     AC_DEFINE_UNQUOTED(ATHENA_Dialog_h_,"$athena_h_path/Dialog.h")
3736     AC_DEFINE_UNQUOTED(ATHENA_Form_h_,"$athena_h_path/Form.h")
3737     AC_DEFINE_UNQUOTED(ATHENA_Command_h_,"$athena_h_path/Command.h")
3738     AC_DEFINE_UNQUOTED(ATHENA_Label_h_,"$athena_h_path/Label.h")
3739     AC_DEFINE_UNQUOTED(ATHENA_LabelP_h_,"$athena_h_path/LabelP.h")
3740     AC_DEFINE_UNQUOTED(ATHENA_Toggle_h_,"$athena_h_path/Toggle.h")
3741     AC_DEFINE_UNQUOTED(ATHENA_ToggleP_h_,"$athena_h_path/ToggleP.h")
3742     AC_DEFINE_UNQUOTED(ATHENA_AsciiText_h_,"$athena_h_path/AsciiText.h")
3743     AC_DEFINE_UNQUOTED(ATHENA_XawInit_h_,"$athena_h_path/XawInit.h")
3744
3745     AC_DEFINE(LWLIB_USES_ATHENA)
3746     AC_DEFINE(NEED_ATHENA)
3747     need_athena="yes"
3748
3749     if test "$athena_3d" = "yes"; then
3750       AC_DEFINE(HAVE_ATHENA_3D)
3751     fi
3752   ;;
3753 esac
3754
3755 case "$all_widgets" in *motif* )
3756   AC_DEFINE(LWLIB_USES_MOTIF)
3757   AC_DEFINE(NEED_MOTIF)
3758   XE_APPEND(lwlib-Xm.o, lwlib_objs)
3759   need_motif=yes ;;
3760 esac
3761
3762 test "$with_menubars"   = "lucid" && XE_APPEND(xlwmenu.o, lwlib_objs)
3763 test "$with_menubars"   = "motif" && XE_APPEND(xlwmenu.o, lwlib_objs)
3764 test "$with_scrollbars" = "lucid" && XE_APPEND(xlwscrollbar.o, lwlib_objs)
3765 test "$with_widgets"   != "no" && test "$with_widgets" != "msw" && \
3766         XE_APPEND(xlwtabs.o xlwgcs.o, lwlib_objs)
3767 case "$with_widgets" in athena* )
3768         XE_APPEND(xlwradio.o xlwcheckbox.o xlwgauge.o, lwlib_objs);;
3769 esac
3770 case "$all_widgets" in *lucid* )
3771   AC_DEFINE(NEED_LUCID)
3772   XE_APPEND(lwlib-Xlw.o, lwlib_objs) ;;
3773 esac
3774
3775 AC_SUBST(lwlib_objs)
3776
3777 test "$with_scrollbars" = "athena" && AC_DEFINE(LWLIB_SCROLLBARS_ATHENA)
3778 test "$with_dialogs"    = "athena" && AC_DEFINE(LWLIB_DIALOGS_ATHENA)
3779
3780 if test "$athena_3d" = "yes"; then
3781   test "$with_scrollbars" = "athena" && AC_DEFINE(LWLIB_SCROLLBARS_ATHENA3D)
3782   test "$with_dialogs"    = "athena" && AC_DEFINE(LWLIB_DIALOGS_ATHENA3D)
3783 fi
3784
3785 case "$with_widgets" in athena* ) AC_DEFINE(LWLIB_WIDGETS_ATHENA);; esac
3786 test "$with_widgets" != "no" && test "$with_widgets" != "msw" && \
3787         AC_DEFINE(LWLIB_TABS_LUCID)
3788
3789 test "$with_menubars"   != "no"    && AC_DEFINE(HAVE_MENUBARS)
3790 test "$with_scrollbars" != "no"    && AC_DEFINE(HAVE_SCROLLBARS)
3791 test "$with_dialogs"    != "no"    && AC_DEFINE(HAVE_DIALOGS)
3792 test "$with_toolbars"   != "no"    && AC_DEFINE(HAVE_TOOLBARS)
3793 test "$with_widgets"    != "no"    && AC_DEFINE(HAVE_WIDGETS)
3794
3795 test "$with_menubars"   = "lucid"  && AC_DEFINE(LWLIB_MENUBARS_LUCID)
3796 test "$with_scrollbars" = "lucid"  && AC_DEFINE(LWLIB_SCROLLBARS_LUCID)
3797
3798 test "$with_menubars"   = "motif"  && AC_DEFINE(LWLIB_MENUBARS_MOTIF)
3799 test "$with_scrollbars" = "motif"  && AC_DEFINE(LWLIB_SCROLLBARS_MOTIF)
3800 test "$with_dialogs"    = "motif"  && AC_DEFINE(LWLIB_DIALOGS_MOTIF)
3801 test "$with_widgets"    = "motif"  && AC_DEFINE(LWLIB_WIDGETS_MOTIF)
3802
3803 test "$with_menubars"   != "no"    && XE_ADD_OBJS(menubar.o)
3804 test "$with_scrollbars" != "no"    && XE_ADD_OBJS(scrollbar.o)
3805 test "$with_dialogs"    != "no"    && XE_ADD_OBJS(dialog.o)
3806 test "$with_toolbars"   != "no"    && XE_ADD_OBJS(toolbar.o)
3807
3808 if test "$with_gtk" = "yes"; then
3809   test "$with_menubars"   != "no"      && XE_ADD_OBJS(menubar-gtk.o)
3810   test "$with_scrollbars" != "no"      && XE_ADD_OBJS(scrollbar-gtk.o)
3811   test "$with_dialogs"    != "no"      && XE_ADD_OBJS(dialog-gtk.o)
3812   test "$with_toolbars"   != "no"      && XE_ADD_OBJS(toolbar-gtk.o)
3813   test "$all_widgets" != "no no no no no" && XE_ADD_OBJS(gui-gtk.o)
3814 fi
3815
3816 if test "$with_x11" = "yes"; then
3817   test "$with_menubars"   != "no"  && XE_ADD_OBJS(menubar-x.o)
3818   test "$with_scrollbars" != "no"  && XE_ADD_OBJS(scrollbar-x.o)
3819   test "$with_dialogs"    != "no"  && XE_ADD_OBJS(dialog-x.o)
3820   test "$with_toolbars"   != "no"  && XE_ADD_OBJS(toolbar-x.o)
3821   test "$all_widgets" != "no no no no no" && XE_ADD_OBJS(gui-x.o)
3822 fi
3823
3824 dnl ----------------------
3825 dnl Mule-dependent options
3826 dnl ----------------------
3827
3828 test -z "$with_mule" && with_mule=no
3829 test -z "$with_file_coding" && with_file_coding=no
3830
3831 dnl if test "$with_mule" = "yes" && test ! -d "$srcdir/lisp/mule"; then
3832 dnl     echo "Attempt to Build with Mule without Mule/Lisp"
3833 dnl     echo "Please install the XEmacs/Mule tarball or"
3834 dnl     echo "rerun configure with --with-mule=no"
3835 dnl     exit 1
3836 dnl fi
3837
3838 if test "$with_file_coding" = "yes" && test "$with_mule" = "no"; then
3839   AC_DEFINE(FILE_CODING)
3840   XE_ADD_OBJS(file-coding.o)
3841 fi
3842
3843 if test "$with_mule" = "yes" ; then
3844   AC_CHECKING(for Mule-related features)
3845   AC_DEFINE(MULE)
3846   AC_DEFINE(FILE_CODING)
3847   XE_ADD_OBJS(mule.o mule-ccl.o mule-charset.o file-coding.o)
3848
3849   dnl Use -lintl to get internationalized strerror for Mule
3850   AC_CHECK_HEADERS(libintl.h)
3851   AC_CHECK_LIB(intl, strerror)
3852
3853   AC_CHECKING(for Mule input methods)
3854   dnl Do we have the XmIm* routines?  And if so, do we want to use them?
3855   dnl XIM seems to be flaky except on Solaris...
3856   dnl test -z "$with_xim" -a "$opsys" != "sol2" && with_xim=no
3857   case "$with_xim" in "" | "yes" )
3858     AC_CHECKING(for XIM)
3859     AC_CHECK_LIB(X11, XOpenIM, with_xim=xlib, with_xim=no)
3860     dnl XIM + Lesstif is not (yet?) usable
3861     dnl Only use Motif if linking Motif anyway, or don't have xlib XIM
3862     if test "$need_motif $have_lesstif" = "yes no"; then
3863       AC_CHECK_LIB(Xm, XmImMbLookupString, with_xim=motif)
3864     elif test "$have_motif $have_lesstif $with_xim" = "yes no no"; then
3865       AC_CHECK_LIB(Xm, XmImMbLookupString, with_xim=motif)
3866     fi ;;
3867   esac
3868   if test "$with_xim" != "no"; then
3869     AC_DEFINE(HAVE_XIM)
3870     if test "$with_xim" = "xlib"; then
3871       AC_DEFINE(XIM_XLIB)
3872       XE_ADD_OBJS(input-method-xlib.o)
3873     fi
3874     if test "$with_xim" = "motif"; then
3875       AC_DEFINE(XIM_MOTIF)
3876       need_motif=yes
3877       XE_ADD_OBJS(input-method-motif.o)
3878     fi
3879     if test "$with_xim" = "motif"; then
3880       with_xfs=no
3881     fi
3882   fi
3883
3884   dnl "with_xfs" = "yes"
3885   if test "$with_xfs" = "yes" ; then
3886     AC_CHECKING(for XFontSet)
3887     AC_CHECK_LIB(X11, XmbDrawString, [:], with_xfs=no)
3888     if test "$with_xfs" = "yes" && test "$with_menubars" = "lucid"; then
3889       AC_DEFINE(USE_XFONTSET)
3890       if test "$with_xim" = "no" ; then
3891         XE_ADD_OBJS(input-method-xlib.o)
3892       fi
3893     fi
3894   fi dnl with_xfs
3895
3896   dnl Autodetect WNN
3897   test "$with_wnn6" = "yes" && with_wnn=yes # wnn6 implies wnn support
3898   test -z "$with_wnn" && { AC_CHECK_HEADER(wnn/jllib.h, ,with_wnn=no) }
3899   dnl gcc 2.97 fixincludes breaks inclusion of wnn/commonhd.h
3900   test -z "$with_wnn" && { AC_CHECK_HEADER(wnn/commonhd.h, ,with_wnn=no) }
3901   dnl Detour to find crypt
3902   if test "$with_wnn" != "no"; then
3903     AC_CHECK_FUNCS(crypt)
3904     test "$ac_cv_func_crypt" != "yes" && { AC_CHECK_LIB(crypt, crypt) }
3905   fi
3906   dnl Back to our regularly scheduled wnn hunting
3907   if test -z "$with_wnn" -o "$with_wnn" = "yes"; then
3908     AC_CHECK_LIB(wnn,jl_dic_list_e,libwnn=wnn,
3909       AC_CHECK_LIB(wnn4,jl_dic_list_e,libwnn=wnn4,
3910         AC_CHECK_LIB(wnn6,jl_dic_list_e,libwnn=wnn6,
3911           AC_CHECK_LIB(wnn6_fromsrc,dic_list_e,libwnn=wnn6_fromsrc,with_wnn=no))))
3912   fi
3913   test -z "$with_wnn" && with_wnn=yes
3914   if test "$with_wnn" = "yes"; then
3915     AC_DEFINE(HAVE_WNN)
3916     XE_PREPEND(-l$libwnn, libs_x)
3917     XE_ADD_OBJS(mule-wnnfns.o)
3918     if test "$with_wnn6" != "no"; then
3919       AC_CHECK_LIB($libwnn, jl_fi_dic_list, with_wnn6=yes)
3920       test "$with_wnn6" = "yes" && AC_DEFINE(WNN6)
3921     fi
3922   fi
3923
3924   dnl Autodetect canna
3925   canna_includes_found=no
3926   if test "$with_canna" != "no"; then
3927     AC_CHECK_HEADER(canna/jrkanji.h,canna_includes_found=yes)
3928   fi
3929   if test "$canna_includes_found" = "no" -a "$with_canna" != "no" -a \
3930       -d "/usr/local/canna/include"; then
3931     save_c_switch_site="$c_switch_site"
3932     c_switch_site="$c_switch_site -I/usr/local/canna/include"
3933     AC_CHECK_HEADER(canna/jrkanji.h,canna_includes_found=yes)
3934     if test "$canna_includes_found" != "yes"; then
3935       c_switch_site="$save_c_switch_site"
3936       with_canna="no"
3937     fi
3938   fi
3939
3940   test -z "$with_canna" && { AC_CHECK_HEADER(canna/RK.h,         , with_canna=no) }
3941   test -z "$with_canna" && { AC_CHECK_LIB(RKC, RkBgnBun,       [:],with_canna=no) }
3942   test -z "$with_canna" && { AC_CHECK_LIB(canna,jrKanjiControl,[:],with_canna=no) }
3943   test -z "$with_canna" && with_canna=yes
3944   if test "$with_canna" = "yes"; then
3945     AC_DEFINE(HAVE_CANNA)
3946     XE_PREPEND(-lcanna -lRKC, libs_x)
3947     XE_ADD_OBJS(mule-canna.o)
3948   fi
3949
3950 else dnl "$with_mule" = "no"
3951   for feature in xim canna wnn; do
3952     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
3953       AC_MSG_WARN("--with-${feature} ignored:  Not valid without Mule support")
3954     fi
3955     eval "with_${feature}=no"
3956   done
3957 fi dnl with_mule
3958
3959
3960 dnl At this point, we know whether we need the motif lib or not.
3961 if test "$need_motif" = "yes" ; then
3962   XE_PREPEND(-lXm, libs_x)
3963   dnl AIX needs the following library for use with Motif
3964   AC_CHECK_LIB(i18n, layout_object_getvalue, [XE_PREPEND(-li18n, libs_x)])
3965   XE_COMPUTE_RUNPATH()
3966 fi
3967
3968 dnl ----------------------------------------------------------------
3969 dnl Check for POSIX functions.
3970 dnl ----------------------------------------------------------------
3971
3972 AC_CHECK_FUNCS(cbrt closedir dup2 eaccess fmod fpathconf frexp ftime getaddrinfo gethostname getnameinfo getpagesize gettimeofday getcwd getwd logb lrand48 matherr mkdir mktime perror poll random rename res_init rint rmdir select setitimer setpgid setlocale setsid sigblock sighold sigprocmask snprintf stpcpy strerror tzset ulimit usleep waitpid vsnprintf fsync ftruncate umask)
3973
3974 dnl getaddrinfo() is borked under hpux11
3975 if test "$ac_cv_func_getaddrinfo" != "no" ; then
3976   case "$opsys" in
3977     hpux11* )
3978       AC_MSG_WARN([Use of getaddrinfo is disabled for HP-UX 11.XX.])
3979       ac_cv_func_getaddrinfo=no
3980       ;;
3981   esac
3982 fi
3983
3984 dnl ----------------------------------------------------------------
3985 dnl Check for PTY support functions.
3986 dnl ----------------------------------------------------------------
3987
3988 dnl There is no "standard" pty allocation method.  Every system is different.
3989 dnl  getpt()  is the preferred pty allocation method on glibc systems.
3990 dnl _getpty() is the preferred pty allocation method on SGI systems.
3991 dnl grantpt(), unlockpt(), ptsname() are defined by Unix98.
3992 AC_CHECK_FUNCS(getpt _getpty grantpt unlockpt ptsname killpg tcgetpgrp)
3993
3994 dnl openpty() is the preferred pty allocation method on BSD and Tru64 systems.
3995 dnl openpty() might be declared in:
3996 dnl - pty.h (Tru64 or Linux)
3997 dnl - libutil.h (FreeBSD)
3998 dnl - util.h (NetBSD)
3999 AC_CHECK_FUNC(openpty, have_openpty=yes, [
4000   AC_CHECK_LIB(util, openpty, have_openpty=yes need_libutil=yes)])
4001 if test "$have_openpty" = "yes"; then
4002   AC_DEFINE(HAVE_OPENPTY)
4003   AC_CHECK_HEADERS(pty.h libutil.h util.h, break)
4004   test "$need_libutil" = "yes" && XE_APPEND(-lutil, libs_system)
4005 fi
4006
4007 dnl Check for STREAM support functions.
4008 dnl Confusingly, "str" means both "string" and "SysV Streams".
4009 AC_CHECK_HEADERS(stropts.h)
4010 if test "$ac_cv_header_stropts_h" = "yes"; then
4011   AC_CHECK_FUNCS(isastream)
4012   AC_CHECK_HEADERS(strtio.h) dnl TIOCSIGNAL
4013 fi
4014
4015 dnl Use our own realpath always.
4016 XE_ADD_OBJS(realpath.o)
4017
4018 dnl Check whether the system provides getloadavg().
4019 AC_CHECK_FUNCS(getloadavg)
4020
4021 if test "$ac_cv_func_getloadavg" = "yes"; then
4022   dnl Solaris 8 declares getloadavg() in <sys/loadavg.h>.
4023   dnl glibc 2.2 declares getloadavg() in <stdlib.h>...
4024   dnl   ...if we #define _GNU_SOURCE, which we do.
4025   AC_CHECK_HEADERS(sys/loadavg.h)
4026 else
4027   dnl We define our own getloadavg() using lower level functions.
4028   XE_ADD_OBJS(getloadavg.o)
4029
4030   dnl Used by getloadavg() - does not require root priveleges
4031   AC_CHECK_LIB(kstat, kstat_open)
4032   AC_CHECK_HEADERS(kstat.h)
4033
4034   dnl Another way to get the load average
4035   AC_CHECK_LIB(kvm, kvm_read)
4036 fi
4037
4038 dnl If netdb.h does not declare h_errno, we must declare it by hand.
4039 AC_MSG_CHECKING(whether netdb declares h_errno)
4040 AC_TRY_LINK([#include <netdb.h>],
4041   [return h_errno;],
4042   [AC_MSG_RESULT(yes)
4043    AC_DEFINE(HAVE_H_ERRNO)],
4044   [AC_MSG_RESULT(no)])
4045
4046 AC_MSG_CHECKING(for sigsetjmp)
4047 AC_TRY_COMPILE([#include <setjmp.h>],
4048         [sigjmp_buf bar; sigsetjmp (bar, 0);],
4049   [AC_MSG_RESULT(yes)
4050    AC_DEFINE(HAVE_SIGSETJMP)],
4051   [AC_MSG_RESULT(no)])
4052
4053 AC_MSG_CHECKING(whether localtime caches TZ)
4054 AC_CACHE_VAL(emacs_cv_localtime_cache,
4055 [if test "$ac_cv_func_tzset" = "yes"; then
4056 AC_TRY_RUN([#include <time.h>
4057 #if STDC_HEADERS
4058 # include <stdlib.h>
4059 #endif
4060 extern char **environ;
4061 unset_TZ ()
4062 {
4063   char **from, **to;
4064   for (to = from = environ; (*to = *from); from++)
4065     if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
4066       to++;
4067 }
4068 char TZ_GMT0[] = "TZ=GMT0";
4069 char TZ_PST8[] = "TZ=PST8";
4070 main()
4071 {
4072   time_t now = time ((time_t *) 0);
4073   int hour_GMT0, hour_unset;
4074   if (putenv (TZ_GMT0) != 0)
4075     exit (1);
4076   hour_GMT0 = localtime (&now)->tm_hour;
4077   unset_TZ ();
4078   hour_unset = localtime (&now)->tm_hour;
4079   if (putenv (TZ_PST8) != 0)
4080     exit (1);
4081   if (localtime (&now)->tm_hour == hour_GMT0)
4082     exit (1);
4083   unset_TZ ();
4084   if (localtime (&now)->tm_hour != hour_unset)
4085     exit (1);
4086   exit (0);
4087 }], emacs_cv_localtime_cache=no, emacs_cv_localtime_cache=yes,
4088 [# If we have tzset, assume the worst when cross-compiling.
4089 emacs_cv_localtime_cache=yes])
4090 else
4091         # If we lack tzset, report that localtime does not cache TZ,
4092         # since we can't invalidate the cache if we don't have tzset.
4093         emacs_cv_localtime_cache=no
4094 fi],[:])dnl
4095 AC_MSG_RESULT($emacs_cv_localtime_cache)
4096 if test $emacs_cv_localtime_cache = yes; then
4097   AC_DEFINE(LOCALTIME_CACHE)
4098 fi
4099
4100 if test "$HAVE_TIMEVAL" = "yes"; then
4101 AC_MSG_CHECKING(whether gettimeofday accepts one or two arguments)
4102 AC_TRY_LINK([
4103 #ifdef TIME_WITH_SYS_TIME
4104 #include <sys/time.h>
4105 #include <time.h>
4106 #else
4107 #ifdef HAVE_SYS_TIME_H
4108 #include <sys/time.h>
4109 #else
4110 #include <time.h>
4111 #endif
4112 #endif
4113   ],
4114   [
4115   struct timeval time;
4116   gettimeofday (&time, 0);
4117 ],
4118   [AC_MSG_RESULT(two)],
4119   [AC_MSG_RESULT(one)
4120    AC_DEFINE(GETTIMEOFDAY_ONE_ARGUMENT)])
4121 fi
4122
4123
4124 AC_C_INLINE
4125 test "$ac_cv_c_inline" != "no" -a "$GCC" = "yes" && XE_ADD_OBJS(inline.o)
4126
4127 dnl HP-UX has a working alloca in libPW.
4128 dnl case "${GCC}${opsys}" in hpux* )
4129 dnl  AC_CHECK_FUNC(alloca, [:], [AC_CHECK_LIB(PW, alloca)])
4130 dnl esac
4131
4132 dnl AC_FUNC_ALLOCA doesn't know about DEC C's #pragma intrinsic(alloca)
4133 if test "$__DECC" != "yes"; then
4134   AC_FUNC_ALLOCA
4135   test -n "$ALLOCA" && XE_ADD_OBJS($ALLOCA)
4136 fi
4137
4138 dnl Check whether vfork exists and works correctly. (This does more
4139 dnl than just check for its existence.) If so, it defines HAVE_VFORK_H.
4140 dnl If not, it defines vfork to be fork.
4141 AC_FUNC_VFORK
4142
4143 dnl Check whether strcoll exists and works correctly. (This does more
4144 dnl than just check for its existence.) If so, it defines HAVE_STRCOLL.
4145 AC_FUNC_STRCOLL
4146
4147 dnl If `getpgrp' takes no argument (the POSIX.1 version), define
4148 dnl `GETPGRP_VOID'.  Otherwise, it is the BSD version, which takes a
4149 dnl process ID as an argument.
4150 AC_CHECK_FUNCS(getpgrp)
4151 AC_FUNC_GETPGRP
4152
4153 dnl We used to call AC_FUNC_MMAP here
4154 dnl Instead we now use following, suggested by Neal Becker
4155 AC_MSG_CHECKING(for working mmap)
4156 case "$opsys" in ultrix* ) have_mmap=no ;; *)
4157 AC_TRY_RUN([#include <stdio.h>
4158 #include <unistd.h>
4159 #include <fcntl.h>
4160 #include <sys/mman.h>
4161
4162 #ifndef MAP_VARIABLE
4163 #define MAP_VARIABLE 0
4164 #endif
4165
4166 #ifndef MAP_FAILED
4167 #define MAP_FAILED -1
4168 #endif
4169
4170 int main (int argc, char *argv[])
4171 {
4172   int fd = -1;
4173   caddr_t p;
4174 #ifndef MAP_ANONYMOUS
4175   fd = open ("/dev/zero", O_RDWR);
4176   if (fd < 0)
4177     return 1;
4178 #define MAP_ANONYMOUS 0
4179 #endif
4180   if (mmap(0, 1024, PROT_READ | PROT_WRITE,
4181            MAP_PRIVATE | MAP_VARIABLE | MAP_ANONYMOUS,
4182            fd, 0) != (void *) MAP_FAILED)
4183     return 0;
4184   perror ("conftest: mmap failed");
4185   return 1;
4186 }], have_mmap=yes, have_mmap=no) ;;
4187 esac
4188 AC_MSG_RESULT($have_mmap)
4189 test "$have_mmap" = "yes" && AC_DEFINE(HAVE_MMAP)
4190
4191 dnl By default we switch off rel-alloc on cygwin as it generally causes us grief
4192 case "$opsys" in cygwin*) 
4193         test "$rel_alloc" = "default" && rel_alloc=no ;;
4194 esac
4195 dnl rel_alloc requires either GNU malloc or system malloc with mmap
4196 dnl We only turn rel_alloc on by default if mmap is available.
4197 test "$GNU_MALLOC" != "yes" -a "$have_mmap" != "yes" && rel_alloc=no
4198 if test "$rel_alloc $have_mmap" = "default yes"; then
4199   if test "$doug_lea_malloc" = "yes"; then
4200     dnl Check if malloc() calls mmap(), making rel_alloc pointless.
4201     AC_MSG_CHECKING(for M_MMAP_THRESHOLD)
4202     AC_TRY_COMPILE([#include <malloc.h>],[
4203 #ifndef M_MMAP_THRESHOLD
4204 #error No M_MMAP_THRESHOLD :-(
4205 !@+$%^&*_)(_ - unlikely to compile...
4206 #endif
4207 ], [rel_alloc=no; AC_MSG_RESULT(yes);], [rel_alloc=yes; AC_MSG_RESULT(no);])
4208   else
4209     rel_alloc=yes
4210   fi
4211 fi
4212 test "$rel_alloc" = "yes" && AC_DEFINE(REL_ALLOC)
4213
4214 dnl Check for terminal I/O variants
4215 dnl TERMIOS systems may have termio.h, but not vice-versa, I think.
4216 AC_CHECK_HEADER(termios.h,
4217   AC_DEFINE(HAVE_TERMIOS)
4218   AC_DEFINE(SIGNALS_VIA_CHARACTERS)
4219   AC_DEFINE(NO_TERMIO),
4220   [AC_CHECK_HEADER(termio.h, [AC_DEFINE(HAVE_TERMIO)])])
4221
4222
4223 dnl Check for Internet sockets.
4224 AC_CHECK_FUNC(socket,
4225  [AC_CHECK_HEADER(netinet/in.h,
4226    [AC_CHECK_HEADER(arpa/inet.h, [
4227   AC_DEFINE(HAVE_SOCKETS)
4228       AC_MSG_CHECKING("for sun_len member in struct sockaddr_un")
4229       AC_TRY_LINK([
4230 #include <sys/types.h>
4231 #include <sys/socket.h>
4232 #include <sys/un.h>
4233       ],
4234       [static struct sockaddr_un x; x.sun_len = 1;],
4235       [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOCKADDR_SUN_LEN)],
4236       [AC_MSG_RESULT(no)])
4237       AC_MSG_CHECKING("for ip_mreq struct in netinet/in.h")
4238       AC_TRY_LINK([
4239 #include <sys/types.h>
4240 #include <netinet/in.h>
4241       ],
4242       [static struct ip_mreq x;],
4243       [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MULTICAST)],
4244       [AC_MSG_RESULT(no)])])])])
4245
4246 dnl Check for SYS V IPC. (Inferior to sockets.)
4247 AC_CHECK_FUNC(msgget,
4248   [AC_CHECK_HEADER(sys/ipc.h,
4249     [AC_CHECK_HEADER(sys/msg.h,
4250       [AC_DEFINE(HAVE_SYSVIPC)])])])
4251
4252 dnl Check for directory variants
4253 AC_CHECK_HEADER(dirent.h, [AC_DEFINE(SYSV_SYSTEM_DIR)],
4254   [AC_CHECK_HEADER(sys/dir.h, , [AC_DEFINE(NONSYSTEM_DIR_LIBRARY)])])
4255
4256 dnl Check for nlist.h
4257 AC_CHECK_HEADER(nlist.h, AC_DEFINE(NLIST_STRUCT), )
4258
4259 dnl Check for sound of various sorts.
4260
4261 dnl Autodetect native sound
4262 AC_CHECKING("for sound support")
4263 test -z "$with_native_sound" -a -n "$native_sound_lib" && with_native_sound=yes
4264
4265 if test "$with_native_sound" != "no"; then
4266   dnl Maybe sound is already on include path...
4267   if test -n "$native_sound_lib"; then
4268     AC_CHECK_HEADER(multimedia/audio_device.h,
4269       [sound_found=yes sound_cflags=""
4270       XE_ADD_OBJS(sunplay.o)])
4271   fi
4272
4273   dnl Autodetect Sun native sound from SUNWaudmo package
4274   if test -z "$sound_found" -a -d "/usr/demo/SOUND"; then
4275     if test -d "/usr/demo/SOUND/include/multimedia"; then
4276       sun_sound_cflags="-I/usr/demo/SOUND/include"
4277     elif test -d "/usr/demo/SOUND/multimedia"; then
4278       sun_sound_cflags="-I/usr/demo/SOUND"
4279     fi
4280
4281     if test -n "$native_sound_lib"; then
4282       sun_sound_lib="$native_sound_lib"
4283     elif test -r "/usr/demo/SOUND/lib/libaudio.a"; then
4284       sun_sound_lib="/usr/demo/SOUND/lib/libaudio.a"
4285     elif test -r "/usr/demo/SOUND/libaudio.a"; then
4286       sun_sound_lib="/usr/demo/SOUND/libaudio.a"
4287     fi
4288
4289     if test -n "$sun_sound_cflags" -a -n "$sun_sound_lib"; then
4290       native_sound_lib="$sun_sound_lib"
4291       sound_cflags="$sun_sound_cflags"
4292       sound_found=yes
4293       XE_ADD_OBJS(sunplay.o)
4294     fi
4295   fi
4296
4297   dnl Check for SGI and HP native sound libs
4298   if test -z "$sound_found"; then
4299     case "$canonical" in
4300     *-sgi-* )
4301       if test -z "$native_sound_lib"; then
4302         AC_CHECK_LIB(audio, ALopenport, native_sound_lib="-laudio")
4303       fi
4304       if test -n "$native_sound_lib"; then
4305         sound_found=yes sound_cflags=""
4306         XE_ADD_OBJS(sgiplay.o)
4307       fi ;;
4308     hppa*-hp-hpux* )
4309       if test -z "$native_sound_lib"; then
4310         AC_CHECK_LIB(Alib, AOpenAudio, native_sound_lib="-lAlib")
4311       fi
4312       if test -n "$native_sound_lib"; then
4313         sound_found=yes
4314         XE_ADD_OBJS(hpplay.o)
4315         if test "$GCC" = "yes" # Kludge city
4316           then sound_cflags="-Dconst= -Dvolatile= -I/usr/audio/examples"
4317           else sound_cflags="+e -I/usr/audio/examples"
4318         fi
4319       fi ;;
4320     esac
4321   fi
4322
4323   dnl Win32 Native uses native sound
4324   if test -z "$sound_found"; then
4325     if test "$with_msw" = "yes"; then
4326     sound_found=yes
4327     native_sound_lib=
4328     fi
4329   fi
4330
4331   dnl Check for Linux/BSD native sound
4332   if test -z "$sound_found"; then
4333     for dir in "machine" "sys" "linux"; do
4334       AC_CHECK_HEADER(${dir}/soundcard.h,
4335         sound_found=yes
4336        need_miscplay=yes
4337         XE_ADD_OBJS(linuxplay.o)
4338         [AC_DEFINE_UNQUOTED(SOUNDCARD_H_FILE, "${dir}/soundcard.h")]
4339         break)
4340     done
4341   fi
4342
4343   test "$sound_found" = "yes" && with_native_sound=yes
4344 fi
4345
4346 if test "$with_native_sound" = "yes"; then
4347   AC_DEFINE(HAVE_NATIVE_SOUND)
4348   test -n "$native_sound_lib" && XE_PREPEND($native_sound_lib, LIBS)
4349 fi
4350
4351 dnl NAS Sound support
4352 if test "$with_nas_sound" != "no"; then
4353   AC_CHECK_HEADER(audio/audiolib.h, [
4354     AC_CHECK_LIB(audio, AuOpenServer, have_nas_sound=yes)])
4355   if test "$have_nas_sound" = "yes"; then
4356     with_nas_sound=yes
4357     AC_DEFINE(HAVE_NAS_SOUND)
4358     XE_ADD_OBJS(nas.o)
4359     XE_PREPEND(-laudio, libs_x)
4360     dnl If the nas library does not contain the error jump point,
4361     dnl then we force safer behavior.
4362     AC_EGREP_HEADER(AuXtErrorJump,audio/Xtutil.h,,[old_nas=yes; AC_DEFINE(NAS_NO_ERROR_JUMP)])
4363   else
4364     test "$with_nas_sound" = "yes" && \
4365       XE_DIE("Required NAS sound support cannot be provided.")
4366     with_nas_sound=no
4367   fi
4368 fi
4369
4370 dnl ESD Sound support
4371 if test "$with_esd_sound" != "no"; then
4372   AC_CHECK_PROG(have_esd_config, esd-config, yes, no)
4373   if test "$have_esd_config" = "yes"; then
4374     save_c_switch_site="$c_switch_site" save_LIBS="$LIBS"
4375     XE_APPEND(`esd-config --cflags`, c_switch_site)
4376     XE_PREPEND(`esd-config --libs`, LIBS)
4377     AC_CHECK_FUNC(esd_play_stream,
4378       have_esd_sound=yes,
4379       c_switch_site="$save_c_switch_site" LIBS="$save_LIBS")
4380   fi
4381
4382   if test "$have_esd_sound" = "yes"; then
4383     with_esd_sound=yes
4384     need_miscplay=yes
4385     XE_ADD_OBJS(esd.o)
4386     AC_DEFINE(HAVE_ESD_SOUND)
4387   else
4388     test "$with_esd_sound" = "yes" && \
4389       XE_DIE("Required ESD sound support cannot be provided.")
4390     with_esd_sound=no
4391   fi
4392 fi
4393
4394 test "$need_miscplay" = "yes" && XE_ADD_OBJS(miscplay.o)
4395
4396 dnl ---------------------
4397 dnl TTY-dependent options
4398 dnl ---------------------
4399
4400 test -z "$with_tty" && with_tty=yes
4401
4402 if test "$with_tty" = "yes"  ; then
4403   AC_CHECKING(for TTY-related features)
4404   AC_DEFINE(HAVE_TTY)
4405   XE_ADD_OBJS(console-tty.o device-tty.o event-tty.o frame-tty.o objects-tty.o redisplay-tty.o cm.o)
4406
4407   dnl Autodetect ncurses.
4408   if test -z "$with_ncurses"; then
4409     AC_CHECK_LIB(ncurses, tgetent, with_ncurses=yes, with_ncurses=no)
4410   fi
4411   if test "$with_ncurses" = "yes"; then
4412     AC_DEFINE(HAVE_NCURSES)
4413     AC_CHECK_HEADER(ncurses/curses.h, curses_h_file=ncurses/curses.h)
4414     AC_CHECK_HEADER(ncurses/term.h, term_h_file=ncurses/term.h)
4415     XE_ADD_OBJS(terminfo.o)
4416     XE_PREPEND(-lncurses, LIBS)
4417
4418     if test "$ac_cv_header_ncurses_curses_h" != "yes" ; then
4419       dnl Try again, and check for the bogus ncurses/ include bug.
4420       dnl (i.e. ncurses/curses.h bogusly includes <unctrl.h> instead of
4421       dnl <ncurses/unctrl.h>)
4422       save_c_switch_site="$c_switch_site"
4423       c_switch_site="$c_switch_site -I/usr/include/ncurses"
4424       AC_CHECK_HEADER(ncurses/curses.h, curses_h_file=ncurses/curses.h)
4425       if test "$ac_cv_header_ncurses_curses_h" = "yes"
4426         then AC_MSG_WARN("Your system has the bogus ncurses include bug.")
4427         else c_switch_site="$save_c_switch_site"
4428       fi
4429     fi
4430   else dnl "$with_ncurses" = "no"
4431     dnl Autodetect terminfo/-lcurses/-ltermlib/-ltermcap
4432     if test "$have_terminfo" = "yes"; then
4433       XE_ADD_OBJS(terminfo.o)
4434       if test -n "$libs_termcap"; then
4435         XE_PREPEND($libs_termcap, LIBS)
4436       else
4437         for lib in curses termlib termcap; do
4438           AC_CHECK_LIB($lib, tgetent, XE_PREPEND(-l${lib}, LIBS); break)
4439         done
4440       fi
4441     else dnl "$have_terminfo" = "no" && "with_ncurses" = "no"
4442       if test -n "$libs_termcap" -a "$opsys" = "openbsd"; then
4443         dnl We need to check if tgoto does not exist in termcap yet
4444         dnl because on OpenBSD libtermcap is another name for libcurses
4445         dnl which provides the same tgoto as ncurses
4446         AC_CHECK_LIB(termcap, tgoto, , XE_ADD_OBJS(tparam.o))
4447       else
4448         XE_ADD_OBJS(tparam.o)
4449       fi
4450       dnl The HP-UX curses library seems to have a badly broken version of select(2)
4451       dnl that makes "poll: interrupted system call" messages to appear and
4452       dnl Emacs subprocesses to hang (e.g. TeX compilation w/ AUCTeX) */
4453       case "$opsys" in *-hp-hpux* ) libs_termcap="-ltermcap" ;; esac
4454       if test -n "$libs_termcap"; then
4455         XE_PREPEND($libs_termcap, LIBS)
4456       else
4457         AC_CHECK_LIB(curses, tgetent, XE_PREPEND(-lcurses, LIBS),
4458           AC_CHECK_LIB(termcap, tgetent, XE_PREPEND(-ltermcap, LIBS),
4459             XE_ADD_OBJS(termcap.o)))
4460       fi
4461     fi
4462   fi
4463   AC_DEFINE_UNQUOTED(CURSES_H_FILE, "${curses_h_file-curses.h}")
4464   AC_DEFINE_UNQUOTED(TERM_H_FILE, "${term_h_file-term.h}")
4465
4466   dnl General Purpose Mouse (libgpm) support
4467   if test "$with_gpm" != "no"; then
4468     AC_CHECK_HEADER(gpm.h, [
4469       AC_CHECK_LIB(gpm, Gpm_Open, have_gpm=yes)])
4470     if test "$have_gpm" = "yes"; then
4471       with_gpm=yes
4472       AC_DEFINE(HAVE_GPM)
4473       XE_ADD_OBJS(gpmevent.o)
4474       XE_PREPEND(-lgpm, LIBS)
4475     elif test "$with_gpm" = "yes"; then
4476       XE_DIE(["GPM requested, but gpm.h or libgpm seems to be missing."])
4477     else
4478       with_gpm=no
4479     fi
4480   fi
4481
4482 else dnl "$with_tty" = "no"
4483   for feature in ncurses gpm; do
4484     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
4485       AC_MSG_WARN("--with-${feature} ignored:  Not valid without TTY support")
4486     fi
4487     eval "with_${feature}=no"
4488   done
4489 fi dnl with_tty
4490
4491 dnl Do we need event-unixoid.o ?
4492 dnl This is needed for X, or for TTY, or for MSWIN w/Cygwin select()
4493 dnl [but not Mingw MSWIN]
4494 test "$with_x11" = "yes" -o "$with_tty" = "yes" -o "$need_event_unixoid" = "yes" && XE_ADD_OBJS(event-unixoid.o)
4495
4496 dnl Database support
4497 dnl We do not necessarily have to have libdb/lib(g)dbm for DB/(G)DBM support.
4498 dnl On FreeBSD, both DB and DBM are part of libc.
4499 dnl By default, we check for DBM support in libgdbm, then libc, then libdbm.
4500
4501 test "$with_database_gdbm $with_database_dbm $with_database_berkdb" \
4502   != "no no no" && AC_CHECKING(for database support)
4503
4504 dnl Check for ndbm.h, required for either kind of DBM support.
4505 if test "$with_database_gdbm $with_database_dbm" != "no no"; then
4506   AC_CHECK_HEADER(ndbm.h, [:], [
4507     test "$with_database_gdbm" = "yes" -o \
4508          "$with_database_dbm"  = "yes" && \
4509       XE_DIE("Required DBM support cannot be provided.")
4510     with_database_gdbm=no with_database_dbm=no])
4511 fi
4512
4513 dnl Check for DBM support in libgdbm.
4514 if test "$with_database_gdbm" != "no"; then
4515   AC_CHECK_LIB(gdbm, dbm_open, [
4516    with_database_gdbm=yes with_database_dbm=no libdbm=-lgdbm], [
4517    if test "$with_database_gdbm" = "yes"; then
4518      XE_DIE("Required GNU DBM support cannot be provided.")
4519    fi
4520    with_database_gdbm=no])
4521 fi
4522
4523 dnl Check for DBM support in libc and libdbm.
4524 if test "$with_database_dbm" != "no"; then
4525   AC_CHECK_FUNC(dbm_open, [with_database_dbm=yes libdbm=], [
4526     AC_CHECK_LIB(dbm, dbm_open, [with_database_dbm=yes libdbm=-ldbm], [
4527       test "$with_database_dbm" = "yes" && \
4528         XE_DIE("Required DBM support cannot be provided.")
4529       with_database_dbm=no])])
4530 fi
4531
4532 dnl Tell make about the DBM support we detected.
4533 test -n "$libdbm" && XE_PREPEND("$libdbm", LIBS)
4534 test "$with_database_gdbm" = "yes" -o \
4535      "$with_database_dbm"  = "yes" && \
4536   AC_DEFINE(HAVE_DBM)
4537
4538 dnl Check for u_int*_t typedefs.
4539 AC_CHECK_TYPE(u_int8_t, uint8_t)
4540 if test $ac_cv_type_u_int8_t = yes; then
4541 AC_DEFINE(HAVE_U_INT8_T,1)
4542 fi
4543 AC_CHECK_TYPE(u_int16_t, uint16_t)
4544 if test $ac_cv_type_u_int16_t = yes; then
4545 AC_DEFINE(HAVE_U_INT16_T,1)
4546 fi
4547 AC_CHECK_TYPE(u_int32_t, uint32_t)
4548 if test $ac_cv_type_u_int32_t = yes; then
4549 AC_DEFINE(HAVE_U_INT32_T,1)
4550 fi
4551 AC_CHECK_TYPE(u_int64_t, uint64_t)
4552 if test $ac_cv_type_u_int64_t = yes; then
4553 AC_DEFINE(HAVE_U_INT64_T,1)
4554 fi
4555
4556 dnl Check for Berkeley DB.
4557 if test "$with_database_berkdb" != "no"; then
4558   AC_MSG_CHECKING(for Berkeley db.h)
4559   for header in "db/db.h" "db.h"; do
4560     case "$opsys" in
4561         *freebsd*)
4562     AC_TRY_COMPILE([
4563 #include <stdlib.h>
4564 #if !(defined __GLIBC__ && __GLIBC_MINOR__ >= 1)
4565 #ifdef HAVE_INTTYPES_H
4566 #define __BIT_TYPES_DEFINED__
4567 #include <inttypes.h>
4568 #endif
4569 #endif
4570 #include <$header>
4571 ],[], db_h_file="$header"; break)
4572         ;;
4573         *)
4574     AC_TRY_COMPILE([
4575 #include <stdlib.h>
4576 #if !(defined __GLIBC__ && __GLIBC_MINOR__ >= 1)
4577 #ifdef HAVE_INTTYPES_H
4578 #define __BIT_TYPES_DEFINED__
4579 #include <inttypes.h>
4580 #if !HAVE_U_INT8_T
4581 typedef uint8_t  u_int8_t;
4582 #endif
4583 #if !HAVE_U_INT16_T
4584 typedef uint16_t u_int16_t;
4585 #endif
4586 #if !HAVE_U_INT32_T
4587 typedef uint32_t u_int32_t;
4588 #endif
4589 #ifdef WE_DONT_NEED_QUADS
4590 #if !HAVE_U_INT64_T
4591 typedef uint64_t u_int64_t;
4592 #endif
4593 #endif
4594 #endif
4595 #endif
4596 #include <$header>
4597 ],[], db_h_file="$header"; break)
4598         ;;
4599         esac
4600   done
4601   if test -z "$db_h_file"
4602   then AC_MSG_RESULT(no); with_database_berkdb=no
4603   else AC_MSG_RESULT($db_h_file)
4604   fi
4605
4606   if test "$with_database_berkdb" != "no"; then
4607     AC_MSG_CHECKING(for Berkeley DB version)
4608     AC_EGREP_CPP(yes,
4609 [#include <$db_h_file>
4610 #if DB_VERSION_MAJOR > 1
4611 yes
4612 #endif
4613 ], [AC_EGREP_CPP(yes,
4614 [#include <$db_h_file>
4615 #if DB_VERSION_MAJOR > 2
4616 yes
4617 #endif
4618 ], [AC_MSG_RESULT(3); dbfunc=db_create],[
4619     AC_MSG_RESULT(2); dbfunc=db_open])],[
4620     AC_MSG_RESULT(1); dbfunc=dbopen])
4621     AC_CHECK_FUNC($dbfunc,     with_database_berkdb=yes need_libdb=no, [
4622     AC_CHECK_LIB(db, $dbfunc,  with_database_berkdb=yes need_libdb=yes)])
4623   fi
4624
4625   if test "$with_database_berkdb" = "yes"; then
4626     AC_DEFINE_UNQUOTED(DB_H_FILE, "$db_h_file")
4627     AC_DEFINE(HAVE_BERKELEY_DB)
4628     test "$need_libdb" = "yes" && XE_PREPEND(-ldb, LIBS)
4629   else with_database_berkdb=no
4630   fi
4631 fi
4632
4633 if test "$with_database_gdbm $with_database_dbm $with_database_berkdb" \
4634      != "no no no"; then
4635   AC_DEFINE(HAVE_DATABASE)
4636   XE_ADD_OBJS(database.o)
4637 fi
4638
4639 dnl Socks support
4640 if test "$with_socks" = "yes"; then
4641   AC_CHECK_LIB(socks, SOCKSinit)
4642   test -n "$ac_cv_lib_socks_SOCKSinit" && AC_DEFINE(HAVE_SOCKS)
4643 fi
4644
4645 dnl Usage tracking (undocumented and likely unused option)
4646 if test "$usage_tracking" = "yes"; then
4647   AC_DEFINE(USAGE_TRACKING)
4648   XE_PREPEND(-Bstatic -lut -Bdynamic, LIBS)
4649 fi
4650
4651 dnl autodetect dll support
4652 if test "$with_modules" != "no"; then
4653   AC_CHECKING(for module support)
4654
4655   dnl Check for MS-Windows
4656   if test "$with_msw" = "yes"; then
4657     have_dl=yes;
4658   else
4659     dnl Check for Darwin
4660     case "$opsys" in
4661       darwin) have_dl=yes; AC_DEFINE(HAVE_DYLD) ;;
4662       *) dnl Find headers and libraries
4663          AC_CHECK_HEADER(dlfcn.h, [
4664            AC_MSG_CHECKING([for dlopen in -lc])
4665            AC_TRY_LINK([#include <dlfcn.h>],dnl
4666               [dlopen ("", 0);], [ have_dl=yes ], [
4667                AC_MSG_CHECKING([for dlopen in -ldl])
4668                ac_save_LIBS="$LIBS"
4669                LIBS="-ldl $LIBS"
4670                AC_TRY_LINK([#include <dlfcn.h>],dnl
4671                  [dlopen ("", 0);], [ have_dl=yes ],
4672                  [LIBS="$ac_save_LIBS"])
4673                ac_save_LIBS=])])
4674         if test -n "$have_dl"; then
4675            AC_DEFINE(HAVE_DLOPEN)
4676         else
4677            AC_CHECK_LIB(dld, shl_load, [
4678            libdl=dld have_dl=yes;
4679            AC_DEFINE(HAVE_SHL_LOAD)], [
4680            AC_CHECK_LIB(dld, dld_init, [
4681            libdl=dld have_dl=yes;
4682            AC_DEFINE(HAVE_DLD_INIT)])])
4683         fi
4684     ;;
4685     esac
4686   fi dnl end !MS-Windows
4687
4688   if test -n "$have_dl"; then
4689     dnl XE_SHLIB_STUFF (in aclocal.m4) defines $can_build_shared
4690     XE_SHLIB_STUFF
4691   fi
4692
4693   if test "$can_build_shared" = "yes"; then
4694     AC_DEFINE(HAVE_SHLIB)
4695     XE_ADD_OBJS(sysdll.o emodules.o)
4696     XE_APPEND(src, INSTALL_ARCH_DEP_SUBDIR)
4697     test -n "$libdl" && XE_PREPEND(-l${libdl}, LIBS)
4698     AC_CHECK_FUNCS(dlerror _dlerror)
4699     with_modules=yes
4700   else
4701     if test "$with_modules" = "yes"; then
4702       XE_DIE("Required module support cannot be provided.")
4703     else
4704       AC_MSG_WARN("Module support cannot be provided.")
4705     fi
4706     with_modules=no
4707   fi
4708 fi
4709
4710 dnl Unfortunately, just because we can link doesn't mean we can run.
4711 dnl One of the above link tests may have succeeded but caused resulting
4712 dnl executables to fail to run.  Also any tests using AC_TRY_RUN will
4713 dnl have reported incorrect results.
4714 AC_TRY_RUN([int main(int c,char *v[]){return 0;}],[:],[
4715   echo ""
4716   echo "*** PANIC *** configure forgot how to build working executables!"
4717   echo ""
4718   echo "*** This is most commonly due to an unforeseen environment, causing"
4719   echo "*** configure to incorrectly compute the sequence of libraries to link."
4720   echo "*** Please examine the tail of config.log for runtime errors."
4721   echo "*** Pay special attention to the -l flags, and perhaps -I and -L."
4722   echo "*** Often adding or removing explicit options in the configure"
4723   echo "*** invocation can work around this kind of problem.  If so, please"
4724   echo "*** report it as a bug to xemacs-beta@xemacs.org."
4725   echo "***"
4726   echo "*** Other possible causes are inability to write to the file system"
4727   echo "*** (bogus permissions or disk full) or a misconfiguration of the dynamic"
4728   echo "*** linker.  On Linux, check /etc/ld.conf and rerun ldconfig if"
4729   echo "*** necessary.  On other systems, try telling configure where to find"
4730   echo "*** the shared libraries using the --site-runtime-libraries option."
4731   echo "***"
4732   echo "*** Another way to shoot yourself in the foot is to specify"
4733   echo "*** --with-FEATURE when FEATURE is not actually installed on your"
4734   echo "*** system.  Don't do that."
4735   exit 1])
4736
4737 dnl Process support
4738 if test "$win32_processes" = "yes"; then
4739   XE_ADD_OBJS(process-nt.o)
4740 else
4741   AC_DEFINE(HAVE_UNIX_PROCESSES)
4742   XE_ADD_OBJS(process-unix.o)
4743 fi
4744
4745 dnl --------------------------------
4746 dnl Compute SUBST-itutable variables
4747 dnl --------------------------------
4748
4749 dnl We ignore (C|LD)_SWITCH_X_(MACHINE|SYSTEM)
4750 dnl Use XE_SPACE instead of plain assignment statements to remove extraneous blanks
4751 XE_SPACE(CFLAGS, $CFLAGS)
4752 XE_SPACE(extra_objs, $extra_objs)
4753 XE_SPACE(c_switch_general, -DHAVE_CONFIG_H $c_switch_site $c_switch_machine $c_switch_system)
4754 XE_SPACE(c_switch_window_system, $c_switch_x_site $c_switch_gtk $X_CFLAGS)
4755 XE_SPACE(c_switch_all, $c_switch_general $c_switch_window_system)
4756 XE_SPACE(ld_switch_general, $ld_switch_site $ld_switch_machine $ld_switch_system $ld_switch_run)
4757 XE_SPACE(ld_switch_window_system, $ld_switch_x_site)
4758 XE_SPACE(ld_switch_all, $ld_switch_general $ld_switch_window_system)
4759 XE_SPACE(ld_libs_general, $LIBS $libs_machine $libs_system $libs_standard)
4760 XE_SPACE(ld_libs_window_system, $X_EXTRA_LIBS $libs_x $libs_gtk $X_PRE_LIBS)
4761 XE_SPACE(ld_libs_all, $ld_libs_window_system $ld_libs_general)
4762
4763 dnl Compute lists of Makefiles and subdirs
4764 AC_SUBST(SRC_SUBDIR_DEPS)
4765 XE_APPEND(src, MAKE_SUBDIR)
4766 internal_makefile_list="Makefile.in"
4767 SUBDIR_MAKEFILES=''
4768 test -d lock || mkdir lock
4769 for dir in $MAKE_SUBDIR; do
4770   case "$dir" in */* ) dnl Implement mkdir -p
4771     ( for d in `echo $dir | sed 's:/: :g'` ; do
4772         test -d "$d" || mkdir "$d"; cd "$d"
4773       done ) ;;
4774    * ) test -d "$dir" || mkdir "$dir" ;;
4775   esac
4776   XE_SPACE(SUBDIR_MAKEFILES, $SUBDIR_MAKEFILES $dir/Makefile $dir/GNUmakefile)
4777   XE_SPACE(internal_makefile_list, $internal_makefile_list $dir/Makefile.in)
4778 done
4779 AC_SUBST(INSTALL_ARCH_DEP_SUBDIR)
4780 AC_SUBST(MAKE_SUBDIR)
4781 AC_SUBST(SUBDIR_MAKEFILES)
4782
4783 dnl Make s&m symlinks in the src directory, for config.h
4784 for dir in src/s src/m; do
4785   if test ! -d "$dir" ; then
4786     echo Making symbolic link to "$srcdir/$dir"
4787     ${LN_S} "$srcdir/$dir" "$dir"
4788   fi
4789 done
4790
4791 if test "$extra_verbose" = "yes"; then
4792   echo ""
4793   PRINT_VAR(extra_objs
4794    c_switch_general  c_switch_window_system  c_switch_all
4795   ld_switch_general ld_switch_window_system ld_switch_all
4796     ld_libs_general   ld_libs_window_system   ld_libs_all)
4797   echo ""
4798 fi
4799
4800 dnl ----------------------------------------------
4801 dnl Create some auxiliary files for developers.
4802 dnl ----------------------------------------------
4803
4804 dnl Create a .gdbinit useful for debugging XEmacs
4805 if test -f "$srcdir/src/.gdbinit" -a ! -f "src/.gdbinit"; then
4806   test "$extra_verbose" = "yes" && echo "creating src/.gdbinit"
4807   echo "source $srcdir/src/.gdbinit" > "src/.gdbinit"
4808 fi
4809
4810 dnl Create a .dbxrc useful for debugging XEmacs
4811 if test -f "$srcdir/src/.dbxrc" -a ! -f "src/.dbxrc"; then
4812   test "$extra_verbose" = "yes" && echo "creating src/.dbxrc"
4813   echo ". $srcdir/src/.dbxrc" > "src/.dbxrc"
4814 fi
4815
4816 dnl Create a useful TAGS file
4817 if test -f "$srcdir/TAGS" -a ! -f "TAGS"; then
4818   test "$extra_verbose" = "yes" && echo "creating TAGS"
4819   echo "\f
4820 $srcdir/TAGS,include" > "TAGS"
4821 fi
4822
4823 dnl Create top level .sbinit for Sun compilers
4824 if test "$__SUNPRO_C" = "yes"; then
4825   test "$extra_verbose" = "yes" && echo "creating .sbinit"
4826   ( echo "# For use with Sun WorkShop's Source browser."
4827     echo "# See sbquery(1) and sbinit(4) for more information"
4828     for dir in $MAKE_SUBDIR; do echo "import $dir"; done
4829   ) > .sbinit
4830 fi
4831
4832 dnl There are no more compile tests; remove the core they created.
4833 rm -f core
4834
4835 dnl ----------------------------------------------
4836 dnl Substitute into Makefile, config.h and paths.h
4837 dnl ----------------------------------------------
4838
4839 dnl what sort of things to edit into Makefile, config.h and paths.h
4840 dnl configuration here uncanonicalized to avoid exceeding size limits.
4841
4842 AC_SUBST(PROGNAME)
4843 AC_SUBST(version)
4844 AC_SUBST(configuration)
4845 AC_SUBST(canonical)
4846 AC_SUBST(inststaticdir)
4847 AC_SUBST(instvardir)
4848 AC_SUBST(srcdir)
4849 AC_SUBST(bindir)
4850 AC_SUBST(datadir)
4851 AC_SUBST(pkgdir)
4852 AC_SUBST(statedir)
4853 AC_SUBST(libdir)
4854 AC_SUBST(mandir)
4855 AC_SUBST(extra_includes)
4856
4857 AC_SUBST(prefix)
4858 AC_SUBST(PREFIX_USER_DEFINED)
4859 dnl Yo, Stephen Bourne!  I want to marry you!
4860 PREFIX=$prefix
4861 while true; do
4862   case "$PREFIX" in
4863     *\$* ) eval "PREFIX=$PREFIX" ;;
4864     *) break ;;
4865   esac
4866 done
4867 AC_SUBST(PREFIX)
4868
4869 AC_SUBST(exec_prefix)
4870 AC_SUBST(EXEC_PREFIX_USER_DEFINED)
4871 EXEC_PREFIX=$exec_prefix
4872 while true; do
4873   case "$EXEC_PREFIX" in
4874     *\$* ) eval "EXEC_PREFIX=$EXEC_PREFIX" ;;
4875     *) break ;;
4876   esac
4877 done
4878 AC_SUBST(EXEC_PREFIX)
4879
4880 AC_SUBST(infodir)
4881 AC_SUBST(INFODIR_USER_DEFINED)
4882 INFODIR=$infodir
4883 while true; do
4884   case "$INFODIR" in
4885     *\$* ) eval "INFODIR=$INFODIR" ;;
4886     *) break ;;
4887   esac
4888 done
4889 AC_SUBST(INFODIR)
4890
4891 AC_SUBST(infopath)
4892 AC_SUBST(INFOPATH_USER_DEFINED)
4893 INFOPATH=$infopath
4894 while true; do
4895   case "$INFOPATH" in
4896     *\$* ) eval "INFOPATH=$INFOPATH" ;;
4897     *) break ;;
4898   esac
4899 done
4900 AC_SUBST(INFOPATH)
4901
4902 AC_SUBST(package_path)
4903 AC_SUBST(PACKAGE_PATH_USER_DEFINED)
4904 PACKAGE_PATH=$package_path
4905 while true; do
4906   case "$PACKAGE_PATH" in
4907     *\$* ) eval "PACKAGE_PATH=$PACKAGE_PATH" ;;
4908     *) break ;;
4909   esac
4910 done
4911 AC_SUBST(PACKAGE_PATH)
4912
4913 AC_SUBST(lispdir)
4914 AC_SUBST(LISPDIR_USER_DEFINED)
4915 LISPDIR=$lispdir
4916 while true; do
4917   case "$LISPDIR" in
4918     *\$* ) eval "LISPDIR=$LISPDIR" ;;
4919     *) break ;;
4920   esac
4921 done
4922 AC_SUBST(LISPDIR)
4923
4924 AC_SUBST(moduledir)
4925 AC_SUBST(MODULEDIR_USER_DEFINED)
4926 MODULEDIR=$moduledir
4927 while true; do
4928   case "$MODULEDIR" in
4929     *\$* ) eval "MODULEDIR=$MODULEDIR" ;;
4930     *) break ;;
4931   esac
4932 done
4933 AC_SUBST(MODULEDIR)
4934
4935 AC_SUBST(sitelispdir)
4936 AC_SUBST(SITELISPDIR_USER_DEFINED)
4937 SITELISPDIR=$sitelispdir
4938 while true; do
4939   case "$SITELISPDIR" in
4940     *\$* ) eval "SITELISPDIR=$SITELISPDIR" ;;
4941     *) break ;;
4942   esac
4943 done
4944 AC_SUBST(SITELISPDIR)
4945
4946 AC_SUBST(sitemoduledir)
4947 AC_SUBST(SITEMODULEDIR_USER_DEFINED)
4948 SITEMODULEDIR=$sitemoduledir
4949 while true; do
4950   case "$SITEMODULEDIR" in
4951     *\$* ) eval "SITEMODULEDIR=$SITEMODULEDIR" ;;
4952     *) break ;;
4953   esac
4954 done
4955 AC_SUBST(SITEMODULEDIR)
4956
4957 AC_SUBST(etcdir)
4958 AC_SUBST(ETCDIR_USER_DEFINED)
4959 ETCDIR=$etcdir
4960 while true; do
4961   case "$ETCDIR" in
4962     *\$* ) eval "ETCDIR=$ETCDIR" ;;
4963     *) break ;;
4964   esac
4965 done
4966 AC_SUBST(ETCDIR)
4967
4968 AC_SUBST(docdir)
4969 AC_SUBST(DOCDIR_USER_DEFINED)
4970 DOCDIR=$docdir
4971 while true; do
4972   case "$DOCDIR" in
4973     *\$* ) eval "DOCDIR=$DOCDIR" ;;
4974     *) break ;;
4975   esac
4976 done
4977 AC_SUBST(DOCDIR)
4978
4979 AC_SUBST(archlibdir)
4980 AC_SUBST(ARCHLIBDIR_USER_DEFINED)
4981 ARCHLIBDIR=$archlibdir
4982 while true; do
4983   case "$ARCHLIBDIR" in
4984     *\$* ) eval "ARCHLIBDIR=$ARCHLIBDIR" ;;
4985     *) break ;;
4986   esac
4987 done
4988 AC_SUBST(ARCHLIBDIR)
4989
4990 AC_SUBST(docdir)
4991 AC_SUBST(bitmapdir)
4992 AC_SUBST(extra_objs)
4993
4994 dnl The following flags combine all the information from:
4995 dnl - command line options (user always gets priority)
4996 dnl - user environment variables
4997 dnl - determined by configure
4998 dnl - the s&m header files (required for ellcc)
4999 AC_SUBST(machfile)
5000 AC_SUBST(opsysfile)
5001 AC_SUBST(c_switch_general)
5002 AC_SUBST(c_switch_window_system)
5003 AC_SUBST(c_switch_all)
5004 AC_SUBST(ld_switch_general)
5005 AC_SUBST(ld_switch_window_system)
5006 AC_SUBST(ld_switch_all)
5007 AC_SUBST(ld_libs_general)
5008 AC_SUBST(ld_libs_window_system)
5009 AC_SUBST(ld_libs_all)
5010 AC_SUBST(CFLAGS)
5011 AC_SUBST(CPPFLAGS)
5012 AC_SUBST(LDFLAGS)
5013 RECURSIVE_MAKE_ARGS="\$(MFLAGS) CC='\$(CC)' CFLAGS='\$(CFLAGS)' LDFLAGS='\$(LDFLAGS)' CPPFLAGS='\$(CPPFLAGS)'"
5014 AC_SUBST(RECURSIVE_MAKE_ARGS)
5015
5016 AC_SUBST(native_sound_lib)
5017 AC_SUBST(sound_cflags)
5018 AC_SUBST(RANLIB)
5019 AC_SUBST(dynodump_arch)
5020
5021 dnl Preliminary support for using a different compiler for xemacs itself.
5022 dnl Useful for building XEmacs with a C++ or 64-bit compiler.
5023 : ${XEMACS_CC:=$CC}
5024 AC_SUBST(XEMACS_CC)
5025
5026 dnl The default is yes
5027 if test "$with_prefix" = "yes"; then
5028   AC_DEFINE(PREFIX_USER_DEFINED)
5029 fi
5030
5031 dnl The default is no
5032 if test "$with_site_lisp" = "no"; then
5033   AC_DEFINE(INHIBIT_SITE_LISP)
5034 fi
5035 dnl The default is yes
5036 if test "$with_site_modules" = "no"; then
5037   AC_DEFINE(INHIBIT_SITE_MODULES)
5038 fi
5039
5040 XE_SPACE(ac_configure_args, $ac_configure_args)
5041 AC_DEFINE_UNQUOTED(EMACS_CONFIGURATION, "$configuration")
5042 AC_DEFINE_UNQUOTED(EMACS_CONFIG_OPTIONS, "$ac_configure_args")
5043
5044 dnl Following are deprecated
5045
5046 null_string=""
5047 AC_DEFINE_UNQUOTED(LD_SWITCH_X_SITE,     $null_string)
5048 AC_DEFINE_UNQUOTED(LD_SWITCH_X_SITE_AUX, $null_string)
5049 AC_DEFINE_UNQUOTED(C_SWITCH_X_SITE,      $null_string)
5050 AC_DEFINE_UNQUOTED(LD_SWITCH_SITE,       $null_string)
5051 AC_DEFINE_UNQUOTED(C_SWITCH_SITE,        $null_string)
5052
5053 dnl Note: as a general rule, *only* define things here that are not
5054 dnl autodetected.  For things that are autodetected, define them
5055 dnl at the point where the autodetection occurs or would occur,
5056 dnl so that the user gets immediate feedback on the results of the
5057 dnl autodetection.
5058
5059 if   test "$GNU_MALLOC"         = "yes"; then AC_DEFINE(GNU_MALLOC)
5060 elif test "$with_system_malloc" = "yes"; then AC_DEFINE(USE_SYSTEM_MALLOC)
5061 elif test "$with_debug_malloc"  = "yes"; then AC_DEFINE(USE_DEBUG_MALLOC)
5062                                               AC_DEFINE(USE_SYSTEM_MALLOC)
5063 fi
5064 test "$with_i18n3"         = "yes" && AC_DEFINE(I18N3)
5065 test "$GCC"                = "yes" && AC_DEFINE(USE_GCC)
5066 test "$external_widget"    = "yes" && AC_DEFINE(EXTERNAL_WIDGET)
5067 test "$quick_build"        = "yes" && AC_DEFINE(QUICK_BUILD)
5068 test "$with_purify"        = "yes" && AC_DEFINE(PURIFY)
5069 test "$with_quantify"      = "yes" && AC_DEFINE(QUANTIFY)
5070 test "$with_pop"           = "yes" && AC_DEFINE(MAIL_USE_POP)
5071 test "$with_kerberos"      = "yes" && AC_DEFINE(KERBEROS)
5072 test "$with_hesiod"        = "yes" && AC_DEFINE(HESIOD)
5073 test "$use_union_type"     = "yes" && AC_DEFINE(USE_UNION_TYPE)
5074 test "$use_regex_malloc"   = "yes" && AC_DEFINE(REGEX_MALLOC)
5075 test "$pdump"              = "yes" && AC_DEFINE(PDUMP)
5076 test "$with_ipv6_cname"    = "yes" && AC_DEFINE(IPV6_CANONICALIZE)
5077
5078 dnl -------------------------------
5079 dnl Report on what we decided to do
5080 dnl -------------------------------
5081
5082 (
5083 dnl /etc/osversion is on SONY NEWS-OS
5084 if test -f /etc/osversion; then dnl SONY NEWS-OS
5085   echo "osversion: `cat /etc/osversion`"
5086 else
5087   echo "uname -a: `uname -a`"
5088 fi
5089 echo ""
5090 echo "$0 $quoted_arguments"
5091 ) > Installation
5092
5093 if test ! -z ${emacs_beta_version} ; then
5094   if test -z "${emacs_is_beta}" ; then
5095         xemacs_betaname=".${emacs_beta_version}"
5096   else
5097         xemacs_betaname="-b${emacs_beta_version}"
5098   fi
5099 else
5100   xemacs_betaname=""
5101 fi
5102
5103 dnl Start stdout redirection to '| tee -a Installation'
5104 (
5105 echo "
5106
5107 XEmacs ${emacs_major_version}.${emacs_minor_version}${xemacs_betaname} \"$xemacs_codename\" configured for \`$canonical'.
5108 "
5109 echo "
5110 Compilation / Installation:"
5111 echo "  Source code location:              $srcdir"
5112 echo "  Installation prefix:               $prefix"
5113 if test -n "$site_includes"; then
5114   echo "  Additional header files:           $site_includes"
5115 fi
5116 if test -n "$site_libraries"; then
5117   echo "  Additional libraries:              $site_libraries"
5118 fi
5119 if test -n "$site_prefixes"; then
5120   echo "  Additional prefixes:               $site_prefixes"
5121 fi
5122 if test -n "$runpath"; then
5123   echo "  Runtime library search path:       $runpath"
5124 fi
5125
5126 if test -n "$opsysfile"
5127 then echo "  Operating system description file: \`$opsysfile'"
5128 else echo "  Not using any operating system description file"
5129 fi
5130 if test -n "$machfile"
5131 then echo "  Machine description file:          \`$machfile'"
5132 else echo "  Not using any machine description file"
5133 fi
5134
5135 echo "  Compiler:                          $CC $CFLAGS"
5136 dnl Let's save some helpful-for-debugging info like compiler and libc versions..
5137 dnl First, see if it's gcc - the same check works everyplace...
5138 case "$CC" in
5139   gcc*) echo "  Compiler version:                  `$CC --version | sed 1q`"
5140         echo "  Compiler specs file:               `$CC -v 2>&1 | sed 's/.* \([[^ ]]\)/\1/' | sed 1q`"
5141         ;;
5142 dnl non-gcc machine-specific magic - contributions welcome
5143   *) case "$canonical" in
5144         *-*-aix*   ) 
5145           dnl Yes, it's this ugly for AIX...
5146           realcc=`which $CC`
5147           dnl Might be a symlink created by replaceCset command
5148           if test -L $realcc ; then
5149             ccdir=`dirname $realcc`
5150             ccprog=`/bin/ls -l $realcc | sed 's/.* \([[^ ]]\)/\1/'`
5151             dnl This doesn't handle ../../xlc type stuff, but I've not seen one...
5152             case $ccprog in
5153                 */*) realcc=$ccprog;;
5154                 *) realcc=$ccdir/$ccprog;;
5155             esac
5156           fi
5157           lpp=`lslpp -wqc $realcc | cut -f2 -d:`
5158           if test ! -z "$lpp" ; then
5159             lppstr=`lslpp -Lqc $lpp`
5160             lpplev=`echo "$lppstr" | cut -f3 -d:`
5161             lppdesc=`echo "$lppstr" | cut -f8 -d:`
5162           fi
5163           if test ! -z "$lpplev" ; then
5164             echo "  Compiler version:                  $lpp $lpplev - $lppdesc"
5165           else
5166             echo "  Compiler version:                  (unknown version)"
5167           fi
5168         ;;
5169         
5170         *-*-solaris*)
5171           ccvers=`$CC -V 2>&1 | sed 1q`
5172           if test ! -z "$ccvers" ; then
5173             echo "  Compiler version:                  $ccvers"
5174           fi
5175         ;;
5176
5177         alpha*-dec-osf*)
5178           ccvers=`$CC -V | tr '\n' ' '`
5179           if test ! -z "$ccvers" ; then
5180             echo "  Compiler version:                  $ccvers"
5181           fi
5182         ;;
5183
5184         mips-sgi-irix*)
5185           ccvers=`$CC -version`
5186           if test ! -z "$ccvers" ; then
5187             echo "  Compiler version:                  $ccvers"
5188           fi
5189         ;;
5190
5191         dnl Intel C++ Compiler on Linux
5192         i[[3-9]]86-pc-linux)
5193           ccvers=`$CC -V 2>&1 | sed -n 's@^Intel.*Version @@'p`
5194           if test ! -z "$ccvers" ; then
5195             echo "  Compiler version:                  $ccvers"
5196           fi
5197         ;;
5198           
5199         *) echo "  Compiler version:                  $CC on $canonical";;
5200   esac
5201 esac
5202
5203 echo "  Relocating allocator for buffers:  $rel_alloc"
5204 echo "  GNU version of malloc:             ${GNU_MALLOC}${GNU_MALLOC_reason}"
5205 case "$ld_switch_site" in
5206   *nocombreloc*) echo "  Linking with \`-z nocombreloc'.
5207     - Consider configuring with --pdump." ;;
5208 esac
5209
5210 dnl Now get the libc version - contributions welcome
5211 case "$canonical" in
5212         *-*-linux*) 
5213           if test -f /etc/redhat-release ; then
5214             echo "  libc:                              `rpm -q glibc`";
5215 dnl need a Debian and Suse check here...
5216           else
5217             echo "Need to guess glibc1/2/etc here";
5218           fi
5219         ;;
5220
5221         *-*-aix*) 
5222           echo "  libc:                              bos.rte.libc `lslpp -Lqc bos.rte.libc | cut -f3 -d:`" 
5223         ;;
5224
5225         *-*-solaris*)
5226           libc=`pkginfo -l SUNWcsl | grep VERSION: | awk '{print $2}'`
5227           echo "  libc:                              SUNWcsl $libc"
5228
5229         ;;
5230
5231         mips-sgi-irix*)
5232           echo "  IRIX version:                      `uname -sRm`'"
5233         ;;
5234           
5235
5236         alpha*-dec-osf*)
5237         dnl Another ugly case
5238           (cd /usr/.smdb.;
5239                 libc=` grep -h libc.so *.inv | awk '$9 == "f" {print $12}' | tr '\n' ','`
5240                 echo "  libc:                              $libc"
5241                 
5242           )
5243         ;;
5244
5245         *) echo "  libc:                              system-provided libc on $canonical" ;;
5246 esac
5247
5248
5249 echo "
5250 Window System:"
5251 if test "$with_msw" = "yes"; then
5252   echo "  Compiling in support for the Microsoft window system."
5253 fi
5254 if test "$with_x11" = "yes"; then
5255   echo "  Compiling in support for the X window system:"
5256   echo "    - X Windows headers location:                 $x_includes"
5257   echo "    - X Windows libraries location:               $x_libraries"
5258   if test "$with_xauth" != yes; then
5259     echo "    - Xau (X authority) not available."
5260   fi
5261   if test "$with_xmu" != yes; then
5262     echo "    - Xmu library not available; substituting equivalent routines."
5263   fi
5264   if test "$with_wmcommand" != no; then
5265     echo "    - Handling WM_COMMAND properly."
5266   fi
5267 fi
5268 if test "$need_motif" = "yes" ; then
5269   echo "  Compiling in support for Motif."
5270   if test "$have_lesstif" = "yes"; then
5271     echo "    - Using LessTif implementation."
5272   fi
5273   echo "  *WARNING*  Many versions of Motif are buggy, requiring workarounds."
5274   echo "             You are likely to experience slow redisplay."
5275   echo "             You may need to install vendor patches to Motif."
5276   echo "             See PROBLEMS for more information."
5277 fi
5278 if test "$need_athena" = "yes"; then
5279   echo "  Compiling in support for the Athena widget set:"
5280   echo "    - Athena headers location:                    $athena_h_path"
5281   echo "    - Athena library to link:                     $athena_lib"
5282 fi
5283 case "$with_menubars" in
5284   gtk   ) echo "  Using GTK menubars."   ;;
5285   lucid ) echo "  Using Lucid menubars." ;;
5286   motif ) echo "  Using Motif menubars."
5287           echo "  *WARNING*  The Motif menubar implementation is currently buggy."
5288           echo "             We recommend using the Lucid menubar instead."
5289           echo "             Re-run configure with --with-menubars='lucid'." ;;
5290     msw ) echo "  Using MS-Windows menubars." ;;
5291 esac
5292 case "$with_scrollbars" in
5293   gtk    ) echo "  Using GTK scrollbars."        ;;
5294   lucid  ) echo "  Using Lucid scrollbars."      ;;
5295   motif  ) echo "  Using Motif scrollbars."      ;;
5296   athena ) echo "  Using Athena scrollbars."     ;;
5297      msw ) echo "  Using MS-Windows scrollbars." ;;
5298 esac
5299 case "$with_dialogs" in
5300   gtk    ) echo "  Using GTK dialog boxes." ;;
5301   motif  ) echo "  Using Motif dialog boxes."
5302            if test "$unexec" = "unexaix.o"; then if test "`uname -v`" = 4 -a "`uname -r`" -ge 3; then
5303              echo "  *WARNING*  The Motif dialog boxes cause problems on AIX 4.3 and higher."
5304              echo "             We recommend using the Athena dialog boxes instead."
5305              echo "             Install libXaw and re-run configure with --with-dialogs='athena'."
5306              echo "             Read the PROBLEMS file for more information."
5307            fi; fi ;;
5308   athena ) echo "  Using Athena dialog boxes."     ;;
5309      msw ) echo "  Using MS-Windows dialog boxes." ;;
5310 esac
5311 case "$with_widgets" in
5312   gtk    ) echo "  Using GTK native widgets."        ;;
5313   motif  ) echo "  Using Motif native widgets."      ;;
5314   athena ) echo "  Using Athena native widgets."     ;;
5315      msw ) echo "  Using MS-Windows native widgets." ;;
5316 esac
5317 if test "$with_dragndrop" = yes; then
5318   echo "  Compiling in support for Drag'n'Drop (EXPERIMENTAL)."
5319   echo "    -  Drag'n'Drop prototype:                             $dragndrop_proto."
5320 fi
5321
5322 echo "
5323 TTY:"
5324 test "$with_ncurses" = yes && echo "  Compiling in support for ncurses."
5325 test "$with_gpm" = yes && echo "  Compiling in support for GPM (General Purpose Mouse)."
5326
5327 echo "
5328 Images:"
5329 test "$with_gif" = yes && echo "  Compiling in support for GIF  images (builtin)."
5330 if test "$with_xpm" = yes; then
5331   echo "  Compiling in support for XPM  images."
5332 elif test "$with_x11" = yes; then
5333   echo "  WARNING: -----------------------------------------------------------"
5334   echo "  WARNING: Compiling without XPM image support."
5335   if test "$xpm_problem" != ""; then
5336     echo "  Reason: $xpm_problem"
5337   fi
5338   echo "  WARNING: You should strongly consider installing XPM."
5339   echo "  WARNING: Otherwise toolbars and other graphics will look suboptimal."
5340   echo "  WARNING: (a copy may be found in ftp://ftp.xemacs.org/pub/xemacs/aux)"
5341   echo "  WARNING: -----------------------------------------------------------"
5342 fi
5343 if test "$with_png" = yes; then
5344   echo "  Compiling in support for PNG  images."
5345 elif test "$window_system" != "none"; then
5346   echo "  WARNING: -----------------------------------------------------------"
5347   echo "  WARNING: Compiling without PNG image support."
5348   if test "$png_problem" != ""; then
5349     echo "  Reason: $png_problem"
5350   fi
5351   echo "  WARNING: You should strongly consider installing the PNG libraries."
5352   echo "  WARNING: Otherwise certain images and glyphs may not display."
5353   echo "  WARNING: (a copy may be found in ftp://ftp.xemacs.org/pub/xemacs/aux)"
5354   echo "  WARNING: -----------------------------------------------------------"
5355 fi
5356 test "$with_jpeg" = yes && echo "  Compiling in support for JPEG images."
5357 test "$with_tiff" = yes && echo "  Compiling in support for TIFF images."
5358 test "$with_xface" = yes && echo "  Compiling in support for X-Face message headers."
5359
5360 echo "
5361 Sound:"
5362 test "$with_native_sound" = yes && echo "  Compiling in support for sound (native)."
5363 test "$with_nas_sound" = yes && echo "  Compiling in support for NAS (network audio system)."
5364 test "$old_nas" = yes && echo "    - NAS library lacks error trapping; will play synchronously."
5365 test "$with_esd_sound" = yes && echo "  Compiling in support for ESD (Enlightened Sound Daemon)."
5366
5367 echo "
5368 Databases:"
5369 test "$with_database_berkdb" = yes && echo "  Compiling in support for Berkeley database."
5370 test "$with_database_dbm"    = yes && echo "  Compiling in support for DBM."
5371 test "$with_database_gdbm"   = yes && echo "  Compiling in support for GNU DBM."
5372 test "$with_ldap" = yes && echo "  Compiling in support for LDAP."
5373 if test "$with_postgresql" = yes; then
5374   echo "  Compiling in support for PostgreSQL."
5375   echo "    - Using PostgreSQL header file:  $libpq_fe_h_file"
5376   test "$with_postgresqlv7" = yes && echo "    - Using PostgreSQL V7 bindings."
5377 fi
5378
5379 echo "
5380 Internationalization:"
5381 test "$with_mule" = yes && echo "  Compiling in support for Mule (multi-lingual Emacs)."
5382 test "$with_file_coding" = yes && echo "  Compiling in support for file coding."
5383 test "$with_xim" != no && echo "  Compiling in support for XIM (X11R5+ I18N input method)."
5384 test "$with_xim" = motif && echo "    - Using Motif to provide XIM support."
5385 test "$with_xim" = xlib && echo "    - Using raw Xlib to provide XIM support."
5386 test "$with_xfs" = yes && echo "    - Using XFontSet to provide bilingual menubar."
5387 test "$with_canna" = yes && echo "  Compiling in support for Canna on Mule."
5388 if test "$with_wnn" = yes; then
5389   echo "  Compiling in support for the WNN input method on Mule."
5390   test "$with_wnn6" = yes && echo "    - Using WNN version 6."
5391 fi
5392 test "$with_i18n3" = yes && echo "  Compiling in support for I18N level 3 (doesn't currently work)."
5393
5394 echo "
5395 Mail:"
5396 test "$with_pop" = yes && echo "  Compiling in support for POP mail retrieval."
5397 test "$with_kerberos" = yes && echo "  Compiling in support for Kerberos POP authentication."
5398 test "$with_hesiod" = yes && echo "  Compiling in support for Hesiod POP server access."
5399 test -n "$mail_locking" && echo "  Compiling in support for \"$mail_locking\" mail spool file locking method."
5400
5401 echo "
5402 Other Features:"
5403 test "$with_ipv6_cname" = no && echo "  Inhibiting IPv6 canonicalization at startup."
5404 test "$with_tooltalk" = yes && echo "  Compiling in support for ToolTalk."
5405 test "$with_workshop" = yes && echo "  Compiling in support for Sun WorkShop."
5406 test "$with_socks" = yes && echo "  Compiling in support for SOCKS."
5407 test "$with_dnet" = yes && echo "  Compiling in support for DNET."
5408 test "$with_modules" = "yes" && echo "  Compiling in support for dynamic shared object modules."
5409 if test "$use_union_type" = yes; then
5410   echo "  WARNING: ---------------------------------------------------------"
5411   echo "  Using the union type for Lisp_Objects."
5412   echo "  Union type has been implicated in hard-to-debug runtime crashes."
5413   echo "  Do NOT use this build of XEmacs for ordinary work.  See PROBLEMS."
5414   echo "  WARNING: ---------------------------------------------------------"
5415 fi
5416 if test "$use_regex_malloc" = no; then
5417   echo "  WARNING: -----------------------------------------------------------"
5418   echo "  Using alloca to allocate the failure stack."
5419   echo "  It may be impossible to detect stack exhaustion, and you will crash."
5420   echo "  Do NOT use this build of XEmacs for ordinary work."
5421   echo "  WARNING: -----------------------------------------------------------"
5422 fi
5423 test "$pdump" = yes && echo "  Using the new portable dumper."
5424 test "$debug" = yes && echo "  Compiling in support for extra debugging code."
5425 test "$usage_tracking" = yes && echo "  Compiling in support for active usage tracking (Sun internal)."
5426 if test "$error_check_extents $error_check_typecheck $error_check_bufpos $error_check_gc $error_check_malloc $error_check_glyphs" \
5427   != "no no no no no no"; then
5428   echo "  WARNING: ---------------------------------------------------------"
5429   echo "  WARNING: Compiling in support for runtime error checking."
5430   echo "  WARNING: XEmacs will run noticeably more slowly as a result."
5431   echo "  WARNING: Error checking is on by default for XEmacs beta releases."
5432   echo "  WARNING: ---------------------------------------------------------"
5433 fi
5434 echo ""
5435 ) | tee -a Installation
5436 dnl echo "The above configure report is appended to \"Installation\" file."
5437 echo ""
5438
5439 dnl -----------------------------------
5440 dnl Now generate config.h and Makefiles
5441 dnl -----------------------------------
5442 dnl This has to be called in order for this variable to get into config.status
5443 AC_SUBST(internal_makefile_list)
5444 # Remove any trailing slashes in these variables.
5445 test -n "$prefix" &&
5446   prefix=`echo '' "$prefix" | sed -e 's:^ ::' -e 's,\([[^/]]\)/*$,\1,'`
5447 test -n "$exec_prefix" &&
5448   exec_prefix=`echo '' "$exec_prefix" | sed -e 's:^ ::' -e 's,\([[^/]]\)/*$,\1,'`
5449
5450 dnl Build Makefile.in's from Makefile.in.in's
5451 dnl except ./Makefile from $srcdir/Makefile.in
5452
5453 for file in $internal_makefile_list; do
5454   test "$file" = src/Makefile.in && \
5455     file="src/Makefile.in:src/Makefile.in.in:src/depend"
5456   XE_APPEND($file, ac_output_files)
5457 done
5458 ac_output_files="$ac_output_files src/paths.h lib-src/config.values"
5459 test "$with_modules" = "yes" && XE_APPEND(lib-src/ellcc.h, ac_output_files)
5460
5461 AC_OUTPUT($ac_output_files,
5462 [for dir in . $MAKE_SUBDIR; do
5463   (
5464     cd $dir
5465     rm -f junk.c
5466     < Makefile.in \
5467       sed -e '/^# Generated/d' \
5468           -e 's%/\*\*/#.*%%' \
5469           -e 's/^ *# */#/' \
5470 dnl Delete Makefile.in.in comment lines
5471           -e '/^##/d' \
5472 dnl Pass through CPP directives unchanged
5473           -e '/^#/ {
5474 p
5475 d
5476 }'        \
5477 dnl Quote other lines to protect from CPP substitution
5478           -e '/./ {
5479 s/\([[\"]]\)/\\\1/g
5480 s/^/"/
5481 s/$/"/
5482 }'  > junk.c;
5483
5484 dnl Create a GNUmakefile and Makefile from Makefile.in.
5485
5486 changequote(<<,>>)dnl
5487 dnl CPP_MAKEFILE(CPPFLAGS,filename)
5488 define(<<CPP_MAKEFILE>>,
5489 echo creating $dir/<<$2>>
5490 $CPP -I. -I${top_srcdir}/src <<$1>> junk.c \
5491 dnl Delete line directives inserted by $CPP
5492   | sed -e 's/^\#.*//'          \
5493 dnl Delete spurious blanks inserted by $CPP
5494         -e 's/^[ TAB][ TAB]*$//'\
5495         -e 's/^ /TAB/'          \
5496 dnl Delete blank lines
5497         -e '/^[ \f]*$/d' \
5498 dnl Restore lines quoted above to original contents.
5499         -e '/^\"/ {
5500         s/\\\([\"]\)/\1/g
5501         s/^[ TAB]*\"//
5502         s/\"[ TAB]*$//
5503 }' > Makefile.new
5504     chmod 444 Makefile.new
5505     mv -f Makefile.new <<$2>>
5506 )dnl CPP_MAKEFILE
5507
5508     CPP_MAKEFILE(,Makefile)
5509     CPP_MAKEFILE(-DUSE_GNU_MAKE,GNUmakefile)
5510 changequote([,])dnl
5511     rm -f junk.c
5512   )
5513 done
5514
5515 dnl Append AC_DEFINE information to lib-src/config.values
5516 dnl (AC_SUBST information is already there (see config.values.sh).
5517 sed < config.status >> lib-src/config.values \
5518   -e '/{ac_dA}.*{ac_dB}.*{ac_dC}.*{ac_dD}$/!d' \
5519   -e 's/\${ac_dA}\(.*\)\${ac_dB}.*\${ac_dC}\(.*\)\${ac_dD}/\1 \2/' \
5520   -e 's/^\([[^ ]]*\) $/\1 ""/' \
5521   -e 's/ 1$/ t/'
5522
5523 ],
5524 [CPP="$CPP"
5525  top_srcdir="$srcdir"
5526  MAKE_SUBDIR="$MAKE_SUBDIR"
5527 ])dnl