Auto-commit of generated files.
[bpt/emacs.git] / configure.ac
CommitLineData
067d23c9
KY
1dnl Autoconf script for GNU Emacs
2dnl To rebuild the `configure' script from this, execute the command
3dnl autoconf
4dnl in the directory containing this script.
5dnl If you changed any AC_DEFINES, also run autoheader.
6dnl
ab422c4d 7dnl Copyright (C) 1994-1996, 1999-2013 Free Software Foundation, Inc.
067d23c9
KY
8dnl
9dnl This file is part of GNU Emacs.
10dnl
11dnl GNU Emacs is free software: you can redistribute it and/or modify
12dnl it under the terms of the GNU General Public License as published by
13dnl the Free Software Foundation, either version 3 of the License, or
14dnl (at your option) any later version.
15dnl
16dnl GNU Emacs is distributed in the hope that it will be useful,
17dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
18dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19dnl GNU General Public License for more details.
20dnl
21dnl You should have received a copy of the GNU General Public License
22dnl along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23
24AC_PREREQ(2.65)
052f924a 25AC_INIT(emacs, 24.3.50)
1e8725cf 26
60f5e585
GM
27dnl This is the documented way to record the args passed to configure,
28dnl rather than $ac_configure_args.
29emacs_config_options="$@"
1e8725cf
GM
30## Add some environment variables, if they were passed via the environment
31## rather than on the command-line.
32for var in CFLAGS CPPFLAGS LDFLAGS; do
33 case "$emacs_config_options" in
34 *$var=*) continue ;;
35 esac
36 eval val="\$${var}"
37 test x"$val" = x && continue
71b84316 38 emacs_config_options="${emacs_config_options}${emacs_config_options:+ }$var=\"$val\""
1e8725cf
GM
39done
40
067d23c9
KY
41AC_CONFIG_HEADER(src/config.h:src/config.in)
42AC_CONFIG_SRCDIR(src/lisp.h)
24e0f6b1 43AC_CONFIG_AUX_DIR(build-aux)
7d732d1a
GM
44dnl Fairly arbitrary, older versions might work too.
45AM_INIT_AUTOMAKE(1.11)
067d23c9
KY
46
47dnl Support for --program-prefix, --program-suffix and
48dnl --program-transform-name options
49AC_ARG_PROGRAM
50
51dnl It is important that variables on the RHS not be expanded here,
52dnl hence the single quotes. This is per the GNU coding standards, see
53dnl (autoconf) Installation Directory Variables
54dnl See also epaths.h below.
55lispdir='${datadir}/emacs/${version}/lisp'
d71dfe75 56leimdir='${datadir}/emacs/${version}/leim'
ca26824c 57standardlisppath='${lispdir}:${leimdir}'
067d23c9
KY
58locallisppath='${datadir}/emacs/${version}/site-lisp:'\
59'${datadir}/emacs/site-lisp'
ca26824c 60lisppath='${locallisppath}:${standardlisppath}'
067d23c9
KY
61etcdir='${datadir}/emacs/${version}/etc'
62archlibdir='${libexecdir}/emacs/${version}/${configuration}'
63docdir='${datadir}/emacs/${version}/etc'
64gamedir='${localstatedir}/games/emacs'
65
da3d2105
DA
66dnl Special option to disable the most of other options.
67AC_ARG_WITH(all,
68[AS_HELP_STRING([--without-all],
c30d4aef
DA
69 [omit almost all features and build
70 small executable with minimal dependencies])],
da3d2105
DA
71 with_features=$withval,
72 with_features=yes)
c30d4aef 73
067d23c9
KY
74dnl OPTION_DEFAULT_OFF(NAME, HELP-STRING)
75dnl Create a new --with option that defaults to being disabled.
76dnl NAME is the base name of the option. The shell variable with_NAME
77dnl will be set to either the user's value (if the option is
78dnl specified; 'yes' for a plain --with-NAME) or to 'no' (if the
79dnl option is not specified). Note that the shell variable name is
80dnl constructed as autoconf does, by replacing non-alphanumeric
81dnl characters with "_".
82dnl HELP-STRING is the help text for the option.
83AC_DEFUN([OPTION_DEFAULT_OFF], [dnl
84 AC_ARG_WITH([$1],[AS_HELP_STRING([--with-$1],[$2])],[],[dnl
85 m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=no])dnl
86])dnl
87
88dnl OPTION_DEFAULT_ON(NAME, HELP-STRING)
c30d4aef
DA
89dnl Create a new --with option that defaults to $enable_features.
90dnl NAME is the base name of the option. The shell variable with_NAME
067d23c9
KY
91dnl will be set either to 'no' (for a plain --without-NAME) or to
92dnl 'yes' (if the option is not specified). Note that the shell
93dnl variable name is constructed as autoconf does, by replacing
94dnl non-alphanumeric characters with "_".
95dnl HELP-STRING is the help text for the option.
96AC_DEFUN([OPTION_DEFAULT_ON], [dnl
97 AC_ARG_WITH([$1],[AS_HELP_STRING([--without-$1],[$2])],[],[dnl
da3d2105 98 m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=$with_features])dnl
067d23c9
KY
99])dnl
100
101OPTION_DEFAULT_ON([pop],[don't support POP mail retrieval with movemail])
102if test "$with_pop" = yes; then
103 AC_DEFINE(MAIL_USE_POP)
104fi
105AH_TEMPLATE(MAIL_USE_POP, [Define to support POP mail retrieval.])dnl
106
107OPTION_DEFAULT_OFF([kerberos],[support Kerberos-authenticated POP])
108if test "$with_kerberos" != no; then
109 AC_DEFINE(KERBEROS)
110fi
111AH_TEMPLATE(KERBEROS,
112 [Define to support Kerberos-authenticated POP mail retrieval.])dnl
113
114OPTION_DEFAULT_OFF([kerberos5],[support Kerberos version 5 authenticated POP])
115if test "${with_kerberos5}" != no; then
116 if test "${with_kerberos}" = no; then
117 with_kerberos=yes
118 AC_DEFINE(KERBEROS)
119 fi
120 AC_DEFINE(KERBEROS5, 1, [Define to use Kerberos 5 instead of Kerberos 4.])
121fi
122
123OPTION_DEFAULT_OFF([hesiod],[support Hesiod to get the POP server host])
124dnl FIXME hesiod support may not be present, so it seems like an error
125dnl to define, or at least use, this unconditionally.
126if test "$with_hesiod" != no; then
127 AC_DEFINE(HESIOD, 1, [Define to support using a Hesiod database to find the POP server.])
128fi
129
130OPTION_DEFAULT_OFF([mmdf],[support MMDF mailboxes])
131if test "$with_mmdf" != no; then
132 AC_DEFINE(MAIL_USE_MMDF, 1, [Define to support MMDF mailboxes in movemail.])
133fi
134
135OPTION_DEFAULT_OFF([mail-unlink],[unlink, rather than empty, mail spool after reading])
136if test "$with_mail_unlink" != no; then
137 AC_DEFINE(MAIL_UNLINK_SPOOL, 1, [Define to unlink, rather than empty, mail spool after reading.])
138fi
139
140AC_ARG_WITH([mailhost],[AS_HELP_STRING([--with-mailhost=HOSTNAME],
141 [string giving default POP mail host])],
142 AC_DEFINE_UNQUOTED(MAILHOST, ["$withval"], [String giving fallback POP mail host.]))
143
144OPTION_DEFAULT_ON([sound],[don't compile with sound support])
145
067d23c9
KY
146dnl FIXME currently it is not the last.
147dnl This should be the last --with option, because --with-x is
3cc53d60 148dnl added later on when we find the file name of X, and it's best to
067d23c9
KY
149dnl keep them together visually.
150AC_ARG_WITH([x-toolkit],[AS_HELP_STRING([--with-x-toolkit=KIT],
d673aedc 151 [use an X toolkit (KIT one of: yes or gtk, gtk2, gtk3, lucid or athena, motif, no)])],
067d23c9
KY
152[ case "${withval}" in
153 y | ye | yes ) val=gtk ;;
154 n | no ) val=no ;;
155 l | lu | luc | luci | lucid ) val=lucid ;;
156 a | at | ath | athe | athen | athena ) val=athena ;;
157 m | mo | mot | moti | motif ) val=motif ;;
158 g | gt | gtk ) val=gtk ;;
d673aedc 159 gtk2 ) val=gtk2 ;;
067d23c9
KY
160 gtk3 ) val=gtk3 ;;
161 * )
162AC_MSG_ERROR([`--with-x-toolkit=$withval' is invalid;
d673aedc
JD
163this option's value should be `yes', `no', `lucid', `athena', `motif', `gtk',
164`gtk2' or `gtk3'. `yes' and `gtk' are synonyms.
165`athena' and `lucid' are synonyms.])
067d23c9
KY
166 ;;
167 esac
168 with_x_toolkit=$val
169])
170
81eafe29
PE
171OPTION_DEFAULT_OFF([wide-int], [prefer wide Emacs integers (typically 62-bit)])
172if test "$with_wide_int" = yes; then
173 AC_DEFINE([WIDE_EMACS_INT], 1, [Use long long for EMACS_INT if available.])
174fi
175
067d23c9
KY
176dnl _ON results in a '--without' option in the --help output, so
177dnl the help text should refer to "don't compile", etc.
178OPTION_DEFAULT_ON([xpm],[don't compile with XPM image support])
179OPTION_DEFAULT_ON([jpeg],[don't compile with JPEG image support])
180OPTION_DEFAULT_ON([tiff],[don't compile with TIFF image support])
181OPTION_DEFAULT_ON([gif],[don't compile with GIF image support])
182OPTION_DEFAULT_ON([png],[don't compile with PNG image support])
183OPTION_DEFAULT_ON([rsvg],[don't compile with SVG image support])
184OPTION_DEFAULT_ON([xml2],[don't compile with XML parsing support])
185OPTION_DEFAULT_ON([imagemagick],[don't compile with ImageMagick image support])
186
187OPTION_DEFAULT_ON([xft],[don't use XFT for anti aliased fonts])
188OPTION_DEFAULT_ON([libotf],[don't use libotf for OpenType font support])
189OPTION_DEFAULT_ON([m17n-flt],[don't use m17n-flt for text shaping])
190
191OPTION_DEFAULT_ON([toolkit-scroll-bars],[don't use Motif or Xaw3d scroll bars])
192OPTION_DEFAULT_ON([xaw3d],[don't use Xaw3d])
193OPTION_DEFAULT_ON([xim],[don't use X11 XIM])
b612ffc9 194OPTION_DEFAULT_OFF([ns],[use NeXTstep (Cocoa or GNUstep) windowing system])
dc098568 195OPTION_DEFAULT_OFF([w32], [use native MS Windows GUI])
067d23c9
KY
196
197OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console])
198OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support])
199OPTION_DEFAULT_ON([gconf],[don't compile with GConf support])
9851bfc5 200OPTION_DEFAULT_ON([gsettings],[don't compile with GSettings support])
067d23c9 201OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support])
7c3d167f 202OPTION_DEFAULT_ON([acl],[don't compile with ACL support])
067d23c9 203OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support])
81606b10 204OPTION_DEFAULT_ON([inotify],[don't compile with inotify (file-watch) support])
067d23c9
KY
205
206## For the times when you want to build Emacs but don't have
207## a suitable makeinfo, and can live without the manuals.
208dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html
209OPTION_DEFAULT_ON([makeinfo],[don't require makeinfo for building manuals])
210
6c269a38
PE
211## Makefile.in needs the cache file name.
212AC_SUBST(cache_file)
213
067d23c9
KY
214## This is an option because I do not know if all info/man support
215## compressed files, nor how to test if they do so.
216OPTION_DEFAULT_ON([compress-info],[don't compress the installed Info pages])
217if test $with_compress_info = yes; then
218 GZIP_INFO=yes
219else
220 GZIP_INFO=
221fi
222AC_SUBST(GZIP_INFO)
223
224AC_ARG_WITH([pkg-config-prog],dnl
3cc53d60
PE
225[AS_HELP_STRING([--with-pkg-config-prog=FILENAME],
226 [file name of pkg-config for finding GTK and librsvg])])
067d23c9
KY
227if test "X${with_pkg_config_prog}" != X; then
228 if test "${with_pkg_config_prog}" != yes; then
229 PKG_CONFIG="${with_pkg_config_prog}"
230 fi
231fi
232
4fc5868a
UM
233AC_ARG_WITH(gameuser,dnl
234[AS_HELP_STRING([--with-gameuser=USER],[user for shared game score files])])
235test "X${with_gameuser}" != X && test "${with_gameuser}" != yes \
236 && gameuser="${with_gameuser}"
237test "X$gameuser" = X && gameuser=games
238
067d23c9 239AC_ARG_WITH([gnustep-conf],dnl
3cc53d60
PE
240[AS_HELP_STRING([--with-gnustep-conf=FILENAME],
241 [name of GNUstep.conf; default $GNUSTEP_CONFIG_FILE, or /etc/GNUstep/GNUstep.conf])])
067d23c9
KY
242test "X${with_gnustep_conf}" != X && test "${with_gnustep_conf}" != yes && \
243 GNUSTEP_CONFIG_FILE="${with_gnustep_conf}"
244test "X$GNUSTEP_CONFIG_FILE" = "X" && \
245 GNUSTEP_CONFIG_FILE=/etc/GNUstep/GNUstep.conf
246
247AC_ARG_ENABLE(ns-self-contained,
248[AS_HELP_STRING([--disable-ns-self-contained],
249 [disable self contained build under NeXTstep])],
250 EN_NS_SELF_CONTAINED=$enableval,
251 EN_NS_SELF_CONTAINED=yes)
252
067d23c9
KY
253AC_ARG_ENABLE(locallisppath,
254[AS_HELP_STRING([--enable-locallisppath=PATH],
255 [directories Emacs should search for lisp files specific
256 to this site])],
257if test "${enableval}" = "no"; then
258 locallisppath=
259elif test "${enableval}" != "yes"; then
260 locallisppath=${enableval}
261fi)
262
263AC_ARG_ENABLE(checking,
264[AS_HELP_STRING([--enable-checking@<:@=LIST@:>@],
265 [enable expensive run-time checks. With LIST,
266 enable only specific categories of checks.
267 Categories are: all,yes,no.
268 Flags are: stringbytes, stringoverrun, stringfreelist,
e509cfa6 269 xmallocoverrun, conslist, glyphs])],
067d23c9
KY
270[ac_checking_flags="${enableval}"],[])
271IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="$IFS,"
272for check in $ac_checking_flags
273do
274 case $check in
275 # these set all the flags to specific states
276 yes) ac_enable_checking=1 ;;
277 no) ac_enable_checking= ;
278 ac_gc_check_stringbytes= ;
279 ac_gc_check_string_overrun= ;
280 ac_gc_check_string_free_list= ;
281 ac_xmalloc_overrun= ;
e509cfa6 282 ac_gc_check_cons_list= ;
94eb8e0a 283 ac_glyphs_debug= ;;
067d23c9
KY
284 all) ac_enable_checking=1 ;
285 ac_gc_check_stringbytes=1 ;
286 ac_gc_check_string_overrun=1 ;
287 ac_gc_check_string_free_list=1 ;
288 ac_xmalloc_overrun=1 ;
e509cfa6 289 ac_gc_check_cons_list=1 ;
94eb8e0a 290 ac_glyphs_debug=1 ;;
067d23c9
KY
291 # these enable particular checks
292 stringbytes) ac_gc_check_stringbytes=1 ;;
293 stringoverrun) ac_gc_check_string_overrun=1 ;;
294 stringfreelist) ac_gc_check_string_free_list=1 ;;
295 xmallocoverrun) ac_xmalloc_overrun=1 ;;
296 conslist) ac_gc_check_cons_list=1 ;;
94eb8e0a 297 glyphs) ac_glyphs_debug=1 ;;
067d23c9
KY
298 *) AC_MSG_ERROR(unknown check category $check) ;;
299 esac
300done
301IFS="$ac_save_IFS"
302
303if test x$ac_enable_checking != x ; then
304 AC_DEFINE(ENABLE_CHECKING, 1,
a54e2c05 305[Define to 1 if expensive run-time data type and consistency checks are enabled.])
067d23c9
KY
306fi
307if test x$ac_gc_check_stringbytes != x ; then
308 AC_DEFINE(GC_CHECK_STRING_BYTES, 1,
309[Define this temporarily to hunt a bug. If defined, the size of
310 strings is redundantly recorded in sdata structures so that it can
311 be compared to the sizes recorded in Lisp strings.])
312fi
40697cd9 313if test x$ac_gc_check_string_overrun != x ; then
067d23c9
KY
314 AC_DEFINE(GC_CHECK_STRING_OVERRUN, 1,
315[Define this to check for short string overrun.])
316fi
317if test x$ac_gc_check_string_free_list != x ; then
318 AC_DEFINE(GC_CHECK_STRING_FREE_LIST, 1,
319[Define this to check the string free list.])
320fi
321if test x$ac_xmalloc_overrun != x ; then
322 AC_DEFINE(XMALLOC_OVERRUN_CHECK, 1,
323[Define this to check for malloc buffer overrun.])
324fi
325if test x$ac_gc_check_cons_list != x ; then
326 AC_DEFINE(GC_CHECK_CONS_LIST, 1,
327[Define this to check for errors in cons list.])
328fi
94eb8e0a 329if test x$ac_glyphs_debug != x ; then
e509cfa6
DA
330 AC_DEFINE(GLYPH_DEBUG, 1,
331[Define this to enable glyphs debugging code.])
332fi
067d23c9 333
646b5f55
AS
334AC_ARG_ENABLE(check-lisp-object-type,
335[AS_HELP_STRING([--enable-check-lisp-object-type],
336 [enable compile time checks for the Lisp_Object data type.
337 This is useful for development for catching certain types of bugs.])],
067d23c9 338if test "${enableval}" != "no"; then
646b5f55
AS
339 AC_DEFINE(CHECK_LISP_OBJECT_TYPE, 1,
340 [Define this to enable compile time checks for the Lisp_Object data type.])
067d23c9
KY
341fi)
342
343
1b3b7caa
GM
344dnl The name of this option is unfortunate. It predates, and has no
345dnl relation to, the "sampling-based elisp profiler" added in 24.3.
346dnl Actually, it stops it working.
347dnl http://lists.gnu.org/archive/html/emacs-devel/2012-11/msg00393.html
067d23c9
KY
348AC_ARG_ENABLE(profiling,
349[AS_HELP_STRING([--enable-profiling],
1b3b7caa
GM
350 [build emacs with low-level, gprof profiling support.
351 Mainly useful for debugging Emacs itself. May not work on
352 all platforms. Stops profiler.el working.])],
067d23c9
KY
353[ac_enable_profiling="${enableval}"],[])
354if test x$ac_enable_profiling != x ; then
355 PROFILING_CFLAGS="-DPROFILING=1 -pg"
356else
357 PROFILING_CFLAGS=
358fi
359AC_SUBST(PROFILING_CFLAGS)
360
361AC_ARG_ENABLE(autodepend,
362[AS_HELP_STRING([--enable-autodepend],
363 [automatically generate dependencies to .h-files.
364 Requires GNU Make and Gcc. Enabled if GNU Make and Gcc is
365 found])],
366[ac_enable_autodepend="${enableval}"],[ac_enable_autodepend=yes])
367
7ec363cf
JD
368AC_ARG_ENABLE(gtk-deprecation-warnings,
369[AS_HELP_STRING([--enable-gtk-deprecation-warnings],
370 [Show Gtk+/Gdk deprecation warnings for Gtk+ >= 3.0])],
371[ac_enable_gtk_deprecation_warnings="${enableval}"],[])
372
067d23c9 373#### Make srcdir absolute, if it isn't already. It's important to
3cc53d60 374#### avoid running the file name through pwd unnecessarily, since pwd can
067d23c9
KY
375#### give you automounter prefixes, which can go away. We do all this
376#### so Emacs can find its files when run uninstalled.
377## Make sure CDPATH doesn't affect cd (in case PWD is relative).
378unset CDPATH
379case "${srcdir}" in
380 /* ) ;;
381 . )
382 ## We may be able to use the $PWD environment variable to make this
383 ## absolute. But sometimes PWD is inaccurate.
3cc53d60 384 ## Note: we used to use $PWD at the end instead of `pwd`,
067d23c9
KY
385 ## but that tested only for a well-formed and valid PWD,
386 ## it did not object when PWD was well-formed and valid but just wrong.
3cc53d60 387 if test ".$PWD" != "." && test ".`(cd "$PWD" ; sh -c pwd)`" = ".`pwd`" ;
067d23c9
KY
388 then
389 srcdir="$PWD"
390 else
3cc53d60 391 srcdir=`(cd "$srcdir"; pwd)`
067d23c9
KY
392 fi
393 ;;
3cc53d60 394 * ) srcdir=`(cd "$srcdir"; pwd)` ;;
067d23c9
KY
395esac
396
067d23c9
KY
397### Canonicalize the configuration name.
398
399AC_CANONICAL_HOST
400canonical=$host
401configuration=${host_alias-${build_alias-$host}}
402
403dnl This used to use changequote, but, apart from `changequote is evil'
404dnl per the autoconf manual, we can speed up autoconf somewhat by quoting
405dnl the great gob of text. Thus it's not processed for possible expansion.
406dnl Just make sure the brackets remain balanced.
407dnl
408dnl Since Emacs can't find matching pairs of quotes, boundaries are
409dnl indicated by comments.
410dnl quotation begins
411[
412
413### If you add support for a new configuration, add code to this
414### switch statement to recognize your configuration name and select
34374650 415### the appropriate operating system file.
067d23c9 416
34374650 417### You would hope that you could choose an s/*.h
067d23c9 418### file based on the operating system portion. However, it turns out
34374650 419### that each s/*.h file is pretty manufacturer-specific.
067d23c9
KY
420### So we basically have to have a special case for each
421### configuration name.
422###
423### As far as handling version numbers on operating systems is
424### concerned, make sure things will fail in a fixable way. If
425### /etc/MACHINES doesn't say anything about version numbers, be
426### prepared to handle anything reasonably. If version numbers
427### matter, be sure /etc/MACHINES says something about it.
428
34374650 429opsys='' unported=no
067d23c9
KY
430case "${canonical}" in
431
695a3dc5
PE
432 ## GNU/Linux and similar ports
433 *-*-linux* )
d6a003a8 434 opsys=gnu-linux
d6a003a8
AS
435 ;;
436
067d23c9
KY
437 ## FreeBSD ports
438 *-*-freebsd* )
439 opsys=freebsd
067d23c9
KY
440 ;;
441
442 ## FreeBSD kernel + glibc based userland
443 *-*-kfreebsd*gnu* )
444 opsys=gnu-kfreebsd
067d23c9
KY
445 ;;
446
447 ## NetBSD ports
448 *-*-netbsd* )
449 opsys=netbsd
067d23c9
KY
450 ;;
451
452 ## OpenBSD ports
453 *-*-openbsd* )
454 opsys=openbsd
067d23c9
KY
455 ;;
456
067d23c9
KY
457 ## Apple Darwin / Mac OS X
458 *-apple-darwin* )
459 case "${canonical}" in
34374650
PE
460 i[3456]86-* ) ;;
461 powerpc-* ) ;;
462 x86_64-* ) ;;
067d23c9
KY
463 * ) unported=yes ;;
464 esac
465 opsys=darwin
136c45ee
GM
466 ## Use fink packages if available.
467 ## FIXME find a better way to do this: http://debbugs.gnu.org/11507
468## if test -d /sw/include && test -d /sw/lib; then
469## GCC_TEST_OPTIONS="-I/sw/include -L/sw/lib"
470## NON_GCC_TEST_OPTIONS=${GCC_TEST_OPTIONS}
471## fi
067d23c9
KY
472 ;;
473
e8bdb06e
KB
474 ## Cygwin ports
475 *-*-cygwin )
476 opsys=cygwin
477 ;;
478
067d23c9
KY
479 ## HP 9000 series 700 and 800, running HP/UX
480 hppa*-hp-hpux10.2* )
d6a003a8 481 opsys=hpux10-20
067d23c9
KY
482 ;;
483 hppa*-hp-hpux1[1-9]* )
d6a003a8 484 opsys=hpux11
067d23c9
KY
485 CFLAGS="-D_INCLUDE__STDC_A1_SOURCE $CFLAGS"
486 ;;
487
067d23c9 488 ## IBM machines
067d23c9 489 rs6000-ibm-aix4.[23]* )
34374650 490 opsys=aix4-2
067d23c9
KY
491 ;;
492 powerpc-ibm-aix4.[23]* )
34374650 493 opsys=aix4-2
067d23c9
KY
494 ;;
495 rs6000-ibm-aix[56]* )
34374650 496 opsys=aix4-2
067d23c9
KY
497 ;;
498 powerpc-ibm-aix[56]* )
34374650 499 opsys=aix4-2
067d23c9
KY
500 ;;
501
067d23c9
KY
502 ## Silicon Graphics machines
503 ## Iris 4D
504 mips-sgi-irix6.5 )
76b397fb 505 opsys=irix6-5
067d23c9
KY
506 # Without defining _LANGUAGE_C, things get masked out in the headers
507 # so that, for instance, grepping for `free' in stdlib.h fails and
508 # AC_HEADER_STD_C fails. (MIPSPro 7.2.1.2m compilers, Irix 6.5.3m).
067d23c9
KY
509 NON_GCC_TEST_OPTIONS="-D_LANGUAGE_C"
510 ;;
511
512 ## Suns
067d23c9
KY
513 *-sun-solaris* \
514 | i[3456]86-*-solaris2* | i[3456]86-*-sunos5* \
515 | x86_64-*-solaris2* | x86_64-*-sunos5*)
516 case "${canonical}" in
34374650
PE
517 i[3456]86-*-* ) ;;
518 amd64-*-*|x86_64-*-*) ;;
519 sparc* ) ;;
067d23c9
KY
520 * ) unported=yes ;;
521 esac
522 case "${canonical}" in
523 *-sunos5.6* | *-solaris2.6* )
524 opsys=sol2-6
067d23c9
KY
525 RANLIB="ar -ts"
526 ;;
527 *-sunos5.[7-9]* | *-solaris2.[7-9]* )
528 opsys=sol2-6
529 emacs_check_sunpro_c=yes
067d23c9
KY
530 ;;
531 *-sunos5* | *-solaris* )
532 opsys=sol2-10
533 emacs_check_sunpro_c=yes
067d23c9
KY
534 ;;
535 esac
536 ## Watch out for a compiler that we know will not work.
537 case "${canonical}" in
538 *-solaris* | *-sunos5* )
539 if [ "x$CC" = x/usr/ucb/cc ]; then
540 ## /usr/ucb/cc doesn't work;
541 ## we should find some other compiler that does work.
542 unset CC
543 fi
544 ;;
545 *) ;;
546 esac
547 ;;
548
067d23c9
KY
549 ## Intel 386 machines where we don't care about the manufacturer.
550 i[3456]86-*-* )
067d23c9 551 case "${canonical}" in
27cb7be2 552 *-darwin* ) opsys=darwin ;;
f04940ae
PE
553 *-sysv4.2uw* ) opsys=unixware ;;
554 *-sysv5uw* ) opsys=unixware ;;
555 *-sysv5OpenUNIX* ) opsys=unixware ;;
067d23c9
KY
556 ## Otherwise, we'll fall through to the generic opsys code at the bottom.
557 esac
558 ;;
559
067d23c9
KY
560 * )
561 unported=yes
562 ;;
563esac
564
565### If the code above didn't choose an operating system, just choose
566### an operating system based on the configuration name. You really
567### only want to use this when you have no idea what the right
568### operating system is; if you know what operating systems a machine
569### runs, it's cleaner to make it explicit in the case statement
570### above.
571if test x"${opsys}" = x; then
572 case "${canonical}" in
573 *-gnu* ) opsys=gnu ;;
574 * )
575 unported=yes
576 ;;
577 esac
578fi
579
580]
581dnl quotation ends
582
583if test $unported = yes; then
584 AC_MSG_ERROR([Emacs hasn't been ported to `${canonical}' systems.
585Check `etc/MACHINES' for recognized configuration names.])
586fi
587
067d23c9
KY
588
589#### Choose a compiler.
27cb7be2 590
067d23c9
KY
591dnl Sets GCC=yes if using gcc.
592AC_PROG_CC
9a514d4a
PE
593AM_PROG_CC_C_O
594
067d23c9
KY
595if test x$GCC = xyes; then
596 test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
597else
598 test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS"
599fi
600
70743157
PE
601# Avoid gnulib's tests for HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW,
602# as we don't use them.
73dcdb9f 603AC_DEFUN([gl_FCNTL_O_FLAGS])
a615a3ae
PE
604# Avoid gnulib's threadlib module, as we do threads our own way.
605AC_DEFUN([gl_THREADLIB])
606
f04940ae 607# Initialize gnulib right after choosing the compiler.
58eaa9ec 608dnl Amongst other things, this sets AR and ARFLAGS.
f04940ae
PE
609gl_EARLY
610
6e8aca60
PE
611# It's helpful to have C macros available to GDB, so prefer -g3 to -g
612# if -g3 works and the user does not specify CFLAGS.
613# This test must follow gl_EARLY; otherwise AC_LINK_IFELSE complains.
614if test "$ac_test_CFLAGS" != set; then
615 case $CFLAGS in
616 '-g')
617 emacs_g3_CFLAGS='-g3';;
618 '-g -O2')
619 emacs_g3_CFLAGS='-g3 -O2';;
620 *)
621 emacs_g3_CFLAGS='';;
622 esac
623 if test -n "$emacs_g3_CFLAGS"; then
624 emacs_save_CFLAGS=$CFLAGS
625 CFLAGS=$emacs_g3_CFLAGS
626 AC_CACHE_CHECK([whether $CC accepts $emacs_g3_CFLAGS],
627 [emacs_cv_prog_cc_g3],
628 [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
629 [emacs_cv_prog_cc_g3=yes],
630 [emacs_cv_prog_cc_g3=no])])
631 if test $emacs_cv_prog_cc_g3 = yes; then
632 CFLAGS=$emacs_g3_CFLAGS
633 else
634 CFLAGS=$emacs_save_CFLAGS
635 fi
636 fi
637fi
638
b8df54ff
PE
639AC_ARG_ENABLE([gcc-warnings],
640 [AS_HELP_STRING([--enable-gcc-warnings],
c4e2ba0a 641 [turn on lots of GCC warnings/errors. This is intended for
f5c08e17
PE
642 developers, and may generate false alarms when used
643 with older or non-GNU development tools.])],
b8df54ff
PE
644 [case $enableval in
645 yes|no) ;;
646 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
647 esac
648 gl_gcc_warnings=$enableval],
649 [gl_gcc_warnings=no]
650)
651
94eb8e0a
DA
652AC_ARG_ENABLE(link-time-optimization,
653[AS_HELP_STRING([--enable-link-time-optimization],
654 [build emacs with link-time optimization.
655 This is supported only for GCC since 4.5.0.])],
656if test "${enableval}" != "no"; then
657 AC_MSG_CHECKING([whether link-time optimization is supported])
658 ac_lto_supported=no
659 if test x$GCC = xyes; then
660 CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
661 if test x$CPUS != x; then
662 LTO="-flto=$CPUS"
663 else
664 LTO="-flto"
f5c08e17 665 fi
94eb8e0a
DA
666 old_CFLAGS=$CFLAGS
667 CFLAGS="$CFLAGS $LTO"
668 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
669 [ac_lto_supported=yes], [ac_lto_supported=no])
670 CFLAGS="$old_CFLAGS"
671 fi
672 AC_MSG_RESULT([$ac_lto_supported])
673 if test "$ac_lto_supported" = "yes"; then
674 CFLAGS="$CFLAGS $LTO"
675 fi
676fi)
677
b8df54ff
PE
678# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
679# ------------------------------------------------
680# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
681# Otherwise, run RUN-IF-NOT-FOUND.
682AC_DEFUN([gl_GCC_VERSION_IFELSE],
683 [AC_PREPROC_IFELSE(
684 [AC_LANG_PROGRAM(
685 [[
686#if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
687/* ok */
688#else
689# error "your version of gcc is older than $1.$2"
690#endif
691 ]]),
692 ], [$3], [$4])
693 ]
694)
695
696# When compiling with GCC, prefer -isystem to -I when including system
697# include files, to avoid generating useless diagnostics for the files.
698if test "$gl_gcc_warnings" != yes; then
699 isystem='-I'
700else
701 isystem='-isystem '
702
703 # This, $nw, is the list of warnings we disable.
704 nw=
705
706 case $with_x_toolkit in
707 lucid | athena | motif)
708 # Old toolkits mishandle 'const'.
709 nw="$nw -Wwrite-strings"
710 ;;
711 *)
712 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
713 ;;
714 esac
715 AC_SUBST([WERROR_CFLAGS])
716
717 nw="$nw -Waggregate-return" # anachronistic
a74e8e38 718 nw="$nw -Wlong-long" # C90 is anachronistic
b8df54ff
PE
719 nw="$nw -Wc++-compat" # We don't care about C++ compilers
720 nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
721 nw="$nw -Wtraditional" # Warns on #elif which we use often
722 nw="$nw -Wcast-qual" # Too many warnings for now
723 nw="$nw -Wconversion" # Too many warnings for now
724 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
725 nw="$nw -Wsign-conversion" # Too many warnings for now
726 nw="$nw -Woverlength-strings" # Not a problem these days
727 nw="$nw -Wtraditional-conversion" # Too many warnings for now
6045c4fd 728 nw="$nw -Wunreachable-code" # so buggy that it's now silently ignored
b8df54ff 729 nw="$nw -Wpadded" # Our structs are not padded
6045c4fd 730 nw="$nw -Wredundant-decls" # we regularly (re)declare functions
b8df54ff 731 nw="$nw -Wlogical-op" # any use of fwrite provokes this
6045c4fd 732 nw="$nw -Wformat-nonliteral" # we do this a lot
b8df54ff
PE
733 nw="$nw -Wvla" # warnings in gettext.h
734 nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
735 nw="$nw -Wswitch-enum" # Too many warnings for now
736 nw="$nw -Wswitch-default" # Too many warnings for now
6045c4fd
PE
737 nw="$nw -Wfloat-equal" # warns about high-quality code
738 nw="$nw -Winline" # OK to ignore 'inline'
79a7bafe 739 nw="$nw -Wjump-misses-init" # We sometimes safely jump over init.
d7fcbbfe
PE
740 nw="$nw -Wstrict-overflow" # OK to optimize assuming that
741 # signed overflow has undefined behavior
6045c4fd
PE
742 nw="$nw -Wsync-nand" # irrelevant here, and provokes ObjC warning
743 nw="$nw -Wunsafe-loop-optimizations" # OK to suppress unsafe optimizations
b8df54ff
PE
744
745 # Emacs doesn't care about shadowing; see
746 # <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
747 nw="$nw -Wshadow"
748
a8e1690b
PE
749 # Emacs's use of alloca inhibits protecting the stack.
750 nw="$nw -Wstack-protector"
751
8ea5c4de 752 # The following line should be removable at some point.
b8df54ff
PE
753 nw="$nw -Wsuggest-attribute=pure"
754
755 gl_MANYWARN_ALL_GCC([ws])
756 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
757 for w in $ws; do
758 gl_WARN_ADD([$w])
759 done
760 gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
761 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
762 gl_WARN_ADD([-Wno-type-limits]) # Too many warnings for now
763 gl_WARN_ADD([-Wno-switch]) # Too many warnings for now
764 gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
765 gl_WARN_ADD([-Wno-format-nonliteral])
766
767 # In spite of excluding -Wlogical-op above, it is enabled, as of
768 # gcc 4.5.0 20090517.
769 gl_WARN_ADD([-Wno-logical-op])
770
771 gl_WARN_ADD([-fdiagnostics-show-option])
772 gl_WARN_ADD([-funit-at-a-time])
773
b8df54ff 774 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
2d3800d2
PE
775 AH_VERBATIM([FORTIFY_SOURCE],
776 [/* Enable compile-time and run-time bounds-checking, and some warnings,
777 without upsetting glibc 2.15+. */
7f8de58c 778 #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
2d3800d2
PE
779 # define _FORTIFY_SOURCE 2
780 #endif
781 ])
b8df54ff
PE
782 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
783
784 # We use a slightly smaller set of warning options for lib/.
785 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
786 nw=
787 nw="$nw -Wunused-macros"
788
789 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
790 AC_SUBST([GNULIB_WARN_CFLAGS])
067d23c9 791fi
067d23c9 792
067d23c9
KY
793
794
f04940ae
PE
795dnl Some other nice autoconf tests.
796dnl These are commented out, since gl_EARLY and/or Autoconf already does them.
797dnl AC_PROG_INSTALL
798dnl AC_PROG_MKDIR_P
799dnl if test "x$RANLIB" = x; then
800dnl AC_PROG_RANLIB
801dnl fi
4f8902cd
GM
802
803
804dnl Sadly, AC_PROG_LN_S is too restrictive. It also tests whether links
805dnl can be made to directories. This is not relevant for our usage, and
806dnl excludes some cases that work fine for us. Eg MS Windows or files
807dnl hosted on AFS, both examples where simple links work, but links to
808dnl directories fail. We use a cut-down version instead.
809dnl AC_PROG_LN_S
810
811AC_MSG_CHECKING([whether ln -s works for files in the same directory])
812rm -f conf$$ conf$$.file
813
814LN_S_FILEONLY='cp -p'
815
816if (echo >conf$$.file) 2>/dev/null; then
817 if ln -s conf$$.file conf$$ 2>/dev/null; then
818 LN_S_FILEONLY='ln -s'
819 elif ln conf$$.file conf$$ 2>/dev/null; then
820 LN_S_FILEONLY=ln
821 fi
822fi
823
824rm -f conf$$ conf$$.file
825
826if test "$LN_S_FILEONLY" = "ln -s"; then
827 AC_MSG_RESULT([yes])
828else
829 AC_MSG_RESULT([no, using $LN_S_FILEONLY])
830fi
831
832AC_SUBST(LN_S_FILEONLY)
833
067d23c9 834
0e7a053e
PE
835AC_PATH_PROG(INSTALL_INFO, install-info, :,
836 $PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin)
067d23c9
KY
837dnl Don't use GZIP, which is used by gzip for additional parameters.
838AC_PATH_PROG(GZIP_PROG, gzip)
839
0b6b25d5
GM
840if test $opsys = gnu-linux; then
841 AC_PATH_PROG(PAXCTL, paxctl,,
842 [$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin])
32d9ba9a
UM
843 if test "X$PAXCTL" != X; then
844 AC_MSG_CHECKING([whether binaries have a PT_PAX_FLAGS header])
845 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
846 [if $PAXCTL -v conftest$EXEEXT >/dev/null 2>&1; then AC_MSG_RESULT(yes)
847 else AC_MSG_RESULT(no); PAXCTL=""; fi])
848 fi
0b6b25d5 849fi
067d23c9 850
23df914b 851## Need makeinfo >= 4.7 (?) to build the manuals.
067d23c9
KY
852AC_PATH_PROG(MAKEINFO, makeinfo, no)
853dnl By this stage, configure has already checked for egrep and set EGREP,
854dnl or exited with an error if no egrep was found.
3cc53d60
PE
855if test "$MAKEINFO" != "no"; then
856 case `
75d7aa24 857 $MAKEINFO --version 2> /dev/null |
3cc53d60
PE
858 $EGREP 'texinfo[[^0-9]]*([[1-4]][[0-9]]+|[[5-9]]|4\.[[7-9]]|4\.[[1-6]][[0-9]]+)'
859 ` in
860 '') MAKEINFO=no;;
861 esac
067d23c9
KY
862fi
863
864## Makeinfo is unusual. For a released Emacs, the manuals are
865## pre-built, and not deleted by the normal clean rules. makeinfo is
866## therefore in the category of "special tools" not normally required, which
867## configure does not have to check for (eg autoconf itself).
868## In a Bazaar checkout on the other hand, the manuals are not included.
869## So makeinfo is a requirement to build from Bazaar, and configure
870## should test for it as it does for any other build requirement.
871## We use the presence of $srcdir/info/emacs to distinguish a release,
872## with pre-built manuals, from a Bazaar checkout.
e5365138
GM
873HAVE_MAKEINFO=yes
874
067d23c9 875if test "$MAKEINFO" = "no"; then
e5365138 876 MAKEINFO=makeinfo
067d23c9 877 if test "x${with_makeinfo}" = "xno"; then
e5365138 878 HAVE_MAKEINFO=no
3cc53d60 879 elif test ! -e "$srcdir/info/emacs" && test ! -e "$srcdir/info/emacs.info"; then
23df914b 880 AC_MSG_ERROR( [You do not seem to have makeinfo >= 4.7, and your
067d23c9
KY
881source tree does not seem to have pre-built manuals in the `info' directory.
882Either install a suitable version of makeinfo, or re-run configure
883with the `--without-makeinfo' option to build without the manuals.] )
884 fi
885fi
e5365138 886AC_SUBST(HAVE_MAKEINFO)
067d23c9 887
8045b906
GM
888dnl Just so that there is only a single place we need to edit.
889INFO_EXT=.info
890INFO_OPTS=--no-split
891AC_SUBST(INFO_EXT)
892AC_SUBST(INFO_OPTS)
893
067d23c9
KY
894dnl Add our options to ac_link now, after it is set up.
895
896if test x$GCC = xyes; then
897 test "x$GCC_LINK_TEST_OPTIONS" != x && \
898 ac_link="$ac_link $GCC_LINK_TEST_OPTIONS"
899else
900 test "x$NON_GCC_LINK_TEST_OPTIONS" != x && \
901 ac_link="$ac_link $NON_GCC_LINK_TEST_OPTIONS"
902fi
903
904dnl We need -znocombreloc if we're using a relatively recent GNU ld.
905dnl If we can link with the flag, it shouldn't do any harm anyhow.
906dnl (Don't use `-z nocombreloc' as -z takes no arg on Irix.)
907dnl Treat GCC specially since it just gives a non-fatal `unrecognized option'
908dnl if not built to support GNU ld.
909
910late_LDFLAGS=$LDFLAGS
911if test x$GCC = xyes; then
912 LDFLAGS="$LDFLAGS -Wl,-znocombreloc"
913else
914 LDFLAGS="$LDFLAGS -znocombreloc"
915fi
916
917AC_MSG_CHECKING([for -znocombreloc])
918AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
919 [AC_MSG_RESULT(yes)],
920 LDFLAGS=$late_LDFLAGS
921 [AC_MSG_RESULT(no)])
922
923
067d23c9
KY
924dnl The function dump-emacs will not be defined and temacs will do
925dnl (load "loadup") automatically unless told otherwise.
4004ef46 926test "x$CANNOT_DUMP" = "x" && CANNOT_DUMP=no
067d23c9 927case "$opsys" in
4004ef46 928 your-opsys-here) CANNOT_DUMP=yes ;;
067d23c9 929esac
4004ef46
GM
930
931test "$CANNOT_DUMP" = "yes" && \
932 AC_DEFINE(CANNOT_DUMP, 1, [Define if Emacs cannot be dumped on your system.])
933
067d23c9
KY
934AC_SUBST(CANNOT_DUMP)
935
936
937UNEXEC_OBJ=unexelf.o
938case "$opsys" in
939 # MSDOS uses unexcoff.o
940 # MSWindows uses unexw32.o
941 aix4-2)
942 UNEXEC_OBJ=unexaix.o
943 ;;
944 cygwin)
945 UNEXEC_OBJ=unexcw.o
946 ;;
947 darwin)
948 UNEXEC_OBJ=unexmacosx.o
949 ;;
950 hpux10-20 | hpux11)
951 UNEXEC_OBJ=unexhp9k800.o
952 ;;
953 sol2-10)
954 # Use the Solaris dldump() function, called from unexsol.c, to dump
955 # emacs, instead of the generic ELF dump code found in unexelf.c.
956 # The resulting binary has a complete symbol table, and is better
957 # for debugging and other observability tools (debuggers, pstack, etc).
b06b1098 958 #
067d23c9
KY
959 # If you encounter a problem using dldump(), please consider sending
960 # a message to the OpenSolaris tools-linking mailing list:
961 # http://mail.opensolaris.org/mailman/listinfo/tools-linking
b06b1098 962 #
067d23c9
KY
963 # It is likely that dldump() works with older Solaris too, but this has
964 # not been tested, so for now this change is for Solaris 10 or newer.
965 UNEXEC_OBJ=unexsol.o
966 ;;
967esac
968
969LD_SWITCH_SYSTEM=
970case "$opsys" in
971 freebsd)
972 ## Let `ld' find image libs and similar things in /usr/local/lib.
973 ## The system compiler, GCC, has apparently been modified to not
974 ## look there, contrary to what a stock GCC would do.
3c30e766
GM
975### It's not our place to do this. See bug#10313#17.
976### LD_SWITCH_SYSTEM=-L/usr/local/lib
977 :
067d23c9
KY
978 ;;
979
980 gnu-linux)
981 ## cpp test was "ifdef __mips__", but presumably this is equivalent...
d6a003a8 982 case $host_cpu in mips*) LD_SWITCH_SYSTEM="-G 0";; esac
067d23c9
KY
983 ;;
984
985 netbsd)
3c30e766
GM
986### It's not our place to do this. See bug#10313#17.
987### LD_SWITCH_SYSTEM="-Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib"
988 :
067d23c9
KY
989 ;;
990
991 openbsd)
992 ## Han Boetes <han@mijncomputer.nl> says this is necessary,
993 ## otherwise Emacs dumps core on elf systems.
994 LD_SWITCH_SYSTEM="-Z"
995 ;;
996esac
997AC_SUBST(LD_SWITCH_SYSTEM)
998
999ac_link="$ac_link $LD_SWITCH_SYSTEM"
1000
4d5c6349 1001## This setting of LD_SWITCH_SYSTEM references LD_SWITCH_X_SITE_RPATH,
067d23c9
KY
1002## which has not been defined yet. When this was handled with cpp,
1003## it was expanded to null when configure sourced the s/*.h file.
1004## Thus LD_SWITCH_SYSTEM had different values in configure and the Makefiles.
1005## FIXME it would be cleaner to put this in LD_SWITCH_SYSTEM_TEMACS
1006## (or somesuch), but because it is supposed to go at the _front_
1007## of LD_SWITCH_SYSTEM, we cannot do that in exactly the same way.
1008## Compare with the gnu-linux case below, which added to the end
1009## of LD_SWITCH_SYSTEM, and so can instead go at the front of
1010## LD_SWITCH_SYSTEM_TEMACS.
1011case "$opsys" in
1012 netbsd|openbsd)
4d5c6349 1013 LD_SWITCH_SYSTEM="\$(LD_SWITCH_X_SITE_RPATH) $LD_SWITCH_SYSTEM" ;;
067d23c9
KY
1014esac
1015
1016
1017C_SWITCH_MACHINE=
34374650
PE
1018case $canonical in
1019 alpha*)
067d23c9
KY
1020 AC_CHECK_DECL([__ELF__])
1021 if test "$ac_cv_have_decl___ELF__" = "yes"; then
1022 ## With ELF, make sure that all common symbols get allocated to in the
1023 ## data section. Otherwise, the dump of temacs may miss variables in
1024 ## the shared library that have been initialized. For example, with
1025 ## GNU libc, __malloc_initialized would normally be resolved to the
1026 ## shared library's .bss section, which is fatal.
1027 if test "x$GCC" = "xyes"; then
1028 C_SWITCH_MACHINE="-fno-common"
1029 else
1030 AC_MSG_ERROR([What gives? Fix me if DEC Unix supports ELF now.])
1031 fi
1032 else
b06b1098 1033 UNEXEC_OBJ=unexalpha.o
067d23c9 1034 fi
34374650
PE
1035 ;;
1036esac
067d23c9
KY
1037AC_SUBST(C_SWITCH_MACHINE)
1038
1039AC_SUBST(UNEXEC_OBJ)
1040
1041C_SWITCH_SYSTEM=
1042## Some programs in src produce warnings saying certain subprograms
1043## are too complex and need a MAXMEM value greater than 2000 for
1044## additional optimization. --nils@exp-math.uni-essen.de
1045test "$opsys" = "aix4.2" && test "x$GCC" != "xyes" && \
1046 C_SWITCH_SYSTEM="-ma -qmaxmem=4000"
1047## gnu-linux might need -D_BSD_SOURCE on old libc5 systems.
1048## It is redundant in glibc2, since we define _GNU_SOURCE.
1049AC_SUBST(C_SWITCH_SYSTEM)
1050
1051
1052LIBS_SYSTEM=
1053case "$opsys" in
1054 ## IBM's X11R5 uses -lIM and -liconv in AIX 3.2.2.
1055 aix4-2) LIBS_SYSTEM="-lrts -lIM -liconv" ;;
1056
1057 freebsd) LIBS_SYSTEM="-lutil" ;;
1058
1059 hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
1060
1f5d53eb 1061 sol2*) LIBS_SYSTEM="-lsocket -lnsl" ;;
067d23c9
KY
1062
1063 ## Motif needs -lgen.
1064 unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;;
1065esac
1066AC_SUBST(LIBS_SYSTEM)
1067
1068
1069### Make sure subsequent tests use flags consistent with the build flags.
1070
1071if test x"${OVERRIDE_CPPFLAGS}" != x; then
1072 CPPFLAGS="${OVERRIDE_CPPFLAGS}"
1073else
1074 CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
1075fi
1076
c1e127f9
PE
1077# Suppress obsolescent Autoconf test for size_t; Emacs assumes C89 or better.
1078AC_DEFUN([AC_TYPE_SIZE_T])
2a84b02d
PE
1079# Likewise for obsolescent test for uid_t, gid_t; Emacs assumes them.
1080AC_DEFUN([AC_TYPE_UID_T])
c1e127f9 1081
067d23c9 1082
067d23c9 1083LIB_MATH=-lm
a9be7d2b
GM
1084dnl Current possibilities handled by sed (aix4-2 -> aix,
1085dnl gnu-linux -> gnu/linux, etc.):
1086dnl gnu, gnu/linux, gnu/kfreebsd, aix, cygwin, darwin, hpux, irix.
1087dnl And special cases: berkeley-unix, usg-unix-v, ms-dos, windows-nt.
98d8c1f9 1088SYSTEM_TYPE=`echo $opsys | sed -e 's/[[0-9]].*//' -e 's|-|/|'`
067d23c9
KY
1089
1090case $opsys in
1091 cygwin )
1092 LIB_MATH=
067d23c9
KY
1093 ;;
1094 darwin )
1095 ## Adding -lm confuses the dynamic linker, so omit it.
1096 LIB_MATH=
067d23c9
KY
1097 ;;
1098 freebsd )
a9be7d2b 1099 SYSTEM_TYPE=berkeley-unix
067d23c9
KY
1100 ;;
1101 gnu-linux | gnu-kfreebsd )
067d23c9
KY
1102 ;;
1103 hpux10-20 | hpux11 )
067d23c9 1104 ;;
0538fab0 1105 dnl NB this may be adjusted below.
067d23c9 1106 netbsd | openbsd )
a9be7d2b 1107 SYSTEM_TYPE=berkeley-unix
067d23c9 1108 ;;
a9be7d2b
GM
1109
1110 sol2* | unixware )
1111 SYSTEM_TYPE=usg-unix-v
1112 ;;
1113
067d23c9
KY
1114esac
1115
1116AC_SUBST(LIB_MATH)
a9be7d2b
GM
1117AC_DEFINE_UNQUOTED(SYSTEM_TYPE, "$SYSTEM_TYPE",
1118 [The type of system you are compiling for; sets `system-type'.])
067d23c9 1119
adbc4ef4 1120
5dad233c
PE
1121pre_PKG_CONFIG_CFLAGS=$CFLAGS
1122pre_PKG_CONFIG_LIBS=$LIBS
d35af63c 1123
0e7a053e
PE
1124AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1125
067d23c9
KY
1126dnl This function definition taken from Gnome 2.0
1127dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
1128dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
1129dnl also defines GSTUFF_PKG_ERRORS on error
1130AC_DEFUN([PKG_CHECK_MODULES], [
1131 succeeded=no
1132
067d23c9
KY
1133 if test "$PKG_CONFIG" = "no" ; then
1134 ifelse([$4], , [AC_MSG_ERROR([
3cc53d60 1135 *** The pkg-config script could not be found. Make sure it is in your path, or give the full name of pkg-config with the PKG_CONFIG environment variable or --with-pkg-config-prog. Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config.])], [$4])
067d23c9
KY
1136 else
1137 PKG_CONFIG_MIN_VERSION=0.9.0
75d7aa24 1138 if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
067d23c9
KY
1139 AC_MSG_CHECKING(for $2)
1140
3cc53d60
PE
1141 if "$PKG_CONFIG" --exists "$2" 2>&AS_MESSAGE_LOG_FD &&
1142 $1_CFLAGS=`"$PKG_CONFIG" --cflags "$2" 2>&AS_MESSAGE_LOG_FD` &&
1143 $1_LIBS=`"$PKG_CONFIG" --libs "$2" 2>&AS_MESSAGE_LOG_FD`; then
b8df54ff
PE
1144 edit_cflags="
1145 s,///*,/,g
1146 s/^/ /
1147 s/ -I/ $isystem/g
1148 s/^ //
1149 "
1150 $1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"`
bf6bba2b
PE
1151 $1_LIBS=`AS_ECHO(["$$1_LIBS"]) | sed -e 's,///*,/,g'`
1152 AC_MSG_RESULT([yes CFLAGS='$$1_CFLAGS' LIBS='$$1_LIBS'])
1153 succeeded=yes
067d23c9
KY
1154 else
1155 AC_MSG_RESULT(no)
1156 $1_CFLAGS=""
1157 $1_LIBS=""
1158 ## If we have a custom action on failure, don't print errors, but
e3141fcf
PE
1159 ## do set a variable so people can do so. Do it in a subshell
1160 ## to capture any diagnostics in invoking pkg-config.
3cc53d60 1161 $1_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "$2") 2>&1`
e3141fcf 1162 ifelse([$4], ,echo "$$1_PKG_ERRORS",)
067d23c9
KY
1163 fi
1164
1165 AC_SUBST($1_CFLAGS)
1166 AC_SUBST($1_LIBS)
1167 else
1168 echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
1169 echo "*** See http://www.freedesktop.org/software/pkgconfig"
1170 fi
1171 fi
1172
1173 if test $succeeded = yes; then
1174 ifelse([$3], , :, [$3])
1175 else
1176 ifelse([$4], , [AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.])], [$4])
1177 fi
1178])
1179
1180
1181if test "${with_sound}" != "no"; then
1182 # Sound support for GNU/Linux and the free BSDs.
b06b1098 1183 AC_CHECK_HEADERS(machine/soundcard.h sys/soundcard.h soundcard.h,
067d23c9
KY
1184 have_sound_header=yes)
1185 # Emulation library used on NetBSD.
1186 AC_CHECK_LIB(ossaudio, _oss_ioctl, LIBSOUND=-lossaudio, LIBSOUND=)
1187 AC_SUBST(LIBSOUND)
1188
1189 ALSA_REQUIRED=1.0.0
1190 ALSA_MODULES="alsa >= $ALSA_REQUIRED"
1191 PKG_CHECK_MODULES(ALSA, $ALSA_MODULES, HAVE_ALSA=yes, HAVE_ALSA=no)
1192 if test $HAVE_ALSA = yes; then
1193 SAVE_CFLAGS="$CFLAGS"
46d14be7 1194 SAVE_LIBS="$LIBS"
067d23c9 1195 CFLAGS="$ALSA_CFLAGS $CFLAGS"
46d14be7 1196 LIBS="$ALSA_LIBS $LIBS"
181855e6 1197 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <asoundlib.h>]], [[snd_lib_error_set_handler (0);]])],
067d23c9
KY
1198 emacs_alsa_normal=yes,
1199 emacs_alsa_normal=no)
1200 if test "$emacs_alsa_normal" != yes; then
181855e6
GM
1201 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <alsa/asoundlib.h>]],
1202 [[snd_lib_error_set_handler (0);]])],
067d23c9
KY
1203 emacs_alsa_subdir=yes,
1204 emacs_alsa_subdir=no)
1205 if test "$emacs_alsa_subdir" != yes; then
1206 AC_MSG_ERROR([pkg-config found alsa, but it does not compile. See config.log for error messages.])
1207 fi
1208 ALSA_CFLAGS="$ALSA_CFLAGS -DALSA_SUBDIR_INCLUDE"
1209 fi
1210
1211 CFLAGS="$SAVE_CFLAGS"
46d14be7 1212 LIBS="$SAVE_LIBS"
067d23c9
KY
1213 LIBSOUND="$LIBSOUND $ALSA_LIBS"
1214 CFLAGS_SOUND="$CFLAGS_SOUND $ALSA_CFLAGS"
1215 AC_DEFINE(HAVE_ALSA, 1, [Define to 1 if ALSA is available.])
1216 fi
1217
1218 dnl Define HAVE_SOUND if we have sound support. We know it works and
1219 dnl compiles only on the specified platforms. For others, it
1220 dnl probably doesn't make sense to try.
1221 if test x$have_sound_header = xyes || test $HAVE_ALSA = yes; then
1222 case "$opsys" in
1223 dnl defined __FreeBSD__ || defined __NetBSD__ || defined __linux__
1224 gnu-linux|freebsd|netbsd)
1225 AC_DEFINE(HAVE_SOUND, 1, [Define to 1 if you have sound support.])
1226 ;;
1227 esac
1228 fi
1229
1230 AC_SUBST(CFLAGS_SOUND)
1231fi
1232
1233dnl checks for header files
0e7a053e 1234AC_CHECK_HEADERS_ONCE(
0e7a053e 1235 linux/version.h sys/systeminfo.h
49cdacda 1236 coff.h pty.h
1ddc2bd6 1237 sys/resource.h
95ef7787 1238 sys/utsname.h pwd.h utmp.h util.h)
067d23c9
KY
1239
1240AC_MSG_CHECKING(if personality LINUX32 can be set)
181855e6 1241AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/personality.h>]], [[personality (PER_LINUX32)]])],
067d23c9
KY
1242 emacs_cv_personality_linux32=yes,
1243 emacs_cv_personality_linux32=no)
1244AC_MSG_RESULT($emacs_cv_personality_linux32)
1245
1246if test $emacs_cv_personality_linux32 = yes; then
1247 AC_DEFINE(HAVE_PERSONALITY_LINUX32, 1,
1248 [Define to 1 if personality LINUX32 can be set.])
1249fi
1250
1251dnl On Solaris 8 there's a compilation warning for term.h because
1252dnl it doesn't define `bool'.
1253AC_CHECK_HEADERS(term.h, , , -)
067d23c9 1254AC_HEADER_TIME
c622b48f
PE
1255AC_CHECK_DECLS([sys_siglist], [], [], [[#include <signal.h>
1256 ]])
067d23c9
KY
1257if test $ac_cv_have_decl_sys_siglist != yes; then
1258 # For Tru64, at least:
c622b48f
PE
1259 AC_CHECK_DECLS([__sys_siglist], [], [], [[#include <signal.h>
1260 ]])
067d23c9
KY
1261 if test $ac_cv_have_decl___sys_siglist = yes; then
1262 AC_DEFINE(sys_siglist, __sys_siglist,
1263 [Define to any substitute for sys_siglist.])
1264 fi
1265fi
1266AC_HEADER_SYS_WAIT
1267
067d23c9
KY
1268dnl Check for speed_t typedef.
1269AC_CACHE_CHECK(for speed_t, emacs_cv_speed_t,
181855e6 1270 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <termios.h>]], [[speed_t x = 1;]])],
067d23c9
KY
1271 emacs_cv_speed_t=yes, emacs_cv_speed_t=no)])
1272if test $emacs_cv_speed_t = yes; then
1273 AC_DEFINE(HAVE_SPEED_T, 1,
1274 [Define to 1 if `speed_t' is declared by <termios.h>.])
1275fi
1276
0e7a053e 1277AC_CHECK_HEADERS_ONCE(sys/socket.h)
067d23c9
KY
1278AC_CHECK_HEADERS(net/if.h, , , [AC_INCLUDES_DEFAULT
1279#if HAVE_SYS_SOCKET_H
1280#include <sys/socket.h>
1281#endif])
377538cb
JD
1282AC_CHECK_HEADERS(ifaddrs.h, , , [AC_INCLUDES_DEFAULT
1283#if HAVE_SYS_SOCKET_H
1284#include <sys/socket.h>
1285#endif])
1286AC_CHECK_HEADERS(net/if_dl.h, , , [AC_INCLUDES_DEFAULT
1287#if HAVE_SYS_SOCKET_H
1288#include <sys/socket.h>
1289#endif])
067d23c9
KY
1290
1291dnl checks for structure members
067d23c9
KY
1292AC_CHECK_MEMBERS([struct ifreq.ifr_flags, struct ifreq.ifr_hwaddr,
1293 struct ifreq.ifr_netmask, struct ifreq.ifr_broadaddr,
377538cb
JD
1294 struct ifreq.ifr_addr,
1295 struct ifreq.ifr_addr.sa_len], , ,
067d23c9
KY
1296 [AC_INCLUDES_DEFAULT
1297#if HAVE_SYS_SOCKET_H
1298#include <sys/socket.h>
1299#endif
1300#if HAVE_NET_IF_H
1301#include <net/if.h>
1302#endif])
1303
4c36be58 1304dnl Check for endianness.
0e7a053e 1305dnl AC_C_BIGENDIAN is done by gnulib.
067d23c9
KY
1306
1307dnl check for Make feature
0e7a053e 1308dnl AC_PROG_MAKE_SET is done by Automake.
067d23c9
KY
1309
1310DEPFLAGS=
1311MKDEPDIR=":"
1312deps_frag=deps.mk
1313dnl check for GNU Make if we have GCC and autodepend is on.
1314if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
1315 AC_MSG_CHECKING([whether we are using GNU Make])
1316 HAVE_GNU_MAKE=no
d2eaf3e4 1317 testval=`${MAKE-make} --version 2>/dev/null | grep 'GNU Make'`
067d23c9
KY
1318 if test "x$testval" != x; then
1319 HAVE_GNU_MAKE=yes
1320 else
1321 ac_enable_autodepend=no
1322 fi
1323 AC_MSG_RESULT([$HAVE_GNU_MAKE])
1324 if test $HAVE_GNU_MAKE = yes; then
1325 AC_MSG_CHECKING([whether gcc understands -MMD -MF])
1326 SAVE_CFLAGS="$CFLAGS"
52ec1feb 1327 CFLAGS="$CFLAGS -MMD -MF deps.d -MP"
181855e6 1328 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], , ac_enable_autodepend=no)
067d23c9
KY
1329 CFLAGS="$SAVE_CFLAGS"
1330 test -f deps.d || ac_enable_autodepend=no
1331 rm -rf deps.d
1332 AC_MSG_RESULT([$ac_enable_autodepend])
1333 fi
1334 if test $ac_enable_autodepend = yes; then
52ec1feb 1335 DEPFLAGS='-MMD -MF ${DEPDIR}/$*.d -MP'
3fe7cdc8
GM
1336 ## MKDIR_P is documented (see AC_PROG_MKDIR_P) to be parallel-safe.
1337 MKDEPDIR='${MKDIR_P} ${DEPDIR}'
067d23c9
KY
1338 deps_frag=autodeps.mk
1339 fi
1340fi
1341deps_frag=$srcdir/src/$deps_frag
1342AC_SUBST(MKDEPDIR)
1343AC_SUBST(DEPFLAGS)
1344AC_SUBST_FILE(deps_frag)
1345
1346
b9704ad9
GM
1347lisp_frag=$srcdir/src/lisp.mk
1348AC_SUBST_FILE(lisp_frag)
1349
1350
067d23c9
KY
1351dnl checks for operating system services
1352AC_SYS_LONG_FILE_NAMES
1353
1354#### Choose a window system.
1355
17a2cbbd
DC
1356## We leave window_system equal to none if
1357## we end up building without one. Any new window system should
1358## set window_system to an appropriate value and add objects to
1359## window-system-specific substs.
1360
1361window_system=none
067d23c9 1362AC_PATH_X
17a2cbbd 1363if test "$no_x" != yes; then
067d23c9
KY
1364 window_system=x11
1365fi
1366
4d5c6349 1367LD_SWITCH_X_SITE_RPATH=
067d23c9
KY
1368if test "${x_libraries}" != NONE; then
1369 if test -n "${x_libraries}"; then
1370 LD_SWITCH_X_SITE=-L`echo ${x_libraries} | sed -e "s/:/ -L/g"`
1056cb66 1371 LD_SWITCH_X_SITE_RPATH=-Wl,-rpath,`echo ${x_libraries} | sed -e "s/:/ -Wl,-rpath,/g"`
067d23c9
KY
1372 fi
1373 x_default_search_path=""
1374 x_search_path=${x_libraries}
1375 if test -z "${x_search_path}"; then
1376 x_search_path=/usr/lib
1377 fi
1378 for x_library in `echo ${x_search_path}: | \
1379 sed -e "s/:/ /g" -e p -e "s:/lib[[^ /]]* :/share :g"`; do
1380 x_search_path="\
1381${x_library}/X11/%L/%T/%N%C%S:\
1382${x_library}/X11/%l/%T/%N%C%S:\
1383${x_library}/X11/%T/%N%C%S:\
1384${x_library}/X11/%L/%T/%N%S:\
1385${x_library}/X11/%l/%T/%N%S:\
1386${x_library}/X11/%T/%N%S"
1387 if test x"${x_default_search_path}" = x; then
1388 x_default_search_path=${x_search_path}
1389 else
1390 x_default_search_path="${x_search_path}:${x_default_search_path}"
1391 fi
1392 done
1393fi
4d5c6349 1394AC_SUBST(LD_SWITCH_X_SITE_RPATH)
067d23c9
KY
1395
1396if test "${x_includes}" != NONE && test -n "${x_includes}"; then
b8df54ff 1397 C_SWITCH_X_SITE="$isystem"`echo ${x_includes} | sed -e "s/:/ $isystem/g"`
067d23c9
KY
1398fi
1399
1400if test x"${x_includes}" = x; then
1401 bitmapdir=/usr/include/X11/bitmaps
1402else
1403 # accumulate include directories that have X11 bitmap subdirectories
1404 bmd_acc="dummyval"
1405 for bmd in `echo ${x_includes} | sed -e "s/:/ /g"`; do
1406 if test -d "${bmd}/X11/bitmaps"; then
1407 bmd_acc="${bmd_acc}:${bmd}/X11/bitmaps"
1408 fi
1409 if test -d "${bmd}/bitmaps"; then
1410 bmd_acc="${bmd_acc}:${bmd}/bitmaps"
1411 fi
1412 done
1413 if test ${bmd_acc} != "dummyval"; then
1414 bitmapdir=`echo ${bmd_acc} | sed -e "s/^dummyval://"`
1415 fi
1416fi
1417
1418HAVE_NS=no
1419NS_IMPL_COCOA=no
1420NS_IMPL_GNUSTEP=no
1421tmp_CPPFLAGS="$CPPFLAGS"
1422tmp_CFLAGS="$CFLAGS"
1423CPPFLAGS="$CPPFLAGS -x objective-c"
1424CFLAGS="$CFLAGS -x objective-c"
0cc87afb 1425GNU_OBJC_CFLAGS=
2550c6e4 1426LIBS_GNUSTEP=
067d23c9
KY
1427if test "${with_ns}" != no; then
1428 if test "${opsys}" = darwin; then
1429 NS_IMPL_COCOA=yes
1430 ns_appdir=`pwd`/nextstep/Emacs.app
9e6b06ed 1431 ns_appbindir=${ns_appdir}/Contents/MacOS
067d23c9 1432 ns_appresdir=${ns_appdir}/Contents/Resources
83da1b55 1433 ns_appsrc=Cocoa/Emacs.base
067d23c9
KY
1434 elif test -f $GNUSTEP_CONFIG_FILE; then
1435 NS_IMPL_GNUSTEP=yes
1436 ns_appdir=`pwd`/nextstep/Emacs.app
9e6b06ed 1437 ns_appbindir=${ns_appdir}
067d23c9 1438 ns_appresdir=${ns_appdir}/Resources
83da1b55 1439 ns_appsrc=GNUstep/Emacs.base
067d23c9
KY
1440 dnl FIXME sourcing this several times in subshells seems inefficient.
1441 GNUSTEP_SYSTEM_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_HEADERS)"
1442 GNUSTEP_SYSTEM_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_LIBRARIES)"
1443 dnl I seemed to need these as well with GNUstep-startup 0.25.
1444 GNUSTEP_LOCAL_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_LOCAL_HEADERS)"
1445 GNUSTEP_LOCAL_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_LOCAL_LIBRARIES)"
1446 test "x${GNUSTEP_LOCAL_HEADERS}" != "x" && \
1447 GNUSTEP_LOCAL_HEADERS="-I${GNUSTEP_LOCAL_HEADERS}"
1448 test "x${GNUSTEP_LOCAL_LIBRARIES}" != "x" && \
1449 GNUSTEP_LOCAL_LIBRARIES="-L${GNUSTEP_LOCAL_LIBRARIES}"
1450 CPPFLAGS="$CPPFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
1451 CFLAGS="$CFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
1452 LDFLAGS="$LDFLAGS -L${GNUSTEP_SYSTEM_LIBRARIES} ${GNUSTEP_LOCAL_LIBRARIES}"
2550c6e4 1453 LIBS_GNUSTEP="-lgnustep-gui -lgnustep-base -lobjc -lpthread"
0cc87afb
GM
1454 dnl GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS to 0 or 1.
1455 dnl If they had chosen to either define it or not, we could have
1456 dnl just used AC_CHECK_DECL here.
1457 AC_CACHE_CHECK(if GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS,
1458 emacs_cv_objc_exceptions,
1459AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <GNUstepBase/GSConfig.h>]],
1460[[#if defined BASE_NATIVE_OBJC_EXCEPTIONS && BASE_NATIVE_OBJC_EXCEPTIONS > 0
14611;
1462#else
1463fail;
1464#endif]])], emacs_cv_objc_exceptions=yes, emacs_cv_objc_exceptions=no ) )
1465 if test $emacs_cv_objc_exceptions = yes; then
1466 dnl _NATIVE_OBJC_EXCEPTIONS is used by the GNUstep headers.
1467 AC_DEFINE(_NATIVE_OBJC_EXCEPTIONS, 1,
1468 [Define if GNUstep uses ObjC exceptions.])
1469 GNU_OBJC_CFLAGS="-fobjc-exceptions"
1470 fi
067d23c9 1471 fi
0cc87afb
GM
1472
1473 dnl This is only used while we test the NS headers, it gets reset below.
1474 CFLAGS="$CFLAGS $GNU_OBJC_CFLAGS"
1475
067d23c9
KY
1476 AC_CHECK_HEADER([AppKit/AppKit.h], [HAVE_NS=yes],
1477 [AC_MSG_ERROR([`--with-ns' was specified, but the include
1478 files are missing or cannot be compiled.])])
335f5ae4
JD
1479
1480 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>],
1481 [
1482#ifdef MAC_OS_X_VERSION_MAX_ALLOWED
1483#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
1484 ; /* OK */
1485#else
1486#error "OSX 10.4 or newer required"
1487#endif
1488#endif
1489 ])],
1490 ns_osx_have_104=yes,
1491 ns_osx_have_104=no)
067d23c9
KY
1492 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <Foundation/NSObjCRuntime.h>],
1493 [NSInteger i;])],
1494 ns_have_nsinteger=yes,
1495 ns_have_nsinteger=no)
335f5ae4
JD
1496 if test $ns_osx_have_104 = no; then
1497 AC_MSG_ERROR([`OSX 10.4 or newer is required']);
1498 fi
b1aa797c
GM
1499 if test $ns_have_nsinteger = yes; then
1500 AC_DEFINE(NS_HAVE_NSINTEGER, 1, [Define to 1 if `NSInteger' is defined.])
067d23c9
KY
1501 fi
1502fi
0fda9b75 1503
2550c6e4 1504AC_SUBST(LIBS_GNUSTEP)
067d23c9 1505
0629a797 1506INSTALL_ARCH_INDEP_EXTRA=install-etc
b4a36200 1507ns_self_contained=no
067d23c9 1508NS_OBJ=
00b3c7ac 1509NS_OBJC_OBJ=
067d23c9 1510if test "${HAVE_NS}" = yes; then
44f92739 1511 if test "$with_toolkit_scroll_bars" = "no"; then
f52bac22 1512 AC_MSG_ERROR([Non-toolkit scroll bars are not implemented for Nextstep.])
44f92739
GM
1513 fi
1514
067d23c9 1515 window_system=nextstep
067d23c9 1516 # set up packaging dirs
067d23c9 1517 if test "${EN_NS_SELF_CONTAINED}" = yes; then
b4a36200 1518 ns_self_contained=yes
067d23c9 1519 prefix=${ns_appresdir}
816be9f6 1520 exec_prefix=${ns_appbindir}
3a4155de
GM
1521 dnl This one isn't really used, only archlibdir is.
1522 libexecdir="\${ns_appbindir}/libexec"
1523 archlibdir="\${ns_appbindir}/libexec"
b42c720d
GM
1524 docdir="\${ns_appresdir}/etc"
1525 etcdir="\${ns_appresdir}/etc"
40c117e7
GM
1526 dnl FIXME maybe set datarootdir instead.
1527 dnl That would also get applications, icons, man.
1528 infodir="\${ns_appresdir}/info"
37f36bcb 1529 mandir="\${ns_appresdir}/man"
b42c720d 1530 lispdir="\${ns_appresdir}/lisp"
d71dfe75 1531 leimdir="\${ns_appresdir}/leim"
0629a797 1532 INSTALL_ARCH_INDEP_EXTRA=
067d23c9 1533 fi
00b3c7ac 1534 NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o"
067d23c9
KY
1535fi
1536CFLAGS="$tmp_CFLAGS"
1537CPPFLAGS="$tmp_CPPFLAGS"
0629a797 1538AC_SUBST(INSTALL_ARCH_INDEP_EXTRA)
b4a36200 1539AC_SUBST(ns_self_contained)
067d23c9 1540AC_SUBST(NS_OBJ)
00b3c7ac 1541AC_SUBST(NS_OBJC_OBJ)
067d23c9 1542
0fda9b75
DC
1543HAVE_W32=no
1544W32_OBJ=
1545W32_LIBS=
1cf1bbd5
DC
1546W32_RES=
1547W32_RES_LINK=
0fda9b75
DC
1548if test "${with_w32}" != no; then
1549 if test "${opsys}" != "cygwin"; then
1550 AC_MSG_ERROR([Using w32 with an autotools build is only supported for Cygwin.])
1551 fi
1552 AC_CHECK_HEADER([windows.h], [HAVE_W32=yes],
1553 [AC_MSG_ERROR([`--with-w32' was specified, but windows.h
1554 cannot be found.])])
dc098568 1555 AC_DEFINE(HAVE_NTGUI, 1, [Define to use native MS Windows GUI.])
1cf1bbd5
DC
1556 AC_CHECK_TOOL(WINDRES, [windres],
1557 [AC_MSG_ERROR([No resource compiler found.])])
0fda9b75
DC
1558 W32_OBJ="w32fns.o w32menu.o w32reg.o w32font.o w32term.o"
1559 W32_OBJ="$W32_OBJ w32xfns.o w32select.o w32uniscribe.o"
1560 W32_LIBS="$W32_LIBS -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32"
1561 W32_LIBS="$W32_LIBS -lusp10 -lcomctl32 -lwinspool"
1cf1bbd5
DC
1562 W32_RES="emacs.res"
1563 # Tell the linker that emacs.res is an object (which we compile from
1564 # the rc file), not a linker script.
ba3b2d88 1565 W32_RES_LINK="-Wl,emacs.res"
0fda9b75
DC
1566fi
1567AC_SUBST(W32_OBJ)
1568AC_SUBST(W32_LIBS)
1cf1bbd5
DC
1569AC_SUBST(W32_RES)
1570AC_SUBST(W32_RES_LINK)
0fda9b75
DC
1571
1572if test "${HAVE_W32}" = "yes"; then
1573 window_system=w32
1574 with_xft=no
1575fi
1576
17a2cbbd
DC
1577## $window_system is now set to the window system we will
1578## ultimately use.
1579
1580term_header=
1581HAVE_X_WINDOWS=no
1582HAVE_X11=no
1583USE_X_TOOLKIT=none
1584
067d23c9
KY
1585case "${window_system}" in
1586 x11 )
1587 HAVE_X_WINDOWS=yes
1588 HAVE_X11=yes
17a2cbbd 1589 term_header=xterm.h
067d23c9
KY
1590 case "${with_x_toolkit}" in
1591 athena | lucid ) USE_X_TOOLKIT=LUCID ;;
1592 motif ) USE_X_TOOLKIT=MOTIF ;;
1593 gtk ) with_gtk=yes
17a2cbbd 1594 term_header=gtkutil.h
c7015153 1595dnl Don't set this for GTK. A lot of tests below assumes Xt when
067d23c9
KY
1596dnl USE_X_TOOLKIT is set.
1597 USE_X_TOOLKIT=none ;;
d673aedc
JD
1598 gtk2 ) with_gtk2=yes
1599 term_header=gtkutil.h
1600 USE_X_TOOLKIT=none ;;
067d23c9 1601 gtk3 ) with_gtk3=yes
17a2cbbd 1602 term_header=gtkutil.h
067d23c9
KY
1603 USE_X_TOOLKIT=none ;;
1604 no ) USE_X_TOOLKIT=none ;;
1605dnl If user did not say whether to use a toolkit, make this decision later:
1606dnl use the toolkit if we have gtk, or X11R5 or newer.
1607 * ) USE_X_TOOLKIT=maybe ;;
1608 esac
1609 ;;
17a2cbbd
DC
1610 nextstep )
1611 term_header=nsterm.h
067d23c9 1612 ;;
0fda9b75
DC
1613 w32 )
1614 term_header=w32term.h
1615 ;;
067d23c9
KY
1616esac
1617
1618if test "$window_system" = none && test "X$with_x" != "Xno"; then
1619 AC_CHECK_PROG(HAVE_XSERVER, X, true, false)
1620 if test "$HAVE_XSERVER" = true ||
1621 test -n "$DISPLAY" ||
1622 test "`echo /usr/lib/libX11.*`" != "/usr/lib/libX11.*"; then
1623 AC_MSG_ERROR([You seem to be running X, but no X development libraries
1624were found. You should install the relevant development files for X
1625and for the toolkit you want, such as Gtk+, Lesstif or Motif. Also make
1626sure you have development files for image handling, i.e.
1627tiff, gif, jpeg, png and xpm.
1628If you are sure you want Emacs compiled without X window support, pass
1629 --without-x
1630to configure.])
1631 fi
1632fi
1633
1634### If we're using X11, we should use the X menu package.
1635HAVE_MENUS=no
1636case ${HAVE_X11} in
1637 yes ) HAVE_MENUS=yes ;;
1638esac
1639
34374650 1640# Does the opsystem file prohibit the use of the GNU malloc?
067d23c9
KY
1641# Assume not, until told otherwise.
1642GNU_MALLOC=yes
4b5b5289
PE
1643
1644AC_CACHE_CHECK(
1645 [whether malloc is Doug Lea style],
1646 [emacs_cv_var_doug_lea_malloc],
1647 [AC_LINK_IFELSE(
1648 [AC_LANG_PROGRAM(
1649 [[#include <malloc.h>
1650 static void hook (void) {}]],
1651 [[malloc_set_state (malloc_get_state ());
1652 __after_morecore_hook = hook;
1653 __malloc_initialize_hook = hook;]])],
1654 [emacs_cv_var_doug_lea_malloc=yes],
1655 [emacs_cv_var_doug_lea_malloc=no])])
1656doug_lea_malloc=$emacs_cv_var_doug_lea_malloc
067d23c9
KY
1657
1658
1659dnl See comments in aix4-2.h about maybe using system malloc there.
1660system_malloc=no
1661case "$opsys" in
1662 ## darwin ld insists on the use of malloc routines in the System framework.
1663 darwin|sol2-10) system_malloc=yes ;;
1664esac
1665
1666if test "${system_malloc}" = "yes"; then
1667 AC_DEFINE(SYSTEM_MALLOC, 1, [Define to use system malloc.])
1668 GNU_MALLOC=no
1669 GNU_MALLOC_reason="
1670 (The GNU allocators don't work with this system configuration.)"
1671 GMALLOC_OBJ=
1672 VMLIMIT_OBJ=
1673else
1674 test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
1675 VMLIMIT_OBJ=vm-limit.o
1ddc2bd6
PE
1676
1677 AC_CHECK_HEADERS([sys/vlimit.h])
1678 AC_CACHE_CHECK([for data_start], [emacs_cv_data_start],
1679 [AC_LINK_IFELSE(
1680 [AC_LANG_PROGRAM(
1681 [[extern char data_start[]; char ch;]],
0e946786 1682 [[return data_start < &ch;]])],
1ddc2bd6
PE
1683 [emacs_cv_data_start=yes],
1684 [emacs_cv_data_start=no])])
1685 if test $emacs_cv_data_start = yes; then
1686 AC_DEFINE([HAVE_DATA_START], 1,
1687 [Define to 1 if data_start is the address of the start
1688 of the main data segment.])
1689 fi
067d23c9
KY
1690fi
1691AC_SUBST(GMALLOC_OBJ)
1692AC_SUBST(VMLIMIT_OBJ)
1693
1694if test "$doug_lea_malloc" = "yes" ; then
1695 if test "$GNU_MALLOC" = yes ; then
1696 GNU_MALLOC_reason="
1697 (Using Doug Lea's new malloc from the GNU C Library.)"
1698 fi
1699 AC_DEFINE(DOUG_LEA_MALLOC, 1,
1700 [Define to 1 if you are using the GNU C Library.])
1701
1702 ## Use mmap directly for allocating larger buffers.
1703 ## FIXME this comes from src/s/{gnu,gnu-linux}.h:
1704 ## #ifdef DOUG_LEA_MALLOC; #undef REL_ALLOC; #endif
bbd240ce 1705 ## Does the AC_FUNC_MMAP test below make this check unnecessary?
067d23c9
KY
1706 case "$opsys" in
1707 gnu*) REL_ALLOC=no ;;
1708 esac
1709fi
1710
1711if test x"${REL_ALLOC}" = x; then
1712 REL_ALLOC=${GNU_MALLOC}
1713fi
1714
1715use_mmap_for_buffers=no
1716case "$opsys" in
fe0e7ad7 1717 cygwin|freebsd|irix6-5) use_mmap_for_buffers=yes ;;
067d23c9
KY
1718esac
1719
1720AC_FUNC_MMAP
1721if test $use_mmap_for_buffers = yes; then
1722 AC_DEFINE(USE_MMAP_FOR_BUFFERS, 1, [Define to use mmap to allocate buffer text.])
1723 REL_ALLOC=no
1724fi
1725
1726LIBS="$LIBS_SYSTEM $LIBS"
1727
1728dnl If found, this defines HAVE_LIBDNET, which m/pmax.h checks,
1729dnl and also adds -ldnet to LIBS, which Autoconf uses for checks.
1730AC_CHECK_LIB(dnet, dnet_ntoa)
1731dnl This causes -lresolv to get used in subsequent tests,
1732dnl which causes failures on some systems such as HPUX 9.
1733dnl AC_CHECK_LIB(resolv, gethostbyname)
1734
1735dnl FIXME replace main with a function we actually want from this library.
1736AC_CHECK_LIB(Xbsd, main, LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -lXbsd")
1737
ae9e757a
JD
1738dnl Check if pthreads is available.
1739LIB_PTHREAD=
0e7a053e 1740AC_CHECK_HEADERS_ONCE(pthread.h)
ae9e757a 1741if test "$ac_cv_header_pthread_h"; then
adee8a65
PE
1742 dnl gmalloc.c uses pthread_atfork, which is not available on older-style
1743 dnl hosts such as MirBSD 10, so test for pthread_atfork instead of merely
1744 dnl testing for pthread_self if Emacs uses gmalloc.c.
1745 if test "$GMALLOC_OBJ" = gmalloc.o; then
1746 emacs_pthread_function=pthread_atfork
1747 else
1748 emacs_pthread_function=pthread_self
1749 fi
1750 AC_CHECK_LIB(pthread, $emacs_pthread_function, HAVE_PTHREAD=yes)
ae9e757a
JD
1751fi
1752if test "$HAVE_PTHREAD" = yes; then
1753 case "${canonical}" in
1754 *-hpux*) ;;
e782cfab
PE
1755 *) LIB_PTHREAD="-lpthread"
1756 LIBS="$LIB_PTHREAD $LIBS" ;;
ae9e757a
JD
1757 esac
1758 AC_DEFINE(HAVE_PTHREAD, 1, [Define to 1 if you have pthread (-lpthread).])
1759fi
1760AC_SUBST([LIB_PTHREAD])
1761
067d23c9
KY
1762AC_CHECK_LIB(pthreads, cma_open)
1763
1764## Note: when using cpp in s/aix4.2.h, this definition depended on
1765## HAVE_LIBPTHREADS. That was not defined earlier in configure when
1766## the system file was sourced. Hence the value of LIBS_SYSTEM
1767## added to LIBS in configure would never contain the pthreads part,
1768## but the value used in Makefiles might. FIXME?
1769##
1770## -lpthreads seems to be necessary for Xlib in X11R6, and should
1771## be harmless on older versions of X where it happens to exist.
1772test "$opsys" = "aix4-2" && \
1773 test $ac_cv_lib_pthreads_cma_open = yes && \
1774 LIBS_SYSTEM="$LIBS_SYSTEM -lpthreads"
1775
1776dnl Check for need for bigtoc support on IBM AIX
1777
1778case ${host_os} in
1779aix*)
1780 AC_CACHE_CHECK([for -bbigtoc option], [gdb_cv_bigtoc], [
1781 case $GCC in
1782 yes) gdb_cv_bigtoc=-Wl,-bbigtoc ;;
1783 *) gdb_cv_bigtoc=-bbigtoc ;;
1784 esac
1785
1786 LDFLAGS=$LDFLAGS\ $gdb_cv_bigtoc
181855e6 1787 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])], [], [gdb_cv_bigtoc=])
067d23c9
KY
1788 ])
1789 ;;
1790esac
1791
1792# Change CFLAGS and CPPFLAGS temporarily so that C_SWITCH_X_SITE gets
1793# used for the tests that follow. We set them back to REAL_CFLAGS and
1794# REAL_CPPFLAGS later on.
1795
1796REAL_CFLAGS="$CFLAGS"
1797REAL_CPPFLAGS="$CPPFLAGS"
1798
1799if test "${HAVE_X11}" = "yes"; then
1800 DEFS="$C_SWITCH_X_SITE $DEFS"
1801 LDFLAGS="$LDFLAGS $LD_SWITCH_X_SITE"
1802 LIBS="-lX11 $LIBS"
1803 CFLAGS="$C_SWITCH_X_SITE $CFLAGS"
1804 CPPFLAGS="$C_SWITCH_X_SITE $CPPFLAGS"
1805
1806 # On Solaris, arrange for LD_RUN_PATH to point to the X libraries for tests.
4d5c6349 1807 # This is handled by LD_SWITCH_X_SITE_RPATH during the real build,
4737362e 1808 # but it's more convenient here to set LD_RUN_PATH since this
4d5c6349 1809 # also works on hosts that don't understand LD_SWITCH_X_SITE_RPATH.
067d23c9
KY
1810 if test "${x_libraries}" != NONE && test -n "${x_libraries}"; then
1811 LD_RUN_PATH=$x_libraries${LD_RUN_PATH+:}$LD_RUN_PATH
1812 export LD_RUN_PATH
1813 fi
1814
1815 if test "${opsys}" = "gnu-linux"; then
1816 AC_MSG_CHECKING(whether X on GNU/Linux needs -b to link)
181855e6
GM
1817 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
1818 [[XOpenDisplay ("foo");]])],
423dbf9b
RS
1819 [xgnu_linux_first_failure=no],
1820 [xgnu_linux_first_failure=yes])
1821 if test "${xgnu_linux_first_failure}" = "yes"; then
067d23c9
KY
1822 OLD_LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE"
1823 OLD_C_SWITCH_X_SITE="$C_SWITCH_X_SITE"
1824 OLD_CPPFLAGS="$CPPFLAGS"
1825 OLD_LIBS="$LIBS"
1826 LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -b i486-linuxaout"
1827 C_SWITCH_X_SITE="$C_SWITCH_X_SITE -b i486-linuxaout"
1828 CPPFLAGS="$CPPFLAGS -b i486-linuxaout"
1829 LIBS="$LIBS -b i486-linuxaout"
181855e6
GM
1830 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
1831 [[XOpenDisplay ("foo");]])],
423dbf9b
RS
1832 [xgnu_linux_second_failure=no],
1833 [xgnu_linux_second_failure=yes])
1834 if test "${xgnu_linux_second_failure}" = "yes"; then
067d23c9
KY
1835 # If we get the same failure with -b, there is no use adding -b.
1836 # So take it out. This plays safe.
1837 LD_SWITCH_X_SITE="$OLD_LD_SWITCH_X_SITE"
1838 C_SWITCH_X_SITE="$OLD_C_SWITCH_X_SITE"
1839 CPPFLAGS="$OLD_CPPFLAGS"
1840 LIBS="$OLD_LIBS"
1841 AC_MSG_RESULT(no)
1842 else
1843 AC_MSG_RESULT(yes)
1844 fi
1845 else
1846 AC_MSG_RESULT(no)
1847 fi
1848 fi
1849
1850 # Reportedly, some broken Solaris systems have XKBlib.h but are missing
1851 # header files included from there.
1852 AC_MSG_CHECKING(for Xkb)
181855e6
GM
1853 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>
1854#include <X11/XKBlib.h>]],
1855 [[XkbDescPtr kb = XkbGetKeyboard (0, XkbAllComponentsMask, XkbUseCoreKbd);]])],
067d23c9
KY
1856 emacs_xkb=yes, emacs_xkb=no)
1857 AC_MSG_RESULT($emacs_xkb)
1858 if test $emacs_xkb = yes; then
a4cedbf7 1859 AC_DEFINE(HAVE_XKB, 1, [Define to 1 if you have the Xkb extension.])
067d23c9
KY
1860 fi
1861
1862 AC_CHECK_FUNCS(XrmSetDatabase XScreenResourceString \
9232a6d9 1863XScreenNumberOfScreen)
067d23c9
KY
1864fi
1865
1866if test "${window_system}" = "x11"; then
1867 AC_MSG_CHECKING(X11 version 6)
1868 AC_CACHE_VAL(emacs_cv_x11_version_6,
181855e6
GM
1869 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
1870[[#if XlibSpecificationRelease < 6
067d23c9
KY
1871fail;
1872#endif
181855e6 1873]])], emacs_cv_x11_version_6=yes, emacs_cv_x11_version_6=no)])
067d23c9
KY
1874 if test $emacs_cv_x11_version_6 = yes; then
1875 AC_MSG_RESULT(6 or newer)
1876 AC_DEFINE(HAVE_X11R6, 1,
1877 [Define to 1 if you have the X11R6 or newer version of Xlib.])
1878 AC_DEFINE(HAVE_X_I18N, 1, [Define if you have usable i18n support.])
1879 ## inoue@ainet.or.jp says Solaris has a bug related to X11R6-style
1880 ## XIM support.
1881 case "$opsys" in
1882 sol2-*) : ;;
1883 *) AC_DEFINE(HAVE_X11R6_XIM, 1,
1884 [Define if you have usable X11R6-style XIM support.])
1885 ;;
1886 esac
1887 else
1888 AC_MSG_RESULT(before 6)
1889 fi
1890fi
1891
1892
1893### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified.
1894HAVE_RSVG=no
be8ec0b3 1895if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes"; then
067d23c9
KY
1896 if test "${with_rsvg}" != "no"; then
1897 RSVG_REQUIRED=2.11.0
1898 RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
1899
1900 PKG_CHECK_MODULES(RSVG, $RSVG_MODULE, HAVE_RSVG=yes, :)
1901 AC_SUBST(RSVG_CFLAGS)
1902 AC_SUBST(RSVG_LIBS)
1903
1904 if test $HAVE_RSVG = yes; then
1905 AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
1906 CFLAGS="$CFLAGS $RSVG_CFLAGS"
1907 LIBS="$RSVG_LIBS $LIBS"
1908 fi
1909 fi
1910fi
1911
1912HAVE_IMAGEMAGICK=no
1913if test "${HAVE_X11}" = "yes"; then
1914 if test "${with_imagemagick}" != "no"; then
f5b06c35
GM
1915 ## 6.2.8 is the earliest version known to work, but earlier versions
1916 ## might work - let us know if you find one.
1917 ## 6.0.7 does not work. See bug#7955.
19151a7f
PE
1918 ## 6.8.2 makes Emacs crash; see Bug#13867.
1919 IMAGEMAGICK_MODULE="Wand >= 6.2.8 Wand != 6.8.2"
067d23c9
KY
1920 PKG_CHECK_MODULES(IMAGEMAGICK, $IMAGEMAGICK_MODULE, HAVE_IMAGEMAGICK=yes, :)
1921 AC_SUBST(IMAGEMAGICK_CFLAGS)
1922 AC_SUBST(IMAGEMAGICK_LIBS)
b06b1098 1923
067d23c9
KY
1924 if test $HAVE_IMAGEMAGICK = yes; then
1925 AC_DEFINE(HAVE_IMAGEMAGICK, 1, [Define to 1 if using imagemagick.])
1926 CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS"
1927 LIBS="$IMAGEMAGICK_LIBS $LIBS"
03043c1b 1928 AC_CHECK_FUNCS(MagickExportImagePixels MagickMergeImageLayers)
067d23c9
KY
1929 fi
1930 fi
1931fi
1932
1933
1934HAVE_GTK=no
c195f2de 1935GTK_OBJ=
d673aedc
JD
1936check_gtk2=no
1937gtk3_pkg_errors=
1938if test "${with_gtk3}" = "yes" || test "${with_gtk}" = "yes" || test "$USE_X_TOOLKIT" = "maybe"; then
0afb4571
J
1939 GLIB_REQUIRED=2.28
1940 GTK_REQUIRED=3.0
067d23c9
KY
1941 GTK_MODULES="gtk+-3.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
1942
1943 dnl Checks for libraries.
1944 PKG_CHECK_MODULES(GTK, $GTK_MODULES, pkg_check_gtk=yes, pkg_check_gtk=no)
d673aedc 1945 if test "$pkg_check_gtk" = "no" && test "$with_gtk3" = "yes"; then
067d23c9
KY
1946 AC_MSG_ERROR($GTK_PKG_ERRORS)
1947 fi
d673aedc
JD
1948 if test "$pkg_check_gtk" = "yes"; then
1949 AC_DEFINE(HAVE_GTK3, 1, [Define to 1 if using GTK 3 or later.])
1950 GTK_OBJ=emacsgtkfixed.o
1951 term_header=gtkutil.h
5fb91e71 1952 USE_GTK_TOOLKIT="GTK3"
7ec363cf
JD
1953 if test "x$ac_enable_gtk_deprecation_warnings" = x; then
1954 GTK_CFLAGS="$GTK_CFLAGS -DGDK_DISABLE_DEPRECATION_WARNINGS"
1955 fi
d673aedc
JD
1956 else
1957 check_gtk2=yes
1958 gtk3_pkg_errors="$GTK_PKG_ERRORS "
1959 fi
067d23c9
KY
1960fi
1961
d673aedc 1962if test "${with_gtk2}" = "yes" || test "$check_gtk2" = "yes"; then
0ffe1065
JD
1963 GLIB_REQUIRED=2.10
1964 GTK_REQUIRED=2.10
067d23c9
KY
1965 GTK_MODULES="gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
1966
1967 dnl Checks for libraries.
1968 PKG_CHECK_MODULES(GTK, $GTK_MODULES, pkg_check_gtk=yes, pkg_check_gtk=no)
e3141fcf
PE
1969 if test "$pkg_check_gtk" = "no" &&
1970 { test "$with_gtk" = yes || test "$with_gtk2" = "yes"; }
1971 then
1972 AC_MSG_ERROR($gtk3_pkg_errors$GTK_PKG_ERRORS)
067d23c9 1973 fi
5fb91e71 1974 test "$pkg_check_gtk" = "yes" && USE_GTK_TOOLKIT="GTK2"
067d23c9 1975fi
067d23c9 1976
067d23c9
KY
1977if test x"$pkg_check_gtk" = xyes; then
1978
1979 AC_SUBST(GTK_CFLAGS)
1980 AC_SUBST(GTK_LIBS)
1981 C_SWITCH_X_SITE="$C_SWITCH_X_SITE $GTK_CFLAGS"
1982 CFLAGS="$CFLAGS $GTK_CFLAGS"
1983 LIBS="$GTK_LIBS $LIBS"
1984 dnl Try to compile a simple GTK program.
1985 GTK_COMPILES=no
1986 AC_CHECK_FUNCS(gtk_main, GTK_COMPILES=yes)
1987 if test "${GTK_COMPILES}" != "yes"; then
1988 if test "$USE_X_TOOLKIT" != "maybe"; then
1989 AC_MSG_ERROR([Gtk+ wanted, but it does not compile, see config.log. Maybe some x11-devel files missing?]);
1990 fi
1991 else
1992 HAVE_GTK=yes
1993 AC_DEFINE(USE_GTK, 1, [Define to 1 if using GTK.])
c195f2de 1994 GTK_OBJ="gtkutil.o $GTK_OBJ"
067d23c9 1995 USE_X_TOOLKIT=none
3cc53d60 1996 if "$PKG_CONFIG" --atleast-version=2.10 gtk+-2.0; then
067d23c9
KY
1997 :
1998 else
1999 AC_MSG_WARN([[Your version of Gtk+ will have problems with
2000 closing open displays. This is no problem if you just use
2001 one display, but if you use more than one and close one of them
2002 Emacs may crash.]])
2003 sleep 3
2004 fi
2005 fi
2006
2007fi
2008AC_SUBST(GTK_OBJ)
2009
2010
2011if test "${HAVE_GTK}" = "yes"; then
2012
2013 dnl GTK scrollbars resemble toolkit scrollbars a lot, so to avoid
2014 dnl a lot if #ifdef:s, say we have toolkit scrollbars.
2015 if test "$with_toolkit_scroll_bars" != no; then
2016 with_toolkit_scroll_bars=yes
2017 fi
2018
2019 dnl Check if we have the old file selection dialog declared and
2020 dnl in the link library. In 2.x it may be in the library,
2021 dnl but not declared if deprecated featured has been selected out.
2022 dnl AC_CHECK_DECL checks for a macro, so check for GTK_TYPE_FILE_SELECTION.
2023 HAVE_GTK_FILE_SELECTION=no
2024 AC_CHECK_DECL(GTK_TYPE_FILE_SELECTION, HAVE_GTK_FILE_SELECTION=yes,
2025 HAVE_GTK_FILE_SELECTION=no, [AC_INCLUDES_DEFAULT
2026#include <gtk/gtk.h>])
2027 if test "$HAVE_GTK_FILE_SELECTION" = yes; then
2028 AC_CHECK_FUNCS(gtk_file_selection_new)
2029 fi
2030
5a1d858b
JD
2031 dnl Same as above for gtk_handle_box.
2032 HAVE_GTK_HANDLE_BOX=no
2033 AC_CHECK_DECL(GTK_TYPE_HANDLE_BOX, HAVE_GTK_HANDLE_BOX=yes,
2034 HAVE_GTK_HANDLE_BOX=no, [AC_INCLUDES_DEFAULT
2035#include <gtk/gtk.h>])
2036 if test "$HAVE_GTK_HANDLE_BOX" = yes; then
2037 AC_CHECK_FUNCS(gtk_handle_box_new)
2038 fi
067d23c9 2039
8b745d92
JD
2040 dnl Same as above for gtk_tearoff_menu_item.
2041 HAVE_GTK_TEAROFF_MENU_ITEM=no
2042 AC_CHECK_DECL(GTK_TYPE_TEAROFF_MENU_ITEM, HAVE_GTK_TEAROFF_MENU_ITEM=yes,
2043 HAVE_GTK_TEAROFF_MENU_ITEM=no, [AC_INCLUDES_DEFAULT
2044#include <gtk/gtk.h>])
2045 if test "$HAVE_GTK_TEAROFF_MENU_ITEM" = yes; then
2046 AC_CHECK_FUNCS(gtk_tearoff_menu_item_new)
2047 fi
2048
067d23c9
KY
2049 dnl Check for functions introduced in 2.14 and later.
2050 AC_CHECK_FUNCS(gtk_widget_get_window gtk_widget_set_has_window \
2051 gtk_dialog_get_action_area gtk_widget_get_sensitive \
2052 gtk_widget_get_mapped gtk_adjustment_get_page_size \
54e9e3bf
JD
2053 gtk_orientable_set_orientation \
2054 gtk_window_set_has_resize_grip)
17a2cbbd
DC
2055
2056 term_header=gtkutil.h
067d23c9
KY
2057fi
2058
2059dnl D-Bus has been tested under GNU/Linux only. Must be adapted for
dcbf5805 2060dnl other platforms.
067d23c9
KY
2061HAVE_DBUS=no
2062DBUS_OBJ=
2063if test "${with_dbus}" = "yes"; then
2064 PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.0, HAVE_DBUS=yes, HAVE_DBUS=no)
2065 if test "$HAVE_DBUS" = yes; then
2066 LIBS="$LIBS $DBUS_LIBS"
2067 AC_DEFINE(HAVE_DBUS, 1, [Define to 1 if using D-Bus.])
dcbf5805 2068 dnl dbus_watch_get_unix_fd has been introduced in D-Bus 1.1.1.
e3a3e213
MA
2069 dnl dbus_type_is_valid and dbus_validate_* have been introduced in
2070 dnl D-Bus 1.5.12.
dcbf5805 2071 AC_CHECK_FUNCS(dbus_watch_get_unix_fd \
e3a3e213 2072 dbus_type_is_valid \
dcbf5805
MA
2073 dbus_validate_bus_name \
2074 dbus_validate_path \
2075 dbus_validate_interface \
2076 dbus_validate_member)
067d23c9
KY
2077 DBUS_OBJ=dbusbind.o
2078 fi
2079fi
2080AC_SUBST(DBUS_OBJ)
2081
9851bfc5
JD
2082dnl GSettings has been tested under GNU/Linux only.
2083HAVE_GSETTINGS=no
2084if test "${HAVE_X11}" = "yes" && test "${with_gsettings}" = "yes"; then
2ad77c9d 2085 PKG_CHECK_MODULES(GSETTINGS, gio-2.0 >= 2.26, HAVE_GSETTINGS=yes, HAVE_GSETTINGS=no)
2e6e11eb 2086 if test "$HAVE_GSETTINGS" = "yes"; then
9851bfc5
JD
2087 AC_DEFINE(HAVE_GSETTINGS, 1, [Define to 1 if using GSettings.])
2088 SETTINGS_CFLAGS="$GSETTINGS_CFLAGS"
2089 SETTINGS_LIBS="$GSETTINGS_LIBS"
2090 fi
2091fi
2092
067d23c9
KY
2093dnl GConf has been tested under GNU/Linux only.
2094dnl The version is really arbitrary, it is about the same age as Gtk+ 2.6.
2095HAVE_GCONF=no
869795d6 2096if test "${HAVE_X11}" = "yes" && test "${with_gconf}" = "yes"; then
067d23c9
KY
2097 PKG_CHECK_MODULES(GCONF, gconf-2.0 >= 2.13, HAVE_GCONF=yes, HAVE_GCONF=no)
2098 if test "$HAVE_GCONF" = yes; then
2099 AC_DEFINE(HAVE_GCONF, 1, [Define to 1 if using GConf.])
2100 dnl Newer GConf doesn't link with g_objects, so this is not defined.
869795d6
JD
2101 SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GCONF_CFLAGS"
2102 SETTINGS_LIBS="$SETTINGS_LIBS $GCONF_LIBS"
067d23c9
KY
2103 fi
2104fi
2105
2e6e11eb 2106if test "$HAVE_GSETTINGS" = "yes" || test "$HAVE_GCONF" = "yes"; then
f278d339
JD
2107 PKG_CHECK_MODULES(GOBJECT, gobject-2.0 >= 2.0, HAVE_GOBJECT=yes, HAVE_GOBJECT=no)
2108 if test "$HAVE_GOBJECT" = "yes"; then
2109 SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GOBJECT_CFLAGS"
2110 SETTINGS_LIBS="$SETTINGS_LIBS $GOBJECT_LIBS"
2111 fi
9851bfc5 2112 SAVE_CFLAGS="$CFLAGS"
46d14be7 2113 SAVE_LIBS="$LIBS"
9851bfc5 2114 CFLAGS="$SETTINGS_CFLAGS $CFLAGS"
46d14be7 2115 LIBS="$SETTINGS_LIBS $LIBS"
9851bfc5
JD
2116 AC_CHECK_FUNCS([g_type_init])
2117 CFLAGS="$SAVE_CFLAGS"
46d14be7 2118 LIBS="$SAVE_LIBS"
9851bfc5
JD
2119fi
2120AC_SUBST(SETTINGS_CFLAGS)
2121AC_SUBST(SETTINGS_LIBS)
2122
2123
067d23c9
KY
2124dnl SELinux is available for GNU/Linux only.
2125HAVE_LIBSELINUX=no
2126LIBSELINUX_LIBS=
2127if test "${with_selinux}" = "yes"; then
2128 AC_CHECK_LIB([selinux], [lgetfilecon], HAVE_LIBSELINUX=yes, HAVE_LIBSELINUX=no)
2129 if test "$HAVE_LIBSELINUX" = yes; then
2130 AC_DEFINE(HAVE_LIBSELINUX, 1, [Define to 1 if using SELinux.])
2131 LIBSELINUX_LIBS=-lselinux
2132 fi
2133fi
2134AC_SUBST(LIBSELINUX_LIBS)
2135
2136HAVE_GNUTLS=no
33630d51 2137HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY=no
067d23c9 2138if test "${with_gnutls}" = "yes" ; then
9f77899d 2139 PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.6.6], HAVE_GNUTLS=yes, HAVE_GNUTLS=no)
067d23c9
KY
2140 if test "${HAVE_GNUTLS}" = "yes"; then
2141 AC_DEFINE(HAVE_GNUTLS, 1, [Define if using GnuTLS.])
2142 fi
33630d51
TZ
2143
2144 CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
2145 LIBS="$LIBGNUTLS_LIBS $LIBS"
2146 AC_CHECK_FUNCS(gnutls_certificate_set_verify_function, HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY=yes)
2147
2148 if test "${HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY}" = "yes"; then
2149 AC_DEFINE(HAVE_GNUTLS_CALLBACK_CERTIFICATE_VERIFY, 1, [Define if using GnuTLS certificate verification callbacks.])
2150 fi
067d23c9 2151fi
33630d51 2152
067d23c9
KY
2153AC_SUBST(LIBGNUTLS_LIBS)
2154AC_SUBST(LIBGNUTLS_CFLAGS)
2155
81606b10 2156dnl inotify is only available on GNU/Linux.
81606b10
RS
2157if test "${with_inotify}" = "yes"; then
2158 AC_CHECK_HEADERS(sys/inotify.h)
2159 if test "$ac_cv_header_sys_inotify_h" = yes ; then
7e77303e 2160 AC_CHECK_FUNC(inotify_init1)
81606b10
RS
2161 fi
2162fi
7e77303e
PE
2163if test "$ac_cv_func_inotify_init1" = yes; then
2164 AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 to use inotify.])
81606b10
RS
2165fi
2166
7c3d167f
RF
2167dnl POSIX ACL support: provided by libacl on GNU/Linux, by libc on FreeBSD.
2168HAVE_POSIX_ACL=no
2169LIBACL_LIBS=
2170if test "${with_acl}" = "yes"; then
2171 AC_CHECK_LIB([acl], [acl_set_file], HAVE_POSIX_ACL=yes, HAVE_POSIX_ACL=no)
2172 if test "$HAVE_POSIX_ACL" = yes; then
2173 AC_DEFINE(HAVE_POSIX_ACL, 1, [Define to 1 if using POSIX ACL support.])
2174 LIBACL_LIBS=-lacl
2175 else
2176 AC_CHECK_FUNC(acl_set_file, HAVE_POSIX_ACL=yes, HAVE_POSIX_ACL=no)
2177 if test "$HAVE_POSIX_ACL" = yes; then
2178 AC_DEFINE(HAVE_POSIX_ACL, 1, [Define to 1 if using POSIX ACL support.])
2179 fi
2180 fi
2181fi
2182AC_SUBST(LIBACL_LIBS)
2183
067d23c9
KY
2184dnl Do not put whitespace before the #include statements below.
2185dnl Older compilers (eg sunos4 cc) choke on it.
2186HAVE_XAW3D=no
2187LUCID_LIBW=
2188if test x"${USE_X_TOOLKIT}" = xmaybe || test x"${USE_X_TOOLKIT}" = xLUCID; then
2189 if test "$with_xaw3d" != no; then
067d23c9 2190 AC_CACHE_VAL(emacs_cv_xaw3d,
181855e6 2191 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
067d23c9 2192#include <X11/Intrinsic.h>
181855e6
GM
2193#include <X11/Xaw3d/Simple.h>]],
2194 [[]])],
37f7b784
CY
2195 [AC_CHECK_LIB(Xaw3d, XawScrollbarSetThumb,
2196 emacs_cv_xaw3d=yes, emacs_cv_xaw3d=no)],
067d23c9
KY
2197 emacs_cv_xaw3d=no)])
2198 else
2199 emacs_cv_xaw3d=no
2200 fi
2201 if test $emacs_cv_xaw3d = yes; then
2c484e75 2202 AC_MSG_CHECKING(for xaw3d)
067d23c9
KY
2203 AC_MSG_RESULT([yes; using Lucid toolkit])
2204 USE_X_TOOLKIT=LUCID
2205 HAVE_XAW3D=yes
2206 LUCID_LIBW=-lXaw3d
2207 AC_DEFINE(HAVE_XAW3D, 1,
2208 [Define to 1 if you have the Xaw3d library (-lXaw3d).])
2209 else
2c484e75 2210 AC_MSG_CHECKING(for xaw3d)
067d23c9
KY
2211 AC_MSG_RESULT(no)
2212 AC_MSG_CHECKING(for libXaw)
2213 AC_CACHE_VAL(emacs_cv_xaw,
181855e6 2214 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
067d23c9 2215#include <X11/Intrinsic.h>
181855e6
GM
2216#include <X11/Xaw/Simple.h>]],
2217 [[]])],
067d23c9
KY
2218 emacs_cv_xaw=yes,
2219 emacs_cv_xaw=no)])
2220 if test $emacs_cv_xaw = yes; then
2221 AC_MSG_RESULT([yes; using Lucid toolkit])
2222 USE_X_TOOLKIT=LUCID
2223 LUCID_LIBW=-lXaw
2224 elif test x"${USE_X_TOOLKIT}" = xLUCID; then
2225 AC_MSG_ERROR([Lucid toolkit requires X11/Xaw include files])
2226 else
d681f183
GM
2227 AC_MSG_ERROR([No X toolkit could be found.
2228If you are sure you want Emacs compiled without an X toolkit, pass
2229 --with-x-toolkit=no
2230to configure. Otherwise, install the development libraries for the toolkit
2231that you want to use (e.g. Gtk+) and re-run configure.])
067d23c9
KY
2232 fi
2233 fi
2234fi
2235
2236X_TOOLKIT_TYPE=$USE_X_TOOLKIT
2237
2238LIBXTR6=
2239if test "${USE_X_TOOLKIT}" != "none"; then
2240 AC_MSG_CHECKING(X11 toolkit version)
2241 AC_CACHE_VAL(emacs_cv_x11_toolkit_version_6,
181855e6
GM
2242 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Intrinsic.h>]],
2243[[#if XtSpecificationRelease < 6
067d23c9
KY
2244fail;
2245#endif
181855e6 2246]])], emacs_cv_x11_toolkit_version_6=yes, emacs_cv_x11_toolkit_version_6=no)])
067d23c9
KY
2247 HAVE_X11XTR6=$emacs_cv_x11_toolkit_version_6
2248 if test $emacs_cv_x11_toolkit_version_6 = yes; then
2249 AC_MSG_RESULT(6 or newer)
2250 AC_DEFINE(HAVE_X11XTR6, 1,
2251 [Define to 1 if you have the X11R6 or newer version of Xt.])
2252 LIBXTR6="-lSM -lICE"
2253 case "$opsys" in
2254 ## Use libw.a along with X11R6 Xt.
2255 unixware) LIBXTR6="$LIBXTR6 -lw" ;;
2256 esac
2257 else
2258 AC_MSG_RESULT(before 6)
2259 fi
2260
2261dnl If using toolkit, check whether libXmu.a exists.
2262dnl tranle@intellicorp.com says libXmu.a can need XtMalloc in libXt.a to link.
2263 OLDLIBS="$LIBS"
2264 if test x$HAVE_X11XTR6 = xyes; then
2265 LIBS="-lXt -lSM -lICE $LIBS"
2266 else
2267 LIBS="-lXt $LIBS"
2268 fi
2269 AC_CHECK_LIB(Xmu, XmuConvertStandardSelection)
2270 test $ac_cv_lib_Xmu_XmuConvertStandardSelection = no && LIBS="$OLDLIBS"
ba9e4b84 2271 dnl ac_cv_lib_Xmu_XmuConvertStandardSelection is also referenced below.
067d23c9
KY
2272fi
2273AC_SUBST(LIBXTR6)
2274
2275dnl FIXME the logic here seems weird, but this is what cpp was doing.
2276dnl Why not just test for libxmu in the normal way?
2277LIBXMU=-lXmu
d6a003a8
AS
2278case $opsys in
2279 ## These systems don't supply Xmu.
067d23c9
KY
2280 hpux* | aix4-2 )
2281 test "X$ac_cv_lib_Xmu_XmuConvertStandardSelection" != "Xyes" && LIBXMU=
2282 ;;
2283esac
2284AC_SUBST(LIBXMU)
2285
2286# On Irix 6.5, at least, we need XShapeQueryExtension from -lXext for Xaw3D.
2287if test "${HAVE_X11}" = "yes"; then
2288 if test "${USE_X_TOOLKIT}" != "none"; then
2289 AC_CHECK_LIB(Xext, XShapeQueryExtension)
2290 fi
2291fi
2292
2293LIBXP=
2294if test "${USE_X_TOOLKIT}" = "MOTIF"; then
c09bfb2f
DA
2295 # OpenMotif may be installed in such a way on some GNU/Linux systems.
2296 if test -d /usr/include/openmotif; then
2297 CPPFLAGS="-I/usr/include/openmotif $CPPFLAGS"
2298 emacs_cv_openmotif=yes
2299 case "$canonical" in
2300 x86_64-*-linux-gnu* | powerpc64-*-linux-gnu* | sparc64-*-linux-gnu*)
2301 test -d /usr/lib64/openmotif && LDFLAGS="-L/usr/lib64/openmotif $LDFLAGS"
2302 ;;
2303 *)
2304 test -d /usr/lib/openmotif && LDFLAGS="-L/usr/lib/openmotif $LDFLAGS"
2305 esac
2306 else
2307 emacs_cv_openmotif=no
2308 fi
2309 AC_CACHE_CHECK(for (Open)Motif version 2.1, emacs_cv_motif_version_2_1,
181855e6
GM
2310 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <Xm/Xm.h>]],
2311 [[#if XmVERSION > 2 || (XmVERSION == 2 && XmREVISION >= 1)
067d23c9
KY
2312int x = 5;
2313#else
2314Motif version prior to 2.1.
181855e6 2315#endif]])],
067d23c9
KY
2316 emacs_cv_motif_version_2_1=yes, emacs_cv_motif_version_2_1=no)])
2317 if test $emacs_cv_motif_version_2_1 = yes; then
2318 AC_CHECK_LIB(Xp, XpCreateContext, LIBXP=-lXp)
c09bfb2f
DA
2319 if test x$emacs_cv_openmotif = xyes; then
2320 REAL_CPPFLAGS="-I/usr/include/openmotif $REAL_CPPFLAGS"
2321 fi
067d23c9
KY
2322 else
2323 AC_CACHE_CHECK(for LessTif where some systems put it, emacs_cv_lesstif,
2324 # We put this in CFLAGS temporarily to precede other -I options
2325 # that might be in CFLAGS temporarily.
2326 # We put this in CPPFLAGS where it precedes the other -I options.
2327 OLD_CPPFLAGS=$CPPFLAGS
2328 OLD_CFLAGS=$CFLAGS
2329 CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CPPFLAGS"
2330 CFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CFLAGS"
181855e6
GM
2331 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include </usr/X11R6/LessTif/Motif1.2/include/Xm/Xm.h>]],
2332 [[int x = 5;]])],
067d23c9
KY
2333 emacs_cv_lesstif=yes, emacs_cv_lesstif=no)])
2334 if test $emacs_cv_lesstif = yes; then
2335 # Make sure this -I option remains in CPPFLAGS after it is set
2336 # back to REAL_CPPFLAGS.
2337 # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
2338 # have those other -I options anyway. Ultimately, having this
2339 # directory ultimately in CPPFLAGS will be enough.
2340 REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
2341 LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
2342 else
2343 CFLAGS=$OLD_CFLAGS
2344 CPPFLAGS=$OLD_CPPFLAGS
2345 fi
2346 fi
e4070def
GM
2347 AC_CHECK_HEADER([Xm/BulletinB.h], [],
2348 [AC_MSG_ERROR([Motif toolkit requested but requirements not found.])])
067d23c9
KY
2349fi
2350
2351dnl Use toolkit scroll bars if configured for GTK or X toolkit and either
2352dnl using Motif or Xaw3d is available, and unless
2353dnl --with-toolkit-scroll-bars=no was specified.
2354
2355AH_TEMPLATE(USE_TOOLKIT_SCROLL_BARS,
2356 [Define to 1 if we should use toolkit scroll bars.])dnl
2357USE_TOOLKIT_SCROLL_BARS=no
2358if test "${with_toolkit_scroll_bars}" != "no"; then
2359 if test "${USE_X_TOOLKIT}" != "none"; then
2360 if test "${USE_X_TOOLKIT}" = "MOTIF"; then
2361 AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2362 HAVE_XAW3D=no
2363 USE_TOOLKIT_SCROLL_BARS=yes
8d8939e8 2364 elif test "${HAVE_XAW3D}" = "yes" || test "${USE_X_TOOLKIT}" = "LUCID"; then
067d23c9
KY
2365 AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2366 USE_TOOLKIT_SCROLL_BARS=yes
2367 fi
2368 elif test "${HAVE_GTK}" = "yes"; then
2369 AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2370 USE_TOOLKIT_SCROLL_BARS=yes
2371 elif test "${HAVE_NS}" = "yes"; then
2372 AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2373 USE_TOOLKIT_SCROLL_BARS=yes
0fda9b75
DC
2374 elif test "${HAVE_W32}" = "yes"; then
2375 AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2376 USE_TOOLKIT_SCROLL_BARS=yes
067d23c9
KY
2377 fi
2378fi
2379
2380dnl See if XIM is available.
181855e6 2381AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
067d23c9 2382 #include <X11/Xlib.h>
181855e6
GM
2383 #include <X11/Xresource.h>]],
2384 [[XIMProc callback;]])],
067d23c9
KY
2385 [HAVE_XIM=yes
2386 AC_DEFINE(HAVE_XIM, 1, [Define to 1 if XIM is available])],
2387 HAVE_XIM=no)
2388
2389dnl `--with-xim' now controls only the initial value of use_xim at run time.
2390
2391if test "${with_xim}" != "no"; then
2392 AC_DEFINE(USE_XIM, 1,
2393 [Define to 1 if we should use XIM, if it is available.])
2394fi
2395
2396
2397if test "${HAVE_XIM}" != "no"; then
2398 late_CFLAGS=$CFLAGS
2399 if test "$GCC" = yes; then
2400 CFLAGS="$CFLAGS --pedantic-errors"
2401 fi
181855e6 2402 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
067d23c9 2403#include <X11/Xlib.h>
181855e6
GM
2404#include <X11/Xresource.h>]],
2405[[Display *display;
067d23c9
KY
2406XrmDatabase db;
2407char *res_name;
2408char *res_class;
2409XIMProc callback;
2410XPointer *client_data;
2411#ifndef __GNUC__
2412/* If we're not using GCC, it's probably not XFree86, and this is
2413 probably right, but we can't use something like --pedantic-errors. */
2414extern Bool XRegisterIMInstantiateCallback(Display*, XrmDatabase, char*,
2415 char*, XIMProc, XPointer*);
2416#endif
2417(void)XRegisterIMInstantiateCallback(display, db, res_name, res_class, callback,
181855e6 2418 client_data);]])],
067d23c9
KY
2419 [emacs_cv_arg6_star=yes])
2420 AH_TEMPLATE(XRegisterIMInstantiateCallback_arg6,
2421 [Define to the type of the 6th arg of XRegisterIMInstantiateCallback,
2422either XPointer or XPointer*.])dnl
2423 if test "$emacs_cv_arg6_star" = yes; then
2424 AC_DEFINE(XRegisterIMInstantiateCallback_arg6, [XPointer*])
2425 else
2426 AC_DEFINE(XRegisterIMInstantiateCallback_arg6, [XPointer])
2427 fi
2428 CFLAGS=$late_CFLAGS
2429fi
2430
2431### Start of font-backend (under any platform) section.
2432# (nothing here yet -- this is a placeholder)
2433### End of font-backend (under any platform) section.
2434
2435### Start of font-backend (under X11) section.
2436if test "${HAVE_X11}" = "yes"; then
2437 PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.2.0, HAVE_FC=yes, HAVE_FC=no)
2438
2439 ## Use -lXft if available, unless `--with-xft=no'.
2440 HAVE_XFT=maybe
2441 if test "${HAVE_FC}" = "no" || test "x${with_x}" = "xno"; then
2442 with_xft="no";
2443 fi
2444 if test "x${with_xft}" != "xno"; then
2445
2446 PKG_CHECK_MODULES(XFT, xft >= 0.13.0, , HAVE_XFT=no)
2447 ## Because xftfont.c uses XRenderQueryExtension, we also
2448 ## need to link to -lXrender.
2449 HAVE_XRENDER=no
2450 AC_CHECK_LIB(Xrender, XRenderQueryExtension, HAVE_XRENDER=yes)
2451 if test "$HAVE_XFT" != no && test "$HAVE_XRENDER" != no; then
2452 OLD_CPPFLAGS="$CPPFLAGS"
2453 OLD_CFLAGS="$CFLAGS"
2454 OLD_LIBS="$LIBS"
2455 CPPFLAGS="$CPPFLAGS $XFT_CFLAGS"
2456 CFLAGS="$CFLAGS $XFT_CFLAGS"
2457 XFT_LIBS="-lXrender $XFT_LIBS"
2458 LIBS="$XFT_LIBS $LIBS"
2459 AC_CHECK_HEADER(X11/Xft/Xft.h,
2460 AC_CHECK_LIB(Xft, XftFontOpen, HAVE_XFT=yes, , $XFT_LIBS))
2461
2462 if test "${HAVE_XFT}" = "yes"; then
2463 AC_DEFINE(HAVE_XFT, 1, [Define to 1 if you have the Xft library.])
2464 AC_SUBST(XFT_LIBS)
2465 C_SWITCH_X_SITE="$C_SWITCH_X_SITE $XFT_CFLAGS"
2466 else
2467 CPPFLAGS="$OLD_CPPFLAGS"
2468 CFLAGS="$OLD_CFLAGS"
2469 LIBS="$OLD_LIBS"
2470 fi # "${HAVE_XFT}" = "yes"
2471 fi # "$HAVE_XFT" != no
2472 fi # "x${with_xft}" != "xno"
2473
870d9cf6
GM
2474 ## We used to allow building with FreeType and without Xft.
2475 ## However, the ftx font backend driver is not in good shape.
067d23c9 2476 if test "$HAVE_XFT" != "yes"; then
870d9cf6 2477 dnl For the "Does Emacs use" message at the end.
067d23c9 2478 HAVE_XFT=no
870d9cf6
GM
2479 HAVE_FREETYPE=no
2480 else
2481 dnl Strict linkers fail with
2482 dnl ftfont.o: undefined reference to symbol 'FT_New_Face'
2483 dnl if -lfreetype is not specified.
2484 dnl The following is needed to set FREETYPE_LIBS.
2485 PKG_CHECK_MODULES(FREETYPE, freetype2, HAVE_FREETYPE=yes,
46dcfee4 2486 HAVE_FREETYPE=no)
870d9cf6
GM
2487
2488 test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(libxft requires libfreetype)
067d23c9
KY
2489 fi
2490
067d23c9
KY
2491 HAVE_LIBOTF=no
2492 if test "${HAVE_FREETYPE}" = "yes"; then
2493 AC_DEFINE(HAVE_FREETYPE, 1,
2494 [Define to 1 if using the freetype and fontconfig libraries.])
2495 if test "${with_libotf}" != "no"; then
2496 PKG_CHECK_MODULES(LIBOTF, libotf, HAVE_LIBOTF=yes,
2497 HAVE_LIBOTF=no)
2498 if test "$HAVE_LIBOTF" = "yes"; then
2499 AC_DEFINE(HAVE_LIBOTF, 1, [Define to 1 if using libotf.])
2500 AC_CHECK_LIB(otf, OTF_get_variation_glyphs,
2501 HAVE_OTF_GET_VARIATION_GLYPHS=yes,
2502 HAVE_OTF_GET_VARIATION_GLYPHS=no)
2503 if test "${HAVE_OTF_GET_VARIATION_GLYPHS}" = "yes"; then
2504 AC_DEFINE(HAVE_OTF_GET_VARIATION_GLYPHS, 1,
2505 [Define to 1 if libotf has OTF_get_variation_glyphs.])
2506 fi
2507 fi
2508 fi
2509 dnl FIXME should there be an error if HAVE_FREETYPE != yes?
2510 dnl Does the new font backend require it, or can it work without it?
2511 fi
2512
2513 HAVE_M17N_FLT=no
2514 if test "${HAVE_LIBOTF}" = yes; then
2515 if test "${with_m17n_flt}" != "no"; then
2516 PKG_CHECK_MODULES(M17N_FLT, m17n-flt, HAVE_M17N_FLT=yes, HAVE_M17N_FLT=no)
2517 if test "$HAVE_M17N_FLT" = "yes"; then
2518 AC_DEFINE(HAVE_M17N_FLT, 1, [Define to 1 if using libm17n-flt.])
2519 fi
2520 fi
2521 fi
2522else
2523 HAVE_XFT=no
2524 HAVE_FREETYPE=no
2525 HAVE_LIBOTF=no
2526 HAVE_M17N_FLT=no
2527fi
2528
2529### End of font-backend (under X11) section.
2530
2531AC_SUBST(FREETYPE_CFLAGS)
2532AC_SUBST(FREETYPE_LIBS)
2533AC_SUBST(FONTCONFIG_CFLAGS)
2534AC_SUBST(FONTCONFIG_LIBS)
2535AC_SUBST(LIBOTF_CFLAGS)
2536AC_SUBST(LIBOTF_LIBS)
2537AC_SUBST(M17N_FLT_CFLAGS)
2538AC_SUBST(M17N_FLT_LIBS)
2539
2540### Use -lXpm if available, unless `--with-xpm=no'.
2541HAVE_XPM=no
2542LIBXPM=
0fda9b75
DC
2543
2544if test "${HAVE_W32}" = "yes"; then
2545 if test "${with_xpm}" != "no"; then
2546 SAVE_CPPFLAGS="$CPPFLAGS"
2547 SAVE_LDFLAGS="$LDFLAGS"
2548 CPPFLAGS="$CPPFLAGS -I/usr/include/noX"
2549 LDFLAGS="$LDFLAGS -L/usr/lib/noX"
2550 AC_CHECK_HEADER(X11/xpm.h,
2551 [AC_CHECK_LIB(Xpm, XpmReadFileToImage, HAVE_XPM=yes)])
2552 if test "${HAVE_XPM}" = "yes"; then
2553 AC_MSG_CHECKING(for XpmReturnAllocPixels preprocessor define)
2554 AC_EGREP_CPP(no_return_alloc_pixels,
2555 [#include "X11/xpm.h"
2556#ifndef XpmReturnAllocPixels
2557no_return_alloc_pixels
2558#endif
2559 ], HAVE_XPM=no, HAVE_XPM=yes)
2560
2561 if test "${HAVE_XPM}" = "yes"; then
2562 REAL_CPPFLAGS="$REAL_CPPFLAGS -I/usr/include/noX"
2563 AC_MSG_RESULT(yes)
2564 else
2565 AC_MSG_RESULT(no)
2566 CPPFLAGS="$SAVE_CPPFLAGS"
2567 LDFLAGS="$SAVE_LDFLAGS"
2568 fi
2569 fi
2570 fi
2571
2572 if test "${HAVE_XPM}" = "yes"; then
791ef5f8 2573 AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
0fda9b75
DC
2574 LIBXPM=-lXpm
2575 fi
2576fi
2577
067d23c9
KY
2578if test "${HAVE_X11}" = "yes"; then
2579 if test "${with_xpm}" != "no"; then
2580 AC_CHECK_HEADER(X11/xpm.h,
2581 [AC_CHECK_LIB(Xpm, XpmReadFileToPixmap, HAVE_XPM=yes, , -lX11)])
2582 if test "${HAVE_XPM}" = "yes"; then
2583 AC_MSG_CHECKING(for XpmReturnAllocPixels preprocessor define)
2584 AC_EGREP_CPP(no_return_alloc_pixels,
2585 [#include "X11/xpm.h"
2586#ifndef XpmReturnAllocPixels
2587no_return_alloc_pixels
2588#endif
2589 ], HAVE_XPM=no, HAVE_XPM=yes)
2590
2591 if test "${HAVE_XPM}" = "yes"; then
2592 AC_MSG_RESULT(yes)
2593 else
2594 AC_MSG_RESULT(no)
2595 fi
2596 fi
2597 fi
2598
2599 if test "${HAVE_XPM}" = "yes"; then
20db1522 2600 AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
067d23c9
KY
2601 LIBXPM=-lXpm
2602 fi
2603fi
0fda9b75 2604
067d23c9
KY
2605AC_SUBST(LIBXPM)
2606
2607### Use -ljpeg if available, unless `--with-jpeg=no'.
2608HAVE_JPEG=no
2609LIBJPEG=
0fda9b75 2610if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
067d23c9
KY
2611 if test "${with_jpeg}" != "no"; then
2612 dnl Checking for jpeglib.h can lose because of a redefinition of
2613 dnl HAVE_STDLIB_H.
2614 AC_CHECK_HEADER(jerror.h,
2615 [AC_CHECK_LIB(jpeg, jpeg_destroy_compress, HAVE_JPEG=yes)])
2616 fi
2617
2618 AH_TEMPLATE(HAVE_JPEG, [Define to 1 if you have the jpeg library (-ljpeg).])dnl
2619 if test "${HAVE_JPEG}" = "yes"; then
2620 AC_DEFINE(HAVE_JPEG)
2621 AC_EGREP_CPP([version= *(6[2-9]|[7-9][0-9])],
2622 [#include <jpeglib.h>
2623 version=JPEG_LIB_VERSION
2624],
2625 [AC_DEFINE(HAVE_JPEG)],
2626 [AC_MSG_WARN([libjpeg found, but not version 6b or later])
2627 HAVE_JPEG=no])
2628 fi
2629 if test "${HAVE_JPEG}" = "yes"; then
2630 LIBJPEG=-ljpeg
2631 fi
2632fi
2633AC_SUBST(LIBJPEG)
2634
2635### Use -lpng if available, unless `--with-png=no'.
2636HAVE_PNG=no
2637LIBPNG=
0fda9b75 2638if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
067d23c9
KY
2639 if test "${with_png}" != "no"; then
2640 # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
2641 # in /usr/include/libpng.
0ccb0b09 2642 AC_CHECK_HEADERS(png.h libpng/png.h, break)
067d23c9
KY
2643 if test "$ac_cv_header_png_h" = yes || test "$ac_cv_header_libpng_png_h" = yes ; then
2644 AC_CHECK_LIB(png, png_get_channels, HAVE_PNG=yes, , -lz -lm)
2645 fi
2646 fi
2647
2648 if test "${HAVE_PNG}" = "yes"; then
2649 AC_DEFINE(HAVE_PNG, 1, [Define to 1 if you have the png library (-lpng).])
2650 LIBPNG="-lpng -lz -lm"
0ccb0b09
PE
2651
2652 AC_CHECK_DECL(png_longjmp,
2653 [],
cda158b4 2654 [AC_DEFINE(PNG_DEPSTRUCT, [],
0ccb0b09
PE
2655 [Define to empty to suppress deprecation warnings when building
2656 with --enable-gcc-warnings and with libpng versions before 1.5,
2657 which lack png_longjmp.])],
2658 [[#ifdef HAVE_LIBPNG_PNG_H
2659 # include <libpng/png.h>
2660 #else
2661 # include <png.h>
2662 #endif
2663 ]])
067d23c9
KY
2664 fi
2665fi
2666AC_SUBST(LIBPNG)
2667
2668### Use -ltiff if available, unless `--with-tiff=no'.
2669HAVE_TIFF=no
2670LIBTIFF=
0fda9b75 2671if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
067d23c9
KY
2672 if test "${with_tiff}" != "no"; then
2673 AC_CHECK_HEADER(tiffio.h,
2674 [tifflibs="-lz -lm"
2675 # At least one tiff package requires the jpeg library.
2676 if test "${HAVE_JPEG}" = yes; then tifflibs="-ljpeg $tifflibs"; fi
2677 AC_CHECK_LIB(tiff, TIFFGetVersion, HAVE_TIFF=yes, , $tifflibs)])
2678 fi
2679
2680 if test "${HAVE_TIFF}" = "yes"; then
2681 AC_DEFINE(HAVE_TIFF, 1, [Define to 1 if you have the tiff library (-ltiff).])
2682 dnl FIXME -lz -lm, as per libpng?
2683 LIBTIFF=-ltiff
2684 fi
2685fi
2686AC_SUBST(LIBTIFF)
2687
2688### Use -lgif or -lungif if available, unless `--with-gif=no'.
2689HAVE_GIF=no
2690LIBGIF=
0fda9b75
DC
2691if test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no" \
2692 || test "${HAVE_W32}" = "yes"; then
067d23c9
KY
2693 AC_CHECK_HEADER(gif_lib.h,
2694# EGifPutExtensionLast only exists from version libungif-4.1.0b1.
2695# Earlier versions can crash Emacs.
2696 [AC_CHECK_LIB(gif, EGifPutExtensionLast, HAVE_GIF=yes, HAVE_GIF=maybe)])
2697
2698 if test "$HAVE_GIF" = yes; then
2699 LIBGIF=-lgif
2700 elif test "$HAVE_GIF" = maybe; then
2701# If gif_lib.h but no libgif, try libungif.
2702 AC_CHECK_LIB(ungif, EGifPutExtensionLast, HAVE_GIF=yes, HAVE_GIF=no)
2703 test "$HAVE_GIF" = yes && LIBGIF=-lungif
2704 fi
2705
2706 if test "${HAVE_GIF}" = "yes"; then
2707 AC_DEFINE(HAVE_GIF, 1, [Define to 1 if you have a gif (or ungif) library.])
2708 fi
2709fi
2710AC_SUBST(LIBGIF)
2711
2712dnl Check for required libraries.
2713if test "${HAVE_X11}" = "yes"; then
2714 MISSING=""
2715 WITH_NO=""
2716 test "${with_xpm}" != "no" && test "${HAVE_XPM}" != "yes" &&
2717 MISSING="libXpm" && WITH_NO="--with-xpm=no"
2718 test "${with_jpeg}" != "no" && test "${HAVE_JPEG}" != "yes" &&
2719 MISSING="$MISSING libjpeg" && WITH_NO="$WITH_NO --with-jpeg=no"
2720 test "${with_png}" != "no" && test "${HAVE_PNG}" != "yes" &&
2721 MISSING="$MISSING libpng" && WITH_NO="$WITH_NO --with-png=no"
2722 test "${with_gif}" != "no" && test "${HAVE_GIF}" != "yes" &&
2723 MISSING="$MISSING libgif/libungif" && WITH_NO="$WITH_NO --with-gif=no"
2724 test "${with_tiff}" != "no" && test "${HAVE_TIFF}" != "yes" &&
2725 MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no"
2726
2727 if test "X${MISSING}" != X; then
2728 AC_MSG_ERROR([The following required libraries were not found:
2729 $MISSING
2730Maybe some development libraries/packages are missing?
2731If you don't want to link with them give
2732 $WITH_NO
2733as options to configure])
2734 fi
2735fi
2736
2737### Use -lgpm if available, unless `--with-gpm=no'.
2738HAVE_GPM=no
2739LIBGPM=
067d23c9
KY
2740if test "${with_gpm}" != "no"; then
2741 AC_CHECK_HEADER(gpm.h,
2742 [AC_CHECK_LIB(gpm, Gpm_Open, HAVE_GPM=yes)])
2743
2744 if test "${HAVE_GPM}" = "yes"; then
2745 AC_DEFINE(HAVE_GPM, 1, [Define to 1 if you have the gpm library (-lgpm).])
2746 LIBGPM=-lgpm
067d23c9
KY
2747 fi
2748fi
2749AC_SUBST(LIBGPM)
2750
2751dnl Check for malloc/malloc.h on darwin
0e7a053e 2752AC_CHECK_HEADERS_ONCE(malloc/malloc.h)
067d23c9 2753
2f097256 2754GNUSTEP_CFLAGS=
067d23c9
KY
2755### Use NeXTstep API to implement GUI.
2756if test "${HAVE_NS}" = "yes"; then
2757 AC_DEFINE(HAVE_NS, 1, [Define to 1 if you are using the NeXTstep API, either GNUstep or Cocoa on Mac OS X.])
2758 if test "${NS_IMPL_COCOA}" = "yes"; then
2759 AC_DEFINE(NS_IMPL_COCOA, 1, [Define to 1 if you are using NS windowing under MacOS X.])
067d23c9
KY
2760 fi
2761 if test "${NS_IMPL_GNUSTEP}" = "yes"; then
2762 AC_DEFINE(NS_IMPL_GNUSTEP, 1, [Define to 1 if you are using NS windowing under GNUstep.])
2763 # See also .m.o rule in Makefile.in */
2764 # FIXME: are all these flags really needed? Document here why. */
2f097256 2765 GNUSTEP_CFLAGS="-D_REENTRANT -fPIC -fno-strict-aliasing -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
0cc87afb
GM
2766 ## Extra CFLAGS applied to src/*.m files.
2767 GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -fgnu-runtime -Wno-import -fconstant-string-class=NSConstantString -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGSWARN -DGSDIAGNOSE"
067d23c9 2768 fi
067d23c9
KY
2769 # We also have mouse menus.
2770 HAVE_MENUS=yes
2771 OTHER_FILES=ns-app
2772fi
2773
0fda9b75
DC
2774if test "${HAVE_W32}" = "yes"; then
2775 HAVE_MENUS=yes
2776fi
067d23c9
KY
2777
2778### Use session management (-lSM -lICE) if available
2779HAVE_X_SM=no
2780LIBXSM=
2781if test "${HAVE_X11}" = "yes"; then
2782 AC_CHECK_HEADER(X11/SM/SMlib.h,
2783 [AC_CHECK_LIB(SM, SmcOpenConnection, HAVE_X_SM=yes, , -lICE)])
2784
2785 if test "${HAVE_X_SM}" = "yes"; then
2786 AC_DEFINE(HAVE_X_SM, 1, [Define to 1 if you have the SM library (-lSM).])
2787 LIBXSM="-lSM -lICE"
2788 case "$LIBS" in
2789 *-lSM*) ;;
2790 *) LIBS="$LIBXSM $LIBS" ;;
2791 esac
2792 fi
2793fi
2794AC_SUBST(LIBXSM)
2795
2796### Use libxml (-lxml2) if available
04d51ad4 2797HAVE_LIBXML2=no
067d23c9
KY
2798if test "${with_xml2}" != "no"; then
2799 ### I'm not sure what the version number should be, so I just guessed.
dab73760 2800 PKG_CHECK_MODULES(LIBXML2, libxml-2.0 > 2.6.17, HAVE_LIBXML2=yes, HAVE_LIBXML2=no)
067d23c9
KY
2801 if test "${HAVE_LIBXML2}" = "yes"; then
2802 LIBS="$LIBXML2_LIBS $LIBS"
2803 AC_CHECK_LIB(xml2, htmlReadMemory, HAVE_LIBXML2=yes, HAVE_LIBXML2=no)
2804 if test "${HAVE_LIBXML2}" = "yes"; then
2805 AC_DEFINE(HAVE_LIBXML2, 1, [Define to 1 if you have the libxml library (-lxml2).])
2806 else
2807 LIBXML2_LIBS=""
2808 LIBXML2_CFLAGS=""
2809 fi
2810 fi
2811fi
2812AC_SUBST(LIBXML2_LIBS)
2813AC_SUBST(LIBXML2_CFLAGS)
2814
2815# If netdb.h doesn't declare h_errno, we must declare it by hand.
2816AC_CACHE_CHECK(whether netdb declares h_errno,
2817 emacs_cv_netdb_declares_h_errno,
181855e6
GM
2818[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
2819 [[return h_errno;]])],
067d23c9
KY
2820 emacs_cv_netdb_declares_h_errno=yes, emacs_cv_netdb_declares_h_errno=no)])
2821if test $emacs_cv_netdb_declares_h_errno = yes; then
2822 AC_DEFINE(HAVE_H_ERRNO, 1, [Define to 1 if netdb.h declares h_errno.])
2823fi
2824
c990426a
PE
2825# sqrt and other floating-point functions such as fmod and frexp
2826# are found in -lm on most systems.
067d23c9
KY
2827AC_CHECK_LIB(m, sqrt)
2828
2829# Check for mail-locking functions in a "mail" library. Probably this should
2830# have the same check as for liblockfile below.
2831AC_CHECK_LIB(mail, maillock, have_mail=yes, have_mail=no)
2832if test $have_mail = yes; then
2833 LIBS_MAIL=-lmail
2834 LIBS="$LIBS_MAIL $LIBS"
2835 AC_DEFINE(HAVE_LIBMAIL, 1, [Define to 1 if you have the `mail' library (-lmail).])
2836else
2837 LIBS_MAIL=
2838fi
2839dnl Debian, at least:
2840AC_CHECK_LIB(lockfile, maillock, have_lockfile=yes, have_lockfile=no)
2841if test $have_lockfile = yes; then
2842 LIBS_MAIL=-llockfile
2843 LIBS="$LIBS_MAIL $LIBS"
2844 AC_DEFINE(HAVE_LIBLOCKFILE, 1, [Define to 1 if you have the `lockfile' library (-llockfile).])
2845else
2846# If we have the shared liblockfile, assume we must use it for mail
2847# locking (e.g. Debian). If we couldn't link against liblockfile
2848# (no liblockfile.a installed), ensure that we don't need to.
2849 dnl This works for files generally, not just executables.
2850 dnl Should we look elsewhere for it? Maybe examine /etc/ld.so.conf?
2851 AC_CHECK_PROG(liblockfile, liblockfile.so, yes, no,
2852 /usr/lib:/lib:/usr/local/lib:$LD_LIBRARY_PATH)
2853 if test $ac_cv_prog_liblockfile = yes; then
2854 AC_MSG_ERROR([Shared liblockfile found but can't link against it.
2855This probably means that movemail could lose mail.
2856There may be a `development' package to install containing liblockfile.])
2857 fi
2858fi
0e7a053e 2859AC_CHECK_HEADERS_ONCE(maillock.h)
067d23c9
KY
2860AC_SUBST(LIBS_MAIL)
2861
2862## Define MAIL_USE_FLOCK (or LOCKF) if the mailer uses flock (or lockf) to
2863## interlock access to the mail spool. The alternative is a lock file named
2864## /usr/spool/mail/$USER.lock.
2865mail_lock=no
2866case "$opsys" in
2867 aix4-2) mail_lock="lockf" ;;
2868
2869 gnu|freebsd|netbsd|openbsd|darwin|irix6-5) mail_lock="flock" ;;
2870
2871 ## On GNU/Linux systems, both methods are used by various mail programs.
2872 ## I assume most people are using newer mailers that have heard of flock.
2873 ## Change this if you need to.
2874 ## Debian contains a patch which says: ``On Debian/GNU/Linux systems,
2875 ## configure gets the right answers, and that means *NOT* using flock.
2876 ## Using flock is guaranteed to be the wrong thing. See Debian Policy
2877 ## for details.'' and then uses `#ifdef DEBIAN'. Unfortunately the
2878 ## Debian maintainer hasn't provided a clean fix for Emacs.
2879 ## movemail.c will use `maillock' when MAILDIR, HAVE_LIBMAIL and
2880 ## HAVE_MAILLOCK_H are defined, so the following appears to be the
2881 ## correct logic. -- fx
2882 ## We must check for HAVE_LIBLOCKFILE too, as movemail does.
2883 ## liblockfile is a Free Software replacement for libmail, used on
2884 ## Debian systems and elsewhere. -rfr.
2885 gnu-*)
2886 mail_lock="flock"
2887 if test $have_mail = yes || test $have_lockfile = yes; then
2888 test $ac_cv_header_maillock_h = yes && mail_lock=no
2889 fi
2890 ;;
2891esac
2892
2893BLESSMAIL_TARGET=
2894case "$mail_lock" in
2895 flock) AC_DEFINE(MAIL_USE_FLOCK, 1, [Define if the mailer uses flock to interlock the mail spool.]) ;;
2896
2897 lockf) AC_DEFINE(MAIL_USE_LOCKF, 1, [Define if the mailer uses lockf to interlock the mail spool.]) ;;
2898
2899 *) BLESSMAIL_TARGET="need-blessmail" ;;
2900esac
2901AC_SUBST(BLESSMAIL_TARGET)
2902
2903
54e8a418 2904AC_CHECK_FUNCS(gethostname \
95ef7787 2905getrusage get_current_dir_name \
dd0333b6 2906lrand48 \
3d082a26 2907select getpagesize setlocale \
9239d970 2908utimes getrlimit setrlimit shutdown getaddrinfo \
8148369c 2909strsignal setitimer \
03043c1b 2910sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \
47d7532e 2911gai_strerror mkstemp getline getdelim sync \
9232a6d9 2912difftime posix_memalign \
316411f0 2913getpwent endpwent getgrent endgrent \
03043c1b 2914touchlock \
c8199d0f 2915cfmakeraw cfsetspeed copysign __executable_start)
067d23c9 2916
4516fbef
GM
2917## Eric Backus <ericb@lsid.hp.com> says, HP-UX 9.x on HP 700 machines
2918## has a broken `rint' in some library versions including math library
2919## version number A.09.05.
2920## You can fix the math library by installing patch number PHSS_4630.
2921## But we can fix it more reliably for Emacs by just not using rint.
5af2266c 2922## We also skip HAVE_RANDOM - see comments in src/conf_post.h.
4516fbef
GM
2923case $opsys in
2924 hpux*) : ;;
2925 *) AC_CHECK_FUNCS(random rint) ;;
2926esac
2927
2018939f
AS
2928dnl Cannot use AC_CHECK_FUNCS
2929AC_CACHE_CHECK([for __builtin_unwind_init],
2930 emacs_cv_func___builtin_unwind_init,
2931[AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_unwind_init ();])],
2932 emacs_cv_func___builtin_unwind_init=yes,
2933 emacs_cv_func___builtin_unwind_init=no)])
2934if test $emacs_cv_func___builtin_unwind_init = yes; then
2935 AC_DEFINE(HAVE___BUILTIN_UNWIND_INIT, 1,
2936 [Define to 1 if you have the `__builtin_unwind_init' function.])
2937fi
2938
0e7a053e 2939AC_CHECK_HEADERS_ONCE(sys/un.h)
067d23c9 2940
067d23c9
KY
2941AC_FUNC_FSEEKO
2942
067d23c9 2943# UNIX98 PTYs.
54e8a418 2944AC_CHECK_FUNCS(grantpt)
067d23c9
KY
2945
2946# PTY-related GNU extensions.
1598ef28 2947AC_CHECK_FUNCS(getpt posix_openpt)
067d23c9
KY
2948
2949# Check this now, so that we will NOT find the above functions in ncurses.
2950# That is because we have not set up to link ncurses in lib-src.
2951# It's better to believe a function is not available
2952# than to expect to find it in ncurses.
2953# Also we need tputs and friends to be able to build at all.
f20f95c6
PE
2954AC_MSG_CHECKING([for library containing tputs])
2955# Run a test program that contains a call to tputs, a call that is
2956# never executed. This tests whether a pre-'main' dynamic linker
2957# works with the library. It's too much trouble to actually call
2958# tputs in the test program, due to portability hassles. When
2959# cross-compiling, assume the test program will run if it links.
2960AC_DEFUN([tputs_link_source], [
2961 AC_LANG_SOURCE(
2962 [[extern void tputs (const char *, int, int (*)(int));
2963 int main (int argc, char **argv)
2964 {
2965 if (argc == 10000)
2966 tputs (argv[0], 0, 0);
2967 return 0;
2968 }]])
2969])
fd8dea03
GM
2970# Maybe curses should be tried earlier?
2971# See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9736#35
a4a18b8b 2972for tputs_library in '' tinfo ncurses terminfo termcap curses; do
f20f95c6
PE
2973 OLIBS=$LIBS
2974 if test -z "$tputs_library"; then
2975 LIBS_TERMCAP=
2976 msg='none required'
2977 else
2978 LIBS_TERMCAP=-l$tputs_library
2979 msg=$LIBS_TERMCAP
2980 LIBS="$LIBS_TERMCAP $LIBS"
2981 fi
2982 AC_RUN_IFELSE([tputs_link_source], [], [msg=no],
2983 [AC_LINK_IFELSE([tputs_link_source], [], [msg=no])])
2984 LIBS=$OLIBS
2985 if test "X$msg" != Xno; then
2986 break
2987 fi
2988done
2989AC_MSG_RESULT([$msg])
2990if test "X$msg" = Xno; then
fd8dea03 2991 AC_MSG_ERROR([The required function `tputs' was not found in any library.
a4a18b8b
GM
2992The following libraries were tried (in order):
2993 libtinfo, libncurses, libterminfo, libtermcap, libcurses
fd8dea03
GM
2994Please try installing whichever of these libraries is most appropriate
2995for your system, together with its header files.
2996For example, a libncurses-dev(el) or similar package.])
067d23c9 2997fi
067d23c9 2998
262f06da
GM
2999## Use termcap instead of terminfo?
3000## Only true for: freebsd < 40000, ms-w32, msdos, netbsd < 599002500.
3001TERMINFO=yes
a4a18b8b
GM
3002## FIXME? In the cases below where we unconditionally set
3003## LIBS_TERMCAP="-lncurses", this overrides LIBS_TERMCAP = -ltinfo,
3004## if that was found above to have tputs.
3005## Should we use the gnu* logic everywhere?
067d23c9 3006case "$opsys" in
067d23c9
KY
3007 ## darwin: Prevents crashes when running Emacs in Terminal.app under 10.2.
3008 ## The ncurses library has been moved out of the System framework in
3009 ## Mac OS X 10.2. So if configure detects it, set the command-line
3010 ## option to use it.
a4a18b8b
GM
3011 darwin) LIBS_TERMCAP="-lncurses" ;;
3012
01319a4e 3013 gnu*) test -z "$LIBS_TERMCAP" && LIBS_TERMCAP="-lncurses" ;;
067d23c9
KY
3014
3015 freebsd)
3016 AC_MSG_CHECKING([whether FreeBSD is new enough to use terminfo])
3017 AC_CACHE_VAL(emacs_cv_freebsd_terminfo,
181855e6
GM
3018 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <osreldate.h>]],
3019[[#if __FreeBSD_version < 400000
067d23c9
KY
3020fail;
3021#endif
181855e6 3022]])], emacs_cv_freebsd_terminfo=yes, emacs_cv_freebsd_terminfo=no)])
067d23c9
KY
3023
3024 AC_MSG_RESULT($emacs_cv_freebsd_terminfo)
3025
3026 if test $emacs_cv_freebsd_terminfo = yes; then
067d23c9
KY
3027 LIBS_TERMCAP="-lncurses"
3028 else
262f06da 3029 TERMINFO=no
067d23c9
KY
3030 LIBS_TERMCAP="-ltermcap"
3031 fi
3032 ;;
3033
3034 netbsd)
01319a4e 3035 if test "x$LIBS_TERMCAP" != "x-lterminfo"; then
262f06da 3036 TERMINFO=no
067d23c9
KY
3037 LIBS_TERMCAP="-ltermcap"
3038 fi
3039 ;;
3040
3ba0a545 3041 openbsd) LIBS_TERMCAP="-lncurses" ;;
067d23c9 3042
067d23c9
KY
3043 ## hpux: Make sure we get select from libc rather than from libcurses
3044 ## because libcurses on HPUX 10.10 has a broken version of select.
3045 ## We used to use -lc -lcurses, but this may be cleaner.
e3da5b19
GM
3046 ## FIXME? But TERMINFO = yes on hpux (it used to be explicitly
3047 # set that way, now it uses the default). Isn't this a contradiction?
067d23c9
KY
3048 hpux*) LIBS_TERMCAP="-ltermcap" ;;
3049
067d23c9
KY
3050esac
3051
3052TERMCAP_OBJ=tparam.o
3053if test $TERMINFO = yes; then
3054 AC_DEFINE(TERMINFO, 1, [Define to 1 if you use terminfo instead of termcap.])
067d23c9
KY
3055 TERMCAP_OBJ=terminfo.o
3056fi
3057AC_SUBST(LIBS_TERMCAP)
3058AC_SUBST(TERMCAP_OBJ)
3059
3060
3061# Do we have res_init, for detecting changes in /etc/resolv.conf?
4516fbef
GM
3062# On Darwin, res_init appears not to be useful: see bug#562 and
3063# http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01467.html
067d23c9 3064resolv=no
4516fbef
GM
3065
3066if test $opsys != darwin; then
3067
3068 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>
067d23c9 3069#include <arpa/nameser.h>
181855e6
GM
3070#include <resolv.h>]],
3071 [[return res_init();]])],
067d23c9 3072 have_res_init=yes, have_res_init=no)
4516fbef
GM
3073 if test "$have_res_init" = no; then
3074 OLIBS="$LIBS"
3075 LIBS="$LIBS -lresolv"
3076 AC_MSG_CHECKING(for res_init with -lresolv)
3077 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>
067d23c9 3078#include <arpa/nameser.h>
181855e6 3079#include <resolv.h>]],
4516fbef
GM
3080 [[return res_init();]])],
3081 have_res_init=yes, have_res_init=no)
3082 AC_MSG_RESULT($have_res_init)
3083 if test "$have_res_init" = yes ; then
3084 resolv=yes
3085 fi
3086 LIBS="$OLIBS"
067d23c9 3087 fi
067d23c9 3088
4516fbef
GM
3089 if test "$have_res_init" = yes; then
3090 AC_DEFINE(HAVE_RES_INIT, 1, [Define to 1 if res_init is available.])
3091 fi
3092fi dnl !darwin
067d23c9
KY
3093
3094# Do we need the Hesiod library to provide the support routines?
4516fbef 3095dnl FIXME? Should we be skipping this on Darwin too?
067d23c9
KY
3096LIBHESIOD=
3097if test "$with_hesiod" != no ; then
3098 # Don't set $LIBS here -- see comments above. FIXME which comments?
3099 AC_CHECK_FUNC(res_send, , [AC_CHECK_FUNC(__res_send, ,
3100 [AC_CHECK_LIB(resolv, res_send, resolv=yes,
3101 [AC_CHECK_LIB(resolv, __res_send, resolv=yes)])])])
3102 if test "$resolv" = yes ; then
3103 RESOLVLIB=-lresolv
3104 else
3105 RESOLVLIB=
3106 fi
3107 AC_CHECK_FUNC(hes_getmailhost, , [AC_CHECK_LIB(hesiod, hes_getmailhost,
3108 hesiod=yes, :, $RESOLVLIB)])
3109
3110 if test x"$hesiod" = xyes; then
3111 AC_DEFINE(HAVE_LIBHESIOD, 1,
3112 [Define to 1 if you have the hesiod library (-lhesiod).])
3113 LIBHESIOD=-lhesiod
3114 fi
3115fi
3116AC_SUBST(LIBHESIOD)
3117
3118# Do we need libresolv (due to res_init or Hesiod)?
4516fbef 3119if test "$resolv" = yes && test $opsys != darwin; then
067d23c9
KY
3120 AC_DEFINE(HAVE_LIBRESOLV, 1,
3121 [Define to 1 if you have the resolv library (-lresolv).])
3122 LIBRESOLV=-lresolv
3123else
3124 LIBRESOLV=
3125fi
3126AC_SUBST(LIBRESOLV)
3127
3128# These tell us which Kerberos-related libraries to use.
3129COM_ERRLIB=
3130CRYPTOLIB=
3131KRB5LIB=
3132DESLIB=
3133KRB4LIB=
3134
3135if test "${with_kerberos}" != no; then
3136 AC_CHECK_LIB(com_err, com_err, have_com_err=yes, have_com_err=no)
3137 if test $have_com_err = yes; then
3138 COM_ERRLIB=-lcom_err
3139 LIBS="$COM_ERRLIB $LIBS"
3140 AC_DEFINE(HAVE_LIBCOM_ERR, 1, [Define to 1 if you have the `com_err' library (-lcom_err).])
3141 fi
3142 AC_CHECK_LIB(crypto, mit_des_cbc_encrypt, have_crypto=yes, have_crypto=no)
3143 if test $have_crypto = yes; then
3144 CRYPTOLIB=-lcrypto
3145 LIBS="$CRYPTOLIB $LIBS"
3146 AC_DEFINE(HAVE_LIBCRYPTO, 1, [Define to 1 if you have the `crypto' library (-lcrypto).])
3147 fi
3148 AC_CHECK_LIB(k5crypto, mit_des_cbc_encrypt, have_k5crypto=yes, have_k5crypto=no)
3149 if test $have_k5crypto = yes; then
3150 CRYPTOLIB=-lk5crypto
3151 LIBS="$CRYPTOLIB $LIBS"
3152 AC_DEFINE(HAVE_LIBK5CRYPTO, 1, [Define to 1 if you have the `k5crypto' library (-lk5crypto).])
3153 fi
3154 AC_CHECK_LIB(krb5, krb5_init_context, have_krb5=yes, have_krb5=no)
3155 if test $have_krb5=yes; then
3156 KRB5LIB=-lkrb5
3157 LIBS="$KRB5LIB $LIBS"
3158 AC_DEFINE(HAVE_LIBKRB5, 1, [Define to 1 if you have the `krb5' library (-lkrb5).])
3159 fi
3160 dnl FIXME Simplify. Does not match 22 logic, thanks to default_off?
3161 if test "${with_kerberos5}" = no; then
3162 AC_CHECK_LIB(des425, des_cbc_encrypt, have_des425=yes, have_des425=no )
3163 if test $have_des425 = yes; then
3164 DESLIB=-ldes425
3165 LIBS="$DESLIB $LIBS"
3166 AC_DEFINE(HAVE_LIBDES425, 1, [Define to 1 if you have the `des425' library (-ldes425).])
3167 else
3168 AC_CHECK_LIB(des, des_cbc_encrypt, have_des=yes, have_des=no)
3169 if test $have_des = yes; then
3170 DESLIB=-ldes
3171 LIBS="$DESLIB $LIBS"
3172 AC_DEFINE(HAVE_LIBDES, 1, [Define to 1 if you have the `des' library (-ldes).])
3173 fi
3174 fi
3175 AC_CHECK_LIB(krb4, krb_get_cred, have_krb4=yes, have_krb4=no)
3176 if test $have_krb4 = yes; then
3177 KRB4LIB=-lkrb4
3178 LIBS="$KRB4LIB $LIBS"
3179 AC_DEFINE(HAVE_LIBKRB4, 1, [Define to 1 if you have the `krb4' library (-lkrb4).])
3180 else
3181 AC_CHECK_LIB(krb, krb_get_cred, have_krb=yes, have_krb=no)
3182 if test $have_krb = yes; then
3183 KRB4LIB=-lkrb
3184 LIBS="$KRB4LIB $LIBS"
3185 AC_DEFINE(HAVE_LIBKRB, 1, [Define to 1 if you have the `krb' library (-lkrb).])
3186 fi
3187 fi
3188 fi
3189
3190 if test "${with_kerberos5}" != no; then
3191 AC_CHECK_HEADERS(krb5.h,
3192 [AC_CHECK_MEMBERS([krb5_error.text, krb5_error.e_text],,,
3193 [#include <krb5.h>])])
3194 else
3195 AC_CHECK_HEADERS(des.h,,
3196 [AC_CHECK_HEADERS(kerberosIV/des.h,,
3197 [AC_CHECK_HEADERS(kerberos/des.h)])])
3198 AC_CHECK_HEADERS(krb.h,,
3199 [AC_CHECK_HEADERS(kerberosIV/krb.h,,
3200 [AC_CHECK_HEADERS(kerberos/krb.h)])])
3201 fi
3202 AC_CHECK_HEADERS(com_err.h)
3203fi
3204
3205AC_SUBST(COM_ERRLIB)
3206AC_SUBST(CRYPTOLIB)
3207AC_SUBST(KRB5LIB)
3208AC_SUBST(DESLIB)
3209AC_SUBST(KRB4LIB)
3210
554fef51 3211AC_CHECK_FUNCS_ONCE(tzset)
067d23c9
KY
3212AC_MSG_CHECKING(whether localtime caches TZ)
3213AC_CACHE_VAL(emacs_cv_localtime_cache,
3214[if test x$ac_cv_func_tzset = xyes; then
181855e6 3215AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
067d23c9
KY
3216char TZ_GMT0[] = "TZ=GMT0";
3217char TZ_PST8[] = "TZ=PST8";
3218main()
3219{
3220 time_t now = time ((time_t *) 0);
3221 int hour_GMT0, hour_unset;
3222 if (putenv (TZ_GMT0) != 0)
3223 exit (1);
3224 hour_GMT0 = localtime (&now)->tm_hour;
3225 unsetenv("TZ");
3226 hour_unset = localtime (&now)->tm_hour;
3227 if (putenv (TZ_PST8) != 0)
3228 exit (1);
3229 if (localtime (&now)->tm_hour == hour_GMT0)
3230 exit (1);
3231 unsetenv("TZ");
3232 if (localtime (&now)->tm_hour != hour_unset)
3233 exit (1);
3234 exit (0);
181855e6 3235}]])], emacs_cv_localtime_cache=no, emacs_cv_localtime_cache=yes,
067d23c9
KY
3236[# If we have tzset, assume the worst when cross-compiling.
3237emacs_cv_localtime_cache=yes])
3238else
3239 # If we lack tzset, report that localtime does not cache TZ,
3240 # since we can't invalidate the cache if we don't have tzset.
3241 emacs_cv_localtime_cache=no
3242fi])dnl
3243AC_MSG_RESULT($emacs_cv_localtime_cache)
3244if test $emacs_cv_localtime_cache = yes; then
3245 AC_DEFINE(LOCALTIME_CACHE, 1,
3246 [Define to 1 if localtime caches TZ.])
3247fi
3248
067d23c9
KY
3249ok_so_far=yes
3250AC_CHECK_FUNC(socket, , ok_so_far=no)
3251if test $ok_so_far = yes; then
3252 AC_CHECK_HEADER(netinet/in.h, , ok_so_far=no)
3253fi
3254if test $ok_so_far = yes; then
3255 AC_CHECK_HEADER(arpa/inet.h, , ok_so_far=no)
3256fi
3257if test $ok_so_far = yes; then
3258dnl Fixme: Not used. Should this be HAVE_SOCKETS?
3259 AC_DEFINE(HAVE_INET_SOCKETS, 1,
3260 [Define to 1 if you have inet sockets.])
3261fi
3262
3263if test -f /usr/lpp/X11/bin/smt.exp; then
3264 AC_DEFINE(HAVE_AIX_SMT_EXP, 1,
3265 [Define to 1 if the file /usr/lpp/X11/bin/smt.exp exists.])
3266fi
3267
3268AC_MSG_CHECKING(whether system supports dynamic ptys)
3269if test -d /dev/pts && ls -d /dev/ptmx > /dev/null 2>&1 ; then
3270 AC_MSG_RESULT(yes)
3271 AC_DEFINE(HAVE_DEV_PTMX, 1, [Define to 1 if dynamic ptys are supported.])
3272else
3273 AC_MSG_RESULT(no)
3274fi
3275
eeceac93
PE
3276dnl Check for a Solaris 2.4 vfork bug that Autoconf misses (through 2.69).
3277dnl This can be removed once we assume Autoconf 2.70.
3278case $canonical in
3279 *-solaris2.4 | *-solaris2.4.*)
3280 dnl Disable the Autoconf-generated vfork test.
3281 : ${ac_cv_func_vfork_works=no};;
3282esac
3283
067d23c9
KY
3284AC_FUNC_FORK
3285
54e8a418 3286AC_CHECK_FUNCS(snprintf)
55e5faa1 3287
067d23c9
KY
3288dnl Adapted from Haible's version.
3289AC_CACHE_CHECK([for nl_langinfo and CODESET], emacs_cv_langinfo_codeset,
181855e6
GM
3290 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
3291 [[char* cs = nl_langinfo(CODESET);]])],
067d23c9
KY
3292 emacs_cv_langinfo_codeset=yes,
3293 emacs_cv_langinfo_codeset=no)
3294 ])
3295if test $emacs_cv_langinfo_codeset = yes; then
3296 AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
3297 [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
3298fi
3299
067d23c9
KY
3300AC_TYPE_MBSTATE_T
3301
067d23c9 3302AC_CACHE_CHECK([for C restricted array declarations], emacs_cv_c_restrict_arr,
181855e6 3303 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void fred (int x[__restrict]);]], [[]])],
067d23c9
KY
3304 emacs_cv_c_restrict_arr=yes, emacs_cv_c_restrict_arr=no)])
3305if test "$emacs_cv_c_restrict_arr" = yes; then
3306 AC_DEFINE(__restrict_arr, __restrict,
3307 [Define to compiler's equivalent of C99 restrict keyword in array
3308 declarations. Define as empty for no equivalent.])
3309fi
3310
3311dnl Fixme: AC_SYS_POSIX_TERMIOS should probably be used, but it's not clear
3312dnl how the tty code is related to POSIX and/or other versions of termios.
3313dnl The following looks like a useful start.
3314dnl
3315dnl AC_SYS_POSIX_TERMIOS
3316dnl if test $ac_cv_sys_posix_termios = yes; then
3317dnl AC_DEFINE(HAVE_TERMIOS, 1, [Define to 1 if you have POSIX-style functions
3318dnl and macros for terminal control.])
3319dnl AC_DEFINE(HAVE_TCATTR, 1, [Define to 1 if you have tcgetattr and tcsetattr.])
3320dnl fi
3321
8d8e2dfe
GM
3322dnl Turned on June 1996 supposing nobody will mind it.
3323AC_DEFINE(AMPERSAND_FULL_NAME, 1, [Define to use the convention that &
3324 in the full name stands for the login id.])
3325
172bedef
GM
3326dnl Every platform that uses configure (ie every non-MS platform)
3327dnl supports this. There is a create-lockfiles option you can
3328dnl customize if you do not want the lock files to be written.
3329dnl So it is not clear that this #define still needs to exist.
3330AC_DEFINE(CLASH_DETECTION, 1, [Define if you want lock files to be written,
3331 so that Emacs can tell instantly when you try to modify a file that
3332 someone else has modified in his/her Emacs.])
3333
ee1cf5cf
GM
3334dnl Everybody supports this, except MS.
3335dnl Seems like the kind of thing we should be testing for, though.
3336## Note: PTYs are broken on darwin <6. Use at your own risk.
3337AC_DEFINE(HAVE_PTYS, 1, [Define if the system supports pty devices.])
3338
3339dnl Everybody supports this, except MS-DOS.
3340dnl Seems like the kind of thing we should be testing for, though.
3341dnl Compare with HAVE_INET_SOCKETS (which is unused...) above.
3342AC_DEFINE(HAVE_SOCKETS, 1, [Define if the system supports
3343 4.2-compatible sockets.])
3344
ca35a5f7
GM
3345AH_TEMPLATE(INTERNAL_TERMINAL, [This is substituted when $TERM is "internal".])
3346
b2c7a106
GM
3347AC_DEFINE(NULL_DEVICE, ["/dev/null"], [Name of the file to open to get
3348 a null file, or a data sink.])
3349
3350AC_DEFINE(SEPCHAR, [':'], [Character that separates PATH elements.])
3351
8d8e2dfe
GM
3352dnl Everybody supports this, except MS-DOS.
3353AC_DEFINE(subprocesses, 1, [Define to enable asynchronous subprocesses.])
3354
b2c7a106
GM
3355AC_DEFINE(USER_FULL_NAME, [pw->pw_gecos], [How to get a user's full name.])
3356
ee1cf5cf 3357
9374581a
GM
3358AC_DEFINE(DIRECTORY_SEP, ['/'],
3359 [Character that separates directories in a file name.])
3360
5c0c0e8a
GM
3361dnl Only used on MS platforms.
3362AH_TEMPLATE(DEVICE_SEP, [Character that separates a device in a file name.])
3363
3364AC_DEFINE(IS_DEVICE_SEP(_c_), 0,
3365 [Returns true if character is a device separator.])
3366
3367AC_DEFINE(IS_DIRECTORY_SEP(_c_), [((_c_) == DIRECTORY_SEP)],
3368 [Returns true if character is a directory separator.])
3369
3370dnl On MS, this also accepts IS_DEVICE_SEP.
3371AC_DEFINE(IS_ANY_SEP(_c_), [(IS_DIRECTORY_SEP (_c_))],
3372 [Returns true if character is any form of separator.])
3373
3374
ba9e4b84
GM
3375AH_TEMPLATE(NO_EDITRES, [Define if XEditRes should not be used.])
3376
3377case $opsys in
3378 aix4-2)
3379 dnl Unfortunately without libXmu we cannot support EditRes.
3380 if test x$ac_cv_lib_Xmu_XmuConvertStandardSelection != xyes; then
5dad233c 3381 AC_DEFINE(NO_EDITRES, 1)
ba9e4b84
GM
3382 fi
3383 ;;
3384
3385 hpux*)
3386 dnl Assar Westerlund <assar@sics.se> says this is necessary for
3387 dnl HP-UX 10.20, and that it works for HP-UX 0 as well.
3388 AC_DEFINE(NO_EDITRES, 1)
3389 ;;
3390esac
3391
3392
45fa9c0f 3393case $opsys in
739ae010
GM
3394 irix6-5 | sol2* | unixware )
3395 dnl Some SVr4s don't define NSIG in sys/signal.h for ANSI environments;
3396 dnl instead, there's a system variable _sys_nsig. Unfortunately, we
3397 dnl need the constant to dimension an array. So wire in the appropriate
3398 dnl value here.
3399 AC_DEFINE(NSIG_MINIMUM, 32, [Minimum value of NSIG.])
3400 ;;
45fa9c0f
GM
3401esac
3402
4a4bbad2 3403emacs_broken_SIGIO=no
ea0bbd17 3404
45fa9c0f 3405case $opsys in
ea0bbd17
GM
3406 dnl SIGIO exists, but the feature doesn't work in the way Emacs needs.
3407 dnl See eg <http://article.gmane.org/gmane.os.openbsd.ports/46831>.
45fa9c0f 3408 hpux* | irix6-5 | openbsd | sol2* | unixware )
4a4bbad2 3409 emacs_broken_SIGIO=yes
c5564388
GM
3410 ;;
3411
ea0bbd17 3412 aix4-2)
42bd1719
GM
3413 dnl On AIX Emacs uses the gmalloc.c malloc implementation. But given
3414 dnl the way this system works, libc functions that return malloced
3415 dnl memory use the libc malloc implementation. Calling xfree or
3416 dnl xrealloc on the results of such functions results in a crash.
3417 dnl
3418 dnl One solution for this could be to define SYSTEM_MALLOC in configure,
3419 dnl but that does not currently work on this system.
3420 dnl
3421 dnl It is possible to completely override the malloc implementation on
3422 dnl AIX, but that involves putting the malloc functions in a shared
3423 dnl library and setting the MALLOCTYPE environment variable to point to
3424 dnl that shared library.
3425 dnl
3426 dnl Emacs currently calls xrealloc on the results of get_current_dir name,
3427 dnl to avoid a crash just use the Emacs implementation for that function.
3428 dnl
3429 dnl FIXME We could change the AC_CHECK_FUNCS call near the start
3430 dnl of this file, so that we do not check for get_current_dir_name
3431 dnl on AIX. But that might be fragile if something else ends
3432 dnl up testing for get_current_dir_name as a dependency.
3433 AC_DEFINE(BROKEN_GET_CURRENT_DIR_NAME, 1, [Define if
3434 get_current_dir_name should not be used.])
3435 ;;
3436
3437 freebsd)
3438 dnl Circumvent a bug in FreeBSD. In the following sequence of
3439 dnl writes/reads on a PTY, read(2) returns bogus data:
3440 dnl
3441 dnl write(2) 1022 bytes
3442 dnl write(2) 954 bytes, get EAGAIN
3443 dnl read(2) 1024 bytes in process_read_output
3444 dnl read(2) 11 bytes in process_read_output
3445 dnl
3446 dnl That is, read(2) returns more bytes than have ever been written
3447 dnl successfully. The 1033 bytes read are the 1022 bytes written
3448 dnl successfully after processing (for example with CRs added if the
3449 dnl terminal is set up that way which it is here). The same bytes will
3450 dnl be seen again in a later read(2), without the CRs.
3451 AC_DEFINE(BROKEN_PTY_READ_AFTER_EAGAIN, 1, [Define on FreeBSD to
3452 work around an issue when reading from a PTY.])
ea0bbd17 3453 ;;
45fa9c0f
GM
3454esac
3455
b4492cba
GM
3456case $opsys in
3457 gnu-* | sol2-10 )
3458 dnl FIXME Can't we test if this exists (eg /proc/$$)?
3459 AC_DEFINE(HAVE_PROCFS, 1, [Define if you have the /proc filesystem.])
3460 ;;
3461esac
3462
9d596af3
GM
3463case $opsys in
3464 darwin | freebsd | netbsd | openbsd )
3465 AC_DEFINE(DONT_REOPEN_PTY, 1, [Define if process.c does not need to
3466 close a pty to make it a controlling terminal (it is already a
3467 controlling terminal of the subprocess, because we did ioctl TIOCSCTTY).])
3468 ;;
3469esac
3470
20e94fdd
GM
3471dnl FIXME Surely we can test for this rather than hard-code it.
3472case $opsys in
3473 netbsd | openbsd) sound_device="/dev/audio" ;;
3474 *) sound_device="/dev/dsp" ;;
3475esac
3476
3477dnl Used in sound.c
3478AC_DEFINE_UNQUOTED(DEFAULT_SOUND_DEVICE, "$sound_device",
3479 [Name of the default sound device.])
3480
09f4e3b0 3481
c43fb4c3
GM
3482dnl Emacs can read input using SIGIO and buffering characters itself,
3483dnl or using CBREAK mode and making C-g cause SIGINT.
3484dnl The choice is controlled by the variable interrupt_input.
3485dnl
3486dnl Define INTERRUPT_INPUT to make interrupt_input = 1 the default (use SIGIO)
3487dnl
4a4bbad2 3488dnl Emacs uses the presence of the USABLE_SIGIO macro
c43fb4c3
GM
3489dnl to indicate whether or not signal-driven I/O is possible. It uses
3490dnl INTERRUPT_INPUT to decide whether to use it by default.
3491dnl
3492dnl SIGIO can be used only on systems that implement it (4.2 and 4.3).
3493dnl CBREAK mode has two disadvantages
3494dnl 1) At least in 4.2, it is impossible to handle the Meta key properly.
3495dnl I hear that in system V this problem does not exist.
3496dnl 2) Control-G causes output to be discarded.
3497dnl I do not know whether this can be fixed in system V.
3498dnl
3499dnl Another method of doing input is planned but not implemented.
3500dnl It would have Emacs fork off a separate process
3501dnl to read the input and send it to the true Emacs process
3502dnl through a pipe.
3503case $opsys in
3504 darwin | gnu-linux | gnu-kfreebsd )
3505 AC_DEFINE(INTERRUPT_INPUT, 1, [Define to read input using SIGIO.])
3506 ;;
3507esac
3508
3509
308aab79
GM
3510dnl If the system's imake configuration file defines `NeedWidePrototypes'
3511dnl as `NO', we must define NARROWPROTO manually. Such a define is
3512dnl generated in the Makefile generated by `xmkmf'. If we don't define
3513dnl NARROWPROTO, we will see the wrong function prototypes for X functions
3514dnl taking float or double parameters.
3515case $opsys in
3516 cygwin|gnu|gnu-linux|gnu-kfreebsd|irix6-5|freebsd|netbsd|openbsd)
3517 AC_DEFINE(NARROWPROTO, 1, [Define if system's imake configuration
3518 file defines `NeedWidePrototypes' as `NO'.])
3519 ;;
3520esac
3521
3522
6e777848
GM
3523dnl Used in process.c, this must be a loop, even if it only runs once.
3524dnl (Except on SGI; see below. Take that, clarity and consistency!)
3525AH_TEMPLATE(PTY_ITERATION, [How to iterate over PTYs.])
3526dnl Only used if !PTY_ITERATION. Iterate from FIRST_PTY_LETTER to z,
3527dnl trying suffixes 0-16.
3528AH_TEMPLATE(FIRST_PTY_LETTER, [Letter to use in finding device name of
3529 first PTY, if PTYs are supported.])
0ab7b23a 3530AH_TEMPLATE(PTY_OPEN, [How to open a PTY, if non-standard.])
3f922c37
GM
3531AH_TEMPLATE(PTY_NAME_SPRINTF, [How to get the device name of the control
3532 end of a PTY, if non-standard.])
3533AH_TEMPLATE(PTY_TTY_NAME_SPRINTF, [How to get device name of the tty
3534 end of a PTY, if non-standard.])
6e777848
GM
3535
3536case $opsys in
3537 aix4-2 )
ef834897 3538 AC_DEFINE(PTY_ITERATION, [int c; for (c = 0; !c ; c++)])
3f922c37
GM
3539 dnl You allocate a pty by opening /dev/ptc to get the master side.
3540 dnl To get the name of the slave side, you just ttyname() the master side.
ef834897
GM
3541 AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");])
3542 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [strcpy (pty_name, ttyname (fd));])
6e777848
GM
3543 ;;
3544
3545 cygwin )
ef834897 3546 AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
0ab7b23a 3547 dnl multi-line AC_DEFINEs are hard. :(
2fe28299 3548 AC_DEFINE(PTY_OPEN, [ do { int dummy; sigset_t blocked, procmask; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, &procmask); if (-1 == openpty (&fd, &dummy, pty_name, 0, 0)) fd = -1; pthread_sigmask (SIG_SETMASK, &procmask, 0); if (fd >= 0) emacs_close (dummy); } while (0)])
ef834897
GM
3549 AC_DEFINE(PTY_NAME_SPRINTF, [])
3550 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
6e777848
GM
3551 ;;
3552
1598ef28 3553 dnl FIXME? Maybe use same as freebsd - see bug#12040.
6e777848 3554 darwin )
ef834897 3555 AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
6e777848
GM
3556 dnl Not used, because PTY_ITERATION is defined.
3557 AC_DEFINE(FIRST_PTY_LETTER, ['p'])
0ab7b23a
GM
3558 dnl Note that openpty may fork via grantpt on Mac OS X 10.4/Darwin 8.
3559 dnl But we don't have to block SIGCHLD because it is blocked in the
3560 dnl implementation of grantpt.
ef834897
GM
3561 AC_DEFINE(PTY_OPEN, [ do { int slave; if (openpty (&fd, &slave, pty_name, NULL, NULL) == -1) fd = -1; else emacs_close (slave); } while (0)])
3562 AC_DEFINE(PTY_NAME_SPRINTF, [])
3563 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
6e777848
GM
3564 ;;
3565
1598ef28 3566 gnu | openbsd )
6e777848
GM
3567 AC_DEFINE(FIRST_PTY_LETTER, ['p'])
3568 ;;
3569
1598ef28 3570 gnu-linux | gnu-kfreebsd | freebsd | netbsd )
6e777848
GM
3571 dnl if HAVE_GRANTPT
3572 if test "x$ac_cv_func_grantpt" = xyes; then
3e91a053 3573 AC_DEFINE(UNIX98_PTYS, 1, [Define if the system has Unix98 PTYs.])
ef834897 3574 AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
3f922c37
GM
3575 dnl Note that grantpt and unlockpt may fork. We must block SIGCHLD
3576 dnl to prevent sigchld_handler from intercepting the child's death.
2fe28299 3577 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (grantpt (fd) != -1 && unlockpt (fd) != -1) ptyname = ptsname(fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (!ptyname) { close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
1598ef28
JB
3578 dnl if HAVE_POSIX_OPENPT
3579 if test "x$ac_cv_func_posix_openpt" = xyes; then
3580 AC_DEFINE(PTY_OPEN, [fd = posix_openpt (O_RDWR | O_NOCTTY)])
a09710e9 3581 AC_DEFINE(PTY_NAME_SPRINTF, [])
0ab7b23a 3582 dnl if HAVE_GETPT
1598ef28 3583 elif test "x$ac_cv_func_getpt" = xyes; then
0ab7b23a 3584 AC_DEFINE(PTY_OPEN, [fd = getpt ()])
ef834897 3585 AC_DEFINE(PTY_NAME_SPRINTF, [])
3f922c37 3586 else
ef834897 3587 AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");])
0ab7b23a 3588 fi
6e777848
GM
3589 else
3590 AC_DEFINE(FIRST_PTY_LETTER, ['p'])
3591 fi
3592 ;;
3593
3f922c37
GM
3594 hpux*)
3595 AC_DEFINE(FIRST_PTY_LETTER, ['p'])
ef834897
GM
3596 AC_DEFINE(PTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);])
3597 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/pty/tty%c%x", c, i);])
3f922c37
GM
3598 ;;
3599
6e777848
GM
3600 irix6-5 )
3601 dnl It looks like this cannot be right, because it is not a loop.
3602 dnl However, process.c actually does this:
3603 dnl # ifndef __sgi
3604 dnl continue;
3605 dnl # else
3606 dnl return -1;
3607 dnl # endif
3608 dnl which presumably makes it OK, since irix == sgi (?).
3609 dnl FIXME it seems like this special treatment is unnecessary?
3610 dnl Why can't irix use a single-trip loop like eg cygwin?
3611 AC_DEFINE(PTY_ITERATION, [])
3612 dnl Not used, because PTY_ITERATION is defined.
3613 AC_DEFINE(FIRST_PTY_LETTER, ['q'])
d983a10b 3614 AC_DEFINE(PTY_OPEN, [ { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCHLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCHLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }])
5dad233c 3615 dnl No need to get the pty name at all.
ef834897 3616 AC_DEFINE(PTY_NAME_SPRINTF, [])
3f922c37 3617 dnl No need to use sprintf to get the tty name--we get that from _getpty.
ef834897 3618 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
6e777848
GM
3619 ;;
3620
3f922c37 3621 sol2* )
3f922c37
GM
3622 dnl On SysVr4, grantpt(3) forks a subprocess, so keep sigchld_handler()
3623 dnl from intercepting that death. If any child but grantpt's should die
3624 dnl within, it should be caught after sigrelse(2).
d983a10b 3625 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
3f922c37
GM
3626 ;;
3627
3f922c37 3628 unixware )
33d63ff4 3629 dnl Comments are as per sol2*.
d983a10b 3630 AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1) fatal("could not grant slave pty"); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
33d63ff4
GM
3631 ;;
3632esac
3633
3634
3635case $opsys in
3636 sol2* | unixware )
3637 dnl This change means that we don't loop through allocate_pty too
3638 dnl many times in the (rare) event of a failure.
3f922c37 3639 AC_DEFINE(FIRST_PTY_LETTER, ['z'])
ef834897 3640 AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");])
33d63ff4
GM
3641 dnl Push various streams modules onto a PTY channel. Used in process.c.
3642 AC_DEFINE(SETUP_SLAVE_PTY, [if (ioctl (xforkin, I_PUSH, "ptem") == -1) fatal ("ioctl I_PUSH ptem"); if (ioctl (xforkin, I_PUSH, "ldterm") == -1) fatal ("ioctl I_PUSH ldterm"); if (ioctl (xforkin, I_PUSH, "ttcompat") == -1) fatal ("ioctl I_PUSH ttcompat");], [How to set up a slave PTY, if needed.])
6e777848
GM
3643 ;;
3644esac
3645
3646
09f4e3b0
GM
3647AH_TEMPLATE(SIGNALS_VIA_CHARACTERS, [Make process_send_signal work by
3648"typing" a signal character on the pty.])
3649
3650case $opsys in
3651 dnl Perry Smith <pedz@ddivt1.austin.ibm.com> says this is correct for AIX.
3652 dnl thomas@mathematik.uni-bremen.de says this is needed for IRIX.
02e7729e 3653 aix4-2 | cygwin | gnu | irix6-5 | freebsd | netbsd | openbsd | darwin )
09f4e3b0
GM
3654 AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1)
3655 ;;
3656
5dad233c 3657 dnl 21 Jun 06: Eric Hanchrow <offby1@blarg.net> says this works.
09f4e3b0
GM
3658 dnl FIXME Does gnu-kfreebsd have linux/version.h? It seems unlikely...
3659 gnu-linux | gnu-kfreebsd )
3660
3661 AC_MSG_CHECKING([for signals via characters])
3662 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
3663#include <linux/version.h>
3664#if LINUX_VERSION_CODE < 0x20400
3665# error "Linux version too old"
3666#endif
3667 ]], [[]])], emacs_signals_via_chars=yes, emacs_signals_via_chars=no)
3668
3669 AC_MSG_RESULT([$emacs_signals_via_chars])
3670 test $emacs_signals_via_chars = yes && AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1)
3671 ;;
3672esac
3673
3674
1ddc2bd6 3675dnl Used in lisp.h, emacs.c, vm-limit.c
c8add24e
GM
3676dnl NEWS.18 describes this as "a number which contains
3677dnl the high bits to be inclusive or'ed with pointers that are unpacked."
3678AH_TEMPLATE(DATA_SEG_BITS, [Extra bits to be or'd in with any pointers
3679stored in a Lisp_Object.])
3680dnl if Emacs uses fewer than 32 bits for the value field of a LISP_OBJECT.
3681
3682case $opsys in
35b3a27e
PE
3683 aix*)
3684 dnl This works with 32-bit executables; Emacs doesn't support 64-bit.
35b3a27e
PE
3685 AC_DEFINE(DATA_SEG_BITS, [0x20000000])
3686 ;;
882cf227
GM
3687 hpux*)
3688 dnl The data segment on this machine always starts at address 0x40000000.
882cf227
GM
3689 AC_DEFINE(DATA_SEG_BITS, [0x40000000])
3690 ;;
3691 irix6-5)
882cf227
GM
3692 AC_DEFINE(DATA_SEG_BITS, [0x10000000])
3693 ;;
3694esac
3695
7ccad002
GM
3696
3697AH_TEMPLATE(TAB3, [Undocumented.])
3698
b4492cba 3699case $opsys in
7ccad002 3700 darwin) AC_DEFINE(TAB3, OXTABS) ;;
8a07a8c6 3701
7ccad002 3702 gnu | freebsd | netbsd | openbsd )
ef834897 3703 AC_DEFINE(TABDLY, OXTABS, [Undocumented.])
7ccad002
GM
3704 AC_DEFINE(TAB3, OXTABS)
3705 ;;
1cce6920 3706
dbee5793 3707 gnu-linux | gnu-kfreebsd )
5b633342
GM
3708 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
3709#ifndef __ia64__
3710# error "not ia64"
3711#endif
3712 ]], [[]])], AC_DEFINE(GC_MARK_SECONDARY_STACK(),
3713 [do { extern void *__libc_ia64_register_backing_store_base; __builtin_ia64_flushrs (); mark_memory (__libc_ia64_register_backing_store_base, __builtin_ia64_bsp ());} while (0)],
3714 [Mark a secondary stack, like the register stack on the ia64.]), [])
dbee5793
GM
3715 ;;
3716
7ccad002
GM
3717 hpux*)
3718 AC_DEFINE(RUN_TIME_REMAP, 1, [Define if emacs.c needs to call
3719 run_time_remap; for HPUX.])
3720 ;;
3721esac
3722
3723
444b01bb 3724dnl This won't be used automatically yet. We also need to know, at least,
5b3f250f
GM
3725dnl that the stack is continuous.
3726AH_TEMPLATE(GC_SETJMP_WORKS, [Define if setjmp is known to save all
3727 registers relevant for conservative garbage collection in the jmp_buf.])
3728
5b3f250f
GM
3729
3730case $opsys in
5b3f250f
GM
3731 dnl Not all the architectures are tested, but there are Debian packages
3732 dnl for SCM and/or Guile on them, so the technique must work. See also
3733 dnl comments in alloc.c concerning setjmp and gcc.
3734 dnl Fixme: it's probably safe to just use the GCC conditional below.
3735 gnu-linux | gnu-kfreebsd )
3736 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
3737#if defined __i386__ || defined __sparc__ || defined __mc68000__ \
3738 || defined __alpha__ || defined __mips__ || defined __s390__ \
3739 || defined __arm__ || defined __powerpc__ || defined __amd64__ \
3740 || defined __ia64__ || defined __sh__
3741/* ok */
3742#else
3743# error "setjmp not known to work on this arch"
3744#endif
444b01bb 3745 ]], [[]])], AC_DEFINE(GC_SETJMP_WORKS, 1))
5b3f250f
GM
3746 ;;
3747esac
3748
3749
3750if test x$GCC = xyes; then
3751 dnl GC_SETJMP_WORKS is nearly always appropriate for GCC.
3752 AC_DEFINE(GC_SETJMP_WORKS, 1)
3753else
3754 case $opsys in
3755 dnl irix: Tested on Irix 6.5. SCM worked on earlier versions.
3756 freebsd | netbsd | openbsd | irix6-5 | sol2* )
3757 AC_DEFINE(GC_SETJMP_WORKS, 1)
3758 ;;
3759 esac
3760fi dnl GCC?
3761
7b6c362e
PE
3762AC_CACHE_CHECK([for _setjmp], [emacs_cv_func__setjmp],
3763 [AC_LINK_IFELSE(
3764 [AC_LANG_PROGRAM(
3765 [[#include <setjmp.h>
3766 ]],
3767 [[jmp_buf j;
3768 if (! _setjmp (j))
3769 _longjmp (j, 1);]])],
3770 [emacs_cv_func__setjmp=yes],
3771 [emacs_cv_func__setjmp=no])])
0328b6de
PE
3772if test $emacs_cv_func__setjmp = yes; then
3773 AC_DEFINE([HAVE__SETJMP], 1, [Define to 1 if _setjmp and _longjmp work.])
3774else
3775 AC_CACHE_CHECK([for sigsetjmp], [emacs_cv_func_sigsetjmp],
3776 [AC_LINK_IFELSE(
3777 [AC_LANG_PROGRAM(
3778 [[#include <setjmp.h>
3779 ]],
3780 [[sigjmp_buf j;
3781 if (! sigsetjmp (j, 1))
3782 siglongjmp (j, 1);]])],
3783 [emacs_cv_func_sigsetjmp=yes],
3784 [emacs_cv_func_sigsetjmp=no])])
3785 if test $emacs_cv_func_sigsetjmp = yes; then
3786 AC_DEFINE([HAVE_SIGSETJMP], 1,
3787 [Define to 1 if sigsetjmp and siglongjmp work.
3788 The value of this symbol is irrelevant if HAVE__SETJMP is defined.])
3789 fi
7b6c362e 3790fi
b65e7c46 3791
0a763bd1
GM
3792case $opsys in
3793 sol2* | unixware )
b65e7c46
GM
3794 dnl TIOCGPGRP is broken in SysVr4, so we can't send signals to PTY
3795 dnl subprocesses the usual way. But TIOCSIGNAL does work for PTYs,
3796 dnl and this is all we need.
3797 AC_DEFINE(TIOCSIGSEND, TIOCSIGNAL, [Some platforms redefine this.])
0a763bd1
GM
3798 ;;
3799esac
3800
5b3f250f 3801
7ccad002
GM
3802case $opsys in
3803 hpux* | sol2* )
32bac6d6 3804 dnl Used in xfaces.c.
7ccad002
GM
3805 AC_DEFINE(XOS_NEEDS_TIME_H, 1, [Compensate for a bug in Xos.h on
3806 some systems, where it requires time.h.])
3807 ;;
3808esac
3809
3810
983188fd
GM
3811dnl Define symbols to identify the version of Unix this is.
3812dnl Define all the symbols that apply correctly.
ae21c275
GM
3813AH_TEMPLATE(DOS_NT, [Define if the system is MS DOS or MS Windows.])
3814AH_TEMPLATE(MSDOS, [Define if the system is MS DOS.])
983188fd
GM
3815AH_TEMPLATE(USG, [Define if the system is compatible with System III.])
3816AH_TEMPLATE(USG5, [Define if the system is compatible with System V.])
268e2432 3817AH_TEMPLATE(USG5_4, [Define if the system is compatible with System V Release 4.])
983188fd
GM
3818
3819case $opsys in
3820 aix4-2)
3821 AC_DEFINE(USG, [])
3822 AC_DEFINE(USG5, [])
3823 dnl This symbol should be defined on AIX Version 3 ???????
3824 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
3825#ifndef _AIX
3826# error "_AIX not defined"
3827#endif
3828 ]], [[]])], [], AC_DEFINE(_AIX, [], [Define if the system is AIX.]))
3829 ;;
3830
3831 cygwin)
3832 AC_DEFINE(CYGWIN, 1, [Define if the system is Cygwin.])
3833 ;;
3834
3835 darwin)
47d7532e
PE
3836 dnl Not __APPLE__, as this may not be defined on non-OSX Darwin.
3837 dnl Not DARWIN, because Panther and lower CoreFoundation.h use DARWIN to
983188fd
GM
3838 dnl distinguish OS X from pure Darwin.
3839 AC_DEFINE(DARWIN_OS, [], [Define if the system is Darwin.])
3840 ;;
3841
983188fd
GM
3842 gnu-linux | gnu-kfreebsd )
3843 AC_DEFINE(USG, [])
3844 AC_DEFINE(GNU_LINUX, [], [Define if ths system is compatible with GNU/Linux.])
3845 ;;
3846
3847 hpux*)
3848 AC_DEFINE(USG, [])
3849 AC_DEFINE(USG5, [])
3850 AC_DEFINE(HPUX, [], [Define if the system is HPUX.])
3851 ;;
3852
3853 irix6-5)
3854 AC_DEFINE(USG, [])
3855 AC_DEFINE(USG5, [])
268e2432 3856 AC_DEFINE(USG5_4, [])
983188fd
GM
3857 AC_DEFINE(IRIX6_5, [], [Define if the system is IRIX.])
3858 ;;
3859
3860 sol2*)
3861 AC_DEFINE(USG, [])
3862 AC_DEFINE(USG5, [])
268e2432 3863 AC_DEFINE(USG5_4, [])
983188fd
GM
3864 AC_DEFINE(SOLARIS2, [], [Define if the system is Solaris.])
3865 ;;
3866
3867 unixware)
3868 AC_DEFINE(USG, [])
3869 AC_DEFINE(USG5, [])
268e2432 3870 AC_DEFINE(USG5_4, [])
983188fd
GM
3871 ;;
3872esac
3873
4a4bbad2
PE
3874AC_CACHE_CHECK([for usable FIONREAD], [emacs_cv_usable_FIONREAD],
3875 [case $opsys in
3876 aix4-2)
3877 dnl BUILD 9008 - FIONREAD problem still exists in X-Windows.
3878 emacs_cv_usable_FIONREAD=no
3879 ;;
3880
3881 *)
3882 AC_COMPILE_IFELSE(
3883 [AC_LANG_PROGRAM([[#include <sys/types.h>
3884 #include <sys/ioctl.h>
3885 #ifdef USG5_4
3886 # include <sys/filio.h>
3887 #endif
3888 ]],
3889 [[int foo = ioctl (0, FIONREAD, &foo);]])],
3890 [emacs_cv_usable_FIONREAD=yes],
3891 [emacs_cv_usable_FIONREAD=no])
3892 ;;
3893 esac])
3894if test $emacs_cv_usable_FIONREAD = yes; then
3895 AC_DEFINE([USABLE_FIONREAD], [1], [Define to 1 if FIONREAD is usable.])
3896
3897 if test $emacs_broken_SIGIO = no; then
3898 AC_CACHE_CHECK([for usable SIGIO], [emacs_cv_usable_SIGIO],
3899 [AC_COMPILE_IFELSE(
3900 [AC_LANG_PROGRAM([[#include <fcntl.h>
3901 #include <signal.h>
3902 ]],
3903 [[int foo = SIGIO | F_SETFL | FASYNC;]])],
3904 [emacs_cv_usable_SIGIO=yes],
3905 [emacs_cv_usable_SIGIO=no])],
3906 [emacs_cv_usable_SIGIO=yes],
3907 [emacs_cv_usable_SIGIO=no])
3908 if test $emacs_cv_usable_SIGIO = yes; then
3909 AC_DEFINE([USABLE_SIGIO], [1], [Define to 1 if SIGIO is usable.])
3910 fi
3911 fi
3912fi
3913
983188fd 3914
7ccad002 3915case $opsys in
42bd1719
GM
3916 dnl Emacs supplies its own malloc, but glib (part of Gtk+) calls
3917 dnl memalign and on Cygwin, that becomes the Cygwin-supplied memalign.
3918 dnl As malloc is not the Cygwin malloc, the Cygwin memalign always
3919 dnl returns ENOSYS. A workaround is to set G_SLICE=always-malloc. */
3920 cygwin)
3921 AC_DEFINE(G_SLICE_ALWAYS_MALLOC, 1, [Define to set the
3922 G_SLICE environment variable to "always-malloc" at startup, if
3923 using GTK.])
3924 ;;
3925
7ccad002 3926 hpux11)
7ccad002
GM
3927 dnl It works to open the pty's tty in the parent (Emacs), then
3928 dnl close and reopen it in the child.
3929 AC_DEFINE(USG_SUBTTY_WORKS, 1, [Define for USG systems where it
3930 works to open a pty's tty in the parent process, then close and
3931 reopen it in the child.])
7ccad002
GM
3932 ;;
3933
3934 irix6-5)
3935 AC_DEFINE(PREFER_VSUSP, 1, [Define if process_send_signal should
3936 use VSUSP instead of VSWTCH.])
7ccad002
GM
3937 ;;
3938
7ccad002
GM
3939 sol2-10)
3940 AC_DEFINE(_STRUCTURED_PROC, 1, [Needed for system_process_attributes
3941 on Solaris.])
7ccad002 3942 ;;
0d369729
GM
3943esac
3944
067d23c9
KY
3945# Set up the CFLAGS for real compilation, so we can substitute it.
3946CFLAGS="$REAL_CFLAGS"
3947CPPFLAGS="$REAL_CPPFLAGS"
3948
3949## Hack to detect a buggy GCC version.
3950if test "x$GCC" = xyes \
3951 && test x"`$CC --version 2> /dev/null | grep 'gcc.* 4.5.0'`" != x \
3952 && test x"`echo $CFLAGS | grep '\-O@<:@23@:>@'`" != x \
3953 && test x"`echo $CFLAGS | grep '\-fno-optimize-sibling-calls'`" = x; then
3954 AC_MSG_ERROR([GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS'.])
3955fi
3956
16fab143 3957version=$PACKAGE_VERSION
067d23c9 3958
ab422c4d 3959copyright="Copyright (C) 2013 Free Software Foundation, Inc."
78f83752
GM
3960AC_DEFINE_UNQUOTED(COPYRIGHT, ["$copyright"],
3961 [Short copyright string for this version of Emacs.])
3962AC_SUBST(copyright)
3963
067d23c9
KY
3964### Specify what sort of things we'll be editing into Makefile and config.h.
3965### Use configuration here uncanonicalized to avoid exceeding size limits.
3966AC_SUBST(version)
3967AC_SUBST(configuration)
3968## Unused?
3969AC_SUBST(canonical)
3970AC_SUBST(srcdir)
3971AC_SUBST(prefix)
3972AC_SUBST(exec_prefix)
3973AC_SUBST(bindir)
3974AC_SUBST(datadir)
3975AC_SUBST(sharedstatedir)
3976AC_SUBST(libexecdir)
3977AC_SUBST(mandir)
3978AC_SUBST(infodir)
3979AC_SUBST(lispdir)
d71dfe75 3980AC_SUBST(leimdir)
ca26824c 3981AC_SUBST(standardlisppath)
067d23c9
KY
3982AC_SUBST(locallisppath)
3983AC_SUBST(lisppath)
3984AC_SUBST(x_default_search_path)
3985AC_SUBST(etcdir)
3986AC_SUBST(archlibdir)
3987AC_SUBST(docdir)
3988AC_SUBST(bitmapdir)
3989AC_SUBST(gamedir)
3990AC_SUBST(gameuser)
3991## FIXME? Nothing uses @LD_SWITCH_X_SITE@.
3992## src/Makefile.in did add LD_SWITCH_X_SITE (as a cpp define) to the
3993## end of LIBX_BASE, but nothing ever set it.
3994AC_SUBST(LD_SWITCH_X_SITE)
3995AC_SUBST(C_SWITCH_X_SITE)
2f097256 3996AC_SUBST(GNUSTEP_CFLAGS)
067d23c9
KY
3997AC_SUBST(CFLAGS)
3998## Used in lwlib/Makefile.in.
3999AC_SUBST(X_TOOLKIT_TYPE)
067d23c9
KY
4000AC_SUBST(ns_appdir)
4001AC_SUBST(ns_appbindir)
4002AC_SUBST(ns_appresdir)
4003AC_SUBST(ns_appsrc)
4004AC_SUBST(GNU_OBJC_CFLAGS)
4005AC_SUBST(OTHER_FILES)
4006
17a2cbbd
DC
4007if test -n "${term_header}"; then
4008 AC_DEFINE_UNQUOTED(TERM_HEADER, "${term_header}",
4009 [Define to the header for the built-in window system.])
4010fi
4011
067d23c9
KY
4012AC_DEFINE_UNQUOTED(EMACS_CONFIGURATION, "${canonical}",
4013 [Define to the canonical Emacs configuration name.])
60f5e585 4014dnl Replace any embedded " characters (bug#13274).
8b0590de 4015emacs_config_options=`echo "$emacs_config_options " | sed -e 's/--no-create //' -e 's/--no-recursion //' -e 's/ *$//' -e "s/\"/'/g"`
60f5e585 4016AC_DEFINE_UNQUOTED(EMACS_CONFIG_OPTIONS, "${emacs_config_options}",
067d23c9 4017 [Define to the options passed to configure.])
68169a33
GM
4018AH_TEMPLATE(config_opsysfile, [Some platforms that do not use configure
4019 define this to include extra configuration information.])
067d23c9
KY
4020
4021XMENU_OBJ=
4022XOBJ=
4023FONT_OBJ=
4024if test "${HAVE_X_WINDOWS}" = "yes" ; then
4025 AC_DEFINE(HAVE_X_WINDOWS, 1,
4026 [Define to 1 if you want to use the X window system.])
4027 XMENU_OBJ=xmenu.o
17a2cbbd 4028 XOBJ="xterm.o xfns.o xselect.o xrdb.o xsmfns.o xsettings.o xgselect.o"
067d23c9
KY
4029 FONT_OBJ=xfont.o
4030 if test "$HAVE_XFT" = "yes"; then
4031 FONT_OBJ="$FONT_OBJ ftfont.o xftfont.o ftxfont.o"
4032 elif test "$HAVE_FREETYPE" = "yes"; then
4033 FONT_OBJ="$FONT_OBJ ftfont.o ftxfont.o"
4034 fi
4035 AC_SUBST(FONT_OBJ)
4036fi
4037AC_SUBST(XMENU_OBJ)
4038AC_SUBST(XOBJ)
4039AC_SUBST(FONT_OBJ)
4040
4041WIDGET_OBJ=
4042MOTIF_LIBW=
4043if test "${USE_X_TOOLKIT}" != "none" ; then
4044 WIDGET_OBJ=widget.o
4045 AC_DEFINE(USE_X_TOOLKIT, 1, [Define to 1 if using an X toolkit.])
4046 if test "${USE_X_TOOLKIT}" = "LUCID"; then
4047 AC_DEFINE(USE_LUCID, 1, [Define to 1 if using the Lucid X toolkit.])
4048 elif test "${USE_X_TOOLKIT}" = "MOTIF"; then
4049 AC_DEFINE(USE_MOTIF, 1, [Define to 1 if using the Motif X toolkit.])
4050 MOTIF_LIBW=-lXm
4051 case "$opsys" in
4052 gnu-linux)
4053 ## Paul Abrahams <abrahams at equinox.shaysnet.com> says this is needed.
4054 MOTIF_LIBW="$MOTIF_LIBW -lXpm"
4055 ;;
4056
4057 unixware)
4058 ## Richard Anthony Ryan <ryanr at ellingtn.ftc.nrcs.usda.gov>
4059 ## says -lXimp is needed in UNIX_SV ... 4.2 1.1.2.
4060 MOTIF_LIBW="MOTIF_LIBW -lXimp"
4061 ;;
4062
4063 aix4-2)
4064 ## olson@mcs.anl.gov says -li18n is needed by -lXm.
4065 MOTIF_LIBW="$MOTIF_LIBW -li18n"
4066 ;;
4067 esac
4068 MOTIF_LIBW="$MOTIF_LIBW $LIBXP"
4069 fi
4070fi
4071AC_SUBST(WIDGET_OBJ)
4072
4073TOOLKIT_LIBW=
4074case "$USE_X_TOOLKIT" in
4075 MOTIF) TOOLKIT_LIBW="$MOTIF_LIBW" ;;
4076 LUCID) TOOLKIT_LIBW="$LUCID_LIBW" ;;
4077 none) test "x$HAVE_GTK" = "xyes" && TOOLKIT_LIBW="$GTK_LIBS" ;;
4078esac
4079AC_SUBST(TOOLKIT_LIBW)
4080
4081if test "$USE_X_TOOLKIT" = "none"; then
4082 LIBXT_OTHER="\$(LIBXSM)"
4083 OLDXMENU_TARGET="really-oldXMenu"
4084else
4085 LIBXT_OTHER="\$(LIBXMU) -lXt \$(LIBXTR6) -lXext"
4086 OLDXMENU_TARGET="really-lwlib"
4087fi
4088AC_SUBST(LIBXT_OTHER)
4089
4090## The X Menu stuff is present in the X10 distribution, but missing
4091## from X11. If we have X10, just use the installed library;
4092## otherwise, use our own copy.
4093if test "${HAVE_X11}" = "yes" ; then
4094 AC_DEFINE(HAVE_X11, 1,
4095 [Define to 1 if you want to use version 11 of X windows.
4096 Otherwise, Emacs expects to use version 10.])
4097
4098 if test "$USE_X_TOOLKIT" = "none"; then
4099 OLDXMENU="\${oldXMenudir}/libXMenu11.a"
4100 else
4101 OLDXMENU="\${lwlibdir}/liblw.a"
4102 fi
4103 LIBXMENU="\$(OLDXMENU)"
4104 LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
4105 OLDXMENU_DEPS="\${OLDXMENU} ../src/\${OLDXMENU}"
4106else
4107 ## For a syntactically valid Makefile; not actually used for anything.
4108 ## See comments in src/Makefile.in.
4109 OLDXMENU=nothing
4110 ## FIXME This case (!HAVE_X11 && HAVE_X_WINDOWS) is no longer possible(?).
4111 if test "${HAVE_X_WINDOWS}" = "yes"; then
4112 LIBXMENU="-lXMenu"
4113 else
4114 LIBXMENU=
4115 fi
4116 LIBX_OTHER=
4117 OLDXMENU_DEPS=
4118fi
4119
4120if test "$HAVE_GTK" = "yes" || test "$HAVE_MENUS" != "yes"; then
4121 OLDXMENU_TARGET=
b06b1098 4122 OLDXMENU=nothing
067d23c9
KY
4123 LIBXMENU=
4124 OLDXMENU_DEPS=
4125fi
4126
4127AC_SUBST(OLDXMENU_TARGET)
4128AC_SUBST(OLDXMENU)
4129AC_SUBST(LIBXMENU)
4130AC_SUBST(LIBX_OTHER)
4131AC_SUBST(OLDXMENU_DEPS)
4132
4133if test "${HAVE_MENUS}" = "yes" ; then
4134 AC_DEFINE(HAVE_MENUS, 1,
4135 [Define to 1 if you have mouse menus.
4136 (This is automatic if you use X, but the option to specify it remains.)
4137 It is also defined with other window systems that support xmenu.c.])
4138fi
4139
4140if test "${GNU_MALLOC}" = "yes" ; then
4141 AC_DEFINE(GNU_MALLOC, 1,
4142 [Define to 1 if you want to use the GNU memory allocator.])
4143fi
4144
4145RALLOC_OBJ=
4146if test "${REL_ALLOC}" = "yes" ; then
4147 AC_DEFINE(REL_ALLOC, 1,
4148 [Define REL_ALLOC if you want to use the relocating allocator for
4149 buffer space.])
4150
4151 test "$system_malloc" != "yes" && RALLOC_OBJ=ralloc.o
4152fi
4153AC_SUBST(RALLOC_OBJ)
4154
4155if test "$opsys" = "cygwin"; then
0fda9b75 4156 CYGWIN_OBJ="sheap.o cygw32.o"
067d23c9
KY
4157 ## Cygwin differs because of its unexec().
4158 PRE_ALLOC_OBJ=
4159 POST_ALLOC_OBJ=lastfile.o
4160else
4161 CYGWIN_OBJ=
4162 PRE_ALLOC_OBJ=lastfile.o
4163 POST_ALLOC_OBJ=
4164fi
4165AC_SUBST(CYGWIN_OBJ)
4166AC_SUBST(PRE_ALLOC_OBJ)
4167AC_SUBST(POST_ALLOC_OBJ)
4168
5dad233c
PE
4169# Configure gnulib. Although this does not affect CFLAGS or LIBS permanently.
4170# it temporarily reverts them to their pre-pkg-config values,
4171# because gnulib needs to work with both src (which uses the
4172# pkg-config stuff) and lib-src (which does not). For example, gnulib
4173# may need to determine whether LIB_CLOCK_GETTIME should contain -lrt,
4174# and it therefore needs to run in an environment where LIBS does not
4175# already contain -lrt merely because 'pkg-config --libs' printed '-lrt'
4176# for some package unrelated to lib-src.
4177SAVE_CFLAGS=$CFLAGS
4178SAVE_LIBS=$LIBS
4179CFLAGS=$pre_PKG_CONFIG_CFLAGS
4180LIBS="$LIB_PTHREAD $pre_PKG_CONFIG_LIBS"
4181gl_ASSERT_NO_GNULIB_POSIXCHECK
4182gl_ASSERT_NO_GNULIB_TESTS
4183gl_INIT
4184CFLAGS=$SAVE_CFLAGS
4185LIBS=$SAVE_LIBS
4186
067d23c9
KY
4187case "$opsys" in
4188 aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;;
4189
4190 darwin)
4191 ## The -headerpad option tells ld (see man page) to leave room at the
4192 ## end of the header for adding load commands. Needed for dumping.
4193 ## 0x690 is the total size of 30 segment load commands (at 56
4194 ## each); under Cocoa 31 commands are required.
4195 if test "$HAVE_NS" = "yes"; then
4196 libs_nsgui="-framework AppKit"
4197 headerpad_extra=6C8
4198 else
4199 libs_nsgui=
4200 headerpad_extra=690
4201 fi
c8618a06 4202 LD_SWITCH_SYSTEM_TEMACS="-fno-pie -prebind $libs_nsgui -Xlinker -headerpad -Xlinker $headerpad_extra"
b06b1098 4203
067d23c9 4204 ## This is here because src/Makefile.in did some extra fiddling around
47d7532e
PE
4205 ## with LD_SWITCH_SYSTEM. It seems cleaner to put this in
4206 ## LD_SWITCH_SYSTEM_TEMACS instead,
067d23c9
KY
4207 test "x$LD_SWITCH_SYSTEM" = "x" && test "x$GCC" != "xyes" && \
4208 LD_SWITCH_SYSTEM_TEMACS="-X $LD_SWITCH_SYSTEM_TEMACS"
4209 ;;
4210
4d5c6349 4211 ## LD_SWITCH_X_SITE_RPATH is a -rpath option saying where to
4737362e
GM
4212 ## find X at run-time.
4213 ## When handled by cpp, this was in LD_SWITCH_SYSTEM. However, at the
4d5c6349 4214 ## point where configure sourced the s/*.h file, LD_SWITCH_X_SITE_RPATH
067d23c9
KY
4215 ## had not yet been defined and was expanded to null. Hence LD_SWITCH_SYSTEM
4216 ## had different values in configure (in ac_link) and src/Makefile.in.
4217 ## It seems clearer therefore to put this piece in LD_SWITCH_SYSTEM_TEMACS.
4d5c6349 4218 gnu*) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_RPATH)" ;;
067d23c9
KY
4219
4220 *) LD_SWITCH_SYSTEM_TEMACS= ;;
4221esac
4222
876da980
PE
4223if test x$ac_enable_profiling != x ; then
4224 case $opsys in
4225 *freebsd | gnu-linux) ;;
4226 *) LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS -pg" ;;
4227 esac
4228fi
4229
067d23c9
KY
4230AC_SUBST(LD_SWITCH_SYSTEM_TEMACS)
4231
17a2cbbd
DC
4232## Common for all window systems
4233if test "$window_system" != "none"; then
067d23c9 4234 AC_DEFINE(HAVE_WINDOW_SYSTEM, 1, [Define if you have a window system.])
17a2cbbd 4235 WINDOW_SYSTEM_OBJ="fontset.o fringe.o image.o"
067d23c9 4236fi
067d23c9 4237
17a2cbbd 4238AC_SUBST(WINDOW_SYSTEM_OBJ)
067d23c9
KY
4239
4240AH_TOP([/* GNU Emacs site configuration template file.
73b0cd50 4241
f0ddbf7b 4242Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2013
73b0cd50 4243 Free Software Foundation, Inc.
067d23c9
KY
4244
4245This file is part of GNU Emacs.
4246
4247GNU Emacs is free software: you can redistribute it and/or modify
4248it under the terms of the GNU General Public License as published by
4249the Free Software Foundation, either version 3 of the License, or
4250(at your option) any later version.
4251
4252GNU Emacs is distributed in the hope that it will be useful,
4253but WITHOUT ANY WARRANTY; without even the implied warranty of
4254MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4255GNU General Public License for more details.
4256
4257You should have received a copy of the GNU General Public License
4258along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
4259
4260
4261/* No code in Emacs #includes config.h twice, but some bits of code
4262 intended to work with other packages as well (like gmalloc.c)
4263 think they can include it as many times as they like. */
4264#ifndef EMACS_CONFIG_H
4265#define EMACS_CONFIG_H
4266])dnl
4267
b429a4ee 4268AH_BOTTOM([#include <conf_post.h>
067d23c9 4269
067d23c9
KY
4270#endif /* EMACS_CONFIG_H */
4271
4272/*
4273Local Variables:
4274mode: c
4275End:
4276*/
4277])dnl
4278
4279#### Report on what we decided to do.
4280#### Report GTK as a toolkit, even if it doesn't use Xt.
4281#### It makes printing result more understandable as using GTK sets
4282#### toolkit_scroll_bars to yes by default.
4283if test "${HAVE_GTK}" = "yes"; then
5fb91e71 4284 USE_X_TOOLKIT="$USE_GTK_TOOLKIT"
067d23c9
KY
4285fi
4286
4287echo "
4288Configured for \`${canonical}'.
4289
4290 Where should the build process find the source code? ${srcdir}
067d23c9
KY
4291 What compiler should emacs be built with? ${CC} ${CFLAGS}
4292 Should Emacs use the GNU version of malloc? ${GNU_MALLOC}${GNU_MALLOC_reason}
4293 Should Emacs use a relocating allocator for buffers? ${REL_ALLOC}
4294 Should Emacs use mmap(2) for buffer allocation? $use_mmap_for_buffers
4295 What window system should Emacs use? ${window_system}
4296 What toolkit should Emacs use? ${USE_X_TOOLKIT}"
4297
4298if test -n "${x_includes}"; then
4299echo " Where do we find X Windows header files? ${x_includes}"
4300else
4301echo " Where do we find X Windows header files? Standard dirs"
4302fi
4303if test -n "${x_libraries}"; then
4304echo " Where do we find X Windows libraries? ${x_libraries}"
4305else
4306echo " Where do we find X Windows libraries? Standard dirs"
4307fi
4308
4309echo " Does Emacs use -lXaw3d? ${HAVE_XAW3D}"
4310echo " Does Emacs use -lXpm? ${HAVE_XPM}"
4311echo " Does Emacs use -ljpeg? ${HAVE_JPEG}"
4312echo " Does Emacs use -ltiff? ${HAVE_TIFF}"
4313echo " Does Emacs use a gif library? ${HAVE_GIF} $LIBGIF"
4314echo " Does Emacs use -lpng? ${HAVE_PNG}"
4315echo " Does Emacs use -lrsvg-2? ${HAVE_RSVG}"
4316echo " Does Emacs use imagemagick? ${HAVE_IMAGEMAGICK}"
4317
4318echo " Does Emacs use -lgpm? ${HAVE_GPM}"
4319echo " Does Emacs use -ldbus? ${HAVE_DBUS}"
4320echo " Does Emacs use -lgconf? ${HAVE_GCONF}"
9851bfc5 4321echo " Does Emacs use GSettings? ${HAVE_GSETTINGS}"
067d23c9 4322echo " Does Emacs use -lselinux? ${HAVE_LIBSELINUX}"
9f77899d 4323echo " Does Emacs use -lgnutls? ${HAVE_GNUTLS}"
067d23c9
KY
4324echo " Does Emacs use -lxml2? ${HAVE_LIBXML2}"
4325
4326echo " Does Emacs use -lfreetype? ${HAVE_FREETYPE}"
4327echo " Does Emacs use -lm17n-flt? ${HAVE_M17N_FLT}"
4328echo " Does Emacs use -lotf? ${HAVE_LIBOTF}"
4329echo " Does Emacs use -lxft? ${HAVE_XFT}"
4330
4331echo " Does Emacs use toolkit scroll bars? ${USE_TOOLKIT_SCROLL_BARS}"
4332echo
4333
5f77c86c
GM
4334if test -n "${EMACSDATA}"; then
4335 echo " Environment variable EMACSDATA set to: $EMACSDATA"
4336fi
4337if test -n "${EMACSDOC}"; then
4338 echo " Environment variable EMACSDOC set to: $EMACSDOC"
4339fi
4340
067d23c9
KY
4341echo
4342
4343if test "$HAVE_NS" = "yes"; then
4344 echo
507ea258 4345 echo "You must run \"${MAKE-make} install\" in order to test the built application.
067d23c9
KY
4346The installed application will go to nextstep/Emacs.app and can be
4347run or moved from there."
4348 if test "$EN_NS_SELF_CONTAINED" = "yes"; then
4349 echo "The application will be fully self-contained."
4350 else
4351 echo "The lisp resources for the application will be installed under ${prefix}.
507ea258 4352You may need to run \"${MAKE-make} install\" with sudo. The application will fail
067d23c9
KY
4353to run if these resources are not installed."
4354 fi
4355 echo
4356fi
4357
badf86af
KB
4358if test "${opsys}" = "cygwin"; then
4359 case `uname -r` in
4360 1.5.*) AC_MSG_WARN([[building Emacs on Cygwin 1.5 is not supported.]])
4361 echo
4362 ;;
4363 esac
4364fi
067d23c9
KY
4365
4366# Remove any trailing slashes in these variables.
4367[test "${prefix}" != NONE &&
4368 prefix=`echo "${prefix}" | sed 's,\([^/]\)/*$,\1,'`
4369test "${exec_prefix}" != NONE &&
4370 exec_prefix=`echo "${exec_prefix}" | sed 's,\([^/]\)/*$,\1,'`]
4371
83da1b55
GM
4372if test "$HAVE_NS" = "yes"; then
4373 if test "$NS_IMPL_GNUSTEP" = yes; then
4374 AC_CONFIG_FILES([nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist:nextstep/templates/Info-gnustep.plist.in \
4375 nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop:nextstep/templates/Emacs.desktop.in])
4376 else
4377 AC_CONFIG_FILES([nextstep/Cocoa/Emacs.base/Contents/Info.plist:nextstep/templates/Info.plist.in \
4378 nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings:nextstep/templates/InfoPlist.strings.in])
4379 fi
4380fi
4381
bdd556a2 4382dnl Obviously there is duplication here wrt $SUBDIR_MAKEFILES.
d0ff0c7d
GM
4383dnl You _can_ use that variable in AC_CONFIG_FILES, so long as any directory
4384dnl using automake (ie lib/) is explicitly listed and not "hidden" in a variable
bdd556a2
GM
4385dnl (else you get "no `Makefile.am' found for any configure output").
4386dnl This will work, but you get a config.status that is not quite right
4387dnl (see http://lists.gnu.org/archive/html/bug-autoconf/2008-08/msg00028.html).
4388dnl That doesn't have any obvious consequences for Emacs, but on the whole
4389dnl it seems better to just live with the duplication.
83da1b55 4390SUBDIR_MAKEFILES="lib/Makefile lib-src/Makefile oldXMenu/Makefile doc/emacs/Makefile doc/misc/Makefile doc/lispintro/Makefile doc/lispref/Makefile src/Makefile lwlib/Makefile lisp/Makefile leim/Makefile nextstep/Makefile"
bdd556a2
GM
4391
4392AC_CONFIG_FILES([Makefile lib/Makefile lib-src/Makefile oldXMenu/Makefile \
4393 doc/emacs/Makefile doc/misc/Makefile doc/lispintro/Makefile \
4394 doc/lispref/Makefile src/Makefile lwlib/Makefile lisp/Makefile \
83da1b55 4395 leim/Makefile nextstep/Makefile])
6c7e099d
GM
4396
4397dnl test/ is not present in release tarfiles.
70716b1d
GM
4398opt_makefile=test/automated/Makefile
4399
3cc53d60 4400if test -f "$srcdir/$opt_makefile.in"; then
70716b1d 4401 SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
bdd556a2
GM
4402 dnl Again, it's best not to use a variable. Though you can add
4403 dnl ", [], [opt_makefile='$opt_makefile']" and it should work.
4404 AC_CONFIG_FILES([test/automated/Makefile])
4405fi
70716b1d 4406
a9f72fc1
GM
4407
4408dnl admin/ may or may not be present.
4409opt_makefile=admin/unidata/Makefile
4410
3cc53d60 4411if test -f "$srcdir/$opt_makefile.in"; then
a9f72fc1
GM
4412 SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
4413 AC_CONFIG_FILES([admin/unidata/Makefile])
4414fi
4415
4416
bdd556a2 4417SUBDIR_MAKEFILES_IN=`echo " ${SUBDIR_MAKEFILES}" | sed -e 's| | $(srcdir)/|g' -e 's|Makefile|Makefile.in|g'`
70716b1d
GM
4418
4419AC_SUBST(SUBDIR_MAKEFILES_IN)
1e8dbdc6
GM
4420
4421dnl Make the necessary directories, if they don't exist.
4422AC_CONFIG_COMMANDS([mkdirs], [
4423for dir in etc lisp ; do
4424 test -d ${dir} || mkdir ${dir}
4425done
4426])
4427
067d23c9
KY
4428dnl You might wonder (I did) why epaths.h is generated by running make,
4429dnl rather than just letting configure generate it from epaths.in.
4430dnl One reason is that the various paths are not fully expanded (see above);
4431dnl eg gamedir=${prefix}/var/games/emacs.
4432dnl Secondly, the GNU Coding standards require that one should be able
4433dnl to run `make prefix=/some/where/else' and override the values set
4434dnl by configure. This also explains the `move-if-change' test and
4435dnl the use of force in the `epaths-force' rule in Makefile.in.
1e8dbdc6 4436AC_CONFIG_COMMANDS([epaths], [
067d23c9 4437echo creating src/epaths.h
8f25abd3 4438${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force
f04940ae 4439], [GCC="$GCC" CPPFLAGS="$CPPFLAGS"])
067d23c9 4440
1e8dbdc6 4441AC_CONFIG_COMMANDS([gdbinit], [
3cc53d60 4442if test ! -f src/.gdbinit && test -f "$srcdir/src/.gdbinit"; then
067d23c9 4443 echo creating src/.gdbinit
75d7aa24 4444 echo "source $srcdir/src/.gdbinit" > src/.gdbinit
067d23c9 4445fi
1e8dbdc6 4446])
067d23c9 4447
1e8dbdc6 4448AC_OUTPUT