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