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