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