Fix the etags test suite
[emacs.git] / configure.ac
blob3df4359fa72d716e9e9d6bc06a4b9d0fee5eb820
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-2021 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 <https://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, 28.0.50, bug-gnu-emacs@gnu.org, , https://www.gnu.org/software/emacs/)
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 AC_CONFIG_MACRO_DIR(m4)
72 xcsdkdir=
73 AC_CHECK_PROGS(XCRUN, [xcrun])
74 if test -n "$XCRUN"; then
75   if test -z "$MAKE"; then
76     dnl Call the variable MAKE_PROG, not MAKE, to avoid confusion with
77     dnl the usual MAKE variable that 'make' itself uses.
78     AC_CHECK_PROG([MAKE_PROG], [make], [yes])
79     if test -z "$MAKE_PROG"; then
80       MAKE="$XCRUN MAKE"
81       export MAKE
82       xcsdkdir=`$XCRUN --show-sdk-path 2>/dev/null`
83     fi
84   fi
87 dnl Check for GNU Make and possibly set MAKE.
88 [emacs_check_gnu_make ()
90   emacs_makeout=`($1 --version) 2>/dev/null` &&
91   case $emacs_makeout in
92     'GNU Make '3.8[1-9]* | 'GNU Make '3.9[0-9]* | \
93     'GNU Make '3.[1-9][0-9][0-9]* | 'GNU Make '[4-9]* | 'GNU Make '[1-9][0-9]* )
94        ac_path_MAKE_found=:;;
95   esac
97 AC_CACHE_CHECK([for GNU Make], [ac_cv_path_MAKE],
98   [ac_path_MAKE_found=false
99    if test -n "$MAKE"; then
100      emacs_check_gnu_make "$MAKE"
101      ac_cv_path_MAKE=$MAKE
102    else
103      emacs_tried_make=false
104      emacs_tried_gmake=false
105      emacs_tried_gnumake=false
106      AC_PATH_PROGS_FEATURE_CHECK([MAKE], [make gmake gnumake],
107        [[emacs_check_gnu_make "$ac_path_MAKE"
108          if $ac_path_MAKE_found; then
109            # Use the fully-qualified program name only if the basename
110            # would not resolve to it.
111            if eval \$emacs_tried_$ac_prog; then
112              ac_cv_path_MAKE=$ac_path_MAKE
113            else
114              ac_cv_path_MAKE=$ac_prog
115            fi
116          fi
117          eval emacs_tried_$ac_prog=:]])
118    fi])
119 $ac_path_MAKE_found || {
120 AC_MSG_ERROR([[Building Emacs requires GNU Make, at least version 3.81.
121 If you have it installed under another name, configure with 'MAKE=...'.
122 For example, run '$0 MAKE=gnu-make'.]])
124 MAKE=$ac_cv_path_MAKE
125 export MAKE
127 dnl Canonicalize the configuration name.
128 AC_CANONICAL_HOST
130 case $host in
131  *-mingw*)
133   if test -z "$host_alias"; then
135       # No --host argument was given to 'configure'; therefore $host
136       # was set to a default value based on the build platform.  But
137       # this default value may be wrong if we are building from a
138       # 64-bit MSYS[2] pre-configured to build 32-bit MinGW programs.
139       # Therefore, we'll try to get the right host platform from the
140       # compiler's target.
142       AC_MSG_CHECKING([the compiler's target])
143       if test -z "$CC"; then
144           cc=gcc
145       else
146           cc=$CC
147       fi
148       cc_target=`$cc -v 2>&1 | sed -n 's/Target: //p'`
149       case "$cc_target" in
150           *-*) host=$cc_target
151               ;;
152           "") AC_MSG_ERROR([Impossible to obtain $cc compiler target.
153 Please explicitly provide --host.])
154               ;;
155           *) AC_MSG_WARN([Compiler reported non-standard target.
156 Defaulting to $host.])
157               ;;
158       esac
159       AC_MSG_RESULT([$host])
160   fi
162   . $srcdir/nt/mingw-cfg.site
164   case $srcdir in
165     /* | ?:*)
166       # srcdir is an absolute path.  In this case, force the format
167       # "/c/foo/bar", to simplify later conversions to native Windows
168       # format ("c:/foo/bar").
169       srcdir=`cd "${srcdir}" && pwd -W`
170       # 'eval' pacifies strict POSIX non-MinGW shells (Bug#18612).
171       # We downcase the drive letter to avoid warnings when
172       # generating autoloads.
173       eval 'srcdir=/`echo ${srcdir:0:1} | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"`"${srcdir:2}"'
174       ;;
175   esac;;
176 esac
178 canonical=$host
179 configuration=${host_alias-${build_alias-$host}}
180 emacs_uname_r=`uname -r`
182 dnl Support for --program-prefix, --program-suffix and
183 dnl --program-transform-name options
184 AC_ARG_PROGRAM
186 dnl It is important that variables on the RHS not be expanded here,
187 dnl hence the single quotes.  This is per the GNU coding standards, see
188 dnl (autoconf) Installation Directory Variables
189 dnl See also epaths.h below.
190 lispdirrel='${version}/lisp'
191 lispdir='${datadir}/emacs/'${lispdirrel}
192 standardlisppath='${lispdir}'
193 locallisppath='${datadir}/emacs/${version}/site-lisp:'\
194 '${datadir}/emacs/site-lisp'
195 lisppath='${locallisppath}:${standardlisppath}'
196 etcdir='${datadir}/emacs/${version}/etc'
197 archlibdir='${libexecdir}/emacs/${version}/${configuration}'
198 etcdocdir='${datadir}/emacs/${version}/etc'
199 gamedir='${localstatedir}/games/emacs'
201 dnl Special option to disable the most of other options.
202 AC_ARG_WITH(all,
203 [AS_HELP_STRING([--without-all],
204                 [omit almost all features and build
205                 small executable with minimal dependencies])],
206   [with_features=$withval],
207   [with_features=yes])
209 dnl OPTION_DEFAULT_OFF(NAME, HELP-STRING)
210 dnl Create a new --with option that defaults to being disabled.
211 dnl NAME is the base name of the option.  The shell variable with_NAME
212 dnl   will be set to either the user's value (if the option is
213 dnl   specified; 'yes' for a plain --with-NAME) or to 'no' (if the
214 dnl   option is not specified).  Note that the shell variable name is
215 dnl   constructed as autoconf does, by replacing non-alphanumeric
216 dnl   characters with "_".
217 dnl HELP-STRING is the help text for the option.
218 AC_DEFUN([OPTION_DEFAULT_OFF], [dnl
219   AC_ARG_WITH([$1],[AS_HELP_STRING([--with-$1],[$2])],[],[dnl
220     m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=no])dnl
221 ])dnl
223 dnl OPTION_DEFAULT_IFAVAILABLE(NAME, HELP-STRING)
224 dnl Create a new --with option that defaults to 'ifavailable'.
225 dnl NAME is the base name of the option.  The shell variable with_NAME
226 dnl   will be set to either the user's value (if the option is
227 dnl   specified; 'yes' for a plain --with-NAME) or to 'ifavailable' (if the
228 dnl   option is not specified).  Note that the shell variable name is
229 dnl   constructed as autoconf does, by replacing non-alphanumeric
230 dnl   characters with "_".
231 dnl HELP-STRING is the help text for the option.
232 AC_DEFUN([OPTION_DEFAULT_IFAVAILABLE], [dnl
233   AC_ARG_WITH([$1],[AS_HELP_STRING([--with-$1],[$2])],[],[dnl
234     m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=ifavailable])dnl
235 ])dnl
238 dnl OPTION_DEFAULT_ON(NAME, HELP-STRING)
239 dnl Create a new --with option that defaults to $with_features.
240 dnl NAME is the base name of the option.  The shell variable with_NAME
241 dnl   will be set either to 'no' (for a plain --without-NAME) or to
242 dnl   'yes' (if the option is not specified).  Note that the shell
243 dnl   variable name is constructed as autoconf does, by replacing
244 dnl   non-alphanumeric characters with "_".
245 dnl HELP-STRING is the help text for the option.
246 AC_DEFUN([OPTION_DEFAULT_ON], [dnl
247   AC_ARG_WITH([$1],[AS_HELP_STRING([--without-$1],[$2])],[],[dnl
248    m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=$with_features])dnl
249 ])dnl
251 # For retrieving mail, unencrypted network connections are the default
252 # only on native MS-Windows platforms.  (FIXME: These platforms should
253 # also be secure by default.)
255 AC_ARG_WITH([mailutils],
256   [AS_HELP_STRING([--with-mailutils],
257      [rely on GNU Mailutils, so that the --without-pop through --with-mailhost
258       options are irrelevant; this is the default if GNU Mailutils is
259       installed])],
260   [],
261   [with_mailutils=$with_features
262    if test "$with_mailutils" = yes; then
263      (movemail --version) >/dev/null 2>&1 || with_mailutils=no
264    fi])
265 if test "$with_mailutils" = no; then
266   with_mailutils=
268 AC_SUBST([with_mailutils])
270 AC_ARG_WITH([pop],
271   [AS_HELP_STRING([--with-pop],
272      [Support POP mail retrieval if Emacs movemail is used (not recommended,
273       as Emacs movemail POP is insecure).  This is the default only on
274       native MS-Windows.])],
275   [],
276   [case $host in
277      *-mingw*) with_pop=yes;;
278      *) with_pop=no-by-default;;
279    esac])
280 if test "$with_pop" = yes; then
281    AC_DEFINE(MAIL_USE_POP)
283 AH_TEMPLATE(MAIL_USE_POP, [Define to support POP mail retrieval.])dnl
285 OPTION_DEFAULT_OFF([kerberos],[support Kerberos-authenticated POP])
286 if test "$with_kerberos" != no; then
287    AC_DEFINE(KERBEROS)
289 AH_TEMPLATE(KERBEROS,
290             [Define to support Kerberos-authenticated POP mail retrieval.])dnl
292 OPTION_DEFAULT_OFF([kerberos5],[support Kerberos version 5 authenticated POP])
293 if test "${with_kerberos5}" != no; then
294   if test "${with_kerberos}" = no; then
295     with_kerberos=yes
296     AC_DEFINE(KERBEROS)
297   fi
298   AC_DEFINE(KERBEROS5, 1, [Define to use Kerberos 5 instead of Kerberos 4.])
301 OPTION_DEFAULT_OFF([hesiod],[support Hesiod to get the POP server host])
302 dnl FIXME hesiod support may not be present, so it seems like an error
303 dnl to define, or at least use, this unconditionally.
304 if test "$with_hesiod" != no; then
305   AC_DEFINE(HESIOD, 1, [Define to support using a Hesiod database to find the POP server.])
308 OPTION_DEFAULT_OFF([mail-unlink],[unlink, rather than empty, mail spool after reading])
309 if test "$with_mail_unlink" != no; then
310    AC_DEFINE(MAIL_UNLINK_SPOOL, 1, [Define to unlink, rather than empty, mail spool after reading.])
313 AC_ARG_WITH([mailhost],[AS_HELP_STRING([--with-mailhost=HOSTNAME],
314     [string giving default POP mail host])],
315     AC_DEFINE_UNQUOTED(MAILHOST, ["$withval"], [String giving fallback POP mail host.]))
317 AC_ARG_WITH([sound],[AS_HELP_STRING([--with-sound=VALUE],
318   [compile with sound support (VALUE one of: yes, alsa, oss, bsd-ossaudio, no;
319 default yes).  Only for GNU/Linux, FreeBSD, NetBSD, MinGW, Cygwin.])],
320   [ case "${withval}" in
321       yes|no|alsa|oss|bsd-ossaudio) val=$withval ;;
322       *) AC_MSG_ERROR(['--with-sound=$withval' is invalid;
323 this option's value should be 'yes', 'no', 'alsa', 'oss', or 'bsd-ossaudio'.])
324       ;;
325     esac
326     with_sound=$val
327   ],
328   [with_sound=$with_features])
330 AC_ARG_WITH([pdumper],
331   AS_HELP_STRING(
332     [--with-pdumper=VALUE],
333     [enable pdumper support unconditionally
334       ('yes', 'no', or 'auto': default 'auto')]),
335     [ case "${withval}" in
336         yes|no|auto) val=$withval ;;
337         *) AC_MSG_ERROR(
338            ['--with-pdumper=$withval' is invalid;
339 this option's value should be 'yes' or 'no'.]) ;;
340       esac
341       with_pdumper=$val
342     ],
343     [with_pdumper=auto])
345 AC_ARG_WITH([unexec],
346   AS_HELP_STRING(
347     [--with-unexec=VALUE],
348     [enable unexec support unconditionally
349       ('yes', 'no', or 'auto': default 'auto')]),
350     [ case "${withval}" in
351         yes|no|auto) val=$withval ;;
352         *) AC_MSG_ERROR(
353            ['--with-unexec=$withval' is invalid;
354 this option's value should be 'yes' or 'no'.]) ;;
355       esac
356       with_unexec=$val
357     ],
358     [with_unexec=auto])
360 AC_ARG_WITH([dumping],[AS_HELP_STRING([--with-dumping=VALUE],
361     [kind of dumping to use for initial Emacs build
362 (VALUE one of: pdumper, unexec, none; default pdumper)])],
363     [ case "${withval}" in
364         pdumper|unexec|none) val=$withval ;;
365         *) AC_MSG_ERROR(['--with-dumping=$withval is invalid;
366 this option's value should be 'pdumper', 'unexec', or 'none'.])
367         ;;
368       esac
369       with_dumping=$val
370     ],
371     [with_dumping=pdumper])
373 if test "$with_pdumper" = "auto"; then
374   if test "$with_dumping" = "pdumper"; then
375     with_pdumper=yes
376   else
377     with_pdumper=no
378   fi
381 if test "$with_unexec" = "auto"; then
382   if test "$with_dumping" = "unexec"; then
383     with_unexec=yes
384   else
385     with_unexec=no
386   fi
389 if test "$with_dumping" = "pdumper" && test "$with_pdumper" = "no"; then
390   AC_MSG_ERROR(['--with-dumping=pdumper' requires pdumper support])
393 if test "$with_dumping" = "unexec" && test "$with_unexec" = "no"; then
394   AC_MSG_ERROR(['--with-dumping=unexec' requires unexec support])
397 if test "$with_pdumper" = "yes"; then
398   AC_DEFINE([HAVE_PDUMPER], 1, [Define to build with portable dumper support])
399   HAVE_PDUMPER=yes
400 else
401   HAVE_PDUMPER=no
403 AC_SUBST([HAVE_PDUMPER])
405 DUMPING=$with_dumping
406 AC_SUBST(DUMPING)
408 dnl FIXME currently it is not the last.
409 dnl This should be the last --with option, because --with-x is
410 dnl added later on when we find the file name of X, and it's best to
411 dnl keep them together visually.
412 AC_ARG_WITH([x-toolkit],[AS_HELP_STRING([--with-x-toolkit=KIT],
413  [use an X toolkit (KIT one of: yes or gtk, gtk2, gtk3, lucid or athena, no)])],
414 [         case "${withval}" in
415             y | ye | yes )      val=gtk ;;
416             n | no )            val=no  ;;
417             l | lu | luc | luci | lucid )       val=lucid ;;
418             a | at | ath | athe | athen | athena )      val=athena ;;
419             g | gt | gtk  )     val=gtk ;;
420             gtk2  )     val=gtk2 ;;
421             gtk3  )     val=gtk3 ;;
422             * )
423 AC_MSG_ERROR(['--with-x-toolkit=$withval' is invalid;
424 this option's value should be 'yes', 'no', 'lucid', 'athena', 'gtk',
425 'gtk2' or 'gtk3'.  'yes' and 'gtk' are synonyms.
426 'athena' and 'lucid' are synonyms.])
427             ;;
428           esac
429           with_x_toolkit=$val
432 OPTION_DEFAULT_OFF([wide-int],
433   [prefer wide Emacs integers (typically 62-bit);
434    on 32-bit hosts, this allows buffer and string size up to 2GB,
435    at the cost of 10% to 30% slowdown of Lisp interpreter
436    and larger memory footprint])
437 if test "$with_wide_int" = yes; then
438   AC_DEFINE([WIDE_EMACS_INT], 1, [Use long long for EMACS_INT if available.])
441 dnl _ON results in a '--without' option in the --help output, so
442 dnl the help text should refer to "don't compile", etc.
443 with_xpm_set=${with_xpm+set}
444 OPTION_DEFAULT_ON([xpm],[don't compile with XPM image support])
445 OPTION_DEFAULT_ON([jpeg],[don't compile with JPEG image support])
446 OPTION_DEFAULT_ON([tiff],[don't compile with TIFF image support])
447 OPTION_DEFAULT_ON([gif],[don't compile with GIF image support])
448 OPTION_DEFAULT_ON([png],[don't compile with PNG image support])
449 OPTION_DEFAULT_ON([rsvg],[don't compile with SVG image support])
450 OPTION_DEFAULT_ON([lcms2],[don't compile with Little CMS support])
451 OPTION_DEFAULT_ON([libsystemd],[don't compile with libsystemd support])
452 OPTION_DEFAULT_ON([cairo],[don't compile with Cairo drawing])
453 OPTION_DEFAULT_ON([xml2],[don't compile with XML parsing support])
454 OPTION_DEFAULT_OFF([imagemagick],[compile with ImageMagick image support])
455 OPTION_DEFAULT_ON([native-image-api], [don't use native image APIs (GDI+ on Windows)])
456 OPTION_DEFAULT_IFAVAILABLE([json], [compile with native JSON support])
458 OPTION_DEFAULT_ON([xft],[don't use XFT for anti aliased fonts])
459 OPTION_DEFAULT_ON([harfbuzz],[don't use HarfBuzz for text shaping])
460 OPTION_DEFAULT_ON([libotf],[don't use libotf for OpenType font support])
461 OPTION_DEFAULT_ON([m17n-flt],[don't use m17n-flt for text shaping])
463 OPTION_DEFAULT_ON([toolkit-scroll-bars],[don't use Xaw3d/GTK toolkit scroll bars])
464 OPTION_DEFAULT_ON([xaw3d],[don't use Xaw3d])
465 OPTION_DEFAULT_ON([xim],[at runtime, default X11 XIM to off])
466 OPTION_DEFAULT_ON([xdbe],[don't use X11 double buffering support])
467 AC_ARG_WITH([ns],[AS_HELP_STRING([--with-ns],
468 [use Nextstep (macOS Cocoa or GNUstep) windowing system.
469 On by default on macOS.])],[],[with_ns=maybe])
470 OPTION_DEFAULT_OFF([w32], [use native MS Windows GUI in a Cygwin build])
472 OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console])
473 OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support])
474 AC_ARG_WITH([gconf],[AS_HELP_STRING([--with-gconf],
475 [compile with Gconf support (Gsettings replaces this)])],[],
476 [if test $with_features = yes; then
477 with_gconf=maybe
478 else
479 with_gconf=no
480 fi])
481 OPTION_DEFAULT_ON([gsettings],[don't compile with GSettings support])
482 OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support])
483 OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support])
484 OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support])
485 OPTION_DEFAULT_ON([modules],[don't compile with dynamic modules support])
486 OPTION_DEFAULT_ON([threads],[don't compile with elisp threading support])
487 OPTION_DEFAULT_OFF([native-compilation],[compile with Emacs Lisp native compiler support])
489 AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB],
490  [use a file notification library (LIB one of: yes, inotify, kqueue, gfile, w32, no)])],
491  [ case "${withval}" in
492     y | ye | yes )      val=yes ;;
493     n | no )            val=no  ;;
494     i | in | ino | inot | inoti | inotif | inotify )    val=inotify ;;
495     k | kq | kqu | kque | kqueu | kqueue )      val=kqueue ;;
496     g | gf | gfi | gfil | gfile )       val=gfile ;;
497     w | w3 | w32 )      val=w32 ;;
498     * ) AC_MSG_ERROR(['--with-file-notification=$withval' is invalid;
499 this option's value should be 'yes', 'no', 'inotify', 'kqueue', 'gfile' or 'w32'.
500 'yes' is a synonym for 'w32' on MS-Windows, for 'no' on Nextstep,
501 otherwise for the first of 'inotify', 'kqueue' or 'gfile' that is usable.])
502     ;;
503    esac
504    with_file_notification=$val
505  ],
506  [with_file_notification=$with_features])
508 OPTION_DEFAULT_OFF([xwidgets],
509   [enable use of xwidgets in Emacs buffers (requires gtk3 or macOS Cocoa)])
511 ## Makefile.in needs the cache file name.
512 AC_SUBST(cache_file)
514 ## This is an option because I do not know if all info/man support
515 ## compressed files, nor how to test if they do so.
516 OPTION_DEFAULT_ON([compress-install],
517   [don't compress some files (.el, .info, etc.) when installing.  Equivalent to:
518 make GZIP_PROG= install])
520 AC_ARG_WITH(gameuser,dnl
521 [AS_HELP_STRING([--with-gameuser=USER_OR_GROUP],
522                 [user for shared game score files.
523                 An argument prefixed by ':' specifies a group instead.])])
524 gameuser=
525 gamegroup=
526 case ${with_gameuser} in
527   '' | no) ;;
528   yes) gamegroup=games ;;
529   :*) gamegroup=${with_gameuser#:} ;;
530   *) gameuser=${with_gameuser} ;;
531 esac
533 AC_ARG_WITH([gnustep-conf],dnl
534 [AS_HELP_STRING([--with-gnustep-conf=FILENAME],
535    [name of GNUstep configuration file to use on systems where the command
536     'gnustep-config' does not work; default $GNUSTEP_CONFIG_FILE, or
537     /etc/GNUstep/GNUstep.conf])])
538 test "X${with_gnustep_conf}" != X && test "${with_gnustep_conf}" != yes && \
539   GNUSTEP_CONFIG_FILE="${with_gnustep_conf}"
540 test "X$GNUSTEP_CONFIG_FILE" = "X" && \
541      GNUSTEP_CONFIG_FILE=/etc/GNUstep/GNUstep.conf
543 AC_ARG_ENABLE(ns-self-contained,
544 [AS_HELP_STRING([--disable-ns-self-contained],
545                 [disable self contained build under NeXTstep])],
546    EN_NS_SELF_CONTAINED=$enableval,
547    EN_NS_SELF_CONTAINED=yes)
549 locallisppathset=no
550 AC_ARG_ENABLE(locallisppath,
551 [AS_HELP_STRING([--enable-locallisppath=PATH],
552                 [directories Emacs should search for lisp files specific
553                  to this site])],
554 if test "${enableval}" = "no"; then
555   locallisppath=
556 elif test "${enableval}" != "yes"; then
557   locallisppath=${enableval} locallisppathset=yes
560 AC_ARG_ENABLE(checking,
561 [AS_HELP_STRING([--enable-checking@<:@=LIST@:>@],
562                 [enable expensive checks.  With LIST,
563                  enable only specific categories of checks.
564                  Categories are: all,yes,no.
565                  Flags are: stringbytes, stringoverrun, stringfreelist,
566                  structs, glyphs])],
567 [ac_checking_flags="${enableval}"],[])
568 IFS="${IFS=     }"; ac_save_IFS="$IFS"; IFS="$IFS,"
569 CHECK_STRUCTS=false
570 for check in $ac_checking_flags
572         case $check in
573         # these set all the flags to specific states
574         yes)            ac_enable_checking=1 ;;
575         no)             ac_enable_checking= ;
576                         CHECK_STRUCTS=false
577                         ac_gc_check_stringbytes= ;
578                         ac_gc_check_string_overrun= ;
579                         ac_gc_check_string_free_list= ;
580                         ac_glyphs_debug= ;;
581         all)            ac_enable_checking=1 ;
582                         CHECK_STRUCTS=true
583                         ac_gc_check_stringbytes=1 ;
584                         ac_gc_check_string_overrun=1 ;
585                         ac_gc_check_string_free_list=1 ;
586                         ac_glyphs_debug=1 ;;
587         # these enable particular checks
588         stringbytes)    ac_gc_check_stringbytes=1 ;;
589         stringoverrun)  ac_gc_check_string_overrun=1 ;;
590         stringfreelist) ac_gc_check_string_free_list=1 ;;
591         structs)        CHECK_STRUCTS=true ;;
592         glyphs)         ac_glyphs_debug=1 ;;
593         *)      AC_MSG_ERROR(unknown check category $check) ;;
594         esac
595 done
596 IFS="$ac_save_IFS"
598 if test x$ac_enable_checking != x ; then
599   AC_DEFINE(ENABLE_CHECKING, 1,
600 [Define to 1 if expensive run-time data type and consistency checks are enabled.])
602 if $CHECK_STRUCTS; then
603   AC_DEFINE([CHECK_STRUCTS], 1,
604     [Define this to check whether someone updated the portable dumper
605      code after changing the layout of a structure that it uses.
606      If you change one of these structures, check that the pdumper.c
607      code is still valid, and update the pertinent hash in pdumper.c
608      by manually copying the hash from the newly-generated dmpstruct.h.])
610 AC_SUBST([CHECK_STRUCTS])
611 if test x$ac_gc_check_stringbytes != x ; then
612   AC_DEFINE(GC_CHECK_STRING_BYTES, 1,
613 [Define this temporarily to hunt a bug.  If defined, the size of
614    strings is redundantly recorded in sdata structures so that it can
615    be compared to the sizes recorded in Lisp strings.])
617 if test x$ac_gc_check_string_overrun != x ; then
618   AC_DEFINE(GC_CHECK_STRING_OVERRUN, 1,
619 [Define this to check for short string overrun.])
621 if test x$ac_gc_check_string_free_list != x ; then
622   AC_DEFINE(GC_CHECK_STRING_FREE_LIST, 1,
623 [Define this to check the string free list.])
625 if test x$ac_glyphs_debug != x ; then
626   AC_DEFINE(GLYPH_DEBUG, 1,
627 [Define this to enable glyphs debugging code.])
630 dnl The name of this option is unfortunate.  It predates, and has no
631 dnl relation to, the "sampling-based elisp profiler" added in 24.3.
632 dnl Actually, it stops it working.
633 dnl https://lists.gnu.org/r/emacs-devel/2012-11/msg00393.html
634 AC_ARG_ENABLE(profiling,
635 [AS_HELP_STRING([--enable-profiling],
636                 [build emacs with low-level, gprof profiling support.
637                 Mainly useful for debugging Emacs itself.  May not work on
638                 all platforms.  Stops profiler.el working.])],
639 [ac_enable_profiling="${enableval}"],[])
640 if test x$ac_enable_profiling != x ; then
641    PROFILING_CFLAGS="-DPROFILING=1 -pg"
642 else
643    PROFILING_CFLAGS=
645 AC_SUBST(PROFILING_CFLAGS)
647 AC_ARG_ENABLE(autodepend,
648 [AS_HELP_STRING([--enable-autodepend],
649                 [automatically generate dependencies to .h-files.
650                  Requires gcc, enabled if found.])],
651 [ac_enable_autodepend="${enableval}"],[ac_enable_autodepend=yes])
653 AC_ARG_ENABLE(gtk-deprecation-warnings,
654 [AS_HELP_STRING([--enable-gtk-deprecation-warnings],
655                 [Show Gtk+/Gdk deprecation warnings for Gtk+ >= 3.0])],
656 [ac_enable_gtk_deprecation_warnings="${enableval}"],[])
658 BUILD_DETAILS=
659 AC_ARG_ENABLE([build-details],
660   [AS_HELP_STRING([--disable-build-details],
661                   [Make the build more deterministic by omitting host
662                    names, time stamps, etc. from the output.])],
663   [test "$enableval" = no && BUILD_DETAILS=--no-build-details])
664 AC_SUBST([BUILD_DETAILS])
666 dnl This used to use changequote, but, apart from 'changequote is evil'
667 dnl per the autoconf manual, we can speed up autoconf somewhat by quoting
668 dnl the great gob of text.  Thus it's not processed for possible expansion.
669 dnl Just make sure the brackets remain balanced.
671 dnl Since Emacs can't find matching pairs of quotes, boundaries are
672 dnl indicated by comments.
673 dnl quotation begins
676 ### If you add support for a new configuration, add code to this
677 ### switch statement to recognize your configuration name and select
678 ### the appropriate opsys.
680 ### As far as handling version numbers on operating systems is
681 ### concerned, make sure things will fail in a fixable way.  If
682 ### /etc/MACHINES doesn't say anything about version numbers, be
683 ### prepared to handle anything reasonably.  If version numbers
684 ### matter, be sure /etc/MACHINES says something about it.
686 opsys='' unported=no
687 case "${canonical}" in
689   ## GNU/Linux and similar ports
690   *-*-linux* )
691     opsys=gnu-linux
692   ;;
694   ## FreeBSD ports
695   *-*-freebsd* )
696     opsys=freebsd
697   ;;
699   ## DragonFly ports
700   *-*-dragonfly* )
701     opsys=dragonfly
702   ;;
704   ## FreeBSD kernel + glibc based userland
705   *-*-kfreebsd*gnu* )
706     opsys=gnu-kfreebsd
707   ;;
709   ## NetBSD ports
710   *-*-netbsd* )
711     opsys=netbsd
712   ;;
714   ## OpenBSD ports
715   *-*-openbsd* | *-*-mirbsd* )
716     opsys=openbsd
717   ;;
719   ## Apple Darwin / macOS
720   *-apple-darwin* )
721     case "${canonical}" in
722       *-apple-darwin[0-9].*) unported=yes ;;
723       i[3456]86-* | x86_64-* | arm-* | aarch64-* )  ;;
724       * )            unported=yes ;;
725     esac
726     opsys=darwin
727     ## FIXME: Find a way to use Fink if available (Bug#11507).
728   ;;
730   ## Chromium Native Client
731   *-nacl )
732     opsys=nacl
733   ;;
735   ## Cygwin ports
736   *-*-cygwin )
737     opsys=cygwin
738   ;;
740   ## HP 9000 series 700 and 800, running HP/UX
741   hppa*-hp-hpux10.2* )
742     opsys=hpux10-20
743   ;;
744   hppa*-hp-hpux1[1-9]* )
745     opsys=hpux11
746     CFLAGS="-D_INCLUDE__STDC_A1_SOURCE $CFLAGS"
747   ;;
749   ## IBM machines
750   rs6000-ibm-aix4.[23]* )
751     opsys=aix4-2
752   ;;
753   powerpc-ibm-aix4.[23]*  )
754     opsys=aix4-2
755   ;;
756   rs6000-ibm-aix[56]* )
757     opsys=aix4-2
758   ;;
759   powerpc-ibm-aix[5-9]* | powerpc-ibm-aix[1-9][0-9]* )
760     opsys=aix4-2
761   ;;
763   ## Solaris
764   *-*-solaris* | *-*-sunos*)
765     case "${canonical}" in
766       i[3456]86-*-* )   ;;
767       amd64-*-*|x86_64-*-*) ;;
768       sparc* )          ;;
769       * )               unported=yes ;;
770     esac
771     opsys=solaris
772     ## Watch out for a compiler that we know will not work.
773     if [ "$CC" = /usr/ucb/cc ]; then
774       ## /usr/ucb/cc doesn't work;
775       ## we should find some other compiler that does work.
776       unset CC
777     fi
778   ;;
780   ## QNX Neutrino
781   *-nto-qnx* )
782     opsys=qnxnto
783     test -z "$CC" && CC=qcc
784     LDFLAGS="-N2M $LDFLAGS"
785   ;;
787   ## Intel 386 machines where we don't care about the manufacturer.
788   i[3456]86-*-* )
789     case "${canonical}" in
790       *-darwin* )               opsys=darwin ;;
791       *-mingw* )
792                 opsys=mingw32
793                 # MinGW overrides and adds some system headers in nt/inc.
794                 GCC_TEST_OPTIONS="-I $srcdir/nt/inc"
795                 ;;
796       *-sysv4.2uw* )            opsys=unixware ;;
797       *-sysv5uw* )              opsys=unixware ;;
798       *-sysv5OpenUNIX* )        opsys=unixware ;;
799       ## Otherwise, we'll fall through to the generic opsys code at the bottom.
800     esac
801   ;;
803   # MinGW64
804   x86_64-*-* )
805     case "${canonical}" in
806       *-mingw* )
807                 opsys=mingw32
808                 # MinGW overrides and adds some system headers in nt/inc.
809                 GCC_TEST_OPTIONS="-I $srcdir/nt/inc"
810                 ;;
811       ## Otherwise, we'll fall through to the generic opsys code at the bottom.
812     esac
813   ;;
815   * )
816     unported=yes
817   ;;
818 esac
820 ### If the code above didn't choose an operating system, just choose
821 ### an operating system based on the configuration name.  You really
822 ### only want to use this when you have no idea what the right
823 ### operating system is; if you know what operating systems a machine
824 ### runs, it's cleaner to make it explicit in the case statement
825 ### above.
826 if test x"${opsys}" = x; then
827   case "${canonical}" in
828     *-gnu* )                            opsys=gnu ;;
829     * )
830       unported=yes
831     ;;
832   esac
836 dnl quotation ends
838 if test $unported = yes; then
839   AC_MSG_ERROR([Emacs does not support '${canonical}' systems.
840 If you think it should, please send a report to ${PACKAGE_BUGREPORT}.
841 Check 'etc/MACHINES' for recognized configuration names.])
844 #### Choose a compiler.
846 dnl Don't bother to test for C89.
847 AC_DEFUN([_AC_PROG_CC_C89], [$2])
849 dnl Sets GCC=yes if using gcc.
850 AC_PROG_CC([gcc cc cl clang "$XCRUN gcc" "$XCRUN clang"])
851 if test -n "$XCRUN"; then
852   AC_CHECK_PROGS(AR, [ar "$XCRUN ar"])
853   test -n "$AR" && export AR
856 dnl Emacs needs C99 or later.
857 gl_PROG_CC_C99
859 AC_PROG_CC_C_O
861 if test x$GCC = xyes; then
862   test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
865 # Avoid gnulib's tests for -lcrypto, so that there's no static dependency on it.
866 AC_DEFUN([gl_CRYPTO_CHECK])
867 # Avoid gnulib's tests for HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW,
868 # as we don't use them.
869 AC_DEFUN([gl_FCNTL_O_FLAGS])
870 # Avoid gnulib's test for pthread_sigmask.
871 funcs=
872 for func in $ac_func_list; do
873   test $func = pthread_sigmask || AS_VAR_APPEND([funcs], [" $func"])
874 done
875 ac_func_list=$funcs
876 # Emacs does not use the wchar or wctype-h modules.
877 AC_DEFUN([gt_TYPE_WINT_T],
878   [GNULIB_OVERRIDES_WINT_T=0
879    AC_SUBST([GNULIB_OVERRIDES_WINT_T])])
881 # Initialize gnulib right after choosing the compiler.
882 dnl Amongst other things, this sets AR and ARFLAGS.
883 gl_EARLY
885 if test "$ac_test_CFLAGS" != set; then
886   # It's helpful to have C macros available to GDB, so prefer -g3 to -g
887   # if -g3 works and the user does not specify CFLAGS.
888   # This test must follow gl_EARLY; otherwise AC_LINK_IFELSE complains.
889   case $CFLAGS in
890     '-g')
891       emacs_g3_CFLAGS='-g3';;
892     '-g -O2')
893       emacs_g3_CFLAGS='-g3 -O2';;
894     *)
895       emacs_g3_CFLAGS='';;
896   esac
897   if test -n "$emacs_g3_CFLAGS"; then
898     emacs_save_CFLAGS=$CFLAGS
899     CFLAGS=$emacs_g3_CFLAGS
900     AC_CACHE_CHECK([whether $CC accepts $emacs_g3_CFLAGS],
901       [emacs_cv_prog_cc_g3],
902       [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
903          [emacs_cv_prog_cc_g3=yes],
904          [emacs_cv_prog_cc_g3=no])])
905     if test $emacs_cv_prog_cc_g3 != yes; then
906       CFLAGS=$emacs_save_CFLAGS
907     fi
908     if test $opsys = mingw32; then
909       CFLAGS="$CFLAGS -gdwarf-2"
910     fi
911   fi
913   case $CFLAGS in
914     *-O*) ;;
915     *)
916       # No optimization flag was inferred for this non-GCC compiler.
917       # Try -O.  This is needed for xlc on AIX; see Bug#14258.
918       emacs_save_CFLAGS=$CFLAGS
919       test -z "$CFLAGS" || CFLAGS="$CFLAGS "
920       CFLAGS=${CFLAGS}-O
921       AC_CACHE_CHECK([whether $CC accepts -O],
922         [emacs_cv_prog_cc_o],
923         [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
924            [emacs_cv_prog_cc_o=yes],
925            [emacs_cv_prog_cc_o=no])])
926       if test $emacs_cv_prog_cc_o != yes; then
927         CFLAGS=$emacs_save_CFLAGS
928       fi ;;
929   esac
932 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
933 # ---------------------------------------------------------------------------
934 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
935 # Otherwise, run RUN-IF-NOT-FOUND.
936 AC_DEFUN([gl_GCC_VERSION_IFELSE],
937   [AC_PREPROC_IFELSE(
938     [AC_LANG_PROGRAM(
939       [[
940 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
941 /* ok */
942 #else
943 # error "your version of gcc is older than $1.$2"
944 #endif
945       ]]),
946     ], [$3], [$4])
947   ]
950 AC_ARG_ENABLE([gcc-warnings],
951   [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
952                   [control generation of GCC warnings.  The TYPE 'yes'
953                    means to fail if any warnings are issued; 'warn-only'
954                    means issue warnings without failing (default for
955                    developer builds); 'no' means disable warnings
956                    (default for non-developer builds).])],
957   [case $enableval in
958      yes|no|warn-only) ;;
959      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
960    esac
961    gl_gcc_warnings=$enableval],
962   [# By default, use 'warn-only' if it looks like the invoker of 'configure'
963    # is a developer as opposed to a builder.  This is most likely true
964    # if GCC is recent enough and there is a .git directory or file;
965    # however, if there is also a .tarball-version file it is probably
966    # just a release imported into Git for patch management.
967    gl_gcc_warnings=no
968    if test -e "$srcdir"/.git && test ! -f "$srcdir"/.tarball-version; then
969      gl_GCC_VERSION_IFELSE([5], [3], [gl_gcc_warnings=warn-only])
970    fi])
972 AC_ARG_ENABLE([check-lisp-object-type],
973   [AS_HELP_STRING([--enable-check-lisp-object-type],
974      [Enable compile time checks for the Lisp_Object data type,
975       which can catch some bugs during development.])])
976 if test "$enable_check_lisp_object_type" = yes; then
977   AC_DEFINE([CHECK_LISP_OBJECT_TYPE], 1,
978     [Define to enable compile-time checks for the Lisp_Object data type.])
981 # clang is unduly picky about some things.
982 AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang],
983   [AC_COMPILE_IFELSE(
984      [AC_LANG_PROGRAM([[
985           #ifndef __clang__
986             error "not clang";
987           #endif
988         ]])],
989      [emacs_cv_clang=yes],
990      [emacs_cv_clang=no])])
992 WERROR_CFLAGS=
993 # When compiling with GCC, prefer -isystem to -I when including system
994 # include files, to avoid generating useless diagnostics for the files.
995 AS_IF([test $gl_gcc_warnings = no],
997   isystem='-I'
998   AS_IF([test "$emacs_cv_clang" = yes],
999    [
1000      # Turn off some warnings if supported.
1001      gl_WARN_ADD([-Wno-switch])
1002      gl_WARN_ADD([-Wno-pointer-sign])
1003      gl_WARN_ADD([-Wno-string-plus-int])
1004      gl_WARN_ADD([-Wno-unknown-attributes])
1005    ])
1006  ],[
1007   isystem='-isystem '
1009   # This, $nw, is the list of warnings we disable.
1010   nw=
1012   case $with_x_toolkit in
1013     lucid | athena | motif)
1014        # Old toolkits mishandle 'const'.
1015        nw="$nw -Wwrite-strings"
1016        ;;
1017   esac
1018   AS_IF([test $gl_gcc_warnings = yes],
1019     [WERROR_CFLAGS=-Werror],
1020     [# Use -fanalyzer and related options only if --enable-gcc-warnings,
1021      # as they slow GCC considerably.
1022      nw="$nw -fanalyzer -Wno-analyzer-double-free -Wno-analyzer-malloc-leak"
1023      nw="$nw -Wno-analyzer-null-dereference -Wno-analyzer-use-after-free"
1024      # Use -Wsuggest-attribute=malloc only if --enable-gcc-warnings,
1025      # as it doesn't flag code that is wrong in any way.
1026      nw="$nw -Wsuggest-attribute=malloc"])
1028   nw="$nw -Wcast-align=strict"      # Emacs is tricky with pointers.
1029   nw="$nw -Wduplicated-branches"    # Too many false alarms
1030   nw="$nw -Wformat-overflow=2"      # False alarms due to GCC bug 80776
1031   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
1032   nw="$nw -Woverlength-strings"     # Not a problem these days
1033   nw="$nw -Wvla"                    # Emacs uses <vla.h>.
1034   nw="$nw -Wunused-const-variable=2" # lisp.h declares const objects.
1035   nw="$nw -Winline"                 # OK to ignore 'inline'
1036   nw="$nw -Wstrict-overflow"        # OK to optimize assuming that
1037                                     # signed overflow has undefined behavior
1038   nw="$nw -Wsync-nand"              # irrelevant here, and provokes ObjC warning
1039   nw="$nw -Wunsafe-loop-optimizations" # OK to suppress unsafe optimizations
1040   nw="$nw -Wbad-function-cast"      # These casts are no worse than others.
1042   # Emacs doesn't care about shadowing; see
1043   # <https://lists.gnu.org/r/emacs-diffs/2011-11/msg00265.html>.
1044   nw="$nw -Wshadow"
1046   # Emacs's use of alloca inhibits protecting the stack.
1047   nw="$nw -Wstack-protector"
1049   # Emacs's use of __attribute__ ((cold)) causes false alarms with this option.
1050   nw="$nw -Wsuggest-attribute=cold"
1052   # Emacs's use of partly-const functions such as Fgnutls_available_p
1053   # make this option problematic.
1054   nw="$nw -Wsuggest-attribute=const"
1056   # Emacs's use of partly-pure functions such as CHECK_TYPE make this
1057   # option problematic.
1058   nw="$nw -Wsuggest-attribute=pure"
1060   if test "$emacs_cv_clang" = yes; then
1061     nw="$nw -Wdouble-promotion"
1062   fi
1064   # This causes too much noise in the MinGW build.
1065   if test $opsys = mingw32; then
1066     nw="$nw -Wsuggest-attribute=format"
1067   fi
1069   gl_MANYWARN_ALL_GCC([ws])
1070   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
1071   for w in $ws; do
1072     gl_WARN_ADD([$w])
1073   done
1074   gl_WARN_ADD([-Wredundant-decls])     # Prefer this, as we don't use Bison.
1075   gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
1076   gl_WARN_ADD([-Wno-override-init])    # More trouble than it is worth
1077   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
1078   gl_WARN_ADD([-Wno-type-limits])      # Too many warnings for now
1079   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
1080   gl_WARN_ADD([-Wno-format-nonliteral])
1082   # clang is unduly picky about some things.
1083   if test "$emacs_cv_clang" = yes; then
1084     gl_WARN_ADD([-Wno-missing-braces])
1085     gl_WARN_ADD([-Wno-null-pointer-arithmetic])
1086   fi
1088   # This causes too much noise in the MinGW build
1089   if test $opsys = mingw32; then
1090     gl_WARN_ADD([-Wno-pointer-sign])
1091   fi
1093   AC_DEFINE([GCC_LINT], [1], [Define to 1 if --enable-gcc-warnings.])
1094   AS_IF([test $gl_gcc_warnings = yes],
1095     [AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
1096      AH_VERBATIM([GNULIB_PORTCHECK_FORTIFY_SOURCE],
1097      [/* Enable compile-time and run-time bounds-checking, and some warnings,
1098          without upsetting glibc 2.15+. */
1099       #if (defined GNULIB_PORTCHECK && !defined _FORTIFY_SOURCE \
1100            && defined __OPTIMIZE__ && __OPTIMIZE__)
1101       # define _FORTIFY_SOURCE 2
1102       #endif
1103      ])])
1104  ])
1106 # clang is picky about these regardless of whether
1107 # --enable-gcc-warnings is specified.
1108 if test "$emacs_cv_clang" = yes; then
1109   gl_WARN_ADD([-Wno-initializer-overrides])
1110   gl_WARN_ADD([-Wno-tautological-compare])
1111   gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
1114 # Use a slightly smaller set of warning options for lib/.
1116 nw="$nw -Wunused-macros"
1117 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
1119 AC_SUBST([WERROR_CFLAGS])
1120 AC_SUBST([GNULIB_WARN_CFLAGS])
1122 edit_cflags="
1123   s,///*,/,g
1124   s/^/ /
1125   s/ -I/ $isystem/g
1126   s/^ //
1129 AC_ARG_ENABLE(link-time-optimization,
1130 [AS_HELP_STRING([--enable-link-time-optimization],
1131                 [build with link-time optimization
1132                  (experimental; see INSTALL)])],
1133 if test "${enableval}" != "no"; then
1134    ac_lto_supported=no
1135    if test "$emacs_cv_clang" = yes; then
1136       AC_MSG_CHECKING([whether link-time optimization is supported by clang])
1137       GOLD_PLUGIN=`$CC -print-file-name=LLVMgold.so 2>/dev/null`
1138       if test -x "$GOLD_PLUGIN"; then
1139          LTO="-flto"
1140       fi
1141    elif test x$GCC = xyes; then
1142       AC_MSG_CHECKING([whether link-time optimization is supported by gcc])
1143       CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
1144       if test x$CPUS != x; then
1145          LTO="-flto=$CPUS"
1146       else
1147          LTO="-flto"
1148       fi
1149    else
1150       AC_MSG_ERROR([Link-time optimization is not supported with your compiler.])
1151    fi
1152    if test -z "$LTO"; then
1153       ac_lto_supported=no
1154    else
1155       old_CFLAGS=$CFLAGS
1156       CFLAGS="$CFLAGS $LTO"
1157       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1158          [ac_lto_supported=yes], [ac_lto_supported=no])
1159          CFLAGS="$old_CFLAGS"
1160    fi
1161    AC_MSG_RESULT([$ac_lto_supported])
1162    if test "$ac_lto_supported" = "yes"; then
1163       CFLAGS="$CFLAGS $LTO"
1164       if test "$emacs_cv_clang" = yes; then
1165          AC_MSG_WARN([Please read INSTALL before using link-time optimization with clang])
1166          # WARNING: 'ar --plugin ...' doesn't work without
1167          # command, so plugin name is appended to ARFLAGS.
1168          ARFLAGS="cru --plugin $GOLD_PLUGIN"
1169          RANLIB="$RANLIB --plugin $GOLD_PLUGIN"
1170       else
1171         dnl The following is needed for GCC 4.9.0.  The GCC 4.9.0 release notes
1172         dnl suggest that instead of -ffat-lto-objects we should use gcc-ar and
1173         dnl gcc-ranlib in place of ar and ranlib, but gcc-ar makes /usr/bin/ar
1174         dnl dump core on Fedora 20, so play it safe for now.
1175         gl_COMPILER_OPTION_IF([-ffat-lto-objects],
1176           [CFLAGS="$CFLAGS -ffat-lto-objects"])
1177       fi
1178    fi
1182 dnl Automake replacements.
1183 AC_DEFUN([AM_CONDITIONAL],
1184   [$2 && $1=1 || $1=
1185    AC_SUBST([$1])])
1187 dnl Prefer silent make output.  For verbose output, use
1188 dnl 'configure --disable-silent-rules' or 'make V=1' .
1189 AC_ARG_ENABLE([silent-rules],
1190   [AS_HELP_STRING(
1191      [--disable-silent-rules],
1192      [verbose build output (undo: "make V=0")])])
1193 if test "$enable_silent_rules" = no; then
1194   AM_DEFAULT_VERBOSITY=1
1195 else
1196   AM_DEFAULT_VERBOSITY=0
1198 AC_SUBST([AM_DEFAULT_VERBOSITY])
1199 AC_CONFIG_FILES([src/verbose.mk])
1201 dnl Some other nice autoconf tests.
1202 AC_PROG_INSTALL
1203 dnl These are commented out, since gl_EARLY and/or Autoconf already does them.
1204 dnl AC_PROG_MKDIR_P
1205 dnl if test "x$RANLIB" = x; then
1206 dnl   AC_PROG_RANLIB
1207 dnl fi
1210 dnl Sadly, AC_PROG_LN_S is too restrictive.  It also tests whether links
1211 dnl can be made to directories.  This is not relevant for our usage, and
1212 dnl excludes some cases that work fine for us.  Eg MS Windows or files
1213 dnl hosted on AFS, both examples where simple links work, but links to
1214 dnl directories fail.  We use a cut-down version instead.
1215 dnl AC_PROG_LN_S
1217 AC_CACHE_CHECK([command to symlink files in the same directory], [emacs_cv_ln_s_fileonly],
1218 [rm -f conf$$ conf$$.file
1220 emacs_cv_ln_s_fileonly='cp -p'
1222 dnl On MinGW, ensure we will call the MSYS /bin/ln.exe, not some
1223 dnl random program in the current directory.
1224 if (echo >conf$$.file) 2>/dev/null; then
1225   if test "$opsys" = "mingw32"; then
1226     emacs_cv_ln_s_fileonly=/bin/ln
1227   elif ln -s conf$$.file conf$$ 2>/dev/null; then
1228     emacs_cv_ln_s_fileonly='ln -s'
1229   elif ln conf$$.file conf$$ 2>/dev/null; then
1230     emacs_cv_ln_s_fileonly=ln
1231   fi
1234 rm -f conf$$ conf$$.file])
1235 LN_S_FILEONLY=$emacs_cv_ln_s_fileonly
1237 AC_SUBST(LN_S_FILEONLY)
1240 dnl AC_PROG_LN_S sets LN_S to 'cp -pR' for MinGW, on the premise that 'ln'
1241 dnl doesn't support links to directories, as in "ln file dir".  But that
1242 dnl use is non-portable, and OTOH MinGW wants to use hard links for Emacs
1243 dnl executables at "make install" time.
1244 dnl See https://lists.gnu.org/r/emacs-devel/2013-04/msg00475.html
1245 dnl for more details.
1246 if test "$opsys" = "mingw32"; then
1247   LN_S="/bin/ln"
1250 dnl On some Debian versions, "install-info" prints irritating messages
1251 dnl "This is not dpkg install-info anymore, but GNU install-info"
1252 dnl if called via an absolute file name.
1253 dnl Use the entirely-identical-but-quieter ginstall-info instead if present.
1254 dnl Sadly some people may have an old ginstall-info installed on
1255 dnl non-Debian systems, so we can't use this.
1256 dnl AC_PATH_PROGS(INSTALL_INFO, [ginstall-info install-info], :,
1257 dnl   $PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin)
1259 AC_PATH_PROG(INSTALL_INFO, install-info, :,
1260   $PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin)
1261 dnl Don't use GZIP, which is used by gzip for additional parameters.
1262 AC_PATH_PROG(GZIP_PROG, gzip)
1264 test $with_compress_install != yes && test -n "$GZIP_PROG" && \
1265    GZIP_PROG=" # $GZIP_PROG # (disabled by configure --without-compress-install)"
1267 if test "$with_dumping" = "unexec" && test "$opsys" = "nacl"; then
1268   AC_MSG_ERROR([nacl is not compatible with --with-dumping=unexec])
1271 AC_CACHE_CHECK([for 'find' args to delete a file],
1272   [emacs_cv_find_delete],
1273   [if touch conftest.tmp && find conftest.tmp -delete 2>/dev/null &&
1274       test ! -f conftest.tmp
1275    then emacs_cv_find_delete="-delete"
1276    else emacs_cv_find_delete="-exec rm -f {} ';'"
1277    fi])
1278 FIND_DELETE=$emacs_cv_find_delete
1279 AC_SUBST([FIND_DELETE])
1281 PAXCTL_dumped=
1282 PAXCTL_notdumped=
1283 if test $with_unexec = yes && test $opsys = gnu-linux; then
1284   if test "${SETFATTR+set}" != set; then
1285     AC_CACHE_CHECK([for setfattr],
1286       [emacs_cv_prog_setfattr],
1287       [touch conftest.tmp
1288        if (setfattr -n user.pax.flags conftest.tmp) >/dev/null 2>&1; then
1289          emacs_cv_prog_setfattr=yes
1290        else
1291          emacs_cv_prog_setfattr=no
1292        fi])
1293     if test "$emacs_cv_prog_setfattr" = yes; then
1294       PAXCTL_notdumped='$(SETFATTR) -n user.pax.flags -v er'
1295       SETFATTR=setfattr
1296     else
1297       SETFATTR=
1298     fi
1299   fi
1300   case $opsys,$PAXCTL_notdumped,$emacs_uname_r in
1301     gnu-linux,,* | netbsd,,[0-7].*)
1302       AC_PATH_PROG([PAXCTL], [paxctl], [],
1303         [$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin])
1304       if test -n "$PAXCTL"; then
1305         if test "$opsys" = netbsd; then
1306           PAXCTL_dumped='$(PAXCTL) +a'
1307           PAXCTL_notdumped=$PAXCTL_dumped
1308         else
1309           AC_MSG_CHECKING([whether binaries have a PT_PAX_FLAGS header])
1310           AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
1311             [if $PAXCTL -v conftest$EXEEXT >/dev/null 2>&1; then
1312                AC_MSG_RESULT([yes])
1313              else
1314                AC_MSG_RESULT([no])
1315                PAXCTL=
1316              fi])
1317           if test -n "$PAXCTL"; then
1318             PAXCTL_dumped='$(PAXCTL) -zex'
1319             PAXCTL_notdumped='$(PAXCTL) -r'
1320           fi
1321         fi
1322       fi;;
1323   esac
1325 AC_SUBST([PAXCTL_dumped])
1326 AC_SUBST([PAXCTL_notdumped])
1327 AC_SUBST([SETFATTR])
1329 # Makeinfo on macOS is ancient, check whether there is a more recent
1330 # version installed by Homebrew.
1331 AC_CHECK_PROGS(BREW, [brew])
1332 if test -n "$BREW"; then
1333   AC_PATH_PROG([MAKEINFO], [makeinfo], [],
1334     [`$BREW --prefix texinfo 2>/dev/null`/bin$PATH_SEPARATOR$PATH])
1337 ## Require makeinfo >= 4.13 (last of the 4.x series) to build the manuals.
1338 : ${MAKEINFO:=makeinfo}
1339 case `($MAKEINFO --version) 2>/dev/null` in
1340   *' (GNU texinfo) '4.1[[3-9]]* | \
1341   *' (GNU texinfo) '[[5-9]]* | \
1342   *' (GNU texinfo) '[[1-9][0-9]]* ) ;;
1343   *) MAKEINFO=no;;
1344 esac
1346 ## Makeinfo is unusual.  For a released Emacs, the manuals are
1347 ## pre-built, and not deleted by the normal clean rules.  makeinfo is
1348 ## therefore in the category of "special tools" not normally required, which
1349 ## configure does not have to check for (eg autoconf itself).
1350 ## In a repository checkout on the other hand, the manuals are not included.
1351 ## So makeinfo is a requirement to build from the repository, and configure
1352 ## should test for it as it does for any other build requirement.
1353 ## We use the presence of $srcdir/info/emacs to distinguish a release,
1354 ## with pre-built manuals, from a repository checkout.
1355 if test "$MAKEINFO" = "no"; then
1356   MAKEINFO=makeinfo
1357   if test ! -e "$srcdir/info/emacs" && test ! -e "$srcdir/info/emacs.info"; then
1358     AC_MSG_ERROR( [You do not seem to have makeinfo >= 4.13, and your
1359 source tree does not seem to have pre-built manuals in the 'info' directory.
1360 Please install a suitable version of makeinfo.] )
1361   else
1362     AC_MSG_WARN( [You do not seem to have makeinfo >= 4.13.
1363 You will not be able to rebuild the manuals if you delete them or change
1364 their sources.] )
1365   fi
1367 AC_SUBST([MAKEINFO])
1369 if test $opsys = mingw32; then
1370    DOCMISC_W32=efaq-w32
1371 else
1372    DOCMISC_W32=
1374 AC_SUBST(DOCMISC_W32)
1376 dnl Add our options to ac_link now, after it is set up.
1378 if test x$GCC = xyes; then
1379   test "x$GCC_LINK_TEST_OPTIONS" != x && \
1380     ac_link="$ac_link $GCC_LINK_TEST_OPTIONS"
1381 else
1382   test "x$NON_GCC_LINK_TEST_OPTIONS" != x && \
1383     ac_link="$ac_link $NON_GCC_LINK_TEST_OPTIONS"
1386 dnl On some platforms using GNU ld, linking temacs needs -znocombreloc.
1387 dnl Although this has something to do with dumping, the details are unknown.
1388 dnl If the flag is used but not needed,
1389 dnl Emacs should still work (albeit a bit more slowly),
1390 dnl so use the flag everywhere that it is supported.
1391 dnl When testing whether the flag works, treat GCC specially
1392 dnl since it just gives a non-fatal 'unrecognized option'
1393 dnl if not built to support GNU ld.
1394 if test "$GCC" = yes; then
1395   LDFLAGS_NOCOMBRELOC="-Wl,-znocombreloc"
1396 else
1397   LDFLAGS_NOCOMBRELOC="-znocombreloc"
1400 AC_CACHE_CHECK([for -znocombreloc], [emacs_cv_znocombreloc],
1401   [if test $with_unexec = no; then
1402      emacs_cv_znocombreloc='not needed'
1403    else
1404      save_LDFLAGS=$LDFLAGS
1405      LDFLAGS="$LDFLAGS $LDFLAGS_NOCOMBRELOC"
1406      AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
1407        [emacs_cv_znocombreloc=yes], [emacs_cv_znocombreloc=no])
1408      LDFLAGS=$save_LDFLAGS
1409    fi])
1411 case $emacs_cv_znocombreloc in
1412   no*)
1413     LDFLAGS_NOCOMBRELOC= ;;
1414 esac
1417 AC_CACHE_CHECK([whether addresses are sanitized],
1418   [emacs_cv_sanitize_address],
1419   [AC_COMPILE_IFELSE(
1420      [AC_LANG_PROGRAM(
1421         [[#ifndef __has_feature
1422           #define __has_feature(f) 0
1423           #endif
1424           #if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
1425           #else
1426            error "Addresses are not sanitized.";
1427           #endif
1428         ]])],
1429      [emacs_cv_sanitize_address=yes],
1430      [emacs_cv_sanitize_address=no])])
1432 if test $with_unexec = yes; then
1433   AC_DEFINE([HAVE_UNEXEC], 1, [Define if Emacs supports unexec.])
1434   if test "$emacs_cv_sanitize_address" = yes; then
1435     AC_MSG_WARN([[Addresses are sanitized; suggest --without-unexec]])
1436   fi
1440 UNEXEC_OBJ=
1441 test $with_unexec = yes &&
1442 case "$opsys" in
1443   # MSDOS uses unexcoff.o
1444   aix4-2)
1445    UNEXEC_OBJ=unexaix.o
1446    ;;
1447   cygwin)
1448    UNEXEC_OBJ=unexcw.o
1449    ;;
1450   darwin)
1451    UNEXEC_OBJ=unexmacosx.o
1452    ;;
1453   hpux10-20 | hpux11)
1454    UNEXEC_OBJ=unexhp9k800.o
1455    ;;
1456   mingw32)
1457    UNEXEC_OBJ=unexw32.o
1458    ;;
1459   solaris)
1460    # Use the Solaris dldump() function, called from unexsol.c, to dump
1461    # emacs, instead of the generic ELF dump code found in unexelf.c.
1462    # The resulting binary has a complete symbol table, and is better
1463    # for debugging and other observability tools (debuggers, pstack, etc).
1464    UNEXEC_OBJ=unexsol.o
1465    ;;
1466   *)
1467    UNEXEC_OBJ=unexelf.o
1468    ;;
1469 esac
1470 AC_SUBST(UNEXEC_OBJ)
1472 LD_SWITCH_SYSTEM=
1473 test "$with_unexec" = no || case "$opsys" in
1474   freebsd|dragonfly)
1475    ## Let 'ld' find image libs and similar things in /usr/local/lib.
1476    ## The system compiler, GCC, has apparently been modified to not
1477    ## look there, contrary to what a stock GCC would do.
1478 ### It's not our place to do this.  See bug#10313#17.
1479 ###   LD_SWITCH_SYSTEM=-L/usr/local/lib
1480       :
1481    ;;
1483   gnu-linux)
1484    ## cpp test was "ifdef __mips__", but presumably this is equivalent...
1485    case $host_cpu in mips*) LD_SWITCH_SYSTEM="-G 0";; esac
1486    ;;
1488   netbsd)
1489 ### It's not our place to do this.  See bug#10313#17.
1490 ###   LD_SWITCH_SYSTEM="-Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib"
1491       :
1492    ;;
1494   openbsd)
1495    ## Han Boetes <han@boetes.org> says this is necessary,
1496    ## otherwise Emacs dumps core on elf systems.
1497    LD_SWITCH_SYSTEM="-Z"
1498    ;;
1499 esac
1500 AC_SUBST(LD_SWITCH_SYSTEM)
1502 ac_link="$ac_link $LD_SWITCH_SYSTEM"
1504 ## This setting of LD_SWITCH_SYSTEM references LD_SWITCH_X_SITE_RPATH,
1505 ## which has not been defined yet.  When this was handled with cpp,
1506 ## it was expanded to null when configure sourced the s/*.h file.
1507 ## Thus LD_SWITCH_SYSTEM had different values in configure and the Makefiles.
1508 ## FIXME it would be cleaner to put this in LD_SWITCH_SYSTEM_TEMACS
1509 ## (or somesuch), but because it is supposed to go at the _front_
1510 ## of LD_SWITCH_SYSTEM, we cannot do that in exactly the same way.
1511 ## Compare with the gnu-linux case below, which added to the end
1512 ## of LD_SWITCH_SYSTEM, and so can instead go at the front of
1513 ## LD_SWITCH_SYSTEM_TEMACS.
1514 case "$opsys" in
1515   netbsd|openbsd)
1516    LD_SWITCH_SYSTEM="\$(LD_SWITCH_X_SITE_RPATH) $LD_SWITCH_SYSTEM" ;;
1517 esac
1519 C_SWITCH_MACHINE=
1521 test $with_unexec = yes &&
1522 case $canonical in
1523  alpha*)
1524     ## With ELF, make sure that all common symbols get allocated to in the
1525     ## data section.  Otherwise, the dump of temacs may miss variables in
1526     ## the shared library that have been initialized.  For example, with
1527     ## GNU libc, __malloc_initialized would normally be resolved to the
1528     ## shared library's .bss section, which is fatal.
1529     if test "x$GCC" = "xyes"; then
1530       C_SWITCH_MACHINE="-fno-common"
1531     else
1532       AC_MSG_ERROR([Non-GCC compilers are not supported.])
1533     fi
1534   ;;
1535 esac
1536 AC_SUBST(C_SWITCH_MACHINE)
1538 C_SWITCH_SYSTEM=
1539 ## Some programs in src produce warnings saying certain subprograms
1540 ## are too complex and need a MAXMEM value greater than 2000 for
1541 ## additional optimization.  --nils@exp-math.uni-essen.de
1542 test "$opsys" = "aix4.2" && test "x$GCC" != "xyes" && \
1543   C_SWITCH_SYSTEM="-ma -qmaxmem=4000"
1544 if test "$opsys" = "mingw32"; then
1545   case "$canonical" in
1546     x86_64-*-mingw*) C_SWITCH_SYSTEM="-mtune=generic" ;;
1547     *) C_SWITCH_SYSTEM="-mtune=pentium4" ;;
1548   esac
1550 ## gnu-linux might need -D_BSD_SOURCE on old libc5 systems.
1551 ## It is redundant in glibc2, since we define _GNU_SOURCE.
1552 AC_SUBST(C_SWITCH_SYSTEM)
1555 LIBS_SYSTEM=
1556 case "$opsys" in
1557   ## IBM's X11R5 uses -lIM and -liconv in AIX 3.2.2.
1558   aix4-2) LIBS_SYSTEM="-lrts -lIM -liconv" ;;
1560   freebsd|dragonfly) LIBS_SYSTEM="-lutil" ;;
1562   hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
1564   qnxnto) LIBS_SYSTEM="-lsocket" ;;
1566   solaris) LIBS_SYSTEM="-lsocket -lnsl" ;;
1568   ## Motif needs -lgen.
1569   unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;;
1570 esac
1572 AC_SUBST(LIBS_SYSTEM)
1574 ### Make sure subsequent tests use flags consistent with the build flags.
1576 if test x"${OVERRIDE_CPPFLAGS}" != x; then
1577   CPPFLAGS="${OVERRIDE_CPPFLAGS}"
1578 else
1579   CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
1582 # Suppress obsolescent Autoconf test for size_t; Emacs assumes C99 or better.
1583 AC_DEFUN([AC_TYPE_SIZE_T])
1584 # Likewise for obsolescent test for uid_t, gid_t; Emacs assumes them.
1585 AC_DEFUN([AC_TYPE_UID_T])
1587 # sqrt and other floating-point functions such as fmod and frexp
1588 # are found in -lm on many systems.
1589 OLD_LIBS=$LIBS
1590 AC_SEARCH_LIBS([sqrt], [m])
1591 if test "X$LIBS" = "X$OLD_LIBS"; then
1592   LIB_MATH=
1593 else
1594   LIB_MATH=$ac_cv_search_sqrt
1596 LIBS=$OLD_LIBS
1598 dnl Current possibilities handled by sed (aix4-2 -> aix,
1599 dnl gnu-linux -> gnu/linux, etc.):
1600 dnl gnu, gnu/linux, gnu/kfreebsd, aix, cygwin, darwin, hpux.
1601 dnl And special cases: berkeley-unix, usg-unix-v, ms-dos, windows-nt.
1602 SYSTEM_TYPE=`echo $opsys | sed -e 's/[[0-9]].*//' -e 's|-|/|'`
1604 case $opsys in
1605   cygwin )
1606     LIB_MATH=
1607     ;;
1608   darwin )
1609     ## Adding -lm confuses the dynamic linker, so omit it.
1610     LIB_MATH=
1611     ;;
1612   freebsd | dragonfly )
1613     SYSTEM_TYPE=berkeley-unix
1614     ;;
1615   gnu-linux | gnu-kfreebsd )
1616     ;;
1617   hpux10-20 | hpux11 )
1618     ;;
1619   mingw32 )
1620     LIB_MATH=
1621     SYSTEM_TYPE=windows-nt
1622     ;;
1623   netbsd | openbsd )
1624     SYSTEM_TYPE=berkeley-unix
1625     ;;
1627   solaris | unixware )
1628     SYSTEM_TYPE=usg-unix-v
1629     ;;
1631 esac
1633 AC_SUBST(LIB_MATH)
1634 AC_DEFINE_UNQUOTED(SYSTEM_TYPE, "$SYSTEM_TYPE",
1635   [The type of system you are compiling for; sets 'system-type'.])
1636 AC_SUBST([SYSTEM_TYPE])
1639 pre_PKG_CONFIG_CFLAGS=$CFLAGS
1640 pre_PKG_CONFIG_LIBS=$LIBS
1642 PKG_PROG_PKG_CONFIG(0.9.0)
1644 dnl EMACS_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4)
1645 dnl acts like PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4,
1646 dnl HAVE_GSTUFF=yes, HAVE_GSTUFF=no) -- see pkg-config man page --
1647 dnl except that it postprocesses CFLAGS as needed for --enable-gcc-warnings.
1648 dnl EMACS_CHECK_MODULES accepts optional 3rd and 4th arguments that
1649 dnl can take the place of the default HAVE_GSTUFF=yes and HAVE_GSTUFF=no
1650 dnl actions.
1651 AC_DEFUN([EMACS_CHECK_MODULES],
1652   [PKG_CHECK_MODULES([$1], [$2],
1653      [$1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"`
1654       m4_default([$3], [HAVE_$1=yes])],
1655      [m4_default([$4], [HAVE_$1=no])])])
1657 HAVE_SOUND=no
1658 if test "${with_sound}" != "no"; then
1659   # Sound support for GNU/Linux, the free BSDs, MinGW, and Cygwin.
1660   AC_CHECK_HEADERS([machine/soundcard.h sys/soundcard.h soundcard.h mmsystem.h],
1661     have_sound_header=yes, [], [
1662     #ifdef __MINGW32__
1663     #define WIN32_LEAN_AND_MEAN
1664     #include <windows.h>
1665     #endif
1666     ])
1667   test "${with_sound}" = "oss" && test "${have_sound_header}" != "yes" && \
1668     AC_MSG_ERROR([OSS sound support requested but not found.])
1670   if test "${with_sound}" = "bsd-ossaudio" || test "${with_sound}" = "yes"; then
1671     # Emulation library used on NetBSD.
1672     AC_CHECK_LIB(ossaudio, _oss_ioctl, LIBSOUND=-lossaudio, LIBSOUND=)
1673     test "${with_sound}" = "bsd-ossaudio" && test -z "$LIBSOUND" && \
1674       AC_MSG_ERROR([bsd-ossaudio sound support requested but not found.])
1675     dnl FIXME?  If we did find ossaudio, should we set with_sound=bsd-ossaudio?
1676     dnl Traditionally, we go on to check for alsa too.  Does that make sense?
1677   fi
1678   AC_SUBST(LIBSOUND)
1680   if test "${with_sound}" = "alsa" || test "${with_sound}" = "yes"; then
1681     ALSA_REQUIRED=1.0.0
1682     ALSA_MODULES="alsa >= $ALSA_REQUIRED"
1683     EMACS_CHECK_MODULES([ALSA], [$ALSA_MODULES])
1684     if test $HAVE_ALSA = yes; then
1685       LIBSOUND="$LIBSOUND $ALSA_LIBS"
1686       CFLAGS_SOUND="$CFLAGS_SOUND $ALSA_CFLAGS"
1687       AC_DEFINE(HAVE_ALSA, 1, [Define to 1 if ALSA is available.])
1688     elif test "${with_sound}" = "alsa"; then
1689       AC_MSG_ERROR([ALSA sound support requested but not found.])
1690     fi
1691   fi                            dnl with_sound = alsa|yes
1693   dnl Define HAVE_SOUND if we have sound support.  We know it works and
1694   dnl compiles only on the specified platforms.  For others, it
1695   dnl probably doesn't make sense to try.
1696   dnl FIXME So surely we should bypass this whole section if not using
1697   dnl one of these platforms?
1698   if test x$have_sound_header = xyes || test $HAVE_ALSA = yes; then
1699      case "$opsys" in
1700        dnl defined __FreeBSD__ || defined __NetBSD__ || defined __linux__
1701        dnl Adjust the --with-sound help text if you change this.
1702        gnu-linux|freebsd|netbsd|mingw32|cygwin)
1703          AC_DEFINE(HAVE_SOUND, 1, [Define to 1 if you have sound support.])
1704          HAVE_SOUND=yes
1705          ;;
1706      esac
1707   fi
1709   AC_SUBST(CFLAGS_SOUND)
1712 dnl checks for header files
1713 AC_CHECK_HEADERS_ONCE(
1714   linux/fs.h
1715   malloc.h
1716   sys/systeminfo.h
1717   sys/sysinfo.h
1718   coff.h pty.h
1719   sys/resource.h
1720   sys/utsname.h pwd.h utmp.h util.h
1721   sanitizer/lsan_interface.h)
1723 AC_CACHE_CHECK([for ADDR_NO_RANDOMIZE],
1724   [emacs_cv_personality_addr_no_randomize],
1725   [AC_COMPILE_IFELSE(
1726      [AC_LANG_PROGRAM([[#include <sys/personality.h>]],
1727                       [[personality (personality (0xffffffff)
1728                                      | ADDR_NO_RANDOMIZE)]])],
1729      [emacs_cv_personality_addr_no_randomize=yes],
1730      [emacs_cv_personality_addr_no_randomize=no])])
1731 if test $emacs_cv_personality_addr_no_randomize = yes; then
1732   AC_DEFINE([HAVE_PERSONALITY_ADDR_NO_RANDOMIZE], [1],
1733             [Define to 1 if personality flag ADDR_NO_RANDOMIZE exists.])
1736 # Note that Solaris has sys/sysinfo.h which defines struct
1737 # sysinfo as well.  To make sure that we're using GNU/Linux
1738 # sysinfo, we explicitly set one of its fields.
1739 if test "$ac_cv_header_sys_sysinfo_h" = yes; then
1740   AC_CACHE_CHECK([if Linux sysinfo may be used], [emacs_cv_linux_sysinfo],
1741   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/sysinfo.h>]],
1742                                      [[struct sysinfo si;
1743                                        si.totalram = 0;
1744                                        sysinfo (&si)]])],
1745     emacs_cv_linux_sysinfo=yes, emacs_cv_linux_sysinfo=no)])
1747   if test $emacs_cv_linux_sysinfo = yes; then
1748     AC_DEFINE([HAVE_LINUX_SYSINFO], 1, [Define to 1 if you have Linux sysinfo function.])
1749     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/sysinfo.h>]],
1750                                        [[struct sysinfo si; return si.mem_unit]])],
1751       AC_DEFINE(LINUX_SYSINFO_UNIT, 1,
1752                 [Define to 1 if Linux sysinfo sizes are in multiples of mem_unit bytes.]))
1753   fi
1756 dnl On Solaris 8 there's a compilation warning for term.h because
1757 dnl it doesn't define 'bool'.
1758 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <term.h>]],[[]])],
1759   AC_DEFINE(HAVE_TERM_H, 1, [Define to 1 if you have the <term.h> header file.]))
1760 AC_HEADER_SYS_WAIT
1762 AC_CHECK_HEADERS_ONCE(sys/socket.h)
1763 AC_CHECK_HEADERS(net/if.h, , , [AC_INCLUDES_DEFAULT
1764 #if HAVE_SYS_SOCKET_H
1765 #include <sys/socket.h>
1766 #endif])
1767 AC_CHECK_HEADERS(ifaddrs.h, , , [AC_INCLUDES_DEFAULT
1768 #if HAVE_SYS_SOCKET_H
1769 #include <sys/socket.h>
1770 #endif])
1771 AC_CHECK_HEADERS(net/if_dl.h, , , [AC_INCLUDES_DEFAULT
1772 #if HAVE_SYS_SOCKET_H
1773 #include <sys/socket.h>
1774 #endif])
1776 dnl checks for structure members
1777 AC_CHECK_MEMBERS([struct ifreq.ifr_flags, struct ifreq.ifr_hwaddr,
1778                   struct ifreq.ifr_netmask, struct ifreq.ifr_broadaddr,
1779                   struct ifreq.ifr_addr,
1780                   struct ifreq.ifr_addr.sa_len], , ,
1781                  [AC_INCLUDES_DEFAULT
1782 #if HAVE_SYS_SOCKET_H
1783 #include <sys/socket.h>
1784 #endif
1785 #if HAVE_NET_IF_H
1786 #include <net/if.h>
1787 #endif])
1789 dnl Check for endianness.
1790 dnl AC_C_BIGENDIAN is done by gnulib.
1792 dnl check for Make feature
1794 AUTO_DEPEND=no
1795 AUTODEPEND_PARENTS='lib src'
1796 dnl check if we have GCC and autodepend is on.
1797 if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
1798    AC_CACHE_CHECK([whether gcc understands -MMD -MF], [emacs_cv_autodepend],
1799    [SAVE_CFLAGS="$CFLAGS"
1800    CFLAGS="$CFLAGS -MMD -MF deps.d -MP"
1801    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1802      [emacs_cv_autodepend=yes], [emacs_cv_autodepend=no])
1803    CFLAGS="$SAVE_CFLAGS"
1804    test -f deps.d || emacs_cv_autodepend=no
1805    rm -rf deps.d])
1806    if test $emacs_cv_autodepend = yes; then
1807       AUTO_DEPEND=yes
1808    fi
1810 AC_SUBST(AUTO_DEPEND)
1812 #### Choose a window system.
1814 ## We leave window_system equal to none if
1815 ## we end up building without one.  Any new window system should
1816 ## set window_system to an appropriate value and add objects to
1817 ## window-system-specific substs.
1819 window_system=none
1820 AC_PATH_X
1821 if test "$no_x" != yes; then
1822   window_system=x11
1825 LD_SWITCH_X_SITE_RPATH=
1826 if test "${x_libraries}" != NONE; then
1827   if test -n "${x_libraries}"; then
1828     LD_SWITCH_X_SITE=-L`AS_ECHO(["$x_libraries"]) | sed -e 's/:/ -L/g'`
1829     LD_SWITCH_X_SITE_RPATH=-Wl,-rpath,`
1830       AS_ECHO(["$x_libraries"]) | sed -e 's/:/ -Wl,-rpath,/g'
1831     `
1832   fi
1833   x_default_search_path=""
1834   x_search_path=${x_libraries}
1835   if test -z "${x_search_path}"; then
1836     x_search_path=/usr/lib
1837   fi
1838   for x_library in `AS_ECHO(["$x_search_path:"]) | \
1839                     sed -e "s/:/ /g" -e p -e "s:/lib[[^ /]]* :/share :g"`; do
1840     x_search_path="\
1841 ${x_library}/X11/%L/%T/%N%C%S:\
1842 ${x_library}/X11/%l/%T/%N%C%S:\
1843 ${x_library}/X11/%T/%N%C%S:\
1844 ${x_library}/X11/%L/%T/%N%S:\
1845 ${x_library}/X11/%l/%T/%N%S:\
1846 ${x_library}/X11/%T/%N%S"
1847     if test x"${x_default_search_path}" = x; then
1848       x_default_search_path=${x_search_path}
1849     else
1850       x_default_search_path="${x_search_path}:${x_default_search_path}"
1851     fi
1852   done
1854 AC_SUBST(LD_SWITCH_X_SITE_RPATH)
1856 if test "${x_includes}" != NONE && test -n "${x_includes}"; then
1857   C_SWITCH_X_SITE=$isystem`AS_ECHO(["$x_includes"]) | sed -e "s/:/ $isystem/g"`
1860 if test x"${x_includes}" = x; then
1861   bitmapdir=/usr/include/X11/bitmaps
1862 else
1863   # accumulate include directories that have X11 bitmap subdirectories
1864   bmd_acc=
1865   for bmd in `AS_ECHO(["$x_includes"]) | sed -e 's/:/ /g'`; do
1866     if test -d "${bmd}/X11/bitmaps"; then
1867       bmd_acc="${bmd_acc}:${bmd}/X11/bitmaps"
1868     fi
1869     if test -d "${bmd}/bitmaps"; then
1870       bmd_acc="${bmd_acc}:${bmd}/bitmaps"
1871     fi
1872   done
1873   bitmapdir=${bmd_acc#:}
1876 NATIVE_IMAGE_API=no
1878 test "${with_ns}" = maybe && test "${opsys}" != darwin && with_ns=no
1879 HAVE_NS=no
1880 NS_GNUSTEP_CONFIG=no
1881 NS_IMPL_COCOA=no
1882 NS_IMPL_GNUSTEP=no
1883 tmp_CPPFLAGS="$CPPFLAGS"
1884 tmp_CFLAGS="$CFLAGS"
1885 CPPFLAGS="$CPPFLAGS -x objective-c"
1886 CFLAGS="$CFLAGS -x objective-c"
1887 GNU_OBJC_CFLAGS=""
1888 LIBS_GNUSTEP=
1889 if test "${with_ns}" != no; then
1890   # macfont.o requires macuvs.h which is absent after 'make extraclean',
1891   # so avoid NS_IMPL_COCOA if macuvs.h is absent.
1892   # Even a headless Emacs can build macuvs.h, so this should let you bootstrap.
1893   if test "${opsys}" = darwin && test -f "$srcdir/src/macuvs.h"; then
1894      lispdirrel=Contents/Resources/lisp
1895      NS_IMPL_COCOA=yes
1896      ns_appdir=`pwd`/nextstep/Emacs.app
1897      ns_appbindir=${ns_appdir}/Contents/MacOS
1898      ns_appresdir=${ns_appdir}/Contents/Resources
1899      ns_appsrc=Cocoa/Emacs.base
1900      ns_fontfile=macfont.o
1901   elif flags=$( (gnustep-config --objc-flags) 2>/dev/null); then
1902      NS_IMPL_GNUSTEP=yes
1903      NS_GNUSTEP_CONFIG=yes
1904      GNU_OBJC_CFLAGS="$flags"
1905      LIBS_GNUSTEP=$(gnustep-config --gui-libs) || exit
1906   elif test -f $GNUSTEP_CONFIG_FILE; then
1907      NS_IMPL_GNUSTEP=yes
1908      dnl FIXME sourcing this several times in subshells seems inefficient.
1909      GNUSTEP_SYSTEM_HEADERS=$(
1910        . $GNUSTEP_CONFIG_FILE
1911        AS_ECHO(["$GNUSTEP_SYSTEM_HEADERS"])
1912      )
1913      GNUSTEP_SYSTEM_LIBRARIES=$(
1914        . $GNUSTEP_CONFIG_FILE
1915        AS_ECHO(["$GNUSTEP_SYSTEM_LIBRARIES"])
1916      )
1917      dnl I seemed to need these as well with GNUstep-startup 0.25.
1918      GNUSTEP_LOCAL_HEADERS=$(
1919        . $GNUSTEP_CONFIG_FILE
1920        AS_ECHO(["$GNUSTEP_LOCAL_HEADERS"])
1921      )
1922      GNUSTEP_LOCAL_LIBRARIES=$(
1923        . $GNUSTEP_CONFIG_FILE
1924        AS_ECHO(["$GNUSTEP_LOCAL_LIBRARIES"])
1925      )
1926      test "x${GNUSTEP_LOCAL_HEADERS}" != "x" && \
1927        GNUSTEP_LOCAL_HEADERS="-I${GNUSTEP_LOCAL_HEADERS}"
1928      test "x${GNUSTEP_LOCAL_LIBRARIES}" != "x" && \
1929        GNUSTEP_LOCAL_LIBRARIES="-L${GNUSTEP_LOCAL_LIBRARIES}"
1930      CPPFLAGS="$CPPFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
1931      CFLAGS="$CFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
1932      LDFLAGS="$LDFLAGS -L${GNUSTEP_SYSTEM_LIBRARIES} ${GNUSTEP_LOCAL_LIBRARIES}"
1933      LIBS_GNUSTEP="-lgnustep-gui -lgnustep-base -lobjc -lpthread"
1934      dnl GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS to 0 or 1.
1935      dnl If they had chosen to either define it or not, we could have
1936      dnl just used AC_CHECK_DECL here.
1937      AC_CACHE_CHECK(if GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS,
1938        emacs_cv_objc_exceptions,
1939 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <GNUstepBase/GSConfig.h>]],
1940 [[#if defined BASE_NATIVE_OBJC_EXCEPTIONS && BASE_NATIVE_OBJC_EXCEPTIONS > 0
1942 #else
1943 fail;
1944 #endif]])], emacs_cv_objc_exceptions=yes, emacs_cv_objc_exceptions=no ) )
1945      if test $emacs_cv_objc_exceptions = yes; then
1946        dnl _NATIVE_OBJC_EXCEPTIONS is used by the GNUstep headers.
1947        AC_DEFINE(_NATIVE_OBJC_EXCEPTIONS, 1,
1948          [Define if GNUstep uses ObjC exceptions.])
1949        GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -fobjc-exceptions"
1950      fi
1951   fi
1952   if test $NS_IMPL_GNUSTEP = yes; then
1953      ns_appdir=`pwd`/nextstep/Emacs.app
1954      ns_appbindir=${ns_appdir}
1955      ns_appresdir=${ns_appdir}/Resources
1956      ns_appsrc=GNUstep/Emacs.base
1957      ns_fontfile=nsfont.o
1958   fi
1960   dnl This is only used while we test the NS headers, it gets reset below.
1961   CPPFLAGS="$CPPFLAGS $GNU_OBJC_CFLAGS"
1962   CFLAGS="$CFLAGS $GNU_OBJC_CFLAGS"
1964   AC_CHECK_HEADER([AppKit/AppKit.h], [HAVE_NS=yes],
1965                   [AC_MSG_ERROR([The include files (AppKit/AppKit.h etc) that
1966 are required for a Nextstep build are missing or cannot be compiled.
1967 Either fix this, or re-configure with the option '--without-ns'.])])
1969   macfont_file=""
1970   if test "${NS_IMPL_COCOA}" = "yes"; then
1971     AC_MSG_CHECKING([for Mac OS X 10.6 or newer])
1972     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>],
1973                                      [
1974 #ifdef MAC_OS_X_VERSION_MAX_ALLOWED
1975 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
1976  ; /* OK */
1977 #else
1978  error "Mac OS X 10.6 or newer required";
1979 #endif
1980 #endif
1981                     ])],
1982                     ns_osx_have_106=yes,
1983                     ns_osx_have_106=no)
1984     AC_MSG_RESULT([$ns_osx_have_106])
1986     if test $ns_osx_have_106 = no; then
1987        AC_MSG_ERROR([Mac OS X 10.6 or newer is required]);
1988     fi
1989   fi
1991   if test "${with_native_image_api}" = yes; then
1992      AC_DEFINE(HAVE_NATIVE_IMAGE_API, 1, [Define to use native OS APIs for images.])
1993      NATIVE_IMAGE_API="yes (ns)"
1994   fi
1997 AC_SUBST(LIBS_GNUSTEP)
1999 INSTALL_ARCH_INDEP_EXTRA=install-etc
2000 ns_self_contained=no
2001 NS_OBJ=
2002 NS_OBJC_OBJ=
2003 if test "${HAVE_NS}" = yes; then
2004   if test "$with_toolkit_scroll_bars" = "no"; then
2005     AC_MSG_WARN([Non-toolkit scroll bars are not implemented for Nextstep.])
2006   fi
2008   window_system=nextstep
2009   # set up packaging dirs
2010   if test "${EN_NS_SELF_CONTAINED}" = yes; then
2011      ns_self_contained=yes
2012      prefix=${ns_appresdir}
2013      exec_prefix=${ns_appbindir}
2014      dnl This one isn't really used, only archlibdir is.
2015      libexecdir="\${ns_appbindir}/libexec"
2016      archlibdir="\${ns_appbindir}/libexec"
2017      etcdocdir="\${ns_appresdir}/etc"
2018      etcdir="\${ns_appresdir}/etc"
2019      dnl FIXME maybe set datarootdir instead.
2020      dnl That would also get applications, icons, man.
2021      infodir="\${ns_appresdir}/info"
2022      mandir="\${ns_appresdir}/man"
2023      lispdir="\${ns_appresdir}/lisp"
2024      test "$locallisppathset" = no && locallisppath=""
2025      INSTALL_ARCH_INDEP_EXTRA=
2026   fi
2028   NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o $ns_fontfile"
2030 CFLAGS="$tmp_CFLAGS"
2031 CPPFLAGS="$tmp_CPPFLAGS"
2032 AC_SUBST(INSTALL_ARCH_INDEP_EXTRA)
2033 AC_SUBST(ns_self_contained)
2034 AC_SUBST(NS_OBJ)
2035 AC_SUBST(NS_OBJC_OBJ)
2037 if test "${HAVE_NS}" = yes; then
2038   AC_CACHE_CHECK(
2039     [if the Objective C compiler supports instancetype],
2040     [emacs_cv_objc_instancetype],
2041     [AC_LANG_PUSH([Objective C])
2042      AC_COMPILE_IFELSE(
2043        [AC_LANG_SOURCE([[@interface Test
2044                           + (instancetype)test;
2045                           @end]])],
2046        emacs_cv_objc_instancetype=yes,
2047        emacs_cv_objc_instancetype=no)
2048      AC_LANG_POP([Objective C])])
2050   if test x$emacs_cv_objc_instancetype = xyes ; then
2051     AC_DEFINE(NATIVE_OBJC_INSTANCETYPE, 1,
2052               [Define if ObjC compiler supports instancetype natively.])
2053   fi
2055   AC_CACHE_CHECK(
2056     [if the Objective C compiler defaults to C99],
2057     [emacs_cv_objc_c99],
2058     [AC_LANG_PUSH([Objective C])
2059      AC_COMPILE_IFELSE(
2060        [AC_LANG_PROGRAM([], [[for (int i = 0;;);]])],
2061        emacs_cv_objc_c99=yes,
2062        emacs_cv_objc_c99=no)
2063      AC_LANG_POP([Objective C])])
2065    if test x$emacs_cv_objc_c99 = xno ; then
2066      GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -std=c99"
2067    fi
2070 HAVE_W32=no
2071 W32_OBJ=
2072 W32_LIBS=
2073 EMACSRES=
2074 CLIENTRES=
2075 CLIENTW=
2076 W32_RES_LINK=
2077 EMACS_MANIFEST=
2078 if test "${with_w32}" != no; then
2079   case "${opsys}" in
2080     cygwin)
2081       AC_CHECK_HEADER([windows.h], [HAVE_W32=yes],
2082              [AC_MSG_ERROR(['--with-w32' was specified, but windows.h
2083                    cannot be found.])])
2084     ;;
2085     mingw32)
2086     ## Using --with-w32 with MinGW is a no-op, but we allow it.
2087     ;;
2088     *)
2089       AC_MSG_ERROR([Using w32 with an autotools build is only supported for Cygwin and MinGW32.])
2090     ;;
2091   esac
2094 if test "${opsys}" = "mingw32"; then
2095   AC_CACHE_CHECK([whether Windows API headers are recent enough], [emacs_cv_w32api],
2096   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2097      #include <windows.h>
2098      #include <usp10.h>]],
2099    [[PIMAGE_NT_HEADERS pHeader;
2100      PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader)]])],
2101    [emacs_cv_w32api=yes], [emacs_cv_w32api=no])])
2102   if test "${emacs_cv_w32api}" = "no"; then
2103     AC_MSG_ERROR([the Windows API headers are too old to support this build.])
2104   fi
2105   HAVE_W32=${emacs_cv_w32api}
2108 FIRSTFILE_OBJ=
2109 NTDIR=
2110 LIBS_ECLIENT=
2111 LIB_WSOCK32=
2112 NTLIB=
2113 CM_OBJ="cm.o"
2114 XARGS_LIMIT=
2115 if test "${HAVE_W32}" = "yes"; then
2116   AC_DEFINE(HAVE_NTGUI, 1, [Define to use native MS Windows GUI.])
2117   if test "$with_toolkit_scroll_bars" = "no"; then
2118     AC_MSG_ERROR([Non-toolkit scroll bars are not implemented for w32 build.])
2119   fi
2120   AC_CHECK_TOOL(WINDRES, [windres],
2121                 [AC_MSG_ERROR([No resource compiler found.])])
2122   W32_OBJ="w32fns.o w32menu.o w32reg.o w32font.o w32term.o"
2123   W32_OBJ="$W32_OBJ w32xfns.o w32select.o w32uniscribe.o w32cygwinx.o"
2124   EMACSRES="emacs.res"
2125   case "$canonical" in
2126     x86_64-*-*) EMACS_MANIFEST="emacs-x64.manifest" ;;
2127     *) EMACS_MANIFEST="emacs-x86.manifest" ;;
2128   esac
2129   dnl Construct something of the form "24,4,0,0" with 4 components.
2130   comma_version=`echo "${PACKAGE_VERSION}.0.0" | sed -e 's/\./,/g' -e 's/^\([[^,]]*,[[^,]]*,[[^,]]*,[[^,]]*\).*/\1/'`
2132   comma_space_version=`echo "$comma_version" | sed 's/,/, /g'`
2133   AC_SUBST(comma_version)
2134   AC_SUBST(comma_space_version)
2135   AC_CONFIG_FILES([nt/emacs.rc nt/emacsclient.rc])
2136   if test "${opsys}" = "cygwin"; then
2137     W32_LIBS="$W32_LIBS -lkernel32 -luser32 -lusp10 -lgdi32"
2138     W32_LIBS="$W32_LIBS -lole32 -lcomdlg32 -lcomctl32 -lwinspool"
2139     # Tell the linker that emacs.res is an object (which we compile from
2140     # the rc file), not a linker script.
2141     W32_RES_LINK="-Wl,emacs.res"
2142   else
2143     W32_OBJ="$W32_OBJ w32.o w32console.o w32heap.o w32inevt.o w32proc.o"
2144     dnl FIXME: This should probably be supported for Cygwin/w32 as
2145     dnl well, but the Cygwin build needs to link against -lgdiplus
2146     if test "${with_native_image_api}" = yes; then
2147       AC_DEFINE(HAVE_NATIVE_IMAGE_API, 1, [Define to use native OS APIs for images.])
2148       NATIVE_IMAGE_API="yes (w32)"
2149       W32_OBJ="$W32_OBJ w32image.o"
2150     fi
2151     W32_LIBS="$W32_LIBS -lwinmm -lusp10 -lgdi32 -lcomdlg32"
2152     W32_LIBS="$W32_LIBS -lmpr -lwinspool -lole32 -lcomctl32"
2153     W32_RES_LINK="\$(EMACSRES)"
2154     CLIENTRES="emacsclient.res"
2155     CLIENTW="emacsclientw\$(EXEEXT)"
2156     FIRSTFILE_OBJ=firstfile.o
2157     NTDIR=nt
2158     CM_OBJ=
2159     LIBS_ECLIENT="-lcomctl32"
2160     LIB_WSOCK32="-lwsock32"
2161     NTLIB="ntlib.$ac_objext"
2162     XARGS_LIMIT="-s 10000"
2163   fi
2166 if test "${HAVE_W32}" = "no" && test "${opsys}" = "cygwin"; then
2167   W32_LIBS="-lkernel32"
2168   W32_OBJ="w32cygwinx.o"
2171 AC_SUBST(W32_OBJ)
2172 AC_SUBST(W32_LIBS)
2173 AC_SUBST(EMACSRES)
2174 AC_SUBST(EMACS_MANIFEST)
2175 AC_SUBST(CLIENTRES)
2176 AC_SUBST(CLIENTW)
2177 AC_SUBST(W32_RES_LINK)
2178 AC_SUBST(FIRSTFILE_OBJ)
2179 AC_SUBST(NTDIR)
2180 AC_SUBST(CM_OBJ)
2181 AC_SUBST(LIBS_ECLIENT)
2182 AC_SUBST(LIB_WSOCK32)
2183 AC_SUBST(NTLIB)
2184 AC_SUBST(XARGS_LIMIT)
2186 if test "${HAVE_W32}" = "yes"; then
2187   window_system=w32
2188   with_xft=no
2191 ## $window_system is now set to the window system we will
2192 ## ultimately use.
2194 term_header=
2195 HAVE_X_WINDOWS=no
2196 HAVE_X11=no
2197 USE_X_TOOLKIT=none
2199 case "${window_system}" in
2200   x11 )
2201     HAVE_X_WINDOWS=yes
2202     HAVE_X11=yes
2203     term_header=xterm.h
2204     case "${with_x_toolkit}" in
2205       athena | lucid ) USE_X_TOOLKIT=LUCID ;;
2206       motif ) USE_X_TOOLKIT=MOTIF ;;
2207       gtk ) with_gtk=yes
2208             term_header=gtkutil.h
2209 dnl Don't set this for GTK.  A lot of tests below assumes Xt when
2210 dnl USE_X_TOOLKIT is set.
2211             USE_X_TOOLKIT=none ;;
2212       gtk2 ) with_gtk2=yes
2213              term_header=gtkutil.h
2214              USE_X_TOOLKIT=none ;;
2215       gtk3 ) with_gtk3=yes
2216              term_header=gtkutil.h
2217              USE_X_TOOLKIT=none ;;
2218       no ) USE_X_TOOLKIT=none ;;
2219 dnl If user did not say whether to use a toolkit, make this decision later:
2220 dnl use the toolkit if we have gtk, or X11R5 or newer.
2221       * ) USE_X_TOOLKIT=maybe ;;
2222     esac
2223   ;;
2224   nextstep )
2225     term_header=nsterm.h
2226   ;;
2227   w32 )
2228     term_header=w32term.h
2229   ;;
2230 esac
2232 if test "$window_system" = none && test "X$with_x" != "Xno"; then
2233    AC_CHECK_PROG(HAVE_XSERVER, X, true, false)
2234    if test "$HAVE_XSERVER" = true ||
2235       test -n "$DISPLAY" ||
2236       {
2237         for emacs_libX11 in /usr/lib/libX11.*; do break; done
2238         test "$emacs_libX11" != '/usr/lib/libX11.*'
2239       }
2240    then
2241         AC_MSG_ERROR([You seem to be running X, but no X development libraries
2242 were found.  You should install the relevant development files for X
2243 and for the toolkit you want, such as Gtk+.  Also make
2244 sure you have development files for image handling, i.e.
2245 tiff, gif, jpeg, png and xpm.
2246 If you are sure you want Emacs compiled without X window support, pass
2247   --without-x
2248 to configure.])
2249    fi
2252 # Does the opsystem file prohibit the use of the GNU malloc?
2253 # Assume not, until told otherwise.
2254 GNU_MALLOC=yes
2256 AC_CACHE_CHECK(
2257   [whether malloc is Doug Lea style],
2258   [emacs_cv_var_doug_lea_malloc],
2259   [emacs_cv_var_doug_lea_malloc=no
2260    dnl Hooks do not work with address sanitization.
2261    if test "$emacs_cv_sanitize_address" != yes; then
2262      AC_LINK_IFELSE(
2263        [AC_LANG_PROGRAM(
2264           [[#include <malloc.h>
2265             static void hook (void) {}]],
2266           [[malloc_set_state (malloc_get_state ());
2267             __after_morecore_hook = hook;
2268             __malloc_initialize_hook = hook;]])],
2269        [emacs_cv_var_doug_lea_malloc=yes])
2270    fi])
2271 doug_lea_malloc=$emacs_cv_var_doug_lea_malloc
2273 hybrid_malloc=
2274 system_malloc=yes
2276 test $with_unexec = yes &&
2277 case "$opsys" in
2278   ## darwin ld insists on the use of malloc routines in the System framework.
2279   darwin | mingw32 | nacl | solaris) ;;
2280   cygwin | qnxnto | freebsd)
2281           hybrid_malloc=yes
2282           system_malloc= ;;
2283   *) test "$ac_cv_func_sbrk" = yes && system_malloc=$emacs_cv_sanitize_address;;
2284 esac
2286 if test "${system_malloc}" != yes && test "${doug_lea_malloc}" != yes \
2287    && test "${UNEXEC_OBJ}" = unexelf.o; then
2288   hybrid_malloc=yes
2291 GMALLOC_OBJ=
2292 HYBRID_MALLOC=
2293 if test "${system_malloc}" = "yes"; then
2294   AC_DEFINE([SYSTEM_MALLOC], 1,
2295     [Define to 1 to use the system memory allocator, even if it is not
2296      Doug Lea style.])
2297   GNU_MALLOC=no
2298   GNU_MALLOC_reason="
2299     (The GNU allocators don't work with this system configuration.)"
2300   VMLIMIT_OBJ=
2301 elif test "$hybrid_malloc" = yes; then
2302   AC_DEFINE(HYBRID_MALLOC, 1,
2303     [Define to use gmalloc before dumping and the system malloc after.])
2304   HYBRID_MALLOC=1
2305   GNU_MALLOC=no
2306   GNU_MALLOC_reason=" (only before dumping)"
2307   GMALLOC_OBJ=gmalloc.o
2308   VMLIMIT_OBJ=
2309 else
2310   test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
2311   VMLIMIT_OBJ=vm-limit.o
2313   AC_CHECK_HEADERS([sys/vlimit.h])
2314   AC_CACHE_CHECK([for data_start], [emacs_cv_data_start],
2315     [AC_LINK_IFELSE(
2316        [AC_LANG_PROGRAM(
2317          [[extern char data_start[]; char ch;]],
2318          [[return data_start < &ch;]])],
2319        [emacs_cv_data_start=yes],
2320        [emacs_cv_data_start=no])])
2321   if test $emacs_cv_data_start = yes; then
2322     AC_DEFINE([HAVE_DATA_START], 1,
2323       [Define to 1 if data_start is the address of the start
2324        of the main data segment.])
2325   fi
2327 AC_SUBST([HYBRID_MALLOC])
2328 AC_SUBST(GMALLOC_OBJ)
2329 AC_SUBST(VMLIMIT_OBJ)
2331 if test "$doug_lea_malloc" = "yes" && test "$hybrid_malloc" != yes; then
2332   if test "$GNU_MALLOC" = yes ; then
2333     GNU_MALLOC_reason="
2334       (Using Doug Lea's new malloc from the GNU C Library.)"
2335   fi
2336   AC_DEFINE(DOUG_LEA_MALLOC, 1,
2337     [Define to 1 if the system memory allocator is Doug Lea style,
2338      with malloc hooks and malloc_set_state.])
2340   ## Use mmap directly for allocating larger buffers.
2341   ## FIXME this comes from src/s/{gnu,gnu-linux}.h:
2342   ## #ifdef DOUG_LEA_MALLOC; #undef REL_ALLOC; #endif
2343   ## Does the AC_FUNC_MMAP test below make this check unnecessary?
2344   case "$opsys" in
2345     mingw32|gnu*) REL_ALLOC=no ;;
2346   esac
2349 if test x"${REL_ALLOC}" = x; then
2350   REL_ALLOC=${GNU_MALLOC}
2353 use_mmap_for_buffers=no
2354 case "$opsys" in
2355   mingw32) use_mmap_for_buffers=yes ;;
2356 esac
2358 AC_FUNC_MMAP
2359 if test $use_mmap_for_buffers = yes; then
2360   AC_DEFINE(USE_MMAP_FOR_BUFFERS, 1, [Define to use mmap to allocate buffer text.])
2361   REL_ALLOC=no
2364 LIBS="$LIBS_SYSTEM $LIBS"
2366 dnl FIXME replace main with a function we actually want from this library.
2367 AC_CHECK_LIB(Xbsd, main, LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -lXbsd")
2369 dnl Check for the POSIX thread library.
2370 LIB_PTHREAD=
2371 AC_CHECK_HEADERS_ONCE(pthread.h)
2372 if test "$ac_cv_header_pthread_h" && test "$opsys" != "mingw32"; then
2373   AC_CACHE_CHECK([for pthread library],
2374     [emacs_cv_pthread_lib],
2375     [emacs_cv_pthread_lib=no
2376      OLD_LIBS=$LIBS
2377      for emacs_pthread_lib in 'none needed' -lpthread; do
2378        case $emacs_pthread_lib in
2379          -*) LIBS="$OLD_LIBS $emacs_pthread_lib";;
2380        esac
2381        AC_LINK_IFELSE(
2382          [AC_LANG_PROGRAM(
2383             [[#include <pthread.h>
2384               #include <signal.h>
2385               sigset_t old_mask, new_mask;
2386               void noop (void) {}]],
2387             [[pthread_t th = pthread_self ();
2388               int status = 0;
2389               status += pthread_create (&th, 0, 0, 0);
2390               status += pthread_sigmask (SIG_BLOCK, &new_mask, &old_mask);
2391               status += pthread_kill (th, 0);
2392               #if ! (defined SYSTEM_MALLOC || defined HYBRID_MALLOC \
2393                      || defined DOUG_LEA_MALLOC)
2394               /* Test for pthread_atfork only if gmalloc uses it,
2395                  as older-style hosts like MirBSD 10 lack it.  */
2396               status += pthread_atfork (noop, noop, noop);
2397               #endif
2398               return status;]])],
2399          [emacs_cv_pthread_lib=$emacs_pthread_lib])
2400        LIBS=$OLD_LIBS
2401        if test "$emacs_cv_pthread_lib" != no; then
2402          break
2403        fi
2404      done])
2405   if test "$emacs_cv_pthread_lib" != no; then
2406     AC_DEFINE([HAVE_PTHREAD], 1, [Define to 1 if you have POSIX threads.])
2407     case $emacs_cv_pthread_lib in
2408       -*) LIB_PTHREAD=$emacs_cv_pthread_lib;;
2409     esac
2410     ac_cv_func_pthread_sigmask=yes
2411     # Some systems optimize for single-threaded programs by default, and
2412     # need special flags to disable these optimizations. For example, the
2413     # definition of 'errno' in <errno.h>.
2414     case $opsys in
2415       hpux* | solaris)
2416         AC_DEFINE([_REENTRANT], 1,
2417           [Define to 1 if your system requires this in multithreaded code.]);;
2418       aix4-2)
2419         AC_DEFINE([_THREAD_SAFE], 1,
2420           [Define to 1 if your system requires this in multithreaded code.]);;
2421     esac
2422   fi
2424 AC_SUBST([LIB_PTHREAD])
2426 AC_MSG_CHECKING([for thread support])
2427 threads_enabled=no
2428 if test "$with_threads" = yes; then
2429    if test "$emacs_cv_pthread_lib" != no; then
2430       AC_DEFINE(THREADS_ENABLED, 1,
2431                 [Define to 1 if you want elisp thread support.])
2432       threads_enabled=yes
2433    elif test "${opsys}" = "mingw32"; then
2434       dnl MinGW can do native Windows threads even without pthreads
2435       AC_DEFINE(THREADS_ENABLED, 1,
2436                 [Define to 1 if you want elisp thread support.])
2437       threads_enabled=yes
2438    fi
2440 AC_MSG_RESULT([$threads_enabled])
2442 dnl Check for need for bigtoc support on IBM AIX
2444 case ${host_os} in
2445 aix*)
2446   AC_CACHE_CHECK([for -bbigtoc option], [gdb_cv_bigtoc], [
2447     case $GCC in
2448     yes) gdb_cv_bigtoc=-Wl,-bbigtoc ;;
2449     *) gdb_cv_bigtoc=-bbigtoc ;;
2450     esac
2452     LDFLAGS=$LDFLAGS\ $gdb_cv_bigtoc
2453     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])], [], [gdb_cv_bigtoc=])
2454   ])
2455   ;;
2456 esac
2458 # Change CFLAGS, CPPFLAGS, and LIBS temporarily so that C_SWITCH_X_SITE
2459 # is for the tests that follow.  We set them back later on.
2461 REAL_CFLAGS="$CFLAGS"
2462 REAL_CPPFLAGS="$CPPFLAGS"
2463 REAL_LIBS="$LIBS"
2465 if test "${HAVE_X11}" = "yes"; then
2466   DEFS="$C_SWITCH_X_SITE $DEFS"
2467   LDFLAGS="$LDFLAGS $LD_SWITCH_X_SITE"
2468   LIBS="-lX11 $LIBS"
2469   CFLAGS="$C_SWITCH_X_SITE $CFLAGS"
2470   CPPFLAGS="$C_SWITCH_X_SITE $CPPFLAGS"
2472   # On Solaris, arrange for LD_RUN_PATH to point to the X libraries for tests.
2473   # This is handled by LD_SWITCH_X_SITE_RPATH during the real build,
2474   # but it's more convenient here to set LD_RUN_PATH since this
2475   # also works on hosts that don't understand LD_SWITCH_X_SITE_RPATH.
2476   if test "${x_libraries}" != NONE && test -n "${x_libraries}"; then
2477     LD_RUN_PATH=$x_libraries${LD_RUN_PATH+:}$LD_RUN_PATH
2478     export LD_RUN_PATH
2479   fi
2481   if test "${opsys}" = "gnu-linux"; then
2482     AC_CACHE_CHECK([whether X on GNU/Linux needs -b to link], [emacs_cv_b_link],
2483     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
2484      [[XOpenDisplay ("foo");]])],
2485      [xgnu_linux_first_failure=no],
2486      [xgnu_linux_first_failure=yes])
2487     if test "${xgnu_linux_first_failure}" = "yes"; then
2488       OLD_CPPFLAGS="$CPPFLAGS"
2489       OLD_LIBS="$LIBS"
2490       CPPFLAGS="$CPPFLAGS -b i486-linuxaout"
2491       LIBS="$LIBS -b i486-linuxaout"
2492       AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
2493        [[XOpenDisplay ("foo");]])],
2494        [xgnu_linux_second_failure=no],
2495        [xgnu_linux_second_failure=yes])
2496       if test "${xgnu_linux_second_failure}" = "yes"; then
2497         # If we get the same failure with -b, there is no use adding -b.
2498         # So leave it out.  This plays safe.
2499         emacs_cv_b_link=no
2500       else
2501         emacs_cv_b_link=yes
2502       fi
2503       CPPFLAGS=$OLD_CPPFLAGS
2504       LIBS=$OLD_LIBS
2505     else
2506       emacs_cv_b_link=no
2507     fi])
2508     if test "x$emacs_cv_b_link" = xyes ; then
2509       LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -b i486-linuxaout"
2510       C_SWITCH_X_SITE="$C_SWITCH_X_SITE -b i486-linuxaout"
2511     fi
2512   fi
2514   # Reportedly, some broken Solaris systems have XKBlib.h but are missing
2515   # header files included from there.
2516   AC_CACHE_CHECK([for Xkb], [emacs_cv_xkb],
2517   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>
2518 #include <X11/XKBlib.h>]],
2519         [[XkbDescPtr kb = XkbGetKeyboard (0, XkbAllComponentsMask, XkbUseCoreKbd);]])],
2520         emacs_cv_xkb=yes, emacs_cv_xkb=no)])
2521   if test $emacs_cv_xkb = yes; then
2522     AC_DEFINE(HAVE_XKB, 1, [Define to 1 if you have the Xkb extension.])
2523   fi
2525   AC_CHECK_FUNCS(XrmSetDatabase XScreenResourceString \
2526 XScreenNumberOfScreen)
2529 if test "${window_system}" = "x11"; then
2530   AC_MSG_CHECKING(X11 version 6)
2531   AC_CACHE_VAL(emacs_cv_x11_version_6,
2532   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
2533 [[#if XlibSpecificationRelease < 6
2534 fail;
2535 #endif
2536 ]])], emacs_cv_x11_version_6=yes, emacs_cv_x11_version_6=no)])
2537   if test $emacs_cv_x11_version_6 = yes; then
2538     AC_MSG_RESULT(6 or newer)
2539     AC_DEFINE(HAVE_X11R6, 1,
2540               [Define to 1 if you have the X11R6 or newer version of Xlib.])
2541     AC_DEFINE(HAVE_X_I18N, 1, [Define if you have usable i18n support.])
2542     ## inoue@ainet.or.jp says Solaris has a bug related to X11R6-style
2543     ## XIM support.
2544     case "$opsys" in
2545       solaris) : ;;
2546       *) AC_DEFINE(HAVE_X11R6_XIM, 1,
2547            [Define if you have usable X11R6-style XIM support.])
2548          ;;
2549     esac
2550   else
2551     AC_MSG_RESULT(before 6)
2552   fi
2556 ### Use -lrsvg-2 if available, unless '--with-rsvg=no' is specified.
2557 HAVE_RSVG=no
2558 if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
2559   if test "${with_rsvg}" != "no"; then
2560     RSVG_REQUIRED=2.14.0
2561     RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
2563     EMACS_CHECK_MODULES([RSVG], [$RSVG_MODULE])
2564     AC_SUBST(RSVG_CFLAGS)
2565     AC_SUBST(RSVG_LIBS)
2567     if test $HAVE_RSVG = yes; then
2568       AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
2569       CFLAGS="$CFLAGS $RSVG_CFLAGS"
2570       # Windows loads librsvg dynamically
2571       if test "${opsys}" = "mingw32"; then
2572         RSVG_LIBS=
2573       fi
2574     fi
2575   fi
2578 HAVE_IMAGEMAGICK=no
2579 if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${HAVE_W32}" = "yes"; then
2580   if test "${with_imagemagick}" != "no"; then
2581     if test -n "$BREW"; then
2582       # Homebrew doesn't link ImageMagick 6 by default, so make sure
2583       # pkgconfig can find it.
2584       export PKG_CONFIG_PATH="$PKG_CONFIG_PATH$PATH_SEPARATOR`$BREW --prefix imagemagick@6 2>/dev/null`/lib/pkgconfig"
2585     fi
2587     EMACS_CHECK_MODULES([IMAGEMAGICK], [MagickWand >= 7])
2588     if test $HAVE_IMAGEMAGICK = yes; then
2589        AC_DEFINE([HAVE_IMAGEMAGICK7], 1, [Define to 1 if using ImageMagick7.])
2590     else
2591        ## 6.3.5 is the earliest version known to work; see Bug#17339.
2592        ## 6.8.2 makes Emacs crash; see Bug#13867.
2593        EMACS_CHECK_MODULES([IMAGEMAGICK], [Wand >= 6.3.5 Wand != 6.8.2])
2594     fi
2596     if test $HAVE_IMAGEMAGICK = yes; then
2597       OLD_CFLAGS=$CFLAGS
2598       OLD_LIBS=$LIBS
2599       CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS"
2600       LIBS="$IMAGEMAGICK_LIBS $LIBS"
2601       AC_CHECK_FUNCS([MagickRelinquishMemory MagickExportImagePixels \
2602                       MagickMergeImageLayers MagickAutoOrientImage])
2603       CFLAGS=$OLD_CFLAGS
2604       LIBS=$OLD_LIBS
2605       # Check that ImageMagick links.  It does not link on Fedora 25
2606       # with './configure CC=clang', as pkg-config outputs flags like
2607       # -lomp that work for GCC but not Clang.
2608       if test "$ac_cv_func_MagickRelinquishMemory" != yes; then
2609         HAVE_IMAGEMAGICK=no
2610       fi
2611     fi
2612     if test $HAVE_IMAGEMAGICK = yes; then
2613       AC_DEFINE([HAVE_IMAGEMAGICK], 1, [Define to 1 if using ImageMagick.])
2614     else
2615       if test "${with_imagemagick}" != "no"; then
2616         AC_MSG_ERROR([ImageMagick wanted, but it does not compile.  Maybe some library files are missing?]);
2617       fi
2618       IMAGEMAGICK_CFLAGS=
2619       IMAGEMAGICK_LIBS=
2620     fi
2621     AC_SUBST([IMAGEMAGICK_CFLAGS])
2622     AC_SUBST([IMAGEMAGICK_LIBS])
2623   fi
2626 AC_CHECK_LIB(anl, getaddrinfo_a, HAVE_GETADDRINFO_A=yes)
2627 if test "${HAVE_GETADDRINFO_A}" = "yes"; then
2628   AC_DEFINE(HAVE_GETADDRINFO_A, 1,
2629 [Define to 1 if you have getaddrinfo_a for asynchronous DNS resolution.])
2630   GETADDRINFO_A_LIBS="-lanl"
2631   AC_SUBST(GETADDRINFO_A_LIBS)
2634 HAVE_GTK=no
2635 GTK_OBJ=
2636 gtk_term_header=$term_header
2637 check_gtk2=no
2638 gtk3_pkg_errors=
2639 if test "${opsys}" != "mingw32"; then
2640   if test "${with_gtk3}" = "yes" || test "${with_gtk}" = "yes" || test "$USE_X_TOOLKIT" = "maybe"; then
2641     GLIB_REQUIRED=2.37.5
2642     GTK_REQUIRED=3.10
2643     GTK_MODULES="gtk+-3.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
2645     dnl Checks for libraries.
2646     EMACS_CHECK_MODULES([GTK], [$GTK_MODULES],
2647       [pkg_check_gtk=yes], [pkg_check_gtk=no])
2648     if test "$pkg_check_gtk" = "no" && test "$with_gtk3" = "yes"; then
2649        AC_MSG_ERROR($GTK_PKG_ERRORS)
2650     fi
2651     if test "$pkg_check_gtk" = "yes"; then
2652        AC_DEFINE(HAVE_GTK3, 1, [Define to 1 if using GTK 3 or later.])
2653        GTK_OBJ=emacsgtkfixed.o
2654        gtk_term_header=gtkutil.h
2655        USE_GTK_TOOLKIT="GTK3"
2656        if test "x$ac_enable_gtk_deprecation_warnings" = x; then
2657          AC_DEFINE([GDK_DISABLE_DEPRECATION_WARNINGS], [1],
2658            [Define to 1 to disable GTK+/GDK deprecation warnings.])
2659          AC_DEFINE([GLIB_DISABLE_DEPRECATION_WARNINGS], [1],
2660            [Define to 1 to disable Glib deprecation warnings.])
2661        fi
2662     else
2663        check_gtk2=yes
2664        gtk3_pkg_errors="$GTK_PKG_ERRORS "
2665     fi
2666   fi
2668   if test "${with_gtk2}" = "yes" || test "$check_gtk2" = "yes"; then
2669     GLIB_REQUIRED=2.28
2670     GTK_REQUIRED=2.24
2671     GTK_MODULES="gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
2673     dnl Checks for libraries.
2674     EMACS_CHECK_MODULES([GTK], [$GTK_MODULES],
2675       [pkg_check_gtk=yes], [pkg_check_gtk=no])
2676     if test "$pkg_check_gtk" = "no" &&
2677        { test "$with_gtk" = yes || test "$with_gtk2" = "yes"; }
2678     then
2679       AC_MSG_ERROR($gtk3_pkg_errors$GTK_PKG_ERRORS)
2680     fi
2681     test "$pkg_check_gtk" = "yes" && USE_GTK_TOOLKIT="GTK2"
2682   fi
2685 OLD_CFLAGS=$CFLAGS
2686 OLD_LIBS=$LIBS
2688 if test x"$pkg_check_gtk" = xyes; then
2690   AC_SUBST(GTK_LIBS)
2691   CFLAGS="$CFLAGS $GTK_CFLAGS"
2692   LIBS="$GTK_LIBS $LIBS"
2693   dnl Try to compile a simple GTK program.
2694   AC_CACHE_CHECK([whether GTK compiles], [emacs_cv_gtk_compiles],
2695   [AC_LINK_IFELSE(
2696     [AC_LANG_PROGRAM(
2697        [[/* Check the Gtk and Glib APIs.  */
2698          #include <gtk/gtk.h>
2699          #include <glib-object.h>
2700          static void
2701          callback (GObject *go, GParamSpec *spec, gpointer user_data)
2702          {}
2703        ]],
2704        [[
2705          GtkSettings *gs = 0;
2706          /* Use G_CALLBACK to make sure function pointers can be cast to void *;
2707             strict C prohibits this.  Use gtk_main_iteration to test that the
2708             libraries are there.  */
2709          if (g_signal_handler_find (G_OBJECT (gs), G_SIGNAL_MATCH_FUNC,
2710                                     0, 0, 0, G_CALLBACK (callback), 0))
2711            gtk_main_iteration ();
2712        ]])],
2713     [emacs_cv_gtk_compiles=yes], [emacs_cv_gtk_compiles=no])])
2714   if test "${emacs_cv_gtk_compiles}" != "yes"; then
2715     GTK_OBJ=
2716     if test "$USE_X_TOOLKIT" != "maybe"; then
2717       AC_MSG_ERROR([Gtk+ wanted, but it does not compile, see config.log.  Maybe some x11-devel files missing?]);
2718     fi
2719   else
2720     C_SWITCH_X_SITE="$C_SWITCH_X_SITE $GTK_CFLAGS"
2721     HAVE_GTK=yes
2722     AC_DEFINE(USE_GTK, 1, [Define to 1 if using GTK.])
2723     GTK_OBJ="gtkutil.o $GTK_OBJ"
2724     term_header=$gtk_term_header
2725     USE_X_TOOLKIT=none
2726     AC_MSG_WARN([[Your version of Gtk+ will have problems with
2727        closing open displays.  This is no problem if you just use
2728        one display, but if you use more than one and close one of them
2729        Emacs may crash.
2730        See https://gitlab.gnome.org/GNOME/gtk/issues/221]])
2731   fi
2734 AC_SUBST(GTK_OBJ)
2737 if test "${HAVE_GTK}" = "yes"; then
2739   dnl  GTK scrollbars resemble toolkit scrollbars a lot, so to avoid
2740   dnl  a lot if #ifdef:s, say we have toolkit scrollbars.
2741   if test "$with_toolkit_scroll_bars" != no; then
2742     with_toolkit_scroll_bars=yes
2743   fi
2745   term_header=gtkutil.h
2747   if test "${USE_GTK_TOOLKIT}" = GTK2; then
2749     dnl  Check if we have the old file selection dialog declared and
2750     dnl  in the link library.  In 2.x it may be in the library,
2751     dnl  but not declared if deprecated featured has been selected out.
2752     dnl  AC_CHECK_DECL checks for a macro, so check for GTK_TYPE_FILE_SELECTION.
2753     HAVE_GTK_FILE_SELECTION=no
2754     AC_CHECK_DECL(GTK_TYPE_FILE_SELECTION, HAVE_GTK_FILE_SELECTION=yes,
2755                      HAVE_GTK_FILE_SELECTION=no, [AC_INCLUDES_DEFAULT
2756 #include <gtk/gtk.h>])
2757     if test "$HAVE_GTK_FILE_SELECTION" = yes; then
2758       AC_CHECK_FUNCS(gtk_file_selection_new)
2759     fi
2761     dnl This procedure causes a bug on certain Ubuntu GTK+2 builds
2762     AC_CHECK_FUNCS(gtk_window_set_has_resize_grip)
2763   fi
2767 dnl Enable xwidgets if GTK3 and WebKitGTK+ are available.
2768 dnl Enable xwidgets if macOS Cocoa and WebKit framework are available.
2769 HAVE_XWIDGETS=no
2770 XWIDGETS_OBJ=
2771 if test "$with_xwidgets" != "no"; then
2772   if test "$USE_GTK_TOOLKIT" = "GTK3" && test "$window_system" != "none"; then
2773     WEBKIT_REQUIRED=2.12
2774     WEBKIT_MODULES="webkit2gtk-4.0 >= $WEBKIT_REQUIRED"
2775     EMACS_CHECK_MODULES([WEBKIT], [$WEBKIT_MODULES])
2776     HAVE_XWIDGETS=$HAVE_WEBKIT
2777     XWIDGETS_OBJ="xwidget.o"
2778   elif test "${NS_IMPL_COCOA}" = "yes"; then
2779     dnl FIXME: Check framework WebKit2
2780     dnl WEBKIT_REQUIRED=M.m.p
2781     WEBKIT_LIBS="-Wl,-framework -Wl,WebKit"
2782     WEBKIT_CFLAGS="-I/System/Library/Frameworks/WebKit.framework/Headers"
2783     HAVE_WEBKIT="yes"
2784     HAVE_XWIDGETS=$HAVE_WEBKIT
2785     XWIDGETS_OBJ="xwidget.o"
2786     NS_OBJC_OBJ="$NS_OBJC_OBJ nsxwidget.o"
2787     dnl Update NS_OBJC_OBJ with added nsxwidget.o
2788     AC_SUBST(NS_OBJC_OBJ)
2789   else
2790     AC_MSG_ERROR([xwidgets requested, it requires GTK3 as X window toolkit or macOS Cocoa as window system.])
2791   fi
2793   test $HAVE_XWIDGETS = yes ||
2794     AC_MSG_ERROR([xwidgets requested but WebKitGTK+ or WebKit framework not found.])
2796   AC_DEFINE([HAVE_XWIDGETS], 1, [Define to 1 if you have xwidgets support.])
2798 AC_SUBST(XWIDGETS_OBJ)
2800 CFLAGS=$OLD_CFLAGS
2801 LIBS=$OLD_LIBS
2803 dnl D-Bus has been tested under GNU/Linux only.  Must be adapted for
2804 dnl other platforms.
2805 HAVE_DBUS=no
2806 DBUS_OBJ=
2807 if test "${with_dbus}" = "yes"; then
2808    EMACS_CHECK_MODULES([DBUS], [dbus-1 >= 1.0])
2809    if test "$HAVE_DBUS" = yes; then
2810      AC_DEFINE(HAVE_DBUS, 1, [Define to 1 if using D-Bus.])
2811      dnl dbus_watch_get_unix_fd has been introduced in D-Bus 1.1.1.
2812      dnl dbus_type_is_valid and dbus_validate_* have been introduced in
2813      dnl D-Bus 1.5.12.
2814      OLD_LIBS=$LIBS
2815      LIBS="$LIBS $DBUS_LIBS"
2816      AC_CHECK_FUNCS(dbus_watch_get_unix_fd \
2817                     dbus_type_is_valid \
2818                     dbus_validate_bus_name \
2819                     dbus_validate_path \
2820                     dbus_validate_interface \
2821                     dbus_validate_member)
2822      LIBS=$OLD_LIBS
2823      DBUS_OBJ=dbusbind.o
2824    fi
2826 AC_SUBST(DBUS_CFLAGS)
2827 AC_SUBST(DBUS_LIBS)
2828 AC_SUBST(DBUS_OBJ)
2830 dnl GSettings has been tested under GNU/Linux only.
2831 HAVE_GSETTINGS=no
2832 if test "${HAVE_X11}" = "yes" && test "${with_gsettings}" = "yes"; then
2833    EMACS_CHECK_MODULES([GSETTINGS], [gio-2.0 >= 2.26])
2834    if test "$HAVE_GSETTINGS" = "yes"; then
2835       old_CFLAGS=$CFLAGS
2836       CFLAGS="$CFLAGS $GSETTINGS_CFLAGS"
2837       old_LIBS=$LIBS
2838       LIBS="$LIBS $GSETTINGS_LIBS"
2839       AC_CACHE_CHECK([whether GSettings is in gio], [emacs_cv_gsettings_in_gio],
2840       [AC_LINK_IFELSE(
2841          [AC_LANG_PROGRAM(
2842              [[/* Check that gsettings really is present.  */
2843              #include <glib-object.h>
2844              #include <gio/gio.h>
2845              ]],
2846              [[
2847                GSettings *settings;
2848                GVariant *val = g_settings_get_value (settings, "");
2849              ]])],
2850        [emacs_cv_gsettings_in_gio=yes], [emacs_cv_gsettings_in_gio=no])])
2852       if test "$emacs_cv_gsettings_in_gio" = "yes"; then
2853         AC_DEFINE(HAVE_GSETTINGS, 1, [Define to 1 if using GSettings.])
2854         SETTINGS_CFLAGS="$GSETTINGS_CFLAGS"
2855         SETTINGS_LIBS="$GSETTINGS_LIBS"
2856         test "$with_gconf" = "yes" || with_gconf=no
2857       fi
2858       CFLAGS=$old_CFLAGS
2859       LIBS=$old_LIBS
2860    fi
2863 dnl GConf has been tested under GNU/Linux only.
2864 dnl The version is really arbitrary, it is about the same age as Gtk+ 2.6.
2865 HAVE_GCONF=no
2866 if test "${HAVE_X11}" = "yes" && test "${with_gconf}" != "no"; then
2867    EMACS_CHECK_MODULES([GCONF], [gconf-2.0 >= 2.13])
2868    if test "$HAVE_GCONF" = yes; then
2869       AC_DEFINE(HAVE_GCONF, 1, [Define to 1 if using GConf.])
2870       dnl Newer GConf doesn't link with g_objects, so this is not defined.
2871       SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GCONF_CFLAGS"
2872       SETTINGS_LIBS="$SETTINGS_LIBS $GCONF_LIBS"
2873    fi
2876 if test "$HAVE_GSETTINGS" = "yes" || test "$HAVE_GCONF" = "yes"; then
2877     EMACS_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.0])
2878     if test "$HAVE_GOBJECT" = "yes"; then
2879        SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GOBJECT_CFLAGS"
2880        SETTINGS_LIBS="$SETTINGS_LIBS $GOBJECT_LIBS"
2881     fi
2882     SAVE_CFLAGS="$CFLAGS"
2883     SAVE_LIBS="$LIBS"
2884     CFLAGS="$SETTINGS_CFLAGS $CFLAGS"
2885     LIBS="$SETTINGS_LIBS $LIBS"
2886     CFLAGS="$SAVE_CFLAGS"
2887     LIBS="$SAVE_LIBS"
2889 AC_SUBST(SETTINGS_CFLAGS)
2890 AC_SUBST(SETTINGS_LIBS)
2893 dnl SELinux is available for GNU/Linux only.
2894 HAVE_LIBSELINUX=no
2895 LIBSELINUX_LIBS=
2896 if test "${with_selinux}" = "yes"; then
2897    AC_CHECK_LIB([selinux], [lgetfilecon], HAVE_LIBSELINUX=yes, HAVE_LIBSELINUX=no)
2898    if test "$HAVE_LIBSELINUX" = yes; then
2899       AC_DEFINE(HAVE_LIBSELINUX, 1, [Define to 1 if using SELinux.])
2900       LIBSELINUX_LIBS=-lselinux
2901    fi
2903 AC_SUBST(LIBSELINUX_LIBS)
2905 HAVE_GNUTLS=no
2906 if test "${with_gnutls}" != "no" ; then
2907   EMACS_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.12.2],
2908     [HAVE_GNUTLS=yes], [HAVE_GNUTLS=no])
2909   if test "${HAVE_GNUTLS}" = "yes"; then
2910     AC_DEFINE(HAVE_GNUTLS, 1, [Define if using GnuTLS.])
2911   fi
2913   # Windows loads GnuTLS dynamically
2914   if test "${opsys}" = "mingw32"; then
2915     LIBGNUTLS_LIBS=
2916   fi
2919 AC_SUBST(LIBGNUTLS_LIBS)
2920 AC_SUBST(LIBGNUTLS_CFLAGS)
2922 HAVE_LIBSYSTEMD=no
2923 if test "${with_libsystemd}" = "yes" ; then
2924   dnl This code has been tested with libsystemd 222 and later.
2925   dnl FIXME: Find the earliest version number for which Emacs should work,
2926   dnl and change '222' to that number.
2927   EMACS_CHECK_MODULES([LIBSYSTEMD], [libsystemd >= 222],
2928     [HAVE_LIBSYSTEMD=yes], [HAVE_LIBSYSTEMD=no])
2929   if test "${HAVE_LIBSYSTEMD}" = "yes"; then
2930     AC_DEFINE(HAVE_LIBSYSTEMD, 1, [Define if using libsystemd.])
2931   fi
2934 AC_SUBST(LIBSYSTEMD_LIBS)
2935 AC_SUBST(LIBSYSTEMD_CFLAGS)
2937 HAVE_JSON=no
2938 JSON_OBJ=
2940 if test "${with_json}" != no; then
2941   EMACS_CHECK_MODULES([JSON], [jansson >= 2.7],
2942     [HAVE_JSON=yes], [HAVE_JSON=no])
2943   if test "${HAVE_JSON}" = yes; then
2944     AC_DEFINE(HAVE_JSON, 1, [Define if using Jansson.])
2945     JSON_OBJ=json.o
2946   fi
2948   # Windows loads libjansson dynamically
2949   if test "${opsys}" = "mingw32"; then
2950     JSON_LIBS=
2951   fi
2954 AC_SUBST(JSON_LIBS)
2955 AC_SUBST(JSON_CFLAGS)
2956 AC_SUBST(JSON_OBJ)
2958 NOTIFY_OBJ=
2959 NOTIFY_SUMMARY=no
2961 dnl MS Windows native file monitor is available for mingw32 only.
2962 case $with_file_notification,$opsys in
2963   w32,cygwin)
2964     AC_MSG_ERROR(['--with-file-notification=w32' was specified, but
2965     this is only supported on MS-Windows native and MinGW32 builds.
2966     Consider using gfile instead.])
2967     ;;
2968   w32,* | yes,mingw32)
2969     AC_CHECK_HEADER(windows.h)
2970     if test "$ac_cv_header_windows_h" = yes ; then
2971        AC_DEFINE(HAVE_W32NOTIFY, 1, [Define to 1 to use w32notify.])
2972        NOTIFY_OBJ=w32notify.o
2973        NOTIFY_SUMMARY="yes (w32)"
2974     fi ;;
2975 esac
2977 dnl inotify is available only on GNU/Linux.
2978 case $with_file_notification,$NOTIFY_OBJ in
2979   inotify, | yes,)
2980     AC_CHECK_HEADER(sys/inotify.h)
2981     if test "$ac_cv_header_sys_inotify_h" = yes ; then
2982         AC_CHECK_FUNC(inotify_init1)
2983         if test "$ac_cv_func_inotify_init1" = yes; then
2984           AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 to use inotify.])
2985           NOTIFY_OBJ=inotify.o
2986           NOTIFY_SUMMARY="yes -lglibc (inotify)"
2987        fi
2988     fi ;;
2989 esac
2991 dnl kqueue is available on BSD-like systems.
2992 case $with_file_notification,$NOTIFY_OBJ in
2993   kqueue,* | yes,)
2994     EMACS_CHECK_MODULES([KQUEUE], [libkqueue])
2995     if test "$HAVE_KQUEUE" = "yes"; then
2996        AC_DEFINE(HAVE_KQUEUE, 1, [Define to 1 to use kqueue.])
2997        CPPFLAGS="$CPPFLAGS -I/usr/include/kqueue"
2998        NOTIFY_CFLAGS=$KQUEUE_CFLAGS
2999        NOTIFY_LIBS=$KQUEUE_LIBS
3000        NOTIFY_OBJ=kqueue.o
3001        NOTIFY_SUMMARY="yes -lkqueue"
3002     else
3003        AC_SEARCH_LIBS(kqueue, [])
3004        if test "$ac_cv_search_kqueue" != no; then
3005          AC_DEFINE(HAVE_KQUEUE, 1, [Define to 1 to use kqueue.])
3006          NOTIFY_OBJ=kqueue.o
3007          NOTIFY_SUMMARY="yes (kqueue)"
3008        fi
3009     fi ;;
3010 esac
3012 dnl g_file_monitor exists since glib 2.18.  G_FILE_MONITOR_EVENT_MOVED
3013 dnl has been added in glib 2.24.  It has been tested under
3014 dnl GNU/Linux only.
3015 case $with_file_notification,$NOTIFY_OBJ in
3016   gfile,* | yes,)
3017     if test "${HAVE_NS}" = yes; then
3018        AC_MSG_ERROR(['--with-file-notification=gfile' is not supported in NextStep builds.
3019 Consider kqueue instead.])
3020     else
3021        EMACS_CHECK_MODULES([GFILENOTIFY], [gio-2.0 >= 2.24])
3022        if test "$HAVE_GFILENOTIFY" = "yes"; then
3023           AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.])
3024           NOTIFY_CFLAGS=$GFILENOTIFY_CFLAGS
3025           NOTIFY_LIBS=$GFILENOTIFY_LIBS
3026           NOTIFY_OBJ=gfilenotify.o
3027           NOTIFY_SUMMARY="yes -lgio (gfile)"
3028        fi
3029     fi ;;
3030 esac
3032 case $with_file_notification,$NOTIFY_OBJ in
3033   yes,* | no,* | *,?*) ;;
3034   *) AC_MSG_ERROR([File notification '$with_file_notification' requested but requirements not found.]) ;;
3035 esac
3037 if test -n "$NOTIFY_OBJ"; then
3038    AC_DEFINE(USE_FILE_NOTIFY, 1, [Define to 1 if using file notifications.])
3040 AC_SUBST(NOTIFY_CFLAGS)
3041 AC_SUBST(NOTIFY_LIBS)
3042 AC_SUBST(NOTIFY_OBJ)
3044 dnl Do not put whitespace before the #include statements below.
3045 dnl Older compilers (eg sunos4 cc) choke on it.
3046 HAVE_XAW3D=no
3047 LUCID_LIBW=
3048 if test x"${USE_X_TOOLKIT}" = xmaybe || test x"${USE_X_TOOLKIT}" = xLUCID; then
3049   if test "$with_xaw3d" != no; then
3050     AC_CACHE_VAL(emacs_cv_xaw3d,
3051     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3052 #include <X11/Intrinsic.h>
3053 #include <X11/Xaw3d/Simple.h>]],
3054       [[]])],
3055       [AC_CHECK_LIB(Xaw3d, XawScrollbarSetThumb,
3056                     emacs_cv_xaw3d=yes, emacs_cv_xaw3d=no)],
3057       emacs_cv_xaw3d=no)])
3058   else
3059     emacs_cv_xaw3d=no
3060   fi
3061   if test $emacs_cv_xaw3d = yes; then
3062     AC_MSG_CHECKING(for xaw3d)
3063     AC_MSG_RESULT([yes; using Lucid toolkit])
3064     USE_X_TOOLKIT=LUCID
3065     HAVE_XAW3D=yes
3066     LUCID_LIBW=-lXaw3d
3067     AC_DEFINE(HAVE_XAW3D, 1,
3068               [Define to 1 if you have the Xaw3d library (-lXaw3d).])
3069   else
3070     AC_MSG_CHECKING(for xaw3d)
3071     AC_MSG_RESULT(no)
3072     AC_MSG_CHECKING(for libXaw)
3073     AC_CACHE_VAL(emacs_cv_xaw,
3074     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3075 #include <X11/Intrinsic.h>
3076 #include <X11/Xaw/Simple.h>]],
3077       [[]])],
3078       emacs_cv_xaw=yes,
3079       emacs_cv_xaw=no)])
3080     if test $emacs_cv_xaw = yes; then
3081       AC_MSG_RESULT([yes; using Lucid toolkit])
3082       USE_X_TOOLKIT=LUCID
3083       LUCID_LIBW=-lXaw
3084     elif test x"${USE_X_TOOLKIT}" = xLUCID; then
3085       AC_MSG_ERROR([Lucid toolkit requires X11/Xaw include files])
3086     else
3087       AC_MSG_ERROR([No X toolkit could be found.
3088 If you are sure you want Emacs compiled without an X toolkit, pass
3089   --with-x-toolkit=no
3090 to configure.  Otherwise, install the development libraries for the toolkit
3091 that you want to use (e.g. Gtk+) and re-run configure.])
3092     fi
3093   fi
3096 X_TOOLKIT_TYPE=$USE_X_TOOLKIT
3098 LIBXTR6=
3099 LIBXMU=
3100 if test "${USE_X_TOOLKIT}" != "none"; then
3101   AC_MSG_CHECKING(X11 toolkit version)
3102   AC_CACHE_VAL(emacs_cv_x11_toolkit_version_6,
3103   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Intrinsic.h>]],
3104 [[#if XtSpecificationRelease < 6
3105 fail;
3106 #endif
3107 ]])], emacs_cv_x11_toolkit_version_6=yes, emacs_cv_x11_toolkit_version_6=no)])
3108   HAVE_X11XTR6=$emacs_cv_x11_toolkit_version_6
3109   if test $emacs_cv_x11_toolkit_version_6 = yes; then
3110     AC_MSG_RESULT(6 or newer)
3111     AC_DEFINE(HAVE_X11XTR6, 1,
3112               [Define to 1 if you have the X11R6 or newer version of Xt.])
3113     LIBXTR6="-lSM -lICE"
3114     case "$opsys" in
3115       ## Use libw.a along with X11R6 Xt.
3116       unixware) LIBXTR6="$LIBXTR6 -lw" ;;
3117     esac
3118   else
3119     AC_MSG_RESULT(before 6)
3120   fi
3122 dnl If using toolkit, check whether libXmu.a exists.
3123 dnl tranle@intellicorp.com says libXmu.a can need XtMalloc in libXt.a to link.
3124   OLDLIBS="$LIBS"
3125   if test x$HAVE_X11XTR6 = xyes; then
3126     OTHERLIBS='-lXt -lSM -lICE'
3127   else
3128     OTHERLIBS='-lXt'
3129   fi
3130   AC_SEARCH_LIBS([XmuConvertStandardSelection], [Xmu], [], [], [$OTHERLIBS])
3131   if test "X$LIBS" != "X$OLDLIBS"; then
3132     LIBXMU=$ac_cv_search_XmuConvertStandardSelection
3133   fi
3134   LIBS=$OLDLIBS
3135   dnl ac_cv_search_XmuConvertStandardSelection is also referenced below.
3137 AC_SUBST(LIBXTR6)
3138 AC_SUBST(LIBXMU)
3140 LIBXP=
3141 if test "${USE_X_TOOLKIT}" = "MOTIF"; then
3142   # OpenMotif may be installed in such a way on some GNU/Linux systems.
3143   if test -d /usr/include/openmotif; then
3144     CPPFLAGS="-I/usr/include/openmotif $CPPFLAGS"
3145     emacs_cv_openmotif=yes
3146     case "$canonical" in
3147       x86_64-*-linux-gnu* | powerpc64-*-linux-gnu* | sparc64-*-linux-gnu*)
3148       test -d /usr/lib64/openmotif && LDFLAGS="-L/usr/lib64/openmotif $LDFLAGS"
3149       ;;
3150       *)
3151       test -d /usr/lib/openmotif && LDFLAGS="-L/usr/lib/openmotif $LDFLAGS"
3152     esac
3153   else
3154     emacs_cv_openmotif=no
3155   fi
3156   AC_CACHE_CHECK(for (Open)Motif version 2.1, emacs_cv_motif_version_2_1,
3157   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <Xm/Xm.h>]],
3158     [[#if XmVERSION > 2 || (XmVERSION == 2 && XmREVISION >= 1)
3159 int x = 5;
3160 #else
3161 Motif version prior to 2.1.
3162 #endif]])],
3163     emacs_cv_motif_version_2_1=yes, emacs_cv_motif_version_2_1=no)])
3164   if test $emacs_cv_motif_version_2_1 = yes; then
3165     AC_CHECK_LIB(Xp, XpCreateContext, LIBXP=-lXp)
3166     if test x$emacs_cv_openmotif = xyes; then
3167       REAL_CPPFLAGS="-I/usr/include/openmotif $REAL_CPPFLAGS"
3168     fi
3169   else
3170     AC_CACHE_CHECK(for LessTif where some systems put it, emacs_cv_lesstif,
3171     # We put this in CFLAGS temporarily to precede other -I options
3172     # that might be in CFLAGS temporarily.
3173     # We put this in CPPFLAGS where it precedes the other -I options.
3174     OLD_CPPFLAGS=$CPPFLAGS
3175     OLD_CFLAGS=$CFLAGS
3176     CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CPPFLAGS"
3177     CFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CFLAGS"
3178     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include </usr/X11R6/LessTif/Motif1.2/include/Xm/Xm.h>]],
3179       [[int x = 5;]])],
3180       emacs_cv_lesstif=yes, emacs_cv_lesstif=no)])
3181     if test $emacs_cv_lesstif = yes; then
3182       # Make sure this -I option remains in CPPFLAGS after it is set
3183       # back to REAL_CPPFLAGS.
3184       # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
3185       # have those other -I options anyway.  Ultimately, having this
3186       # directory ultimately in CPPFLAGS will be enough.
3187       REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
3188       LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
3189     else
3190       CFLAGS=$OLD_CFLAGS
3191       CPPFLAGS=$OLD_CPPFLAGS
3192     fi
3193   fi
3194   AC_CHECK_HEADER([Xm/BulletinB.h], [],
3195     [AC_MSG_ERROR([Motif toolkit requested but requirements not found.])])
3198 dnl Use toolkit scroll bars if configured for GTK or X toolkit and either
3199 dnl using Motif or Xaw3d is available, and unless
3200 dnl --with-toolkit-scroll-bars=no was specified.
3202 AH_TEMPLATE(USE_TOOLKIT_SCROLL_BARS,
3203             [Define to 1 if we should use toolkit scroll bars.])dnl
3204 USE_TOOLKIT_SCROLL_BARS=no
3205 if test "${with_toolkit_scroll_bars}" != "no"; then
3206   if test "${USE_X_TOOLKIT}" != "none"; then
3207     if test "${USE_X_TOOLKIT}" = "MOTIF"; then
3208       AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3209       HAVE_XAW3D=no
3210       USE_TOOLKIT_SCROLL_BARS=yes
3211     elif test "${HAVE_XAW3D}" = "yes" || test "${USE_X_TOOLKIT}" = "LUCID"; then
3212       AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3213       USE_TOOLKIT_SCROLL_BARS=yes
3214     fi
3215   elif test "${HAVE_GTK}" = "yes"; then
3216     AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3217     USE_TOOLKIT_SCROLL_BARS=yes
3218   elif test "${HAVE_NS}" = "yes"; then
3219     AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3220     USE_TOOLKIT_SCROLL_BARS=yes
3221   elif test "${HAVE_W32}" = "yes"; then
3222     AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3223     USE_TOOLKIT_SCROLL_BARS=yes
3224   fi
3227 dnl See if XIM is available.
3228 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3229           #include <X11/Xlib.h>
3230           #include <X11/Xresource.h>]],
3231          [[XIMProc  callback;]])],
3232          [HAVE_XIM=yes
3233          AC_DEFINE(HAVE_XIM, 1, [Define to 1 if XIM is available])],
3234          HAVE_XIM=no)
3236 dnl Note this is non-standard.  --with-xim does not control whether
3237 dnl XIM support is compiled in, it only affects the runtime default of
3238 dnl use_xim in xterm.c.
3239 if test "${with_xim}" != "no"; then
3240   AC_DEFINE(USE_XIM, 1,
3241             [Define to 1 to default runtime use of XIM to on.])
3245 if test "${HAVE_XIM}" != "no"; then
3246   late_CFLAGS=$CFLAGS
3247   if test "$GCC" = yes; then
3248     CFLAGS="$CFLAGS --pedantic-errors"
3249   fi
3250   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3251 #include <X11/Xlib.h>
3252 #include <X11/Xresource.h>]],
3253 [[Display *display;
3254 XrmDatabase db;
3255 char *res_name;
3256 char *res_class;
3257 XIMProc  callback;
3258 XPointer *client_data;
3259 #ifndef __GNUC__
3260 /* If we're not using GCC, it's probably not XFree86, and this is
3261    probably right, but we can't use something like --pedantic-errors.  */
3262 extern Bool XRegisterIMInstantiateCallback(Display*, XrmDatabase, char*,
3263                                            char*, XIMProc, XPointer*);
3264 #endif
3265 (void)XRegisterIMInstantiateCallback(display, db, res_name, res_class, callback,
3266    client_data);]])],
3267     [emacs_cv_arg6_star=yes])
3268   AH_TEMPLATE(XRegisterIMInstantiateCallback_arg6,
3269          [Define to the type of the 6th arg of XRegisterIMInstantiateCallback,
3270 either XPointer or XPointer*.])dnl
3271   if test "$emacs_cv_arg6_star" = yes; then
3272     AC_DEFINE(XRegisterIMInstantiateCallback_arg6, [XPointer*])
3273   else
3274     AC_DEFINE(XRegisterIMInstantiateCallback_arg6, [XPointer])
3275   fi
3276   CFLAGS=$late_CFLAGS
3279 # Check for XRender
3280 HAVE_XRENDER=no
3281 if test "${HAVE_X11}" = "yes"; then
3282   AC_COMPILE_IFELSE(
3283     [AC_LANG_PROGRAM(
3284        [[#include <X11/Intrinsic.h>
3285          #include <X11/extensions/Xrender.h>
3286        ]],
3287        [[return !XRenderQueryExtension;]])],
3288     [AC_CHECK_LIB([Xrender], [XRenderQueryExtension], [HAVE_XRENDER=yes])])
3289   if test $HAVE_XRENDER = yes; then
3290     XRENDER_LIBS="-lXrender"
3291     AC_SUBST(XRENDER_LIBS)
3292     AC_DEFINE([HAVE_XRENDER], 1, [Define to 1 if XRender is available.])
3293   fi
3296 HAVE_CAIRO=no
3297 if test "${HAVE_X11}" = "yes"; then
3298   if test "${with_cairo}" != "no"; then
3299     CAIRO_REQUIRED=1.8.0
3300     CAIRO_MODULE="cairo >= $CAIRO_REQUIRED"
3301     EMACS_CHECK_MODULES(CAIRO, $CAIRO_MODULE)
3302     if test $HAVE_CAIRO = yes; then
3303       AC_DEFINE(USE_CAIRO, 1, [Define to 1 if using cairo.])
3304       CFLAGS="$CFLAGS $CAIRO_CFLAGS"
3305       LIBS="$LIBS $CAIRO_LIBS"
3306       AC_SUBST(CAIRO_CFLAGS)
3307       AC_SUBST(CAIRO_LIBS)
3308     else
3309       AC_MSG_WARN([cairo requested but not found.])
3310     fi
3311   fi
3314 ### Start of font-backend (under any platform) section.
3315 # (nothing here yet -- this is a placeholder)
3316 ### End of font-backend (under any platform) section.
3318 ### Start of font-backend (under X11) section.
3319 if test "${HAVE_X11}" = "yes"; then
3320   if test $HAVE_CAIRO = yes; then
3321     dnl Strict linkers fail with
3322     dnl ftfont.o: undefined reference to symbol 'FT_New_Face'
3323     dnl if -lfreetype is not specified.
3324     dnl The following is needed to set FREETYPE_LIBS.
3325     EMACS_CHECK_MODULES([FREETYPE], [freetype2])
3327     test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(cairo requires libfreetype)
3329     EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
3331     test "$HAVE_FONTCONFIG" = "no" && AC_MSG_ERROR(cairo requires libfontconfig)
3332     dnl For the "Does Emacs use" message at the end.
3333     HAVE_XFT=no
3334   else
3335     ## Use -lXft if available, unless '--with-xft=no'.
3336     HAVE_XFT=maybe
3337     if test "x${with_x}" = "xno"; then
3338       with_xft="no";
3339     fi
3341     if test "$with_xft" != no; then
3342       EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
3343       with_xft=$HAVE_FONTCONFIG
3344     fi
3346     if test "x${with_xft}" != "xno"; then
3348       EMACS_CHECK_MODULES([XFT], [xft >= 0.13.0], [], [HAVE_XFT=no])
3349       ## Because xterm.c uses XRenderQueryExtension when XFT is
3350       ## enabled, we also need to link to -lXrender.
3351       if test "$HAVE_XFT" != no && test "$HAVE_XRENDER" != no; then
3352         OLD_CPPFLAGS="$CPPFLAGS"
3353         OLD_CFLAGS="$CFLAGS"
3354         OLD_LIBS="$LIBS"
3355         CPPFLAGS="$CPPFLAGS $XFT_CFLAGS"
3356         CFLAGS="$CFLAGS $XFT_CFLAGS"
3357         LIBS="$XFT_LIBS $LIBS"
3358         AC_CHECK_HEADER(X11/Xft/Xft.h,
3359           AC_CHECK_LIB(Xft, XftFontOpen, HAVE_XFT=yes, , $XFT_LIBS) , ,
3360           [[#include <X11/X.h>]])
3362         if test "${HAVE_XFT}" = "yes"; then
3363           AC_DEFINE(HAVE_XFT, 1, [Define to 1 if you have the Xft library.])
3364             AC_SUBST(XFT_LIBS)
3365           C_SWITCH_X_SITE="$C_SWITCH_X_SITE $XFT_CFLAGS"
3366         fi                        # "${HAVE_XFT}" = "yes"
3367         CPPFLAGS=$OLD_CPPFLAGS
3368         CFLAGS=$OLD_CFLAGS
3369         LIBS=$OLD_LIBS
3370       else
3371       # Make sure XFT is disabled if we found XFT but not XRender
3372         HAVE_XFT=no
3373       fi                          # "$HAVE_XFT" != no
3374     fi                            # "x${with_xft}" != "xno"
3376     if test "$HAVE_XFT" != "yes"; then
3377        dnl For the "Does Emacs use" message at the end.
3378        HAVE_XFT=no
3379        HAVE_FREETYPE=no
3380     else
3381        dnl Strict linkers fail with
3382        dnl ftfont.o: undefined reference to symbol 'FT_New_Face'
3383        dnl if -lfreetype is not specified.
3384        dnl The following is needed to set FREETYPE_LIBS.
3385        EMACS_CHECK_MODULES([FREETYPE], [freetype2])
3387        test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(libxft requires libfreetype)
3388     fi
3389   fi                              # $HAVE_CAIRO != yes
3391   HAVE_LIBOTF=no
3392   if test "${HAVE_FREETYPE}" = "yes"; then
3393     AC_DEFINE(HAVE_FREETYPE, 1,
3394               [Define to 1 if using the freetype and fontconfig libraries.])
3395     OLD_CFLAGS=$CFLAGS
3396     OLD_LIBS=$LIBS
3397     CFLAGS="$CFLAGS $FREETYPE_CFLAGS"
3398     LIBS="$FREETYPE_LIBS $LIBS"
3399     AC_CHECK_FUNCS(FT_Face_GetCharVariantIndex)
3400     CFLAGS=$OLD_CFLAGS
3401     LIBS=$OLD_LIBS
3402     if test "${with_libotf}" != "no"; then
3403       EMACS_CHECK_MODULES([LIBOTF], [libotf])
3404       if test "$HAVE_LIBOTF" = "yes"; then
3405         AC_DEFINE(HAVE_LIBOTF, 1, [Define to 1 if using libotf.])
3406         AC_CHECK_LIB(otf, OTF_get_variation_glyphs,
3407                      HAVE_OTF_GET_VARIATION_GLYPHS=yes,
3408                      HAVE_OTF_GET_VARIATION_GLYPHS=no)
3409         if test "${HAVE_OTF_GET_VARIATION_GLYPHS}" = "yes"; then
3410           AC_DEFINE(HAVE_OTF_GET_VARIATION_GLYPHS, 1,
3411                     [Define to 1 if libotf has OTF_get_variation_glyphs.])
3412         fi
3413         if ! $PKG_CONFIG --atleast-version=0.9.16 libotf; then
3414           AC_DEFINE(HAVE_OTF_KANNADA_BUG, 1,
3415 [Define to 1 if libotf is affected by https://debbugs.gnu.org/28110.])
3416         fi
3417       fi
3418     fi
3419   dnl FIXME should there be an error if HAVE_FREETYPE != yes?
3420   dnl Does the new font backend require it, or can it work without it?
3421   fi
3423   HAVE_M17N_FLT=no
3424   if test "${HAVE_LIBOTF}" = yes; then
3425     if test "${with_m17n_flt}" != "no"; then
3426       EMACS_CHECK_MODULES([M17N_FLT], [m17n-flt])
3427       if test "$HAVE_M17N_FLT" = "yes"; then
3428         AC_DEFINE(HAVE_M17N_FLT, 1, [Define to 1 if using libm17n-flt.])
3429       fi
3430     fi
3431   fi
3432 else # "${HAVE_X11}" != "yes"
3433   HAVE_XFT=no
3434   HAVE_FREETYPE=no
3435   HAVE_LIBOTF=no
3436   HAVE_M17N_FLT=no
3437 fi   # "${HAVE_X11}" != "yes"
3439 HAVE_HARFBUZZ=no
3440 ### On MS-Windows we use hb_font_get_nominal_glyph, which appeared
3441 ### in HarfBuzz version 1.2.3
3442 if test "${HAVE_W32}" = "yes"; then
3443   harfbuzz_required_ver=1.2.3
3444 else
3445   harfbuzz_required_ver=0.9.42
3447 if test "${HAVE_X11}" = "yes" && test "${HAVE_FREETYPE}" = "yes" \
3448         || test "${HAVE_W32}" = "yes"; then
3449   if test "${with_harfbuzz}" != "no"; then
3450     EMACS_CHECK_MODULES([HARFBUZZ], [harfbuzz >= $harfbuzz_required_ver])
3451     if test "$HAVE_HARFBUZZ" = "yes"; then
3452       AC_DEFINE(HAVE_HARFBUZZ, 1, [Define to 1 if using HarfBuzz.])
3453       ### mingw32 and Cygwin-w32 don't use -lharfbuzz, since they load
3454       ### the library dynamically.
3455       if test "${HAVE_W32}" = "yes"; then
3456         HARFBUZZ_LIBS=
3457       fi
3458     fi
3459   fi
3462 ### End of font-backend section.
3464 AC_SUBST(FREETYPE_CFLAGS)
3465 AC_SUBST(FREETYPE_LIBS)
3466 AC_SUBST(FONTCONFIG_CFLAGS)
3467 AC_SUBST(FONTCONFIG_LIBS)
3468 AC_SUBST(HARFBUZZ_CFLAGS)
3469 AC_SUBST(HARFBUZZ_LIBS)
3470 AC_SUBST(LIBOTF_CFLAGS)
3471 AC_SUBST(LIBOTF_LIBS)
3472 AC_SUBST(M17N_FLT_CFLAGS)
3473 AC_SUBST(M17N_FLT_LIBS)
3475 if test "${HAVE_X11}" = "yes"; then
3476   AC_CHECK_HEADER(X11/Xlib-xcb.h,
3477     AC_CHECK_LIB(xcb, xcb_translate_coordinates, HAVE_XCB=yes))
3478   if test "${HAVE_XCB}" = "yes"; then
3479     AC_CHECK_LIB(X11-xcb, XGetXCBConnection, HAVE_X11_XCB=yes)
3480     if test "${HAVE_X11_XCB}" = "yes"; then
3481       AC_DEFINE(USE_XCB, 1,
3482 [Define to 1 if you have the XCB library and X11-XCB library for mixed
3483    X11/XCB programming.])
3484       XCB_LIBS="-lX11-xcb -lxcb"
3485       AC_SUBST(XCB_LIBS)
3486     fi
3487   fi
3490 ### Use -lXpm if available, unless '--with-xpm=no'.
3491 ### mingw32 doesn't use -lXpm, since it loads the library dynamically.
3492 ### The Cygwin-w32 build uses <noX/xpm.h> instead of <X11/xpm.h>, so
3493 ### we need to set LDFLAGS accordingly.
3494 HAVE_XPM=no
3495 LIBXPM=
3496 if test "${HAVE_W32}" = "yes" && test "${opsys}" = "cygwin"; then
3497   if test "${with_xpm}" != "no"; then
3498     SAVE_LDFLAGS="$LDFLAGS"
3499     LDFLAGS="$LDFLAGS -L/usr/lib/noX"
3500     AC_CHECK_HEADER(noX/xpm.h,
3501       [AC_CHECK_LIB(Xpm, XpmReadFileToImage, HAVE_XPM=yes)])
3502     if test "${HAVE_XPM}" = "yes"; then
3503       AC_CACHE_CHECK([for XpmReturnAllocPixels preprocessor define],
3504       [emacs_cv_cpp_xpm_return_alloc_pixels],
3505       [AC_EGREP_CPP(no_return_alloc_pixels,
3506       [#include "noX/xpm.h"
3507 #ifndef XpmReturnAllocPixels
3508 no_return_alloc_pixels
3509 #endif
3510       ], emacs_cv_cpp_xpm_return_alloc_pixels=no,
3511       emacs_cv_cpp_xpm_return_alloc_pixels=yes)])
3513       if test "$emacs_cv_cpp_xpm_return_alloc_pixels" = "no"; then
3514         HAVE_XPM=no
3515         LDFLAGS="$SAVE_LDFLAGS"
3516       fi
3517     fi
3518   fi
3520   if test "${HAVE_XPM}" = "yes"; then
3521     AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
3522     LIBXPM=-lXpm
3523   fi
3526 if test "${HAVE_X11}" = "yes"; then
3527   dnl Avoid Xpm on AIX unless requested, as it crashes; see Bug#17598.
3528   case $opsys,$with_xpm_set,$with_xpm in
3529     aix4-2,set,yes) ;;
3530     aix4-2,*) with_xpm=no;;
3531   esac
3533   if test "${with_xpm}" != "no"; then
3534     AC_CHECK_HEADER(X11/xpm.h,
3535       [AC_CHECK_LIB(Xpm, XpmReadFileToPixmap, HAVE_XPM=yes, , -lX11)])
3536     if test "${HAVE_XPM}" = "yes"; then
3537       AC_CACHE_CHECK([for XpmReturnAllocPixels preprocessor define],
3538       [emacs_cv_cpp_xpm_return_alloc_pixels],
3539       [AC_EGREP_CPP(no_return_alloc_pixels,
3540       [#include "X11/xpm.h"
3541 #ifndef XpmReturnAllocPixels
3542 no_return_alloc_pixels
3543 #endif
3544       ], emacs_cv_cpp_xpm_return_alloc_pixels=no,
3545       emacs_cv_cpp_xpm_return_alloc_pixels=yes)])
3547       if test "$emacs_cv_cpp_xpm_return_alloc_pixels" = "no"; then
3548         HAVE_XPM=no
3549       fi
3550     fi
3551   fi
3553   if test "${HAVE_XPM}" = "yes"; then
3554     AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
3555     LIBXPM=-lXpm
3556   elif test "$opsys,$LUCID_LIBW" = aix4-2,-lXaw; then
3557     dnl AIX -lXaw needs -lXpm linked too; see Bug#17598 Message#152.
3558     LIBXPM=-lXpm
3559   fi
3562 ### FIXME: Perhaps regroup to minimize code duplication due to MinGW's
3563 ### slightly different requirements wrt image libraries (it doesn't
3564 ### use -lXpm because it loads the xpm shared library dynamically at
3565 ### run time).
3566 if test "${opsys}" = "mingw32"; then
3567   if test "${with_xpm}" != "no"; then
3568     AC_CHECK_HEADER(X11/xpm.h, HAVE_XPM=yes, HAVE_XPM=no, [
3569 #define FOR_MSW 1])
3570   fi
3572   if test "${HAVE_XPM}" = "yes"; then
3573     AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
3574   fi
3577 AC_SUBST(LIBXPM)
3579 ### Use -ljpeg if available, unless '--with-jpeg=no'.
3580 HAVE_JPEG=no
3581 LIBJPEG=
3582 if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes" \
3583    || test "${HAVE_NS}" = "yes"; then
3584   if test "${with_jpeg}" != "no"; then
3585     AC_CACHE_CHECK([for jpeglib 6b or later],
3586       [emacs_cv_jpeglib],
3587       [OLD_LIBS=$LIBS
3588        for emacs_cv_jpeglib in yes -ljpeg no; do
3589          case $emacs_cv_jpeglib in
3590            yes) ;;
3591            no) break;;
3592            *) LIBS="$LIBS $emacs_cv_jpeglib";;
3593          esac
3594          AC_LINK_IFELSE(
3595            [AC_LANG_PROGRAM(
3596               [[#undef HAVE_STDLIB_H /* Avoid config.h/jpeglib.h collision.  */
3597                 #include <stdio.h> /* jpeglib.h needs FILE and size_t.  */
3598                 #include <jpeglib.h>
3599                 #include <jerror.h>
3600                 char verify[JPEG_LIB_VERSION < 62 ? -1 : 1];
3601                 struct jpeg_decompress_struct cinfo;
3602               ]],
3603               [[
3604                 jpeg_create_decompress (&cinfo);
3605                 WARNMS (&cinfo, JWRN_JPEG_EOF);
3606                 jpeg_destroy_decompress (&cinfo);
3607               ]])],
3608            [emacs_link_ok=yes],
3609            [emacs_link_ok=no])
3610          LIBS=$OLD_LIBS
3611          test $emacs_link_ok = yes && break
3612        done])
3613     if test "$emacs_cv_jpeglib" != no; then
3614       HAVE_JPEG=yes
3615       AC_DEFINE([HAVE_JPEG], 1,
3616         [Define to 1 if you have the jpeg library (typically -ljpeg).])
3617       ### mingw32 doesn't use -ljpeg, since it loads the library
3618       ### dynamically when needed, and doesn't want a run-time
3619       ### dependency on the jpeglib DLL.
3620       test "$emacs_cv_jpeglib" != yes && test "${opsys}" != "mingw32" \
3621       && LIBJPEG=$emacs_cv_jpeglib
3622     fi
3623   fi
3625 AC_SUBST(LIBJPEG)
3627 HAVE_LCMS2=no
3628 LCMS2_CFLAGS=
3629 LCMS2_LIBS=
3630 if test "${with_lcms2}" != "no"; then
3631   EMACS_CHECK_MODULES([LCMS2], [lcms2])
3633 if test "${HAVE_LCMS2}" = "yes"; then
3634   AC_DEFINE([HAVE_LCMS2], 1, [Define to 1 if you have the lcms2 library (-llcms2).])
3635   ### mingw32 doesn't use -llcms2, since it loads the library dynamically.
3636   if test "${opsys}" = "mingw32"; then
3637      LCMS2_LIBS=
3638   fi
3640 AC_SUBST(LCMS2_CFLAGS)
3641 AC_SUBST(LCMS2_LIBS)
3643 HAVE_ZLIB=no
3644 LIBZ=
3645 if test "${with_zlib}" != "no"; then
3646   OLIBS=$LIBS
3647   AC_SEARCH_LIBS([inflateEnd], [z], [HAVE_ZLIB=yes])
3648   LIBS=$OLIBS
3649   case $ac_cv_search_inflateEnd in
3650     -*) LIBZ=$ac_cv_search_inflateEnd ;;
3651   esac
3653 if test "${HAVE_ZLIB}" = "yes"; then
3654   AC_DEFINE([HAVE_ZLIB], 1, [Define to 1 if you have the zlib library (-lz).])
3655   ### mingw32 doesn't use -lz, since it loads the library dynamically.
3656   if test "${opsys}" = "mingw32"; then
3657      LIBZ=
3658   fi
3660 AC_SUBST(LIBZ)
3662 ### Dynamic modules support
3663 LIBMODULES=
3664 HAVE_MODULES=no
3665 MODULES_OBJ=
3666 NEED_DYNLIB=no
3667 case $opsys in
3668   cygwin|mingw32) MODULES_SUFFIX=".dll" ;;
3669   darwin) MODULES_SUFFIX=".dylib" ;;
3670   *) MODULES_SUFFIX=".so" ;;
3671 esac
3672 case "${opsys}" in
3673   darwin) MODULES_SECONDARY_SUFFIX='.so' ;;
3674   *) MODULES_SECONDARY_SUFFIX='' ;;
3675 esac
3676 if test "${with_modules}" != "no"; then
3677   case $opsys in
3678     gnu|gnu-linux)
3679       LIBMODULES="-ldl"
3680       HAVE_MODULES=yes
3681       ;;
3682     cygwin|mingw32|darwin)
3683       HAVE_MODULES=yes
3684       ;;
3685     *)
3686       # BSD systems have dlopen in libc.
3687       AC_CHECK_FUNC([dlopen], [HAVE_MODULES=yes])
3688       ;;
3689   esac
3691   if test "${HAVE_MODULES}" = no; then
3692     AC_MSG_ERROR([Dynamic modules are not supported on your system])
3693   else
3694     SAVE_LIBS=$LIBS
3695     LIBS="$LIBS $LIBMODULES"
3696     AC_CHECK_FUNCS([dladdr dlfunc])
3697     LIBS=$SAVE_LIBS
3698   fi
3701 if test "${HAVE_MODULES}" = yes; then
3702    MODULES_OBJ="emacs-module.o"
3703    NEED_DYNLIB=yes
3704    AC_DEFINE(HAVE_MODULES, 1, [Define to 1 if dynamic modules are enabled])
3705    AC_DEFINE_UNQUOTED(MODULES_SUFFIX, "$MODULES_SUFFIX",
3706      [System extension for dynamic libraries])
3707    if test -n "${MODULES_SECONDARY_SUFFIX}"; then
3708      AC_DEFINE_UNQUOTED(MODULES_SECONDARY_SUFFIX, "$MODULES_SECONDARY_SUFFIX",
3709        [Alternative system extension for dynamic libraries.])
3710    fi
3712 AC_SUBST(MODULES_OBJ)
3713 AC_SUBST(LIBMODULES)
3714 AC_SUBST(HAVE_MODULES)
3715 AC_SUBST(MODULES_SUFFIX)
3716 AC_SUBST(MODULES_SECONDARY_SUFFIX)
3718 AC_CONFIG_FILES([src/emacs-module.h])
3719 AC_SUBST_FILE([module_env_snippet_25])
3720 AC_SUBST_FILE([module_env_snippet_26])
3721 AC_SUBST_FILE([module_env_snippet_27])
3722 AC_SUBST_FILE([module_env_snippet_28])
3723 module_env_snippet_25="$srcdir/src/module-env-25.h"
3724 module_env_snippet_26="$srcdir/src/module-env-26.h"
3725 module_env_snippet_27="$srcdir/src/module-env-27.h"
3726 module_env_snippet_28="$srcdir/src/module-env-28.h"
3727 emacs_major_version="${PACKAGE_VERSION%%.*}"
3728 AC_SUBST(emacs_major_version)
3730 ### Emacs Lisp native compiler support
3732 AC_DEFUN([libgccjit_smoke_test], [
3733   AC_LANG_SOURCE(
3734     [[#include <libgccjit.h>
3735       #include <stdlib.h>
3736       #include <stdio.h>
3737       int
3738       main (int argc, char **argv)
3739       {
3740         gcc_jit_context *ctxt;
3741         gcc_jit_result *result;
3742         ctxt = gcc_jit_context_acquire ();
3743         if (!ctxt)
3744           exit (1);
3745         gcc_jit_type *int_type =
3746           gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
3747         gcc_jit_function *func =
3748           gcc_jit_context_new_function (ctxt, NULL,
3749                                         GCC_JIT_FUNCTION_EXPORTED,
3750                                         int_type, "foo", 0, NULL, 0);
3751         gcc_jit_block *block = gcc_jit_function_new_block (func, "foo");
3752         gcc_jit_block_end_with_return (
3753           block,
3754           NULL,
3755           gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 1));
3756         result = gcc_jit_context_compile (ctxt);
3757         if (!result)
3758           exit (1);
3759         typedef int (*fn_type) (void);
3760         fn_type foo =
3761           (fn_type)gcc_jit_result_get_code (result, "foo");
3762         if (!foo)
3763           exit (1);
3764         if (foo () != 1)
3765           exit (1);
3766         gcc_jit_context_release (ctxt);
3767         gcc_jit_result_release (result);
3768         return 0;
3769       }]])])
3771 AC_DEFUN([libgccjit_not_found], [
3772   AC_MSG_ERROR([elisp native compiler requested but libgccjit not found.
3773 Please try installing libgccjit or similar package.
3774 If you are sure you want Emacs compiled without elisp native compiler, pass
3775   --without-native-compilation
3776 to configure.])])
3778 AC_DEFUN([libgccjit_dev_not_found], [
3779   AC_MSG_ERROR([elisp native compiler requested but libgccjit header files were
3780 not found.
3781 Please try installing libgccjit-dev or similar package.
3782 If you are sure you want Emacs compiled without elisp native compiler, pass
3783 --without-nativecomp
3784 to configure.])])
3786 AC_DEFUN([libgccjit_broken], [
3787   AC_MSG_ERROR([Installed libgccjit has failed passing the smoke test.
3788 You can verify it yourself compiling:
3789 <https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html>.
3790 Please report the issue to your distribution if libgccjit was installed through
3791 that.
3792 Here instructions on how to compile and install libgccjit from source:
3793 <https://gcc.gnu.org/wiki/JIT>.])])
3795 HAVE_NATIVE_COMP=no
3796 LIBGCCJIT_LIB=
3797 if test "${with_native_compilation}" != "no"; then
3798     if test "${HAVE_PDUMPER}" = no; then
3799        AC_MSG_ERROR(['--with-nativecomp' requires '--with-dumping=pdumper'])
3800     fi
3801     if test "${HAVE_ZLIB}" = no; then
3802        AC_MSG_ERROR(['--with-nativecomp' requires zlib])
3803     fi
3805     # Ensure libgccjit installed by Homebrew can be found.
3806     if test -n "$BREW"; then
3807       BREW_LIBGCCJIT_PREFIX=`$BREW --prefix --installed libgccjit 2>/dev/null`
3808       if test "$BREW_LIBGCCJIT_PREFIX"; then
3809         brew_libdir=`find ${BREW_LIBGCCJIT_PREFIX}/ -name \*.so \
3810                      | sed -e '1!d;s|/[[^/]]*\.so$||'`
3811         CFLAGS="$CFLAGS -I${BREW_LIBGCCJIT_PREFIX}/include"
3812         LDFLAGS="$LDFLAGS -L${brew_libdir} -I${BREW_LIBGCCJIT_PREFIX}/include"
3813       fi
3814     fi
3816     # Check if libgccjit is available.
3817     AC_CHECK_LIB(gccjit, gcc_jit_context_acquire, [], [libgccjit_not_found])
3818     AC_CHECK_HEADERS(libgccjit.h, [], [libgccjit_dev_not_found])
3819     emacs_save_LIBS=$LIBS
3820     LIBS="-lgccjit"
3821     # Check if libgccjit really works.
3822     AC_RUN_IFELSE([libgccjit_smoke_test], [], [libgccjit_broken])
3823     LIBS=$emacs_save_LIBS
3824     HAVE_NATIVE_COMP=yes
3825     case "${opsys}" in
3826       # mingw32 loads the library dynamically.
3827       mingw32) ;;
3828       # OpenBSD doesn't have libdl, all the functions are in libc
3829       netbsd|openbsd)
3830         LIBGCCJIT_LIB="-lgccjit" ;;
3831       *)
3832         LIBGCCJIT_LIB="-lgccjit -ldl" ;;
3833     esac
3834     NEED_DYNLIB=yes
3835     AC_DEFINE(HAVE_NATIVE_COMP, 1, [Define to 1 if native compiler is available.])
3837 AC_DEFINE_UNQUOTED(NATIVE_ELISP_SUFFIX, ".eln",
3838   [System extension for native compiled elisp])
3839 AC_SUBST(HAVE_NATIVE_COMP)
3840 AC_SUBST(LIBGCCJIT_LIB)
3842 DYNLIB_OBJ=
3843 if test "${NEED_DYNLIB}" = yes; then
3844   DYNLIB_OBJ="dynlib.o"
3846 AC_SUBST(DYNLIB_OBJ)
3848 ### Use -lpng if available, unless '--with-png=no'.
3849 HAVE_PNG=no
3850 LIBPNG=
3851 PNG_CFLAGS=
3852 if test "${with_png}" != no; then
3853   # mingw32 loads the library dynamically.
3854   if test "$opsys" = mingw32; then
3855     AC_CHECK_HEADER([png.h], [HAVE_PNG=yes])
3856   elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes" \
3857        || test "${HAVE_NS}" = "yes"; then
3858     EMACS_CHECK_MODULES([PNG], [libpng >= 1.0.0])
3859     if test $HAVE_PNG = yes; then
3860       LIBPNG=$PNG_LIBS
3861     else
3862       # Test old way in case pkg-config doesn't have it (older machines).
3863       AC_MSG_CHECKING([for libpng not configured by pkg-config])
3865       png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` &&
3866       png_ldflags=`(libpng-config --ldflags) 2>&AS_MESSAGE_LOG_FD` || {
3867         # libpng-config does not work; configure by hand.
3868         # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
3869         # in /usr/include/libpng.
3870         if test -r /usr/include/libpng/png.h &&
3871            test ! -r /usr/include/png.h; then
3872           png_cflags=-I/usr/include/libpng
3873         else
3874           png_cflags=
3875         fi
3876         png_ldflags='-lpng'
3877       }
3878       SAVE_CFLAGS=$CFLAGS
3879       SAVE_LIBS=$LIBS
3880       CFLAGS="$CFLAGS $png_cflags"
3881       LIBS="$png_ldflags -lz -lm $LIBS"
3882       AC_LINK_IFELSE(
3883         [AC_LANG_PROGRAM([[#include <png.h>]],
3884            [[return !png_get_channels (0, 0);]])],
3885         [HAVE_PNG=yes
3886          PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"`
3887          LIBPNG=$png_ldflags])
3888       CFLAGS=$SAVE_CFLAGS
3889       LIBS=$SAVE_LIBS
3890       AC_MSG_RESULT([$HAVE_PNG])
3891     fi
3893     # $LIBPNG requires explicit -lz in some cases.
3894     # We don't know what those cases are, exactly, so play it safe and
3895     # append -lz to any nonempty $LIBPNG, unless we're already using LIBZ.
3896     case " $LIBPNG ",$LIBZ in
3897       *' -lz '*, | *' ',?*) ;;
3898       *) LIBPNG="$LIBPNG -lz" ;;
3899     esac
3900   fi
3902 if test $HAVE_PNG = yes; then
3903   AC_DEFINE([HAVE_PNG], [1], [Define to 1 if you have the png library.])
3905   SAVE_CFLAGS=$CFLAGS
3906   CFLAGS="$CFLAGS $PNG_CFLAGS"
3907   AC_CHECK_DECL([png_longjmp],
3908     [],
3909     [AC_DEFINE([PNG_DEPSTRUCT], [],
3910        [Define to empty to suppress deprecation warnings when building
3911         with --enable-gcc-warnings and with libpng versions before 1.5,
3912         which lack png_longjmp.])],
3913     [[#include <png.h>
3914     ]])
3915   CFLAGS=$SAVE_CFLAGS
3917 AC_SUBST(LIBPNG)
3918 AC_SUBST(PNG_CFLAGS)
3920 ### Use -ltiff if available, unless '--with-tiff=no'.
3921 ### mingw32 doesn't use -ltiff, since it loads the library dynamically.
3922 HAVE_TIFF=no
3923 LIBTIFF=
3924 if test "${opsys}" = "mingw32"; then
3925   if test "${with_tiff}" != "no"; then
3926     AC_CHECK_HEADER(tiffio.h, HAVE_TIFF=yes, HAVE_TIFF=no)
3927   fi
3928   if test "${HAVE_TIFF}" = "yes"; then
3929     AC_DEFINE(HAVE_TIFF, 1, [Define to 1 if you have the tiff library (-ltiff).])
3930   fi
3931 elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes" \
3932      || test "${HAVE_NS}" = "yes"; then
3933   if test "${with_tiff}" != "no"; then
3934     AC_CHECK_HEADER(tiffio.h,
3935       [tifflibs="-lz -lm"
3936       # At least one tiff package requires the jpeg library.
3937       if test "${HAVE_JPEG}" = yes; then tifflibs="-ljpeg $tifflibs"; fi
3938       AC_CHECK_LIB(tiff, TIFFGetVersion, HAVE_TIFF=yes, , $tifflibs)])
3939   fi
3941   if test "${HAVE_TIFF}" = "yes"; then
3942     AC_DEFINE(HAVE_TIFF, 1, [Define to 1 if you have the tiff library (-ltiff).])
3943     dnl FIXME -lz -lm, as per libpng?
3944     LIBTIFF=-ltiff
3945   fi
3947 AC_SUBST(LIBTIFF)
3949 ### Use -lgif or -lungif if available, unless '--with-gif=no'.
3950 ### mingw32 doesn't use -lgif/-lungif, since it loads the library dynamically.
3951 HAVE_GIF=no
3952 LIBGIF=
3953 if test "${opsys}" = "mingw32"; then
3954   if test "${with_gif}" != "no"; then
3955     AC_CHECK_HEADER(gif_lib.h, HAVE_GIF=yes, HAVE_GIF=no)
3956   fi
3957   if test "${HAVE_GIF}" = "yes"; then
3958     AC_DEFINE(HAVE_GIF, 1, [Define to 1 if you have a gif (or ungif) library.])
3959   fi
3960 elif test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no" \
3961         || test "${HAVE_W32}" = "yes" || test "${HAVE_NS}" = "yes"; then
3962   AC_CHECK_HEADER(gif_lib.h,
3963 # EGifPutExtensionLast only exists from version libungif-4.1.0b1.
3964 # Earlier versions can crash Emacs, but version 5.0 removes EGifPutExtensionLast.
3965     [AC_CHECK_LIB(gif, GifMakeMapObject, HAVE_GIF=yes,
3966         [AC_CHECK_LIB(gif, EGifPutExtensionLast, HAVE_GIF=yes, HAVE_GIF=maybe)])])
3968   if test "$HAVE_GIF" = yes; then
3969     LIBGIF=-lgif
3970   elif test "$HAVE_GIF" = maybe; then
3971 # If gif_lib.h but no libgif, try libungif.
3972     AC_CHECK_LIB(ungif, EGifPutExtensionLast, HAVE_GIF=yes, HAVE_GIF=no)
3973     test "$HAVE_GIF" = yes && LIBGIF=-lungif
3974   fi
3976   if test "${HAVE_GIF}" = "yes"; then
3977     AC_DEFINE(HAVE_GIF, 1, [Define to 1 if you have a gif (or ungif) library.])
3978   fi
3980 AC_SUBST(LIBGIF)
3982 dnl Check for required libraries.
3983 MISSING=
3984 WITH_IFAVAILABLE=
3985 if test "${HAVE_X11}" = "yes"; then
3986   case $with_xpm,$HAVE_XPM in
3987     no,* | ifavailable,* | *,yes) ;;
3988     *) MISSING="libXpm"
3989        WITH_IFAVAILABLE="--with-xpm=ifavailable";;
3990   esac
3991   case $with_jpeg,$HAVE_JPEG in
3992     no,* | ifavailable,* | *,yes) ;;
3993     *) MISSING="$MISSING libjpeg"
3994        WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-jpeg=ifavailable";;
3995   esac
3996   case $with_png,$HAVE_PNG in
3997     no,* | ifavailable,* | *,yes) ;;
3998     *) MISSING="$MISSING libpng"
3999        WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-png=ifavailable";;
4000   esac
4001   case $with_gif,$HAVE_GIF in
4002     no,* | ifavailable,* | *,yes) ;;
4003     *) MISSING="$MISSING libgif/libungif"
4004        WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-gif=ifavailable";;
4005   esac
4006   case $with_tiff,$HAVE_TIFF in
4007     no,* | ifavailable,* | *,yes) ;;
4008     *) MISSING="$MISSING libtiff"
4009        WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-tiff=ifavailable";;
4010   esac
4012 case $with_gnutls,$HAVE_GNUTLS in
4013   no,* | ifavailable,* | *,yes) ;;
4014   *) MISSING="$MISSING gnutls"
4015      WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-gnutls=ifavailable";;
4016 esac
4017 case $with_json,$HAVE_JSON in
4018   no,* | ifavailable,* | *,yes) ;;
4019   *) MISSING="$MISSING json"
4020      WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-json=ifavailable";;
4021 esac
4022 if test "X${MISSING}" != X; then
4023   # If we have a missing library, and we don't have pkg-config installed,
4024   # the missing pkg-config may be the reason.  Give the user a hint.
4025   if test "X${PKG_CONFIG}" = X; then
4026     AC_MSG_WARN([Unable to locate a usable pkg-config])
4027   fi
4028   AC_MSG_ERROR([The following required libraries were not found:
4029     $MISSING
4030 Maybe some development libraries/packages are missing?
4031 To build anyway, give:
4032     $WITH_IFAVAILABLE
4033 as options to configure.])
4036 ### Use -lgpm if available, unless '--with-gpm=no'.
4037 HAVE_GPM=no
4038 LIBGPM=
4039 if test "${with_gpm}" != "no"; then
4040   AC_CHECK_HEADER(gpm.h,
4041     [AC_CHECK_LIB(gpm, Gpm_Open, HAVE_GPM=yes)])
4043   if test "${HAVE_GPM}" = "yes"; then
4044     AC_DEFINE(HAVE_GPM, 1, [Define to 1 if you have the gpm library (-lgpm).])
4045     LIBGPM=-lgpm
4046   fi
4048 AC_SUBST(LIBGPM)
4050 dnl Check for malloc/malloc.h on darwin
4051 AC_CHECK_HEADERS_ONCE(malloc/malloc.h)
4053 GNUSTEP_CFLAGS=
4054 ### Use NeXTstep API to implement GUI.
4055 if test "${HAVE_NS}" = "yes"; then
4056   AC_DEFINE(HAVE_NS, 1, [Define to 1 if you are using the NeXTstep API, either GNUstep or Cocoa on macOS.])
4057   if test "${NS_IMPL_COCOA}" = "yes"; then
4058     AC_DEFINE(NS_IMPL_COCOA, 1, [Define to 1 if you are using NS windowing under macOS.])
4059   fi
4060   if test "${NS_IMPL_GNUSTEP}" = "yes"; then
4061     AC_DEFINE(NS_IMPL_GNUSTEP, 1, [Define to 1 if you are using NS windowing under GNUstep.])
4062     if test $NS_GNUSTEP_CONFIG != yes; then
4063       # See also .m.o rule in src/Makefile.in.  */
4064       # FIXME: are all these flags really needed?  Document here why.  */
4065       GNUSTEP_CFLAGS="-D_REENTRANT -fPIC -fno-strict-aliasing -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
4066       ## Extra CFLAGS applied to src/*.m files.
4067       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"
4068     fi
4069   fi
4070   OTHER_FILES=ns-app
4073 ### Use session management (-lSM -lICE) if available
4074 HAVE_X_SM=no
4075 LIBXSM=
4076 if test "${HAVE_X11}" = "yes"; then
4077   AC_CHECK_HEADER(X11/SM/SMlib.h,
4078     [AC_CHECK_LIB(SM, SmcOpenConnection, HAVE_X_SM=yes, , -lICE)])
4080   if test "${HAVE_X_SM}" = "yes"; then
4081     AC_DEFINE(HAVE_X_SM, 1, [Define to 1 if you have the SM library (-lSM).])
4082     LIBXSM="-lSM -lICE"
4083   fi
4085 AC_SUBST(LIBXSM)
4087 ### Use XRandr (-lXrandr) if available
4088 HAVE_XRANDR=no
4089 if test "${HAVE_X11}" = "yes"; then
4090   XRANDR_REQUIRED=1.2.2
4091   XRANDR_MODULES="xrandr >= $XRANDR_REQUIRED"
4092   EMACS_CHECK_MODULES([XRANDR], [$XRANDR_MODULES])
4093   if test $HAVE_XRANDR = no; then
4094     # Test old way in case pkg-config doesn't have it (older machines).
4095     # Include Xrender.h by hand to work around bug in older Xrandr.h
4096     # (e.g. RHEL5) and silence (harmless) configure warning (bug#18465).
4097     AC_CHECK_HEADER(X11/extensions/Xrandr.h,
4098       [AC_CHECK_LIB(Xrandr, XRRGetScreenResources, HAVE_XRANDR=yes)],
4099       [], [AC_INCLUDES_DEFAULT
4100 #include <X11/extensions/Xrender.h>])
4101     if test $HAVE_XRANDR = yes; then
4102       XRANDR_LIBS=-lXrandr
4103     fi
4104   fi
4105   if test $HAVE_XRANDR = yes; then
4106     AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you have the XRandr extension.])
4107   fi
4109 AC_SUBST(XRANDR_CFLAGS)
4110 AC_SUBST(XRANDR_LIBS)
4112 ### Use Xinerama (-lXinerama) if available
4113 HAVE_XINERAMA=no
4114 if test "${HAVE_X11}" = "yes"; then
4115   XINERAMA_REQUIRED=1.0.2
4116   XINERAMA_MODULES="xinerama >= $XINERAMA_REQUIRED"
4117   EMACS_CHECK_MODULES([XINERAMA], [$XINERAMA_MODULES])
4118   if test $HAVE_XINERAMA = no; then
4119     # Test old way in case pkg-config doesn't have it (older machines).
4120     AC_CHECK_HEADER(X11/extensions/Xinerama.h,
4121       [AC_CHECK_LIB(Xinerama, XineramaQueryExtension, HAVE_XINERAMA=yes)])
4122     if test $HAVE_XINERAMA = yes; then
4123       XINERAMA_LIBS=-lXinerama
4124     fi
4125   fi
4126   if test $HAVE_XINERAMA = yes; then
4127     AC_DEFINE(HAVE_XINERAMA, 1, [Define to 1 if you have the Xinerama extension.])
4128   fi
4130 AC_SUBST(XINERAMA_CFLAGS)
4131 AC_SUBST(XINERAMA_LIBS)
4133 ### Use Xfixes (-lXfixes) if available
4134 HAVE_XFIXES=no
4135 if test "${HAVE_X11}" = "yes"; then
4136   XFIXES_REQUIRED=4.0.0
4137   XFIXES_MODULES="xfixes >= $XFIXES_REQUIRED"
4138   EMACS_CHECK_MODULES([XFIXES], [$XFIXES_MODULES])
4139   if test $HAVE_XFIXES = no; then
4140     # Test old way in case pkg-config doesn't have it (older machines).
4141     AC_CHECK_HEADER(X11/extensions/Xfixes.h,
4142       [AC_CHECK_LIB(Xfixes, XFixesHideCursor, HAVE_XFIXES=yes)])
4143     if test $HAVE_XFIXES = yes; then
4144       XFIXES_LIBS=-lXfixes
4145     fi
4146   fi
4147   if test $HAVE_XFIXES = yes; then
4148     AC_DEFINE(HAVE_XFIXES, 1, [Define to 1 if you have the Xfixes extension.])
4149   fi
4151 AC_SUBST(XFIXES_CFLAGS)
4152 AC_SUBST(XFIXES_LIBS)
4154 ### Use Xdbe (-lXdbe) if available
4155 HAVE_XDBE=no
4156 if test "${HAVE_X11}" = "yes"; then
4157   if test "${with_xdbe}" != "no"; then
4158     AC_CHECK_HEADER(X11/extensions/Xdbe.h,
4159       [AC_CHECK_LIB(Xext, XdbeAllocateBackBufferName, HAVE_XDBE=yes)],
4160       [],
4161       [#include <X11/Xlib.h>
4162       ])
4163   fi
4164   if test $HAVE_XDBE = yes; then
4165     XDBE_LIBS=-lXext
4166   fi
4167   if test $HAVE_XDBE = yes; then
4168     AC_DEFINE(HAVE_XDBE, 1, [Define to 1 if you have the Xdbe extension.])
4169   fi
4171 AC_SUBST(XDBE_CFLAGS)
4172 AC_SUBST(XDBE_LIBS)
4174 ### Use libxml (-lxml2) if available
4175 ### mingw32 doesn't use -lxml2, since it loads the library dynamically.
4176 HAVE_LIBXML2=no
4177 if test "${with_xml2}" != "no"; then
4178   ### I'm not sure what the version number should be, so I just guessed.
4179   EMACS_CHECK_MODULES([LIBXML2], [libxml-2.0 > 2.6.17])
4180   # Built-in libxml2 on OS X 10.8 lacks libxml-2.0.pc.
4181   if test "${HAVE_LIBXML2}" != "yes" && test "$opsys" = "darwin"; then
4182     SAVE_CPPFLAGS="$CPPFLAGS"
4183     if test -z "$xcsdkdir" -a -n "$XCRUN" -a ! -d /usr/include; then
4184       dnl /usr/include is not found.  Try Xcode SDK dir if it is sane.
4185       xcsdkdir=`$XCRUN --show-sdk-path 2>/dev/null`
4186       case $xcsdkdir in
4187         *[[\\\"\#\$\&\'\`$am_lf\ \      ]]*)
4188         xcsdkdir="" ;;
4189       esac
4190     fi
4191     CPPFLAGS="$CPPFLAGS -isystem${xcsdkdir}/usr/include/libxml2"
4192     AC_CHECK_HEADER(libxml/HTMLparser.h,
4193       [AC_CHECK_DECL(HTML_PARSE_RECOVER, HAVE_LIBXML2=yes, ,
4194                      [#include <libxml/HTMLparser.h>])])
4195     CPPFLAGS="$SAVE_CPPFLAGS"
4196     if test "${HAVE_LIBXML2}" = "yes"; then
4197       LIBXML2_CFLAGS="-isystem${xcsdkdir}/usr/include/libxml2"
4198       LIBXML2_LIBS="-lxml2"
4199     fi
4200   fi
4201   if test "${HAVE_LIBXML2}" = "yes"; then
4202     if test "${opsys}" != "mingw32"; then
4203       AC_CHECK_LIB(xml2, htmlReadMemory, HAVE_LIBXML2=yes, HAVE_LIBXML2=no,
4204         [$LIBXML2_LIBS])
4205     else
4206       LIBXML2_LIBS=""
4207     fi
4208     if test "${HAVE_LIBXML2}" = "yes"; then
4209       AC_DEFINE(HAVE_LIBXML2, 1, [Define to 1 if you have the libxml library (-lxml2).])
4210     else
4211       LIBXML2_LIBS=""
4212       LIBXML2_CFLAGS=""
4213     fi
4214   fi
4216 AC_SUBST(LIBXML2_LIBS)
4217 AC_SUBST(LIBXML2_CFLAGS)
4219 BLESSMAIL_TARGET=
4220 LIBS_MAIL=
4221 if test ! "$with_mailutils"; then
4222   # Check for mail-locking functions in a "mail" library.  Probably this should
4223   # have the same check as for liblockfile below.
4224   AC_CHECK_LIB([mail], [maillock], [have_mail=yes], [have_mail=no])
4225   if test $have_mail = yes; then
4226     LIBS_MAIL=-lmail
4227     AC_DEFINE([HAVE_LIBMAIL], [1],
4228       [Define to 1 if you have the 'mail' library (-lmail).])
4230     OLD_LIBS=$LIBS
4231     LIBS="$LIBS_MAIL $LIBS"
4232     AC_CHECK_FUNCS([touchlock])
4233     LIBS=$OLD_LIBS
4234   fi
4235   dnl Debian, at least:
4236   AC_CHECK_LIB([lockfile], [maillock], [have_lockfile=yes], [have_lockfile=no])
4237   if test $have_lockfile = yes; then
4238      LIBS_MAIL=-llockfile
4239      AC_DEFINE([HAVE_LIBLOCKFILE], [1],
4240        [Define to 1 if you have the 'lockfile' library (-llockfile).])
4241   else
4242     # If we have the shared liblockfile, assume we must use it for mail
4243     # locking (e.g. Debian).  If we couldn't link against liblockfile
4244     # (no liblockfile.a installed), ensure that we don't need to.
4245     dnl This works for files generally, not just executables.
4246     dnl Should we look elsewhere for it?  Maybe examine /etc/ld.so.conf?
4247     AC_CHECK_PROG([liblockfile], [liblockfile.so], [yes], [no],
4248                   [/usr/lib:/lib:/usr/local/lib:$LD_LIBRARY_PATH])
4249     if test "$ac_cv_prog_liblockfile" = yes; then
4250       AC_MSG_ERROR([Shared liblockfile found but can't link against it.
4251 This probably means that movemail could lose mail.
4252 There may be a 'development' package to install containing liblockfile.])
4253     fi
4254   fi
4255   AC_CHECK_HEADERS([maillock.h])
4257   ## Define MAIL_USE_FLOCK (or LOCKF) if the mailer uses flock (or lockf) to
4258   ## interlock access to the mail spool.  The alternative is a lock file named
4259   ## /usr/spool/mail/$USER.lock.
4260   mail_lock=no
4261   case $opsys in
4262     aix4-2) mail_lock="lockf" ;;
4264     gnu|freebsd|dragonfly|netbsd|openbsd|darwin) mail_lock="flock" ;;
4266     ## On GNU/Linux systems, both methods are used by various mail programs.
4267     ## I assume most people are using newer mailers that have heard of flock.
4268     ## Change this if you need to.
4269     ## Debian contains a patch which says: "On Debian/GNU/Linux systems,
4270     ## configure gets the right answers, and that means *NOT* using flock.
4271     ## Using flock is guaranteed to be the wrong thing. See Debian Policy
4272     ## for details." and then uses '#ifdef DEBIAN'.  Unfortunately the
4273     ## Debian maintainer hasn't provided a clean fix for Emacs.
4274     ## movemail.c will use 'maillock' when MAILDIR, HAVE_LIBMAIL and
4275     ## HAVE_MAILLOCK_H are defined, so the following appears to be the
4276     ## correct logic.  -- fx
4277     ## We must check for HAVE_LIBLOCKFILE too, as movemail does.
4278     ## liblockfile is a Free Software replacement for libmail, used on
4279     ## Debian systems and elsewhere. -rfr.
4280     gnu-*)
4281       mail_lock="flock"
4282       if test $have_mail = yes || test $have_lockfile = yes; then
4283         test $ac_cv_header_maillock_h = yes && mail_lock=no
4284       fi ;;
4286     mingw32)
4287       mail_lock="none-needed" ;;
4288   esac
4290   case $mail_lock in
4291     flock) AC_DEFINE([MAIL_USE_FLOCK], [1],
4292              [Define if the mailer uses flock to interlock the mail spool.]);;
4294     lockf) AC_DEFINE([MAIL_USE_LOCKF], [1],
4295              [Define if the mailer uses lockf to interlock the mail spool.]);;
4297     none-needed) ;;
4299     *) BLESSMAIL_TARGET="need-blessmail" ;;
4300   esac
4302 AC_SUBST([BLESSMAIL_TARGET])
4303 AC_SUBST([LIBS_MAIL])
4305 HAVE_SECCOMP=no
4306 AC_CHECK_HEADERS(
4307   [linux/seccomp.h linux/filter.h],
4308   [AC_CHECK_DECLS(
4309     [SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_TSYNC],
4310     [HAVE_SECCOMP=yes], [],
4311     [[
4312     #include <linux/seccomp.h>
4313     ]])])
4314 AC_SUBST([HAVE_SECCOMP])
4316 EMACS_CHECK_MODULES([LIBSECCOMP], [libseccomp >= 2.4.0])
4317 AC_SUBST([HAVE_LIBSECCOMP])
4318 AC_SUBST([LIBSECCOMP_LIBS])
4319 AC_SUBST([LIBSECCOMP_CFLAGS])
4321 OLD_LIBS=$LIBS
4322 LIBS="$LIB_PTHREAD $LIB_MATH $LIBS"
4323 AC_CHECK_FUNCS(accept4 fchdir gethostname \
4324 getrusage get_current_dir_name \
4325 lrand48 random rint trunc \
4326 select getpagesize setlocale newlocale \
4327 getrlimit setrlimit shutdown \
4328 pthread_sigmask strsignal setitimer \
4329 sendto recvfrom getsockname getifaddrs freeifaddrs \
4330 gai_strerror sync \
4331 getpwent endpwent getgrent endgrent \
4332 cfmakeraw cfsetspeed __executable_start log2 pthread_setname_np \
4333 pthread_set_name_np)
4334 LIBS=$OLD_LIBS
4336 if test "$ac_cv_func_pthread_setname_np" = "yes"; then
4337   AC_CACHE_CHECK(
4338    [whether pthread_setname_np takes a single argument],
4339    [emacs_cv_pthread_setname_np_1arg],
4340    [AC_COMPILE_IFELSE(
4341      [AC_LANG_PROGRAM(
4342        [[#include <pthread.h>]],
4343        [[pthread_setname_np ("a");]])],
4344      [emacs_cv_pthread_setname_np_1arg=yes],
4345      [emacs_cv_pthread_setname_np_1arg=no])])
4346   if test "$emacs_cv_pthread_setname_np_1arg" = "yes"; then
4347     AC_DEFINE(
4348       HAVE_PTHREAD_SETNAME_NP_1ARG, 1,
4349       [Define to 1 if pthread_setname_np takes a single argument.])
4350   else
4351     AC_CACHE_CHECK(
4352      [whether pthread_setname_np takes three arguments],
4353      [emacs_cv_pthread_setname_np_3arg],
4354      [AC_COMPILE_IFELSE(
4355        [AC_LANG_PROGRAM(
4356          [[#include <pthread.h>]],
4357          [[pthread_setname_np (0, "%s", "a");]])],
4358        [emacs_cv_pthread_setname_np_3arg=yes],
4359        [emacs_cv_pthread_setname_np_3arg=no])])
4360      if test "$emacs_cv_pthread_setname_np_3arg" = "yes"; then
4361        AC_DEFINE(
4362          HAVE_PTHREAD_SETNAME_NP_3ARG, 1,
4363          [Define to 1 if pthread_setname_np takes three arguments.])
4364      fi
4365   fi
4368 dnl No need to check for posix_memalign if aligned_alloc works.
4369 AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break])
4370 AC_CHECK_DECLS([aligned_alloc], [], [], [[#include <stdlib.h>]])
4372 case $with_unexec,$canonical in
4373   yes,alpha*)
4374     AC_CHECK_DECL([__ELF__], [],
4375       [AC_MSG_ERROR([Non-ELF systems are not supported on this platform.])]);;
4376 esac
4378 # Dump loading
4379 AC_CHECK_FUNCS([posix_madvise])
4381 dnl Cannot use AC_CHECK_FUNCS
4382 AC_CACHE_CHECK([for __builtin_frame_address],
4383   [emacs_cv_func___builtin_frame_address],
4384   [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_frame_address (0);])],
4385      [emacs_cv_func___builtin_frame_address=yes],
4386      [emacs_cv_func___builtin_frame_address=no])])
4387 if test $emacs_cv_func___builtin_frame_address = yes; then
4388   AC_DEFINE([HAVE___BUILTIN_FRAME_ADDRESS], 1,
4389             [Define to 1 if you have the '__builtin_frame_address' function.])
4391 AC_CACHE_CHECK([for __builtin_unwind_init],
4392                emacs_cv_func___builtin_unwind_init,
4393 [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_unwind_init ();])],
4394                 emacs_cv_func___builtin_unwind_init=yes,
4395                 emacs_cv_func___builtin_unwind_init=no)])
4396 if test $emacs_cv_func___builtin_unwind_init = yes; then
4397   AC_DEFINE(HAVE___BUILTIN_UNWIND_INIT, 1,
4398             [Define to 1 if you have the '__builtin_unwind_init' function.])
4401 AC_CHECK_HEADERS_ONCE(sys/un.h)
4403 AC_FUNC_FSEEKO
4405 # UNIX98 PTYs.
4406 AC_CHECK_FUNCS(grantpt)
4408 # PTY-related GNU extensions.
4409 AC_CHECK_FUNCS(getpt posix_openpt)
4411 dnl Run a test program that contains a call to tputs, a call that is
4412 dnl never executed.  This tests whether a pre-'main' dynamic linker
4413 dnl works with the library.  It's too much trouble to actually call
4414 dnl tputs in the test program, due to portability hassles.  When
4415 dnl cross-compiling, assume the test program will run if it links.
4416 AC_DEFUN([tputs_link_source], [
4417   AC_LANG_SOURCE(
4418      [[extern void tputs (const char *, int, int (*)(int));
4419        int main (int argc, char **argv)
4420        {
4421           if (argc == 10000)
4422             tputs (argv[0], 0, 0);
4423           return 0;
4424        }]])
4426 # Check this now, so that we will NOT find the above functions in ncurses.
4427 # That is because we have not set up to link ncurses in lib-src.
4428 # It's better to believe a function is not available
4429 # than to expect to find it in ncurses.
4430 # Also we need tputs and friends to be able to build at all.
4431 AC_CACHE_CHECK([for library containing tputs], [emacs_cv_tputs_lib],
4432 [if test "${opsys}" = "mingw32"; then
4433   emacs_cv_tputs_lib='none required'
4434 else
4435   # curses precedes termcap because of AIX (Bug#9736#35) and OpenIndiana.
4436   tputs_libraries='tinfo ncurses terminfo curses termcap tinfow ncursesw'
4437   for tputs_library in '' $tputs_libraries; do
4438     OLIBS=$LIBS
4439     if test -z "$tputs_library"; then
4440       emacs_cv_tputs_lib='none required'
4441     else
4442       emacs_cv_tputs_lib=-l$tputs_library
4443       LIBS="$emacs_cv_tputs_lib $LIBS"
4444     fi
4445     AC_RUN_IFELSE([tputs_link_source], [], [emacs_cv_tputs_lib=no],
4446       [AC_LINK_IFELSE([tputs_link_source], [], [emacs_cv_tputs_lib=no])])
4447     LIBS=$OLIBS
4448     if test "X$emacs_cv_tputs_lib" != Xno; then
4449       break
4450     fi
4451   done
4452 fi])
4453 AS_CASE(["$emacs_cv_tputs_lib"],
4454   [no], [AC_MSG_ERROR([The required function 'tputs' was not found in any library.
4455 The following libraries were tried (in order):
4456   libtinfo, libncurses, libterminfo, libcurses, libtermcap
4457 Please try installing whichever of these libraries is most appropriate
4458 for your system, together with its header files.
4459 For example, a libncurses-dev(el) or similar package.])],
4460   [-l*], [LIBS_TERMCAP=$emacs_cv_tputs_lib],
4461   [*], [LIBS_TERMCAP=])
4463 ## Use termcap instead of terminfo?
4464 ## Only true for: freebsd < 40000, ms-w32, msdos, netbsd < 599002500.
4465 TERMINFO=yes
4466 ## FIXME?  In the cases below where we unconditionally set
4467 ## LIBS_TERMCAP="-lncurses", this overrides LIBS_TERMCAP = -ltinfo,
4468 ## if that was found above to have tputs.
4469 ## Should we use the gnu* logic everywhere?
4470 case "$opsys" in
4471   ## darwin: Prevents crashes when running Emacs in Terminal.app under 10.2.
4472   ##  The ncurses library has been moved out of the System framework in
4473   ##  Mac OS X 10.2.  So if configure detects it, set the command-line
4474   ##  option to use it.
4475   darwin) LIBS_TERMCAP="-lncurses" ;;
4477   gnu*) test -z "$LIBS_TERMCAP" && LIBS_TERMCAP="-lncurses" ;;
4479   freebsd)
4480     AC_MSG_CHECKING([whether FreeBSD is new enough to use terminfo])
4481     AC_CACHE_VAL(emacs_cv_freebsd_terminfo,
4482     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <osreldate.h>]],
4483 [[#if __FreeBSD_version < 400000
4484 fail;
4485 #endif
4486 ]])], emacs_cv_freebsd_terminfo=yes, emacs_cv_freebsd_terminfo=no)])
4488     AC_MSG_RESULT($emacs_cv_freebsd_terminfo)
4490     if test $emacs_cv_freebsd_terminfo = yes; then
4491       LIBS_TERMCAP="-lncurses"
4492     else
4493       TERMINFO=no
4494       LIBS_TERMCAP="-ltermcap"
4495     fi
4496     ;;
4498   mingw32)
4499     TERMINFO=no
4500     LIBS_TERMCAP=
4501     ;;
4503   netbsd)
4504     if test "x$LIBS_TERMCAP" != "x-lterminfo"; then
4505       TERMINFO=no
4506       LIBS_TERMCAP="-ltermcap"
4507     fi
4508     ;;
4510   openbsd | dragonfly) LIBS_TERMCAP="-lncurses" ;;
4512   ## hpux: Make sure we get select from libc rather than from libcurses
4513   ##  because libcurses on HPUX 10.10 has a broken version of select.
4514   ##  We used to use -lc -lcurses, but this may be cleaner.
4515   ## FIXME?  But TERMINFO = yes on hpux (it used to be explicitly
4516   # set that way, now it uses the default).  Isn't this a contradiction?
4517   hpux*) LIBS_TERMCAP="-ltermcap" ;;
4519 esac
4521 TERMCAP_OBJ=tparam.o
4522 if test $TERMINFO = yes; then
4523   AC_DEFINE(TERMINFO, 1, [Define to 1 if you use terminfo instead of termcap.])
4524   TERMCAP_OBJ=terminfo.o
4525   AC_CACHE_CHECK([whether $LIBS_TERMCAP library defines BC],
4526     [emacs_cv_terminfo_defines_BC],
4527     [OLD_LIBS=$LIBS
4528      LIBS="$LIBS $LIBS_TERMCAP"
4529      AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern char *BC;]], [[return !*BC;]])],
4530        [emacs_cv_terminfo_defines_BC=yes],
4531        [emacs_cv_terminfo_defines_BC=no])
4532      LIBS=$OLD_LIBS])
4533   if test "$emacs_cv_terminfo_defines_BC" = yes; then
4534     AC_DEFINE([TERMINFO_DEFINES_BC], 1, [Define to 1 if the
4535       terminfo library defines the variables BC, PC, and UP.])
4536   fi
4538 if test "X$LIBS_TERMCAP" = "X-lncurses"; then
4539   AC_DEFINE(USE_NCURSES, 1, [Define to 1 if you use ncurses.])
4541 AC_SUBST(LIBS_TERMCAP)
4542 AC_SUBST(TERMCAP_OBJ)
4544 # GNU/Linux-specific timer functions.
4545 AC_CACHE_CHECK([for timerfd interface], [emacs_cv_have_timerfd],
4546   [AC_COMPILE_IFELSE(
4547      [AC_LANG_PROGRAM([[#include <sys/timerfd.h>
4548                       ]],
4549                       [[timerfd_create (CLOCK_REALTIME,
4550                                         TFD_CLOEXEC | TFD_NONBLOCK);
4551                         timerfd_settime (0, TFD_TIMER_ABSTIME, 0, 0);]])],
4552      [emacs_cv_have_timerfd=yes],
4553      [emacs_cv_have_timerfd=no])])
4554 if test "$emacs_cv_have_timerfd" = yes; then
4555   AC_DEFINE([HAVE_TIMERFD], 1,
4556     [Define to 1 if timerfd functions are supported as in GNU/Linux.])
4559 # Alternate stack for signal handlers.
4560 AC_CACHE_CHECK([whether signals can be handled on alternate stack],
4561                [emacs_cv_alternate_stack],
4562   [AC_COMPILE_IFELSE(
4563      [AC_LANG_PROGRAM([[#include <signal.h>
4564                       ]],
4565                       [[stack_t ss;
4566                         struct sigaction sa;
4567                         ss.ss_sp = malloc (SIGSTKSZ);
4568                         ss.ss_size = SIGSTKSZ;
4569                         sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
4570                         sigaltstack (&ss, 0);
4571                         sigaction (SIGSEGV, &sa, 0);]])],
4572      [emacs_cv_alternate_stack=yes],
4573      [emacs_cv_alternate_stack=no])])
4575 # Do we need the Hesiod library to provide the support routines?
4576 dnl FIXME?  Should we be skipping this on Darwin too?
4577 LIBHESIOD=
4578 LIBRESOLV=
4579 if test "$with_hesiod" != no ; then
4580   # Don't set $LIBS here -- see comments above.  FIXME which comments?
4581   resolv=no
4582   AC_CHECK_FUNC(res_send, , [AC_CHECK_FUNC(__res_send, ,
4583      [AC_CHECK_LIB(resolv, res_send, resolv=yes,
4584                   [AC_CHECK_LIB(resolv, __res_send, resolv=yes)])])])
4585   if test "$resolv" = yes ; then
4586     RESOLVLIB=-lresolv
4587   else
4588     RESOLVLIB=
4589   fi
4590   hesiod=no
4591   AC_CHECK_FUNC(hes_getmailhost, , [AC_CHECK_LIB(hesiod, hes_getmailhost,
4592         hesiod=yes, :, $RESOLVLIB)])
4594   if test x"$hesiod" = xyes; then
4595     LIBHESIOD=-lhesiod
4596     LIBRESOLV=$RESOLVLIB
4597   fi
4599 AC_SUBST(LIBHESIOD)
4600 AC_SUBST(LIBRESOLV)
4602 # These tell us which Kerberos-related libraries to use.
4603 COM_ERRLIB=
4604 CRYPTOLIB=
4605 KRB5LIB=
4606 DESLIB=
4607 KRB4LIB=
4609 if test "${with_kerberos}" != no; then
4610   OLD_LIBS=$LIBS
4611   AC_CHECK_LIB(com_err, com_err, have_com_err=yes, have_com_err=no)
4612   if test $have_com_err = yes; then
4613     COM_ERRLIB=-lcom_err
4614     LIBS="$COM_ERRLIB $LIBS"
4615   fi
4616   AC_CHECK_LIB(crypto, mit_des_cbc_encrypt, have_crypto=yes, have_crypto=no)
4617   if test $have_crypto = yes; then
4618     CRYPTOLIB=-lcrypto
4619     LIBS="$CRYPTOLIB $LIBS"
4620   fi
4621   AC_CHECK_LIB(k5crypto, mit_des_cbc_encrypt, have_k5crypto=yes, have_k5crypto=no)
4622   if test $have_k5crypto = yes; then
4623     CRYPTOLIB=-lk5crypto
4624     LIBS="$CRYPTOLIB $LIBS"
4625   fi
4626   AC_CHECK_LIB(krb5, krb5_init_context, have_krb5=yes, have_krb5=no)
4627   if test $have_krb5=yes; then
4628     KRB5LIB=-lkrb5
4629     LIBS="$KRB5LIB $LIBS"
4630   fi
4631   dnl FIXME Simplify.  Does not match 22 logic, thanks to default_off?
4632   if test "${with_kerberos5}" = no; then
4633     AC_CHECK_LIB(des425, des_cbc_encrypt, have_des425=yes, have_des425=no )
4634     if test $have_des425 = yes; then
4635       DESLIB=-ldes425
4636       LIBS="$DESLIB $LIBS"
4637     else
4638       AC_CHECK_LIB(des, des_cbc_encrypt, have_des=yes, have_des=no)
4639       if test $have_des = yes; then
4640         DESLIB=-ldes
4641         LIBS="$DESLIB $LIBS"
4642       fi
4643     fi
4644     AC_CHECK_LIB(krb4, krb_get_cred, have_krb4=yes, have_krb4=no)
4645     if test $have_krb4 = yes; then
4646       KRB4LIB=-lkrb4
4647       LIBS="$KRB4LIB $LIBS"
4648     else
4649       AC_CHECK_LIB(krb, krb_get_cred, have_krb=yes, have_krb=no)
4650       if test $have_krb = yes; then
4651         KRB4LIB=-lkrb
4652         LIBS="$KRB4LIB $LIBS"
4653       fi
4654     fi
4655   fi
4657   if test "${with_kerberos5}" != no; then
4658     AC_CHECK_HEADERS(krb5.h,
4659       [AC_CHECK_MEMBERS([krb5_error.text, krb5_error.e_text],,,
4660                         [#include <krb5.h>])])
4661   else
4662     AC_CHECK_HEADERS(krb.h,,
4663                      [AC_CHECK_HEADERS(kerberosIV/krb.h,,
4664                                        [AC_CHECK_HEADERS(kerberos/krb.h)])])
4665   fi
4666   AC_CHECK_HEADERS(com_err.h)
4667   LIBS=$OLD_LIBS
4670 AC_SUBST(COM_ERRLIB)
4671 AC_SUBST(CRYPTOLIB)
4672 AC_SUBST(KRB5LIB)
4673 AC_SUBST(DESLIB)
4674 AC_SUBST(KRB4LIB)
4676 AC_CHECK_HEADERS(valgrind/valgrind.h)
4678 AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]])
4680 AC_CHECK_FUNCS_ONCE([__lsan_ignore_object sbrk])
4682 AC_FUNC_FORK
4684 dnl AC_CHECK_FUNCS_ONCE wouldn’t be right for snprintf, which needs
4685 dnl the current CFLAGS etc.
4686 AC_CHECK_FUNCS(snprintf)
4688 dnl Check for glib.  This differs from other library checks in that
4689 dnl Emacs need not link to glib unless some other library is already
4690 dnl linking to glib.  Although glib provides no facilities that Emacs
4691 dnl needs for its own purposes, when glib is present Emacs needs to
4692 dnl use primitives like g_main_context_query to avoid clashing with
4693 dnl glib at a low level.
4695 dnl Check this late, since it depends on $GTK_CFLAGS etc.
4696 XGSELOBJ=
4697 AC_CACHE_CHECK([whether GLib is linked in], [emacs_cv_links_glib],
4698 [OLDCFLAGS="$CFLAGS"
4699 OLDLIBS="$LIBS"
4700 CFLAGS="$CFLAGS $GTK_CFLAGS $RSVG_CFLAGS $DBUS_CFLAGS $SETTINGS_CFLAGS"
4701 LIBS="$LIBS $GTK_LIBS $RSVG_LIBS $DBUS_LIBS $SETTINGS_LIBS"
4702 CFLAGS="$CFLAGS $NOTIFY_CFLAGS $CAIRO_CFLAGS"
4703 LIBS="$LIBS $NOTIFY_LIBS $CAIRO_LIBS"
4704 AC_LINK_IFELSE([AC_LANG_PROGRAM(
4705         [[#include <glib.h>
4706         ]],
4707         [[g_print ("Hello world");]])],
4708      [emacs_cv_links_glib=yes],
4709      [emacs_cv_links_glib=no])
4710 CFLAGS="$OLDCFLAGS"
4711 LIBS="$OLDLIBS"])
4712 if test "${emacs_cv_links_glib}" = "yes"; then
4713   AC_DEFINE(HAVE_GLIB, 1, [Define to 1 if GLib is linked in.])
4714   if test "$HAVE_NS" = no;then
4715     XGSELOBJ=xgselect.o
4716   fi
4718 AC_SUBST(XGSELOBJ)
4720 dnl Adapted from Haible's version.
4721 AC_CACHE_CHECK([for nl_langinfo and CODESET], [emacs_cv_langinfo_codeset],
4722   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
4723     [[char *cs = nl_langinfo(CODESET);]])],
4724     [emacs_cv_langinfo_codeset=yes],
4725     [emacs_cv_langinfo_codeset=no])
4726   ])
4727 if test "$emacs_cv_langinfo_codeset" = yes; then
4728   AC_DEFINE([HAVE_LANGINFO_CODESET], 1,
4729     [Define if you have <langinfo.h> and nl_langinfo (CODESET).])
4731   AC_CACHE_CHECK([for nl_langinfo and _NL_PAPER_WIDTH],
4732     [emacs_cv_langinfo__nl_paper_width],
4733     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
4734       [[char *cs = nl_langinfo (_NL_PAPER_WIDTH);]])],
4735       [emacs_cv_langinfo__nl_paper_width=yes],
4736       [emacs_cv_langinfo__nl_paper_width=no])
4737     ])
4738   if test "$emacs_cv_langinfo__nl_paper_width" = yes; then
4739     AC_DEFINE([HAVE_LANGINFO__NL_PAPER_WIDTH], 1,
4740       [Define if you have <langinfo.h> and nl_langinfo (_NL_PAPER_WIDTH).])
4741   fi
4744 AC_TYPE_MBSTATE_T
4746 dnl Fixme: AC_SYS_POSIX_TERMIOS should probably be used, but it's not clear
4747 dnl how the tty code is related to POSIX and/or other versions of termios.
4748 dnl The following looks like a useful start.
4750 dnl AC_SYS_POSIX_TERMIOS
4751 dnl if test $ac_cv_sys_posix_termios = yes; then
4752 dnl    AC_DEFINE(HAVE_TERMIOS, 1, [Define to 1 if you have POSIX-style functions
4753 dnl                                and macros for terminal control.])
4754 dnl    AC_DEFINE(HAVE_TCATTR, 1, [Define to 1 if you have tcgetattr and tcsetattr.])
4755 dnl fi
4757 dnl Turned on June 1996 supposing nobody will mind it.
4758 dnl MinGW emulates passwd database, so this feature doesn't make sense there.
4759 if test "${opsys}" != "mingw32"; then
4760    AC_DEFINE(AMPERSAND_FULL_NAME, 1, [Define to use the convention that &
4761      in the full name stands for the login id.])
4764 dnl Everybody supports this, except MS.
4765 dnl Seems like the kind of thing we should be testing for, though.
4766 ## Note: PTYs are broken on darwin <6.  Use at your own risk.
4767 if test "${opsys}" != "mingw32"; then
4768   AC_DEFINE(HAVE_PTYS, 1, [Define if the system supports pty devices.])
4771 dnl Everybody supports this, except MS-DOS.
4772 dnl Seems like the kind of thing we should be testing for, though.
4773 AC_DEFINE(HAVE_SOCKETS, 1, [Define if the system supports
4774   4.2-compatible sockets.])
4776 AH_TEMPLATE(INTERNAL_TERMINAL, [This is substituted when $TERM is "internal".])
4778 AH_TEMPLATE(NULL_DEVICE, [Name of the file to open to get
4779   a null file, or a data sink.])
4780 if test "${opsys}" = "mingw32"; then
4781   AC_DEFINE(NULL_DEVICE, ["NUL:"])
4782 else
4783   AC_DEFINE(NULL_DEVICE, ["/dev/null"])
4786 if test "${opsys}" = "mingw32"; then
4787   SEPCHAR=';'
4788 else
4789   SEPCHAR=':'
4791 AC_DEFINE_UNQUOTED(SEPCHAR, ['$SEPCHAR'], [Character that separates PATH elements.])
4792 dnl This is for MinGW, and is used in test/Makefile.in.
4793 dnl The MSYS Bash has heuristics for replacing ':' with ';' when it
4794 dnl decides that a command-line argument to be passed to a MinGW program
4795 dnl is a PATH-style list of directories.  But that heuristics plays it
4796 dnl safe, and only does the replacement when it is _absolutely_ sure it
4797 dnl sees a colon-separated list of file names; e.g. ":." is left alone,
4798 dnl which breaks in-tree builds.  So we do this manually instead.
4799 dnl Note that we cannot rely on PATH_SEPARATOR, as that one will always
4800 dnl be computed as ':' in MSYS Bash.
4801 AC_SUBST(SEPCHAR)
4803 dnl Everybody supports this, except MS-DOS.
4804 AC_DEFINE(subprocesses, 1, [Define to enable asynchronous subprocesses.])
4806 AC_DEFINE(USER_FULL_NAME, [pw->pw_gecos], [How to get a user's full name.])
4809 AC_DEFINE(DIRECTORY_SEP, ['/'],
4810   [Character that separates directories in a file name.])
4812 if test "${opsys}" = "mingw32"; then
4813   AC_DEFINE(IS_DEVICE_SEP(_c_), [((_c_) == ':')],
4814     [Returns true if character is a device separator.])
4816   AC_DEFINE(IS_DIRECTORY_SEP(_c_), [((_c_) == '/' || (_c_) == '\\')],
4817     [Returns true if character is a directory separator.])
4819   AC_DEFINE(IS_ANY_SEP(_c_), [(IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP(_c_))],
4820     [Returns true if character is any form of separator.])
4821 else
4822   AC_DEFINE(IS_DEVICE_SEP(_c_), 0,
4823     [Returns true if character is a device separator.])
4825   AC_DEFINE(IS_DIRECTORY_SEP(_c_), [((_c_) == DIRECTORY_SEP)],
4826     [Returns true if character is a directory separator.])
4828   AC_DEFINE(IS_ANY_SEP(_c_), [(IS_DIRECTORY_SEP (_c_))],
4829     [Returns true if character is any form of separator.])
4832 if test "$USE_X_TOOLKIT" != "none"; then
4833   have_editres=yes
4834   case $opsys in
4835     hpux*)
4836       dnl Assar Westerlund <assar@sics.se> says this is necessary
4837       dnl for HP-UX 10.20, and that it works for HP-UX 0 as well.
4838       have_editres=no
4839     ;;
4840   esac
4841   if test "$have_editres" != no && test ! -z "$LIBXMU"; then
4842     OLDLIBS="$LIBS"
4843     dnl See libXmu.a check above.
4844     if test x$HAVE_X11XTR6 = xyes; then
4845       LIBS="-lXt -lSM -lICE $LIBXMU"
4846     else
4847       OTHERLIBS="-lXt -$LIBXMU"
4848     fi
4849     AC_LINK_IFELSE([AC_LANG_PROGRAM(
4850       [[#include <X11/Intrinsic.h>
4851        #include <X11/Xmu/Editres.h>]],
4852       [[_XEditResCheckMessages (0, 0, 0, 0);]])],
4853       [AC_DEFINE([X_TOOLKIT_EDITRES], 1,
4854         [Define to 1 if we should use XEditRes.])])
4855     LIBS=$OLDLIBS
4856   fi
4859 case $opsys in
4860   solaris | unixware )
4861     dnl Some SVr4s don't define NSIG in sys/signal.h for ANSI environments;
4862     dnl instead, there's a system variable _sys_nsig.  Unfortunately, we
4863     dnl need the constant to dimension an array.  So wire in the appropriate
4864     dnl value here.
4865     AC_DEFINE(NSIG_MINIMUM, 32, [Minimum value of NSIG.])
4866     ;;
4867 esac
4869 emacs_broken_SIGIO=no
4871 case $opsys in
4872   dnl SIGIO exists, but the feature doesn't work in the way Emacs needs.
4873   hpux* | nacl | openbsd | solaris | unixware )
4874     emacs_broken_SIGIO=yes
4875     ;;
4877   aix4-2)
4878     dnl On AIX Emacs uses the gmalloc.c malloc implementation.  But given
4879     dnl the way this system works, libc functions that return malloced
4880     dnl memory use the libc malloc implementation. Calling xfree or
4881     dnl xrealloc on the results of such functions results in a crash.
4882     dnl
4883     dnl One solution for this could be to define SYSTEM_MALLOC in configure,
4884     dnl but that does not currently work on this system.
4885     dnl
4886     dnl It is possible to completely override the malloc implementation on
4887     dnl AIX, but that involves putting the malloc functions in a shared
4888     dnl library and setting the MALLOCTYPE environment variable to point to
4889     dnl that shared library.
4890     dnl
4891     dnl Emacs currently calls xrealloc on the results of get_current_dir name,
4892     dnl to avoid a crash just use the Emacs implementation for that function.
4893     dnl
4894     dnl FIXME We could change the AC_CHECK_FUNCS call near the start
4895     dnl of this file, so that we do not check for get_current_dir_name
4896     dnl on AIX.  But that might be fragile if something else ends
4897     dnl up testing for get_current_dir_name as a dependency.
4898     AC_DEFINE(BROKEN_GET_CURRENT_DIR_NAME, 1, [Define if
4899       get_current_dir_name should not be used.])
4900     ;;
4902   freebsd)
4903     dnl Circumvent a bug in FreeBSD.  In the following sequence of
4904     dnl writes/reads on a PTY, read(2) returns bogus data:
4905     dnl
4906     dnl write(2)  1022 bytes
4907     dnl write(2)   954 bytes, get EAGAIN
4908     dnl read(2)   1024 bytes in process_read_output
4909     dnl read(2)     11 bytes in process_read_output
4910     dnl
4911     dnl That is, read(2) returns more bytes than have ever been written
4912     dnl successfully.  The 1033 bytes read are the 1022 bytes written
4913     dnl successfully after processing (for example with CRs added if the
4914     dnl terminal is set up that way which it is here).  The same bytes will
4915     dnl be seen again in a later read(2), without the CRs.
4916     AC_DEFINE(BROKEN_PTY_READ_AFTER_EAGAIN, 1, [Define on FreeBSD to
4917       work around an issue when reading from a PTY.])
4918     ;;
4919 esac
4921 case $opsys in
4922   gnu-* | solaris )
4923     dnl FIXME Can't we test if this exists (eg /proc/$$)?
4924     AC_DEFINE(HAVE_PROCFS, 1, [Define if you have the /proc filesystem.])
4925   ;;
4926 esac
4928 case $opsys in
4929   darwin | dragonfly | freebsd | netbsd | openbsd )
4930     AC_DEFINE(DONT_REOPEN_PTY, 1, [Define if process.c does not need to
4931       close a pty to make it a controlling terminal (it is already a
4932       controlling terminal of the subprocess, because we did ioctl TIOCSCTTY).])
4933   ;;
4934 esac
4936 dnl FIXME Surely we can test for this rather than hard-code it.
4937 case $opsys in
4938   netbsd | openbsd) sound_device="/dev/audio" ;;
4939   *) sound_device="/dev/dsp" ;;
4940 esac
4942 dnl Used in sound.c
4943 AC_DEFINE_UNQUOTED(DEFAULT_SOUND_DEVICE, "$sound_device",
4944   [Name of the default sound device.])
4947 dnl Emacs can read input using SIGIO and buffering characters itself,
4948 dnl or using CBREAK mode and making C-g cause SIGINT.
4949 dnl The choice is controlled by the variable interrupt_input.
4951 dnl Define INTERRUPT_INPUT to make interrupt_input = 1 the default (use SIGIO)
4953 dnl Emacs uses the presence of the USABLE_SIGIO macro
4954 dnl to indicate whether or not signal-driven I/O is possible.  It uses
4955 dnl INTERRUPT_INPUT to decide whether to use it by default.
4957 dnl SIGIO can be used only on systems that implement it (4.2 and 4.3).
4958 dnl CBREAK mode has two disadvantages
4959 dnl 1) At least in 4.2, it is impossible to handle the Meta key properly.
4960 dnl I hear that in system V this problem does not exist.
4961 dnl 2) Control-G causes output to be discarded.
4962 dnl I do not know whether this can be fixed in system V.
4964 dnl Another method of doing input is planned but not implemented.
4965 dnl It would have Emacs fork off a separate process
4966 dnl to read the input and send it to the true Emacs process
4967 dnl through a pipe.
4968 case $opsys in
4969   darwin | gnu-linux | gnu-kfreebsd )
4970     AC_DEFINE(INTERRUPT_INPUT, 1, [Define to read input using SIGIO.])
4971   ;;
4972 esac
4975 dnl If the system's imake configuration file defines 'NeedWidePrototypes'
4976 dnl as 'NO', we must define NARROWPROTO manually.  Such a define is
4977 dnl generated in the Makefile generated by 'xmkmf'.  If we don't define
4978 dnl NARROWPROTO, we will see the wrong function prototypes for X functions
4979 dnl taking float or double parameters.
4980 case $opsys in
4981   cygwin|gnu|gnu-linux|gnu-kfreebsd|freebsd|netbsd|openbsd)
4982     AC_DEFINE(NARROWPROTO, 1, [Define if system's imake configuration
4983       file defines 'NeedWidePrototypes' as 'NO'.])
4984   ;;
4985 esac
4988 dnl Used in process.c, this must be a loop, even if it only runs once.
4989 AH_TEMPLATE(PTY_ITERATION, [How to iterate over PTYs.])
4990 dnl Only used if !PTY_ITERATION.  Iterate from FIRST_PTY_LETTER to z,
4991 dnl trying suffixes 0-16.
4992 AH_TEMPLATE(FIRST_PTY_LETTER, [Letter to use in finding device name of
4993   first PTY, if PTYs are supported.])
4994 AH_TEMPLATE(PTY_OPEN, [How to open a PTY, if non-standard.])
4995 AH_TEMPLATE(PTY_NAME_SPRINTF, [How to get the device name of the control
4996   end of a PTY, if non-standard.])
4997 AH_TEMPLATE(PTY_TTY_NAME_SPRINTF, [How to get device name of the tty
4998   end of a PTY, if non-standard.])
5000 case $opsys in
5001   aix4-2 )
5002     AC_DEFINE(PTY_ITERATION, [int c; for (c = 0; !c ; c++)])
5003     dnl You allocate a pty by opening /dev/ptc to get the master side.
5004     dnl To get the name of the slave side, you just ttyname() the master side.
5005     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");])
5006     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [strcpy (pty_name, ttyname (fd));])
5007     ;;
5009   cygwin )
5010     AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
5011     dnl multi-line AC_DEFINEs are hard. :(
5012     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)])
5013     AC_DEFINE(PTY_NAME_SPRINTF, [])
5014     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
5015     ;;
5017   gnu | qnxnto )
5018     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
5019     ;;
5021   gnu-linux | gnu-kfreebsd | dragonfly | freebsd | openbsd | netbsd | darwin | nacl )
5022     dnl if HAVE_GRANTPT
5023     if test "x$ac_cv_func_grantpt" = xyes; then
5024       AC_DEFINE(UNIX98_PTYS, 1, [Define if the system has Unix98 PTYs.])
5025       AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
5026       dnl Note that grantpt and unlockpt may fork.  We must block SIGCHLD
5027       dnl to prevent sigchld_handler from intercepting the child's death.
5028       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); }])
5029       dnl if HAVE_POSIX_OPENPT
5030       if test "x$ac_cv_func_posix_openpt" = xyes; then
5031         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)])
5032         AC_DEFINE(PTY_NAME_SPRINTF, [])
5033       dnl if HAVE_GETPT
5034       elif test "x$ac_cv_func_getpt" = xyes; then
5035         AC_DEFINE(PTY_OPEN, [fd = getpt ()])
5036         AC_DEFINE(PTY_NAME_SPRINTF, [])
5037       else
5038         AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");])
5039       fi
5040     else
5041       AC_DEFINE(FIRST_PTY_LETTER, ['p'])
5042     fi
5043     ;;
5045   hpux*)
5046     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
5047     AC_DEFINE(PTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);])
5048     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/pty/tty%c%x", c, i);])
5049     ;;
5051   solaris )
5052     dnl On SysVr4, grantpt(3) forks a subprocess, so do not use
5053     dnl O_CLOEXEC when opening the pty, and keep the SIGCHLD handler
5054     dnl from intercepting that death.  If any child but grantpt's should die
5055     dnl within, it should be caught after sigrelse(2).
5056     AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)])
5057     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); }])
5058     ;;
5060   unixware )
5061     dnl Comments are as per solaris.
5062     AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)])
5063     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); }])
5064     ;;
5065 esac
5068 case $opsys in
5069   solaris | unixware )
5070     dnl This change means that we don't loop through allocate_pty too
5071     dnl many times in the (rare) event of a failure.
5072     AC_DEFINE(FIRST_PTY_LETTER, ['z'])
5073     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");])
5074     dnl Push various streams modules onto a PTY channel.  Used in process.c.
5075     AC_DEFINE(SETUP_SLAVE_PTY, [if (ioctl (std_in, I_PUSH, "ptem") == -1) fatal ("ioctl I_PUSH ptem"); if (ioctl (std_in, I_PUSH, "ldterm") == -1) fatal ("ioctl I_PUSH ldterm"); if (ioctl (std_in, I_PUSH, "ttcompat") == -1) fatal ("ioctl I_PUSH ttcompat");], [How to set up a slave PTY, if needed.])
5076     ;;
5077 esac
5080 AH_TEMPLATE(SIGNALS_VIA_CHARACTERS, [Make process_send_signal work by
5081 "typing" a signal character on the pty.])
5083 case $opsys in
5084   dnl Perry Smith <pedz@ddivt1.austin.ibm.com> says this is correct for AIX.
5085   aix4-2 | cygwin | gnu | dragonfly | freebsd | netbsd | openbsd | darwin )
5086     AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1)
5087     ;;
5089   dnl 21 Jun 06: Eric Hanchrow <offby1@blarg.net> says this works.
5090   dnl FIXME Does gnu-kfreebsd have linux/version.h?  It seems unlikely...
5091   gnu-linux | gnu-kfreebsd )
5093     AC_CACHE_CHECK([for signals via characters], [emacs_cv_signals_via_chars],
5094     [AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
5095 #include <linux/version.h>
5096 #if LINUX_VERSION_CODE < 0x20400
5097 # error "Linux version too old"
5098 #endif
5099       ]], [[]])], emacs_cv_signals_via_chars=yes, emacs_cv_signals_via_chars=no)])
5101     test "$emacs_cv_signals_via_chars" = yes && AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1)
5102     ;;
5103 esac
5106 AH_TEMPLATE(TAB3, [Undocumented.])
5108 case $opsys in
5109   darwin) AC_DEFINE(TAB3, OXTABS) ;;
5111   gnu | dragonfly | freebsd | netbsd | openbsd )
5112     AC_DEFINE(TABDLY, OXTABS, [Undocumented.])
5113     AC_DEFINE(TAB3, OXTABS)
5114     ;;
5116   gnu-linux | gnu-kfreebsd )
5117     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
5118 #ifndef __ia64__
5119 # error "not ia64"
5120 #endif
5121       ]], [[]])], AC_DEFINE(GC_MARK_SECONDARY_STACK(),
5122         [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)],
5123         [Mark a secondary stack, like the register stack on the ia64.]), [])
5124     ;;
5126   hpux*)
5127     AC_DEFINE(RUN_TIME_REMAP, 1, [Define if emacs.c needs to call
5128       run_time_remap; for HPUX.])
5129     ;;
5130 esac
5133 dnl This won't be used automatically yet.  We also need to know, at least,
5134 dnl that the stack is continuous.
5135 AH_TEMPLATE(GC_SETJMP_WORKS, [Define if setjmp is known to save all
5136   registers relevant for conservative garbage collection in the jmp_buf.])
5139 case $opsys in
5140   dnl Not all the architectures are tested, but there are Debian packages
5141   dnl for SCM and/or Guile on them, so the technique must work.  See also
5142   dnl comments in alloc.c concerning setjmp and gcc.
5143   dnl Fixme: it's probably safe to just use the GCC conditional below.
5144   gnu-linux | gnu-kfreebsd )
5145     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
5146 #if defined __i386__ || defined __sparc__ || defined __mc68000__ \
5147   || defined __alpha__ || defined __mips__ || defined __s390__ \
5148   || defined __arm__ || defined __powerpc__ || defined __amd64__ \
5149   || defined __ia64__ || defined __sh__
5150 /* ok */
5151 #else
5152 # error "setjmp not known to work on this arch"
5153 #endif
5154     ]], [[]])], AC_DEFINE(GC_SETJMP_WORKS, 1))
5155     ;;
5156 esac
5159 if test x$GCC = xyes; then
5160    dnl GC_SETJMP_WORKS is nearly always appropriate for GCC.
5161    AC_DEFINE(GC_SETJMP_WORKS, 1)
5162 else
5163   case $opsys in
5164     aix* | dragonfly | freebsd | netbsd | openbsd | solaris )
5165       AC_DEFINE(GC_SETJMP_WORKS, 1)
5166       ;;
5167   esac
5168 fi                              dnl GCC?
5170 dnl In a weird quirk, MS runtime uses _setjmp and longjmp.
5171 AC_CACHE_CHECK([for _setjmp], [emacs_cv_func__setjmp],
5172   [AC_LINK_IFELSE(
5173      [AC_LANG_PROGRAM(
5174        [[#include <setjmp.h>
5175          #ifdef __MINGW32__
5176          # define _longjmp longjmp
5177          #endif
5178        ]],
5179        [[jmp_buf j;
5180          if (! _setjmp (j))
5181            _longjmp (j, 1);]])],
5182      [emacs_cv_func__setjmp=yes],
5183      [emacs_cv_func__setjmp=no])])
5184 if test $emacs_cv_func__setjmp = yes; then
5185   AC_DEFINE([HAVE__SETJMP], 1, [Define to 1 if _setjmp and _longjmp work.])
5188 # We need to preserve signal mask to handle C stack overflows.
5189 AC_CACHE_CHECK([for sigsetjmp], [emacs_cv_func_sigsetjmp],
5190   [AC_LINK_IFELSE(
5191      [AC_LANG_PROGRAM(
5192        [[#include <setjmp.h>
5193        ]],
5194        [[sigjmp_buf j;
5195          if (! sigsetjmp (j, 1))
5196            siglongjmp (j, 1);]])],
5197      [emacs_cv_func_sigsetjmp=yes],
5198      [emacs_cv_func_sigsetjmp=no])])
5199 if test $emacs_cv_func_sigsetjmp = yes; then
5200   AC_DEFINE([HAVE_SIGSETJMP], 1,
5201     [Define to 1 if sigsetjmp and siglongjmp work.])
5204 case $emacs_cv_func_sigsetjmp,$emacs_cv_alternate_stack,$opsys in
5205   yes,yes,* | *,*,mingw32)
5206     AC_DEFINE([HAVE_STACK_OVERFLOW_HANDLING], 1,
5207       [Define to 1 if C stack overflow can be handled in some cases.]);;
5208 esac
5210 case $opsys in
5211   solaris | unixware )
5212     dnl TIOCGPGRP is broken in SysVr4, so we can't send signals to PTY
5213     dnl subprocesses the usual way.  But TIOCSIGNAL does work for PTYs,
5214     dnl and this is all we need.
5215     AC_DEFINE(TIOCSIGSEND, TIOCSIGNAL, [Some platforms redefine this.])
5216     ;;
5217 esac
5220 case $opsys in
5221   hpux* | solaris )
5222     dnl Used in xfaces.c.
5223     AC_DEFINE(XOS_NEEDS_TIME_H, 1, [Compensate for a bug in Xos.h on
5224       some systems, where it requires time.h.])
5225     ;;
5226 esac
5229 dnl Define symbols to identify the version of Unix this is.
5230 dnl Define all the symbols that apply correctly.
5231 AH_TEMPLATE(DOS_NT, [Define if the system is MS DOS or MS Windows.])
5232 AH_TEMPLATE(MSDOS, [Define if the system is MS DOS.])
5233 AH_TEMPLATE(USG, [Define if the system is compatible with System III.])
5234 AH_TEMPLATE(USG5_4, [Define if the system is compatible with System V Release 4.])
5236 case $opsys in
5237   aix4-2)
5238     AC_DEFINE(USG, [])
5239     dnl This symbol should be defined on AIX Version 3  ???????
5240     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
5241 #ifndef _AIX
5242 # error "_AIX not defined"
5243 #endif
5244     ]], [[]])], [], AC_DEFINE(_AIX, [], [Define if the system is AIX.]))
5245     ;;
5247   cygwin)
5248     AC_DEFINE(CYGWIN, 1, [Define if the system is Cygwin.])
5249     ;;
5251   darwin)
5252     dnl Not __APPLE__, as this may not be defined on non-macOS Darwin.
5253     dnl Not DARWIN, because Panther and lower CoreFoundation.h use DARWIN to
5254     dnl distinguish macOS from pure Darwin.
5255     AC_DEFINE(DARWIN_OS, [], [Define if the system is Darwin.])
5256     ;;
5258   gnu-linux | gnu-kfreebsd )
5259     AC_DEFINE(USG, [])
5260     AC_DEFINE(GNU_LINUX, [], [Define if ths system is compatible with GNU/Linux.])
5261     ;;
5263   hpux*)
5264     AC_DEFINE(USG, [])
5265     AC_DEFINE(HPUX, [], [Define if the system is HPUX.])
5266     ;;
5268   mingw32)
5269     AC_DEFINE(DOS_NT, [])
5270     AC_DEFINE(WINDOWSNT, 1, [Define if compiling for native MS Windows.])
5271     if test "x$ac_enable_checking" != "x" ; then
5272       AC_DEFINE(EMACSDEBUG, 1, [Define to 1 to enable w32 debug facilities.])
5273     fi
5274     ;;
5276   solaris)
5277     AC_DEFINE(USG, [])
5278     AC_DEFINE(USG5_4, [])
5279     AC_DEFINE(SOLARIS2, [], [Define if the system is Solaris.])
5280     ;;
5282   unixware)
5283     AC_DEFINE(USG, [])
5284     AC_DEFINE(USG5_4, [])
5285     ;;
5286 esac
5288 AC_CACHE_CHECK([for usable FIONREAD], [emacs_cv_usable_FIONREAD],
5289   [case $opsys in
5290      aix4-2 | nacl)
5291        dnl BUILD 9008 - FIONREAD problem still exists in X-Windows.
5292        emacs_cv_usable_FIONREAD=no
5293        ;;
5295      mingw32)
5296        emacs_cv_usable_FIONREAD=yes
5297        ;;
5299      *)
5300        AC_COMPILE_IFELSE(
5301          [AC_LANG_PROGRAM([[#include <sys/types.h>
5302                             #include <sys/ioctl.h>
5303                             #ifdef USG5_4
5304                             # include <sys/filio.h>
5305                             #endif
5306                           ]],
5307                           [[int foo = ioctl (0, FIONREAD, &foo);]])],
5308          [emacs_cv_usable_FIONREAD=yes],
5309          [emacs_cv_usable_FIONREAD=no])
5310        ;;
5311    esac])
5312 if test $emacs_cv_usable_FIONREAD = yes; then
5313   AC_DEFINE([USABLE_FIONREAD], [1], [Define to 1 if FIONREAD is usable.])
5315   if test $emacs_broken_SIGIO = no; then
5316     AC_CACHE_CHECK([for usable SIGIO], [emacs_cv_usable_SIGIO],
5317       [AC_COMPILE_IFELSE(
5318          [AC_LANG_PROGRAM([[#include <fcntl.h>
5319                             #include <signal.h>
5320                           ]],
5321                           [[int foo = SIGIO | F_SETFL | FASYNC;]])],
5322          [emacs_cv_usable_SIGIO=yes],
5323          [emacs_cv_usable_SIGIO=no])],
5324       [emacs_cv_usable_SIGIO=yes],
5325       [emacs_cv_usable_SIGIO=no])
5326     if test $emacs_cv_usable_SIGIO = yes; then
5327       AC_DEFINE([USABLE_SIGIO], [1], [Define to 1 if SIGIO is usable.])
5328     fi
5329   fi
5332 case $opsys in
5333   hpux11)
5334     dnl It works to open the pty's tty in the parent (Emacs), then
5335     dnl close and reopen it in the child.
5336     AC_DEFINE(USG_SUBTTY_WORKS, 1, [Define for USG systems where it
5337       works to open a pty's tty in the parent process, then close and
5338       reopen it in the child.])
5339     ;;
5341   solaris)
5342     AC_DEFINE(_STRUCTURED_PROC, 1, [Needed for system_process_attributes
5343       on Solaris.])
5344     ;;
5345 esac
5347 # Set up the CFLAGS for real compilation, so we can substitute it.
5348 CFLAGS="$REAL_CFLAGS"
5349 CPPFLAGS="$REAL_CPPFLAGS"
5350 LIBS="$REAL_LIBS"
5352 ## Hack to detect a buggy GCC version.
5353 if test "$GCC" = yes && \
5354    $CC --version 2> /dev/null | grep 'gcc.* 4.5.0' >/dev/null; then
5355   case $CFLAGS in
5356     *-fno-optimize-sibling-calls*) ;;
5357     *-O@<:@23@:>@*)
5358       AC_MSG_ERROR([GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS.]);;
5359   esac
5362 version=$PACKAGE_VERSION
5364 copyright="Copyright (C) 2021 Free Software Foundation, Inc."
5365 AC_DEFINE_UNQUOTED(COPYRIGHT, ["$copyright"],
5366   [Short copyright string for this version of Emacs.])
5367 AC_SUBST(copyright)
5369 ### Specify what sort of things we'll be editing into Makefile and config.h.
5370 ### Use configuration here uncanonicalized to avoid exceeding size limits.
5371 AC_SUBST(version)
5372 AC_SUBST(configuration)
5373 ## Unused?
5374 AC_SUBST(canonical)
5375 AC_SUBST(srcdir)
5376 AC_SUBST(prefix)
5377 AC_SUBST(exec_prefix)
5378 AC_SUBST(bindir)
5379 AC_SUBST(datadir)
5380 AC_SUBST(sharedstatedir)
5381 AC_SUBST(libexecdir)
5382 AC_SUBST(mandir)
5383 AC_SUBST(infodir)
5384 AC_SUBST(lispdirrel)
5385 AC_SUBST(lispdir)
5386 AC_SUBST(standardlisppath)
5387 AC_SUBST(locallisppath)
5388 AC_SUBST(lisppath)
5389 AC_SUBST(x_default_search_path)
5390 AC_SUBST(etcdir)
5391 AC_SUBST(archlibdir)
5392 AC_SUBST(etcdocdir)
5393 AC_SUBST(bitmapdir)
5394 AC_SUBST(gamedir)
5395 AC_SUBST(gameuser)
5396 AC_SUBST(gamegroup)
5397 ## FIXME? Nothing uses @LD_SWITCH_X_SITE@.
5398 ## src/Makefile.in did add LD_SWITCH_X_SITE (as a cpp define) to the
5399 ## end of LIBX_BASE, but nothing ever set it.
5400 AC_SUBST(LD_SWITCH_X_SITE)
5401 AC_SUBST(C_SWITCH_X_SITE)
5402 AC_SUBST(GNUSTEP_CFLAGS)
5403 AC_SUBST(CFLAGS)
5404 ## Used in lwlib/Makefile.in.
5405 AC_SUBST(X_TOOLKIT_TYPE)
5406 AC_SUBST(ns_appdir)
5407 AC_SUBST(ns_appbindir)
5408 AC_SUBST(ns_appresdir)
5409 AC_SUBST(ns_appsrc)
5410 AC_SUBST(GNU_OBJC_CFLAGS)
5411 AC_SUBST(OTHER_FILES)
5413 if test -n "${term_header}"; then
5414     AC_DEFINE_UNQUOTED(TERM_HEADER, "${term_header}",
5415         [Define to the header for the built-in window system.])
5418 AC_DEFINE_UNQUOTED(EMACS_CONFIGURATION,  "${canonical}",
5419                    [Define to the canonical Emacs configuration name.])
5420 AC_DEFINE_UNQUOTED(EMACS_CONFIG_OPTIONS, "${emacs_config_options}",
5421                    [Define to the options passed to configure.])
5423 XMENU_OBJ=
5424 XOBJ=
5425 FONT_OBJ=
5426 if test "${HAVE_X_WINDOWS}" = "yes" ; then
5427   AC_DEFINE(HAVE_X_WINDOWS, 1,
5428             [Define to 1 if you want to use the X window system.])
5429   XMENU_OBJ=xmenu.o
5430   XOBJ="xterm.o xfns.o xselect.o xrdb.o xsmfns.o xsettings.o"
5431   FONT_OBJ=xfont.o
5432   if test "$HAVE_CAIRO" = "yes"; then
5433     FONT_OBJ="$FONT_OBJ ftfont.o ftcrfont.o"
5434   elif test "$HAVE_XFT" = "yes"; then
5435     FONT_OBJ="$FONT_OBJ ftfont.o xftfont.o"
5436   elif test "$HAVE_FREETYPE" = "yes"; then
5437     FONT_OBJ="$FONT_OBJ ftfont.o"
5438   fi
5440 if test "${HAVE_HARFBUZZ}" = "yes" ; then
5441   FONT_OBJ="$FONT_OBJ hbfont.o"
5443 AC_SUBST(FONT_OBJ)
5444 AC_SUBST(XMENU_OBJ)
5445 AC_SUBST(XOBJ)
5446 AC_SUBST(FONT_OBJ)
5448 WIDGET_OBJ=
5449 MOTIF_LIBW=
5450 if test "${USE_X_TOOLKIT}" != "none" ; then
5451   WIDGET_OBJ=widget.o
5452   AC_DEFINE(USE_X_TOOLKIT, 1, [Define to 1 if using an X toolkit.])
5453   if test "${USE_X_TOOLKIT}" = "LUCID"; then
5454     AC_DEFINE(USE_LUCID, 1, [Define to 1 if using the Lucid X toolkit.])
5455   elif test "${USE_X_TOOLKIT}" = "MOTIF"; then
5456     AC_DEFINE(USE_MOTIF, 1, [Define to 1 if using the Motif X toolkit.])
5457     MOTIF_LIBW=-lXm
5458     case "$opsys" in
5459       gnu-linux)
5460         ## Paul Abrahams <abrahams at equinox.shaysnet.com> says this is needed.
5461         MOTIF_LIBW="$MOTIF_LIBW -lXpm"
5462         ;;
5464       unixware)
5465         ## Richard Anthony Ryan <ryanr at ellingtn.ftc.nrcs.usda.gov>
5466         ## says -lXimp is needed in UNIX_SV ... 4.2 1.1.2.
5467         MOTIF_LIBW="MOTIF_LIBW -lXimp"
5468         ;;
5470       aix4-2)
5471         ## olson@mcs.anl.gov says -li18n is needed by -lXm.
5472         MOTIF_LIBW="$MOTIF_LIBW -li18n"
5473         ;;
5474     esac
5475     MOTIF_LIBW="$MOTIF_LIBW $LIBXP"
5476   fi
5478 AC_SUBST(WIDGET_OBJ)
5480 TOOLKIT_LIBW=
5481 case "$USE_X_TOOLKIT" in
5482   MOTIF) TOOLKIT_LIBW="$MOTIF_LIBW" ;;
5483   LUCID) TOOLKIT_LIBW="$LUCID_LIBW" ;;
5484   none) test "x$HAVE_GTK" = "xyes" && TOOLKIT_LIBW="$GTK_LIBS" ;;
5485 esac
5486 if test "$HAVE_XWIDGETS" = "yes"; then
5487   TOOLKIT_LIBW="$TOOLKIT_LIBW -lXcomposite"
5489 AC_SUBST(TOOLKIT_LIBW)
5491 if test "${opsys}" != "mingw32"; then
5492   if test "$USE_X_TOOLKIT" = "none"; then
5493     LIBXT_OTHER="\$(LIBXSM)"
5494   else
5495     LIBXT_OTHER="\$(LIBXMU) -lXt \$(LIBXTR6) -lXext"
5496   fi
5498 AC_SUBST(LIBXT_OTHER)
5500 if test "${HAVE_X11}" = "yes" ; then
5501   AC_DEFINE(HAVE_X11, 1,
5502             [Define to 1 if you want to use version 11 of X windows.])
5503   LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
5504 else
5505   LIBX_OTHER=
5507 AC_SUBST(LIBX_OTHER)
5509 HAVE_OLDXMENU=no
5510 if test "$HAVE_GTK" = yes || test "$HAVE_X11" != yes; then
5511   LIBXMENU=
5512 elif test "$USE_X_TOOLKIT" = none; then
5513   HAVE_OLDXMENU=yes
5514   LIBXMENU='$(oldXMenudir)/libXMenu11.a'
5515   AUTODEPEND_PARENTS="$AUTODEPEND_PARENTS oldXMenu"
5516 else
5517   LIBXMENU='$(lwlibdir)/liblw.a'
5518   AUTODEPEND_PARENTS="$AUTODEPEND_PARENTS lwlib"
5520 AC_SUBST(LIBXMENU)
5522 AC_CACHE_CHECK([for struct alignment],
5523   [emacs_cv_struct_alignment],
5524   [AC_COMPILE_IFELSE(
5525      [AC_LANG_PROGRAM([[#include <stddef.h>
5526                         struct s { char c; } __attribute__ ((aligned (8)));
5527                         struct t { char c; struct s s; };
5528                         char verify[offsetof (struct t, s) == 8 ? 1 : -1];
5529                       ]])],
5530      [emacs_cv_struct_alignment=yes],
5531      [emacs_cv_struct_alignment=no])])
5532 if test "$emacs_cv_struct_alignment" = yes; then
5533   AC_DEFINE([HAVE_STRUCT_ATTRIBUTE_ALIGNED], 1,
5534     [Define to 1 if 'struct __attribute__ ((aligned (N)))' aligns the
5535      structure to an N-byte boundary.])
5538 AC_C_TYPEOF
5540 AC_CACHE_CHECK([for statement expressions],
5541   [emacs_cv_statement_expressions],
5542   [AC_COMPILE_IFELSE(
5543      [AC_LANG_PROGRAM([], [[return ({ int x = 5; x-x; });]])],
5544      [emacs_cv_statement_expressions=yes],
5545      [emacs_cv_statement_expressions=no])])
5546 if test "$emacs_cv_statement_expressions" = yes; then
5547   AC_DEFINE([HAVE_STATEMENT_EXPRESSIONS], 1,
5548     [Define to 1 if statement expressions work.])
5551 if test "${GNU_MALLOC}" = "yes" ; then
5552   AC_DEFINE(GNU_MALLOC, 1,
5553             [Define to 1 if you want to use the GNU memory allocator.])
5556 RALLOC_OBJ=
5557 if test "${REL_ALLOC}" = "yes" ; then
5558   AC_DEFINE(REL_ALLOC, 1,
5559             [Define REL_ALLOC if you want to use the relocating allocator for
5560              buffer space.])
5562   test "$system_malloc" != "yes" && RALLOC_OBJ=ralloc.o
5564 AC_SUBST(RALLOC_OBJ)
5566 if test "$opsys" = "cygwin"; then
5567   CYGWIN_OBJ="cygw32.o"
5568   ## Cygwin differs because of its unexec().
5569   PRE_ALLOC_OBJ=
5570   POST_ALLOC_OBJ=lastfile.o
5571 elif test "$opsys" = "mingw32"; then
5572   CYGWIN_OBJ=
5573   PRE_ALLOC_OBJ=
5574   POST_ALLOC_OBJ=lastfile.o
5575 else
5576   CYGWIN_OBJ=
5577   PRE_ALLOC_OBJ=lastfile.o
5578   POST_ALLOC_OBJ=
5580 AC_SUBST(CYGWIN_OBJ)
5581 AC_SUBST(PRE_ALLOC_OBJ)
5582 AC_SUBST(POST_ALLOC_OBJ)
5584 dnl Call this 'FORTIFY_SOUR' so that it sorts before the 'FORTIFY_SOURCE'
5585 dnl verbatim defined above.  The tricky name is apropos, as this hack
5586 dnl makes Fortify go sour!
5587 AH_VERBATIM([FORTIFY_SOUR],
5588 [/* Without the following workaround, Emacs runs slowly on OS X 10.8.
5589    The workaround disables some useful run-time checking, so it
5590    should be conditional to the platforms with the performance bug.
5591    Perhaps Apple will fix this some day; also see m4/extern-inline.m4.  */
5592 #if defined __APPLE__ && defined __GNUC__
5593 # ifndef _DONT_USE_CTYPE_INLINE_
5594 #  define _DONT_USE_CTYPE_INLINE_
5595 # endif
5596 # ifndef _FORTIFY_SOURCE
5597 #  define _FORTIFY_SOURCE 0
5598 # endif
5599 #endif
5602 # If user asks to omit features, disable optional features that gnulib
5603 # might otherwise enable.
5604 if test "$with_features" = no && test "$enable_acl" != yes; then
5605   enable_acl=no
5608 # Configure gnulib.  Although this does not affect CFLAGS or LIBS permanently.
5609 # it temporarily reverts them to their pre-pkg-config values,
5610 # because gnulib needs to work with both src (which uses the
5611 # pkg-config stuff) and lib-src (which does not).  For example, gnulib
5612 # may need to determine whether LIB_CLOCK_GETTIME should contain -lrt,
5613 # and it therefore needs to run in an environment where LIBS does not
5614 # already contain -lrt merely because 'pkg-config --libs' printed '-lrt'
5615 # for some package unrelated to lib-src.
5616 SAVE_CFLAGS=$CFLAGS
5617 SAVE_LIBS=$LIBS
5618 CFLAGS=$pre_PKG_CONFIG_CFLAGS
5619 LIBS="$LIB_PTHREAD $pre_PKG_CONFIG_LIBS"
5620 gl_ASSERT_NO_GNULIB_POSIXCHECK
5621 gl_ASSERT_NO_GNULIB_TESTS
5622 gl_INIT
5623 CFLAGS=$SAVE_CFLAGS
5624 LIBS=$SAVE_LIBS
5626 # timer_getoverrun needs the same libarary as timer_settime
5627 OLD_LIBS=$LIBS
5628 LIBS="$LIB_TIMER_TIME $LIBS"
5629 AC_CHECK_FUNCS(timer_getoverrun)
5630 LIBS=$OLD_LIBS
5632 if test "${opsys}" = "mingw32"; then
5633   CPPFLAGS="$CPPFLAGS -DUSE_CRT_DLL=1 -I \${abs_top_srcdir}/nt/inc"
5634   # Remove unneeded switches from the value of CC that goes to Makefiles
5635   CC=`AS_ECHO(["$CC"]) | sed -e "s,$GCC_TEST_OPTIONS,,"`
5638 case "$opsys" in
5639   aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;;
5641   cygwin) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000" ;;
5643   darwin)
5644    if test "$HAVE_NS" = "yes"; then
5645      libs_nsgui="-framework AppKit"
5646      if test "$NS_IMPL_COCOA" = "yes"; then
5647         libs_nsgui="$libs_nsgui -framework IOKit -framework Carbon -framework IOSurface"
5648      fi
5649    else
5650      libs_nsgui=
5651    fi
5652    LD_SWITCH_SYSTEM_TEMACS=$libs_nsgui
5653    ## The -headerpad option tells ld (see man page) to leave room at the
5654    ## end of the header for adding load commands.  Needed for dumping.
5655    ## 0x1000 is enough for roughly 52 load commands on the x86_64
5656    ## architecture (where they are 78 bytes each). The actual number of
5657    ## load commands added is not consistent but normally ranges from
5658    ## about 14 to about 34. Setting it high gets us plenty of slop and
5659    ## only costs about 1.5K of wasted binary space.
5660    headerpad_extra=1000
5661    if test "$with_unexec" = yes; then
5662      LD_SWITCH_SYSTEM_TEMACS="-fno-pie $LD_SWITCH_SYSTEM_TEMACS -Xlinker -headerpad -Xlinker $headerpad_extra"
5663    fi
5665    ## This is here because src/Makefile.in did some extra fiddling around
5666    ## with LD_SWITCH_SYSTEM.  It seems cleaner to put this in
5667    ## LD_SWITCH_SYSTEM_TEMACS instead,
5668    test "x$LD_SWITCH_SYSTEM" = "x" && test "x$GCC" != "xyes" && \
5669      LD_SWITCH_SYSTEM_TEMACS="-X $LD_SWITCH_SYSTEM_TEMACS"
5670    ;;
5672   ## LD_SWITCH_X_SITE_RPATH is a -rpath option saying where to
5673   ## find X at run-time.
5674   ## When handled by cpp, this was in LD_SWITCH_SYSTEM.  However, at the
5675   ## point where configure sourced the s/*.h file, LD_SWITCH_X_SITE_RPATH
5676   ## had not yet been defined and was expanded to null.  Hence LD_SWITCH_SYSTEM
5677   ## had different values in configure (in ac_link) and src/Makefile.in.
5678   ## It seems clearer therefore to put this piece in LD_SWITCH_SYSTEM_TEMACS.
5679   gnu*) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_RPATH)" ;;
5681   mingw32)
5682    ## Is it any better under MinGW64 to relocate emacs into higher addresses?
5683    case "$canonical" in
5684      x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x400000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
5685      *) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
5686    esac
5687    ## If they want unexec, disable Windows ASLR for the Emacs binary
5688    if test "$with_dumping" = "unexec"; then
5689       case "$canonical" in
5690         x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS -Wl,-disable-dynamicbase -Wl,-disable-high-entropy-va -Wl,-default-image-base-low" ;;
5691         *) LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS -Wl,-disable-dynamicbase" ;;
5692       esac
5693    fi
5694    ;;
5696   *) LD_SWITCH_SYSTEM_TEMACS= ;;
5697 esac
5699 # -no-pie or -nopie fixes a temacs segfault on Gentoo, OpenBSD,
5700 # Ubuntu, and other systems with "hardened" GCC configurations for
5701 # some reason (Bug#18784).  We don't know why this works, but not
5702 # segfaulting is better than segfaulting.  Use ac_c_werror_flag=yes
5703 # when trying the option, otherwise clang keeps warning that it does
5704 # not understand it, and pre-4.6 GCC has a similar problem
5705 # (Bug#20338).  Prefer -no-pie to -nopie, as -no-pie is the
5706 # spelling used by GCC 6.1.0 and later (Bug#24682).
5707 AC_CACHE_CHECK(
5708   [for $CC option to disable position independent executables],
5709   [emacs_cv_prog_cc_no_pie],
5710   [if test $with_unexec = no; then
5711      emacs_cv_prog_cc_no_pie='not needed'
5712    else
5713      emacs_save_c_werror_flag=$ac_c_werror_flag
5714      emacs_save_LDFLAGS=$LDFLAGS
5715      ac_c_werror_flag=yes
5716      for emacs_cv_prog_cc_no_pie in -no-pie -nopie no; do
5717        test $emacs_cv_prog_cc_no_pie = no && break
5718        LDFLAGS="$emacs_save_LDFLAGS $emacs_cv_prog_cc_no_pie"
5719        AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [break])
5720      done
5721      ac_c_werror_flag=$emacs_save_c_werror_flag
5722      LDFLAGS=$emacs_save_LDFLAGS
5723    fi])
5724 case $emacs_cv_prog_cc_no_pie in
5725   -*)
5726     LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS $emacs_cv_prog_cc_no_pie"
5727     ;;
5728 esac
5730 if test x$ac_enable_profiling != x ; then
5731   case $opsys in
5732     *freebsd | gnu-linux) ;;
5733     *) LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS -pg" ;;
5734   esac
5737 LD_SWITCH_SYSTEM_TEMACS="$LDFLAGS_NOCOMBRELOC $LD_SWITCH_SYSTEM_TEMACS"
5739 AC_SUBST(LD_SWITCH_SYSTEM_TEMACS)
5741 ## Common for all window systems
5742 if test "$window_system" != "none"; then
5743   AC_DEFINE(HAVE_WINDOW_SYSTEM, 1, [Define if you have a window system.])
5744   AC_DEFINE(POLL_FOR_INPUT, 1, [Define if you poll periodically to detect C-g.])
5745   WINDOW_SYSTEM_OBJ="fontset.o fringe.o image.o"
5748 AC_SUBST(WINDOW_SYSTEM_OBJ)
5750 AH_TOP([/* GNU Emacs site configuration template file.
5752 Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2021
5753   Free Software Foundation, Inc.
5755 This file is part of GNU Emacs.
5757 GNU Emacs is free software: you can redistribute it and/or modify
5758 it under the terms of the GNU General Public License as published by
5759 the Free Software Foundation, either version 3 of the License, or (at
5760 your option) any later version.
5762 GNU Emacs is distributed in the hope that it will be useful,
5763 but WITHOUT ANY WARRANTY; without even the implied warranty of
5764 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5765 GNU General Public License for more details.
5767 You should have received a copy of the GNU General Public License
5768 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
5771 /* No code in Emacs #includes config.h twice, but some bits of code
5772    intended to work with other packages as well (like gmalloc.c)
5773    think they can include it as many times as they like.  */
5774 #ifndef EMACS_CONFIG_H
5775 #define EMACS_CONFIG_H
5776 ])dnl
5778 AH_BOTTOM([#include <conf_post.h>
5780 #endif /* EMACS_CONFIG_H */
5783 Local Variables:
5784 mode: c
5785 End:
5787 ])dnl
5789 #### Report on what we decided to do.
5790 #### Report GTK as a toolkit, even if it doesn't use Xt.
5791 #### It makes printing result more understandable as using GTK sets
5792 #### toolkit_scroll_bars to yes by default.
5793 if test "${HAVE_GTK}" = "yes"; then
5794   USE_X_TOOLKIT="$USE_GTK_TOOLKIT"
5797 if test $USE_ACL -ne 0; then
5798   ACL_SUMMARY="yes $LIB_ACL"
5799 else
5800   ACL_SUMMARY=no
5803 if test -z "$GMP_H"; then
5804   HAVE_GMP=yes
5805 else
5806   HAVE_GMP=no
5809 emacs_standard_dirs='Standard dirs'
5810 AS_ECHO(["
5811 Configured for '${canonical}'.
5813   Where should the build process find the source code?    ${srcdir}
5814   What compiler should emacs be built with?               ${CC} ${CFLAGS}
5815   Should Emacs use the GNU version of malloc?             ${GNU_MALLOC}${GNU_MALLOC_reason}
5816   Should Emacs use a relocating allocator for buffers?    ${REL_ALLOC}
5817   Should Emacs use mmap(2) for buffer allocation?         $use_mmap_for_buffers
5818   What window system should Emacs use?                    ${window_system}
5819   What toolkit should Emacs use?                          ${USE_X_TOOLKIT}
5820   Where do we find X Windows header files?                ${x_includes:-$emacs_standard_dirs}
5821   Where do we find X Windows libraries?                   ${x_libraries:-$emacs_standard_dirs}"])
5823 #### Please respect alphabetical ordering when making additions.
5824 optsep=
5825 emacs_config_features=
5826 for opt in ACL CAIRO DBUS FREETYPE GCONF GIF GLIB GMP GNUTLS GPM GSETTINGS \
5827  HARFBUZZ IMAGEMAGICK JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 \
5828  M17N_FLT MODULES NATIVE_COMP NOTIFY NS OLDXMENU PDUMPER PNG RSVG SECCOMP \
5829  SOUND THREADS TIFF \
5830  TOOLKIT_SCROLL_BARS UNEXEC X11 XAW3D XDBE XFT XIM XPM XWIDGETS X_TOOLKIT \
5831  ZLIB; do
5833     case $opt in
5834       PDUMPER) val=${with_pdumper} ;;
5835       UNEXEC) val=${with_unexec} ;;
5836       GLIB) val=${emacs_cv_links_glib} ;;
5837       NOTIFY|ACL) eval val=\${${opt}_SUMMARY} ;;
5838       TOOLKIT_SCROLL_BARS|X_TOOLKIT) eval val=\${USE_$opt} ;;
5839       THREADS) val=${threads_enabled} ;;
5840       *) eval val=\${HAVE_$opt} ;;
5841     esac
5842     case x$val in
5843       xno|xnone|x) continue ;;
5844     esac
5845     case $opt in
5846       X_TOOLKIT)
5847         case $val in
5848           GTK*|LUCID|MOTIF) opt=$val ;;
5849           *) continue ;;
5850         esac
5851       ;;
5852       NOTIFY)
5853         case $val in
5854           *lkqueue*) opt="$opt LIBKQUEUE" ;;
5855           *kqueue*) opt="$opt KQUEUE" ;;
5856           *inotify*) opt="$opt INOTIFY" ;;
5857           *gfile*) opt="$opt GFILENOTIFY" ;;
5858           *w32*) opt="$opt W32NOTIFY" ;;
5859         esac
5860       ;;
5861     esac
5862     AS_VAR_APPEND([emacs_config_features], ["$optsep$opt"])
5863     optsep=' '
5864 done
5865 AC_DEFINE_UNQUOTED(EMACS_CONFIG_FEATURES, "${emacs_config_features}",
5866   [Summary of some of the main features enabled by configure.])
5868 AS_ECHO(["  Does Emacs use -lXaw3d?                                 ${HAVE_XAW3D}
5869   Does Emacs use -lXpm?                                   ${HAVE_XPM}
5870   Does Emacs use -ljpeg?                                  ${HAVE_JPEG}
5871   Does Emacs use -ltiff?                                  ${HAVE_TIFF}
5872   Does Emacs use a gif library?                           ${HAVE_GIF} $LIBGIF
5873   Does Emacs use a png library?                           ${HAVE_PNG} $LIBPNG
5874   Does Emacs use -lrsvg-2?                                ${HAVE_RSVG}
5875   Does Emacs use cairo?                                   ${HAVE_CAIRO}
5876   Does Emacs use -llcms2?                                 ${HAVE_LCMS2}
5877   Does Emacs use imagemagick?                             ${HAVE_IMAGEMAGICK}
5878   Does Emacs use native APIs for images?                  ${NATIVE_IMAGE_API}
5879   Does Emacs support sound?                               ${HAVE_SOUND}
5880   Does Emacs use -lgpm?                                   ${HAVE_GPM}
5881   Does Emacs use -ldbus?                                  ${HAVE_DBUS}
5882   Does Emacs use -lgconf?                                 ${HAVE_GCONF}
5883   Does Emacs use GSettings?                               ${HAVE_GSETTINGS}
5884   Does Emacs use a file notification library?             ${NOTIFY_SUMMARY}
5885   Does Emacs use access control lists?                    ${ACL_SUMMARY}
5886   Does Emacs use -lselinux?                               ${HAVE_LIBSELINUX}
5887   Does Emacs use -lgnutls?                                ${HAVE_GNUTLS}
5888   Does Emacs use -lxml2?                                  ${HAVE_LIBXML2}
5889   Does Emacs use -lfreetype?                              ${HAVE_FREETYPE}
5890   Does Emacs use HarfBuzz?                                ${HAVE_HARFBUZZ}
5891   Does Emacs use -lm17n-flt?                              ${HAVE_M17N_FLT}
5892   Does Emacs use -lotf?                                   ${HAVE_LIBOTF}
5893   Does Emacs use -lxft?                                   ${HAVE_XFT}
5894   Does Emacs use -lsystemd?                               ${HAVE_LIBSYSTEMD}
5895   Does Emacs use -ljansson?                               ${HAVE_JSON}
5896   Does Emacs use the GMP library?                         ${HAVE_GMP}
5897   Does Emacs directly use zlib?                           ${HAVE_ZLIB}
5898   Does Emacs have dynamic modules support?                ${HAVE_MODULES}
5899   Does Emacs use toolkit scroll bars?                     ${USE_TOOLKIT_SCROLL_BARS}
5900   Does Emacs support Xwidgets?                            ${HAVE_XWIDGETS}
5901   Does Emacs have threading support in lisp?              ${threads_enabled}
5902   Does Emacs support the portable dumper?                 ${with_pdumper}
5903   Does Emacs support legacy unexec dumping?               ${with_unexec}
5904   Which dumping strategy does Emacs use?                  ${with_dumping}
5905   Does Emacs have native lisp compiler?                   ${HAVE_NATIVE_COMP}
5908 if test -n "${EMACSDATA}"; then
5909    AS_ECHO(["  Environment variable EMACSDATA set to:                  $EMACSDATA"])
5911 if test -n "${EMACSDOC}"; then
5912    AS_ECHO(["  Environment variable EMACSDOC set to:                   $EMACSDOC"])
5915 echo
5917 if test "$HAVE_NS" = "yes"; then
5918    echo
5919    AS_ECHO(["Run '${MAKE-make}' to build Emacs, then run 'src/emacs' to test it.
5920 Run '${MAKE-make} install' in order to build an application bundle.
5921 The application will go to nextstep/Emacs.app and can be run or moved
5922 from there."])
5923    if test "$EN_NS_SELF_CONTAINED" = "yes"; then
5924       echo "The application will be fully self-contained."
5925     else
5926       AS_ECHO(["The lisp resources for the application will be installed under ${prefix}.
5927 You may need to run \"${MAKE-make} install\" with sudo.  The application will fail
5928 to run if these resources are not installed."])
5929    fi
5930    echo
5933 case $opsys,$emacs_uname_r in
5934   cygwin,1.5.*)
5935     AC_MSG_WARN([[building Emacs on Cygwin 1.5 is not supported.]])
5936            echo
5937            ;;
5938   cygwin,3.0.[[0-7]]'('* | cygwin,3.1.[[0-2]]'('*)
5939     AC_DEFINE([HAVE_CYGWIN_O_PATH_BUG], 1,
5940       [Define to 1 if opening a FIFO, socket, or symlink with O_PATH is buggy.]);;
5941 esac
5943 # Remove any trailing slashes in these variables.
5944 case $prefix in
5945   */) prefix=`AS_DIRNAME(["$prefix."])`;;
5946 esac
5947 case $exec_prefix in
5948   */) exec_prefix=`AS_DIRNAME(["$exec_prefix."])`;;
5949 esac
5951 if test "$HAVE_NS" = "yes"; then
5952   if test "$NS_IMPL_GNUSTEP" = yes; then
5953     AC_CONFIG_FILES([nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist:nextstep/templates/Info-gnustep.plist.in \
5954       nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop:nextstep/templates/Emacs.desktop.in])
5955     ns_check_file=Resources/Info-gnustep.plist
5956   else
5957     AC_CONFIG_FILES([nextstep/Cocoa/Emacs.base/Contents/Info.plist:nextstep/templates/Info.plist.in \
5958       nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings:nextstep/templates/InfoPlist.strings.in])
5959     ns_check_file=Contents/Info.plist
5960   fi
5961   AC_SUBST(ns_check_file)
5964 AC_CONFIG_FILES([Makefile lib/gnulib.mk])
5966 dnl config.status treats $srcdir specially, so I think this is ok...
5967 AC_CONFIG_FILES([$srcdir/doc/man/emacs.1])
5969 m4_define([subdir_makefiles],
5970   [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])
5971 SUBDIR_MAKEFILES="subdir_makefiles"
5972 AC_CONFIG_FILES(subdir_makefiles)
5974 dnl The test/ directory is missing if './make-dist --no-tests' was used.
5975 opt_makefile=test/Makefile
5976 if test -f "$srcdir/$opt_makefile.in"; then
5977   SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
5978   dnl Again, it's best not to use a variable.  Though you can add
5979   dnl ", [], [opt_makefile='$opt_makefile']" and it should work.
5980   AC_CONFIG_FILES([test/Makefile])
5984 dnl The admin/ directory used to be excluded from tarfiles.
5985 if test -d $srcdir/admin; then
5986   SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES admin/charsets/Makefile admin/unidata/Makefile admin/grammars/Makefile"
5987   AC_CONFIG_FILES([admin/charsets/Makefile])
5988   AC_CONFIG_FILES([admin/unidata/Makefile])
5989   AC_CONFIG_FILES([admin/grammars/Makefile])
5990 fi                              dnl -d admin
5993 SUBDIR_MAKEFILES_IN=`echo " ${SUBDIR_MAKEFILES}" | sed -e 's| | $(srcdir)/|g' -e 's|Makefile|Makefile.in|g'`
5995 AC_SUBST(SUBDIR_MAKEFILES_IN)
5997 dnl You might wonder (I did) why epaths.h is generated by running make,
5998 dnl rather than just letting configure generate it from epaths.in.
5999 dnl One reason is that the various paths are not fully expanded (see above);
6000 dnl e.g., gamedir='${localstatedir}/games/emacs'.
6001 dnl Secondly, the GNU Coding standards require that one should be able
6002 dnl to run 'make prefix=/some/where/else' and override the values set
6003 dnl by configure.  This also explains the 'move-if-change' test and
6004 dnl the use of force in the 'epaths-force' rule in Makefile.in.
6005 AC_CONFIG_COMMANDS([src/epaths.h], [
6006 if test "${opsys}" = "mingw32"; then
6007   ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-w32
6008 else
6009   ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force
6010 fi || AC_MSG_ERROR(['src/epaths.h' could not be made.])
6011 ], [GCC="$GCC" CPPFLAGS="$CPPFLAGS" opsys="$opsys"])
6013 dnl NB we have to cheat and use the ac_... version because abs_top_srcdir
6014 dnl is not yet set, sigh.  Or we could use ../$srcdir/src/.gdbinit,
6015 dnl or a symlink?
6016 AC_CONFIG_COMMANDS([src/.gdbinit], [
6017 if test ! -f src/.gdbinit && test -f "$srcdir/src/.gdbinit"; then
6018   AS_ECHO(["source $ac_abs_top_srcdir/src/.gdbinit"]) > src/.gdbinit
6022 dnl Perhaps this would be better named doc-emacs-emacsver.texi?
6023 dnl See comments for etc-refcards-emacsver.tex.
6024 dnl Since we get a doc/emacs directory generated anyway, for the Makefile,
6025 dnl it is not quite the same.  But we are generating in $srcdir.
6026 AC_CONFIG_COMMANDS([doc/emacs/emacsver.texi], [
6027 ${MAKE-make} -s --no-print-directory -C doc/emacs doc-emacsver || \
6028 AC_MSG_ERROR(['doc/emacs/emacsver.texi' could not be made.])
6031 dnl If we give this the more natural name, etc/refcards/emacsver.texi,
6032 dnl then a directory etc/refcards is created in the build directory,
6033 dnl which is probably harmless, but confusing (in out-of-tree builds).
6034 dnl (If we were to generate etc/refcards/Makefile, this might change.)
6035 dnl It is really $srcdir/etc/refcards/emacsver.tex that we generate.
6036 AC_CONFIG_COMMANDS([etc-refcards-emacsver.tex], [
6037 ${MAKE-make} -s MAKEFILE_NAME=do-not-make-Makefile etc-emacsver || \
6038 AC_MSG_ERROR(['etc/refcards/emacsver.tex' could not be made.])
6041 if test $AUTO_DEPEND = yes; then
6042    for dir in $AUTODEPEND_PARENTS; do
6043      AS_MKDIR_P([$dir/deps])
6044    done
6046 if $gl_gnulib_enabled_dynarray || $gl_gnulib_enabled_scratch_buffer; then
6047   AS_MKDIR_P([lib/malloc])
6048   if test $AUTO_DEPEND = yes; then
6049     AS_MKDIR_P([lib/deps/malloc])
6050   fi
6053 AC_OUTPUT
6055 if test ! "$with_mailutils"; then
6056   if test "$with_pop" = yes; then
6057     AC_MSG_WARN([This configuration installs a 'movemail' program
6058 that retrieves POP3 email via only insecure channels.
6059 To omit insecure POP3, you can use '$0 --without-pop'.])
6060   elif test "$with_pop" = no-by-default; then
6061     AC_MSG_WARN([This configuration installs a 'movemail' program
6062 that does not retrieve POP3 email.  By default, Emacs 25 and earlier
6063 installed a 'movemail' program that retrieved POP3 email via only
6064 insecure channels, a practice that is no longer recommended but that
6065 you can continue to support by using '$0 --with-pop'.])
6066   fi
6068   case $opsys in
6069     mingw32)
6070       # Don't suggest GNU Mailutils, as it hasn't been ported.
6071       ;;
6072     *)
6073       emacs_fix_movemail="use '$0 --with-mailutils'"
6074       case `(movemail --version) 2>/dev/null` in
6075         *Mailutils*) ;;
6076         *) emacs_fix_movemail="install GNU Mailutils
6077 <https://mailutils.org> and $emacs_fix_movemail";;
6078       esac
6079       AC_MSG_NOTICE([You might want to $emacs_fix_movemail.]);;
6080   esac
6083 if test "${HAVE_XFT}" = yes; then
6084   AC_MSG_WARN([This configuration uses libXft, which has a number of
6085     font rendering issues, and is being considered for removal in the
6086     next release of Emacs.  Please consider using Cairo graphics +
6087     HarfBuzz text shaping instead (they are auto-detected if the
6088     relevant development headers are installed).])
6091 if test "${HAVE_CAIRO}" = "yes" && test "${HAVE_HARFBUZZ}" = no; then
6092   AC_MSG_WARN([This configuration uses the Cairo graphics library,
6093     but not the HarfBuzz font shaping library (minimum version $harfbuzz_required_ver).
6094     We recommend the use of HarfBuzz when using Cairo, please install
6095     appropriate HarfBuzz development packages.])
6098 # Let plain 'make' work.
6099 test "$MAKE" = make || test -f makefile || cat >makefile <<EOF
6100 .POSIX:
6101 MAKE = $MAKE
6102 all:
6103         \$(MAKE) -f Makefile \$?
6104 .DEFAULT:
6105         \$(MAKE) -f Makefile \$<