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