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