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