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