Improve TTY library detection
[sxemacs] / configure.ac
1 dnl SXEmacs config script for autoconf >=2.60
2 dnl -------------------------------------------------------------------------
3 dnl Overrides of standard autoconf macros.
4
5 m4_include([sxemacs_version.m4])
6
7 dnl -------------------------------------------------------------------------
8 dnl Autoconf startup.
9 dnl -------------------------------------------------------------------------
10
11 AC_PREREQ([2.62])
12 AC_INIT([SXEmacs], [SXEM4CS_VERSION], [http://issues.sxemacs.org/])
13 AC_CONFIG_HEADER([src/config.h])
14 AC_CONFIG_SRCDIR([src/lisp.h])
15 AC_CONFIG_AUX_DIR([.])
16 AC_CONFIG_MACRO_DIR([m4])
17
18 dnl -------------------------------------------------------------------------
19 dnl Local copyright notices.
20 dnl -------------------------------------------------------------------------
21
22 AC_COPYRIGHT(
23 [#### Configuration script for SXEmacs.  Largely divergent from FSF.
24 #### Guess values for system-dependent variables and create Makefiles.
25 #### Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
26 #### Copyright (C) 1993-1995 Board of Trustees, University of Illinois.
27 #### Copyright (C) 1996, 1997 Sun Microsystems, Inc.
28 #### Copyright (C) 1995, 1996, 2002, 2003, 2004 Ben Wing.
29 #### Copyright (C) 2000, 2001 Martin Buchholz.
30 #### Copyright (C) 1998, 1999 J. Kean Johnston.
31 #### Copyright (C) 2005 Malcolm Purvis.
32 #### Copyright (C) 2005, 2006, 2007 Steve Youngs.
33 #### Copyright (C) 2006, 2007, 2008 Sebastian Freundt.
34 #### Copyright (C) 2007, 2010, 2011, 2012 Nelson Ferreira
35
36 ### Don't edit this script!
37 ### This script was automatically generated by the `autoconf' program
38 ### from the file `./configure.ac'.
39 ### To rebuild it, execute the command
40 ###     autoconf
41 ### in the this directory.
42
43 ### This file is part of SXEmacs.
44
45 ### SXEmacs is free software: you can redistribute it and/or modify
46 ### it under the terms of the GNU General Public License as published by
47 ### the Free Software Foundation, either version 3 of the License, or
48 ### (at your option) any later version.
49
50 ### SXEmacs is distributed in the hope that it will be useful,
51 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
52 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
53 ### GNU General Public License for more details.
54
55 ### You should have received a copy of the GNU General Public License
56 ### along with this program.  If not, see <http://www.gnu.org/licenses/>.
57
58 ### Parts of SXEmacs are also distributed under a BSD-like licence.
59 ### Check file headers for more information.
60
61 ### For usage, run `./configure --help'
62 ### For more detailed information on building and installing SXEmacs,
63 ### read the file `INSTALL'.
64 ###
65 ### If configure succeeds, it leaves its status in config.status.
66 ### A log of configuration tests can be found in config.log.
67 ### If configure fails after disturbing the status quo,
68 ###     config.status is removed.
69 ])
70
71 AC_REVISION([SXEM4CS_GIT_VERSION])
72
73
74 dnl Build Options
75 dnl =============
76 OG_OPTION_GROUP(Build Options)
77
78 OG_ARG_WITH([prefix],
79         AS_HELP_STRING([--with-prefix@<:@=ARG@:>@],
80                 [Whether to compile the value of --prefix into the executable.]),
81         [yes], [YES (DO compile prefix into the executable)])
82
83 OG_ARG_WITH([sitemoduledir],
84         AS_HELP_STRING([--with-sitemoduledir=DIR],
85                 [Directory for loadable modules that are not part of
86                 the SXEmacs core distribution (3rd party emodules).]),
87         [none], [$prefix/lib/sxemacs/$build/site-modules], [og_any],
88         [AC_DEFINE([SITEMODULEDIR_USER_DEFINED], [1],
89                 [sitemoduledir has been specified on the configure line.])],
90         [with_sitemoduledir='${libdir}/${PROGNAME}/${configuration}/site-modules'])
91
92 OG_ARG_WITH([site-includes],
93         AS_HELP_STRING([--with-site-includes=PATH],
94                 [Colon separated list of _extra_ include directories
95                 to search for headers.]),
96         [none], [None], [og_any])
97
98 OG_ARG_WITH([site-libraries],
99         AS_HELP_STRING([--with-site-libraries=PATH],
100                 [Colon separated list of extra lib directories to
101                 search for libraries. (Default: None)]),
102         [none], [None], [og_any])
103
104 OG_ARG_WITH([site-prefixes],
105         AS_HELP_STRING([--with-site-prefixes=PATH],
106                 [Colon separated list of extra prefix directories to
107                 search for headers and libraries.  Sometimes this can
108                 be used instead of specifying both
109                 --with-site-includes and
110                 --with-site-libraries.]),
111         [none], [None], [og_any])
112
113 OG_ARG_WITH([lispdir],
114         AS_HELP_STRING([--with-lispdir=DIR],
115                 [Where to install core lisp files.]),
116         [none], [$prefix/lib/sxemacs-$version/lisp], [og_any],
117         [AC_DEFINE([LISPDIR_USER_DEFINED], [1],
118                 [lispdir has been specified on the configure line.])],
119         [with_lispdir='${datadir}/${instvardir}/lisp'])
120
121 OG_ARG_WITH([archlibdir],
122         AS_HELP_STRING([--with-archlibdir=DIR],
123                 [Directory for arch-dependent files.]),
124         [none], [$prefix/lib/sxemacs-$version/$build], [og_any],
125         [AC_DEFINE([ARCHLIBDIR_USER_DEFINED], [1],
126                 [archlibdir has been specified on the configure line.])],
127         [with_archlibdir='${libdir}/${instvardir}/${configuration}'])
128
129 OG_ARG_WITH([moduledir],
130         AS_HELP_STRING([--with-moduledir=DIR],
131                 [Directory for loadable modules.]),
132         [none], [$prefix/lib/sxemacs-$version/$build/modules], [og_any],
133         [AC_DEFINE([MODULEDIR_USER_DEFINED], [1],
134                 [moduledir has been specified on the configure line.])],
135         [with_moduledir='${libdir}/${instvardir}/${configuration}/modules'])
136
137 OG_ARG_WITH([etcdir],
138         AS_HELP_STRING([--with-etcdir=DIR],
139                 []),
140         [none], [$prefix/lib/sxemacs-$version/etc], [og_any],
141         [AC_DEFINE([ETCDIR_USER_DEFINED], [1],
142                 [etcdir has been specified on the configure line.])],
143         [with_etcdir='${datadir}/${instvardir}/etc'])
144
145 OG_ARG_WITH([infopath],
146         AS_HELP_STRING([--with-infopath=PATH],
147                 [Colon separated list of directories to use as
148                 the info search path. This is not normally needed.]),
149         [none], [None], [og_any],
150         [AC_DEFINE([INFOPATH_USER_DEFINED], [1],
151                 [inforpath has been specified on the configure line.])], [])
152
153 OG_ARG_WITH([docdir],
154         AS_HELP_STRING([--with-docdir=DIR],
155                 [Where it store certain doc files (not info or man).]),
156         [none], [$prefix/lib/sxemacs-$version/$build], [og_any],
157         [AC_DEFINE([DOCDIR_USER_DEFINED], [1],
158                 [docdir has been specified on the configure line.])],
159         [with_docdir='${archlibdir}'])
160
161 OG_ARG_WITH([site-runtime-libraries],
162         AS_HELP_STRING([--with-site-runtime-libraries=PATH],
163                 [Colon separated list of directories to search for
164                 libraries at run time.  This isn't normally needed.]),
165         [none], [None], [og_any])
166
167 OG_ARG_WITH([module-path],
168         AS_HELP_STRING([--with-module-path=PATH],
169                 [Search path to the emodules directories.
170                 A colon separated list of directories. Normally, there is
171                 no need to set this.]),
172         [none], [None], [og_any],
173         [AC_DEFINE([MODULE_PATH_USER_DEFINED], [1],
174                 [module-path has been specified on the configure line.])],
175         [])
176
177 OG_ARG_WITH([package-prefix],
178         AS_HELP_STRING([--with-package-prefix=PATH],
179                 [What to use as a prefix to the system-wide package
180                 directories.  It doesn't affect the package directories
181                 under the user's home directory, and is totally ignored if
182                 --with-package-path is set.
183                 Normally, you would not need to set this.]),
184         [none], [None], [og_any],
185         [AC_DEFINE([PACKAGE_PREFIX_USER_DEFINED], [1],
186                 [package-prefix has been specified on the configure line.])],
187         [])
188
189 OG_ARG_WITH([package-path],
190         AS_HELP_STRING([--with-package-path=PATH],
191                 [Search path to the package directories.
192                 This path is made up of 3 separate "path elements",
193                 each element is a colon separated list of directories,
194                 with the boundary between elements being a double
195                 colon.  The 3 path elements are for "early", "late",
196                 and "last" package directories.  If only a single
197                 element is specified it is "late".  Example:
198                 early1:early2::late1:late2::last1:last2.  Setting this
199                 overrides --with-package-prefix.  Normally, there is
200                 no need to set this.]),
201         [none], [None], [og_any],
202         [AC_DEFINE([PACKAGE_PATH_USER_DEFINED], [1],
203                 [package-path has been specified on the configure line.])],
204         [])
205
206 dnl stupid option, innit?
207 OG_ARG_WITH([quick-build],
208         AS_HELP_STRING([--with-quick-build],
209                 [Speed up the build cycle by leaving out steps where
210                 SXEmacs will still work (more or less) without them.
211                 Potentially dangerous if you don't know what you're
212                 doing. This (1) doesn't garbage-collect after loading
213                 each file during dumping, (2) doesn't automatically
214                 rebuild the DOC file (remove it by hand to get it
215                 rebuilt), (3) Removes config.h lisp.h and associated
216                 files from the dependency lists so changes to these
217                 files don't automatically cause all .c files
218                 to be rebuilt.]),
219         [no], [No], [])
220
221 OG_ARG_WITH([compiler],
222         AS_HELP_STRING([--with-compiler=COMPILER],
223                 [Do not use me! Use CC=<your-compiler> instead!
224                 C compiler to use.
225                 Note: SXEmacs _CANNOT_ be built with a C++ compiler.]),
226         [none], [None], [og_any], [
227                 OG_WARN_OBSOLETE_OPTION([--with-compiler], [CC=<your-cc>])])
228
229 OG_ARG_WITH([cflags],
230         AS_HELP_STRING([--with-cflags],
231                 [Do not use me! Use CFLAGS=<your flags> instead!
232                 Compiler flags (such as -O); setting this overrides
233                 all default compiler flags except those that control
234                 warnings. Most people wouldn't need to set
235                 this.]),
236         [none], [None], [og_any], [
237                 OG_WARN_OBSOLETE_OPTION([--with-cflags], [CFLAGS=<your flags>])])
238
239 OG_ARG_WITH([cflags-warning],
240         AS_HELP_STRING([--with-cflags-warning],
241                 [Do not use me! I will disappear soon!]),
242         [none], [None], [og_any])
243
244 OG_ARG_WITH([cpp],
245         AS_HELP_STRING([--with-cpp],
246                 [Do not use me! Use CPP=<your-cpp> instead!]),
247         [none], [None], [og_any], [
248                 OG_WARN_OBSOLETE_OPTION([--with-cpp], [CPP=<your-cpp>])
249                 CPP="$with_cpp"])
250
251 OG_ARG_WITH([cppflags],
252         AS_HELP_STRING([--with-cppflags],
253                 [Do not use me! Use CPPFLAGS=<your flags> instead!]),
254         [none], [None], [og_any], [
255                 OG_WARN_OBSOLETE_OPTION([--with-cppflags], [CPPFLAGS=<your flags>])
256                 CPPFLAGS="$with_cppflags"])
257
258 OG_ARG_WITH([libs],
259         AS_HELP_STRING([--with-libs],
260                 [Do not use me! Use LIBS=<your libs> instead!]),
261         [none], [None], [og_any], [
262                 OG_WARN_OBSOLETE_OPTION([--with-libs], [LIBS=<your libs>])
263                 LIBS="$with_libs"])
264
265 OG_ARG_WITH([ldflags],
266         AS_HELP_STRING([--with-ldflags],
267                 [Do not use me! Use LDFLAGS=<your flags> instead!]),
268         [none], [None], [og_any], [
269                 OG_WARN_OBSOLETE_OPTION([--with-ldflags], [LDFLAGS=<your flags>])
270                 LDFLAGS="$with_ldflags"])
271
272 OG_ARG_WITH([ridiculously-aggressive-optimisations],
273         AS_HELP_STRING([--with-ridiculously-aggressive-optimisations],
274                 [Whether to try all possible optimisations]),
275         [no], [No])
276
277 OG_ARG_WITH([maximum-warning-output],
278         AS_HELP_STRING([--with-maximum-warning-output],
279                 [Whether to output as many warnings as possible]),
280         [no], [No])
281
282
283 dnl Internal Options
284 dnl ================
285 OG_OPTION_GROUP(Internal Options)
286
287 OG_ARG_WITH([dynamic],
288         AS_HELP_STRING([--with-dynamic],
289                 [Link dynamically if supported by system.
290                 'NO' forces static linking.]),
291         [auto], [Autodetect])
292
293 OG_ARG_WITH([rel-alloc],
294         AS_HELP_STRING([--with-rel-alloc],
295                 [Relocating allocator for buffers.]),
296         [default], [Autodetect])
297
298 OG_ARG_WITH([dlmalloc],
299         AS_HELP_STRING([--with-dlmalloc],
300                 [Use Doug Lea's malloc.]),
301         [default], [Autodetect])
302
303 OG_ARG_WITH([debug-malloc],
304         AS_HELP_STRING([--with-debug-malloc],
305                 [Use a debugging malloc.]),
306         [no], [NO])
307
308 OG_ARG_WITH([system-malloc],
309         AS_HELP_STRING([--with-system-malloc],
310                 [Use a system malloc instead of GNU.]),
311         [default], [YES if using quantify or purify; NO otherwise])
312
313 OG_ARG_WITH([regex-malloc],
314         AS_HELP_STRING([--with-regex-malloc],
315                 [Use malloc for regex failure stack.]),
316         [yes], [YES])
317
318 OG_ARG_WITH([ffi],
319         AS_HELP_STRING([--with-ffi],
320                 [Compile in experimental support for
321                 Foreign Function Interface.]),
322         [yes], [YES])
323
324 OG_ARG_WITH([module-support],
325         AS_HELP_STRING([--with-module-support],
326                 [Compile in experimental support for dynamically
327                 loaded libraries (Dynamic Shared Objects).]),
328         [yes], [YES if shared libraries are supported])
329
330 OG_MULTIARG_WITH([modules], [dnl
331         AS_HELP_STRING([--with-modules], [
332                 Which modules to compile and install.])],
333         [all], [all], [dnl
334         OG_MULTIARG_ITEM([ase], [ase], [algebraic structures])
335         OG_MULTIARG_ITEM([cl], [cl], [fast Common Lisp implementation])
336 ])
337         dnl OG_MULTIARG_ITEM([dbus], [dbus], [D-BUS bindings])
338
339 OG_MULTIARG_WITH([static-modules], [dnl
340         AS_HELP_STRING([--with-static-modules], [
341                 Which modules to compile as archives to link their
342                 functionality statically into the SXEmacs binary.])
343         AS_HELP_STRING([], [
344                 You should regard this as a proof of concept.])],
345         [none], [NONE], [dnl
346         OG_MULTIARG_ITEM([ase], [ase], [algebraic structures])
347         OG_MULTIARG_ITEM([cl], [cl], [fast Common Lisp implementation])
348 ])
349         dnl OG_MULTIARG_ITEM([dbus], [dbus], [D-BUS bindings])
350
351 OG_MULTIARG_WITH([ent], [dnl
352         AS_HELP_STRING([--with-ent], [
353                 Compile in support for enhanced number types,
354                 using internal and external libraries.])],
355         [none int fpfloat indef gmp], [int fpfloat indef gmp], [dnl
356         OG_MULTIARG_ITEM([int], [int], [native integer arithmetics])
357         OG_MULTIARG_ITEM([fpfloat], [fpfloat], [native fixed precision floats])
358         OG_MULTIARG_ITEM([indef], [indef], [native abstract indefinites])
359         OG_MULTIARG_ITEM([gmp], [GMP], [GNU multiprecision library])
360         OG_MULTIARG_ITEM([mpfr], [MPFR], [Multiprecision Floats with correct Rounding])
361         OG_MULTIARG_ITEM([mpc], [MPC], [Multiprecision Complex numbers (C/R)])
362         OG_MULTIARG_ITEM([pseug], [pseudoG], [native Gaussian Numbers (Z+Z)])
363         OG_MULTIARG_ITEM([pseuc], [pseudoC], [native Complex Numbers (C/R)])
364         OG_MULTIARG_ITEM([quatern], [Quaternions], [native Quaternions (Z+Z+Z+Z)])
365         OG_MULTIARG_ITEM([ecm], [ECM], [factorisations per Elliptic Curve Method])
366         OG_MULTIARG_MUTEX([mpz], [Arbitrary precision integers], [gmp mp])
367         OG_MULTIARG_MUTEX([complex], [Complex numbers as in C/R], [mpc pseuc])
368 ])
369
370 OG_MULTIARG_WITH([ase], [dnl
371         AS_HELP_STRING([--with-ase], [
372                 Compile in support for algebraic structures based on ENT,
373                 using internal and external libraries.])],
374         [none], [none], [dnl
375         OG_MULTIARG_ITEM([cart], [cartesian], [Cartesian Products of ENT and ASE objects])
376         OG_MULTIARG_ITEM([dig], [digraph], [Directed 2-ary Graphs with Colours])
377         OG_MULTIARG_ITEM([intv], [interval], [Intervals of comparable or normed ENT and ASE objects])
378         OG_MULTIARG_ITEM([metric], [metric], [Metric Spaces])
379         OG_MULTIARG_ITEM([nbhood], [neighbourhood], [Neighbourhoods of comparable or normed ENT and ASE objects])
380         OG_MULTIARG_ITEM([perm], [permutation], [Permutations])
381         OG_MULTIARG_ITEM([resclass], [resclass], [Residue Class Rings and Classes])
382 ])
383
384 OG_ARG_WITH([compre],
385         AS_HELP_STRING([--with-compre],[
386                 Provide exhaustive caching of compiled regexps. This will
387                 mean that frequently used regexps will be faster to use
388                 since the compile step will not be needed after first use.]),
389         [yes], [By default do cache compiled regexps.])
390
391 OG_MULTIARG_WITH([experimental-features], [dnl
392         AS_HELP_STRING([--with-experimental-features], [
393                 Activate experimental code, that is code which is
394                 considered useful but whose effects in conjunction with
395                 the variety of elisp projects cannot be foreseen.])
396         AS_HELP_STRING([], [
397                 During the beta phase of SXEmacs all experimental code
398                 will be unconditionally enabled.  However, if you plan
399                 to use this SXEmacs in a production environment you
400                 can switch off some portions.])],
401         [all nobdwgc], [ALL but bdwgc], [dnl
402         OG_MULTIARG_ITEM([bdwgc], [bdwgc], [the Boehm-Demers-Weiser collector])
403         OG_MULTIARG_ITEM([asyneq], [asyneq], [asynchronous event queues])
404 ])
405         dnl stop that pom stuff
406         dnl OG_MULTIARG_ITEM([pom], [pom], [thread-safe objects])
407
408 OG_ARG_WITH([event-driver],
409         AS_HELP_STRING([--with-event-driver], [
410                 Which event routines to use.
411                 Events control the way how external `sources' are
412                 incorporated into SXEmacs.  Sources hereby are user inputs,
413                 such as key strokes, mouse moves, pedalling, slapping the
414                 monitor, etc.; but there are manifold further sources, such as
415                 process signals, data on a socket, focussing an X window,
416                 lapsing a timeout, and so forth.])
417 AS_HELP_STRING([], [
418                 An event driver can cope with all (or most) of these in a
419                 uniform and abstract way.  SXEmacs can either be driven
420                 using its built-in event handlers, or using one of the
421                 external systems.]),
422         [auto], [Autodetect], [auto built-in libevent liboop glib])
423
424
425 dnl Debugging Options
426 dnl ================
427 OG_OPTION_GROUP(Debugging Options)
428
429 OG_ARG_WITH([debug],
430         AS_HELP_STRING([--with-debug],
431                 [Compile with extra debugging code.
432                 This will turn on: --with-assertions
433                 and --with-memory-usage-stats.]),
434         [yes], [YES for beta; NO for release])
435
436 OG_ARG_WITH([memory-usage-stats],
437         AS_HELP_STRING([--with-memory-usage-stats],
438                 [Compile with support for statistics about memory usage at runtime.]),
439         [yes], [YES for beta])
440
441 OG_MULTIARG_WITH([error-checking], [dnl
442         AS_HELP_STRING([--with-error-checking=TYPE], [
443                 Compile with internal error-checking added.])
444         AS_HELP_STRING([], [
445                 WARNING: Causes noticeable loss of speed!])],
446         [all], [ALL for beta; NONE otherwise], [dnl
447         OG_MULTIARG_ITEM([extents], [extents], [checks on extents])
448         OG_MULTIARG_ITEM([types], [types], [checks on types])
449         OG_MULTIARG_ITEM([gc], [gc], [checks on garbage collection])
450         OG_MULTIARG_ITEM([malloc], [malloc], [checks on memory allocation])
451         OG_MULTIARG_ITEM([byte_code], [byte_code], [checks on byte compiled code])
452         OG_MULTIARG_ITEM([bufpos], [bufpos], [checks on buffer position])
453         OG_MULTIARG_ITEM([glyphs], [glyphs], [checks on glyph data])
454         OG_MULTIARG_ITEM([stack], [stack], [checks on stack barriers])
455         OG_MULTIARG_ITEM([malldbg], [malldbg], [malloc debugging code])
456 ])
457
458 OG_ARG_WITH([purify],
459         AS_HELP_STRING([--with-purify],
460                 [Add support for memory debugging using Purify.]),
461         [no], [NO])
462
463 OG_ARG_WITH([quantify],
464         AS_HELP_STRING([--with-quantify],
465                 [Add support for performance debugging using Quantify.]),
466         [no], [NO])
467
468
469 dnl Window System Features
470 dnl ======================
471 OG_OPTION_GROUP(Window System Features)
472
473 OG_ARG_WITH([toolbars],
474         AS_HELP_STRING([--with-toolbars],
475                 [Compile in toolbar support.]),
476         [yes], [YES])
477
478 OG_ARG_WITH([external-widget],
479         AS_HELP_STRING([--with-external-widget],
480                 [Enable the "external widget" interface,
481                 which allows a SXEmacs frame to appear as a widget in
482                 another application.
483                 To date, we haven't heard of anyone who has actually done this.
484                 Consider this EXPERIMENTAL.]),
485         [no], [NO])
486
487 OG_ARG_WITH([menubars],
488         AS_HELP_STRING([--with-menubars=TYPE],
489                 [Type of menubars to use.  The Lucid menubars emulate
490                 Motif (mostly) but are faster.]),
491         [lucid], [Lucid], [lucid no])
492
493 OG_ARG_WITH([scrollbars],
494         AS_HELP_STRING([--with-scrollbars=TYPE],
495                 [Type of scrollbars to use.
496                 *WARNING*  The Motif scrollbars are currently broken.]),
497         [lucid], [Lucid], [lucid motif athena no])
498
499 OG_ARG_WITH([dialogs],
500         AS_HELP_STRING([--with-dialogs=TYPE],
501                 [Type of dialog boxes to use.  Athena dialogs will
502                  be used if Athena can be found.]),
503         [athena], [], [athena motif no])
504
505 OG_ARG_WITH([widgets],
506         AS_HELP_STRING([--with-widgets=TYPE],
507                 [Type of native widgets to use.  Athena widgets will
508                 be used if Athena can be found.]),
509         [athena], [], [athena motif no])
510
511 OG_ARG_WITH([athena],
512         AS_HELP_STRING([--with-athena=TYPE],
513                 [Type of Athena widgets to use.]),
514         [auto], [Autodetect], [auto xaw 3d next 95 xpm no])
515
516 OG_ARG_WITH([xim],
517         AS_HELP_STRING([--with-xim],
518                 [Type of Mule input method to use.]),
519         [auto], [Autodetect], [yes no xlib motif])
520
521 OG_ARG_WITH([wmcommand],
522         AS_HELP_STRING([--with-wmcommand],
523                 [Compile with realized leader window which will
524                 keep the WM_COMMAND property.]),
525         [yes], [YES])
526
527 OG_ARG_WITH([xmu],
528         AS_HELP_STRING([--with-xmu],
529                 [For those unfortunates whose vendors don't ship Xmu.]),
530         [auto], [Autodetect])
531
532 OG_ARG_WITH([xfs],
533         AS_HELP_STRING([--with-xfs],
534                 [Compile with XFontSet support for internationalized
535                 menubar.  Incompatible with `--with-xim=motif'.
536                 `--with-menubars=lucid' (the default) is desirable.]),
537         [no], [NO])
538
539 dnl TTY Options
540 dnl ================
541 OG_OPTION_GROUP(TTY options)
542
543 OG_ARG_WITH([tty],
544         AS_HELP_STRING([--with-tty],
545                 [Add support for ttys.]),
546         [auto], [Autodetect])
547
548 OG_ARG_WITH([ncurses],
549         AS_HELP_STRING([--with-ncurses],
550                 [Use the ncurses library for tty support.]),
551         [auto], [Autodetect])
552
553 OG_ARG_WITH([curses],
554         AS_HELP_STRING([--with-curses],
555                 [Use the curses library for tty support.]),
556         [auto], [Autodetect])
557
558 OG_ARG_WITH([terminfo],
559         AS_HELP_STRING([--with-terminfo],
560                 [Use the terminfo library for tty support.]),
561         [auto], [Autodetect])
562
563 OG_ARG_WITH([tinfo],
564         AS_HELP_STRING([--with-tinfo],
565                 [Use the ncurses tinfo library for tty support.]),
566         [auto], [Autodetect])
567
568 OG_ARG_WITH([termlib],
569         AS_HELP_STRING([--with-termlib],
570                 [Use the termlib library for tty support.]),
571         [auto], [Autodetect])
572
573 OG_ARG_WITH([termcap],
574         AS_HELP_STRING([--with-termcap],
575                 [Use the termcap library for tty support.]),
576         [auto], [Autodetect])
577
578 OG_ARG_WITH([builtin-tty],
579         AS_HELP_STRING([--with-builtin-tty],
580                 [Use builtin termcap like code. LEGACY CODE. Please consider
581                 installing ncurses. Requires /etc/termcap or TERMCAP
582                 environment variable to work.]),
583         [no], [No])
584
585
586 OG_ARG_WITH([gpm],
587         AS_HELP_STRING([--with-gpm],
588                 [Compile in GPM mouse support for ttys.]),
589         [auto], [Autodetect])
590
591
592 dnl Database Options
593 dnl ================
594 OG_OPTION_GROUP(Database options)
595
596 OG_MULTIARG_WITH([database], [dnl
597         AS_HELP_STRING([--with-database=TYPE],
598                 [Compile with database support.])],
599         [auto], [Autodetect], [dnl
600         OG_MULTIARG_ITEM([berkdb], [berkdb], [Berkeley DB support])
601         OG_MULTIARG_ITEM([dbm], [dbm], [DBM database support])
602         OG_MULTIARG_ITEM([gdbm], [gdbm], [GNU DBM support])
603 ])
604
605 OG_ARG_WITH([ldap],
606         AS_HELP_STRING([--with-ldap],
607                 [Compile with support for the LDAP protocol.]),
608         [no], [NO])
609
610 OG_ARG_WITH([postgresql],
611         AS_HELP_STRING([--with-postgresql],
612                 [Compile with support for the PostgreSQL RDBMS.]),
613         [yes], [Autodetect])
614
615
616 dnl Multimedia Options
617 dnl ==================
618 OG_OPTION_GROUP(Multimedia options)
619
620 OG_MULTIARG_WITH([image], [dnl
621         AS_HELP_STRING([--with-image=TYPE],
622                 [Compile with image support.])],
623         [auto], [Autodetect all image support], [dnl
624         OG_MULTIARG_ITEM([gif], [GIF], [GIF image format])
625         OG_MULTIARG_ITEM([xpm], [XPM], [X PixMap image format])
626         OG_MULTIARG_ITEM([png], [PNG], [Portable Network Graphic format])
627         OG_MULTIARG_ITEM([jpeg], [JPEG], [jpeg image format])
628         OG_MULTIARG_ITEM([tiff], [TIFF], [TIFF image format])
629         OG_MULTIARG_ITEM([xface], [xface], [base64 encoded xbm])
630 ])
631
632 OG_MULTIARG_WITH([sound], [dnl
633         AS_HELP_STRING([--with-sound=TYPE],
634                 [Compile with sound support.])],
635         [auto], [Autodetect all sound support], [dnl
636         OG_MULTIARG_ITEM([alsa], [ALSA], [kernel-based linux sound standard])
637         OG_MULTIARG_ITEM([ao], [ao], [generic audio output layer])
638         OG_MULTIARG_ITEM([esd], [ESD], [Enlightenment Sound Daemon])
639         OG_MULTIARG_ITEM([jack], [Jack], [a low-latency audio server])
640         OG_MULTIARG_ITEM([nas], [NAS], [Network Audio System])
641         OG_MULTIARG_ITEM([oss], [OSS], [Open Sound System])
642         OG_MULTIARG_ITEM([pulse], [PulseAudio], [PulseAudio Sound Server])
643 ])
644
645 OG_MULTIARG_WITH([media], [dnl
646         AS_HELP_STRING([--with-media=TYPE],
647                 [Compile with media stream support.])],
648         [auto], [Autodetect all media stream support libraries], [dnl
649         OG_MULTIARG_ITEM([ffmpeg], [FFmpeg], [media streams handled by ffmpeg])
650         OG_MULTIARG_ITEM([internal], [internal], [media streams handled internally])
651         OG_MULTIARG_ITEM([mad], [Mad], [media streams handled by mad])
652         OG_MULTIARG_ITEM([sndfile], [sndfile], [media streams handled by sndfile])
653         OG_MULTIARG_ITEM([sox], [SoX], [media streams handled by sox])
654         OG_MULTIARG_ITEM([magic], [magic], [file/libmagic support])
655 ])
656
657
658 dnl Cryptography Options
659 dnl ====================
660 OG_OPTION_GROUP(Cryptography options)
661
662 OG_ARG_WITH([openssl],
663         AS_HELP_STRING([--with-openssl],
664                 [Compile in experimental support for
665                 OpenSSL libcrypto and libssl.]),
666         [yes], [YES])
667
668 OG_ARG_WITH([gnutls],
669         AS_HELP_STRING([--with-gnutls],
670                 [Compile in experimental support for
671                 GnuTLS transport security.]),
672         [no], [NO])
673
674
675 dnl Networking Options
676 dnl ==================
677 OG_OPTION_GROUP(Networking options)
678
679 OG_ARG_WITH([dnet],
680         AS_HELP_STRING([--with-dnet],
681                 [Compile with support for DECnet.]),
682         [no], [NO])
683
684 OG_ARG_WITH([socks],
685         AS_HELP_STRING([--with-socks],
686                 [Compile with support for SOCKS (an Internet proxy).]),
687         [auto], [Autodetect])
688
689 OG_ARG_WITH([ipv6-cname],
690         AS_HELP_STRING([--with-ipv6-cname],
691                 [Try IPv6 information first when canonicalizing host names.
692                 This option has no effect unless system supports
693                 getaddrinfo(3) and getnameinfo(3).]),
694         [no], [NO])
695
696 OG_ARG_WITH([pop],
697         AS_HELP_STRING([--with-pop],
698                 [Support POP for mail retrieval.]),
699         [no], [NO])
700
701 OG_ARG_WITH([kerberos],
702         AS_HELP_STRING([--with-kerberos],
703                 [Support Kerberos-authenticated POP.]),
704         [no], [NO])
705
706 OG_ARG_WITH([hesiod],
707         AS_HELP_STRING([--with-hesiod],
708                 [Support Hesiod to get the POP server host.]),
709         [no], [NO])
710
711
712 dnl File-related Options
713 dnl ====================
714 OG_OPTION_GROUP(File-related options)
715
716 OG_ARG_WITH([clash-detection],
717         AS_HELP_STRING([--with-clash-detection],
718                 [Use lock files to detect multiple edits
719                 of the same file.]),
720         [no], [NO])
721
722 OG_ARG_WITH([mail-locking],
723         AS_HELP_STRING([--with-mail-locking=TYPE],
724                 [Specify the locking to be used by movemail to prevent
725                 concurrent updates of mail spool files. Valid types
726                 are `lockf'  `flock'  `file'  `locking'  `pop' or `mmdf'.]),
727         [auto], [Autodetect], [lockf flock file locking mmdf pop no])
728
729
730 dnl Internationalisation Options
731 dnl ============================
732 OG_OPTION_GROUP(Internationalisation options)
733
734 OG_ARG_WITH([mule],
735         AS_HELP_STRING([--with-mule],
736                 [Compile with Mule (MUlti-Lingual Emacs) support
737                 needed to support non-Latin-1 (including Asian)
738                 languages.]),
739         [yes], [YES])
740
741 OG_ARG_WITH([canna],
742         AS_HELP_STRING([--with-canna],
743                 [Compile with support for Canna (a Japanese input method
744                 used in conjunction with Mule support).]),
745         [auto], [Autodetect when Mule is enabled])
746
747 OG_ARG_WITH([wnn],
748         AS_HELP_STRING([--with-wnn],
749                 [Compile with support for Wnn (a multi-language input
750                 method used in conjunction with Mule support).]),
751         [auto], [Autodetect when Mule is enabled])
752
753 OG_ARG_WITH([wnn6],
754         AS_HELP_STRING([--with-wnn6],
755                 [Compile with support for the commercial package Wnn6.]),
756         [auto], [Autodetect when Mule is enabled])
757
758
759
760 dnl dnl Other Options
761 dnl dnl =============
762 dnl OG_OPTION_GROUP(Other options)
763 dnl
764
765 ## -------------------------------------------------------------------------
766 ## Check for users who regularly forget about running autoconf
767 ## -------------------------------------------------------------------------
768 AS_IF([test -f "$0.ac" -a "$0.ac" -nt "$0"],
769    AC_MSG_ERROR([What are you doing? RUN autoreconf NOW!!!]))
770
771 #
772 # Turn off core generation. We are already verifying the program fails, no need
773 # poluting the workspace. Of course if you are a SXEmacs developer you may want
774 # to comemnt this on occasion :-)
775 ulimit -c 0
776
777 ## initialise our nestable msg funs
778 SXE_INIT_MSG_LEVEL
779
780 AC_PROG_SED
781
782 ECHO=echo
783
784 dnl Small snippet to make echo -n work on solaris
785 ECHO_N= ECHO_C=
786 case `echo -n x` in
787 -n*)
788         case `echo 'x\c'` in
789         *c*)
790                 ;;
791         *)
792                 ECHO_C='\c'
793                 ;;
794         esac
795         ;;
796 *)
797         ECHO_N='-n'
798         ;;
799 esac
800
801
802 echo
803 echo "Preparing the build chain"
804 echo "========================="
805
806 ## We should brag about ourselves, no?
807 AC_DEFINE([XEMACS], [1], [Pretend to be an XEmacs])
808 AC_DEFINE([SXEMACS], [1], [Why not? It's the truth!])
809
810 dnl -------------------------------------------------------------------------
811 dnl Command line argument processing.
812 dnl -------------------------------------------------------------------------
813 dnl Check for bogus options
814 dnl -------------------------------------------------------------------------
815 SXE_CHECK_COMMAND_LINE
816
817 AM_INIT_AUTOMAKE([foreign -Wall])
818 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
819 SXE_CHECK_BUILDCHAIN
820 AC_SUBST(EGREP)
821
822 progname=$0
823 progbasename=$(basename $progname)
824 progdirname=$(dirname $progname)
825
826 ## Build Options
827 ## =============
828
829 echo
830 echo "Build and System Specific Options"
831 echo "================================="
832
833 SXE_EXPLORE_BUILD_ENVIRONMENT
834
835 dnl ----------------------------------------
836 dnl Find out which version of SXEmacs this is
837 dnl ----------------------------------------
838 AC_CHECK_PROG([have_git], [git], [yes], [no])
839 AC_MSG_CHECKING([for SXEmacs version])
840 AC_MSG_RESULT([SXEmacs SXEM4CS_VERSION])
841 dnl Must do the following first to determine verbosity for AC_DEFINE
842 AS_IF([test -n "[]SXEM4CS_BETA_P[]"],beta=yes,beta=no)
843 : "${extra_verbose=$beta}"
844
845 AC_MSG_CHECKING([for SXEmacs patchlevel])
846 CURDIR=$(pwd)
847 cd "$sxe_srcdir"
848 AS_IF([test "$have_git" = "yes"], 
849             [sxemacs_git_version=`git describe 2> /dev/null | head -1`])
850 AS_IF([test -z "$sxemacs_git_version"],
851         sxemacs_git_version="[]SXEM4CS_GIT_VERSION[]")
852 AC_MSG_RESULT([$sxemacs_git_version])
853 version="$sxemacs_git_version"
854 cd "$CURDIR"
855 main_version="$sxemacs_git_version"
856 AC_DEFINE_UNQUOTED([EMACS_MAJOR_VERSION], [SXEM4CS_MAJOR_VERSION], [Description here!])
857 AC_DEFINE_UNQUOTED([EMACS_MINOR_VERSION], [SXEM4CS_MINOR_VERSION], [Description here!])
858 old_version=[]SXEM4CS_VERSION[]
859 if test -n "[]SXEM4CS_BETA_VERSION[]"; then
860         AC_MSG_CHECKING([if we are a beta version])
861         if test "$beta" = "yes"; then
862                 AC_MSG_RESULT([yes])
863                 AC_DEFINE_UNQUOTED([EMACS_BETA_VERSION], [SXEM4CS_BETA_VERSION],
864                         [Description here!])
865         else
866                 AC_MSG_RESULT([no])
867                 AC_DEFINE_UNQUOTED([EMACS_PATCH_LEVEL], [SXEM4CS_BETA_VERSION],
868                         [Description here!])
869         fi
870 fi
871 AC_DEFINE_UNQUOTED([SXEMACS_CODENAME], ["[]SXEM4CS_CODENAME[]"], [Description here!])
872 AC_DEFINE_UNQUOTED([EMACS_VERSION], ["$version"], [Description here!])
873 AC_DEFINE_UNQUOTED([SXEMACS_GIT_VERSION], ["$sxemacs_git_version"],
874         [Description here!])
875
876 PROGNAME=sxemacs
877
878 AC_DEFINE_UNQUOTED([EMACS_PROGNAME], ["$PROGNAME"], [Description here!])
879
880 ## build stuff in lib-src unconditionally
881 SXE_APPEND([lib-src], [MAKE_SUBDIR])
882 SXE_APPEND([lib-src], [INSTALL_ARCH_DEP_SUBDIR])
883
884 ## C compiler build chain
885 AC_USE_SYSTEM_EXTENSIONS
886 AC_LANG([C])
887 AS_MESSAGE([Let's look for the entire C build chain])
888 SXE_CHECK_CC
889 SXE_CHECK_CFLAGS
890
891 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
892
893 ## check machine chars
894 AS_MESSAGE([Let's have a detailed glance at your machine])
895 SXE_PROC_CPUID
896 SXE_PROC_VENDORID
897 SXE_NPROCESSORS
898 SXE_CHECK_PROC_GOODNESS
899
900
901 ## Debugging Options
902 ## =================
903 ## echo
904 ## echo "Debugging Options"
905 ## echo "================="
906
907 dnl ----------------------------------
908 dnl Error checking and debugging flags
909 dnl ----------------------------------
910 dnl Error checking default to "yes" in beta versions, to "no" in releases.
911 dnl Same goes for --enable-debug and --extra-verbosity.
912 if test "$with_error_checking_extents" = yes; then
913         have_error_checking_extents="yes"
914         AC_DEFINE([ERROR_CHECK_EXTENTS], [1], [Description here!])
915         AC_DEFINE([USE_ASSERTIONS], [1], [Description here!])
916 fi
917 if test "$with_error_checking_types" = yes; then
918         have_error_checking_types="yes"
919         AC_DEFINE([ERROR_CHECK_TYPECHECK], [1], [Description here!])
920         AC_DEFINE_UNQUOTED([type_checking_assert(assertion)],
921                 [assert (assertion)], [
922                 Make sure that all X... macros are dereferencing the correct type,
923                 and that all XSET... macros (as much as possible) are setting the
924                 correct type of structure.  Highly recommended for all
925                 development work.])
926         AC_DEFINE([USE_ASSERTIONS], [1], [Description here!])
927 else
928         AC_DEFINE_UNQUOTED([type_checking_assert(assertion)], [], [])
929 fi
930 if test "$with_error_checking_bufpos" = yes; then
931         have_error_checking_bufpos="yes"
932         AC_DEFINE([ERROR_CHECK_BUFPOS], [1], [Description here!])
933         AC_DEFINE_UNQUOTED([bufpos_checking_assert(assertion)],
934                 [assert (assertion)], [dnl
935                 Make sure valid buffer positions are passed to BUF_* macros])
936         AC_DEFINE([USE_ASSERTIONS], [1], [Description here!])
937 else
938         AC_DEFINE_UNQUOTED([bufpos_checking_assert(assertion)], [], [])
939 fi
940 if test "$with_error_checking_gc" = yes; then
941         have_error_checking_gc="yes"
942         AC_DEFINE([ERROR_CHECK_GC], [1], [Description here!])
943         AC_DEFINE_UNQUOTED([gc_checking_assert(assertion)],
944                 [assert (assertion)], [dnl
945                 Attempt to catch bugs related to garbage collection
946                 (e.g. not GCPRO'ing)])
947         AC_DEFINE([USE_ASSERTIONS], [1], [Description here!])
948 else
949         AC_DEFINE_UNQUOTED([gc_checking_assert(assertion)], [], [])
950 fi
951 if test "$with_error_checking_malloc" = yes; then
952         have_error_checking_malloc="yes"
953         AC_DEFINE([ERROR_CHECK_MALLOC], [1], [Description here!])
954         AC_DEFINE([USE_ASSERTIONS], [1], [Description here!])
955 fi
956 if test "$with_error_checking_byte_code"  = yes; then
957         have_error_checking_byte_code="yes"
958         AC_DEFINE([ERROR_CHECK_BYTE_CODE], [1], [Description here!])
959         AC_DEFINE([USE_ASSERTIONS], [1], [Description here!])
960 fi
961 if test "$with_error_checking_glyphs" = yes; then
962         have_error_checking_glyphs="yes"
963         AC_DEFINE([ERROR_CHECK_GLYPHS], [1], [Description here!])
964         AC_DEFINE([USE_ASSERTIONS], [1], [Description here!])
965 fi
966
967 dnl enable_debug=yes must be set when error checking is present.  This should be
968 dnl fixed up.
969 dnl with_debug implies other options
970 if test "${with_debug:=$beta}" = "yes"; then
971         with_memory_usage_stats=yes
972         SXE_ADD_CRUFT_OBJS([debug.o])
973         SXE_ADD_CRUFT_OBJS([tests.o])
974         AC_DEFINE([DEBUG_SXEMACS], [1], [Description here!])
975 fi
976 if test "$with_memory_usage_stats" = "yes"; then
977         AC_DEFINE([MEMORY_USAGE_STATS], [1], [Description here!])
978 fi
979
980
981
982 dnl --------------------------------------------------------------
983 dnl $opsys detection complete; defaults depending on $opsys follow
984 dnl --------------------------------------------------------------
985
986
987 dnl --------------------------------------------------------------
988 dnl WooHoo! pdump is ON always and everywhere! --SY.
989 dnl --------------------------------------------------------------
990 with_pdump=yes
991
992 if test "$with_dynamic" != "no"; then
993         case "$opsys" in
994         hpux* | sunos4* )
995                 with_dynamic=no
996                 ;;
997         *)
998                 with_dynamic=yes
999                 ;;
1000         esac
1001 fi
1002 if test "$with_dynamic" = "yes"; then
1003         case "$opsys" in
1004         hpux* | sunos4* | sco5 )
1005                 opsys="${opsys}-shr"
1006                 ;;
1007         decosf* )
1008                 ld_call_shared="-call_shared"
1009                 ;;
1010         darwin* )
1011                 AC_DEFINE([DLSYM_NEEDS_UNDERSCORE], [1], [Description here!])
1012                 if test "x$have_ld_no_pie" != "x"; then
1013                         SXE_PREPEND_LINKER_FLAG([-no_pie], [ld_switch_site])
1014                 fi
1015                 ;;
1016         esac
1017 else dnl "$with_dynamic" = "no"
1018         case "$opsys" in
1019         sol2 )
1020                 echo "Static linking is not supported on Solaris 2."
1021                 echo "Rerun configure without specifying --without-dynamic."
1022                 exit 1
1023                 ;;
1024         linux )
1025                 ld_call_shared="-Bstatic"
1026                 ;;
1027         decosf* )
1028                 ld_call_shared="-non_shared"
1029                 ;;
1030         darwin* )
1031                 AC_DEFINE([DLSYM_NEEDS_UNDERSCORE], [1], [Description here!])
1032                 if test "x$have_ld_no_pie" != "x"; then
1033                         SXE_PREPEND_LINKER_FLAG([-no_pie], [ld_switch_site])
1034                 fi
1035                 ;;
1036         esac
1037 fi
1038
1039 dnl Tools configuration
1040 case "$opsys" in
1041 aix* )
1042         NON_GNU_CC=xlc
1043         ;;      dnl Use xlc by default on AIX
1044 darwin )
1045         RANLIB="ranlib -c"
1046         ;;  dnl Avoid link error in lwlib-config.c
1047         ## this needs rework I think because RANLIB is provided by LT_INIT anyway
1048 esac
1049
1050 stack_trace_eye_catcher=\
1051 `echo ${PROGNAME}_${version}_${ac_cv_build} | sed 'y!@/.-!____!'`
1052 AC_DEFINE_UNQUOTED([STACK_TRACE_EYE_CATCHER], [$stack_trace_eye_catcher],
1053         [Just a very looong string to make traces more readable.])
1054
1055 dnl --------------------------------------------------
1056 dnl Determine the compiler, set up for feature testing
1057 dnl --------------------------------------------------
1058
1059 if test "$with_clash_detection" != "no"; then
1060         AC_DEFINE([CLASH_DETECTION], [1], [Description here!])
1061         SXE_ADD_CRUFT_OBJS([filelock.o])
1062 fi
1063
1064
1065 dnl what exactly do we determine here? and where is it used?
1066 dnl dnl Determine GCC version.
1067 dnl if test "$GCC" = "yes"; then
1068 dnl     AC_RUN_IFELSE([AC_LANG_SOURCE([[
1069 dnl int main ()
1070 dnl {
1071 dnl #if __GNUC__ >= 3
1072 dnl     return 11;
1073 dnl #else
1074 dnl     return 0;
1075 dnl #endif
1076 dnl }]])], [:], [dnl
1077 dnl case "$?" in
1078 dnl 11)
1079 dnl     echo "You appear to be using GCC version 3 or above."
1080 dnl     __GCC3=yes
1081 dnl     ;;
1082 dnl esac], [__GCC3=no])
1083 dnl fi
1084
1085 dnl We don't do AC_PROG_CC for SXEMACS_CC; if we can't trust these people....
1086 : ${SXEMACS_CC:="$CC"}
1087
1088 dnl Figure out what C preprocessor to use.
1089
1090 dnl On Sun systems, people sometimes set up the variable CPP
1091 dnl with a value that is a directory, not an executable at all.
1092 dnl Detect that case, and ignore that value.
1093 test -n "$CPP" -a -d "$CPP" && CPP=
1094
1095 test -n "$NON_GNU_CPP" -a "$GCC" != "yes" -a -z "$CPP" && CPP="$NON_GNU_CPP"
1096
1097 dnl --------------------------------------------------------------------
1098 dnl Compiler feature macros
1099 dnl --------------------------------------------------------------------
1100
1101
1102 dnl --------------------------------------------------------------------
1103 dnl Extract some information from the operating system and machine files
1104 dnl --------------------------------------------------------------------
1105
1106 echo "Extracting information from the machine- and system-dependent headers..."
1107
1108 SXE_CHECK_MACHARCH
1109 SXE_EXTRACT_MACHARCH_INFO
1110
1111 dnl s&m files shouldn't be required to define anything, or even to exist.
1112 dnl So we default SYSTEM_TYPE to the obvious documented standard, `uname -s`,
1113 dnl appropriately emacsulated.
1114 if test -z "$system_type"; then
1115         AC_DEFINE_UNQUOTED([SYSTEM_TYPE],
1116                 ["`uname -s | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`"],
1117                 [Description here!])
1118 fi
1119
1120 dnl If the s&m files don't define a system-specific dumper, simply use pdump.
1121 dnl Sometime in the future, we'll remove all definitions of UNEXEC
1122 dnl from all the s&m files.
1123 test -z "$unexec" && with_pdump=yes
1124
1125 if test "$with_pdump" = "yes"; then
1126         ordinary_link="yes"
1127         ld="${ordinary_ld}"
1128         start_files=
1129         libs_standard=
1130         unexec=
1131         lib_gcc=
1132 fi
1133
1134 dnl dnl For debugging...
1135 dnl SXE_PRINT_VAR([libs_machine libs_system libs_termcap libs_standard
1136 dnl     objects_machine objects_system c_switch_machine c_switch_system
1137 dnl     ld_switch_machine ld_switch_system unexec ld_switch_shared
1138 dnl     ld lib_gcc ld_text_start_addr start_files ordinary_link
1139 dnl     have_terminfo mail_use_flock mail_use_lockf]) && echo ""
1140
1141 dnl bitch at build attempt on win32 machines
1142 case "$opsys" in mingw* | cygwin*)
1143         SXE_DIE("Invalid operation system. Cannot build on win32 machines.")
1144 esac
1145
1146 dnl Non-ordinary link usually requires -lc
1147 test "$ordinary_link" = "no" -a -z "$libs_standard" && libs_standard="-lc"
1148
1149 ## perform compiler specific things
1150 SXE_DO_CC_HACKS
1151 ## machine specific extensions
1152 SXE_CHECK_SIMD_EXTENSIONS
1153
1154 ## some linker flags that might come in handy
1155 SXE_CHECK_LDFLAGS
1156
1157 ## suffices to be defined late, for instance here
1158 SXE_CHECK_PARSER_LEXER
1159
1160 if test "$with_pdump" != "yes"; then
1161         ## GNU ld now defaults to combreloc, which screws up unexec,
1162         ## but not pdump.
1163         ## Note that it's OK if the GNU style long option causes
1164         ## non-GNU ld to barf a usage message, that's often good
1165         ## enough.  Please report it, though.
1166         ## #### Should make this Solaris-friendly.
1167         ## Link with -z nocombreloc for now.
1168         SXE_CHECK_LD_ZFLAG([nocombreloc])
1169         if test "$sxe_cv_ld__z_nocombreloc" = "yes"; then
1170                 SXE_PREPEND_LINKER_FLAG([-z nocombreloc], [ld_switch_site])
1171         fi
1172 fi
1173
1174 dnl Inform compiler that certain flags are meant for the linker
1175 SXE_PROTECT_LINKER_FLAGS(ld_switch_system)
1176 SXE_PROTECT_LINKER_FLAGS(ld_switch_machine)
1177 SXE_PROTECT_LINKER_FLAGS(ld_switch_site)
1178 SXE_PROTECT_LINKER_FLAGS(LDFLAGS)
1179 SXE_PROTECT_LINKER_FLAGS(ld_call_shared)
1180
1181 dnl Add s&m-determined objects to link line
1182 test -n "$objects_machine" && SXE_ADD_CORE_OBJS($objects_machine)
1183 test -n "$objects_system"  && SXE_ADD_CORE_OBJS($objects_system)
1184 test "$with_pdump" = "yes" && SXE_ADD_CORE_OBJS(dumper.o)
1185
1186
1187 dnl Feed s&m crud to src/Makefile
1188
1189 dnl Linux/powerpc needs the following magic for some reason
1190 dnl [Not needed with YellowDog 2.3 and causes link problems with YellowDog 3.0,
1191 dnl the two most popular PowerPC distributions.]
1192 dnl test "$machine$opsys" = "powerpclinux" && start_flags="-T $sxe_srcdir/src/ppc.ldscript"
1193
1194 AC_LANG(C)
1195 if test "$unexec" = "unexaix.o"; then
1196 dnl AIX needs various hacks to make static linking work.
1197   if   test "$with_dynamic" = "no"; then
1198   start_flags="-Wl,-bnso,-bnodelcsect"
1199   test "$GCC" = "yes" && start_flags="-B/bin/ ${start_flags}"
1200   for f in "/lib/syscalls.exp" "/lib/threads.exp"; do
1201     if test -r "$f"; then start_flags="${start_flags},-bI:${f}"; fi
1202   done
1203   for f in "/usr/lpp/X11/bin/smt.exp" "/usr/bin/X11/smt.exp"; do
1204     if test -r "$f"; then start_flags="${start_flags},-bI:${f}"; break; fi
1205   done
1206   AC_CHECK_LIB([c], [terminateAndUnload], [SXE_APPEND(-lC, libs_system)])
1207   fi
1208 elif test -n "$ld_text_start_addr"; then
1209   start_flags="-T $ld_text_start_addr -e __start"
1210 fi
1211 AC_SUBST(start_flags)
1212
1213 AC_SUBST(ld_switch_shared)
1214 AC_SUBST(start_files)
1215 if test "$ordinary_link" = "no" -a "$GCC" = "yes"; then
1216         if test -z "$linker"; then
1217                 linker='$(CC) -nostdlib'
1218                 SXE_APPEND([-nostdlib], [start_flags])
1219         fi
1220         test -z "$lib_gcc" && lib_gcc='`$(CC) -print-libgcc-file-name`'
1221 fi
1222 test "$GCC" != "yes" && lib_gcc=
1223 AC_SUBST(ld)
1224 AC_SUBST(lib_gcc)
1225
1226
1227
1228 ## ---------------------------------------------------------------
1229 ## Add site and system specific flags to compile and link commands
1230 ## ---------------------------------------------------------------
1231
1232 ## compute those site prefixes
1233 SXE_COMPUTE_SITE_PREFIXES
1234 ## compute a LD_RUN_PATH
1235 SXE_COMPUTE_LD_RUN_PATH
1236
1237
1238 ## some header checks
1239 SXE_CHECK_BASIC_HEADERS
1240 ## the very basic c types
1241 SXE_CHECK_BASIC_TYPES
1242
1243 ## for signalling
1244 SXE_CHECK_SIGNALS
1245
1246 AC_CHECK_MEMBERS([struct stat.st_rdev])
1247 AC_CHECK_TYPES([ptrdiff_t])
1248
1249 ## check whether intptr_t is definied in sys/types.h
1250 SXE_CHECK_INTPTR_T
1251
1252 dnl -lm is required for floating point support, among other things
1253 AC_CHECK_FUNC([sin], [], [AC_CHECK_LIB([m], [sin])])
1254
1255
1256 dnl check for Make feature
1257 AC_PROG_MAKE_SET
1258
1259
1260 dnl check for long file names
1261 AC_SYS_LONG_FILE_NAMES
1262 AC_SYS_LARGEFILE
1263 AC_SYS_INTERPRETER
1264 AC_SYS_POSIX_TERMIOS
1265
1266 AC_FUNC_MALLOC
1267 AC_FUNC_MKTIME
1268
1269 dnl See if mkstemp is available
1270 AC_CHECK_FUNCS([mkstemp])
1271
1272 SXE_CHECK_FILE_LOCK
1273
1274 case "$opsys" in decosf*)
1275         AC_CHECK_LIB([pthreads], [cma_open])
1276         AS_IF([test "$ac_cv_lib_pthreads_cma_open" = "yes"],
1277                 c_switch_site="$c_switch_site -threads")
1278         ;;
1279 esac
1280
1281
1282 dnl ----------------------------------------------------------------
1283 dnl Miscellaneous flags
1284 dnl ----------------------------------------------------------------
1285
1286 AC_MSG_CHECKING(whether the -xildoff compiler flag is required)
1287 if   ${CC-cc} '-###' -xildon  no_such_file.c 2>&1 | grep '^[^ ]*/ild ' > /dev/null ; then
1288   if ${CC-cc} '-###' -xildoff no_such_file.c 2>&1 | grep '^[^ ]*/ild ' > /dev/null ;
1289     then AC_MSG_RESULT(no);
1290     else AC_MSG_RESULT(yes); SXE_APPEND_UNDUP(-xildoff, ld_switch_site)
1291   fi
1292   else AC_MSG_RESULT(no)
1293 fi
1294
1295 dnl Link with "-z ignore" on Solaris if supported
1296 if test "$opsys" = "sol2"; then
1297   if test "$os_release" -ge 506; then
1298     AC_MSG_CHECKING(for "-z ignore" linker flag)
1299     case "`ld -h 2>&1`" in
1300       *-z\ ignore\|record* ) AC_MSG_RESULT(yes)
1301         SXE_PREPEND_UNDUP(-z ignore, ld_switch_site) ;;
1302       *) AC_MSG_RESULT(no) ;;
1303     esac
1304   fi
1305 fi
1306
1307 dnl ----------------------------------------------------------------
1308 dnl Check for Unixoid pty/process support.
1309 dnl ----------------------------------------------------------------
1310
1311 dnl There is no "standard" pty allocation method.  Every system is different.
1312 dnl  getpt()  is the preferred pty allocation method on glibc systems.
1313 dnl _getpty() is the preferred pty allocation method on SGI systems.
1314 dnl grantpt(), unlockpt(), ptsname() are defined by Unix98.
1315 AC_CHECK_FUNCS([getpt _getpty grantpt unlockpt ptsname killpg tcgetpgrp])
1316
1317 dnl openpty() is the preferred pty allocation method on BSD and Tru64 systems.
1318 dnl openpty() might be declared in:
1319 dnl - pty.h (Tru64 or Linux)
1320 dnl - libutil.h (FreeBSD)
1321 dnl - util.h (NetBSD)
1322 AC_CHECK_FUNC(openpty, have_openpty=yes, [
1323   AC_CHECK_LIB(util, openpty, have_openpty=yes need_libutil=yes)])
1324 if test "$have_openpty" = "yes"; then
1325   AC_DEFINE([HAVE_OPENPTY], [1], [Description here!])
1326   AC_CHECK_HEADERS(libutil.h util.h, break)
1327   test "$need_libutil" = "yes" && SXE_APPEND(-lutil, libs_system)
1328 fi
1329
1330 dnl Check for system-specific pty header files
1331 dnl Often the TIOCSIG* symbols are hiding there.
1332 case "$opsys" in
1333   dnl HPUX pty.h #defines TRUE and FALSE, so just use ptyio.h there.
1334   hpux*) AC_CHECK_HEADERS(sys/ptyio.h) ;;
1335   *) AC_CHECK_HEADERS(pty.h)
1336      test "$ac_cv_header_pty_h" = "no" && AC_CHECK_HEADERS(sys/pty.h)
1337      ;;
1338 esac
1339
1340 dnl Check for STREAM support functions.
1341 dnl Confusingly, "str" means both "string" and "SysV Streams".
1342 AC_CHECK_HEADERS(stropts.h)
1343 if test "$ac_cv_header_stropts_h" = "yes"; then
1344   AC_CHECK_FUNCS(isastream)
1345   AC_CHECK_HEADERS(strtio.h) dnl TIOCSIGNAL
1346 fi
1347
1348 dnl Check whether the system provides getloadavg().
1349 AC_CHECK_FUNCS(getloadavg)
1350
1351 if test "$ac_cv_func_getloadavg" = "yes"; then
1352   dnl Solaris 8 declares getloadavg() in <sys/loadavg.h>.
1353   dnl glibc 2.2 declares getloadavg() in <stdlib.h>...
1354   dnl   ...if we #define _GNU_SOURCE, which we do.
1355   AC_CHECK_HEADERS(sys/loadavg.h)
1356 else
1357   dnl We define our own getloadavg() using lower level functions.
1358   SXE_ADD_CRUFT_OBJS([getloadavg.o])
1359
1360   dnl Used by getloadavg() - does not require root priveleges
1361   AC_CHECK_LIB(kstat, kstat_open)
1362   AC_CHECK_HEADERS(kstat.h)
1363
1364   dnl Another way to get the load average
1365   AC_CHECK_LIB(kvm, kvm_read)
1366 fi
1367
1368 dnl If netdb.h does not declare h_errno, we must declare it by hand.
1369 AC_MSG_CHECKING(whether netdb declares h_errno)
1370 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
1371   [[return h_errno;]])],
1372   [AC_MSG_RESULT(yes)
1373    AC_DEFINE([HAVE_H_ERRNO], [1], [Description here!])],
1374   [AC_MSG_RESULT(no)])
1375
1376 AC_MSG_CHECKING([for sigsetjmp])
1377 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1378 #include <setjmp.h>
1379         ]], [[
1380 sigjmp_buf bar;
1381 sigsetjmp (bar, 0);
1382         ]])],
1383         [sxe_cv_c_func_sigsetjmp="yes"],
1384         [sxe_cv_c_func_sigsetjmp="no"])
1385 AC_MSG_RESULT([$sxe_cv_c_func_sigsetjmp])
1386 if test "$sxe_cv_c_func_sigsetjmp" = "yes"; then
1387         AC_DEFINE([HAVE_SIGSETJMP], [1], [Description here!])
1388         AC_DEFINE_UNQUOTED([SETJMP(x)], [sigsetjmp (x, 0)], [dnl
1389                 We want to avoid saving the signal mask if possible, because
1390                 that necessitates a system call.])
1391         AC_DEFINE_UNQUOTED([LONGJMP(x, y)], [siglongjmp(x, y)], [dnl
1392                 Description here!])
1393         AC_DEFINE_UNQUOTED([JMP_BUF], [sigjmp_buf], [dnl
1394                 Description here!])
1395 else
1396         AC_DEFINE_UNQUOTED([SETJMP(x)], [setjmp(x)], [dnl
1397                 We want to avoid saving the signal mask if possible, because
1398                 that necessitates a system call.])
1399         AC_DEFINE_UNQUOTED([LONGJMP(x, y)], [longjmp(x, y)], [Description here!])
1400         AC_DEFINE_UNQUOTED([JMP_BUF], [jmp_buf], [Description here!])
1401 fi
1402
1403
1404 AC_MSG_CHECKING(whether localtime caches TZ)
1405 AC_CACHE_VAL(emacs_cv_localtime_cache,
1406 [if test "$ac_cv_func_tzset" = "yes"; then
1407 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
1408 #if STDC_HEADERS
1409 # include <stdlib.h>
1410 #endif
1411 extern char **environ;
1412 unset_TZ ()
1413 {
1414   char **from, **to;
1415   for (to = from = environ; (*to = *from); from++)
1416     if (! (to[[0]][[0]] == 'T' && to[[0]][[1]] == 'Z' && to[[0]][[2]] == '='))
1417       to++;
1418 }
1419 char TZ_GMT0[[]] = "TZ=GMT0";
1420 char TZ_PST8[[]] = "TZ=PST8";
1421 main()
1422 {
1423   time_t now = time ((time_t *) 0);
1424   int hour_GMT0, hour_unset;
1425   if (putenv (TZ_GMT0) != 0)
1426     exit (1);
1427   hour_GMT0 = localtime (&now)->tm_hour;
1428   unset_TZ ();
1429   hour_unset = localtime (&now)->tm_hour;
1430   if (putenv (TZ_PST8) != 0)
1431     exit (1);
1432   if (localtime (&now)->tm_hour == hour_GMT0)
1433     exit (1);
1434   unset_TZ ();
1435   if (localtime (&now)->tm_hour != hour_unset)
1436     exit (1);
1437   exit (0);
1438 }]])], emacs_cv_localtime_cache=no, emacs_cv_localtime_cache=yes,
1439 [# If we have tzset, assume the worst when cross-compiling.
1440 emacs_cv_localtime_cache=yes])
1441 else
1442         # If we lack tzset, report that localtime does not cache TZ,
1443         # since we can't invalidate the cache if we don't have tzset.
1444         emacs_cv_localtime_cache=no
1445 fi],[:])dnl
1446 AC_MSG_RESULT($emacs_cv_localtime_cache)
1447 if test $emacs_cv_localtime_cache = yes; then
1448   AC_DEFINE([LOCALTIME_CACHE], [1], [Description here!])
1449 fi
1450
1451
1452 need_alloca_c=no
1453 dnl HP-UX has a working alloca in libPW.
1454 dnl case "${GCC}${opsys}" in hpux* )
1455 dnl  AC_CHECK_FUNC(alloca, [:], [AC_CHECK_LIB(PW, alloca)])
1456 dnl esac
1457
1458 dnl AC_FUNC_ALLOCA doesn't know about DEC C's #pragma intrinsic(alloca)
1459 if test "$__DECC" != "yes"; then
1460         AC_FUNC_ALLOCA
1461         if test -n "$ALLOCA"; then
1462                 SXE_ADD_CRUFT_OBJS([$ALLOCA])
1463                 need_alloca_c=yes
1464         fi
1465 fi
1466
1467 AC_MSG_CHECKING(for working alloca in function calls)
1468 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1469 #if defined (__GNUC__)
1470 #define alloca __builtin_alloca
1471 #elif defined (__DECC)
1472 #include <alloca.h>
1473 #pragma intrinsic(alloca)
1474 #elif defined (HAVE_ALLOCA_H)
1475 #include <alloca.h>
1476 #elif defined (_AIX)
1477 #pragma alloca
1478 #elif ! defined (alloca)
1479 #ifdef C_ALLOCA
1480 #define alloca xemacs_c_alloca
1481 #else
1482 void *alloca ();
1483 #endif /* C_ALLOCA */
1484 #endif /* !defined (alloca) */
1485
1486 void
1487 f1 (double a, void *ptr, int b)
1488 {
1489   unsigned char *ptr2 = (unsigned char *) ptr;
1490   if (ptr2[[0]] != 0xBF || ptr2[[1]] != 0xBF || ptr2[[3000]] != 0xBF)
1491     exit (1);
1492   if (a != 3.1415 || b != -5490)
1493     exit (1);
1494 }
1495
1496 int
1497 f2 (short c, void *ptr, long e)
1498 {
1499   unsigned char *ptr2 = (unsigned char *) ptr;
1500   if (ptr2[[0]] != 0xFB || ptr2[[1]] != 0xFB || ptr2[[1000]] != 0xFB)
1501     exit (1);
1502   if (c != 665 || e != 776776776)
1503     exit (1);
1504   f1 (3.1415, memset (alloca (3001), 0xBF, 3001), -5490);
1505   return 42;
1506 }
1507
1508 int
1509 main (int argc, char *argv[])
1510 {
1511   if (f2 (665, memset (alloca (1001), 0xFB, 1001), 776776776) != 42)
1512     return 1;
1513   return 0;
1514 }
1515 ]])], working_alloca_in_function_calls=yes, working_alloca_in_function_calls=no,
1516 working_alloca_in_function_calls=no)
1517 AC_MSG_RESULT($working_alloca_in_function_calls)
1518 test "$working_alloca_in_function_calls" != "yes" && \
1519   AC_DEFINE([BROKEN_ALLOCA_IN_FUNCTION_CALLS], [1], [Description here!])
1520
1521 AM_CONDITIONAL([NEED_ALLOCA_C], [
1522         test "$working_alloca_in_function_calls" = "yes" && \
1523         test "$need_alloca_c" = "yes"])
1524
1525 dnl Check whether strcoll exists and works correctly. (This does more
1526 dnl than just check for its existence.) If so, it defines HAVE_STRCOLL.
1527 AC_FUNC_STRCOLL
1528
1529 dnl If `getpgrp' takes no argument (the POSIX.1 version), define
1530 dnl `GETPGRP_VOID'.  Otherwise, it is the BSD version, which takes a
1531 dnl process ID as an argument.
1532 AC_CHECK_FUNCS(getpgrp)
1533 AC_FUNC_GETPGRP
1534
1535 dnl We used to call AC_FUNC_MMAP here
1536 dnl Instead we now use following, suggested by Neal Becker
1537 AC_MSG_CHECKING(for working mmap)
1538 case "$opsys" in ultrix* ) have_mmap=no ;; *)
1539 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
1540 #include <unistd.h>
1541 #include <fcntl.h>
1542 #include <sys/mman.h>
1543
1544 #ifndef MAP_VARIABLE
1545 #define MAP_VARIABLE 0
1546 #endif
1547
1548 #ifndef MAP_FAILED
1549 #define MAP_FAILED -1
1550 #endif
1551
1552 int main (int argc, char *argv[])
1553 {
1554   int fd = -1;
1555   caddr_t p;
1556 #ifndef MAP_ANONYMOUS
1557   fd = open ("/dev/zero", O_RDWR);
1558   if (fd < 0)
1559     return 1;
1560 #define MAP_ANONYMOUS 0
1561 #endif
1562   if (mmap(0, 1024, PROT_READ | PROT_WRITE,
1563            MAP_PRIVATE | MAP_VARIABLE | MAP_ANONYMOUS,
1564            fd, 0) != (void *) MAP_FAILED)
1565     return 0;
1566   perror ("conftest: mmap failed");
1567   return 1;
1568 }]])], have_mmap=yes, have_mmap=no, have_mmap=no) ;;
1569 esac
1570 AC_MSG_RESULT($have_mmap)
1571 test "$have_mmap" = "yes" && AC_DEFINE([HAVE_MMAP], [1], [Description here!])
1572
1573 dnl rel_alloc requires either GNU malloc or system malloc with mmap
1574 dnl We only turn rel_alloc on by default if mmap is available.
1575 test "$GNU_MALLOC" != "yes" -a "$have_mmap" != "yes" && with_rel_alloc=no
1576 if test "$with_rel_alloc $have_mmap" = "default yes"; then
1577         if test "$doug_lea_malloc" = "yes"; then
1578                 dnl Check if malloc() calls mmap(), making rel_alloc pointless.
1579                 AC_MSG_CHECKING(for M_MMAP_THRESHOLD)
1580                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]],[[
1581 #ifndef M_MMAP_THRESHOLD
1582 #error No M_MMAP_THRESHOLD :-(
1583 !@+$%^&*_)(_ - unlikely to compile...
1584 #endif
1585                         ]])], [
1586                         with_rel_alloc=no
1587                         AC_MSG_RESULT(yes)], [
1588                         with_rel_alloc=yes
1589                         AC_MSG_RESULT(no)])
1590         else
1591                 with_rel_alloc=yes
1592         fi
1593 fi
1594 if test "$with_rel_alloc" = "yes"; then
1595         AC_DEFINE([REL_ALLOC], [1], [Description here!])
1596         SXE_ADD_MEMALLOC_OBJS(ralloc.o)
1597 fi
1598
1599 dnl Check for tests/rminal I/O variants
1600 dnl TERMIOS systems may have termio.h, but not vice-versa, I think.
1601 AC_CHECK_HEADER(termios.h,
1602   AC_DEFINE([HAVE_TERMIOS], [1], [Description here!])
1603   AC_DEFINE([SIGNALS_VIA_CHARACTERS], [1], [Description here!])
1604   AC_DEFINE([NO_TERMIO], [1], [Description here!]),
1605   [AC_CHECK_HEADER(termio.h, [AC_DEFINE([HAVE_TERMIO], [1], [Description here!])])])
1606
1607
1608 dnl Check for directory variants
1609 AC_CHECK_HEADER(dirent.h, [AC_DEFINE([SYSV_SYSTEM_DIR], [1], [Description here!])],
1610   [AC_CHECK_HEADER(sys/dir.h, , [AC_DEFINE([NONSYSTEM_DIR_LIBRARY], [1], [Description here!])])])
1611
1612 dnl check for readdir64_r (the reentrant version of readdir64)
1613 AC_CHECK_FUNC(readdir64_r, [AC_DEFINE([HAVE_LARGEFILE], [1], [Description here!])])
1614
1615 dnl Check for nlist.h
1616 AC_CHECK_HEADER([nlist.h], [AC_DEFINE([NLIST_STRUCT], [1], [Description here!])], [])
1617
1618 dnl firstly check for pthread support so that we can use the
1619 dnl asynchronous playing routines
1620
1621 dnl special pthread handling
1622 dnl AIX uses pthreads instead of pthread, and HP/UX uses cma
1623 dnl FreeBSD uses -pthread
1624 AC_CHECK_LIB(pthread, pthread_create)
1625 if test "${ac_cv_lib_pthread_pthread_create}" = "yes"; then
1626         have_threads=yes
1627
1628         SXE_CHECK_COMPILER_FLAGS([-pthreads])
1629         SXE_CHECK_COMPILER_FLAGS([-pthread])
1630         if test "${sxe_cv_c_flags__pthreads}" = "yes"; then
1631                 SXE_PREPEND_UNDUP([-pthreads], [c_switch_site])
1632         fi
1633         if test "${sxe_cv_c_flags__pthread}" = "yes"; then
1634                 SXE_PREPEND_UNDUP([-pthread], [c_switch_site])
1635         fi
1636         SXE_PREPEND([-lpthread], [MM_LIBS])
1637 fi
1638
1639 dnl test for AIX pthreads
1640 AC_CHECK_LIB(pthreads, pthread_create)
1641 if test $ac_cv_lib_pthreads_pthread_create = yes; then
1642   have_threads=yes
1643   SXE_PREPEND(-lpthreads, MM_LIBS)
1644 fi
1645
1646 dnl test for HPUX cma threads.
1647 AC_CHECK_LIB(cma, pthread_create)
1648 if test $ac_cv_lib_cma_pthread_create = yes; then
1649   have_threads=yes
1650   SXE_PREPEND(-lcma, MM_LIBS)
1651 fi
1652
1653 dnl FreeBSD -pthread check
1654 AC_DEFUN([AC_PTHREAD_FREEBSD],
1655 [AC_MSG_CHECKING([if we need -pthread for threads])
1656 AC_CACHE_VAL(ac_cv_ldflag_pthread,
1657         [ac_save_ld_switch_site="$ld_switch_site"
1658         ld_switch_site="-pthread $ld_switch_site"
1659         AC_LINK_IFELSE([AC_LANG_PROGRAM([[char pthread_create();]],
1660         [[char pthread_create();]])],
1661         eval "ac_cv_ldflag_pthread=yes",
1662         eval "ac_cv_ldflag_pthread=no"),
1663         ld_switch_site="$ac_save_ld_switch_site"
1664 ])
1665 if eval "test \"`echo $ac_cv_ldflag_pthread`\" = yes"; then
1666         AC_MSG_RESULT(yes)
1667         have_threads=yes
1668         SXE_PREPEND_UNDUP("-pthread", ld_switch_site)
1669         SXE_PREPEND_UNDUP("-D_THREAD_SAFE", c_switch_site)
1670 else
1671         AC_MSG_RESULT(no)
1672 fi])
1673
1674 dnl If all other thread tests fail, try BSD's -pthread
1675 if test "$have_threads" != yes; then
1676   AC_PTHREAD_FREEBSD
1677 fi
1678
1679 if test "$have_threads" = yes; then
1680   AC_DEFINE([HAVE_THREADS], [1], [Description here!])
1681 fi
1682
1683
1684 ## Internal Options
1685 ## ================
1686
1687 echo
1688 echo "Internal Options"
1689 echo "================"
1690
1691 SXE_CHECK_LIBTOOL
1692 SXE_CHECK_LIBLTDL
1693
1694 dnl ----------------------------------------------------------------
1695 dnl Check for POSIX functions.
1696 dnl ----------------------------------------------------------------
1697
1698 SXE_CHECK_BASIC_FUNS
1699 AC_CHECK_FUNCS([alarm cbrt closedir dup2 eaccess endpwent floor fmod fpathconf frexp fsync ftime ftruncate getaddrinfo getcwd gethostbyname gethostname getnameinfo getpagesize getrlimit gettimeofday getwd isascii isatty link logb lrand48 matherr memchr memmove memset mkdir mktime munmap perror poll pow putenv random re_comp readlink regcomp rename res_init rint rmdir select setitimer setlocale setpgid setsid sigblock sighold sigprocmask snprintf socket sqrt stpcpy strncpy strncat strcasecmp strchr strdup strerror strlwr strrchr strspn strtol strupr symlink ttyname tzset ulimit umask uname usleep utime vlimit vsnprintf waitpid wcscmp wcslen])
1700
1701 AS_IF([test "$have_isatty" = "yes"],
1702         AC_DEFINE([HAVE_ISATTY], [1], [isatty is available]))
1703 AS_IF([test "$have_ttyname" = "yes"],
1704         AC_DEFINE([HAVE_TTYNAME], [1], [ttyname is available]))
1705
1706
1707 ## combines all these time structures and funs
1708 SXE_CHECK_METRONOME
1709 SXE_CHECK_SUFFICIENCY([metronome], [metronome])
1710
1711 ## check for a sane dirname/realpath
1712 SXE_CHECK_DIRNAME
1713 SXE_CHECK_REALPATH
1714
1715 dnl -----------------------------------
1716 dnl Do some misc autoconf-special tests
1717 dnl -----------------------------------
1718
1719 dnl Do the opsystem or machine files prohibit the use of the GNU malloc?
1720 dnl Assume not, until told otherwise.
1721 GNU_MALLOC=yes
1722 if test "$with_dlmalloc" != "no"; then
1723         doug_lea_malloc=yes
1724 else
1725         doug_lea_malloc=no
1726 fi
1727 after_morecore_hook_exists=yes
1728 AC_CHECK_FUNC(malloc_set_state, ,doug_lea_malloc=no)
1729 AC_MSG_CHECKING(whether __after_morecore_hook exists)
1730 AC_LINK_IFELSE([AC_LANG_SOURCE([[extern void (* __after_morecore_hook)();],[__after_morecore_hook = 0]])],
1731   [AC_MSG_RESULT(yes)],
1732   [AC_MSG_RESULT(no)
1733    after_morecore_hook_exists=no])
1734 if test "$system_malloc" = "yes" ; then
1735   GNU_MALLOC=no
1736   GNU_MALLOC_reason="
1737     - The GNU allocators don't work with this system configuration."
1738 elif test "$with_system_malloc" = "yes" ; then
1739   GNU_MALLOC=no
1740   GNU_MALLOC_reason="
1741     - User chose not to use GNU allocators."
1742 elif test "$with_debug_malloc" = "yes" ; then
1743   GNU_MALLOC=no
1744   GNU_MALLOC_reason="
1745     - User chose to use Debugging Malloc."
1746 fi
1747
1748 if test "$doug_lea_malloc" = "yes" -a "$GNU_MALLOC" = "yes" ; then
1749         GNU_MALLOC_reason="
1750     - Using Doug Lea's new malloc from the GNU C Library."
1751         AC_DEFINE([DOUG_LEA_MALLOC], [1], [Description here!])
1752         if test "$after_morecore_hook_exists" = "no" ; then
1753                 GNU_MALLOC_reason="
1754     - Using Doug Lea's new malloc from the Linux C Library."
1755         AC_DEFINE([_NO_MALLOC_WARNING_], [1], [Description here!])
1756         fi
1757 fi
1758 AM_CONDITIONAL([USE_MEMALLOC], [test -n "${libmemalloc_objs}"])
1759
1760 dnl #### mcheck is broken in all versions of Linux libc and glibc.
1761 dnl Try this again when 2.1 hits the streets.
1762 dnl Avoid using free-hook.c if support exists for malloc debugging in libc
1763 have_libmcheck=no
1764 if test "$with_error_checking_malloc" = "yes" -a \
1765    "$have_glibc" = "yes" -a \
1766    "$doug_lea_malloc" = "yes"; then
1767         AC_CHECK_HEADERS(mcheck.h)
1768         AC_CHECK_LIB(mcheck, mcheck, [have_libmcheck=yes], [have_libmcheck=no])
1769 fi
1770
1771 if test "$with_module_support" != "no"; then
1772         AS_MESSAGE([checking for module support])
1773         if test "$sxe_cv_feat_libltdl" = "yes"; then
1774                 have_module_support="yes"
1775                 with_module_support="yes"
1776                 SXE_ADD_CRUFT_OBJS([emodules-ng.o])
1777                 AC_DEFINE([HAVE_EMODULES], [1], [Whether emods would be available])
1778                 AC_DEFINE([WITH_EMODULES], [1], [Whether emods shall be available])
1779         else
1780                 have_module_support="no"
1781                 AC_DEFINE([WITH_EMODULES], [1], [Whether emods shall be available])
1782         fi
1783 fi
1784
1785 AM_CONDITIONAL([DESCEND_MODULES],
1786         [test "$with_module_support $have_module_support" = "yes yes"])
1787 if test "$with_module_support $have_module_support" = "yes"; then
1788         SXE_APPEND([src], [MAKE_SUBDIR])
1789         SXE_APPEND([src], [INSTALL_ARCH_DEP_SUBDIR])
1790         SXE_APPEND([modules], [MAKE_AM_SUBDIR])
1791         SXE_APPEND([modules], [SRC_SUBDIR_DEPS])
1792 dnl else
1793 dnl     MOD_CC="$SXEMACS_CC"
1794 dnl     MODCFLAGS="\$(SXE_CFLAGS) -I../../src -I\$(sxe_srcdir)/../../src"
1795 dnl     INSTALLPATH=""
1796 dnl     MOD_INSTALL_PROGRAM="true"
1797 dnl     OBJECT_TO_BUILD="\$(MODNAME).o"
1798 fi
1799
1800 if test "$with_modules_ase" = "yes"; then
1801         have_modules_ase=yes
1802 fi
1803 if test "$with_static_modules_ase" = "yes"; then
1804         have_static_modules_ase=yes
1805 fi
1806 SXE_EMOD_STATMOD([ase])
1807 if test "$have_modules_ase $have_static_modules_ase" != " "; then
1808         have_ase_cart="yes"
1809         have_ase_dig="yes"
1810         have_ase_intv="yes"
1811         have_ase_metric="yes"
1812         have_ase_nbhood="yes"
1813         have_ase_perm="yes"
1814         have_ase_resclass="yes"
1815 fi
1816 if test "$have_bison" = "yes"; then
1817         if test "$with_modules_cl" = "yes" ; then
1818                 have_modules_cl="yes"
1819         fi
1820         if test "$with_static_modules_cl" = "yes"; then
1821                 have_static_modules_cl="yes"
1822         fi
1823 else
1824         if test "$with_modules_cl" = "yes" -o "$with_static_modules_cl" = "yes"; then
1825                 AC_MSG_WARN([Sorry no bison means no cl module for you.])
1826         fi
1827 fi
1828
1829 SXE_EMOD_STATMOD([cl])
1830
1831 dnl D-Bus
1832 dnl SXE_CHECK_DBUS
1833 dnl if test "$have_dbus" = "yes"; then
1834 dnl     if test "$with_modules_dbus" = "yes"; then
1835 dnl             have_modules_dbus=yes
1836 dnl     fi
1837 dnl     if test "$with_static_modules_dbus" = "yes"; then
1838 dnl             have_static_modules_dbus=yes
1839 dnl     fi
1840 dnl else
1841 dnl     AC_MSG_WARN([I cannot believe you do not have d-bus.])
1842 dnl fi
1843
1844 dnl SXE_EMOD_STATMOD([dbus])
1845
1846 AM_CONDITIONAL([AUTARKIC], [test "0" = "1"])
1847 MODARCHDIR=
1848 MAKE_DOCFILE="$sxe_blddir/lib-src/make-docfile"
1849 ELLMAKEDOC=$MAKE_DOCFILE
1850 ELLCC=$MOD_CC
1851 AC_SUBST(ELLCC)
1852 AC_SUBST(ELLMAKEDOC)
1853 AC_SUBST(with_modules, $with_modules)
1854 AC_SUBST(MOD_CC)
1855 AC_SUBST(MODARCHDIR)
1856 AC_SUBST(MAKE_DOCFILE)
1857 AC_SUBST(MODCFLAGS)
1858 AC_SUBST(INSTALLPATH)
1859 AC_SUBST(MOD_INSTALL_PROGRAM)
1860 AC_SUBST(OBJECT_TO_BUILD)
1861 SXE_SUBST_STATMOD_A
1862
1863 ## FFI support
1864 SXE_CHECK_FFI
1865 SXE_CHECK_SUFFICIENCY([ffi], [FFI support], [
1866         ## additional actions
1867         AC_DEFINE([HAVE_LIBFFI], [1], [Description here!])
1868         HAVE_LIBFFI=yes
1869         FFI_LIBS="-lffi"
1870         SXE_ADD_CRUFT_OBJS([effi.o])
1871 ])
1872
1873 ## ENT support
1874 SXE_CHECK_ENT
1875
1876 ## check for pseudo gaussian numbers
1877 AC_MSG_CHECKING([for pseug (gaussian numbers)])
1878 if test "$sxe_cv_feat_gmp" = "yes"; then
1879         ## the good case
1880         AC_DEFINE([HAVE_PSEUG], [1], [Whether we COULD do gaussian numbers!])
1881         sxe_cv_feat_pseug="yes"
1882 else
1883         sxe_cv_feat_pseug="no"
1884 fi
1885 AC_MSG_RESULT([$sxe_cv_feat_pseug])
1886
1887 ## check for pseudo complex numbers
1888 AC_MSG_CHECKING([for pseuc (pseudo complex numbers)])
1889 if test "$sxe_cv_feat_mpfr" = "yes"; then
1890         ## the good case
1891         AC_DEFINE([HAVE_PSEUC], [1], [Whether we COULD do complex numbers!])
1892         sxe_cv_feat_pseuc="yes"
1893 else
1894         sxe_cv_feat_pseuc="no"
1895 fi
1896 AC_MSG_RESULT([$sxe_cv_feat_pseuc])
1897
1898 ## check for pseudo quaternions
1899 AC_MSG_CHECKING([for quatern (quaternion numbers)])
1900 if test "$sxe_cv_feat_gmp" = "yes"; then
1901         ## the good case
1902         AC_DEFINE([HAVE_QUATERN], [1], [Whether we COULD do quaternions!])
1903         sxe_cv_feat_quatern="yes"
1904 else
1905         sxe_cv_feat_quatern="no"
1906 fi
1907 AC_MSG_RESULT([$sxe_cv_feat_quatern])
1908
1909
1910 ## go through what the PH^Wuser has specified
1911 ## it's a wee bit more complex, so let's go for it
1912 ## we use a dijkstra-if
1913 ent_dijkstra="$with_ent_gmp $sxe_cv_feat_gmp"
1914 if test "$ent_dijkstra" = "yes yes"; then
1915         AC_DEFINE([WITH_GMP], [1], [Whether GMP support was desired!])
1916         SXE_PREPEND([$GMP_LIBS], [ENT_LIBS])
1917         SXE_ADD_ENT_OBJS([ent-gmp.o])
1918         have_ent_gmp="yes"
1919 elif test "$ent_dijkstra" = "yes no"; then
1920         ## pity, we wanted GMP but we dont have it
1921         AC_DEFINE([WITH_GMP], [1], [Whether GMP support was desired!])
1922         have_ent_gmp="no"
1923 elif test "$ent_dijkstra" = "no yes"; then
1924         ## we didn't want GMP but we have it
1925         ## do nothing in that case
1926         have_ent_gmp="no"
1927 elif test "$ent_dijkstra" = "no no"; then
1928         ## great, we didnt opt for GMP and we're lucky, it's not there either
1929         have_ent_gmp="no"
1930 fi
1931
1932 ## evaluate mpfr results
1933 ent_dijkstra="$with_ent_mpfr $sxe_cv_feat_mpfr"
1934 if test "$ent_dijkstra" = "yes yes"; then
1935         ## the good case
1936         AC_DEFINE([WITH_MPFR], [1], [Description here!])
1937         SXE_PREPEND([$MPFR_LIBS], [ENT_LIBS])
1938         SXE_ADD_ENT_OBJS([ent-mpfr.o])
1939         have_ent_mpfr="yes"
1940 elif test "$ent_dijkstra" = "yes no"; then
1941         ## we want but can't have
1942         AC_DEFINE([WITH_MPFR], [1], [Description here!])
1943         have_ent_mpfr="no"
1944 elif test "$ent_dijkstra" = "no yes"; then
1945         have_ent_mpfr="no"
1946 elif test "$ent_dijkstra" = "no no"; then
1947         have_ent_mpfr="no"
1948 fi
1949
1950
1951 ## whether to enable gaussian numbers
1952 ent_dijkstra="$with_ent_pseug $sxe_cv_feat_pseug"
1953 if test "$ent_dijkstra" = "yes yes"; then
1954         ## perfick
1955         AC_DEFINE([WITH_PSEUG], [1], [Description here!])
1956         SXE_PREPEND([$GMP_LIBS], [ENT_LIBS])
1957         SXE_ADD_ENT_OBJS([ent-gaussian.o])
1958         have_ent_pseug="yes"
1959 elif test "$ent_dijkstra" = "yes no"; then
1960         ## grrrr
1961         AC_DEFINE([WITH_PSEUG], [1], [Description here!])
1962         have_ent_pseug="no"
1963 elif test "$ent_dijkstra" = "no yes"; then
1964         have_ent_pseug="no"
1965 elif test "$ent_dijkstra" = "no no"; then
1966         have_ent_pseug="no"
1967 fi
1968
1969 ## whether to enable emulated complex numbers
1970 ent_dijkstra="$with_ent_pseuc $sxe_cv_feat_pseuc $with_ent_mpc $sxe_cv_feat_mpc"
1971 if test "$ent_dijkstra" = "yes yes yes yes"; then
1972         ## skip pseuc usage
1973         have_ent_pseuc="veto"
1974         AC_DEFINE([WITH_PSEUC], [1], [Description here!])
1975         AS_MESSAGE([ENT: Built-in support for complex numbers available, dnl
1976 but omitted in favour of MPC.])
1977         omit_ent_pseuc_in_favour_of="mpc"
1978         ## set up to use plain mpc
1979         AC_DEFINE([WITH_MPC], [1], [Description here!])
1980         SXE_PREPEND([$MPC_LIBS], [ENT_LIBS])
1981         SXE_ADD_ENT_OBJS([ent-mpc.o])
1982         have_ent_mpc="yes"
1983 elif test "$ent_dijkstra" = "yes yes yes no"; then
1984         ## user planned to use mpc, hasnt got it though
1985         ## now he's cursed with pseudo complex numbers :)
1986         AC_DEFINE([WITH_PSEUC], [1], [Description here!])
1987         have_ent_pseuc="yes"
1988         SXE_PREPEND([$MPFR_LIBS], [ENT_LIBS])
1989         SXE_ADD_ENT_OBJS([ent-pseumpc.o])
1990         ## we want mpc but can't have, set up that
1991         AC_DEFINE([WITH_MPC], [1], [Description here!])
1992         have_ent_mpc="no"
1993 elif test "$ent_dijkstra" = "yes yes no yes"; then
1994         ## user coulda used mpc but disabled it for whatever reasons ... Wait!
1995         ## Horst, is that you?!
1996         AC_DEFINE([WITH_PSEUC], [1], [Description here!])
1997         AS_MESSAGE([ENT: dnl
1998 MPC support for complex numbers IS possible, however YOU think you want dnl
1999 the built-in emulated stuff?  Seriously?  Good, so be it!])
2000         SXE_PREPEND([$MPFR_LIBS], [ENT_LIBS])
2001         SXE_ADD_ENT_OBJS([ent-pseumpc.o])
2002         have_ent_pseuc="yes"
2003         omit_ent_mpc_in_favour_of="pseuc"
2004         ## however brag that we have mpc
2005         have_ent_mpc="yes"
2006 elif test "$ent_dijkstra" = "yes yes no no"; then
2007         AC_DEFINE([WITH_PSEUC], [1], [Description here!])
2008         have_ent_pseuc="yes"
2009         SXE_PREPEND([$MPFR_LIBS], [ENT_LIBS])
2010         SXE_ADD_ENT_OBJS([ent-pseumpc.o])
2011         have_ent_mpc="no"
2012 elif test "$with_ent_pseuc $sxe_cv_feat_pseuc" = "yes no"; then
2013         AC_DEFINE([WITH_PSEUC], [1], [Description here!])
2014         have_ent_pseuc="no"
2015 elif test "$with_ent_pseuc $sxe_cv_feat_pseuc" = "no yes"; then
2016         have_ent_pseuc="no"
2017 elif test "$with_ent_pseuc $sxe_cv_feat_pseuc" = "no no"; then
2018         have_ent_pseuc="no"
2019 fi
2020
2021 ## whether to enable gaussian numbers
2022 ent_dijkstra="$with_ent_quatern $sxe_cv_feat_quatern"
2023 if test "$ent_dijkstra" = "yes yes"; then
2024         ## perfick
2025         AC_DEFINE([WITH_QUATERN], [1], [Description here!])
2026         SXE_PREPEND([$GMP_LIBS], [ENT_LIBS])
2027         SXE_ADD_ENT_OBJS([ent-quatern.o])
2028         have_ent_quatern="yes"
2029 elif test "$ent_dijkstra" = "yes no"; then
2030         ## grrrr
2031         AC_DEFINE([WITH_QUATERN], [1], [Description here!])
2032         have_ent_quatern="no"
2033 elif test "$ent_dijkstra" = "no yes"; then
2034         have_ent_quatern="no"
2035 elif test "$ent_dijkstra" = "no no"; then
2036         have_ent_quatern="no"
2037 fi
2038
2039 ## elliptic curve support
2040 ent_dijkstra="$with_ent_ecm $sxe_cv_feat_ecm"
2041 if test "$ent_dijkstra" = "yes yes"; then
2042         ## perfick case
2043         AC_DEFINE([WITH_ECM], [1], [Description here!])
2044         SXE_PREPEND([$ECM_LIBS], [ENT_LIBS])
2045         SXE_ADD_ENT_OBJS([ent-ecm.o])
2046         have_ent_ecm="yes"
2047 elif test "$ent_dijkstra" = "no yes"; then
2048         have_ent_ecm="no"
2049 elif test "$ent_dijkstra" = "yes no"; then
2050         AC_DEFINE([WITH_ECM], [1], [Description here!])
2051         have_ent_ecm="no"
2052 elif test "$ent_dijkstra" = "no no"; then
2053         have_ent_ecm="no"
2054 fi
2055
2056
2057 ## Floating operation support is now unconditional
2058 SXE_CHECK_MATHS_VALUES
2059 if test "$ac_cv_sizeof_long_double" != 0; then
2060         ##AC_DEFINE_UNQUOTED([fpfloat], [long double], [Description here!])
2061         ##AC_DEFINE([fpfloat_long_double_p], [1], [Description here!])
2062         fpfloat="long double"
2063         fpfloat_long_double_p=1
2064         have_fpfloat=yes
2065 elif test "$ac_cv_sizeof_double" != 0; then
2066         ##AC_DEFINE_UNQUOTED([fpfloat], [double], [Description here!])
2067         ##AC_DEFINE([fpfloat_double_p], [1], [Description here!])
2068         fpfloat="double"
2069         fpfloat_double_p=1
2070         have_fpfloat=yes
2071 else
2072         AS_MESSAGE([Uh oh, no float type is bad news.])
2073         have_fpfloat=no
2074 fi
2075
2076 AC_MSG_CHECKING([if need to add -lm])
2077 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2078 #include <math.h>
2079 ]],[[
2080 return sin(0.0);
2081 ]])], [AC_MSG_RESULT([no])], [
2082         AC_MSG_RESULT([maybe])
2083         save_LIBS=$LIBS
2084         SXE_APPEND([-lm], [LIBS])
2085         AC_MSG_CHECKING([if can add -lm])
2086         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2087 #include <math.h>
2088 ]],[[
2089 return sin(0.0);
2090 ]])], [AC_MSG_RESULT([yes])], [
2091         AC_MSG_RESULT([no])
2092         AC_MSG_WARN([No way to use math functions found. Reverting option append.])
2093         LIBS=$save_LIBS])])
2094
2095
2096
2097 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2098 #include <math.h>
2099 ]],[[
2100 return atanh(1.0) + asinh(1.0) + acosh(1.0);
2101 ]])], [AC_DEFINE([HAVE_INVERSE_HYPERBOLIC], [1], [Description here!])])
2102
2103 if test "$have_fpfloat" = "yes"; then
2104         AC_DEFINE([HAVE_FPFLOAT], [1], [Description here!])
2105
2106         SXE_CHECK_CLEAN_FLOATOPS(
2107                 [have_clean_floatops="yes"], [have_clean_floatops="no"])
2108
2109         ## it would seem odd to define the destiny of our float arithmetic here
2110         if test "$have_clean_floatops" = "yes"; then
2111                 AC_DEFINE_UNQUOTED([fpfloat], [$fpfloat], [Description here!])
2112                 AC_DEFINE_UNQUOTED([fpfloat_long_double_p],
2113                         [${fpfloat_long_double_p:-0}], [Description here!])
2114                 AC_DEFINE_UNQUOTED([fpfloat_double_p],
2115                         [${fpfloat_double_p:-0}], [Description here!])
2116         else
2117                 AS_MESSAGE([downgrading to `double' floats])
2118                 AC_DEFINE_UNQUOTED([fpfloat], [double], [Description here!])
2119                 AC_DEFINE_UNQUOTED([fpfloat_long_double_p],
2120                         [0], [Description here!])
2121                 AC_DEFINE([fpfloat_double_p],
2122                         [1], [Description here!])
2123         fi
2124 fi
2125
2126 ## trivial checks, you cannot (yet) turn off internal arithmetic entirely
2127 ## so we always `have' it
2128 dnl with_ent_int=yes
2129 have_ent_int=yes
2130 dnl with_ent_indef=yes
2131 have_ent_indef=yes
2132 dnl with_ent_fpfloat=yes
2133 have_ent_fpfloat=yes
2134 dnl we attempt to always use ent.o
2135 AC_DEFINE([WITH_NUMBER_TYPES], [1], [Description here!])
2136 SXE_SUBST_ENT_OBJS
2137
2138 dnl experimental code support
2139 if test "$with_compre" != "no"; then
2140         AC_MSG_CHECKING([if compre prerequisites are met])
2141         AC_MSG_RESULT([yes])
2142         AC_DEFINE([EF_USE_COMPRE], [1],
2143                 [Whether to provide compiled regular expression!])
2144         have_compre=yes
2145 fi
2146 if test "$with_experimental_features_pom" = "yes"; then
2147         AC_MSG_CHECKING([if pom prerequisites are met])
2148         if test "$have_threads" = "yes"; then
2149                 AC_MSG_RESULT([yes])
2150                 AC_DEFINE([EF_USE_POM], [1],
2151                         [Whether to protect all lisp objects with mutexes!])
2152                 have_experimental_features_pom=yes
2153         else
2154                 AC_MSG_RESULT([no])
2155         fi
2156 fi
2157 if test "$with_experimental_features_asyneq" = "yes"; then
2158         AC_MSG_CHECKING([if asyneq prerequisites are met])
2159         if test "$have_threads" = "yes"; then
2160                 AC_MSG_RESULT([yes])
2161                 AC_DEFINE([EF_USE_ASYNEQ], [1],
2162                         [Whether to setup asynchronous event queues!])
2163                 have_experimental_features_asyneq=yes
2164                 SXE_ADD_EVENTS_OBJS([event-queue.o workers.o worker-asyneq.o])
2165         else
2166                 AC_MSG_RESULT([no])
2167         fi
2168 fi
2169 SXE_SUBST_EVENTS_OBJS
2170
2171 SXE_CHECK_EVENTS
2172 SXE_CHECK_SUFFICIENCY([events], [event system])
2173
2174 ## check asm helpers
2175 SXE_CHECK_ASM_HELPERS
2176
2177 ## compression titbits
2178 SXE_CHECK_ZLIB
2179 SXE_CHECK_BZLIB
2180 SXE_CHECK_LZMA
2181
2182
2183 ## Cryptography Options
2184 ## ====================
2185 echo
2186 echo "Cryptography Options"
2187 echo "===================="
2188
2189 ## in case someone else (ldap, pgsql, etc.) needs it
2190 SXE_CHECK_OPENSSL
2191 SXE_CHECK_SUFFICIENCY([openssl], [OpenSSL support])
2192
2193 dnl OpenSSL
2194 if test "$with_openssl" != "no" -a "$have_openssl" = "yes"; then
2195         SXE_ADD_CRUFT_OBJS([openssl.o])
2196 elif test "$with_openssl" != "no"; then
2197         AC_MSG_WARN([Required OpenSSL support cannot be provided.])
2198         AC_MSG_WARN([Check --with-site-prefixes.])
2199 fi
2200 if test "$have_openssl" = "no" -o "$with_openssl" = "no"; then
2201         OPENSSL_CPPFLAGS=""
2202         OPENSSL_LDFLAGS=""
2203         OPENSSL_LIBS=""
2204 fi
2205 AC_SUBST([OPENSSL_CPPFLAGS])
2206 AC_SUBST([OPENSSL_LDFLAGS])
2207 AC_SUBST([OPENSSL_LIBS])
2208
2209 SXE_CHECK_KERBEROS
2210 SXE_CHECK_KERBEROS5
2211 if test "$with_kerberos" = "yes"; then
2212         AC_DEFINE([WITH_KERBEROS], [1], [Whether kerberos support was requested])
2213         if test "$sxe_cv_feat_kerberos" = "yes"; then
2214                 SXE_PREPEND([$KERBEROS_LIBS], [ld_libs_general])
2215         fi
2216 fi
2217
2218
2219 ## Networking Options
2220 ## ==================
2221 echo
2222 echo "Networking Options"
2223 echo "=================="
2224
2225 SXE_CHECK_SOCKETS
2226 SXE_CHECK_SUFFICIENCY([unix], [unix domain sockets])
2227 SXE_CHECK_SUFFICIENCY([sysvipc], [SysV IPC message])
2228 SXE_CHECK_SUFFICIENCY([sockets], [tcp/udp sockets])
2229 SXE_CHECK_SUFFICIENCY([tcpudp], [tcp/udp sockets])
2230 SXE_CHECK_SUFFICIENCY([multicast], [multicast])
2231
2232 dnl Decnet
2233 if test "$with_dnet" = "yes"; then
2234   AC_CHECK_LIB(dnet, main,
2235     [AC_DEFINE([HAVE_LIBDNET], [1], [Description here!])],
2236     [SXE_DIE("DECnet requested but can't find libdnet")])
2237 fi
2238
2239 dnl Socks support
2240 if test "$with_socks" = "yes"; then
2241   AC_CHECK_LIB(socks, SOCKSinit)
2242   test -n "$ac_cv_lib_socks_SOCKSinit" && AC_DEFINE([HAVE_SOCKS], [1], [Description here!])
2243 fi
2244
2245
2246 ## Window System Features
2247 ## ======================
2248 echo
2249 echo "Window System Features"
2250 echo "======================"
2251
2252 dnl ----------------------
2253 dnl Choose a window system
2254 dnl ----------------------
2255
2256 AS_MESSAGE([checking for specified window system])
2257
2258 if test "$with_x" != "no"; then
2259         if test "$with_x11" != "no"; then
2260                 dnl User-specified --x-includes or --x-libraries implies --with-x11.
2261                 test "$x_includes $x_libraries" != "NONE NONE" && \
2262                         window_system=x11
2263                         with_x11=yes
2264         fi
2265
2266         dnl Autodetection of X11 libraries and includes
2267         dnl -------------------------------------------
2268         dnl AC_PATH_XTRA thinks it can find our X headers and includes, but
2269         dnl it often gets it wrong, so we only use it as a last resort.
2270
2271         dnl $OPENWINHOME implies --x-includes and --x-libraries
2272         dnl Not (yet) handled by autoconf2
2273         if test "$x_includes $x_libraries" = "NONE NONE" \
2274                 -a -n "$OPENWINHOME" \
2275                 -a "$OPENWINHOME" != "/usr/openwin" \
2276                 -a -d "$OPENWINHOME"; then
2277                 test -d "$OPENWINHOME/lib"           && \
2278                         x_libraries="$OPENWINHOME/lib"
2279                 test -d "$OPENWINHOME/include"       && \
2280                         x_includes="$OPENWINHOME/include"
2281                 test -d "$OPENWINHOME/share/include" && \
2282                         x_includes="$OPENWINHOME/share/include"
2283         fi
2284
2285         if test -z "$x_includes" -o \
2286            "$x_includes" = "NONE" -o \
2287            ! -d "$x_includes"; then
2288                 dnl AC_PATH_XTRA often guesses /usr/include, when some other
2289                 dnl include directory is a MUCH better guess (Linux, HP-UX 10.20).
2290                 dnl This is a workaround for idiot (esp. HP) system vendors, who
2291                 dnl provide a /usr/include/X11, but DON'T FULLY POPULATE IT.
2292                 for dir in "/usr/X11" "/usr/X11R7" "/usr/X11R6" \
2293                         "/usr/local" "/usr"; do
2294                         if test -d "$dir/include/X11"; then
2295                                 x_includes="$dir/include"
2296                                 break
2297                         fi
2298                 done
2299         fi
2300
2301         if test -z "$x_libraries" -o \
2302            "$x_libraries" = "NONE" -o \
2303            ! -d "$x_libraries"; then
2304                 for dir in \
2305                         "/usr/X11/lib" \
2306                         "/usr/X11R7/lib" "/usr/lib/X11R7" \
2307                         "/usr/X11R6/lib" "/usr/lib/X11R6" \
2308                         "/usr/local/lib" "/usr/local/lib/X11" \
2309                         "/usr/lib" "/usr/lib/X11"; do
2310                         if test -r "$dir/libX11.a"; then
2311                                 x_libraries="$dir"
2312                                 break
2313                         fi
2314                 done
2315         fi
2316
2317         AC_PATH_XTRA
2318         if test "$with_x11" != "no"; then
2319                 if test "$no_x" = "yes"; then
2320                         with_x11=no
2321                         window_system=none
2322                         HAVE_X_WINDOWS=no
2323                 else
2324                         with_x11=yes
2325                         window_system=x11
2326                         HAVE_X_WINDOWS=yes
2327                 fi
2328         fi
2329 fi
2330
2331 dnl #### wmperry:: !x11 != NONE
2332 dnl case "$with_x11" in
2333 dnl  yes ) window_system=x11  HAVE_X_WINDOWS=yes ;;
2334 dnl  no  ) window_system=none HAVE_X_WINDOWS=no  ;;
2335 dnl esac
2336
2337 AM_CONDITIONAL([DESCEND_LWLIB], [test "$with_x11" = "yes"])
2338 if test "$with_x11" = "yes"; then
2339         AC_DEFINE([HAVE_X_WINDOWS], [1], [Description here!])
2340         AC_DEFINE([NeedFunctionPrototypes], [1], [Description here!])
2341         AC_DEFINE([FUNCPROTO], [15], [Whatever this is.])
2342         AC_DEFINE([HAVE_UNIXOID_EVENT_LOOP], [1], [Description here!])
2343         SXE_APPEND([lwlib], [MAKE_SUBDIR])
2344         SXE_APPEND([lwlib], [SRC_SUBDIR_DEPS])
2345
2346         SXE_ADD_SXEUIX11_OBJS([console-x.o device-x.o event-Xt.o frame-x.o])
2347         SXE_ADD_SXEUIX11_OBJS([glyphs-x.o objects-x.o redisplay-x.o select-x.o])
2348         SXE_ADD_SXEUIX11_OBJS([xgccache.o])
2349
2350         SXE_DUMP_LIBS
2351         ## some debian systems are trying to fool us ... now fool them back!
2352         if test -d "$x_includes"; then
2353                 CPPFLAGS="$CPPFLAGS -I$x_includes"
2354         fi
2355         if test -d "$x_libraries"; then
2356                 LDFLAGS="$LDFLAGS -L$x_libraries"
2357         fi
2358
2359         dnl Look for Motif, but only if not found in $x_includes and $x_libraries
2360         AC_CHECK_HEADERS([Xm/Xm.h])
2361         if test "$ac_cv_header_Xm_Xm_h" = "yes"; then
2362                 AC_CHECK_LIB([Xm], [XmStringFree], [got_motif=yes])
2363         fi
2364
2365         if test "$got_motif" != "yes"; then
2366                 dnl Try to find Motif dirs
2367                 dnl These take precedence over other X libs/includes, so PRE-pend
2368                 for lib_dir in \
2369                         "/usr/dt/lib" "/usr/lib/Motif2.1" \
2370                         "/usr/lib/Motif1.2" "/usr/lib/Motif1.1"; do
2371                         inc_dir=`echo $lib_dir | sed -e 's/lib/include/'`
2372                         if test -d "$lib_dir" -a -d "$inc_dir"; then
2373                                 case "$x_libraries" in
2374                                 *"$lib_dir"* )
2375                                         ;;
2376                                 *)
2377                                         x_libraries="$lib_dir $x_libraries"
2378                                         SXE_PREPEND(["-L${lib_dir}"], [X_LIBS])
2379                                         ;;
2380                                 esac
2381                                 case "$x_includes" in
2382                                 "$inc_dir"* )
2383                                         ;;
2384                                 *)
2385                                         x_includes="$inc_dir $x_includes"
2386                                         SXE_PREPEND_UNDUP(["-I${inc_dir}"], [X_CFLAGS])
2387                                         ;;
2388                                 esac
2389                                 break; dnl only need ONE Motif implementation!
2390                         fi
2391                 done
2392         fi
2393
2394         dnl Contrib X libs/includes do NOT take precedence, so AP-pend
2395         for rel in "X11R7" "X11R6" "X11R5" "X11R4"; do
2396                 lib_dir="/usr/contrib/$rel/lib" inc_dir="/usr/contrib/$rel/include"
2397                 if test -d "$lib_dir" -a -d "$inc_dir"; then
2398                         case "$x_libraries" in
2399                         *"$lib_dir"* )
2400                                 ;;
2401                         *)
2402                                 x_libraries="$x_libraries $lib_dir"
2403                                 SXE_APPEND(["-L${lib_dir}"], [X_LIBS])
2404                                 ;;
2405                         esac
2406                         case "$x_includes" in
2407                         "$inc_dir"* )
2408                                 ;;
2409                         *)
2410                                 x_includes="$x_includes $inc_dir"
2411                                 SXE_APPEND_UNDUP(["-I${inc_dir}"], [X_CFLAGS])
2412                                 ;;
2413                         esac
2414                         break; dnl Only need ONE X11 implementation !
2415                 fi
2416         done
2417
2418         dnl Avoid version mismatch for shared library libXm.so on osf4
2419         case "$opsys" in
2420         decosf*)
2421                 AS_IF([test "$GCC" = yes -a -d "/usr/shlib"],
2422                         SXE_APPEND([-L/usr/shlib], [X_LIBS]))
2423                 ;;
2424         esac
2425
2426         LDFLAGS="$LDFLAGS $X_LIBS"
2427
2428         if test "$extra_verbose" = "yes"; then
2429                 echo
2430                 echo "X11 compilation variables:"
2431                 SXE_PRINT_VAR(x_libraries x_includes
2432                         X_CFLAGS X_LIBS X_PRE_LIBS X_EXTRA_LIBS)
2433                 echo
2434         fi
2435
2436         dnl Set up bitmaps search path.
2437         dnl The original suggestion was to unconditionally to append X11/bitmaps
2438         dnl to each element of $x_includes, I'm pretty sure this is the wrong
2439         dnl thing to do.  We test for bitmaps and X11/bitmaps directories on each
2440         dnl element and add them to BITMAPDIR if they exist.
2441         bitmapdirs=
2442         if test "$x_includes" != NONE; then
2443                 for i in $x_includes; do
2444                         if test -d "$i/bitmaps"; then
2445                                 bitmapdirs="$i/bitmaps:$bitmapdirs"
2446                         fi
2447                         if test -d "$i/X11/bitmaps"; then
2448                                 bitmapdirs="$i/X11/bitmaps:$bitmapdirs"
2449                         fi
2450                 done
2451                 bitmapdirs=`echo "$bitmapdirs" | sed s/.$//`
2452         fi
2453         if test ! -z "$bitmapdirs"; then
2454                 AC_DEFINE_UNQUOTED([BITMAPDIR], ["$bitmapdirs"], [Description here!])
2455         fi
2456
2457 dnl   dnl Autodetect defines extracted from X config by xmkmf, e.g. NARROWPROTO
2458 dnl   AS_MESSAGE(checking for X defines extracted by xmkmf)
2459 dnl   rm -fr conftestdir
2460 dnl   if mkdir conftestdir; then
2461 dnl     cd conftestdir
2462 dnl     cat > Imakefile <<'EOF'
2463 dnl xetest:
2464 dnl     @echo ${PROTO_DEFINES} ${STD_DEFINES}
2465 dnl EOF
2466 dnl     if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
2467 dnl       # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
2468 dnl       xmkmf_defines=`${MAKE-make} xetest 2>/dev/null | grep -v make`
2469 dnl     fi
2470 dnl     cd ..
2471 dnl     rm -fr conftestdir
2472 dnl     for word in $xmkmf_defines; do
2473 dnl       case "$word" in
2474 dnl       -D__STDC__*) ;;
2475 dnl       -D* )
2476 dnl     sym=`echo '' $word | sed -e 's:^ *-D::' -e 's:=.*::'`
2477 dnl     case "$word" in
2478 dnl       -D*=* ) val=`echo '' $word | sed -e 's:^.*=::'` ;;
2479 dnl       *     ) val=1 ;;
2480 dnl     esac
2481 dnl dnl Avoid re-AC_DEFINE-ing xmkmf symbols we've already defined above.
2482 dnl     if grep "^#define $sym " confdefs.h >/dev/null; then :; else
2483 dnl       if test "$val" = "1"
2484 dnl         then AC_DEFINE_UNQUOTED([$sym], [], [Description here!])
2485 dnl         else AC_DEFINE_UNQUOTED([$sym], [$val], [Description here!])
2486 dnl       fi
2487 dnl     fi  ;;
2488 dnl       esac
2489 dnl     done
2490 dnl   fi
2491
2492         dnl make sure we can find Intrinsic.h
2493         AC_CHECK_HEADER([X11/Intrinsic.h], [],
2494                 [AC_MSG_ERROR([Unable to find X11 header files. Try using --x-includes=<path> if you know the path, or --with-x=no to disable X11 support.])])
2495
2496         dnl Check some more headers
2497         AC_CHECK_HEADERS([X11/Intrinsic.h X11/StringDefs.h X11/Shell.h X11/ShellP.h],
2498                 [],[],
2499                 [[#if HAVE_X11_INTRINSIC_H
2500                   # include <X11/Intrinsic.h>
2501                   # include <X11/IntrinsicP.h>
2502                   # include <X11/CoreP.h>
2503                   #endif]])
2504
2505         dnl -lXt and -lX11 are required
2506         dnl Some broken systems require the magic "-b i486-linuxaout" flag
2507
2508         dnl Other broken systems will not pass these tests unless the pre and
2509         dnl extra libs are passed on...
2510         LIBS="$LIBS $X_PRE_LIBS $X_EXTRA_LIBS"
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                         [],
2515                         [AC_MSG_ERROR([Unable to find X11 libraries. Try using --x-libraries=<path> if you know the path, or --with-x=no to disable X11 support.])])
2516         fi
2517         SXE_PREPEND([-lX11], [libs_x])
2518         LIBS="$LIBS -lX11"
2519         if test "$extra_verbose" = "yes"; then
2520                 echo "    Setting libs_x to \"-lX11\""
2521         fi
2522         dnl Autodetect -lXext
2523         AC_CHECK_LIB([Xext], [XShapeSelectInput], [SXE_PREPEND([-lXext], [libs_x])])
2524
2525         dnl Require -lXt
2526         AC_CHECK_LIB([Xt], [XtOpenDisplay], [SXE_PREPEND([-lXt], [libs_x])], [
2527                 AC_MSG_ERROR([Unable to find X11 libraries. Try using --x-libraries=<path> if you know the path, or --with-x=no to disable X11 support.])])
2528
2529         AC_MSG_CHECKING([the version of X11 being used])
2530         AC_RUN_IFELSE([AC_LANG_SOURCE([[
2531 #include <X11/Intrinsic.h>
2532 int main(int c, char *v[]) { return c>1 ? XlibSpecificationRelease : 0; }]])],
2533                 [./conftest foobar; x11_release=$?],[x11_release=4],[x11_release=4])
2534         AC_MSG_RESULT(R${x11_release})
2535         AC_DEFINE_UNQUOTED([X11_RELEASE], [${x11_release}], [Description here!])
2536
2537         AC_CHECK_FUNCS([XConvertCase])
2538         AC_CHECK_LIB([Xt], [XtRegisterDrawable])
2539         if test "$ac_cv_lib_Xt_XtRegisterDrawable" = "yes"; then
2540                 AC_DEFINE([HAVE_XTREGISTERDRAWABLE], [1], [Description])
2541         fi
2542
2543         AC_CHECK_HEADERS(X11/Xlocale.h)
2544
2545         dnl XFree86 has a non-standard prototype for this X11R6 function
2546         AC_CHECK_FUNCS(XRegisterIMInstantiateCallback)
2547         AC_MSG_CHECKING(for standard XRegisterIMInstantiateCallback prototype)
2548         AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2549 #ifndef NeedFunctionPrototypes
2550 #define NeedFunctionPrototypes 1
2551 #endif
2552 #include <X11/Xlib.h>
2553 extern Bool XRegisterIMInstantiateCallback(
2554         Display*, struct _XrmHashBucketRec*, char*, char*, XIMProc, XPointer*);
2555 ]])],
2556         [AC_MSG_RESULT(yes)],
2557         [AC_MSG_RESULT(no)
2558                 AC_DEFINE([XREGISTERIMINSTANTIATECALLBACK_NONSTANDARD_PROTOTYPE],
2559                         [], [Description here!])])
2560
2561         dnl autodetect -lXmu
2562         AC_CHECK_LIB([Xmu], [XmuReadBitmapDataFromFile],
2563                 [with_xmu=yes], [with_xmu=no])
2564         if test "$with_xmu" = "no"; then
2565                 SXE_ADD_SXEUIX11_OBJS([xmu.o])
2566         else
2567                 SXE_PREPEND([-lXmu], [libs_x])
2568                 AC_DEFINE([HAVE_XMU], [1], [Description here!])
2569         fi
2570
2571         dnl Autodetect -lXbsd
2572         dnl #### Someone, please add a better function than main
2573         AC_CHECK_LIB([Xbsd], [main], SXE_PREPEND([-lXbsd], [libs_x]))
2574
2575         dnl restore old values
2576         SXE_RESTORE_LIBS
2577 fi dnl $with_x11 = yes
2578
2579 AC_SUBST([install_pp])
2580
2581 dnl test "$with_dragndrop" != "no" && with_dragndrop="$with_dragndrop_default"
2582 dnl test -z "$window_system" && window_system="none"
2583 with_dragndrop="no"
2584
2585 dnl Test for features that require a window system - ANY window system
2586 if test "$window_system" = "none"; then
2587   for feature in menubars scrollbars toolbars dialogs dragndrop xface
2588   do
2589     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
2590        AC_MSG_WARN([--with-$feature ignored:  Not valid without window system support])
2591     fi
2592     eval "with_${feature}=no"
2593   done
2594 else
2595   test -z "with_toolbars" && with_toolbars=yes
2596 fi
2597
2598 dnl Test for features that require X11 support
2599 if test "$with_x11" != "yes"; then
2600   for feature in offix wmcommand xim xmu nas_sound
2601   do
2602     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
2603        AC_MSG_WARN([--with-$feature ignored:  Not valid without X support])
2604     fi
2605     eval "with_${feature}=no"
2606   done
2607 fi
2608
2609 dnl Balloon Help requires the Shape extension, not available everywhere,
2610 dnl for example not on AIX 4.3.
2611 if test "$with_x11" = "yes"; then
2612   AC_CHECK_HEADER(X11/extensions/shape.h, [
2613    AC_DEFINE([HAVE_BALLOON_HELP], [1], [Description here!])
2614    SXE_ADD_SXEUIX11_OBJS(balloon_help.o balloon-x.o)
2615    ])
2616 fi
2617
2618 dnl FSF 19.29 has some bitmapdir stuff here.
2619 bitmapdir=
2620
2621 case "$window_system" in
2622   x11  ) HAVE_X_WINDOWS=yes; echo "  Using X11." ;;
2623   none ) HAVE_X_WINDOWS=no ; echo "  Using no window system." ;;
2624 esac
2625
2626 if test -n "$window_system" -a "$window_system" != "none"; then
2627         AC_DEFINE_UNQUOTED([HAVE_WINDOW_SYSTEM], [1], [Description here!])
2628 fi
2629
2630 case "$x_libraries" in *X11R4* )
2631   test "$opsys" = "hpux9"     && opsysfile="s/hpux9-x11r4.h"
2632   test "$opsys" = "hpux9-shr" && opsysfile="s/hpux9shxr4.h"
2633 esac
2634
2635 dnl Enable or disable proper handling of WM_COMMAND
2636 AS_MESSAGE(checking for WM_COMMAND option);
2637 dnl if test "$with_wmcommand" = "yes"; then
2638 if test "$with_wmcommand" != "no"; then
2639   AC_DEFINE([HAVE_WMCOMMAND], [1], [Description here!])
2640 fi
2641
2642 dnl Autodetect Xauth
2643 dnl -lXau is only used by gnuclient, so use a special variable for Xauth X libs
2644 test "$with_xauth" != "no" && test "$window_system" = "none" && with_xauth=no
2645 SXE_DUMP_LIBS
2646 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
2647 LDFLAGS="$LDFLAGS $X_LIBS"
2648 AC_CHECK_HEADER([X11/Xauth.h], [:], [with_xauth=no])
2649 AC_CHECK_LIB([Xau], [XauGetAuthByAddr], [:], [with_xauth=no])
2650 if test "$with_xauth" = "yes"; then
2651   AC_DEFINE([HAVE_XAUTH], [1], [Description here!])
2652   SXE_CONSECUTIVE_UNDUP([libs_xauth], [$X_EXTRA_LIBS -lXau $libs_x $X_PRE_LIBS])
2653 fi
2654 SXE_RESTORE_LIBS
2655 AC_SUBST(libs_xauth)
2656
2657 dnl ----------------------
2658 dnl X-Specific Graphics libraries
2659 dnl ----------------------
2660
2661 ## Oki, now that we really need a more exhaustive way to autodetect
2662 ## athena and other widgets we construct a chain.  The elements of
2663 ## that chain are simple atomic tests (provided by AC_DEFUNs).
2664 ## The chain is defined to be:
2665 ##
2666 ## neXtaw -> Xaw3d -> XawXpm -> Xaw95  ->  Xaw  ->  Motif  ->  Nirvana
2667 ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^      ^^^      ^^^^^
2668 ##         3d sets                       non-3d   non-athena
2669 ##
2670 ## Now if the user passes a --with-athena=foo option, we jump
2671 ## directly to the according test-suite and in case this fails we jump
2672 ## off the cliff.
2673 ##
2674 ## Attention:
2675 ## We shall perform every test-suite twice, once the correct way, and
2676 ## once with #include'ing the Xfuncproto header.
2677 ## Thanks to the many, many distributions which treat their users
2678 ## like braindead zombies!
2679 ## Especially, I would like to thank Fedora/RedHat for bringing
2680 ## this up. Go on guys, you rock!
2681
2682 ## and now the test chain
2683 if test "$with_x11" = "yes" -a "$with_x" != "no"; then
2684         SXE_CHECK_XTOOLKITS
2685         SXE_CHECK_XT_DEPENDENCIES
2686 else
2687         with_menubars=no
2688         with_scrollbars=no
2689         with_dialogs=no
2690         with_toolbars=no
2691         with_widgets=no
2692 fi
2693
2694 dnl Always compile OffiX unless --without-offix is given, no
2695 dnl X11 support is compiled in, no standard Xmu is available,
2696 dnl or dragndrop support is disabled
2697 dnl Because OffiX support currently loses when more than one display
2698 dnl is in use, we now disable it by default -slb 07/10/1998.
2699 test "$window_system" != "x11" && with_offix=no
2700 if test "$with_xmu" != yes -a "$with_x11" = yes; then
2701   if test "$with_offix" = "yes" ; then
2702     AC_MSG_WARN([--with-offix forced to `no'; no real Xmu support])
2703   fi
2704   with_offix=no
2705 fi
2706 if test "$with_dragndrop" = "no" ; then
2707   if test "$with_offix" = "yes" ; then
2708     AC_MSG_WARN([--with-offix forced to `no'; no generic Drag'n'Drop support])
2709   fi
2710   with_offix=no
2711 fi
2712 if test "$with_offix" = "yes"; then
2713   AC_DEFINE([HAVE_OFFIX_DND], [1], [Description here!])
2714   SXE_APPEND(offix.o, dnd_objs)
2715   SXE_APPEND(OffiX, dragndrop_proto)
2716 fi
2717
2718
2719 ## TTY Options
2720 ## ===========
2721 echo
2722 echo "TTY Options"
2723 echo "==========="
2724
2725
2726 dnl ---------------------
2727 dnl TTY-dependent options
2728 dnl ---------------------
2729
2730 dnl checks for header files
2731 AC_CHECK_HEADERS([libintl.h nlist.h sgtty.h termio.h termios.h])
2732
2733 AS_IF([test "$with_tty" != "no"],[
2734    AS_MESSAGE(checking for TTY-related features)
2735    dnl Check if needed calls are available at all...
2736    
2737    with_tty_libs=""
2738    detect_tty_libs=""
2739    for lib in ncurses curses tinfo terminfo termlib termcap
2740    do
2741        eval "with=\$with_${lib}"
2742        if test "$with" = no
2743        then
2744           AC_MSG_WARN(["Ignoring available ${lib} due to --with-${lib}=no"])
2745        elif test "$with" = "yes"
2746        then
2747           with_tty_libs="$with_tty_libs $lib"
2748        else
2749           detect_tty_libs="$detect_tty_libs $lib"
2750        fi
2751    done
2752
2753    # All terminal info functions needed
2754    tty_funcs="tgetent tgetstr tgetflag tgetnum tparm tgoto tputs"
2755    tty_libs=""
2756    # Filter by existing libs, printf is sure to be available with libc, so failure
2757    # would come from lib not find
2758    for lib in $with_tty_libs $detect_tty_libs
2759    do
2760        SXE_CHECK_LINK_LIB($lib)
2761        if eval "test \"\$sxe_cv_c_lib_${lib}\" != yes"
2762        then
2763           if eval "test \"\$with_${lib}\" = yes"
2764           then
2765              AC_MSG_WARN(["Ignoring --with-${lib}=yes due to library not linkable"])
2766              eval "with_${lib}=no"
2767           fi
2768           continue
2769        fi
2770
2771        AC_CHECK_LIB([$lib], [$tty_funcs])
2772
2773        # Lets verify we have all functions
2774        for func in $tty_func
2775        do
2776            if eval "test \"\$ac_cv_lib_${lib}_${func}\" = no"
2777            then
2778               AS_MESSAGE(["Skipping ${lib}, does not support to all TTY functions"])
2779               lib=""
2780               break
2781            fi
2782        done
2783
2784        tty_libs="$tty_libs $lib"
2785    done
2786
2787    if test -n "$tty_libs"
2788    then
2789       AS_MESSAGE(["Considering libraries: $tty_libs"])
2790    
2791       # Check which preferred lib can be used
2792       for func in $tty_funcs
2793       do
2794          # Make sure no flags are harmed during the search
2795          sxe_save_LIBS=$LIBS
2796          AC_SEARCH_LIBS($func, $tty_libs)
2797          LIBS=$sxe_save_LIBS
2798       done
2799
2800       # Minimize the set of libraries
2801       tty_feature=""
2802       tty_fun=""
2803       for func in $tty_funcs
2804       do
2805           eval lib=\$ac_cv_search_${func}
2806           if test "$lib" != no -a "$lib" != "none required"
2807           then
2808               for feature in $tty_feature
2809               do
2810                   if test "$feature" = "$lib"
2811                   then
2812                      lib=""
2813                      func=""
2814                      break;
2815                   fi
2816               done
2817               tty_feature="$tty_feature $lib"
2818               tty_fun="$tty_fun $func"
2819           fi
2820        done
2821    fi
2822
2823    if test -n "$tty_feature"
2824    then
2825       # Check all the expected functions still compile with all the added
2826       # libraries
2827       sxe_save_LIBS=$LIBS
2828       LIBS="$LIBS $tty_feature"
2829       AC_CHECK_FUNCS($tty_funcs)
2830       for func in $tty_fun
2831       do
2832         if eval "test \"\$ac_cv_func_${func}\" = no"
2833         then
2834             tty_feature=""
2835             break
2836         fi
2837       done
2838       LIBS=$sxe_save_LIBS
2839    fi
2840
2841    if test -n "$tty_feature"
2842    then
2843       SXE_PREPEND($tty_feature, LIBS)
2844       for lib in $tty_feature
2845       do
2846          l=`echo $lib | sed -e 's/^-l//g'`
2847          eval "with_${l}=yes"
2848       done
2849       with_builtin_tty=no
2850       have_tty=yes
2851    else
2852       AC_MSG_WARN([Could not link all needed tty functions.]
2853                   [Please consider installing ncurses.])
2854       if test "$with_builtin_tty" = yes
2855       then
2856           AC_MSG_WARN([Using builtin tty support.])
2857           have_tty=yes
2858       else
2859           AC_MSG_WARN([Use --with-builtin-tty=yes if you cannot use ncurses.])
2860           have_tty=no
2861       fi
2862    fi
2863
2864    if test "$with_builtin_tty" = yes
2865    then
2866       # Add our own wrappers using termcap
2867       SXE_ADD_SXEUITTY_OBJS(termcap.o)
2868       SXE_ADD_SXEUITTY_OBJS(tparam.o)
2869       have_tty=yes
2870    elif test "$have_tty" = yes
2871    then
2872       # Terminfo interface, since tgetent etc are available
2873       SXE_ADD_SXEUITTY_OBJS(terminfo.o)
2874    fi
2875
2876    # Check headers, first generally
2877    AC_CHECK_HEADER(termcap.h, termcap_h_file=termcap.h)
2878    AC_CHECK_HEADER(term.h,    term_h_file=term.h)
2879    
2880    if test "$have_ncurses" = yes; then
2881       # Verify how ncurses overrides them
2882       AC_CHECK_HEADER(ncurses/ncurses.h, curses_h_file=ncurses/ncurses.h)
2883       if test -z "$curses_h_file"; then
2884             AC_CHECK_HEADER(ncurses/curses.h,  curses_h_file=ncurses/curses.h)
2885       fi
2886       if test -n "$curses_h_file"; then
2887             AC_CHECK_HEADER(ncurses/termcap.h, termcap_h_file=ncurses/termcap.h)
2888             AC_CHECK_HEADER(ncurses/term.h,    term_h_file=ncurses/term.h)
2889       else
2890             AC_CHECK_HEADER(ncurses.h,         curses_h_file=ncurses.h)
2891       fi
2892       
2893       if test -z "$curses_h_file" ; then
2894           dnl Try again, and check for the bogus ncurses/ include bug.
2895           dnl (i.e. ncurses/curses.h bogusly includes <unctrl.h> instead of
2896           dnl <ncurses/unctrl.h>)
2897           save_c_switch_site="$c_switch_site"
2898           c_switch_site="$c_switch_site -I/usr/include/ncurses"
2899           AC_CHECK_HEADER(ncurses/ncurses.h,   curses_h_file=ncurses/ncurses.h)
2900           if test -z "$curses_h_file"; then
2901             AC_CHECK_HEADER(ncurses/curses.h,  curses_h_file=ncurses/curses.h)
2902           fi
2903           if test -n "$curses_h_file"; then
2904             AC_CHECK_HEADER(ncurses/termcap.h, termcap_h_file=ncurses/termcap.h)
2905             AC_CHECK_HEADER(ncurses/term.h,    term_h_file=ncurses/term.h)
2906           else
2907             AC_CHECK_HEADER(ncurses.h,         curses_h_file=ncurses.h)
2908           fi
2909           if test -n "$curses_h_file"
2910           then
2911                 AC_MSG_WARN([Your system has the bogus ncurses include bug.])
2912                 AC_CHECK_HEADER(termcap.h,         curses_h_file=termcap.h)
2913                 AC_CHECK_HEADER(term.h,            curses_h_file=term.h)
2914           else c_switch_site="$save_c_switch_site"
2915           fi
2916       fi
2917    fi
2918    
2919    if test -n "$curses_h_file"; then
2920         AC_DEFINE_UNQUOTED([HAVE_CURSES_H], [1],
2921                            [There is a curses.h header file available])
2922    fi
2923
2924    if test -n "$termcap_h_file"; then
2925         AC_DEFINE_UNQUOTED([HAVE_TERMCAP_H], [1],
2926                            [There is a termcap.h header available])
2927    fi
2928
2929    if test -n "$term_h_file"; then
2930         AC_DEFINE_UNQUOTED([HAVE_TERM_H], [1],
2931                            [There is a term.h header available])
2932    fi
2933
2934    AC_DEFINE_UNQUOTED([CURSES_H_FILE], ["${curses_h_file-curses.h}"],
2935                       [The curses.h header file])
2936    AC_DEFINE_UNQUOTED([TERMCAP_H_FILE], ["${termcap_h_file-termcap.h}"],
2937                       [The termcap.h header file])
2938    AC_DEFINE_UNQUOTED([TERM_H_FILE], ["${term_h_file-term.h}"],
2939                       [The term.h header file])
2940 ],[
2941   for feature in ncurses curses termcap terminfo termlib gpm; do
2942     if eval "test -n \"\$with_${feature}\" -a \"\$with_${feature}\" != no" ; then
2943       AC_MSG_WARN([--with-${feature} ignored:  Not valid without TTY support])
2944     fi
2945     eval "with_${feature}=\"\""
2946   done
2947 ])
2948
2949 AS_IF([test "$with_tty" != "no" -a "$have_tty" != no], [
2950         AC_DEFINE([HAVE_TTY], [1],
2951                   [Include TTY support for SXEmacs])
2952         AC_DEFINE([HAVE_UNIXOID_EVENT_LOOP], [1],
2953                   [Include Unixoid event loop - TTY provided])
2954         SXE_ADD_SXEUITTY_OBJS([console-tty.o device-tty.o event-tty.o frame-tty.o objects-tty.o redisplay-tty.o cm.o])
2955 ])
2956
2957 AS_IF([test "$with_tty" != "no" -a "$have_tty" != no], [
2958   dnl General Purpose Mouse (libgpm) support
2959   AS_IF([test "$with_gpm" != "no"], [
2960     AC_CHECK_HEADER(gpm.h, [
2961       AC_CHECK_LIB(gpm, Gpm_Open, have_gpm=yes)])
2962     AS_IF([test "$have_gpm" = "yes"], [
2963       with_gpm=yes
2964       AC_DEFINE([HAVE_GPM], [1], [General Purpose Mouse (libgpm) is available])
2965       SXE_ADD_SXEUITTY_OBJS(gpmevent.o)
2966       SXE_PREPEND(-lgpm, LIBS) ],[ with_gpm=no ])
2967   ])
2968 ])
2969
2970 SXE_CHECK_UI_SUFFICIENCY
2971
2972 AS_IF([test -z "$window_system" -o "$window_system" = "none" ], [
2973     dnl It ought to be reasonable to have no output device at all, and only use
2974     dnl SXEmacs in --batch mode.
2975     AS_IF([test "$have_tty" = "no"],
2976        AC_MSG_ERROR([No window system nor TTY support. SXEmacs cannot be compiled.
2977 Check INSTALL and PROBLEMS files for hints on how to solve.]))
2978 ])
2979
2980 ## Uncertain options
2981 ## =================
2982 echo
2983 echo "Uncertain options"
2984 echo "================="
2985
2986 ## for native xml support one day
2987 SXE_LANG_CHECK_XML
2988 SXE_CHECK_SUFFICIENCY([libxml2], [xml language])
2989 ## for BoehmGC support one day
2990 SXE_CHECK_BDWGC
2991 SXE_CHECK_SUFFICIENCY([bdwgc], [Boehm-Demers-Weiser GC])
2992
2993 if test "$with_experimental_features_bdwgc" = "yes"; then
2994         AC_MSG_CHECKING([if bdwgc prerequisites are met])
2995         AC_MSG_RESULT([${have_bdwgc}])
2996         have_experimental_features_bdwgc=${have_bdwgc}
2997         if test "${have_bdwgc}" = "yes"; then
2998                 AC_DEFINE([EF_USE_BDWGC], [1],
2999                         [Whether to actually use the BDWGC!])
3000         fi
3001 fi
3002
3003
3004 dnl This one is for the static initializeds variables in
3005 dnl offix.c, so that the thing is dumped after lastfile.o
3006 AC_SUBST(dnd_objs)
3007
3008 dnl Autodetect dll support
3009
3010 LIBSTDCPP=
3011 AC_SUBST(LIBSTDCPP)
3012
3013
3014 ## Multimedia Options
3015 ## ==================
3016 echo
3017 echo "Multimedia Options"
3018 echo "=================="
3019
3020 dnl ----------------------
3021 dnl Graphics libraries
3022 dnl ----------------------
3023
3024 if test "$with_image_xpm" = "yes"; then
3025         SXE_MM_CHECK_XPM([have_image_xpm=yes], [have_image_xpm=no])
3026
3027         AC_MSG_CHECKING([for sufficient xpm support])
3028         if test "$have_image_xpm" = "yes"; then
3029                 AC_MSG_RESULT([yes])
3030                 AC_DEFINE([HAVE_XPM], [1], [Description here!])
3031                 SXE_PREPEND([-lXpm], [MM_LIBS])
3032         else
3033                 AC_MSG_RESULT([no])
3034                 have_image_xpm=no
3035         fi
3036 fi
3037 AM_CONDITIONAL([WITH_BDWGC],
3038         [test "$with_experimental_features_bdwgc" = "yes" -a \
3039               "$have_bdwgc" = "yes"])
3040
3041 if test "$with_image_xface" = "yes"; then
3042         SXE_MM_CHECK_XFACE([have_image_xface=yes], [have_image_xface=no])
3043
3044         AC_MSG_CHECKING([for sufficient xface support])
3045         if test "$have_image_xface" = "yes"; then
3046                 AC_MSG_RESULT([yes])
3047                 AC_DEFINE([HAVE_XFACE], [1], [dnl
3048                         Both compface.h and libcompface have been found.])
3049                 SXE_PREPEND([-lcompface], [MM_LIBS])
3050         else
3051                 AC_MSG_RESULT([no])
3052                 have_image_xface=no
3053         fi
3054 fi
3055
3056 if test "$with_image_gif" = "yes"; then
3057         SXE_MM_CHECK_GIF([have_image_gif=yes], [have_image_gif=no])
3058
3059         AC_MSG_CHECKING([for sufficient gif support])
3060         if test "$have_image_gif" = "yes"; then
3061                 AC_MSG_RESULT([yes])
3062                 AC_DEFINE([HAVE_GIF], [1], [Enable internal GIF decoding])
3063                 SXE_ADD_MM_OBJS(dgif_lib.o gif_io.o)
3064         else
3065                 AC_MSG_RESULT([no])
3066         fi
3067 fi
3068
3069 SXE_MM_SEARCH_INFLATE
3070
3071 if test "$with_image_jpeg" = "yes"; then
3072         SXE_MM_CHECK_JPEG([have_image_jpeg=yes], [have_image_jpeg=no])
3073
3074         AC_MSG_CHECKING([for sufficient jpeg support])
3075         if test "$have_image_jpeg" = "yes"; then
3076                 AC_MSG_RESULT([yes])
3077                 AC_DEFINE([HAVE_JPEG], [1], [
3078                         Both jpeglib.h and libjpeg have been found.])
3079                 SXE_PREPEND([-ljpeg], [MM_LIBS])
3080         else
3081                 AC_MSG_RESULT([no])
3082         fi
3083 fi
3084
3085 if test "$with_image_png" = "yes"; then
3086         AC_DEFINE([WITH_PNG], [1], [Define to 1 if png support is desired.])
3087         SXE_MM_CHECK_PNG([have_image_png="yes"], [have_image_png="no"])
3088
3089         SXE_MSG_CHECKING([for sufficient PNG support])
3090         SXE_MSG_RESULT([${sxe_cv_feat_png}])
3091         if test "$sxe_cv_feat_png" = "yes"; then
3092                 SXE_PREPEND_UNDUP([$PNG_CPPFLAGS], [MM_CPPFLAGS])
3093                 SXE_PREPEND_UNDUP([$PNG_LDFLAGS], [MM_LDFLAGS])
3094                 SXE_PREPEND([$PNG_LIBS], [MM_LIBS])
3095         fi
3096 fi
3097
3098 if test "$with_image_tiff" = "yes"; then
3099         SXE_MM_CHECK_TIFF([have_image_tiff=yes], [have_image_tiff=no])
3100
3101         AC_MSG_CHECKING([for sufficient TIFF support])
3102         if test "$have_image_tiff" = "yes"; then
3103                 AC_MSG_RESULT([yes])
3104                 AC_DEFINE([HAVE_TIFF], [1], [
3105                         Both tiffio.h and libtiff have been found.])
3106                 SXE_PREPEND([-ltiff], [MM_LIBS])
3107         else
3108                 AC_MSG_RESULT([no])
3109         fi
3110 fi
3111
3112 dnl Check for audio output and media stream libraries.
3113
3114 dnl internal media stream analysis support
3115 if test "$with_media_internal" != "no"; then
3116         need_media_internal=yes
3117         have_media_internal=yes
3118 fi
3119
3120 ## Since almost any of the below tests uses pkgconfig we make a
3121 ## once-for-all-times check now
3122 SXE_SEARCH_CONFIG_PROG([pkg-config])
3123 if test "$have_pkg_config" = "yes" -a -n "$with_site_prefixes"; then
3124         for dir in $with_site_prefixes; do
3125                 pkgcfg_dir="${dir}/lib/pkgconfig"
3126                 if test -n "$PKG_CONFIG_PATH"; then
3127                    PKG_CONFIG_PATH="$PKG_CONFIG_PATH":"$pkgcfg_dir"
3128                 else
3129                    PKG_CONFIG_PATH="$pkgcfg_dir"
3130                 fi
3131         done
3132         export PKG_CONFIG_PATH
3133 fi
3134
3135 dnl libsndfile support
3136 if test "$with_media_sndfile" != "no"; then
3137         SXE_MM_CHECK_SNDFILE([have_media_sndfile=yes], [have_media_sndfile=no])
3138
3139         AC_MSG_CHECKING([for sufficient sndfile support])
3140         if test "$have_media_sndfile" = "yes"; then
3141                 AC_MSG_RESULT([yes])
3142                 SNDFILE_LIBS=`$PKG_CONFIG --libs sndfile`
3143                 SNDFILE_CPPFLAGS=`$PKG_CONFIG --cflags sndfile`
3144                 SNDFILE_VERSION=`$PKG_CONFIG --modversion sndfile`
3145                 SXE_PREPEND([$SNDFILE_LIBS], [MM_LIBS])
3146                 SXE_PREPEND_UNDUP([$SNDFILE_CPPFLAGS], [MM_CPPFLAGS])
3147                 SXE_ADD_MM_OBJS([media-sndfile.o])
3148                 AC_DEFINE([HAVE_SNDFILE], [1],
3149                         [Whether we appear to have support for the sndfile library!])
3150                 AC_DEFINE_UNQUOTED([SNDFILE_VERSION], [$SNDFILE_VERSION],
3151                         [Version of the sndfile library!])
3152         else
3153                 AC_MSG_RESULT([no])
3154                 have_media_sndfile=no
3155         fi
3156 fi
3157
3158 dnl libavcodec/libavformat/ffmpeg support
3159 if test "$with_media_ffmpeg" != "no"; then
3160         SXE_MM_CHECK_FFMPEG([have_media_ffmpeg=yes], [have_media_ffmpeg=no])
3161
3162         AC_MSG_CHECKING([for sufficient FFmpeg support])
3163
3164         if test "$have_media_ffmpeg" = "yes"; then
3165                 AC_MSG_RESULT([yes])
3166                 FFMPEG_LIBS=`$PKG_CONFIG --libs libavformat`
3167                 FFMPEG_CPPFLAGS=`$PKG_CONFIG --cflags libavformat`
3168                 SXE_PREPEND($FFMPEG_LIBS, MM_LIBS)
3169                 SXE_PREPEND_UNDUP($FFMPEG_CPPFLAGS, MM_CPPFLAGS)
3170                 SXE_ADD_MM_OBJS([media-ffmpeg.o])
3171                 AC_DEFINE([HAVE_FFMPEG], [1], [Description here!])
3172         else
3173                 AC_MSG_RESULT([no])
3174                 have_media_ffmpeg=no
3175         fi
3176 fi
3177
3178 dnl sox support
3179 if test "$with_media_sox" != "no"; then
3180         SXE_MM_CHECK_SOX([have_media_sox=yes], [have_media_sox=no])
3181
3182         AC_MSG_CHECKING([for sufficient SoX support])
3183         if test "$sxe_cv_feat_sox" = "yes"; then
3184                 AC_MSG_RESULT([yes])
3185                 SXE_ADD_MM_OBJS([media-sox.o])
3186                 SXE_PREPEND_UNDUP([$sox_cppflags], [MM_CPPFLAGS])
3187                 SXE_PREPEND_UNDUP([$sox_ldflags], [MM_LDFLAGS])
3188                 SXE_PREPEND([$sox_libs], [MM_LIBS])
3189                 AC_DEFINE([HAVE_SOX], [1], [Description here!])
3190         else
3191                 AC_MSG_RESULT(no)
3192                 have_media_sox=no
3193         fi
3194 fi
3195
3196 dnl mad support
3197 if test "$with_media_mad" != "no"; then
3198         SXE_MM_CHECK_MAD([have_media_mad=yes], [have_media_mad=no])
3199
3200         AC_MSG_CHECKING([for sufficient mad support])
3201         if test "$have_media_mad" = "yes"; then
3202                 AC_MSG_RESULT([yes])
3203                 SXE_ADD_MM_OBJS([media-mad.o])
3204                 SXE_PREPEND([-lmad], [MM_LIBS])
3205                 AC_DEFINE([HAVE_MAD], [1], [Description here!])
3206         else
3207                 AC_MSG_RESULT(no)
3208                 have_media_mad=no
3209         fi
3210 fi
3211
3212 ## file/libmagic support
3213 if test "$with_media_magic" != "no"; then
3214         SXE_MM_CHECK_MAGIC([have_media_magic=yes], [have_media_magic=no])
3215
3216         AC_MSG_CHECKING([for sufficient magic support])
3217         if test "$have_media_magic" = "yes"; then
3218                 AC_MSG_RESULT([yes])
3219                 SXE_ADD_MM_OBJS([media-magic.o])
3220                 SXE_PREPEND([-lmagic], [MM_LIBS])
3221                 AC_DEFINE([HAVE_MAGIC], [1], [Whether libmagic is available])
3222         else
3223                 AC_MSG_RESULT([no])
3224                 have_media_magic=no
3225         fi
3226 fi
3227
3228
3229 dnl Autodetect OSS sound
3230 AS_MESSAGE([checking for OSS sound support])
3231 dnl test -z "$with_sound_oss" -a -n "$with_oss_sound_lib" && with_sound_oss=yes
3232
3233 dnl Check for Linux/BSD sound (called OSS)
3234 if test "$with_sound_oss" != "no"; then
3235         SXE_MM_CHECK_OSS([have_sound_oss=yes], [have_sound_oss=no])
3236
3237         AC_MSG_CHECKING([for sufficient OSS support])
3238         if test "$have_sound_oss" = "yes"; then
3239                 AC_MSG_RESULT([yes])
3240                 SXE_ADD_MM_OBJS([sound-oss.o])
3241                 AC_DEFINE([HAVE_INTERNAL_SOUND], [1], [Description here!])
3242                 AC_DEFINE([HAVE_OSS_SOUND], [1], [Description here!])
3243         else
3244                 AC_MSG_RESULT([no])
3245                 have_sound_oss=yes
3246         fi
3247 fi
3248
3249 dnl NAS Sound support
3250 if test "$with_sound_nas" != "no"; then
3251         SXE_MM_CHECK_NAS([have_sound_nas=yes], [have_sound_nas=no])
3252
3253         AC_MSG_CHECKING([for sufficient NAS support])
3254         if test "$have_sound_nas" = "yes"; then
3255                 AC_MSG_RESULT([yes])
3256                 AC_DEFINE([HAVE_NAS_SOUND], [1], [Description here!])
3257                 SXE_ADD_MM_OBJS([sound-nas.o])
3258                 SXE_PREPEND([-laudio], [MM_LIBS])
3259         else
3260                 AC_MSG_RESULT([no])
3261                 have_nas_sound=no
3262         fi
3263 fi
3264
3265 dnl ESD Sound support
3266 if test "$with_sound_esd" != "no"; then
3267         SXE_MM_CHECK_ESD([have_sound_esd=yes], [have_sound_esd=no])
3268
3269         AC_MSG_CHECKING([for sufficient ESD support])
3270         if test "$have_sound_esd" = "yes"; then
3271                 AC_MSG_RESULT([yes])
3272                 need_internal_media=yes
3273                 SXE_ADD_MM_OBJS([sound-esd.o])
3274                 ESD_LIBS=$("${ESD_CONFIG}" --libs)
3275                 SXE_PREPEND(["${ESD_LIBS}"], [MM_LIBS])
3276                 AC_DEFINE([HAVE_ESD_SOUND], [1], [Description here!])
3277         else
3278                 AC_MSG_RESULT([no])
3279                 have_esd_sound=no
3280         fi
3281 fi
3282
3283 dnl PulseAudio Sound support
3284 if test "$with_sound_pulse" != "no"; then
3285         SXE_MM_CHECK_PULSE([have_sound_pulse=yes], [have_sound_pulse=no])
3286
3287         AC_MSG_CHECKING([for sufficient PulseAudio support])
3288         if test "$have_sound_pulse" = "yes"; then
3289                 AC_MSG_RESULT([yes])
3290                 need_internal_media=yes
3291                 SXE_ADD_MM_OBJS([sound-pulse.o])
3292                 SXE_PREPEND($PULSE_LIBS, MM_LIBS)
3293                 SXE_PREPEND_UNDUP($PULSE_CFLAGS, MM_CPPFLAGS)
3294                 AC_DEFINE([HAVE_PULSE_SOUND], [1],
3295                         [Whether to put in support for PulseAudio.])
3296         else
3297                 AC_MSG_RESULT(no)
3298                 have_sound_pulse=no
3299         fi
3300 fi
3301
3302 dnl Jack Sound support
3303 if test "$with_sound_jack" != "no"; then
3304         SXE_MM_CHECK_JACK([have_sound_jack=yes], [have_sound_jack=no])
3305
3306         AC_MSG_CHECKING([for sufficient Jack support])
3307         if test "$have_sound_jack" = "yes"; then
3308                 AC_MSG_RESULT([yes])
3309                 dnl okay, we have Jack on the system, but we have no working
3310                 dnl interface to it :(
3311                 JACK_LIBS=`$PKG_CONFIG --libs jack`
3312                 JACK_VERSION=`$PKG_CONFIG --modversion jack`
3313                 need_internal_media=yes
3314                 SXE_ADD_MM_OBJS([sound-jack.o])
3315                 SXE_PREPEND([$JACK_LIBS], [MM_LIBS])
3316                 AC_DEFINE([HAVE_JACK_SOUND], [1], [Description here!])
3317                 AC_DEFINE_UNQUOTED([JACK_VERSION], [$JACK_VERSION],
3318                         [Description here!])
3319         else
3320                 AC_MSG_RESULT(no)
3321         fi
3322 fi
3323
3324 dnl alsa sound support
3325 if test "$with_sound_alsa" != "no"; then
3326         SXE_MM_CHECK_ALSA([have_sound_alsa=yes], [have_sound_alsa=no])
3327
3328         AC_MSG_CHECKING([for sufficient ALSA support])
3329         if test "$have_sound_alsa" = "yes"; then
3330                 AC_MSG_RESULT([yes])
3331                 SXE_ADD_MM_OBJS([sound-alsa.o])
3332                 SXE_PREPEND([-lasound], [MM_LIBS])
3333         else
3334                 AC_MSG_RESULT(no)
3335                 have_sound_alsa=no
3336         fi
3337 fi
3338
3339 dnl libao sound support
3340 if test "$with_sound_ao" != "no"; then
3341         SXE_MM_CHECK_AO([have_sound_ao=yes], [have_sound_ao=no])
3342
3343         AC_MSG_CHECKING([for sufficient AO support])
3344         if test "$have_sound_ao" = "yes"; then
3345                 AC_MSG_RESULT([yes])
3346                 AO_LIBS=`$PKG_CONFIG --libs ao`
3347                 ao_version=`$PKG_CONFIG --modversion ao`
3348                 SXE_ADD_MM_OBJS([sound-ao.o])
3349                 SXE_PREPEND($AO_LIBS, MM_LIBS)
3350                 AC_DEFINE([HAVE_AO_SOUND], [1], [Description here!])
3351                 AC_DEFINE_UNQUOTED([AO_VERSION], [$ao_version], [Description here!])
3352         else
3353                 AC_MSG_RESULT(no)
3354                 have_sound_ao=no
3355         fi
3356 fi
3357
3358 if test \
3359    "$have_sound_alsa \
3360     $have_sound_ao \
3361     $have_sound_esd \
3362     $have_sound_jack \
3363     $have_sound_nas \
3364     $have_sound_pulse" != "no no no no no no"; then
3365         AC_DEFINE([HAVE_AUDIO], [1], [Description here!])
3366 fi
3367 if test "$need_internal_media" = "yes"; then
3368         with_internal_media=yes
3369         AC_DEFINE([HAVE_INTERNAL_MEDIA], [1], [Description here!])
3370         SXE_ADD_MM_OBJS([media-internal.o])
3371 fi
3372 AC_SUBST([MM_LIBS])
3373 AC_SUBST([MM_CPPFLAGS])
3374 AC_SUBST([MM_LDFLAGS])
3375 SXE_SUBST_MM_OBJS
3376
3377
3378 ## Internationalisation Options
3379 ## ============================
3380 echo
3381 echo "Internationalisation Options"
3382 echo "============================"
3383
3384 dnl ----------------------
3385 dnl Mule-dependent options
3386 dnl ----------------------
3387
3388 dnl if test "$with_mule" = "yes" && test ! -d "$sxe_srcdir/lisp/mule"; then
3389 dnl     echo "Attempt to Build with Mule without Mule/Lisp"
3390 dnl     echo "Please install the SXEmacs/Mule tarball or"
3391 dnl     echo "rerun configure with --with-mule=no"
3392 dnl     exit 1
3393 dnl fi
3394
3395 if test "$with_file_coding" = "yes" && test "$with_mule" = "no"; then
3396   AC_DEFINE([FILE_CODING], [1], [Description here!])
3397   SXE_ADD_MULE_OBJS(file-coding.o)
3398 fi
3399
3400 if test "$with_mule" = "yes" ; then
3401         SXE_CHECK_MULE
3402
3403 else dnl "$with_mule" = "no"
3404         for feature in xim canna wnn; do
3405                 if eval "test -n \"\$with_${feature}\" -a \
3406                         \"\$with_${feature}\" != no" ; then
3407                         AC_MSG_WARN([--with-${feature} ignored:  Not valid without Mule support])
3408                 fi
3409                 eval "with_${feature}=no"
3410         done
3411 fi dnl with_mule
3412 SXE_SUBST_MULE_OBJS
3413 AM_CONDITIONAL([WITH_MULE], [test "$with_mule" = "yes"])
3414
3415
3416 dnl At this point, we know whether we need the motif lib or not.
3417 if test "$need_motif" = "yes" ; then
3418         SXE_PREPEND([-lXm], [libs_x])
3419         dnl AIX needs the following library for use with Motif
3420         AC_CHECK_LIB([i18n], [layout_object_getvalue])
3421         if test "$ac_cv_lib_i18n_layout_object_getvalue" = "yes"; then
3422                 SXE_PREPEND([-li18n], [libs_x])
3423         fi
3424 fi
3425
3426 dnl getaddrinfo() is borked under hpux11
3427 if test "$ac_cv_func_getaddrinfo" != "no" ; then
3428   case "$opsys" in
3429     hpux11 )
3430       AC_MSG_WARN([Use of getaddrinfo is disabled for HP-UX 11.XX.])
3431       ac_cv_func_getaddrinfo=no
3432       ;;
3433   esac
3434 fi
3435
3436
3437 ## Database Options
3438 ## ================
3439 echo
3440 echo "Database Options"
3441 echo "================"
3442
3443 dnl Database support
3444 dnl We do not necessarily have to have libdb/lib(g)dbm for DB/(G)DBM support.
3445 dnl On FreeBSD, both DB and DBM are part of libc.
3446 dnl By default, we check for DBM support in libgdbm, then libc, then libdbm.
3447
3448 ## initialise values
3449 have_database_berkdb=no
3450 have_database_gdbm=no
3451 have_database_dbm=no
3452
3453 if test "$with_database_gdbm $with_database_dbm $with_database_berkdb" \
3454    != "no no no"; then
3455         AS_MESSAGE(checking for database support)
3456 fi
3457
3458 dnl Check for ndbm.h, required for either kind of DBM support.
3459 if test "$with_database_gdbm $with_database_dbm" != "no no"; then
3460         SXE_CHECK_NDBM
3461         if test "$sxe_cv_feat_ndbm" = "no"; then
3462                 have_database_gdbm="no"
3463                 have_database_dbm="no"
3464         fi
3465 fi
3466
3467 dnl Check for DBM support in libgdbm or libgdbm_compat.
3468 if test "$with_database_gdbm" != "no"; then
3469         SXE_CHECK_GDBM
3470
3471         if test "$sxe_cv_feat_gdbm" = "yes"; then
3472                 have_database_gdbm="yes"
3473         else
3474                 have_database_gdbm="no"
3475         fi
3476 fi
3477
3478 dnl Check for DBM support in libc and libdbm.
3479 if test "$with_database_dbm" != "no"; then
3480         SXE_CHECK_DBM
3481
3482         if test "$sxe_cv_feat_gdbm" != "yes" -a \
3483                 "$sxe_cv_feat_dbm" = "yes"; then
3484                 have_database_dbm="yes"
3485         else
3486                 have_database_dbm="no"
3487         fi
3488 fi
3489
3490 dnl Check for Berkeley DB.
3491 if test "$with_database_berkdb" != "no"; then
3492         SXE_CHECK_BERKDB
3493
3494         if test "$sxe_cv_feat_berkdb" = "yes"; then
3495                 have_database_berkdb="yes"
3496         else
3497                 have_database_berkdb="no"
3498         fi
3499 fi
3500
3501 if test "$have_database_gdbm $have_database_dbm $have_database_berkdb" \
3502      != "no no no"; then
3503         AC_DEFINE([HAVE_DATABASE], [1], [Description here!])
3504         SXE_ADD_DB_OBJS([database.o])
3505
3506         SXE_CHECK_NDBM_BERKDB_CONFLICT
3507         if test "$sxe_cv_db_ndbm_berkdb_conflict" = "yes"; then
3508                 ## can't do nothing because the way we designed it
3509                 ## is going to conflict at compile time
3510                 have_database_gdbm="no"
3511                 have_database_dbm="no"
3512
3513         elif test "$have_database_gdbm $have_database_dbm" != "no no"; then
3514                 AC_DEFINE([HAVE_DBM], [1], [Description here!])
3515
3516                 ## Also, tell make about the DBM support we detected.
3517                 if test -n "$libdbm"; then
3518                         SXE_PREPEND([$libdbm], [DB_LIBS])
3519                 fi
3520         fi
3521 fi
3522
3523
3524 dnl Autodetect LDAP
3525 if test "$with_ldap" != "no"; then
3526         SXE_CHECK_LDAP
3527 fi
3528 if test "$have_ldap" = "yes"; then
3529         AC_DEFINE([HAVE_LDAP], [1], [Description here!])
3530         SXE_ADD_DB_OBJS(eldap.o)
3531         if test "$have_ldap_des" = "yes" ; then
3532                 SXE_PREPEND(-ldes, DB_LIBS)
3533         fi
3534         if test "$have_ldap_krb" = "yes" ; then
3535                 SXE_PREPEND(-lkrb, DB_LIBS)
3536         fi
3537         if test "$have_ldap_lber" = "yes" ; then
3538                 SXE_PREPEND(-llber, DB_LIBS)
3539         fi
3540         SXE_PREPEND(-lldap, DB_LIBS)
3541
3542         dnl save our values until here
3543         save_LIBS="$LIBS"
3544         LIBS="$DB_LIBS $LIBS"
3545         AC_CHECK_FUNCS(
3546                 [ldap_set_option ldap_get_lderrno ldap_result2error ldap_parse_result])
3547         dnl and restore
3548         LIBS="$save_LIBS"
3549 fi
3550
3551 dnl Autodetect PostgreSQL
3552 if test "x$with_postgresql" != "xno"; then
3553         SXE_CHECK_POSTGRESQL
3554 fi
3555 SXE_SUBST_DB_OBJS
3556
3557
3558 dnl Usage tracking (undocumented and likely unused option)
3559 if test "$usage_tracking" = "yes"; then
3560   AC_DEFINE([USAGE_TRACKING], [1], [Description here!])
3561   SXE_PREPEND(-Bstatic -lut -Bdynamic, LIBS)
3562 fi
3563
3564 dnl Unfortunately, just because we can link doesn't mean we can run.
3565 dnl One of the above link tests may have succeeded but caused resulting
3566 dnl executables to fail to run.  Also any tests using AC_RUN_IFELSE will
3567 dnl have reported incorrect results.
3568 AC_RUN_IFELSE([AC_LANG_SOURCE([[int main(int c,char *v[]){return 0;}]])],[:],[
3569   echo ""
3570   echo "*** PANIC *** The C compiler can no longer build working executables."
3571   echo "*** PANIC *** Please examine the tail of config.log for runtime errors."
3572   echo "*** PANIC *** The most likely reason for this problem is that configure"
3573   echo "*** PANIC *** links with shared libraries, but those libraries cannot be"
3574   echo "*** PANIC *** found at run time."
3575   echo "*** PANIC ***"
3576   echo "*** PANIC *** On a Linux system, edit /etc/ld.so.conf and re-run ldconfig."
3577   echo "*** PANIC *** On other systems, try telling configure where to find the"
3578   echo "*** PANIC *** shared libraries using the --with-site-runtime-libraries option"
3579   echo "*** PANIC ***"
3580   echo "*** PANIC *** Another way to shoot yourself in the foot is to specify"
3581   echo "*** PANIC *** --with-FEATURE when FEATURE is not actually installed"
3582   echo "*** PANIC *** on your system.  Don't do that."
3583   exit 1], [AS_MESSAGE(cannot cross-compile)])
3584
3585 dnl Process support
3586 AC_DEFINE([HAVE_UNIX_PROCESSES], [1], [Description here!])
3587
3588 dnl --------------------------------
3589 dnl Compute SUBST-itutable variables
3590 dnl --------------------------------
3591
3592 dnl We ignore (C|LD)_SWITCH_X_(MACHINE|SYSTEM)
3593 dnl Use SXE_CONSECUTIVE_UNDUP instead of plain assignment statements to remove extraneous blanks
3594 if test "$with_module_support" = "yes"; then
3595         ld_libs_module=
3596 else
3597         SXE_CONSECUTIVE_UNDUP(ld_libs_module, $ldap_libs $postgresql_libs)
3598 fi
3599
3600 SXE_UNDUP(CFLAGS, $CFLAGS)
3601 SXE_UNDUP(c_switch_general, -DHAVE_CONFIG_H $c_switch_site $c_switch_machine $c_switch_system $CFLAGS $CPPFLAGS)
3602 SXE_UNDUP(c_switch_window_system, $c_switch_x_site $X_CFLAGS)
3603 SXE_UNDUP(c_switch_all, $c_switch_general $c_switch_window_system)
3604 SXE_UNDUP(ld_switch_general, $ld_switch_site $ld_switch_machine $ld_switch_system $ld_switch_run)
3605 SXE_UNDUP(ld_switch_window_system, $ld_switch_x_site)
3606 SXE_UNDUP(ld_switch_all, $ld_switch_general $ld_switch_window_system)
3607 dnl Since some systems need libs to be restated later, we can't just dedup, we can only safely dedup
3608 dnl consecutive occurrences
3609 SXE_CONSECUTIVE_UNDUP(ld_libs_general, $LIBS $libs_machine $libs_system $libs_standard)
3610 SXE_CONSECUTIVE_UNDUP(ld_libs_window_system, $X_EXTRA_LIBS $libs_x $X_PRE_LIBS)
3611 SXE_CONSECUTIVE_UNDUP(ld_libs_all, $OPENSSL_LIBS $DB_LIBS $ENT_LIBS $MM_LIBS $ld_libs_window_system $ld_libs_general $ld_libs_module)
3612
3613 dnl For no-module builds, make the src dir last
3614 if test "$with_module_support" = "no"; then
3615         SXE_APPEND(src, MAKE_SUBDIR)    dnl is that still important?
3616 fi
3617
3618 EMACS=$sxe_blddir/src/$PROGNAME
3619 AC_SUBST(EMACS)
3620
3621 dnl Compute lists of Makefiles and subdirs
3622 AC_SUBST(SRC_SUBDIR_DEPS)
3623 internal_makefile_list="Makefile.in"
3624 SUBDIR_MAKEFILES=''
3625 test -d lock || mkdir lock
3626 for dir in $MAKE_SUBDIR; do
3627   case "$dir" in */* ) dnl Implement mkdir -p
3628     ( for d in `echo $dir | sed 's:/: :g'` ; do
3629         test -d "$d" || mkdir "$d"; cd "$d"
3630       done ) ;;
3631    * ) test -d "$dir" || mkdir "$dir" ;;
3632   esac
3633   SXE_SPACE(SUBDIR_MAKEFILES, $SUBDIR_MAKEFILES $dir/Makefile $dir/Makefile)
3634   SXE_SPACE(internal_makefile_list, $internal_makefile_list $dir/Makefile.in)
3635 done
3636
3637 AC_SUBST(INSTALL_ARCH_DEP_SUBDIR)
3638 AC_SUBST(MAKE_SUBDIR)
3639 AC_SUBST(MAKE_AM_SUBDIR)
3640 AC_SUBST(SUBDIR_MAKEFILES)
3641
3642 dnl ----------------------------------------------
3643 dnl Create some auxiliary files for developers.
3644 dnl ----------------------------------------------
3645
3646 dnl Create a useful TAGS file
3647 if test -f "$sxe_srcdir/TAGS" -a ! -f "TAGS"; then
3648   test "$extra_verbose" = "yes" && echo "creating TAGS"
3649   echo "\f
3650 $sxe_srcdir/TAGS,include" > "TAGS"
3651 fi
3652
3653 dnl Create top level .sbinit for Sun compilers
3654 if test "$__SUNPRO_C" = "yes"; then
3655   test "$extra_verbose" = "yes" && echo "creating .sbinit"
3656   ( echo "# For use with Sun WorkShop's Source browser."
3657     echo "# See sbquery(1) and sbinit(4) for more information"
3658     for dir in $MAKE_SUBDIR; do echo "import $dir"; done
3659   ) > .sbinit
3660 fi
3661
3662 ### whether to build with profile.o
3663 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3664 int main(int c, char *v[])
3665 {
3666 #ifdef HAVE_SETITIMER
3667         return 1;
3668 #else
3669         return 0;
3670 #endif
3671 }]])], [./conftest; have_setitimer=$?],
3672         [have_setitimer=$?],[have_setitimer=0])
3673 AM_CONDITIONAL([HAVE_SETITIMER], [test "$have_setitimer" = "1"])
3674
3675
3676 dnl There are no more compile tests; remove the core they created.
3677 rm -f core
3678
3679 dnl --------------------------------------------------
3680 dnl Substitute into Makefile, config.h and sxe-paths.h
3681 dnl --------------------------------------------------
3682
3683 dnl what sort of things to edit into Makefile, config.h and sxe-paths.h
3684 dnl configuration here uncanonicalized to avoid exceeding size limits.
3685
3686 AC_SUBST(PROGNAME)
3687 AC_SUBST(MULE)
3688 AC_SUBST(HAVE_LIBFFI)
3689 AC_SUBST(version)
3690 AC_SUBST(VERSION)
3691 AC_SUBST(old_version)
3692 AC_SUBST(inststaticdir)
3693 AC_SUBST(instvardir)
3694 AC_SUBST(instvarsepdir)
3695 AC_SUBST(sxe_srcdir)
3696 AC_SUBST(emodsrcdir)
3697 AC_SUBST(sxe_blddir)
3698 AC_SUBST(emodblddir)
3699 AC_SUBST(bindir)
3700 AC_SUBST(datarootdir)
3701 AC_SUBST(datadir)
3702 AC_SUBST(statedir)
3703 AC_SUBST(libdir)
3704 AC_SUBST(mandir)
3705 AC_SUBST(extra_includes)
3706
3707 AC_SUBST(prefix)
3708 AC_SUBST(PREFIX_USER_DEFINED)
3709 dnl Yo, Stephen Bourne!  I want to marry you!
3710 PREFIX=$prefix
3711 while true; do
3712   case "$PREFIX" in
3713     *\$* ) eval "PREFIX=\"${PREFIX}\"" ;;
3714     *) break ;;
3715   esac
3716 done
3717 AC_SUBST(PREFIX)
3718
3719 AC_SUBST(exec_prefix)
3720 AC_SUBST(EXEC_PREFIX_USER_DEFINED)
3721 EXEC_PREFIX=$exec_prefix
3722 while true; do
3723   case "$EXEC_PREFIX" in
3724     *\$* ) eval "EXEC_PREFIX=\"${EXEC_PREFIX}\"" ;;
3725     *) break ;;
3726   esac
3727 done
3728 AC_SUBST(EXEC_PREFIX)
3729
3730 AC_SUBST(infodir)
3731 AC_SUBST(INFODIR_USER_DEFINED)
3732 INFODIR=$infodir
3733 while true; do
3734   case "$INFODIR" in
3735     *\$* ) eval "INFODIR=\"${INFODIR}\"" ;;
3736     *) break ;;
3737   esac
3738 done
3739 AC_SUBST(INFODIR)
3740
3741 AC_SUBST(infopath,$with_infopath)
3742 AC_SUBST(INFOPATH_USER_DEFINED)
3743 INFOPATH=$with_infopath
3744 while true; do
3745   case "$INFOPATH" in
3746     *\$* ) eval "INFOPATH=\"${INFOPATH}\"" ;;
3747     *) break ;;
3748   esac
3749 done
3750 AC_SUBST(INFOPATH)
3751
3752 if test -z "$with_module_path"; then
3753     with_module_path="~/.sxemacs/${configuration}/modules:${libdir}/${PROGNAME}/${configuration}/site-modules:${libdir}/${instvardir}/${configuration}/modules"
3754 fi
3755
3756 AC_SUBST(module_path,$with_module_path)
3757 AC_SUBST(MODULE_PATH_USER_DEFINED)
3758 MODULE_PATH=$with_module_path
3759 while true; do
3760   case "$MODULE_PATH" in
3761     *\$* ) eval "MODULE_PATH=\"${MODULE_PATH}\"" ;;
3762     *) break ;;
3763   esac
3764 done
3765 AC_SUBST(MODULE_PATH)
3766
3767 if test -z "$with_package_prefix" ; then
3768   with_package_prefix=${prefix}/share/sxemacs
3769 fi
3770
3771 if test -z "$with_package_path" && test -n "$with_package_prefix" ; then
3772   if test "$with_mule" = "yes" ; then
3773     with_package_path="~/.sxemacs/site-packages:~/.sxemacs/sxemacs-packages:~/.sxemacs/xemacs-packages:~/.sxemacs/mule-packages"
3774     with_package_path="${with_package_path}:${with_package_prefix}/site-packages:${with_package_prefix}/sxemacs-packages:${with_package_prefix}/xemacs-packages:${with_package_prefix}/mule-packages"
3775   else
3776     with_package_path="~/.sxemacs/site-packages:~/.sxemacs/sxemacs-packages:~/.sxemacs/xemacs-packages"
3777     with_package_path="${with_package_path}:${with_package_prefix}/site-packages:${with_package_prefix}/sxemacs-packages:${with_package_prefix}/xemacs-packages"
3778   fi
3779 fi
3780
3781 AC_SUBST(package_path,$with_package_path)
3782 AC_SUBST(PACKAGE_PATH_USER_DEFINED)
3783 PACKAGE_PATH=$with_package_path
3784 while true; do
3785   case "$PACKAGE_PATH" in
3786     *\$* ) eval "PACKAGE_PATH=\"${PACKAGE_PATH}\"" ;;
3787     *) break ;;
3788   esac
3789 done
3790 AC_SUBST(PACKAGE_PATH)
3791
3792 AC_SUBST(lispdir, $with_lispdir)
3793 AC_SUBST(LISPDIR_USER_DEFINED)
3794 LISPDIR=$with_lispdir
3795 while true; do
3796   case "$LISPDIR" in
3797     *\$* ) eval "LISPDIR=\"${LISPDIR}\"" ;;
3798     *) break ;;
3799   esac
3800 done
3801 AC_SUBST(LISPDIR)
3802
3803 AC_SUBST(moduledir,$with_moduledir)
3804 AC_SUBST(MODULEDIR_USER_DEFINED)
3805 MODULEDIR=$with_moduledir
3806 while true; do
3807   case "$MODULEDIR" in
3808     *\$* ) eval "MODULEDIR=\"${MODULEDIR}\"" ;;
3809     *) break ;;
3810   esac
3811 done
3812 AC_SUBST(MODULEDIR)
3813
3814 AC_SUBST([sitelispdir], [$with_sitelispdir])
3815 AC_SUBST([SITELISPDIR_USER_DEFINED])
3816 SITELISPDIR=$sitelispdir
3817 while true; do
3818   case "$SITELISPDIR" in
3819     *\$* ) eval "SITELISPDIR=\"${SITELISPDIR}\"" ;;
3820     *) break ;;
3821   esac
3822 done
3823 AC_SUBST(SITELISPDIR)
3824
3825 AC_SUBST(sitemoduledir,$with_sitemoduledir)
3826 AC_SUBST(SITEMODULEDIR_USER_DEFINED)
3827 SITEMODULEDIR=$with_sitemoduledir
3828 while true; do
3829   case "$SITEMODULEDIR" in
3830     *\$* ) eval "SITEMODULEDIR=\"${SITEMODULEDIR}\"" ;;
3831     *) break ;;
3832   esac
3833 done
3834 AC_SUBST(SITEMODULEDIR)
3835
3836 AC_SUBST(etcdir,$with_etcdir)
3837 AC_SUBST(ETCDIR_USER_DEFINED)
3838 ETCDIR=$with_etcdir
3839 while true; do
3840   case "$ETCDIR" in
3841     *\$* ) eval "ETCDIR=\"${ETCDIR}\"" ;;
3842     *) break ;;
3843   esac
3844 done
3845 AC_SUBST(ETCDIR)
3846
3847 AC_SUBST(archlibdir,$with_archlibdir)
3848 AC_SUBST(ARCHLIBDIR_USER_DEFINED)
3849 ARCHLIBDIR=$with_archlibdir
3850 while true; do
3851   case "$ARCHLIBDIR" in
3852     *\$* ) eval "ARCHLIBDIR=\"${ARCHLIBDIR}\"" ;;
3853     *) break ;;
3854   esac
3855 done
3856 AC_SUBST(ARCHLIBDIR)
3857
3858 AC_SUBST(docdir,$with_docdir)
3859 AC_SUBST(DOCDIR_USER_DEFINED)
3860 DOCDIR=$with_docdir
3861 while true; do
3862   case "$DOCDIR" in
3863     *\$* ) eval "DOCDIR=\"${DOCDIR}\"" ;;
3864     *) break ;;
3865   esac
3866 done
3867 AC_SUBST(DOCDIR)
3868
3869 AC_SUBST(docdir)
3870 AC_SUBST(bitmapdir)
3871
3872 dnl The following flags combine all the information from:
3873 dnl - command line options (user always gets priority)
3874 dnl - user environment variables
3875 dnl - determined by configure
3876 dnl - the s&m header files (required for ellcc)
3877 AC_SUBST(machfile)
3878 AC_SUBST(opsysfile)
3879 AC_SUBST(c_switch_general)
3880 AC_SUBST(c_switch_window_system)
3881 AC_SUBST(c_switch_all)
3882 AC_SUBST(ld_switch_general)
3883 AC_SUBST(ld_switch_window_system)
3884 AC_SUBST(ld_switch_all)
3885 AC_SUBST(ld_libs_general)
3886 AC_SUBST(ld_libs_window_system)
3887 AC_SUBST(ld_libs_all)
3888 AC_SUBST(CFLAGS)
3889 AC_SUBST(CPPFLAGS)
3890 AC_SUBST(LDFLAGS)
3891 RECURSIVE_MAKE_ARGS="\$(MFLAGS) CC='\$(CC)' CFLAGS='\$(CFLAGS)' LDFLAGS='\$(LDFLAGS)' CPPFLAGS='\$(CPPFLAGS)'"
3892 if test -z "$MAKE"; then
3893         MAKE=make
3894 fi
3895 case `$MAKE --version 2>/dev/null` in
3896    GNU\ Make*)
3897         AM_MAKEFLAGS="-w $AM_MAKEFLAGS"
3898         RECURSIVE_MAKE_ARGS="-w $RECURSIVE_MAKE_ARGS"
3899    ;;
3900    *)
3901         echo ===================================
3902         echo $MAKE does not seem to be GNU Make
3903         echo If you find makefile errors please try using GNU Make as some
3904         echo autoconf constructs may not be proper for your make variant
3905         echo ===================================
3906    ;;
3907 esac
3908 AC_SUBST(RECURSIVE_MAKE_ARGS)
3909 AC_SUBST(AM_MAKEFLAGS)
3910
3911 AC_SUBST(sound_cflags)
3912 AC_SUBST(AR)
3913 AC_SUBST(RANLIB)
3914
3915 AC_SUBST(SXEMACS_CC)
3916 AC_SUBST(SXE_CFLAGS)
3917
3918 SXE_SUBST_CORE_OBJS()
3919
3920 SXE_SUBST_CRUFT_OBJS
3921
3922 dnl The default is yes
3923 if test "$with_prefix" = "yes"; then
3924   AC_DEFINE([PREFIX_USER_DEFINED], [1], [Description here!])
3925 fi
3926
3927 dnl Should this stay even though --with-site-modules is no longer an
3928 dnl option?  It is used in emacs.c for when the -no-site-modules cmd line
3929 dnl opt is used.  That cmd line opt definitely has usefullness.  Sebastian?
3930 dnl --SY.
3931 dnl The default is yes
3932 if test "$with_site_modules" = "no"; then
3933   AC_DEFINE([INHIBIT_SITE_MODULES], [1], [Description here!])
3934 fi
3935
3936 dnl SXE_SPACE(ac_configure_args, $ac_configure_args)
3937 AC_DEFINE_UNQUOTED([EMACS_CONFIGURATION], ["$ac_cv_build"], [Description here!])
3938 AC_DEFINE_UNQUOTED([EMACS_CONFIG_OPTIONS], ["$ac_configure_args"], [Description here!])
3939
3940 AC_SUBST([srcdir_equals_blddir_p])
3941
3942 dnl Following are deprecated
3943 null_string=""
3944 AC_DEFINE_UNQUOTED([LD_SWITCH_X_SITE], [$null_string], [Description here!])
3945 AC_DEFINE_UNQUOTED([LD_SWITCH_X_SITE_AUX], [$null_string], [Description here!])
3946 AC_DEFINE_UNQUOTED([C_SWITCH_X_SITE], [$null_string], [Description here!])
3947 AC_DEFINE_UNQUOTED([LD_SWITCH_SITE], [$null_string], [Description here!])
3948 AC_DEFINE_UNQUOTED([C_SWITCH_SITE], [$null_string], [Description here!])
3949
3950 dnl Note: as a general rule, *only* define things here that are not
3951 dnl autodetected.  For things that are autodetected, define them
3952 dnl at the point where the autodetection occurs or would occur,
3953 dnl so that the user gets immediate feedback on the results of the
3954 dnl autodetection.
3955
3956 if test "$GNU_MALLOC" = "yes"; then
3957         AC_DEFINE([GNU_MALLOC], [1], [Description here!])
3958         SXE_ADD_MEMALLOC_OBJS(vm-limit.o)
3959         if test "$doug_lea_malloc" != "yes"; then
3960                 SXE_ADD_MEMALLOC_OBJS(gmalloc.o)
3961         fi
3962         if test "$with_error_checking_malloc" = "yes"; then
3963                 dnl SXE_ADD_MEMALLOC_OBJS(free-hook.o)
3964                 :
3965         fi
3966 elif test "$with_system_malloc" = "yes" -o "$system_malloc" = "yes"; then
3967         AC_DEFINE([USE_SYSTEM_MALLOC], [1], [Description here!])
3968         AC_DEFINE([SYSTEM_MALLOC], [1], [Description here!])
3969 elif test "$with_debug_malloc"  = "yes"; then
3970         AC_DEFINE([USE_DEBUG_MALLOC], [1], [Description here!])
3971         AC_DEFINE([USE_SYSTEM_MALLOC], [1], [Description here!])
3972         AC_DEFINE([SYSTEM_MALLOC], [1], [Description here!])
3973         SXE_APPEND(-ldmalloc, MEMALLOC_LIBS)
3974 else
3975         SXE_ADD_MEMALLOC_OBJS([malloc.o])
3976 fi
3977 test "$GCC" = "yes" && \
3978         AC_DEFINE([USE_GCC], [1], [Description here!])
3979 test "$with_external_widget" = "yes" && \
3980         AC_DEFINE([EXTERNAL_WIDGET], [1], [Description here!])
3981 test "$with_quick_build" = "yes" && \
3982         AC_DEFINE([QUICK_BUILD], [1], [Description here!])
3983 if test "$with_purify" = "yes"; then
3984         AC_DEFINE([PURIFY], [1], [Description here!])
3985         AC_DEFINE([XLIB_ILLEGAL_ACCESS], [1], [Description here!])
3986 fi
3987 if test "$with_quantify" = "yes"; then
3988         AC_DEFINE([QUANTIFY], [1], [Description here!])
3989         AC_DEFINE([XLIB_ILLEGAL_ACCESS], [1], [Description here!])
3990 fi
3991 test "$with_pop" = "yes" && \
3992         AC_DEFINE([MAIL_USE_POP], [1], [Description here!])
3993 test "$with_hesiod" = "yes" && \
3994         AC_DEFINE([HESIOD], [1], [Description here!])
3995 test "$with_regex_malloc" = "yes" && \
3996         AC_DEFINE([REGEX_MALLOC], [1], [Description here!])
3997 test "$with_ipv6_cname" = "yes" && \
3998         AC_DEFINE([IPV6_CANONICALIZE], [1], [Description here!])
3999 if test "$with_pdump" = "yes"; then
4000         AC_DEFINE([PDUMP], [1], [Description here!])    dnl deprecated!
4001         AC_DEFINE([WITH_PDUMP], [1], [Description here!])
4002 fi
4003
4004 AM_CONDITIONAL([WITH_EXTW], [test "$with_external_widget" = "yes"])
4005 AM_CONDITIONAL([WITH_PDUMP], [test "$with_pdump" = "yes"])
4006 AC_SUBST([MEMALLOC_LIBS])
4007 SXE_SUBST_MEMALLOC_OBJS
4008
4009
4010 AC_DEFINE_UNQUOTED([USER_FULL_NAME], [pw->pw_gecos], [dnl
4011         USER_FULL_NAME returns a string that is the user's full name.
4012         It can assume that the variable `pw' points to the password file
4013         entry for this user.
4014
4015         At some sites, the pw_gecos field contains the user's full name.
4016         If neither this nor any other field contains the right thing, use
4017         pw_name, giving the user's login name, since that is better than
4018         nothing.])
4019
4020 AC_DEFINE([SIGTYPE], [RETSIGTYPE], [SIGTYPE is the macro we actually use])
4021 AC_DEFINE([SIGRETURN], [return], [SIGTYPE is the macro we actually use])
4022
4023 ## finally, redefine VERSION; this has to be done after all tests on C sources
4024 ## were run because otherwise the symbol VERSION would be defined twice and
4025 ## the C compiler would warn, sigh, and due to this stupid -Werror flag we ...
4026 ## tadadada ... will fail to run _any_ C test successfully
4027 AC_DEFINE_UNQUOTED([VERSION], ["$version"], [Version of SXEmacs.])
4028
4029 AH_TOP([
4030 #ifndef INCLUDED_sxe_config_h_
4031 #define INCLUDED_sxe_config_h_
4032
4033 #ifndef NOT_C_CODE
4034 #if defined (__GNUC__)
4035 #define alloca __builtin_alloca
4036 #elif defined __DECC
4037 #include <alloca.h>
4038 #pragma intrinsic(alloca)
4039 #elif defined __INTEL_COMPILER && defined HAVE_ALLOCA_H
4040 /* defer #include to end of file */
4041 #elif defined HAVE_ALLOCA_H
4042 #include <alloca.h>
4043 #elif defined(_AIX)
4044 #pragma alloca
4045 #elif ! defined (alloca)
4046 void *alloca();
4047 #endif
4048 #endif  /* C code */
4049 ])
4050
4051 AH_BOTTOM([
4052 /* The configuration script may define `opsysfile' to be the name of
4053    the s/...h file that describes your operating system.
4054    The file name is chosen based on the configuration name. */
4055
4056 #ifdef config_opsysfile
4057 #include config_opsysfile
4058 #endif
4059
4060 /* The configuration script may define `machfile' to be the name of
4061    the m/...h file that describes the machine you are using.
4062    The file name is chosen based on the configuration name. */
4063
4064 #ifdef config_machfile
4065 #include config_machfile
4066 #endif
4067
4068 /* basic system calls */
4069 #if defined (INTERRUPTIBLE_IO) || defined (DEBUG_ENCAPSULATION)
4070 # define ENCAPSULATE_READ
4071 # define ENCAPSULATE_WRITE
4072 #endif
4073 #if defined (INTERRUPTIBLE_OPEN) || defined (MULE) || defined (DEBUG_ENCAPSULATION)
4074 # define ENCAPSULATE_OPEN
4075 #endif
4076 #if defined (INTERRUPTIBLE_CLOSE) || defined (DEBUG_ENCAPSULATION)
4077 # define ENCAPSULATE_CLOSE
4078 #endif
4079 /* stdio calls */
4080 #if defined (INTERRUPTIBLE_IO) || defined (DEBUG_ENCAPSULATION)
4081 # define ENCAPSULATE_FREAD
4082 # define ENCAPSULATE_FWRITE
4083 #endif
4084 #if defined (INTERRUPTIBLE_OPEN) || defined (MULE) || defined (DEBUG_ENCAPSULATION)
4085 # define ENCAPSULATE_FOPEN
4086 #endif
4087 #if defined (INTERRUPTIBLE_CLOSE) || defined (DEBUG_ENCAPSULATION)
4088 # define ENCAPSULATE_FCLOSE
4089 #endif
4090
4091 #if defined (HAVE_SOCKS) && !defined (DO_NOT_SOCKSIFY)
4092 #define accept Raccept
4093 #define bind Rbind
4094 #define connect Rconnect
4095 #define getsockname Rgetsockname
4096 #define listen Rlisten
4097 #endif                          /* HAVE_SOCKS && !DO_NOT_SOCKSIFY */
4098
4099 #ifndef NOT_C_CODE              /* Actually means C or C++ */
4100 # if defined (__cplusplus)
4101 /* Avoid C++ keywords used as ordinary C identifiers */
4102 #  define class c_class
4103 #  define new   c_new
4104 #  define this  c_this
4105 #  define catch c_catch
4106 #  define EXTERN_C extern "C"
4107 # else                          /* C code */
4108 #  define EXTERN_C extern
4109 # endif
4110 #endif                          /* C or C++ */
4111 /* Strictly speaking, only int or unsigned int are valid types in a
4112    bitfield.  In practice, we would like to use enums as bitfields.
4113    The following should just result in warning avoidance:
4114    warning: nonportable bit-field type */
4115 #ifdef __GNUC__
4116 #define enum_field(enumeration_type) enum enumeration_type
4117 #else
4118 #define enum_field(enumeration_type) unsigned int
4119 #endif
4120
4121 #ifndef NOT_C_CODE
4122 #if defined __INTEL_COMPILER && defined HAVE_ALLOCA_H
4123 /* icc's alloca.h pulls in <features.h>,
4124    but that must be done after _GNU_SOURCE and friends are defined */
4125 #include <alloca.h>
4126 #endif
4127 #endif                          /* C code */
4128
4129 #endif  /* INCLUDED_sxe_config_h_ */
4130 ])
4131
4132
4133 dnl -------------------------------------------------------------------------
4134 dnl -------------------------------
4135 dnl Report on what we decided to do
4136 dnl -------------------------------
4137
4138 dnl #### We should tag this as the _build_ environment.
4139 dnl Before doing that, though, must check if tools care about line 1.
4140
4141 (
4142 dnl /etc/osversion is on SONY NEWS-OS
4143 if test -f /etc/osversion; then dnl SONY NEWS-OS
4144   echo "osversion: `cat /etc/osversion`"
4145 else
4146   echo "uname -a: `uname -a`"
4147 fi
4148 echo ""
4149 echo "$0 $ac_configure_args"
4150 ) > Installation
4151
4152 if test ! -z ${emacs_beta_version} ; then
4153   if test -z "${emacs_is_beta}" ; then
4154         sxemacs_betaname=".${emacs_beta_version}"
4155   else
4156         sxemacs_betaname="-b${emacs_beta_version}"
4157   fi
4158 else
4159   sxemacs_betaname=""
4160 fi
4161
4162 dnl -----------------
4163 dnl Talking LFSL now!
4164 dnl -----------------
4165
4166 dnl -----------------------------------
4167 dnl Now generate config.h and Makefiles
4168 dnl -----------------------------------
4169
4170 dnl This has to be called in order for this variable to get into config.status
4171 AC_SUBST([internal_makefile_list])
4172 # Remove any trailing slashes in these variables.
4173 if test -n "$prefix"; then
4174         prefix=`echo '' "$prefix" | sed -e 's:^ ::' -e 's,\([[^/]]\)/*$,\1,'`
4175 fi
4176 if test -n "$exec_prefix"; then
4177         exec_prefix=`echo '' "$exec_prefix" | sed -e 's:^ ::' -e 's,\([[^/]]\)/*$,\1,'`
4178 fi
4179
4180 make_ifeq="ifeq"
4181 make_endif="endif"
4182 make_else="else"
4183 AC_SUBST([make_ifeq])
4184 AC_SUBST([make_endif])
4185 AC_SUBST([make_else])
4186
4187 dnl Coupla things needed for subst'ing into the sxemacs.desktop file
4188 ABS_PROGNAME=${prefix}/bin/${PROGNAME}
4189 ABS_ETCDIR=${ETCDIR}
4190 SXE_CANONICALISE_PATH([ABS_PROGNAME])
4191 SXE_CANONICALISE_PATH([ABS_ETCDIR])
4192 AC_SUBST([ABS_PROGNAME])
4193 AC_SUBST([ABS_ETCDIR])
4194
4195 AC_CONFIG_FILES([src/sxe-paths.h])
4196 AC_CONFIG_FILES([Makefile])
4197 AC_CONFIG_FILES([lib-src/Makefile])
4198 AC_CONFIG_FILES([src/Makefile])
4199 AC_CONFIG_FILES([src/ui/Makefile])
4200 AC_CONFIG_FILES([src/ui/TTY/Makefile])
4201 AC_CONFIG_FILES([src/ui/lwlib/Makefile])
4202 AC_CONFIG_FILES([src/ui/X11/Makefile])
4203 AC_CONFIG_FILES([src/events/Makefile])
4204 AC_CONFIG_FILES([src/ent/Makefile])
4205 AC_CONFIG_FILES([src/media/Makefile])
4206 AC_CONFIG_FILES([src/mem/Makefile])
4207 AC_CONFIG_FILES([src/database/Makefile])
4208 AC_CONFIG_FILES([src/mule/Makefile])
4209 AC_CONFIG_FILES([src/.gdbinit:src/gdbinit])
4210 AC_CONFIG_FILES([src/.dbxrc:src/dbxrc])
4211 AC_CONFIG_FILES([lisp/Makefile])
4212 AC_CONFIG_FILES([info/Makefile])
4213 AC_CONFIG_FILES([tests/Makefile])
4214 AC_CONFIG_FILES([modules/Makefile])
4215 AC_CONFIG_FILES([etc/Makefile])
4216 AC_CONFIG_FILES([etc/sxemacs.desktop])
4217 AC_CONFIG_FILES([sxemacs.pc])
4218 AC_CONFIG_LINKS([.sxemacs.source.tree:])
4219
4220 AC_OUTPUT
4221 SXE_SUMMARY