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