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