Port flexible array members to GCC + valgrind
[emacs.git] / configure.ac
blob9856228d5171757f423963b19b6857a352bf38e1
1 dnl  Autoconf script for GNU Emacs
2 dnl To rebuild the 'configure' script from this, execute the command
3 dnl     autoconf
4 dnl in the directory containing this script.
5 dnl If you changed any AC_DEFINES, also run autoheader.
6 dnl
7 dnl Copyright (C) 1994-1996, 1999-2016 Free Software Foundation, Inc.
8 dnl
9 dnl  This file is part of GNU Emacs.
10 dnl
11 dnl  GNU Emacs is free software: you can redistribute it and/or modify
12 dnl  it under the terms of the GNU General Public License as published by
13 dnl  the Free Software Foundation, either version 3 of the License, or
14 dnl  (at your option) any later version.
15 dnl
16 dnl  GNU Emacs is distributed in the hope that it will be useful,
17 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
18 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 dnl  GNU General Public License for more details.
20 dnl
21 dnl  You should have received a copy of the GNU General Public License
22 dnl  along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
24 AC_PREREQ(2.65)
25 dnl Note this is parsed by (at least) make-dist and lisp/cedet/ede/emacs.el.
26 AC_INIT(GNU Emacs, 25.1.50, bug-gnu-emacs@gnu.org)
28 dnl Set emacs_config_options to the options of 'configure', quoted for the shell,
29 dnl and then quoted again for a C string.  Separate options with spaces.
30 dnl Add some environment variables, if they were passed via the environment
31 dnl rather than on the command-line.
32 emacs_config_options=
33 optsep=
34 dnl This is the documented way to record the args passed to configure,
35 dnl rather than $ac_configure_args.
36 for opt in "$@" CFLAGS CPPFLAGS LDFLAGS; do
37   case $opt in
38     -n | --no-create | --no-recursion)
39       continue ;;
40     CFLAGS | CPPFLAGS | LDFLAGS)
41       eval 'test "${'$opt'+set}" = set' || continue
42       case " $*" in
43         *" $opt="*) continue ;;
44       esac
45       eval opt=$opt=\$$opt ;;
46   esac
48   emacs_shell_specials=$IFS\''"#$&()*;<>?@<:@\\`{|~'
49   case $opt in
50     *[["$emacs_shell_specials"]]*)
51       case $opt in
52         *\'*)
53           emacs_quote_apostrophes="s/'/'\\\\''/g"
54           opt=`AS_ECHO(["$opt"]) | sed "$emacs_quote_apostrophes"` ;;
55       esac
56       opt="'$opt'"
57       case $opt in
58         *[['"\\']]*)
59           emacs_quote_for_c='s/[["\\]]/\\&/g; $!s/$/\\n\\/'
60           opt=`AS_ECHO(["$opt"]) | sed "$emacs_quote_for_c"` ;;
61       esac ;;
62   esac
63   AS_VAR_APPEND([emacs_config_options], ["$optsep$opt"])
64   optsep=' '
65 done
67 AC_CONFIG_HEADERS(src/config.h:src/config.in)
68 AC_CONFIG_SRCDIR(src/lisp.h)
69 AC_CONFIG_AUX_DIR(build-aux)
70 dnl automake 1.13 and later understand this, making -I m4 unnecessary.
71 dnl With older versions this is a no-op.
72 AC_CONFIG_MACRO_DIR(m4)
74 xcsdkdir=
75 AC_CHECK_PROGS(XCRUN, [xcrun])
76 if test -n "$XCRUN"; then
77   if test -z "$MAKE"; then
78     dnl Call the variable MAKE_PROG, not MAKE, to avoid confusion with
79     dnl the usual MAKE variable that 'make' itself uses.
80     AC_CHECK_PROG([MAKE_PROG], [make], [yes])
81     if test -z "$MAKE_PROG"; then
82       MAKE="$XCRUN MAKE"
83       export MAKE
84       xcsdkdir=`$XCRUN --show-sdk-path 2>/dev/null`
85     fi
86   fi
89 dnl GNU Make is required, so don't test for its individual features.
90 am_cv_make_support_nested_variables=yes
91 AC_DEFUN([AC_PROG_MAKE_SET],
92   [SET_MAKE=
93    AC_SUBST([SET_MAKE])])
95 dnl Check for GNU Make and possibly set MAKE before running AM_INIT_AUTOMAKE.
96 [emacs_check_gnu_make ()
98   emacs_makeout=`($1 --version) 2>/dev/null` &&
99   case $emacs_makeout in
100     'GNU Make '3.8[1-9]* | 'GNU Make '3.9[0-9]* | \
101     'GNU Make '3.[1-9][0-9][0-9]* | 'GNU Make '[4-9]* | 'GNU Make '[1-9][0-9]* )
102        ac_path_MAKE_found=:;;
103   esac
105 AC_CACHE_CHECK([for GNU Make], [ac_cv_path_MAKE],
106   [ac_path_MAKE_found=false
107    if test -n "$MAKE"; then
108      emacs_check_gnu_make "$MAKE"
109      ac_cv_path_MAKE=$MAKE
110    else
111      emacs_tried_make=false
112      emacs_tried_gmake=false
113      emacs_tried_gnumake=false
114      AC_PATH_PROGS_FEATURE_CHECK([MAKE], [make gmake gnumake],
115        [[emacs_check_gnu_make "$ac_path_MAKE"
116          if $ac_path_MAKE_found; then
117            # Use the fully-qualified program name only if the basename
118            # would not resolve to it.
119            if eval \$emacs_tried_$ac_prog; then
120              ac_cv_path_MAKE=$ac_path_MAKE
121            else
122              ac_cv_path_MAKE=$ac_prog
123            fi
124          fi
125          eval emacs_tried_$ac_prog=:]])
126    fi])
127 $ac_path_MAKE_found || {
128 AC_MSG_ERROR([[Building Emacs requires GNU Make, at least version 3.81.
129 If you have it installed under another name, configure with 'MAKE=...'.
130 For example, run '$0 MAKE=gnu-make'.]])
132 MAKE=$ac_cv_path_MAKE
133 export MAKE
135 dnl Fairly arbitrary, older versions might work too.
136 AM_INIT_AUTOMAKE(1.11)
138 dnl Canonicalize the configuration name.
139 AC_CANONICAL_HOST
141 case $host in
142  *-mingw*)
144   if test -z "$host_alias"; then
146       # No --host argument was given to 'configure'; therefore $host
147       # was set to a default value based on the build platform.  But
148       # this default value may be wrong if we are building from a
149       # 64-bit MSYS[2] pre-configured to build 32-bit MinGW programs.
150       # Therefore, we'll try to get the right host platform from the
151       # compiler's target.
153       AC_MSG_CHECKING([the compiler's target])
154       if test -z "$CC"; then
155           cc=gcc
156       else
157           cc=$CC
158       fi
159       cc_target=`$cc -v 2>&1 | sed -n 's/Target: //p'`
160       case "$cc_target" in
161           *-*) host=$cc_target
162               ;;
163           "") AC_MSG_ERROR([Impossible to obtain $cc compiler target.
164 Please explicitly provide --host.])
165               ;;
166           *) AC_MSG_WARN([Compiler reported non-standard target.
167 Defaulting to $host.])
168               ;;
169       esac
170       AC_MSG_RESULT([$host])
171   fi
173   . $srcdir/nt/mingw-cfg.site
175   case $srcdir in
176     /* | ?:*)
177       # srcdir is an absolute path.  In this case, force the format
178       # "/c/foo/bar", to simplify later conversions to native Windows
179       # format ("c:/foo/bar").
180       srcdir=`cd "${srcdir}" && pwd -W`
181       # 'eval' pacifies strict POSIX non-MinGW shells (Bug#18612).
182       eval 'srcdir="/${srcdir:0:1}${srcdir:2}"'
183       ;;
184   esac;;
185 esac
187 canonical=$host
188 configuration=${host_alias-${build_alias-$host}}
190 dnl Support for --program-prefix, --program-suffix and
191 dnl --program-transform-name options
192 AC_ARG_PROGRAM
194 dnl It is important that variables on the RHS not be expanded here,
195 dnl hence the single quotes.  This is per the GNU coding standards, see
196 dnl (autoconf) Installation Directory Variables
197 dnl See also epaths.h below.
198 lispdir='${datadir}/emacs/${version}/lisp'
199 standardlisppath='${lispdir}'
200 locallisppath='${datadir}/emacs/${version}/site-lisp:'\
201 '${datadir}/emacs/site-lisp'
202 lisppath='${locallisppath}:${standardlisppath}'
203 etcdir='${datadir}/emacs/${version}/etc'
204 archlibdir='${libexecdir}/emacs/${version}/${configuration}'
205 etcdocdir='${datadir}/emacs/${version}/etc'
206 gamedir='${localstatedir}/games/emacs'
208 dnl Special option to disable the most of other options.
209 AC_ARG_WITH(all,
210 [AS_HELP_STRING([--without-all],
211                 [omit almost all features and build
212                 small executable with minimal dependencies])],
213   [with_features=$withval],
214   [with_features=yes])
216 dnl OPTION_DEFAULT_OFF(NAME, HELP-STRING)
217 dnl Create a new --with option that defaults to being disabled.
218 dnl NAME is the base name of the option.  The shell variable with_NAME
219 dnl   will be set to either the user's value (if the option is
220 dnl   specified; 'yes' for a plain --with-NAME) or to 'no' (if the
221 dnl   option is not specified).  Note that the shell variable name is
222 dnl   constructed as autoconf does, by replacing non-alphanumeric
223 dnl   characters with "_".
224 dnl HELP-STRING is the help text for the option.
225 AC_DEFUN([OPTION_DEFAULT_OFF], [dnl
226   AC_ARG_WITH([$1],[AS_HELP_STRING([--with-$1],[$2])],[],[dnl
227     m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=no])dnl
228 ])dnl
230 dnl OPTION_DEFAULT_ON(NAME, HELP-STRING)
231 dnl Create a new --with option that defaults to $with_features.
232 dnl NAME is the base name of the option.  The shell variable with_NAME
233 dnl   will be set either to 'no' (for a plain --without-NAME) or to
234 dnl   'yes' (if the option is not specified).  Note that the shell
235 dnl   variable name is constructed as autoconf does, by replacing
236 dnl   non-alphanumeric characters with "_".
237 dnl HELP-STRING is the help text for the option.
238 AC_DEFUN([OPTION_DEFAULT_ON], [dnl
239   AC_ARG_WITH([$1],[AS_HELP_STRING([--without-$1],[$2])],[],[dnl
240    m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=$with_features])dnl
241 ])dnl
243 OPTION_DEFAULT_ON([pop],[don't support POP mail retrieval with movemail])
244 if test "$with_pop" = yes; then
245    AC_DEFINE(MAIL_USE_POP)
247 AH_TEMPLATE(MAIL_USE_POP, [Define to support POP mail retrieval.])dnl
249 OPTION_DEFAULT_OFF([kerberos],[support Kerberos-authenticated POP])
250 if test "$with_kerberos" != no; then
251    AC_DEFINE(KERBEROS)
253 AH_TEMPLATE(KERBEROS,
254             [Define to support Kerberos-authenticated POP mail retrieval.])dnl
256 OPTION_DEFAULT_OFF([kerberos5],[support Kerberos version 5 authenticated POP])
257 if test "${with_kerberos5}" != no; then
258   if test "${with_kerberos}" = no; then
259     with_kerberos=yes
260     AC_DEFINE(KERBEROS)
261   fi
262   AC_DEFINE(KERBEROS5, 1, [Define to use Kerberos 5 instead of Kerberos 4.])
265 OPTION_DEFAULT_OFF([hesiod],[support Hesiod to get the POP server host])
266 dnl FIXME hesiod support may not be present, so it seems like an error
267 dnl to define, or at least use, this unconditionally.
268 if test "$with_hesiod" != no; then
269   AC_DEFINE(HESIOD, 1, [Define to support using a Hesiod database to find the POP server.])
272 OPTION_DEFAULT_OFF([mail-unlink],[unlink, rather than empty, mail spool after reading])
273 if test "$with_mail_unlink" != no; then
274    AC_DEFINE(MAIL_UNLINK_SPOOL, 1, [Define to unlink, rather than empty, mail spool after reading.])
277 AC_ARG_WITH([mailhost],[AS_HELP_STRING([--with-mailhost=HOSTNAME],
278     [string giving default POP mail host])],
279     AC_DEFINE_UNQUOTED(MAILHOST, ["$withval"], [String giving fallback POP mail host.]))
281 AC_ARG_WITH([sound],[AS_HELP_STRING([--with-sound=VALUE],
282   [compile with sound support (VALUE one of: yes, alsa, oss, bsd-ossaudio, no;
283 default yes).  Only for GNU/Linux, FreeBSD, NetBSD, MinGW, Cygwin.])],
284   [ case "${withval}" in
285       yes|no|alsa|oss|bsd-ossaudio) val=$withval ;;
286       *) AC_MSG_ERROR(['--with-sound=$withval' is invalid;
287 this option's value should be 'yes', 'no', 'alsa', 'oss', or 'bsd-ossaudio'.])
288       ;;
289     esac
290     with_sound=$val
291   ],
292   [with_sound=$with_features])
294 dnl FIXME currently it is not the last.
295 dnl This should be the last --with option, because --with-x is
296 dnl added later on when we find the file name of X, and it's best to
297 dnl keep them together visually.
298 AC_ARG_WITH([x-toolkit],[AS_HELP_STRING([--with-x-toolkit=KIT],
299  [use an X toolkit (KIT one of: yes or gtk, gtk2, gtk3, lucid or athena, motif, no)])],
300 [         case "${withval}" in
301             y | ye | yes )      val=gtk ;;
302             n | no )            val=no  ;;
303             l | lu | luc | luci | lucid )       val=lucid ;;
304             a | at | ath | athe | athen | athena )      val=athena ;;
305             m | mo | mot | moti | motif )       val=motif ;;
306             g | gt | gtk  )     val=gtk ;;
307             gtk2  )     val=gtk2 ;;
308             gtk3  )     val=gtk3 ;;
309             * )
310 AC_MSG_ERROR(['--with-x-toolkit=$withval' is invalid;
311 this option's value should be 'yes', 'no', 'lucid', 'athena', 'motif', 'gtk',
312 'gtk2' or 'gtk3'.  'yes' and 'gtk' are synonyms.
313 'athena' and 'lucid' are synonyms.])
314             ;;
315           esac
316           with_x_toolkit=$val
319 OPTION_DEFAULT_OFF([wide-int], [prefer wide Emacs integers (typically 62-bit); allows buffer and string size up to 2GB on 32-bit hosts, at the cost of 10% to 30% slowdown of Lisp interpreter and larger memory footprint])
320 if test "$with_wide_int" = yes; then
321   AC_DEFINE([WIDE_EMACS_INT], 1, [Use long long for EMACS_INT if available.])
324 dnl _ON results in a '--without' option in the --help output, so
325 dnl the help text should refer to "don't compile", etc.
326 with_xpm_set=${with_xpm+set}
327 OPTION_DEFAULT_ON([xpm],[don't compile with XPM image support])
328 OPTION_DEFAULT_ON([jpeg],[don't compile with JPEG image support])
329 OPTION_DEFAULT_ON([tiff],[don't compile with TIFF image support])
330 OPTION_DEFAULT_ON([gif],[don't compile with GIF image support])
331 OPTION_DEFAULT_ON([png],[don't compile with PNG image support])
332 OPTION_DEFAULT_ON([rsvg],[don't compile with SVG image support])
333 OPTION_DEFAULT_ON([libsystemd],[don't compile with libsystemd support])
334 OPTION_DEFAULT_OFF([cairo],[compile with Cairo drawing (experimental)])
335 OPTION_DEFAULT_ON([xml2],[don't compile with XML parsing support])
336 OPTION_DEFAULT_ON([imagemagick],[don't compile with ImageMagick image support])
338 OPTION_DEFAULT_ON([xft],[don't use XFT for anti aliased fonts])
339 OPTION_DEFAULT_ON([libotf],[don't use libotf for OpenType font support])
340 OPTION_DEFAULT_ON([m17n-flt],[don't use m17n-flt for text shaping])
342 OPTION_DEFAULT_ON([toolkit-scroll-bars],[don't use Motif or Xaw3d scroll bars])
343 OPTION_DEFAULT_ON([xaw3d],[don't use Xaw3d])
344 OPTION_DEFAULT_ON([xim],[don't use X11 XIM])
345 AC_ARG_WITH([ns],[AS_HELP_STRING([--with-ns],
346 [use Nextstep (OS X Cocoa or GNUstep) windowing system.
347 On by default on Mac OS X.])],[],[with_ns=maybe])
348 OPTION_DEFAULT_OFF([w32], [use native MS Windows GUI in a Cygwin build])
350 OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console])
351 OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support])
352 OPTION_DEFAULT_ON([gconf],[don't compile with GConf support])
353 OPTION_DEFAULT_ON([gsettings],[don't compile with GSettings support])
354 OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support])
355 OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support])
356 OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support])
357 OPTION_DEFAULT_OFF([modules],[compile with dynamic modules support])
359 AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB],
360  [use a file notification library (LIB one of: yes, inotify, kqueue, gfile, w32, no)])],
361  [ case "${withval}" in
362     y | ye | yes )      val=yes ;;
363     n | no )            val=no  ;;
364     i | in | ino | inot | inoti | inotif | inotify )    val=inotify ;;
365     k | kq | kqu | kque | kqueu | kqueue )      val=kqueue ;;
366     g | gf | gfi | gfil | gfile )       val=gfile ;;
367     w | w3 | w32 )      val=w32 ;;
368     * ) AC_MSG_ERROR(['--with-file-notification=$withval' is invalid;
369 this option's value should be 'yes', 'no', 'inotify', 'kqueue', 'gfile' or 'w32'.
370 'yes' is a synonym for 'w32' on MS-Windows, for 'no' on Nextstep,
371 otherwise for the first of 'inotify', 'kqueue' or 'gfile' that is usable.])
372     ;;
373    esac
374    with_file_notification=$val
375  ],
376  [with_file_notification=$with_features])
378 OPTION_DEFAULT_OFF([xwidgets],
379   [enable use of some gtk widgets in Emacs buffers (requires gtk3)])
381 ## For the times when you want to build Emacs but don't have
382 ## a suitable makeinfo, and can live without the manuals.
383 dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html
384 OPTION_DEFAULT_ON([makeinfo],[don't require makeinfo for building manuals])
386 ## This might be a 'configure' arg.
387 AC_SUBST([ACLOCAL_PATH])
389 ## Makefile.in needs the cache file name.
390 AC_SUBST(cache_file)
392 ## This is an option because I do not know if all info/man support
393 ## compressed files, nor how to test if they do so.
394 OPTION_DEFAULT_ON([compress-install],
395   [don't compress some files (.el, .info, etc.) when installing.  Equivalent to:
396 make GZIP_PROG= install])
398 AC_ARG_WITH(gameuser,dnl
399 [AS_HELP_STRING([--with-gameuser=USER_OR_GROUP],
400                 [user for shared game score files.
401                 An argument prefixed by ':' specifies a group instead.])])
402 gameuser=
403 gamegroup=
404 # We don't test if we can actually chown/chgrp here, because configure
405 # may run without root privileges.  lib-src/Makefile.in will handle
406 # any errors due to missing user/group gracefully.
407 case ${with_gameuser} in
408   no) ;;
409   "" | yes) gamegroup=games ;;
410   :*) gamegroup=${with_gameuser#:} ;;
411   *) gameuser=${with_gameuser} ;;
412 esac
414 AC_ARG_WITH([gnustep-conf],dnl
415 [AS_HELP_STRING([--with-gnustep-conf=FILENAME],
416    [name of GNUstep configuration file to use on systems where the command
417     'gnustep-config' does not work; default $GNUSTEP_CONFIG_FILE, or
418     /etc/GNUstep/GNUstep.conf])])
419 test "X${with_gnustep_conf}" != X && test "${with_gnustep_conf}" != yes && \
420   GNUSTEP_CONFIG_FILE="${with_gnustep_conf}"
421 test "X$GNUSTEP_CONFIG_FILE" = "X" && \
422      GNUSTEP_CONFIG_FILE=/etc/GNUstep/GNUstep.conf
424 AC_ARG_ENABLE(ns-self-contained,
425 [AS_HELP_STRING([--disable-ns-self-contained],
426                 [disable self contained build under NeXTstep])],
427    EN_NS_SELF_CONTAINED=$enableval,
428    EN_NS_SELF_CONTAINED=yes)
430 locallisppathset=no
431 AC_ARG_ENABLE(locallisppath,
432 [AS_HELP_STRING([--enable-locallisppath=PATH],
433                 [directories Emacs should search for lisp files specific
434                  to this site])],
435 if test "${enableval}" = "no"; then
436   locallisppath=
437 elif test "${enableval}" != "yes"; then
438   locallisppath=${enableval} locallisppathset=yes
441 AC_ARG_ENABLE(checking,
442 [AS_HELP_STRING([--enable-checking@<:@=LIST@:>@],
443                 [enable expensive run-time checks.  With LIST,
444                  enable only specific categories of checks.
445                  Categories are: all,yes,no.
446                  Flags are: stringbytes, stringoverrun, stringfreelist,
447                  xmallocoverrun, conslist, glyphs])],
448 [ac_checking_flags="${enableval}"],[])
449 IFS="${IFS=     }"; ac_save_IFS="$IFS"; IFS="$IFS,"
450 for check in $ac_checking_flags
452         case $check in
453         # these set all the flags to specific states
454         yes)            ac_enable_checking=1 ;;
455         no)             ac_enable_checking= ;
456                         ac_gc_check_stringbytes= ;
457                         ac_gc_check_string_overrun= ;
458                         ac_gc_check_string_free_list= ;
459                         ac_xmalloc_overrun= ;
460                         ac_gc_check_cons_list= ;
461                         ac_glyphs_debug= ;;
462         all)            ac_enable_checking=1 ;
463                         ac_gc_check_stringbytes=1 ;
464                         ac_gc_check_string_overrun=1 ;
465                         ac_gc_check_string_free_list=1 ;
466                         ac_xmalloc_overrun=1 ;
467                         ac_gc_check_cons_list=1 ;
468                         ac_glyphs_debug=1 ;;
469         # these enable particular checks
470         stringbytes)    ac_gc_check_stringbytes=1 ;;
471         stringoverrun)  ac_gc_check_string_overrun=1 ;;
472         stringfreelist) ac_gc_check_string_free_list=1 ;;
473         xmallocoverrun) ac_xmalloc_overrun=1 ;;
474         conslist)       ac_gc_check_cons_list=1 ;;
475         glyphs)         ac_glyphs_debug=1 ;;
476         *)      AC_MSG_ERROR(unknown check category $check) ;;
477         esac
478 done
479 IFS="$ac_save_IFS"
481 if test x$ac_enable_checking != x ; then
482   AC_DEFINE(ENABLE_CHECKING, 1,
483 [Define to 1 if expensive run-time data type and consistency checks are enabled.])
485 if test x$ac_gc_check_stringbytes != x ; then
486   AC_DEFINE(GC_CHECK_STRING_BYTES, 1,
487 [Define this temporarily to hunt a bug.  If defined, the size of
488    strings is redundantly recorded in sdata structures so that it can
489    be compared to the sizes recorded in Lisp strings.])
491 if test x$ac_gc_check_string_overrun != x ; then
492   AC_DEFINE(GC_CHECK_STRING_OVERRUN, 1,
493 [Define this to check for short string overrun.])
495 if test x$ac_gc_check_string_free_list != x ; then
496   AC_DEFINE(GC_CHECK_STRING_FREE_LIST, 1,
497 [Define this to check the string free list.])
499 if test x$ac_xmalloc_overrun != x ; then
500   AC_DEFINE(XMALLOC_OVERRUN_CHECK, 1,
501 [Define this to check for malloc buffer overrun.])
503 if test x$ac_gc_check_cons_list != x ; then
504   AC_DEFINE(GC_CHECK_CONS_LIST, 1,
505 [Define this to check for errors in cons list.])
507 if test x$ac_glyphs_debug != x ; then
508   AC_DEFINE(GLYPH_DEBUG, 1,
509 [Define this to enable glyphs debugging code.])
512 AC_ARG_ENABLE(check-lisp-object-type,
513 [AS_HELP_STRING([--enable-check-lisp-object-type],
514                 [enable compile time checks for the Lisp_Object data type.
515                 This is useful for development for catching certain types of bugs.])],
516 if test "${enableval}" != "no"; then
517    AC_DEFINE(CHECK_LISP_OBJECT_TYPE, 1,
518    [Define this to enable compile time checks for the Lisp_Object data type.])
522 dnl The name of this option is unfortunate.  It predates, and has no
523 dnl relation to, the "sampling-based elisp profiler" added in 24.3.
524 dnl Actually, it stops it working.
525 dnl http://lists.gnu.org/archive/html/emacs-devel/2012-11/msg00393.html
526 AC_ARG_ENABLE(profiling,
527 [AS_HELP_STRING([--enable-profiling],
528                 [build emacs with low-level, gprof profiling support.
529                 Mainly useful for debugging Emacs itself.  May not work on
530                 all platforms.  Stops profiler.el working.])],
531 [ac_enable_profiling="${enableval}"],[])
532 if test x$ac_enable_profiling != x ; then
533    PROFILING_CFLAGS="-DPROFILING=1 -pg"
534 else
535    PROFILING_CFLAGS=
537 AC_SUBST(PROFILING_CFLAGS)
539 AC_ARG_ENABLE(autodepend,
540 [AS_HELP_STRING([--enable-autodepend],
541                 [automatically generate dependencies to .h-files.
542                  Requires gcc, enabled if found.])],
543 [ac_enable_autodepend="${enableval}"],[ac_enable_autodepend=yes])
545 AC_ARG_ENABLE(gtk-deprecation-warnings,
546 [AS_HELP_STRING([--enable-gtk-deprecation-warnings],
547                 [Show Gtk+/Gdk deprecation warnings for Gtk+ >= 3.0])],
548 [ac_enable_gtk_deprecation_warnings="${enableval}"],[])
550 BUILD_DETAILS=
551 AC_ARG_ENABLE([build-details],
552   [AS_HELP_STRING([--disable-build-details],
553                   [Make the build more deterministic by omitting host
554                    names, time stamps, etc. from the output.])],
555   [test "$enableval" = no && BUILD_DETAILS=--no-build-details])
556 AC_SUBST([BUILD_DETAILS])
558 dnl This used to use changequote, but, apart from 'changequote is evil'
559 dnl per the autoconf manual, we can speed up autoconf somewhat by quoting
560 dnl the great gob of text.  Thus it's not processed for possible expansion.
561 dnl Just make sure the brackets remain balanced.
563 dnl Since Emacs can't find matching pairs of quotes, boundaries are
564 dnl indicated by comments.
565 dnl quotation begins
568 ### If you add support for a new configuration, add code to this
569 ### switch statement to recognize your configuration name and select
570 ### the appropriate opsys.
572 ### As far as handling version numbers on operating systems is
573 ### concerned, make sure things will fail in a fixable way.  If
574 ### /etc/MACHINES doesn't say anything about version numbers, be
575 ### prepared to handle anything reasonably.  If version numbers
576 ### matter, be sure /etc/MACHINES says something about it.
578 opsys='' unported=no
579 case "${canonical}" in
581   ## GNU/Linux and similar ports
582   *-*-linux* )
583     opsys=gnu-linux
584   ;;
586   ## FreeBSD ports
587   *-*-freebsd* )
588     opsys=freebsd
589   ;;
591   ## DragonFly ports
592   *-*-dragonfly* )
593     opsys=dragonfly
594   ;;
596   ## FreeBSD kernel + glibc based userland
597   *-*-kfreebsd*gnu* )
598     opsys=gnu-kfreebsd
599   ;;
601   ## NetBSD ports
602   *-*-netbsd* )
603     opsys=netbsd
604   ;;
606   ## OpenBSD ports
607   *-*-openbsd* | *-*-mirbsd* )
608     opsys=openbsd
609   ;;
611   ## Apple Darwin / Mac OS X
612   *-apple-darwin* )
613     case "${canonical}" in
614       *-apple-darwin[0-9].*) unported=yes ;;
615       i[3456]86-* | x86_64-* )  ;;
616       * )            unported=yes ;;
617     esac
618     opsys=darwin
619     ## FIXME: Find a way to use Fink if available (Bug#11507).
620   ;;
622   ## Chromium Native Client
623   *-nacl )
624     opsys=nacl
625   ;;
627   ## Cygwin ports
628   *-*-cygwin )
629     opsys=cygwin
630   ;;
632   ## HP 9000 series 700 and 800, running HP/UX
633   hppa*-hp-hpux10.2* )
634     opsys=hpux10-20
635   ;;
636   hppa*-hp-hpux1[1-9]* )
637     opsys=hpux11
638     CFLAGS="-D_INCLUDE__STDC_A1_SOURCE $CFLAGS"
639   ;;
641   ## IBM machines
642   rs6000-ibm-aix4.[23]* )
643     opsys=aix4-2
644   ;;
645   powerpc-ibm-aix4.[23]*  )
646     opsys=aix4-2
647   ;;
648   rs6000-ibm-aix[56]* )
649     opsys=aix4-2
650   ;;
651   powerpc-ibm-aix[5-9]* | powerpc-ibm-aix[1-9][0-9]* )
652     opsys=aix4-2
653   ;;
655   ## Suns
656   *-sun-solaris* \
657     | i[3456]86-*-solaris2* | i[3456]86-*-sunos5* \
658     | x86_64-*-solaris2*    | x86_64-*-sunos5*)
659     case "${canonical}" in
660       i[3456]86-*-* )   ;;
661       amd64-*-*|x86_64-*-*) ;;
662       sparc* )          ;;
663       * )               unported=yes ;;
664     esac
665     case "${canonical}" in
666       *-sunos5.[1-9][0-9]* | *-solaris2.[1-9][0-9]* )
667                 opsys=sol2-10
668                 emacs_check_sunpro_c=yes
669                 ;;
670       *-sunos5.[1-5]* | *-solaris2.[1-5]* ) unported=yes ;;
671       ## Note that Emacs 23.1's NEWS said the following would be dropped.
672       *-sunos5.6* | *-solaris2.6* )
673                 opsys=sol2-6
674                 RANLIB="ar -ts"
675                 ;;
676       ## 5.7 EOL Aug 2008, 5.8 EOL Mar 2012.
677       *-sunos5.[7-9]* | *-solaris2.[7-9]* )
678                 opsys=sol2-6
679                 emacs_check_sunpro_c=yes
680                 ;;
681     esac
682     ## Watch out for a compiler that we know will not work.
683     case "${canonical}" in
684      *-solaris* | *-sunos5* )
685                 if [ "x$CC" = x/usr/ucb/cc ]; then
686                   ## /usr/ucb/cc doesn't work;
687                   ## we should find some other compiler that does work.
688                   unset CC
689                 fi
690                 ;;
691       *) ;;
692     esac
693   ;;
695   ## Intel 386 machines where we don't care about the manufacturer.
696   i[3456]86-*-* )
697     case "${canonical}" in
698       *-darwin* )               opsys=darwin ;;
699       *-mingw* )
700                 opsys=mingw32
701                 # MinGW overrides and adds some system headers in nt/inc.
702                 GCC_TEST_OPTIONS="-I $srcdir/nt/inc"
703                 ;;
704       *-sysv4.2uw* )            opsys=unixware ;;
705       *-sysv5uw* )              opsys=unixware ;;
706       *-sysv5OpenUNIX* )        opsys=unixware ;;
707       ## Otherwise, we'll fall through to the generic opsys code at the bottom.
708     esac
709   ;;
711   # MinGW64
712   x86_64-*-* )
713     case "${canonical}" in
714       *-mingw* )
715                 opsys=mingw32
716                 # MinGW overrides and adds some system headers in nt/inc.
717                 GCC_TEST_OPTIONS="-I $srcdir/nt/inc"
718                 ;;
719       ## Otherwise, we'll fall through to the generic opsys code at the bottom.
720     esac
721   ;;
723   * )
724     unported=yes
725   ;;
726 esac
728 ### If the code above didn't choose an operating system, just choose
729 ### an operating system based on the configuration name.  You really
730 ### only want to use this when you have no idea what the right
731 ### operating system is; if you know what operating systems a machine
732 ### runs, it's cleaner to make it explicit in the case statement
733 ### above.
734 if test x"${opsys}" = x; then
735   case "${canonical}" in
736     *-gnu* )                            opsys=gnu ;;
737     * )
738       unported=yes
739     ;;
740   esac
744 dnl quotation ends
746 if test $unported = yes; then
747   AC_MSG_ERROR([Emacs does not support '${canonical}' systems.
748 If you think it should, please send a report to ${PACKAGE_BUGREPORT}.
749 Check 'etc/MACHINES' for recognized configuration names.])
752 #### Choose a compiler.
754 dnl Don't bother to test for C89.
755 AC_DEFUN([_AC_PROG_CC_C89], [$2])
757 dnl Sets GCC=yes if using gcc.
758 AC_PROG_CC([gcc cc cl clang "$XCRUN gcc" "$XCRUN clang"])
759 if test -n "$XCRUN"; then
760   AC_CHECK_PROGS(AR, [ar "$XCRUN ar"])
761   test -n "$AR" && export AR
764 dnl Emacs needs C99 or later.
765 gl_PROG_CC_C99
767 AM_PROG_CC_C_O
769 if test x$GCC = xyes; then
770   test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
773 dnl This is used in lib/Makefile.am to use nt/gnulib.mk, the
774 dnl alternative to lib/gnulib.mk, so as to avoid generating header files
775 dnl that clash with MinGW.
776 AM_CONDITIONAL([BUILDING_FOR_WINDOWSNT], [test "x$opsys" = "xmingw32"])
778 # Skip gnulib's tests for flexible array members, as Emacs assumes C99.
779 AC_DEFUN([AC_C_FLEXIBLE_ARRAY_MEMBER])
780 # Avoid gnulib's tests for -lcrypto, so that there's no static dependency on it.
781 AC_DEFUN([gl_CRYPTO_CHECK])
782 # Avoid gnulib's tests for HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW,
783 # as we don't use them.
784 AC_DEFUN([gl_FCNTL_O_FLAGS])
785 # Avoid gnulib's test for pthread_sigmask.
786 funcs=
787 for func in $ac_func_list; do
788   test $func = pthread_sigmask || AS_VAR_APPEND([funcs], [" $func"])
789 done
790 ac_func_list=$funcs
791 # Use the system putenv even if it lacks GNU features, as we don't need them,
792 # and the gnulib replacement runs afoul of a FreeBSD 10.1 bug; see Bug#19874.
793 AC_CHECK_FUNCS_ONCE([putenv])
794 AC_DEFUN([gl_FUNC_PUTENV],
795   [test "$ac_cv_func_putenv" = yes || REPLACE_PUTENV=1])
797 # Initialize gnulib right after choosing the compiler.
798 dnl Amongst other things, this sets AR and ARFLAGS.
799 gl_EARLY
801 if test "$ac_test_CFLAGS" != set; then
802   # It's helpful to have C macros available to GDB, so prefer -g3 to -g
803   # if -g3 works and the user does not specify CFLAGS.
804   # This test must follow gl_EARLY; otherwise AC_LINK_IFELSE complains.
805   case $CFLAGS in
806     '-g')
807       emacs_g3_CFLAGS='-g3';;
808     '-g -O2')
809       emacs_g3_CFLAGS='-g3 -O2';;
810     *)
811       emacs_g3_CFLAGS='';;
812   esac
813   if test -n "$emacs_g3_CFLAGS"; then
814     emacs_save_CFLAGS=$CFLAGS
815     CFLAGS=$emacs_g3_CFLAGS
816     AC_CACHE_CHECK([whether $CC accepts $emacs_g3_CFLAGS],
817       [emacs_cv_prog_cc_g3],
818       [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
819          [emacs_cv_prog_cc_g3=yes],
820          [emacs_cv_prog_cc_g3=no])])
821     if test $emacs_cv_prog_cc_g3 != yes; then
822       CFLAGS=$emacs_save_CFLAGS
823     fi
824     if test $opsys = mingw32; then
825       CFLAGS="$CFLAGS -gdwarf-2"
826     fi
827   fi
829   case $CFLAGS in
830     *-O*) ;;
831     *)
832       # No optimization flag was inferred for this non-GCC compiler.
833       # Try -O.  This is needed for xlc on AIX; see Bug#14258.
834       emacs_save_CFLAGS=$CFLAGS
835       test -z "$CFLAGS" || CFLAGS="$CFLAGS "
836       CFLAGS=${CFLAGS}-O
837       AC_CACHE_CHECK([whether $CC accepts -O],
838         [emacs_cv_prog_cc_o],
839         [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
840            [emacs_cv_prog_cc_o=yes],
841            [emacs_cv_prog_cc_o=no])])
842       if test $emacs_cv_prog_cc_o != yes; then
843         CFLAGS=$emacs_save_CFLAGS
844       fi ;;
845   esac
848 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
849 # ---------------------------------------------------------------------------
850 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
851 # Otherwise, run RUN-IF-NOT-FOUND.
852 AC_DEFUN([gl_GCC_VERSION_IFELSE],
853   [AC_PREPROC_IFELSE(
854     [AC_LANG_PROGRAM(
855       [[
856 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
857 /* ok */
858 #else
859 # error "your version of gcc is older than $1.$2"
860 #endif
861       ]]),
862     ], [$3], [$4])
863   ]
866 AC_ARG_ENABLE([gcc-warnings],
867   [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
868                   [control generation of GCC warnings.  The TYPE 'yes'
869                    means to fail if any warnings are issued; 'warn-only'
870                    means issue warnings without failing (default for
871                    developer builds); 'no' means disable warnings
872                    (default for non-developer builds).])],
873   [case $enableval in
874      yes|no|warn-only) ;;
875      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
876    esac
877    gl_gcc_warnings=$enableval],
878   [# By default, use 'warn-only' if it looks like the invoker of 'configure'
879    # is a developer as opposed to a builder.  This is most likely true
880    # if GCC is recent enough and there is a .git directory or file;
881    # however, if there is also a .tarball-version file it is probably
882    # just a release imported into Git for patch management.
883    gl_gcc_warnings=no
884    if test -e "$srcdir"/.git && test ! -f "$srcdir"/.tarball-version; then
885      gl_GCC_VERSION_IFELSE([5], [3], [gl_gcc_warnings=warn-only])]
886    fi
889 # clang is unduly picky about some things.
890 AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang],
891   [AC_COMPILE_IFELSE(
892      [AC_LANG_PROGRAM([[
893           #ifndef __clang__
894             error "not clang";
895           #endif
896         ]])],
897      [emacs_cv_clang=yes],
898      [emacs_cv_clang=no])])
900 # When compiling with GCC, prefer -isystem to -I when including system
901 # include files, to avoid generating useless diagnostics for the files.
902 AS_IF([test $gl_gcc_warnings = no],
904   isystem='-I'
905   AS_IF([test "$emacs_cv_clang" = yes],
906    [
907      # Turn off some warnings if supported.
908      gl_WARN_ADD([-Wno-switch])
909      gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
910      gl_WARN_ADD([-Wno-pointer-sign])
911      gl_WARN_ADD([-Wno-string-plus-int])
912      gl_WARN_ADD([-Wno-unknown-attributes])
913    ])
914  ],[
915   isystem='-isystem '
917   # This, $nw, is the list of warnings we disable.
918   nw=
920   case $with_x_toolkit in
921     lucid | athena | motif)
922        # Old toolkits mishandle 'const'.
923        nw="$nw -Wwrite-strings"
924        ;;
925   esac
926   AS_IF([test $gl_gcc_warnings = yes],
927     [gl_WARN_ADD([-Werror], [WERROR_CFLAGS])])
928   AC_SUBST([WERROR_CFLAGS])
930   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
931   nw="$nw -Woverlength-strings"     # Not a problem these days
932   nw="$nw -Wformat-nonliteral"      # we do this a lot
933   nw="$nw -Wvla"                    # Emacs uses <vla.h>.
934   nw="$nw -Wswitch-default"         # Too many warnings for now
935   nw="$nw -Wunused-const-variable=2" # lisp.h declares const objects.
936   nw="$nw -Winline"                 # OK to ignore 'inline'
937   nw="$nw -Wstrict-overflow"        # OK to optimize assuming that
938                                     # signed overflow has undefined behavior
939   nw="$nw -Wsync-nand"              # irrelevant here, and provokes ObjC warning
940   nw="$nw -Wunsafe-loop-optimizations" # OK to suppress unsafe optimizations
941   nw="$nw -Wbad-function-cast"      # These casts are no worse than others.
943   # Emacs doesn't care about shadowing; see
944   # <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
945   nw="$nw -Wshadow"
947   # Emacs's use of alloca inhibits protecting the stack.
948   nw="$nw -Wstack-protector"
950   # Emacs's use of partly-const functions such as Fgnutls_available_p
951   # make this option problematic.
952   nw="$nw -Wsuggest-attribute=const"
954   # Emacs's use of partly-pure functions such as CHECK_TYPE make this
955   # option problematic.
956   nw="$nw -Wsuggest-attribute=pure"
958   # This part is merely for shortening the command line,
959   # since -Wall implies -Wswitch.
960   nw="$nw -Wswitch"
962   # This part is merely for shortening the command line,
963   # since -Wno-FOO needs to be added below regardless.
964   nw="$nw -Wmissing-field-initializers"
965   nw="$nw -Wtype-limits"
966   nw="$nw -Wunused-parameter"
968   if test $emacs_cv_clang = yes; then
969     nw="$nw -Wcast-align"
970   fi
972   # This causes too much noise in the MinGW build
973   if test $opsys = mingw32; then
974     nw="$nw -Wpointer-sign"
975   fi
977   gl_MANYWARN_ALL_GCC([ws])
978   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
979   for w in $ws; do
980     gl_WARN_ADD([$w])
981   done
982   gl_WARN_ADD([-Wredundant-decls])     # Prefer this, as we don't use Bison.
983   gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
984   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
985   gl_WARN_ADD([-Wno-type-limits])      # Too many warnings for now
986   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
987   gl_WARN_ADD([-Wno-format-nonliteral])
989   # More things that clang is unduly picky about.
990   if test $emacs_cv_clang = yes; then
991     gl_WARN_ADD([-Wno-tautological-compare])
992     gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
993   fi
995   # This causes too much noise in the MinGW build
996   if test $opsys = mingw32; then
997     gl_WARN_ADD([-Wno-pointer-sign])
998   fi
1000   AC_DEFINE([GCC_LINT], [1], [Define to 1 if --enable-gcc-warnings.])
1001   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
1002   AH_VERBATIM([GNULIB_PORTCHECK_FORTIFY_SOURCE],
1003   [/* Enable compile-time and run-time bounds-checking, and some warnings,
1004       without upsetting glibc 2.15+. */
1005    #if (defined GNULIB_PORTCHECK && !defined _FORTIFY_SOURCE \
1006         && defined __OPTIMIZE__ && __OPTIMIZE__)
1007    # define _FORTIFY_SOURCE 2
1008    #endif
1009   ])
1011   # We use a slightly smaller set of warning options for lib/.
1012   # Remove the following and save the result in GNULIB_WARN_CFLAGS.
1013   nw=
1014   nw="$nw -Wunused-macros"
1016   gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
1017   AC_SUBST([GNULIB_WARN_CFLAGS])
1018  ])
1020 edit_cflags="
1021   s,///*,/,g
1022   s/^/ /
1023   s/ -I/ $isystem/g
1024   s/^ //
1027 AC_ARG_ENABLE(link-time-optimization,
1028 [AS_HELP_STRING([--enable-link-time-optimization],
1029                 [build emacs with link-time optimization.
1030                  This requires GCC 4.5.0 or later, or clang.
1031                  (Note that clang support is experimental - see INSTALL.)
1032                  It also makes Emacs harder to debug, and when we tried it
1033                  with GCC 4.9.0 x86-64 it made Emacs slower, so it's not
1034                  recommended for typical use.])],
1035 if test "${enableval}" != "no"; then
1036    ac_lto_supported=no
1037    if test $emacs_cv_clang = yes; then
1038       AC_MSG_CHECKING([whether link-time optimization is supported by clang])
1039       GOLD_PLUGIN=`$CC -print-file-name=LLVMgold.so 2>/dev/null`
1040       if test -x "$GOLD_PLUGIN"; then
1041          LTO="-flto"
1042       fi
1043    elif test x$GCC = xyes; then
1044       AC_MSG_CHECKING([whether link-time optimization is supported by gcc])
1045       CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
1046       if test x$CPUS != x; then
1047          LTO="-flto=$CPUS"
1048       else
1049          LTO="-flto"
1050       fi
1051    else
1052       AC_MSG_ERROR([Link-time optimization is not supported with your compiler.])
1053    fi
1054    if test -z "$LTO"; then
1055       ac_lto_supported=no
1056    else
1057       old_CFLAGS=$CFLAGS
1058       CFLAGS="$CFLAGS $LTO"
1059       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1060          [ac_lto_supported=yes], [ac_lto_supported=no])
1061          CFLAGS="$old_CFLAGS"
1062    fi
1063    AC_MSG_RESULT([$ac_lto_supported])
1064    if test "$ac_lto_supported" = "yes"; then
1065       CFLAGS="$CFLAGS $LTO"
1066       if test x$emacs_cv_clang = xyes; then
1067          AC_MSG_WARN([Please read INSTALL before using link-time optimization with clang])
1068          # WARNING: 'ar --plugin ...' doesn't work without
1069          # command, so plugin name is appended to ARFLAGS.
1070          ARFLAGS="cru --plugin $GOLD_PLUGIN"
1071          RANLIB="$RANLIB --plugin $GOLD_PLUGIN"
1072       else
1073         dnl The following is needed for GCC 4.9.0.  The GCC 4.9.0 release notes
1074         dnl suggest that instead of -ffat-lto-objects we should use gcc-ar and
1075         dnl gcc-ranlib in place of ar and ranlib, but gcc-ar makes /usr/bin/ar
1076         dnl dump core on Fedora 20, so play it safe for now.
1077         gl_COMPILER_OPTION_IF([-ffat-lto-objects],
1078           [CFLAGS="$CFLAGS -ffat-lto-objects"])
1079       fi
1080    fi
1083 dnl Prefer silent make output.  For verbose output, use
1084 dnl 'configure --disable-silent-rules' or 'make V=1' .
1085 AM_SILENT_RULES([yes])
1086 dnl Port to Automake 1.11.
1087 dnl This section can be removed once we assume Automake 1.14 or later.
1088 : ${AM_V=$AM_DEFAULT_VERBOSITY}
1089 : ${AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY}
1090 AC_SUBST([AM_V])
1091 AM_SUBST_NOTMAKE([AM_V])
1092 AC_SUBST([AM_DEFAULT_V])
1093 AM_SUBST_NOTMAKE([AM_DEFAULT_V])
1094 AC_SUBST([AM_DEFAULT_VERBOSITY])
1096 dnl Some other nice autoconf tests.
1097 dnl These are commented out, since gl_EARLY and/or Autoconf already does them.
1098 dnl AC_PROG_INSTALL
1099 dnl AC_PROG_MKDIR_P
1100 dnl if test "x$RANLIB" = x; then
1101 dnl   AC_PROG_RANLIB
1102 dnl fi
1105 dnl Sadly, AC_PROG_LN_S is too restrictive.  It also tests whether links
1106 dnl can be made to directories.  This is not relevant for our usage, and
1107 dnl excludes some cases that work fine for us.  Eg MS Windows or files
1108 dnl hosted on AFS, both examples where simple links work, but links to
1109 dnl directories fail.  We use a cut-down version instead.
1110 dnl AC_PROG_LN_S
1112 AC_MSG_CHECKING([whether ln -s works for files in the same directory])
1113 rm -f conf$$ conf$$.file
1115 LN_S_FILEONLY='cp -p'
1117 dnl On MinGW, ensure we will call the MSYS /bin/ln.exe, not some
1118 dnl random program in the current directory.
1119 if (echo >conf$$.file) 2>/dev/null; then
1120   if ln -s conf$$.file conf$$ 2>/dev/null; then
1121     if test "$opsys" = "mingw32"; then
1122       LN_S_FILEONLY='/bin/ln -s'
1123     else
1124       LN_S_FILEONLY='ln -s'
1125     fi
1126   elif ln conf$$.file conf$$ 2>/dev/null; then
1127     if test "$opsys" = "mingw32"; then
1128       LN_S_FILEONLY=/bin/ln
1129     else
1130       LN_S_FILEONLY=ln
1131     fi
1132   fi
1135 rm -f conf$$ conf$$.file
1137 if test "$LN_S_FILEONLY" = "ln -s"; then
1138    AC_MSG_RESULT([yes])
1139 else
1140    AC_MSG_RESULT([no, using $LN_S_FILEONLY])
1143 AC_SUBST(LN_S_FILEONLY)
1146 dnl AC_PROG_LN_S sets LN_S to 'cp -pR' for MinGW, on the premise that 'ln'
1147 dnl doesn't support links to directories, as in "ln file dir".  But that
1148 dnl use is non-portable, and OTOH MinGW wants to use hard links for Emacs
1149 dnl executables at "make install" time.
1150 dnl See http://lists.gnu.org/archive/html/emacs-devel/2013-04/msg00475.html
1151 dnl for more details.
1152 if test "$opsys" = "mingw32"; then
1153   LN_S="/bin/ln"
1156 dnl On some Debian versions, "install-info" prints irritating messages
1157 dnl "This is not dpkg install-info anymore, but GNU install-info"
1158 dnl if called via an absolute file name.
1159 dnl Use the entirely-identical-but-quieter ginstall-info instead if present.
1160 dnl Sadly some people may have an old ginstall-info installed on
1161 dnl non-Debian systems, so we can't use this.
1162 dnl AC_PATH_PROGS(INSTALL_INFO, [ginstall-info install-info], :,
1163 dnl   $PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin)
1165 AC_PATH_PROG(INSTALL_INFO, install-info, :,
1166   $PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin)
1167 dnl Don't use GZIP, which is used by gzip for additional parameters.
1168 AC_PATH_PROG(GZIP_PROG, gzip)
1170 test $with_compress_install != yes && test -n "$GZIP_PROG" && \
1171    GZIP_PROG=" # $GZIP_PROG # (disabled by configure --without-compress-install)"
1173 PAXCTL_dumped=
1174 PAXCTL_notdumped=
1175 if test $opsys = gnu-linux; then
1176   if test "${SETFATTR+set}" != set; then
1177     AC_CACHE_CHECK([for setfattr],
1178       [emacs_cv_prog_setfattr],
1179       [touch conftest.tmp
1180        if (setfattr -n user.pax.flags conftest.tmp) >/dev/null 2>&1; then
1181          emacs_cv_prog_setfattr=yes
1182        else
1183          emacs_cv_prog_setfattr=no
1184        fi])
1185     if test "$emacs_cv_prog_setfattr" = yes; then
1186       PAXCTL_notdumped='$(SETFATTR) -n user.pax.flags -v er'
1187       SETFATTR=setfattr
1188     else
1189       SETFATTR=
1190     fi
1191     rm -f conftest.tmp
1192     AC_SUBST([SETFATTR])
1193   fi
1195 case $opsys,$PAXCTL_notdumped in
1196   gnu-linux, | netbsd,)
1197     AC_PATH_PROG([PAXCTL], [paxctl], [],
1198       [$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin])
1199     if test -n "$PAXCTL"; then
1200       if test "$opsys" = netbsd; then
1201         PAXCTL_dumped='$(PAXCTL) +a'
1202         PAXCTL_notdumped=$PAXCTL_dumped
1203       else
1204         AC_MSG_CHECKING([whether binaries have a PT_PAX_FLAGS header])
1205         AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
1206           [if $PAXCTL -v conftest$EXEEXT >/dev/null 2>&1; then
1207              AC_MSG_RESULT([yes])
1208            else
1209              AC_MSG_RESULT([no])
1210              PAXCTL=
1211            fi])
1212         if test -n "$PAXCTL"; then
1213           PAXCTL_dumped='$(PAXCTL) -zex'
1214           PAXCTL_notdumped='$(PAXCTL) -r'
1215         fi
1216       fi
1217     fi;;
1218 esac
1219 AC_SUBST([PAXCTL_dumped])
1220 AC_SUBST([PAXCTL_notdumped])
1222 ## Need makeinfo >= 4.7 (?) to build the manuals.
1223 if test "$MAKEINFO" != "no"; then
1224   if test "$MAKEINFO" = "${am_missing_run}makeinfo"; then
1225     MAKEINFO=makeinfo
1226   fi
1227   case `($MAKEINFO --version) 2>/dev/null` in
1228     *' (GNU texinfo) '4.[[7-9]]* | \
1229     *' (GNU texinfo) '4.[[1-9][0-9]]* | \
1230     *' (GNU texinfo) '[[5-9]]* | \
1231     *' (GNU texinfo) '[[1-9][0-9]]* ) ;;
1232     *) MAKEINFO=no;;
1233   esac
1236 ## Makeinfo is unusual.  For a released Emacs, the manuals are
1237 ## pre-built, and not deleted by the normal clean rules.  makeinfo is
1238 ## therefore in the category of "special tools" not normally required, which
1239 ## configure does not have to check for (eg autoconf itself).
1240 ## In a repository checkout on the other hand, the manuals are not included.
1241 ## So makeinfo is a requirement to build from the repository, and configure
1242 ## should test for it as it does for any other build requirement.
1243 ## We use the presence of $srcdir/info/emacs to distinguish a release,
1244 ## with pre-built manuals, from a repository checkout.
1245 HAVE_MAKEINFO=yes
1247 if test "$MAKEINFO" = "no"; then
1248   MAKEINFO=makeinfo
1249   if test "x${with_makeinfo}" = "xno"; then
1250     HAVE_MAKEINFO=no
1251   elif test ! -e "$srcdir/info/emacs" && test ! -e "$srcdir/info/emacs.info"; then
1252     AC_MSG_ERROR( [You do not seem to have makeinfo >= 4.7, and your
1253 source tree does not seem to have pre-built manuals in the 'info' directory.
1254 Either install a suitable version of makeinfo, or re-run configure
1255 with the '--without-makeinfo' option to build without the manuals.] )
1256   fi
1258 AC_SUBST(HAVE_MAKEINFO)
1260 if test $opsys = mingw32; then
1261    DOCMISC_W32=efaq-w32
1262 else
1263    DOCMISC_W32=
1265 AC_SUBST(DOCMISC_W32)
1267 dnl Add our options to ac_link now, after it is set up.
1269 if test x$GCC = xyes; then
1270   test "x$GCC_LINK_TEST_OPTIONS" != x && \
1271     ac_link="$ac_link $GCC_LINK_TEST_OPTIONS"
1272 else
1273   test "x$NON_GCC_LINK_TEST_OPTIONS" != x && \
1274     ac_link="$ac_link $NON_GCC_LINK_TEST_OPTIONS"
1277 dnl We need -znocombreloc if we're using a relatively recent GNU ld.
1278 dnl If we can link with the flag, it shouldn't do any harm anyhow.
1279 dnl Treat GCC specially since it just gives a non-fatal 'unrecognized option'
1280 dnl if not built to support GNU ld.
1282 dnl For a long time, -znocombreloc was added to LDFLAGS rather than
1283 dnl LD_SWITCH_SYSTEM_TEMACS.  That is:
1284 dnl * inappropriate, as LDFLAGS is a user option but this is essential.
1285 dnl   Eg "make LDFLAGS=... all" could run into problems,
1286 dnl   http://bugs.debian.org/684788
1287 dnl * unnecessary, since temacs is the only thing that actually needs it.
1288 dnl   Indeed this is where it was originally, prior to:
1289 dnl   http://lists.gnu.org/archive/html/emacs-pretest-bug/2004-03/msg00170.html
1290 late_LDFLAGS="$LDFLAGS"
1291 if test x$GCC = xyes; then
1292   LDFLAGS_NOCOMBRELOC="-Wl,-znocombreloc"
1293 else
1294   LDFLAGS_NOCOMBRELOC="-znocombreloc"
1297 LDFLAGS="$LDFLAGS $LDFLAGS_NOCOMBRELOC"
1299 AC_MSG_CHECKING([for -znocombreloc])
1300 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
1301   [AC_MSG_RESULT(yes)],
1302   LDFLAGS_NOCOMBRELOC=
1303   [AC_MSG_RESULT(no)])
1305 LDFLAGS="$late_LDFLAGS"
1307 AC_CACHE_CHECK([whether addresses are sanitized],
1308   [emacs_cv_sanitize_address],
1309   [AC_COMPILE_IFELSE(
1310      [AC_LANG_PROGRAM(
1311         [[#ifndef __has_feature
1312           #define __has_feature(f) 0
1313           #endif
1314           #if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
1315           #else
1316            error "Addresses are not sanitized.";
1317           #endif
1318         ]])],
1319      [emacs_cv_sanitize_address=yes],
1320      [emacs_cv_sanitize_address=no])])
1322 dnl The function dump-emacs will not be defined and temacs will do
1323 dnl (load "loadup") automatically unless told otherwise.
1324 test "x$CANNOT_DUMP" = "x" && CANNOT_DUMP=no
1325 case "$opsys" in
1326   nacl) CANNOT_DUMP=yes ;;
1327 esac
1329 if test "$CANNOT_DUMP" = "yes"; then
1330   AC_DEFINE(CANNOT_DUMP, 1, [Define if Emacs cannot be dumped on your system.])
1331 elif test "$emacs_cv_sanitize_address" = yes; then
1332   AC_MSG_WARN([[Addresses are sanitized; suggest CANNOT_DUMP=yes]])
1335 AC_SUBST(CANNOT_DUMP)
1338 UNEXEC_OBJ=unexelf.o
1339 case "$opsys" in
1340   # MSDOS uses unexcoff.o
1341   aix4-2)
1342    UNEXEC_OBJ=unexaix.o
1343    ;;
1344   cygwin)
1345    UNEXEC_OBJ=unexcw.o
1346    ;;
1347   darwin)
1348    UNEXEC_OBJ=unexmacosx.o
1349    ;;
1350   hpux10-20 | hpux11)
1351    UNEXEC_OBJ=unexhp9k800.o
1352    ;;
1353   mingw32)
1354    UNEXEC_OBJ=unexw32.o
1355    ;;
1356   sol2-10)
1357    # Use the Solaris dldump() function, called from unexsol.c, to dump
1358    # emacs, instead of the generic ELF dump code found in unexelf.c.
1359    # The resulting binary has a complete symbol table, and is better
1360    # for debugging and other observability tools (debuggers, pstack, etc).
1361    #
1362    # If you encounter a problem using dldump(), please consider sending
1363    # a message to the OpenSolaris tools-linking mailing list:
1364    #      http://mail.opensolaris.org/mailman/listinfo/tools-linking
1365    #
1366    # It is likely that dldump() works with older Solaris too, but this has
1367    # not been tested, so for now this change is for Solaris 10 or newer.
1368    UNEXEC_OBJ=unexsol.o
1369    ;;
1370 esac
1372 LD_SWITCH_SYSTEM=
1373 case "$opsys" in
1374   freebsd|dragonfly)
1375    ## Let 'ld' find image libs and similar things in /usr/local/lib.
1376    ## The system compiler, GCC, has apparently been modified to not
1377    ## look there, contrary to what a stock GCC would do.
1378 ### It's not our place to do this.  See bug#10313#17.
1379 ###   LD_SWITCH_SYSTEM=-L/usr/local/lib
1380       :
1381    ;;
1383   gnu-linux)
1384    ## cpp test was "ifdef __mips__", but presumably this is equivalent...
1385    case $host_cpu in mips*) LD_SWITCH_SYSTEM="-G 0";; esac
1386    ;;
1388   netbsd)
1389 ### It's not our place to do this.  See bug#10313#17.
1390 ###   LD_SWITCH_SYSTEM="-Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib"
1391       :
1392    ;;
1394   openbsd)
1395    ## Han Boetes <han@boetes.org> says this is necessary,
1396    ## otherwise Emacs dumps core on elf systems.
1397    LD_SWITCH_SYSTEM="-Z"
1398    ;;
1399 esac
1400 AC_SUBST(LD_SWITCH_SYSTEM)
1402 ac_link="$ac_link $LD_SWITCH_SYSTEM"
1404 ## This setting of LD_SWITCH_SYSTEM references LD_SWITCH_X_SITE_RPATH,
1405 ## which has not been defined yet.  When this was handled with cpp,
1406 ## it was expanded to null when configure sourced the s/*.h file.
1407 ## Thus LD_SWITCH_SYSTEM had different values in configure and the Makefiles.
1408 ## FIXME it would be cleaner to put this in LD_SWITCH_SYSTEM_TEMACS
1409 ## (or somesuch), but because it is supposed to go at the _front_
1410 ## of LD_SWITCH_SYSTEM, we cannot do that in exactly the same way.
1411 ## Compare with the gnu-linux case below, which added to the end
1412 ## of LD_SWITCH_SYSTEM, and so can instead go at the front of
1413 ## LD_SWITCH_SYSTEM_TEMACS.
1414 case "$opsys" in
1415   netbsd|openbsd)
1416    LD_SWITCH_SYSTEM="\$(LD_SWITCH_X_SITE_RPATH) $LD_SWITCH_SYSTEM" ;;
1417 esac
1420 C_SWITCH_MACHINE=
1421 case $canonical in
1422  alpha*)
1423   AC_CHECK_DECL([__ELF__])
1424   if test "$ac_cv_have_decl___ELF__" = "yes"; then
1425     ## With ELF, make sure that all common symbols get allocated to in the
1426     ## data section.  Otherwise, the dump of temacs may miss variables in
1427     ## the shared library that have been initialized.  For example, with
1428     ## GNU libc, __malloc_initialized would normally be resolved to the
1429     ## shared library's .bss section, which is fatal.
1430     if test "x$GCC" = "xyes"; then
1431       C_SWITCH_MACHINE="-fno-common"
1432     else
1433       AC_MSG_ERROR([Non-GCC compilers are not supported.])
1434     fi
1435   else
1436       dnl This was the unexalpha.c case.  Removed in 24.1, 2010-07-24,
1437       dnl albeit under the mistaken assumption that said file
1438       dnl was no longer used.
1439       AC_MSG_ERROR([Non-ELF systems are not supported since Emacs 24.1.])
1440   fi
1441   ;;
1442 esac
1443 AC_SUBST(C_SWITCH_MACHINE)
1445 AC_SUBST(UNEXEC_OBJ)
1447 C_SWITCH_SYSTEM=
1448 ## Some programs in src produce warnings saying certain subprograms
1449 ## are too complex and need a MAXMEM value greater than 2000 for
1450 ## additional optimization.  --nils@exp-math.uni-essen.de
1451 test "$opsys" = "aix4.2" && test "x$GCC" != "xyes" && \
1452   C_SWITCH_SYSTEM="-ma -qmaxmem=4000"
1453 if test "$opsys" = "mingw32"; then
1454   case "$canonical" in
1455     x86_64-*-mingw*) C_SWITCH_SYSTEM="-mtune=generic" ;;
1456     *) C_SWITCH_SYSTEM="-mtune=pentium4" ;;
1457   esac
1459 ## gnu-linux might need -D_BSD_SOURCE on old libc5 systems.
1460 ## It is redundant in glibc2, since we define _GNU_SOURCE.
1461 AC_SUBST(C_SWITCH_SYSTEM)
1464 LIBS_SYSTEM=
1465 case "$opsys" in
1466   ## IBM's X11R5 uses -lIM and -liconv in AIX 3.2.2.
1467   aix4-2) LIBS_SYSTEM="-lrts -lIM -liconv" ;;
1469   freebsd|dragonfly) LIBS_SYSTEM="-lutil" ;;
1471   hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
1473   sol2*) LIBS_SYSTEM="-lsocket -lnsl" ;;
1475   ## Motif needs -lgen.
1476   unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;;
1477 esac
1479 AC_SUBST(LIBS_SYSTEM)
1481 ### Make sure subsequent tests use flags consistent with the build flags.
1483 if test x"${OVERRIDE_CPPFLAGS}" != x; then
1484   CPPFLAGS="${OVERRIDE_CPPFLAGS}"
1485 else
1486   CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
1489 # Suppress obsolescent Autoconf test for size_t; Emacs assumes C99 or better.
1490 AC_DEFUN([AC_TYPE_SIZE_T])
1491 # Likewise for obsolescent test for uid_t, gid_t; Emacs assumes them.
1492 AC_DEFUN([AC_TYPE_UID_T])
1494 # sqrt and other floating-point functions such as fmod and frexp
1495 # are found in -lm on many systems.
1496 OLD_LIBS=$LIBS
1497 AC_SEARCH_LIBS([sqrt], [m])
1498 if test "X$LIBS" = "X$OLD_LIBS"; then
1499   LIB_MATH=
1500 else
1501   LIB_MATH=$ac_cv_search_sqrt
1503 LIBS=$OLD_LIBS
1505 dnl Current possibilities handled by sed (aix4-2 -> aix,
1506 dnl gnu-linux -> gnu/linux, etc.):
1507 dnl gnu, gnu/linux, gnu/kfreebsd, aix, cygwin, darwin, hpux.
1508 dnl And special cases: berkeley-unix, usg-unix-v, ms-dos, windows-nt.
1509 SYSTEM_TYPE=`echo $opsys | sed -e 's/[[0-9]].*//' -e 's|-|/|'`
1511 case $opsys in
1512   cygwin )
1513     LIB_MATH=
1514     ;;
1515   darwin )
1516     ## Adding -lm confuses the dynamic linker, so omit it.
1517     LIB_MATH=
1518     ;;
1519   freebsd | dragonfly )
1520     SYSTEM_TYPE=berkeley-unix
1521     ;;
1522   gnu-linux | gnu-kfreebsd )
1523     ;;
1524   hpux10-20 | hpux11 )
1525     ;;
1526   mingw32 )
1527     LIB_MATH=
1528     SYSTEM_TYPE=windows-nt
1529     ;;
1530   dnl NB this may be adjusted below.
1531   netbsd | openbsd )
1532     SYSTEM_TYPE=berkeley-unix
1533     ;;
1535   sol2* | unixware )
1536     SYSTEM_TYPE=usg-unix-v
1537     ;;
1539 esac
1541 AC_SUBST(LIB_MATH)
1542 AC_DEFINE_UNQUOTED(SYSTEM_TYPE, "$SYSTEM_TYPE",
1543   [The type of system you are compiling for; sets 'system-type'.])
1546 pre_PKG_CONFIG_CFLAGS=$CFLAGS
1547 pre_PKG_CONFIG_LIBS=$LIBS
1549 PKG_PROG_PKG_CONFIG(0.9.0)
1551 dnl EMACS_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4)
1552 dnl acts like PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4,
1553 dnl HAVE_GSTUFF=yes, HAVE_GSTUFF=no) -- see pkg-config man page --
1554 dnl except that it postprocesses CFLAGS as needed for --enable-gcc-warnings.
1555 dnl EMACS_CHECK_MODULES accepts optional 3rd and 4th arguments that
1556 dnl can take the place of the default HAVE_GSTUFF=yes and HAVE_GSTUFF=no
1557 dnl actions.
1558 AC_DEFUN([EMACS_CHECK_MODULES],
1559   [PKG_CHECK_MODULES([$1], [$2],
1560      [$1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"`
1561       m4_default([$3], [HAVE_$1=yes])],
1562      [m4_default([$4], [HAVE_$1=no])])])
1564 HAVE_SOUND=no
1565 if test "${with_sound}" != "no"; then
1566   # Sound support for GNU/Linux, the free BSDs, MinGW, and Cygwin.
1567   AC_CHECK_HEADERS([machine/soundcard.h sys/soundcard.h soundcard.h mmsystem.h],
1568     have_sound_header=yes, [], [
1569     #ifdef __MINGW32__
1570     #define WIN32_LEAN_AND_MEAN
1571     #include <windows.h>
1572     #endif
1573     ])
1574   test "${with_sound}" = "oss" && test "${have_sound_header}" != "yes" && \
1575     AC_MSG_ERROR([OSS sound support requested but not found.])
1577   if test "${with_sound}" = "bsd-ossaudio" || test "${with_sound}" = "yes"; then
1578     # Emulation library used on NetBSD.
1579     AC_CHECK_LIB(ossaudio, _oss_ioctl, LIBSOUND=-lossaudio, LIBSOUND=)
1580     test "${with_sound}" = "bsd-ossaudio" && test -z "$LIBSOUND" && \
1581       AC_MSG_ERROR([bsd-ossaudio sound support requested but not found.])
1582     dnl FIXME?  If we did find ossaudio, should we set with_sound=bsd-ossaudio?
1583     dnl Traditionally, we go on to check for alsa too.  Does that make sense?
1584   fi
1585   AC_SUBST(LIBSOUND)
1587   if test "${with_sound}" = "alsa" || test "${with_sound}" = "yes"; then
1588     ALSA_REQUIRED=1.0.0
1589     ALSA_MODULES="alsa >= $ALSA_REQUIRED"
1590     EMACS_CHECK_MODULES([ALSA], [$ALSA_MODULES])
1591     if test $HAVE_ALSA = yes; then
1592       SAVE_CFLAGS="$CFLAGS"
1593       SAVE_LIBS="$LIBS"
1594       CFLAGS="$ALSA_CFLAGS $CFLAGS"
1595       LIBS="$ALSA_LIBS $LIBS"
1596       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <asoundlib.h>]], [[snd_lib_error_set_handler (0);]])],
1597                       emacs_alsa_normal=yes,
1598                     emacs_alsa_normal=no)
1599       if test "$emacs_alsa_normal" != yes; then
1600         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <alsa/asoundlib.h>]],
1601                        [[snd_lib_error_set_handler (0);]])],
1602                        emacs_alsa_subdir=yes,
1603                      emacs_alsa_subdir=no)
1604         if test "$emacs_alsa_subdir" != yes; then
1605           AC_MSG_ERROR([pkg-config found alsa, but it does not compile.  See config.log for error messages.])
1606         fi
1607         ALSA_CFLAGS="$ALSA_CFLAGS -DALSA_SUBDIR_INCLUDE"
1608       fi
1610       CFLAGS="$SAVE_CFLAGS"
1611       LIBS="$SAVE_LIBS"
1612       LIBSOUND="$LIBSOUND $ALSA_LIBS"
1613       CFLAGS_SOUND="$CFLAGS_SOUND $ALSA_CFLAGS"
1614       AC_DEFINE(HAVE_ALSA, 1, [Define to 1 if ALSA is available.])
1615     elif test "${with_sound}" = "alsa"; then
1616       AC_MSG_ERROR([ALSA sound support requested but not found.])
1617     fi
1618   fi                            dnl with_sound = alsa|yes
1620   dnl Define HAVE_SOUND if we have sound support.  We know it works and
1621   dnl compiles only on the specified platforms.  For others, it
1622   dnl probably doesn't make sense to try.
1623   dnl FIXME So surely we should bypass this whole section if not using
1624   dnl one of these platforms?
1625   if test x$have_sound_header = xyes || test $HAVE_ALSA = yes; then
1626      case "$opsys" in
1627        dnl defined __FreeBSD__ || defined __NetBSD__ || defined __linux__
1628        dnl Adjust the --with-sound help text if you change this.
1629        gnu-linux|freebsd|netbsd|mingw32|cygwin)
1630          AC_DEFINE(HAVE_SOUND, 1, [Define to 1 if you have sound support.])
1631          HAVE_SOUND=yes
1632          ;;
1633      esac
1634   fi
1636   AC_SUBST(CFLAGS_SOUND)
1639 dnl checks for header files
1640 AC_CHECK_HEADERS_ONCE(
1641   malloc.h
1642   sys/systeminfo.h
1643   sys/sysinfo.h
1644   coff.h pty.h
1645   sys/resource.h
1646   sys/utsname.h pwd.h utmp.h util.h)
1648 AC_CACHE_CHECK([for ADDR_NO_RANDOMIZE],
1649   [emacs_cv_personality_addr_no_randomize],
1650   [AC_COMPILE_IFELSE(
1651      [AC_LANG_PROGRAM([[#include <sys/personality.h>]],
1652                       [[personality (personality (0xffffffff)
1653                                      | ADDR_NO_RANDOMIZE)]])],
1654      [emacs_cv_personality_addr_no_randomize=yes],
1655      [emacs_cv_personality_addr_no_randomize=no])])
1656 if test $emacs_cv_personality_addr_no_randomize = yes; then
1657   AC_DEFINE([HAVE_PERSONALITY_ADDR_NO_RANDOMIZE], [1],
1658             [Define to 1 if personality flag ADDR_NO_RANDOMIZE exists.])
1661 # Note that Solaris has sys/sysinfo.h which defines struct
1662 # sysinfo as well.  To make sure that we're using GNU/Linux
1663 # sysinfo, we explicitly set one of its fields.
1664 if test "$ac_cv_header_sys_sysinfo_h" = yes; then
1665   AC_MSG_CHECKING([if Linux sysinfo may be used])
1666   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/sysinfo.h>]],
1667                                      [[struct sysinfo si;
1668                                        si.totalram = 0;
1669                                        sysinfo (&si)]])],
1670     emacs_cv_linux_sysinfo=yes, emacs_cv_linux_sysinfo=no)
1671   AC_MSG_RESULT($emacs_cv_linux_sysinfo)
1672   if test $emacs_cv_linux_sysinfo = yes; then
1673     AC_DEFINE([HAVE_LINUX_SYSINFO], 1, [Define to 1 if you have Linux sysinfo function.])
1674     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/sysinfo.h>]],
1675                                        [[struct sysinfo si; return si.mem_unit]])],
1676       AC_DEFINE(LINUX_SYSINFO_UNIT, 1,
1677                 [Define to 1 if Linux sysinfo sizes are in multiples of mem_unit bytes.]))
1678   fi
1681 dnl On Solaris 8 there's a compilation warning for term.h because
1682 dnl it doesn't define 'bool'.
1683 AC_CHECK_HEADERS(term.h, , , -)
1684 AC_HEADER_TIME
1685 AC_CHECK_DECLS([sys_siglist], [], [], [[#include <signal.h>
1686                                       ]])
1687 if test $ac_cv_have_decl_sys_siglist != yes; then
1688   # For Tru64, at least:
1689   AC_CHECK_DECLS([__sys_siglist], [], [], [[#include <signal.h>
1690                                           ]])
1692 AC_HEADER_SYS_WAIT
1694 AC_CHECK_HEADERS_ONCE(sys/socket.h)
1695 AC_CHECK_HEADERS(net/if.h, , , [AC_INCLUDES_DEFAULT
1696 #if HAVE_SYS_SOCKET_H
1697 #include <sys/socket.h>
1698 #endif])
1699 AC_CHECK_HEADERS(ifaddrs.h, , , [AC_INCLUDES_DEFAULT
1700 #if HAVE_SYS_SOCKET_H
1701 #include <sys/socket.h>
1702 #endif])
1703 AC_CHECK_HEADERS(net/if_dl.h, , , [AC_INCLUDES_DEFAULT
1704 #if HAVE_SYS_SOCKET_H
1705 #include <sys/socket.h>
1706 #endif])
1708 dnl checks for structure members
1709 AC_CHECK_MEMBERS([struct ifreq.ifr_flags, struct ifreq.ifr_hwaddr,
1710                   struct ifreq.ifr_netmask, struct ifreq.ifr_broadaddr,
1711                   struct ifreq.ifr_addr,
1712                   struct ifreq.ifr_addr.sa_len], , ,
1713                  [AC_INCLUDES_DEFAULT
1714 #if HAVE_SYS_SOCKET_H
1715 #include <sys/socket.h>
1716 #endif
1717 #if HAVE_NET_IF_H
1718 #include <net/if.h>
1719 #endif])
1721 dnl Check for endianness.
1722 dnl AC_C_BIGENDIAN is done by gnulib.
1724 dnl check for Make feature
1726 AUTO_DEPEND=no
1727 dnl check if we have GCC and autodepend is on.
1728 if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
1729    AC_MSG_CHECKING([whether gcc understands -MMD -MF])
1730    SAVE_CFLAGS="$CFLAGS"
1731    CFLAGS="$CFLAGS -MMD -MF deps.d -MP"
1732    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], , ac_enable_autodepend=no)
1733    CFLAGS="$SAVE_CFLAGS"
1734    test -f deps.d || ac_enable_autodepend=no
1735    rm -rf deps.d
1736    AC_MSG_RESULT([$ac_enable_autodepend])
1737    if test $ac_enable_autodepend = yes; then
1738       AUTO_DEPEND=yes
1739    fi
1741 AC_SUBST(AUTO_DEPEND)
1743 dnl checks for operating system services
1744 AC_SYS_LONG_FILE_NAMES
1746 #### Choose a window system.
1748 ## We leave window_system equal to none if
1749 ## we end up building without one.  Any new window system should
1750 ## set window_system to an appropriate value and add objects to
1751 ## window-system-specific substs.
1753 window_system=none
1754 AC_PATH_X
1755 if test "$no_x" != yes; then
1756   window_system=x11
1759 LD_SWITCH_X_SITE_RPATH=
1760 if test "${x_libraries}" != NONE; then
1761   if test -n "${x_libraries}"; then
1762     LD_SWITCH_X_SITE=-L`AS_ECHO(["$x_libraries"]) | sed -e 's/:/ -L/g'`
1763     LD_SWITCH_X_SITE_RPATH=-Wl,-rpath,`
1764       AS_ECHO(["$x_libraries"]) | sed -e 's/:/ -Wl,-rpath,/g'
1765     `
1766   fi
1767   x_default_search_path=""
1768   x_search_path=${x_libraries}
1769   if test -z "${x_search_path}"; then
1770     x_search_path=/usr/lib
1771   fi
1772   for x_library in `AS_ECHO(["$x_search_path:"]) | \
1773                     sed -e "s/:/ /g" -e p -e "s:/lib[[^ /]]* :/share :g"`; do
1774     x_search_path="\
1775 ${x_library}/X11/%L/%T/%N%C%S:\
1776 ${x_library}/X11/%l/%T/%N%C%S:\
1777 ${x_library}/X11/%T/%N%C%S:\
1778 ${x_library}/X11/%L/%T/%N%S:\
1779 ${x_library}/X11/%l/%T/%N%S:\
1780 ${x_library}/X11/%T/%N%S"
1781     if test x"${x_default_search_path}" = x; then
1782       x_default_search_path=${x_search_path}
1783     else
1784       x_default_search_path="${x_search_path}:${x_default_search_path}"
1785     fi
1786   done
1788 AC_SUBST(LD_SWITCH_X_SITE_RPATH)
1790 if test "${x_includes}" != NONE && test -n "${x_includes}"; then
1791   C_SWITCH_X_SITE=$isystem`AS_ECHO(["$x_includes"]) | sed -e "s/:/ $isystem/g"`
1794 if test x"${x_includes}" = x; then
1795   bitmapdir=/usr/include/X11/bitmaps
1796 else
1797   # accumulate include directories that have X11 bitmap subdirectories
1798   bmd_acc=
1799   for bmd in `AS_ECHO(["$x_includes"]) | sed -e 's/:/ /g'`; do
1800     if test -d "${bmd}/X11/bitmaps"; then
1801       bmd_acc="${bmd_acc}:${bmd}/X11/bitmaps"
1802     fi
1803     if test -d "${bmd}/bitmaps"; then
1804       bmd_acc="${bmd_acc}:${bmd}/bitmaps"
1805     fi
1806   done
1807   bitmapdir=${bmd_acc#:}
1810 test "${with_ns}" = maybe && test "${opsys}" != darwin && with_ns=no
1811 HAVE_NS=no
1812 NS_GNUSTEP_CONFIG=no
1813 NS_IMPL_COCOA=no
1814 NS_IMPL_GNUSTEP=no
1815 tmp_CPPFLAGS="$CPPFLAGS"
1816 tmp_CFLAGS="$CFLAGS"
1817 CPPFLAGS="$CPPFLAGS -x objective-c"
1818 CFLAGS="$CFLAGS -x objective-c"
1819 GNU_OBJC_CFLAGS=
1820 LIBS_GNUSTEP=
1821 if test "${with_ns}" != no; then
1822   if test "${opsys}" = darwin; then
1823      NS_IMPL_COCOA=yes
1824      ns_appdir=`pwd`/nextstep/Emacs.app
1825      ns_appbindir=${ns_appdir}/Contents/MacOS
1826      ns_appresdir=${ns_appdir}/Contents/Resources
1827      ns_appsrc=Cocoa/Emacs.base
1828      ns_fontfile=macfont.o
1829   elif flags=$( (gnustep-config --objc-flags) 2>/dev/null); then
1830      NS_IMPL_GNUSTEP=yes
1831      NS_GNUSTEP_CONFIG=yes
1832      GNU_OBJC_CFLAGS=$flags
1833      LIBS_GNUSTEP=$(gnustep-config --gui-libs) || exit
1834   elif test -f $GNUSTEP_CONFIG_FILE; then
1835      NS_IMPL_GNUSTEP=yes
1836      dnl FIXME sourcing this several times in subshells seems inefficient.
1837      GNUSTEP_SYSTEM_HEADERS=$(
1838        . $GNUSTEP_CONFIG_FILE
1839        AS_ECHO(["$GNUSTEP_SYSTEM_HEADERS"])
1840      )
1841      GNUSTEP_SYSTEM_LIBRARIES=$(
1842        . $GNUSTEP_CONFIG_FILE
1843        AS_ECHO(["$GNUSTEP_SYSTEM_LIBRARIES"])
1844      )
1845      dnl I seemed to need these as well with GNUstep-startup 0.25.
1846      GNUSTEP_LOCAL_HEADERS=$(
1847        . $GNUSTEP_CONFIG_FILE
1848        AS_ECHO(["$GNUSTEP_LOCAL_HEADERS"])
1849      )
1850      GNUSTEP_LOCAL_LIBRARIES=$(
1851        . $GNUSTEP_CONFIG_FILE
1852        AS_ECHO(["$GNUSTEP_LOCAL_LIBRARIES"])
1853      )
1854      test "x${GNUSTEP_LOCAL_HEADERS}" != "x" && \
1855        GNUSTEP_LOCAL_HEADERS="-I${GNUSTEP_LOCAL_HEADERS}"
1856      test "x${GNUSTEP_LOCAL_LIBRARIES}" != "x" && \
1857        GNUSTEP_LOCAL_LIBRARIES="-L${GNUSTEP_LOCAL_LIBRARIES}"
1858      CPPFLAGS="$CPPFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
1859      CFLAGS="$CFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
1860      LDFLAGS="$LDFLAGS -L${GNUSTEP_SYSTEM_LIBRARIES} ${GNUSTEP_LOCAL_LIBRARIES}"
1861      LIBS_GNUSTEP="-lgnustep-gui -lgnustep-base -lobjc -lpthread"
1862      dnl GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS to 0 or 1.
1863      dnl If they had chosen to either define it or not, we could have
1864      dnl just used AC_CHECK_DECL here.
1865      AC_CACHE_CHECK(if GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS,
1866        emacs_cv_objc_exceptions,
1867 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <GNUstepBase/GSConfig.h>]],
1868 [[#if defined BASE_NATIVE_OBJC_EXCEPTIONS && BASE_NATIVE_OBJC_EXCEPTIONS > 0
1870 #else
1871 fail;
1872 #endif]])], emacs_cv_objc_exceptions=yes, emacs_cv_objc_exceptions=no ) )
1873      if test $emacs_cv_objc_exceptions = yes; then
1874        dnl _NATIVE_OBJC_EXCEPTIONS is used by the GNUstep headers.
1875        AC_DEFINE(_NATIVE_OBJC_EXCEPTIONS, 1,
1876          [Define if GNUstep uses ObjC exceptions.])
1877        GNU_OBJC_CFLAGS="-fobjc-exceptions"
1878      fi
1879   fi
1880   if test $NS_IMPL_GNUSTEP = yes; then
1881      ns_appdir=`pwd`/nextstep/Emacs.app
1882      ns_appbindir=${ns_appdir}
1883      ns_appresdir=${ns_appdir}/Resources
1884      ns_appsrc=GNUstep/Emacs.base
1885      ns_fontfile=nsfont.o
1886   fi
1888   dnl This is only used while we test the NS headers, it gets reset below.
1889   CPPFLAGS="$CPPFLAGS $GNU_OBJC_CFLAGS"
1890   CFLAGS="$CFLAGS $GNU_OBJC_CFLAGS"
1892   AC_CHECK_HEADER([AppKit/AppKit.h], [HAVE_NS=yes],
1893                   [AC_MSG_ERROR([The include files (AppKit/AppKit.h etc) that
1894 are required for a Nextstep build are missing or cannot be compiled.
1895 Either fix this, or re-configure with the option '--without-ns'.])])
1897   macfont_file=""
1898   if test "${NS_IMPL_COCOA}" = "yes"; then
1899     AC_MSG_CHECKING([for OSX 10.6 or newer])
1900     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>],
1901                                      [
1902 #ifdef MAC_OS_X_VERSION_MAX_ALLOWED
1903 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
1904  ; /* OK */
1905 #else
1906  error "OSX 10.6 or newer required";
1907 #endif
1908 #endif
1909                     ])],
1910                     ns_osx_have_106=yes,
1911                     ns_osx_have_106=no)
1912     AC_MSG_RESULT([$ns_osx_have_106])
1914     if test $ns_osx_have_106 = no; then
1915        AC_MSG_ERROR([OSX 10.6 or newer is required]);
1916     fi
1917   fi
1920 AC_SUBST(LIBS_GNUSTEP)
1922 INSTALL_ARCH_INDEP_EXTRA=install-etc
1923 ns_self_contained=no
1924 NS_OBJ=
1925 NS_OBJC_OBJ=
1926 if test "${HAVE_NS}" = yes; then
1927   if test "$with_toolkit_scroll_bars" = "no"; then
1928     AC_MSG_ERROR([Non-toolkit scroll bars are not implemented for Nextstep.])
1929   fi
1931   window_system=nextstep
1932   # set up packaging dirs
1933   if test "${EN_NS_SELF_CONTAINED}" = yes; then
1934      ns_self_contained=yes
1935      prefix=${ns_appresdir}
1936      exec_prefix=${ns_appbindir}
1937      dnl This one isn't really used, only archlibdir is.
1938      libexecdir="\${ns_appbindir}/libexec"
1939      archlibdir="\${ns_appbindir}/libexec"
1940      etcdocdir="\${ns_appresdir}/etc"
1941      etcdir="\${ns_appresdir}/etc"
1942      dnl FIXME maybe set datarootdir instead.
1943      dnl That would also get applications, icons, man.
1944      infodir="\${ns_appresdir}/info"
1945      mandir="\${ns_appresdir}/man"
1946      lispdir="\${ns_appresdir}/lisp"
1947      test "$locallisppathset" = no && locallisppath=""
1948      INSTALL_ARCH_INDEP_EXTRA=
1949   fi
1951   NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o $ns_fontfile"
1953 CFLAGS="$tmp_CFLAGS"
1954 CPPFLAGS="$tmp_CPPFLAGS"
1955 AC_SUBST(INSTALL_ARCH_INDEP_EXTRA)
1956 AC_SUBST(ns_self_contained)
1957 AC_SUBST(NS_OBJ)
1958 AC_SUBST(NS_OBJC_OBJ)
1960 HAVE_W32=no
1961 W32_OBJ=
1962 W32_LIBS=
1963 EMACSRES=
1964 CLIENTRES=
1965 CLIENTW=
1966 W32_RES_LINK=
1967 EMACS_MANIFEST=
1968 UPDATE_MANIFEST=
1969 if test "${with_w32}" != no; then
1970   case "${opsys}" in
1971     cygwin)
1972       AC_CHECK_HEADER([windows.h], [HAVE_W32=yes],
1973              [AC_MSG_ERROR(['--with-w32' was specified, but windows.h
1974                    cannot be found.])])
1975     ;;
1976     mingw32)
1977     ## Using --with-w32 with MinGW is a no-op, but we allow it.
1978     ;;
1979     *)
1980       AC_MSG_ERROR([Using w32 with an autotools build is only supported for Cygwin and MinGW32.])
1981     ;;
1982   esac
1985 if test "${opsys}" = "mingw32"; then
1986   AC_MSG_CHECKING([whether Windows API headers are recent enough])
1987   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1988      #include <windows.h>
1989      #include <usp10.h>]],
1990    [[PIMAGE_NT_HEADERS pHeader;
1991      PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader)]])],
1992    [emacs_cv_w32api=yes
1993     HAVE_W32=yes],
1994    emacs_cv_w32api=no)
1995   AC_MSG_RESULT($emacs_cv_w32api)
1996   if test "${emacs_cv_w32api}" = "no"; then
1997     AC_MSG_ERROR([the Windows API headers are too old to support this build.])
1998   fi
2001 FIRSTFILE_OBJ=
2002 NTDIR=
2003 LIBS_ECLIENT=
2004 LIB_WSOCK32=
2005 NTLIB=
2006 CM_OBJ="cm.o"
2007 XARGS_LIMIT=
2008 if test "${HAVE_W32}" = "yes"; then
2009   AC_DEFINE(HAVE_NTGUI, 1, [Define to use native MS Windows GUI.])
2010   if test "$with_toolkit_scroll_bars" = "no"; then
2011     AC_MSG_ERROR([Non-toolkit scroll bars are not implemented for w32 build.])
2012   fi
2013   AC_CHECK_TOOL(WINDRES, [windres],
2014                 [AC_MSG_ERROR([No resource compiler found.])])
2015   W32_OBJ="w32fns.o w32menu.o w32reg.o w32font.o w32term.o"
2016   W32_OBJ="$W32_OBJ w32xfns.o w32select.o w32uniscribe.o"
2017   EMACSRES="emacs.res"
2018   case "$canonical" in
2019     x86_64-*-*) EMACS_MANIFEST="emacs-x64.manifest" ;;
2020     *) EMACS_MANIFEST="emacs-x86.manifest" ;;
2021   esac
2022   dnl Construct something of the form "24,4,0,0" with 4 components.
2023   comma_version=`echo "${PACKAGE_VERSION}.0.0" | sed -e 's/\./,/g' -e 's/^\([[^,]]*,[[^,]]*,[[^,]]*,[[^,]]*\).*/\1/'`
2025   comma_space_version=`echo "$comma_version" | sed 's/,/, /g'`
2026   AC_SUBST(comma_version)
2027   AC_SUBST(comma_space_version)
2028   AC_CONFIG_FILES([nt/emacs.rc nt/emacsclient.rc])
2029   if test "${opsys}" = "cygwin"; then
2030     W32_LIBS="$W32_LIBS -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32"
2031     W32_LIBS="$W32_LIBS -lusp10 -lcomctl32 -lwinspool"
2032     # Tell the linker that emacs.res is an object (which we compile from
2033     # the rc file), not a linker script.
2034     W32_RES_LINK="-Wl,emacs.res"
2035   else
2036     UPDATE_MANIFEST=update-game-score.exe.manifest
2037     W32_OBJ="$W32_OBJ w32.o w32console.o w32heap.o w32inevt.o w32proc.o"
2038     W32_LIBS="$W32_LIBS -lwinmm -lgdi32 -lcomdlg32"
2039     W32_LIBS="$W32_LIBS -lmpr -lwinspool -lole32 -lcomctl32 -lusp10"
2040     W32_RES_LINK="\$(EMACSRES)"
2041     CLIENTRES="emacsclient.res"
2042     CLIENTW="emacsclientw\$(EXEEXT)"
2043     FIRSTFILE_OBJ=firstfile.o
2044     NTDIR=nt
2045     CM_OBJ=
2046     LIBS_ECLIENT="-lcomctl32"
2047     LIB_WSOCK32="-lwsock32"
2048     NTLIB="ntlib.$ac_objext"
2049     XARGS_LIMIT="-s 10000"
2050   fi
2052 AC_SUBST(W32_OBJ)
2053 AC_SUBST(W32_LIBS)
2054 AC_SUBST(EMACSRES)
2055 AC_SUBST(EMACS_MANIFEST)
2056 AC_SUBST(UPDATE_MANIFEST)
2057 AC_SUBST(CLIENTRES)
2058 AC_SUBST(CLIENTW)
2059 AC_SUBST(W32_RES_LINK)
2060 AC_SUBST(FIRSTFILE_OBJ)
2061 AC_SUBST(NTDIR)
2062 AC_SUBST(CM_OBJ)
2063 AC_SUBST(LIBS_ECLIENT)
2064 AC_SUBST(LIB_WSOCK32)
2065 AC_SUBST(NTLIB)
2066 AC_SUBST(XARGS_LIMIT)
2068 if test "${HAVE_W32}" = "yes"; then
2069   window_system=w32
2070   with_xft=no
2073 ## $window_system is now set to the window system we will
2074 ## ultimately use.
2076 term_header=
2077 HAVE_X_WINDOWS=no
2078 HAVE_X11=no
2079 USE_X_TOOLKIT=none
2081 case "${window_system}" in
2082   x11 )
2083     HAVE_X_WINDOWS=yes
2084     HAVE_X11=yes
2085     term_header=xterm.h
2086     case "${with_x_toolkit}" in
2087       athena | lucid ) USE_X_TOOLKIT=LUCID ;;
2088       motif ) USE_X_TOOLKIT=MOTIF ;;
2089       gtk ) with_gtk=yes
2090             term_header=gtkutil.h
2091 dnl Don't set this for GTK.  A lot of tests below assumes Xt when
2092 dnl USE_X_TOOLKIT is set.
2093             USE_X_TOOLKIT=none ;;
2094       gtk2 ) with_gtk2=yes
2095              term_header=gtkutil.h
2096              USE_X_TOOLKIT=none ;;
2097       gtk3 ) with_gtk3=yes
2098              term_header=gtkutil.h
2099              USE_X_TOOLKIT=none ;;
2100       no ) USE_X_TOOLKIT=none ;;
2101 dnl If user did not say whether to use a toolkit, make this decision later:
2102 dnl use the toolkit if we have gtk, or X11R5 or newer.
2103       * ) USE_X_TOOLKIT=maybe ;;
2104     esac
2105   ;;
2106   nextstep )
2107     term_header=nsterm.h
2108   ;;
2109   w32 )
2110     term_header=w32term.h
2111   ;;
2112 esac
2114 if test "$window_system" = none && test "X$with_x" != "Xno"; then
2115    AC_CHECK_PROG(HAVE_XSERVER, X, true, false)
2116    if test "$HAVE_XSERVER" = true ||
2117       test -n "$DISPLAY" ||
2118       {
2119         for emacs_libX11 in /usr/lib/libX11.*; do break; done
2120         test "$emacs_libX11" != '/usr/lib/libX11.*'
2121       }
2122    then
2123         AC_MSG_ERROR([You seem to be running X, but no X development libraries
2124 were found.  You should install the relevant development files for X
2125 and for the toolkit you want, such as Gtk+ or Motif.  Also make
2126 sure you have development files for image handling, i.e.
2127 tiff, gif, jpeg, png and xpm.
2128 If you are sure you want Emacs compiled without X window support, pass
2129   --without-x
2130 to configure.])
2131    fi
2134 # Does the opsystem file prohibit the use of the GNU malloc?
2135 # Assume not, until told otherwise.
2136 GNU_MALLOC=yes
2138 AC_CACHE_CHECK(
2139   [whether malloc is Doug Lea style],
2140   [emacs_cv_var_doug_lea_malloc],
2141   [emacs_cv_var_doug_lea_malloc=no
2142    dnl Hooks do not work with address sanitization.
2143    if test "$emacs_cv_sanitize_address" != yes; then
2144      AC_LINK_IFELSE(
2145        [AC_LANG_PROGRAM(
2146           [[#include <malloc.h>
2147             static void hook (void) {}]],
2148           [[malloc_set_state (malloc_get_state ());
2149             __after_morecore_hook = hook;
2150             __malloc_initialize_hook = hook;]])],
2151        [emacs_cv_var_doug_lea_malloc=yes])
2152    fi])
2153 doug_lea_malloc=$emacs_cv_var_doug_lea_malloc
2155 system_malloc=$emacs_cv_sanitize_address
2157 hybrid_malloc=
2159 case "$opsys" in
2160   ## darwin ld insists on the use of malloc routines in the System framework.
2161   darwin | mingw32 | nacl | sol2-10) system_malloc=yes ;;
2162   cygwin) hybrid_malloc=yes;;
2163 esac
2165 if test "${system_malloc}" != yes && test "${doug_lea_malloc}" != yes \
2166    && test "${UNEXEC_OBJ}" = unexelf.o; then
2167   hybrid_malloc=yes
2170 GMALLOC_OBJ=
2171 HYBRID_MALLOC=
2172 if test "${system_malloc}" = "yes"; then
2173   AC_DEFINE([SYSTEM_MALLOC], 1,
2174     [Define to 1 to use the system memory allocator, even if it is not
2175      Doug Lea style.])
2176   GNU_MALLOC=no
2177   GNU_MALLOC_reason="
2178     (The GNU allocators don't work with this system configuration.)"
2179   VMLIMIT_OBJ=
2180 elif test "$hybrid_malloc" = yes; then
2181   AC_DEFINE(HYBRID_MALLOC, 1,
2182     [Define to use gmalloc before dumping and the system malloc after.])
2183   HYBRID_MALLOC=1
2184   GNU_MALLOC=no
2185   GNU_MALLOC_reason=" (only before dumping)"
2186   GMALLOC_OBJ=gmalloc.o
2187   VMLIMIT_OBJ=
2188 else
2189   test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
2190   VMLIMIT_OBJ=vm-limit.o
2192   AC_CHECK_HEADERS([sys/vlimit.h])
2193   AC_CACHE_CHECK([for data_start], [emacs_cv_data_start],
2194     [AC_LINK_IFELSE(
2195        [AC_LANG_PROGRAM(
2196          [[extern char data_start[]; char ch;]],
2197          [[return data_start < &ch;]])],
2198        [emacs_cv_data_start=yes],
2199        [emacs_cv_data_start=no])])
2200   if test $emacs_cv_data_start = yes; then
2201     AC_DEFINE([HAVE_DATA_START], 1,
2202       [Define to 1 if data_start is the address of the start
2203        of the main data segment.])
2204   fi
2206 AC_SUBST([HYBRID_MALLOC])
2207 AM_CONDITIONAL([HYBRID_MALLOC_LIB], [test -n "$HYBRID_MALLOC"])
2208 AC_SUBST(GMALLOC_OBJ)
2209 AC_SUBST(VMLIMIT_OBJ)
2211 if test "$doug_lea_malloc" = "yes" && test "$hybrid_malloc" != yes; then
2212   if test "$GNU_MALLOC" = yes ; then
2213     GNU_MALLOC_reason="
2214       (Using Doug Lea's new malloc from the GNU C Library.)"
2215   fi
2216   AC_DEFINE(DOUG_LEA_MALLOC, 1,
2217     [Define to 1 if the system memory allocator is Doug Lea style,
2218      with malloc hooks and malloc_set_state.])
2220   ## Use mmap directly for allocating larger buffers.
2221   ## FIXME this comes from src/s/{gnu,gnu-linux}.h:
2222   ## #ifdef DOUG_LEA_MALLOC; #undef REL_ALLOC; #endif
2223   ## Does the AC_FUNC_MMAP test below make this check unnecessary?
2224   case "$opsys" in
2225     mingw32|gnu*) REL_ALLOC=no ;;
2226   esac
2229 if test x"${REL_ALLOC}" = x; then
2230   REL_ALLOC=${GNU_MALLOC}
2233 use_mmap_for_buffers=no
2234 case "$opsys" in
2235   cygwin|mingw32) use_mmap_for_buffers=yes ;;
2236 esac
2238 AC_FUNC_MMAP
2239 if test $use_mmap_for_buffers = yes; then
2240   AC_DEFINE(USE_MMAP_FOR_BUFFERS, 1, [Define to use mmap to allocate buffer text.])
2241   REL_ALLOC=no
2244 LIBS="$LIBS_SYSTEM $LIBS"
2246 dnl FIXME replace main with a function we actually want from this library.
2247 AC_CHECK_LIB(Xbsd, main, LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -lXbsd")
2249 dnl Check for the POSIX thread library.
2250 LIB_PTHREAD=
2251 AC_CHECK_HEADERS_ONCE(pthread.h)
2252 if test "$ac_cv_header_pthread_h" && test "$opsys" != "mingw32"; then
2253   AC_CACHE_CHECK([for pthread library],
2254     [emacs_cv_pthread_lib],
2255     [emacs_cv_pthread_lib=no
2256      OLD_LIBS=$LIBS
2257      for emacs_pthread_lib in 'none needed' -lpthread; do
2258        case $emacs_pthread_lib in
2259          -*) LIBS="$OLD_LIBS $emacs_pthread_lib";;
2260        esac
2261        AC_LINK_IFELSE(
2262          [AC_LANG_PROGRAM(
2263             [[#include <pthread.h>
2264               #include <signal.h>
2265               sigset_t old_mask, new_mask;
2266               void noop (void) {}]],
2267             [[pthread_t th = pthread_self ();
2268               int status = 0;
2269               status += pthread_create (&th, 0, 0, 0);
2270               status += pthread_sigmask (SIG_BLOCK, &new_mask, &old_mask);
2271               status += pthread_kill (th, 0);
2272               #if ! (defined SYSTEM_MALLOC || defined HYBRID_MALLOC \
2273                      || defined DOUG_LEA_MALLOC)
2274               /* Test for pthread_atfork only if gmalloc uses it,
2275                  as older-style hosts like MirBSD 10 lack it.  */
2276               status += pthread_atfork (noop, noop, noop);
2277               #endif
2278               return status;]])],
2279          [emacs_cv_pthread_lib=$emacs_pthread_lib])
2280        LIBS=$OLD_LIBS
2281        if test "$emacs_cv_pthread_lib" != no; then
2282          break
2283        fi
2284      done])
2285   if test "$emacs_cv_pthread_lib" != no; then
2286     AC_DEFINE([HAVE_PTHREAD], 1, [Define to 1 if you have POSIX threads.])
2287     case $emacs_cv_pthread_lib in
2288       -*) LIB_PTHREAD=$emacs_cv_pthread_lib;;
2289     esac
2290     ac_cv_func_pthread_sigmask=yes
2291     # Some systems optimize for single-threaded programs by default, and
2292     # need special flags to disable these optimizations. For example, the
2293     # definition of 'errno' in <errno.h>.
2294     case $opsys in
2295       hpux* | sol*)
2296         AC_DEFINE([_REENTRANT], 1,
2297           [Define to 1 if your system requires this in multithreaded code.]);;
2298       aix4-2)
2299         AC_DEFINE([_THREAD_SAFE], 1,
2300           [Define to 1 if your system requires this in multithreaded code.]);;
2301     esac
2302   fi
2304 AC_SUBST([LIB_PTHREAD])
2306 dnl Check for need for bigtoc support on IBM AIX
2308 case ${host_os} in
2309 aix*)
2310   AC_CACHE_CHECK([for -bbigtoc option], [gdb_cv_bigtoc], [
2311     case $GCC in
2312     yes) gdb_cv_bigtoc=-Wl,-bbigtoc ;;
2313     *) gdb_cv_bigtoc=-bbigtoc ;;
2314     esac
2316     LDFLAGS=$LDFLAGS\ $gdb_cv_bigtoc
2317     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])], [], [gdb_cv_bigtoc=])
2318   ])
2319   ;;
2320 esac
2322 # Change CFLAGS, CPPFLAGS, and LIBS temporarily so that C_SWITCH_X_SITE
2323 # is for the tests that follow.  We set them back later on.
2325 REAL_CFLAGS="$CFLAGS"
2326 REAL_CPPFLAGS="$CPPFLAGS"
2327 REAL_LIBS="$LIBS"
2329 if test "${HAVE_X11}" = "yes"; then
2330   DEFS="$C_SWITCH_X_SITE $DEFS"
2331   LDFLAGS="$LDFLAGS $LD_SWITCH_X_SITE"
2332   LIBS="-lX11 $LIBS"
2333   CFLAGS="$C_SWITCH_X_SITE $CFLAGS"
2334   CPPFLAGS="$C_SWITCH_X_SITE $CPPFLAGS"
2336   # On Solaris, arrange for LD_RUN_PATH to point to the X libraries for tests.
2337   # This is handled by LD_SWITCH_X_SITE_RPATH during the real build,
2338   # but it's more convenient here to set LD_RUN_PATH since this
2339   # also works on hosts that don't understand LD_SWITCH_X_SITE_RPATH.
2340   if test "${x_libraries}" != NONE && test -n "${x_libraries}"; then
2341     LD_RUN_PATH=$x_libraries${LD_RUN_PATH+:}$LD_RUN_PATH
2342     export LD_RUN_PATH
2343   fi
2345   if test "${opsys}" = "gnu-linux"; then
2346     AC_MSG_CHECKING(whether X on GNU/Linux needs -b to link)
2347     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
2348      [[XOpenDisplay ("foo");]])],
2349      [xgnu_linux_first_failure=no],
2350      [xgnu_linux_first_failure=yes])
2351     if test "${xgnu_linux_first_failure}" = "yes"; then
2352       OLD_CPPFLAGS="$CPPFLAGS"
2353       OLD_LIBS="$LIBS"
2354       CPPFLAGS="$CPPFLAGS -b i486-linuxaout"
2355       LIBS="$LIBS -b i486-linuxaout"
2356       AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
2357        [[XOpenDisplay ("foo");]])],
2358        [xgnu_linux_second_failure=no],
2359        [xgnu_linux_second_failure=yes])
2360       if test "${xgnu_linux_second_failure}" = "yes"; then
2361         # If we get the same failure with -b, there is no use adding -b.
2362         # So leave it out.  This plays safe.
2363         AC_MSG_RESULT(no)
2364       else
2365         LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -b i486-linuxaout"
2366         C_SWITCH_X_SITE="$C_SWITCH_X_SITE -b i486-linuxaout"
2367         AC_MSG_RESULT(yes)
2368       fi
2369       CPPFLAGS=$OLD_CPPFLAGS
2370       LIBS=$OLD_LIBS
2371     else
2372       AC_MSG_RESULT(no)
2373     fi
2374   fi
2376   # Reportedly, some broken Solaris systems have XKBlib.h but are missing
2377   # header files included from there.
2378   AC_MSG_CHECKING(for Xkb)
2379   AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>
2380 #include <X11/XKBlib.h>]],
2381         [[XkbDescPtr kb = XkbGetKeyboard (0, XkbAllComponentsMask, XkbUseCoreKbd);]])],
2382         emacs_xkb=yes, emacs_xkb=no)
2383   AC_MSG_RESULT($emacs_xkb)
2384   if test $emacs_xkb = yes; then
2385     AC_DEFINE(HAVE_XKB, 1, [Define to 1 if you have the Xkb extension.])
2386   fi
2388   AC_CHECK_FUNCS(XrmSetDatabase XScreenResourceString \
2389 XScreenNumberOfScreen)
2392 if test "${window_system}" = "x11"; then
2393   AC_MSG_CHECKING(X11 version 6)
2394   AC_CACHE_VAL(emacs_cv_x11_version_6,
2395   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
2396 [[#if XlibSpecificationRelease < 6
2397 fail;
2398 #endif
2399 ]])], emacs_cv_x11_version_6=yes, emacs_cv_x11_version_6=no)])
2400   if test $emacs_cv_x11_version_6 = yes; then
2401     AC_MSG_RESULT(6 or newer)
2402     AC_DEFINE(HAVE_X11R6, 1,
2403               [Define to 1 if you have the X11R6 or newer version of Xlib.])
2404     AC_DEFINE(HAVE_X_I18N, 1, [Define if you have usable i18n support.])
2405     ## inoue@ainet.or.jp says Solaris has a bug related to X11R6-style
2406     ## XIM support.
2407     case "$opsys" in
2408       sol2-*) : ;;
2409       *) AC_DEFINE(HAVE_X11R6_XIM, 1,
2410            [Define if you have usable X11R6-style XIM support.])
2411          ;;
2412     esac
2413   else
2414     AC_MSG_RESULT(before 6)
2415   fi
2419 ### Use -lrsvg-2 if available, unless '--with-rsvg=no' is specified.
2420 HAVE_RSVG=no
2421 if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
2422   if test "${with_rsvg}" != "no"; then
2423     RSVG_REQUIRED=2.11.0
2424     RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
2426     EMACS_CHECK_MODULES([RSVG], [$RSVG_MODULE])
2427     AC_SUBST(RSVG_CFLAGS)
2428     AC_SUBST(RSVG_LIBS)
2430     if test $HAVE_RSVG = yes; then
2431       AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
2432       CFLAGS="$CFLAGS $RSVG_CFLAGS"
2433       # Windows loads librsvg dynamically
2434       if test "${opsys}" = "mingw32"; then
2435         RSVG_LIBS=
2436       fi
2437     fi
2438   fi
2441 HAVE_IMAGEMAGICK=no
2442 if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${HAVE_W32}" = "yes"; then
2443   if test "${with_imagemagick}" != "no"; then
2444     ## 6.3.5 is the earliest version known to work; see Bug#17339.
2445     ## 6.8.2 makes Emacs crash; see Bug#13867.
2446     IMAGEMAGICK_MODULE="Wand >= 6.3.5 Wand != 6.8.2"
2447     EMACS_CHECK_MODULES([IMAGEMAGICK], [$IMAGEMAGICK_MODULE])
2448     AC_SUBST(IMAGEMAGICK_CFLAGS)
2449     AC_SUBST(IMAGEMAGICK_LIBS)
2451     if test $HAVE_IMAGEMAGICK = yes; then
2452       AC_DEFINE(HAVE_IMAGEMAGICK, 1, [Define to 1 if using imagemagick.])
2453       OLD_CFLAGS=$CFLAGS
2454       OLD_LIBS=$LIBS
2455       CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS"
2456       LIBS="$IMAGEMAGICK_LIBS $LIBS"
2457       AC_CHECK_FUNCS(MagickExportImagePixels MagickMergeImageLayers MagickAutoOrientImage)
2458       CFLAGS=$OLD_CFLAGS
2459       LIBS=$OLD_LIBS
2460     fi
2461   fi
2464 AC_CHECK_LIB(anl, getaddrinfo_a, HAVE_GETADDRINFO_A=yes)
2465 if test "${HAVE_GETADDRINFO_A}" = "yes"; then
2466   AC_DEFINE(HAVE_GETADDRINFO_A, 1,
2467 [Define to 1 if you have getaddrinfo_a for asynchronous DNS resolution.])
2468   GETADDRINFO_A_LIBS="-lanl"
2469   AC_SUBST(GETADDRINFO_A_LIBS)
2472 HAVE_GTK=no
2473 GTK_OBJ=
2474 gtk_term_header=$term_header
2475 check_gtk2=no
2476 gtk3_pkg_errors=
2477 if test "${opsys}" != "mingw32"; then
2478   if test "${with_gtk3}" = "yes" || test "${with_gtk}" = "yes" || test "$USE_X_TOOLKIT" = "maybe"; then
2479     GLIB_REQUIRED=2.28
2480     GTK_REQUIRED=3.0
2481     GTK_MODULES="gtk+-3.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
2483     dnl Checks for libraries.
2484     EMACS_CHECK_MODULES([GTK], [$GTK_MODULES],
2485       [pkg_check_gtk=yes], [pkg_check_gtk=no])
2486     if test "$pkg_check_gtk" = "no" && test "$with_gtk3" = "yes"; then
2487        AC_MSG_ERROR($GTK_PKG_ERRORS)
2488     fi
2489     if test "$pkg_check_gtk" = "yes"; then
2490        AC_DEFINE(HAVE_GTK3, 1, [Define to 1 if using GTK 3 or later.])
2491        GTK_OBJ=emacsgtkfixed.o
2492        gtk_term_header=gtkutil.h
2493        USE_GTK_TOOLKIT="GTK3"
2494        if test "x$ac_enable_gtk_deprecation_warnings" = x; then
2495          AC_DEFINE([GDK_DISABLE_DEPRECATION_WARNINGS], [1],
2496            [Define to 1 to disable GTK+/GDK deprecation warnings.])
2497          AC_DEFINE([GLIB_DISABLE_DEPRECATION_WARNINGS], [1],
2498            [Define to 1 to disable Glib deprecation warnings.])
2499        fi
2500     else
2501        check_gtk2=yes
2502        gtk3_pkg_errors="$GTK_PKG_ERRORS "
2503     fi
2504   fi
2506   if test "${with_gtk2}" = "yes" || test "$check_gtk2" = "yes"; then
2507     GLIB_REQUIRED=2.10
2508     GTK_REQUIRED=2.10
2509     GTK_MODULES="gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
2511     dnl Checks for libraries.
2512     EMACS_CHECK_MODULES([GTK], [$GTK_MODULES],
2513       [pkg_check_gtk=yes], [pkg_check_gtk=no])
2514     if test "$pkg_check_gtk" = "no" &&
2515        { test "$with_gtk" = yes || test "$with_gtk2" = "yes"; }
2516     then
2517       AC_MSG_ERROR($gtk3_pkg_errors$GTK_PKG_ERRORS)
2518     fi
2519     test "$pkg_check_gtk" = "yes" && USE_GTK_TOOLKIT="GTK2"
2520   fi
2523 OLD_CFLAGS=$CFLAGS
2524 OLD_LIBS=$LIBS
2526 if test x"$pkg_check_gtk" = xyes; then
2528   AC_SUBST(GTK_LIBS)
2529   CFLAGS="$CFLAGS $GTK_CFLAGS"
2530   LIBS="$GTK_LIBS $LIBS"
2531   dnl Try to compile a simple GTK program.
2532   AC_MSG_CHECKING([whether GTK compiles])
2533   GTK_COMPILES=no
2534   AC_LINK_IFELSE(
2535     [AC_LANG_PROGRAM(
2536        [[/* Check the Gtk and Glib APIs.  */
2537          #include <gtk/gtk.h>
2538          #include <glib-object.h>
2539          static void
2540          callback (GObject *go, GParamSpec *spec, gpointer user_data)
2541          {}
2542        ]],
2543        [[
2544          GtkSettings *gs = 0;
2545          /* Use G_CALLBACK to make sure function pointers can be cast to void *;
2546             strict C prohibits this.  Use gtk_main_iteration to test that the
2547             libraries are there.  */
2548          if (g_signal_handler_find (G_OBJECT (gs), G_SIGNAL_MATCH_FUNC,
2549                                     0, 0, 0, G_CALLBACK (callback), 0))
2550            gtk_main_iteration ();
2551        ]])],
2552     [GTK_COMPILES=yes])
2553   AC_MSG_RESULT([$GTK_COMPILES])
2554   if test "${GTK_COMPILES}" != "yes"; then
2555     GTK_OBJ=
2556     if test "$USE_X_TOOLKIT" != "maybe"; then
2557       AC_MSG_ERROR([Gtk+ wanted, but it does not compile, see config.log.  Maybe some x11-devel files missing?]);
2558     fi
2559   else
2560     C_SWITCH_X_SITE="$C_SWITCH_X_SITE $GTK_CFLAGS"
2561     HAVE_GTK=yes
2562     AC_DEFINE(USE_GTK, 1, [Define to 1 if using GTK.])
2563     GTK_OBJ="gtkutil.o $GTK_OBJ"
2564     term_header=$gtk_term_header
2565     USE_X_TOOLKIT=none
2566     AC_MSG_WARN([[Your version of Gtk+ will have problems with
2567        closing open displays.  This is no problem if you just use
2568        one display, but if you use more than one and close one of them
2569        Emacs may crash.
2570        See http://bugzilla.gnome.org/show_bug.cgi?id=85715]])
2571     sleep 3
2572   fi
2575 AC_SUBST(GTK_OBJ)
2578 if test "${HAVE_GTK}" = "yes"; then
2580   dnl  GTK scrollbars resemble toolkit scrollbars a lot, so to avoid
2581   dnl  a lot if #ifdef:s, say we have toolkit scrollbars.
2582   if test "$with_toolkit_scroll_bars" != no; then
2583     with_toolkit_scroll_bars=yes
2584   fi
2586   dnl  Check if we have the old file selection dialog declared and
2587   dnl  in the link library.  In 2.x it may be in the library,
2588   dnl  but not declared if deprecated featured has been selected out.
2589   dnl  AC_CHECK_DECL checks for a macro, so check for GTK_TYPE_FILE_SELECTION.
2590   HAVE_GTK_FILE_SELECTION=no
2591   AC_CHECK_DECL(GTK_TYPE_FILE_SELECTION, HAVE_GTK_FILE_SELECTION=yes,
2592                    HAVE_GTK_FILE_SELECTION=no, [AC_INCLUDES_DEFAULT
2593 #include <gtk/gtk.h>])
2594   if test "$HAVE_GTK_FILE_SELECTION" = yes; then
2595     AC_CHECK_FUNCS(gtk_file_selection_new)
2596   fi
2598   dnl Same as above for gtk_handle_box.
2599   HAVE_GTK_HANDLE_BOX=no
2600   AC_CHECK_DECL(GTK_TYPE_HANDLE_BOX, HAVE_GTK_HANDLE_BOX=yes,
2601                    HAVE_GTK_HANDLE_BOX=no, [AC_INCLUDES_DEFAULT
2602 #include <gtk/gtk.h>])
2603   if test "$HAVE_GTK_HANDLE_BOX" = yes; then
2604     AC_CHECK_FUNCS(gtk_handle_box_new)
2605   fi
2607   dnl Same as above for gtk_tearoff_menu_item.
2608   HAVE_GTK_TEAROFF_MENU_ITEM=no
2609   AC_CHECK_DECL(GTK_TYPE_TEAROFF_MENU_ITEM, HAVE_GTK_TEAROFF_MENU_ITEM=yes,
2610                    HAVE_GTK_TEAROFF_MENU_ITEM=no, [AC_INCLUDES_DEFAULT
2611 #include <gtk/gtk.h>])
2612   if test "$HAVE_GTK_TEAROFF_MENU_ITEM" = yes; then
2613     AC_CHECK_FUNCS(gtk_tearoff_menu_item_new)
2614   fi
2616   dnl Check for functions introduced in 2.14 and later.
2617   AC_CHECK_FUNCS(gtk_widget_get_window gtk_widget_set_has_window \
2618                  gtk_dialog_get_action_area gtk_widget_get_sensitive \
2619                  gtk_widget_get_mapped gtk_adjustment_get_page_size \
2620                  gtk_orientable_set_orientation \
2621                  gtk_window_set_has_resize_grip)
2623  term_header=gtkutil.h
2627 dnl Enable xwidgets if GTK3 and WebKitGTK+ are available.
2628 HAVE_XWIDGETS=no
2629 XWIDGETS_OBJ=
2630 if test "$with_xwidgets" != "no"; then
2631   test "$USE_GTK_TOOLKIT" = "GTK3" && test "$window_system" != "none" ||
2632     AC_MSG_ERROR([xwidgets requested but gtk3 not used.])
2634   WEBKIT_REQUIRED=1.4.0
2635   WEBKIT_MODULES="webkitgtk-3.0 >= $WEBKIT_REQUIRED"
2636   EMACS_CHECK_MODULES([WEBKIT], [$WEBKIT_MODULES])
2637   HAVE_XWIDGETS=$HAVE_WEBKIT
2638   test $HAVE_XWIDGETS = yes ||
2639     AC_MSG_ERROR([xwidgets requested but WebKitGTK+ not found.])
2641   XWIDGETS_OBJ=xwidget.o
2642   AC_DEFINE([HAVE_XWIDGETS], 1, [Define to 1 if you have xwidgets support.])
2644 AC_SUBST(XWIDGETS_OBJ)
2646 CFLAGS=$OLD_CFLAGS
2647 LIBS=$OLD_LIBS
2649 dnl D-Bus has been tested under GNU/Linux only.  Must be adapted for
2650 dnl other platforms.
2651 HAVE_DBUS=no
2652 DBUS_OBJ=
2653 if test "${with_dbus}" = "yes"; then
2654    EMACS_CHECK_MODULES([DBUS], [dbus-1 >= 1.0])
2655    if test "$HAVE_DBUS" = yes; then
2656      AC_DEFINE(HAVE_DBUS, 1, [Define to 1 if using D-Bus.])
2657      dnl dbus_watch_get_unix_fd has been introduced in D-Bus 1.1.1.
2658      dnl dbus_type_is_valid and dbus_validate_* have been introduced in
2659      dnl D-Bus 1.5.12.
2660      OLD_LIBS=$LIBS
2661      LIBS="$LIBS $DBUS_LIBS"
2662      AC_CHECK_FUNCS(dbus_watch_get_unix_fd \
2663                     dbus_type_is_valid \
2664                     dbus_validate_bus_name \
2665                     dbus_validate_path \
2666                     dbus_validate_interface \
2667                     dbus_validate_member)
2668      LIBS=$OLD_LIBS
2669      DBUS_OBJ=dbusbind.o
2670    fi
2672 AC_SUBST(DBUS_CFLAGS)
2673 AC_SUBST(DBUS_LIBS)
2674 AC_SUBST(DBUS_OBJ)
2676 dnl GSettings has been tested under GNU/Linux only.
2677 HAVE_GSETTINGS=no
2678 if test "${HAVE_X11}" = "yes" && test "${with_gsettings}" = "yes"; then
2679    EMACS_CHECK_MODULES([GSETTINGS], [gio-2.0 >= 2.26])
2680    if test "$HAVE_GSETTINGS" = "yes"; then
2681       old_CFLAGS=$CFLAGS
2682       CFLAGS="$CFLAGS $GSETTINGS_CFLAGS"
2683       old_LIBS=$LIBS
2684       LIBS="$LIBS $GSETTINGS_LIBS"
2685       AC_MSG_CHECKING([whether GSettings is in gio])
2686       AC_LINK_IFELSE(
2687          [AC_LANG_PROGRAM(
2688              [[/* Check that gsettings really is present.  */
2689              #include <glib-object.h>
2690              #include <gio/gio.h>
2691              ]],
2692              [[
2693                GSettings *settings;
2694                GVariant *val = g_settings_get_value (settings, "");
2695              ]])],
2696          [], HAVE_GSETTINGS=no)
2697       AC_MSG_RESULT([$HAVE_GSETTINGS])
2699       if test "$HAVE_GSETTINGS" = "yes"; then
2700         AC_DEFINE(HAVE_GSETTINGS, 1, [Define to 1 if using GSettings.])
2701         SETTINGS_CFLAGS="$GSETTINGS_CFLAGS"
2702         SETTINGS_LIBS="$GSETTINGS_LIBS"
2703       fi
2704       CFLAGS=$old_CFLAGS
2705       LIBS=$old_LIBS
2706    fi
2709 dnl GConf has been tested under GNU/Linux only.
2710 dnl The version is really arbitrary, it is about the same age as Gtk+ 2.6.
2711 HAVE_GCONF=no
2712 if test "${HAVE_X11}" = "yes" && test "${with_gconf}" = "yes"; then
2713    EMACS_CHECK_MODULES([GCONF], [gconf-2.0 >= 2.13])
2714    if test "$HAVE_GCONF" = yes; then
2715       AC_DEFINE(HAVE_GCONF, 1, [Define to 1 if using GConf.])
2716       dnl Newer GConf doesn't link with g_objects, so this is not defined.
2717       SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GCONF_CFLAGS"
2718       SETTINGS_LIBS="$SETTINGS_LIBS $GCONF_LIBS"
2719    fi
2722 if test "$HAVE_GSETTINGS" = "yes" || test "$HAVE_GCONF" = "yes"; then
2723     EMACS_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.0])
2724     if test "$HAVE_GOBJECT" = "yes"; then
2725        SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GOBJECT_CFLAGS"
2726        SETTINGS_LIBS="$SETTINGS_LIBS $GOBJECT_LIBS"
2727     fi
2728     SAVE_CFLAGS="$CFLAGS"
2729     SAVE_LIBS="$LIBS"
2730     CFLAGS="$SETTINGS_CFLAGS $CFLAGS"
2731     LIBS="$SETTINGS_LIBS $LIBS"
2732     CFLAGS="$SAVE_CFLAGS"
2733     LIBS="$SAVE_LIBS"
2735 AC_SUBST(SETTINGS_CFLAGS)
2736 AC_SUBST(SETTINGS_LIBS)
2739 dnl SELinux is available for GNU/Linux only.
2740 HAVE_LIBSELINUX=no
2741 LIBSELINUX_LIBS=
2742 if test "${with_selinux}" = "yes"; then
2743    AC_CHECK_LIB([selinux], [lgetfilecon], HAVE_LIBSELINUX=yes, HAVE_LIBSELINUX=no)
2744    if test "$HAVE_LIBSELINUX" = yes; then
2745       AC_DEFINE(HAVE_LIBSELINUX, 1, [Define to 1 if using SELinux.])
2746       LIBSELINUX_LIBS=-lselinux
2747    fi
2749 AC_SUBST(LIBSELINUX_LIBS)
2751 HAVE_GNUTLS=no
2752 if test "${with_gnutls}" = "yes" ; then
2753   EMACS_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.12.2],
2754     [HAVE_GNUTLS=yes], [HAVE_GNUTLS=no])
2755   if test "${HAVE_GNUTLS}" = "yes"; then
2756     AC_DEFINE(HAVE_GNUTLS, 1, [Define if using GnuTLS.])
2757     EMACS_CHECK_MODULES([LIBGNUTLS3], [gnutls >= 3.0.0],
2758       [AC_DEFINE(HAVE_GNUTLS3, 1, [Define if using GnuTLS v3.])], [])
2759   fi
2761   # Windows loads GnuTLS dynamically
2762   if test "${opsys}" = "mingw32"; then
2763     LIBGNUTLS_LIBS=
2764   fi
2767 AC_SUBST(LIBGNUTLS_LIBS)
2768 AC_SUBST(LIBGNUTLS_CFLAGS)
2770 HAVE_LIBSYSTEMD=no
2771 if test "${with_libsystemd}" = "yes" ; then
2772   dnl This code has been tested with libsystemd 222 and later.
2773   dnl FIXME: Find the earliest version number for which Emacs should work,
2774   dnl and change '222' to that number.
2775   EMACS_CHECK_MODULES([LIBSYSTEMD], [libsystemd >= 222],
2776     [HAVE_LIBSYSTEMD=yes], [HAVE_LIBSYSTEMD=no])
2777   if test "${HAVE_LIBSYSTEMD}" = "yes"; then
2778     AC_DEFINE(HAVE_LIBSYSTEMD, 1, [Define if using libsystemd.])
2779   fi
2782 AC_SUBST(LIBSYSTEMD_LIBS)
2783 AC_SUBST(LIBSYSTEMD_CFLAGS)
2785 NOTIFY_OBJ=
2786 NOTIFY_SUMMARY=no
2788 dnl MS Windows native file monitor is available for mingw32 only.
2789 case $with_file_notification,$opsys in
2790   w32,cygwin)
2791     AC_MSG_ERROR(['--with-file-notification=w32' was specified, but
2792     this is only supported on MS-Windows native and MinGW32 builds.
2793     Consider using gfile instead.])
2794     ;;
2795   w32,* | yes,mingw32)
2796     AC_CHECK_HEADER(windows.h)
2797     if test "$ac_cv_header_windows_h" = yes ; then
2798        AC_DEFINE(HAVE_W32NOTIFY, 1, [Define to 1 to use w32notify.])
2799        NOTIFY_OBJ=w32notify.o
2800        NOTIFY_SUMMARY="yes (w32)"
2801     fi ;;
2802 esac
2804 dnl inotify is available only on GNU/Linux.
2805 case $with_file_notification,$NOTIFY_OBJ in
2806   inotify, | yes,)
2807     AC_CHECK_HEADER(sys/inotify.h)
2808     if test "$ac_cv_header_sys_inotify_h" = yes ; then
2809         AC_CHECK_FUNC(inotify_init1)
2810         if test "$ac_cv_func_inotify_init1" = yes; then
2811           AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 to use inotify.])
2812           NOTIFY_OBJ=inotify.o
2813           NOTIFY_SUMMARY="yes -lglibc (inotify)"
2814        fi
2815     fi ;;
2816 esac
2818 dnl kqueue is available on BSD-like systems.
2819 case $with_file_notification,$NOTIFY_OBJ in
2820   kqueue,* | yes,)
2821     EMACS_CHECK_MODULES([KQUEUE], [libkqueue])
2822     if test "$HAVE_KQUEUE" = "yes"; then
2823        AC_DEFINE(HAVE_KQUEUE, 1, [Define to 1 to use kqueue.])
2824        CPPFLAGS="$CPPFLAGS -I/usr/include/kqueue"
2825        NOTIFY_CFLAGS=$KQUEUE_CFLAGS
2826        NOTIFY_LIBS=$KQUEUE_LIBS
2827        NOTIFY_OBJ=kqueue.o
2828        NOTIFY_SUMMARY="yes -lkqueue"
2829     else
2830        AC_SEARCH_LIBS(kqueue, [])
2831        if test "$ac_cv_search_kqueue" != no; then
2832          AC_DEFINE(HAVE_KQUEUE, 1, [Define to 1 to use kqueue.])
2833          NOTIFY_OBJ=kqueue.o
2834          NOTIFY_SUMMARY="yes (kqueue)"
2835        fi
2836     fi ;;
2837 esac
2839 dnl g_file_monitor exists since glib 2.18.  G_FILE_MONITOR_EVENT_MOVED
2840 dnl has been added in glib 2.24.  It has been tested under
2841 dnl GNU/Linux only.
2842 case $with_file_notification,$NOTIFY_OBJ in
2843   gfile,* | yes,)
2844     if test "${HAVE_NS}" = yes; then
2845        AC_MSG_ERROR(['--with-file-notification=gfile' is not supported in NextStep builds.
2846 Consider kqueue instead.])
2847     else
2848        EMACS_CHECK_MODULES([GFILENOTIFY], [gio-2.0 >= 2.24])
2849        if test "$HAVE_GFILENOTIFY" = "yes"; then
2850           AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.])
2851           NOTIFY_CFLAGS=$GFILENOTIFY_CFLAGS
2852           NOTIFY_LIBS=$GFILENOTIFY_LIBS
2853           NOTIFY_OBJ=gfilenotify.o
2854           NOTIFY_SUMMARY="yes -lgio (gfile)"
2855        fi
2856     fi ;;
2857 esac
2859 case $with_file_notification,$NOTIFY_OBJ in
2860   yes,* | no,* | *,?*) ;;
2861   *) AC_MSG_ERROR([File notification '$with_file_notification' requested but requirements not found.]) ;;
2862 esac
2864 if test -n "$NOTIFY_OBJ"; then
2865    AC_DEFINE(USE_FILE_NOTIFY, 1, [Define to 1 if using file notifications.])
2867 AC_SUBST(NOTIFY_CFLAGS)
2868 AC_SUBST(NOTIFY_LIBS)
2869 AC_SUBST(NOTIFY_OBJ)
2871 dnl Do not put whitespace before the #include statements below.
2872 dnl Older compilers (eg sunos4 cc) choke on it.
2873 HAVE_XAW3D=no
2874 LUCID_LIBW=
2875 if test x"${USE_X_TOOLKIT}" = xmaybe || test x"${USE_X_TOOLKIT}" = xLUCID; then
2876   if test "$with_xaw3d" != no; then
2877     AC_CACHE_VAL(emacs_cv_xaw3d,
2878     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2879 #include <X11/Intrinsic.h>
2880 #include <X11/Xaw3d/Simple.h>]],
2881       [[]])],
2882       [AC_CHECK_LIB(Xaw3d, XawScrollbarSetThumb,
2883                     emacs_cv_xaw3d=yes, emacs_cv_xaw3d=no)],
2884       emacs_cv_xaw3d=no)])
2885   else
2886     emacs_cv_xaw3d=no
2887   fi
2888   if test $emacs_cv_xaw3d = yes; then
2889     AC_MSG_CHECKING(for xaw3d)
2890     AC_MSG_RESULT([yes; using Lucid toolkit])
2891     USE_X_TOOLKIT=LUCID
2892     HAVE_XAW3D=yes
2893     LUCID_LIBW=-lXaw3d
2894     AC_DEFINE(HAVE_XAW3D, 1,
2895               [Define to 1 if you have the Xaw3d library (-lXaw3d).])
2896   else
2897     AC_MSG_CHECKING(for xaw3d)
2898     AC_MSG_RESULT(no)
2899     AC_MSG_CHECKING(for libXaw)
2900     AC_CACHE_VAL(emacs_cv_xaw,
2901     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2902 #include <X11/Intrinsic.h>
2903 #include <X11/Xaw/Simple.h>]],
2904       [[]])],
2905       emacs_cv_xaw=yes,
2906       emacs_cv_xaw=no)])
2907     if test $emacs_cv_xaw = yes; then
2908       AC_MSG_RESULT([yes; using Lucid toolkit])
2909       USE_X_TOOLKIT=LUCID
2910       LUCID_LIBW=-lXaw
2911     elif test x"${USE_X_TOOLKIT}" = xLUCID; then
2912       AC_MSG_ERROR([Lucid toolkit requires X11/Xaw include files])
2913     else
2914       AC_MSG_ERROR([No X toolkit could be found.
2915 If you are sure you want Emacs compiled without an X toolkit, pass
2916   --with-x-toolkit=no
2917 to configure.  Otherwise, install the development libraries for the toolkit
2918 that you want to use (e.g. Gtk+) and re-run configure.])
2919     fi
2920   fi
2923 X_TOOLKIT_TYPE=$USE_X_TOOLKIT
2925 LIBXTR6=
2926 LIBXMU=
2927 if test "${USE_X_TOOLKIT}" != "none"; then
2928   AC_MSG_CHECKING(X11 toolkit version)
2929   AC_CACHE_VAL(emacs_cv_x11_toolkit_version_6,
2930   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Intrinsic.h>]],
2931 [[#if XtSpecificationRelease < 6
2932 fail;
2933 #endif
2934 ]])], emacs_cv_x11_toolkit_version_6=yes, emacs_cv_x11_toolkit_version_6=no)])
2935   HAVE_X11XTR6=$emacs_cv_x11_toolkit_version_6
2936   if test $emacs_cv_x11_toolkit_version_6 = yes; then
2937     AC_MSG_RESULT(6 or newer)
2938     AC_DEFINE(HAVE_X11XTR6, 1,
2939               [Define to 1 if you have the X11R6 or newer version of Xt.])
2940     LIBXTR6="-lSM -lICE"
2941     case "$opsys" in
2942       ## Use libw.a along with X11R6 Xt.
2943       unixware) LIBXTR6="$LIBXTR6 -lw" ;;
2944     esac
2945   else
2946     AC_MSG_RESULT(before 6)
2947   fi
2949 dnl If using toolkit, check whether libXmu.a exists.
2950 dnl tranle@intellicorp.com says libXmu.a can need XtMalloc in libXt.a to link.
2951   OLDLIBS="$LIBS"
2952   if test x$HAVE_X11XTR6 = xyes; then
2953     OTHERLIBS='-lXt -lSM -lICE'
2954   else
2955     OTHERLIBS='-lXt'
2956   fi
2957   AC_SEARCH_LIBS([XmuConvertStandardSelection], [Xmu], [], [], [$OTHERLIBS])
2958   if test "X$LIBS" != "X$OLDLIBS"; then
2959     LIBXMU=$ac_cv_search_XmuConvertStandardSelection
2960   fi
2961   LIBS=$OLDLIBS
2962   dnl ac_cv_search_XmuConvertStandardSelection is also referenced below.
2964 AC_SUBST(LIBXTR6)
2965 AC_SUBST(LIBXMU)
2967 LIBXP=
2968 if test "${USE_X_TOOLKIT}" = "MOTIF"; then
2969   # OpenMotif may be installed in such a way on some GNU/Linux systems.
2970   if test -d /usr/include/openmotif; then
2971     CPPFLAGS="-I/usr/include/openmotif $CPPFLAGS"
2972     emacs_cv_openmotif=yes
2973     case "$canonical" in
2974       x86_64-*-linux-gnu* | powerpc64-*-linux-gnu* | sparc64-*-linux-gnu*)
2975       test -d /usr/lib64/openmotif && LDFLAGS="-L/usr/lib64/openmotif $LDFLAGS"
2976       ;;
2977       *)
2978       test -d /usr/lib/openmotif && LDFLAGS="-L/usr/lib/openmotif $LDFLAGS"
2979     esac
2980   else
2981     emacs_cv_openmotif=no
2982   fi
2983   AC_CACHE_CHECK(for (Open)Motif version 2.1, emacs_cv_motif_version_2_1,
2984   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <Xm/Xm.h>]],
2985     [[#if XmVERSION > 2 || (XmVERSION == 2 && XmREVISION >= 1)
2986 int x = 5;
2987 #else
2988 Motif version prior to 2.1.
2989 #endif]])],
2990     emacs_cv_motif_version_2_1=yes, emacs_cv_motif_version_2_1=no)])
2991   if test $emacs_cv_motif_version_2_1 = yes; then
2992     AC_CHECK_LIB(Xp, XpCreateContext, LIBXP=-lXp)
2993     if test x$emacs_cv_openmotif = xyes; then
2994       REAL_CPPFLAGS="-I/usr/include/openmotif $REAL_CPPFLAGS"
2995     fi
2996   else
2997     AC_CACHE_CHECK(for LessTif where some systems put it, emacs_cv_lesstif,
2998     # We put this in CFLAGS temporarily to precede other -I options
2999     # that might be in CFLAGS temporarily.
3000     # We put this in CPPFLAGS where it precedes the other -I options.
3001     OLD_CPPFLAGS=$CPPFLAGS
3002     OLD_CFLAGS=$CFLAGS
3003     CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CPPFLAGS"
3004     CFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CFLAGS"
3005     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include </usr/X11R6/LessTif/Motif1.2/include/Xm/Xm.h>]],
3006       [[int x = 5;]])],
3007       emacs_cv_lesstif=yes, emacs_cv_lesstif=no)])
3008     if test $emacs_cv_lesstif = yes; then
3009       # Make sure this -I option remains in CPPFLAGS after it is set
3010       # back to REAL_CPPFLAGS.
3011       # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
3012       # have those other -I options anyway.  Ultimately, having this
3013       # directory ultimately in CPPFLAGS will be enough.
3014       REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
3015       LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
3016     else
3017       CFLAGS=$OLD_CFLAGS
3018       CPPFLAGS=$OLD_CPPFLAGS
3019     fi
3020   fi
3021   AC_CHECK_HEADER([Xm/BulletinB.h], [],
3022     [AC_MSG_ERROR([Motif toolkit requested but requirements not found.])])
3025 dnl Use toolkit scroll bars if configured for GTK or X toolkit and either
3026 dnl using Motif or Xaw3d is available, and unless
3027 dnl --with-toolkit-scroll-bars=no was specified.
3029 AH_TEMPLATE(USE_TOOLKIT_SCROLL_BARS,
3030             [Define to 1 if we should use toolkit scroll bars.])dnl
3031 USE_TOOLKIT_SCROLL_BARS=no
3032 if test "${with_toolkit_scroll_bars}" != "no"; then
3033   if test "${USE_X_TOOLKIT}" != "none"; then
3034     if test "${USE_X_TOOLKIT}" = "MOTIF"; then
3035       AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3036       HAVE_XAW3D=no
3037       USE_TOOLKIT_SCROLL_BARS=yes
3038     elif test "${HAVE_XAW3D}" = "yes" || test "${USE_X_TOOLKIT}" = "LUCID"; then
3039       AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3040       USE_TOOLKIT_SCROLL_BARS=yes
3041     fi
3042   elif test "${HAVE_GTK}" = "yes"; then
3043     AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3044     USE_TOOLKIT_SCROLL_BARS=yes
3045   elif test "${HAVE_NS}" = "yes"; then
3046     AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3047     USE_TOOLKIT_SCROLL_BARS=yes
3048   elif test "${HAVE_W32}" = "yes"; then
3049     AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3050     USE_TOOLKIT_SCROLL_BARS=yes
3051   fi
3054 dnl See if XIM is available.
3055 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3056           #include <X11/Xlib.h>
3057           #include <X11/Xresource.h>]],
3058          [[XIMProc  callback;]])],
3059          [HAVE_XIM=yes
3060          AC_DEFINE(HAVE_XIM, 1, [Define to 1 if XIM is available])],
3061          HAVE_XIM=no)
3063 dnl '--with-xim' now controls only the initial value of use_xim at run time.
3065 if test "${with_xim}" != "no"; then
3066   AC_DEFINE(USE_XIM, 1,
3067             [Define to 1 if we should use XIM, if it is available.])
3071 if test "${HAVE_XIM}" != "no"; then
3072   late_CFLAGS=$CFLAGS
3073   if test "$GCC" = yes; then
3074     CFLAGS="$CFLAGS --pedantic-errors"
3075   fi
3076   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3077 #include <X11/Xlib.h>
3078 #include <X11/Xresource.h>]],
3079 [[Display *display;
3080 XrmDatabase db;
3081 char *res_name;
3082 char *res_class;
3083 XIMProc  callback;
3084 XPointer *client_data;
3085 #ifndef __GNUC__
3086 /* If we're not using GCC, it's probably not XFree86, and this is
3087    probably right, but we can't use something like --pedantic-errors.  */
3088 extern Bool XRegisterIMInstantiateCallback(Display*, XrmDatabase, char*,
3089                                            char*, XIMProc, XPointer*);
3090 #endif
3091 (void)XRegisterIMInstantiateCallback(display, db, res_name, res_class, callback,
3092    client_data);]])],
3093     [emacs_cv_arg6_star=yes])
3094   AH_TEMPLATE(XRegisterIMInstantiateCallback_arg6,
3095          [Define to the type of the 6th arg of XRegisterIMInstantiateCallback,
3096 either XPointer or XPointer*.])dnl
3097   if test "$emacs_cv_arg6_star" = yes; then
3098     AC_DEFINE(XRegisterIMInstantiateCallback_arg6, [XPointer*])
3099   else
3100     AC_DEFINE(XRegisterIMInstantiateCallback_arg6, [XPointer])
3101   fi
3102   CFLAGS=$late_CFLAGS
3105 ### Start of font-backend (under any platform) section.
3106 # (nothing here yet -- this is a placeholder)
3107 ### End of font-backend (under any platform) section.
3109 ### Start of font-backend (under X11) section.
3110 if test "${HAVE_X11}" = "yes"; then
3111     ## Use -lXft if available, unless '--with-xft=no'.
3112     HAVE_XFT=maybe
3113     if test "x${with_x}" = "xno"; then
3114       with_xft="no";
3115     fi
3117     if test "$with_xft" != no; then
3118       EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
3119       with_xft=$HAVE_FONTCONFIG
3120     fi
3122     if test "x${with_xft}" != "xno"; then
3124       EMACS_CHECK_MODULES([XFT], [xft >= 0.13.0], [], [HAVE_XFT=no])
3125       ## Because xftfont.c uses XRenderQueryExtension, we also
3126       ## need to link to -lXrender.
3127       HAVE_XRENDER=no
3128       AC_CHECK_LIB(Xrender, XRenderQueryExtension, HAVE_XRENDER=yes)
3129       if test "$HAVE_XFT" != no && test "$HAVE_XRENDER" != no; then
3130         OLD_CPPFLAGS="$CPPFLAGS"
3131         OLD_CFLAGS="$CFLAGS"
3132         OLD_LIBS="$LIBS"
3133         CPPFLAGS="$CPPFLAGS $XFT_CFLAGS"
3134         CFLAGS="$CFLAGS $XFT_CFLAGS"
3135         XFT_LIBS="-lXrender $XFT_LIBS"
3136         LIBS="$XFT_LIBS $LIBS"
3137         AC_CHECK_HEADER(X11/Xft/Xft.h,
3138           AC_CHECK_LIB(Xft, XftFontOpen, HAVE_XFT=yes, , $XFT_LIBS) , ,
3139           [[#include <X11/X.h>]])
3141         if test "${HAVE_XFT}" = "yes"; then
3142           AC_DEFINE(HAVE_XFT, 1, [Define to 1 if you have the Xft library.])
3143             AC_SUBST(XFT_LIBS)
3144           C_SWITCH_X_SITE="$C_SWITCH_X_SITE $XFT_CFLAGS"
3145         fi                        # "${HAVE_XFT}" = "yes"
3146         CPPFLAGS=$OLD_CPPFLAGS
3147         CFLAGS=$OLD_CFLAGS
3148         LIBS=$OLD_LIBS
3149       fi                          # "$HAVE_XFT" != no
3150     fi                            # "x${with_xft}" != "xno"
3152     ## We used to allow building with FreeType and without Xft.
3153     ## However, the ftx font backend driver is not in good shape.
3154     if test "$HAVE_XFT" != "yes"; then
3155        dnl For the "Does Emacs use" message at the end.
3156        HAVE_XFT=no
3157        HAVE_FREETYPE=no
3158     else
3159        dnl Strict linkers fail with
3160        dnl ftfont.o: undefined reference to symbol 'FT_New_Face'
3161        dnl if -lfreetype is not specified.
3162        dnl The following is needed to set FREETYPE_LIBS.
3163        EMACS_CHECK_MODULES([FREETYPE], [freetype2])
3165        test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(libxft requires libfreetype)
3166     fi
3168     HAVE_LIBOTF=no
3169     if test "${HAVE_FREETYPE}" = "yes"; then
3170       AC_DEFINE(HAVE_FREETYPE, 1,
3171                 [Define to 1 if using the freetype and fontconfig libraries.])
3172       if test "${with_libotf}" != "no"; then
3173         EMACS_CHECK_MODULES([LIBOTF], [libotf])
3174         if test "$HAVE_LIBOTF" = "yes"; then
3175           AC_DEFINE(HAVE_LIBOTF, 1, [Define to 1 if using libotf.])
3176           AC_CHECK_LIB(otf, OTF_get_variation_glyphs,
3177                        HAVE_OTF_GET_VARIATION_GLYPHS=yes,
3178                        HAVE_OTF_GET_VARIATION_GLYPHS=no)
3179           if test "${HAVE_OTF_GET_VARIATION_GLYPHS}" = "yes"; then
3180             AC_DEFINE(HAVE_OTF_GET_VARIATION_GLYPHS, 1,
3181                       [Define to 1 if libotf has OTF_get_variation_glyphs.])
3182           fi
3183         fi
3184       fi
3185     dnl FIXME should there be an error if HAVE_FREETYPE != yes?
3186     dnl Does the new font backend require it, or can it work without it?
3187     fi
3189     HAVE_M17N_FLT=no
3190     if test "${HAVE_LIBOTF}" = yes; then
3191       if test "${with_m17n_flt}" != "no"; then
3192         EMACS_CHECK_MODULES([M17N_FLT], [m17n-flt])
3193         if test "$HAVE_M17N_FLT" = "yes"; then
3194           AC_DEFINE(HAVE_M17N_FLT, 1, [Define to 1 if using libm17n-flt.])
3195         fi
3196       fi
3197     fi
3198 else
3199     HAVE_XFT=no
3200     HAVE_FREETYPE=no
3201     HAVE_LIBOTF=no
3202     HAVE_M17N_FLT=no
3205 ### End of font-backend (under X11) section.
3207 AC_SUBST(FREETYPE_CFLAGS)
3208 AC_SUBST(FREETYPE_LIBS)
3209 AC_SUBST(FONTCONFIG_CFLAGS)
3210 AC_SUBST(FONTCONFIG_LIBS)
3211 AC_SUBST(LIBOTF_CFLAGS)
3212 AC_SUBST(LIBOTF_LIBS)
3213 AC_SUBST(M17N_FLT_CFLAGS)
3214 AC_SUBST(M17N_FLT_LIBS)
3216 HAVE_CAIRO=no
3217 if test "${HAVE_X11}" = "yes"; then
3218   if test "${with_cairo}" != "no"; then
3219     CAIRO_REQUIRED=1.12.0
3220     CAIRO_MODULE="cairo >= $CAIRO_REQUIRED"
3221     EMACS_CHECK_MODULES(CAIRO, $CAIRO_MODULE)
3222     if test $HAVE_CAIRO = yes; then
3223       AC_DEFINE(USE_CAIRO, 1, [Define to 1 if using cairo.])
3224     else
3225       AC_MSG_ERROR([cairo requested but not found.])
3226     fi
3228     CFLAGS="$CFLAGS $CAIRO_CFLAGS"
3229     LIBS="$LIBS $CAIRO_LIBS"
3230     AC_SUBST(CAIRO_CFLAGS)
3231     AC_SUBST(CAIRO_LIBS)
3232   fi
3235 if test "${HAVE_X11}" = "yes"; then
3236   AC_CHECK_HEADER(X11/Xlib-xcb.h,
3237     AC_CHECK_LIB(xcb, xcb_translate_coordinates, HAVE_XCB=yes))
3238   if test "${HAVE_XCB}" = "yes"; then
3239     AC_CHECK_LIB(X11-xcb, XGetXCBConnection, HAVE_X11_XCB=yes)
3240     if test "${HAVE_X11_XCB}" = "yes"; then
3241       AC_DEFINE(USE_XCB, 1,
3242 [Define to 1 if you have the XCB library and X11-XCB library for mixed
3243    X11/XCB programming.])
3244       XCB_LIBS="-lX11-xcb -lxcb"
3245       AC_SUBST(XCB_LIBS)
3246     fi
3247   fi
3250 ### Use -lXpm if available, unless '--with-xpm=no'.
3251 ### mingw32 doesn't use -lXpm, since it loads the library dynamically.
3252 ### The Cygwin-w32 build uses <noX/xpm.h> instead of <X11/xpm.h>, so
3253 ### we need to set LDFLAGS accordingly.
3254 HAVE_XPM=no
3255 LIBXPM=
3256 if test "${HAVE_W32}" = "yes" && test "${opsys}" = "cygwin"; then
3257   if test "${with_xpm}" != "no"; then
3258     SAVE_LDFLAGS="$LDFLAGS"
3259     LDFLAGS="$LDFLAGS -L/usr/lib/noX"
3260     AC_CHECK_HEADER(noX/xpm.h,
3261       [AC_CHECK_LIB(Xpm, XpmReadFileToImage, HAVE_XPM=yes)])
3262     if test "${HAVE_XPM}" = "yes"; then
3263       AC_MSG_CHECKING(for XpmReturnAllocPixels preprocessor define)
3264       AC_EGREP_CPP(no_return_alloc_pixels,
3265       [#include "noX/xpm.h"
3266 #ifndef XpmReturnAllocPixels
3267 no_return_alloc_pixels
3268 #endif
3269       ], HAVE_XPM=no, HAVE_XPM=yes)
3271       if test "${HAVE_XPM}" = "yes"; then
3272         AC_MSG_RESULT(yes)
3273       else
3274         AC_MSG_RESULT(no)
3275         LDFLAGS="$SAVE_LDFLAGS"
3276       fi
3277     fi
3278   fi
3280   if test "${HAVE_XPM}" = "yes"; then
3281     AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
3282     LIBXPM=-lXpm
3283   fi
3286 if test "${HAVE_X11}" = "yes"; then
3287   dnl Avoid Xpm on AIX unless requested, as it crashes; see Bug#17598.
3288   test "$opsys$with_xpm_set" = aix4-2 && with_xpm=no
3290   if test "${with_xpm}" != "no"; then
3291     AC_CHECK_HEADER(X11/xpm.h,
3292       [AC_CHECK_LIB(Xpm, XpmReadFileToPixmap, HAVE_XPM=yes, , -lX11)])
3293     if test "${HAVE_XPM}" = "yes"; then
3294       AC_MSG_CHECKING(for XpmReturnAllocPixels preprocessor define)
3295       AC_EGREP_CPP(no_return_alloc_pixels,
3296       [#include "X11/xpm.h"
3297 #ifndef XpmReturnAllocPixels
3298 no_return_alloc_pixels
3299 #endif
3300       ], HAVE_XPM=no, HAVE_XPM=yes)
3302       if test "${HAVE_XPM}" = "yes"; then
3303         AC_MSG_RESULT(yes)
3304       else
3305         AC_MSG_RESULT(no)
3306       fi
3307     fi
3308   fi
3310   if test "${HAVE_XPM}" = "yes"; then
3311     AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
3312     LIBXPM=-lXpm
3313   elif test "$opsys,$LUCID_LIBW" = aix4-2,-lXaw; then
3314     dnl AIX -lXaw needs -lXpm linked too; see Bug#17598 Message#152.
3315     LIBXPM=-lXpm
3316   fi
3319 ### FIXME: Perhaps regroup to minimize code duplication due to MinGW's
3320 ### slightly different requirements wrt image libraries (it doesn't
3321 ### use -lXpm because it loads the xpm shared library dynamically at
3322 ### run time).
3323 if test "${opsys}" = "mingw32"; then
3324   if test "${with_xpm}" != "no"; then
3325     AC_CHECK_HEADER(X11/xpm.h, HAVE_XPM=yes, HAVE_XPM=no, [
3326 #define FOR_MSW 1])
3327   fi
3329   if test "${HAVE_XPM}" = "yes"; then
3330     AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
3331   fi
3334 AC_SUBST(LIBXPM)
3336 ### Use -ljpeg if available, unless '--with-jpeg=no'.
3337 HAVE_JPEG=no
3338 LIBJPEG=
3339 if test "${with_jpeg}" != "no"; then
3340   AC_CACHE_CHECK([for jpeglib 6b or later],
3341     [emacs_cv_jpeglib],
3342     [OLD_LIBS=$LIBS
3343      for emacs_cv_jpeglib in yes -ljpeg no; do
3344        case $emacs_cv_jpeglib in
3345          yes) ;;
3346          no) break;;
3347          *) LIBS="$LIBS $emacs_cv_jpeglib";;
3348        esac
3349        AC_LINK_IFELSE(
3350          [AC_LANG_PROGRAM(
3351             [[#undef HAVE_STDLIB_H /* Avoid config.h/jpeglib.h collision.  */
3352               #include <stdio.h> /* jpeglib.h needs FILE and size_t.  */
3353               #include <jpeglib.h>
3354               #include <jerror.h>
3355               char verify[JPEG_LIB_VERSION < 62 ? -1 : 1];
3356               struct jpeg_decompress_struct cinfo;
3357             ]],
3358             [[
3359               jpeg_create_decompress (&cinfo);
3360               WARNMS (&cinfo, JWRN_JPEG_EOF);
3361               jpeg_destroy_decompress (&cinfo);
3362             ]])],
3363          [emacs_link_ok=yes],
3364          [emacs_link_ok=no])
3365        LIBS=$OLD_LIBS
3366        test $emacs_link_ok = yes && break
3367      done])
3368   if test "$emacs_cv_jpeglib" != no; then
3369     HAVE_JPEG=yes
3370     AC_DEFINE([HAVE_JPEG], 1,
3371       [Define to 1 if you have the jpeg library (typically -ljpeg).])
3372     ### mingw32 doesn't use -ljpeg, since it loads the library
3373     ### dynamically when needed, and doesn't want a run-time
3374     ### dependency on the jpeglib DLL.
3375     test "$emacs_cv_jpeglib" != yes && test "${opsys}" != "mingw32" \
3376     && LIBJPEG=$emacs_cv_jpeglib
3377   fi
3379 AC_SUBST(LIBJPEG)
3381 HAVE_ZLIB=no
3382 LIBZ=
3383 if test "${with_zlib}" != "no"; then
3384   OLIBS=$LIBS
3385   AC_SEARCH_LIBS([inflateEnd], [z], [HAVE_ZLIB=yes])
3386   LIBS=$OLIBS
3387   case $ac_cv_search_inflateEnd in
3388     -*) LIBZ=$ac_cv_search_inflateEnd ;;
3389   esac
3391 if test "${HAVE_ZLIB}" = "yes"; then
3392   AC_DEFINE([HAVE_ZLIB], 1, [Define to 1 if you have the zlib library (-lz).])
3393   ### mingw32 doesn't use -lz, since it loads the library dynamically.
3394   if test "${opsys}" = "mingw32"; then
3395      LIBZ=
3396   fi
3398 AC_SUBST(LIBZ)
3400 ### Dynamic modules support
3401 LIBMODULES=
3402 HAVE_MODULES=no
3403 MODULES_OBJ=
3404 MODULES_SUFFIX=
3405 if test "${with_modules}" != "no"; then
3406   case $opsys in
3407     gnu|gnu-linux)
3408       LIBMODULES="-ldl"
3409       MODULES_SUFFIX=".so"
3410       HAVE_MODULES=yes
3411       ;;
3412     cygwin|mingw32)
3413       MODULES_SUFFIX=".dll"
3414       HAVE_MODULES=yes
3415       ;;
3416     darwin)
3417       MODULES_SUFFIX=".so"
3418       HAVE_MODULES=yes
3419       ;;
3420     *)
3421       # BSD systems have dlopen in libc.
3422       AC_CHECK_FUNC([dlopen],
3423         [MODULES_SUFFIX=".so"
3424          HAVE_MODULES=yes])
3425       ;;
3426   esac
3428   if test "${HAVE_MODULES}" = no; then
3429     AC_MSG_ERROR([Dynamic modules are not supported on your system])
3430   else
3431     SAVE_LIBS=$LIBS
3432     LIBS="$LIBS $LIBMODULES"
3433     AC_CHECK_FUNCS([dladdr dlfunc])
3434     LIBS=$SAVE_LIBS
3435   fi
3438 if test "${HAVE_MODULES}" = yes; then
3439    MODULES_OBJ="dynlib.o emacs-module.o"
3440    AC_DEFINE(HAVE_MODULES, 1, [Define to 1 if dynamic modules are enabled])
3441    AC_DEFINE_UNQUOTED(MODULES_SUFFIX, "$MODULES_SUFFIX",
3442      [System extension for dynamic libraries])
3444 AC_SUBST(MODULES_OBJ)
3445 AC_SUBST(LIBMODULES)
3447 ### Use -lpng if available, unless '--with-png=no'.
3448 HAVE_PNG=no
3449 LIBPNG=
3450 PNG_CFLAGS=
3451 if test "${NS_IMPL_COCOA}" = yes; then
3452   : # Nothing to do
3453 elif test "${with_png}" != no; then
3454   # mingw32 loads the library dynamically.
3455   if test "$opsys" = mingw32; then
3456     AC_CHECK_HEADER([png.h], [HAVE_PNG=yes])
3457   elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
3458     AC_MSG_CHECKING([for png])
3459     png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` &&
3460     png_libs=`(libpng-config --libs) 2>&AS_MESSAGE_LOG_FD` || {
3461       # libpng-config does not work; configure by hand.
3462       # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
3463       # in /usr/include/libpng.
3464       if test -r /usr/include/libpng/png.h &&
3465          test ! -r /usr/include/png.h; then
3466         png_cflags=-I/usr/include/libpng
3467       else
3468         png_cflags=
3469       fi
3470       png_libs='-lpng'
3471     }
3472     SAVE_CFLAGS=$CFLAGS
3473     SAVE_LIBS=$LIBS
3474     CFLAGS="$CFLAGS $png_cflags"
3475     LIBS="$png_libs -lz -lm $LIBS"
3476     AC_LINK_IFELSE(
3477       [AC_LANG_PROGRAM([[#include <png.h>]],
3478          [[return !png_get_channels (0, 0);]])],
3479       [HAVE_PNG=yes
3480        PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"`
3481        LIBPNG=$png_libs
3482        # $LIBPNG requires explicit -lz in some cases.
3483        # We don't know what those cases are, exactly, so play it safe and
3484        # append -lz to any nonempty $LIBPNG, unless we're already using LIBZ.
3485        if test -n "$LIBPNG" && test -z "$LIBZ"; then
3486          LIBPNG="$LIBPNG -lz"
3487        fi])
3488     CFLAGS=$SAVE_CFLAGS
3489     LIBS=$SAVE_LIBS
3490     AC_MSG_RESULT([$HAVE_PNG])
3491   fi
3493 if test $HAVE_PNG = yes; then
3494   AC_DEFINE([HAVE_PNG], [1], [Define to 1 if you have the png library.])
3496   SAVE_CFLAGS=$CFLAGS
3497   CFLAGS="$CFLAGS $PNG_CFLAGS"
3498   AC_CHECK_DECL([png_longjmp],
3499     [],
3500     [AC_DEFINE([PNG_DEPSTRUCT], [],
3501        [Define to empty to suppress deprecation warnings when building
3502         with --enable-gcc-warnings and with libpng versions before 1.5,
3503         which lack png_longjmp.])],
3504     [[#include <png.h>
3505     ]])
3506   CFLAGS=$SAVE_CFLAGS
3508 AC_SUBST(LIBPNG)
3509 AC_SUBST(PNG_CFLAGS)
3511 ### Use -ltiff if available, unless '--with-tiff=no'.
3512 ### mingw32 doesn't use -ltiff, since it loads the library dynamically.
3513 HAVE_TIFF=no
3514 LIBTIFF=
3515 if test "${opsys}" = "mingw32"; then
3516   if test "${with_tiff}" != "no"; then
3517     AC_CHECK_HEADER(tiffio.h, HAVE_TIFF=yes, HAVE_TIFF=no)
3518   fi
3519   if test "${HAVE_TIFF}" = "yes"; then
3520     AC_DEFINE(HAVE_TIFF, 1, [Define to 1 if you have the tiff library (-ltiff).])
3521   fi
3522 elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
3523   if test "${with_tiff}" != "no"; then
3524     AC_CHECK_HEADER(tiffio.h,
3525       [tifflibs="-lz -lm"
3526       # At least one tiff package requires the jpeg library.
3527       if test "${HAVE_JPEG}" = yes; then tifflibs="-ljpeg $tifflibs"; fi
3528       AC_CHECK_LIB(tiff, TIFFGetVersion, HAVE_TIFF=yes, , $tifflibs)])
3529   fi
3531   if test "${HAVE_TIFF}" = "yes"; then
3532     AC_DEFINE(HAVE_TIFF, 1, [Define to 1 if you have the tiff library (-ltiff).])
3533     dnl FIXME -lz -lm, as per libpng?
3534     LIBTIFF=-ltiff
3535   fi
3537 AC_SUBST(LIBTIFF)
3539 ### Use -lgif or -lungif if available, unless '--with-gif=no'.
3540 ### mingw32 doesn't use -lgif/-lungif, since it loads the library dynamically.
3541 HAVE_GIF=no
3542 LIBGIF=
3543 if test "${opsys}" = "mingw32"; then
3544   if test "${with_gif}" != "no"; then
3545     AC_CHECK_HEADER(gif_lib.h, HAVE_GIF=yes, HAVE_GIF=no)
3546   fi
3547   if test "${HAVE_GIF}" = "yes"; then
3548     AC_DEFINE(HAVE_GIF, 1, [Define to 1 if you have a gif (or ungif) library.])
3549   fi
3550 elif test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no" \
3551         || test "${HAVE_W32}" = "yes"; then
3552   AC_CHECK_HEADER(gif_lib.h,
3553 # EGifPutExtensionLast only exists from version libungif-4.1.0b1.
3554 # Earlier versions can crash Emacs, but version 5.0 removes EGifPutExtensionLast.
3555     [AC_CHECK_LIB(gif, GifMakeMapObject, HAVE_GIF=yes,
3556         [AC_CHECK_LIB(gif, EGifPutExtensionLast, HAVE_GIF=yes, HAVE_GIF=maybe)])])
3558   if test "$HAVE_GIF" = yes; then
3559     LIBGIF=-lgif
3560   elif test "$HAVE_GIF" = maybe; then
3561 # If gif_lib.h but no libgif, try libungif.
3562     AC_CHECK_LIB(ungif, EGifPutExtensionLast, HAVE_GIF=yes, HAVE_GIF=no)
3563     test "$HAVE_GIF" = yes && LIBGIF=-lungif
3564   fi
3566   if test "${HAVE_GIF}" = "yes"; then
3567     AC_DEFINE(HAVE_GIF, 1, [Define to 1 if you have a gif (or ungif) library.])
3568   fi
3570 AC_SUBST(LIBGIF)
3572 dnl Check for required libraries.
3573 MISSING=
3574 WITH_NO=
3575 if test "${HAVE_X11}" = "yes"; then
3576   test "${with_xpm}" != "no" && test "${HAVE_XPM}" != "yes" &&
3577     MISSING="libXpm" && WITH_NO="--with-xpm=no"
3578   test "${with_jpeg}" != "no" && test "${HAVE_JPEG}" != "yes" &&
3579     MISSING="$MISSING libjpeg" && WITH_NO="$WITH_NO --with-jpeg=no"
3580   test "${with_png}" != "no" && test "${HAVE_PNG}" != "yes" &&
3581     MISSING="$MISSING libpng" && WITH_NO="$WITH_NO --with-png=no"
3582   test "${with_gif}" != "no" && test "${HAVE_GIF}" != "yes" &&
3583     MISSING="$MISSING libgif/libungif" && WITH_NO="$WITH_NO --with-gif=no"
3584   test "${with_tiff}" != "no" && test "${HAVE_TIFF}" != "yes" &&
3585     MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no"
3587 test "${with_gnutls}" != "no" && test "${HAVE_GNUTLS}" != "yes" &&
3588   MISSING="$MISSING gnutls" && WITH_NO="$WITH_NO --with-gnutls=no"
3589 if test "X${MISSING}" != X; then
3590   AC_MSG_ERROR([The following required libraries were not found:
3591     $MISSING
3592 Maybe some development libraries/packages are missing?
3593 If you don't want to link with them give
3594     $WITH_NO
3595 as options to configure])
3598 ### Use -lgpm if available, unless '--with-gpm=no'.
3599 HAVE_GPM=no
3600 LIBGPM=
3601 if test "${with_gpm}" != "no"; then
3602   AC_CHECK_HEADER(gpm.h,
3603     [AC_CHECK_LIB(gpm, Gpm_Open, HAVE_GPM=yes)])
3605   if test "${HAVE_GPM}" = "yes"; then
3606     AC_DEFINE(HAVE_GPM, 1, [Define to 1 if you have the gpm library (-lgpm).])
3607     LIBGPM=-lgpm
3608   fi
3610 AC_SUBST(LIBGPM)
3612 dnl Check for malloc/malloc.h on darwin
3613 AC_CHECK_HEADERS_ONCE(malloc/malloc.h)
3615 GNUSTEP_CFLAGS=
3616 ### Use NeXTstep API to implement GUI.
3617 if test "${HAVE_NS}" = "yes"; then
3618   AC_DEFINE(HAVE_NS, 1, [Define to 1 if you are using the NeXTstep API, either GNUstep or Cocoa on Mac OS X.])
3619   if test "${NS_IMPL_COCOA}" = "yes"; then
3620     AC_DEFINE(NS_IMPL_COCOA, 1, [Define to 1 if you are using NS windowing under MacOS X.])
3621   fi
3622   if test "${NS_IMPL_GNUSTEP}" = "yes"; then
3623     AC_DEFINE(NS_IMPL_GNUSTEP, 1, [Define to 1 if you are using NS windowing under GNUstep.])
3624     if test $NS_GNUSTEP_CONFIG != yes; then
3625       # See also .m.o rule in src/Makefile.in.  */
3626       # FIXME: are all these flags really needed?  Document here why.  */
3627       GNUSTEP_CFLAGS="-D_REENTRANT -fPIC -fno-strict-aliasing -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
3628       ## Extra CFLAGS applied to src/*.m files.
3629       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"
3630     fi
3631   fi
3632   OTHER_FILES=ns-app
3635 ### Use session management (-lSM -lICE) if available
3636 HAVE_X_SM=no
3637 LIBXSM=
3638 if test "${HAVE_X11}" = "yes"; then
3639   AC_CHECK_HEADER(X11/SM/SMlib.h,
3640     [AC_CHECK_LIB(SM, SmcOpenConnection, HAVE_X_SM=yes, , -lICE)])
3642   if test "${HAVE_X_SM}" = "yes"; then
3643     AC_DEFINE(HAVE_X_SM, 1, [Define to 1 if you have the SM library (-lSM).])
3644     LIBXSM="-lSM -lICE"
3645   fi
3647 AC_SUBST(LIBXSM)
3649 ### Use XRandr (-lXrandr) if available
3650 HAVE_XRANDR=no
3651 if test "${HAVE_X11}" = "yes"; then
3652   XRANDR_REQUIRED=1.2.2
3653   XRANDR_MODULES="xrandr >= $XRANDR_REQUIRED"
3654   EMACS_CHECK_MODULES([XRANDR], [$XRANDR_MODULES])
3655   if test $HAVE_XRANDR = no; then
3656     # Test old way in case pkg-config doesn't have it (older machines).
3657     # Include Xrender.h by hand to work around bug in older Xrandr.h
3658     # (e.g. RHEL5) and silence (harmless) configure warning (bug#18465).
3659     AC_CHECK_HEADER(X11/extensions/Xrandr.h,
3660       [AC_CHECK_LIB(Xrandr, XRRGetScreenResources, HAVE_XRANDR=yes)],
3661       [], [AC_INCLUDES_DEFAULT
3662 #include <X11/extensions/Xrender.h>])
3663     if test $HAVE_XRANDR = yes; then
3664       XRANDR_LIBS=-lXrandr
3665     fi
3666   fi
3667   if test $HAVE_XRANDR = yes; then
3668     AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you have the XRandr extension.])
3669   fi
3671 AC_SUBST(XRANDR_CFLAGS)
3672 AC_SUBST(XRANDR_LIBS)
3674 ### Use Xinerama (-lXinerama) if available
3675 HAVE_XINERAMA=no
3676 if test "${HAVE_X11}" = "yes"; then
3677   XINERAMA_REQUIRED=1.0.2
3678   XINERAMA_MODULES="xinerama >= $XINERAMA_REQUIRED"
3679   EMACS_CHECK_MODULES([XINERAMA], [$XINERAMA_MODULES])
3680   if test $HAVE_XINERAMA = no; then
3681     # Test old way in case pkg-config doesn't have it (older machines).
3682     AC_CHECK_HEADER(X11/extensions/Xinerama.h,
3683       [AC_CHECK_LIB(Xinerama, XineramaQueryExtension, HAVE_XINERAMA=yes)])
3684     if test $HAVE_XINERAMA = yes; then
3685       XINERAMA_LIBS=-lXinerama
3686     fi
3687   fi
3688   if test $HAVE_XINERAMA = yes; then
3689     AC_DEFINE(HAVE_XINERAMA, 1, [Define to 1 if you have the Xinerama extension.])
3690   fi
3692 AC_SUBST(XINERAMA_CFLAGS)
3693 AC_SUBST(XINERAMA_LIBS)
3695 ### Use Xfixes (-lXfixes) if available
3696 HAVE_XFIXES=no
3697 if test "${HAVE_X11}" = "yes"; then
3698   XFIXES_REQUIRED=4.0.0
3699   XFIXES_MODULES="xfixes >= $XFIXES_REQUIRED"
3700   EMACS_CHECK_MODULES([XFIXES], [$XFIXES_MODULES])
3701   if test $HAVE_XFIXES = no; then
3702     # Test old way in case pkg-config doesn't have it (older machines).
3703     AC_CHECK_HEADER(X11/extensions/Xfixes.h,
3704       [AC_CHECK_LIB(Xfixes, XFixesHideCursor, HAVE_XFIXES=yes)])
3705     if test $HAVE_XFIXES = yes; then
3706       XFIXES_LIBS=-lXfixes
3707     fi
3708   fi
3709   if test $HAVE_XFIXES = yes; then
3710     AC_DEFINE(HAVE_XFIXES, 1, [Define to 1 if you have the Xfixes extension.])
3711   fi
3713 AC_SUBST(XFIXES_CFLAGS)
3714 AC_SUBST(XFIXES_LIBS)
3716 ### Use libxml (-lxml2) if available
3717 ### mingw32 doesn't use -lxml2, since it loads the library dynamically.
3718 HAVE_LIBXML2=no
3719 if test "${with_xml2}" != "no"; then
3720   ### I'm not sure what the version number should be, so I just guessed.
3721   EMACS_CHECK_MODULES([LIBXML2], [libxml-2.0 > 2.6.17])
3722   # Built-in libxml2 on OS X 10.8 lacks libxml-2.0.pc.
3723   if test "${HAVE_LIBXML2}" != "yes" && test "$opsys" = "darwin"; then
3724     SAVE_CPPFLAGS="$CPPFLAGS"
3725     if test -z "$xcsdkdir" -a -n "$XCRUN" -a ! -d /usr/include; then
3726       dnl /usr/include is not found.  Try Xcode SDK dir if it is sane.
3727       xcsdkdir=`$XCRUN --show-sdk-path 2>/dev/null`
3728       case $xcsdkdir in
3729         *[[\\\"\#\$\&\'\`$am_lf\ \      ]]*)
3730         xcsdkdir="" ;;
3731       esac
3732     fi
3733     CPPFLAGS="$CPPFLAGS -I$xcsdkdir/usr/include/libxml2"
3734     AC_CHECK_HEADER(libxml/HTMLparser.h,
3735       [AC_CHECK_DECL(HTML_PARSE_RECOVER, HAVE_LIBXML2=yes, ,
3736                      [#include <libxml/HTMLparser.h>])])
3737     CPPFLAGS="$SAVE_CPPFLAGS"
3738     if test "${HAVE_LIBXML2}" = "yes"; then
3739       LIBXML2_CFLAGS="-I'$xcsdkdir/usr/include/libxml2'"
3740       LIBXML2_LIBS="-lxml2"
3741     fi
3742   fi
3743   if test "${HAVE_LIBXML2}" = "yes"; then
3744     if test "${opsys}" != "mingw32"; then
3745       AC_CHECK_LIB(xml2, htmlReadMemory, HAVE_LIBXML2=yes, HAVE_LIBXML2=no,
3746         [$LIBXML2_LIBS])
3747     else
3748       LIBXML2_LIBS=""
3749     fi
3750     if test "${HAVE_LIBXML2}" = "yes"; then
3751       AC_DEFINE(HAVE_LIBXML2, 1, [Define to 1 if you have the libxml library (-lxml2).])
3752     else
3753       LIBXML2_LIBS=""
3754       LIBXML2_CFLAGS=""
3755     fi
3756   fi
3758 AC_SUBST(LIBXML2_LIBS)
3759 AC_SUBST(LIBXML2_CFLAGS)
3761 # Check for mail-locking functions in a "mail" library.  Probably this should
3762 # have the same check as for liblockfile below.
3763 AC_CHECK_LIB(mail, maillock, have_mail=yes, have_mail=no)
3764 if test $have_mail = yes; then
3765   LIBS_MAIL=-lmail
3766   AC_DEFINE(HAVE_LIBMAIL, 1, [Define to 1 if you have the 'mail' library (-lmail).])
3768   OLD_LIBS=$LIBS
3769   LIBS="$LIBS_MAIL $LIBS"
3770   AC_CHECK_FUNCS(touchlock)
3771   LIBS=$OLD_LIBS
3772 else
3773   LIBS_MAIL=
3775 dnl Debian, at least:
3776 AC_CHECK_LIB(lockfile, maillock, have_lockfile=yes, have_lockfile=no)
3777 if test $have_lockfile = yes; then
3778    LIBS_MAIL=-llockfile
3779    AC_DEFINE(HAVE_LIBLOCKFILE, 1, [Define to 1 if you have the 'lockfile' library (-llockfile).])
3780 else
3781 # If we have the shared liblockfile, assume we must use it for mail
3782 # locking (e.g. Debian).  If we couldn't link against liblockfile
3783 # (no liblockfile.a installed), ensure that we don't need to.
3784   dnl This works for files generally, not just executables.
3785   dnl Should we look elsewhere for it?  Maybe examine /etc/ld.so.conf?
3786   AC_CHECK_PROG(liblockfile, liblockfile.so, yes, no,
3787                 /usr/lib:/lib:/usr/local/lib:$LD_LIBRARY_PATH)
3788   if test $ac_cv_prog_liblockfile = yes; then
3789     AC_MSG_ERROR([Shared liblockfile found but can't link against it.
3790 This probably means that movemail could lose mail.
3791 There may be a 'development' package to install containing liblockfile.])
3792   fi
3794 AC_CHECK_HEADERS_ONCE(maillock.h)
3795 AC_SUBST(LIBS_MAIL)
3797 ## Define MAIL_USE_FLOCK (or LOCKF) if the mailer uses flock (or lockf) to
3798 ## interlock access to the mail spool.  The alternative is a lock file named
3799 ## /usr/spool/mail/$USER.lock.
3800 mail_lock=no
3801 case "$opsys" in
3802   aix4-2) mail_lock="lockf" ;;
3804   gnu|freebsd|dragonfly|netbsd|openbsd|darwin) mail_lock="flock" ;;
3806   ## On GNU/Linux systems, both methods are used by various mail programs.
3807   ## I assume most people are using newer mailers that have heard of flock.
3808   ## Change this if you need to.
3809   ## Debian contains a patch which says: "On Debian/GNU/Linux systems,
3810   ## configure gets the right answers, and that means *NOT* using flock.
3811   ## Using flock is guaranteed to be the wrong thing. See Debian Policy
3812   ## for details." and then uses '#ifdef DEBIAN'.  Unfortunately the
3813   ## Debian maintainer hasn't provided a clean fix for Emacs.
3814   ## movemail.c will use 'maillock' when MAILDIR, HAVE_LIBMAIL and
3815   ## HAVE_MAILLOCK_H are defined, so the following appears to be the
3816   ## correct logic.  -- fx
3817   ## We must check for HAVE_LIBLOCKFILE too, as movemail does.
3818   ## liblockfile is a Free Software replacement for libmail, used on
3819   ## Debian systems and elsewhere. -rfr.
3820   gnu-*)
3821     mail_lock="flock"
3822     if test $have_mail = yes || test $have_lockfile = yes; then
3823       test $ac_cv_header_maillock_h = yes && mail_lock=no
3824     fi
3825     ;;
3827   mingw32)
3828     mail_lock="none-needed" ;;
3829 esac
3831 BLESSMAIL_TARGET=
3832 case "$mail_lock" in
3833   flock) AC_DEFINE(MAIL_USE_FLOCK, 1, [Define if the mailer uses flock to interlock the mail spool.]) ;;
3835   lockf) AC_DEFINE(MAIL_USE_LOCKF, 1, [Define if the mailer uses lockf to interlock the mail spool.]) ;;
3837   none-needed) ;;
3839   *) BLESSMAIL_TARGET="need-blessmail" ;;
3840 esac
3841 AC_SUBST(BLESSMAIL_TARGET)
3843 OLD_LIBS=$LIBS
3844 LIBS="$LIB_PTHREAD $LIB_MATH $LIBS"
3845 AC_CHECK_FUNCS(accept4 fchdir gethostname \
3846 getrusage get_current_dir_name \
3847 lrand48 random rint \
3848 select getpagesize setlocale newlocale \
3849 getrlimit setrlimit shutdown \
3850 pthread_sigmask strsignal setitimer \
3851 sendto recvfrom getsockname getifaddrs freeifaddrs \
3852 gai_strerror sync \
3853 getpwent endpwent getgrent endgrent \
3854 cfmakeraw cfsetspeed copysign __executable_start log2)
3855 LIBS=$OLD_LIBS
3857 dnl No need to check for posix_memalign if aligned_alloc works.
3858 AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break])
3859 AC_CHECK_DECLS([aligned_alloc], [], [], [[#include <stdlib.h>]])
3861 dnl Cannot use AC_CHECK_FUNCS
3862 AC_CACHE_CHECK([for __builtin_unwind_init],
3863                emacs_cv_func___builtin_unwind_init,
3864 [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_unwind_init ();])],
3865                 emacs_cv_func___builtin_unwind_init=yes,
3866                 emacs_cv_func___builtin_unwind_init=no)])
3867 if test $emacs_cv_func___builtin_unwind_init = yes; then
3868   AC_DEFINE(HAVE___BUILTIN_UNWIND_INIT, 1,
3869             [Define to 1 if you have the '__builtin_unwind_init' function.])
3872 AC_CHECK_HEADERS_ONCE(sys/un.h)
3874 AC_FUNC_FSEEKO
3876 # UNIX98 PTYs.
3877 AC_CHECK_FUNCS(grantpt)
3879 # PTY-related GNU extensions.
3880 AC_CHECK_FUNCS(getpt posix_openpt)
3882 # Check this now, so that we will NOT find the above functions in ncurses.
3883 # That is because we have not set up to link ncurses in lib-src.
3884 # It's better to believe a function is not available
3885 # than to expect to find it in ncurses.
3886 # Also we need tputs and friends to be able to build at all.
3887 AC_MSG_CHECKING([for library containing tputs])
3888 # Run a test program that contains a call to tputs, a call that is
3889 # never executed.  This tests whether a pre-'main' dynamic linker
3890 # works with the library.  It's too much trouble to actually call
3891 # tputs in the test program, due to portability hassles.  When
3892 # cross-compiling, assume the test program will run if it links.
3893 AC_DEFUN([tputs_link_source], [
3894   AC_LANG_SOURCE(
3895      [[extern void tputs (const char *, int, int (*)(int));
3896        int main (int argc, char **argv)
3897        {
3898           if (argc == 10000)
3899             tputs (argv[0], 0, 0);
3900           return 0;
3901        }]])
3903 if test "${opsys}" = "mingw32"; then
3904   msg='none required'
3905 else
3906   # Maybe curses should be tried earlier?
3907   # See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9736#35
3908   for tputs_library in '' tinfo ncurses terminfo termcap curses; do
3909     OLIBS=$LIBS
3910     if test -z "$tputs_library"; then
3911       LIBS_TERMCAP=
3912       msg='none required'
3913     else
3914       LIBS_TERMCAP=-l$tputs_library
3915       msg=$LIBS_TERMCAP
3916       LIBS="$LIBS_TERMCAP $LIBS"
3917     fi
3918     AC_RUN_IFELSE([tputs_link_source], [], [msg=no],
3919       [AC_LINK_IFELSE([tputs_link_source], [], [msg=no])])
3920     LIBS=$OLIBS
3921     if test "X$msg" != Xno; then
3922       break
3923     fi
3924   done
3926 AC_MSG_RESULT([$msg])
3927 if test "X$msg" = Xno; then
3928   AC_MSG_ERROR([The required function 'tputs' was not found in any library.
3929 The following libraries were tried (in order):
3930   libtinfo, libncurses, libterminfo, libtermcap, libcurses
3931 Please try installing whichever of these libraries is most appropriate
3932 for your system, together with its header files.
3933 For example, a libncurses-dev(el) or similar package.])
3936 ## Use termcap instead of terminfo?
3937 ## Only true for: freebsd < 40000, ms-w32, msdos, netbsd < 599002500.
3938 TERMINFO=yes
3939 ## FIXME?  In the cases below where we unconditionally set
3940 ## LIBS_TERMCAP="-lncurses", this overrides LIBS_TERMCAP = -ltinfo,
3941 ## if that was found above to have tputs.
3942 ## Should we use the gnu* logic everywhere?
3943 case "$opsys" in
3944   ## darwin: Prevents crashes when running Emacs in Terminal.app under 10.2.
3945   ##  The ncurses library has been moved out of the System framework in
3946   ##  Mac OS X 10.2.  So if configure detects it, set the command-line
3947   ##  option to use it.
3948   darwin) LIBS_TERMCAP="-lncurses" ;;
3950   gnu*) test -z "$LIBS_TERMCAP" && LIBS_TERMCAP="-lncurses" ;;
3952   freebsd)
3953     AC_MSG_CHECKING([whether FreeBSD is new enough to use terminfo])
3954     AC_CACHE_VAL(emacs_cv_freebsd_terminfo,
3955     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <osreldate.h>]],
3956 [[#if __FreeBSD_version < 400000
3957 fail;
3958 #endif
3959 ]])], emacs_cv_freebsd_terminfo=yes, emacs_cv_freebsd_terminfo=no)])
3961     AC_MSG_RESULT($emacs_cv_freebsd_terminfo)
3963     if test $emacs_cv_freebsd_terminfo = yes; then
3964       LIBS_TERMCAP="-lncurses"
3965     else
3966       TERMINFO=no
3967       LIBS_TERMCAP="-ltermcap"
3968     fi
3969     ;;
3971   mingw32)
3972     TERMINFO=no
3973     LIBS_TERMCAP=
3974     ;;
3976   netbsd)
3977     if test "x$LIBS_TERMCAP" != "x-lterminfo"; then
3978       TERMINFO=no
3979       LIBS_TERMCAP="-ltermcap"
3980     fi
3981     ;;
3983   openbsd | dragonfly) LIBS_TERMCAP="-lncurses" ;;
3985   ## hpux: Make sure we get select from libc rather than from libcurses
3986   ##  because libcurses on HPUX 10.10 has a broken version of select.
3987   ##  We used to use -lc -lcurses, but this may be cleaner.
3988   ## FIXME?  But TERMINFO = yes on hpux (it used to be explicitly
3989   # set that way, now it uses the default).  Isn't this a contradiction?
3990   hpux*) LIBS_TERMCAP="-ltermcap" ;;
3992 esac
3994 TERMCAP_OBJ=tparam.o
3995 if test $TERMINFO = yes; then
3996   AC_DEFINE(TERMINFO, 1, [Define to 1 if you use terminfo instead of termcap.])
3997   TERMCAP_OBJ=terminfo.o
3999 if test "X$LIBS_TERMCAP" = "X-lncurses"; then
4000   AC_DEFINE(USE_NCURSES, 1, [Define to 1 if you use ncurses.])
4002 AC_SUBST(LIBS_TERMCAP)
4003 AC_SUBST(TERMCAP_OBJ)
4005 # GNU/Linux-specific timer functions.
4006 AC_CACHE_CHECK([for timerfd interface], [emacs_cv_have_timerfd],
4007   [AC_COMPILE_IFELSE(
4008      [AC_LANG_PROGRAM([[#include <sys/timerfd.h>
4009                       ]],
4010                       [[timerfd_create (CLOCK_REALTIME,
4011                                         TFD_CLOEXEC | TFD_NONBLOCK);
4012                         timerfd_settime (0, TFD_TIMER_ABSTIME, 0, 0);]])],
4013      [emacs_cv_have_timerfd=yes],
4014      [emacs_cv_have_timerfd=no])])
4015 if test "$emacs_cv_have_timerfd" = yes; then
4016   AC_DEFINE([HAVE_TIMERFD], 1,
4017     [Define to 1 if timerfd functions are supported as in GNU/Linux.])
4020 # Alternate stack for signal handlers.
4021 AC_CACHE_CHECK([whether signals can be handled on alternate stack],
4022                [emacs_cv_alternate_stack],
4023   [AC_COMPILE_IFELSE(
4024      [AC_LANG_PROGRAM([[#include <signal.h>
4025                       ]],
4026                       [[stack_t ss;
4027                         struct sigaction sa;
4028                         ss.ss_sp = malloc (SIGSTKSZ);
4029                         ss.ss_size = SIGSTKSZ;
4030                         sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
4031                         sigaltstack (&ss, 0);
4032                         sigaction (SIGSEGV, &sa, 0);]])],
4033      [emacs_cv_alternate_stack=yes],
4034      [emacs_cv_alternate_stack=no])])
4036 # Do we need the Hesiod library to provide the support routines?
4037 dnl FIXME?  Should we be skipping this on Darwin too?
4038 LIBHESIOD=
4039 LIBRESOLV=
4040 if test "$with_hesiod" != no ; then
4041   # Don't set $LIBS here -- see comments above.  FIXME which comments?
4042   resolv=no
4043   AC_CHECK_FUNC(res_send, , [AC_CHECK_FUNC(__res_send, ,
4044      [AC_CHECK_LIB(resolv, res_send, resolv=yes,
4045                   [AC_CHECK_LIB(resolv, __res_send, resolv=yes)])])])
4046   if test "$resolv" = yes ; then
4047     RESOLVLIB=-lresolv
4048   else
4049     RESOLVLIB=
4050   fi
4051   hesiod=no
4052   AC_CHECK_FUNC(hes_getmailhost, , [AC_CHECK_LIB(hesiod, hes_getmailhost,
4053         hesiod=yes, :, $RESOLVLIB)])
4055   if test x"$hesiod" = xyes; then
4056     LIBHESIOD=-lhesiod
4057     LIBRESOLV=$RESOLVLIB
4058   fi
4060 AC_SUBST(LIBHESIOD)
4061 AC_SUBST(LIBRESOLV)
4063 # These tell us which Kerberos-related libraries to use.
4064 COM_ERRLIB=
4065 CRYPTOLIB=
4066 KRB5LIB=
4067 DESLIB=
4068 KRB4LIB=
4070 if test "${with_kerberos}" != no; then
4071   OLD_LIBS=$LIBS
4072   AC_CHECK_LIB(com_err, com_err, have_com_err=yes, have_com_err=no)
4073   if test $have_com_err = yes; then
4074     COM_ERRLIB=-lcom_err
4075     LIBS="$COM_ERRLIB $LIBS"
4076   fi
4077   AC_CHECK_LIB(crypto, mit_des_cbc_encrypt, have_crypto=yes, have_crypto=no)
4078   if test $have_crypto = yes; then
4079     CRYPTOLIB=-lcrypto
4080     LIBS="$CRYPTOLIB $LIBS"
4081   fi
4082   AC_CHECK_LIB(k5crypto, mit_des_cbc_encrypt, have_k5crypto=yes, have_k5crypto=no)
4083   if test $have_k5crypto = yes; then
4084     CRYPTOLIB=-lk5crypto
4085     LIBS="$CRYPTOLIB $LIBS"
4086   fi
4087   AC_CHECK_LIB(krb5, krb5_init_context, have_krb5=yes, have_krb5=no)
4088   if test $have_krb5=yes; then
4089     KRB5LIB=-lkrb5
4090     LIBS="$KRB5LIB $LIBS"
4091   fi
4092   dnl FIXME Simplify.  Does not match 22 logic, thanks to default_off?
4093   if test "${with_kerberos5}" = no; then
4094     AC_CHECK_LIB(des425, des_cbc_encrypt, have_des425=yes, have_des425=no )
4095     if test $have_des425 = yes; then
4096       DESLIB=-ldes425
4097       LIBS="$DESLIB $LIBS"
4098     else
4099       AC_CHECK_LIB(des, des_cbc_encrypt, have_des=yes, have_des=no)
4100       if test $have_des = yes; then
4101         DESLIB=-ldes
4102         LIBS="$DESLIB $LIBS"
4103       fi
4104     fi
4105     AC_CHECK_LIB(krb4, krb_get_cred, have_krb4=yes, have_krb4=no)
4106     if test $have_krb4 = yes; then
4107       KRB4LIB=-lkrb4
4108       LIBS="$KRB4LIB $LIBS"
4109     else
4110       AC_CHECK_LIB(krb, krb_get_cred, have_krb=yes, have_krb=no)
4111       if test $have_krb = yes; then
4112         KRB4LIB=-lkrb
4113         LIBS="$KRB4LIB $LIBS"
4114       fi
4115     fi
4116   fi
4118   if test "${with_kerberos5}" != no; then
4119     AC_CHECK_HEADERS(krb5.h,
4120       [AC_CHECK_MEMBERS([krb5_error.text, krb5_error.e_text],,,
4121                         [#include <krb5.h>])])
4122   else
4123     AC_CHECK_HEADERS(krb.h,,
4124                      [AC_CHECK_HEADERS(kerberosIV/krb.h,,
4125                                        [AC_CHECK_HEADERS(kerberos/krb.h)])])
4126   fi
4127   AC_CHECK_HEADERS(com_err.h)
4128   LIBS=$OLD_LIBS
4131 AC_SUBST(COM_ERRLIB)
4132 AC_SUBST(CRYPTOLIB)
4133 AC_SUBST(KRB5LIB)
4134 AC_SUBST(DESLIB)
4135 AC_SUBST(KRB4LIB)
4137 AC_CHECK_HEADERS(valgrind/valgrind.h)
4139 AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]])
4141 AC_CHECK_FUNCS_ONCE(tzset)
4143 ok_so_far=yes
4144 AC_CHECK_FUNC(socket, , ok_so_far=no)
4145 if test $ok_so_far = yes; then
4146   AC_CHECK_HEADER(netinet/in.h, , ok_so_far=no)
4148 if test $ok_so_far = yes; then
4149   AC_CHECK_HEADER(arpa/inet.h, , ok_so_far=no)
4151 if test $ok_so_far = yes; then
4152 dnl Fixme: Not used.  Should this be HAVE_SOCKETS?
4153   AC_DEFINE(HAVE_INET_SOCKETS, 1,
4154             [Define to 1 if you have inet sockets.])
4157 AC_FUNC_FORK
4159 AC_CHECK_FUNCS(snprintf)
4161 dnl Check for glib.  This differs from other library checks in that
4162 dnl Emacs need not link to glib unless some other library is already
4163 dnl linking to glib.  Although glib provides no facilities that Emacs
4164 dnl needs for its own purposes, when glib is present Emacs needs to
4165 dnl use primitives like g_main_context_query to avoid clashing with
4166 dnl glib at a low level.
4168 dnl Check this late, since it depends on $GTK_CFLAGS etc.
4169 XGSELOBJ=
4170 OLDCFLAGS="$CFLAGS"
4171 OLDLIBS="$LIBS"
4172 CFLAGS="$CFLAGS $GTK_CFLAGS $RSVG_CFLAGS $DBUS_CFLAGS $SETTINGS_CFLAGS"
4173 LIBS="$LIBS $GTK_LIBS $RSVG_LIBS $DBUS_LIBS $SETTINGS_LIBS"
4174 CFLAGS="$CFLAGS $NOTIFY_CFLAGS $CAIRO_CFLAGS"
4175 LIBS="$LIBS $NOTIFY_LIBS $CAIRO_LIBS"
4176 AC_MSG_CHECKING([whether GLib is linked in])
4177 AC_LINK_IFELSE([AC_LANG_PROGRAM(
4178         [[#include <glib.h>
4179         ]],
4180         [[g_print ("Hello world");]])],
4181      [links_glib=yes],
4182      [links_glib=no])
4183 AC_MSG_RESULT([$links_glib])
4184 if test "${links_glib}" = "yes"; then
4185   AC_DEFINE(HAVE_GLIB, 1, [Define to 1 if GLib is linked in.])
4186   if test "$HAVE_NS" = no;then
4187     XGSELOBJ=xgselect.o
4188   fi
4190 CFLAGS="$OLDCFLAGS"
4191 LIBS="$OLDLIBS"
4192 AC_SUBST(XGSELOBJ)
4194 dnl Adapted from Haible's version.
4195 AC_CACHE_CHECK([for nl_langinfo and CODESET], emacs_cv_langinfo_codeset,
4196   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
4197     [[char* cs = nl_langinfo(CODESET);]])],
4198     emacs_cv_langinfo_codeset=yes,
4199     emacs_cv_langinfo_codeset=no)
4200   ])
4201 if test $emacs_cv_langinfo_codeset = yes; then
4202   AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
4203     [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
4206 AC_TYPE_MBSTATE_T
4208 dnl Fixme: AC_SYS_POSIX_TERMIOS should probably be used, but it's not clear
4209 dnl how the tty code is related to POSIX and/or other versions of termios.
4210 dnl The following looks like a useful start.
4212 dnl AC_SYS_POSIX_TERMIOS
4213 dnl if test $ac_cv_sys_posix_termios = yes; then
4214 dnl    AC_DEFINE(HAVE_TERMIOS, 1, [Define to 1 if you have POSIX-style functions
4215 dnl                                and macros for terminal control.])
4216 dnl    AC_DEFINE(HAVE_TCATTR, 1, [Define to 1 if you have tcgetattr and tcsetattr.])
4217 dnl fi
4219 dnl Turned on June 1996 supposing nobody will mind it.
4220 dnl MinGW emulates passwd database, so this feature doesn't make sense there.
4221 if test "${opsys}" != "mingw32"; then
4222    AC_DEFINE(AMPERSAND_FULL_NAME, 1, [Define to use the convention that &
4223      in the full name stands for the login id.])
4226 dnl Everybody supports this, except MS.
4227 dnl Seems like the kind of thing we should be testing for, though.
4228 ## Note: PTYs are broken on darwin <6.  Use at your own risk.
4229 if test "${opsys}" != "mingw32"; then
4230   AC_DEFINE(HAVE_PTYS, 1, [Define if the system supports pty devices.])
4233 dnl Everybody supports this, except MS-DOS.
4234 dnl Seems like the kind of thing we should be testing for, though.
4235 dnl Compare with HAVE_INET_SOCKETS (which is unused...) above.
4236 AC_DEFINE(HAVE_SOCKETS, 1, [Define if the system supports
4237   4.2-compatible sockets.])
4239 AH_TEMPLATE(INTERNAL_TERMINAL, [This is substituted when $TERM is "internal".])
4241 AH_TEMPLATE(NULL_DEVICE, [Name of the file to open to get
4242   a null file, or a data sink.])
4243 if test "${opsys}" = "mingw32"; then
4244   AC_DEFINE(NULL_DEVICE, ["NUL:"])
4245 else
4246   AC_DEFINE(NULL_DEVICE, ["/dev/null"])
4249 if test "${opsys}" = "mingw32"; then
4250   SEPCHAR=';'
4251 else
4252   SEPCHAR=':'
4254 AC_DEFINE_UNQUOTED(SEPCHAR, ['$SEPCHAR'], [Character that separates PATH elements.])
4255 dnl This is for MinGW, and is used in test/Makefile.in.
4256 dnl The MSYS Bash has heuristics for replacing ':' with ';' when it
4257 dnl decides that a command-line argument to be passed to a MinGW program
4258 dnl is a PATH-style list of directories.  But that heuristics plays it
4259 dnl safe, and only does the replacement when it is _absolutely_ sure it
4260 dnl sees a colon-separated list of file names; e.g. ":." is left alone,
4261 dnl which breaks in-tree builds.  So we do this manually instead.
4262 dnl Note that we cannot rely on PATH_SEPARATOR, as that one will always
4263 dnl be computed as ':' in MSYS Bash.
4264 AC_SUBST(SEPCHAR)
4266 dnl Everybody supports this, except MS-DOS.
4267 AC_DEFINE(subprocesses, 1, [Define to enable asynchronous subprocesses.])
4269 AC_DEFINE(USER_FULL_NAME, [pw->pw_gecos], [How to get a user's full name.])
4272 AC_DEFINE(DIRECTORY_SEP, ['/'],
4273   [Character that separates directories in a file name.])
4275 if test "${opsys}" = "mingw32"; then
4276   AC_DEFINE(IS_DEVICE_SEP(_c_), [((_c_) == ':')],
4277     [Returns true if character is a device separator.])
4279   AC_DEFINE(IS_DIRECTORY_SEP(_c_), [((_c_) == '/' || (_c_) == '\\')],
4280     [Returns true if character is a directory separator.])
4282   AC_DEFINE(IS_ANY_SEP(_c_), [(IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP(_c_))],
4283     [Returns true if character is any form of separator.])
4284 else
4285   AC_DEFINE(IS_DEVICE_SEP(_c_), 0,
4286     [Returns true if character is a device separator.])
4288   AC_DEFINE(IS_DIRECTORY_SEP(_c_), [((_c_) == DIRECTORY_SEP)],
4289     [Returns true if character is a directory separator.])
4291   AC_DEFINE(IS_ANY_SEP(_c_), [(IS_DIRECTORY_SEP (_c_))],
4292     [Returns true if character is any form of separator.])
4295 if test "$USE_X_TOOLKIT" != "none"; then
4296   have_editres=yes
4297   case $opsys in
4298     hpux*)
4299       dnl Assar Westerlund <assar@sics.se> says this is necessary
4300       dnl for HP-UX 10.20, and that it works for HP-UX 0 as well.
4301       have_editres=no
4302     ;;
4303   esac
4304   if test "$have_editres" != no && test ! -z "$LIBXMU"; then
4305     OLDLIBS="$LIBS"
4306     dnl See libXmu.a check above.
4307     if test x$HAVE_X11XTR6 = xyes; then
4308       LIBS="-lXt -lSM -lICE $LIBXMU"
4309     else
4310       OTHERLIBS="-lXt -$LIBXMU"
4311     fi
4312     AC_TRY_LINK(
4313       [#include <X11/Intrinsic.h>
4314        #include <X11/Xmu/Editres.h>],
4315       [_XEditResCheckMessages (0, 0, 0, 0);],
4316       [AC_DEFINE([X_TOOLKIT_EDITRES], 1,
4317         [Define to 1 if we should use XEditRes.])])
4318     LIBS=$OLDLIBS
4319   fi
4322 case $opsys in
4323   sol2* | unixware )
4324     dnl Some SVr4s don't define NSIG in sys/signal.h for ANSI environments;
4325     dnl instead, there's a system variable _sys_nsig.  Unfortunately, we
4326     dnl need the constant to dimension an array.  So wire in the appropriate
4327     dnl value here.
4328     AC_DEFINE(NSIG_MINIMUM, 32, [Minimum value of NSIG.])
4329     ;;
4330 esac
4332 emacs_broken_SIGIO=no
4334 case $opsys in
4335   dnl SIGIO exists, but the feature doesn't work in the way Emacs needs.
4336   dnl See eg <http://article.gmane.org/gmane.os.openbsd.ports/46831>.
4337   hpux* | nacl | openbsd | sol2* | unixware )
4338     emacs_broken_SIGIO=yes
4339     ;;
4341   aix4-2)
4342     dnl On AIX Emacs uses the gmalloc.c malloc implementation.  But given
4343     dnl the way this system works, libc functions that return malloced
4344     dnl memory use the libc malloc implementation. Calling xfree or
4345     dnl xrealloc on the results of such functions results in a crash.
4346     dnl
4347     dnl One solution for this could be to define SYSTEM_MALLOC in configure,
4348     dnl but that does not currently work on this system.
4349     dnl
4350     dnl It is possible to completely override the malloc implementation on
4351     dnl AIX, but that involves putting the malloc functions in a shared
4352     dnl library and setting the MALLOCTYPE environment variable to point to
4353     dnl that shared library.
4354     dnl
4355     dnl Emacs currently calls xrealloc on the results of get_current_dir name,
4356     dnl to avoid a crash just use the Emacs implementation for that function.
4357     dnl
4358     dnl FIXME We could change the AC_CHECK_FUNCS call near the start
4359     dnl of this file, so that we do not check for get_current_dir_name
4360     dnl on AIX.  But that might be fragile if something else ends
4361     dnl up testing for get_current_dir_name as a dependency.
4362     AC_DEFINE(BROKEN_GET_CURRENT_DIR_NAME, 1, [Define if
4363       get_current_dir_name should not be used.])
4364     ;;
4366   freebsd)
4367     dnl Circumvent a bug in FreeBSD.  In the following sequence of
4368     dnl writes/reads on a PTY, read(2) returns bogus data:
4369     dnl
4370     dnl write(2)  1022 bytes
4371     dnl write(2)   954 bytes, get EAGAIN
4372     dnl read(2)   1024 bytes in process_read_output
4373     dnl read(2)     11 bytes in process_read_output
4374     dnl
4375     dnl That is, read(2) returns more bytes than have ever been written
4376     dnl successfully.  The 1033 bytes read are the 1022 bytes written
4377     dnl successfully after processing (for example with CRs added if the
4378     dnl terminal is set up that way which it is here).  The same bytes will
4379     dnl be seen again in a later read(2), without the CRs.
4380     AC_DEFINE(BROKEN_PTY_READ_AFTER_EAGAIN, 1, [Define on FreeBSD to
4381       work around an issue when reading from a PTY.])
4382     ;;
4383 esac
4385 case $opsys in
4386   gnu-* | sol2-10 )
4387     dnl FIXME Can't we test if this exists (eg /proc/$$)?
4388     AC_DEFINE(HAVE_PROCFS, 1, [Define if you have the /proc filesystem.])
4389   ;;
4390 esac
4392 case $opsys in
4393   darwin | dragonfly | freebsd | netbsd | openbsd )
4394     AC_DEFINE(DONT_REOPEN_PTY, 1, [Define if process.c does not need to
4395       close a pty to make it a controlling terminal (it is already a
4396       controlling terminal of the subprocess, because we did ioctl TIOCSCTTY).])
4397   ;;
4398 esac
4400 dnl FIXME Surely we can test for this rather than hard-code it.
4401 case $opsys in
4402   netbsd | openbsd) sound_device="/dev/audio" ;;
4403   *) sound_device="/dev/dsp" ;;
4404 esac
4406 dnl Used in sound.c
4407 AC_DEFINE_UNQUOTED(DEFAULT_SOUND_DEVICE, "$sound_device",
4408   [Name of the default sound device.])
4411 dnl Emacs can read input using SIGIO and buffering characters itself,
4412 dnl or using CBREAK mode and making C-g cause SIGINT.
4413 dnl The choice is controlled by the variable interrupt_input.
4415 dnl Define INTERRUPT_INPUT to make interrupt_input = 1 the default (use SIGIO)
4417 dnl Emacs uses the presence of the USABLE_SIGIO macro
4418 dnl to indicate whether or not signal-driven I/O is possible.  It uses
4419 dnl INTERRUPT_INPUT to decide whether to use it by default.
4421 dnl SIGIO can be used only on systems that implement it (4.2 and 4.3).
4422 dnl CBREAK mode has two disadvantages
4423 dnl 1) At least in 4.2, it is impossible to handle the Meta key properly.
4424 dnl I hear that in system V this problem does not exist.
4425 dnl 2) Control-G causes output to be discarded.
4426 dnl I do not know whether this can be fixed in system V.
4428 dnl Another method of doing input is planned but not implemented.
4429 dnl It would have Emacs fork off a separate process
4430 dnl to read the input and send it to the true Emacs process
4431 dnl through a pipe.
4432 case $opsys in
4433   darwin | gnu-linux | gnu-kfreebsd )
4434     AC_DEFINE(INTERRUPT_INPUT, 1, [Define to read input using SIGIO.])
4435   ;;
4436 esac
4439 dnl If the system's imake configuration file defines 'NeedWidePrototypes'
4440 dnl as 'NO', we must define NARROWPROTO manually.  Such a define is
4441 dnl generated in the Makefile generated by 'xmkmf'.  If we don't define
4442 dnl NARROWPROTO, we will see the wrong function prototypes for X functions
4443 dnl taking float or double parameters.
4444 case $opsys in
4445   cygwin|gnu|gnu-linux|gnu-kfreebsd|freebsd|netbsd|openbsd)
4446     AC_DEFINE(NARROWPROTO, 1, [Define if system's imake configuration
4447       file defines 'NeedWidePrototypes' as 'NO'.])
4448   ;;
4449 esac
4452 dnl Used in process.c, this must be a loop, even if it only runs once.
4453 AH_TEMPLATE(PTY_ITERATION, [How to iterate over PTYs.])
4454 dnl Only used if !PTY_ITERATION.  Iterate from FIRST_PTY_LETTER to z,
4455 dnl trying suffixes 0-16.
4456 AH_TEMPLATE(FIRST_PTY_LETTER, [Letter to use in finding device name of
4457   first PTY, if PTYs are supported.])
4458 AH_TEMPLATE(PTY_OPEN, [How to open a PTY, if non-standard.])
4459 AH_TEMPLATE(PTY_NAME_SPRINTF, [How to get the device name of the control
4460   end of a PTY, if non-standard.])
4461 AH_TEMPLATE(PTY_TTY_NAME_SPRINTF, [How to get device name of the tty
4462   end of a PTY, if non-standard.])
4464 case $opsys in
4465   aix4-2 )
4466     AC_DEFINE(PTY_ITERATION, [int c; for (c = 0; !c ; c++)])
4467     dnl You allocate a pty by opening /dev/ptc to get the master side.
4468     dnl To get the name of the slave side, you just ttyname() the master side.
4469     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");])
4470     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [strcpy (pty_name, ttyname (fd));])
4471     ;;
4473   cygwin )
4474     AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
4475     dnl multi-line AC_DEFINEs are hard. :(
4476     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 (false)])
4477     AC_DEFINE(PTY_NAME_SPRINTF, [])
4478     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
4479     ;;
4481   gnu | openbsd )
4482     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
4483     ;;
4485   gnu-linux | gnu-kfreebsd | dragonfly | freebsd | netbsd | darwin | nacl )
4486     dnl if HAVE_GRANTPT
4487     if test "x$ac_cv_func_grantpt" = xyes; then
4488       AC_DEFINE(UNIX98_PTYS, 1, [Define if the system has Unix98 PTYs.])
4489       AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
4490       dnl Note that grantpt and unlockpt may fork.  We must block SIGCHLD
4491       dnl to prevent sigchld_handler from intercepting the child's death.
4492       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) { emacs_close (fd); return -1; } snprintf (pty_name, PTY_NAME_SIZE, "%s", ptyname); }])
4493       dnl if HAVE_POSIX_OPENPT
4494       if test "x$ac_cv_func_posix_openpt" = xyes; then
4495         AC_DEFINE(PTY_OPEN, [do { fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY); if (fd < 0 && errno == EINVAL) fd = posix_openpt (O_RDWR | O_NOCTTY); } while (false)])
4496         AC_DEFINE(PTY_NAME_SPRINTF, [])
4497       dnl if HAVE_GETPT
4498       elif test "x$ac_cv_func_getpt" = xyes; then
4499         AC_DEFINE(PTY_OPEN, [fd = getpt ()])
4500         AC_DEFINE(PTY_NAME_SPRINTF, [])
4501       else
4502         AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");])
4503       fi
4504     else
4505       AC_DEFINE(FIRST_PTY_LETTER, ['p'])
4506     fi
4507     ;;
4509   hpux*)
4510     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
4511     AC_DEFINE(PTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);])
4512     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/pty/tty%c%x", c, i);])
4513     ;;
4515   sol2* )
4516     dnl On SysVr4, grantpt(3) forks a subprocess, so do not use
4517     dnl O_CLOEXEC when opening the pty, and keep the SIGCHLD handler
4518     dnl from intercepting that death.  If any child but grantpt's should die
4519     dnl within, it should be caught after sigrelse(2).
4520     AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)])
4521     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, PTY_NAME_SIZE, "%s", ptyname); }])
4522     ;;
4524   unixware )
4525     dnl Comments are as per sol2*.
4526     AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)])
4527     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, PTY_NAME_SIZE, "%s", ptyname); }])
4528     ;;
4529 esac
4532 case $opsys in
4533   sol2* | unixware )
4534     dnl This change means that we don't loop through allocate_pty too
4535     dnl many times in the (rare) event of a failure.
4536     AC_DEFINE(FIRST_PTY_LETTER, ['z'])
4537     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");])
4538     dnl Push various streams modules onto a PTY channel.  Used in process.c.
4539     AC_DEFINE(SETUP_SLAVE_PTY, [if (ioctl (forkin, I_PUSH, "ptem") == -1) fatal ("ioctl I_PUSH ptem"); if (ioctl (forkin, I_PUSH, "ldterm") == -1) fatal ("ioctl I_PUSH ldterm"); if (ioctl (forkin, I_PUSH, "ttcompat") == -1) fatal ("ioctl I_PUSH ttcompat");], [How to set up a slave PTY, if needed.])
4540     ;;
4541 esac
4544 AH_TEMPLATE(SIGNALS_VIA_CHARACTERS, [Make process_send_signal work by
4545 "typing" a signal character on the pty.])
4547 case $opsys in
4548   dnl Perry Smith <pedz@ddivt1.austin.ibm.com> says this is correct for AIX.
4549   aix4-2 | cygwin | gnu | dragonfly | freebsd | netbsd | openbsd | darwin )
4550     AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1)
4551     ;;
4553   dnl 21 Jun 06: Eric Hanchrow <offby1@blarg.net> says this works.
4554   dnl FIXME Does gnu-kfreebsd have linux/version.h?  It seems unlikely...
4555   gnu-linux | gnu-kfreebsd )
4557     AC_MSG_CHECKING([for signals via characters])
4558     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4559 #include <linux/version.h>
4560 #if LINUX_VERSION_CODE < 0x20400
4561 # error "Linux version too old"
4562 #endif
4563       ]], [[]])], emacs_signals_via_chars=yes, emacs_signals_via_chars=no)
4565     AC_MSG_RESULT([$emacs_signals_via_chars])
4566     test $emacs_signals_via_chars = yes && AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1)
4567     ;;
4568 esac
4571 AH_TEMPLATE(TAB3, [Undocumented.])
4573 case $opsys in
4574   darwin) AC_DEFINE(TAB3, OXTABS) ;;
4576   gnu | dragonfly | freebsd | netbsd | openbsd )
4577     AC_DEFINE(TABDLY, OXTABS, [Undocumented.])
4578     AC_DEFINE(TAB3, OXTABS)
4579     ;;
4581   gnu-linux | gnu-kfreebsd )
4582     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4583 #ifndef __ia64__
4584 # error "not ia64"
4585 #endif
4586       ]], [[]])], AC_DEFINE(GC_MARK_SECONDARY_STACK(),
4587         [do { extern void *__libc_ia64_register_backing_store_base; __builtin_ia64_flushrs (); mark_memory (__libc_ia64_register_backing_store_base, __builtin_ia64_bsp ());} while (false)],
4588         [Mark a secondary stack, like the register stack on the ia64.]), [])
4589     ;;
4591   hpux*)
4592     AC_DEFINE(RUN_TIME_REMAP, 1, [Define if emacs.c needs to call
4593       run_time_remap; for HPUX.])
4594     ;;
4595 esac
4598 dnl This won't be used automatically yet.  We also need to know, at least,
4599 dnl that the stack is continuous.
4600 AH_TEMPLATE(GC_SETJMP_WORKS, [Define if setjmp is known to save all
4601   registers relevant for conservative garbage collection in the jmp_buf.])
4604 case $opsys in
4605   dnl Not all the architectures are tested, but there are Debian packages
4606   dnl for SCM and/or Guile on them, so the technique must work.  See also
4607   dnl comments in alloc.c concerning setjmp and gcc.
4608   dnl Fixme: it's probably safe to just use the GCC conditional below.
4609   gnu-linux | gnu-kfreebsd )
4610     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4611 #if defined __i386__ || defined __sparc__ || defined __mc68000__ \
4612   || defined __alpha__ || defined __mips__ || defined __s390__ \
4613   || defined __arm__ || defined __powerpc__ || defined __amd64__ \
4614   || defined __ia64__ || defined __sh__
4615 /* ok */
4616 #else
4617 # error "setjmp not known to work on this arch"
4618 #endif
4619     ]], [[]])], AC_DEFINE(GC_SETJMP_WORKS, 1))
4620     ;;
4621 esac
4624 if test x$GCC = xyes; then
4625    dnl GC_SETJMP_WORKS is nearly always appropriate for GCC.
4626    AC_DEFINE(GC_SETJMP_WORKS, 1)
4627 else
4628   case $opsys in
4629     aix* | dragonfly | freebsd | netbsd | openbsd | sol2* )
4630       AC_DEFINE(GC_SETJMP_WORKS, 1)
4631       ;;
4632   esac
4633 fi                              dnl GCC?
4635 dnl In a weird quirk, MS runtime uses _setjmp and longjmp.
4636 AC_CACHE_CHECK([for _setjmp], [emacs_cv_func__setjmp],
4637   [AC_LINK_IFELSE(
4638      [AC_LANG_PROGRAM(
4639        [[#include <setjmp.h>
4640          #ifdef __MINGW32__
4641          # define _longjmp longjmp
4642          #endif
4643        ]],
4644        [[jmp_buf j;
4645          if (! _setjmp (j))
4646            _longjmp (j, 1);]])],
4647      [emacs_cv_func__setjmp=yes],
4648      [emacs_cv_func__setjmp=no])])
4649 if test $emacs_cv_func__setjmp = yes; then
4650   AC_DEFINE([HAVE__SETJMP], 1, [Define to 1 if _setjmp and _longjmp work.])
4653 # We need to preserve signal mask to handle C stack overflows.
4654 AC_CACHE_CHECK([for sigsetjmp], [emacs_cv_func_sigsetjmp],
4655   [AC_LINK_IFELSE(
4656      [AC_LANG_PROGRAM(
4657        [[#include <setjmp.h>
4658        ]],
4659        [[sigjmp_buf j;
4660          if (! sigsetjmp (j, 1))
4661            siglongjmp (j, 1);]])],
4662      [emacs_cv_func_sigsetjmp=yes],
4663      [emacs_cv_func_sigsetjmp=no])])
4664 if test $emacs_cv_func_sigsetjmp = yes; then
4665   AC_DEFINE([HAVE_SIGSETJMP], 1,
4666     [Define to 1 if sigsetjmp and siglongjmp work.])
4669 case $emacs_cv_func_sigsetjmp,$emacs_cv_alternate_stack,$opsys in
4670   yes,yes,* | *,*,mingw32)
4671     AC_DEFINE([HAVE_STACK_OVERFLOW_HANDLING], 1,
4672       [Define to 1 if C stack overflow can be handled in some cases.]);;
4673 esac
4675 case $opsys in
4676   sol2* | unixware )
4677     dnl TIOCGPGRP is broken in SysVr4, so we can't send signals to PTY
4678     dnl subprocesses the usual way.  But TIOCSIGNAL does work for PTYs,
4679     dnl and this is all we need.
4680     AC_DEFINE(TIOCSIGSEND, TIOCSIGNAL, [Some platforms redefine this.])
4681     ;;
4682 esac
4685 case $opsys in
4686   hpux* | sol2* )
4687     dnl Used in xfaces.c.
4688     AC_DEFINE(XOS_NEEDS_TIME_H, 1, [Compensate for a bug in Xos.h on
4689       some systems, where it requires time.h.])
4690     ;;
4691 esac
4694 dnl Define symbols to identify the version of Unix this is.
4695 dnl Define all the symbols that apply correctly.
4696 AH_TEMPLATE(DOS_NT, [Define if the system is MS DOS or MS Windows.])
4697 AH_TEMPLATE(MSDOS, [Define if the system is MS DOS.])
4698 AH_TEMPLATE(USG, [Define if the system is compatible with System III.])
4699 AH_TEMPLATE(USG5_4, [Define if the system is compatible with System V Release 4.])
4701 case $opsys in
4702   aix4-2)
4703     AC_DEFINE(USG, [])
4704     dnl This symbol should be defined on AIX Version 3  ???????
4705     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4706 #ifndef _AIX
4707 # error "_AIX not defined"
4708 #endif
4709     ]], [[]])], [], AC_DEFINE(_AIX, [], [Define if the system is AIX.]))
4710     ;;
4712   cygwin)
4713     AC_DEFINE(CYGWIN, 1, [Define if the system is Cygwin.])
4714     ;;
4716   darwin)
4717     dnl Not __APPLE__, as this may not be defined on non-OSX Darwin.
4718     dnl Not DARWIN, because Panther and lower CoreFoundation.h use DARWIN to
4719     dnl distinguish OS X from pure Darwin.
4720     AC_DEFINE(DARWIN_OS, [], [Define if the system is Darwin.])
4721     ;;
4723   gnu-linux | gnu-kfreebsd )
4724     AC_DEFINE(USG, [])
4725     AC_DEFINE(GNU_LINUX, [], [Define if ths system is compatible with GNU/Linux.])
4726     ;;
4728   hpux*)
4729     AC_DEFINE(USG, [])
4730     AC_DEFINE(HPUX, [], [Define if the system is HPUX.])
4731     ;;
4733   mingw32)
4734     AC_DEFINE(DOS_NT, [])
4735     AC_DEFINE(WINDOWSNT, 1, [Define if compiling for native MS Windows.])
4736     if test "x$ac_enable_checking" != "x" ; then
4737       AC_DEFINE(EMACSDEBUG, 1, [Define to 1 to enable w32 debug facilities.])
4738     fi
4739     ;;
4741   sol2*)
4742     AC_DEFINE(USG, [])
4743     AC_DEFINE(USG5_4, [])
4744     AC_DEFINE(SOLARIS2, [], [Define if the system is Solaris.])
4745     ;;
4747   unixware)
4748     AC_DEFINE(USG, [])
4749     AC_DEFINE(USG5_4, [])
4750     ;;
4751 esac
4753 AC_CACHE_CHECK([for usable FIONREAD], [emacs_cv_usable_FIONREAD],
4754   [case $opsys in
4755      aix4-2 | nacl)
4756        dnl BUILD 9008 - FIONREAD problem still exists in X-Windows.
4757        emacs_cv_usable_FIONREAD=no
4758        ;;
4760      mingw32)
4761        emacs_cv_usable_FIONREAD=yes
4762        ;;
4764      *)
4765        AC_COMPILE_IFELSE(
4766          [AC_LANG_PROGRAM([[#include <sys/types.h>
4767                             #include <sys/ioctl.h>
4768                             #ifdef USG5_4
4769                             # include <sys/filio.h>
4770                             #endif
4771                           ]],
4772                           [[int foo = ioctl (0, FIONREAD, &foo);]])],
4773          [emacs_cv_usable_FIONREAD=yes],
4774          [emacs_cv_usable_FIONREAD=no])
4775        ;;
4776    esac])
4777 if test $emacs_cv_usable_FIONREAD = yes; then
4778   AC_DEFINE([USABLE_FIONREAD], [1], [Define to 1 if FIONREAD is usable.])
4780   if test $emacs_broken_SIGIO = no; then
4781     AC_CACHE_CHECK([for usable SIGIO], [emacs_cv_usable_SIGIO],
4782       [AC_COMPILE_IFELSE(
4783          [AC_LANG_PROGRAM([[#include <fcntl.h>
4784                             #include <signal.h>
4785                           ]],
4786                           [[int foo = SIGIO | F_SETFL | FASYNC;]])],
4787          [emacs_cv_usable_SIGIO=yes],
4788          [emacs_cv_usable_SIGIO=no])],
4789       [emacs_cv_usable_SIGIO=yes],
4790       [emacs_cv_usable_SIGIO=no])
4791     if test $emacs_cv_usable_SIGIO = yes; then
4792       AC_DEFINE([USABLE_SIGIO], [1], [Define to 1 if SIGIO is usable.])
4793     fi
4794   fi
4797 case $opsys in
4798   hpux11)
4799     dnl It works to open the pty's tty in the parent (Emacs), then
4800     dnl close and reopen it in the child.
4801     AC_DEFINE(USG_SUBTTY_WORKS, 1, [Define for USG systems where it
4802       works to open a pty's tty in the parent process, then close and
4803       reopen it in the child.])
4804     ;;
4806   sol2-10)
4807     AC_DEFINE(_STRUCTURED_PROC, 1, [Needed for system_process_attributes
4808       on Solaris.])
4809     ;;
4810 esac
4812 # Set up the CFLAGS for real compilation, so we can substitute it.
4813 CFLAGS="$REAL_CFLAGS"
4814 CPPFLAGS="$REAL_CPPFLAGS"
4815 LIBS="$REAL_LIBS"
4817 ## Hack to detect a buggy GCC version.
4818 if test "$GCC" = yes && \
4819    $CC --version 2> /dev/null | grep 'gcc.* 4.5.0' >/dev/null; then
4820   case $CFLAGS in
4821     *-fno-optimize-sibling-calls*) ;;
4822     *-O@<:@23@:>@*)
4823       AC_MSG_ERROR([GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS.]);;
4824   esac
4827 version=$PACKAGE_VERSION
4829 copyright="Copyright (C) 2016 Free Software Foundation, Inc."
4830 AC_DEFINE_UNQUOTED(COPYRIGHT, ["$copyright"],
4831   [Short copyright string for this version of Emacs.])
4832 AC_SUBST(copyright)
4834 ### Specify what sort of things we'll be editing into Makefile and config.h.
4835 ### Use configuration here uncanonicalized to avoid exceeding size limits.
4836 AC_SUBST(version)
4837 AC_SUBST(configuration)
4838 ## Unused?
4839 AC_SUBST(canonical)
4840 AC_SUBST(srcdir)
4841 AC_SUBST(prefix)
4842 AC_SUBST(exec_prefix)
4843 AC_SUBST(bindir)
4844 AC_SUBST(datadir)
4845 AC_SUBST(sharedstatedir)
4846 AC_SUBST(libexecdir)
4847 AC_SUBST(mandir)
4848 AC_SUBST(infodir)
4849 AC_SUBST(lispdir)
4850 AC_SUBST(standardlisppath)
4851 AC_SUBST(locallisppath)
4852 AC_SUBST(lisppath)
4853 AC_SUBST(x_default_search_path)
4854 AC_SUBST(etcdir)
4855 AC_SUBST(archlibdir)
4856 AC_SUBST(etcdocdir)
4857 AC_SUBST(bitmapdir)
4858 AC_SUBST(gamedir)
4859 AC_SUBST(gameuser)
4860 AC_SUBST(gamegroup)
4861 ## FIXME? Nothing uses @LD_SWITCH_X_SITE@.
4862 ## src/Makefile.in did add LD_SWITCH_X_SITE (as a cpp define) to the
4863 ## end of LIBX_BASE, but nothing ever set it.
4864 AC_SUBST(LD_SWITCH_X_SITE)
4865 AC_SUBST(C_SWITCH_X_SITE)
4866 AC_SUBST(GNUSTEP_CFLAGS)
4867 AC_SUBST(CFLAGS)
4868 ## Used in lwlib/Makefile.in.
4869 AC_SUBST(X_TOOLKIT_TYPE)
4870 AC_SUBST(ns_appdir)
4871 AC_SUBST(ns_appbindir)
4872 AC_SUBST(ns_appresdir)
4873 AC_SUBST(ns_appsrc)
4874 AC_SUBST(GNU_OBJC_CFLAGS)
4875 AC_SUBST(OTHER_FILES)
4877 if test -n "${term_header}"; then
4878     AC_DEFINE_UNQUOTED(TERM_HEADER, "${term_header}",
4879         [Define to the header for the built-in window system.])
4882 AC_DEFINE_UNQUOTED(EMACS_CONFIGURATION,  "${canonical}",
4883                    [Define to the canonical Emacs configuration name.])
4884 AC_DEFINE_UNQUOTED(EMACS_CONFIG_OPTIONS, "${emacs_config_options}",
4885                    [Define to the options passed to configure.])
4886 AH_TEMPLATE(config_opsysfile, [Some platforms that do not use configure
4887   define this to include extra configuration information.])
4889 case $opsys in
4890   mingw32)
4891     AC_DEFINE(config_opsysfile, <ms-w32.h>, [])
4892     ;;
4893 esac
4895 XMENU_OBJ=
4896 XOBJ=
4897 FONT_OBJ=
4898 if test "${HAVE_X_WINDOWS}" = "yes" ; then
4899   AC_DEFINE(HAVE_X_WINDOWS, 1,
4900             [Define to 1 if you want to use the X window system.])
4901   XMENU_OBJ=xmenu.o
4902   XOBJ="xterm.o xfns.o xselect.o xrdb.o xsmfns.o xsettings.o"
4903   FONT_OBJ=xfont.o
4904   if test "$HAVE_CAIRO" = "yes"; then
4905     FONT_OBJ="ftfont.o ftcrfont.o"
4906   elif test "$HAVE_XFT" = "yes"; then
4907     FONT_OBJ="$FONT_OBJ ftfont.o xftfont.o ftxfont.o"
4908   elif test "$HAVE_FREETYPE" = "yes"; then
4909     FONT_OBJ="$FONT_OBJ ftfont.o ftxfont.o"
4910   fi
4911   AC_SUBST(FONT_OBJ)
4913 AC_SUBST(XMENU_OBJ)
4914 AC_SUBST(XOBJ)
4915 AC_SUBST(FONT_OBJ)
4917 WIDGET_OBJ=
4918 MOTIF_LIBW=
4919 if test "${USE_X_TOOLKIT}" != "none" ; then
4920   WIDGET_OBJ=widget.o
4921   AC_DEFINE(USE_X_TOOLKIT, 1, [Define to 1 if using an X toolkit.])
4922   if test "${USE_X_TOOLKIT}" = "LUCID"; then
4923     AC_DEFINE(USE_LUCID, 1, [Define to 1 if using the Lucid X toolkit.])
4924   elif test "${USE_X_TOOLKIT}" = "MOTIF"; then
4925     AC_DEFINE(USE_MOTIF, 1, [Define to 1 if using the Motif X toolkit.])
4926     MOTIF_LIBW=-lXm
4927     case "$opsys" in
4928       gnu-linux)
4929         ## Paul Abrahams <abrahams at equinox.shaysnet.com> says this is needed.
4930         MOTIF_LIBW="$MOTIF_LIBW -lXpm"
4931         ;;
4933       unixware)
4934         ## Richard Anthony Ryan <ryanr at ellingtn.ftc.nrcs.usda.gov>
4935         ## says -lXimp is needed in UNIX_SV ... 4.2 1.1.2.
4936         MOTIF_LIBW="MOTIF_LIBW -lXimp"
4937         ;;
4939       aix4-2)
4940         ## olson@mcs.anl.gov says -li18n is needed by -lXm.
4941         MOTIF_LIBW="$MOTIF_LIBW -li18n"
4942         ;;
4943     esac
4944     MOTIF_LIBW="$MOTIF_LIBW $LIBXP"
4945   fi
4947 AC_SUBST(WIDGET_OBJ)
4949 TOOLKIT_LIBW=
4950 case "$USE_X_TOOLKIT" in
4951   MOTIF) TOOLKIT_LIBW="$MOTIF_LIBW" ;;
4952   LUCID) TOOLKIT_LIBW="$LUCID_LIBW" ;;
4953   none) test "x$HAVE_GTK" = "xyes" && TOOLKIT_LIBW="$GTK_LIBS" ;;
4954 esac
4955 if test "$HAVE_XWIDGETS" = "yes"; then
4956   TOOLKIT_LIBW="$TOOLKIT_LIBW -lXcomposite"
4958 AC_SUBST(TOOLKIT_LIBW)
4960 if test "${opsys}" != "mingw32"; then
4961   if test "$USE_X_TOOLKIT" = "none"; then
4962     LIBXT_OTHER="\$(LIBXSM)"
4963   else
4964     LIBXT_OTHER="\$(LIBXMU) -lXt \$(LIBXTR6) -lXext"
4965   fi
4967 AC_SUBST(LIBXT_OTHER)
4969 if test "${HAVE_X11}" = "yes" ; then
4970   AC_DEFINE(HAVE_X11, 1,
4971             [Define to 1 if you want to use version 11 of X windows.])
4972   LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
4973 else
4974   LIBX_OTHER=
4976 AC_SUBST(LIBX_OTHER)
4978 if test "$HAVE_GTK" = yes || test "$HAVE_X11" != yes; then
4979   LIBXMENU=
4980 elif test "$USE_X_TOOLKIT" = none; then
4981   LIBXMENU='$(oldXMenudir)/libXMenu11.a'
4982 else
4983   LIBXMENU='$(lwlibdir)/liblw.a'
4985 AC_SUBST(LIBXMENU)
4987 AC_CACHE_CHECK([for struct alignment],
4988   [emacs_cv_struct_alignment],
4989   [AC_COMPILE_IFELSE(
4990      [AC_LANG_PROGRAM([[#include <stddef.h>
4991                         struct __attribute__ ((aligned (8))) s { char c; };
4992                         struct t { char c; struct s s; };
4993                         char verify[offsetof (struct t, s) == 8 ? 1 : -1];
4994                       ]])],
4995      [emacs_cv_struct_alignment=yes],
4996      [emacs_cv_struct_alignment=no])])
4997 if test "$emacs_cv_struct_alignment" = yes; then
4998   AC_DEFINE([HAVE_STRUCT_ATTRIBUTE_ALIGNED], 1,
4999     [Define to 1 if 'struct __attribute__ ((aligned (N)))' aligns the
5000      structure to an N-byte boundary.])
5003 if test "${GNU_MALLOC}" = "yes" ; then
5004   AC_DEFINE(GNU_MALLOC, 1,
5005             [Define to 1 if you want to use the GNU memory allocator.])
5008 RALLOC_OBJ=
5009 if test "${REL_ALLOC}" = "yes" ; then
5010   AC_DEFINE(REL_ALLOC, 1,
5011             [Define REL_ALLOC if you want to use the relocating allocator for
5012              buffer space.])
5014   test "$system_malloc" != "yes" && RALLOC_OBJ=ralloc.o
5016 AC_SUBST(RALLOC_OBJ)
5018 if test "$opsys" = "cygwin"; then
5019   CYGWIN_OBJ="cygw32.o"
5020   ## Cygwin differs because of its unexec().
5021   PRE_ALLOC_OBJ=
5022   POST_ALLOC_OBJ=lastfile.o
5023 elif test "$opsys" = "mingw32"; then
5024   CYGWIN_OBJ=
5025   PRE_ALLOC_OBJ=
5026   POST_ALLOC_OBJ=lastfile.o
5027 else
5028   CYGWIN_OBJ=
5029   PRE_ALLOC_OBJ=lastfile.o
5030   POST_ALLOC_OBJ=
5032 AC_SUBST(CYGWIN_OBJ)
5033 AC_SUBST(PRE_ALLOC_OBJ)
5034 AC_SUBST(POST_ALLOC_OBJ)
5036 dnl Call this 'FORTIFY_SOUR' so that it sorts before the 'FORTIFY_SOURCE'
5037 dnl verbatim defined above.  The tricky name is apropos, as this hack
5038 dnl makes Fortify go sour!
5039 AH_VERBATIM([FORTIFY_SOUR],
5040 [/* Without the following workaround, Emacs runs slowly on OS X 10.8.
5041    The workaround disables some useful run-time checking, so it
5042    should be conditional to the platforms with the performance bug.
5043    Perhaps Apple will fix this some day; also see m4/extern-inline.m4.  */
5044 #if defined __APPLE__ && defined __GNUC__
5045 # ifndef _DONT_USE_CTYPE_INLINE_
5046 #  define _DONT_USE_CTYPE_INLINE_
5047 # endif
5048 # ifndef _FORTIFY_SOURCE
5049 #  define _FORTIFY_SOURCE 0
5050 # endif
5051 #endif
5054 # If user asks to omit features, disable optional features that gnulib
5055 # might otherwise enable.
5056 if test "$with_features" = no && test "$enable_acl" != yes; then
5057   enable_acl=no
5060 # Configure gnulib.  Although this does not affect CFLAGS or LIBS permanently.
5061 # it temporarily reverts them to their pre-pkg-config values,
5062 # because gnulib needs to work with both src (which uses the
5063 # pkg-config stuff) and lib-src (which does not).  For example, gnulib
5064 # may need to determine whether LIB_CLOCK_GETTIME should contain -lrt,
5065 # and it therefore needs to run in an environment where LIBS does not
5066 # already contain -lrt merely because 'pkg-config --libs' printed '-lrt'
5067 # for some package unrelated to lib-src.
5068 SAVE_CFLAGS=$CFLAGS
5069 SAVE_LIBS=$LIBS
5070 CFLAGS=$pre_PKG_CONFIG_CFLAGS
5071 LIBS="$LIB_PTHREAD $pre_PKG_CONFIG_LIBS"
5072 gl_ASSERT_NO_GNULIB_POSIXCHECK
5073 gl_ASSERT_NO_GNULIB_TESTS
5074 gl_INIT
5075 CFLAGS=$SAVE_CFLAGS
5076 LIBS=$SAVE_LIBS
5078 if test "${opsys}" = "mingw32"; then
5079   CPPFLAGS="$CPPFLAGS -DUSE_CRT_DLL=1 -I \${abs_top_srcdir}/nt/inc"
5080   # Remove unneeded switches from the value of CC that goes to Makefiles
5081   CC=`AS_ECHO(["$CC"]) | sed -e "s,$GCC_TEST_OPTIONS,,"`
5084 case "$opsys" in
5085   aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;;
5087   cygwin) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000" ;;
5089   darwin)
5090    ## The -headerpad option tells ld (see man page) to leave room at the
5091    ## end of the header for adding load commands.  Needed for dumping.
5092    ## 0x1000 is enough for roughly 52 load commands on the x86_64
5093    ## architecture (where they are 78 bytes each). The actual number of
5094    ## load commands added is not consistent but normally ranges from
5095    ## about 14 to about 34. Setting it high gets us plenty of slop and
5096    ## only costs about 1.5K of wasted binary space.
5097    headerpad_extra=1000
5098    if test "$HAVE_NS" = "yes"; then
5099      libs_nsgui="-framework AppKit"
5100      if test "$NS_IMPL_COCOA" = "yes"; then
5101         libs_nsgui="$libs_nsgui -framework IOKit"
5102      fi
5103    else
5104      libs_nsgui=
5105    fi
5106    LD_SWITCH_SYSTEM_TEMACS="-fno-pie -prebind $libs_nsgui -Xlinker -headerpad -Xlinker $headerpad_extra"
5108    ## This is here because src/Makefile.in did some extra fiddling around
5109    ## with LD_SWITCH_SYSTEM.  It seems cleaner to put this in
5110    ## LD_SWITCH_SYSTEM_TEMACS instead,
5111    test "x$LD_SWITCH_SYSTEM" = "x" && test "x$GCC" != "xyes" && \
5112      LD_SWITCH_SYSTEM_TEMACS="-X $LD_SWITCH_SYSTEM_TEMACS"
5113    ;;
5115   ## LD_SWITCH_X_SITE_RPATH is a -rpath option saying where to
5116   ## find X at run-time.
5117   ## When handled by cpp, this was in LD_SWITCH_SYSTEM.  However, at the
5118   ## point where configure sourced the s/*.h file, LD_SWITCH_X_SITE_RPATH
5119   ## had not yet been defined and was expanded to null.  Hence LD_SWITCH_SYSTEM
5120   ## had different values in configure (in ac_link) and src/Makefile.in.
5121   ## It seems clearer therefore to put this piece in LD_SWITCH_SYSTEM_TEMACS.
5122   gnu*) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_RPATH)" ;;
5124   mingw32)
5125    ## Is it any better under MinGW64 to relocate emacs into higher addresses?
5126    case "$canonical" in
5127      x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x400000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
5128      *) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
5129    esac
5130    ;;
5132   *) LD_SWITCH_SYSTEM_TEMACS= ;;
5133 esac
5135 # -nopie fixes a temacs segfault on Gentoo, OpenBSD, and other systems
5136 # with "hardened" GCC configurations for some reason (Bug#18784).
5137 # We don't know why -nopie works, but not segfaulting is better than
5138 # segfaulting.  Use ac_c_werror_flag=yes when trying -nopie, otherwise
5139 # clang keeps warning that it does not understand -nopie, and pre-4.6
5140 # GCC has a similar problem (Bug#20338).
5141 AC_CACHE_CHECK([whether $CC accepts -nopie],
5142   [emacs_cv_prog_cc_nopie],
5143   [emacs_save_c_werror_flag=$ac_c_werror_flag
5144    emacs_save_LDFLAGS=$LDFLAGS
5145    ac_c_werror_flag=yes
5146    LDFLAGS="$LDFLAGS -nopie"
5147    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
5148      [emacs_cv_prog_cc_nopie=yes],
5149      [emacs_cv_prog_cc_nopie=no])
5150    ac_c_werror_flag=$emacs_save_c_werror_flag
5151    LDFLAGS=$emacs_save_LDFLAGS])
5152 if test "$emacs_cv_prog_cc_nopie" = yes; then
5153   LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS -nopie"
5156 if test x$ac_enable_profiling != x ; then
5157   case $opsys in
5158     *freebsd | gnu-linux) ;;
5159     *) LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS -pg" ;;
5160   esac
5163 LD_SWITCH_SYSTEM_TEMACS="$LDFLAGS_NOCOMBRELOC $LD_SWITCH_SYSTEM_TEMACS"
5165 AC_SUBST(LD_SWITCH_SYSTEM_TEMACS)
5167 ## Common for all window systems
5168 if test "$window_system" != "none"; then
5169   AC_DEFINE(HAVE_WINDOW_SYSTEM, 1, [Define if you have a window system.])
5170   AC_DEFINE(POLL_FOR_INPUT, 1, [Define if you poll periodically to detect C-g.])
5171   WINDOW_SYSTEM_OBJ="fontset.o fringe.o image.o"
5174 AC_SUBST(WINDOW_SYSTEM_OBJ)
5176 AH_TOP([/* GNU Emacs site configuration template file.
5178 Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2016
5179   Free Software Foundation, Inc.
5181 This file is part of GNU Emacs.
5183 GNU Emacs is free software: you can redistribute it and/or modify
5184 it under the terms of the GNU General Public License as published by
5185 the Free Software Foundation, either version 3 of the License, or (at
5186 your option) any later version.
5188 GNU Emacs is distributed in the hope that it will be useful,
5189 but WITHOUT ANY WARRANTY; without even the implied warranty of
5190 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5191 GNU General Public License for more details.
5193 You should have received a copy of the GNU General Public License
5194 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
5197 /* No code in Emacs #includes config.h twice, but some bits of code
5198    intended to work with other packages as well (like gmalloc.c)
5199    think they can include it as many times as they like.  */
5200 #ifndef EMACS_CONFIG_H
5201 #define EMACS_CONFIG_H
5202 ])dnl
5204 AH_BOTTOM([#include <conf_post.h>
5206 #endif /* EMACS_CONFIG_H */
5209 Local Variables:
5210 mode: c
5211 End:
5213 ])dnl
5215 #### Report on what we decided to do.
5216 #### Report GTK as a toolkit, even if it doesn't use Xt.
5217 #### It makes printing result more understandable as using GTK sets
5218 #### toolkit_scroll_bars to yes by default.
5219 if test "${HAVE_GTK}" = "yes"; then
5220   USE_X_TOOLKIT="$USE_GTK_TOOLKIT"
5223 if test $USE_ACL -ne 0; then
5224   ACL_SUMMARY="yes $LIB_ACL"
5225 else
5226   ACL_SUMMARY=no
5229 emacs_standard_dirs='Standard dirs'
5230 AS_ECHO(["
5231 Configured for '${canonical}'.
5233   Where should the build process find the source code?    ${srcdir}
5234   What compiler should emacs be built with?               ${CC} ${CFLAGS}
5235   Should Emacs use the GNU version of malloc?             ${GNU_MALLOC}${GNU_MALLOC_reason}
5236   Should Emacs use a relocating allocator for buffers?    ${REL_ALLOC}
5237   Should Emacs use mmap(2) for buffer allocation?         $use_mmap_for_buffers
5238   What window system should Emacs use?                    ${window_system}
5239   What toolkit should Emacs use?                          ${USE_X_TOOLKIT}
5240   Where do we find X Windows header files?                ${x_includes:-$emacs_standard_dirs}
5241   Where do we find X Windows libraries?                   ${x_libraries:-$emacs_standard_dirs}"])
5243 optsep=
5244 emacs_config_features=
5245 for opt in XAW3D XPM JPEG TIFF GIF PNG RSVG CAIRO IMAGEMAGICK SOUND GPM DBUS \
5246   GCONF GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT \
5247   LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS X_TOOLKIT X11 NS MODULES \
5248   XWIDGETS LIBSYSTEMD CANNOT_DUMP; do
5250     case $opt in
5251       CANNOT_DUMP) eval val=\${$opt} ;;
5252       NOTIFY|ACL) eval val=\${${opt}_SUMMARY} ;;
5253       TOOLKIT_SCROLL_BARS|X_TOOLKIT) eval val=\${USE_$opt} ;;
5254       *) eval val=\${HAVE_$opt} ;;
5255     esac
5256     case x$val in
5257       xno|xnone|x) continue ;;
5258     esac
5259     case $opt in
5260       X_TOOLKIT)
5261         case $val in
5262           GTK*|LUCID|MOTIF) opt=$val ;;
5263           *) continue ;;
5264         esac
5265       ;;
5266     esac
5267     AS_VAR_APPEND([emacs_config_features], ["$optsep$opt"])
5268     optsep=' '
5269 done
5270 AC_DEFINE_UNQUOTED(EMACS_CONFIG_FEATURES, "${emacs_config_features}",
5271   [Summary of some of the main features enabled by configure.])
5273 AS_ECHO(["  Does Emacs use -lXaw3d?                                 ${HAVE_XAW3D}
5274   Does Emacs use -lXpm?                                   ${HAVE_XPM}
5275   Does Emacs use -ljpeg?                                  ${HAVE_JPEG}
5276   Does Emacs use -ltiff?                                  ${HAVE_TIFF}
5277   Does Emacs use a gif library?                           ${HAVE_GIF} $LIBGIF
5278   Does Emacs use a png library?                           ${HAVE_PNG} $LIBPNG
5279   Does Emacs use -lrsvg-2?                                ${HAVE_RSVG}
5280   Does Emacs use cairo?                                   ${HAVE_CAIRO}
5281   Does Emacs use imagemagick?                             ${HAVE_IMAGEMAGICK}
5282   Does Emacs support sound?                               ${HAVE_SOUND}
5283   Does Emacs use -lgpm?                                   ${HAVE_GPM}
5284   Does Emacs use -ldbus?                                  ${HAVE_DBUS}
5285   Does Emacs use -lgconf?                                 ${HAVE_GCONF}
5286   Does Emacs use GSettings?                               ${HAVE_GSETTINGS}
5287   Does Emacs use a file notification library?             ${NOTIFY_SUMMARY}
5288   Does Emacs use access control lists?                    ${ACL_SUMMARY}
5289   Does Emacs use -lselinux?                               ${HAVE_LIBSELINUX}
5290   Does Emacs use -lgnutls?                                ${HAVE_GNUTLS}
5291   Does Emacs use -lxml2?                                  ${HAVE_LIBXML2}
5292   Does Emacs use -lfreetype?                              ${HAVE_FREETYPE}
5293   Does Emacs use -lm17n-flt?                              ${HAVE_M17N_FLT}
5294   Does Emacs use -lotf?                                   ${HAVE_LIBOTF}
5295   Does Emacs use -lxft?                                   ${HAVE_XFT}
5296   Does Emacs use -lsystemd?                               ${HAVE_LIBSYSTEMD}
5297   Does Emacs directly use zlib?                           ${HAVE_ZLIB}
5298   Does Emacs have dynamic modules support?                ${HAVE_MODULES}
5299   Does Emacs use toolkit scroll bars?                     ${USE_TOOLKIT_SCROLL_BARS}
5300   Does Emacs support Xwidgets (requires gtk3)?            ${HAVE_XWIDGETS}
5303 if test -n "${EMACSDATA}"; then
5304    AS_ECHO(["  Environment variable EMACSDATA set to:                  $EMACSDATA"])
5306 if test -n "${EMACSDOC}"; then
5307    AS_ECHO(["  Environment variable EMACSDOC set to:                   $EMACSDOC"])
5310 echo
5312 if test "$HAVE_NS" = "yes"; then
5313    echo
5314    AS_ECHO(["You must run \"${MAKE-make} install\" in order to test the built application.
5315 The installed application will go to nextstep/Emacs.app and can be
5316 run or moved from there."])
5317    if test "$EN_NS_SELF_CONTAINED" = "yes"; then
5318       echo "The application will be fully self-contained."
5319     else
5320       AS_ECHO(["The lisp resources for the application will be installed under ${prefix}.
5321 You may need to run \"${MAKE-make} install\" with sudo.  The application will fail
5322 to run if these resources are not installed."])
5323    fi
5324    echo
5327 if test "${opsys}" = "cygwin"; then
5328   case `uname -r` in
5329     1.5.*) AC_MSG_WARN([[building Emacs on Cygwin 1.5 is not supported.]])
5330            echo
5331            ;;
5332   esac
5335 # Remove any trailing slashes in these variables.
5336 case $prefix in
5337   */) prefix=`AS_DIRNAME(["$prefix."])`;;
5338 esac
5339 case $exec_prefix in
5340   */) exec_prefix=`AS_DIRNAME(["$exec_prefix."])`;;
5341 esac
5343 if test "$HAVE_NS" = "yes"; then
5344   if test "$NS_IMPL_GNUSTEP" = yes; then
5345     AC_CONFIG_FILES([nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist:nextstep/templates/Info-gnustep.plist.in \
5346       nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop:nextstep/templates/Emacs.desktop.in])
5347     ns_check_file=Resources/Info-gnustep.plist
5348   else
5349     AC_CONFIG_FILES([nextstep/Cocoa/Emacs.base/Contents/Info.plist:nextstep/templates/Info.plist.in \
5350       nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings:nextstep/templates/InfoPlist.strings.in])
5351     ns_check_file=Contents/Info.plist
5352   fi
5353   AC_SUBST(ns_check_file)
5356 dnl config.status treats $srcdir specially, so I think this is ok...
5357 AC_CONFIG_FILES([$srcdir/doc/man/emacs.1])
5359 dnl Obviously there is duplication here wrt $SUBDIR_MAKEFILES.
5360 dnl You _can_ use that variable in AC_CONFIG_FILES, so long as any directory
5361 dnl using automake (ie lib/) is explicitly listed and not "hidden" in a variable
5362 dnl (else you get "no 'Makefile.am' found for any configure output").
5363 dnl This will work, but you get a config.status that is not quite right
5364 dnl (see http://lists.gnu.org/archive/html/bug-autoconf/2008-08/msg00028.html).
5365 dnl That doesn't have any obvious consequences for Emacs, but on the whole
5366 dnl it seems better to just live with the duplication.
5367 SUBDIR_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 nt/Makefile"
5369 AC_CONFIG_FILES([Makefile lib/Makefile lib-src/Makefile oldXMenu/Makefile \
5370        doc/emacs/Makefile doc/misc/Makefile doc/lispintro/Makefile \
5371        doc/lispref/Makefile src/Makefile lwlib/Makefile lisp/Makefile \
5372        leim/Makefile nextstep/Makefile nt/Makefile])
5374 dnl test/ is not present in release tarfiles.
5375 opt_makefile=test/Makefile
5377 if test -f "$srcdir/$opt_makefile.in"; then
5378   SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
5379   dnl Again, it's best not to use a variable.  Though you can add
5380   dnl ", [], [opt_makefile='$opt_makefile']" and it should work.
5381   AC_CONFIG_FILES([test/Makefile])
5385 dnl The admin/ directory used to be excluded from tarfiles.
5386 if test -d $srcdir/admin; then
5387   SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES admin/charsets/Makefile admin/unidata/Makefile admin/grammars/Makefile"
5388   AC_CONFIG_FILES([admin/charsets/Makefile])
5389   AC_CONFIG_FILES([admin/unidata/Makefile])
5390   AC_CONFIG_FILES([admin/grammars/Makefile])
5391 fi                              dnl -d admin
5394 SUBDIR_MAKEFILES_IN=`echo " ${SUBDIR_MAKEFILES}" | sed -e 's| | $(srcdir)/|g' -e 's|Makefile|Makefile.in|g'`
5396 AC_SUBST(SUBDIR_MAKEFILES_IN)
5398 dnl You might wonder (I did) why epaths.h is generated by running make,
5399 dnl rather than just letting configure generate it from epaths.in.
5400 dnl One reason is that the various paths are not fully expanded (see above);
5401 dnl eg gamedir=${prefix}/var/games/emacs.
5402 dnl Secondly, the GNU Coding standards require that one should be able
5403 dnl to run 'make prefix=/some/where/else' and override the values set
5404 dnl by configure.  This also explains the 'move-if-change' test and
5405 dnl the use of force in the 'epaths-force' rule in Makefile.in.
5406 AC_CONFIG_COMMANDS([src/epaths.h], [
5407 if test "${opsys}" = "mingw32"; then
5408   ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-w32
5409 else
5410   ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force
5411 fi || AC_MSG_ERROR(['src/epaths.h' could not be made.])
5412 ], [GCC="$GCC" CPPFLAGS="$CPPFLAGS" opsys="$opsys"])
5414 dnl NB we have to cheat and use the ac_... version because abs_top_srcdir
5415 dnl is not yet set, sigh.  Or we could use ../$srcdir/src/.gdbinit,
5416 dnl or a symlink?
5417 AC_CONFIG_COMMANDS([src/.gdbinit], [
5418 if test ! -f src/.gdbinit && test -f "$srcdir/src/.gdbinit"; then
5419   AS_ECHO(["source $ac_abs_top_srcdir/src/.gdbinit"]) > src/.gdbinit
5423 dnl Perhaps this would be better named doc-emacs-emacsver.texi?
5424 dnl See comments for etc-refcards-emacsver.tex.
5425 dnl Since we get a doc/emacs directory generated anyway, for the Makefile,
5426 dnl it is not quite the same.  But we are generating in $srcdir.
5427 AC_CONFIG_COMMANDS([doc/emacs/emacsver.texi], [
5428 ${MAKE-make} -s --no-print-directory -C doc/emacs doc-emacsver || \
5429 AC_MSG_ERROR(['doc/emacs/emacsver.texi' could not be made.])
5432 dnl If we give this the more natural name, etc/refcards/emacsver.texi,
5433 dnl then a directory etc/refcards is created in the build directory,
5434 dnl which is probably harmless, but confusing (in out-of-tree builds).
5435 dnl (If we were to generate etc/refcards/Makefile, this might change.)
5436 dnl It is really $srcdir/etc/refcards/emacsver.tex that we generate.
5437 AC_CONFIG_COMMANDS([etc-refcards-emacsver.tex], [
5438 ${MAKE-make} -s MAKEFILE_NAME=do-not-make-Makefile etc-emacsver || \
5439 AC_MSG_ERROR(['etc/refcards/emacsver.tex' could not be made.])
5442 AC_OUTPUT
5444 test "$MAKE" = make || AC_MSG_NOTICE([Now you can run '$MAKE'.])