Merge from origin/emacs-30
[emacs.git] / configure.ac
blob8a5ba7db3d1b4012d3f1c4f153e108e46a63b3b8
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-2024 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], [31.0.50], [bug-gnu-emacs@gnu.org], [],
27   [https://www.gnu.org/software/emacs/])
29 if test "$XCONFIGURE" = "android"; then
30   # configure is being called recursively to configure Emacs for
31   # Android!
32   AC_MSG_NOTICE([called to recursively configure Emacs for Android.])
33   # Set CC to ANDROID_CC and CFLAGS to ANDROID_CFLAGS.
34   CC=$ANDROID_CC
35   # Set -Wno-implicit-function-declaration.  Building Emacs for older
36   # versions of Android requires configure tests to fail if the
37   # functions are not defined, as the Android library in the NDK
38   # defines subroutines that are not available in the headers being
39   # used.
40   CFLAGS="$ANDROID_CFLAGS -Werror=implicit-function-declaration"
41   # Don't explicitly enable support for large files unless Emacs is
42   # being built for API 21 or later.  Otherwise, mmap does not work.
43   #
44   # Moreover, 64-bit variants of file IO functions in the C library are
45   # liable to fail with ENOSYS or EINVAL on earlier API versions, and as
46   # such their definitions must be explicitly disabled on NDK releases
47   # that enable them by default.
48   AS_IF([test "$ANDROID_SDK" -lt "21"], [
49     CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=32"
50     enable_largefile=no
51     enable_year2038=no])
54 dnl Set emacs_config_options to the options of 'configure', quoted for the shell,
55 dnl and then quoted again for a C string.  Separate options with spaces.
56 dnl Add some environment variables, if they were passed via the environment
57 dnl rather than on the command-line.
58 emacs_config_options=
59 optsep=
60 dnl This is the documented way to record the args passed to configure,
61 dnl rather than $ac_configure_args.
62 for opt in "$@" CFLAGS CPPFLAGS LDFLAGS; do
63   case $opt in
64     -n | --no-create | --no-recursion)
65       continue ;;
66     CFLAGS | CPPFLAGS | LDFLAGS)
67       eval 'test "${'$opt'+set}" = set' || continue
68       case " $*" in
69         *" $opt="*) continue ;;
70       esac
71       eval opt=$opt=\$$opt ;;
72   esac
74   emacs_shell_specials=$IFS\''"#$&()*;<>?@<:@\\`{|~'
75   case $opt in
76     *[["$emacs_shell_specials"]]*)
77       case $opt in
78         *\'*)
79           emacs_quote_apostrophes="s/'/'\\\\''/g"
80           opt=`AS_ECHO(["$opt"]) | sed "$emacs_quote_apostrophes"` ;;
81       esac
82       opt="'$opt'"
83       case $opt in
84         *[['"\\']]*)
85           emacs_quote_for_c='s/[["\\]]/\\&/g; $!s/$/\\n\\/'
86           opt=`AS_ECHO(["$opt"]) | sed "$emacs_quote_for_c"` ;;
87       esac ;;
88   esac
89   AS_VAR_APPEND([emacs_config_options], ["$optsep$opt"])
90   optsep=' '
91 done
93 AC_CONFIG_HEADERS([src/config.h:src/config.in])
94 AC_CONFIG_SRCDIR([src/lisp.h])
95 AC_CONFIG_AUX_DIR([build-aux])
96 AC_CONFIG_MACRO_DIR([m4])
98 xcsdkdir=
99 AC_CHECK_PROGS([XCRUN], [xcrun])
100 if test -n "$XCRUN"; then
101   if test -z "$MAKE"; then
102     dnl Call the variable MAKE_PROG, not MAKE, to avoid confusion with
103     dnl the usual MAKE variable that 'make' itself uses.
104     AC_CHECK_PROG([MAKE_PROG], [make], [yes])
105     if test -z "$MAKE_PROG"; then
106       MAKE="$XCRUN MAKE"
107       export MAKE
108       xcsdkdir=`$XCRUN --show-sdk-path 2>/dev/null`
109     fi
110   fi
113 dnl Check for GNU Make and possibly set MAKE.
114 [emacs_check_gnu_make ()
116   emacs_makeout=`($1 --version) 2>/dev/null` &&
117   case $emacs_makeout in
118     'GNU Make '3.8[1-9]* | 'GNU Make '3.9[0-9]* | \
119     'GNU Make '3.[1-9][0-9][0-9]* | 'GNU Make '[4-9]* | 'GNU Make '[1-9][0-9]* )
120        ac_path_MAKE_found=:;;
121   esac
123 AC_CACHE_CHECK([for GNU Make], [ac_cv_path_MAKE],
124   [ac_path_MAKE_found=false
125    if test -n "$MAKE"; then
126      emacs_check_gnu_make "$MAKE"
127      ac_cv_path_MAKE=$MAKE
128    else
129      emacs_tried_make=false
130      emacs_tried_gmake=false
131      emacs_tried_gnumake=false
132      AC_PATH_PROGS_FEATURE_CHECK([MAKE], [make gmake gnumake],
133        [[emacs_check_gnu_make "$ac_path_MAKE"
134          if $ac_path_MAKE_found; then
135            # Use the fully-qualified program name only if the basename
136            # would not resolve to it.
137            if eval \$emacs_tried_$ac_prog; then
138              ac_cv_path_MAKE=$ac_path_MAKE
139            else
140              ac_cv_path_MAKE=$ac_prog
141            fi
142          fi
143          eval emacs_tried_$ac_prog=:]])
144    fi])
145 $ac_path_MAKE_found || {
146 AC_MSG_ERROR([[Building Emacs requires GNU Make, at least version 3.81.
147 If you have it installed under another name, configure with 'MAKE=...'.
148 For example, run '$0 MAKE=gnu-make'.]])
150 MAKE=$ac_cv_path_MAKE
151 export MAKE
153 dnl Canonicalize the configuration name.
154 if test "$XCONFIGURE" = "android"; then
155   dnl Set host to whatever Android system Emacs is being configured
156   dnl for.  Determine this by looking at the output of ANDROID_CC.
158   AC_MSG_CHECKING([the cross-compiler's target])
159   cc_target=`${CC} -v 2>&1 | sed -n 's/Target: //p'`
160   case "$cc_target" in
161     *android*) host_alias=$cc_target
162     ;;
163     *) AC_MSG_ERROR([The cross compiler does not compile for Android.
164 Please verify that you specified the correct compiler in the ANDROID_CC
165 variable when you ran configure.])
166     ;;
167   esac
168   AC_MSG_RESULT([$host_alias])
171 AC_CANONICAL_HOST
172 AC_CANONICAL_BUILD
174 AS_IF([test "$XCONFIGURE" = "android"],[
175   # Initialize the Android NDK build system.  Make sure to use the
176   # passed through NDK path.
177   # Make sure to pass through the CFLAGS, as older versions of the
178   # NDK require them to be able to find system includes.
179   with_ndk_path="$android_ndk_path"
180   with_ndk_cxx="$android_ndk_cxx"
181   ndk_INIT([$android_abi], [$ANDROID_SDK], [cross/ndk-build],
182            [$ANDROID_CFLAGS])
184   # At the same time, configure libexec with the build directory
185   # set to `exec'.
186   AS_MKDIR_P([exec])
188   # Enter exec and configure it, using the C compiler as both the
189   # assembler and the linker.  Determine the absolute name of the
190   # source directory.
191   # N.B. that the linker is actually cc, so pass -nostdlib, lest
192   # the crt be linked in.  Likewise for as.
194   AS_CASE([$srcdir], [.], [emacs_srcdir=`pwd`],
195     [[[\\/]* | ?:[\\/]*]], [emacs_srcdir=$srcdir],
196     [*], [emacs_srcdir=`pwd`/$srcdir])
198   AC_MSG_NOTICE([configuring in `exec'])
200   # Derive a name for a cache file for this configure script from the
201   # current, if specified.
202   exec_cache_file=
203   AS_CASE([$cache_file], [/dev/null | ""], [],
204     [[[\\/]* | ?:[\\/]*]], [exec_cache_file="--cache-file=$cache_file.2"],
205     [*], [exec_cache_file="--cache-file=../$cache_file.2"])
206   OLDCWD=`pwd`
207   cd exec
208   $CONFIG_SHELL $emacs_srcdir/exec/configure            \
209                 --host=$host "CC=$CC" "LD=$CC" "AS=$CC" \
210                 "AR=$AR" "CFLAGS=$CFLAGS" $exec_cache_file
211   emacs_val=$?
212   cd $OLDCWD
214   AS_IF([test "$emacs_val" != "0"],
215     [AC_MSG_ERROR([failed to configure in `exec'])])
218 case $host in
219  *-mingw*)
221   if test -z "$host_alias"; then
223       # No --host argument was given to 'configure'; therefore $host
224       # was set to a default value based on the build platform.  But
225       # this default value may be wrong if we are building from a
226       # 64-bit MSYS[2] pre-configured to build 32-bit MinGW programs.
227       # Therefore, we'll try to get the right host platform from the
228       # compiler's target.
230       AC_MSG_CHECKING([the compiler's target])
231       if test -z "$CC"; then
232           cc=gcc
233       else
234           cc=$CC
235       fi
236       cc_target=`$cc -v 2>&1 | sed -n 's/Target: //p'`
237       case "$cc_target" in
238           *-*) host=$cc_target
239               ;;
240           "") AC_MSG_ERROR([Impossible to obtain $cc compiler target.
241 Please explicitly provide --host.])
242               ;;
243           *) AC_MSG_WARN([Compiler reported non-standard target.
244 Defaulting to $host.])
245               ;;
246       esac
247       AC_MSG_RESULT([$host])
248   fi
250   . $srcdir/nt/mingw-cfg.site
252   case $srcdir in
253     /* | ?:*)
254       # srcdir is an absolute path.  In this case, force the format
255       # "/c/foo/bar", to simplify later conversions to native Windows
256       # format ("c:/foo/bar").
257       srcdir=`cd "${srcdir}" && pwd -W`
258       # 'eval' pacifies strict POSIX non-MinGW shells (Bug#18612).
259       # We downcase the drive letter to avoid warnings when
260       # generating autoloads.
261       eval 'srcdir=/`echo ${srcdir:0:1} | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"`"${srcdir:2}"'
262       ;;
263   esac;;
264 esac
266 canonical=$host
267 configuration=${host_alias-${build_alias-$host}}
268 emacs_uname_r=`uname -r`
270 dnl Support for --program-prefix, --program-suffix and
271 dnl --program-transform-name options
272 AC_ARG_PROGRAM
274 dnl It is important that variables on the RHS not be expanded here,
275 dnl hence the single quotes.  This is per the GNU coding standards, see
276 dnl (autoconf) Installation Directory Variables
277 dnl See also epaths.h below.
278 lispdirrel='${version}/lisp'
279 lispdir='${datadir}/emacs/'${lispdirrel}
280 standardlisppath='${lispdir}'
281 locallisppath='${datadir}/emacs/${version}/site-lisp:'\
282 '${datadir}/emacs/site-lisp'
283 lisppath='${locallisppath}:${standardlisppath}'
284 etcdir='${datadir}/emacs/${version}/etc'
285 archlibdir='${libexecdir}/emacs/${version}/${configuration}'
286 etcdocdir='${datadir}/emacs/${version}/etc'
287 gamedir='${localstatedir}/games/emacs'
289 dnl Special option to disable the most of other options.
290 AC_ARG_WITH([all],
291 [AS_HELP_STRING([--without-all],
292                 [omit almost all features and build
293                 small executable with minimal dependencies])],
294   [with_features=$withval],
295   [with_features=yes])
297 dnl ARCH_INDEPENDENT_CONFIG_FILES(FILE...)
298 dnl Like AC_CONFIG_FILES(FILE).  However, do not generate this
299 dnl   if configure is being called recursively in preparation
300 dnl   for cross-compilation.
301 AC_DEFUN([ARCH_INDEPENDENT_CONFIG_FILES], [
302   AS_IF([test "$XCONFIGURE" != "android"], [AC_CONFIG_FILES([$1])])])
304 dnl OPTION_DEFAULT_OFF(NAME, HELP-STRING)
305 dnl Create a new --with option that defaults to being disabled.
306 dnl NAME is the base name of the option.  The shell variable with_NAME
307 dnl   will be set to either the user's value (if the option is
308 dnl   specified; 'yes' for a plain --with-NAME) or to 'no' (if the
309 dnl   option is not specified).  Note that the shell variable name is
310 dnl   constructed as autoconf does, by replacing non-alphanumeric
311 dnl   characters with "_".
312 dnl HELP-STRING is the help text for the option.
313 AC_DEFUN([OPTION_DEFAULT_OFF], [dnl
314   AC_ARG_WITH([$1],[AS_HELP_STRING([--with-$1],[$2])],[],[dnl
315     m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=no])dnl
316 ])dnl
318 dnl OPTION_DEFAULT_IFAVAILABLE(NAME, HELP-STRING)
319 dnl Create a new --with option that defaults to 'ifavailable',
320 dnl unless it is overridden by $with_features being equal to 'no'.
321 dnl NAME is the base name of the option.  The shell variable with_NAME
322 dnl   will be set to either the user's value (if the option is
323 dnl   specified; 'yes' for a plain --with-NAME) or to 'ifavailable' (if the
324 dnl   option is not specified).  Note that the shell variable name is
325 dnl   constructed as autoconf does, by replacing non-alphanumeric
326 dnl   characters with "_".
327 dnl HELP-STRING is the help text for the option.
328 AC_DEFUN([OPTION_DEFAULT_IFAVAILABLE], [dnl
329   AC_ARG_WITH([$1],[AS_HELP_STRING([--with-$1],[$2])],[],[dnl
330     AS_IF([test "$with_features" != no],
331       [m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=ifavailable],
332       [m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=no])dnl
333   ])dnl
334 ])dnl
336 dnl OPTION_DEFAULT_ON(NAME, HELP-STRING)
337 dnl Create a new --with option that defaults to $with_features.
338 dnl NAME is the base name of the option.  The shell variable with_NAME
339 dnl   will be set either to 'no' (for a plain --without-NAME) or to
340 dnl   'yes' (if the option is not specified).  Note that the shell
341 dnl   variable name is constructed as autoconf does, by replacing
342 dnl   non-alphanumeric characters with "_".
343 dnl HELP-STRING is the help text for the option.
344 AC_DEFUN([OPTION_DEFAULT_ON], [dnl
345   AC_ARG_WITH([$1],[AS_HELP_STRING([--without-$1],[$2])],[],[dnl
346    m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=$with_features])dnl
347 ])dnl
349 # For retrieving mail, unencrypted network connections are the default
350 # only on native MS-Windows platforms.  (FIXME: These platforms should
351 # also be secure by default.)
353 AC_ARG_WITH([mailutils],
354   [AS_HELP_STRING([--with-mailutils],
355      [rely on GNU Mailutils, so that the --without-pop through --with-mailhost
356       options are irrelevant; this is the default if GNU Mailutils is
357       installed])],
358   [],
359   [AS_IF([test "$with_features" != "no"],
360    [with_mailutils=yes-unless-android
361     AS_IF([test "x$XCONFIGURE" != "xandroid"],
362      [(movemail --version) >/dev/null 2>&1 || with_mailutils=no],
363      [dnl Don't check for movemail if cross-compiling.
364       dnl instead, default to false.
365       with_mailutils=no])])])
367 AC_ARG_WITH([pop],
368   [AS_HELP_STRING([--with-pop],
369      [Support POP mail retrieval if Emacs movemail is used (not recommended,
370       as Emacs movemail POP is insecure).  This is the default only on
371       native MS-Windows and Android.])],
372   [],
373   dnl Enable movemail POP support on Android as GNU Mailutils is
374   dnl normally unavailable on that platform.
375   [AS_CASE([$host],
376      [*-mingw*|*android*], [with_pop=yes],
377      [with_pop=no-by-default])])
378 if test "$with_pop" = yes; then
379    AC_DEFINE([MAIL_USE_POP])
381 AH_TEMPLATE([MAIL_USE_POP], [Define to support POP mail retrieval.])dnl
383 OPTION_DEFAULT_OFF([kerberos],[support Kerberos-authenticated POP])
384 if test "$with_kerberos" != no; then
385    AC_DEFINE([KERBEROS])
387 AH_TEMPLATE([KERBEROS],
388             [Define to support Kerberos-authenticated POP mail retrieval.])dnl
390 OPTION_DEFAULT_OFF([kerberos5],[support Kerberos version 5 authenticated POP])
391 if test "${with_kerberos5}" != no; then
392   if test "${with_kerberos}" = no; then
393     with_kerberos=yes
394     AC_DEFINE([KERBEROS])
395   fi
396   AC_DEFINE([KERBEROS5], [1],
397     [Define to use Kerberos 5 instead of Kerberos 4.])
400 OPTION_DEFAULT_OFF([hesiod],[support Hesiod to get the POP server host])
401 dnl FIXME hesiod support may not be present, so it seems like an error
402 dnl to define, or at least use, this unconditionally.
403 if test "$with_hesiod" != no; then
404   AC_DEFINE([HESIOD], [1],
405     [Define to support using a Hesiod database to find the POP server.])
408 OPTION_DEFAULT_OFF([mail-unlink],[unlink, rather than empty, mail spool after reading])
409 if test "$with_mail_unlink" != no; then
410    AC_DEFINE([MAIL_UNLINK_SPOOL], [1],
411      [Define to unlink, rather than empty, mail spool after reading.])
414 AC_ARG_WITH([mailhost],[AS_HELP_STRING([--with-mailhost=HOSTNAME],
415     [string giving default POP mail host])],
416     AC_DEFINE_UNQUOTED([MAILHOST], ["$withval"],
417       [String giving fallback POP mail host.]))
419 AC_ARG_WITH([sound],[AS_HELP_STRING([--with-sound=VALUE],
420   [compile with sound support (VALUE one of: yes, alsa, oss, bsd-ossaudio, no;
421 default yes).  Only for GNU/Linux, FreeBSD, NetBSD, MinGW, Cygwin.])],
422   [ case "${withval}" in
423       yes|no|alsa|oss|bsd-ossaudio) val=$withval ;;
424       *) AC_MSG_ERROR(['--with-sound=$withval' is invalid;
425 this option's value should be 'yes', 'no', 'alsa', 'oss', or 'bsd-ossaudio'.])
426       ;;
427     esac
428     with_sound=$val
429   ],
430   [with_sound=$with_features])
432 AC_ARG_WITH([pdumper],
433   AS_HELP_STRING(
434     [--with-pdumper=VALUE],
435     [enable pdumper support unconditionally
436       ('yes', 'no', or 'auto': default 'auto')]),
437     [ case "${withval}" in
438         yes|no|auto) val=$withval ;;
439         *) AC_MSG_ERROR(
440            ['--with-pdumper=$withval' is invalid;
441 this option's value should be 'yes' or 'no'.]) ;;
442       esac
443       with_pdumper=$val
444     ],
445     [with_pdumper=auto])
447 AC_ARG_WITH([unexec],
448   AS_HELP_STRING(
449     [--with-unexec=VALUE],
450     [enable unexec support unconditionally
451       ('yes', 'no', or 'auto': default 'auto')]),
452     [ case "${withval}" in
453         yes|no|auto) val=$withval ;;
454         *) AC_MSG_ERROR(
455            ['--with-unexec=$withval' is invalid;
456 this option's value should be 'yes' or 'no'.]) ;;
457       esac
458       with_unexec=$val
459     ],
460     [with_unexec=auto])
462 AC_ARG_WITH([dumping],[AS_HELP_STRING([--with-dumping=VALUE],
463     [kind of dumping to use for initial Emacs build
464 (VALUE one of: pdumper, unexec, none; default pdumper)])],
465     [ case "${withval}" in
466         pdumper|unexec|none) val=$withval ;;
467         *) AC_MSG_ERROR(['--with-dumping=$withval is invalid;
468 this option's value should be 'pdumper', 'unexec', or 'none'.])
469         ;;
470       esac
471       with_dumping=$val
472     ],
473     [with_dumping=pdumper])
475 if test "$with_pdumper" = "auto"; then
476   if test "$with_dumping" = "pdumper"; then
477     with_pdumper=yes
478   else
479     with_pdumper=no
480   fi
483 if test "$with_unexec" = "auto"; then
484   if test "$with_dumping" = "unexec"; then
485     with_unexec=yes
486   else
487     with_unexec=no
488   fi
491 if test "$with_dumping" = "pdumper" && test "$with_pdumper" = "no"; then
492   AC_MSG_ERROR(['--with-dumping=pdumper' requires pdumper support])
495 if test "$with_dumping" = "unexec" && test "$with_unexec" = "no"; then
496   AC_MSG_ERROR(['--with-dumping=unexec' requires unexec support])
499 if test "$with_pdumper" = "yes"; then
500   AC_DEFINE([HAVE_PDUMPER], [1],
501     [Define to build with portable dumper support])
502   HAVE_PDUMPER=yes
503 else
504   HAVE_PDUMPER=no
506 AC_SUBST([HAVE_PDUMPER])
508 DUMPING=$with_dumping
509 AC_SUBST([DUMPING])
511 dnl FIXME currently it is not the last.
512 dnl This should be the last --with option, because --with-x is
513 dnl added later on when we find the file name of X, and it's best to
514 dnl keep them together visually.
515 AC_ARG_WITH([x-toolkit],[AS_HELP_STRING([--with-x-toolkit=KIT],
516  [use an X toolkit (KIT one of: yes or gtk, gtk2, gtk3, lucid or athena, motif, no)])],
517 [         case "${withval}" in
518             y | ye | yes )      val=gtk ;;
519             n | no )            val=no  ;;
520             l | lu | luc | luci | lucid )       val=lucid ;;
521             a | at | ath | athe | athen | athena )      val=athena ;;
522             m | mo | mot | moti | motif )       val=motif ;;
523             g | gt | gtk  )     val=gtk ;;
524             gtk2  )     val=gtk2 ;;
525             gtk3  )     val=gtk3 ;;
526             * )
527 AC_MSG_ERROR(['--with-x-toolkit=$withval' is invalid;
528 this option's value should be 'yes', 'no', 'lucid', 'athena', 'motif', 'gtk',
529 'gtk2' or 'gtk3'.  'yes' and 'gtk' are synonyms.
530 'athena' and 'lucid' are synonyms.])
531             ;;
532           esac
533           with_x_toolkit=$val
536 OPTION_DEFAULT_OFF([wide-int],
537   [prefer wide Emacs integers (typically 62-bit);
538    on 32-bit hosts, this allows buffer and string size up to 2GB,
539    at the cost of 10% to 30% slowdown of Lisp interpreter
540    and larger memory footprint])
541 if test "$with_wide_int" = yes; then
542   AC_DEFINE([WIDE_EMACS_INT], [1], [Use long long for EMACS_INT if available.])
545 dnl _ON results in a '--without' option in the --help output, so
546 dnl the help text should refer to "don't compile", etc.
547 with_xpm_set=${with_xpm+set}
548 OPTION_DEFAULT_ON([xpm],[don't compile with XPM image support])
549 OPTION_DEFAULT_ON([jpeg],[don't compile with JPEG image support])
550 OPTION_DEFAULT_ON([tiff],[don't compile with TIFF image support])
551 OPTION_DEFAULT_ON([gif],[don't compile with GIF image support])
552 OPTION_DEFAULT_ON([png],[don't compile with PNG image support])
553 OPTION_DEFAULT_ON([rsvg],[don't compile with SVG image support])
554 OPTION_DEFAULT_ON([webp],[don't compile with WebP image support])
555 OPTION_DEFAULT_ON([sqlite3],[don't compile with sqlite3 support])
556 OPTION_DEFAULT_ON([lcms2],[don't compile with Little CMS support])
557 OPTION_DEFAULT_ON([libsystemd],[don't compile with libsystemd support])
558 OPTION_DEFAULT_ON([cairo],[don't compile with Cairo drawing])
559 OPTION_DEFAULT_OFF([cairo-xcb], [use XCB surfaces for Cairo support])
560 OPTION_DEFAULT_ON([xml2],[don't compile with XML parsing support])
561 OPTION_DEFAULT_OFF([imagemagick],[compile with ImageMagick image support])
562 OPTION_DEFAULT_ON([native-image-api], [don't use native image APIs (GDI+ on Windows)])
563 OPTION_DEFAULT_IFAVAILABLE([tree-sitter], [compile with tree-sitter])
565 OPTION_DEFAULT_ON([xft],[don't use XFT for anti aliased fonts])
566 OPTION_DEFAULT_ON([harfbuzz],[don't use HarfBuzz for text shaping])
567 OPTION_DEFAULT_ON([libotf],[don't use libotf for OpenType font support])
568 OPTION_DEFAULT_ON([m17n-flt],[don't use m17n-flt for text shaping])
570 OPTION_DEFAULT_ON([toolkit-scroll-bars],[don't use Motif/Xaw3d/GTK toolkit scroll bars])
571 OPTION_DEFAULT_ON([xaw3d],[don't use Xaw3d])
572 OPTION_DEFAULT_ON([xim],[at runtime, default X11 XIM to off])
573 OPTION_DEFAULT_ON([xdbe],[don't use X11 double buffering support])
574 AC_ARG_WITH([ns],[AS_HELP_STRING([--with-ns],
575 [use Nextstep (macOS Cocoa or GNUstep) windowing system.
576 On by default on macOS.])],[],[with_ns=maybe])
577 OPTION_DEFAULT_OFF([w32], [use native MS Windows GUI in a Cygwin build])
578 OPTION_DEFAULT_OFF([pgtk], [use GTK to support window systems other than X])
580 OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console])
581 OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support])
582 AC_ARG_WITH([gconf],[AS_HELP_STRING([--with-gconf],
583 [compile with Gconf support (Gsettings replaces this)])],[],
584 [if test $with_features = yes; then
585 with_gconf=maybe
586 else
587 with_gconf=no
588 fi])
589 OPTION_DEFAULT_ON([gsettings],[don't compile with GSettings support])
590 OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support])
591 OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support])
592 OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support])
593 OPTION_DEFAULT_ON([modules],[don't compile with dynamic modules support])
594 OPTION_DEFAULT_ON([threads],[don't compile with elisp threading support])
595 OPTION_DEFAULT_OFF([cygwin32-native-compilation],[use native compilation on 32-bit Cygwin])
596 OPTION_DEFAULT_ON([xinput2],[don't use version 2 of the X Input Extension for input])
597 OPTION_DEFAULT_OFF([small-ja-dic],[generate a smaller-size Japanese dictionary])
598 OPTION_DEFAULT_OFF([android],[cross-compile Android application package])
599 OPTION_DEFAULT_ON([android-debug],[don't build Emacs as a debug package on Android])
601 # Find out of Android support is enabled and mailutils has defaulted
602 # to `yes-unless-android'.  Disable it if so.
604 AS_IF([test "x$with_mailutils" = "xyes-unless-android"],
605   [AS_IF([test "x$with_android" != "xno"],
606      [with_mailutils=no],
607      [with_mailutils=yes])])
609 # Clear with_mailutils if it's set to no.
611 AS_IF([test "$with_mailutils" = no],
612   [with_mailutils=])
614 AS_IF([test x"$with_mailutils" = xyes],
615   [AC_DEFINE([HAVE_MAILUTILS], [1],
616      [Define to 1 if Emacs was configured with mailutils])])
618 AC_SUBST([with_mailutils])
620 AC_ARG_WITH([shared-user-id],
621   [AS_HELP_STRING([--with-shared-user-id=ID],
622     [use the given shared user ID in Android builds])])
624 AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB],
625  [use a file notification library (LIB one of: yes, inotify, kqueue, gfile, w32, no)])],
626  [ case "${withval}" in
627     y | ye | yes )      val=yes ;;
628     n | no )            val=no  ;;
629     i | in | ino | inot | inoti | inotif | inotify )    val=inotify ;;
630     k | kq | kqu | kque | kqueu | kqueue )      val=kqueue ;;
631     g | gf | gfi | gfil | gfile )       val=gfile ;;
632     w | w3 | w32 )      val=w32 ;;
633     * ) AC_MSG_ERROR(['--with-file-notification=$withval' is invalid;
634 this option's value should be 'yes', 'no', 'inotify', 'kqueue', 'gfile' or 'w32'.
635 'yes' is a synonym for 'w32' on MS-Windows, for 'no' on Nextstep,
636 otherwise for the first of 'inotify', 'kqueue' or 'gfile' that is usable.])
637     ;;
638    esac
639    with_file_notification=$val
640  ],
641  [with_file_notification=$with_features])
643 OPTION_DEFAULT_OFF([xwidgets],
644   [enable use of xwidgets in Emacs buffers (requires gtk3 or macOS Cocoa)])
646 OPTION_DEFAULT_OFF([be-app],
647   [enable use of Haiku's Application Kit as a window system])
649 OPTION_DEFAULT_OFF([be-cairo],
650   [enable use of cairo under Haiku's Application Kit])
652 ## Makefile.in needs the cache file name.
653 AC_SUBST([cache_file])
655 ## This is an option because I do not know if all info/man support
656 ## compressed files, nor how to test if they do so.
657 OPTION_DEFAULT_ON([compress-install],
658   [don't compress some files (.el, .info, etc.) when installing.  Equivalent to:
659 make GZIP_PROG= install])
661 AC_ARG_WITH([gameuser],
662 [AS_HELP_STRING([--with-gameuser=USER_OR_GROUP],
663                 [user for shared game score files.
664                 An argument prefixed by ':' specifies a group instead.])])
665 gameuser=
666 gamegroup=
667 case ${with_gameuser} in
668   '' | no) ;;
669   yes) gamegroup=games ;;
670   :*) gamegroup=${with_gameuser#:} ;;
671   *) gameuser=${with_gameuser} ;;
672 esac
674 AC_ARG_WITH([gnustep-conf],
675 [AS_HELP_STRING([--with-gnustep-conf=FILENAME],
676    [name of GNUstep configuration file to use on systems where the command
677     'gnustep-config' does not work; default $GNUSTEP_CONFIG_FILE, or
678     /etc/GNUstep/GNUstep.conf])])
679 test "X${with_gnustep_conf}" != X && test "${with_gnustep_conf}" != yes && \
680   GNUSTEP_CONFIG_FILE="${with_gnustep_conf}"
681 test "X$GNUSTEP_CONFIG_FILE" = "X" && \
682      GNUSTEP_CONFIG_FILE=/etc/GNUstep/GNUstep.conf
684 AC_ARG_ENABLE([ns-self-contained],
685 [AS_HELP_STRING([--disable-ns-self-contained],
686                 [disable self contained build under NeXTstep])],
687    [EN_NS_SELF_CONTAINED=$enableval],
688    [EN_NS_SELF_CONTAINED=yes])
690 locallisppathset=no
691 AC_ARG_ENABLE([locallisppath],
692 [AS_HELP_STRING([--enable-locallisppath=PATH],
693                 [directories Emacs should search for lisp files specific
694                  to this site])],
695 [if test "${enableval}" = "no"; then
696   locallisppath=
697 elif test "${enableval}" != "yes"; then
698   locallisppath=${enableval} locallisppathset=yes
699 fi])
701 AC_ARG_ENABLE([checking],
702 [AS_HELP_STRING([--enable-checking@<:@=LIST@:>@],
703                 [enable expensive checks.  With LIST,
704                  enable only specific categories of checks.
705                  Categories are: all,yes,no.
706                  Flags are: stringbytes, stringoverrun, stringfreelist,
707                  structs, glyphs])],
708 [ac_checking_flags="${enableval}"],[])
709 IFS="${IFS=     }"; ac_save_IFS="$IFS"; IFS="$IFS,"
710 CHECK_STRUCTS=false
711 for check in $ac_checking_flags
713         case $check in
714         # these set all the flags to specific states
715         yes)            ac_enable_checking=1 ;;
716         no)             ac_enable_checking= ;
717                         CHECK_STRUCTS=false
718                         ac_gc_check_stringbytes= ;
719                         ac_gc_check_string_overrun= ;
720                         ac_gc_check_string_free_list= ;
721                         ac_glyphs_debug= ;;
722         all)            ac_enable_checking=1 ;
723                         CHECK_STRUCTS=true
724                         ac_gc_check_stringbytes=1 ;
725                         ac_gc_check_string_overrun=1 ;
726                         ac_gc_check_string_free_list=1 ;
727                         ac_glyphs_debug=1 ;;
728         # these enable particular checks
729         stringbytes)    ac_gc_check_stringbytes=1 ;;
730         stringoverrun)  ac_gc_check_string_overrun=1 ;;
731         stringfreelist) ac_gc_check_string_free_list=1 ;;
732         structs)        CHECK_STRUCTS=true ;;
733         glyphs)         ac_glyphs_debug=1 ;;
734         *)      AC_MSG_ERROR([unknown check category $check]) ;;
735         esac
736 done
737 IFS="$ac_save_IFS"
739 # This environment variable is used to signal that checking should be
740 # enabled on Android.  When that happens, simply enable checking for
741 # the cross-compiled Android binary.
743 AS_IF([test "x$XCONFIGURE" = "xandroid" \
744        && test "x$android_enable_checking" = "xyes"],
745   [ac_enable_checking=yes])
747 # There is little point in enabling checking in the build machine if
748 # cross-compiling for Android.
749 AS_IF([test "$with_android" = no || test -n "$XCONFIGURE"],[
750   if test x$ac_enable_checking != x ; then
751     AC_DEFINE([ENABLE_CHECKING], [1],
752   [Define to 1 if expensive run-time data type and consistency checks are enabled.])
753   fi
754   if $CHECK_STRUCTS; then
755     AC_DEFINE([CHECK_STRUCTS], [1],
756       [Define this to check whether someone updated the portable dumper
757        code after changing the layout of a structure that it uses.
758        If you change one of these structures, check that the pdumper.c
759        code is still valid, and update the pertinent hash in pdumper.c
760        by manually copying the hash from the newly-generated dmpstruct.h.])
761   fi
762   AC_SUBST([CHECK_STRUCTS])
763   if test x$ac_gc_check_stringbytes != x ; then
764     AC_DEFINE([GC_CHECK_STRING_BYTES], [1],
765   [Define this temporarily to hunt a bug.  If defined, the size of
766      strings is redundantly recorded in sdata structures so that it can
767      be compared to the sizes recorded in Lisp strings.])
768   fi
769   if test x$ac_gc_check_string_overrun != x ; then
770     AC_DEFINE([GC_CHECK_STRING_OVERRUN], [1],
771   [Define this to check for short string overrun.])
772   fi
773   if test x$ac_gc_check_string_free_list != x ; then
774     AC_DEFINE([GC_CHECK_STRING_FREE_LIST], [1],
775   [Define this to check the string free list.])
776   fi
777   if test x$ac_glyphs_debug != x ; then
778     AC_DEFINE([GLYPH_DEBUG], [1],
779   [Define this to enable glyphs debugging code.])
780   fi
781 ],[AS_IF([test "x$ac_enable_checking" != x],
782     [android_enable_checking=yes
783      export android_enable_checking])])
785 AC_ARG_ENABLE([gc-mark-trace],
786  [AS_HELP_STRING([--disable-gc-mark-trace],
787                  [disable the mark trace buffer used for debugging the Emacs
788                  garbage collector])],
789  [ac_enable_gc_mark_trace="${enableval}"],
790  [ac_enable_gc_mark_trace=yes])
791 if test "x$ac_enable_gc_mark_trace" = xyes ; then
792    AC_DEFINE([GC_REMEMBER_LAST_MARKED], [1],
793    [Define to 1 to enable GC mark trace buffer.])
796 dnl The name of this option is unfortunate.  It predates, and has no
797 dnl relation to, the "sampling-based elisp profiler" added in 24.3.
798 dnl Actually, it stops it working.
799 dnl https://lists.gnu.org/r/emacs-devel/2012-11/msg00393.html
800 AC_ARG_ENABLE([profiling],
801 [AS_HELP_STRING([--enable-profiling],
802                 [build emacs with low-level, gprof profiling support.
803                 Mainly useful for debugging Emacs itself.  May not work on
804                 all platforms.  Stops profiler.el working.])],
805 [ac_enable_profiling="${enableval}"],[])
806 if test x$ac_enable_profiling != x ; then
807    PROFILING_CFLAGS="-DPROFILING=1 -pg"
808 else
809    PROFILING_CFLAGS=
811 AC_SUBST([PROFILING_CFLAGS])
813 AC_ARG_ENABLE([autodepend],
814 [AS_HELP_STRING([--enable-autodepend],
815                 [automatically generate dependencies to .h-files.
816                  Requires gcc, enabled if found.])],
817 [ac_enable_autodepend="${enableval}"],[ac_enable_autodepend=yes])
819 AC_ARG_ENABLE([gtk-deprecation-warnings],
820 [AS_HELP_STRING([--enable-gtk-deprecation-warnings],
821                 [Show Gtk+/Gdk deprecation warnings for Gtk+ >= 3.0])],
822 [ac_enable_gtk_deprecation_warnings="${enableval}"],[])
824 BUILD_DETAILS=
825 AC_ARG_ENABLE([build-details],
826   [AS_HELP_STRING([--disable-build-details],
827                   [Make the build more deterministic by omitting host
828                    names, time stamps, etc. from the output.])],
829   [test "$enableval" = no && BUILD_DETAILS=--no-build-details])
830 AC_SUBST([BUILD_DETAILS])
832 # JAVA_PUSH_LINT(OPT)
833 # -------------------
834 # Check if javac supports the diagnostic flag -Xlint:OPT.
835 # If it does, add it to WARN_JAVAFLAGS.
837 AC_DEFUN([JAVA_PUSH_LINT],
839   AC_CACHE_CHECK([whether Java compiler accepts -Xlint:$1],
840     [emacs_cv_javac_knows_lint_$1],
841     AS_IF([rm -f conftest.class
842 cat << EOF > conftest.java
844 class conftest
850 ("$JAVAC" -Xlint:$1 conftest.java 2>&AS_MESSAGE_LOG_FD) \
851   && rm -f conftest.class], [emacs_cv_javac_knows_lint_$1=yes],
852      [emacs_cv_javac_knows_lint_$1=no]))
854   AS_IF([test "$emacs_cv_javac_knows_lint_$1" = "yes"],
855     [WARN_JAVAFLAGS="$WARN_JAVAFLAGS -Xlint:$1"])
858 # Start Android configuration.  This is done in three steps:
860 # First, the SDK tools needed to build the Android package on the host
861 # are found.
863 # Then, configure is called inside itself with the NDK C and C++
864 # compilers, and the Makefiles generated, along with config.h, are
865 # renamed to end with .android.
867 # Finally, configure continues to configure the Emacs binary that will
868 # run on the host.
870 ANDROID=
871 JAVAC=
872 AAPT=
873 JARSIGNER=
874 APKSIGNER=
875 ZIPALIGN=
877 ANDROID_JAR=
878 ANDROID_ABI=
879 WARN_JAVAFLAGS=
880 ANDROID_SHARED_USER_ID=
881 ANDROID_SHARED_USER_NAME=
882 IS_D8_R8=
884 # This is a list of Makefiles that have alternative versions for
885 # Android.
886 android_makefiles="lib/Makefile lib/gnulib.mk lib-src/Makefile src/Makefile"
888 # This is whether or not to package mailutils into the executable.
889 emacs_use_mailutils=
891 AC_ARG_VAR([ANDROID_CC], [The Android C cross-compiler.])
892 AC_ARG_VAR([SDK_BUILD_TOOLS], [Name of directory holding Android SDK build-tools.])
893 AC_ARG_VAR([ANDROID_CFLAGS], [Flags given to the Android C cross-compiler.])
894 AC_ARG_VAR([JAVAC], [Java compiler path.  Used for Android.])
895 AC_ARG_VAR([JARSIGNER], [Java package signer path.  Used for Android.])
896 AC_ARG_VAR([APKSIGNER], [Android package signer path.  Used for Android.])
897 AC_ARG_VAR([SDK_BUILD_TOOLS], [Path to the Android SDK build tools.])
898 AC_ARG_VAR([ZIP], [Path to the `zip' utility.])
900 if test "$with_android" = "yes"; then
901    AC_MSG_ERROR([Please specify the path to the Android.jar file, like so:
903   ./configure --with-android=/path/to/android.jar
905 along with the path to the SDK build-tools (this is the directory with
906 tools such as aapt, dx, and aidl):
908               SDK_BUILD_TOOLS=/path/to/sdk-build-tools
910 The cross-compiler should then be specified:
912               ANDROID_CC=/path/to/armv7a-linux-androideabi19-clang
914 In addition, you may pass any special arguments to the cross-compiler
915 via the ANDROID_CFLAGS environment variable.])
916 elif test "$with_android" = "no" || test "$with_android" = ""; then
917   ANDROID=no
918 else
919   AC_CHECK_PROGS([JAVAC], [javac])
920   if test "$JAVAC" = ""; then
921     AC_MSG_ERROR([The Java compiler required to build Emacs was not found.
922 Please make sure `javac' can be found on your path, or alternatively specify
923 the path to your Java compiler before configuring Emacs, like so:
925   JAVAC=/opt/jdk/bin/javac ./configure --with-android])
926   fi
928   AC_CHECK_PROGS([JARSIGNER], [jarsigner])
929   if test "$JARSIGNER" = ""; then
930     AC_MSG_ERROR([The Java package signing utility was not found.
931 Please make sure `jarsigner' can be found on your path, or alternatively
932 specify its location before configuring Emacs, like so:
934   JARSIGNER=/opt/jdk/bin/jarsigner ./configure --with-android])
935   fi
937   AC_CACHE_CHECK([whether the Java compiler works],
938     [emacs_cv_working_javac],
939     AS_IF([rm -f conftest.class
940 cat << EOF > conftest.java
942 import android.app.Activity;
943 import android.os.Bundle;
945 class conftest extends Activity
947   @Override
948   public void
949   onCreate (Bundle savedInstanceState)
950   {
951     super.onCreate (savedInstanceState);
952   }
956 ("$JAVAC" -classpath "$with_android" -target 1.7 -source 1.7 conftest.java \
957   -d . >&AS_MESSAGE_LOG_FD 2>&1) && test -s conftest.class && rm -f conftest.class],
958           [emacs_cv_working_javac=yes],
959           [emacs_cv_working_javac=no]))
961   if test "$emacs_cv_working_javac" = "no"; then
962     AC_MSG_ERROR([The Java compiler does not work, or you did not specify
963 a valid path to android.jar.  See config.log for more details.])
964   fi
966   AC_CACHE_CHECK([whether android.jar is new enough],
967     [emacs_cv_android_v_or_later],
968     AS_IF([rm -f conftest.class
969 cat << EOF > conftest.java
971 import android.os.Build;
973 class conftest
975   private static int test = Build.VERSION_CODES.VANILLA_ICE_CREAM;
979 ("$JAVAC" -classpath "$with_android" -target 1.7 -source 1.7 conftest.java \
980   -d . >&AS_MESSAGE_LOG_FD 2>&1) && test -s conftest.class && rm -f conftest.class],
981           [emacs_cv_android_v_or_later=yes],
982           [emacs_cv_android_v_or_later=no]))
984   if test "$emacs_cv_android_v_or_later" = "no"; then
985     AC_MSG_ERROR([Emacs must be built with an android.jar file produced for \
986 Android 15 (Vanilla Ice Cream) or later.])
987   fi
989   dnl See if the Java compiler supports the `--release' option which
990   dnl makes it check for and prevent using features introduced after
991   dnl Java 1.7.
993   AC_CACHE_CHECK([whether javac accepts --release 7],
994     [emacs_cv_javac_release_7], AS_IF([rm -f conftest.class
995 cat << EOF > conftest.java
997 class conftest
1003 ("$JAVAC" --release 7 conftest.java 2>&AS_MESSAGE_LOG_FD) \
1004   && rm -f conftest.class],
1005       [emacs_cv_javac_release_7=yes],
1006       [emacs_cv_javac_release_7=no]))
1008   if test "$emacs_cv_javac_release_7" = "yes"; then
1009     WARN_JAVAFLAGS="$WARN_JAVAFLAGS --release 7"
1010   else
1011     dnl If not, just make sure the generated bytecode is correct.
1012     WARN_JAVAFLAGS="$WARN_JAVAFLAGS -target 1.7 -source 1.7"
1013   fi
1015   dnl Enable some useful Java linting options.
1016   JAVA_PUSH_LINT([deprecation])
1017   JAVA_PUSH_LINT([cast])
1018   JAVA_PUSH_LINT([divzero])
1019   JAVA_PUSH_LINT([nonempty])
1020   JAVA_PUSH_LINT([empty])
1021   JAVA_PUSH_LINT([finally])
1022   JAVA_PUSH_LINT([overrides])
1023   JAVA_PUSH_LINT([path])
1024   JAVA_PUSH_LINT([serial])
1025   JAVA_PUSH_LINT([unchecked])
1027   # Get the name of the android.jar file.
1028   ANDROID_JAR="$with_android"
1030   # Substitute this into java/Makefile.
1031   AC_SUBST([WARN_JAVAFLAGS])
1033   AC_PATH_PROGS([AAPT], [aapt], [], "${SDK_BUILD_TOOLS}:$PATH")
1034   if test "$AAPT" = ""; then
1035     AC_MSG_ERROR([The Android asset packaging tool was not found.
1036 Please verify that the path to the SDK build tools you specified is correct])
1037   fi
1039   AC_PATH_PROGS([APKSIGNER], [apksigner], [], "${SDK_BUILD_TOOLS}:$PATH")
1040   if test "$APKSIGNER" = ""; then
1041     AC_MSG_ERROR([The Android package signing tool was not found.
1042 Please verify that the path to the SDK build tools you specified is correct])
1043   fi
1045   AC_PATH_PROGS([D8], [d8], [], "${SDK_BUILD_TOOLS}:$PATH")
1046   if test "$D8" = ""; then
1047     AC_MSG_ERROR([The Android dexer was not found.
1048 Please verify that the path to the SDK build tools you specified is correct])
1049   fi
1051   # Locate any d8.jar within the SDK build tools directory.  The R8
1052   # optimizing compiler is also present in this bundle, and it generates
1053   # far superior code.
1054   emacs_val=`which $D8`
1055   emacs_val=`AS_DIRNAME([$emacs_val])`/lib/d8.jar
1056   AS_IF([test -f "$emacs_val"],
1057     [AC_CACHE_CHECK([whether d8.jar coresident with d8 binary provides r8],
1058        [emacs_cv_d8_provides_r8],
1059        [AS_IF([java -cp "$emacs_val" com.android.tools.r8.R8 --help &>/dev/null],
1060          [emacs_cv_d8_provides_r8=yes], [emacs_cv_d8_provides_r8=no])])])
1061   AS_IF([test "$emacs_cv_d8_provides_r8" = "yes"],
1062     # And substitute it for D8 if present.
1063     [D8="java -cp $emacs_val com.android.tools.r8.R8"
1064      IS_D8_R8=yes])
1066   AC_PATH_PROGS([ZIPALIGN], [zipalign], [], "${SDK_BUILD_TOOLS}:$PATH")
1067   if test "ZIPALIGN" = ""; then
1068     AC_MSG_ERROR([The Android ZIP archive alignment utility was not found.
1069 Please verify that the path to the SDK build tools you specified is correct]);
1070   fi
1072   dnl Now configure Emacs to generate binaries for Android.  After the
1073   dnl configuration completes, move the generated Makefiles.
1075   if test "$ANDROID_CC" = ""; then
1076     AC_MSG_ERROR([Please specify the path to the Android cross-compiler
1077 for your machine.  For example:
1079   ANDROID_CC=/path/to/armv7a-linux-androideabi19-clang    \\
1080     ./configure --with-android])
1081   fi
1083   dnl Obtain the cross compiler's target to find out where binaries go
1084   dnl in the resulting package.
1086   AC_MSG_CHECKING([for the kind of Android system Emacs is being built for])
1087   cc_target=`${ANDROID_CC} -v 2>&1 | sed -n 's/Target: //p'`
1088   case "$cc_target" in
1090     *i[3-6]86*) android_abi=x86
1091       ;;
1092     *x86_64*) android_abi=x86_64
1093       ;;
1094     *aarch64*) android_abi=arm64-v8a
1095       ;;
1096     *arm*v7a*) android_abi=armeabi-v7a
1097       ;;
1098     *mips64*) android_abi=mips64
1099       ;;
1100     *mips*) android_abi=mips
1101       ;;
1102     *arm*) android_abi=armeabi
1103       ;;
1105     *) AC_MSG_ERROR([configure could not determine the type of Android \
1106 binary Emacs is being configured for.  Please port this configure script \
1107 to your Android system, or verify that you specified the correct compiler \
1108 in the ANDROID_CC variable when you ran configure.
1110 The compiler target is: $cc_target])
1111       ;;
1112   esac
1113   AC_MSG_RESULT([$android_abi])
1115   ANDROID_ABI=$android_abi
1117   dnl Obtain the minimum SDK version of the resulting Emacs binary
1118   dnl built with this NDK.
1120   ANDROID_MIN_SDK=8
1121   AC_MSG_CHECKING([for the lowest Android version Emacs can run on])
1122   [android_sdk=`echo "$cc_target" | grep -oE 'android([0-9][0-9]?)'`]
1124   if test -n "$android_sdk"; then
1125     android_sdk=`echo "$android_sdk" | sed -n 's/android//p'`
1126     AC_MSG_RESULT([$android_sdk])
1127     ANDROID_MIN_SDK=$android_sdk
1128   else
1129     # This is probably GCC.
1130     [ cat << EOF > conftest.c
1131 #include <android/api-level.h>
1132 extern const char *foo;
1135 main (void)
1137 #if __ANDROID_API__ < 7
1138    foo = "emacs_api_6";
1139 #elif __ANDROID_API__ < 8
1140    foo = "emacs_api_7";
1141 #elif __ANDROID_API__ < 9
1142    foo = "emacs_api_8";
1143 #elif __ANDROID_API__ < 10
1144   foo = "emacs_api_9";
1145 #elif __ANDROID_API__ < 11
1146   foo = "emacs_api_10";
1147 #elif __ANDROID_API__ < 12
1148   foo = "emacs_api_11";
1149 #elif __ANDROID_API__ < 13
1150   foo = "emacs_api_12";
1151 #elif __ANDROID_API__ < 14
1152    foo = "emacs_api_13";
1153 #elif __ANDROID_API__ < 15
1154    foo = "emacs_api_14";
1155 #elif __ANDROID_API__ < 16
1156    foo = "emacs_api_15";
1157 #elif __ANDROID_API__ < 17
1158    foo = "emacs_api_16";
1159 #elif __ANDROID_API__ < 18
1160    foo = "emacs_api_17";
1161 #elif __ANDROID_API__ < 19
1162    foo = "emacs_api_18";
1163 #elif __ANDROID_API__ < 20
1164    foo = "emacs_api_19";
1165 #elif __ANDROID_API__ < 21
1166    foo = "emacs_api_20";
1167 #elif __ANDROID_API__ < 22
1168    foo = "emacs_api_21";
1169 #elif __ANDROID_API__ < 23
1170    foo = "emacs_api_22";
1171 #elif __ANDROID_API__ < 24
1172    foo = "emacs_api_23";
1173 #elif __ANDROID_API__ < 25
1174    foo = "emacs_api_24";
1175 #elif __ANDROID_API__ < 26
1176    foo = "emacs_api_25";
1177 #elif __ANDROID_API__ < 27
1178    foo = "emacs_api_26";
1179 #elif __ANDROID_API__ < 28
1180    foo = "emacs_api_27";
1181 #elif __ANDROID_API__ < 29
1182    foo = "emacs_api_28";
1183 #elif __ANDROID_API__ < 30
1184    foo = "emacs_api_29";
1185 #elif __ANDROID_API__ < 31
1186    foo = "emacs_api_30";
1187 #elif __ANDROID_API__ < 32
1188    foo = "emacs_api_31";
1189 #elif __ANDROID_API__ < 33
1190    foo = "emacs_api_32";
1191 #elif __ANDROID_API__ < 34
1192    foo = "emacs_api_33";
1193 #elif __ANDROID_API__ < 35
1194    foo = "emacs_api_34";
1195 #elif __ANDROID_API__ < 36
1196    foo = "emacs_api_35";
1197 #else
1198    foo = "emacs_api_future";
1199 #endif
1201 EOF]
1203     AC_CACHE_VAL([emacs_cv_android_api],
1204                  [$ANDROID_CC $ANDROID_CFLAGS -c conftest.c -o conftest.o \
1205                   && emacs_cv_android_api=`grep -ao -E                    \
1206                      "emacs_api_([[0-9][0-9]]?|future)" conftest.o`])
1207     android_sdk="$emacs_cv_android_api"
1208     rm -rf conftest.c conftest.o
1210     # If this version of the NDK requires __ANDROID_API__ to be
1211     # specified, then complain to the user.
1212     if test "$android_sdk" = "emacs_api_future"; then
1213        AC_MSG_ERROR([The version of Android to build for was not specified.
1214 You must tell the Android compiler what version of Android to build for,
1215 by defining the __ANDROID_API__ preprocessor macro in ANDROID_CC, like so:
1217     ANDROID_CC="/path/to/ndk/arm-linux-android-gcc -D__ANDROID_API__=8"])
1218     fi
1220     if test -n "$android_sdk"; then
1221        android_sdk=`echo $android_sdk | sed -n 's/emacs_api_//p'`
1222        AC_MSG_RESULT([$android_sdk])
1223        ANDROID_MIN_SDK=$android_sdk
1224     else
1225       AC_MSG_RESULT([unknown ($cc_target); assuming 8])
1226       AC_MSG_ERROR([configure could not determine the versions of Android \
1227 a binary built with this compiler will run on.  The generated application \
1228 package will likely install on older systems but crash on startup.])
1229       android_sdk=8
1230     fi
1231   fi
1232   AC_SUBST([ANDROID_MIN_SDK])
1234   # Now tell java/Makefile if Emacs is being built for Android 4.3 or
1235   # earlier.
1236   ANDROID_SDK_18_OR_EARLIER=
1237   if test "$android_sdk" -le "18"; then
1238      ANDROID_SDK_18_OR_EARLIER=yes
1239   fi
1240   AC_SUBST([ANDROID_SDK_18_OR_EARLIER])
1242   # Likewise for Android 2.2.
1243   ANDROID_SDK_8_OR_EARLIER=
1244   if test "$android_sdk" -le "8"; then
1245      ANDROID_SDK_8_OR_EARLIER=yes
1246      AC_CHECK_PROGS([ZIP], [zip])
1247      AS_IF([test -z "$ZIP"],
1248        [AC_MSG_ERROR([The `zip' utility is required for generating \
1249 packages targeting Android 2.2.])])
1250   fi
1251   AC_SUBST([ANDROID_SDK_8_OR_EARLIER])
1252   AC_SUBST([ZIP])
1254   # Save confdefs.h and config.log for now.
1255   mv -f confdefs.h _confdefs.h
1256   mv -f config.log _config.log
1258   # Make sure these files are removed upon exit.
1259   trap "rm -rf _confdefs.h _config.log" 0
1261   # Figure out what --with-FOO options to pass through.
1262   passthrough="$passthrough --with-png=$with_png"
1263   passthrough="$passthrough --with-webp=$with_webp"
1264   passthrough="$passthrough --with-gif=$with_gif"
1265   passthrough="$passthrough --with-jpeg=$with_jpeg"
1266   passthrough="$passthrough --with-xml2=$with_xml2"
1267   passthrough="$passthrough --with-sqlite3=$with_sqlite3"
1268   passthrough="$passthrough --with-gnutls=$with_gnutls"
1269   passthrough="$passthrough --with-tiff=$with_tiff"
1270   passthrough="$passthrough --with-selinux=$with_selinux"
1271   passthrough="$passthrough --with-modules=$with_modules"
1272   passthrough="$passthrough --with-tree-sitter=$with_tree_sitter"
1273   passthrough="$passthrough --with-imagemagick=$with_imagemagick"
1274   passthrough="$passthrough --with-lcms2=$with_lcms2"
1275   passthrough="$passthrough --with-mailutils=$with_mailutils"
1276   passthrough="$passthrough --with-pop=$with_pop"
1277   passthrough="$passthrough --with-harfbuzz=$with_harfbuzz"
1278   passthrough="$passthrough --with-threads=$with_threads"
1279   passthrough="$passthrough --with-rsvg=$with_rsvg"
1281   # Now pass through some checking-related options.
1282   emacs_val="--enable-check-lisp-object-type=$enable_check_lisp_object_type"
1283   passthrough="$passthrough $emacs_val"
1285   # And derive a name for the recursive configure invocation's cache
1286   # file if one should be specified for this.
1287   AS_IF([test -n "$cache_file" && test "$cache_file" != "/dev/null"],
1288     [passthrough="$passthrough --cache-file=$cache_file.1"])
1290   AS_IF([test "x$with_mailutils" = "xyes"], [emacs_use_mailutils=yes])
1291   AC_SUBST([emacs_use_mailutils])
1293   AS_IF([XCONFIGURE=android ANDROID_CC="$ANDROID_CC"            \
1294          ANDROID_SDK="$android_sdk" android_abi=$android_abi    \
1295          android_ndk_path="$with_ndk_path"                      \
1296          android_ndk_cxx="$android_ndk_cxx"                     \
1297          $CONFIG_SHELL $0 $passthrough], [],
1298     [AC_MSG_ERROR([Failed to cross-configure Emacs for android.])])
1300   # Now set ANDROID to yes.
1301   ANDROID=yes
1303   for makefile in $android_makefiles; do
1304     AC_MSG_NOTICE([Generating $makefile.android])
1305     mv -f "$makefile" "$makefile.android"
1306   done
1308   AC_MSG_NOTICE([Generating src/config.h.android])
1309   mv -f src/config.h src/config.h.android
1311   # Tell AndroidManifest.xml whether or not Emacs should be built
1312   # debug.
1313   ANDROID_DEBUGGABLE=false
1314   if test "$with_android_debug" = "yes"; then
1315     ANDROID_DEBUGGABLE=true
1316   fi
1317   AC_SUBST([ANDROID_DEBUGGABLE])
1319   # Move confdefs.h back now that the recursive call to configure is
1320   # complete.
1321   mv -f _confdefs.h confdefs.h
1323   # Move the Android config.log to config.log.android.  */
1324   mv -f config.log config.log.android
1326   # And _config.log back.
1327   mv -f _config.log config.log
1330 AC_SUBST([ANDROID])
1331 AC_SUBST([JAVAC])
1332 AC_SUBST([AAPT])
1333 AC_SUBST([D8])
1334 AC_SUBST([ZIPALIGN])
1335 AC_SUBST([ANDROID_JAR])
1336 AC_SUBST([ANDROID_ABI])
1337 AC_SUBST([IS_D8_R8])
1339 if test "$XCONFIGURE" = "android"; then
1340   ANDROID=yes
1342   # Enable cross compiling.
1343   cross_compiling=yes
1346 AC_SUBST([XCONFIGURE])
1348 if test "$ANDROID" = "yes"; then
1349   # When --with-android is specified, almost all build options must be
1350   # disabled, both within the recursive invocation of configure and
1351   # outside.
1352   with_xpm=no
1354   # Some of these dependencies are now supported within Android, so
1355   # they can be enabled.
1356   if test "$XCONFIGURE" != "android"; then
1357     with_png=no
1358     with_webp=no
1359     with_gif=no
1360     with_jpeg=no
1361     with_xml2=no
1362     with_sqlite3=no
1363     with_gnutls=no
1364     with_tiff=no
1365     with_selinux=no
1366     with_modules=no
1367     with_tree_sitter=no
1368     with_imagemagick=no
1369     with_lcms2=no
1370     with_mailutils=no
1371     with_pop=no
1372     with_harfbuzz=no
1373     with_native_compilation=no
1374     with_threads=no
1375     with_rsvg=no
1376   fi
1378   with_libsystemd=no
1379   with_cairo=no
1380   with_xft=no
1381   with_libotf=no
1382   with_gpm=no
1383   with_dbus=no
1384   with_gsettings=no
1385   with_ns=no
1387   # zlib is available in android.
1390 dnl This used to use changequote, but, apart from 'changequote is evil'
1391 dnl per the autoconf manual, we can speed up autoconf somewhat by quoting
1392 dnl the great gob of text.  Thus it's not processed for possible expansion.
1393 dnl Just make sure the brackets remain balanced.
1395 dnl Since Emacs can't find matching pairs of quotes, boundaries are
1396 dnl indicated by comments.
1397 dnl quotation begins
1400 ### If you add support for a new configuration, add code to this
1401 ### switch statement to recognize your configuration name and select
1402 ### the appropriate opsys.
1404 ### As far as handling version numbers on operating systems is
1405 ### concerned, make sure things will fail in a fixable way.  If
1406 ### /etc/MACHINES doesn't say anything about version numbers, be
1407 ### prepared to handle anything reasonably.  If version numbers
1408 ### matter, be sure /etc/MACHINES says something about it.
1410 opsys='' unported=no
1411 case "${canonical}" in
1413   ## Android
1414   *linux-android* )
1415     opsys=android
1416   ;;
1418   ## GNU/Linux and similar ports
1419   *-*-linux* )
1420     opsys=gnu-linux
1421   ;;
1423   ## FreeBSD ports
1424   *-*-freebsd* )
1425     opsys=freebsd
1426   ;;
1428   ## DragonFly ports
1429   *-*-dragonfly* )
1430     opsys=dragonfly
1431   ;;
1433   ## FreeBSD kernel + glibc based userland
1434   *-*-kfreebsd*gnu* )
1435     opsys=gnu-kfreebsd
1436   ;;
1438   ## NetBSD ports
1439   *-*-netbsd* )
1440     opsys=netbsd
1441   ;;
1443   ## OpenBSD ports
1444   *-*-openbsd* | *-*-mirbsd* )
1445     opsys=openbsd
1446   ;;
1448   ## Apple Darwin / macOS
1449   *-apple-darwin* )
1450     case "${canonical}" in
1451       *-apple-darwin[0-9].*) unported=yes ;;
1452       i[3456]86-* | x86_64-* | arm-* | aarch64-* )  ;;
1453       * )            unported=yes ;;
1454     esac
1455     opsys=darwin
1456     ## FIXME: Find a way to use Fink if available (Bug#11507).
1457   ;;
1459   ## Chromium Native Client
1460   *-nacl )
1461     opsys=nacl
1462   ;;
1464   ## Cygwin ports
1465   *-*-cygwin )
1466     opsys=cygwin
1467   ;;
1469   ## HP 9000 series 700 and 800, running HP/UX
1470   hppa*-hp-hpux10.2* )
1471     opsys=hpux10-20
1472   ;;
1473   hppa*-hp-hpux1[1-9]* )
1474     opsys=hpux11
1475     CFLAGS="-D_INCLUDE__STDC_A1_SOURCE $CFLAGS"
1476   ;;
1478   ## IBM machines
1479   rs6000-ibm-aix4.[23]* )
1480     opsys=aix4-2
1481   ;;
1482   powerpc-ibm-aix4.[23]*  )
1483     opsys=aix4-2
1484   ;;
1485   rs6000-ibm-aix[56]* )
1486     opsys=aix4-2
1487   ;;
1488   powerpc-ibm-aix[5-9]* | powerpc-ibm-aix[1-9][0-9]* )
1489     opsys=aix4-2
1490   ;;
1492   ## Solaris
1493   *-*-solaris* | *-*-sunos*)
1494     case "${canonical}" in
1495       i[3456]86-*-* )   ;;
1496       amd64-*-*|x86_64-*-*) ;;
1497       sparc* )          ;;
1498       * )               unported=yes ;;
1499     esac
1500     opsys=solaris
1501     ## Watch out for a compiler that we know will not work.
1502     if [ "$CC" = /usr/ucb/cc ]; then
1503       ## /usr/ucb/cc doesn't work;
1504       ## we should find some other compiler that does work.
1505       unset CC
1506     fi
1507   ;;
1509   ## QNX Neutrino
1510   *-nto-qnx* )
1511     opsys=qnxnto
1512     test -z "$CC" && CC=qcc
1513     LDFLAGS="-N2M $LDFLAGS"
1514   ;;
1516   *-haiku )
1517     opsys=haiku
1518   ;;
1520   ## Intel 386 machines where we don't care about the manufacturer.
1521   i[3456]86-*-* )
1522     case "${canonical}" in
1523       *-darwin* )               opsys=darwin ;;
1524       *-mingw* )
1525                 opsys=mingw32
1526                 # MinGW overrides and adds some system headers in nt/inc.
1527                 # Also, GCC 14 turns on implicit-function-declaration
1528                 # error by default, which fails configure tests where our
1529                 # emulation of Posix headers defines only the minimal
1530                 # stuff we actually need.
1531                 GCC_TEST_OPTIONS="-I $srcdir/nt/inc -Wno-error=implicit-function-declaration"
1532                 ;;
1533       *-sysv4.2uw* )            opsys=unixware ;;
1534       *-sysv5uw* )              opsys=unixware ;;
1535       *-sysv5OpenUNIX* )        opsys=unixware ;;
1536       ## Otherwise, we'll fall through to the generic opsys code at the bottom.
1537     esac
1538   ;;
1540   # MinGW64
1541   x86_64-*-* )
1542     case "${canonical}" in
1543       *-mingw* )
1544                 opsys=mingw32
1545                 # MinGW overrides and adds some system headers in nt/inc.
1546                 GCC_TEST_OPTIONS="-I $srcdir/nt/inc -Wno-error=implicit-function-declaration"
1547                 ;;
1548       ## Otherwise, we'll fall through to the generic opsys code at the bottom.
1549     esac
1550   ;;
1552   * )
1553     unported=yes
1554   ;;
1555 esac
1557 ### If the code above didn't choose an operating system, just choose
1558 ### an operating system based on the configuration name.  You really
1559 ### only want to use this when you have no idea what the right
1560 ### operating system is; if you know what operating systems a machine
1561 ### runs, it's cleaner to make it explicit in the case statement
1562 ### above.
1563 if test x"${opsys}" = x; then
1564   case "${canonical}" in
1565     *-gnu* )                            opsys=gnu ;;
1566     * )
1567       unported=yes
1568     ;;
1569   esac
1573 dnl quotation ends
1575 if test $unported = yes; then
1576   AC_MSG_ERROR([Emacs does not support '${canonical}' systems.
1577 If you think it should, please send a report to ${PACKAGE_BUGREPORT}.
1578 Check 'etc/MACHINES' for recognized configuration names.])
1581 #### Choose a compiler.
1583 dnl Don't bother to test for C89.
1584 AC_DEFUN([_AC_PROG_CC_C89], [$2])
1586 dnl Sets GCC=yes if using gcc.
1587 AC_PROG_CC([gcc cc cl clang "$XCRUN gcc" "$XCRUN clang"])
1589 if test -n "$XCRUN"; then
1590   AC_CHECK_PROGS([AR], [ar "$XCRUN ar"])
1591   test -n "$AR" && export AR
1594 dnl Emacs needs C99 or later.
1595 gl_PROG_CC_C99
1597 AC_PROG_CC_C_O
1599 if test x$GCC = xyes; then
1600   test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
1603 # Avoid gnulib's tests for -lcrypto, so that there's no static dependency on it.
1604 AC_DEFUN([gl_CRYPTO_CHECK])
1605 # Avoid gnulib's tests for HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW,
1606 # as we don't use them.
1607 AC_DEFUN([gl_FCNTL_O_FLAGS])
1608 # Avoid gnulib's test for pthread_sigmask.
1609 funcs=
1610 for func in $ac_func_list; do
1611   test $func = pthread_sigmask || AS_VAR_APPEND([funcs], [" $func"])
1612 done
1613 ac_func_list=$funcs
1614 # Emacs does not use the wchar or wctype-h modules.
1615 AC_DEFUN([gt_TYPE_WINT_T],
1616   [GNULIBHEADERS_OVERRIDE_WINT_T=0
1617    AC_SUBST([GNULIBHEADERS_OVERRIDE_WINT_T])])
1618 # Emacs does not need precise checks for the Solaris 10 MB_CUR_MAX bug.
1619 AC_DEFUN_ONCE([gl_STDLIB_H],
1620   [AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
1621    gl_NEXT_HEADERS([stdlib.h])])
1622 # Emacs does not need to check for off64_t.
1623 AC_DEFUN([gl_TYPE_OFF64_T],
1624   [HAVE_OFF64_T=1
1625    AC_SUBST([HAVE_OFF64_T])])
1627 # Initialize gnulib right after choosing the compiler.
1628 dnl Amongst other things, this sets AR and ARFLAGS.
1629 gl_EARLY
1631 # ndk_LATE must be enclosed in this conditional to prevent the
1632 # AC_PROG_CXX it indirectly requires from being expanded at top level.
1633 if test "$ndk_INITIALIZED" = "yes"; then
1634   ndk_LATE_EARLY
1635   ndk_LATE
1638 if test "$ac_test_CFLAGS" != set; then
1639   # It's helpful to have C macros available to GDB, so prefer -g3 to -g
1640   # if -g3 works and the user does not specify CFLAGS.
1641   # This test must follow gl_EARLY; otherwise AC_LINK_IFELSE complains.
1642   case $CFLAGS in
1643     '-g')
1644       emacs_g3_CFLAGS='-g3';;
1645     '-g -O2')
1646       emacs_g3_CFLAGS='-g3 -O2';;
1647     *)
1648       emacs_g3_CFLAGS='';;
1649   esac
1650   if test -n "$emacs_g3_CFLAGS"; then
1651     emacs_save_CFLAGS=$CFLAGS
1652     CFLAGS=$emacs_g3_CFLAGS
1653     AC_CACHE_CHECK([whether $CC accepts $emacs_g3_CFLAGS],
1654       [emacs_cv_prog_cc_g3],
1655       [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
1656          [emacs_cv_prog_cc_g3=yes],
1657          [emacs_cv_prog_cc_g3=no])])
1658     if test $emacs_cv_prog_cc_g3 != yes; then
1659       CFLAGS=$emacs_save_CFLAGS
1660     fi
1661     # Haiku also needs -gdwarf-2 because its GDB is too old
1662     # to understand newer formats.
1663     if test $opsys = mingw32 || test $opsys = haiku; then
1664       CFLAGS="$CFLAGS -gdwarf-2"
1665     fi
1666   fi
1668   case $CFLAGS in
1669     *-O*) ;;
1670     *)
1671       # No optimization flag was inferred for this non-GCC compiler.
1672       # Try -O.  This is needed for xlc on AIX; see Bug#14258.
1673       emacs_save_CFLAGS=$CFLAGS
1674       test -z "$CFLAGS" || CFLAGS="$CFLAGS "
1675       CFLAGS=${CFLAGS}-O
1676       AC_CACHE_CHECK([whether $CC accepts -O],
1677         [emacs_cv_prog_cc_o],
1678         [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
1679            [emacs_cv_prog_cc_o=yes],
1680            [emacs_cv_prog_cc_o=no])])
1681       if test $emacs_cv_prog_cc_o != yes; then
1682         CFLAGS=$emacs_save_CFLAGS
1683       fi ;;
1684   esac
1687 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
1688 # ---------------------------------------------------------------------------
1689 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
1690 # Otherwise, run RUN-IF-NOT-FOUND.
1691 AC_DEFUN([gl_GCC_VERSION_IFELSE],
1692   [AC_PREPROC_IFELSE(
1693     [AC_LANG_PROGRAM(
1694       [[
1695 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
1696 /* ok */
1697 #else
1698 # error "your version of gcc is older than $1.$2"
1699 #endif
1700       ]]),
1701     ], [$3], [$4])
1702   ]
1705 # clang is unduly picky about some things.
1706 AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang],
1707   [AC_COMPILE_IFELSE(
1708      [AC_LANG_PROGRAM([[
1709           #ifndef __clang__
1710             error "not clang";
1711           #endif
1712         ]])],
1713      [emacs_cv_clang=yes],
1714      [emacs_cv_clang=no])])
1716 AC_ARG_ENABLE([gcc-warnings],
1717   [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
1718                   [control generation of GCC warnings.  The TYPE 'yes'
1719                    means to fail if any warnings are issued; 'warn-only'
1720                    means issue warnings without failing (default for
1721                    developer builds); 'no' means disable warnings
1722                    (default for non-developer builds).])],
1723   [case $enableval in
1724      yes|no|warn-only) ;;
1725      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
1726    esac
1727    gl_gcc_warnings=$enableval],
1728   [# By default, use 'warn-only' if it looks like the invoker of 'configure'
1729    # is a developer as opposed to a builder.  This is most likely true
1730    # if GCC is recent enough and there is a .git directory or file;
1731    # however, if there is also a .tarball-version file it is probably
1732    # just a release imported into Git for patch management.
1733    gl_gcc_warnings=no
1734    AS_IF([test -d "$srcdir"/.git || test -f "$srcdir"/.git],
1735      [AS_IF([test -f "$srcdir"/.tarball-version], [],
1736         # Clang typically identifies itself as GCC 4.2 or something similar
1737         # even if it is recent enough to accept the warnings we enable.
1738         [AS_IF([test "$emacs_cv_clang" = yes],
1739            [gl_gcc_warnings=warn-only],
1740            [gl_GCC_VERSION_IFELSE([5], [3], [gl_gcc_warnings=warn-only])])])])])
1742 NATIVE_COMPILATION_AOT=no
1743 AC_ARG_WITH([native-compilation],
1744   [AS_HELP_STRING([--with-native-compilation@<:@=TYPE@:>@],
1745                   [compile with Emacs Lisp native compiler support.  The TYPE
1746                    'yes' (or empty) means to enable it and compile natively
1747                    preloaded Lisp files; 'no' means to disable it;
1748                    'aot' will make the build process compile all the Lisp
1749                    files in the tree natively ahead of time.  (This will
1750                    usually be quite slow.)])],
1751   [
1752   case $withval in
1753      aot)
1754        withval=yes
1755        NATIVE_COMPILATION_AOT=yes
1756        ;;
1757      yes|no) ;;
1758      *)      AC_MSG_ERROR([bad value $withval for native-compilation option]) ;;
1759    esac
1760    with_native_compilation=$withval],
1761   [with_native_compilation=default]
1763 AC_SUBST([NATIVE_COMPILATION_AOT])
1765 AC_ARG_ENABLE([check-lisp-object-type],
1766   [AS_HELP_STRING([--enable-check-lisp-object-type],
1767      [Enable compile time checks for the Lisp_Object data type,
1768       which can catch some bugs during development.])])
1769 if test "$enable_check_lisp_object_type" = yes; then
1770   AC_DEFINE([CHECK_LISP_OBJECT_TYPE], [1],
1771     [Define to enable compile-time checks for the Lisp_Object data type.])
1774 WERROR_CFLAGS=
1775 # When compiling with GCC, prefer -isystem to -I when including system
1776 # include files, to avoid generating useless diagnostics for the files.
1777 AS_IF([test $gl_gcc_warnings = no],
1779   isystem='-I'
1780   AS_IF([test "$emacs_cv_clang" = yes],
1781    [
1782      # Turn off some warnings if supported.
1783      gl_WARN_ADD([-Wno-pointer-sign])
1784      gl_WARN_ADD([-Wno-string-plus-int])
1785      gl_WARN_ADD([-Wno-unknown-attributes])
1786      gl_WARN_ADD([-Wno-unknown-pragmas])
1787    ])
1788  ],[
1789   isystem='-isystem '
1791   # This, $nw, is the list of warnings we disable.
1792   nw=
1794   case $with_x_toolkit in
1795     lucid | athena | motif)
1796        # Old toolkits mishandle 'const'.
1797        nw="$nw -Wwrite-strings"
1798        ;;
1799   esac
1800   AS_IF([test $gl_gcc_warnings = yes],
1801     [WERROR_CFLAGS=-Werror],
1802     [# Use -fanalyzer and related options only if --enable-gcc-warnings,
1803      # as they slow GCC considerably.
1804      nw="$nw -fanalyzer -Wno-analyzer-double-free -Wno-analyzer-malloc-leak"
1805      nw="$nw -Wno-analyzer-null-dereference -Wno-analyzer-use-after-free"
1806      # Use -Wsuggest-attribute=malloc only if --enable-gcc-warnings,
1807      # as it doesn't flag code that is wrong in any way.
1808      nw="$nw -Wsuggest-attribute=malloc"])
1810   nw="$nw -Wcast-align=strict"      # Emacs is tricky with pointers.
1811   nw="$nw -Wduplicated-branches"    # Too many false alarms
1812   nw="$nw -Wformat-overflow=2"      # False alarms due to GCC bug 110333
1813   nw="$nw -Woverlength-strings"     # Not a problem these days
1814   nw="$nw -Wvla"                    # Emacs uses <vla.h>.
1815   nw="$nw -Wunused-const-variable=2" # lisp.h declares const objects.
1816   nw="$nw -Winline"                 # OK to ignore 'inline'
1817   nw="$nw -Wstrict-overflow"        # OK to optimize assuming that
1818                                     # signed overflow has undefined behavior
1819   nw="$nw -Wsync-nand"              # irrelevant here, and provokes ObjC warning
1820   nw="$nw -Wunsafe-loop-optimizations" # OK to suppress unsafe optimizations
1821   nw="$nw -Wbad-function-cast"      # These casts are no worse than others.
1823   # Emacs doesn't care about shadowing; see
1824   # <https://lists.gnu.org/r/emacs-diffs/2011-11/msg00265.html>.
1825   nw="$nw -Wshadow"
1827   # Emacs's use of alloca inhibits protecting the stack.
1828   nw="$nw -Wstack-protector"
1830   # Emacs's use of __attribute__ ((cold)) causes false alarms with this option.
1831   nw="$nw -Wsuggest-attribute=cold"
1833   # Emacs's use of partly-const functions such as Fgnutls_available_p
1834   # make this option problematic.
1835   nw="$nw -Wsuggest-attribute=const"
1837   # Emacs's use of partly-pure functions such as CHECK_TYPE make this
1838   # option problematic.
1839   nw="$nw -Wsuggest-attribute=pure"
1841   # Emacs doesn't need this paranoia.
1842   nw="$nw -Wbidi-chars=any,ucn"
1844   if test "$emacs_cv_clang" = yes; then
1845     nw="$nw -Wdouble-promotion"
1846     nm="$nm -Wunknown-pragmas"
1847   fi
1849   # This causes too much noise in the MinGW build.
1850   if test $opsys = mingw32; then
1851     nw="$nw -Wsuggest-attribute=format"
1852   fi
1854   # If Emacs is being built for Android and many functions are
1855   # currently stubbed out for operation on the build machine, disable
1856   # -Wsuggest-attribute=noreturn.
1858   AS_IF([test "$ANDROID" = "yes"],
1859     [nw="$nw -Wsuggest-attribute=noreturn"])
1861   gl_MANYWARN_ALL_GCC([ws])
1862   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
1863   for w in $ws; do
1864     gl_WARN_ADD([$w])
1865   done
1866   gl_WARN_ADD([-Wredundant-decls])     # Prefer this, as we don't use Bison.
1867   gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
1868   gl_WARN_ADD([-Wno-override-init])    # More trouble than it is worth
1869   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
1870   gl_WARN_ADD([-Wno-type-limits])      # Too many warnings for now
1871   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
1872   gl_WARN_ADD([-Wno-format-nonliteral])
1873   gl_WARN_ADD([-Wno-bidi-chars])
1874   AS_IF([test $gl_gcc_warnings = yes],
1875     [gl_WARN_ADD([-Wno-analyzer-fd-leak])]) # GCC bug 109839
1877   # clang is unduly picky about some things.
1878   if test "$emacs_cv_clang" = yes; then
1879     gl_WARN_ADD([-Wno-bitwise-instead-of-logical])
1880     gl_WARN_ADD([-Wno-missing-braces])
1881     gl_WARN_ADD([-Wno-null-pointer-arithmetic])
1882     gl_WARN_ADD([-Wno-implicit-const-int-float-conversion])
1883     gl_WARN_ADD([-Wno-int-in-bool-context])
1884     gl_WARN_ADD([-Wno-shift-overflow])
1885   fi
1887   # This causes too much noise in the MinGW build
1888   if test $opsys = mingw32; then
1889     gl_WARN_ADD([-Wno-pointer-sign])
1890   fi
1892   AC_DEFINE([GCC_LINT], [1], [Define to 1 if --enable-gcc-warnings.])
1893   AS_IF([test $gl_gcc_warnings = yes],
1894     [AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
1895      AH_VERBATIM([GNULIB_PORTCHECK_FORTIFY_SOURCE],
1896      [/* Enable compile-time and run-time bounds-checking, and some warnings,
1897          without upsetting glibc 2.15+. */
1898       #if (defined GNULIB_PORTCHECK && !defined _FORTIFY_SOURCE \
1899            && defined __OPTIMIZE__ && __OPTIMIZE__)
1900       # define _FORTIFY_SOURCE 2
1901       #endif
1902      ])])
1903  ])
1905 # clang is picky about these regardless of whether
1906 # --enable-gcc-warnings is specified.
1907 if test "$emacs_cv_clang" = yes; then
1908   gl_WARN_ADD([-Wno-initializer-overrides])
1909   gl_WARN_ADD([-Wno-tautological-compare])
1910   gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
1913 # Suppress deprecation warnings from using sprintf variants,
1914 # starting with Xcode 14.1 on macOS 13.
1915 # These warnings are false alarms, as Emacs usage of sprintf is safe.
1916 if test $opsys = darwin; then
1917   gl_WARN_ADD([-Wno-deprecated-declarations])
1920 # Use a slightly smaller set of warning options for lib/.
1922 nw="$nw -Wunused-macros"
1923 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
1925 AC_SUBST([WERROR_CFLAGS])
1926 AC_SUBST([GNULIB_WARN_CFLAGS])
1928 edit_cflags="
1929   s,///*,/,g
1930   s/^/ /
1931   s/ -I/ $isystem/g
1932   s/^ //
1935 AC_ARG_ENABLE([link-time-optimization],
1936 [AS_HELP_STRING([--enable-link-time-optimization],
1937                 [build with link-time optimization
1938                  (experimental; see INSTALL)])],
1939 if test "${enableval}" != "no"; then
1940    ac_lto_supported=no
1941    if test "$emacs_cv_clang" = yes; then
1942       AC_MSG_CHECKING([whether link-time optimization is supported by clang])
1943       GOLD_PLUGIN=`$CC -print-file-name=LLVMgold.so 2>/dev/null`
1944       if test -x "$GOLD_PLUGIN"; then
1945          LTO="-flto"
1946       fi
1947    elif test x$GCC = xyes; then
1948       AC_MSG_CHECKING([whether link-time optimization is supported by gcc])
1949       CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
1950       if test x$CPUS != x; then
1951          LTO="-flto=$CPUS"
1952       else
1953          LTO="-flto"
1954       fi
1955    else
1956       AC_MSG_ERROR([Link-time optimization is not supported with your compiler.])
1957    fi
1958    if test -z "$LTO"; then
1959       ac_lto_supported=no
1960    else
1961       old_CFLAGS=$CFLAGS
1962       CFLAGS="$CFLAGS $LTO"
1963       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1964          [ac_lto_supported=yes], [ac_lto_supported=no])
1965          CFLAGS="$old_CFLAGS"
1966    fi
1967    AC_MSG_RESULT([$ac_lto_supported])
1968    if test "$ac_lto_supported" = "yes"; then
1969       CFLAGS="$CFLAGS $LTO"
1970       if test "$emacs_cv_clang" = yes; then
1971          AC_MSG_WARN([Please read INSTALL before using link-time optimization with clang])
1972          # WARNING: 'ar --plugin ...' doesn't work without
1973          # command, so plugin name is appended to ARFLAGS.
1974          ARFLAGS="cru --plugin $GOLD_PLUGIN"
1975          RANLIB="$RANLIB --plugin $GOLD_PLUGIN"
1976       else
1977         dnl The following is needed for GCC 4.9.0.  The GCC 4.9.0 release notes
1978         dnl suggest that instead of -ffat-lto-objects we should use gcc-ar and
1979         dnl gcc-ranlib in place of ar and ranlib, but gcc-ar makes /usr/bin/ar
1980         dnl dump core on Fedora 20, so play it safe for now.
1981         gl_COMPILER_OPTION_IF([-ffat-lto-objects],
1982           [CFLAGS="$CFLAGS -ffat-lto-objects"])
1983       fi
1984    fi
1988 dnl Automake replacements.
1989 AC_DEFUN([AM_CONDITIONAL],
1990   [$2 && $1_CONDITION=1 || $1_CONDITION=
1991    AC_SUBST([$1_CONDITION])])
1992 AC_DEFUN([AM_COND_IF],
1993   [AS_IF([test "$$1_CONDITION"], [$2], [$3])])
1995 dnl Prefer silent make output.  For verbose output, use
1996 dnl 'configure --disable-silent-rules' or 'make V=1' .
1997 AC_ARG_ENABLE([silent-rules],
1998   [AS_HELP_STRING(
1999      [--disable-silent-rules],
2000      [verbose build output (undo: "make V=0")])])
2001 if test "$enable_silent_rules" = no; then
2002   AM_DEFAULT_VERBOSITY=1
2003 else
2004   AM_DEFAULT_VERBOSITY=0
2006 AC_SUBST([AM_DEFAULT_VERBOSITY])
2007 ARCH_INDEPENDENT_CONFIG_FILES([src/verbose.mk])
2009 dnl Some other nice autoconf tests.
2010 AC_PROG_INSTALL
2011 dnl These are commented out, since gl_EARLY and/or Autoconf already does them.
2012 dnl AC_PROG_MKDIR_P
2013 dnl if test "x$RANLIB" = x; then
2014 dnl   AC_PROG_RANLIB
2015 dnl fi
2018 dnl Sadly, AC_PROG_LN_S is too restrictive.  It also tests whether links
2019 dnl can be made to directories.  This is not relevant for our usage, and
2020 dnl excludes some cases that work fine for us.  Eg MS Windows or files
2021 dnl hosted on AFS, both examples where simple links work, but links to
2022 dnl directories fail.  We use a cut-down version instead.
2023 dnl AC_PROG_LN_S
2025 AC_CACHE_CHECK([command to symlink files in the same directory], [emacs_cv_ln_s_fileonly],
2026 [rm -f conf$$ conf$$.file
2028 emacs_cv_ln_s_fileonly='cp -p'
2030 dnl On MinGW, ensure we will call the MSYS /bin/ln.exe, not some
2031 dnl random program in the current directory.
2032 if (echo >conf$$.file) 2>/dev/null; then
2033   if test "$opsys" = "mingw32"; then
2034     emacs_cv_ln_s_fileonly=/bin/ln
2035   elif ln -s conf$$.file conf$$ 2>/dev/null; then
2036     emacs_cv_ln_s_fileonly='ln -s'
2037   elif ln conf$$.file conf$$ 2>/dev/null; then
2038     emacs_cv_ln_s_fileonly=ln
2039   fi
2042 rm -f conf$$ conf$$.file])
2043 LN_S_FILEONLY=$emacs_cv_ln_s_fileonly
2045 AC_SUBST([LN_S_FILEONLY])
2048 dnl AC_PROG_LN_S sets LN_S to 'cp -pR' for MinGW, on the premise that 'ln'
2049 dnl doesn't support links to directories, as in "ln file dir".  But that
2050 dnl use is non-portable, and OTOH MinGW wants to use hard links for Emacs
2051 dnl executables at "make install" time.
2052 dnl See https://lists.gnu.org/r/emacs-devel/2013-04/msg00475.html
2053 dnl for more details.
2054 if test "$opsys" = "mingw32"; then
2055   LN_S="/bin/ln"
2058 dnl On some Debian versions, "install-info" prints irritating messages
2059 dnl "This is not dpkg install-info anymore, but GNU install-info"
2060 dnl if called via an absolute file name.
2061 dnl Use the entirely-identical-but-quieter ginstall-info instead if present.
2062 dnl Sadly some people may have an old ginstall-info installed on
2063 dnl non-Debian systems, so we can't use this.
2064 dnl AC_PATH_PROGS([INSTALL_INFO], [ginstall-info install-info], [:],
2065 dnl   [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin])
2067 AC_PATH_PROG([INSTALL_INFO], [install-info], [:],
2068   [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin])
2069 dnl Don't use GZIP, which is used by gzip for additional parameters.
2070 AC_PATH_PROG([GZIP_PROG], [gzip])
2072 test $with_compress_install != yes && test -n "$GZIP_PROG" && \
2073    GZIP_PROG=" # $GZIP_PROG # (disabled by configure --without-compress-install)"
2075 if test "$with_dumping" = "unexec" && test "$opsys" = "nacl"; then
2076   AC_MSG_ERROR([nacl is not compatible with --with-dumping=unexec])
2079 AC_CACHE_CHECK([for 'find' args to delete a file],
2080   [emacs_cv_find_delete],
2081   [if touch conftest.tmp && find conftest.tmp -delete 2>/dev/null &&
2082       test ! -f conftest.tmp
2083    then emacs_cv_find_delete="-delete"
2084    else emacs_cv_find_delete="-exec rm -f {} +"
2085    fi])
2086 FIND_DELETE=$emacs_cv_find_delete
2087 AC_SUBST([FIND_DELETE])
2089 PAXCTL_dumped=
2090 PAXCTL_notdumped=
2091 if test $with_unexec = yes && test $opsys = gnu-linux; then
2092   if test "${SETFATTR+set}" != set; then
2093     AC_CACHE_CHECK([for setfattr],
2094       [emacs_cv_prog_setfattr],
2095       [touch conftest.tmp
2096        if (setfattr -n user.pax.flags conftest.tmp) >/dev/null 2>&1; then
2097          emacs_cv_prog_setfattr=yes
2098        else
2099          emacs_cv_prog_setfattr=no
2100        fi])
2101     if test "$emacs_cv_prog_setfattr" = yes; then
2102       PAXCTL_notdumped='$(SETFATTR) -n user.pax.flags -v er'
2103       SETFATTR=setfattr
2104     else
2105       SETFATTR=
2106     fi
2107   fi
2108   case $opsys,$PAXCTL_notdumped,$emacs_uname_r in
2109     gnu-linux,,* | netbsd,,[0-7].*)
2110       AC_PATH_PROG([PAXCTL], [paxctl], [],
2111         [$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin])
2112       if test -n "$PAXCTL"; then
2113         if test "$opsys" = netbsd; then
2114           PAXCTL_dumped='$(PAXCTL) +a'
2115           PAXCTL_notdumped=$PAXCTL_dumped
2116         else
2117           AC_MSG_CHECKING([whether binaries have a PT_PAX_FLAGS header])
2118           AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
2119             [if $PAXCTL -v conftest$EXEEXT >/dev/null 2>&1; then
2120                AC_MSG_RESULT([yes])
2121              else
2122                AC_MSG_RESULT([no])
2123                PAXCTL=
2124              fi])
2125           if test -n "$PAXCTL"; then
2126             PAXCTL_dumped='$(PAXCTL) -zex'
2127             PAXCTL_notdumped='$(PAXCTL) -r'
2128           fi
2129         fi
2130       fi;;
2131   esac
2133 AC_SUBST([PAXCTL_dumped])
2134 AC_SUBST([PAXCTL_notdumped])
2135 AC_SUBST([SETFATTR])
2137 # Makeinfo on macOS is ancient, check whether there is a more recent
2138 # version installed by Homebrew.
2139 AC_CHECK_PROGS([BREW], [brew])
2140 if test -n "$BREW"; then
2141   AC_PATH_PROG([MAKEINFO], [makeinfo], [],
2142     [`$BREW --prefix texinfo 2>/dev/null`/bin$PATH_SEPARATOR$PATH])
2145 # Check MacPorts on macOS.
2146 if test $opsys = darwin; then
2147   AC_PATH_PROG([HAVE_MACPORTS], [port])
2150 ## Require makeinfo >= 4.13 (last of the 4.x series) to build the manuals.
2151 : ${MAKEINFO:=makeinfo}
2152 case `($MAKEINFO --version) 2>/dev/null` in
2153   *' (GNU texinfo) '4.1[[3-9]]* | \
2154   *' (GNU texinfo) '[[5-9]]* | \
2155   *' (GNU texinfo) '[[1-9][0-9]]* ) ;;
2156   *) MAKEINFO=no;;
2157 esac
2159 ## Makeinfo is unusual.  For a released Emacs, the manuals are
2160 ## pre-built, and not deleted by the normal clean rules.  makeinfo is
2161 ## therefore in the category of "special tools" not normally required, which
2162 ## configure does not have to check for (eg autoconf itself).
2163 ## In a repository checkout on the other hand, the manuals are not included.
2164 ## So makeinfo is a requirement to build from the repository, and configure
2165 ## should test for it as it does for any other build requirement.
2166 ## We use the presence of $srcdir/info/emacs to distinguish a release,
2167 ## with pre-built manuals, from a repository checkout.
2168 if test "$MAKEINFO" = "no"; then
2169   MAKEINFO=makeinfo
2170   if test ! -e "$srcdir/info/emacs" && test ! -e "$srcdir/info/emacs.info"; then
2171     AC_MSG_ERROR( [You do not seem to have makeinfo >= 4.13, and your
2172 source tree does not seem to have pre-built manuals in the 'info' directory.
2173 Please install a suitable version of makeinfo.] )
2174   else
2175     AC_MSG_WARN( [You do not seem to have makeinfo >= 4.13.
2176 You will not be able to rebuild the manuals if you delete them or change
2177 their sources.] )
2178   fi
2180 AC_SUBST([MAKEINFO])
2182 if test $opsys = mingw32; then
2183    DOCMISC_W32=efaq-w32
2184 else
2185    DOCMISC_W32=
2187 AC_SUBST([DOCMISC_W32])
2189 dnl Add our options to ac_link now, after it is set up.
2191 if test x$GCC = xyes; then
2192   test "x$GCC_LINK_TEST_OPTIONS" != x && \
2193     ac_link="$ac_link $GCC_LINK_TEST_OPTIONS"
2194 else
2195   test "x$NON_GCC_LINK_TEST_OPTIONS" != x && \
2196     ac_link="$ac_link $NON_GCC_LINK_TEST_OPTIONS"
2199 dnl On some platforms using GNU ld, linking temacs needs -znocombreloc.
2200 dnl Although this has something to do with dumping, the details are unknown.
2201 dnl If the flag is used but not needed,
2202 dnl Emacs should still work (albeit a bit more slowly),
2203 dnl so use the flag everywhere that it is supported.
2204 dnl When testing whether the flag works, treat GCC specially
2205 dnl since it just gives a non-fatal 'unrecognized option'
2206 dnl if not built to support GNU ld.
2207 if test "$GCC" = yes; then
2208   LDFLAGS_NOCOMBRELOC="-Wl,-znocombreloc"
2209 else
2210   LDFLAGS_NOCOMBRELOC="-znocombreloc"
2213 AC_CACHE_CHECK([for -znocombreloc], [emacs_cv_znocombreloc],
2214   [if test $with_unexec = no; then
2215      emacs_cv_znocombreloc='not needed'
2216    else
2217      save_LDFLAGS=$LDFLAGS
2218      LDFLAGS="$LDFLAGS $LDFLAGS_NOCOMBRELOC"
2219      AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
2220        [emacs_cv_znocombreloc=yes], [emacs_cv_znocombreloc=no])
2221      LDFLAGS=$save_LDFLAGS
2222    fi])
2224 case $emacs_cv_znocombreloc in
2225   no*)
2226     LDFLAGS_NOCOMBRELOC= ;;
2227 esac
2230 AC_CACHE_CHECK([whether addresses are sanitized],
2231   [emacs_cv_sanitize_address],
2232   [AC_COMPILE_IFELSE(
2233      [AC_LANG_PROGRAM(
2234         [[#ifndef __has_feature
2235           #define __has_feature(f) 0
2236           #endif
2237           #if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
2238           #else
2239            error "Addresses are not sanitized.";
2240           #endif
2241         ]])],
2242      [emacs_cv_sanitize_address=yes],
2243      [emacs_cv_sanitize_address=no])])
2245 if test $with_unexec = yes; then
2246   AC_DEFINE([HAVE_UNEXEC], [1], [Define if Emacs supports unexec.])
2247   if test "$emacs_cv_sanitize_address" = yes; then
2248     AC_MSG_WARN([[Addresses are sanitized; suggest --without-unexec]])
2249   fi
2253 UNEXEC_OBJ=
2254 test $with_unexec = yes &&
2255 case "$opsys" in
2256   # MSDOS uses unexcoff.o
2257   aix4-2)
2258    UNEXEC_OBJ=unexaix.o
2259    ;;
2260   cygwin)
2261    UNEXEC_OBJ=unexcw.o
2262    ;;
2263   darwin)
2264    UNEXEC_OBJ=unexmacosx.o
2265    ;;
2266   hpux10-20 | hpux11)
2267    UNEXEC_OBJ=unexhp9k800.o
2268    ;;
2269   mingw32)
2270    UNEXEC_OBJ=unexw32.o
2271    ;;
2272   solaris)
2273    # Use the Solaris dldump() function, called from unexsol.c, to dump
2274    # emacs, instead of the generic ELF dump code found in unexelf.c.
2275    # The resulting binary has a complete symbol table, and is better
2276    # for debugging and other observability tools (debuggers, pstack, etc).
2277    UNEXEC_OBJ=unexsol.o
2278    ;;
2279   *)
2280    UNEXEC_OBJ=unexelf.o
2281    ;;
2282 esac
2283 AC_SUBST([UNEXEC_OBJ])
2285 LD_SWITCH_SYSTEM=
2286 test "$with_unexec" = no || case "$opsys" in
2287   freebsd|dragonfly)
2288    ## Let 'ld' find image libs and similar things in /usr/local/lib.
2289    ## The system compiler, GCC, has apparently been modified to not
2290    ## look there, contrary to what a stock GCC would do.
2291 ### It's not our place to do this.  See bug#10313#17.
2292 ###   LD_SWITCH_SYSTEM=-L/usr/local/lib
2293       :
2294    ;;
2296   gnu-linux)
2297    ## cpp test was "ifdef __mips__", but presumably this is equivalent...
2298    case $host_cpu in mips*) LD_SWITCH_SYSTEM="-G 0";; esac
2299    ;;
2301   netbsd)
2302 ### It's not our place to do this.  See bug#10313#17.
2303 ###   LD_SWITCH_SYSTEM="-Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib"
2304       :
2305    ;;
2307   openbsd)
2308    ## Han Boetes <han@boetes.org> says this is necessary,
2309    ## otherwise Emacs dumps core on elf systems.
2310    LD_SWITCH_SYSTEM="-Z"
2311    ;;
2312 esac
2313 AC_SUBST([LD_SWITCH_SYSTEM])
2315 ac_link="$ac_link $LD_SWITCH_SYSTEM"
2317 ## This setting of LD_SWITCH_SYSTEM references LD_SWITCH_X_SITE_RPATH,
2318 ## which has not been defined yet.  When this was handled with cpp,
2319 ## it was expanded to null when configure sourced the s/*.h file.
2320 ## Thus LD_SWITCH_SYSTEM had different values in configure and the Makefiles.
2321 ## FIXME it would be cleaner to put this in LD_SWITCH_SYSTEM_TEMACS
2322 ## (or somesuch), but because it is supposed to go at the _front_
2323 ## of LD_SWITCH_SYSTEM, we cannot do that in exactly the same way.
2324 ## Compare with the gnu-linux case below, which added to the end
2325 ## of LD_SWITCH_SYSTEM, and so can instead go at the front of
2326 ## LD_SWITCH_SYSTEM_TEMACS.
2327 case "$opsys" in
2328   netbsd|openbsd)
2329    LD_SWITCH_SYSTEM="\$(LD_SWITCH_X_SITE_RPATH) $LD_SWITCH_SYSTEM" ;;
2330 esac
2332 C_SWITCH_MACHINE=
2334 test $with_unexec = yes &&
2335 case $canonical in
2336  alpha*)
2337     ## With ELF, make sure that all common symbols get allocated to in the
2338     ## data section.  Otherwise, the dump of temacs may miss variables in
2339     ## the shared library that have been initialized.  For example, with
2340     ## GNU libc, __malloc_initialized would normally be resolved to the
2341     ## shared library's .bss section, which is fatal.
2342     if test "x$GCC" = "xyes"; then
2343       C_SWITCH_MACHINE="-fno-common"
2344     else
2345       AC_MSG_ERROR([Non-GCC compilers are not supported.])
2346     fi
2347   ;;
2348 esac
2350 AC_CACHE_CHECK([for flags to work around GCC bug 58416],
2351   [emacs_cv_gcc_bug_58416_CFLAGS],
2352   [emacs_cv_gcc_bug_58416_CFLAGS='none needed'
2353    AS_CASE([$canonical],
2354      [[i[3456]86-* | x86_64-*]],
2355        [AS_IF([test "$GCC" = yes],
2356           [old_CFLAGS=$CFLAGS
2357            # If no flags are needed (e.g., not GCC 4+), don't use any.
2358            # Otherwise, use -mfpmath=sse if already assuming SSE2.
2359            # Otherwise, use -fno-tree-sra.
2360            for emacs_cv_gcc_bug_58416_CFLAGS in \
2361                'none needed' -mfpmath=sse -fno-tree-sra
2362            do
2363              AS_CASE([$emacs_cv_gcc_bug_58416_CFLAGS],
2364                ['none needed'], [],
2365                [-fno-tree-sra], [break],
2366                [CFLAGS="$old_CFLAGS $emacs_cv_gcc_bug_58416_CFLAGS"])
2367              AC_COMPILE_IFELSE(
2368                [AC_LANG_DEFINES_PROVIDED
2369                 [/* Work around GCC bug with double in unions on x86,
2370                     where the generated insns copy non-floating-point data
2371                     via fldl/fstpl instruction pairs.  This can misbehave
2372                     the data's bit pattern looks like a NaN.  See, e.g.:
2373                        https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58416#c10
2374                        https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71460
2375                        https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93271
2376                        https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114659
2377                     Problem observed with 'gcc -m32' with GCC 14.1.1
2378                     20240607 (Red Hat 14.1.1-5) on x86-64.  */
2379                  #include <float.h>
2380                  #if \
2381                      (4 <= __GNUC__ && __GNUC__ <= 14 && !defined __clang__ \
2382                       && (defined __i386__ || defined __x86_64__) \
2383                       && ! (0 <= FLT_EVAL_METHOD && FLT_EVAL_METHOD <= 1))
2384                  # error "GCC bug 58416 is possibly present"
2385                  #endif
2386                ]],
2387                [break])
2388            done
2389            CFLAGS=$old_CFLAGS])])])
2390 AS_CASE([$emacs_cv_gcc_bug_58416_CFLAGS],
2391   [-*],
2392     [C_SWITCH_MACHINE="$C_SWITCH_MACHINE $emacs_cv_gcc_bug_58416_CFLAGS"])
2394 AC_SUBST([C_SWITCH_MACHINE])
2396 C_SWITCH_SYSTEM=
2397 ## Some programs in src produce warnings saying certain subprograms
2398 ## are too complex and need a MAXMEM value greater than 2000 for
2399 ## additional optimization.  --nils@exp-math.uni-essen.de
2400 test "$opsys" = "aix4.2" && test "x$GCC" != "xyes" && \
2401   C_SWITCH_SYSTEM="-ma -qmaxmem=4000"
2402 if test "$opsys" = "mingw32"; then
2403   case "$canonical" in
2404     x86_64-*-mingw*) C_SWITCH_SYSTEM="-mtune=generic" ;;
2405     *) C_SWITCH_SYSTEM="-mtune=pentium4" ;;
2406   esac
2408 ## gnu-linux might need -D_BSD_SOURCE on old libc5 systems.
2409 ## It is redundant in glibc2, since we define _GNU_SOURCE.
2410 AC_SUBST([C_SWITCH_SYSTEM])
2413 LIBS_SYSTEM=
2414 case "$opsys" in
2415   ## IBM's X11R5 uses -lIM and -liconv in AIX 3.2.2.
2416   aix4-2) LIBS_SYSTEM="-lrts -lIM -liconv" ;;
2418   freebsd|dragonfly) LIBS_SYSTEM="-lutil" ;;
2420   hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
2422   qnxnto) LIBS_SYSTEM="-lsocket" ;;
2424   solaris) LIBS_SYSTEM="-lsocket -lnsl" ;;
2426   ## Motif needs -lgen.
2427   unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;;
2429   # Haiku needs -lbsd for cfsetspeed.
2430   haiku) LIBS_SYSTEM="-lnetwork -lbsd" ;;
2431 esac
2433 AC_SUBST([LIBS_SYSTEM])
2435 ### Make sure subsequent tests use flags consistent with the build flags.
2437 if test x"${OVERRIDE_CPPFLAGS}" != x; then
2438   CPPFLAGS="${OVERRIDE_CPPFLAGS}"
2439 else
2440   CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
2443 # Suppress obsolescent Autoconf test for size_t; Emacs assumes C99 or better.
2444 AC_DEFUN([AC_TYPE_SIZE_T])
2445 # Likewise for obsolescent test for uid_t, gid_t; Emacs assumes them.
2446 AC_DEFUN([AC_TYPE_UID_T])
2447 ac_cv_type_gid_t=yes # AC_TYPE_GETGROUPS needs this in Autoconf 2.72.
2449 # Check for all math.h functions that Emacs uses; on some platforms,
2450 # -lm is needed for some of these functions.
2451 AC_CACHE_CHECK([for math library],
2452   [emacs_cv_lib_math],
2453   [OLD_LIBS=$LIBS
2454    AC_LINK_IFELSE(
2455      [AC_LANG_SOURCE([[
2456         #include <math.h>
2457         int
2458         main (int argc, char **argv)
2459         {
2460           double d = argc;
2461           float f = argc;
2462           int i = argc;
2463           long l = argc;
2464           d = acos (d);
2465           d = asin (d);
2466           d = atan (d);
2467           d = atan2 (d, d);
2468           d = ceil (d);
2469           d = copysign (d, d);
2470           d = cos (d);
2471           d = exp (d);
2472           d = fabs (d);
2473           d = floor (d);
2474           d = fmod (d, d);
2475           d = frexp (d, &i);
2476           d = ldexp (d, i);
2477           d = log (d);
2478           d = log10 (d);
2479           d = pow (d, d);
2480           d = rint (d);
2481           d = scalbn (d, l);
2482           d = sin (d);
2483           d = sqrt (d);
2484           d = tan (d);
2485           d = trunc (d);
2486           f = fabsf (f);
2487           f = powf (f, f);
2488           i = ilogb (d);
2489           i = signbit (d);
2490           l = lrint (d);
2491           l = lround (d);
2492           return d == f && i == l;
2493         }
2494      ]])],
2495      [emacs_cv_lib_math='none required'],
2496      [LIBS="-lm $LIBS"
2497       AC_LINK_IFELSE([],
2498         [emacs_cv_lib_math=-lm],
2499         [AC_MSG_ERROR([Math library (-lm) not found])])])
2500    LIBS=$OLD_LIBS])
2501 case $emacs_cv_lib_math in
2502   -*) LIB_MATH=$emacs_cv_lib_math;;
2503   *)  LIB_MATH=;;
2504 esac
2506 dnl Current possibilities handled by sed (aix4-2 -> aix,
2507 dnl gnu-linux -> gnu/linux, etc.):
2508 dnl gnu, gnu/linux, gnu/kfreebsd, aix, cygwin, darwin, hpux.
2509 dnl And special cases: berkeley-unix, usg-unix-v, ms-dos, windows-nt.
2510 SYSTEM_TYPE=`echo $opsys | sed -e 's/[[0-9]].*//' -e 's|-|/|'`
2512 case $opsys in
2513   cygwin )
2514     LIB_MATH=
2515     ;;
2516   darwin )
2517     ## Adding -lm confuses the dynamic linker, so omit it.
2518     LIB_MATH=
2519     ;;
2520   freebsd | dragonfly )
2521     SYSTEM_TYPE=berkeley-unix
2522     ;;
2523   gnu-linux | gnu-kfreebsd )
2524     ;;
2525   hpux10-20 | hpux11 )
2526     ;;
2527   mingw32 )
2528     LIB_MATH=
2529     SYSTEM_TYPE=windows-nt
2530     ;;
2531   netbsd | openbsd )
2532     SYSTEM_TYPE=berkeley-unix
2533     ;;
2535   solaris | unixware )
2536     SYSTEM_TYPE=usg-unix-v
2537     ;;
2539 esac
2541 AC_SUBST([LIB_MATH])
2542 AC_DEFINE_UNQUOTED([SYSTEM_TYPE], ["$SYSTEM_TYPE"],
2543   [The type of system you are compiling for; sets 'system-type'.])
2544 AC_SUBST([SYSTEM_TYPE])
2546 pre_PKG_CONFIG_CFLAGS=$CFLAGS
2547 pre_PKG_CONFIG_LIBS=$LIBS
2549 dnl pkg-config does not work when cross-compiling for Android.
2550 if test "${ANDROID}" != "yes"; then
2551   PKG_PROG_PKG_CONFIG([0.9.0])
2554 dnl EMACS_CHECK_MODULES([GSTUFF], [gtk+-2.0 >= 1.3 glib = 1.3.4])
2555 dnl acts like PKG_CHECK_MODULES([GSTUFF], [gtk+-2.0 >= 1.3 glib = 1.3.4],
2556 dnl [HAVE_GSTUFF=yes], [HAVE_GSTUFF=no]) -- see pkg-config man page --
2557 dnl except that it postprocesses CFLAGS as needed for --enable-gcc-warnings.
2558 dnl EMACS_CHECK_MODULES accepts optional 3rd and 4th arguments that
2559 dnl can take the place of the default HAVE_GSTUFF=yes and HAVE_GSTUFF=no
2560 dnl actions.
2561 AC_DEFUN([EMACS_CHECK_MODULES],
2562   [AS_IF([test -n "$ndk_INITIALIZED"],
2563     [ndk_CHECK_MODULES([$1], [$2], m4_default([$3], [HAVE_$1=yes]),
2564       m4_default([$4],[HAVE_$1=no]))],
2565     [PKG_CHECK_MODULES([$1], [$2],
2566        [$1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"`
2567         m4_default([$3], [HAVE_$1=yes])],
2568        [m4_default([$4], [HAVE_$1=no])])])])
2570 dnl EMACS_CHECK_LIB(NAME, FUNCTION, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND,
2571 dnl OTHER-LIBRARIES, INCLUDES)
2572 dnl ---------------------------------------------------------------------
2573 dnl This is like AC_CHECK_LIB; however, there is no default action, and
2574 dnl when cross-configuring for Android, AC_CHECK_DECLS is called with NAME
2575 dnl and INCLUDES instead, as the library being checked against will likely
2576 dnl be built together with Emacs.
2577 AC_DEFUN([EMACS_CHECK_LIB],
2578   [AS_IF([test -n "$ndk_INITIALIZED"],
2579     [AC_CHECK_DECL([$2], [$3], [$4], [$6])],
2580     [AC_CHECK_LIB([$1], [$2], [$3], [$4], [$5])])])
2582 HAVE_SOUND=no
2583 if test "${with_sound}" != "no"; then
2584   # Sound support for GNU/Linux, the free BSDs, MinGW, and Cygwin.
2585   AC_CHECK_HEADERS([machine/soundcard.h sys/soundcard.h soundcard.h mmsystem.h],
2586     [have_sound_header=yes], [], [
2587     #ifdef __MINGW32__
2588     #define WIN32_LEAN_AND_MEAN
2589     #include <windows.h>
2590     #endif
2591     ])
2592   test "${with_sound}" = "oss" && test "${have_sound_header}" != "yes" && \
2593     AC_MSG_ERROR([OSS sound support requested but not found.])
2595   if test "${with_sound}" = "bsd-ossaudio" || test "${with_sound}" = "yes"; then
2596     # OSS emulation library used on NetBSD and OpenBSD.
2597     AC_CHECK_LIB([ossaudio], [_oss_ioctl], [LIBSOUND=-lossaudio], [LIBSOUND=])
2598     test "${with_sound}" = "bsd-ossaudio" && test -z "$LIBSOUND" && \
2599       AC_MSG_ERROR([bsd-ossaudio sound support requested but not found.])
2600     # On {Net,Open}BSD use the system audio library instead of
2601     # potentially switching to ALSA below, as ALSA on these appears to
2602     # just wrap system libraries.
2603     test "${with_sound}" = "yes" && test "$LIBSOUND" = "-lossaudio" && \
2604       with_sound="bsd-ossaudio"
2605   fi
2606   AC_SUBST([LIBSOUND])
2608   if test "${with_sound}" = "alsa" || test "${with_sound}" = "yes"; then
2609     ALSA_REQUIRED=1.0.0
2610     ALSA_MODULES="alsa >= $ALSA_REQUIRED"
2611     EMACS_CHECK_MODULES([ALSA], [$ALSA_MODULES])
2612     if test $HAVE_ALSA = yes; then
2613       LIBSOUND="$LIBSOUND $ALSA_LIBS"
2614       CFLAGS_SOUND="$CFLAGS_SOUND $ALSA_CFLAGS"
2615       AC_DEFINE([HAVE_ALSA], [1], [Define to 1 if ALSA is available.])
2616     elif test "${with_sound}" = "alsa"; then
2617       AC_MSG_ERROR([ALSA sound support requested but not found.])
2618     fi
2619   fi                            dnl with_sound = alsa|yes
2621   dnl Define HAVE_SOUND if we have sound support.  We know it works and
2622   dnl compiles only on the specified platforms.  For others, it
2623   dnl probably doesn't make sense to try.
2624   dnl FIXME So surely we should bypass this whole section if not using
2625   dnl one of these platforms?
2626   if test x$have_sound_header = xyes || test $HAVE_ALSA = yes; then
2627      case "$opsys" in
2628        dnl defined __FreeBSD__ || defined __NetBSD__ || defined __linux__
2629        dnl Adjust the --with-sound help text if you change this.
2630        gnu-linux|freebsd|netbsd|mingw32|cygwin)
2631          AC_DEFINE([HAVE_SOUND], [1], [Define to 1 if you have sound support.])
2632          HAVE_SOUND=yes
2633          ;;
2634      esac
2635   fi
2637   AC_SUBST([CFLAGS_SOUND])
2640 dnl checks for header files
2641 AC_CHECK_HEADERS_ONCE(
2642  [linux/fs.h
2643   malloc.h
2644   sys/systeminfo.h
2645   sys/sysinfo.h
2646   coff.h pty.h
2647   sys/resource.h
2648   sys/utsname.h pwd.h util.h
2649   sanitizer/lsan_interface.h
2650   sanitizer/asan_interface.h
2651   sanitizer/common_interface_defs.h])
2653 AC_CACHE_CHECK([for ADDR_NO_RANDOMIZE],
2654   [emacs_cv_personality_addr_no_randomize],
2655   [AC_COMPILE_IFELSE(
2656      [AC_LANG_PROGRAM([[#include <sys/personality.h>]],
2657                       [[personality (personality (0xffffffff)
2658                                      | ADDR_NO_RANDOMIZE)]])],
2659      [emacs_cv_personality_addr_no_randomize=yes],
2660      [emacs_cv_personality_addr_no_randomize=no])])
2661 if test $emacs_cv_personality_addr_no_randomize = yes; then
2662   AC_DEFINE([HAVE_PERSONALITY_ADDR_NO_RANDOMIZE], [1],
2663             [Define to 1 if personality flag ADDR_NO_RANDOMIZE exists.])
2666 # Note that Solaris has sys/sysinfo.h which defines struct
2667 # sysinfo as well.  To make sure that we're using GNU/Linux
2668 # sysinfo, we explicitly set one of its fields.
2669 if test "$ac_cv_header_sys_sysinfo_h" = yes; then
2670   AC_CACHE_CHECK([if Linux sysinfo may be used], [emacs_cv_linux_sysinfo],
2671   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/sysinfo.h>]],
2672                                      [[struct sysinfo si;
2673                                        si.totalram = 0;
2674                                        sysinfo (&si)]])],
2675     emacs_cv_linux_sysinfo=yes, emacs_cv_linux_sysinfo=no)])
2677   if test $emacs_cv_linux_sysinfo = yes; then
2678     AC_DEFINE([HAVE_LINUX_SYSINFO], [1],
2679       [Define to 1 if you have Linux sysinfo function.])
2680     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/sysinfo.h>]],
2681                                        [[struct sysinfo si; return si.mem_unit]])],
2682       AC_DEFINE([LINUX_SYSINFO_UNIT], [1],
2683                 [Define to 1 if Linux sysinfo sizes are in multiples of mem_unit bytes.]))
2684   fi
2687 dnl On Solaris 8 there's a compilation warning for term.h because
2688 dnl it doesn't define 'bool'.
2689 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <term.h>]],[[]])],
2690   [AC_DEFINE([HAVE_TERM_H], [1],
2691      [Define to 1 if you have the <term.h> header file.])])
2692 AC_HEADER_SYS_WAIT
2694 AC_CHECK_HEADERS_ONCE([sys/socket.h])
2695 AC_CHECK_HEADERS([net/if.h], [], [], [AC_INCLUDES_DEFAULT
2696 #if HAVE_SYS_SOCKET_H
2697 #include <sys/socket.h>
2698 #endif])
2699 AC_CHECK_HEADERS([ifaddrs.h], [], [], [AC_INCLUDES_DEFAULT
2700 #if HAVE_SYS_SOCKET_H
2701 #include <sys/socket.h>
2702 #endif])
2703 AC_CHECK_HEADERS([net/if_dl.h], [], [], [AC_INCLUDES_DEFAULT
2704 #if HAVE_SYS_SOCKET_H
2705 #include <sys/socket.h>
2706 #endif])
2708 dnl checks for structure members
2709 AC_CHECK_MEMBERS([struct ifreq.ifr_flags, struct ifreq.ifr_hwaddr,
2710                   struct ifreq.ifr_netmask, struct ifreq.ifr_broadaddr,
2711                   struct ifreq.ifr_addr,
2712                   struct ifreq.ifr_addr.sa_len], [], [],
2713                  [AC_INCLUDES_DEFAULT
2714 #if HAVE_SYS_SOCKET_H
2715 #include <sys/socket.h>
2716 #endif
2717 #if HAVE_NET_IF_H
2718 #include <net/if.h>
2719 #endif])
2721 dnl Check for endianness.
2722 dnl AC_C_BIGENDIAN is done by gnulib.
2724 dnl check for Make feature
2726 AUTO_DEPEND=no
2727 AUTODEPEND_PARENTS='lib src'
2728 dnl check if we have GCC and autodepend is on.
2729 if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
2730    AC_CACHE_CHECK([whether gcc understands -MMD -MF], [emacs_cv_autodepend],
2731    [SAVE_CFLAGS="$CFLAGS"
2732    CFLAGS="$CFLAGS -MMD -MF deps.d -MP"
2733    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
2734      [emacs_cv_autodepend=yes], [emacs_cv_autodepend=no])
2735    CFLAGS="$SAVE_CFLAGS"
2736    test -f deps.d || emacs_cv_autodepend=no
2737    rm -rf deps.d])
2738    if test $emacs_cv_autodepend = yes; then
2739       AUTO_DEPEND=yes
2740    fi
2742 AC_SUBST([AUTO_DEPEND])
2744 #### Choose a window system.
2746 ## We leave window_system equal to none if
2747 ## we end up building without one.  Any new window system should
2748 ## set window_system to an appropriate value and add objects to
2749 ## window-system-specific substs.
2751 window_system=none
2753 ANDROID_OBJ=
2754 ANDROID_LIBS=
2755 # ANDROID_CFLAGS is a precious variable used to pass information to
2756 # the cross-compiler.
2757 ANDROID_BUILD_CFLAGS=
2758 REALLY_ANDROID=
2759 CM_OBJ="cm.o"
2761 AS_IF([test "$ANDROID" = "yes"],[
2762   window_system=android
2763   no_x=yes
2764   ANDROID_OBJ="androidterm.o androidfns.o androidfont.o androidmenu.o"
2765   ANDROID_OBJ="$ANDROID_OBJ android.o"
2766   ANDROID_LIBS=
2767   CM_OBJ=
2769   AC_DEFINE([HAVE_ANDROID], [1], [Define to 1 if Emacs is being built
2770 with Android support])
2772   AS_IF([test "$XCONFIGURE" != "android"], [
2773     AC_DEFINE([ANDROID_STUBIFY], [1], [Define to 1 if Emacs is being built
2774 for Android, but all API calls need to be stubbed out])
2776     # Now set any shared user ID that was specified.
2777     AS_IF([test -n "$with_shared_user_id"],
2778       [emacs_val=$with_shared_user_id
2779        emacs_val=`AS_ECHO(["$with_shared_user_id"]) \
2780                   | sed -e 's/"/\\"/'`
2781        emacs_val="\"$emacs_val\""
2782        ANDROID_SHARED_USER_ID="android:sharedUserId=$emacs_val"
2783        # `android:sharedUserName' is required for sharedUserID to work
2784        # on recent Android releases.  It does not otherwise affect the
2785        # behavior of any code.
2786        emacs_val="\"@string/shared_user_name\""
2787        ANDROID_SHARED_USER_NAME="android:sharedUserLabel=$emacs_val"])],[
2788     # Emacs will be built as a shared library, and a wrapper around it
2789     # will also be built for the benefit of applications.  This
2790     # requires Emacs be built as a position independent executable.
2791     ANDROID_BUILD_CFLAGS="-fPIC -fvisibility=hidden"
2793     # Graphics code in sfntfont-android.c benefits heavily from
2794     # vectorization.
2795     ANDROID_BUILD_CFLAGS="$ANDROID_BUILD_CFLAGS -ftree-vectorize"
2797     # Link with libraries required for Android support.
2798     # API 9 and later require `-landroid' for the asset manager.
2799     # API 8 uses an emulation via the JNI.
2800     AS_IF([test "$ANDROID_SDK" -lt "9"],
2801       [ANDROID_LIBS="-llog -ljnigraphics"],
2802       [ANDROID_LIBS="-landroid -llog -ljnigraphics"])
2804     # This is required to make the system load emacs.apk's libpng
2805     # (among others) instead of the system's own.  But it doesn't work
2806     # on all Android versions yet, so for now just suffix shared
2807     # libraries with _emacs.
2808     # ANDROID_LDFLAGS="-Wl,-rpath,'\$\$ORIGIN'"
2810     # Link with the sfnt font library and sfntfont.o, along with
2811     # sfntfont-android.o.
2812     ANDROID_OBJ="$ANDROID_OBJ sfnt.o sfntfont.o sfntfont-android.o"
2814     # Build androidselect.o and androidvfs.o.
2815     ANDROID_OBJ="$ANDROID_OBJ androidselect.o androidvfs.o"
2817     # Check for some functions not always present in the NDK.
2818     AC_CHECK_DECLS([android_get_device_api_level])
2820     # Mention this build is really for Android.
2821     REALLY_ANDROID=yes])])
2823 AC_SUBST([ANDROID])
2824 AC_SUBST([ANDROID_OBJ])
2825 AC_SUBST([ANDROID_LIBS])
2826 AC_SUBST([ANDROID_LDFLAGS])
2827 AC_SUBST([ANDROID_BUILD_CFLAGS])
2828 AC_SUBST([ANDROID_SHARED_USER_ID])
2829 AC_SUBST([ANDROID_SHARED_USER_NAME])
2831 # Check for pw_gecos in struct passwd; this is known to be missing on
2832 # Android.
2834 AH_TEMPLATE([USER_FULL_NAME], [How to get a user's full name.])
2835 AC_CHECK_MEMBERS([struct passwd.pw_gecos], [], [], [#include <pwd.h>])
2836 AS_IF([test x"$REALLY_ANDROID" = "xyes"],
2837   [AC_DEFINE([USER_FULL_NAME], [android_user_full_name (pw)])],
2838   [AS_IF([test x"$ac_cv_member_struct_passwd_pw_gecos" = "xyes"],
2839     [AC_DEFINE([USER_FULL_NAME], [pw->pw_gecos])],
2840     [AC_DEFINE([USER_FULL_NAME], [NULL])])])
2842 if test "${with_pgtk}" = "yes"; then
2843   window_system=pgtk
2846 if test "${ANDROID}" != "yes"; then
2847   AC_PATH_X
2848   if test "$no_x" != yes && test "${with_pgtk}" != "yes"; then
2849     window_system=x11
2850   fi
2853 LD_SWITCH_X_SITE_RPATH=
2854 if test "${x_libraries}" != NONE; then
2855   if test -n "${x_libraries}"; then
2856     LD_SWITCH_X_SITE=-L`AS_ECHO(["$x_libraries"]) | sed -e 's/:/ -L/g'`
2857     LD_SWITCH_X_SITE_RPATH=-Wl,-rpath,`
2858       AS_ECHO(["$x_libraries"]) | sed -e 's/:/ -Wl,-rpath,/g'
2859     `
2860   fi
2861   x_default_search_path=""
2862   x_search_path=${x_libraries}
2863   if test -z "${x_search_path}"; then
2864     x_search_path=/usr/lib
2865   fi
2866   for x_library in `AS_ECHO(["$x_search_path:"]) | \
2867                     sed -e "s/:/ /g" -e p -e "s:/lib[[^ /]]* :/share :g"`; do
2868     x_search_path="\
2869 ${x_library}/X11/%L/%T/%N%C%S:\
2870 ${x_library}/X11/%l/%T/%N%C%S:\
2871 ${x_library}/X11/%T/%N%C%S:\
2872 ${x_library}/X11/%L/%T/%N%S:\
2873 ${x_library}/X11/%l/%T/%N%S:\
2874 ${x_library}/X11/%T/%N%S"
2875     if test x"${x_default_search_path}" = x; then
2876       x_default_search_path=${x_search_path}
2877     else
2878       x_default_search_path="${x_search_path}:${x_default_search_path}"
2879     fi
2880   done
2882 AC_SUBST([LD_SWITCH_X_SITE_RPATH])
2884 if test "${x_includes}" != NONE && test -n "${x_includes}"; then
2885   C_SWITCH_X_SITE=$isystem`AS_ECHO(["$x_includes"]) | sed -e "s/:/ $isystem/g"`
2888 if test x"${x_includes}" = x; then
2889   bitmapdir=/usr/include/X11/bitmaps
2890 else
2891   # accumulate include directories that have X11 bitmap subdirectories
2892   AS_UNSET([bmd_acc])
2893   for bmd in `AS_ECHO(["$x_includes"]) | sed -e 's/:/ /g'`; do
2894     if test -d "${bmd}/X11/bitmaps"; then
2895       bmd_acc="${bmd_acc+$bmd_acc:}${bmd}/X11/bitmaps"
2896     fi
2897     if test -d "${bmd}/bitmaps"; then
2898       bmd_acc="${bmd_acc+$bmd_acc:}${bmd}/bitmaps"
2899     fi
2900   done
2901   bitmapdir=$bmd_acc
2904 NATIVE_IMAGE_API=no
2906 test "${with_ns}" = maybe && test "${opsys}" != darwin && with_ns=no
2907 HAVE_NS=no
2908 NS_GNUSTEP_CONFIG=no
2909 NS_IMPL_COCOA=no
2910 NS_IMPL_GNUSTEP=no
2911 tmp_CPPFLAGS="$CPPFLAGS"
2912 tmp_CFLAGS="$CFLAGS"
2913 CPPFLAGS="$CPPFLAGS -x objective-c"
2914 CFLAGS="$CFLAGS -x objective-c"
2915 GNU_OBJC_CFLAGS=""
2916 LIBS_GNUSTEP=
2917 if test "${with_ns}" != no; then
2918   # macfont.o requires macuvs.h which is absent after 'make extraclean',
2919   # so avoid NS_IMPL_COCOA if macuvs.h is absent.
2920   # Even a headless Emacs can build macuvs.h, so this should let you bootstrap.
2921   if test "${opsys}" = darwin && test -f "$srcdir/src/macuvs.h"; then
2922      NS_IMPL_COCOA=yes
2923      ns_appdir=`pwd`/nextstep/Emacs.app
2924      ns_appbindir=${ns_appdir}/Contents/MacOS
2925      ns_applibexecdir=${ns_appdir}/Contents/MacOS/libexec
2926      ns_applibdir=${ns_appdir}/Contents/Frameworks
2927      ns_appresdir=${ns_appdir}/Contents/Resources
2928      ns_appsrc=Cocoa/Emacs.base
2929      ns_fontfile=macfont.o
2930   elif flags=`(gnustep-config --objc-flags) 2>/dev/null`; then
2931      NS_IMPL_GNUSTEP=yes
2932      NS_GNUSTEP_CONFIG=yes
2933      GNU_OBJC_CFLAGS="$flags"
2934      LIBS_GNUSTEP=`gnustep-config --gui-libs || exit`
2935   elif test -f $GNUSTEP_CONFIG_FILE; then
2936      NS_IMPL_GNUSTEP=yes
2937      dnl FIXME sourcing this several times in subshells seems inefficient.
2938      GNUSTEP_SYSTEM_HEADERS=`. $GNUSTEP_CONFIG_FILE \
2939        && AS_ECHO(["$GNUSTEP_SYSTEM_HEADERS"])`
2940      GNUSTEP_SYSTEM_LIBRARIES=` . $GNUSTEP_CONFIG_FILE \
2941        && AS_ECHO(["$GNUSTEP_SYSTEM_LIBRARIES"])`
2942      dnl I seemed to need these as well with GNUstep-startup 0.25.
2943      GNUSTEP_LOCAL_HEADERS=`. $GNUSTEP_CONFIG_FILE \
2944        && AS_ECHO(["$GNUSTEP_LOCAL_HEADERS"])`
2945      GNUSTEP_LOCAL_LIBRARIES=`. $GNUSTEP_CONFIG_FILE \
2946        && AS_ECHO(["$GNUSTEP_LOCAL_LIBRARIES"])`
2947      test "x${GNUSTEP_LOCAL_HEADERS}" != "x" && \
2948        GNUSTEP_LOCAL_HEADERS="-I${GNUSTEP_LOCAL_HEADERS}"
2949      test "x${GNUSTEP_LOCAL_LIBRARIES}" != "x" && \
2950        GNUSTEP_LOCAL_LIBRARIES="-L${GNUSTEP_LOCAL_LIBRARIES}"
2951      CPPFLAGS="$CPPFLAGS -isystem ${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
2952      CFLAGS="$CFLAGS -isystem ${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
2953      LDFLAGS="$LDFLAGS -L${GNUSTEP_SYSTEM_LIBRARIES} ${GNUSTEP_LOCAL_LIBRARIES}"
2954      LIBS_GNUSTEP="-lgnustep-gui -lgnustep-base -lobjc -lpthread"
2955      dnl GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS to 0 or 1.
2956      dnl If they had chosen to either define it or not, we could have
2957      dnl just used AC_CHECK_DECL here.
2958      AC_CACHE_CHECK([if GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS],
2959        [emacs_cv_objc_exceptions],
2960        [AC_COMPILE_IFELSE(
2961           [AC_LANG_PROGRAM([[#include <GNUstepBase/GSConfig.h>]],
2962 [[#if defined BASE_NATIVE_OBJC_EXCEPTIONS && BASE_NATIVE_OBJC_EXCEPTIONS > 0
2964 #else
2965 fail;
2966 #endif]])],
2967        [emacs_cv_objc_exceptions=yes],
2968        [emacs_cv_objc_exceptions=no])])
2969      if test $emacs_cv_objc_exceptions = yes; then
2970        dnl _NATIVE_OBJC_EXCEPTIONS is used by the GNUstep headers.
2971        AC_DEFINE([_NATIVE_OBJC_EXCEPTIONS], [1],
2972          [Define if GNUstep uses ObjC exceptions.])
2973        GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -fobjc-exceptions"
2974      fi
2975   fi
2976   if test $NS_IMPL_GNUSTEP = yes; then
2977      ns_appdir=`pwd`/nextstep/Emacs.app
2978      ns_appbindir=${ns_appdir}
2979      ns_applibexecdir=${ns_appdir}/libexec
2980      ns_applibdir=${ns_appdir}/Frameworks
2981      ns_appresdir=${ns_appdir}/Resources
2982      ns_appsrc=GNUstep/Emacs.base
2983      ns_fontfile=nsfont.o
2984   fi
2986   dnl This is only used while we test the NS headers, it gets reset below.
2987   CPPFLAGS="$CPPFLAGS $GNU_OBJC_CFLAGS"
2988   CFLAGS="$CFLAGS $GNU_OBJC_CFLAGS"
2990   AC_CHECK_HEADER([AppKit/AppKit.h], [HAVE_NS=yes],
2991                   [AC_MSG_ERROR([The include files (AppKit/AppKit.h etc) that
2992 are required for a Nextstep build are missing or cannot be compiled.
2993 Either fix this, or re-configure with the option '--without-ns'.])])
2995   macfont_file=""
2996   if test "${NS_IMPL_COCOA}" = "yes"; then
2997     AC_MSG_CHECKING([for Mac OS X 10.6 or newer])
2998     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>],
2999                                      [
3000 #ifdef MAC_OS_X_VERSION_MAX_ALLOWED
3001 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
3002  ; /* OK */
3003 #else
3004  error "Mac OS X 10.6 or newer required";
3005 #endif
3006 #endif
3007                     ])],
3008                     [ns_osx_have_106=yes],
3009                     [ns_osx_have_106=no])
3010     AC_MSG_RESULT([$ns_osx_have_106])
3012     if test $ns_osx_have_106 = no; then
3013        AC_MSG_ERROR([Mac OS X 10.6 or newer is required]);
3014     fi
3015   fi
3017   AC_CACHE_CHECK([for Mac OS X 12.0 or later],
3018                  [emacs_cv_macosx_12_0],
3019                  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3020 #include <AvailabilityMacros.h>
3021 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 120000
3022 Mac OS X 12.x or later.
3023 #endif
3024                  ]])], [emacs_cv_macosx_12_0=no],
3025                  [emacs_cv_macosx_12_0=yes]))
3027   if test "${with_native_image_api}" = yes; then
3028      AC_DEFINE([HAVE_NATIVE_IMAGE_API], [1],
3029        [Define to use native OS APIs for images.])
3030      NATIVE_IMAGE_API="yes (ns)"
3031   fi
3034 AC_SUBST([LIBS_GNUSTEP])
3036 INSTALL_ARCH_INDEP_EXTRA=install-etc
3037 ns_self_contained=no
3038 NS_OBJ=
3039 NS_OBJC_OBJ=
3040 if test "${HAVE_NS}" = yes; then
3041   if test "$with_toolkit_scroll_bars" = "no"; then
3042     AC_MSG_WARN([Non-toolkit scroll bars are not implemented for Nextstep.])
3043   fi
3045   window_system=nextstep
3046   # set up packaging dirs
3047   if test "${EN_NS_SELF_CONTAINED}" = yes; then
3048      AC_DEFINE([NS_SELF_CONTAINED], [1], [Build an NS bundled app])
3049      ns_self_contained=yes
3050      prefix=${ns_appresdir}
3051      exec_prefix=${ns_appbindir}
3052      dnl This one isn't really used, only archlibdir is.
3053      libexecdir="\${ns_applibexecdir}"
3054      archlibdir="\${ns_applibexecdir}"
3055      etcdocdir="\${ns_appresdir}/etc"
3056      etcdir="\${ns_appresdir}/etc"
3057      dnl FIXME maybe set datarootdir instead.
3058      dnl That would also get applications, icons, man.
3059      infodir="\${ns_appresdir}/info"
3060      mandir="\${ns_appresdir}/man"
3061      lispdir="\${ns_appresdir}/lisp"
3062      lispdirrel="\${ns_appresdir}/lisp"
3063      test "$locallisppathset" = no && locallisppath="\${ns_appresdir}/site-lisp"
3064      INSTALL_ARCH_INDEP_EXTRA=
3065   fi
3067   NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o $ns_fontfile"
3069 CFLAGS="$tmp_CFLAGS"
3070 CPPFLAGS="$tmp_CPPFLAGS"
3071 AC_SUBST([INSTALL_ARCH_INDEP_EXTRA])
3072 AC_SUBST([ns_self_contained])
3073 AC_SUBST([NS_OBJ])
3074 AC_SUBST([NS_OBJC_OBJ])
3076 if test "${HAVE_NS}" = yes; then
3077   AC_LANG_PUSH([Objective C])
3078   AC_CACHE_CHECK(
3079     [if the Objective C compiler supports instancetype],
3080     [emacs_cv_objc_instancetype],
3081     [AC_COMPILE_IFELSE(
3082        [AC_LANG_SOURCE([[@interface Test
3083                           + (instancetype)test;
3084                           @end]])],
3085        [emacs_cv_objc_instancetype=yes],
3086        [emacs_cv_objc_instancetype=no])])
3088   if test x$emacs_cv_objc_instancetype = xyes ; then
3089     AC_DEFINE([NATIVE_OBJC_INSTANCETYPE], [1],
3090               [Define if ObjC compiler supports instancetype natively.])
3091   fi
3093   AC_CACHE_CHECK(
3094     [if the Objective C compiler defaults to C99],
3095     [emacs_cv_objc_c99],
3096     [AC_COMPILE_IFELSE(
3097        [AC_LANG_PROGRAM([], [[for (int i = 0;;);]])],
3098        [emacs_cv_objc_c99=yes],
3099        [emacs_cv_objc_c99=no])])
3101   if test x$emacs_cv_objc_c99 = xno ; then
3102     GNU_OBJC_CFLAGS="$GNU_OBJC_CFLAGS -std=c99"
3103   fi
3104   AC_LANG_POP([Objective C])
3107 HAVE_BE_APP=no
3108 if test "${opsys}" = "haiku" && test "${with_be_app}" = "yes"; then
3109    dnl Only GCC is supported.  Clang might work, but it's
3110    dnl not reliable, so don't check for it here.
3111    AC_PROG_CXX([gcc g++])
3112    CXXFLAGS="$CXXFLAGS $emacs_g3_CFLAGS"
3113    AC_LANG_PUSH([C++])
3114    AC_CHECK_HEADER([app/Application.h], [HAVE_BE_APP=yes],
3115                    [AC_MSG_ERROR([The Application Kit headers required for building
3116 with the Application Kit were not found or cannot be compiled. Either fix this, or
3117 re-configure with the option '--without-be-app'.])])
3118    AC_LANG_POP([C++])
3121 AC_SUBST([HAVE_BE_APP])
3123 HAVE_W32=no
3124 W32_OBJ=
3125 W32_LIBS=
3126 EMACSRES=
3127 CLIENTRES=
3128 CLIENTW=
3129 W32_RES_LINK=
3130 EMACS_MANIFEST=
3131 if test "${with_w32}" != no; then
3132   case "${opsys}" in
3133     cygwin)
3134       AC_CHECK_HEADER([windows.h], [HAVE_W32=yes],
3135              [AC_MSG_ERROR(['--with-w32' was specified, but windows.h
3136                    cannot be found.])])
3137     ;;
3138     mingw32)
3139     ## Using --with-w32 with MinGW is a no-op, but we allow it.
3140     ;;
3141     *)
3142       AC_MSG_ERROR([Using w32 with an autotools build is only supported for Cygwin and MinGW32.])
3143     ;;
3144   esac
3147 if test "${opsys}" = "mingw32"; then
3148   AC_CACHE_CHECK([whether Windows API headers are recent enough], [emacs_cv_w32api],
3149   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3150      #include <windows.h>
3151      #include <usp10.h>]],
3152    [[PIMAGE_NT_HEADERS pHeader;
3153      PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader)]])],
3154    [emacs_cv_w32api=yes], [emacs_cv_w32api=no])])
3155   if test "${emacs_cv_w32api}" = "no"; then
3156     AC_MSG_ERROR([the Windows API headers are too old to support this build.])
3157   fi
3158   HAVE_W32=${emacs_cv_w32api}
3161 FIRSTFILE_OBJ=
3162 NTDIR=
3163 LIBS_ECLIENT=
3164 LIB_WSOCK32=
3165 NTLIB=
3166 XARGS_LIMIT=
3167 if test "${HAVE_W32}" = "yes"; then
3168   AC_DEFINE([HAVE_NTGUI], [1], [Define to use native MS Windows GUI.])
3169   if test "$with_toolkit_scroll_bars" = "no"; then
3170     AC_MSG_ERROR([Non-toolkit scroll bars are not implemented for w32 build.])
3171   fi
3172   AC_CHECK_TOOL([WINDRES], [windres],
3173                 [AC_MSG_ERROR([No resource compiler found.])])
3174   W32_OBJ="w32fns.o w32menu.o w32reg.o w32font.o w32term.o"
3175   W32_OBJ="$W32_OBJ w32xfns.o w32select.o w32uniscribe.o w32cygwinx.o"
3176   EMACSRES="emacs.res"
3177   case "$canonical" in
3178     x86_64-*-*) EMACS_MANIFEST="emacs-x64.manifest" ;;
3179     *) EMACS_MANIFEST="emacs-x86.manifest" ;;
3180   esac
3181   dnl Construct something of the form "24,4,0,0" with 4 components.
3182   comma_version=`echo "${PACKAGE_VERSION}.0.0" | sed -e 's/\./,/g' -e 's/^\([[^,]]*,[[^,]]*,[[^,]]*,[[^,]]*\).*/\1/'`
3184   comma_space_version=`echo "$comma_version" | sed 's/,/, /g'`
3185   AC_SUBST([comma_version])
3186   AC_SUBST([comma_space_version])
3187   AC_CONFIG_FILES([nt/emacs.rc nt/emacsclient.rc])
3188   if test "${opsys}" = "cygwin"; then
3189     W32_LIBS="$W32_LIBS -lkernel32 -luser32 -lusp10 -lgdi32"
3190     W32_LIBS="$W32_LIBS -lole32 -lcomdlg32 -lcomctl32 -lwinspool"
3191     # Tell the linker that emacs.res is an object (which we compile from
3192     # the rc file), not a linker script.
3193     W32_RES_LINK="-Wl,emacs.res"
3194   else
3195     W32_OBJ="$W32_OBJ w32.o w32console.o w32heap.o w32inevt.o w32proc.o"
3196     dnl FIXME: This should probably be supported for Cygwin/w32 as
3197     dnl well, but the Cygwin build needs to link against -lgdiplus
3198     if test "${with_native_image_api}" = yes; then
3199       AC_DEFINE([HAVE_NATIVE_IMAGE_API], [1],
3200         [Define to use native OS APIs for images.])
3201       NATIVE_IMAGE_API="yes (w32)"
3202       W32_OBJ="$W32_OBJ w32image.o"
3203     fi
3204     W32_LIBS="$W32_LIBS -lwinmm -lgdi32 -lcomdlg32"
3205     W32_LIBS="$W32_LIBS -lmpr -lwinspool -lole32 -lcomctl32"
3206     W32_RES_LINK="\$(EMACSRES)"
3207     CLIENTRES="emacsclient.res"
3208     CLIENTW="emacsclientw\$(EXEEXT)"
3209     FIRSTFILE_OBJ=firstfile.o
3210     NTDIR=nt
3211     CM_OBJ=
3212     LIBS_ECLIENT="-lcomctl32"
3213     LIB_WSOCK32="-lwsock32"
3214     NTLIB="ntlib.$ac_objext"
3215     XARGS_LIMIT="-s 10000"
3216   fi
3219 if test "${HAVE_W32}" = "no" && test "${opsys}" = "cygwin"; then
3220   W32_LIBS="-lkernel32"
3221   W32_OBJ="w32cygwinx.o"
3224 AC_SUBST([W32_OBJ])
3225 AC_SUBST([W32_LIBS])
3226 AC_SUBST([EMACSRES])
3227 AC_SUBST([EMACS_MANIFEST])
3228 AC_SUBST([CLIENTRES])
3229 AC_SUBST([CLIENTW])
3230 AC_SUBST([W32_RES_LINK])
3231 AC_SUBST([FIRSTFILE_OBJ])
3232 AC_SUBST([NTDIR])
3233 AC_SUBST([CM_OBJ])
3234 AC_SUBST([LIBS_ECLIENT])
3235 AC_SUBST([LIB_WSOCK32])
3236 AC_SUBST([NTLIB])
3237 AC_SUBST([XARGS_LIMIT])
3239 if test "${HAVE_W32}" = "yes"; then
3240   window_system=w32
3241   with_xft=no
3244 HAIKU_OBJ=
3245 HAIKU_CXX_OBJ=
3246 HAIKU_LIBS=
3247 HAIKU_CFLAGS=
3249 if test "$opsys" = "haiku"; then
3250   HAIKU_OBJ="$HAIKU_OBJ haiku.o"
3253 if test "${HAVE_BE_APP}" = "yes"; then
3254   AC_DEFINE([HAVE_HAIKU], [1],
3255       [Define if Emacs will be built with Haiku windowing support])
3258 if test "${HAVE_BE_APP}" = "yes"; then
3259   window_system=haiku
3260   with_xft=no
3261   HAIKU_OBJ="$HAIKU_OBJ haikufns.o haikuterm.o haikumenu.o haikufont.o haikuselect.o haiku_io.o"
3262   HAIKU_CXX_OBJ="haiku_support.o haiku_font_support.o haiku_draw_support.o haiku_select.o"
3263   HAIKU_LIBS="-lbe -lgame -ltranslation -ltracker" # -lgame is needed for set_mouse_position.
3265   if test "${with_native_image_api}" = yes; then
3266      AC_DEFINE([HAVE_NATIVE_IMAGE_API], [1],
3267        [Define to use native OS APIs for images.])
3268      NATIVE_IMAGE_API="yes (haiku)"
3269      HAIKU_OBJ="$HAIKU_OBJ haikuimage.o"
3270   fi
3273 AC_SUBST([HAIKU_LIBS])
3274 AC_SUBST([HAIKU_OBJ])
3275 AC_SUBST([HAIKU_CXX_OBJ])
3276 AC_SUBST([HAIKU_CFLAGS])
3278 ## $window_system is now set to the window system we will
3279 ## ultimately use.
3281 term_header=
3282 HAVE_X_WINDOWS=no
3283 HAVE_X11=no
3284 USE_X_TOOLKIT=none
3285 HAVE_PGTK=no
3287 case "${window_system}" in
3288   x11 )
3289     HAVE_X_WINDOWS=yes
3290     HAVE_X11=yes
3291     term_header=xterm.h
3292     case "${with_x_toolkit}" in
3293       athena | lucid ) USE_X_TOOLKIT=LUCID ;;
3294       motif ) USE_X_TOOLKIT=MOTIF ;;
3295       gtk ) with_gtk=yes
3296             term_header=gtkutil.h
3297 dnl Don't set this for GTK.  A lot of tests below assumes Xt when
3298 dnl USE_X_TOOLKIT is set.
3299             USE_X_TOOLKIT=none ;;
3300       gtk2 ) with_gtk2=yes
3301              term_header=gtkutil.h
3302              USE_X_TOOLKIT=none ;;
3303       gtk3 ) with_gtk3=yes
3304              term_header=gtkutil.h
3305              USE_X_TOOLKIT=none ;;
3306       no ) USE_X_TOOLKIT=none ;;
3307 dnl If user did not say whether to use a toolkit, make this decision later:
3308 dnl use the toolkit if we have gtk, or X11R5 or newer.
3309       * ) USE_X_TOOLKIT=maybe ;;
3310     esac
3311   ;;
3312   nextstep )
3313     term_header=nsterm.h
3314   ;;
3315   w32 )
3316     term_header=w32term.h
3317   ;;
3318   pgtk )
3319     term_header=pgtkterm.h
3320     with_gtk3=yes
3321     USE_X_TOOLKIT=none
3322     HAVE_PGTK=yes
3323     AC_DEFINE([HAVE_PGTK], [1], [Define to 1 if you have pure Gtk+-3.])
3324   ;;
3325   haiku )
3326     term_header=haikuterm.h
3327   ;;
3328   android )
3329     term_header=androidterm.h
3330   ;;
3331 esac
3333 AC_SUBST([HAVE_PGTK])
3335 if test "$window_system" = none && test "X$with_x" != "Xno"; then
3336    AC_CHECK_PROG([HAVE_XSERVER], [X], [true], [false])
3337    if test "$HAVE_XSERVER" = true ||
3338       test -n "$DISPLAY" ||
3339       {
3340         for emacs_libX11 in /usr/lib/libX11.*; do break; done
3341         test "$emacs_libX11" != '/usr/lib/libX11.*'
3342       }
3343    then
3344         AC_MSG_ERROR([You seem to be running X, but no X development libraries
3345 were found.  You should install the relevant development files for X
3346 and for the toolkit you want, such as Gtk+ or Motif.  Also make
3347 sure you have development files for image handling, i.e.
3348 tiff, gif, jpeg, png and xpm.
3349 If you are sure you want Emacs compiled without X window support, pass
3350   --without-x
3351 to configure.])
3352    fi
3355 # Does the opsystem file prohibit the use of the GNU malloc?
3356 # Assume not, until told otherwise.
3357 GNU_MALLOC=yes
3359 AC_CACHE_CHECK(
3360   [whether malloc is Doug Lea style],
3361   [emacs_cv_var_doug_lea_malloc],
3362   [emacs_cv_var_doug_lea_malloc=no
3363    dnl Hooks do not work with address sanitization.
3364    if test "$emacs_cv_sanitize_address" != yes; then
3365      AC_LINK_IFELSE(
3366        [AC_LANG_PROGRAM(
3367           [[#include <malloc.h>
3368             static void hook (void) {}]],
3369           [[malloc_set_state (malloc_get_state ());
3370             __after_morecore_hook = hook;
3371             __malloc_initialize_hook = hook;]])],
3372        [emacs_cv_var_doug_lea_malloc=yes])
3373    fi])
3374 doug_lea_malloc=$emacs_cv_var_doug_lea_malloc
3376 hybrid_malloc=
3377 system_malloc=yes
3379 dnl This must be before the test of $ac_cv_func_sbrk below.
3380 AC_CHECK_FUNCS_ONCE([sbrk])
3382 test $with_unexec = yes &&
3383 case "$opsys" in
3384   ## darwin ld insists on the use of malloc routines in the System framework.
3385   darwin | mingw32 | nacl | solaris) ;;
3386   cygwin | qnxnto | freebsd)
3387           hybrid_malloc=yes
3388           system_malloc= ;;
3389   *) test "$ac_cv_func_sbrk" = yes && system_malloc=$emacs_cv_sanitize_address;;
3390 esac
3392 if test "${system_malloc}" != yes && test "${doug_lea_malloc}" != yes \
3393    && test "${UNEXEC_OBJ}" = unexelf.o; then
3394   hybrid_malloc=yes
3397 GMALLOC_OBJ=
3398 HYBRID_MALLOC=
3399 if test "${system_malloc}" = "yes"; then
3400   AC_DEFINE([SYSTEM_MALLOC], [1],
3401     [Define to 1 to use the system memory allocator, even if it is not
3402      Doug Lea style.])
3403   GNU_MALLOC=no
3404   GNU_MALLOC_reason="
3405     (The GNU allocators don't work with this system configuration.)"
3406   VMLIMIT_OBJ=
3407 elif test "$hybrid_malloc" = yes; then
3408   AC_DEFINE([HYBRID_MALLOC], [1],
3409     [Define to use gmalloc before dumping and the system malloc after.])
3410   HYBRID_MALLOC=1
3411   GNU_MALLOC=no
3412   GNU_MALLOC_reason=" (only before dumping)"
3413   GMALLOC_OBJ=gmalloc.o
3414   VMLIMIT_OBJ=
3415 else
3416   test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
3417   VMLIMIT_OBJ=vm-limit.o
3419   AC_CHECK_HEADERS([sys/vlimit.h])
3420   AC_CACHE_CHECK([for data_start], [emacs_cv_data_start],
3421     [AC_LINK_IFELSE(
3422        [AC_LANG_PROGRAM(
3423          [[extern char data_start[]; char ch;]],
3424          [[return data_start < &ch;]])],
3425        [emacs_cv_data_start=yes],
3426        [emacs_cv_data_start=no])])
3427   if test $emacs_cv_data_start = yes; then
3428     AC_DEFINE([HAVE_DATA_START], [1],
3429       [Define to 1 if data_start is the address of the start
3430        of the main data segment.])
3431   fi
3433 AC_SUBST([HYBRID_MALLOC])
3434 AC_SUBST([GMALLOC_OBJ])
3435 AC_SUBST([VMLIMIT_OBJ])
3437 if test "$doug_lea_malloc" = "yes" && test "$hybrid_malloc" != yes; then
3438   if test "$GNU_MALLOC" = yes ; then
3439     GNU_MALLOC_reason="
3440       (Using Doug Lea's new malloc from the GNU C Library.)"
3441   fi
3442   AC_DEFINE([DOUG_LEA_MALLOC], [1],
3443     [Define to 1 if the system memory allocator is Doug Lea style,
3444      with malloc hooks and malloc_set_state.])
3446   ## Use mmap directly for allocating larger buffers.
3447   ## FIXME this comes from src/s/{gnu,gnu-linux}.h:
3448   ## #ifdef DOUG_LEA_MALLOC; #undef REL_ALLOC; #endif
3449   ## Does the AC_FUNC_MMAP test below make this check unnecessary?
3450   case "$opsys" in
3451     mingw32|gnu*) REL_ALLOC=no ;;
3452   esac
3455 if test x"${REL_ALLOC}" = x; then
3456   REL_ALLOC=${GNU_MALLOC}
3459 use_mmap_for_buffers=no
3460 case "$opsys" in
3461   mingw32) use_mmap_for_buffers=yes ;;
3462 esac
3464 AC_FUNC_MMAP
3465 if test $use_mmap_for_buffers = yes; then
3466   AC_DEFINE([USE_MMAP_FOR_BUFFERS], [1],
3467     [Define to use mmap to allocate buffer text.])
3468   REL_ALLOC=no
3471 LIBS="$LIBS_SYSTEM $LIBS"
3473 dnl FIXME replace main with a function we actually want from this library.
3474 AC_CHECK_LIB([Xbsd], [main], [LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -lXbsd"])
3476 dnl Check for the POSIX thread library.
3477 LIB_PTHREAD=
3478 AC_CHECK_HEADERS_ONCE([pthread.h])
3479 if test "$ac_cv_header_pthread_h" && test "$opsys" != "mingw32"; then
3480   AC_CACHE_CHECK([for pthread library],
3481     [emacs_cv_pthread_lib],
3482     [emacs_cv_pthread_lib=no
3483      OLD_LIBS=$LIBS
3484      for emacs_pthread_lib in 'none needed' -lpthread; do
3485        case $emacs_pthread_lib in
3486          -*) LIBS="$OLD_LIBS $emacs_pthread_lib";;
3487        esac
3488        AC_LINK_IFELSE(
3489          [AC_LANG_PROGRAM(
3490             [[#include <pthread.h>
3491               #include <signal.h>
3492               sigset_t old_mask, new_mask;
3493               void noop (void) {}]],
3494             [[pthread_t th = pthread_self ();
3495               int status = 0;
3496               status += pthread_create (&th, 0, 0, 0);
3497               status += pthread_sigmask (SIG_BLOCK, &new_mask, &old_mask);
3498               status += pthread_kill (th, 0);
3499               #if ! (defined SYSTEM_MALLOC || defined HYBRID_MALLOC \
3500                      || defined DOUG_LEA_MALLOC)
3501               /* Test for pthread_atfork only if gmalloc uses it,
3502                  as older-style hosts like MirBSD 10 lack it.  */
3503               status += pthread_atfork (noop, noop, noop);
3504               #endif
3505               return status;]])],
3506          [emacs_cv_pthread_lib=$emacs_pthread_lib])
3507        LIBS=$OLD_LIBS
3508        if test "$emacs_cv_pthread_lib" != no; then
3509          break
3510        fi
3511      done])
3512   if test "$emacs_cv_pthread_lib" != no; then
3513     AC_DEFINE([HAVE_PTHREAD], [1], [Define to 1 if you have POSIX threads.])
3514     case $emacs_cv_pthread_lib in
3515       -*) LIB_PTHREAD=$emacs_cv_pthread_lib;;
3516     esac
3517     ac_cv_func_pthread_sigmask=yes
3518     # Some systems optimize for single-threaded programs by default, and
3519     # need special flags to disable these optimizations. For example, the
3520     # definition of 'errno' in <errno.h>.
3521     case $opsys in
3522       hpux* | solaris)
3523         AC_DEFINE([_REENTRANT], [1],
3524           [Define to 1 if your system requires this in multithreaded code.]);;
3525       aix4-2)
3526         AC_DEFINE([_THREAD_SAFE], [1],
3527           [Define to 1 if your system requires this in multithreaded code.]);;
3528     esac
3529   fi
3531 AC_SUBST([LIB_PTHREAD])
3533 AC_MSG_CHECKING([for thread support])
3534 threads_enabled=no
3535 if test "$with_threads" = yes; then
3536    if test "$emacs_cv_pthread_lib" != no; then
3537       AC_DEFINE([THREADS_ENABLED], [1],
3538                 [Define to 1 if you want elisp thread support.])
3539       threads_enabled=yes
3540    elif test "${opsys}" = "mingw32"; then
3541       dnl MinGW can do native Windows threads even without pthreads
3542       AC_DEFINE([THREADS_ENABLED], [1],
3543                 [Define to 1 if you want elisp thread support.])
3544       threads_enabled=yes
3545    fi
3547 AC_MSG_RESULT([$threads_enabled])
3549 dnl Check for need for bigtoc support on IBM AIX
3551 case ${host_os} in
3552 aix*)
3553   AC_CACHE_CHECK([for -bbigtoc option], [gdb_cv_bigtoc], [
3554     case $GCC in
3555     yes) gdb_cv_bigtoc=-Wl,-bbigtoc ;;
3556     *) gdb_cv_bigtoc=-bbigtoc ;;
3557     esac
3559     LDFLAGS=$LDFLAGS\ $gdb_cv_bigtoc
3560     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])], [], [gdb_cv_bigtoc=])
3561   ])
3562   ;;
3563 esac
3565 # Change CFLAGS, CPPFLAGS, and LIBS temporarily so that C_SWITCH_X_SITE
3566 # is for the tests that follow.  We set them back later on.
3568 REAL_CFLAGS="$CFLAGS"
3569 REAL_CPPFLAGS="$CPPFLAGS"
3570 REAL_LIBS="$LIBS"
3572 if test "${HAVE_X11}" = "yes"; then
3573   DEFS="$C_SWITCH_X_SITE $DEFS"
3574   LDFLAGS="$LDFLAGS $LD_SWITCH_X_SITE"
3575   LIBS="-lX11 $LIBS"
3576   CFLAGS="$C_SWITCH_X_SITE $CFLAGS"
3577   CPPFLAGS="$C_SWITCH_X_SITE $CPPFLAGS"
3579   # On Solaris, arrange for LD_RUN_PATH to point to the X libraries for tests.
3580   # This is handled by LD_SWITCH_X_SITE_RPATH during the real build,
3581   # but it's more convenient here to set LD_RUN_PATH since this
3582   # also works on hosts that don't understand LD_SWITCH_X_SITE_RPATH.
3583   if test "${x_libraries}" != NONE && test -n "${x_libraries}"; then
3584     LD_RUN_PATH=$x_libraries${LD_RUN_PATH+:}$LD_RUN_PATH
3585     export LD_RUN_PATH
3586   fi
3588   # Reportedly, some broken Solaris systems have XKBlib.h but are missing
3589   # header files included from there.
3590   AC_CACHE_CHECK([for Xkb], [emacs_cv_xkb],
3591   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>
3592 #include <X11/XKBlib.h>]],
3593         [[XkbDescPtr kb = XkbGetKeyboard (0, XkbAllComponentsMask, XkbUseCoreKbd);]])],
3594         [emacs_cv_xkb=yes],
3595         [emacs_cv_xkb=no])])
3596   if test $emacs_cv_xkb = yes; then
3597     AC_DEFINE([HAVE_XKB], [1], [Define to 1 if you have the Xkb extension.])
3598     AC_CHECK_FUNCS([XkbRefreshKeyboardMapping XkbFreeNames])
3599   fi
3601   AC_CHECK_FUNCS([XrmSetDatabase XScreenResourceString XScreenNumberOfScreen])
3602   AC_CHECK_FUNCS([XDisplayCells XDestroySubwindows])
3605 if test "${window_system}" = "x11"; then
3606   AC_MSG_CHECKING([X11 version 6])
3607   AC_CACHE_VAL([emacs_cv_x11_version_6],
3608   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
3609 [[#if XlibSpecificationRelease < 6
3610 fail;
3611 #endif
3612 ]])], [emacs_cv_x11_version_6=yes],
3613       [emacs_cv_x11_version_6=no])])
3614   if test $emacs_cv_x11_version_6 = yes; then
3615     AC_MSG_RESULT([6 or newer])
3616     AC_DEFINE([HAVE_X11R6], [1],
3617               [Define to 1 if you have the X11R6 or newer version of Xlib.])
3618     AC_DEFINE([HAVE_X_I18N], [1], [Define if you have usable i18n support.])
3619     AC_CHECK_MEMBERS([XICCallback.callback], [], [], [#include <X11/Xlib.h>])
3620     ## inoue@ainet.or.jp says Solaris has a bug related to X11R6-style
3621     ## XIM support.
3622     case "$opsys" in
3623       solaris) : ;;
3624       *) AC_DEFINE([HAVE_X11R6_XIM], [1],
3625            [Define if you have usable X11R6-style XIM support.])
3626          ;;
3627     esac
3628   else
3629     AC_MSG_RESULT([before 6])
3630   fi
3633 ### Use -lrsvg-2 if available, unless '--with-rsvg=no' is specified.
3634 HAVE_RSVG=no
3635 if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" \
3636    || test "${opsys}" = "mingw32" || test "${HAVE_BE_APP}" = "yes" \
3637    || test "${window_system}" = "pgtk" \
3638    || test "${REALLY_ANDROID}" = "yes"; then
3639   if test "${with_rsvg}" != "no"; then
3640     RSVG_REQUIRED=2.14.0
3641     AS_IF([test "${REALLY_ANDROID}" = "yes"],
3642       [RSVG_MODULE="librsvg"],
3643       [RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"])
3645     EMACS_CHECK_MODULES([RSVG], [$RSVG_MODULE])
3646     AC_SUBST([RSVG_CFLAGS])
3647     AC_SUBST([RSVG_LIBS])
3649     if test $HAVE_RSVG = yes; then
3650       AC_DEFINE([HAVE_RSVG], [1], [Define to 1 if using librsvg.])
3651       CFLAGS="$CFLAGS $RSVG_CFLAGS"
3652       # Windows loads librsvg dynamically
3653       if test "${opsys}" = "mingw32"; then
3654         RSVG_LIBS=
3655       fi
3656     fi
3657   fi
3660 ### Use -lwebp if available, unless '--with-webp=no'
3661 HAVE_WEBP=no
3662 if test "${with_webp}" != "no"; then
3663    if test "${HAVE_X11}" = "yes" || test "${opsys}" = "mingw32" \
3664    || test "${HAVE_W32}" = "yes" || test "${HAVE_NS}" = "yes" \
3665    || test "${HAVE_BE_APP}" = "yes" || test "${HAVE_PGTK}" = "yes" \
3666    || test "${REALLY_ANDROID}" = "yes"; then
3667       WEBP_REQUIRED=0.6.0
3668       WEBP_MODULE="libwebpdemux >= $WEBP_REQUIRED"
3670       EMACS_CHECK_MODULES([WEBP], [$WEBP_MODULE])
3672       # WebPGetInfo is sometimes not present inside libwebpdemux, so
3673       # if it does not link, also check for libwebpdecoder.
3675       OLD_CFLAGS=$CFLAGS
3676       OLD_LIBS=$LIBS
3677       CFLAGS="$CFLAGS $WEBP_CFLAGS"
3678       LIBS="$LIBS $WEBP_LIBS"
3680       AS_IF([test "$REALLY_ANDROID" != "yes"], [
3681         AC_CHECK_FUNC([WebPGetInfo], [],
3682           [WEBP_MODULE="$WEBP_MODULE libwebpdecoder >= $WEBP_REQUIRED"
3683            HAVE_WEBP=no
3684            AS_UNSET([WEBP_LIBS])
3685            AS_UNSET([WEBP_CFLAGS])
3686            EMACS_CHECK_MODULES([WEBP], [$WEBP_MODULE])])])
3688       CFLAGS=$OLD_CFLAGS
3689       LIBS=$OLD_LIBS
3691       AC_SUBST([WEBP_CFLAGS])
3692       AC_SUBST([WEBP_LIBS])
3693    fi
3694    if test $HAVE_WEBP = yes; then
3695       AC_DEFINE([HAVE_WEBP], [1], [Define to 1 if using libwebp.])
3696       # Windows loads libwebp dynamically
3697       if test "${opsys}" = "mingw32"; then
3698         WEBP_LIBS=
3699       fi
3700    fi
3703 ### Use -lsqlite3 if available, unless '--with-sqlite3=no'
3704 HAVE_SQLITE3=no
3705 SQLITE3_LIBS=
3706 SQLITE3_CFLAGS=
3707 if test "${with_sqlite3}" != "no"; then
3708    if test "${REALLY_ANDROID}" = "yes"; then
3709      ndk_SEARCH_MODULE([sqlite3], [SQLITE3], [HAVE_SQLITE3=yes])
3711      if test "$HAVE_SQLITE3" = "yes"; then
3712        SAVE_CFLAGS="$CFLAGS"
3713        CFLAGS="$CFLAGS $SQLITE3_CFLAGS"
3714        AC_CHECK_DECL([sqlite3_open_v2], [HAVE_SQLITE=yes],
3715          [HAVE_SQLITE3=no], [#include <sqlite3.h>])
3716        CFLAGS="$SAVE_CFLAGS"
3717      fi
3718    else
3719      AC_CHECK_LIB([sqlite3], [sqlite3_open_v2],
3720        [HAVE_SQLITE3=yes],
3721        [HAVE_SQLITE3=no])
3722      if test "$HAVE_SQLITE3" = "yes"; then
3723        SQLITE3_LIBS=-lsqlite3
3724        LIBS="$SQLITE3_LIBS $LIBS"
3725        # Windows loads libsqlite dynamically
3726        if test "${opsys}" = "mingw32"; then
3727           SQLITE3_LIBS=
3728        fi
3729        AC_CHECK_LIB([sqlite3], [sqlite3_load_extension],
3730          [HAVE_SQLITE3_LOAD_EXTENSION=yes],
3731          [HAVE_SQLITE3_LOAD_EXTENSION=no])
3732        if test "$HAVE_SQLITE3_LOAD_EXTENSION" = "yes"; then
3733          AC_DEFINE([HAVE_SQLITE3_LOAD_EXTENSION], [1],
3734            [Define to 1 if sqlite3 supports loading extensions.])
3735        fi
3736      fi
3737   fi
3739   if test "$HAVE_SQLITE3" = "yes"; then
3740     AC_DEFINE([HAVE_SQLITE3], [1],
3741       [Define to 1 if you have the libsqlite3 library (-lsqlite).])
3742   fi
3745 AC_SUBST([SQLITE3_LIBS])
3746 AC_SUBST([SQLITE3_CFLAGS])
3748 HAVE_IMAGEMAGICK=no
3749 if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${HAVE_W32}" = "yes" || \
3750    test "${HAVE_BE_APP}" = "yes" || test "${window_system}" = "pgtk" || \
3751    test "${REALLY_ANDROID}" = "yes"; then
3752   if test "${with_imagemagick}" != "no"; then
3753     if test -n "$BREW"; then
3754       # Homebrew doesn't link ImageMagick 6 by default, so make sure
3755       # pkgconfig can find it.
3756       export PKG_CONFIG_PATH="$PKG_CONFIG_PATH$PATH_SEPARATOR`$BREW --prefix imagemagick@6 2>/dev/null`/lib/pkgconfig"
3757     fi
3759     EMACS_CHECK_MODULES([IMAGEMAGICK], [MagickWand >= 7])
3760     if test $HAVE_IMAGEMAGICK = yes; then
3761        AC_DEFINE([HAVE_IMAGEMAGICK7], [1],
3762          [Define to 1 if using ImageMagick7.])
3763     else
3764        ## 6.3.5 is the earliest version known to work; see Bug#17339.
3765        ## 6.8.2 makes Emacs crash; see Bug#13867.
3766        EMACS_CHECK_MODULES([IMAGEMAGICK], [Wand >= 6.3.5 Wand != 6.8.2])
3767     fi
3769     if test $HAVE_IMAGEMAGICK = yes; then
3770       OLD_CFLAGS=$CFLAGS
3771       OLD_LIBS=$LIBS
3772       CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS"
3773       LIBS="$IMAGEMAGICK_LIBS $LIBS"
3774       if test "$REALLY_ANDROID" != "yes"; then
3775         AC_CHECK_FUNCS([MagickRelinquishMemory MagickExportImagePixels \
3776                         MagickMergeImageLayers MagickAutoOrientImage])
3777       else
3778         # AC_CHECK_FUNCS doesn't work for Android dependencies because
3779         # they are built alongside Emacs.
3780         AC_CHECK_DECLS([MagickRelinquishMemory,MagickExportImagePixels,
3781 MagickMergeImageLayers,MagickAutoOrientImage],
3782                        [], [], [#include <MagickWand/MagickWand.h>])
3783       fi
3784       CFLAGS=$OLD_CFLAGS
3785       LIBS=$OLD_LIBS
3786       # Check that ImageMagick links.  It does not link on Fedora 25
3787       # with './configure CC=clang', as pkg-config outputs flags like
3788       # -lomp that work for GCC but not Clang.
3789       if test "$ac_cv_func_MagickRelinquishMemory" != yes \
3790          && test "$REALLY_ANDROID" != "yes"; then
3791         HAVE_IMAGEMAGICK=no
3792       fi
3793     fi
3794     if test $HAVE_IMAGEMAGICK = yes; then
3795       AC_DEFINE([HAVE_IMAGEMAGICK], [1], [Define to 1 if using ImageMagick.])
3796     else
3797       if test "${with_imagemagick}" != "no"; then
3798         AC_MSG_ERROR([ImageMagick wanted, but it does not compile.  Maybe some library files are missing?]);
3799       fi
3800       IMAGEMAGICK_CFLAGS=
3801       IMAGEMAGICK_LIBS=
3802     fi
3803     AC_SUBST([IMAGEMAGICK_CFLAGS])
3804     AC_SUBST([IMAGEMAGICK_LIBS])
3805   fi
3808 AC_CHECK_LIB([anl], [getaddrinfo_a], [HAVE_GETADDRINFO_A=yes])
3809 if test "${HAVE_GETADDRINFO_A}" = "yes"; then
3810   AC_DEFINE([HAVE_GETADDRINFO_A], [1],
3811 [Define to 1 if you have getaddrinfo_a for asynchronous DNS resolution.])
3812   GETADDRINFO_A_LIBS="-lanl"
3813   AC_SUBST([GETADDRINFO_A_LIBS])
3816 HAVE_GTK=no
3817 GTK_OBJ=
3818 gtk_term_header=$term_header
3819 check_gtk2=no
3820 gtk3_pkg_errors=
3821 if test "${opsys}" != "mingw32"; then
3822   if test "${with_gtk3}" = "yes" || test "${with_gtk}" = "yes" || test "$USE_X_TOOLKIT" = "maybe"; then
3823     GLIB_REQUIRED=2.37.5
3824     if test "${window_system}" = "x11"; then
3825       GTK_REQUIRED=3.10
3826     else
3827       GTK_REQUIRED=3.22.23
3828     fi
3829     GTK_MODULES="gtk+-3.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
3831     dnl Checks for libraries.
3832     EMACS_CHECK_MODULES([GTK], [$GTK_MODULES],
3833       [pkg_check_gtk=yes], [pkg_check_gtk=no])
3834     if test "$pkg_check_gtk" = "no" && test "$with_gtk3" = "yes"; then
3835        AC_MSG_ERROR([$GTK_PKG_ERRORS])
3836     fi
3837     if test "$pkg_check_gtk" = "yes"; then
3838        AC_DEFINE([HAVE_GTK3], [1], [Define to 1 if using GTK 3 or later.])
3839        GTK_OBJ=emacsgtkfixed.o
3840        gtk_term_header=gtkutil.h
3841        USE_GTK_TOOLKIT="GTK3"
3842        if test "x$ac_enable_gtk_deprecation_warnings" = x; then
3843          AC_DEFINE([GDK_DISABLE_DEPRECATION_WARNINGS], [1],
3844            [Define to 1 to disable GTK+/GDK deprecation warnings.])
3845          AC_DEFINE([GLIB_DISABLE_DEPRECATION_WARNINGS], [1],
3846            [Define to 1 to disable Glib deprecation warnings.])
3847        fi
3848     else
3849        check_gtk2=yes
3850        gtk3_pkg_errors="$GTK_PKG_ERRORS "
3851     fi
3852   fi
3854   if test "${with_gtk2}" = "yes" || test "$check_gtk2" = "yes"; then
3855     GLIB_REQUIRED=2.28
3856     GTK_REQUIRED=2.24
3857     GTK_MODULES="gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
3859     dnl Checks for libraries.
3860     EMACS_CHECK_MODULES([GTK], [$GTK_MODULES],
3861       [pkg_check_gtk=yes], [pkg_check_gtk=no])
3862     if test "$pkg_check_gtk" = "no" &&
3863        { test "$with_gtk" = yes || test "$with_gtk2" = "yes"; }
3864     then
3865       AC_MSG_ERROR([$gtk3_pkg_errors$GTK_PKG_ERRORS])
3866     fi
3867     test "$pkg_check_gtk" = "yes" && USE_GTK_TOOLKIT="GTK2"
3868   fi
3871 OLD_CFLAGS=$CFLAGS
3872 OLD_LIBS=$LIBS
3874 if test x"$pkg_check_gtk" = xyes; then
3876   AC_SUBST([GTK_LIBS])
3877   CFLAGS="$CFLAGS $GTK_CFLAGS"
3878   LIBS="$GTK_LIBS $LIBS"
3879   dnl Try to compile a simple GTK program.
3880   AC_CACHE_CHECK([whether GTK compiles], [emacs_cv_gtk_compiles],
3881   [AC_LINK_IFELSE(
3882     [AC_LANG_PROGRAM(
3883        [[/* Check the Gtk and Glib APIs.  */
3884          #include <gtk/gtk.h>
3885          #include <glib-object.h>
3886          static void
3887          callback (GObject *go, GParamSpec *spec, gpointer user_data)
3888          {}
3889        ]],
3890        [[
3891          GtkSettings *gs = 0;
3892          /* Use G_CALLBACK to make sure function pointers can be cast to void *;
3893             strict C prohibits this.  Use gtk_main_iteration to test that the
3894             libraries are there.  */
3895          if (g_signal_handler_find (G_OBJECT (gs), G_SIGNAL_MATCH_FUNC,
3896                                     0, 0, 0, G_CALLBACK (callback), 0))
3897            gtk_main_iteration ();
3898        ]])],
3899     [emacs_cv_gtk_compiles=yes], [emacs_cv_gtk_compiles=no])])
3900   if test "${emacs_cv_gtk_compiles}" != "yes"; then
3901     GTK_OBJ=
3902     if test "$USE_X_TOOLKIT" != "maybe"; then
3903       AC_MSG_ERROR([Gtk+ wanted, but it does not compile, see config.log.  Maybe some x11-devel files missing?]);
3904     fi
3905   else
3906     C_SWITCH_X_SITE="$C_SWITCH_X_SITE $GTK_CFLAGS"
3907     HAVE_GTK=yes
3908     AC_DEFINE([USE_GTK], [1], [Define to 1 if using GTK.])
3909     GTK_OBJ="gtkutil.o $GTK_OBJ"
3910     term_header=$gtk_term_header
3911     USE_X_TOOLKIT=none
3912     AC_MSG_WARN([[Your version of Gtk+ will have problems with
3913        closing open displays.  This is no problem if you just use
3914        one display, but if you use more than one and close one of them
3915        Emacs may crash.
3916        See https://gitlab.gnome.org/GNOME/gtk/issues/221]])
3917   fi
3920 AC_SUBST([GTK_OBJ])
3923 if test "${HAVE_GTK}" = "yes"; then
3925   dnl  GTK scrollbars resemble toolkit scrollbars a lot, so to avoid
3926   dnl  a lot if #ifdef:s, say we have toolkit scrollbars.
3927   if test "$with_toolkit_scroll_bars" != no; then
3928     with_toolkit_scroll_bars=yes
3929   fi
3931   term_header=gtkutil.h
3933   if test "${USE_GTK_TOOLKIT}" = GTK2; then
3935     dnl  Check if we have the old file selection dialog declared and
3936     dnl  in the link library.  In 2.x it may be in the library,
3937     dnl  but not declared if deprecated featured has been selected out.
3938     dnl  AC_CHECK_DECL checks for a macro, so check for GTK_TYPE_FILE_SELECTION.
3939     HAVE_GTK_FILE_SELECTION=no
3940     AC_CHECK_DECL([GTK_TYPE_FILE_SELECTION],
3941                   [HAVE_GTK_FILE_SELECTION=yes],
3942                   [HAVE_GTK_FILE_SELECTION=no],
3943                   [AC_INCLUDES_DEFAULT
3944 #include <gtk/gtk.h>])
3945     if test "$HAVE_GTK_FILE_SELECTION" = yes; then
3946       AC_CHECK_FUNCS([gtk_file_selection_new])
3947     fi
3949     dnl This procedure causes a bug on certain Ubuntu GTK+2 builds
3950     AC_CHECK_FUNCS([gtk_window_set_has_resize_grip])
3951   fi
3954 CFLAGS=$OLD_CFLAGS
3955 LIBS=$OLD_LIBS
3957 PGTK_OBJ=
3958 PGTK_LIBS=
3959 if test "$window_system" = "pgtk"; then
3960   PGTK_OBJ="pgtkfns.o pgtkterm.o pgtkselect.o pgtkmenu.o pgtkim.o xsettings.o"
3961   PGTK_LIBS="$GTK_LIBS"
3963 AC_SUBST([PGTK_OBJ])
3964 AC_SUBST([PGTK_LIBS])
3966 AC_CHECK_FUNCS([malloc_trim])
3968 dnl D-Bus has been tested under GNU/Linux only.  Must be adapted for
3969 dnl other platforms.
3970 HAVE_DBUS=no
3971 DBUS_OBJ=
3972 if test "${with_dbus}" = "yes"; then
3973    EMACS_CHECK_MODULES([DBUS], [dbus-1 >= 1.0])
3974    if test "$HAVE_DBUS" = yes; then
3975      AC_DEFINE([HAVE_DBUS], [1], [Define to 1 if using D-Bus.])
3976      dnl dbus_watch_get_unix_fd has been introduced in D-Bus 1.1.1.
3977      dnl dbus_type_is_valid and dbus_validate_* have been introduced in
3978      dnl D-Bus 1.5.12.
3979      dnl dbus_message_set_allow_interactive_authorization was introduced
3980      dnl in D-Bus 1.8.10.
3981      OLD_LIBS=$LIBS
3982      LIBS="$LIBS $DBUS_LIBS"
3983      AC_CHECK_FUNCS([dbus_watch_get_unix_fd \
3984                     dbus_type_is_valid \
3985                     dbus_validate_bus_name \
3986                     dbus_validate_path \
3987                     dbus_validate_interface \
3988                     dbus_validate_member \
3989                     dbus_message_set_allow_interactive_authorization])
3990      LIBS=$OLD_LIBS
3991      DBUS_OBJ=dbusbind.o
3992    fi
3994 AC_SUBST([DBUS_CFLAGS])
3995 AC_SUBST([DBUS_LIBS])
3996 AC_SUBST([DBUS_OBJ])
3998 dnl GSettings has been tested under GNU/Linux only.
3999 HAVE_GSETTINGS=no
4000 if test "${HAVE_X11}" = "yes" -o "${window_system}" = "pgtk" && test "${with_gsettings}" = "yes"; then
4001    EMACS_CHECK_MODULES([GSETTINGS], [gio-2.0 >= 2.26])
4002    if test "$HAVE_GSETTINGS" = "yes"; then
4003       old_CFLAGS=$CFLAGS
4004       CFLAGS="$CFLAGS $GSETTINGS_CFLAGS"
4005       old_LIBS=$LIBS
4006       LIBS="$LIBS $GSETTINGS_LIBS"
4007       AC_CACHE_CHECK([whether GSettings is in gio], [emacs_cv_gsettings_in_gio],
4008       [AC_LINK_IFELSE(
4009          [AC_LANG_PROGRAM(
4010              [[/* Check that gsettings really is present.  */
4011              #include <glib-object.h>
4012              #include <gio/gio.h>
4013              ]],
4014              [[
4015                GSettings *settings;
4016                GVariant *val = g_settings_get_value (settings, "");
4017              ]])],
4018        [emacs_cv_gsettings_in_gio=yes], [emacs_cv_gsettings_in_gio=no])])
4020       if test "$emacs_cv_gsettings_in_gio" = "yes"; then
4021         AC_DEFINE([HAVE_GSETTINGS], [1], [Define to 1 if using GSettings.])
4022         SETTINGS_CFLAGS="$GSETTINGS_CFLAGS"
4023         SETTINGS_LIBS="$GSETTINGS_LIBS"
4024         test "$with_gconf" = "yes" || with_gconf=no
4025       fi
4026       CFLAGS=$old_CFLAGS
4027       LIBS=$old_LIBS
4028    fi
4030 AC_SUBST([HAVE_GSETTINGS])
4032 dnl GConf has been tested under GNU/Linux only.
4033 dnl The version is really arbitrary, it is about the same age as Gtk+ 2.6.
4034 HAVE_GCONF=no
4035 if test "${HAVE_X11}" = "yes" -o "${window_system}" = "pgtk" && test "${with_gconf}" != "no"; then
4036    EMACS_CHECK_MODULES([GCONF], [gconf-2.0 >= 2.13])
4037    if test "$HAVE_GCONF" = yes; then
4038       AC_DEFINE([HAVE_GCONF], [1], [Define to 1 if using GConf.])
4039       dnl Newer GConf doesn't link with g_objects, so this is not defined.
4040       SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GCONF_CFLAGS"
4041       SETTINGS_LIBS="$SETTINGS_LIBS $GCONF_LIBS"
4042    fi
4045 if test "$HAVE_GSETTINGS" = "yes" || test "$HAVE_GCONF" = "yes"; then
4046     EMACS_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.0])
4047     if test "$HAVE_GOBJECT" = "yes"; then
4048        SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GOBJECT_CFLAGS"
4049        SETTINGS_LIBS="$SETTINGS_LIBS $GOBJECT_LIBS"
4050     fi
4051     SAVE_CFLAGS="$CFLAGS"
4052     SAVE_LIBS="$LIBS"
4053     CFLAGS="$SETTINGS_CFLAGS $CFLAGS"
4054     LIBS="$SETTINGS_LIBS $LIBS"
4055     CFLAGS="$SAVE_CFLAGS"
4056     LIBS="$SAVE_LIBS"
4058 AC_SUBST([SETTINGS_CFLAGS])
4059 AC_SUBST([SETTINGS_LIBS])
4061 USE_STARTUP_NOTIFICATION=no
4062 if test "${HAVE_GTK}" = "yes"; then
4063     USE_STARTUP_NOTIFICATION=yes
4065 AC_SUBST([USE_STARTUP_NOTIFICATION])
4067 dnl SELinux is available for Linux kernel based systems only.
4068 dnl These include GNU/Linux and Android.
4069 HAVE_LIBSELINUX=no
4070 LIBSELINUX_LIBS=
4071 LIBSELINUX_CFLAGS=
4072 if test "${with_selinux}" = "yes"; then
4073    if test "$REALLY_ANDROID" = "yes"; then
4074      ndk_SEARCH_MODULE([libselinux], [LIBSELINUX],
4075        [HAVE_LIBSELINUX=yes])
4076    else
4077      AC_CHECK_LIB([selinux], [lgetfilecon],
4078        [HAVE_LIBSELINUX=yes],
4079        [HAVE_LIBSELINUX=no])
4080    fi
4081    if test "$HAVE_LIBSELINUX" = yes; then
4082       AC_DEFINE([HAVE_LIBSELINUX], [1], [Define to 1 if using SELinux.])
4083       if test "$REALLY_ANDROID" != "yes"; then
4084         LIBSELINUX_LIBS=-lselinux
4085       fi
4086    fi
4088 AC_SUBST([LIBSELINUX_LIBS])
4089 AC_SUBST([LIBSELINUX_CFLAGS])
4091 HAVE_GNUTLS=no
4092 if test "${with_gnutls}" != "no" ; then
4093   EMACS_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.12.2],
4094     [HAVE_GNUTLS=yes], [HAVE_GNUTLS=no])
4095   if test "${HAVE_GNUTLS}" = "yes"; then
4096     AC_DEFINE([HAVE_GNUTLS], [1], [Define if using GnuTLS.])
4097   fi
4099   # Windows loads GnuTLS dynamically
4100   if test "${opsys}" = "mingw32"; then
4101     LIBGNUTLS_LIBS=
4102   fi
4105 AC_SUBST([LIBGNUTLS_LIBS])
4106 AC_SUBST([LIBGNUTLS_CFLAGS])
4108 HAVE_LIBSYSTEMD=no
4109 if test "${with_libsystemd}" = "yes" ; then
4110   dnl This code has been tested with libsystemd 222 and later.
4111   dnl FIXME: Find the earliest version number for which Emacs should work,
4112   dnl and change '222' to that number.
4113   EMACS_CHECK_MODULES([LIBSYSTEMD], [libsystemd >= 222],
4114     [HAVE_LIBSYSTEMD=yes], [HAVE_LIBSYSTEMD=no])
4115   if test "${HAVE_LIBSYSTEMD}" = "yes"; then
4116     AC_DEFINE([HAVE_LIBSYSTEMD], [1], [Define if using libsystemd.])
4117   fi
4120 AC_SUBST([LIBSYSTEMD_LIBS])
4121 AC_SUBST([LIBSYSTEMD_CFLAGS])
4123 HAVE_TREE_SITTER=no
4124 TREE_SITTER_OBJ=
4125 NEED_DYNLIB=no
4127 if test "${with_tree_sitter}" != "no"; then
4128    dnl Tree-sitter 0.20.2 added support to change the malloc it uses
4129    dnl at runtime, we need that feature.  However, tree-sitter's
4130    dnl Makefile has problems, until that's fixed, all tree-sitter
4131    dnl libraries distributed are versioned 0.6.3.  We try to
4132    dnl accept a tree-sitter library that has incorrect version as long
4133    dnl as it supports changing malloc.
4134   EMACS_CHECK_MODULES([TREE_SITTER], [tree-sitter >= 0.20.2],
4135     [HAVE_TREE_SITTER=yes], [HAVE_TREE_SITTER=no])
4136   if test "${HAVE_TREE_SITTER}" = yes; then
4137     AC_DEFINE(HAVE_TREE_SITTER, 1, [Define if using tree-sitter.])
4138     NEED_DYNLIB=yes
4139   else
4140     EMACS_CHECK_MODULES([TREE_SITTER], [tree-sitter >= 0.6.3],
4141       [HAVE_TREE_SITTER=yes], [HAVE_TREE_SITTER=no])
4142     if test "${HAVE_TREE_SITTER}" = yes; then
4143       OLD_CFLAGS=$CFLAGS
4144       OLD_LIBS=$LIBS
4145       CFLAGS="$CFLAGS $TREE_SITTER_CFLAGS"
4146       LIBS="$TREE_SITTER_LIBS $LIBS"
4147       AC_CHECK_FUNCS([ts_set_allocator])
4148       CFLAGS=$OLD_CFLAGS
4149       LIBS=$OLD_LIBS
4150       if test "$ac_cv_func_ts_set_allocator" = yes; then
4151         AC_DEFINE(HAVE_TREE_SITTER, 1, [Define if using tree-sitter.])
4152         NEED_DYNLIB=yes
4153       else
4154         AC_MSG_ERROR([Tree-sitter library exists but its version is too old]);
4155         TREE_SITTER_CFLAGS=
4156         TREE_SITTER_LIBS=
4157       fi
4158     fi
4159   fi
4161   # Windows loads tree-sitter dynamically
4162   if test "${opsys}" = "mingw32"; then
4163     TREE_SITTER_LIBS=
4164   fi
4167 AC_SUBST(TREE_SITTER_LIBS)
4168 AC_SUBST(TREE_SITTER_CFLAGS)
4170 NOTIFY_OBJ=
4171 NOTIFY_SUMMARY=no
4173 dnl MS Windows native file monitor is available for mingw32 only.
4174 case $with_file_notification,$opsys in
4175   w32,cygwin)
4176     AC_MSG_ERROR(['--with-file-notification=w32' was specified, but
4177     this is only supported on MS-Windows native and MinGW32 builds.
4178     Consider using gfile instead.])
4179     ;;
4180   w32,* | yes,mingw32)
4181     AC_CHECK_HEADER([windows.h])
4182     if test "$ac_cv_header_windows_h" = yes ; then
4183        AC_DEFINE([HAVE_W32NOTIFY], [1], [Define to 1 to use w32notify.])
4184        NOTIFY_OBJ=w32notify.o
4185        NOTIFY_SUMMARY="yes (w32)"
4186     fi ;;
4187 esac
4189 dnl inotify is available only on Linux-kernel based systems.
4190 case $with_file_notification,$NOTIFY_OBJ in
4191   inotify, | yes,)
4192     AC_CHECK_HEADER([sys/inotify.h])
4193     if test "$ac_cv_header_sys_inotify_h" = yes ; then
4194         AC_CHECK_FUNCS([inotify_init inotify_init1])
4195         if test "$ac_cv_func_inotify_init" = yes; then
4196           AC_DEFINE([HAVE_INOTIFY], [1], [Define to 1 to use inotify.])
4197           NOTIFY_OBJ=inotify.o
4198           NOTIFY_SUMMARY="yes (inotify)"
4199        fi
4200     fi ;;
4201 esac
4203 AS_IF([test "$opsys" != "haiku"], [
4204  dnl kqueue is available on BSD-like systems and Haiku, but Haiku's
4205  dnl implementation cannot monitor filesystem activity.
4206  case $with_file_notification,$NOTIFY_OBJ in
4207    kqueue,* | yes,)
4208      EMACS_CHECK_MODULES([KQUEUE], [libkqueue])
4209      if test "$HAVE_KQUEUE" = "yes"; then
4210         AC_DEFINE([HAVE_KQUEUE], [1], [Define to 1 to use kqueue.])
4211         CPPFLAGS="$CPPFLAGS -I/usr/include/kqueue"
4212         NOTIFY_CFLAGS=$KQUEUE_CFLAGS
4213         NOTIFY_LIBS=$KQUEUE_LIBS
4214         NOTIFY_OBJ=kqueue.o
4215         NOTIFY_SUMMARY="yes -lkqueue"
4216      else
4217         AC_SEARCH_LIBS([kqueue], [])
4218         if test "$ac_cv_search_kqueue" != no; then
4219           AC_DEFINE([HAVE_KQUEUE], [1], [Define to 1 to use kqueue.])
4220           NOTIFY_OBJ=kqueue.o
4221           NOTIFY_SUMMARY="yes (kqueue)"
4222         fi
4223      fi ;;
4224  esac])
4226 dnl g_file_monitor exists since glib 2.18.  G_FILE_MONITOR_EVENT_MOVED
4227 dnl has been added in glib 2.24.  It has been tested under
4228 dnl GNU/Linux only.
4229 case $with_file_notification,$NOTIFY_OBJ in
4230   gfile,* | yes,)
4231     if test "${HAVE_NS}" = yes; then
4232        AC_MSG_ERROR(['--with-file-notification=gfile' is not supported in NextStep builds.
4233 Consider kqueue instead.])
4234     else
4235        EMACS_CHECK_MODULES([GFILENOTIFY], [gio-2.0 >= 2.24])
4236        if test "$HAVE_GFILENOTIFY" = "yes"; then
4237           AC_DEFINE([HAVE_GFILENOTIFY], [1], [Define to 1 if using GFile.])
4238           NOTIFY_CFLAGS=$GFILENOTIFY_CFLAGS
4239           NOTIFY_LIBS=$GFILENOTIFY_LIBS
4240           NOTIFY_OBJ=gfilenotify.o
4241           NOTIFY_SUMMARY="yes -lgio (gfile)"
4242        fi
4243     fi ;;
4244 esac
4246 case $with_file_notification,$NOTIFY_OBJ in
4247   yes,* | no,* | *,?*) ;;
4248   *) AC_MSG_ERROR([File notification '$with_file_notification' requested but requirements not found.]) ;;
4249 esac
4251 if test -n "$NOTIFY_OBJ"; then
4252    AC_DEFINE([USE_FILE_NOTIFY], [1],
4253      [Define to 1 if using file notifications.])
4255 AC_SUBST([NOTIFY_CFLAGS])
4256 AC_SUBST([NOTIFY_LIBS])
4257 AC_SUBST([NOTIFY_OBJ])
4259 dnl Do not put whitespace before the #include statements below.
4260 dnl Older compilers (eg sunos4 cc) choke on it.
4261 HAVE_XAW3D=no
4262 LUCID_LIBW=
4263 if test x"${USE_X_TOOLKIT}" = xmaybe || test x"${USE_X_TOOLKIT}" = xLUCID; then
4264   if test "$with_xaw3d" != no; then
4265     AC_CACHE_VAL([emacs_cv_xaw3d],
4266     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4267 #include <X11/Intrinsic.h>
4268 #include <X11/Xaw3d/Simple.h>]],
4269       [[]])],
4270       [AC_CHECK_LIB([Xaw3d], [XawScrollbarSetThumb],
4271                     [emacs_cv_xaw3d=yes],
4272                     [emacs_cv_xaw3d=no])],
4273       [emacs_cv_xaw3d=no])])
4274   else
4275     emacs_cv_xaw3d=no
4276   fi
4277   if test $emacs_cv_xaw3d = yes; then
4278     AC_MSG_CHECKING([for xaw3d])
4279     AC_MSG_RESULT([yes; using Lucid toolkit])
4280     USE_X_TOOLKIT=LUCID
4281     HAVE_XAW3D=yes
4282     LUCID_LIBW=-lXaw3d
4283     AC_DEFINE([HAVE_XAW3D], [1],
4284               [Define to 1 if you have the Xaw3d library (-lXaw3d).])
4285   else
4286     AC_MSG_CHECKING([for xaw3d])
4287     AC_MSG_RESULT([no])
4288     AC_MSG_CHECKING([for libXaw])
4289     AC_CACHE_VAL([emacs_cv_xaw],
4290     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4291 #include <X11/Intrinsic.h>
4292 #include <X11/Xaw/Simple.h>]],
4293       [[]])],
4294       [emacs_cv_xaw=yes],
4295       [emacs_cv_xaw=no])])
4296     if test $emacs_cv_xaw = yes; then
4297       AC_MSG_RESULT([yes; using Lucid toolkit])
4298       USE_X_TOOLKIT=LUCID
4299       LUCID_LIBW=-lXaw
4300     elif test x"${USE_X_TOOLKIT}" = xLUCID; then
4301       AC_MSG_ERROR([Lucid toolkit requires X11/Xaw include files])
4302     else
4303       AC_MSG_ERROR([No X toolkit could be found.
4304 If you are sure you want Emacs compiled without an X toolkit, pass
4305   --with-x-toolkit=no
4306 to configure.  Otherwise, install the development libraries for the toolkit
4307 that you want to use (e.g. Gtk+) and re-run configure.])
4308     fi
4309   fi
4312 X_TOOLKIT_TYPE=$USE_X_TOOLKIT
4314 LIBXTR6=
4315 LIBXMU=
4316 if test "${USE_X_TOOLKIT}" != "none"; then
4317   AC_MSG_CHECKING([X11 toolkit version])
4318   AC_CACHE_VAL([emacs_cv_x11_toolkit_version_6],
4319   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Intrinsic.h>]],
4320 [[#if XtSpecificationRelease < 6
4321 fail;
4322 #endif
4323 ]])], [emacs_cv_x11_toolkit_version_6=yes],
4324       [emacs_cv_x11_toolkit_version_6=no])])
4325   HAVE_X11XTR6=$emacs_cv_x11_toolkit_version_6
4326   if test $emacs_cv_x11_toolkit_version_6 = yes; then
4327     AC_MSG_RESULT([6 or newer])
4328     AC_DEFINE([HAVE_X11XTR6], [1],
4329               [Define to 1 if you have the X11R6 or newer version of Xt.])
4330     LIBXTR6="-lSM -lICE"
4331     case "$opsys" in
4332       ## Use libw.a along with X11R6 Xt.
4333       unixware) LIBXTR6="$LIBXTR6 -lw" ;;
4334     esac
4335   else
4336     AC_MSG_RESULT([before 6])
4337   fi
4339 dnl If using toolkit, check whether libXmu.a exists.
4340 dnl tranle@intellicorp.com says libXmu.a can need XtMalloc in libXt.a to link.
4341   OLDLIBS="$LIBS"
4342   if test x$HAVE_X11XTR6 = xyes; then
4343     OTHERLIBS='-lXt -lSM -lICE'
4344   else
4345     OTHERLIBS='-lXt'
4346   fi
4347   AC_SEARCH_LIBS([XmuConvertStandardSelection], [Xmu], [], [], [$OTHERLIBS])
4348   if test "X$LIBS" != "X$OLDLIBS"; then
4349     LIBXMU=$ac_cv_search_XmuConvertStandardSelection
4350   fi
4351   LIBS=$OLDLIBS
4352   dnl ac_cv_search_XmuConvertStandardSelection is also referenced below.
4354 AC_SUBST([LIBXTR6])
4355 AC_SUBST([LIBXMU])
4357 LIBXP=
4358 if test "${USE_X_TOOLKIT}" = "MOTIF"; then
4359   # OpenMotif may be installed in such a way on some GNU/Linux systems.
4360   if test -d /usr/include/openmotif; then
4361     CPPFLAGS="-I/usr/include/openmotif $CPPFLAGS"
4362     emacs_cv_openmotif=yes
4363     case "$canonical" in
4364       x86_64-*-linux-gnu* | powerpc64-*-linux-gnu* | sparc64-*-linux-gnu*)
4365       test -d /usr/lib64/openmotif && LDFLAGS="-L/usr/lib64/openmotif $LDFLAGS"
4366       ;;
4367       *)
4368       test -d /usr/lib/openmotif && LDFLAGS="-L/usr/lib/openmotif $LDFLAGS"
4369     esac
4370   else
4371     emacs_cv_openmotif=no
4372   fi
4373   AC_CACHE_CHECK([for (Open)Motif version 2.1], [emacs_cv_motif_version_2_1],
4374   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <Xm/Xm.h>]],
4375     [[#if XmVERSION > 2 || (XmVERSION == 2 && XmREVISION >= 1)
4376 int x = 5;
4377 #else
4378 Motif version prior to 2.1.
4379 #endif]])],
4380      [emacs_cv_motif_version_2_1=yes],
4381      [emacs_cv_motif_version_2_1=no])])
4382   if test $emacs_cv_motif_version_2_1 = yes; then
4383     AC_CHECK_LIB([Xp], [XpCreateContext], [LIBXP=-lXp])
4384     if test x$emacs_cv_openmotif = xyes; then
4385       REAL_CPPFLAGS="-I/usr/include/openmotif $REAL_CPPFLAGS"
4386     fi
4387   else
4388     # We put this in CFLAGS temporarily to precede other -I options
4389     # that might be in CFLAGS temporarily.
4390     # We put this in CPPFLAGS where it precedes the other -I options.
4391     OLD_CPPFLAGS=$CPPFLAGS
4392     OLD_CFLAGS=$CFLAGS
4393     CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CPPFLAGS"
4394     CFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CFLAGS"
4395     AC_CACHE_CHECK([for LessTif where some systems put it], [emacs_cv_lesstif],
4396       [AC_COMPILE_IFELSE(
4397          [AC_LANG_PROGRAM(
4398             [[#include </usr/X11R6/LessTif/Motif1.2/include/Xm/Xm.h>
4399             ]],
4400             [[int x = 5;]])],
4401          [emacs_cv_lesstif=yes],
4402          [emacs_cv_lesstif=no])])
4403     if test $emacs_cv_lesstif = yes; then
4404       # Make sure this -I option remains in CPPFLAGS after it is set
4405       # back to REAL_CPPFLAGS.
4406       # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
4407       # have those other -I options anyway.  Ultimately, having this
4408       # directory ultimately in CPPFLAGS will be enough.
4409       REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
4410       LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
4411     else
4412       CFLAGS=$OLD_CFLAGS
4413       CPPFLAGS=$OLD_CPPFLAGS
4414     fi
4415   fi
4416   AC_CHECK_HEADER([Xm/BulletinB.h], [],
4417     [AC_MSG_ERROR([Motif toolkit requested but requirements not found.])])
4420 dnl Use toolkit scroll bars if configured for GTK or X toolkit and either
4421 dnl using Motif or Xaw3d is available, and unless
4422 dnl --with-toolkit-scroll-bars=no was specified.
4424 AH_TEMPLATE([USE_TOOLKIT_SCROLL_BARS],
4425             [Define to 1 if we should use toolkit scroll bars.])dnl
4426 USE_TOOLKIT_SCROLL_BARS=no
4427 if test "${with_toolkit_scroll_bars}" != "no"; then
4428   if test "${USE_X_TOOLKIT}" != "none"; then
4429     if test "${USE_X_TOOLKIT}" = "MOTIF"; then
4430       AC_DEFINE([USE_TOOLKIT_SCROLL_BARS])
4431       HAVE_XAW3D=no
4432       USE_TOOLKIT_SCROLL_BARS=yes
4433     elif test "${HAVE_XAW3D}" = "yes" || test "${USE_X_TOOLKIT}" = "LUCID"; then
4434       AC_DEFINE([USE_TOOLKIT_SCROLL_BARS])
4435       USE_TOOLKIT_SCROLL_BARS=yes
4436     fi
4437   elif test "${HAVE_GTK}" = "yes"; then
4438     AC_DEFINE([USE_TOOLKIT_SCROLL_BARS])
4439     USE_TOOLKIT_SCROLL_BARS=yes
4440   elif test "${HAVE_NS}" = "yes"; then
4441     AC_DEFINE([USE_TOOLKIT_SCROLL_BARS])
4442     USE_TOOLKIT_SCROLL_BARS=yes
4443   elif test "${HAVE_W32}" = "yes"; then
4444     AC_DEFINE([USE_TOOLKIT_SCROLL_BARS])
4445     USE_TOOLKIT_SCROLL_BARS=yes
4446   elif test "${HAVE_BE_APP}" = "yes"; then
4447     AC_DEFINE([USE_TOOLKIT_SCROLL_BARS])
4448     USE_TOOLKIT_SCROLL_BARS=yes
4449   fi
4450 elif test "${window_system}" != "x11" && test "${window_system}" != "none"; then
4451   AC_MSG_ERROR([Non-toolkit scroll bars are not implemented for your system])
4454 dnl See if XIM is available.
4455 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4456           #include <X11/Xlib.h>
4457           #include <X11/Xresource.h>]],
4458          [[XIMProc  callback;]])],
4459          [HAVE_XIM=yes
4460          AC_DEFINE([HAVE_XIM], [1], [Define to 1 if XIM is available])],
4461          [HAVE_XIM=no])
4463 dnl Note this is non-standard.  --with-xim does not control whether
4464 dnl XIM support is compiled in, it only affects the runtime default of
4465 dnl use_xim in xterm.c.
4466 if test "${with_xim}" != "no"; then
4467   AC_DEFINE([USE_XIM], [1],
4468             [Define to 1 to default runtime use of XIM to on.])
4471 # Check for XRender
4472 HAVE_XRENDER=no
4473 if test "${HAVE_X11}" = "yes"; then
4474   AC_COMPILE_IFELSE(
4475     [AC_LANG_PROGRAM(
4476        [[#include <X11/Intrinsic.h>
4477          #include <X11/extensions/Xrender.h>
4478        ]],
4479        [[return !XRenderQueryExtension;]])],
4480     [AC_CHECK_LIB([Xrender], [XRenderQueryExtension], [HAVE_XRENDER=yes])])
4481   if test $HAVE_XRENDER = yes; then
4482     XRENDER_LIBS="-lXrender"
4483     AC_SUBST([XRENDER_LIBS])
4484     AC_DEFINE([HAVE_XRENDER], [1], [Define to 1 if XRender is available.])
4485   fi
4488 HAVE_CAIRO=no
4489 if test "${HAVE_X11}" = "yes"; then
4490   if test "${with_cairo}" != "no"; then
4491     CAIRO_REQUIRED=1.8.0
4492     CAIRO_MODULE="cairo >= $CAIRO_REQUIRED"
4493     EMACS_CHECK_MODULES([CAIRO], [$CAIRO_MODULE])
4494     if test $HAVE_CAIRO = yes; then
4495       AS_IF([test "x$with_cairo_xcb" = "xyes"], [
4496         CAIRO_XCB_MODULE="cairo-xcb >= $CAIRO_REQUIRED"
4497         EMACS_CHECK_MODULES([CAIRO_XCB], [$CAIRO_XCB_MODULE])
4498         AS_IF([test "x$HAVE_CAIRO_XCB" = "xyes"], [
4499           CAIRO_CFLAGS="$CAIRO_CFLAGS $CAIRO_XCB_CFLAGS"
4500           CAIRO_LIBS="$CAIRO_LIBS $CAIRO_XCB_LIBS"
4501           AC_DEFINE([USE_CAIRO_XCB], [1],
4502             [Define to 1 if cairo XCB surfaces are available.])])])
4503       AC_DEFINE([USE_CAIRO], [1], [Define to 1 if using cairo.])
4504       CFLAGS="$CFLAGS $CAIRO_CFLAGS"
4505       LIBS="$LIBS $CAIRO_LIBS"
4506       AC_SUBST([CAIRO_CFLAGS])
4507       AC_SUBST([CAIRO_LIBS])
4508     else
4509       AC_MSG_WARN([cairo requested but not found.])
4510     fi
4511   fi
4514 dnl Enable xwidgets if GTK3 and WebKitGTK+ are available.
4515 dnl Enable xwidgets if macOS Cocoa and WebKit framework are available.
4516 HAVE_XWIDGETS=no
4517 XWIDGETS_OBJ=
4518 if test "$with_xwidgets" != "no"; then
4519   if test "$USE_GTK_TOOLKIT" = "GTK3" && test "$window_system" != "none"; then
4520     WEBKIT_REQUIRED=2.12
4521     WEBKIT_BROKEN=2.41.92
4522     WEBKIT_MODULES="webkit2gtk-4.1 >= $WEBKIT_REQUIRED webkit2gtk-4.1 < $WEBKIT_BROKEN"
4523     EMACS_CHECK_MODULES([WEBKIT], [$WEBKIT_MODULES])
4524     if test "$HAVE_WEBKIT" = "no"; then
4525       WEBKIT_MODULES="webkit2gtk-4.0 >= $WEBKIT_REQUIRED webkit2gtk-4.0 < $WEBKIT_BROKEN"
4526       EMACS_CHECK_MODULES([WEBKIT], [$WEBKIT_MODULES])
4527     fi
4528     HAVE_XWIDGETS=$HAVE_WEBKIT
4529     XWIDGETS_OBJ="xwidget.o"
4530     if test "$HAVE_X_WINDOWS" = "yes" && test "${with_cairo}" = "no"; then
4531       CAIRO_XLIB_MODULES="cairo >= 1.8.0 cairo-xlib >= 1.8.0"
4532       EMACS_CHECK_MODULES([CAIRO_XLIB], [$CAIRO_XLIB_MODULES])
4533       if test $HAVE_CAIRO_XLIB = "yes"; then
4534         CAIRO_CFLAGS="$CAIRO_XLIB_CFLAGS"
4535         CAIRO_LIBS="$CAIRO_XLIB_LIBS"
4536         AC_SUBST([CAIRO_CFLAGS])
4537         AC_SUBST([CAIRO_LIBS])
4538       else
4539         AC_MSG_ERROR([xwidgets requested, but a suitable cairo installation wasn't found])
4540       fi
4541     fi
4542   elif test "${NS_IMPL_COCOA}" = "yes"; then
4543     dnl FIXME: Check framework WebKit2
4544     dnl WEBKIT_REQUIRED=M.m.p
4545     WEBKIT_LIBS="-Wl,-framework -Wl,WebKit"
4546     WEBKIT_CFLAGS="-I/System/Library/Frameworks/WebKit.framework/Headers"
4547     HAVE_WEBKIT="yes"
4548     HAVE_XWIDGETS=$HAVE_WEBKIT
4549     XWIDGETS_OBJ="xwidget.o"
4550     NS_OBJC_OBJ="$NS_OBJC_OBJ nsxwidget.o"
4551     dnl Update NS_OBJC_OBJ with added nsxwidget.o
4552     AC_SUBST([NS_OBJC_OBJ])
4553   else
4554     AC_MSG_ERROR([xwidgets requested, it requires GTK3 as X window toolkit or macOS Cocoa as window system.])
4555   fi
4557   test $HAVE_XWIDGETS = yes ||
4558     AC_MSG_ERROR([xwidgets requested but WebKitGTK+ or WebKit framework not found.])
4560   AC_DEFINE([HAVE_XWIDGETS], [1], [Define to 1 if you have xwidgets support.])
4562 AC_SUBST([XWIDGETS_OBJ])
4564 if test "$window_system" = "pgtk"; then
4565   CAIRO_REQUIRED=1.12.0
4566   CAIRO_MODULE="cairo >= $CAIRO_REQUIRED"
4567   EMACS_CHECK_MODULES([CAIRO], [$CAIRO_MODULE])
4568   if test $HAVE_CAIRO = yes; then
4569     AC_DEFINE([USE_CAIRO], [1], [Define to 1 if using cairo.])
4570   else
4571     AC_MSG_ERROR([cairo required but not found.])
4572   fi
4574   CFLAGS="$CFLAGS $CAIRO_CFLAGS"
4575   LIBS="$LIBS $CAIRO_LIBS"
4576   AC_SUBST([CAIRO_CFLAGS])
4577   AC_SUBST([CAIRO_LIBS])
4580 if test "${HAVE_BE_APP}" = "yes"; then
4581   if test "${with_be_cairo}" != "no"; then
4582     CAIRO_REQUIRED=1.8.0
4583     CAIRO_MODULE="cairo >= $CAIRO_REQUIRED"
4584     EMACS_CHECK_MODULES([CAIRO], [$CAIRO_MODULE])
4585     if test $HAVE_CAIRO = yes; then
4586       AC_DEFINE([USE_BE_CAIRO], [1], [Define to 1 if using cairo on Haiku.])
4587       CFLAGS="$CFLAGS $CAIRO_CFLAGS"
4588       LIBS="$LIBS $CAIRO_LIBS"
4589       AC_SUBST([CAIRO_CFLAGS])
4590       AC_SUBST([CAIRO_LIBS])
4591     else
4592       AC_MSG_WARN([cairo requested but not found.])
4593     fi
4594   fi
4597 ### Start of font-backend (under any platform) section.
4598 # (nothing here yet -- this is a placeholder)
4599 ### End of font-backend (under any platform) section.
4601 ### Start of font-backend (under X11) section.
4602 if test "${HAVE_X11}" = "yes"; then
4603   if test $HAVE_CAIRO = yes; then
4604     dnl Strict linkers fail with
4605     dnl ftfont.o: undefined reference to symbol 'FT_New_Face'
4606     dnl if -lfreetype is not specified.
4607     dnl The following is needed to set FREETYPE_LIBS.
4608     EMACS_CHECK_MODULES([FREETYPE], [freetype2])
4610     test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR([cairo requires libfreetype])
4612     EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
4614     test "$HAVE_FONTCONFIG" = "no" &&
4615       AC_MSG_ERROR([cairo requires libfontconfig])
4616     dnl For the "Does Emacs use" message at the end.
4617     HAVE_XFT=no
4618   else
4619     ## Use -lXft if available, unless '--with-xft=no'.
4620     HAVE_XFT=maybe
4621     if test "x${with_x}" = "xno"; then
4622       with_xft="no";
4623     fi
4625     if test "$with_xft" != no; then
4626       EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
4627       with_xft=$HAVE_FONTCONFIG
4628     fi
4630     if test "x${with_xft}" != "xno"; then
4632       EMACS_CHECK_MODULES([XFT], [xft >= 0.13.0], [], [HAVE_XFT=no])
4633       ## Because xterm.c uses XRenderQueryExtension when XFT is
4634       ## enabled, we also need to link to -lXrender.
4635       if test "$HAVE_XFT" != no && test "$HAVE_XRENDER" != no; then
4636         OLD_CPPFLAGS="$CPPFLAGS"
4637         OLD_CFLAGS="$CFLAGS"
4638         OLD_LIBS="$LIBS"
4639         CPPFLAGS="$CPPFLAGS $XFT_CFLAGS"
4640         CFLAGS="$CFLAGS $XFT_CFLAGS"
4641         LIBS="$XFT_LIBS $LIBS"
4642         AC_CHECK_HEADER([X11/Xft/Xft.h],
4643           [AC_CHECK_LIB([Xft], [XftFontOpen], [HAVE_XFT=yes],
4644              [], [$XFT_LIBS])],
4645           [],
4646           [[#include <X11/X.h>]])
4648         if test "${HAVE_XFT}" = "yes"; then
4649           AC_DEFINE([HAVE_XFT], [1], [Define to 1 if you have the Xft library.])
4650             AC_SUBST([XFT_LIBS])
4651           C_SWITCH_X_SITE="$C_SWITCH_X_SITE $XFT_CFLAGS"
4652         fi                        # "${HAVE_XFT}" = "yes"
4653         CPPFLAGS=$OLD_CPPFLAGS
4654         CFLAGS=$OLD_CFLAGS
4655         LIBS=$OLD_LIBS
4656       else
4657       # Make sure XFT is disabled if we found XFT but not XRender
4658         HAVE_XFT=no
4659       fi                          # "$HAVE_XFT" != no
4660     fi                            # "x${with_xft}" != "xno"
4662     if test "$HAVE_XFT" != "yes"; then
4663        dnl For the "Does Emacs use" message at the end.
4664        HAVE_XFT=no
4665        HAVE_FREETYPE=no
4666     else
4667        dnl Strict linkers fail with
4668        dnl ftfont.o: undefined reference to symbol 'FT_New_Face'
4669        dnl if -lfreetype is not specified.
4670        dnl The following is needed to set FREETYPE_LIBS.
4671        EMACS_CHECK_MODULES([FREETYPE], [freetype2])
4673        test "$HAVE_FREETYPE" = "no" &&
4674          AC_MSG_ERROR([libxft requires libfreetype])
4675     fi
4676   fi                              # $HAVE_CAIRO != yes
4678   HAVE_LIBOTF=no
4679   if test "${HAVE_FREETYPE}" = "yes"; then
4680     AC_DEFINE([HAVE_FREETYPE], [1],
4681               [Define to 1 if using the freetype and fontconfig libraries.])
4682     OLD_CFLAGS=$CFLAGS
4683     OLD_LIBS=$LIBS
4684     CFLAGS="$CFLAGS $FREETYPE_CFLAGS"
4685     LIBS="$FREETYPE_LIBS $LIBS"
4686     AC_CHECK_FUNCS([FT_Face_GetCharVariantIndex])
4687     CFLAGS=$OLD_CFLAGS
4688     LIBS=$OLD_LIBS
4689     if test "${with_libotf}" != "no"; then
4690       EMACS_CHECK_MODULES([LIBOTF], [libotf])
4691       if test "$HAVE_LIBOTF" = "yes"; then
4692         AC_DEFINE([HAVE_LIBOTF], [1], [Define to 1 if using libotf.])
4693         AC_CHECK_LIB([otf], [OTF_get_variation_glyphs],
4694                      [HAVE_OTF_GET_VARIATION_GLYPHS=yes],
4695                      [HAVE_OTF_GET_VARIATION_GLYPHS=no])
4696         if test "${HAVE_OTF_GET_VARIATION_GLYPHS}" = "yes"; then
4697           AC_DEFINE([HAVE_OTF_GET_VARIATION_GLYPHS], [1],
4698                     [Define to 1 if libotf has OTF_get_variation_glyphs.])
4699         fi
4700         if $PKG_CONFIG --atleast-version=0.9.16 libotf; then :; else
4701           AC_DEFINE([HAVE_OTF_KANNADA_BUG], [1],
4702 [Define to 1 if libotf is affected by https://debbugs.gnu.org/28110.])
4703         fi
4704       fi
4705     fi
4706   dnl FIXME should there be an error if HAVE_FREETYPE != yes?
4707   dnl Does the new font backend require it, or can it work without it?
4708   fi
4710   HAVE_M17N_FLT=no
4711   if test "${HAVE_LIBOTF}" = yes; then
4712     if test "${with_m17n_flt}" != "no"; then
4713       EMACS_CHECK_MODULES([M17N_FLT], [m17n-flt])
4714       if test "$HAVE_M17N_FLT" = "yes"; then
4715         AC_DEFINE([HAVE_M17N_FLT], [1], [Define to 1 if using libm17n-flt.])
4716       fi
4717     fi
4718   fi
4719 else # "${HAVE_X11}" != "yes"
4720   if test $window_system = pgtk; then
4721     EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
4722     EMACS_CHECK_MODULES([FREETYPE], [freetype2])
4723     if test "$HAVE_FONTCONFIG" != yes -o "$HAVE_FREETYPE" != yes; then
4724       AC_MSG_ERROR([fontconfig and freetype is required.])
4725     fi
4726     HAVE_LIBOTF=no
4727     AC_DEFINE([HAVE_FREETYPE], [1],
4728               [Define to 1 if using the freetype and fontconfig libraries.])
4729     if test "${with_libotf}" != "no"; then
4730       EMACS_CHECK_MODULES([LIBOTF], [libotf])
4731       if test "$HAVE_LIBOTF" = "yes"; then
4732         AC_DEFINE([HAVE_LIBOTF], [1], [Define to 1 if using libotf.])
4733         AC_CHECK_LIB([otf], [OTF_get_variation_glyphs],
4734                      [HAVE_OTF_GET_VARIATION_GLYPHS=yes],
4735                      [HAVE_OTF_GET_VARIATION_GLYPHS=no])
4736         if test "${HAVE_OTF_GET_VARIATION_GLYPHS}" = "yes"; then
4737           AC_DEFINE([HAVE_OTF_GET_VARIATION_GLYPHS], [1],
4738                     [Define to 1 if libotf has OTF_get_variation_glyphs.])
4739         fi
4740       fi
4741     fi
4742   else
4743     HAVE_XFT=no
4744     HAVE_FREETYPE=no
4745     HAVE_LIBOTF=no
4746     HAVE_M17N_FLT=no
4747   fi
4748 fi   # "${HAVE_X11}" != "yes"
4750 HAVE_HARFBUZZ=no
4751 ### On MS-Windows we use hb_font_get_nominal_glyph, which appeared
4752 ### in HarfBuzz version 1.2.3
4753 if test "${HAVE_W32}" = "yes"; then
4754   harfbuzz_required_ver=1.2.3
4755 else
4756   harfbuzz_required_ver=0.9.42
4758 if test "${HAVE_X11}" = "yes" && test "${HAVE_FREETYPE}" = "yes" \
4759         || test "$window_system" = "pgtk" \
4760         || test "${HAVE_W32}" = "yes" \
4761         || test "$REALLY_ANDROID" = "yes"; then
4762   if test "${with_harfbuzz}" != "no"; then
4763     EMACS_CHECK_MODULES([HARFBUZZ], [harfbuzz >= $harfbuzz_required_ver])
4764     AS_IF([test "$HAVE_HARFBUZZ" = "yes"],[
4765       AC_DEFINE([HAVE_HARFBUZZ], [1], [Define to 1 if using HarfBuzz.])
4766       ### mingw32 and Cygwin-w32 don't use -lharfbuzz, since they load
4767       ### the library dynamically.
4768       AS_IF([test "${HAVE_W32}" = "yes"], [HARFBUZZ_LIBS=])
4769       ## Now check for `hb_font_set_var_named_instance'.
4770       OLD_CFLAGS=$CFLAGS
4771       CFLAGS="$HARFBUZZ_CFLAGS $CFLAGS"
4772       EMACS_CHECK_LIB([harfbuzz], [hb_font_set_var_named_instance],
4773         [AC_DEFINE([HAVE_HB_FONT_SET_VAR_NAMED_INSTANCE], [1],
4774           [Define to 1 if `hb_font_set_var_named_instance' is present.])],
4775         [], [$HARFBUZZ_LIBS], [#include <hb.h>])
4776       CFLAGS=$OLD_CFLAGS])
4777   fi
4780 ### Start of font-backend (under Haiku) selectionn.
4781 if test "${HAVE_BE_APP}" = "yes"; then
4782   if test $HAVE_CAIRO = "yes"; then
4783       EMACS_CHECK_MODULES([FREETYPE], [freetype2 >= 2.5.0])
4784       test "$HAVE_FREETYPE" = "no" &&
4785         AC_MSG_ERROR([cairo on Haiku requires libfreetype])
4786       EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
4787       test "$HAVE_FONTCONFIG" = "no" &&
4788         AC_MSG_ERROR([cairo on Haiku requires libfontconfig])
4789   fi
4791   HAVE_LIBOTF=no
4793   if test "${HAVE_FREETYPE}" = "yes"; then
4794     AC_DEFINE([HAVE_FREETYPE], [1],
4795               [Define to 1 if using the freetype and fontconfig libraries.])
4796     OLD_CFLAGS=$CFLAGS
4797     OLD_LIBS=$LIBS
4798     CFLAGS="$CFLAGS $FREETYPE_CFLAGS"
4799     LIBS="$FREETYPE_LIBS $LIBS"
4800     AC_CHECK_FUNCS([FT_Face_GetCharVariantIndex])
4801     CFLAGS=$OLD_CFLAGS
4802     LIBS=$OLD_LIBS
4803     if test "${with_libotf}" != "no"; then
4804       EMACS_CHECK_MODULES([LIBOTF], [libotf])
4805       if test "$HAVE_LIBOTF" = "yes"; then
4806         AC_DEFINE([HAVE_LIBOTF], [1], [Define to 1 if using libotf.])
4807         AC_CHECK_LIB([otf], [OTF_get_variation_glyphs],
4808                      [HAVE_OTF_GET_VARIATION_GLYPHS=yes],
4809                      [HAVE_OTF_GET_VARIATION_GLYPHS=no])
4810         if test "${HAVE_OTF_GET_VARIATION_GLYPHS}" = "yes"; then
4811           AC_DEFINE([HAVE_OTF_GET_VARIATION_GLYPHS], [1],
4812                     [Define to 1 if libotf has OTF_get_variation_glyphs.])
4813         fi
4814         if $PKG_CONFIG --atleast-version=0.9.16 libotf; then :; else
4815           AC_DEFINE([HAVE_OTF_KANNADA_BUG], [1],
4816 [Define to 1 if libotf is affected by https://debbugs.gnu.org/28110.])
4817         fi
4818       fi
4819     fi
4820   dnl FIXME should there be an error if HAVE_FREETYPE != yes?
4821   dnl Does the new font backend require it, or can it work without it?
4822   fi
4825 if test "${HAVE_BE_APP}" = "yes" && test "${HAVE_FREETYPE}" = "yes"; then
4826   if test "${with_harfbuzz}" != "no"; then
4827     EMACS_CHECK_MODULES([HARFBUZZ], [harfbuzz >= $harfbuzz_required_ver])
4828     if test "$HAVE_HARFBUZZ" = "yes"; then
4829       AC_DEFINE([HAVE_HARFBUZZ], [1], [Define to 1 if using HarfBuzz.])
4830     fi
4831   fi
4834 ### End of font-backend section.
4836 AC_SUBST([FREETYPE_CFLAGS])
4837 AC_SUBST([FREETYPE_LIBS])
4838 AC_SUBST([FONTCONFIG_CFLAGS])
4839 AC_SUBST([FONTCONFIG_LIBS])
4840 AC_SUBST([HARFBUZZ_CFLAGS])
4841 AC_SUBST([HARFBUZZ_LIBS])
4842 AC_SUBST([LIBOTF_CFLAGS])
4843 AC_SUBST([LIBOTF_LIBS])
4844 AC_SUBST([M17N_FLT_CFLAGS])
4845 AC_SUBST([M17N_FLT_LIBS])
4847 XCB_LIBS=
4848 if test "${HAVE_X11}" = "yes"; then
4849   AC_CHECK_HEADER([X11/Xlib-xcb.h],
4850     [AC_CHECK_LIB([xcb], [xcb_translate_coordinates], [HAVE_XCB=yes])])
4851   if test "${HAVE_XCB}" = "yes"; then
4852     AC_CHECK_LIB([X11-xcb], [XGetXCBConnection], [HAVE_X11_XCB=yes])
4853     if test "${HAVE_X11_XCB}" = "yes"; then
4854       AC_DEFINE([USE_XCB], [1],
4855 [Define to 1 if you have the XCB library and X11-XCB library for mixed
4856 X11/XCB programming.])
4857       XCB_LIBS="-lX11-xcb -lxcb"
4858     fi
4859   fi
4861 AC_SUBST([XCB_LIBS])
4863 ### Use -lXpm if available, unless '--with-xpm=no'.
4864 ### mingw32 doesn't use -lXpm, since it loads the library dynamically.
4865 ### The Cygwin-w32 build uses <noX/xpm.h> instead of <X11/xpm.h>, so
4866 ### we need to set LDFLAGS accordingly.
4867 HAVE_XPM=no
4868 LIBXPM=
4869 if test "${HAVE_W32}" = "yes" && test "${opsys}" = "cygwin"; then
4870   if test "${with_xpm}" != "no"; then
4871     SAVE_LDFLAGS="$LDFLAGS"
4872     LDFLAGS="$LDFLAGS -L/usr/lib/noX"
4873     AC_CHECK_HEADER([noX/xpm.h],
4874       [AC_CHECK_LIB([Xpm], [XpmReadFileToImage], [HAVE_XPM=yes])])
4875     if test "${HAVE_XPM}" = "yes"; then
4876       AC_CACHE_CHECK([for XpmReturnAllocPixels preprocessor define],
4877       [emacs_cv_cpp_xpm_return_alloc_pixels],
4878       [AC_EGREP_CPP([no_return_alloc_pixels],
4879       [#include "noX/xpm.h"
4880 #ifndef XpmReturnAllocPixels
4881 no_return_alloc_pixels
4882 #endif
4883       ], [emacs_cv_cpp_xpm_return_alloc_pixels=no],
4884          [emacs_cv_cpp_xpm_return_alloc_pixels=yes])])
4886       if test "$emacs_cv_cpp_xpm_return_alloc_pixels" = "no"; then
4887         HAVE_XPM=no
4888         LDFLAGS="$SAVE_LDFLAGS"
4889       fi
4890     fi
4891   fi
4893   if test "${HAVE_XPM}" = "yes"; then
4894     AC_DEFINE([HAVE_XPM], [1],
4895       [Define to 1 if you have the Xpm library (-lXpm).])
4896     LIBXPM=-lXpm
4897   fi
4900 if test "${HAVE_X11}" = "yes"; then
4901   dnl Avoid Xpm on AIX unless requested, as it crashes; see Bug#17598.
4902   case $opsys,$with_xpm_set,$with_xpm in
4903     aix4-2,set,yes) ;;
4904     aix4-2,*) with_xpm=no;;
4905   esac
4907   if test "${with_xpm}" != "no"; then
4908     AC_CHECK_HEADER([X11/xpm.h],
4909       [AC_CHECK_LIB([Xpm], [XpmReadFileToPixmap],
4910          [HAVE_XPM=yes], [], [-lX11])])
4911     if test "${HAVE_XPM}" = "yes"; then
4912       AC_CACHE_CHECK([for XpmReturnAllocPixels preprocessor define],
4913       [emacs_cv_cpp_xpm_return_alloc_pixels],
4914       [AC_EGREP_CPP([no_return_alloc_pixels],
4915       [#include "X11/xpm.h"
4916 #ifndef XpmReturnAllocPixels
4917 no_return_alloc_pixels
4918 #endif
4919       ], [emacs_cv_cpp_xpm_return_alloc_pixels=no],
4920          [emacs_cv_cpp_xpm_return_alloc_pixels=yes])])
4922       if test "$emacs_cv_cpp_xpm_return_alloc_pixels" = "no"; then
4923         HAVE_XPM=no
4924       fi
4925     fi
4926   fi
4928   if test "${HAVE_XPM}" = "yes"; then
4929     AC_DEFINE([HAVE_XPM], [1],
4930       [Define to 1 if you have the Xpm library (-lXpm).])
4931     LIBXPM=-lXpm
4932   elif test "$opsys,$LUCID_LIBW" = aix4-2,-lXaw; then
4933     dnl AIX -lXaw needs -lXpm linked too; see Bug#17598 Message#152.
4934     LIBXPM=-lXpm
4935   fi
4938 ### FIXME: Perhaps regroup to minimize code duplication due to MinGW's
4939 ### slightly different requirements wrt image libraries (it doesn't
4940 ### use -lXpm because it loads the xpm shared library dynamically at
4941 ### run time).
4942 if test "${opsys}" = "mingw32"; then
4943   if test "${with_xpm}" != "no"; then
4944     AC_CHECK_HEADER([X11/xpm.h], [HAVE_XPM=yes], [HAVE_XPM=no], [
4945 #define FOR_MSW 1])
4946   fi
4948   if test "${HAVE_XPM}" = "yes"; then
4949     AC_DEFINE([HAVE_XPM], [1],
4950       [Define to 1 if you have the Xpm library (-lXpm).])
4951   fi
4954 AC_SUBST([LIBXPM])
4956 ### Use -ljpeg if available, unless '--with-jpeg=no'.
4957 HAVE_JPEG=no
4958 LIBJPEG=
4959 JPEG_CFLAGS=
4960 if test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes" \
4961    || test "${HAVE_NS}" = "yes" || test "${HAVE_BE_APP}" = "yes" \
4962    || test "$window_system" = "pgtk" \
4963    || test "${REALLY_ANDROID}" = "yes"; then
4964   if test "${with_jpeg}" != "no"; then
4965     if test "${REALLY_ANDROID}" = "yes"; then
4966       # Look for libjpeg using the NDK.
4967       ndk_SEARCH_MODULE([libjpeg], [JPEG], [HAVE_JPEG=yes])
4969       if test "$HAVE_JPEG" = "yes"; then
4970         LIBJPEG="$JPEG_LIBS"
4972         AC_DEFINE([HAVE_JPEG], [1],
4973           [Define to 1 if you have the jpeg library (typically -ljpeg).])
4974       fi
4975     else
4976       AC_CACHE_CHECK([for jpeglib 6b or later],
4977         [emacs_cv_jpeglib],
4978         [OLD_LIBS=$LIBS
4979          for emacs_cv_jpeglib in yes -ljpeg no; do
4980            case $emacs_cv_jpeglib in
4981              yes) ;;
4982              no) break;;
4983              *) LIBS="$LIBS $emacs_cv_jpeglib";;
4984            esac
4985            AC_LINK_IFELSE(
4986              [AC_LANG_PROGRAM(
4987                 [[#undef HAVE_STDLIB_H /* Avoid config.h/jpeglib.h collision.  */
4988                   #include <stdio.h> /* jpeglib.h needs FILE and size_t.  */
4989                   #include <jpeglib.h>
4990                   #include <jerror.h>
4991                   char verify[JPEG_LIB_VERSION < 62 ? -1 : 1];
4992                   struct jpeg_decompress_struct cinfo;
4993                 ]],
4994                 [[
4995                   jpeg_create_decompress (&cinfo);
4996                   WARNMS (&cinfo, JWRN_JPEG_EOF);
4997                   jpeg_destroy_decompress (&cinfo);
4998                 ]])],
4999              [emacs_link_ok=yes],
5000              [emacs_link_ok=no])
5001            LIBS=$OLD_LIBS
5002            test $emacs_link_ok = yes && break
5003          done])
5004       if test "$emacs_cv_jpeglib" != no; then
5005         HAVE_JPEG=yes
5006         AC_DEFINE([HAVE_JPEG], [1],
5007           [Define to 1 if you have the jpeg library (typically -ljpeg).])
5008         ### mingw32 doesn't use -ljpeg, since it loads the library
5009         ### dynamically when needed, and doesn't want a run-time
5010         ### dependency on the jpeglib DLL.
5011         test "$emacs_cv_jpeglib" != yes && test "${opsys}" != "mingw32" \
5012         && LIBJPEG=$emacs_cv_jpeglib
5013       fi
5014     fi
5015   fi
5017 AC_SUBST([LIBJPEG])
5018 AC_SUBST([JPEG_CFLAGS])
5020 HAVE_LCMS2=no
5021 LCMS2_CFLAGS=
5022 LCMS2_LIBS=
5023 if test "${with_lcms2}" != "no"; then
5024   EMACS_CHECK_MODULES([LCMS2], [lcms2])
5026 if test "${HAVE_LCMS2}" = "yes"; then
5027   AC_DEFINE([HAVE_LCMS2], [1],
5028     [Define to 1 if you have the lcms2 library (-llcms2).])
5029   ### mingw32 doesn't use -llcms2, since it loads the library dynamically.
5030   if test "${opsys}" = "mingw32"; then
5031      LCMS2_LIBS=
5032   fi
5034 AC_SUBST([LCMS2_CFLAGS])
5035 AC_SUBST([LCMS2_LIBS])
5037 HAVE_ZLIB=no
5038 LIBZ=
5039 if test "${with_zlib}" != "no"; then
5040   OLIBS=$LIBS
5041   AC_SEARCH_LIBS([inflateEnd], [z], [HAVE_ZLIB=yes])
5042   LIBS=$OLIBS
5043   case $ac_cv_search_inflateEnd in
5044     -*) LIBZ=$ac_cv_search_inflateEnd ;;
5045   esac
5047 if test "${HAVE_ZLIB}" = "yes"; then
5048   AC_DEFINE([HAVE_ZLIB], [1],
5049     [Define to 1 if you have the zlib library (-lz).])
5050   ### mingw32 doesn't use -lz, since it loads the library dynamically.
5051   if test "${opsys}" = "mingw32"; then
5052      LIBZ=
5053   fi
5055 AC_SUBST([LIBZ])
5057 ### Dynamic library support
5058 case $opsys in
5059   cygwin|mingw32) DYNAMIC_LIB_SUFFIX=".dll" ;;
5060   darwin) DYNAMIC_LIB_SUFFIX=".dylib" ;;
5061   *) DYNAMIC_LIB_SUFFIX=".so" ;;
5062 esac
5063 case "${opsys}" in
5064   darwin) DYNAMIC_LIB_SECONDARY_SUFFIX='.so' ;;
5065   *) DYNAMIC_LIB_SECONDARY_SUFFIX='' ;;
5066 esac
5067 AC_DEFINE_UNQUOTED(DYNAMIC_LIB_SUFFIX, "$DYNAMIC_LIB_SUFFIX",
5068   [System extension for dynamic libraries])
5069 AC_DEFINE_UNQUOTED(DYNAMIC_LIB_SECONDARY_SUFFIX, "$DYNAMIC_LIB_SECONDARY_SUFFIX",
5070   [Alternative system extension for dynamic libraries.])
5072 AC_SUBST(DYNAMIC_LIB_SUFFIX)
5073 AC_SUBST(DYNAMIC_LIB_SECONDARY_SUFFIX)
5075 ### Dynamic modules support
5076 LIBMODULES=
5077 HAVE_MODULES=no
5078 MODULES_OBJ=
5079 MODULES_SUFFIX="${DYNAMIC_LIB_SUFFIX}"
5080 MODULES_SECONDARY_SUFFIX="${DYNAMIC_LIB_SECONDARY_SUFFIX}"
5082 # pgtkterm.c uses dlsym
5083 if test $window_system = pgtk; then
5084   case $opsys in
5085     gnu|gnu-linux)
5086     LIBMODULES="-ldl"
5087     ;;
5088   esac
5091 AS_IF([test "x$with_modules" != "xno"],
5092   [AS_CASE(["$opsys"],
5093     [gnu|gnu-linux],
5094       [LIBMODULES="-ldl"
5095        HAVE_MODULES=yes],
5096     [cygwin|mingw32|darwin],
5097       [HAVE_MODULES=yes],
5098     # BSD systems have dlopen in libc.
5099     [AC_CHECK_FUNC([dlopen], [HAVE_MODULES=yes])])
5101   AS_IF([test "x$HAVE_MODULES" = "xno"],
5102     [AS_IF([test "$with_modules" = "ifavailable"],
5103       [AC_MSG_WARN([Dynamic modules are not supported on your system])],
5104       [AC_MSG_ERROR([Dynamic modules are not supported on your system])])],
5105     [SAVE_LIBS=$LIBS
5106      LIBS="$LIBS $LIBMODULES"
5107      AC_CHECK_FUNCS([dladdr dlfunc])
5108      LIBS=$SAVE_LIBS])])
5110 AS_IF([test "x$HAVE_MODULES" = xyes],
5111    [MODULES_OBJ="emacs-module.o"
5112     NEED_DYNLIB=yes
5113     AC_DEFINE([HAVE_MODULES], [1], [Define to 1 if dynamic modules are enabled])
5114     AC_DEFINE_UNQUOTED([MODULES_SUFFIX], ["$MODULES_SUFFIX"],
5115       [System extension for dynamic libraries])
5116     AS_IF([test -n "$MODULES_SECONDARY_SUFFIX"],
5117       [AC_DEFINE_UNQUOTED([MODULES_SECONDARY_SUFFIX],
5118         ["$MODULES_SECONDARY_SUFFIX"],
5119         [Alternative system extension for dynamic libraries.])])])
5121 AC_SUBST([MODULES_OBJ])
5122 AC_SUBST([LIBMODULES])
5123 AC_SUBST([HAVE_MODULES])
5124 AC_SUBST([MODULES_SUFFIX])
5125 AC_SUBST([MODULES_SECONDARY_SUFFIX])
5127 ARCH_INDEPENDENT_CONFIG_FILES([src/emacs-module.h])
5128 AC_SUBST_FILE([module_env_snippet_25])
5129 AC_SUBST_FILE([module_env_snippet_26])
5130 AC_SUBST_FILE([module_env_snippet_27])
5131 AC_SUBST_FILE([module_env_snippet_28])
5132 AC_SUBST_FILE([module_env_snippet_29])
5133 AC_SUBST_FILE([module_env_snippet_30])
5134 AC_SUBST_FILE([module_env_snippet_31])
5135 module_env_snippet_25="$srcdir/src/module-env-25.h"
5136 module_env_snippet_26="$srcdir/src/module-env-26.h"
5137 module_env_snippet_27="$srcdir/src/module-env-27.h"
5138 module_env_snippet_28="$srcdir/src/module-env-28.h"
5139 module_env_snippet_29="$srcdir/src/module-env-29.h"
5140 module_env_snippet_30="$srcdir/src/module-env-30.h"
5141 module_env_snippet_31="$srcdir/src/module-env-31.h"
5142 emacs_major_version=`AS_ECHO([$PACKAGE_VERSION]) | sed 's/[[.]].*//'`
5143 AC_SUBST([emacs_major_version])
5145 ### Emacs Lisp native compiler support
5147 AC_DEFUN([libgccjit_smoke_test], [
5148   AC_LANG_SOURCE(
5149     [[#include <libgccjit.h>
5150       #include <stdlib.h>
5151       #include <stdio.h>
5152       int
5153       main (int argc, char **argv)
5154       {
5155         gcc_jit_context *ctxt;
5156         gcc_jit_result *result;
5157         ctxt = gcc_jit_context_acquire ();
5158         if (!ctxt)
5159           exit (1);
5160         gcc_jit_type *int_type =
5161           gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
5162         gcc_jit_function *func =
5163           gcc_jit_context_new_function (ctxt, NULL,
5164                                         GCC_JIT_FUNCTION_EXPORTED,
5165                                         int_type, "foo", 0, NULL, 0);
5166         gcc_jit_block *block = gcc_jit_function_new_block (func, "foo");
5167         gcc_jit_block_end_with_return (
5168           block,
5169           NULL,
5170           gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 1));
5171         result = gcc_jit_context_compile (ctxt);
5172         if (!result)
5173           exit (1);
5174         typedef int (*fn_type) (void);
5175         fn_type foo =
5176           (fn_type)gcc_jit_result_get_code (result, "foo");
5177         if (!foo)
5178           exit (1);
5179         if (foo () != 1)
5180           exit (1);
5181         gcc_jit_context_release (ctxt);
5182         gcc_jit_result_release (result);
5183         return 0;
5184       }]])])
5186 AC_DEFUN([libgccjit_not_found_err], [
5187   AC_MSG_ERROR([ELisp native compiler was requested, but libgccjit was not found.
5188 Please try installing libgccjit or a similar package.
5189 If you are sure you want Emacs be compiled without ELisp native compiler,
5190 pass the --without-native-compilation option to configure.])])
5192 AC_DEFUN([libgccjit_dev_not_found_err], [
5193   AC_MSG_ERROR([ELisp native compiler was requested, but libgccjit header files were
5194 not found.
5195 Please try installing libgccjit-dev or a similar package.
5196 If you are sure you want Emacs be compiled without ELisp native compiler,
5197 pass the --without-native-compilation option to configure.])])
5199 AC_DEFUN([libgccjit_broken_err], [
5200   AC_MSG_ERROR([The installed libgccjit failed to compile and run a test program using
5201 the libgccjit library; see config.log for the details of the failure.
5202 The test program can be found here:
5203 <https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html>.
5204 You can try compiling it yourself to investigate the issues.
5205 Please report the issue to your distribution if libgccjit was installed
5206 through that.
5207 You can find the instructions on how to compile and install libgccjit from
5208 source on this site:
5209 <https://gcc.gnu.org/wiki/JIT>.])])
5211 HAVE_NATIVE_COMP=no
5212 LIBGCCJIT_LIBS=
5213 LIBGCCJIT_CFLAGS=
5214 if test "$canonical" = i686-pc-cygwin; then
5215   if test "${with_cygwin32_native_compilation}" = yes; then
5216     with_native_compilation=yes
5217   elif test "${with_native_compilation}" != no; then
5218     AC_MSG_ERROR([Native compilation is not supported on 32-bit Cygwin.
5219 If you really want to try it anyway, use the configure option
5220 '--with-cygwin32-native-compilation'.])
5221   fi
5224 AC_DEFUN([libgccjit_not_found], [
5225   AC_MSG_WARN([Elisp native compiler can't be enabled as libgccjit was not
5226 found.
5227 Please try installing libgccjit or a similar package if you want to have it
5228 enabled.])
5230   with_native_compilation=no
5233 AC_DEFUN([libgccjit_dev_not_found], [
5234   AC_MSG_WARN([Elisp native compiler can't be enabled as libgccjit header files
5235 were not found.
5236 Please try installing libgccjit-dev or a similar package if you want to have it
5237 enabled.])
5239   with_native_compilation=no
5242 AC_DEFUN([libgccjit_broken], [
5243   AC_MSG_WARN([Elisp native compiler can't be enabled as the installed libgccjit
5244 failed to compile and run a test program using the libgccjit library; see
5245 config.log for the details of the failure.
5246 The test program can be found here:
5247 <https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html>.
5248 You can try compiling it yourself to investigate the issues.
5249 Please report the issue to your distribution if libgccjit was installed
5250 through that.
5251 You can find the instructions on how to compile and install libgccjit from
5252 source on this site:
5253 <https://gcc.gnu.org/wiki/JIT>.])
5255   with_native_compilation=no])
5257 if test "$with_features" = "no" \
5258    && test "${with_native_compilation}" = "default"; then
5259   with_native_compilation=no
5262 if test "${with_native_compilation}" = "default"; then
5263     # Check if libgccjit is available.
5264     AC_CHECK_LIB([gccjit], [gcc_jit_context_acquire],
5265       [], [libgccjit_not_found])
5266     AC_CHECK_HEADERS([libgccjit.h], [], [libgccjit_dev_not_found])
5267     if test "${with_native_compilation}" != "no"; then
5268       # Check if libgccjit really works.
5269       AC_RUN_IFELSE([libgccjit_smoke_test], [], [libgccjit_broken])
5270     fi
5271     if test "$with_unexec" = yes; then
5272       with_native_compilation=no
5273     fi
5276 if test "${with_native_compilation}" != "no"; then
5277     if test "$with_unexec" = yes; then
5278        AC_MSG_ERROR(['--with-native-compilation' is not compatible with unexec])
5279     fi
5280     if test "${HAVE_ZLIB}" = no; then
5281        AC_MSG_ERROR(['--with-native-compilation' requires zlib])
5282     fi
5284     SAVE_CFLAGS=$CFLAGS
5285     SAVE_LIBS=$LIBS
5287     if test "${opsys}" = "darwin"; then
5288       # Ensure libgccjit installed by Homebrew or macports can be found.
5289       if test -n "$BREW"; then
5290         if test -n "`$BREW --prefix --installed libgccjit 2>/dev/null`"; then
5291           MAC_CFLAGS="-I$(dirname $($BREW ls -v libgccjit | \
5292                                                 grep libgccjit.h))"
5293           MAC_LIBS="-L$(dirname $($BREW ls -v libgccjit \
5294                                   | grep -m1 -E 'libgccjit\.(so|dylib)$'))"
5295         fi
5296       fi
5298       if test -n "$HAVE_MACPORTS"; then
5299         # Determine which gcc version has been installed (gcc11, for
5300         # instance). Use the latest version, if more than one is
5301         # available.  (We filter out the gcc4 packages, because they
5302         # don't support jit, and they have names like "gcc49" that
5303         # sort later than "gcc11".)
5304         PORT_PACKAGE=`port installed active | grep '^ *gcc@<:@0-9@:>@* ' | \
5305                             awk '{ print $1; }' | grep -v 'gcc4@<:@0-9@:>@' | \
5306                             sort -V | tail -n 1`
5307         if test -n "$PORT_PACKAGE"; then
5308           emacs_val=`port contents $PORT_PACKAGE | grep libgccjit.h`
5309           emacs_val=`dirname $emacs_val`
5310           MAC_CFLAGS="-I$emacs_val"
5311           emacs_val=`port contents $PORT_PACKAGE | grep libgccjit.dylib`
5312           emacs_val=`dirname $emacs_val`
5313           MAC_LIBS="-L$emacs_val"
5314         fi
5315       fi
5317       if test -n "$MAC_CFLAGS" && test -n "$MAC_LIBS"; then
5318         CFLAGS="$CFLAGS ${MAC_CFLAGS}"
5319         LIBS="$LIBS ${MAC_LIBS}"
5320       fi
5321     fi
5323     # In the default case we already checked
5324     if test "${with_native_compilation}" != "default"; then
5325       # Check if libgccjit is available.
5326       AC_CHECK_LIB([gccjit], [gcc_jit_context_acquire],
5327         [], [libgccjit_not_found_err])
5328       AC_CHECK_HEADERS([libgccjit.h], [], [libgccjit_dev_not_found_err])
5329       # Check if libgccjit really works.
5330       AC_RUN_IFELSE([libgccjit_smoke_test], [], [libgccjit_broken_err])
5331     fi
5332     HAVE_NATIVE_COMP=yes
5333     case "${opsys}" in
5334       # mingw32 loads the library dynamically.
5335       mingw32) ;;
5336       # Neither NetBSD, OpenBSD nor Haiku have libdl, with all dynamic
5337       # linker functions placed within libc.
5338       netbsd|openbsd|haiku)
5339         LIBGCCJIT_LIBS="-lgccjit" ;;
5340       darwin)
5341         LIBGCCJIT_CFLAGS="${MAC_CFLAGS}"
5342         LIBGCCJIT_LIBS="${MAC_LIBS} -lgccjit -ldl";;
5343       *)
5344         LIBGCCJIT_LIBS="-lgccjit -ldl" ;;
5345     esac
5346     NEED_DYNLIB=yes
5347     AC_DEFINE([HAVE_NATIVE_COMP], [1],
5348       [Define to 1 if native compiler is available.])
5350     CFLAGS=$SAVE_CFLAGS
5351     LIBS=$SAVE_LIBS
5353 AC_DEFINE_UNQUOTED([NATIVE_ELISP_SUFFIX], [".eln"],
5354   [System extension for native compiled elisp])
5355 AC_SUBST([HAVE_NATIVE_COMP])
5356 AC_SUBST([LIBGCCJIT_CFLAGS])
5357 AC_SUBST([LIBGCCJIT_LIBS])
5359 DYNLIB_OBJ=
5360 if test "${NEED_DYNLIB}" = yes; then
5361   DYNLIB_OBJ="dynlib.o"
5363 AC_SUBST([DYNLIB_OBJ])
5365 ### Use -lpng if available, unless '--with-png=no'.
5366 HAVE_PNG=no
5367 LIBPNG=
5368 PNG_CFLAGS=
5369 if test "${with_png}" != no; then
5370   # mingw32 loads the library dynamically.
5371   if test "$opsys" = mingw32; then
5372     AC_CHECK_HEADER([png.h], [HAVE_PNG=yes])
5373   elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes" \
5374        || test "${HAVE_NS}" = "yes" || test "${HAVE_BE_APP}" = "yes" \
5375        || test "$window_system" = "pgtk" \
5376        || test "${REALLY_ANDROID}" = "yes"; then
5377     EMACS_CHECK_MODULES([PNG], [libpng >= 1.0.0])
5378     if test $HAVE_PNG = yes; then
5379       LIBPNG=$PNG_LIBS
5380     else
5381       # Test old way in case pkg-config doesn't have it (older machines).
5382       AC_MSG_CHECKING([for libpng not configured by pkg-config])
5384       png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` &&
5385       png_ldflags=`(libpng-config --ldflags) 2>&AS_MESSAGE_LOG_FD` || {
5386         # libpng-config does not work; configure by hand.
5387         # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
5388         # in /usr/include/libpng.
5389         if test -r /usr/include/libpng/png.h &&
5390            test ! -r /usr/include/png.h; then
5391           png_cflags=-I/usr/include/libpng
5392         else
5393           png_cflags=
5394         fi
5395         png_ldflags='-lpng'
5396       }
5397       SAVE_CFLAGS=$CFLAGS
5398       SAVE_LIBS=$LIBS
5399       CFLAGS="$CFLAGS $png_cflags"
5400       LIBS="$png_ldflags -lz -lm $LIBS"
5401       AC_LINK_IFELSE(
5402         [AC_LANG_PROGRAM([[#include <png.h>]],
5403            [[return !png_get_channels (0, 0);]])],
5404         [HAVE_PNG=yes
5405          PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"`
5406          LIBPNG=$png_ldflags])
5407       CFLAGS=$SAVE_CFLAGS
5408       LIBS=$SAVE_LIBS
5409       AC_MSG_RESULT([$HAVE_PNG])
5410     fi
5412     # $LIBPNG requires explicit -lz in some cases.
5413     # We don't know what those cases are, exactly, so play it safe and
5414     # append -lz to any nonempty $LIBPNG, unless we're already using LIBZ.
5415     case " $LIBPNG ",$LIBZ in
5416       *' -lz '*, | *' ',?*) ;;
5417       *) LIBPNG="$LIBPNG -lz" ;;
5418     esac
5419   fi
5421 if test $HAVE_PNG = yes; then
5422   AC_DEFINE([HAVE_PNG], [1], [Define to 1 if you have the png library.])
5424   SAVE_CFLAGS=$CFLAGS
5425   CFLAGS="$CFLAGS $PNG_CFLAGS"
5426   AC_CHECK_DECL([png_longjmp],
5427     [],
5428     [AC_DEFINE([PNG_DEPSTRUCT], [],
5429        [Define to empty to suppress deprecation warnings when building
5430         with --enable-gcc-warnings and with libpng versions before 1.5,
5431         which lack png_longjmp.])],
5432     [[#include <png.h>
5433     ]])
5434   CFLAGS=$SAVE_CFLAGS
5436 AC_SUBST([LIBPNG])
5437 AC_SUBST([PNG_CFLAGS])
5439 ### Use -ltiff if available, unless '--with-tiff=no'.
5440 ### mingw32 doesn't use -ltiff, since it loads the library dynamically.
5441 HAVE_TIFF=no
5442 LIBTIFF=
5443 TIFF_CFLAGS=
5444 if test "${opsys}" = "mingw32"; then
5445   if test "${with_tiff}" != "no"; then
5446     AC_CHECK_HEADER([tiffio.h], [HAVE_TIFF=yes], [HAVE_TIFF=no])
5447   fi
5448   if test "${HAVE_TIFF}" = "yes"; then
5449     AC_DEFINE([HAVE_TIFF], [1],
5450       [Define to 1 if you have the tiff library (-ltiff).])
5451   fi
5452 elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes" \
5453      || test "${HAVE_NS}" = "yes" || test "${HAVE_BE_APP}" = "yes" \
5454      || test "$window_system" = "pgtk" \
5455      || test "${REALLY_ANDROID}" = "yes"; then
5456   if test "${with_tiff}" != "no"; then
5457     if test "${REALLY_ANDROID}" != "yes"; then
5458       AC_CHECK_HEADER([tiffio.h],
5459         [tifflibs="-lz -lm"
5460         # At least one tiff package requires the jpeg library.
5461         if test "${HAVE_JPEG}" = yes; then tifflibs="-ljpeg $tifflibs"; fi
5462         AC_CHECK_LIB([tiff], [TIFFGetVersion], [HAVE_TIFF=yes], [],
5463           [$tifflibs])])
5464     else
5465       ndk_SEARCH_MODULE([libtiff], [TIFF], [HAVE_TIFF=yes])
5467       if test "$HAVE_TIFF" = "yes"; then
5468         LIBTIFF="$TIFF_LIBS"
5469       fi
5470     fi
5471   fi
5473   if test "${HAVE_TIFF}" = "yes"; then
5474     AC_DEFINE([HAVE_TIFF], [1],
5475       [Define to 1 if you have the tiff library (-ltiff).])
5477     if test "$REALLY_ANDROID" != "yes"; then
5478       dnl FIXME -lz -lm, as per libpng?
5479       LIBTIFF=-ltiff
5480     fi
5481   fi
5483 AC_SUBST([LIBTIFF])
5484 AC_SUBST([TIFF_CFLAGS])
5486 ### Use -lgif or -lungif if available, unless '--with-gif=no'.
5487 ### mingw32 doesn't use -lgif/-lungif, since it loads the library dynamically.
5488 HAVE_GIF=no
5489 GIF_CFLAGS=
5490 LIBGIF=
5491 if test "${opsys}" = "mingw32"; then
5492   if test "${with_gif}" != "no"; then
5493     AC_CHECK_HEADER([gif_lib.h], [HAVE_GIF=yes], [HAVE_GIF=no])
5494   fi
5495   if test "${HAVE_GIF}" = "yes"; then
5496     AC_DEFINE([HAVE_GIF], [1],
5497       [Define to 1 if you have a gif (or ungif) library.])
5498   fi
5499 elif test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no" \
5500         || test "${HAVE_W32}" = "yes" || test "${HAVE_NS}" = "yes" \
5501         || test "${HAVE_BE_APP}" = "yes" || test "$window_system" = "pgtk" \
5502         || test "${REALLY_ANDROID}" = "yes" \
5503         && test "${with_gif}" != "no"; then
5504   AC_CHECK_HEADER([gif_lib.h],
5505 # EGifPutExtensionLast only exists from version libungif-4.1.0b1.
5506 # Earlier versions can crash Emacs, but version 5.0 removes EGifPutExtensionLast.
5507     [AC_CHECK_LIB([gif], [GifMakeMapObject], [HAVE_GIF=yes],
5508         [AC_CHECK_LIB([gif], [EGifPutExtensionLast],
5509            [HAVE_GIF=yes],
5510            [HAVE_GIF=maybe])])])
5512   if test "$HAVE_GIF" = yes; then
5513     LIBGIF=-lgif
5514   elif test "$HAVE_GIF" = maybe; then
5515 # If gif_lib.h but no libgif, try libungif.
5516     AC_CHECK_LIB([ungif], [EGifPutExtensionLast],
5517       [HAVE_GIF=yes],
5518       [HAVE_GIF=no])
5519     test "$HAVE_GIF" = yes && LIBGIF=-lungif
5520   fi
5522 # Finally, try ndk-build on Android.
5523   if test "$REALLY_ANDROID" = "yes"; then
5524     ndk_SEARCH_MODULE([libgif], [GIF], [HAVE_GIF=yes],
5525       [HAVE_GIF=no])
5526     test "$HAVE_GIF" = yes && LIBGIF="$GIF_LIBS"
5527   fi
5529   if test "${HAVE_GIF}" = "yes"; then
5530     AC_DEFINE([HAVE_GIF], [1],
5531       [Define to 1 if you have a gif (or ungif) library.])
5532   fi
5534 AC_SUBST([LIBGIF])
5535 AC_SUBST([GIF_CFLAGS])
5537 dnl Check for required libraries.
5538 MISSING=
5539 WITH_IFAVAILABLE=
5540 if test "${HAVE_X11}" = "yes"; then
5541   case $with_xpm,$HAVE_XPM in
5542     no,* | ifavailable,* | *,yes) ;;
5543     *) MISSING="libXpm"
5544        WITH_IFAVAILABLE="--with-xpm=ifavailable";;
5545   esac
5546   case $with_jpeg,$HAVE_JPEG in
5547     no,* | ifavailable,* | *,yes) ;;
5548     *) MISSING="$MISSING libjpeg"
5549        WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-jpeg=ifavailable";;
5550   esac
5551   case $with_png,$HAVE_PNG in
5552     no,* | ifavailable,* | *,yes) ;;
5553     *) MISSING="$MISSING libpng"
5554        WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-png=ifavailable";;
5555   esac
5556   case $with_gif,$HAVE_GIF in
5557     no,* | ifavailable,* | *,yes) ;;
5558     *) MISSING="$MISSING libgif/libungif"
5559        WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-gif=ifavailable";;
5560   esac
5561   case $with_tiff,$HAVE_TIFF in
5562     no,* | ifavailable,* | *,yes) ;;
5563     *) MISSING="$MISSING libtiff"
5564        WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-tiff=ifavailable";;
5565   esac
5567 case $with_gnutls,$HAVE_GNUTLS in
5568   no,* | ifavailable,* | *,yes) ;;
5569   *) MISSING="$MISSING gnutls"
5570      WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-gnutls=ifavailable";;
5571 esac
5572 case $with_tree_sitter,$HAVE_TREE_SITTER in
5573   no,* | ifavailable,* | *,yes) ;;
5574   *) MISSING="$MISSING tree-sitter"
5575      WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-tree-sitter=ifavailable";;
5576 esac
5578 if test "X${MISSING}" != X; then
5579   # If we have a missing library, and we don't have pkg-config installed,
5580   # the missing pkg-config may be the reason.  Give the user a hint.
5581   if test "X${PKG_CONFIG}" = X; then
5582     AC_MSG_WARN([Unable to locate a usable pkg-config])
5583   fi
5584   AC_MSG_ERROR([The following required libraries were not found:
5585     $MISSING
5586 Maybe some development libraries/packages are missing?
5587 To build anyway, give:
5588     $WITH_IFAVAILABLE
5589 as options to configure.])
5592 ### Use -lgpm if available, unless '--with-gpm=no'.
5593 HAVE_GPM=no
5594 LIBGPM=
5595 if test "${with_gpm}" != "no"; then
5596   AC_CHECK_HEADER([gpm.h],
5597     [AC_CHECK_LIB([gpm], [Gpm_Open], [HAVE_GPM=yes])])
5599   if test "${HAVE_GPM}" = "yes"; then
5600     AC_DEFINE([HAVE_GPM], [1],
5601       [Define to 1 if you have the gpm library (-lgpm).])
5602     LIBGPM=-lgpm
5603   fi
5605 AC_SUBST([LIBGPM])
5607 dnl Check for malloc/malloc.h on darwin
5608 AC_CHECK_HEADERS_ONCE([malloc/malloc.h])
5610 GNUSTEP_CFLAGS=
5611 ### Use NeXTstep API to implement GUI.
5612 if test "${HAVE_NS}" = "yes"; then
5613   AC_DEFINE([HAVE_NS], [1],
5614     [Define to 1 if you are using the NeXTstep API,
5615      either GNUstep or Cocoa on macOS.])
5616   if test "${NS_IMPL_COCOA}" = "yes"; then
5617     AC_DEFINE([NS_IMPL_COCOA], [1],
5618       [Define to 1 if you are using NS windowing under macOS.])
5619   fi
5620   if test "${NS_IMPL_GNUSTEP}" = "yes"; then
5621     AC_DEFINE([NS_IMPL_GNUSTEP], [1],
5622       [Define to 1 if you are using NS windowing under GNUstep.])
5623     if test $NS_GNUSTEP_CONFIG != yes; then
5624       # See also .m.o rule in src/Makefile.in.  */
5625       # FIXME: are all these flags really needed?  Document here why.  */
5626       GNUSTEP_CFLAGS="-D_REENTRANT -fPIC -fno-strict-aliasing -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
5627       ## Extra CFLAGS applied to src/*.m files.
5628       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"
5629     fi
5630   fi
5631   OTHER_FILES=ns-app
5634 ### Use session management (-lSM -lICE) if available
5635 HAVE_X_SM=no
5636 LIBXSM=
5637 if test "${HAVE_X11}" = "yes"; then
5638   AC_CHECK_HEADER([X11/SM/SMlib.h],
5639     [AC_CHECK_LIB([SM], [SmcOpenConnection], [HAVE_X_SM=yes], [], [-lICE])])
5641   if test "${HAVE_X_SM}" = "yes"; then
5642     AC_DEFINE([HAVE_X_SM], [1],
5643       [Define to 1 if you have the SM library (-lSM).])
5644     LIBXSM="-lSM -lICE"
5645   fi
5647 AC_SUBST([LIBXSM])
5649 ### Use XRandr (-lXrandr) if available
5650 HAVE_XRANDR=no
5651 if test "${HAVE_X11}" = "yes"; then
5652   XRANDR_REQUIRED=1.2.2
5653   XRANDR_MODULES="xrandr >= $XRANDR_REQUIRED"
5654   EMACS_CHECK_MODULES([XRANDR], [$XRANDR_MODULES])
5655   if test $HAVE_XRANDR = no; then
5656     # Test old way in case pkg-config doesn't have it (older machines).
5657     # Include Xrender.h by hand to work around bug in older Xrandr.h
5658     # (e.g. RHEL5) and silence (harmless) configure warning (bug#18465).
5659     AC_CHECK_HEADER([X11/extensions/Xrandr.h],
5660       [AC_CHECK_LIB([Xrandr], [XRRGetScreenResources], [HAVE_XRANDR=yes])],
5661       [], [AC_INCLUDES_DEFAULT
5662 #include <X11/extensions/Xrender.h>])
5663     if test $HAVE_XRANDR = yes; then
5664       XRANDR_LIBS=-lXrandr
5665     fi
5666   fi
5667   if test $HAVE_XRANDR = yes; then
5668     AC_DEFINE([HAVE_XRANDR], [1],
5669       [Define to 1 if you have the XRandr extension.])
5670   fi
5672 AC_SUBST([XRANDR_CFLAGS])
5673 AC_SUBST([XRANDR_LIBS])
5675 ### Use Xinerama (-lXinerama) if available
5676 HAVE_XINERAMA=no
5677 if test "${HAVE_X11}" = "yes"; then
5678   XINERAMA_REQUIRED=1.0.2
5679   XINERAMA_MODULES="xinerama >= $XINERAMA_REQUIRED"
5680   EMACS_CHECK_MODULES([XINERAMA], [$XINERAMA_MODULES])
5681   if test $HAVE_XINERAMA = no; then
5682     # Test old way in case pkg-config doesn't have it (older machines).
5683     AC_CHECK_HEADER([X11/extensions/Xinerama.h],
5684       [AC_CHECK_LIB([Xinerama], [XineramaQueryExtension],
5685          [HAVE_XINERAMA=yes])])
5686     if test $HAVE_XINERAMA = yes; then
5687       XINERAMA_LIBS=-lXinerama
5688     fi
5689   fi
5690   if test $HAVE_XINERAMA = yes; then
5691     AC_DEFINE([HAVE_XINERAMA], [1],
5692       [Define to 1 if you have the Xinerama extension.])
5693   fi
5695 AC_SUBST([XINERAMA_CFLAGS])
5696 AC_SUBST([XINERAMA_LIBS])
5698 ### Use Xfixes (-lXfixes) if available
5699 HAVE_XFIXES=no
5700 if test "${HAVE_X11}" = "yes"; then
5701   XFIXES_REQUIRED=1.0.0
5702   XFIXES_MODULES="xfixes >= $XFIXES_REQUIRED"
5703   EMACS_CHECK_MODULES([XFIXES], [$XFIXES_MODULES])
5704   if test $HAVE_XFIXES = no; then
5705     # Test old way in case pkg-config doesn't have it (older machines).
5706     AC_CHECK_HEADER([X11/extensions/Xfixes.h],
5707       [AC_CHECK_LIB([Xfixes], [XFixesHideCursor], [HAVE_XFIXES=yes])])
5708     if test $HAVE_XFIXES = yes; then
5709       XFIXES_LIBS=-lXfixes
5710     fi
5711   fi
5712   if test $HAVE_XFIXES = yes; then
5713     AC_DEFINE([HAVE_XFIXES], [1],
5714       [Define to 1 if you have the Xfixes extension.])
5715   fi
5717 AC_SUBST([XFIXES_CFLAGS])
5718 AC_SUBST([XFIXES_LIBS])
5720 ## Use XInput 2.0 if available
5721 HAVE_XINPUT2=no
5722 if test "${HAVE_X11}" = "yes" && test "${with_xinput2}" != "no"; then
5723    EMACS_CHECK_MODULES([XINPUT], [xi])
5724    if test $HAVE_XINPUT = yes; then
5725      # Now check for XInput2.h
5726      AC_CHECK_HEADER([X11/extensions/XInput2.h],
5727        [AC_CHECK_LIB([Xi], [XIGrabButton], [HAVE_XINPUT2=yes])])
5728    fi
5729    if test $HAVE_XINPUT2 = yes; then
5730      AC_DEFINE([HAVE_XINPUT2], [1],
5731        [Define to 1 if the X Input Extension version 2.0 or later is present.])
5732      if test "$USE_GTK_TOOLKIT" = "GTK2"; then
5733        AC_MSG_WARN([You are building Emacs with GTK+ 2 and the X Input Extension version 2.
5734 This might lead to problems if your version of GTK+ is not built with support for XInput 2.])
5735      fi
5737      # Now check for some members (which used in conjunction with
5738      # protocol definitions) can be used to determine the version of
5739      # XInput supported.
5740      AC_CHECK_MEMBERS([XIScrollClassInfo.type, XITouchClassInfo.type,
5741        XIBarrierReleasePointerInfo.deviceid, XIGestureClassInfo.type],
5742        [], [], [#include <X11/extensions/XInput2.h>])
5743    fi
5745 AC_SUBST([XINPUT_CFLAGS])
5746 AC_SUBST([XINPUT_LIBS])
5748 XSYNC_LIBS=
5749 XSYNC_CFLAGS=
5750 HAVE_XSYNC=no
5751 if test "${HAVE_X11}" = "yes"; then
5752    AC_CHECK_HEADER([X11/extensions/sync.h],
5753      [AC_CHECK_LIB([Xext], [XSyncQueryExtension], [HAVE_XSYNC=yes])],
5754      [], [#include <X11/Xlib.h>])
5756   if test "${HAVE_XSYNC}" = "yes"; then
5757     AC_DEFINE([HAVE_XSYNC], [1],
5758       [Define to 1 if the X Synchronization Extension is available.])
5759     XSYNC_LIBS="-lXext"
5760     OLDLIBS="$LIBS"
5761     LIBS="-lXext $LIBS" # Set this temporarily for AC_CHECK_FUNC
5762     AC_CHECK_FUNCS([XSyncTriggerFence]) # Check for version 3.1
5763     LIBS="$OLDLIBS"
5764   fi
5766 AC_SUBST([XSYNC_LIBS])
5767 AC_SUBST([XSYNC_CFLAGS])
5769 ### Use Xdbe (-lXdbe) if available
5770 HAVE_XDBE=no
5771 if test "${HAVE_X11}" = "yes"; then
5772   if test "${with_xdbe}" != "no"; then
5773     AC_CHECK_HEADER([X11/extensions/Xdbe.h],
5774       [AC_CHECK_LIB([Xext], [XdbeAllocateBackBufferName], [HAVE_XDBE=yes])],
5775       [],
5776       [#include <X11/Xlib.h>
5777       ])
5778   fi
5779   if test $HAVE_XDBE = yes; then
5780     XDBE_LIBS=-lXext
5781   fi
5782   if test $HAVE_XDBE = yes; then
5783     AC_DEFINE([HAVE_XDBE], [1], [Define to 1 if you have the Xdbe extension.])
5784   fi
5786 AC_SUBST([XDBE_CFLAGS])
5787 AC_SUBST([XDBE_LIBS])
5789 ### Use the Nonrectangular Window Shape extension if available.
5790 HAVE_XSHAPE=no
5791 HAVE_XCB_SHAPE=no
5792 if test "${HAVE_X11}" = "yes"; then
5793   AC_CHECK_HEADER([X11/extensions/shape.h],
5794     [AC_CHECK_LIB([Xext], [XShapeQueryVersion], [HAVE_XSHAPE=yes])],
5795     [],
5796     [#include <X11/extensions/shape.h>
5797     ])
5798   if test $HAVE_XSHAPE = yes; then
5799     XSHAPE_LIBS=-lXext
5800     AC_CHECK_HEADER([xcb/shape.h],
5801       [AC_CHECK_LIB([xcb-shape], [xcb_shape_combine], [HAVE_XCB_SHAPE=yes])],
5802       [],
5803       [#include <xcb/shape.h>])
5805     if test $HAVE_XCB_SHAPE = yes && test "$XCB_LIBS" != ""; then
5806       XSHAPE_LIBS="$XSHAPE_LIBS -lxcb-shape"
5807       AC_DEFINE([HAVE_XCB_SHAPE], [1],
5808         [Define to 1 if XCB supports the
5809          Nonrectangular Window Shape extension.])
5810     fi
5811   fi
5812   if test $HAVE_XSHAPE = yes; then
5813     AC_DEFINE([HAVE_XSHAPE], [1],
5814       [Define to 1 if you have the Nonrectangular Window Shape extension.])
5815   fi
5817 AC_SUBST([XSHAPE_CFLAGS])
5818 AC_SUBST([XSHAPE_LIBS])
5820 ### Use Xcomposite (-lXcomposite) if available
5821 HAVE_XCOMPOSITE=no
5822 if test "${HAVE_X11}" = "yes"; then
5823   AC_CHECK_HEADER([X11/extensions/Xcomposite.h],
5824     [AC_CHECK_LIB([Xcomposite], [XCompositeRedirectWindow],
5825        [HAVE_XCOMPOSITE=yes])],
5826     [],
5827     [#include <X11/extensions/Xcomposite.h>
5828     ])
5829   if test $HAVE_XCOMPOSITE = yes; then
5830     XCOMPOSITE_LIBS=-lXcomposite
5831   fi
5832   if test $HAVE_XCOMPOSITE = yes; then
5833     AC_DEFINE([HAVE_XCOMPOSITE], [1],
5834       [Define to 1 if you have the XCOMPOSITE extension.])
5835   fi
5837 AC_SUBST([XCOMPOSITE_CFLAGS])
5838 AC_SUBST([XCOMPOSITE_LIBS])
5840 ### Use libxml (-lxml2) if available
5841 ### mingw32 doesn't use -lxml2, since it loads the library dynamically.
5842 HAVE_LIBXML2=no
5843 if test "${with_xml2}" != "no"; then
5844   ### I'm not sure what the version number should be, so I just guessed.
5845   EMACS_CHECK_MODULES([LIBXML2], [libxml-2.0 > 2.6.17])
5846   # Built-in libxml2 on OS X 10.8 lacks libxml-2.0.pc.
5847   if test "${HAVE_LIBXML2}" != "yes" && test "$opsys" = "darwin"; then
5848     SAVE_CPPFLAGS="$CPPFLAGS"
5849     if test -z "$xcsdkdir" -a -n "$XCRUN" -a ! -d /usr/include; then
5850       dnl /usr/include is not found.  Try Xcode SDK dir if it is sane.
5851       xcsdkdir=`$XCRUN --show-sdk-path 2>/dev/null`
5852       case $xcsdkdir in
5853         *[[\\\"\#\$\&\'\`$am_lf\ \      ]]*)
5854         xcsdkdir="" ;;
5855       esac
5856     fi
5857     CPPFLAGS="$CPPFLAGS -isystem${xcsdkdir}/usr/include/libxml2"
5858     AC_CHECK_HEADER([libxml/HTMLparser.h],
5859       [AC_CHECK_DECL([HTML_PARSE_RECOVER], [HAVE_LIBXML2=yes], [],
5860                      [#include <libxml/HTMLparser.h>])])
5861     CPPFLAGS="$SAVE_CPPFLAGS"
5862     if test "${HAVE_LIBXML2}" = "yes"; then
5863       LIBXML2_CFLAGS="-isystem${xcsdkdir}/usr/include/libxml2"
5864       LIBXML2_LIBS="-lxml2"
5865     fi
5866   fi
5867   if test "${HAVE_LIBXML2}" = "yes"; then
5868     if test "${opsys}" != "mingw32"; then
5869       SAVE_CFLAGS=$CFLAGS
5870       CFLAGS="$CFLAGS $LIBXML2_CFLAGS"
5871       EMACS_CHECK_LIB([xml2], [htmlReadMemory],
5872         [HAVE_LIBXML2=yes],
5873         [HAVE_LIBXML2=no],
5874         [$LIBXML2_LIBS], [#include <libxml/HTMLparser.h>])
5875       CFLAGS="$SAVE_CFLAGS"
5876     else
5877       LIBXML2_LIBS=""
5878     fi
5879     if test "${HAVE_LIBXML2}" = "yes"; then
5880       AC_DEFINE([HAVE_LIBXML2], [1],
5881         [Define to 1 if you have the libxml library (-lxml2).])
5882     else
5883       LIBXML2_LIBS=""
5884       LIBXML2_CFLAGS=""
5885     fi
5886   fi
5888 AC_SUBST([LIBXML2_LIBS])
5889 AC_SUBST([LIBXML2_CFLAGS])
5891 BLESSMAIL_TARGET=
5892 LIBS_MAIL=
5893 if test ! "$with_mailutils"; then
5894   # Check for mail-locking functions in a "mail" library.  Probably this should
5895   # have the same check as for liblockfile below.
5896   AC_CHECK_LIB([mail], [maillock], [have_mail=yes], [have_mail=no])
5897   if test $have_mail = yes; then
5898     LIBS_MAIL=-lmail
5899     AC_DEFINE([HAVE_LIBMAIL], [1],
5900       [Define to 1 if you have the 'mail' library (-lmail).])
5902     OLD_LIBS=$LIBS
5903     LIBS="$LIBS_MAIL $LIBS"
5904     AC_CHECK_FUNCS([touchlock])
5905     LIBS=$OLD_LIBS
5906   fi
5907   dnl Debian, at least:
5908   AC_CHECK_LIB([lockfile], [maillock], [have_lockfile=yes], [have_lockfile=no])
5909   if test $have_lockfile = yes; then
5910      LIBS_MAIL=-llockfile
5911      AC_DEFINE([HAVE_LIBLOCKFILE], [1],
5912        [Define to 1 if you have the 'lockfile' library (-llockfile).])
5913   else
5914     # If we have the shared liblockfile, assume we must use it for mail
5915     # locking (e.g. Debian).  If we couldn't link against liblockfile
5916     # (no liblockfile.a installed), ensure that we don't need to.
5917     dnl This works for files generally, not just executables.
5918     dnl Should we look elsewhere for it?  Maybe examine /etc/ld.so.conf?
5919     AC_CHECK_PROG([liblockfile], [liblockfile.so], [yes], [no],
5920                   [/usr/lib:/lib:/usr/local/lib:$LD_LIBRARY_PATH])
5921     if test "$ac_cv_prog_liblockfile" = yes; then
5922       AC_MSG_ERROR([Shared liblockfile found but can't link against it.
5923 This probably means that movemail could lose mail.
5924 There may be a 'development' package to install containing liblockfile.])
5925     fi
5926   fi
5927   AC_CHECK_HEADERS([maillock.h])
5929   ## Define MAIL_USE_FLOCK (or LOCKF) if the mailer uses flock (or lockf) to
5930   ## interlock access to the mail spool.  The alternative is a lock file named
5931   ## /usr/spool/mail/$USER.lock.
5932   mail_lock=no
5933   case $opsys in
5934     aix4-2) mail_lock="lockf" ;;
5936     gnu|freebsd|dragonfly|netbsd|openbsd|darwin) mail_lock="flock" ;;
5938     ## On GNU/Linux systems, both methods are used by various mail programs.
5939     ## I assume most people are using newer mailers that have heard of flock.
5940     ## Change this if you need to.
5941     ## Debian contains a patch which says: "On Debian/GNU/Linux systems,
5942     ## configure gets the right answers, and that means *NOT* using flock.
5943     ## Using flock is guaranteed to be the wrong thing. See Debian Policy
5944     ## for details." and then uses '#ifdef DEBIAN'.  Unfortunately the
5945     ## Debian maintainer hasn't provided a clean fix for Emacs.
5946     ## movemail.c will use 'maillock' when MAILDIR, HAVE_LIBMAIL and
5947     ## HAVE_MAILLOCK_H are defined, so the following appears to be the
5948     ## correct logic.  -- fx
5949     ## We must check for HAVE_LIBLOCKFILE too, as movemail does.
5950     ## liblockfile is a Free Software replacement for libmail, used on
5951     ## Debian systems and elsewhere. -rfr.
5952     gnu-*)
5953       mail_lock="flock"
5954       if test $have_mail = yes || test $have_lockfile = yes; then
5955         test $ac_cv_header_maillock_h = yes && mail_lock=no
5956       fi ;;
5958     mingw32)
5959       mail_lock="none-needed" ;;
5960   esac
5962   case $mail_lock in
5963     flock) AC_DEFINE([MAIL_USE_FLOCK], [1],
5964              [Define if the mailer uses flock to interlock the mail spool.]);;
5966     lockf) AC_DEFINE([MAIL_USE_LOCKF], [1],
5967              [Define if the mailer uses lockf to interlock the mail spool.]);;
5969     none-needed) ;;
5971     *) BLESSMAIL_TARGET="need-blessmail" ;;
5972   esac
5974 AC_SUBST([BLESSMAIL_TARGET])
5975 AC_SUBST([LIBS_MAIL])
5977 HAVE_SECCOMP=no
5978 AC_CHECK_HEADERS(
5979   [linux/seccomp.h linux/filter.h],
5980   [AC_CHECK_DECLS(
5981     [SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_TSYNC],
5982     [HAVE_SECCOMP=yes], [],
5983     [[
5984     #include <linux/seccomp.h>
5985     ]])])
5986 AC_SUBST([HAVE_SECCOMP])
5988 EMACS_CHECK_MODULES([LIBSECCOMP], [libseccomp >= 2.5.2])
5989 AC_SUBST([HAVE_LIBSECCOMP])
5990 AC_SUBST([LIBSECCOMP_LIBS])
5991 AC_SUBST([LIBSECCOMP_CFLAGS])
5993 AC_CHECK_SIZEOF([long])
5994 SIZEOF_LONG="$ac_cv_sizeof_long"
5995 AC_SUBST([SIZEOF_LONG])
5997 OLD_LIBS=$LIBS
5998 LIBS="$LIB_PTHREAD $LIB_MATH $LIBS"
5999 AC_CHECK_FUNCS([accept4 fchdir gethostname \
6000 getrusage get_current_dir_name \
6001 lrand48 random rint tcdrain trunc \
6002 select getpagesize newlocale \
6003 getrlimit setrlimit shutdown \
6004 pthread_sigmask strsignal setitimer \
6005 sendto recvfrom getsockname getifaddrs freeifaddrs \
6006 gai_strerror sync \
6007 endpwent getgrent endgrent \
6008 cfmakeraw cfsetspeed __executable_start log2 pthread_setname_np \
6009 pthread_set_name_np])
6011 # getpwent is not present in older versions of Android.  (bug#65319)
6012 gl_CHECK_FUNCS_ANDROID([getpwent], [[#include <pwd.h>]])
6014 # renameat2 is not present in older versions of Android.
6015 gl_CHECK_FUNCS_ANDROID([renameat2], [[#include <stdio.h>]])
6017 if test "$ac_cv_func_cfmakeraw" != "yes"; then
6018   # On some systems (Android), cfmakeraw is inline, so AC_CHECK_FUNCS
6019   # cannot find it.  Check if some code including termios.h and using
6020   # cfmakeraw builds.
6021   AC_CACHE_CHECK([whether cfmakeraw is inline],
6022    [emacs_cv_func_cfmakeraw_inline],
6023    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
6024        [[#include <termios.h>]],
6025        [[&cfmakeraw;]])],
6026      [emacs_cv_func_cfmakeraw_inline=yes],
6027      [emacs_cv_func_cfmakeraw_inline=no])])
6029   if test "$emacs_cv_func_cfmakeraw_inline" = "yes"; then
6030      # Define HAVE_CFMAKERAW again.
6031      AC_DEFINE([HAVE_CFMAKERAW], [1])
6032   fi
6035 if test "$ac_cv_func_cfsetspeed" != "yes"; then
6036   AC_CACHE_CHECK([whether cfsetspeed is inline],
6037    [emacs_cv_func_cfsetspeed_inline],
6038    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
6039        [[#include <termios.h>]],
6040        [[&cfsetspeed;]])],
6041      [emacs_cv_func_cfsetspeed_inline=yes],
6042      [emacs_cv_func_cfsetspeed_inline=no])])
6044   if test "$emacs_cv_func_cfsetspeed_inline" = "yes"; then
6045      # Define HAVE_CFSETSPEED again.
6046      AC_DEFINE([HAVE_CFSETSPEED], [1])
6047   fi
6050 LIBS=$OLD_LIBS
6052 if test "$ac_cv_func_pthread_setname_np" = "yes"; then
6053   AC_CACHE_CHECK(
6054    [whether pthread_setname_np takes a single argument],
6055    [emacs_cv_pthread_setname_np_1arg],
6056    [AC_COMPILE_IFELSE(
6057      [AC_LANG_PROGRAM(
6058        [[#include <pthread.h>]],
6059        [[pthread_setname_np ("a");]])],
6060      [emacs_cv_pthread_setname_np_1arg=yes],
6061      [emacs_cv_pthread_setname_np_1arg=no])])
6062   if test "$emacs_cv_pthread_setname_np_1arg" = "yes"; then
6063     AC_DEFINE(
6064       [HAVE_PTHREAD_SETNAME_NP_1ARG], [1],
6065       [Define to 1 if pthread_setname_np takes a single argument.])
6066   else
6067     AC_CACHE_CHECK(
6068      [whether pthread_setname_np takes three arguments],
6069      [emacs_cv_pthread_setname_np_3arg],
6070      [AC_COMPILE_IFELSE(
6071        [AC_LANG_PROGRAM(
6072          [[#include <pthread.h>]],
6073          [[pthread_setname_np (0, "%s", "a");]])],
6074        [emacs_cv_pthread_setname_np_3arg=yes],
6075        [emacs_cv_pthread_setname_np_3arg=no])])
6076      if test "$emacs_cv_pthread_setname_np_3arg" = "yes"; then
6077        AC_DEFINE(
6078          [HAVE_PTHREAD_SETNAME_NP_3ARG], [1],
6079          [Define to 1 if pthread_setname_np takes three arguments.])
6080      fi
6081   fi
6084 dnl No need to check for posix_memalign if aligned_alloc works.
6085 AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break])
6086 AC_CHECK_DECLS([aligned_alloc], [], [], [[#include <stdlib.h>]])
6088 case $with_unexec,$canonical in
6089   yes,alpha*)
6090     AC_CHECK_DECL([__ELF__], [],
6091       [AC_MSG_ERROR([Non-ELF systems are not supported on this platform.])]);;
6092 esac
6094 if test "$with_unexec" = yes && test "$opsys" = "haiku"; then
6095   dnl A serious attempt was actually made to port unexec to Haiku.
6096   dnl Something in libstdc++ seems to prevent it from working.
6097   AC_MSG_ERROR([Haiku is not supported by the legacy unexec dumper.
6098 Please use the portable dumper instead.])
6101 # Dump loading.  Android lacks posix_madvise.
6102 AC_CHECK_FUNCS([posix_madvise madvise])
6104 dnl Cannot use AC_CHECK_FUNCS
6105 AC_CACHE_CHECK([for __builtin_frame_address],
6106   [emacs_cv_func___builtin_frame_address],
6107   [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_frame_address (0);])],
6108      [emacs_cv_func___builtin_frame_address=yes],
6109      [emacs_cv_func___builtin_frame_address=no])])
6110 if test $emacs_cv_func___builtin_frame_address = yes; then
6111   AC_DEFINE([HAVE___BUILTIN_FRAME_ADDRESS], [1],
6112             [Define to 1 if you have the '__builtin_frame_address' function.])
6114 AC_CACHE_CHECK([for __builtin_unwind_init],
6115                [emacs_cv_func___builtin_unwind_init],
6116 [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_unwind_init ();])],
6117                 [emacs_cv_func___builtin_unwind_init=yes],
6118                 [emacs_cv_func___builtin_unwind_init=no])])
6119 if test $emacs_cv_func___builtin_unwind_init = yes; then
6120   AC_DEFINE([HAVE___BUILTIN_UNWIND_INIT], [1],
6121             [Define to 1 if you have the '__builtin_unwind_init' function.])
6124 AC_CHECK_HEADERS_ONCE([sys/un.h])
6126 AC_FUNC_FSEEKO
6128 # UNIX98 PTYs.
6129 AC_CHECK_FUNCS([grantpt])
6131 # PTY-related GNU extensions.
6132 AC_CHECK_FUNCS([getpt posix_openpt])
6134 dnl Run a test program that contains a call to tputs, a call that is
6135 dnl never executed.  This tests whether a pre-'main' dynamic linker
6136 dnl works with the library.  It's too much trouble to actually call
6137 dnl tputs in the test program, due to portability hassles.  When
6138 dnl cross-compiling, assume the test program will run if it links.
6139 AC_DEFUN([tputs_link_source], [
6140   AC_LANG_SOURCE(
6141      [[extern void tputs (const char *, int, int (*)(int));
6142        int main (int argc, char **argv)
6143        {
6144           if (argc == 10000)
6145             tputs (argv[0], 0, 0);
6146           return 0;
6147        }]])
6149 # Check this now, so that we will NOT find the above functions in ncurses.
6150 # That is because we have not set up to link ncurses in lib-src.
6151 # It's better to believe a function is not available
6152 # than to expect to find it in ncurses.
6153 # Also we need tputs and friends to be able to build at all.
6154 AC_CACHE_CHECK([for library containing tputs], [emacs_cv_tputs_lib],
6155 [if test "${opsys}" = "mingw32" || test x"$REALLY_ANDROID" = "xyes"; then
6156   emacs_cv_tputs_lib='none required'
6157 else
6158   # curses precedes termcap because of AIX (Bug#9736#35) and OpenIndiana.
6159   tputs_libraries='tinfo ncurses terminfo curses termcap tinfow ncursesw'
6160   for tputs_library in '' $tputs_libraries; do
6161     OLIBS=$LIBS
6162     if test -z "$tputs_library"; then
6163       emacs_cv_tputs_lib='none required'
6164     else
6165       emacs_cv_tputs_lib=-l$tputs_library
6166       LIBS="$emacs_cv_tputs_lib $LIBS"
6167     fi
6168     AC_RUN_IFELSE([tputs_link_source], [], [emacs_cv_tputs_lib=no],
6169       [AC_LINK_IFELSE([tputs_link_source], [], [emacs_cv_tputs_lib=no])])
6170     LIBS=$OLIBS
6171     if test "X$emacs_cv_tputs_lib" != Xno; then
6172       break
6173     fi
6174   done
6175 fi])
6176 AS_CASE(["$emacs_cv_tputs_lib"],
6177   [no], [AC_MSG_ERROR([The required function 'tputs' was not found in any library.
6178 The following libraries were tried (in order):
6179   libtinfo, libncurses, libterminfo, libcurses, libtermcap
6180 Please try installing whichever of these libraries is most appropriate
6181 for your system, together with its header files.
6182 For example, a libncurses-dev(el) or similar package.])],
6183   [-l*], [LIBS_TERMCAP=$emacs_cv_tputs_lib],
6184   [*], [LIBS_TERMCAP=])
6186 ## Use termcap instead of terminfo?
6187 ## Only true for: freebsd < 40000, ms-w32, msdos, netbsd < 599002500.
6188 TERMINFO=yes
6189 ## FIXME?  In the cases below where we unconditionally set
6190 ## LIBS_TERMCAP="-lncurses", this overrides LIBS_TERMCAP = -ltinfo,
6191 ## if that was found above to have tputs.
6192 ## Should we use the gnu* logic everywhere?
6193 case "$opsys$REALLY_ANDROID" in
6194   ## darwin: Prevents crashes when running Emacs in Terminal.app under 10.2.
6195   ##  The ncurses library has been moved out of the System framework in
6196   ##  Mac OS X 10.2.  So if configure detects it, set the command-line
6197   ##  option to use it.
6198   darwin) LIBS_TERMCAP="-lncurses" ;;
6200   gnu*) test -z "$LIBS_TERMCAP" && LIBS_TERMCAP="-lncurses" ;;
6202   freebsd)
6203     AC_MSG_CHECKING([whether FreeBSD is new enough to use terminfo])
6204     AC_CACHE_VAL([emacs_cv_freebsd_terminfo],
6205     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <osreldate.h>]],
6206 [[#if __FreeBSD_version < 400000
6207 fail;
6208 #endif
6209 ]])], [emacs_cv_freebsd_terminfo=yes],
6210       [emacs_cv_freebsd_terminfo=no])])
6212     AC_MSG_RESULT([$emacs_cv_freebsd_terminfo])
6214     if test $emacs_cv_freebsd_terminfo = yes; then
6215       LIBS_TERMCAP="-lncurses"
6216     else
6217       TERMINFO=no
6218       LIBS_TERMCAP="-ltermcap"
6219     fi
6220     ;;
6222   # The case condition is a concatenation of both $opsys and
6223   # $REALLY_ANDROID.  Only disable termcap if building a GUI program.
6224   # (bug#65340)
6225   mingw32 | androidyes)
6226     TERMINFO=no
6227     LIBS_TERMCAP=
6228     ;;
6230   netbsd)
6231     # NetBSD versions prior to 6.0 lack native terminfo, but have a
6232     # tputs() built on top of termcap in these libraries. Use native
6233     # termcap instead in this case. NetBSD >= 6.0 has native terminfo
6234     # implementation in -lterminfo.
6235     if test "x$LIBS_TERMCAP" = "x-ltermcap" -o "x$LIBS_TERMCAP" = "x-lcurses"; then
6236       TERMINFO=no
6237       LIBS_TERMCAP="-ltermcap"
6238     fi
6239     ;;
6241   openbsd | dragonfly) LIBS_TERMCAP="-lncurses" ;;
6243   ## hpux: Make sure we get select from libc rather than from libcurses
6244   ##  because libcurses on HPUX 10.10 has a broken version of select.
6245   ##  We used to use -lc -lcurses, but this may be cleaner.
6246   ## FIXME?  But TERMINFO = yes on hpux (it used to be explicitly
6247   # set that way, now it uses the default).  Isn't this a contradiction?
6248   hpux*) LIBS_TERMCAP="-ltermcap" ;;
6250 esac
6252 TERMCAP_OBJ=tparam.o
6253 if test $TERMINFO = yes; then
6254   AC_DEFINE([TERMINFO], [1],
6255     [Define to 1 if you use terminfo instead of termcap.])
6256   TERMCAP_OBJ=terminfo.o
6257   AC_CACHE_CHECK([whether $LIBS_TERMCAP library defines BC],
6258     [emacs_cv_terminfo_defines_BC],
6259     [OLD_LIBS=$LIBS
6260      LIBS="$LIBS $LIBS_TERMCAP"
6261      AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern char *BC;]], [[return !*BC;]])],
6262        [emacs_cv_terminfo_defines_BC=yes],
6263        [emacs_cv_terminfo_defines_BC=no])
6264      LIBS=$OLD_LIBS])
6265   if test "$emacs_cv_terminfo_defines_BC" = yes; then
6266     AC_DEFINE([TERMINFO_DEFINES_BC], [1], [Define to 1 if the
6267       terminfo library defines the variables BC, PC, and UP.])
6268   fi
6270 if test "X$LIBS_TERMCAP" = "X-lncurses"; then
6271   AC_DEFINE([USE_NCURSES], [1], [Define to 1 if you use ncurses.])
6273 AC_SUBST([LIBS_TERMCAP])
6274 AC_SUBST([TERMCAP_OBJ])
6276 # GNU/Linux-specific timer functions.
6277 AC_CACHE_CHECK([for timerfd interface], [emacs_cv_have_timerfd],
6278   [AC_COMPILE_IFELSE(
6279      [AC_LANG_PROGRAM([[#include <sys/timerfd.h>
6280                       ]],
6281                       [[timerfd_create (CLOCK_REALTIME,
6282                                         TFD_CLOEXEC | TFD_NONBLOCK);
6283                         timerfd_settime (0, TFD_TIMER_ABSTIME, 0, 0);]])],
6284      [emacs_cv_have_timerfd=yes],
6285      [emacs_cv_have_timerfd=no])])
6286 if test "$emacs_cv_have_timerfd" = yes; then
6287   AC_DEFINE([HAVE_TIMERFD], [1],
6288     [Define to 1 if timerfd functions are supported as in GNU/Linux.])
6291 # Alternate stack for signal handlers.
6292 AC_CACHE_CHECK([whether signals can be handled on alternate stack],
6293                [emacs_cv_alternate_stack],
6294   [AC_COMPILE_IFELSE(
6295      [AC_LANG_PROGRAM([[#include <signal.h>
6296                         #include <stdlib.h>
6297                       ]],
6298                       [[stack_t ss;
6299                         struct sigaction sa;
6300                         ss.ss_sp = malloc (SIGSTKSZ);
6301                         ss.ss_size = SIGSTKSZ;
6302                         sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
6303                         sigaltstack (&ss, 0);
6304                         sigaction (SIGSEGV, &sa, 0);]])],
6305      [emacs_cv_alternate_stack=yes],
6306      [emacs_cv_alternate_stack=no])])
6308 # Do we need the Hesiod library to provide the support routines?
6309 dnl FIXME?  Should we be skipping this on Darwin too?
6310 LIBHESIOD=
6311 LIBRESOLV=
6312 if test "$with_hesiod" != no ; then
6313   # Don't set $LIBS here -- see comments above.  FIXME which comments?
6314   resolv=no
6315   AC_CHECK_FUNC([res_send], [], [AC_CHECK_FUNC([__res_send], [],
6316      [AC_CHECK_LIB([resolv], [res_send], [resolv=yes],
6317                   [AC_CHECK_LIB([resolv], [__res_send], [resolv=yes])])])])
6318   if test "$resolv" = yes ; then
6319     RESOLVLIB=-lresolv
6320   else
6321     RESOLVLIB=
6322   fi
6323   hesiod=no
6324   AC_CHECK_FUNC([hes_getmailhost], [],
6325     [AC_CHECK_LIB([hesiod], [hes_getmailhost],
6326        [hesiod=yes], [:], [$RESOLVLIB])])
6328   if test x"$hesiod" = xyes; then
6329     LIBHESIOD=-lhesiod
6330     LIBRESOLV=$RESOLVLIB
6331   fi
6333 AC_SUBST([LIBHESIOD])
6334 AC_SUBST([LIBRESOLV])
6336 # These tell us which Kerberos-related libraries to use.
6337 COM_ERRLIB=
6338 CRYPTOLIB=
6339 KRB5LIB=
6340 DESLIB=
6341 KRB4LIB=
6343 if test "${with_kerberos}" != no; then
6344   OLD_LIBS=$LIBS
6345   AC_CHECK_LIB([com_err], [com_err], [have_com_err=yes], [have_com_err=no])
6346   if test $have_com_err = yes; then
6347     COM_ERRLIB=-lcom_err
6348     LIBS="$COM_ERRLIB $LIBS"
6349   fi
6350   AC_CHECK_LIB([crypto], [mit_des_cbc_encrypt],
6351     [have_crypto=yes],
6352     [have_crypto=no])
6353   if test $have_crypto = yes; then
6354     CRYPTOLIB=-lcrypto
6355     LIBS="$CRYPTOLIB $LIBS"
6356   fi
6357   AC_CHECK_LIB([k5crypto], [mit_des_cbc_encrypt],
6358     [have_k5crypto=yes],
6359     [have_k5crypto=no])
6360   if test $have_k5crypto = yes; then
6361     CRYPTOLIB=-lk5crypto
6362     LIBS="$CRYPTOLIB $LIBS"
6363   fi
6364   AC_CHECK_LIB([krb5], [krb5_init_context], [have_krb5=yes], [have_krb5=no])
6365   if test $have_krb5=yes; then
6366     KRB5LIB=-lkrb5
6367     LIBS="$KRB5LIB $LIBS"
6368   fi
6369   dnl FIXME Simplify.  Does not match 22 logic, thanks to default_off?
6370   if test "${with_kerberos5}" = no; then
6371     AC_CHECK_LIB([des425], [des_cbc_encrypt],
6372       [have_des425=yes],
6373       [have_des425=no])
6374     if test $have_des425 = yes; then
6375       DESLIB=-ldes425
6376       LIBS="$DESLIB $LIBS"
6377     else
6378       AC_CHECK_LIB([des], [des_cbc_encrypt], [have_des=yes], [have_des=no])
6379       if test $have_des = yes; then
6380         DESLIB=-ldes
6381         LIBS="$DESLIB $LIBS"
6382       fi
6383     fi
6384     AC_CHECK_LIB([krb4], [krb_get_cred], [have_krb4=yes], [have_krb4=no])
6385     if test $have_krb4 = yes; then
6386       KRB4LIB=-lkrb4
6387       LIBS="$KRB4LIB $LIBS"
6388     else
6389       AC_CHECK_LIB([krb], [krb_get_cred], [have_krb=yes], [have_krb=no])
6390       if test $have_krb = yes; then
6391         KRB4LIB=-lkrb
6392         LIBS="$KRB4LIB $LIBS"
6393       fi
6394     fi
6395   fi
6397   if test "${with_kerberos5}" != no; then
6398     AC_CHECK_HEADERS([krb5.h],
6399       [AC_CHECK_MEMBERS([krb5_error.text, krb5_error.e_text], [], [],
6400                         [#include <krb5.h>])])
6401   else
6402     AC_CHECK_HEADERS([krb.h], [],
6403                      [AC_CHECK_HEADERS([kerberosIV/krb.h], [],
6404                                        [AC_CHECK_HEADERS([kerberos/krb.h])])])
6405   fi
6406   AC_CHECK_HEADERS([com_err.h])
6407   LIBS=$OLD_LIBS
6410 AC_SUBST([COM_ERRLIB])
6411 AC_SUBST([CRYPTOLIB])
6412 AC_SUBST([KRB5LIB])
6413 AC_SUBST([DESLIB])
6414 AC_SUBST([KRB4LIB])
6416 AC_CHECK_HEADERS([valgrind/valgrind.h])
6418 AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]])
6420 AC_CHECK_FUNCS_ONCE([__lsan_ignore_object])
6422 AC_FUNC_FORK
6424 dnl AC_CHECK_FUNCS_ONCE wouldn’t be right for snprintf, which needs
6425 dnl the current CFLAGS etc.
6426 AC_CHECK_FUNCS([snprintf open_memstream])
6428 dnl posix_spawn.  The chdir and setsid functionality is relatively
6429 dnl recent, so we check for it specifically.
6430 AC_CHECK_HEADERS([spawn.h])
6431 AC_SUBST([HAVE_SPAWN_H])
6432 AC_CHECK_FUNCS([posix_spawn \
6433                 posix_spawn_file_actions_addchdir \
6434                 posix_spawn_file_actions_addchdir_np \
6435                 posix_spawnattr_setflags])
6436 AC_SUBST([HAVE_POSIX_SPAWN])
6437 AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
6438 AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP])
6439 AC_SUBST([HAVE_POSIX_SPAWNATTR_SETFLAGS])
6440 AC_CHECK_DECLS([POSIX_SPAWN_SETSID], [], [], [[
6441                #include <spawn.h>
6442                ]])
6443 AC_SUBST([HAVE_DECL_POSIX_SPAWN_SETSID])
6445 dnl Check for glib.  This differs from other library checks in that
6446 dnl Emacs need not link to glib unless some other library is already
6447 dnl linking to glib.  Although glib provides no facilities that Emacs
6448 dnl needs for its own purposes, when glib is present Emacs needs to
6449 dnl use primitives like g_main_context_query to avoid clashing with
6450 dnl glib at a low level.
6452 dnl Check this late, since it depends on $GTK_CFLAGS etc.
6453 XGSELOBJ=
6454 AC_CACHE_CHECK([whether GLib is linked in], [emacs_cv_links_glib],
6455 [OLDCFLAGS="$CFLAGS"
6456 OLDLIBS="$LIBS"
6457 CFLAGS="$CFLAGS $GTK_CFLAGS $RSVG_CFLAGS $DBUS_CFLAGS $SETTINGS_CFLAGS"
6458 LIBS="$LIBS $GTK_LIBS $RSVG_LIBS $DBUS_LIBS $SETTINGS_LIBS"
6459 CFLAGS="$CFLAGS $NOTIFY_CFLAGS $CAIRO_CFLAGS"
6460 LIBS="$LIBS $NOTIFY_LIBS $CAIRO_LIBS"
6461 AC_LINK_IFELSE([AC_LANG_PROGRAM(
6462         [[#include <glib.h>
6463         ]],
6464         [[g_print ("Hello world");]])],
6465      [emacs_cv_links_glib=yes],
6466      [emacs_cv_links_glib=no])
6467 CFLAGS="$OLDCFLAGS"
6468 LIBS="$OLDLIBS"])
6469 if test "${emacs_cv_links_glib}" = "yes"; then
6470   AC_DEFINE([HAVE_GLIB], [1], [Define to 1 if GLib is linked in.])
6471   if test "$HAVE_NS" = no ; then
6472     XGSELOBJ=xgselect.o
6473   fi
6475 AC_SUBST([XGSELOBJ])
6477 AC_DEFUN([EMACS_PAPER_WIDTH],
6478   [AC_REQUIRE([AM_LANGINFO_CODESET])
6479    AS_IF([test "$am_cv_langinfo_codeset" = yes],
6480      [AC_CACHE_CHECK([for nl_langinfo and _NL_PAPER_WIDTH],
6481         [emacs_cv_langinfo__nl_paper_width],
6482         [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
6483           [[char *cs = nl_langinfo (_NL_PAPER_WIDTH);]])],
6484           [emacs_cv_langinfo__nl_paper_width=yes],
6485           [emacs_cv_langinfo__nl_paper_width=no])
6486         ])
6487       AS_IF([test "$emacs_cv_langinfo__nl_paper_width" = yes],
6488         [AC_DEFINE([HAVE_LANGINFO__NL_PAPER_WIDTH], [1],
6489            [Define if you have <langinfo.h>
6490             and nl_langinfo (_NL_PAPER_WIDTH).])])])])
6491 EMACS_PAPER_WIDTH
6493 AC_TYPE_MBSTATE_T
6495 dnl Fixme: AC_SYS_POSIX_TERMIOS should probably be used, but it's not clear
6496 dnl how the tty code is related to POSIX and/or other versions of termios.
6497 dnl The following looks like a useful start.
6499 dnl AC_SYS_POSIX_TERMIOS
6500 dnl if test $ac_cv_sys_posix_termios = yes; then
6501 dnl    AC_DEFINE([HAVE_TERMIOS], [1],
6502 dnl      [Define to 1 if you have POSIX-style
6503 dnl       functions and macros for terminal control.])
6504 dnl    AC_DEFINE([HAVE_TCATTR], [1],
6505 dnl      [Define to 1 if you have tcgetattr and tcsetattr.])
6506 dnl fi
6508 dnl Turned on June 1996 supposing nobody will mind it.
6509 dnl MinGW emulates passwd database, so this feature doesn't make sense there.
6510 if test "${opsys}" != "mingw32"; then
6511    AC_DEFINE([AMPERSAND_FULL_NAME], [1], [Define to use the convention that &
6512      in the full name stands for the login id.])
6515 dnl Everybody supports this, except MS.
6516 dnl Seems like the kind of thing we should be testing for, though.
6517 ## Note: PTYs are broken on darwin <6.  Use at your own risk.
6518 if test "${opsys}" != "mingw32"; then
6519   AC_DEFINE([HAVE_PTYS], [1], [Define if the system supports pty devices.])
6522 dnl Everybody supports this, except MS-DOS.
6523 dnl Seems like the kind of thing we should be testing for, though.
6524 AC_DEFINE([HAVE_SOCKETS], [1], [Define if the system supports
6525   4.2-compatible sockets.])
6527 AH_TEMPLATE([INTERNAL_TERMINAL],
6528   [This is substituted when $TERM is "internal".])
6530 AH_TEMPLATE([NULL_DEVICE], [Name of the file to open to get
6531   a null file, or a data sink.])
6532 if test "${opsys}" = "mingw32"; then
6533   AC_DEFINE([NULL_DEVICE], ["NUL:"])
6534 else
6535   AC_DEFINE([NULL_DEVICE], ["/dev/null"])
6538 if test "${opsys}" = "mingw32"; then
6539   SEPCHAR=';'
6540 else
6541   SEPCHAR=':'
6543 AC_DEFINE_UNQUOTED([SEPCHAR], ['$SEPCHAR'],
6544   [Character that separates PATH elements.])
6545 dnl This is for MinGW, and is used in test/Makefile.in.
6546 dnl The MSYS Bash has heuristics for replacing ':' with ';' when it
6547 dnl decides that a command-line argument to be passed to a MinGW program
6548 dnl is a PATH-style list of directories.  But that heuristics plays it
6549 dnl safe, and only does the replacement when it is _absolutely_ sure it
6550 dnl sees a colon-separated list of file names; e.g. ":." is left alone,
6551 dnl which breaks in-tree builds.  So we do this manually instead.
6552 dnl Note that we cannot rely on PATH_SEPARATOR, as that one will always
6553 dnl be computed as ':' in MSYS Bash.
6554 AC_SUBST([SEPCHAR])
6556 dnl Everybody supports this, except MS-DOS.
6557 AC_DEFINE([subprocesses], [1], [Define to enable asynchronous subprocesses.])
6559 AC_DEFINE([DIRECTORY_SEP], ['/'],
6560   [Character that separates directories in a file name.])
6562 if test "${opsys}" = "mingw32"; then
6563   AC_DEFINE([IS_DEVICE_SEP(_c_)], [((_c_) == ':')],
6564     [Returns true if character is a device separator.])
6566   AC_DEFINE([IS_DIRECTORY_SEP(_c_)], [((_c_) == '/' || (_c_) == '\\')],
6567     [Returns true if character is a directory separator.])
6569   AC_DEFINE([IS_ANY_SEP(_c_)],
6570     [(IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP (_c_))],
6571     [Returns true if character is any form of separator.])
6572 else
6573   AC_DEFINE([IS_DEVICE_SEP(_c_)], 0,
6574     [Returns true if character is a device separator.])
6576   AC_DEFINE([IS_DIRECTORY_SEP(_c_)], [((_c_) == DIRECTORY_SEP)],
6577     [Returns true if character is a directory separator.])
6579   AC_DEFINE([IS_ANY_SEP(_c_)], [(IS_DIRECTORY_SEP (_c_))],
6580     [Returns true if character is any form of separator.])
6583 if test "$USE_X_TOOLKIT" != "none"; then
6584   have_editres=yes
6585   case $opsys in
6586     hpux*)
6587       dnl Assar Westerlund <assar@sics.se> says this is necessary
6588       dnl for HP-UX 10.20, and that it works for HP-UX 0 as well.
6589       have_editres=no
6590     ;;
6591   esac
6592   if test "$have_editres" != no && test ! -z "$LIBXMU"; then
6593     OLDLIBS="$LIBS"
6594     dnl See libXmu.a check above.
6595     if test x$HAVE_X11XTR6 = xyes; then
6596       LIBS="-lXt -lSM -lICE $LIBXMU"
6597     else
6598       OTHERLIBS="-lXt -$LIBXMU"
6599     fi
6600     AC_LINK_IFELSE([AC_LANG_PROGRAM(
6601       [[#include <X11/Intrinsic.h>
6602        #include <X11/Xmu/Editres.h>]],
6603       [[_XEditResCheckMessages (0, 0, 0, 0);]])],
6604       [AC_DEFINE([X_TOOLKIT_EDITRES], [1],
6605         [Define to 1 if we should use XEditRes.])])
6606     LIBS=$OLDLIBS
6607   fi
6610 case $opsys in
6611   solaris | unixware )
6612     dnl Some SVr4s don't define NSIG in sys/signal.h for ANSI environments;
6613     dnl instead, there's a system variable _sys_nsig.  Unfortunately, we
6614     dnl need the constant to dimension an array.  So wire in the appropriate
6615     dnl value here.
6616     AC_DEFINE([NSIG_MINIMUM], [32], [Minimum value of NSIG.])
6617     ;;
6618 esac
6620 emacs_broken_SIGIO=no
6622 case $opsys in
6623   dnl SIGIO exists, but the feature doesn't work in the way Emacs needs.
6624   hpux* | nacl | solaris | unixware )
6625     emacs_broken_SIGIO=yes
6626     ;;
6628   aix4-2)
6629     dnl On AIX Emacs uses the gmalloc.c malloc implementation.  But given
6630     dnl the way this system works, libc functions that return malloced
6631     dnl memory use the libc malloc implementation. Calling xfree or
6632     dnl xrealloc on the results of such functions results in a crash.
6633     dnl
6634     dnl One solution for this could be to define SYSTEM_MALLOC in configure,
6635     dnl but that does not currently work on this system.
6636     dnl
6637     dnl It is possible to completely override the malloc implementation on
6638     dnl AIX, but that involves putting the malloc functions in a shared
6639     dnl library and setting the MALLOCTYPE environment variable to point to
6640     dnl that shared library.
6641     dnl
6642     dnl Emacs currently calls xrealloc on the results of get_current_dir name,
6643     dnl to avoid a crash just use the Emacs implementation for that function.
6644     dnl
6645     dnl FIXME We could change the AC_CHECK_FUNCS call near the start
6646     dnl of this file, so that we do not check for get_current_dir_name
6647     dnl on AIX.  But that might be fragile if something else ends
6648     dnl up testing for get_current_dir_name as a dependency.
6649     AC_DEFINE([BROKEN_GET_CURRENT_DIR_NAME], [1], [Define if
6650       get_current_dir_name should not be used.])
6651     ;;
6653   freebsd)
6654     dnl Circumvent a bug in FreeBSD.  In the following sequence of
6655     dnl writes/reads on a PTY, read(2) returns bogus data:
6656     dnl
6657     dnl write(2)  1022 bytes
6658     dnl write(2)   954 bytes, get EAGAIN
6659     dnl read(2)   1024 bytes in process_read_output
6660     dnl read(2)     11 bytes in process_read_output
6661     dnl
6662     dnl That is, read(2) returns more bytes than have ever been written
6663     dnl successfully.  The 1033 bytes read are the 1022 bytes written
6664     dnl successfully after processing (for example with CRs added if the
6665     dnl terminal is set up that way which it is here).  The same bytes will
6666     dnl be seen again in a later read(2), without the CRs.
6667     AC_DEFINE([BROKEN_PTY_READ_AFTER_EAGAIN], [1], [Define on FreeBSD to
6668       work around an issue when reading from a PTY.])
6669     ;;
6670 esac
6672 case $opsys in
6673   gnu-* | android | solaris | cygwin )
6674     dnl FIXME Can't we test if this exists (eg /proc/$$)?
6675     AC_DEFINE([HAVE_PROCFS], [1], [Define if you have the /proc filesystem.])
6676   ;;
6677 esac
6679 case $opsys in
6680   darwin | dragonfly | freebsd | netbsd | openbsd )
6681     AC_DEFINE([DONT_REOPEN_PTY], [1], [Define if process.c does not need to
6682       close a pty to make it a controlling terminal (it is already a
6683       controlling terminal of the subprocess, because we did ioctl TIOCSCTTY).])
6684   ;;
6685 esac
6687 dnl FIXME Surely we can test for this rather than hard-code it.
6688 case $opsys in
6689   netbsd | openbsd) sound_device="/dev/audio" ;;
6690   *) sound_device="/dev/dsp" ;;
6691 esac
6693 dnl Used in sound.c
6694 AC_DEFINE_UNQUOTED([DEFAULT_SOUND_DEVICE], ["$sound_device"],
6695   [Name of the default sound device.])
6698 dnl Emacs can read input using SIGIO and buffering characters itself,
6699 dnl or using CBREAK mode and making C-g cause SIGINT.
6700 dnl The choice is controlled by the variable interrupt_input.
6702 dnl Define INTERRUPT_INPUT to make interrupt_input = 1 the default (use SIGIO)
6704 dnl Emacs uses the presence of the USABLE_SIGIO macro
6705 dnl to indicate whether or not signal-driven I/O is possible.  It uses
6706 dnl INTERRUPT_INPUT to decide whether to use it by default.
6708 dnl SIGIO can be used only on systems that implement it (4.2 and 4.3).
6709 dnl CBREAK mode has two disadvantages
6710 dnl 1) At least in 4.2, it is impossible to handle the Meta key properly.
6711 dnl I hear that in system V this problem does not exist.
6712 dnl 2) Control-G causes output to be discarded.
6713 dnl I do not know whether this can be fixed in system V.
6715 dnl Another method of doing input is planned but not implemented.
6716 dnl It would have Emacs fork off a separate process
6717 dnl to read the input and send it to the true Emacs process
6718 dnl through a pipe.
6719 case $opsys in
6720   darwin | gnu-linux | gnu-kfreebsd)
6721     AC_DEFINE([INTERRUPT_INPUT], [1], [Define to read input using SIGIO.])
6722   ;;
6723 esac
6726 dnl If the system's imake configuration file defines 'NeedWidePrototypes'
6727 dnl as 'NO', we must define NARROWPROTO manually.  Such a define is
6728 dnl generated in the Makefile generated by 'xmkmf'.  If we don't define
6729 dnl NARROWPROTO, we will see the wrong function prototypes for X functions
6730 dnl taking float or double parameters.
6731 case $opsys in
6732   cygwin|gnu|gnu-linux|gnu-kfreebsd|freebsd|netbsd|openbsd)
6733     AC_DEFINE([NARROWPROTO], [1], [Define if system's imake configuration
6734       file defines 'NeedWidePrototypes' as 'NO'.])
6735   ;;
6736 esac
6739 dnl Used in process.c, this must be a loop, even if it only runs once.
6740 AH_TEMPLATE([PTY_ITERATION], [How to iterate over PTYs.])
6741 dnl Only used if !PTY_ITERATION.  Iterate from FIRST_PTY_LETTER to z,
6742 dnl trying suffixes 0-16.
6743 AH_TEMPLATE([FIRST_PTY_LETTER], [Letter to use in finding device name of
6744   first PTY, if PTYs are supported.])
6745 AH_TEMPLATE([PTY_OPEN], [How to open a PTY, if non-standard.])
6746 AH_TEMPLATE([PTY_NAME_SPRINTF], [How to get the device name of the control
6747   end of a PTY, if non-standard.])
6748 AH_TEMPLATE([PTY_TTY_NAME_SPRINTF], [How to get device name of the tty
6749   end of a PTY, if non-standard.])
6751 case $opsys in
6752   aix4-2 )
6753     AC_DEFINE([PTY_ITERATION], [int c; for (c = 0; !c ; c++)])
6754     dnl You allocate a pty by opening /dev/ptc to get the master side.
6755     dnl To get the name of the slave side, you just ttyname() the master side.
6756     AC_DEFINE([PTY_NAME_SPRINTF], [strcpy (pty_name, "/dev/ptc");])
6757     AC_DEFINE([PTY_TTY_NAME_SPRINTF], [strcpy (pty_name, ttyname (fd));])
6758     ;;
6760   cygwin )
6761     AC_DEFINE([PTY_ITERATION], [int i; for (i = 0; i < 1; i++)])
6762     dnl multi-line AC_DEFINEs are hard. :(
6763     AC_DEFINE([PTY_OPEN],
6764       [ 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)])
6765     AC_DEFINE([PTY_NAME_SPRINTF], [])
6766     AC_DEFINE([PTY_TTY_NAME_SPRINTF], [])
6767     ;;
6769   gnu | qnxnto )
6770     AC_DEFINE([FIRST_PTY_LETTER], ['p'])
6771     ;;
6773   android )
6774     AC_DEFINE([PTY_ITERATION], [int i; for (i = 0; i < 1; ++i)])
6775     dnl grantpt may be defined in libc but not declared.  The same
6776     dnl goes for posix_openpt.  When that is the case, it means that
6777     dnl grantpt or posix_openpt cannot actually be used.
6778     AC_CHECK_DECLS([grantpt, posix_openpt])
6779     AS_IF([test "x$ac_cv_have_decl_grantpt" = xyes],
6780       [AC_DEFINE([PTY_TTY_NAME_SPRINTF],
6781         [{ 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); }])],
6782       [AC_DEFINE([PTY_TTY_NAME_SPRINTF],
6783         [{ char *ptyname = 0; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); if (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); }])])
6784     AS_IF([test "x$ac_cv_have_decl_posix_openpt" = xyes],
6785       [AC_DEFINE([PTY_OPEN],
6786         [do { fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY); if (fd < 0 && errno == EINVAL) fd = posix_openpt (O_RDWR | O_NOCTTY); } while (false)])
6787        AC_DEFINE([PTY_NAME_SPRINTF], [])],
6788       [AC_DEFINE([PTY_NAME_SPRINTF], [])
6789        AC_DEFINE([PTY_OPEN], [fd = getpt ()])])
6790     ;;
6792   gnu-linux | gnu-kfreebsd | dragonfly | freebsd | openbsd | netbsd | darwin | nacl )
6793     dnl if HAVE_GRANTPT
6794     if test "x$ac_cv_func_grantpt" = xyes; then
6795       AC_DEFINE([UNIX98_PTYS], [1], [Define if the system has Unix98 PTYs.])
6796       AC_DEFINE([PTY_ITERATION], [int i; for (i = 0; i < 1; i++)])
6797       dnl Note that grantpt and unlockpt may fork.  We must block SIGCHLD
6798       dnl to prevent sigchld_handler from intercepting the child's death.
6799       AC_DEFINE([PTY_TTY_NAME_SPRINTF],
6800         [{ 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); }])
6801       dnl if HAVE_POSIX_OPENPT
6802       if test "x$ac_cv_func_posix_openpt" = xyes; then
6803         AC_DEFINE([PTY_OPEN],
6804           [do { fd = posix_openpt (O_RDWR | O_CLOEXEC | O_NOCTTY); if (fd < 0 && errno == EINVAL) fd = posix_openpt (O_RDWR | O_NOCTTY); } while (false)])
6805         AC_DEFINE([PTY_NAME_SPRINTF], [])
6806       dnl if HAVE_GETPT
6807       elif test "x$ac_cv_func_getpt" = xyes; then
6808         AC_DEFINE([PTY_OPEN], [fd = getpt ()])
6809         AC_DEFINE([PTY_NAME_SPRINTF], [])
6810       else
6811         AC_DEFINE([PTY_NAME_SPRINTF], [strcpy (pty_name, "/dev/ptmx");])
6812       fi
6813     else
6814       AC_DEFINE([FIRST_PTY_LETTER], ['p'])
6815     fi
6816     ;;
6818   hpux*)
6819     AC_DEFINE([FIRST_PTY_LETTER], ['p'])
6820     AC_DEFINE([PTY_NAME_SPRINTF],
6821       [sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);])
6822     AC_DEFINE([PTY_TTY_NAME_SPRINTF],
6823       [sprintf (pty_name, "/dev/pty/tty%c%x", c, i);])
6824     ;;
6826   solaris )
6827     dnl On SysVr4, grantpt(3) forks a subprocess, so do not use
6828     dnl O_CLOEXEC when opening the pty, and keep the SIGCHLD handler
6829     dnl from intercepting that death.  If any child but grantpt's should die
6830     dnl within, it should be caught after sigrelse(2).
6831     AC_DEFINE([PTY_OPEN], [fd = open (pty_name, O_RDWR | O_NONBLOCK)])
6832     AC_DEFINE([PTY_TTY_NAME_SPRINTF],
6833       [{ 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); }])
6834     ;;
6836   unixware )
6837     dnl Comments are as per solaris.
6838     AC_DEFINE([PTY_OPEN], [fd = open (pty_name, O_RDWR | O_NONBLOCK)])
6839     AC_DEFINE([PTY_TTY_NAME_SPRINTF],
6840       [{ 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); }])
6841     ;;
6843   haiku*)
6844     AC_DEFINE([FIRST_PTY_LETTER], ['s'])
6845     AC_DEFINE([PTY_NAME_SPRINTF], [])
6846     dnl on Haiku pty names aren't distinctive, thus the use of posix_openpt
6847     AC_DEFINE([PTY_OPEN], [fd = posix_openpt (O_RDWR | O_NONBLOCK)])
6848     AC_DEFINE([PTY_TTY_NAME_SPRINTF],
6849       [{ char *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); }])
6850     ;;
6851 esac
6854 case $opsys in
6855   solaris | unixware )
6856     dnl This change means that we don't loop through allocate_pty too
6857     dnl many times in the (rare) event of a failure.
6858     AC_DEFINE([FIRST_PTY_LETTER], ['z'])
6859     AC_DEFINE([PTY_NAME_SPRINTF], [strcpy (pty_name, "/dev/ptmx");])
6860     dnl Push various streams modules onto a PTY channel.  Used in process.c.
6861     AC_DEFINE([SETUP_SLAVE_PTY],
6862       [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.])
6863     ;;
6864 esac
6867 AH_TEMPLATE([SIGNALS_VIA_CHARACTERS], [Make process_send_signal work by
6868 "typing" a signal character on the pty.])
6870 case $opsys in
6871   dnl Perry Smith <pedz@ddivt1.austin.ibm.com> says this is correct for AIX.
6872   aix4-2 | cygwin | gnu | dragonfly | freebsd | netbsd | openbsd | darwin )
6873     AC_DEFINE([SIGNALS_VIA_CHARACTERS], [1])
6874     ;;
6876   dnl 21 Jun 06: Eric Hanchrow <offby1@blarg.net> says this works.
6877   dnl FIXME Does gnu-kfreebsd have linux/version.h?  It seems unlikely...
6878   gnu-linux | gnu-kfreebsd )
6880     AC_CACHE_CHECK([for signals via characters], [emacs_cv_signals_via_chars],
6881     [AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
6882 #include <linux/version.h>
6883 #if LINUX_VERSION_CODE < 0x20400
6884 # error "Linux version too old"
6885 #endif
6886       ]], [[]])],
6887         [emacs_cv_signals_via_chars=yes],
6888         [emacs_cv_signals_via_chars=no])])
6890     test "$emacs_cv_signals_via_chars" = yes &&
6891       AC_DEFINE([SIGNALS_VIA_CHARACTERS], [1])
6892     ;;
6893 esac
6896 AH_TEMPLATE([TAB3], [Undocumented.])
6898 case $opsys in
6899   darwin) AC_DEFINE([TAB3], [OXTABS]) ;;
6901   gnu | dragonfly | freebsd | netbsd | openbsd )
6902     AC_DEFINE([TABDLY], [OXTABS], [Undocumented.])
6903     AC_DEFINE([TAB3], [OXTABS])
6904     ;;
6906   gnu-linux | gnu-kfreebsd )
6907     AC_PREPROC_IFELSE(
6908       [AC_LANG_PROGRAM(
6909          [[
6910 #ifndef __ia64__
6911 # error "not ia64"
6912 #endif
6913          ]], [[]])],
6914       [AC_DEFINE([GC_MARK_SECONDARY_STACK()],
6915         [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)],
6916         [Mark a secondary stack, like the register stack on the ia64.])], [])
6917     ;;
6919   hpux*)
6920     AC_DEFINE([RUN_TIME_REMAP], [1], [Define if emacs.c needs to call
6921       run_time_remap; for HPUX.])
6922     ;;
6923 esac
6926 dnl This won't be used automatically yet.  We also need to know, at least,
6927 dnl that the stack is continuous.
6928 AH_TEMPLATE([GC_SETJMP_WORKS], [Define if setjmp is known to save all
6929   registers relevant for conservative garbage collection in the jmp_buf.])
6932 case $opsys in
6933   dnl Not all the architectures are tested, but there are Debian packages
6934   dnl for SCM and/or Guile on them, so the technique must work.  See also
6935   dnl comments in alloc.c concerning setjmp and gcc.
6936   dnl Fixme: it's probably safe to just use the GCC conditional below.
6937   gnu-linux | gnu-kfreebsd )
6938     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
6939 #if defined __i386__ || defined __sparc__ || defined __mc68000__ \
6940   || defined __alpha__ || defined __mips__ || defined __s390__ \
6941   || defined __arm__ || defined __powerpc__ || defined __amd64__ \
6942   || defined __x86_64__ \
6943   || defined __ia64__ || defined __sh__
6944 /* ok */
6945 #else
6946 # error "setjmp not known to work on this arch"
6947 #endif
6948     ]], [[]])], [AC_DEFINE([GC_SETJMP_WORKS], [1])])
6949     ;;
6950 esac
6953 if test x$GCC = xyes; then
6954    dnl GC_SETJMP_WORKS is nearly always appropriate for GCC.
6955    AC_DEFINE([GC_SETJMP_WORKS], [1])
6956 else
6957   case $opsys in
6958     aix* | dragonfly | freebsd | netbsd | openbsd | solaris )
6959       AC_DEFINE([GC_SETJMP_WORKS], [1])
6960       ;;
6961   esac
6962 fi                              dnl GCC?
6964 dnl In a weird quirk, MS runtime uses _setjmp and longjmp.
6965 AC_CACHE_CHECK([for _setjmp], [emacs_cv_func__setjmp],
6966   [AC_LINK_IFELSE(
6967      [AC_LANG_PROGRAM(
6968        [[#include <setjmp.h>
6969          #ifdef __MINGW32__
6970          # define _longjmp longjmp
6971          #endif
6972        ]],
6973        [[jmp_buf j;
6974          if (! _setjmp (j))
6975            _longjmp (j, 1);]])],
6976      [emacs_cv_func__setjmp=yes],
6977      [emacs_cv_func__setjmp=no])])
6978 if test $emacs_cv_func__setjmp = yes; then
6979   AC_DEFINE([HAVE__SETJMP], [1], [Define to 1 if _setjmp and _longjmp work.])
6982 # We need to preserve signal mask to handle C stack overflows.
6983 AC_CACHE_CHECK([for sigsetjmp], [emacs_cv_func_sigsetjmp],
6984   [AC_LINK_IFELSE(
6985      [AC_LANG_PROGRAM(
6986        [[#include <setjmp.h>
6987        ]],
6988        [[sigjmp_buf j;
6989          if (! sigsetjmp (j, 1))
6990            siglongjmp (j, 1);]])],
6991      [emacs_cv_func_sigsetjmp=yes],
6992      [emacs_cv_func_sigsetjmp=no])])
6993 if test $emacs_cv_func_sigsetjmp = yes; then
6994   AC_DEFINE([HAVE_SIGSETJMP], [1],
6995     [Define to 1 if sigsetjmp and siglongjmp work.])
6998 case $emacs_cv_func_sigsetjmp,$emacs_cv_alternate_stack,$opsys in
6999   yes,yes,* | *,*,mingw32)
7000     AC_DEFINE([HAVE_STACK_OVERFLOW_HANDLING], [1],
7001       [Define to 1 if C stack overflow can be handled in some cases.]);;
7002 esac
7004 case $opsys in
7005   solaris | unixware )
7006     dnl TIOCGPGRP is broken in SysVr4, so we can't send signals to PTY
7007     dnl subprocesses the usual way.  But TIOCSIGNAL does work for PTYs,
7008     dnl and this is all we need.
7009     AC_DEFINE([TIOCSIGSEND], [TIOCSIGNAL], [Some platforms redefine this.])
7010     ;;
7011 esac
7014 case $opsys in
7015   hpux* | solaris )
7016     dnl Used in xfaces.c.
7017     AC_DEFINE([XOS_NEEDS_TIME_H], [1], [Compensate for a bug in Xos.h on
7018       some systems, where it requires time.h.])
7019     ;;
7020 esac
7023 dnl Define symbols to identify the version of Unix this is.
7024 dnl Define all the symbols that apply correctly.
7025 AH_TEMPLATE([DOS_NT], [Define if the system is MS DOS or MS Windows.])
7026 AH_TEMPLATE([MSDOS], [Define if the system is MS DOS.])
7027 AH_TEMPLATE([USG], [Define if the system is compatible with System III.])
7028 AH_TEMPLATE([USG5_4],
7029   [Define if the system is compatible with System V Release 4.])
7031 case $opsys in
7032   aix4-2)
7033     AC_DEFINE([USG], [])
7034     dnl This symbol should be defined on AIX Version 3  ???????
7035     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
7036 #ifndef _AIX
7037 # error "_AIX not defined"
7038 #endif
7039     ]], [[]])], [], [AC_DEFINE([_AIX], [], [Define if the system is AIX.])])
7040     ;;
7042   cygwin)
7043     AC_DEFINE([CYGWIN], [1], [Define if the system is Cygwin.])
7044     ;;
7046   darwin)
7047     dnl Not __APPLE__, as this may not be defined on non-macOS Darwin.
7048     dnl Not DARWIN, because Panther and lower CoreFoundation.h use DARWIN to
7049     dnl distinguish macOS from pure Darwin.
7050     AC_DEFINE([DARWIN_OS], [], [Define if the system is Darwin.])
7051     ;;
7053   gnu-linux | gnu-kfreebsd )
7054     AC_DEFINE([USG], [])
7055     AC_DEFINE([GNU_LINUX], [],
7056       [Define if this system is compatible with GNU/Linux.])
7057     ;;
7059   hpux*)
7060     AC_DEFINE([USG], [])
7061     AC_DEFINE([HPUX], [], [Define if the system is HPUX.])
7062     ;;
7064   mingw32)
7065     AC_DEFINE([DOS_NT], [])
7066     AC_DEFINE([WINDOWSNT], [1], [Define if compiling for native MS Windows.])
7067     if test "x$ac_enable_checking" != "x" ; then
7068       AC_DEFINE([EMACSDEBUG], [1],
7069         [Define to 1 to enable w32 debug facilities.])
7070     fi
7071     ;;
7073   solaris)
7074     AC_DEFINE([USG], [])
7075     AC_DEFINE([USG5_4], [])
7076     AC_DEFINE([SOLARIS2], [], [Define if the system is Solaris.])
7077     ;;
7079   unixware)
7080     AC_DEFINE([USG], [])
7081     AC_DEFINE([USG5_4], [])
7082     ;;
7084   haiku)
7085     AC_DEFINE([HAIKU], [], [Define if the system is Haiku.])
7086     ;;
7087 esac
7089 AC_SYS_POSIX_TERMIOS
7090 if test $ac_cv_sys_posix_termios = yes; then
7091   AC_CHECK_SIZEOF([speed_t], [], [#include <termios.h>])
7092   dnl on Haiku, and possibly other platforms, speed_t is defined to
7093   dnl unsigned char, even when speeds greater than 200 baud are
7094   dnl defined.
7096   if test ${ac_cv_sizeof_speed_t} -lt 2; then
7097     AC_DEFINE([HAVE_TINY_SPEED_T], [1],
7098         [Define to 1 if speed_t has some sort of nonsensically tiny size.])
7099   fi
7102 AC_CACHE_CHECK([for usable FIONREAD], [emacs_cv_usable_FIONREAD],
7103   [case $opsys in
7104      aix4-2 | nacl)
7105        dnl BUILD 9008 - FIONREAD problem still exists in X-Windows.
7106        emacs_cv_usable_FIONREAD=no
7107        ;;
7109      mingw32)
7110        emacs_cv_usable_FIONREAD=yes
7111        ;;
7113      *)
7114        AC_COMPILE_IFELSE(
7115          [AC_LANG_PROGRAM([[#include <sys/types.h>
7116                             #include <sys/ioctl.h>
7117                             #ifdef USG5_4
7118                             # include <sys/filio.h>
7119                             #endif
7120                           ]],
7121                           [[int foo = ioctl (0, FIONREAD, &foo);]])],
7122          [emacs_cv_usable_FIONREAD=yes],
7123          [emacs_cv_usable_FIONREAD=no])
7124        ;;
7125    esac])
7126 if test $emacs_cv_usable_FIONREAD = yes; then
7127   AC_DEFINE([USABLE_FIONREAD], [1], [Define to 1 if FIONREAD is usable.])
7129   if test $emacs_broken_SIGIO = no; then
7130     AC_CACHE_CHECK([for usable SIGIO], [emacs_cv_usable_SIGIO],
7131       [AC_COMPILE_IFELSE(
7132          [AC_LANG_PROGRAM([[#include <fcntl.h>
7133                             #include <signal.h>
7134                           ]],
7135                           [[int foo = SIGIO | F_SETFL | FASYNC;]])],
7136          [emacs_cv_usable_SIGIO=yes],
7137          [emacs_cv_usable_SIGIO=no])],
7138       [emacs_cv_usable_SIGIO=yes],
7139       [emacs_cv_usable_SIGIO=no])
7140     if test $emacs_cv_usable_SIGIO = yes; then
7141       AC_DEFINE([USABLE_SIGIO], [1], [Define to 1 if SIGIO is usable.])
7142     fi
7143   fi
7145   if test $emacs_broken_SIGIO = no && test $emacs_cv_usable_SIGIO = no; then
7146     AC_CACHE_CHECK([for usable SIGPOLL], [emacs_cv_usable_SIGPOLL],
7147       [AC_COMPILE_IFELSE(
7148          [AC_LANG_PROGRAM([[#include <fcntl.h>
7149                             #include <signal.h>
7150                           ]],
7151                           [[int foo = SIGPOLL | F_SETFL;]])],
7152          [emacs_cv_usable_SIGPOLL=yes],
7153          [emacs_cv_usable_SIGPOLL=no])],
7154       [emacs_cv_usable_SIGPOLL=yes],
7155       [emacs_cv_usable_SIGPOLL=no])
7156     if test $emacs_cv_usable_SIGPOLL = yes; then
7157       AC_DEFINE([USABLE_SIGPOLL], [1], [Define to 1 if SIGPOLL is usable but SIGIO is not.])
7158     fi
7159   fi
7162 case $opsys in
7163   hpux11)
7164     dnl It works to open the pty's tty in the parent (Emacs), then
7165     dnl close and reopen it in the child.
7166     AC_DEFINE([USG_SUBTTY_WORKS], [1], [Define for USG systems where it
7167       works to open a pty's tty in the parent process, then close and
7168       reopen it in the child.])
7169     ;;
7171   solaris)
7172     AC_DEFINE([_STRUCTURED_PROC], [1], [Needed for system_process_attributes
7173       on Solaris.])
7174     ;;
7175 esac
7177 # Set up the CFLAGS for real compilation, so we can substitute it.
7178 CFLAGS="$REAL_CFLAGS"
7179 CPPFLAGS="$REAL_CPPFLAGS"
7180 LIBS="$REAL_LIBS"
7182 ## Hack to detect a buggy GCC version.
7183 if test "$GCC" = yes && \
7184    $CC --version 2> /dev/null | grep 'gcc.* 4.5.0' >/dev/null; then
7185   case $CFLAGS in
7186     *-fno-optimize-sibling-calls*) ;;
7187     *-O@<:@23@:>@*)
7188       AC_MSG_ERROR([GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS.]);;
7189   esac
7192 version=$PACKAGE_VERSION
7194 copyright="Copyright (C) 2024 Free Software Foundation, Inc."
7195 AC_DEFINE_UNQUOTED([COPYRIGHT], ["$copyright"],
7196   [Short copyright string for this version of Emacs.])
7197 AC_SUBST([copyright])
7199 ### Specify what sort of things we'll be editing into Makefile and config.h.
7200 ### Use configuration here uncanonicalized to avoid exceeding size limits.
7201 AC_SUBST([version])
7202 AC_SUBST([configuration])
7203 ## Unused?
7204 AC_SUBST([canonical])
7205 AC_SUBST([srcdir])
7206 AC_SUBST([prefix])
7207 AC_SUBST([exec_prefix])
7208 AC_SUBST([bindir])
7209 AC_SUBST([datadir])
7210 AC_SUBST([gsettingsschemadir])
7211 AC_SUBST([sharedstatedir])
7212 AC_SUBST([libexecdir])
7213 AC_SUBST([mandir])
7214 AC_SUBST([infodir])
7215 AC_SUBST([lispdirrel])
7216 AC_SUBST([lispdir])
7217 AC_SUBST([standardlisppath])
7218 AC_SUBST([locallisppath])
7219 AC_SUBST([lisppath])
7220 AC_SUBST([x_default_search_path])
7221 AC_SUBST([etcdir])
7222 AC_SUBST([archlibdir])
7223 AC_SUBST([etcdocdir])
7224 AC_SUBST([bitmapdir])
7225 AC_SUBST([gamedir])
7226 AC_SUBST([gameuser])
7227 AC_SUBST([gamegroup])
7228 ## FIXME? Nothing uses @LD_SWITCH_X_SITE@.
7229 ## src/Makefile.in did add LD_SWITCH_X_SITE (as a cpp define) to the
7230 ## end of LIBX_BASE, but nothing ever set it.
7231 AC_SUBST([LD_SWITCH_X_SITE])
7232 AC_SUBST([C_SWITCH_X_SITE])
7233 AC_SUBST([GNUSTEP_CFLAGS])
7234 AC_SUBST([CFLAGS])
7235 ## Used in lwlib/Makefile.in.
7236 AC_SUBST([X_TOOLKIT_TYPE])
7237 AC_SUBST([ns_appdir])
7238 AC_SUBST([ns_appbindir])
7239 AC_SUBST([ns_applibexecdir])
7240 AC_SUBST([ns_applibdir])
7241 AC_SUBST([ns_appresdir])
7242 AC_SUBST([ns_appsrc])
7243 AC_SUBST([GNU_OBJC_CFLAGS])
7244 AC_SUBST([OTHER_FILES])
7246 if test -n "${term_header}"; then
7247     AC_DEFINE_UNQUOTED([TERM_HEADER], ["${term_header}"],
7248         [Define to the header for the built-in window system.])
7251 AC_DEFINE_UNQUOTED([EMACS_CONFIGURATION],  ["${canonical}"],
7252                    [Define to the canonical Emacs configuration name.])
7253 AC_DEFINE_UNQUOTED([EMACS_CONFIG_OPTIONS], "${emacs_config_options}",
7254                    [Define to the options passed to configure.])
7256 XMENU_OBJ=
7257 XOBJ=
7258 FONT_OBJ=
7259 if test "${HAVE_X_WINDOWS}" = "yes" ; then
7260   AC_DEFINE([HAVE_X_WINDOWS], [1],
7261             [Define to 1 if you want to use the X window system.])
7262   XMENU_OBJ=xmenu.o
7263   XOBJ="xterm.o xfns.o xselect.o xrdb.o xsmfns.o xsettings.o"
7264   FONT_OBJ=xfont.o
7265   if test "$HAVE_CAIRO" = "yes"; then
7266     FONT_OBJ="$FONT_OBJ ftfont.o ftcrfont.o"
7267   elif test "$HAVE_XFT" = "yes"; then
7268     FONT_OBJ="$FONT_OBJ ftfont.o xftfont.o"
7269   elif test "$HAVE_FREETYPE" = "yes"; then
7270     FONT_OBJ="$FONT_OBJ ftfont.o"
7271   fi
7274 if test "${window_system}" = "pgtk"; then
7275    FONT_OBJ="ftfont.o ftcrfont.o"
7278 if test "${HAVE_BE_APP}" = "yes" ; then
7279   if test "${HAVE_CAIRO}" = "yes"; then
7280     FONT_OBJ="$FONT_OBJ ftfont.o ftcrfont.o"
7281   fi
7284 if test "${HAVE_HARFBUZZ}" = "yes" ; then
7285   FONT_OBJ="$FONT_OBJ hbfont.o"
7287 AC_SUBST([FONT_OBJ])
7288 AC_SUBST([XMENU_OBJ])
7289 AC_SUBST([XOBJ])
7290 AC_SUBST([FONT_OBJ])
7292 WIDGET_OBJ=
7293 MOTIF_LIBW=
7294 if test "${USE_X_TOOLKIT}" != "none" ; then
7295   WIDGET_OBJ=widget.o
7296   AC_DEFINE([USE_X_TOOLKIT], [1], [Define to 1 if using an X toolkit.])
7297   if test "${USE_X_TOOLKIT}" = "LUCID"; then
7298     AC_DEFINE([USE_LUCID], [1], [Define to 1 if using the Lucid X toolkit.])
7299   elif test "${USE_X_TOOLKIT}" = "MOTIF"; then
7300     AC_DEFINE([USE_MOTIF], [1], [Define to 1 if using the Motif X toolkit.])
7301     MOTIF_LIBW=-lXm
7302     case "$opsys" in
7303       gnu-linux)
7304         ## Paul Abrahams <abrahams at equinox.shaysnet.com> says this is needed.
7305         MOTIF_LIBW="$MOTIF_LIBW -lXpm"
7306         ;;
7308       unixware)
7309         ## Richard Anthony Ryan <ryanr at ellingtn.ftc.nrcs.usda.gov>
7310         ## says -lXimp is needed in UNIX_SV ... 4.2 1.1.2.
7311         MOTIF_LIBW="MOTIF_LIBW -lXimp"
7312         ;;
7314       aix4-2)
7315         ## olson@mcs.anl.gov says -li18n is needed by -lXm.
7316         MOTIF_LIBW="$MOTIF_LIBW -li18n"
7317         ;;
7318     esac
7319     MOTIF_LIBW="$MOTIF_LIBW $LIBXP"
7320   fi
7322 AC_SUBST([WIDGET_OBJ])
7324 TOOLKIT_LIBW=
7325 case "$USE_X_TOOLKIT" in
7326   MOTIF) TOOLKIT_LIBW="$MOTIF_LIBW" ;;
7327   LUCID) TOOLKIT_LIBW="$LUCID_LIBW" ;;
7328   none) test "x$HAVE_GTK" = "xyes" && TOOLKIT_LIBW="$GTK_LIBS" ;;
7329 esac
7330 if test "$HAVE_XWIDGETS" = "yes"; then
7331   TOOLKIT_LIBW="$TOOLKIT_LIBW -lXcomposite"
7333 AC_SUBST([TOOLKIT_LIBW])
7335 if test "${opsys}" != "mingw32"; then
7336   if test "$USE_X_TOOLKIT" = "none"; then
7337     LIBXT_OTHER="\$(LIBXSM)"
7338   else
7339     LIBXT_OTHER="\$(LIBXMU) -lXt \$(LIBXTR6) -lXext"
7340   fi
7342 AC_SUBST([LIBXT_OTHER])
7344 if test "${HAVE_X11}" = "yes" ; then
7345   AC_DEFINE([HAVE_X11], [1],
7346             [Define to 1 if you want to use version 11 of X windows.])
7347   LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
7348 else
7349   LIBX_OTHER=
7351 AC_SUBST([LIBX_OTHER])
7353 HAVE_OLDXMENU=no
7354 if test "$HAVE_GTK" = yes || test "$HAVE_X11" != yes; then
7355   LIBXMENU=
7356 elif test "$USE_X_TOOLKIT" = none; then
7357   HAVE_OLDXMENU=yes
7358   LIBXMENU='$(oldXMenudir)/libXMenu11.a'
7359   AUTODEPEND_PARENTS="$AUTODEPEND_PARENTS oldXMenu"
7360 else
7361   LIBXMENU='$(lwlibdir)/liblw.a'
7362   AUTODEPEND_PARENTS="$AUTODEPEND_PARENTS lwlib"
7364 AC_SUBST([LIBXMENU])
7366 AC_CACHE_CHECK([for struct alignment],
7367   [emacs_cv_struct_alignment],
7368   [AC_COMPILE_IFELSE(
7369      [AC_LANG_PROGRAM([[#include <stddef.h>
7370                         struct s { char c; } __attribute__ ((aligned (8)));
7371                         struct t { char c; struct s s; };
7372                         char verify[offsetof (struct t, s) == 8 ? 1 : -1];
7373                       ]])],
7374      [emacs_cv_struct_alignment=yes],
7375      [emacs_cv_struct_alignment=no])])
7376 if test "$emacs_cv_struct_alignment" = yes; then
7377   AC_DEFINE([HAVE_STRUCT_ATTRIBUTE_ALIGNED], [1],
7378     [Define to 1 if 'struct __attribute__ ((aligned (N)))' aligns the
7379      structure to an N-byte boundary.])
7382 AC_C_RESTRICT
7383 AC_C_TYPEOF
7385 AC_CACHE_CHECK([for statement expressions],
7386   [emacs_cv_statement_expressions],
7387   [AC_COMPILE_IFELSE(
7388      [AC_LANG_PROGRAM([], [[return ({ int x = 5; x-x; });]])],
7389      [emacs_cv_statement_expressions=yes],
7390      [emacs_cv_statement_expressions=no])])
7391 if test "$emacs_cv_statement_expressions" = yes; then
7392   AC_DEFINE([HAVE_STATEMENT_EXPRESSIONS], [1],
7393     [Define to 1 if statement expressions work.])
7396 if test "${GNU_MALLOC}" = "yes" ; then
7397   AC_DEFINE([GNU_MALLOC], [1],
7398             [Define to 1 if you want to use the GNU memory allocator.])
7401 RALLOC_OBJ=
7402 if test "${REL_ALLOC}" = "yes" ; then
7403   AC_DEFINE([REL_ALLOC], [1],
7404             [Define REL_ALLOC if you want to use the relocating allocator for
7405              buffer space.])
7407   test "$system_malloc" != "yes" && RALLOC_OBJ=ralloc.o
7409 AC_SUBST([RALLOC_OBJ])
7411 if test "$opsys" = "cygwin"; then
7412   CYGWIN_OBJ="cygw32.o"
7413   ## Cygwin differs because of its unexec().
7414   PRE_ALLOC_OBJ=
7415   POST_ALLOC_OBJ=lastfile.o
7416 elif test "$opsys" = "mingw32"; then
7417   CYGWIN_OBJ=
7418   PRE_ALLOC_OBJ=
7419   POST_ALLOC_OBJ=lastfile.o
7420 else
7421   CYGWIN_OBJ=
7422   PRE_ALLOC_OBJ=lastfile.o
7423   POST_ALLOC_OBJ=
7425 AC_SUBST([CYGWIN_OBJ])
7426 AC_SUBST([PRE_ALLOC_OBJ])
7427 AC_SUBST([POST_ALLOC_OBJ])
7429 dnl Call this 'FORTIFY_SOUR' so that it sorts before the 'FORTIFY_SOURCE'
7430 dnl verbatim defined above.  The tricky name is apropos, as this hack
7431 dnl makes Fortify go sour!
7432 AH_VERBATIM([FORTIFY_SOUR],
7433 [/* Without the following workaround, Emacs runs slowly on OS X 10.8.
7434    The workaround disables some useful run-time checking, so it
7435    should be conditional to the platforms with the performance bug.
7436    Perhaps Apple will fix this some day; also see m4/extern-inline.m4.  */
7437 #if defined __APPLE__ && defined __GNUC__
7438 # ifndef _DONT_USE_CTYPE_INLINE_
7439 #  define _DONT_USE_CTYPE_INLINE_
7440 # endif
7441 # ifndef _FORTIFY_SOURCE
7442 #  define _FORTIFY_SOURCE 0
7443 # endif
7444 #endif
7447 # If user asks to omit features, disable optional features that gnulib
7448 # might otherwise enable.
7449 if test "$with_features" = no && test "$enable_acl" != yes; then
7450   enable_acl=no
7453 # Configure gnulib.  Although this does not affect CFLAGS or LIBS permanently.
7454 # it temporarily reverts them to their pre-pkg-config values,
7455 # because gnulib needs to work with both src (which uses the
7456 # pkg-config stuff) and lib-src (which does not).  For example, gnulib
7457 # may need to determine whether CLOCK_TIME_LIB should contain -lrt,
7458 # and it therefore needs to run in an environment where LIBS does not
7459 # already contain -lrt merely because 'pkg-config --libs' printed '-lrt'
7460 # for some package unrelated to lib-src.
7461 SAVE_CFLAGS=$CFLAGS
7462 SAVE_LIBS=$LIBS
7463 CFLAGS=$pre_PKG_CONFIG_CFLAGS
7464 LIBS="$LIB_PTHREAD $pre_PKG_CONFIG_LIBS"
7465 gl_ASSERT_NO_GNULIB_POSIXCHECK
7466 gl_ASSERT_NO_GNULIB_TESTS
7467 gl_EEMALLOC
7468 gl_INIT
7469 CFLAGS=$SAVE_CFLAGS
7470 LIBS=$SAVE_LIBS
7472 # Set up libgmp on Android.  Make sure to override what gnulib has
7473 # found.
7474 LIBGMP_CFLAGS=
7475 if test "$REALLY_ANDROID" = "yes" && test "$with_libgmp" != "no"; then
7476   HAVE_LIBGMP=no
7477   ndk_SEARCH_MODULE([libgmp], [LIBGMP], [HAVE_LIBGMP=yes])
7479   if test "$HAVE_LIBGMP" = "yes"; then
7480     SAVE_CFLAGS="$CFLAGS"
7481     CFLAGS="$CFLAGS $LIBGMP_CFLAGS"
7482     unset ac_cv_header_gmp_h
7483     unset ac_cv_header_gmp_gmp_h
7484     AC_CHECK_HEADERS([gmp.h gmp/gmp.h], [break])
7485     CFLAGS="$SAVE_CFLAGS"
7486     GL_GENERATE_GMP_H=
7487     GL_GENERATE_GMP_H_CONDITION=
7488     GL_GENERATE_GMP_GMP_H=
7489     GL_GENERATE_GMP_GMP_H_CONDITION=
7490     GL_GENERATE_MINI_GMP_H=
7491     GL_GENERATE_MINI_GMP_H_CONDITION=
7493     if test "$ac_cv_header_gmp_h" != "no" \
7494        || test "$ac_cv_header_gmp_gmp_h" != "no"; then
7495        HAVE_LIBGMP=yes
7496        GL_GENERATE_GMP_H=false
7497        LIBGMP="$LIBGMP_LIBS"
7498        GMP_H=
7499     fi
7500   fi
7502 AC_SUBST([LIBGMP_CFLAGS])
7504 # timer_getoverrun needs the same library as timer_settime
7505 OLD_LIBS=$LIBS
7506 LIBS="$LIB_TIMER_TIME $LIBS"
7507 AC_CHECK_FUNCS([timer_getoverrun])
7508 LIBS=$OLD_LIBS
7510 if test "${opsys}" = "mingw32"; then
7511   CPPFLAGS="$CPPFLAGS -DUSE_CRT_DLL=1 -I \${abs_top_srcdir}/nt/inc"
7512   # Remove unneeded switches from the value of CC that goes to Makefiles
7513   CC=`AS_ECHO(["$CC"]) | sed -e "s,$GCC_TEST_OPTIONS,,"`
7516 case "$opsys" in
7517   aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;;
7519   cygwin) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000" ;;
7521   darwin)
7522    if test "$HAVE_NS" = "yes"; then
7523      libs_nsgui="-framework AppKit"
7524      if test "$NS_IMPL_COCOA" = "yes"; then
7525         libs_nsgui="$libs_nsgui -framework IOKit -framework Carbon \
7526                     -framework IOSurface -framework QuartzCore"
7527         if test "$emacs_cv_macosx_12_0" = "yes"; then
7528           libs_nsgui="$libs_nsgui -framework UniformTypeIdentifiers"
7529         fi
7530      fi
7531    else
7532      libs_nsgui=
7533    fi
7534    LD_SWITCH_SYSTEM_TEMACS=$libs_nsgui
7535    ## The -headerpad option tells ld (see man page) to leave room at the
7536    ## end of the header for adding load commands.  Needed for dumping.
7537    ## 0x1000 is enough for roughly 52 load commands on the x86_64
7538    ## architecture (where they are 78 bytes each). The actual number of
7539    ## load commands added is not consistent but normally ranges from
7540    ## about 14 to about 34. Setting it high gets us plenty of slop and
7541    ## only costs about 1.5K of wasted binary space.
7542    headerpad_extra=1000
7543    if test "$with_unexec" = yes; then
7544      LD_SWITCH_SYSTEM_TEMACS="-fno-pie $LD_SWITCH_SYSTEM_TEMACS -Xlinker -headerpad -Xlinker $headerpad_extra"
7545    fi
7547    ## This is here because src/Makefile.in did some extra fiddling around
7548    ## with LD_SWITCH_SYSTEM.  It seems cleaner to put this in
7549    ## LD_SWITCH_SYSTEM_TEMACS instead,
7550    test "x$LD_SWITCH_SYSTEM" = "x" && test "x$GCC" != "xyes" && \
7551      LD_SWITCH_SYSTEM_TEMACS="-X $LD_SWITCH_SYSTEM_TEMACS"
7552    ;;
7554   ## LD_SWITCH_X_SITE_RPATH is a -rpath option saying where to
7555   ## find X at run-time.
7556   ## When handled by cpp, this was in LD_SWITCH_SYSTEM.  However, at the
7557   ## point where configure sourced the s/*.h file, LD_SWITCH_X_SITE_RPATH
7558   ## had not yet been defined and was expanded to null.  Hence LD_SWITCH_SYSTEM
7559   ## had different values in configure (in ac_link) and src/Makefile.in.
7560   ## It seems clearer therefore to put this piece in LD_SWITCH_SYSTEM_TEMACS.
7561   gnu*) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_RPATH)" ;;
7563   mingw32)
7564    ## Is it any better under MinGW64 to relocate emacs into higher addresses?
7565    ## If the values of -image-base are modified, the corresponding
7566    ## values of DEFAULT_IMAGE_BASE in w32fns.c should be kept in sync.
7567    case "$canonical" in
7568      x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x400000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
7569      *) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
7570    esac
7571    ## If they want unexec, disable Windows ASLR for the Emacs binary
7572    if test "$with_dumping" = "unexec"; then
7573       case "$canonical" in
7574         x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS -Wl,-disable-dynamicbase -Wl,-disable-high-entropy-va -Wl,-default-image-base-low" ;;
7575         *) LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS -Wl,-disable-dynamicbase" ;;
7576       esac
7577    fi
7578    ;;
7580   *) LD_SWITCH_SYSTEM_TEMACS= ;;
7581 esac
7583 # -no-pie or -nopie fixes a temacs segfault on Gentoo, OpenBSD,
7584 # Ubuntu, and other systems with "hardened" GCC configurations for
7585 # some reason (Bug#18784).  We don't know why this works, but not
7586 # segfaulting is better than segfaulting.  Use ac_c_werror_flag=yes
7587 # when trying the option, otherwise clang keeps warning that it does
7588 # not understand it, and pre-4.6 GCC has a similar problem
7589 # (Bug#20338).  Prefer -no-pie to -nopie, as -no-pie is the
7590 # spelling used by GCC 6.1.0 and later (Bug#24682).
7591 AC_CACHE_CHECK(
7592   [for $CC option to disable position independent executables],
7593   [emacs_cv_prog_cc_no_pie],
7594   [if test $with_unexec = no; then
7595      emacs_cv_prog_cc_no_pie='not needed'
7596    else
7597      emacs_save_c_werror_flag=$ac_c_werror_flag
7598      emacs_save_LDFLAGS=$LDFLAGS
7599      ac_c_werror_flag=yes
7600      for emacs_cv_prog_cc_no_pie in -no-pie -nopie no; do
7601        test $emacs_cv_prog_cc_no_pie = no && break
7602        LDFLAGS="$emacs_save_LDFLAGS $emacs_cv_prog_cc_no_pie"
7603        AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [break])
7604      done
7605      ac_c_werror_flag=$emacs_save_c_werror_flag
7606      LDFLAGS=$emacs_save_LDFLAGS
7607    fi])
7608 case $emacs_cv_prog_cc_no_pie in
7609   -*)
7610     LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS $emacs_cv_prog_cc_no_pie"
7611     ;;
7612 esac
7614 if test x$ac_enable_profiling != x ; then
7615   case $opsys in
7616     *freebsd | gnu-linux) ;;
7617     *) LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS -pg" ;;
7618   esac
7621 LD_SWITCH_SYSTEM_TEMACS="$LDFLAGS_NOCOMBRELOC $LD_SWITCH_SYSTEM_TEMACS"
7623 AC_SUBST([LD_SWITCH_SYSTEM_TEMACS])
7625 ## Common for all window systems
7626 if test "$window_system" != "none"; then
7627   AC_DEFINE([HAVE_WINDOW_SYSTEM], [1], [Define if you have a window system.])
7628   AC_DEFINE([POLL_FOR_INPUT], [1],
7629     [Define if you poll periodically to detect C-g.])
7630   WINDOW_SYSTEM_OBJ="fontset.o fringe.o image.o"
7632   if test "$window_system" = "x11" || test "$REALLY_ANDROID" = "yes"; then
7633     AC_DEFINE([HAVE_TEXT_CONVERSION], [1],
7634       [Define if the window system has text conversion support.])
7635     WINDOW_SYSTEM_OBJ="$WINDOW_SYSTEM_OBJ textconv.o"
7636   fi
7639 AC_SUBST([WINDOW_SYSTEM_OBJ])
7641 # Some systems have MB_CUR_MAX defined to a call to
7642 # __ctype_get_mb_cur_max, but do not have __ctype_get_mb_cur_max in
7643 # libc.  Check for that situation and define MB_CUR_MAX to something
7644 # sane.
7646 AC_CHECK_FUNC([__ctype_get_mb_cur_max])
7648 AC_CACHE_CHECK([whether MB_CUR_MAX is defined to function that won't link],
7649   [emacs_cv_broken_mb_cur_max],
7650   [AC_EGREP_CPP(__ctype_get_mb_cur_max, [
7651 #include <stdlib.h>
7652 #ifndef MB_CUR_MAX
7653 #define MB_CUR_MAX -1
7654 #endif
7655 static int foo = MB_CUR_MAX;
7656 ], [AS_IF([test "$ac_cv_func___ctype_get_mb_cur_max" = "yes"],
7657      [emacs_cv_broken_mb_cur_max=no],
7658      [emacs_cv_broken_mb_cur_max=yes])],
7659   [emacs_cv_broken_mb_cur_max=no])])
7661 AS_IF([test "$emacs_cv_broken_mb_cur_max" = "yes"],
7662  # Define this to 4, which is right for Android.
7663  [AS_CASE([$opsys], [android],
7664    [AC_DEFINE([REPLACEMENT_MB_CUR_MAX], [4],
7665       [Define to MB_CUR_MAX if stdlib.h is broken.])],
7666    [AC_MSG_ERROR([MB_CUR_MAX does not work on your system.
7667 Please modify configure.ac to set an appropriate value, then
7668 send your change to bug-gnu-emacs@gnu.org])])])
7670 AH_TOP([/* GNU Emacs site configuration template file.
7672 Copyright (C) 1988-2024 Free Software Foundation, Inc.
7674 This file is part of GNU Emacs.
7676 GNU Emacs is free software: you can redistribute it and/or modify
7677 it under the terms of the GNU General Public License as published by
7678 the Free Software Foundation, either version 3 of the License, or (at
7679 your option) any later version.
7681 GNU Emacs is distributed in the hope that it will be useful,
7682 but WITHOUT ANY WARRANTY; without even the implied warranty of
7683 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7684 GNU General Public License for more details.
7686 You should have received a copy of the GNU General Public License
7687 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
7690 /* No code in Emacs #includes config.h twice, but some bits of code
7691    intended to work with other packages as well (like gmalloc.c)
7692    think they can include it as many times as they like.  */
7693 #ifndef EMACS_CONFIG_H
7694 #define EMACS_CONFIG_H
7695 ])dnl
7697 AH_BOTTOM([#include <conf_post.h>
7699 #endif /* EMACS_CONFIG_H */
7702 Local Variables:
7703 mode: c
7704 End:
7706 ])dnl
7708 #### Report on what we decided to do.
7709 #### Report GTK as a toolkit, even if it doesn't use Xt.
7710 #### It makes printing result more understandable as using GTK sets
7711 #### toolkit_scroll_bars to yes by default.
7712 if test "${HAVE_GTK}" = "yes"; then
7713   USE_X_TOOLKIT="$USE_GTK_TOOLKIT"
7716 if test $USE_ACL -ne 0; then
7717   ACL_SUMMARY="yes"
7718   test "$LIB_ACL" && ACL_SUMMARY="$ACL_SUMMARY $LIB_ACL"
7719   test "$LIB_XATTR" && ACL_SUMMARY="$ACL_SUMMARY $LIB_XATTR"
7720 else
7721   ACL_SUMMARY=no
7724 if test -z "$GMP_H"; then
7725   HAVE_GMP=yes
7726 else
7727   HAVE_GMP=no
7730 emacs_standard_dirs='Standard dirs'
7731 AS_ECHO(["
7732 Configured for '${canonical}'.
7734   Where should the build process find the source code?    ${srcdir}
7735   What compiler should emacs be built with?               ${CC} ${CFLAGS}
7736   Should Emacs use the GNU version of malloc?             ${GNU_MALLOC}${GNU_MALLOC_reason}
7737   Should Emacs use a relocating allocator for buffers?    ${REL_ALLOC}
7738   Should Emacs use mmap(2) for buffer allocation?         $use_mmap_for_buffers
7739   What window system should Emacs use?                    ${window_system}
7740   What toolkit should Emacs use?                          ${USE_X_TOOLKIT}
7741   Where do we find X Windows header files?                ${x_includes:-$emacs_standard_dirs}
7742   Where do we find X Windows libraries?                   ${x_libraries:-$emacs_standard_dirs}"])
7744 #### Please respect alphabetical ordering when making additions.
7745 optsep=
7746 emacs_config_features=
7747 for opt in ACL BE_APP CAIRO DBUS FREETYPE GCONF GIF GLIB GMP GNUTLS GPM GSETTINGS \
7748  HARFBUZZ IMAGEMAGICK JPEG LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 \
7749  M17N_FLT MODULES NATIVE_COMP NOTIFY NS OLDXMENU PDUMPER PGTK PNG RSVG SECCOMP \
7750  SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER \
7751  UNEXEC WEBP X11 XAW3D XDBE XFT XIM XINPUT2 XPM XWIDGETS X_TOOLKIT \
7752  ZLIB; do
7754     case $opt in
7755       PDUMPER) val=${with_pdumper} ;;
7756       UNEXEC) val=${with_unexec} ;;
7757       GLIB) val=${emacs_cv_links_glib} ;;
7758       NOTIFY|ACL) eval val=\${${opt}_SUMMARY} ;;
7759       TOOLKIT_SCROLL_BARS|X_TOOLKIT) eval val=\${USE_$opt} ;;
7760       THREADS) val=${threads_enabled} ;;
7761       *) eval val=\${HAVE_$opt} ;;
7762     esac
7763     case x$val in
7764       xno|xnone|x) continue ;;
7765     esac
7766     case $opt in
7767       X_TOOLKIT)
7768         case $val in
7769           GTK*|LUCID|MOTIF) opt=$val ;;
7770           *) continue ;;
7771         esac
7772       ;;
7773       NOTIFY)
7774         case $val in
7775           *lkqueue*) opt="$opt LIBKQUEUE" ;;
7776           *kqueue*) opt="$opt KQUEUE" ;;
7777           *inotify*) opt="$opt INOTIFY" ;;
7778           *gfile*) opt="$opt GFILENOTIFY" ;;
7779           *w32*) opt="$opt W32NOTIFY" ;;
7780         esac
7781       ;;
7782     esac
7783     AS_VAR_APPEND([emacs_config_features], ["$optsep$opt"])
7784     optsep=' '
7785 done
7786 AC_DEFINE_UNQUOTED([EMACS_CONFIG_FEATURES], ["${emacs_config_features}"],
7787   [Summary of some of the main features enabled by configure.])
7789 # This is just a printable representation of the shared user ID.
7790 android_shared_user=
7791 AS_IF([test -n "$with_shared_user_id"],[android_shared_user="($with_shared_user_id)"])
7793 AS_ECHO(["  Does Emacs use -lXaw3d?                                 ${HAVE_XAW3D}
7794   Is Emacs being built for Android?                       ${ANDROID} ${android_shared_user}
7795   Does Emacs use the X Double Buffer Extension?           ${HAVE_XDBE}
7796   Does Emacs use -lXpm?                                   ${HAVE_XPM}
7797   Does Emacs use -ljpeg?                                  ${HAVE_JPEG}
7798   Does Emacs use -ltiff?                                  ${HAVE_TIFF}
7799   Does Emacs use a gif library?                           ${HAVE_GIF} $LIBGIF
7800   Does Emacs use a png library?                           ${HAVE_PNG} $LIBPNG
7801   Does Emacs use -lrsvg-2?                                ${HAVE_RSVG}
7802   Does Emacs use -lwebp?                                  ${HAVE_WEBP}
7803   Does Emacs use -lsqlite3?                               ${HAVE_SQLITE3}
7804   Does Emacs use cairo?                                   ${HAVE_CAIRO}
7805   Does Emacs use -llcms2?                                 ${HAVE_LCMS2}
7806   Does Emacs use imagemagick?                             ${HAVE_IMAGEMAGICK}
7807   Does Emacs use native APIs for images?                  ${NATIVE_IMAGE_API}
7808   Does Emacs support sound?                               ${HAVE_SOUND}
7809   Does Emacs use -lgpm?                                   ${HAVE_GPM}
7810   Does Emacs use -ldbus?                                  ${HAVE_DBUS}
7811   Does Emacs use -lgconf?                                 ${HAVE_GCONF}
7812   Does Emacs use GSettings?                               ${HAVE_GSETTINGS}
7813   Does Emacs use a file notification library?             ${NOTIFY_SUMMARY}
7814   Does Emacs use access control lists?                    ${ACL_SUMMARY}
7815   Does Emacs use -lselinux?                               ${HAVE_LIBSELINUX}
7816   Does Emacs use -lgnutls?                                ${HAVE_GNUTLS}
7817   Does Emacs use -lxml2?                                  ${HAVE_LIBXML2}
7818   Does Emacs use -lfreetype?                              ${HAVE_FREETYPE}
7819   Does Emacs use HarfBuzz?                                ${HAVE_HARFBUZZ}
7820   Does Emacs use -lm17n-flt?                              ${HAVE_M17N_FLT}
7821   Does Emacs use -lotf?                                   ${HAVE_LIBOTF}
7822   Does Emacs use -lxft?                                   ${HAVE_XFT}
7823   Does Emacs use -lsystemd?                               ${HAVE_LIBSYSTEMD}
7824   Does Emacs use -ltree-sitter?                           ${HAVE_TREE_SITTER}
7825   Does Emacs use the GMP library?                         ${HAVE_GMP}
7826   Does Emacs directly use zlib?                           ${HAVE_ZLIB}
7827   Does Emacs have dynamic modules support?                ${HAVE_MODULES}
7828   Does Emacs use toolkit scroll bars?                     ${USE_TOOLKIT_SCROLL_BARS}
7829   Does Emacs support Xwidgets?                            ${HAVE_XWIDGETS}
7830   Does Emacs have threading support in lisp?              ${threads_enabled}
7831   Does Emacs support the portable dumper?                 ${with_pdumper}
7832   Does Emacs support legacy unexec dumping?               ${with_unexec}
7833   Which dumping strategy does Emacs use?                  ${with_dumping}
7834   Does Emacs have native lisp compiler?                   ${HAVE_NATIVE_COMP}
7835   Does Emacs use version 2 of the X Input Extension?      ${HAVE_XINPUT2}
7836   Does Emacs generate a smaller-size Japanese dictionary? ${with_small_ja_dic}
7839 if test -n "${EMACSDATA}"; then
7840    AS_ECHO(["  Environment variable EMACSDATA set to:                  $EMACSDATA"])
7842 if test -n "${EMACSDOC}"; then
7843    AS_ECHO(["  Environment variable EMACSDOC set to:                   $EMACSDOC"])
7846 echo
7848 if test "$HAVE_NS" = "yes"; then
7849    echo
7850    AS_ECHO(["Run '${MAKE-make}' to build Emacs, then run 'src/emacs' to test it.
7851 Run '${MAKE-make} install' in order to build an application bundle.
7852 The application will go to nextstep/Emacs.app and can be run or moved
7853 from there."])
7854    if test "$EN_NS_SELF_CONTAINED" = "yes"; then
7855       echo "The application will be fully self-contained."
7856     else
7857       AS_ECHO(["The lisp resources for the application will be installed under ${prefix}.
7858 You may need to run \"${MAKE-make} install\" with sudo.  The application will fail
7859 to run if these resources are not installed."])
7860    fi
7861    echo
7864 case $opsys,$emacs_uname_r in
7865   cygwin,1.5.*)
7866     AC_MSG_WARN([[building Emacs on Cygwin 1.5 is not supported.]])
7867            echo
7868            ;;
7869   cygwin,3.0.[[0-7]]'('* | cygwin,3.1.[[0-2]]'('*)
7870     AC_DEFINE([HAVE_CYGWIN_O_PATH_BUG], [1],
7871       [Define to 1 if opening a FIFO, socket, or symlink with O_PATH is buggy.]);;
7872 esac
7874 # Remove any trailing slashes in these variables.
7875 case $prefix in
7876   */) prefix=`AS_DIRNAME(["$prefix."])`;;
7877 esac
7878 case $exec_prefix in
7879   */) exec_prefix=`AS_DIRNAME(["$exec_prefix."])`;;
7880 esac
7882 if test "$HAVE_NS" = "yes"; then
7883   if test "$NS_IMPL_GNUSTEP" = yes; then
7884     AC_CONFIG_FILES([nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist:nextstep/templates/Info-gnustep.plist.in \
7885       nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop:nextstep/templates/Emacs.desktop.in])
7886     ns_check_file=Resources/Info-gnustep.plist
7887   else
7888     AC_CONFIG_FILES([nextstep/Cocoa/Emacs.base/Contents/Info.plist:nextstep/templates/Info.plist.in \
7889       nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings:nextstep/templates/InfoPlist.strings.in])
7890     ns_check_file=Contents/Info.plist
7891   fi
7892   AC_SUBST([ns_check_file])
7895 AC_CONFIG_FILES([Makefile lib/gnulib.mk])
7897 dnl config.status treats $srcdir specially, so I think this is ok...
7898 ARCH_INDEPENDENT_CONFIG_FILES([$srcdir/doc/man/emacs.1])
7900 AC_CONFIG_FILES([lib/Makefile lib-src/Makefile oldXMenu/Makefile src/Makefile
7901                  lwlib/Makefile nextstep/Makefile nt/Makefile])
7902 ARCH_INDEPENDENT_CONFIG_FILES([doc/emacs/Makefile doc/misc/Makefile
7903                                doc/lispintro/Makefile doc/lispref/Makefile
7904                                lisp/Makefile leim/Makefile])
7906 SUBDIR_MAKEFILES="lib/Makefile lib-src/Makefile oldXMenu/Makefile src/Makefile lwlib/Makefile nextstep/Makefile nt/Makefile doc/emacs/Makefile doc/misc/Makefile doc/lispintro/Makefile doc/lispref/Makefile lisp/Makefile leim/Makefile"
7908 dnl The test/ directory is missing if './make-dist --no-tests' was used.
7909 opt_makefile=test/Makefile
7910 if test -f "$srcdir/$opt_makefile.in"; then
7911   SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
7912   dnl Again, it's best not to use a variable.  Though you can add
7913   dnl ", [], [opt_makefile='$opt_makefile']" and it should work.
7914   ARCH_INDEPENDENT_CONFIG_FILES([test/Makefile])
7915   ARCH_INDEPENDENT_CONFIG_FILES([test/manual/noverlay/Makefile])
7917 opt_makefile=test/infra/Makefile
7918 if test -f "$srcdir/$opt_makefile.in"; then
7919   SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
7920   dnl Again, it's best not to use a variable.  Though you can add
7921   dnl ", [], [opt_makefile='$opt_makefile']" and it should work.
7922   ARCH_INDEPENDENT_CONFIG_FILES([test/infra/Makefile])
7925 if test "$ANDROID" = "yes"; then
7926   SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES java/Makefile cross/Makefile"
7929 dnl The admin/ directory used to be excluded from tarfiles.
7930 if test -d $srcdir/admin; then
7931   SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES admin/charsets/Makefile admin/unidata/Makefile admin/grammars/Makefile"
7932   ARCH_INDEPENDENT_CONFIG_FILES([admin/charsets/Makefile])
7933   ARCH_INDEPENDENT_CONFIG_FILES([admin/unidata/Makefile])
7934   ARCH_INDEPENDENT_CONFIG_FILES([admin/grammars/Makefile])
7935 fi                              dnl -d admin
7938 SUBDIR_MAKEFILES_IN=`echo " ${SUBDIR_MAKEFILES}" | sed -e 's| | $(srcdir)/|g' -e 's|Makefile|Makefile.in|g'`
7940 AC_SUBST([SUBDIR_MAKEFILES_IN])
7942 SMALL_JA_DIC=$with_small_ja_dic
7943 AC_SUBST([SMALL_JA_DIC])
7945 dnl The following commands are run on the build system when building
7946 dnl Emacs.
7948 if test "$XCONFIGURE" != "android"; then
7949   dnl You might wonder (I did) why epaths.h is generated by running
7950   dnl make, rather than just letting configure generate it from
7951   dnl epaths.in.  One reason is that the various paths are not fully
7952   dnl expanded (see above); e.g.,
7953   dnl gamedir='${localstatedir}/games/emacs'.  Secondly, the GNU
7954   dnl Coding standards require that one should be able to run 'make
7955   dnl prefix=/some/where/else' and override the values set by
7956   dnl configure.  This also explains the 'move-if-change' test and the
7957   dnl use of force in the 'epaths-force' rule in Makefile.in.
7958   AC_CONFIG_COMMANDS([src/epaths.h], [
7959   if test "${opsys}" = "mingw32"; then
7960     ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-w32
7961   elif test "$HAVE_NS" = "yes" && test "$EN_NS_SELF_CONTAINED" = "yes"; then
7962     ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-ns-self-contained
7963   else
7964     ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force
7965   fi || AC_MSG_ERROR(['src/epaths.h' could not be made.])
7966   ], [GCC="$GCC" CPPFLAGS="$CPPFLAGS" opsys="$opsys" HAVE_NS="$HAVE_NS"
7967       EN_NS_SELF_CONTAINED="$EN_NS_SELF_CONTAINED"])
7969   dnl NB we have to cheat and use the ac_... version because abs_top_srcdir
7970   dnl is not yet set, sigh.  Or we could use ../$srcdir/src/.gdbinit,
7971   dnl or a symlink?
7972   AC_CONFIG_COMMANDS([src/.gdbinit], [
7973   if test ! -f src/.gdbinit && test -f "$srcdir/src/.gdbinit"; then
7974     AS_ECHO(["source $ac_abs_top_srcdir/src/.gdbinit"]) > src/.gdbinit
7975   fi
7976   ])
7978   dnl Perhaps this would be better named doc-emacs-emacsver.texi?
7979   dnl See comments for etc-refcards-emacsver.tex.
7980   dnl Since we get a doc/emacs directory generated anyway, for the Makefile,
7981   dnl it is not quite the same.  But we are generating in $srcdir.
7982   AC_CONFIG_COMMANDS([doc/emacs/emacsver.texi], [
7983   ${MAKE-make} -s --no-print-directory -C doc/emacs doc-emacsver || \
7984   AC_MSG_ERROR(['doc/emacs/emacsver.texi' could not be made.])
7985   ])
7987   dnl If we give this the more natural name, etc/refcards/emacsver.texi,
7988   dnl then a directory etc/refcards is created in the build directory,
7989   dnl which is probably harmless, but confusing (in out-of-tree builds).
7990   dnl (If we were to generate etc/refcards/Makefile, this might change.)
7991   dnl It is really $srcdir/etc/refcards/emacsver.tex that we generate.
7992   AC_CONFIG_COMMANDS([etc-refcards-emacsver.tex], [
7993   ${MAKE-make} -s MAKEFILE_NAME=do-not-make-Makefile etc-emacsver || \
7994   AC_MSG_ERROR(['etc/refcards/emacsver.tex' could not be made.])
7995   ])
7997   if test $AUTO_DEPEND = yes; then
7998      for dir in $AUTODEPEND_PARENTS; do
7999        AS_MKDIR_P([$dir/deps])
8000        AS_MKDIR_P([cross/$dir/deps])
8001      done
8002   fi
8003   if $gl_gnulib_enabled_dynarray || $gl_gnulib_enabled_scratch_buffer; then
8004     AS_MKDIR_P([lib/malloc])
8005     AS_MKDIR_P([cross/lib/malloc])
8006     if test $AUTO_DEPEND = yes; then
8007       AS_MKDIR_P([lib/deps/malloc])
8008       AS_MKDIR_P([cross/lib/deps/malloc])
8009     fi
8010   fi
8012   dnl Make cross/lib, which various Makefiles in cross expect to
8013   dnl always exist.
8014   AS_MKDIR_P([cross/lib])
8015   AS_MKDIR_P([cross/lib/malloc])
8016   AS_MKDIR_P([cross/lib/sys])
8017   AS_MKDIR_P([cross/lib-src])
8019   dnl Make cross/etc; this directory will hold the documentation file
8020   dnl holding doc strings for Android specific C files that aren't
8021   dnl built during the initial compilation of Emacs for the build
8022   dnl machine.
8023   AS_MKDIR_P([cross/etc])
8025   AS_IF([test "x$with_android" != "xno"], [
8026     dnl Link gnulib files to cross/lib as well.  af_alg.h and
8027     dnl lib/save-cwd.h are copied manually from gnulib, and as such
8028     dnl aren't specified in gl_FILE_LIST.
8029     emacs_files='gl_FILE_LIST lib/af_alg.h lib/save-cwd.h'
8030     dnl These files are specific to Emacs.
8031     emacs_files="$emacs_files lib/fingerprint.c lib/fingerprint.h \
8032                    lib/save-cwd.c lib/openat-die.c lib/save-cwd.c \
8033                    lib/min-max.h"
8034     for file in $emacs_files; do
8035       AS_IF([expr "X${file}J" : "Xlib/.*[[ch]]J" >/dev/null],
8036         [AS_IF([test -f "$srcdir/$file"],
8037           [AC_CONFIG_LINKS([cross/$file:$file])])])
8038     done])
8041 # Make java/Makefile
8042 ARCH_INDEPENDENT_CONFIG_FILES([java/Makefile])
8043 ARCH_INDEPENDENT_CONFIG_FILES([cross/Makefile])
8045 # Make java/AndroidManifest.xml
8046 ARCH_INDEPENDENT_CONFIG_FILES([java/AndroidManifest.xml])
8048 # Make ndk-build Makefiles.  This is only done inside the recursive
8049 # configure.
8050 ndk_CONFIG_FILES
8052 AC_OUTPUT
8054 if test ! "$with_mailutils"; then
8055   if test "$with_pop" = yes; then
8056     AC_MSG_WARN([This configuration installs a 'movemail' program
8057 that retrieves POP3 email via only insecure channels.
8058 To omit insecure POP3, you can use '$0 --without-pop'.])
8059   elif test "$with_pop" = no-by-default; then
8060     AC_MSG_WARN([This configuration installs a 'movemail' program
8061 that does not retrieve POP3 email.  By default, Emacs 25 and earlier
8062 installed a 'movemail' program that retrieved POP3 email via only
8063 insecure channels, a practice that is no longer recommended but that
8064 you can continue to support by using '$0 --with-pop'.])
8065   fi
8067   case $opsys in
8068     mingw32)
8069       # Don't suggest GNU Mailutils, as it hasn't been ported.
8070       ;;
8071     *)
8072       emacs_fix_movemail="use '$0 --with-mailutils'"
8073       case `(movemail --version) 2>/dev/null` in
8074         *Mailutils*) ;;
8075         *) emacs_fix_movemail="install GNU Mailutils
8076 <https://mailutils.org> and $emacs_fix_movemail";;
8077       esac
8078       AC_MSG_NOTICE([You might want to $emacs_fix_movemail.]);;
8079   esac
8082 if test "${HAVE_XFT}" = yes; then
8083   AC_MSG_WARN([This configuration uses libXft, which has a number of
8084     font rendering issues, and is being considered for removal in the
8085     next release of Emacs.  Please consider using Cairo graphics +
8086     HarfBuzz text shaping instead (they are auto-detected if the
8087     relevant development headers are installed).])
8090 if test "${HAVE_CAIRO}" = "yes" && test "${HAVE_HARFBUZZ}" = no; then
8091   AC_MSG_WARN([This configuration uses the Cairo graphics library,
8092     but not the HarfBuzz font shaping library (minimum version $harfbuzz_required_ver).
8093     We recommend the use of HarfBuzz when using Cairo, please install
8094     appropriate HarfBuzz development packages.])
8097 # Let plain 'make' work.
8098 test "$MAKE" = make || test -f makefile || cat >makefile <<EOF
8099 .POSIX:
8100 MAKE = $MAKE
8101 all:
8102         \$(MAKE) -f Makefile \$?
8103 .DEFAULT:
8104         \$(MAKE) -f Makefile \$<