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