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