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