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