Improve documentation of etags-related features
[emacs.git] / configure.ac
blobd294412dc4a8d56373e9a6c4baa1c1bd4665b168
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-2017 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 <http://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, 26.0.50, bug-gnu-emacs@gnu.org)
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 # FIXME: The default options '--without-mailutils --with-pop' result
236 # in a movemail implementation that supports only unencrypted POP3
237 # connections.  Encrypted connections should be the 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 OPTION_DEFAULT_ON([pop],
255   [don't support POP mail retrieval with movemail (--without-pop or
256    --with-mailutils is recommended, as movemail POP is insecure)])
257 if test "$with_pop" = yes; then
258    AC_DEFINE(MAIL_USE_POP)
260 AH_TEMPLATE(MAIL_USE_POP, [Define to support POP mail retrieval.])dnl
262 OPTION_DEFAULT_OFF([kerberos],[support Kerberos-authenticated POP])
263 if test "$with_kerberos" != no; then
264    AC_DEFINE(KERBEROS)
266 AH_TEMPLATE(KERBEROS,
267             [Define to support Kerberos-authenticated POP mail retrieval.])dnl
269 OPTION_DEFAULT_OFF([kerberos5],[support Kerberos version 5 authenticated POP])
270 if test "${with_kerberos5}" != no; then
271   if test "${with_kerberos}" = no; then
272     with_kerberos=yes
273     AC_DEFINE(KERBEROS)
274   fi
275   AC_DEFINE(KERBEROS5, 1, [Define to use Kerberos 5 instead of Kerberos 4.])
278 OPTION_DEFAULT_OFF([hesiod],[support Hesiod to get the POP server host])
279 dnl FIXME hesiod support may not be present, so it seems like an error
280 dnl to define, or at least use, this unconditionally.
281 if test "$with_hesiod" != no; then
282   AC_DEFINE(HESIOD, 1, [Define to support using a Hesiod database to find the POP server.])
285 OPTION_DEFAULT_OFF([mail-unlink],[unlink, rather than empty, mail spool after reading])
286 if test "$with_mail_unlink" != no; then
287    AC_DEFINE(MAIL_UNLINK_SPOOL, 1, [Define to unlink, rather than empty, mail spool after reading.])
290 AC_ARG_WITH([mailhost],[AS_HELP_STRING([--with-mailhost=HOSTNAME],
291     [string giving default POP mail host])],
292     AC_DEFINE_UNQUOTED(MAILHOST, ["$withval"], [String giving fallback POP mail host.]))
294 AC_ARG_WITH([sound],[AS_HELP_STRING([--with-sound=VALUE],
295   [compile with sound support (VALUE one of: yes, alsa, oss, bsd-ossaudio, no;
296 default yes).  Only for GNU/Linux, FreeBSD, NetBSD, MinGW, Cygwin.])],
297   [ case "${withval}" in
298       yes|no|alsa|oss|bsd-ossaudio) val=$withval ;;
299       *) AC_MSG_ERROR(['--with-sound=$withval' is invalid;
300 this option's value should be 'yes', 'no', 'alsa', 'oss', or 'bsd-ossaudio'.])
301       ;;
302     esac
303     with_sound=$val
304   ],
305   [with_sound=$with_features])
307 dnl FIXME currently it is not the last.
308 dnl This should be the last --with option, because --with-x is
309 dnl added later on when we find the file name of X, and it's best to
310 dnl keep them together visually.
311 AC_ARG_WITH([x-toolkit],[AS_HELP_STRING([--with-x-toolkit=KIT],
312  [use an X toolkit (KIT one of: yes or gtk, gtk2, gtk3, lucid or athena, motif, no)])],
313 [         case "${withval}" in
314             y | ye | yes )      val=gtk ;;
315             n | no )            val=no  ;;
316             l | lu | luc | luci | lucid )       val=lucid ;;
317             a | at | ath | athe | athen | athena )      val=athena ;;
318             m | mo | mot | moti | motif )       val=motif ;;
319             g | gt | gtk  )     val=gtk ;;
320             gtk2  )     val=gtk2 ;;
321             gtk3  )     val=gtk3 ;;
322             * )
323 AC_MSG_ERROR(['--with-x-toolkit=$withval' is invalid;
324 this option's value should be 'yes', 'no', 'lucid', 'athena', 'motif', 'gtk',
325 'gtk2' or 'gtk3'.  'yes' and 'gtk' are synonyms.
326 'athena' and 'lucid' are synonyms.])
327             ;;
328           esac
329           with_x_toolkit=$val
332 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])
333 if test "$with_wide_int" = yes; then
334   AC_DEFINE([WIDE_EMACS_INT], 1, [Use long long for EMACS_INT if available.])
337 dnl _ON results in a '--without' option in the --help output, so
338 dnl the help text should refer to "don't compile", etc.
339 with_xpm_set=${with_xpm+set}
340 OPTION_DEFAULT_ON([xpm],[don't compile with XPM image support])
341 OPTION_DEFAULT_ON([jpeg],[don't compile with JPEG image support])
342 OPTION_DEFAULT_ON([tiff],[don't compile with TIFF image support])
343 OPTION_DEFAULT_ON([gif],[don't compile with GIF image support])
344 OPTION_DEFAULT_ON([png],[don't compile with PNG image support])
345 OPTION_DEFAULT_ON([rsvg],[don't compile with SVG image support])
346 OPTION_DEFAULT_ON([libsystemd],[don't compile with libsystemd support])
347 OPTION_DEFAULT_OFF([cairo],[compile with Cairo drawing (experimental)])
348 OPTION_DEFAULT_ON([xml2],[don't compile with XML parsing support])
349 OPTION_DEFAULT_ON([imagemagick],[don't compile with ImageMagick image support])
351 OPTION_DEFAULT_ON([xft],[don't use XFT for anti aliased fonts])
352 OPTION_DEFAULT_ON([libotf],[don't use libotf for OpenType font support])
353 OPTION_DEFAULT_ON([m17n-flt],[don't use m17n-flt for text shaping])
355 OPTION_DEFAULT_ON([toolkit-scroll-bars],[don't use Motif or Xaw3d scroll bars])
356 OPTION_DEFAULT_ON([xaw3d],[don't use Xaw3d])
357 OPTION_DEFAULT_ON([xim],[don't use X11 XIM])
358 AC_ARG_WITH([ns],[AS_HELP_STRING([--with-ns],
359 [use Nextstep (macOS Cocoa or GNUstep) windowing system.
360 On by default on macOS.])],[],[with_ns=maybe])
361 OPTION_DEFAULT_OFF([w32], [use native MS Windows GUI in a Cygwin build])
363 OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console])
364 OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support])
365 AC_ARG_WITH([gconf],[AS_HELP_STRING([--with-gconf],
366 [compile with Gconf support (Gsettings replaces this)])],[],[with_gconf=maybe])
367 OPTION_DEFAULT_ON([gsettings],[don't compile with GSettings support])
368 OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support])
369 OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support])
370 OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support])
371 OPTION_DEFAULT_OFF([modules],[compile with dynamic modules support])
372 OPTION_DEFAULT_ON([threads],[don't compile with elisp threading support])
374 AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB],
375  [use a file notification library (LIB one of: yes, inotify, kqueue, gfile, w32, no)])],
376  [ case "${withval}" in
377     y | ye | yes )      val=yes ;;
378     n | no )            val=no  ;;
379     i | in | ino | inot | inoti | inotif | inotify )    val=inotify ;;
380     k | kq | kqu | kque | kqueu | kqueue )      val=kqueue ;;
381     g | gf | gfi | gfil | gfile )       val=gfile ;;
382     w | w3 | w32 )      val=w32 ;;
383     * ) AC_MSG_ERROR(['--with-file-notification=$withval' is invalid;
384 this option's value should be 'yes', 'no', 'inotify', 'kqueue', 'gfile' or 'w32'.
385 'yes' is a synonym for 'w32' on MS-Windows, for 'no' on Nextstep,
386 otherwise for the first of 'inotify', 'kqueue' or 'gfile' that is usable.])
387     ;;
388    esac
389    with_file_notification=$val
390  ],
391  [with_file_notification=$with_features])
393 OPTION_DEFAULT_OFF([xwidgets],
394   [enable use of some gtk widgets in Emacs buffers (requires gtk3)])
396 ## For the times when you want to build Emacs but don't have
397 ## a suitable makeinfo, and can live without the manuals.
398 dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html
399 OPTION_DEFAULT_ON([makeinfo],[don't require makeinfo for building manuals])
401 ## Makefile.in needs the cache file name.
402 AC_SUBST(cache_file)
404 ## This is an option because I do not know if all info/man support
405 ## compressed files, nor how to test if they do so.
406 OPTION_DEFAULT_ON([compress-install],
407   [don't compress some files (.el, .info, etc.) when installing.  Equivalent to:
408 make GZIP_PROG= install])
410 AC_ARG_WITH(gameuser,dnl
411 [AS_HELP_STRING([--with-gameuser=USER_OR_GROUP],
412                 [user for shared game score files.
413                 An argument prefixed by ':' specifies a group instead.])])
414 gameuser=
415 gamegroup=
416 case ${with_gameuser} in
417   '' | no) ;;
418   yes) gamegroup=games ;;
419   :*) gamegroup=${with_gameuser#:} ;;
420   *) gameuser=${with_gameuser} ;;
421 esac
423 AC_ARG_WITH([gnustep-conf],dnl
424 [AS_HELP_STRING([--with-gnustep-conf=FILENAME],
425    [name of GNUstep configuration file to use on systems where the command
426     'gnustep-config' does not work; default $GNUSTEP_CONFIG_FILE, or
427     /etc/GNUstep/GNUstep.conf])])
428 test "X${with_gnustep_conf}" != X && test "${with_gnustep_conf}" != yes && \
429   GNUSTEP_CONFIG_FILE="${with_gnustep_conf}"
430 test "X$GNUSTEP_CONFIG_FILE" = "X" && \
431      GNUSTEP_CONFIG_FILE=/etc/GNUstep/GNUstep.conf
433 AC_ARG_ENABLE(ns-self-contained,
434 [AS_HELP_STRING([--disable-ns-self-contained],
435                 [disable self contained build under NeXTstep])],
436    EN_NS_SELF_CONTAINED=$enableval,
437    EN_NS_SELF_CONTAINED=yes)
439 locallisppathset=no
440 AC_ARG_ENABLE(locallisppath,
441 [AS_HELP_STRING([--enable-locallisppath=PATH],
442                 [directories Emacs should search for lisp files specific
443                  to this site])],
444 if test "${enableval}" = "no"; then
445   locallisppath=
446 elif test "${enableval}" != "yes"; then
447   locallisppath=${enableval} locallisppathset=yes
450 AC_ARG_ENABLE(checking,
451 [AS_HELP_STRING([--enable-checking@<:@=LIST@:>@],
452                 [enable expensive run-time checks.  With LIST,
453                  enable only specific categories of checks.
454                  Categories are: all,yes,no.
455                  Flags are: stringbytes, stringoverrun, stringfreelist,
456                  xmallocoverrun, conslist, glyphs])],
457 [ac_checking_flags="${enableval}"],[])
458 IFS="${IFS=     }"; ac_save_IFS="$IFS"; IFS="$IFS,"
459 for check in $ac_checking_flags
461         case $check in
462         # these set all the flags to specific states
463         yes)            ac_enable_checking=1 ;;
464         no)             ac_enable_checking= ;
465                         ac_gc_check_stringbytes= ;
466                         ac_gc_check_string_overrun= ;
467                         ac_gc_check_string_free_list= ;
468                         ac_xmalloc_overrun= ;
469                         ac_gc_check_cons_list= ;
470                         ac_glyphs_debug= ;;
471         all)            ac_enable_checking=1 ;
472                         ac_gc_check_stringbytes=1 ;
473                         ac_gc_check_string_overrun=1 ;
474                         ac_gc_check_string_free_list=1 ;
475                         ac_xmalloc_overrun=1 ;
476                         ac_gc_check_cons_list=1 ;
477                         ac_glyphs_debug=1 ;;
478         # these enable particular checks
479         stringbytes)    ac_gc_check_stringbytes=1 ;;
480         stringoverrun)  ac_gc_check_string_overrun=1 ;;
481         stringfreelist) ac_gc_check_string_free_list=1 ;;
482         xmallocoverrun) ac_xmalloc_overrun=1 ;;
483         conslist)       ac_gc_check_cons_list=1 ;;
484         glyphs)         ac_glyphs_debug=1 ;;
485         *)      AC_MSG_ERROR(unknown check category $check) ;;
486         esac
487 done
488 IFS="$ac_save_IFS"
490 if test x$ac_enable_checking != x ; then
491   AC_DEFINE(ENABLE_CHECKING, 1,
492 [Define to 1 if expensive run-time data type and consistency checks are enabled.])
494 if test x$ac_gc_check_stringbytes != x ; then
495   AC_DEFINE(GC_CHECK_STRING_BYTES, 1,
496 [Define this temporarily to hunt a bug.  If defined, the size of
497    strings is redundantly recorded in sdata structures so that it can
498    be compared to the sizes recorded in Lisp strings.])
500 if test x$ac_gc_check_string_overrun != x ; then
501   AC_DEFINE(GC_CHECK_STRING_OVERRUN, 1,
502 [Define this to check for short string overrun.])
504 if test x$ac_gc_check_string_free_list != x ; then
505   AC_DEFINE(GC_CHECK_STRING_FREE_LIST, 1,
506 [Define this to check the string free list.])
508 if test x$ac_xmalloc_overrun != x ; then
509   AC_DEFINE(XMALLOC_OVERRUN_CHECK, 1,
510 [Define this to check for malloc buffer overrun.])
512 if test x$ac_gc_check_cons_list != x ; then
513   AC_DEFINE(GC_CHECK_CONS_LIST, 1,
514 [Define this to check for errors in cons list.])
516 if test x$ac_glyphs_debug != x ; then
517   AC_DEFINE(GLYPH_DEBUG, 1,
518 [Define this to enable glyphs debugging code.])
521 dnl The name of this option is unfortunate.  It predates, and has no
522 dnl relation to, the "sampling-based elisp profiler" added in 24.3.
523 dnl Actually, it stops it working.
524 dnl http://lists.gnu.org/archive/html/emacs-devel/2012-11/msg00393.html
525 AC_ARG_ENABLE(profiling,
526 [AS_HELP_STRING([--enable-profiling],
527                 [build emacs with low-level, gprof profiling support.
528                 Mainly useful for debugging Emacs itself.  May not work on
529                 all platforms.  Stops profiler.el working.])],
530 [ac_enable_profiling="${enableval}"],[])
531 if test x$ac_enable_profiling != x ; then
532    PROFILING_CFLAGS="-DPROFILING=1 -pg"
533 else
534    PROFILING_CFLAGS=
536 AC_SUBST(PROFILING_CFLAGS)
538 AC_ARG_ENABLE(autodepend,
539 [AS_HELP_STRING([--enable-autodepend],
540                 [automatically generate dependencies to .h-files.
541                  Requires gcc, enabled if found.])],
542 [ac_enable_autodepend="${enableval}"],[ac_enable_autodepend=yes])
544 AC_ARG_ENABLE(gtk-deprecation-warnings,
545 [AS_HELP_STRING([--enable-gtk-deprecation-warnings],
546                 [Show Gtk+/Gdk deprecation warnings for Gtk+ >= 3.0])],
547 [ac_enable_gtk_deprecation_warnings="${enableval}"],[])
549 BUILD_DETAILS=
550 AC_ARG_ENABLE([build-details],
551   [AS_HELP_STRING([--disable-build-details],
552                   [Make the build more deterministic by omitting host
553                    names, time stamps, etc. from the output.])],
554   [test "$enableval" = no && BUILD_DETAILS=--no-build-details])
555 AC_SUBST([BUILD_DETAILS])
557 dnl This used to use changequote, but, apart from 'changequote is evil'
558 dnl per the autoconf manual, we can speed up autoconf somewhat by quoting
559 dnl the great gob of text.  Thus it's not processed for possible expansion.
560 dnl Just make sure the brackets remain balanced.
562 dnl Since Emacs can't find matching pairs of quotes, boundaries are
563 dnl indicated by comments.
564 dnl quotation begins
567 ### If you add support for a new configuration, add code to this
568 ### switch statement to recognize your configuration name and select
569 ### the appropriate opsys.
571 ### As far as handling version numbers on operating systems is
572 ### concerned, make sure things will fail in a fixable way.  If
573 ### /etc/MACHINES doesn't say anything about version numbers, be
574 ### prepared to handle anything reasonably.  If version numbers
575 ### matter, be sure /etc/MACHINES says something about it.
577 opsys='' unported=no
578 case "${canonical}" in
580   ## GNU/Linux and similar ports
581   *-*-linux* )
582     opsys=gnu-linux
583   ;;
585   ## FreeBSD ports
586   *-*-freebsd* )
587     opsys=freebsd
588   ;;
590   ## DragonFly ports
591   *-*-dragonfly* )
592     opsys=dragonfly
593   ;;
595   ## FreeBSD kernel + glibc based userland
596   *-*-kfreebsd*gnu* )
597     opsys=gnu-kfreebsd
598   ;;
600   ## NetBSD ports
601   *-*-netbsd* )
602     opsys=netbsd
603   ;;
605   ## OpenBSD ports
606   *-*-openbsd* | *-*-mirbsd* )
607     opsys=openbsd
608   ;;
610   ## Apple Darwin / macOS
611   *-apple-darwin* )
612     case "${canonical}" in
613       *-apple-darwin[0-9].*) unported=yes ;;
614       i[3456]86-* | x86_64-* )  ;;
615       * )            unported=yes ;;
616     esac
617     opsys=darwin
618     ## FIXME: Find a way to use Fink if available (Bug#11507).
619   ;;
621   ## Chromium Native Client
622   *-nacl )
623     opsys=nacl
624   ;;
626   ## Cygwin ports
627   *-*-cygwin )
628     opsys=cygwin
629   ;;
631   ## HP 9000 series 700 and 800, running HP/UX
632   hppa*-hp-hpux10.2* )
633     opsys=hpux10-20
634   ;;
635   hppa*-hp-hpux1[1-9]* )
636     opsys=hpux11
637     CFLAGS="-D_INCLUDE__STDC_A1_SOURCE $CFLAGS"
638   ;;
640   ## IBM machines
641   rs6000-ibm-aix4.[23]* )
642     opsys=aix4-2
643   ;;
644   powerpc-ibm-aix4.[23]*  )
645     opsys=aix4-2
646   ;;
647   rs6000-ibm-aix[56]* )
648     opsys=aix4-2
649   ;;
650   powerpc-ibm-aix[5-9]* | powerpc-ibm-aix[1-9][0-9]* )
651     opsys=aix4-2
652   ;;
654   ## Suns
655   *-sun-solaris* \
656     | i[3456]86-*-solaris2* | i[3456]86-*-sunos5* \
657     | x86_64-*-solaris2*    | x86_64-*-sunos5*)
658     case "${canonical}" in
659       i[3456]86-*-* )   ;;
660       amd64-*-*|x86_64-*-*) ;;
661       sparc* )          ;;
662       * )               unported=yes ;;
663     esac
664     case "${canonical}" in
665       *-sunos5.[1-9][0-9]* | *-solaris2.[1-9][0-9]* )
666                 opsys=sol2-10
667                 emacs_check_sunpro_c=yes
668                 ;;
669       *-sunos5.[1-5]* | *-solaris2.[1-5]* ) unported=yes ;;
670       ## Note that Emacs 23.1's NEWS said the following would be dropped.
671       *-sunos5.6* | *-solaris2.6* )
672                 opsys=sol2-6
673                 RANLIB="ar -ts"
674                 ;;
675       ## 5.7 EOL Aug 2008, 5.8 EOL Mar 2012.
676       *-sunos5.[7-9]* | *-solaris2.[7-9]* )
677                 opsys=sol2-6
678                 emacs_check_sunpro_c=yes
679                 ;;
680     esac
681     ## Watch out for a compiler that we know will not work.
682     case "${canonical}" in
683      *-solaris* | *-sunos5* )
684                 if [ "x$CC" = x/usr/ucb/cc ]; then
685                   ## /usr/ucb/cc doesn't work;
686                   ## we should find some other compiler that does work.
687                   unset CC
688                 fi
689                 ;;
690       *) ;;
691     esac
692   ;;
694   ## Intel 386 machines where we don't care about the manufacturer.
695   i[3456]86-*-* )
696     case "${canonical}" in
697       *-darwin* )               opsys=darwin ;;
698       *-mingw* )
699                 opsys=mingw32
700                 # MinGW overrides and adds some system headers in nt/inc.
701                 GCC_TEST_OPTIONS="-I $srcdir/nt/inc"
702                 ;;
703       *-sysv4.2uw* )            opsys=unixware ;;
704       *-sysv5uw* )              opsys=unixware ;;
705       *-sysv5OpenUNIX* )        opsys=unixware ;;
706       ## Otherwise, we'll fall through to the generic opsys code at the bottom.
707     esac
708   ;;
710   # MinGW64
711   x86_64-*-* )
712     case "${canonical}" in
713       *-mingw* )
714                 opsys=mingw32
715                 # MinGW overrides and adds some system headers in nt/inc.
716                 GCC_TEST_OPTIONS="-I $srcdir/nt/inc"
717                 ;;
718       ## Otherwise, we'll fall through to the generic opsys code at the bottom.
719     esac
720   ;;
722   * )
723     unported=yes
724   ;;
725 esac
727 ### If the code above didn't choose an operating system, just choose
728 ### an operating system based on the configuration name.  You really
729 ### only want to use this when you have no idea what the right
730 ### operating system is; if you know what operating systems a machine
731 ### runs, it's cleaner to make it explicit in the case statement
732 ### above.
733 if test x"${opsys}" = x; then
734   case "${canonical}" in
735     *-gnu* )                            opsys=gnu ;;
736     * )
737       unported=yes
738     ;;
739   esac
743 dnl quotation ends
745 if test $unported = yes; then
746   AC_MSG_ERROR([Emacs does not support '${canonical}' systems.
747 If you think it should, please send a report to ${PACKAGE_BUGREPORT}.
748 Check 'etc/MACHINES' for recognized configuration names.])
751 #### Choose a compiler.
753 dnl Don't bother to test for C89.
754 AC_DEFUN([_AC_PROG_CC_C89], [$2])
756 dnl Sets GCC=yes if using gcc.
757 AC_PROG_CC([gcc cc cl clang "$XCRUN gcc" "$XCRUN clang"])
758 if test -n "$XCRUN"; then
759   AC_CHECK_PROGS(AR, [ar "$XCRUN ar"])
760   test -n "$AR" && export AR
763 dnl Emacs needs C99 or later.
764 gl_PROG_CC_C99
766 AC_PROG_CC_C_O
768 if test x$GCC = xyes; then
769   test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
772 # Avoid gnulib's tests for -lcrypto, so that there's no static dependency on it.
773 AC_DEFUN([gl_CRYPTO_CHECK])
774 # Avoid gnulib's tests for HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW,
775 # as we don't use them.
776 AC_DEFUN([gl_FCNTL_O_FLAGS])
777 # Avoid gnulib's test for pthread_sigmask.
778 funcs=
779 for func in $ac_func_list; do
780   test $func = pthread_sigmask || AS_VAR_APPEND([funcs], [" $func"])
781 done
782 ac_func_list=$funcs
783 # Use the system putenv even if it lacks GNU features, as we don't need them,
784 # and the gnulib replacement runs afoul of a FreeBSD 10.1 bug; see Bug#19874.
785 AC_CHECK_FUNCS_ONCE([putenv])
786 AC_DEFUN([gl_FUNC_PUTENV],
787   [test "$ac_cv_func_putenv" = yes || REPLACE_PUTENV=1])
788 # Emacs does not use the wchar or wctype-h modules.
789 AC_DEFUN([gt_TYPE_WINT_T],
790   [GNULIB_OVERRIDES_WINT_T=0
791    AC_SUBST([GNULIB_OVERRIDES_WINT_T])])
793 # Initialize gnulib right after choosing the compiler.
794 dnl Amongst other things, this sets AR and ARFLAGS.
795 gl_EARLY
797 if test "$ac_test_CFLAGS" != set; then
798   # It's helpful to have C macros available to GDB, so prefer -g3 to -g
799   # if -g3 works and the user does not specify CFLAGS.
800   # This test must follow gl_EARLY; otherwise AC_LINK_IFELSE complains.
801   case $CFLAGS in
802     '-g')
803       emacs_g3_CFLAGS='-g3';;
804     '-g -O2')
805       emacs_g3_CFLAGS='-g3 -O2';;
806     *)
807       emacs_g3_CFLAGS='';;
808   esac
809   if test -n "$emacs_g3_CFLAGS"; then
810     emacs_save_CFLAGS=$CFLAGS
811     CFLAGS=$emacs_g3_CFLAGS
812     AC_CACHE_CHECK([whether $CC accepts $emacs_g3_CFLAGS],
813       [emacs_cv_prog_cc_g3],
814       [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
815          [emacs_cv_prog_cc_g3=yes],
816          [emacs_cv_prog_cc_g3=no])])
817     if test $emacs_cv_prog_cc_g3 != yes; then
818       CFLAGS=$emacs_save_CFLAGS
819     fi
820     if test $opsys = mingw32; then
821       CFLAGS="$CFLAGS -gdwarf-2"
822     fi
823   fi
825   case $CFLAGS in
826     *-O*) ;;
827     *)
828       # No optimization flag was inferred for this non-GCC compiler.
829       # Try -O.  This is needed for xlc on AIX; see Bug#14258.
830       emacs_save_CFLAGS=$CFLAGS
831       test -z "$CFLAGS" || CFLAGS="$CFLAGS "
832       CFLAGS=${CFLAGS}-O
833       AC_CACHE_CHECK([whether $CC accepts -O],
834         [emacs_cv_prog_cc_o],
835         [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
836            [emacs_cv_prog_cc_o=yes],
837            [emacs_cv_prog_cc_o=no])])
838       if test $emacs_cv_prog_cc_o != yes; then
839         CFLAGS=$emacs_save_CFLAGS
840       fi ;;
841   esac
844 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
845 # ---------------------------------------------------------------------------
846 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
847 # Otherwise, run RUN-IF-NOT-FOUND.
848 AC_DEFUN([gl_GCC_VERSION_IFELSE],
849   [AC_PREPROC_IFELSE(
850     [AC_LANG_PROGRAM(
851       [[
852 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
853 /* ok */
854 #else
855 # error "your version of gcc is older than $1.$2"
856 #endif
857       ]]),
858     ], [$3], [$4])
859   ]
862 AC_ARG_ENABLE([gcc-warnings],
863   [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
864                   [control generation of GCC warnings.  The TYPE 'yes'
865                    means to fail if any warnings are issued; 'warn-only'
866                    means issue warnings without failing (default for
867                    developer builds); 'no' means disable warnings
868                    (default for non-developer builds).])],
869   [case $enableval in
870      yes|no|warn-only) ;;
871      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
872    esac
873    gl_gcc_warnings=$enableval],
874   [# By default, use 'warn-only' if it looks like the invoker of 'configure'
875    # is a developer as opposed to a builder.  This is most likely true
876    # if GCC is recent enough and there is a .git directory or file;
877    # however, if there is also a .tarball-version file it is probably
878    # just a release imported into Git for patch management.
879    gl_gcc_warnings=no
880    if test -e "$srcdir"/.git && test ! -f "$srcdir"/.tarball-version; then
881      gl_GCC_VERSION_IFELSE([5], [3], [gl_gcc_warnings=warn-only])
882    fi])
884 AC_ARG_ENABLE([check-lisp-object-type],
885   [AS_HELP_STRING([--enable-check-lisp-object-type],
886      [Enable compile-time checks for the Lisp_Object data type,
887       which can catch some bugs during development.
888       The default is "no" if --enable-gcc-warnings is "no".])])
889 if test "${enable_check_lisp_object_type-$gl_gcc_warnings}" != "no"; then
890   AC_DEFINE([CHECK_LISP_OBJECT_TYPE], 1,
891     [Define to enable compile-time checks for the Lisp_Object data type.])
894 # clang is unduly picky about some things.
895 AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang],
896   [AC_COMPILE_IFELSE(
897      [AC_LANG_PROGRAM([[
898           #ifndef __clang__
899             error "not clang";
900           #endif
901         ]])],
902      [emacs_cv_clang=yes],
903      [emacs_cv_clang=no])])
905 WERROR_CFLAGS=
906 # When compiling with GCC, prefer -isystem to -I when including system
907 # include files, to avoid generating useless diagnostics for the files.
908 AS_IF([test $gl_gcc_warnings = no],
910   isystem='-I'
911   AS_IF([test "$emacs_cv_clang" = yes],
912    [
913      # Turn off some warnings if supported.
914      gl_WARN_ADD([-Wno-switch])
915      gl_WARN_ADD([-Wno-pointer-sign])
916      gl_WARN_ADD([-Wno-string-plus-int])
917      gl_WARN_ADD([-Wno-unknown-attributes])
918    ])
919  ],[
920   isystem='-isystem '
922   # This, $nw, is the list of warnings we disable.
923   nw=
925   case $with_x_toolkit in
926     lucid | athena | motif)
927        # Old toolkits mishandle 'const'.
928        nw="$nw -Wwrite-strings"
929        ;;
930   esac
931   AS_IF([test $gl_gcc_warnings = yes],
932     [WERROR_CFLAGS=-Werror])
934   nw="$nw -Wduplicated-branches"    # Too many false alarms
935   nw="$nw -Wformat-overflow=2"      # False alarms due to GCC bug 80776
936   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
937   nw="$nw -Woverlength-strings"     # Not a problem these days
938   nw="$nw -Wformat-nonliteral"      # we do this a lot
939   nw="$nw -Wvla"                    # Emacs uses <vla.h>.
940   nw="$nw -Wswitch-default"         # Too many warnings for now
941   nw="$nw -Wunused-const-variable=2" # lisp.h declares const objects.
942   nw="$nw -Winline"                 # OK to ignore 'inline'
943   nw="$nw -Wstrict-overflow"        # OK to optimize assuming that
944                                     # signed overflow has undefined behavior
945   nw="$nw -Wsync-nand"              # irrelevant here, and provokes ObjC warning
946   nw="$nw -Wunsafe-loop-optimizations" # OK to suppress unsafe optimizations
947   nw="$nw -Wbad-function-cast"      # These casts are no worse than others.
949   # Emacs doesn't care about shadowing; see
950   # <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
951   nw="$nw -Wshadow"
953   # Emacs's use of alloca inhibits protecting the stack.
954   nw="$nw -Wstack-protector"
956   # Emacs's use of partly-const functions such as Fgnutls_available_p
957   # make this option problematic.
958   nw="$nw -Wsuggest-attribute=const"
960   # Emacs's use of partly-pure functions such as CHECK_TYPE make this
961   # option problematic.
962   nw="$nw -Wsuggest-attribute=pure"
964   # This part is merely for shortening the command line,
965   # since -Wall implies -Wswitch.
966   nw="$nw -Wswitch"
968   # This part is merely for shortening the command line,
969   # since -Wno-FOO needs to be added below regardless.
970   nw="$nw -Wmissing-field-initializers"
971   nw="$nw -Woverride-init"
972   nw="$nw -Wtype-limits"
973   nw="$nw -Wunused-parameter"
975   if test "$emacs_cv_clang" = yes; then
976     nw="$nw -Wcast-align"
977     nw="$nw -Wdouble-promotion"
978     nw="$nw -Wmissing-braces"
979   fi
981   # These cause too much noise in the MinGW build
982   if test $opsys = mingw32; then
983     nw="$nw -Wpointer-sign"
984     nw="$nw -Wsuggest-attribute=format"
985   fi
987   gl_MANYWARN_ALL_GCC([ws])
988   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
989   for w in $ws; do
990     gl_WARN_ADD([$w])
991   done
992   gl_WARN_ADD([-Wredundant-decls])     # Prefer this, as we don't use Bison.
993   gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
994   gl_WARN_ADD([-Wno-override-init])    # More trouble than it is worth
995   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
996   gl_WARN_ADD([-Wno-type-limits])      # Too many warnings for now
997   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
998   gl_WARN_ADD([-Wno-format-nonliteral])
1000   # clang is unduly picky about braces.
1001   if test "$emacs_cv_clang" = yes; then
1002     gl_WARN_ADD([-Wno-missing-braces])
1003   fi
1005   # This causes too much noise in the MinGW build
1006   if test $opsys = mingw32; then
1007     gl_WARN_ADD([-Wno-pointer-sign])
1008   fi
1010   AC_DEFINE([GCC_LINT], [1], [Define to 1 if --enable-gcc-warnings.])
1011   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
1012   AH_VERBATIM([GNULIB_PORTCHECK_FORTIFY_SOURCE],
1013   [/* Enable compile-time and run-time bounds-checking, and some warnings,
1014       without upsetting glibc 2.15+. */
1015    #if (defined GNULIB_PORTCHECK && !defined _FORTIFY_SOURCE \
1016         && defined __OPTIMIZE__ && __OPTIMIZE__)
1017    # define _FORTIFY_SOURCE 2
1018    #endif
1019   ])
1020  ])
1022 # clang is picky about these regardless of whether
1023 # --enable-gcc-warnings is specified.
1024 if test "$emacs_cv_clang" = yes; then
1025   gl_WARN_ADD([-Wno-initializer-overrides])
1026   gl_WARN_ADD([-Wno-tautological-compare])
1027   gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
1030 # Use a slightly smaller set of warning options for lib/.
1032 nw="$nw -Wunused-macros"
1033 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
1035 AC_SUBST([WERROR_CFLAGS])
1036 AC_SUBST([GNULIB_WARN_CFLAGS])
1038 edit_cflags="
1039   s,///*,/,g
1040   s/^/ /
1041   s/ -I/ $isystem/g
1042   s/^ //
1045 AC_ARG_ENABLE(link-time-optimization,
1046 [AS_HELP_STRING([--enable-link-time-optimization],
1047                 [build with link-time optimization
1048                  (experimental; see INSTALL)])],
1049 if test "${enableval}" != "no"; then
1050    ac_lto_supported=no
1051    if test "$emacs_cv_clang" = yes; then
1052       AC_MSG_CHECKING([whether link-time optimization is supported by clang])
1053       GOLD_PLUGIN=`$CC -print-file-name=LLVMgold.so 2>/dev/null`
1054       if test -x "$GOLD_PLUGIN"; then
1055          LTO="-flto"
1056       fi
1057    elif test x$GCC = xyes; then
1058       AC_MSG_CHECKING([whether link-time optimization is supported by gcc])
1059       CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
1060       if test x$CPUS != x; then
1061          LTO="-flto=$CPUS"
1062       else
1063          LTO="-flto"
1064       fi
1065    else
1066       AC_MSG_ERROR([Link-time optimization is not supported with your compiler.])
1067    fi
1068    if test -z "$LTO"; then
1069       ac_lto_supported=no
1070    else
1071       old_CFLAGS=$CFLAGS
1072       CFLAGS="$CFLAGS $LTO"
1073       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1074          [ac_lto_supported=yes], [ac_lto_supported=no])
1075          CFLAGS="$old_CFLAGS"
1076    fi
1077    AC_MSG_RESULT([$ac_lto_supported])
1078    if test "$ac_lto_supported" = "yes"; then
1079       CFLAGS="$CFLAGS $LTO"
1080       if test "$emacs_cv_clang" = yes; then
1081          AC_MSG_WARN([Please read INSTALL before using link-time optimization with clang])
1082          # WARNING: 'ar --plugin ...' doesn't work without
1083          # command, so plugin name is appended to ARFLAGS.
1084          ARFLAGS="cru --plugin $GOLD_PLUGIN"
1085          RANLIB="$RANLIB --plugin $GOLD_PLUGIN"
1086       else
1087         dnl The following is needed for GCC 4.9.0.  The GCC 4.9.0 release notes
1088         dnl suggest that instead of -ffat-lto-objects we should use gcc-ar and
1089         dnl gcc-ranlib in place of ar and ranlib, but gcc-ar makes /usr/bin/ar
1090         dnl dump core on Fedora 20, so play it safe for now.
1091         gl_COMPILER_OPTION_IF([-ffat-lto-objects],
1092           [CFLAGS="$CFLAGS -ffat-lto-objects"])
1093       fi
1094    fi
1098 dnl Automake replacements.
1099 AC_DEFUN([AM_CONDITIONAL],
1100   [$2 && $1=1 || $1=
1101    AC_SUBST([$1])])
1103 dnl Prefer silent make output.  For verbose output, use
1104 dnl 'configure --disable-silent-rules' or 'make V=1' .
1105 dnl This code is adapted from Automake.
1106 dnl Although it can be simplified now that GNU Make is assumed,
1107 dnl the simplification hasn't been done yet.
1108 AC_ARG_ENABLE([silent-rules],
1109   [AS_HELP_STRING(
1110      [--disable-silent-rules],
1111      [verbose build output (undo: "make V=0")])])
1112 if test "$enable_silent_rules" = no; then
1113   AM_DEFAULT_VERBOSITY=1
1114 else
1115   AM_DEFAULT_VERBOSITY=0
1117 AM_V='$(V)'
1118 AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
1119 AC_SUBST([AM_V])
1120 AC_SUBST([AM_DEFAULT_V])
1121 AC_SUBST([AM_DEFAULT_VERBOSITY])
1123 dnl Some other nice autoconf tests.
1124 AC_PROG_INSTALL
1125 dnl These are commented out, since gl_EARLY and/or Autoconf already does them.
1126 dnl AC_PROG_MKDIR_P
1127 dnl if test "x$RANLIB" = x; then
1128 dnl   AC_PROG_RANLIB
1129 dnl fi
1132 dnl Sadly, AC_PROG_LN_S is too restrictive.  It also tests whether links
1133 dnl can be made to directories.  This is not relevant for our usage, and
1134 dnl excludes some cases that work fine for us.  Eg MS Windows or files
1135 dnl hosted on AFS, both examples where simple links work, but links to
1136 dnl directories fail.  We use a cut-down version instead.
1137 dnl AC_PROG_LN_S
1139 AC_CACHE_CHECK([command to symlink files in the same directory], [emacs_cv_ln_s_fileonly],
1140 [rm -f conf$$ conf$$.file
1142 emacs_cv_ln_s_fileonly='cp -p'
1144 dnl On MinGW, ensure we will call the MSYS /bin/ln.exe, not some
1145 dnl random program in the current directory.
1146 if (echo >conf$$.file) 2>/dev/null; then
1147   if ln -s conf$$.file conf$$ 2>/dev/null; then
1148     if test "$opsys" = "mingw32"; then
1149       emacs_cv_ln_s_fileonly='/bin/ln -s'
1150     else
1151       emacs_cv_ln_s_fileonly='ln -s'
1152     fi
1153   elif ln conf$$.file conf$$ 2>/dev/null; then
1154     if test "$opsys" = "mingw32"; then
1155       emacs_cv_ln_s_fileonly=/bin/ln
1156     else
1157       emacs_cv_ln_s_fileonly=ln
1158     fi
1159   fi
1162 rm -f conf$$ conf$$.file])
1163 LN_S_FILEONLY=$emacs_cv_ln_s_fileonly
1165 AC_SUBST(LN_S_FILEONLY)
1168 dnl AC_PROG_LN_S sets LN_S to 'cp -pR' for MinGW, on the premise that 'ln'
1169 dnl doesn't support links to directories, as in "ln file dir".  But that
1170 dnl use is non-portable, and OTOH MinGW wants to use hard links for Emacs
1171 dnl executables at "make install" time.
1172 dnl See http://lists.gnu.org/archive/html/emacs-devel/2013-04/msg00475.html
1173 dnl for more details.
1174 if test "$opsys" = "mingw32"; then
1175   LN_S="/bin/ln"
1178 dnl On some Debian versions, "install-info" prints irritating messages
1179 dnl "This is not dpkg install-info anymore, but GNU install-info"
1180 dnl if called via an absolute file name.
1181 dnl Use the entirely-identical-but-quieter ginstall-info instead if present.
1182 dnl Sadly some people may have an old ginstall-info installed on
1183 dnl non-Debian systems, so we can't use this.
1184 dnl AC_PATH_PROGS(INSTALL_INFO, [ginstall-info install-info], :,
1185 dnl   $PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin)
1187 AC_PATH_PROG(INSTALL_INFO, install-info, :,
1188   $PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin)
1189 dnl Don't use GZIP, which is used by gzip for additional parameters.
1190 AC_PATH_PROG(GZIP_PROG, gzip)
1192 test $with_compress_install != yes && test -n "$GZIP_PROG" && \
1193    GZIP_PROG=" # $GZIP_PROG # (disabled by configure --without-compress-install)"
1195 AC_CACHE_CHECK([for 'find' args to delete a file],
1196   [emacs_cv_find_delete],
1197   [if touch conftest.tmp && find conftest.tmp -delete 2>/dev/null &&
1198       test ! -f conftest.tmp
1199    then emacs_cv_find_delete="-delete"
1200    else emacs_cv_find_delete="-exec rm -f {} ';'"
1201    fi])
1202 FIND_DELETE=$emacs_cv_find_delete
1203 AC_SUBST([FIND_DELETE])
1205 PAXCTL_dumped=
1206 PAXCTL_notdumped=
1207 if test $opsys = gnu-linux; then
1208   if test "${SETFATTR+set}" != set; then
1209     AC_CACHE_CHECK([for setfattr],
1210       [emacs_cv_prog_setfattr],
1211       [touch conftest.tmp
1212        if (setfattr -n user.pax.flags conftest.tmp) >/dev/null 2>&1; then
1213          emacs_cv_prog_setfattr=yes
1214        else
1215          emacs_cv_prog_setfattr=no
1216        fi])
1217     if test "$emacs_cv_prog_setfattr" = yes; then
1218       PAXCTL_notdumped='$(SETFATTR) -n user.pax.flags -v er'
1219       SETFATTR=setfattr
1220     else
1221       SETFATTR=
1222     fi
1223     rm -f conftest.tmp
1224     AC_SUBST([SETFATTR])
1225   fi
1227 case $opsys,$PAXCTL_notdumped,$emacs_uname_r in
1228   gnu-linux,,* | netbsd,,[0-7].*)
1229     AC_PATH_PROG([PAXCTL], [paxctl], [],
1230       [$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin])
1231     if test -n "$PAXCTL"; then
1232       if test "$opsys" = netbsd; then
1233         PAXCTL_dumped='$(PAXCTL) +a'
1234         PAXCTL_notdumped=$PAXCTL_dumped
1235       else
1236         AC_MSG_CHECKING([whether binaries have a PT_PAX_FLAGS header])
1237         AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
1238           [if $PAXCTL -v conftest$EXEEXT >/dev/null 2>&1; then
1239              AC_MSG_RESULT([yes])
1240            else
1241              AC_MSG_RESULT([no])
1242              PAXCTL=
1243            fi])
1244         if test -n "$PAXCTL"; then
1245           PAXCTL_dumped='$(PAXCTL) -zex'
1246           PAXCTL_notdumped='$(PAXCTL) -r'
1247         fi
1248       fi
1249     fi;;
1250 esac
1251 AC_SUBST([PAXCTL_dumped])
1252 AC_SUBST([PAXCTL_notdumped])
1254 ## Require makeinfo >= 4.13 (last of the 4.x series) to build the manuals.
1255 if test "${MAKEINFO:=makeinfo}" != "no"; then
1256   case `($MAKEINFO --version) 2>/dev/null` in
1257     *' (GNU texinfo) '4.1[[3-9]]* | \
1258     *' (GNU texinfo) '[[5-9]]* | \
1259     *' (GNU texinfo) '[[1-9][0-9]]* ) ;;
1260     *) MAKEINFO=no;;
1261   esac
1264 ## Makeinfo is unusual.  For a released Emacs, the manuals are
1265 ## pre-built, and not deleted by the normal clean rules.  makeinfo is
1266 ## therefore in the category of "special tools" not normally required, which
1267 ## configure does not have to check for (eg autoconf itself).
1268 ## In a repository checkout on the other hand, the manuals are not included.
1269 ## So makeinfo is a requirement to build from the repository, and configure
1270 ## should test for it as it does for any other build requirement.
1271 ## We use the presence of $srcdir/info/emacs to distinguish a release,
1272 ## with pre-built manuals, from a repository checkout.
1273 HAVE_MAKEINFO=yes
1275 if test "$MAKEINFO" = "no"; then
1276   MAKEINFO=makeinfo
1277   if test "x${with_makeinfo}" = "xno"; then
1278     HAVE_MAKEINFO=no
1279   elif test ! -e "$srcdir/info/emacs" && test ! -e "$srcdir/info/emacs.info"; then
1280     AC_MSG_ERROR( [You do not seem to have makeinfo >= 4.13, and your
1281 source tree does not seem to have pre-built manuals in the 'info' directory.
1282 Either install a suitable version of makeinfo, or re-run configure
1283 with the '--without-makeinfo' option to build without the manuals.] )
1284   fi
1286 AC_SUBST([MAKEINFO])
1287 AC_SUBST(HAVE_MAKEINFO)
1289 if test $opsys = mingw32; then
1290    DOCMISC_W32=efaq-w32
1291 else
1292    DOCMISC_W32=
1294 AC_SUBST(DOCMISC_W32)
1296 dnl Add our options to ac_link now, after it is set up.
1298 if test x$GCC = xyes; then
1299   test "x$GCC_LINK_TEST_OPTIONS" != x && \
1300     ac_link="$ac_link $GCC_LINK_TEST_OPTIONS"
1301 else
1302   test "x$NON_GCC_LINK_TEST_OPTIONS" != x && \
1303     ac_link="$ac_link $NON_GCC_LINK_TEST_OPTIONS"
1306 dnl We need -znocombreloc if we're using a relatively recent GNU ld.
1307 dnl If we can link with the flag, it shouldn't do any harm anyhow.
1308 dnl Treat GCC specially since it just gives a non-fatal 'unrecognized option'
1309 dnl if not built to support GNU ld.
1311 dnl For a long time, -znocombreloc was added to LDFLAGS rather than
1312 dnl LD_SWITCH_SYSTEM_TEMACS.  That is:
1313 dnl * inappropriate, as LDFLAGS is a user option but this is essential.
1314 dnl   Eg "make LDFLAGS=... all" could run into problems,
1315 dnl   http://bugs.debian.org/684788
1316 dnl * unnecessary, since temacs is the only thing that actually needs it.
1317 dnl   Indeed this is where it was originally, prior to:
1318 dnl   http://lists.gnu.org/archive/html/emacs-pretest-bug/2004-03/msg00170.html
1319 if test x$GCC = xyes; then
1320   LDFLAGS_NOCOMBRELOC="-Wl,-znocombreloc"
1321 else
1322   LDFLAGS_NOCOMBRELOC="-znocombreloc"
1325 AC_CACHE_CHECK([for -znocombreloc], [emacs_cv_znocombreloc],
1326 [late_LDFLAGS="$LDFLAGS"
1327 LDFLAGS="$LDFLAGS $LDFLAGS_NOCOMBRELOC"
1329 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
1330   [emacs_cv_znocombreloc=yes], [emacs_cv_znocombreloc=no])
1332 LDFLAGS="$late_LDFLAGS"])
1334 if test x$emacs_cv_znocombreloc = xno; then
1335   LDFLAGS_NOCOMBRELOC=
1339 AC_CACHE_CHECK([whether addresses are sanitized],
1340   [emacs_cv_sanitize_address],
1341   [AC_COMPILE_IFELSE(
1342      [AC_LANG_PROGRAM(
1343         [[#ifndef __has_feature
1344           #define __has_feature(f) 0
1345           #endif
1346           #if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
1347           #else
1348            error "Addresses are not sanitized.";
1349           #endif
1350         ]])],
1351      [emacs_cv_sanitize_address=yes],
1352      [emacs_cv_sanitize_address=no])])
1354 dnl The function dump-emacs will not be defined and temacs will do
1355 dnl (load "loadup") automatically unless told otherwise.
1356 test "x$CANNOT_DUMP" = "x" && CANNOT_DUMP=no
1357 case "$opsys" in
1358   nacl) CANNOT_DUMP=yes ;;
1359 esac
1361 if test "$CANNOT_DUMP" = "yes"; then
1362   AC_DEFINE(CANNOT_DUMP, 1, [Define if Emacs cannot be dumped on your system.])
1363 elif test "$emacs_cv_sanitize_address" = yes; then
1364   AC_MSG_WARN([[Addresses are sanitized; suggest CANNOT_DUMP=yes]])
1367 AC_SUBST(CANNOT_DUMP)
1370 UNEXEC_OBJ=unexelf.o
1371 case "$opsys" in
1372   # MSDOS uses unexcoff.o
1373   aix4-2)
1374    UNEXEC_OBJ=unexaix.o
1375    ;;
1376   cygwin)
1377    UNEXEC_OBJ=unexcw.o
1378    ;;
1379   darwin)
1380    UNEXEC_OBJ=unexmacosx.o
1381    ;;
1382   hpux10-20 | hpux11)
1383    UNEXEC_OBJ=unexhp9k800.o
1384    ;;
1385   mingw32)
1386    UNEXEC_OBJ=unexw32.o
1387    ;;
1388   sol2-10)
1389    # Use the Solaris dldump() function, called from unexsol.c, to dump
1390    # emacs, instead of the generic ELF dump code found in unexelf.c.
1391    # The resulting binary has a complete symbol table, and is better
1392    # for debugging and other observability tools (debuggers, pstack, etc).
1393    #
1394    # If you encounter a problem using dldump(), please consider sending
1395    # a message to the OpenSolaris tools-linking mailing list:
1396    #      http://mail.opensolaris.org/mailman/listinfo/tools-linking
1397    #
1398    # It is likely that dldump() works with older Solaris too, but this has
1399    # not been tested, so for now this change is for Solaris 10 or newer.
1400    UNEXEC_OBJ=unexsol.o
1401    ;;
1402 esac
1403 test "$CANNOT_DUMP" = "yes" && UNEXEC_OBJ=
1405 LD_SWITCH_SYSTEM=
1406 case "$opsys" in
1407   freebsd|dragonfly)
1408    ## Let 'ld' find image libs and similar things in /usr/local/lib.
1409    ## The system compiler, GCC, has apparently been modified to not
1410    ## look there, contrary to what a stock GCC would do.
1411 ### It's not our place to do this.  See bug#10313#17.
1412 ###   LD_SWITCH_SYSTEM=-L/usr/local/lib
1413       :
1414    ;;
1416   gnu-linux)
1417    ## cpp test was "ifdef __mips__", but presumably this is equivalent...
1418    case $host_cpu in mips*) LD_SWITCH_SYSTEM="-G 0";; esac
1419    ;;
1421   netbsd)
1422 ### It's not our place to do this.  See bug#10313#17.
1423 ###   LD_SWITCH_SYSTEM="-Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib"
1424       :
1425    ;;
1427   openbsd)
1428    ## Han Boetes <han@boetes.org> says this is necessary,
1429    ## otherwise Emacs dumps core on elf systems.
1430    LD_SWITCH_SYSTEM="-Z"
1431    ;;
1432 esac
1433 AC_SUBST(LD_SWITCH_SYSTEM)
1435 ac_link="$ac_link $LD_SWITCH_SYSTEM"
1437 ## This setting of LD_SWITCH_SYSTEM references LD_SWITCH_X_SITE_RPATH,
1438 ## which has not been defined yet.  When this was handled with cpp,
1439 ## it was expanded to null when configure sourced the s/*.h file.
1440 ## Thus LD_SWITCH_SYSTEM had different values in configure and the Makefiles.
1441 ## FIXME it would be cleaner to put this in LD_SWITCH_SYSTEM_TEMACS
1442 ## (or somesuch), but because it is supposed to go at the _front_
1443 ## of LD_SWITCH_SYSTEM, we cannot do that in exactly the same way.
1444 ## Compare with the gnu-linux case below, which added to the end
1445 ## of LD_SWITCH_SYSTEM, and so can instead go at the front of
1446 ## LD_SWITCH_SYSTEM_TEMACS.
1447 case "$opsys" in
1448   netbsd|openbsd)
1449    LD_SWITCH_SYSTEM="\$(LD_SWITCH_X_SITE_RPATH) $LD_SWITCH_SYSTEM" ;;
1450 esac
1453 C_SWITCH_MACHINE=
1454 case $canonical in
1455  alpha*)
1456   AC_CHECK_DECL([__ELF__])
1457   if test "$ac_cv_have_decl___ELF__" = "yes"; then
1458     ## With ELF, make sure that all common symbols get allocated to in the
1459     ## data section.  Otherwise, the dump of temacs may miss variables in
1460     ## the shared library that have been initialized.  For example, with
1461     ## GNU libc, __malloc_initialized would normally be resolved to the
1462     ## shared library's .bss section, which is fatal.
1463     if test "x$GCC" = "xyes"; then
1464       C_SWITCH_MACHINE="-fno-common"
1465     else
1466       AC_MSG_ERROR([Non-GCC compilers are not supported.])
1467     fi
1468   else
1469       dnl This was the unexalpha.c case.  Removed in 24.1, 2010-07-24,
1470       dnl albeit under the mistaken assumption that said file
1471       dnl was no longer used.
1472       AC_MSG_ERROR([Non-ELF systems are not supported since Emacs 24.1.])
1473   fi
1474   ;;
1475 esac
1476 AC_SUBST(C_SWITCH_MACHINE)
1478 AC_SUBST(UNEXEC_OBJ)
1480 C_SWITCH_SYSTEM=
1481 ## Some programs in src produce warnings saying certain subprograms
1482 ## are too complex and need a MAXMEM value greater than 2000 for
1483 ## additional optimization.  --nils@exp-math.uni-essen.de
1484 test "$opsys" = "aix4.2" && test "x$GCC" != "xyes" && \
1485   C_SWITCH_SYSTEM="-ma -qmaxmem=4000"
1486 if test "$opsys" = "mingw32"; then
1487   case "$canonical" in
1488     x86_64-*-mingw*) C_SWITCH_SYSTEM="-mtune=generic" ;;
1489     *) C_SWITCH_SYSTEM="-mtune=pentium4" ;;
1490   esac
1492 ## gnu-linux might need -D_BSD_SOURCE on old libc5 systems.
1493 ## It is redundant in glibc2, since we define _GNU_SOURCE.
1494 AC_SUBST(C_SWITCH_SYSTEM)
1497 LIBS_SYSTEM=
1498 case "$opsys" in
1499   ## IBM's X11R5 uses -lIM and -liconv in AIX 3.2.2.
1500   aix4-2) LIBS_SYSTEM="-lrts -lIM -liconv" ;;
1502   freebsd|dragonfly) LIBS_SYSTEM="-lutil" ;;
1504   hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
1506   sol2*) LIBS_SYSTEM="-lsocket -lnsl" ;;
1508   ## Motif needs -lgen.
1509   unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;;
1510 esac
1512 AC_SUBST(LIBS_SYSTEM)
1514 ### Make sure subsequent tests use flags consistent with the build flags.
1516 if test x"${OVERRIDE_CPPFLAGS}" != x; then
1517   CPPFLAGS="${OVERRIDE_CPPFLAGS}"
1518 else
1519   CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
1522 # Suppress obsolescent Autoconf test for size_t; Emacs assumes C99 or better.
1523 AC_DEFUN([AC_TYPE_SIZE_T])
1524 # Likewise for obsolescent test for uid_t, gid_t; Emacs assumes them.
1525 AC_DEFUN([AC_TYPE_UID_T])
1527 # sqrt and other floating-point functions such as fmod and frexp
1528 # are found in -lm on many systems.
1529 OLD_LIBS=$LIBS
1530 AC_SEARCH_LIBS([sqrt], [m])
1531 if test "X$LIBS" = "X$OLD_LIBS"; then
1532   LIB_MATH=
1533 else
1534   LIB_MATH=$ac_cv_search_sqrt
1536 LIBS=$OLD_LIBS
1538 dnl Current possibilities handled by sed (aix4-2 -> aix,
1539 dnl gnu-linux -> gnu/linux, etc.):
1540 dnl gnu, gnu/linux, gnu/kfreebsd, aix, cygwin, darwin, hpux.
1541 dnl And special cases: berkeley-unix, usg-unix-v, ms-dos, windows-nt.
1542 SYSTEM_TYPE=`echo $opsys | sed -e 's/[[0-9]].*//' -e 's|-|/|'`
1544 case $opsys in
1545   cygwin )
1546     LIB_MATH=
1547     ;;
1548   darwin )
1549     ## Adding -lm confuses the dynamic linker, so omit it.
1550     LIB_MATH=
1551     ;;
1552   freebsd | dragonfly )
1553     SYSTEM_TYPE=berkeley-unix
1554     ;;
1555   gnu-linux | gnu-kfreebsd )
1556     ;;
1557   hpux10-20 | hpux11 )
1558     ;;
1559   mingw32 )
1560     LIB_MATH=
1561     SYSTEM_TYPE=windows-nt
1562     ;;
1563   dnl NB this may be adjusted below.
1564   netbsd | openbsd )
1565     SYSTEM_TYPE=berkeley-unix
1566     ;;
1568   sol2* | unixware )
1569     SYSTEM_TYPE=usg-unix-v
1570     ;;
1572 esac
1574 AC_SUBST(LIB_MATH)
1575 AC_DEFINE_UNQUOTED(SYSTEM_TYPE, "$SYSTEM_TYPE",
1576   [The type of system you are compiling for; sets 'system-type'.])
1577 AC_SUBST([SYSTEM_TYPE])
1580 pre_PKG_CONFIG_CFLAGS=$CFLAGS
1581 pre_PKG_CONFIG_LIBS=$LIBS
1583 PKG_PROG_PKG_CONFIG(0.9.0)
1585 dnl EMACS_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4)
1586 dnl acts like PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4,
1587 dnl HAVE_GSTUFF=yes, HAVE_GSTUFF=no) -- see pkg-config man page --
1588 dnl except that it postprocesses CFLAGS as needed for --enable-gcc-warnings.
1589 dnl EMACS_CHECK_MODULES accepts optional 3rd and 4th arguments that
1590 dnl can take the place of the default HAVE_GSTUFF=yes and HAVE_GSTUFF=no
1591 dnl actions.
1592 AC_DEFUN([EMACS_CHECK_MODULES],
1593   [PKG_CHECK_MODULES([$1], [$2],
1594      [$1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"`
1595       m4_default([$3], [HAVE_$1=yes])],
1596      [m4_default([$4], [HAVE_$1=no])])])
1598 HAVE_SOUND=no
1599 if test "${with_sound}" != "no"; then
1600   # Sound support for GNU/Linux, the free BSDs, MinGW, and Cygwin.
1601   AC_CHECK_HEADERS([machine/soundcard.h sys/soundcard.h soundcard.h mmsystem.h],
1602     have_sound_header=yes, [], [
1603     #ifdef __MINGW32__
1604     #define WIN32_LEAN_AND_MEAN
1605     #include <windows.h>
1606     #endif
1607     ])
1608   test "${with_sound}" = "oss" && test "${have_sound_header}" != "yes" && \
1609     AC_MSG_ERROR([OSS sound support requested but not found.])
1611   if test "${with_sound}" = "bsd-ossaudio" || test "${with_sound}" = "yes"; then
1612     # Emulation library used on NetBSD.
1613     AC_CHECK_LIB(ossaudio, _oss_ioctl, LIBSOUND=-lossaudio, LIBSOUND=)
1614     test "${with_sound}" = "bsd-ossaudio" && test -z "$LIBSOUND" && \
1615       AC_MSG_ERROR([bsd-ossaudio sound support requested but not found.])
1616     dnl FIXME?  If we did find ossaudio, should we set with_sound=bsd-ossaudio?
1617     dnl Traditionally, we go on to check for alsa too.  Does that make sense?
1618   fi
1619   AC_SUBST(LIBSOUND)
1621   if test "${with_sound}" = "alsa" || test "${with_sound}" = "yes"; then
1622     ALSA_REQUIRED=1.0.0
1623     ALSA_MODULES="alsa >= $ALSA_REQUIRED"
1624     EMACS_CHECK_MODULES([ALSA], [$ALSA_MODULES])
1625     if test $HAVE_ALSA = yes; then
1626       SAVE_CFLAGS="$CFLAGS"
1627       SAVE_LIBS="$LIBS"
1628       CFLAGS="$ALSA_CFLAGS $CFLAGS"
1629       LIBS="$ALSA_LIBS $LIBS"
1630       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <asoundlib.h>]], [[snd_lib_error_set_handler (0);]])],
1631                       emacs_alsa_normal=yes,
1632                     emacs_alsa_normal=no)
1633       if test "$emacs_alsa_normal" != yes; then
1634         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <alsa/asoundlib.h>]],
1635                        [[snd_lib_error_set_handler (0);]])],
1636                        emacs_alsa_subdir=yes,
1637                      emacs_alsa_subdir=no)
1638         if test "$emacs_alsa_subdir" != yes; then
1639           AC_MSG_ERROR([pkg-config found alsa, but it does not compile.  See config.log for error messages.])
1640         fi
1641         ALSA_CFLAGS="$ALSA_CFLAGS -DALSA_SUBDIR_INCLUDE"
1642       fi
1644       CFLAGS="$SAVE_CFLAGS"
1645       LIBS="$SAVE_LIBS"
1646       LIBSOUND="$LIBSOUND $ALSA_LIBS"
1647       CFLAGS_SOUND="$CFLAGS_SOUND $ALSA_CFLAGS"
1648       AC_DEFINE(HAVE_ALSA, 1, [Define to 1 if ALSA is available.])
1649     elif test "${with_sound}" = "alsa"; then
1650       AC_MSG_ERROR([ALSA sound support requested but not found.])
1651     fi
1652   fi                            dnl with_sound = alsa|yes
1654   dnl Define HAVE_SOUND if we have sound support.  We know it works and
1655   dnl compiles only on the specified platforms.  For others, it
1656   dnl probably doesn't make sense to try.
1657   dnl FIXME So surely we should bypass this whole section if not using
1658   dnl one of these platforms?
1659   if test x$have_sound_header = xyes || test $HAVE_ALSA = yes; then
1660      case "$opsys" in
1661        dnl defined __FreeBSD__ || defined __NetBSD__ || defined __linux__
1662        dnl Adjust the --with-sound help text if you change this.
1663        gnu-linux|freebsd|netbsd|mingw32|cygwin)
1664          AC_DEFINE(HAVE_SOUND, 1, [Define to 1 if you have sound support.])
1665          HAVE_SOUND=yes
1666          ;;
1667      esac
1668   fi
1670   AC_SUBST(CFLAGS_SOUND)
1673 dnl checks for header files
1674 AC_CHECK_HEADERS_ONCE(
1675   linux/fs.h
1676   malloc.h
1677   sys/systeminfo.h
1678   sys/sysinfo.h
1679   coff.h pty.h
1680   sys/resource.h
1681   sys/utsname.h pwd.h utmp.h util.h sys/prctl.h)
1683 AC_CACHE_CHECK([for ADDR_NO_RANDOMIZE],
1684   [emacs_cv_personality_addr_no_randomize],
1685   [AC_COMPILE_IFELSE(
1686      [AC_LANG_PROGRAM([[#include <sys/personality.h>]],
1687                       [[personality (personality (0xffffffff)
1688                                      | ADDR_NO_RANDOMIZE)]])],
1689      [emacs_cv_personality_addr_no_randomize=yes],
1690      [emacs_cv_personality_addr_no_randomize=no])])
1691 if test $emacs_cv_personality_addr_no_randomize = yes; then
1692   AC_DEFINE([HAVE_PERSONALITY_ADDR_NO_RANDOMIZE], [1],
1693             [Define to 1 if personality flag ADDR_NO_RANDOMIZE exists.])
1696 # Note that Solaris has sys/sysinfo.h which defines struct
1697 # sysinfo as well.  To make sure that we're using GNU/Linux
1698 # sysinfo, we explicitly set one of its fields.
1699 if test "$ac_cv_header_sys_sysinfo_h" = yes; then
1700   AC_CACHE_CHECK([if Linux sysinfo may be used], [emacs_cv_linux_sysinfo],
1701   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/sysinfo.h>]],
1702                                      [[struct sysinfo si;
1703                                        si.totalram = 0;
1704                                        sysinfo (&si)]])],
1705     emacs_cv_linux_sysinfo=yes, emacs_cv_linux_sysinfo=no)])
1707   if test $emacs_cv_linux_sysinfo = yes; then
1708     AC_DEFINE([HAVE_LINUX_SYSINFO], 1, [Define to 1 if you have Linux sysinfo function.])
1709     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/sysinfo.h>]],
1710                                        [[struct sysinfo si; return si.mem_unit]])],
1711       AC_DEFINE(LINUX_SYSINFO_UNIT, 1,
1712                 [Define to 1 if Linux sysinfo sizes are in multiples of mem_unit bytes.]))
1713   fi
1716 dnl On Solaris 8 there's a compilation warning for term.h because
1717 dnl it doesn't define 'bool'.
1718 AC_CHECK_HEADERS(term.h, , , -)
1719 AC_HEADER_TIME
1720 AC_CHECK_DECLS([sys_siglist], [], [], [[#include <signal.h>
1721                                       ]])
1722 if test $ac_cv_have_decl_sys_siglist != yes; then
1723   # For Tru64, at least:
1724   AC_CHECK_DECLS([__sys_siglist], [], [], [[#include <signal.h>
1725                                           ]])
1727 AC_HEADER_SYS_WAIT
1729 AC_CHECK_HEADERS_ONCE(sys/socket.h)
1730 AC_CHECK_HEADERS(net/if.h, , , [AC_INCLUDES_DEFAULT
1731 #if HAVE_SYS_SOCKET_H
1732 #include <sys/socket.h>
1733 #endif])
1734 AC_CHECK_HEADERS(ifaddrs.h, , , [AC_INCLUDES_DEFAULT
1735 #if HAVE_SYS_SOCKET_H
1736 #include <sys/socket.h>
1737 #endif])
1738 AC_CHECK_HEADERS(net/if_dl.h, , , [AC_INCLUDES_DEFAULT
1739 #if HAVE_SYS_SOCKET_H
1740 #include <sys/socket.h>
1741 #endif])
1743 dnl checks for structure members
1744 AC_CHECK_MEMBERS([struct ifreq.ifr_flags, struct ifreq.ifr_hwaddr,
1745                   struct ifreq.ifr_netmask, struct ifreq.ifr_broadaddr,
1746                   struct ifreq.ifr_addr,
1747                   struct ifreq.ifr_addr.sa_len], , ,
1748                  [AC_INCLUDES_DEFAULT
1749 #if HAVE_SYS_SOCKET_H
1750 #include <sys/socket.h>
1751 #endif
1752 #if HAVE_NET_IF_H
1753 #include <net/if.h>
1754 #endif])
1756 dnl Check for endianness.
1757 dnl AC_C_BIGENDIAN is done by gnulib.
1759 dnl check for Make feature
1761 AUTO_DEPEND=no
1762 AUTODEPEND_PARENTS='lib src'
1763 dnl check if we have GCC and autodepend is on.
1764 if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
1765    AC_CACHE_CHECK([whether gcc understands -MMD -MF], [emacs_cv_autodepend],
1766    [SAVE_CFLAGS="$CFLAGS"
1767    CFLAGS="$CFLAGS -MMD -MF deps.d -MP"
1768    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1769      [emacs_cv_autodepend=yes], [emacs_cv_autodepend=no])
1770    CFLAGS="$SAVE_CFLAGS"
1771    test -f deps.d || emacs_cv_autodepend=no
1772    rm -rf deps.d])
1773    if test $emacs_cv_autodepend = yes; then
1774       AUTO_DEPEND=yes
1775    fi
1777 AC_SUBST(AUTO_DEPEND)
1779 #### Choose a window system.
1781 ## We leave window_system equal to none if
1782 ## we end up building without one.  Any new window system should
1783 ## set window_system to an appropriate value and add objects to
1784 ## window-system-specific substs.
1786 window_system=none
1787 AC_PATH_X
1788 if test "$no_x" != yes; then
1789   window_system=x11
1792 LD_SWITCH_X_SITE_RPATH=
1793 if test "${x_libraries}" != NONE; then
1794   if test -n "${x_libraries}"; then
1795     LD_SWITCH_X_SITE=-L`AS_ECHO(["$x_libraries"]) | sed -e 's/:/ -L/g'`
1796     LD_SWITCH_X_SITE_RPATH=-Wl,-rpath,`
1797       AS_ECHO(["$x_libraries"]) | sed -e 's/:/ -Wl,-rpath,/g'
1798     `
1799   fi
1800   x_default_search_path=""
1801   x_search_path=${x_libraries}
1802   if test -z "${x_search_path}"; then
1803     x_search_path=/usr/lib
1804   fi
1805   for x_library in `AS_ECHO(["$x_search_path:"]) | \
1806                     sed -e "s/:/ /g" -e p -e "s:/lib[[^ /]]* :/share :g"`; do
1807     x_search_path="\
1808 ${x_library}/X11/%L/%T/%N%C%S:\
1809 ${x_library}/X11/%l/%T/%N%C%S:\
1810 ${x_library}/X11/%T/%N%C%S:\
1811 ${x_library}/X11/%L/%T/%N%S:\
1812 ${x_library}/X11/%l/%T/%N%S:\
1813 ${x_library}/X11/%T/%N%S"
1814     if test x"${x_default_search_path}" = x; then
1815       x_default_search_path=${x_search_path}
1816     else
1817       x_default_search_path="${x_search_path}:${x_default_search_path}"
1818     fi
1819   done
1821 AC_SUBST(LD_SWITCH_X_SITE_RPATH)
1823 if test "${x_includes}" != NONE && test -n "${x_includes}"; then
1824   C_SWITCH_X_SITE=$isystem`AS_ECHO(["$x_includes"]) | sed -e "s/:/ $isystem/g"`
1827 if test x"${x_includes}" = x; then
1828   bitmapdir=/usr/include/X11/bitmaps
1829 else
1830   # accumulate include directories that have X11 bitmap subdirectories
1831   bmd_acc=
1832   for bmd in `AS_ECHO(["$x_includes"]) | sed -e 's/:/ /g'`; do
1833     if test -d "${bmd}/X11/bitmaps"; then
1834       bmd_acc="${bmd_acc}:${bmd}/X11/bitmaps"
1835     fi
1836     if test -d "${bmd}/bitmaps"; then
1837       bmd_acc="${bmd_acc}:${bmd}/bitmaps"
1838     fi
1839   done
1840   bitmapdir=${bmd_acc#:}
1843 test "${with_ns}" = maybe && test "${opsys}" != darwin && with_ns=no
1844 HAVE_NS=no
1845 NS_GNUSTEP_CONFIG=no
1846 NS_IMPL_COCOA=no
1847 NS_IMPL_GNUSTEP=no
1848 tmp_CPPFLAGS="$CPPFLAGS"
1849 tmp_CFLAGS="$CFLAGS"
1850 CPPFLAGS="$CPPFLAGS -x objective-c"
1851 CFLAGS="$CFLAGS -x objective-c"
1852 GNU_OBJC_CFLAGS=
1853 LIBS_GNUSTEP=
1854 if test "${with_ns}" != no; then
1855   if test "${opsys}" = darwin; then
1856      NS_IMPL_COCOA=yes
1857      ns_appdir=`pwd`/nextstep/Emacs.app
1858      ns_appbindir=${ns_appdir}/Contents/MacOS
1859      ns_appresdir=${ns_appdir}/Contents/Resources
1860      ns_appsrc=Cocoa/Emacs.base
1861      ns_fontfile=macfont.o
1862   elif flags=$( (gnustep-config --objc-flags) 2>/dev/null); then
1863      NS_IMPL_GNUSTEP=yes
1864      NS_GNUSTEP_CONFIG=yes
1865      GNU_OBJC_CFLAGS=$flags
1866      LIBS_GNUSTEP=$(gnustep-config --gui-libs) || exit
1867   elif test -f $GNUSTEP_CONFIG_FILE; then
1868      NS_IMPL_GNUSTEP=yes
1869      dnl FIXME sourcing this several times in subshells seems inefficient.
1870      GNUSTEP_SYSTEM_HEADERS=$(
1871        . $GNUSTEP_CONFIG_FILE
1872        AS_ECHO(["$GNUSTEP_SYSTEM_HEADERS"])
1873      )
1874      GNUSTEP_SYSTEM_LIBRARIES=$(
1875        . $GNUSTEP_CONFIG_FILE
1876        AS_ECHO(["$GNUSTEP_SYSTEM_LIBRARIES"])
1877      )
1878      dnl I seemed to need these as well with GNUstep-startup 0.25.
1879      GNUSTEP_LOCAL_HEADERS=$(
1880        . $GNUSTEP_CONFIG_FILE
1881        AS_ECHO(["$GNUSTEP_LOCAL_HEADERS"])
1882      )
1883      GNUSTEP_LOCAL_LIBRARIES=$(
1884        . $GNUSTEP_CONFIG_FILE
1885        AS_ECHO(["$GNUSTEP_LOCAL_LIBRARIES"])
1886      )
1887      test "x${GNUSTEP_LOCAL_HEADERS}" != "x" && \
1888        GNUSTEP_LOCAL_HEADERS="-I${GNUSTEP_LOCAL_HEADERS}"
1889      test "x${GNUSTEP_LOCAL_LIBRARIES}" != "x" && \
1890        GNUSTEP_LOCAL_LIBRARIES="-L${GNUSTEP_LOCAL_LIBRARIES}"
1891      CPPFLAGS="$CPPFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
1892      CFLAGS="$CFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
1893      LDFLAGS="$LDFLAGS -L${GNUSTEP_SYSTEM_LIBRARIES} ${GNUSTEP_LOCAL_LIBRARIES}"
1894      LIBS_GNUSTEP="-lgnustep-gui -lgnustep-base -lobjc -lpthread"
1895      dnl GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS to 0 or 1.
1896      dnl If they had chosen to either define it or not, we could have
1897      dnl just used AC_CHECK_DECL here.
1898      AC_CACHE_CHECK(if GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS,
1899        emacs_cv_objc_exceptions,
1900 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <GNUstepBase/GSConfig.h>]],
1901 [[#if defined BASE_NATIVE_OBJC_EXCEPTIONS && BASE_NATIVE_OBJC_EXCEPTIONS > 0
1903 #else
1904 fail;
1905 #endif]])], emacs_cv_objc_exceptions=yes, emacs_cv_objc_exceptions=no ) )
1906      if test $emacs_cv_objc_exceptions = yes; then
1907        dnl _NATIVE_OBJC_EXCEPTIONS is used by the GNUstep headers.
1908        AC_DEFINE(_NATIVE_OBJC_EXCEPTIONS, 1,
1909          [Define if GNUstep uses ObjC exceptions.])
1910        GNU_OBJC_CFLAGS="-fobjc-exceptions"
1911      fi
1912   fi
1913   if test $NS_IMPL_GNUSTEP = yes; then
1914      ns_appdir=`pwd`/nextstep/Emacs.app
1915      ns_appbindir=${ns_appdir}
1916      ns_appresdir=${ns_appdir}/Resources
1917      ns_appsrc=GNUstep/Emacs.base
1918      ns_fontfile=nsfont.o
1919   fi
1921   dnl This is only used while we test the NS headers, it gets reset below.
1922   CPPFLAGS="$CPPFLAGS $GNU_OBJC_CFLAGS"
1923   CFLAGS="$CFLAGS $GNU_OBJC_CFLAGS"
1925   AC_CHECK_HEADER([AppKit/AppKit.h], [HAVE_NS=yes],
1926                   [AC_MSG_ERROR([The include files (AppKit/AppKit.h etc) that
1927 are required for a Nextstep build are missing or cannot be compiled.
1928 Either fix this, or re-configure with the option '--without-ns'.])])
1930   macfont_file=""
1931   if test "${NS_IMPL_COCOA}" = "yes"; then
1932     AC_MSG_CHECKING([for Mac OS X 10.6 or newer])
1933     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>],
1934                                      [
1935 #ifdef MAC_OS_X_VERSION_MAX_ALLOWED
1936 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
1937  ; /* OK */
1938 #else
1939  error "Mac OS X 10.6 or newer required";
1940 #endif
1941 #endif
1942                     ])],
1943                     ns_osx_have_106=yes,
1944                     ns_osx_have_106=no)
1945     AC_MSG_RESULT([$ns_osx_have_106])
1947     if test $ns_osx_have_106 = no; then
1948        AC_MSG_ERROR([Mac OS X 10.6 or newer is required]);
1949     fi
1950   fi
1953 AC_SUBST(LIBS_GNUSTEP)
1955 INSTALL_ARCH_INDEP_EXTRA=install-etc
1956 ns_self_contained=no
1957 NS_OBJ=
1958 NS_OBJC_OBJ=
1959 if test "${HAVE_NS}" = yes; then
1960   if test "$with_toolkit_scroll_bars" = "no"; then
1961     AC_MSG_ERROR([Non-toolkit scroll bars are not implemented for Nextstep.])
1962   fi
1964   window_system=nextstep
1965   # set up packaging dirs
1966   if test "${EN_NS_SELF_CONTAINED}" = yes; then
1967      ns_self_contained=yes
1968      prefix=${ns_appresdir}
1969      exec_prefix=${ns_appbindir}
1970      dnl This one isn't really used, only archlibdir is.
1971      libexecdir="\${ns_appbindir}/libexec"
1972      archlibdir="\${ns_appbindir}/libexec"
1973      etcdocdir="\${ns_appresdir}/etc"
1974      etcdir="\${ns_appresdir}/etc"
1975      dnl FIXME maybe set datarootdir instead.
1976      dnl That would also get applications, icons, man.
1977      infodir="\${ns_appresdir}/info"
1978      mandir="\${ns_appresdir}/man"
1979      lispdir="\${ns_appresdir}/lisp"
1980      test "$locallisppathset" = no && locallisppath=""
1981      INSTALL_ARCH_INDEP_EXTRA=
1982   fi
1984   NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o $ns_fontfile"
1986 CFLAGS="$tmp_CFLAGS"
1987 CPPFLAGS="$tmp_CPPFLAGS"
1988 AC_SUBST(INSTALL_ARCH_INDEP_EXTRA)
1989 AC_SUBST(ns_self_contained)
1990 AC_SUBST(NS_OBJ)
1991 AC_SUBST(NS_OBJC_OBJ)
1993 if test "${HAVE_NS}" = yes; then
1994   AC_CACHE_CHECK(
1995     [if the Objective C compiler supports instancetype],
1996     [emacs_cv_objc_instancetype],
1997     [AC_LANG_PUSH([Objective C])
1998      AC_COMPILE_IFELSE(
1999        [AC_LANG_SOURCE([[@interface Test
2000                           + (instancetype)test;
2001                           @end]])],
2002        emacs_cv_objc_instancetype=yes,
2003        emacs_cv_objc_instancetype=no)
2004      AC_LANG_POP([Objective C])])
2006   if test x$emacs_cv_objc_instancetype = xyes ; then
2007     AC_DEFINE(NATIVE_OBJC_INSTANCETYPE, 1,
2008               [Define if ObjC compiler supports instancetype natively.])
2009   fi
2012 HAVE_W32=no
2013 W32_OBJ=
2014 W32_LIBS=
2015 EMACSRES=
2016 CLIENTRES=
2017 CLIENTW=
2018 W32_RES_LINK=
2019 EMACS_MANIFEST=
2020 if test "${with_w32}" != no; then
2021   case "${opsys}" in
2022     cygwin)
2023       AC_CHECK_HEADER([windows.h], [HAVE_W32=yes],
2024              [AC_MSG_ERROR(['--with-w32' was specified, but windows.h
2025                    cannot be found.])])
2026     ;;
2027     mingw32)
2028     ## Using --with-w32 with MinGW is a no-op, but we allow it.
2029     ;;
2030     *)
2031       AC_MSG_ERROR([Using w32 with an autotools build is only supported for Cygwin and MinGW32.])
2032     ;;
2033   esac
2036 if test "${opsys}" = "mingw32"; then
2037   AC_CACHE_CHECK([whether Windows API headers are recent enough], [emacs_cv_w32api],
2038   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2039      #include <windows.h>
2040      #include <usp10.h>]],
2041    [[PIMAGE_NT_HEADERS pHeader;
2042      PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader)]])],
2043    [emacs_cv_w32api=yes], [emacs_cv_w32api=no])])
2044   if test "${emacs_cv_w32api}" = "no"; then
2045     AC_MSG_ERROR([the Windows API headers are too old to support this build.])
2046   fi
2047   HAVE_W32=${emacs_cv_w32api}
2050 FIRSTFILE_OBJ=
2051 NTDIR=
2052 LIBS_ECLIENT=
2053 LIB_WSOCK32=
2054 NTLIB=
2055 CM_OBJ="cm.o"
2056 XARGS_LIMIT=
2057 if test "${HAVE_W32}" = "yes"; then
2058   AC_DEFINE(HAVE_NTGUI, 1, [Define to use native MS Windows GUI.])
2059   if test "$with_toolkit_scroll_bars" = "no"; then
2060     AC_MSG_ERROR([Non-toolkit scroll bars are not implemented for w32 build.])
2061   fi
2062   AC_CHECK_TOOL(WINDRES, [windres],
2063                 [AC_MSG_ERROR([No resource compiler found.])])
2064   W32_OBJ="w32fns.o w32menu.o w32reg.o w32font.o w32term.o"
2065   W32_OBJ="$W32_OBJ w32xfns.o w32select.o w32uniscribe.o"
2066   EMACSRES="emacs.res"
2067   case "$canonical" in
2068     x86_64-*-*) EMACS_MANIFEST="emacs-x64.manifest" ;;
2069     *) EMACS_MANIFEST="emacs-x86.manifest" ;;
2070   esac
2071   dnl Construct something of the form "24,4,0,0" with 4 components.
2072   comma_version=`echo "${PACKAGE_VERSION}.0.0" | sed -e 's/\./,/g' -e 's/^\([[^,]]*,[[^,]]*,[[^,]]*,[[^,]]*\).*/\1/'`
2074   comma_space_version=`echo "$comma_version" | sed 's/,/, /g'`
2075   AC_SUBST(comma_version)
2076   AC_SUBST(comma_space_version)
2077   AC_CONFIG_FILES([nt/emacs.rc nt/emacsclient.rc])
2078   if test "${opsys}" = "cygwin"; then
2079     W32_LIBS="$W32_LIBS -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32"
2080     W32_LIBS="$W32_LIBS -lusp10 -lcomctl32 -lwinspool"
2081     # Tell the linker that emacs.res is an object (which we compile from
2082     # the rc file), not a linker script.
2083     W32_RES_LINK="-Wl,emacs.res"
2084   else
2085     W32_OBJ="$W32_OBJ w32.o w32console.o w32heap.o w32inevt.o w32proc.o"
2086     W32_LIBS="$W32_LIBS -lwinmm -lgdi32 -lcomdlg32"
2087     W32_LIBS="$W32_LIBS -lmpr -lwinspool -lole32 -lcomctl32 -lusp10"
2088     W32_RES_LINK="\$(EMACSRES)"
2089     CLIENTRES="emacsclient.res"
2090     CLIENTW="emacsclientw\$(EXEEXT)"
2091     FIRSTFILE_OBJ=firstfile.o
2092     NTDIR=nt
2093     CM_OBJ=
2094     LIBS_ECLIENT="-lcomctl32"
2095     LIB_WSOCK32="-lwsock32"
2096     NTLIB="ntlib.$ac_objext"
2097     XARGS_LIMIT="-s 10000"
2098   fi
2100 AC_SUBST(W32_OBJ)
2101 AC_SUBST(W32_LIBS)
2102 AC_SUBST(EMACSRES)
2103 AC_SUBST(EMACS_MANIFEST)
2104 AC_SUBST(CLIENTRES)
2105 AC_SUBST(CLIENTW)
2106 AC_SUBST(W32_RES_LINK)
2107 AC_SUBST(FIRSTFILE_OBJ)
2108 AC_SUBST(NTDIR)
2109 AC_SUBST(CM_OBJ)
2110 AC_SUBST(LIBS_ECLIENT)
2111 AC_SUBST(LIB_WSOCK32)
2112 AC_SUBST(NTLIB)
2113 AC_SUBST(XARGS_LIMIT)
2115 if test "${HAVE_W32}" = "yes"; then
2116   window_system=w32
2117   with_xft=no
2120 ## $window_system is now set to the window system we will
2121 ## ultimately use.
2123 term_header=
2124 HAVE_X_WINDOWS=no
2125 HAVE_X11=no
2126 USE_X_TOOLKIT=none
2128 case "${window_system}" in
2129   x11 )
2130     HAVE_X_WINDOWS=yes
2131     HAVE_X11=yes
2132     term_header=xterm.h
2133     case "${with_x_toolkit}" in
2134       athena | lucid ) USE_X_TOOLKIT=LUCID ;;
2135       motif ) USE_X_TOOLKIT=MOTIF ;;
2136       gtk ) with_gtk=yes
2137             term_header=gtkutil.h
2138 dnl Don't set this for GTK.  A lot of tests below assumes Xt when
2139 dnl USE_X_TOOLKIT is set.
2140             USE_X_TOOLKIT=none ;;
2141       gtk2 ) with_gtk2=yes
2142              term_header=gtkutil.h
2143              USE_X_TOOLKIT=none ;;
2144       gtk3 ) with_gtk3=yes
2145              term_header=gtkutil.h
2146              USE_X_TOOLKIT=none ;;
2147       no ) USE_X_TOOLKIT=none ;;
2148 dnl If user did not say whether to use a toolkit, make this decision later:
2149 dnl use the toolkit if we have gtk, or X11R5 or newer.
2150       * ) USE_X_TOOLKIT=maybe ;;
2151     esac
2152   ;;
2153   nextstep )
2154     term_header=nsterm.h
2155   ;;
2156   w32 )
2157     term_header=w32term.h
2158   ;;
2159 esac
2161 if test "$window_system" = none && test "X$with_x" != "Xno"; then
2162    AC_CHECK_PROG(HAVE_XSERVER, X, true, false)
2163    if test "$HAVE_XSERVER" = true ||
2164       test -n "$DISPLAY" ||
2165       {
2166         for emacs_libX11 in /usr/lib/libX11.*; do break; done
2167         test "$emacs_libX11" != '/usr/lib/libX11.*'
2168       }
2169    then
2170         AC_MSG_ERROR([You seem to be running X, but no X development libraries
2171 were found.  You should install the relevant development files for X
2172 and for the toolkit you want, such as Gtk+ or Motif.  Also make
2173 sure you have development files for image handling, i.e.
2174 tiff, gif, jpeg, png and xpm.
2175 If you are sure you want Emacs compiled without X window support, pass
2176   --without-x
2177 to configure.])
2178    fi
2181 # Does the opsystem file prohibit the use of the GNU malloc?
2182 # Assume not, until told otherwise.
2183 GNU_MALLOC=yes
2185 AC_CACHE_CHECK(
2186   [whether malloc is Doug Lea style],
2187   [emacs_cv_var_doug_lea_malloc],
2188   [emacs_cv_var_doug_lea_malloc=no
2189    dnl Hooks do not work with address sanitization.
2190    if test "$emacs_cv_sanitize_address" != yes; then
2191      AC_LINK_IFELSE(
2192        [AC_LANG_PROGRAM(
2193           [[#include <malloc.h>
2194             static void hook (void) {}]],
2195           [[malloc_set_state (malloc_get_state ());
2196             __after_morecore_hook = hook;
2197             __malloc_initialize_hook = hook;]])],
2198        [emacs_cv_var_doug_lea_malloc=yes])
2199    fi])
2200 doug_lea_malloc=$emacs_cv_var_doug_lea_malloc
2202 hybrid_malloc=
2203 system_malloc=yes
2205 test "$CANNOT_DUMP" = yes ||
2206 case "$opsys" in
2207   ## darwin ld insists on the use of malloc routines in the System framework.
2208   darwin | mingw32 | nacl | sol2-10) ;;
2209   cygwin) hybrid_malloc=yes
2210           system_malloc= ;;
2211   *) test "$ac_cv_func_sbrk" = yes && system_malloc=$emacs_cv_sanitize_address;;
2212 esac
2214 if test "${system_malloc}" != yes && test "${doug_lea_malloc}" != yes \
2215    && test "${UNEXEC_OBJ}" = unexelf.o; then
2216   hybrid_malloc=yes
2219 GMALLOC_OBJ=
2220 HYBRID_MALLOC=
2221 if test "${system_malloc}" = "yes"; then
2222   AC_DEFINE([SYSTEM_MALLOC], 1,
2223     [Define to 1 to use the system memory allocator, even if it is not
2224      Doug Lea style.])
2225   GNU_MALLOC=no
2226   GNU_MALLOC_reason="
2227     (The GNU allocators don't work with this system configuration.)"
2228   VMLIMIT_OBJ=
2229 elif test "$hybrid_malloc" = yes; then
2230   AC_DEFINE(HYBRID_MALLOC, 1,
2231     [Define to use gmalloc before dumping and the system malloc after.])
2232   HYBRID_MALLOC=1
2233   GNU_MALLOC=no
2234   GNU_MALLOC_reason=" (only before dumping)"
2235   GMALLOC_OBJ=gmalloc.o
2236   VMLIMIT_OBJ=
2237 else
2238   test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
2239   VMLIMIT_OBJ=vm-limit.o
2241   AC_CHECK_HEADERS([sys/vlimit.h])
2242   AC_CACHE_CHECK([for data_start], [emacs_cv_data_start],
2243     [AC_LINK_IFELSE(
2244        [AC_LANG_PROGRAM(
2245          [[extern char data_start[]; char ch;]],
2246          [[return data_start < &ch;]])],
2247        [emacs_cv_data_start=yes],
2248        [emacs_cv_data_start=no])])
2249   if test $emacs_cv_data_start = yes; then
2250     AC_DEFINE([HAVE_DATA_START], 1,
2251       [Define to 1 if data_start is the address of the start
2252        of the main data segment.])
2253   fi
2255 AC_SUBST([HYBRID_MALLOC])
2256 AC_SUBST(GMALLOC_OBJ)
2257 AC_SUBST(VMLIMIT_OBJ)
2259 if test "$doug_lea_malloc" = "yes" && test "$hybrid_malloc" != yes; then
2260   if test "$GNU_MALLOC" = yes ; then
2261     GNU_MALLOC_reason="
2262       (Using Doug Lea's new malloc from the GNU C Library.)"
2263   fi
2264   AC_DEFINE(DOUG_LEA_MALLOC, 1,
2265     [Define to 1 if the system memory allocator is Doug Lea style,
2266      with malloc hooks and malloc_set_state.])
2268   ## Use mmap directly for allocating larger buffers.
2269   ## FIXME this comes from src/s/{gnu,gnu-linux}.h:
2270   ## #ifdef DOUG_LEA_MALLOC; #undef REL_ALLOC; #endif
2271   ## Does the AC_FUNC_MMAP test below make this check unnecessary?
2272   case "$opsys" in
2273     mingw32|gnu*) REL_ALLOC=no ;;
2274   esac
2277 if test x"${REL_ALLOC}" = x; then
2278   REL_ALLOC=${GNU_MALLOC}
2281 use_mmap_for_buffers=no
2282 case "$opsys" in
2283   mingw32) use_mmap_for_buffers=yes ;;
2284 esac
2286 AC_FUNC_MMAP
2287 if test $use_mmap_for_buffers = yes; then
2288   AC_DEFINE(USE_MMAP_FOR_BUFFERS, 1, [Define to use mmap to allocate buffer text.])
2289   REL_ALLOC=no
2292 LIBS="$LIBS_SYSTEM $LIBS"
2294 dnl FIXME replace main with a function we actually want from this library.
2295 AC_CHECK_LIB(Xbsd, main, LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -lXbsd")
2297 dnl Check for the POSIX thread library.
2298 LIB_PTHREAD=
2299 AC_CHECK_HEADERS_ONCE(pthread.h)
2300 if test "$ac_cv_header_pthread_h" && test "$opsys" != "mingw32"; then
2301   AC_CACHE_CHECK([for pthread library],
2302     [emacs_cv_pthread_lib],
2303     [emacs_cv_pthread_lib=no
2304      OLD_LIBS=$LIBS
2305      for emacs_pthread_lib in 'none needed' -lpthread; do
2306        case $emacs_pthread_lib in
2307          -*) LIBS="$OLD_LIBS $emacs_pthread_lib";;
2308        esac
2309        AC_LINK_IFELSE(
2310          [AC_LANG_PROGRAM(
2311             [[#include <pthread.h>
2312               #include <signal.h>
2313               sigset_t old_mask, new_mask;
2314               void noop (void) {}]],
2315             [[pthread_t th = pthread_self ();
2316               int status = 0;
2317               status += pthread_create (&th, 0, 0, 0);
2318               status += pthread_sigmask (SIG_BLOCK, &new_mask, &old_mask);
2319               status += pthread_kill (th, 0);
2320               #if ! (defined SYSTEM_MALLOC || defined HYBRID_MALLOC \
2321                      || defined DOUG_LEA_MALLOC)
2322               /* Test for pthread_atfork only if gmalloc uses it,
2323                  as older-style hosts like MirBSD 10 lack it.  */
2324               status += pthread_atfork (noop, noop, noop);
2325               #endif
2326               return status;]])],
2327          [emacs_cv_pthread_lib=$emacs_pthread_lib])
2328        LIBS=$OLD_LIBS
2329        if test "$emacs_cv_pthread_lib" != no; then
2330          break
2331        fi
2332      done])
2333   if test "$emacs_cv_pthread_lib" != no; then
2334     AC_DEFINE([HAVE_PTHREAD], 1, [Define to 1 if you have POSIX threads.])
2335     case $emacs_cv_pthread_lib in
2336       -*) LIB_PTHREAD=$emacs_cv_pthread_lib;;
2337     esac
2338     ac_cv_func_pthread_sigmask=yes
2339     # Some systems optimize for single-threaded programs by default, and
2340     # need special flags to disable these optimizations. For example, the
2341     # definition of 'errno' in <errno.h>.
2342     case $opsys in
2343       hpux* | sol*)
2344         AC_DEFINE([_REENTRANT], 1,
2345           [Define to 1 if your system requires this in multithreaded code.]);;
2346       aix4-2)
2347         AC_DEFINE([_THREAD_SAFE], 1,
2348           [Define to 1 if your system requires this in multithreaded code.]);;
2349     esac
2350   fi
2352 AC_SUBST([LIB_PTHREAD])
2354 AC_MSG_CHECKING([for thread support])
2355 threads_enabled=no
2356 if test "$with_threads" = yes; then
2357    if test "$emacs_cv_pthread_lib" != no; then
2358       AC_DEFINE(THREADS_ENABLED, 1,
2359                 [Define to 1 if you want elisp thread support.])
2360       threads_enabled=yes
2361    elif test "${opsys}" = "mingw32"; then
2362       dnl MinGW can do native Windows threads even without pthreads
2363       AC_DEFINE(THREADS_ENABLED, 1,
2364                 [Define to 1 if you want elisp thread support.])
2365       threads_enabled=yes
2366    fi
2368 AC_MSG_RESULT([$threads_enabled])
2370 dnl Check for need for bigtoc support on IBM AIX
2372 case ${host_os} in
2373 aix*)
2374   AC_CACHE_CHECK([for -bbigtoc option], [gdb_cv_bigtoc], [
2375     case $GCC in
2376     yes) gdb_cv_bigtoc=-Wl,-bbigtoc ;;
2377     *) gdb_cv_bigtoc=-bbigtoc ;;
2378     esac
2380     LDFLAGS=$LDFLAGS\ $gdb_cv_bigtoc
2381     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])], [], [gdb_cv_bigtoc=])
2382   ])
2383   ;;
2384 esac
2386 # Change CFLAGS, CPPFLAGS, and LIBS temporarily so that C_SWITCH_X_SITE
2387 # is for the tests that follow.  We set them back later on.
2389 REAL_CFLAGS="$CFLAGS"
2390 REAL_CPPFLAGS="$CPPFLAGS"
2391 REAL_LIBS="$LIBS"
2393 if test "${HAVE_X11}" = "yes"; then
2394   DEFS="$C_SWITCH_X_SITE $DEFS"
2395   LDFLAGS="$LDFLAGS $LD_SWITCH_X_SITE"
2396   LIBS="-lX11 $LIBS"
2397   CFLAGS="$C_SWITCH_X_SITE $CFLAGS"
2398   CPPFLAGS="$C_SWITCH_X_SITE $CPPFLAGS"
2400   # On Solaris, arrange for LD_RUN_PATH to point to the X libraries for tests.
2401   # This is handled by LD_SWITCH_X_SITE_RPATH during the real build,
2402   # but it's more convenient here to set LD_RUN_PATH since this
2403   # also works on hosts that don't understand LD_SWITCH_X_SITE_RPATH.
2404   if test "${x_libraries}" != NONE && test -n "${x_libraries}"; then
2405     LD_RUN_PATH=$x_libraries${LD_RUN_PATH+:}$LD_RUN_PATH
2406     export LD_RUN_PATH
2407   fi
2409   if test "${opsys}" = "gnu-linux"; then
2410     AC_CACHE_CHECK([whether X on GNU/Linux needs -b to link], [emacs_cv_b_link],
2411     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
2412      [[XOpenDisplay ("foo");]])],
2413      [xgnu_linux_first_failure=no],
2414      [xgnu_linux_first_failure=yes])
2415     if test "${xgnu_linux_first_failure}" = "yes"; then
2416       OLD_CPPFLAGS="$CPPFLAGS"
2417       OLD_LIBS="$LIBS"
2418       CPPFLAGS="$CPPFLAGS -b i486-linuxaout"
2419       LIBS="$LIBS -b i486-linuxaout"
2420       AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
2421        [[XOpenDisplay ("foo");]])],
2422        [xgnu_linux_second_failure=no],
2423        [xgnu_linux_second_failure=yes])
2424       if test "${xgnu_linux_second_failure}" = "yes"; then
2425         # If we get the same failure with -b, there is no use adding -b.
2426         # So leave it out.  This plays safe.
2427         emacs_cv_b_link=no
2428       else
2429         emacs_cv_b_link=yes
2430       fi
2431       CPPFLAGS=$OLD_CPPFLAGS
2432       LIBS=$OLD_LIBS
2433     else
2434       emacs_cv_b_link=no
2435     fi])
2436     if test "x$emacs_cv_b_link" = xyes ; then
2437       LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -b i486-linuxaout"
2438       C_SWITCH_X_SITE="$C_SWITCH_X_SITE -b i486-linuxaout"
2439     fi
2440   fi
2442   # Reportedly, some broken Solaris systems have XKBlib.h but are missing
2443   # header files included from there.
2444   AC_CACHE_CHECK([for Xkb], [emacs_cv_xkb],
2445   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>
2446 #include <X11/XKBlib.h>]],
2447         [[XkbDescPtr kb = XkbGetKeyboard (0, XkbAllComponentsMask, XkbUseCoreKbd);]])],
2448         emacs_cv_xkb=yes, emacs_cv_xkb=no)])
2449   if test $emacs_cv_xkb = yes; then
2450     AC_DEFINE(HAVE_XKB, 1, [Define to 1 if you have the Xkb extension.])
2451   fi
2453   AC_CHECK_FUNCS(XrmSetDatabase XScreenResourceString \
2454 XScreenNumberOfScreen)
2457 if test "${window_system}" = "x11"; then
2458   AC_MSG_CHECKING(X11 version 6)
2459   AC_CACHE_VAL(emacs_cv_x11_version_6,
2460   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
2461 [[#if XlibSpecificationRelease < 6
2462 fail;
2463 #endif
2464 ]])], emacs_cv_x11_version_6=yes, emacs_cv_x11_version_6=no)])
2465   if test $emacs_cv_x11_version_6 = yes; then
2466     AC_MSG_RESULT(6 or newer)
2467     AC_DEFINE(HAVE_X11R6, 1,
2468               [Define to 1 if you have the X11R6 or newer version of Xlib.])
2469     AC_DEFINE(HAVE_X_I18N, 1, [Define if you have usable i18n support.])
2470     ## inoue@ainet.or.jp says Solaris has a bug related to X11R6-style
2471     ## XIM support.
2472     case "$opsys" in
2473       sol2-*) : ;;
2474       *) AC_DEFINE(HAVE_X11R6_XIM, 1,
2475            [Define if you have usable X11R6-style XIM support.])
2476          ;;
2477     esac
2478   else
2479     AC_MSG_RESULT(before 6)
2480   fi
2484 ### Use -lrsvg-2 if available, unless '--with-rsvg=no' is specified.
2485 HAVE_RSVG=no
2486 if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
2487   if test "${with_rsvg}" != "no"; then
2488     RSVG_REQUIRED=2.11.0
2489     RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
2491     EMACS_CHECK_MODULES([RSVG], [$RSVG_MODULE])
2492     AC_SUBST(RSVG_CFLAGS)
2493     AC_SUBST(RSVG_LIBS)
2495     if test $HAVE_RSVG = yes; then
2496       AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
2497       CFLAGS="$CFLAGS $RSVG_CFLAGS"
2498       # Windows loads librsvg dynamically
2499       if test "${opsys}" = "mingw32"; then
2500         RSVG_LIBS=
2501       fi
2502     fi
2503   fi
2506 HAVE_IMAGEMAGICK=no
2507 if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${HAVE_W32}" = "yes"; then
2508   if test "${with_imagemagick}" != "no"; then
2509     ## 6.3.5 is the earliest version known to work; see Bug#17339.
2510     ## 6.8.2 makes Emacs crash; see Bug#13867.
2511     ## 7 and later have not been ported to; See Bug#25967.
2512     IMAGEMAGICK_MODULE="Wand >= 6.3.5 Wand != 6.8.2 Wand < 7"
2513     EMACS_CHECK_MODULES([IMAGEMAGICK], [$IMAGEMAGICK_MODULE])
2515     if test $HAVE_IMAGEMAGICK = yes; then
2516       OLD_CFLAGS=$CFLAGS
2517       OLD_LIBS=$LIBS
2518       CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS"
2519       LIBS="$IMAGEMAGICK_LIBS $LIBS"
2520       AC_CHECK_FUNCS([MagickRelinquishMemory MagickExportImagePixels \
2521                       MagickMergeImageLayers MagickAutoOrientImage])
2522       CFLAGS=$OLD_CFLAGS
2523       LIBS=$OLD_LIBS
2524       # Check that ImageMagick links.  It does not link on Fedora 25
2525       # with './configure CC=clang', as pkg-config outputs flags like
2526       # -lomp that work for GCC but not Clang.
2527       if test "$ac_cv_func_MagickRelinquishMemory" != yes; then
2528         HAVE_IMAGEMAGICK=no
2529       fi
2530     fi
2531     if test $HAVE_IMAGEMAGICK = yes; then
2532       AC_DEFINE([HAVE_IMAGEMAGICK], 1, [Define to 1 if using ImageMagick.])
2533     else
2534       IMAGEMAGICK_CFLAGS=
2535       IMAGEMAGICK_LIBS=
2536     fi
2537     AC_SUBST([IMAGEMAGICK_CFLAGS])
2538     AC_SUBST([IMAGEMAGICK_LIBS])
2539   fi
2542 AC_CHECK_LIB(anl, getaddrinfo_a, HAVE_GETADDRINFO_A=yes)
2543 if test "${HAVE_GETADDRINFO_A}" = "yes"; then
2544   AC_DEFINE(HAVE_GETADDRINFO_A, 1,
2545 [Define to 1 if you have getaddrinfo_a for asynchronous DNS resolution.])
2546   GETADDRINFO_A_LIBS="-lanl"
2547   AC_SUBST(GETADDRINFO_A_LIBS)
2550 HAVE_GTK=no
2551 GTK_OBJ=
2552 gtk_term_header=$term_header
2553 check_gtk2=no
2554 gtk3_pkg_errors=
2555 if test "${opsys}" != "mingw32"; then
2556   if test "${with_gtk3}" = "yes" || test "${with_gtk}" = "yes" || test "$USE_X_TOOLKIT" = "maybe"; then
2557     GLIB_REQUIRED=2.28
2558     GTK_REQUIRED=3.0
2559     GTK_MODULES="gtk+-3.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
2561     dnl Checks for libraries.
2562     EMACS_CHECK_MODULES([GTK], [$GTK_MODULES],
2563       [pkg_check_gtk=yes], [pkg_check_gtk=no])
2564     if test "$pkg_check_gtk" = "no" && test "$with_gtk3" = "yes"; then
2565        AC_MSG_ERROR($GTK_PKG_ERRORS)
2566     fi
2567     if test "$pkg_check_gtk" = "yes"; then
2568        AC_DEFINE(HAVE_GTK3, 1, [Define to 1 if using GTK 3 or later.])
2569        GTK_OBJ=emacsgtkfixed.o
2570        gtk_term_header=gtkutil.h
2571        USE_GTK_TOOLKIT="GTK3"
2572        if test "x$ac_enable_gtk_deprecation_warnings" = x; then
2573          AC_DEFINE([GDK_DISABLE_DEPRECATION_WARNINGS], [1],
2574            [Define to 1 to disable GTK+/GDK deprecation warnings.])
2575          AC_DEFINE([GLIB_DISABLE_DEPRECATION_WARNINGS], [1],
2576            [Define to 1 to disable Glib deprecation warnings.])
2577        fi
2578     else
2579        check_gtk2=yes
2580        gtk3_pkg_errors="$GTK_PKG_ERRORS "
2581     fi
2582   fi
2584   if test "${with_gtk2}" = "yes" || test "$check_gtk2" = "yes"; then
2585     GLIB_REQUIRED=2.10
2586     GTK_REQUIRED=2.10
2587     GTK_MODULES="gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
2589     dnl Checks for libraries.
2590     EMACS_CHECK_MODULES([GTK], [$GTK_MODULES],
2591       [pkg_check_gtk=yes], [pkg_check_gtk=no])
2592     if test "$pkg_check_gtk" = "no" &&
2593        { test "$with_gtk" = yes || test "$with_gtk2" = "yes"; }
2594     then
2595       AC_MSG_ERROR($gtk3_pkg_errors$GTK_PKG_ERRORS)
2596     fi
2597     test "$pkg_check_gtk" = "yes" && USE_GTK_TOOLKIT="GTK2"
2598   fi
2601 OLD_CFLAGS=$CFLAGS
2602 OLD_LIBS=$LIBS
2604 if test x"$pkg_check_gtk" = xyes; then
2606   AC_SUBST(GTK_LIBS)
2607   CFLAGS="$CFLAGS $GTK_CFLAGS"
2608   LIBS="$GTK_LIBS $LIBS"
2609   dnl Try to compile a simple GTK program.
2610   AC_CACHE_CHECK([whether GTK compiles], [emacs_cv_gtk_compiles],
2611   [AC_LINK_IFELSE(
2612     [AC_LANG_PROGRAM(
2613        [[/* Check the Gtk and Glib APIs.  */
2614          #include <gtk/gtk.h>
2615          #include <glib-object.h>
2616          static void
2617          callback (GObject *go, GParamSpec *spec, gpointer user_data)
2618          {}
2619        ]],
2620        [[
2621          GtkSettings *gs = 0;
2622          /* Use G_CALLBACK to make sure function pointers can be cast to void *;
2623             strict C prohibits this.  Use gtk_main_iteration to test that the
2624             libraries are there.  */
2625          if (g_signal_handler_find (G_OBJECT (gs), G_SIGNAL_MATCH_FUNC,
2626                                     0, 0, 0, G_CALLBACK (callback), 0))
2627            gtk_main_iteration ();
2628        ]])],
2629     [emacs_cv_gtk_compiles=yes], [emacs_cv_gtk_compiles=no])])
2630   if test "${emacs_cv_gtk_compiles}" != "yes"; then
2631     GTK_OBJ=
2632     if test "$USE_X_TOOLKIT" != "maybe"; then
2633       AC_MSG_ERROR([Gtk+ wanted, but it does not compile, see config.log.  Maybe some x11-devel files missing?]);
2634     fi
2635   else
2636     C_SWITCH_X_SITE="$C_SWITCH_X_SITE $GTK_CFLAGS"
2637     HAVE_GTK=yes
2638     AC_DEFINE(USE_GTK, 1, [Define to 1 if using GTK.])
2639     GTK_OBJ="gtkutil.o $GTK_OBJ"
2640     term_header=$gtk_term_header
2641     USE_X_TOOLKIT=none
2642     AC_MSG_WARN([[Your version of Gtk+ will have problems with
2643        closing open displays.  This is no problem if you just use
2644        one display, but if you use more than one and close one of them
2645        Emacs may crash.
2646        See http://bugzilla.gnome.org/show_bug.cgi?id=85715]])
2647   fi
2650 AC_SUBST(GTK_OBJ)
2653 if test "${HAVE_GTK}" = "yes"; then
2655   dnl  GTK scrollbars resemble toolkit scrollbars a lot, so to avoid
2656   dnl  a lot if #ifdef:s, say we have toolkit scrollbars.
2657   if test "$with_toolkit_scroll_bars" != no; then
2658     with_toolkit_scroll_bars=yes
2659   fi
2661   dnl  Check if we have the old file selection dialog declared and
2662   dnl  in the link library.  In 2.x it may be in the library,
2663   dnl  but not declared if deprecated featured has been selected out.
2664   dnl  AC_CHECK_DECL checks for a macro, so check for GTK_TYPE_FILE_SELECTION.
2665   HAVE_GTK_FILE_SELECTION=no
2666   AC_CHECK_DECL(GTK_TYPE_FILE_SELECTION, HAVE_GTK_FILE_SELECTION=yes,
2667                    HAVE_GTK_FILE_SELECTION=no, [AC_INCLUDES_DEFAULT
2668 #include <gtk/gtk.h>])
2669   if test "$HAVE_GTK_FILE_SELECTION" = yes; then
2670     AC_CHECK_FUNCS(gtk_file_selection_new)
2671   fi
2673   dnl Same as above for gtk_handle_box.
2674   HAVE_GTK_HANDLE_BOX=no
2675   AC_CHECK_DECL(GTK_TYPE_HANDLE_BOX, HAVE_GTK_HANDLE_BOX=yes,
2676                    HAVE_GTK_HANDLE_BOX=no, [AC_INCLUDES_DEFAULT
2677 #include <gtk/gtk.h>])
2678   if test "$HAVE_GTK_HANDLE_BOX" = yes; then
2679     AC_CHECK_FUNCS(gtk_handle_box_new)
2680   fi
2682   dnl Same as above for gtk_tearoff_menu_item.
2683   HAVE_GTK_TEAROFF_MENU_ITEM=no
2684   AC_CHECK_DECL(GTK_TYPE_TEAROFF_MENU_ITEM, HAVE_GTK_TEAROFF_MENU_ITEM=yes,
2685                    HAVE_GTK_TEAROFF_MENU_ITEM=no, [AC_INCLUDES_DEFAULT
2686 #include <gtk/gtk.h>])
2687   if test "$HAVE_GTK_TEAROFF_MENU_ITEM" = yes; then
2688     AC_CHECK_FUNCS(gtk_tearoff_menu_item_new)
2689   fi
2691   dnl Check for functions introduced in 2.14 and later.
2692   AC_CHECK_FUNCS(gtk_widget_get_window gtk_widget_set_has_window \
2693                  gtk_dialog_get_action_area gtk_widget_get_sensitive \
2694                  gtk_widget_get_mapped gtk_adjustment_get_page_size \
2695                  gtk_orientable_set_orientation \
2696                  gtk_window_set_has_resize_grip)
2698  term_header=gtkutil.h
2702 dnl Enable xwidgets if GTK3 and WebKitGTK+ are available.
2703 HAVE_XWIDGETS=no
2704 XWIDGETS_OBJ=
2705 if test "$with_xwidgets" != "no"; then
2706   test "$USE_GTK_TOOLKIT" = "GTK3" && test "$window_system" != "none" ||
2707     AC_MSG_ERROR([xwidgets requested but gtk3 not used.])
2709   WEBKIT_REQUIRED=2.12
2710   WEBKIT_MODULES="webkit2gtk-4.0 >= $WEBKIT_REQUIRED"
2711   EMACS_CHECK_MODULES([WEBKIT], [$WEBKIT_MODULES])
2712   HAVE_XWIDGETS=$HAVE_WEBKIT
2713   test $HAVE_XWIDGETS = yes ||
2714     AC_MSG_ERROR([xwidgets requested but WebKitGTK+ not found.])
2716   XWIDGETS_OBJ=xwidget.o
2717   AC_DEFINE([HAVE_XWIDGETS], 1, [Define to 1 if you have xwidgets support.])
2719 AC_SUBST(XWIDGETS_OBJ)
2721 CFLAGS=$OLD_CFLAGS
2722 LIBS=$OLD_LIBS
2724 dnl D-Bus has been tested under GNU/Linux only.  Must be adapted for
2725 dnl other platforms.
2726 HAVE_DBUS=no
2727 DBUS_OBJ=
2728 if test "${with_dbus}" = "yes"; then
2729    EMACS_CHECK_MODULES([DBUS], [dbus-1 >= 1.0])
2730    if test "$HAVE_DBUS" = yes; then
2731      AC_DEFINE(HAVE_DBUS, 1, [Define to 1 if using D-Bus.])
2732      dnl dbus_watch_get_unix_fd has been introduced in D-Bus 1.1.1.
2733      dnl dbus_type_is_valid and dbus_validate_* have been introduced in
2734      dnl D-Bus 1.5.12.
2735      OLD_LIBS=$LIBS
2736      LIBS="$LIBS $DBUS_LIBS"
2737      AC_CHECK_FUNCS(dbus_watch_get_unix_fd \
2738                     dbus_type_is_valid \
2739                     dbus_validate_bus_name \
2740                     dbus_validate_path \
2741                     dbus_validate_interface \
2742                     dbus_validate_member)
2743      LIBS=$OLD_LIBS
2744      DBUS_OBJ=dbusbind.o
2745    fi
2747 AC_SUBST(DBUS_CFLAGS)
2748 AC_SUBST(DBUS_LIBS)
2749 AC_SUBST(DBUS_OBJ)
2751 dnl GSettings has been tested under GNU/Linux only.
2752 HAVE_GSETTINGS=no
2753 if test "${HAVE_X11}" = "yes" && test "${with_gsettings}" = "yes"; then
2754    EMACS_CHECK_MODULES([GSETTINGS], [gio-2.0 >= 2.26])
2755    if test "$HAVE_GSETTINGS" = "yes"; then
2756       old_CFLAGS=$CFLAGS
2757       CFLAGS="$CFLAGS $GSETTINGS_CFLAGS"
2758       old_LIBS=$LIBS
2759       LIBS="$LIBS $GSETTINGS_LIBS"
2760       AC_CACHE_CHECK([whether GSettings is in gio], [emacs_cv_gsettings_in_gio],
2761       [AC_LINK_IFELSE(
2762          [AC_LANG_PROGRAM(
2763              [[/* Check that gsettings really is present.  */
2764              #include <glib-object.h>
2765              #include <gio/gio.h>
2766              ]],
2767              [[
2768                GSettings *settings;
2769                GVariant *val = g_settings_get_value (settings, "");
2770              ]])],
2771        [emacs_cv_gsettings_in_gio=yes], [emacs_cv_gsettings_in_gio=no])])
2773       if test "$emacs_cv_gsettings_in_gio" = "yes"; then
2774         AC_DEFINE(HAVE_GSETTINGS, 1, [Define to 1 if using GSettings.])
2775         SETTINGS_CFLAGS="$GSETTINGS_CFLAGS"
2776         SETTINGS_LIBS="$GSETTINGS_LIBS"
2777         test "$with_gconf" = "yes" || with_gconf=no
2778       fi
2779       CFLAGS=$old_CFLAGS
2780       LIBS=$old_LIBS
2781    fi
2784 dnl GConf has been tested under GNU/Linux only.
2785 dnl The version is really arbitrary, it is about the same age as Gtk+ 2.6.
2786 HAVE_GCONF=no
2787 if test "${HAVE_X11}" = "yes" && test "${with_gconf}" != "no"; then
2788    EMACS_CHECK_MODULES([GCONF], [gconf-2.0 >= 2.13])
2789    if test "$HAVE_GCONF" = yes; then
2790       AC_DEFINE(HAVE_GCONF, 1, [Define to 1 if using GConf.])
2791       dnl Newer GConf doesn't link with g_objects, so this is not defined.
2792       SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GCONF_CFLAGS"
2793       SETTINGS_LIBS="$SETTINGS_LIBS $GCONF_LIBS"
2794    fi
2797 if test "$HAVE_GSETTINGS" = "yes" || test "$HAVE_GCONF" = "yes"; then
2798     EMACS_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.0])
2799     if test "$HAVE_GOBJECT" = "yes"; then
2800        SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GOBJECT_CFLAGS"
2801        SETTINGS_LIBS="$SETTINGS_LIBS $GOBJECT_LIBS"
2802     fi
2803     SAVE_CFLAGS="$CFLAGS"
2804     SAVE_LIBS="$LIBS"
2805     CFLAGS="$SETTINGS_CFLAGS $CFLAGS"
2806     LIBS="$SETTINGS_LIBS $LIBS"
2807     CFLAGS="$SAVE_CFLAGS"
2808     LIBS="$SAVE_LIBS"
2810 AC_SUBST(SETTINGS_CFLAGS)
2811 AC_SUBST(SETTINGS_LIBS)
2814 dnl SELinux is available for GNU/Linux only.
2815 HAVE_LIBSELINUX=no
2816 LIBSELINUX_LIBS=
2817 if test "${with_selinux}" = "yes"; then
2818    AC_CHECK_LIB([selinux], [lgetfilecon], HAVE_LIBSELINUX=yes, HAVE_LIBSELINUX=no)
2819    if test "$HAVE_LIBSELINUX" = yes; then
2820       AC_DEFINE(HAVE_LIBSELINUX, 1, [Define to 1 if using SELinux.])
2821       LIBSELINUX_LIBS=-lselinux
2822    fi
2824 AC_SUBST(LIBSELINUX_LIBS)
2826 HAVE_GNUTLS=no
2827 if test "${with_gnutls}" = "yes" ; then
2828   EMACS_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.12.2],
2829     [HAVE_GNUTLS=yes], [HAVE_GNUTLS=no])
2830   if test "${HAVE_GNUTLS}" = "yes"; then
2831     AC_DEFINE(HAVE_GNUTLS, 1, [Define if using GnuTLS.])
2832   fi
2834   # Windows loads GnuTLS dynamically
2835   if test "${opsys}" = "mingw32"; then
2836     LIBGNUTLS_LIBS=
2837   fi
2840 AC_SUBST(LIBGNUTLS_LIBS)
2841 AC_SUBST(LIBGNUTLS_CFLAGS)
2843 HAVE_LIBSYSTEMD=no
2844 if test "${with_libsystemd}" = "yes" ; then
2845   dnl This code has been tested with libsystemd 222 and later.
2846   dnl FIXME: Find the earliest version number for which Emacs should work,
2847   dnl and change '222' to that number.
2848   EMACS_CHECK_MODULES([LIBSYSTEMD], [libsystemd >= 222],
2849     [HAVE_LIBSYSTEMD=yes], [HAVE_LIBSYSTEMD=no])
2850   if test "${HAVE_LIBSYSTEMD}" = "yes"; then
2851     AC_DEFINE(HAVE_LIBSYSTEMD, 1, [Define if using libsystemd.])
2852   fi
2855 AC_SUBST(LIBSYSTEMD_LIBS)
2856 AC_SUBST(LIBSYSTEMD_CFLAGS)
2858 NOTIFY_OBJ=
2859 NOTIFY_SUMMARY=no
2861 dnl MS Windows native file monitor is available for mingw32 only.
2862 case $with_file_notification,$opsys in
2863   w32,cygwin)
2864     AC_MSG_ERROR(['--with-file-notification=w32' was specified, but
2865     this is only supported on MS-Windows native and MinGW32 builds.
2866     Consider using gfile instead.])
2867     ;;
2868   w32,* | yes,mingw32)
2869     AC_CHECK_HEADER(windows.h)
2870     if test "$ac_cv_header_windows_h" = yes ; then
2871        AC_DEFINE(HAVE_W32NOTIFY, 1, [Define to 1 to use w32notify.])
2872        NOTIFY_OBJ=w32notify.o
2873        NOTIFY_SUMMARY="yes (w32)"
2874     fi ;;
2875 esac
2877 dnl inotify is available only on GNU/Linux.
2878 case $with_file_notification,$NOTIFY_OBJ in
2879   inotify, | yes,)
2880     AC_CHECK_HEADER(sys/inotify.h)
2881     if test "$ac_cv_header_sys_inotify_h" = yes ; then
2882         AC_CHECK_FUNC(inotify_init1)
2883         if test "$ac_cv_func_inotify_init1" = yes; then
2884           AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 to use inotify.])
2885           NOTIFY_OBJ=inotify.o
2886           NOTIFY_SUMMARY="yes -lglibc (inotify)"
2887        fi
2888     fi ;;
2889 esac
2891 dnl kqueue is available on BSD-like systems.
2892 case $with_file_notification,$NOTIFY_OBJ in
2893   kqueue,* | yes,)
2894     EMACS_CHECK_MODULES([KQUEUE], [libkqueue])
2895     if test "$HAVE_KQUEUE" = "yes"; then
2896        AC_DEFINE(HAVE_KQUEUE, 1, [Define to 1 to use kqueue.])
2897        CPPFLAGS="$CPPFLAGS -I/usr/include/kqueue"
2898        NOTIFY_CFLAGS=$KQUEUE_CFLAGS
2899        NOTIFY_LIBS=$KQUEUE_LIBS
2900        NOTIFY_OBJ=kqueue.o
2901        NOTIFY_SUMMARY="yes -lkqueue"
2902     else
2903        AC_SEARCH_LIBS(kqueue, [])
2904        if test "$ac_cv_search_kqueue" != no; then
2905          AC_DEFINE(HAVE_KQUEUE, 1, [Define to 1 to use kqueue.])
2906          NOTIFY_OBJ=kqueue.o
2907          NOTIFY_SUMMARY="yes (kqueue)"
2908        fi
2909     fi ;;
2910 esac
2912 dnl g_file_monitor exists since glib 2.18.  G_FILE_MONITOR_EVENT_MOVED
2913 dnl has been added in glib 2.24.  It has been tested under
2914 dnl GNU/Linux only.
2915 case $with_file_notification,$NOTIFY_OBJ in
2916   gfile,* | yes,)
2917     if test "${HAVE_NS}" = yes; then
2918        AC_MSG_ERROR(['--with-file-notification=gfile' is not supported in NextStep builds.
2919 Consider kqueue instead.])
2920     else
2921        EMACS_CHECK_MODULES([GFILENOTIFY], [gio-2.0 >= 2.24])
2922        if test "$HAVE_GFILENOTIFY" = "yes"; then
2923           AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.])
2924           NOTIFY_CFLAGS=$GFILENOTIFY_CFLAGS
2925           NOTIFY_LIBS=$GFILENOTIFY_LIBS
2926           NOTIFY_OBJ=gfilenotify.o
2927           NOTIFY_SUMMARY="yes -lgio (gfile)"
2928        fi
2929     fi ;;
2930 esac
2932 case $with_file_notification,$NOTIFY_OBJ in
2933   yes,* | no,* | *,?*) ;;
2934   *) AC_MSG_ERROR([File notification '$with_file_notification' requested but requirements not found.]) ;;
2935 esac
2937 if test -n "$NOTIFY_OBJ"; then
2938    AC_DEFINE(USE_FILE_NOTIFY, 1, [Define to 1 if using file notifications.])
2940 AC_SUBST(NOTIFY_CFLAGS)
2941 AC_SUBST(NOTIFY_LIBS)
2942 AC_SUBST(NOTIFY_OBJ)
2944 dnl Do not put whitespace before the #include statements below.
2945 dnl Older compilers (eg sunos4 cc) choke on it.
2946 HAVE_XAW3D=no
2947 LUCID_LIBW=
2948 if test x"${USE_X_TOOLKIT}" = xmaybe || test x"${USE_X_TOOLKIT}" = xLUCID; then
2949   if test "$with_xaw3d" != no; then
2950     AC_CACHE_VAL(emacs_cv_xaw3d,
2951     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2952 #include <X11/Intrinsic.h>
2953 #include <X11/Xaw3d/Simple.h>]],
2954       [[]])],
2955       [AC_CHECK_LIB(Xaw3d, XawScrollbarSetThumb,
2956                     emacs_cv_xaw3d=yes, emacs_cv_xaw3d=no)],
2957       emacs_cv_xaw3d=no)])
2958   else
2959     emacs_cv_xaw3d=no
2960   fi
2961   if test $emacs_cv_xaw3d = yes; then
2962     AC_MSG_CHECKING(for xaw3d)
2963     AC_MSG_RESULT([yes; using Lucid toolkit])
2964     USE_X_TOOLKIT=LUCID
2965     HAVE_XAW3D=yes
2966     LUCID_LIBW=-lXaw3d
2967     AC_DEFINE(HAVE_XAW3D, 1,
2968               [Define to 1 if you have the Xaw3d library (-lXaw3d).])
2969   else
2970     AC_MSG_CHECKING(for xaw3d)
2971     AC_MSG_RESULT(no)
2972     AC_MSG_CHECKING(for libXaw)
2973     AC_CACHE_VAL(emacs_cv_xaw,
2974     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2975 #include <X11/Intrinsic.h>
2976 #include <X11/Xaw/Simple.h>]],
2977       [[]])],
2978       emacs_cv_xaw=yes,
2979       emacs_cv_xaw=no)])
2980     if test $emacs_cv_xaw = yes; then
2981       AC_MSG_RESULT([yes; using Lucid toolkit])
2982       USE_X_TOOLKIT=LUCID
2983       LUCID_LIBW=-lXaw
2984     elif test x"${USE_X_TOOLKIT}" = xLUCID; then
2985       AC_MSG_ERROR([Lucid toolkit requires X11/Xaw include files])
2986     else
2987       AC_MSG_ERROR([No X toolkit could be found.
2988 If you are sure you want Emacs compiled without an X toolkit, pass
2989   --with-x-toolkit=no
2990 to configure.  Otherwise, install the development libraries for the toolkit
2991 that you want to use (e.g. Gtk+) and re-run configure.])
2992     fi
2993   fi
2996 X_TOOLKIT_TYPE=$USE_X_TOOLKIT
2998 LIBXTR6=
2999 LIBXMU=
3000 if test "${USE_X_TOOLKIT}" != "none"; then
3001   AC_MSG_CHECKING(X11 toolkit version)
3002   AC_CACHE_VAL(emacs_cv_x11_toolkit_version_6,
3003   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Intrinsic.h>]],
3004 [[#if XtSpecificationRelease < 6
3005 fail;
3006 #endif
3007 ]])], emacs_cv_x11_toolkit_version_6=yes, emacs_cv_x11_toolkit_version_6=no)])
3008   HAVE_X11XTR6=$emacs_cv_x11_toolkit_version_6
3009   if test $emacs_cv_x11_toolkit_version_6 = yes; then
3010     AC_MSG_RESULT(6 or newer)
3011     AC_DEFINE(HAVE_X11XTR6, 1,
3012               [Define to 1 if you have the X11R6 or newer version of Xt.])
3013     LIBXTR6="-lSM -lICE"
3014     case "$opsys" in
3015       ## Use libw.a along with X11R6 Xt.
3016       unixware) LIBXTR6="$LIBXTR6 -lw" ;;
3017     esac
3018   else
3019     AC_MSG_RESULT(before 6)
3020   fi
3022 dnl If using toolkit, check whether libXmu.a exists.
3023 dnl tranle@intellicorp.com says libXmu.a can need XtMalloc in libXt.a to link.
3024   OLDLIBS="$LIBS"
3025   if test x$HAVE_X11XTR6 = xyes; then
3026     OTHERLIBS='-lXt -lSM -lICE'
3027   else
3028     OTHERLIBS='-lXt'
3029   fi
3030   AC_SEARCH_LIBS([XmuConvertStandardSelection], [Xmu], [], [], [$OTHERLIBS])
3031   if test "X$LIBS" != "X$OLDLIBS"; then
3032     LIBXMU=$ac_cv_search_XmuConvertStandardSelection
3033   fi
3034   LIBS=$OLDLIBS
3035   dnl ac_cv_search_XmuConvertStandardSelection is also referenced below.
3037 AC_SUBST(LIBXTR6)
3038 AC_SUBST(LIBXMU)
3040 LIBXP=
3041 if test "${USE_X_TOOLKIT}" = "MOTIF"; then
3042   # OpenMotif may be installed in such a way on some GNU/Linux systems.
3043   if test -d /usr/include/openmotif; then
3044     CPPFLAGS="-I/usr/include/openmotif $CPPFLAGS"
3045     emacs_cv_openmotif=yes
3046     case "$canonical" in
3047       x86_64-*-linux-gnu* | powerpc64-*-linux-gnu* | sparc64-*-linux-gnu*)
3048       test -d /usr/lib64/openmotif && LDFLAGS="-L/usr/lib64/openmotif $LDFLAGS"
3049       ;;
3050       *)
3051       test -d /usr/lib/openmotif && LDFLAGS="-L/usr/lib/openmotif $LDFLAGS"
3052     esac
3053   else
3054     emacs_cv_openmotif=no
3055   fi
3056   AC_CACHE_CHECK(for (Open)Motif version 2.1, emacs_cv_motif_version_2_1,
3057   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <Xm/Xm.h>]],
3058     [[#if XmVERSION > 2 || (XmVERSION == 2 && XmREVISION >= 1)
3059 int x = 5;
3060 #else
3061 Motif version prior to 2.1.
3062 #endif]])],
3063     emacs_cv_motif_version_2_1=yes, emacs_cv_motif_version_2_1=no)])
3064   if test $emacs_cv_motif_version_2_1 = yes; then
3065     AC_CHECK_LIB(Xp, XpCreateContext, LIBXP=-lXp)
3066     if test x$emacs_cv_openmotif = xyes; then
3067       REAL_CPPFLAGS="-I/usr/include/openmotif $REAL_CPPFLAGS"
3068     fi
3069   else
3070     AC_CACHE_CHECK(for LessTif where some systems put it, emacs_cv_lesstif,
3071     # We put this in CFLAGS temporarily to precede other -I options
3072     # that might be in CFLAGS temporarily.
3073     # We put this in CPPFLAGS where it precedes the other -I options.
3074     OLD_CPPFLAGS=$CPPFLAGS
3075     OLD_CFLAGS=$CFLAGS
3076     CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CPPFLAGS"
3077     CFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CFLAGS"
3078     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include </usr/X11R6/LessTif/Motif1.2/include/Xm/Xm.h>]],
3079       [[int x = 5;]])],
3080       emacs_cv_lesstif=yes, emacs_cv_lesstif=no)])
3081     if test $emacs_cv_lesstif = yes; then
3082       # Make sure this -I option remains in CPPFLAGS after it is set
3083       # back to REAL_CPPFLAGS.
3084       # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
3085       # have those other -I options anyway.  Ultimately, having this
3086       # directory ultimately in CPPFLAGS will be enough.
3087       REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
3088       LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
3089     else
3090       CFLAGS=$OLD_CFLAGS
3091       CPPFLAGS=$OLD_CPPFLAGS
3092     fi
3093   fi
3094   AC_CHECK_HEADER([Xm/BulletinB.h], [],
3095     [AC_MSG_ERROR([Motif toolkit requested but requirements not found.])])
3098 dnl Use toolkit scroll bars if configured for GTK or X toolkit and either
3099 dnl using Motif or Xaw3d is available, and unless
3100 dnl --with-toolkit-scroll-bars=no was specified.
3102 AH_TEMPLATE(USE_TOOLKIT_SCROLL_BARS,
3103             [Define to 1 if we should use toolkit scroll bars.])dnl
3104 USE_TOOLKIT_SCROLL_BARS=no
3105 if test "${with_toolkit_scroll_bars}" != "no"; then
3106   if test "${USE_X_TOOLKIT}" != "none"; then
3107     if test "${USE_X_TOOLKIT}" = "MOTIF"; then
3108       AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3109       HAVE_XAW3D=no
3110       USE_TOOLKIT_SCROLL_BARS=yes
3111     elif test "${HAVE_XAW3D}" = "yes" || test "${USE_X_TOOLKIT}" = "LUCID"; then
3112       AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3113       USE_TOOLKIT_SCROLL_BARS=yes
3114     fi
3115   elif test "${HAVE_GTK}" = "yes"; then
3116     AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3117     USE_TOOLKIT_SCROLL_BARS=yes
3118   elif test "${HAVE_NS}" = "yes"; then
3119     AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3120     USE_TOOLKIT_SCROLL_BARS=yes
3121   elif test "${HAVE_W32}" = "yes"; then
3122     AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
3123     USE_TOOLKIT_SCROLL_BARS=yes
3124   fi
3127 dnl See if XIM is available.
3128 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3129           #include <X11/Xlib.h>
3130           #include <X11/Xresource.h>]],
3131          [[XIMProc  callback;]])],
3132          [HAVE_XIM=yes
3133          AC_DEFINE(HAVE_XIM, 1, [Define to 1 if XIM is available])],
3134          HAVE_XIM=no)
3136 dnl '--with-xim' now controls only the initial value of use_xim at run time.
3138 if test "${with_xim}" != "no"; then
3139   AC_DEFINE(USE_XIM, 1,
3140             [Define to 1 if we should use XIM, if it is available.])
3144 if test "${HAVE_XIM}" != "no"; then
3145   late_CFLAGS=$CFLAGS
3146   if test "$GCC" = yes; then
3147     CFLAGS="$CFLAGS --pedantic-errors"
3148   fi
3149   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3150 #include <X11/Xlib.h>
3151 #include <X11/Xresource.h>]],
3152 [[Display *display;
3153 XrmDatabase db;
3154 char *res_name;
3155 char *res_class;
3156 XIMProc  callback;
3157 XPointer *client_data;
3158 #ifndef __GNUC__
3159 /* If we're not using GCC, it's probably not XFree86, and this is
3160    probably right, but we can't use something like --pedantic-errors.  */
3161 extern Bool XRegisterIMInstantiateCallback(Display*, XrmDatabase, char*,
3162                                            char*, XIMProc, XPointer*);
3163 #endif
3164 (void)XRegisterIMInstantiateCallback(display, db, res_name, res_class, callback,
3165    client_data);]])],
3166     [emacs_cv_arg6_star=yes])
3167   AH_TEMPLATE(XRegisterIMInstantiateCallback_arg6,
3168          [Define to the type of the 6th arg of XRegisterIMInstantiateCallback,
3169 either XPointer or XPointer*.])dnl
3170   if test "$emacs_cv_arg6_star" = yes; then
3171     AC_DEFINE(XRegisterIMInstantiateCallback_arg6, [XPointer*])
3172   else
3173     AC_DEFINE(XRegisterIMInstantiateCallback_arg6, [XPointer])
3174   fi
3175   CFLAGS=$late_CFLAGS
3178 ### Start of font-backend (under any platform) section.
3179 # (nothing here yet -- this is a placeholder)
3180 ### End of font-backend (under any platform) section.
3182 ### Start of font-backend (under X11) section.
3183 if test "${HAVE_X11}" = "yes"; then
3184     ## Use -lXft if available, unless '--with-xft=no'.
3185     HAVE_XFT=maybe
3186     if test "x${with_x}" = "xno"; then
3187       with_xft="no";
3188     fi
3190     if test "$with_xft" != no; then
3191       EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
3192       with_xft=$HAVE_FONTCONFIG
3193     fi
3195     if test "x${with_xft}" != "xno"; then
3197       EMACS_CHECK_MODULES([XFT], [xft >= 0.13.0], [], [HAVE_XFT=no])
3198       ## Because xftfont.c uses XRenderQueryExtension, we also
3199       ## need to link to -lXrender.
3200       HAVE_XRENDER=no
3201       AC_CHECK_LIB(Xrender, XRenderQueryExtension, HAVE_XRENDER=yes)
3202       if test "$HAVE_XFT" != no && test "$HAVE_XRENDER" != no; then
3203         OLD_CPPFLAGS="$CPPFLAGS"
3204         OLD_CFLAGS="$CFLAGS"
3205         OLD_LIBS="$LIBS"
3206         CPPFLAGS="$CPPFLAGS $XFT_CFLAGS"
3207         CFLAGS="$CFLAGS $XFT_CFLAGS"
3208         XFT_LIBS="-lXrender $XFT_LIBS"
3209         LIBS="$XFT_LIBS $LIBS"
3210         AC_CHECK_HEADER(X11/Xft/Xft.h,
3211           AC_CHECK_LIB(Xft, XftFontOpen, HAVE_XFT=yes, , $XFT_LIBS) , ,
3212           [[#include <X11/X.h>]])
3214         if test "${HAVE_XFT}" = "yes"; then
3215           AC_DEFINE(HAVE_XFT, 1, [Define to 1 if you have the Xft library.])
3216             AC_SUBST(XFT_LIBS)
3217           C_SWITCH_X_SITE="$C_SWITCH_X_SITE $XFT_CFLAGS"
3218         fi                        # "${HAVE_XFT}" = "yes"
3219         CPPFLAGS=$OLD_CPPFLAGS
3220         CFLAGS=$OLD_CFLAGS
3221         LIBS=$OLD_LIBS
3222       fi                          # "$HAVE_XFT" != no
3223     fi                            # "x${with_xft}" != "xno"
3225     ## We used to allow building with FreeType and without Xft.
3226     ## However, the ftx font backend driver is not in good shape.
3227     if test "$HAVE_XFT" != "yes"; then
3228        dnl For the "Does Emacs use" message at the end.
3229        HAVE_XFT=no
3230        HAVE_FREETYPE=no
3231     else
3232        dnl Strict linkers fail with
3233        dnl ftfont.o: undefined reference to symbol 'FT_New_Face'
3234        dnl if -lfreetype is not specified.
3235        dnl The following is needed to set FREETYPE_LIBS.
3236        EMACS_CHECK_MODULES([FREETYPE], [freetype2])
3238        test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(libxft requires libfreetype)
3239     fi
3241     HAVE_LIBOTF=no
3242     if test "${HAVE_FREETYPE}" = "yes"; then
3243       AC_DEFINE(HAVE_FREETYPE, 1,
3244                 [Define to 1 if using the freetype and fontconfig libraries.])
3245       if test "${with_libotf}" != "no"; then
3246         EMACS_CHECK_MODULES([LIBOTF], [libotf])
3247         if test "$HAVE_LIBOTF" = "yes"; then
3248           AC_DEFINE(HAVE_LIBOTF, 1, [Define to 1 if using libotf.])
3249           AC_CHECK_LIB(otf, OTF_get_variation_glyphs,
3250                        HAVE_OTF_GET_VARIATION_GLYPHS=yes,
3251                        HAVE_OTF_GET_VARIATION_GLYPHS=no)
3252           if test "${HAVE_OTF_GET_VARIATION_GLYPHS}" = "yes"; then
3253             AC_DEFINE(HAVE_OTF_GET_VARIATION_GLYPHS, 1,
3254                       [Define to 1 if libotf has OTF_get_variation_glyphs.])
3255           fi
3256         fi
3257       fi
3258     dnl FIXME should there be an error if HAVE_FREETYPE != yes?
3259     dnl Does the new font backend require it, or can it work without it?
3260     fi
3262     HAVE_M17N_FLT=no
3263     if test "${HAVE_LIBOTF}" = yes; then
3264       if test "${with_m17n_flt}" != "no"; then
3265         EMACS_CHECK_MODULES([M17N_FLT], [m17n-flt])
3266         if test "$HAVE_M17N_FLT" = "yes"; then
3267           AC_DEFINE(HAVE_M17N_FLT, 1, [Define to 1 if using libm17n-flt.])
3268         fi
3269       fi
3270     fi
3271 else
3272     HAVE_XFT=no
3273     HAVE_FREETYPE=no
3274     HAVE_LIBOTF=no
3275     HAVE_M17N_FLT=no
3278 ### End of font-backend (under X11) section.
3280 AC_SUBST(FREETYPE_CFLAGS)
3281 AC_SUBST(FREETYPE_LIBS)
3282 AC_SUBST(FONTCONFIG_CFLAGS)
3283 AC_SUBST(FONTCONFIG_LIBS)
3284 AC_SUBST(LIBOTF_CFLAGS)
3285 AC_SUBST(LIBOTF_LIBS)
3286 AC_SUBST(M17N_FLT_CFLAGS)
3287 AC_SUBST(M17N_FLT_LIBS)
3289 HAVE_CAIRO=no
3290 if test "${HAVE_X11}" = "yes"; then
3291   if test "${with_cairo}" != "no"; then
3292     CAIRO_REQUIRED=1.12.0
3293     CAIRO_MODULE="cairo >= $CAIRO_REQUIRED"
3294     EMACS_CHECK_MODULES(CAIRO, $CAIRO_MODULE)
3295     if test $HAVE_CAIRO = yes; then
3296       AC_DEFINE(USE_CAIRO, 1, [Define to 1 if using cairo.])
3297     else
3298       AC_MSG_ERROR([cairo requested but not found.])
3299     fi
3301     CFLAGS="$CFLAGS $CAIRO_CFLAGS"
3302     LIBS="$LIBS $CAIRO_LIBS"
3303     AC_SUBST(CAIRO_CFLAGS)
3304     AC_SUBST(CAIRO_LIBS)
3305   fi
3308 if test "${HAVE_X11}" = "yes"; then
3309   AC_CHECK_HEADER(X11/Xlib-xcb.h,
3310     AC_CHECK_LIB(xcb, xcb_translate_coordinates, HAVE_XCB=yes))
3311   if test "${HAVE_XCB}" = "yes"; then
3312     AC_CHECK_LIB(X11-xcb, XGetXCBConnection, HAVE_X11_XCB=yes)
3313     if test "${HAVE_X11_XCB}" = "yes"; then
3314       AC_DEFINE(USE_XCB, 1,
3315 [Define to 1 if you have the XCB library and X11-XCB library for mixed
3316    X11/XCB programming.])
3317       XCB_LIBS="-lX11-xcb -lxcb"
3318       AC_SUBST(XCB_LIBS)
3319     fi
3320   fi
3323 ### Use -lXpm if available, unless '--with-xpm=no'.
3324 ### mingw32 doesn't use -lXpm, since it loads the library dynamically.
3325 ### The Cygwin-w32 build uses <noX/xpm.h> instead of <X11/xpm.h>, so
3326 ### we need to set LDFLAGS accordingly.
3327 HAVE_XPM=no
3328 LIBXPM=
3329 if test "${HAVE_W32}" = "yes" && test "${opsys}" = "cygwin"; then
3330   if test "${with_xpm}" != "no"; then
3331     SAVE_LDFLAGS="$LDFLAGS"
3332     LDFLAGS="$LDFLAGS -L/usr/lib/noX"
3333     AC_CHECK_HEADER(noX/xpm.h,
3334       [AC_CHECK_LIB(Xpm, XpmReadFileToImage, HAVE_XPM=yes)])
3335     if test "${HAVE_XPM}" = "yes"; then
3336       AC_CACHE_CHECK([for XpmReturnAllocPixels preprocessor define],
3337       [emacs_cv_cpp_xpm_return_alloc_pixels],
3338       [AC_EGREP_CPP(no_return_alloc_pixels,
3339       [#include "noX/xpm.h"
3340 #ifndef XpmReturnAllocPixels
3341 no_return_alloc_pixels
3342 #endif
3343       ], emacs_cv_cpp_xpm_return_alloc_pixels=no,
3344       emacs_cv_cpp_xpm_return_alloc_pixels=yes)])
3346       if test "$emacs_cv_cpp_xpm_return_alloc_pixels" = "no"; then
3347         HAVE_XPM=no
3348         LDFLAGS="$SAVE_LDFLAGS"
3349       fi
3350     fi
3351   fi
3353   if test "${HAVE_XPM}" = "yes"; then
3354     AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
3355     LIBXPM=-lXpm
3356   fi
3359 if test "${HAVE_X11}" = "yes"; then
3360   dnl Avoid Xpm on AIX unless requested, as it crashes; see Bug#17598.
3361   test "$opsys$with_xpm_set" = aix4-2 && with_xpm=no
3363   if test "${with_xpm}" != "no"; then
3364     AC_CHECK_HEADER(X11/xpm.h,
3365       [AC_CHECK_LIB(Xpm, XpmReadFileToPixmap, HAVE_XPM=yes, , -lX11)])
3366     if test "${HAVE_XPM}" = "yes"; then
3367       AC_CACHE_CHECK([for XpmReturnAllocPixels preprocessor define],
3368       [emacs_cv_cpp_xpm_return_alloc_pixels],
3369       [AC_EGREP_CPP(no_return_alloc_pixels,
3370       [#include "X11/xpm.h"
3371 #ifndef XpmReturnAllocPixels
3372 no_return_alloc_pixels
3373 #endif
3374       ], emacs_cv_cpp_xpm_return_alloc_pixels=no,
3375       emacs_cv_cpp_xpm_return_alloc_pixels=yes)])
3377       if test "$emacs_cv_cpp_xpm_return_alloc_pixels" = "no"; then
3378         HAVE_XPM=no
3379       fi
3380     fi
3381   fi
3383   if test "${HAVE_XPM}" = "yes"; then
3384     AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
3385     LIBXPM=-lXpm
3386   elif test "$opsys,$LUCID_LIBW" = aix4-2,-lXaw; then
3387     dnl AIX -lXaw needs -lXpm linked too; see Bug#17598 Message#152.
3388     LIBXPM=-lXpm
3389   fi
3392 ### FIXME: Perhaps regroup to minimize code duplication due to MinGW's
3393 ### slightly different requirements wrt image libraries (it doesn't
3394 ### use -lXpm because it loads the xpm shared library dynamically at
3395 ### run time).
3396 if test "${opsys}" = "mingw32"; then
3397   if test "${with_xpm}" != "no"; then
3398     AC_CHECK_HEADER(X11/xpm.h, HAVE_XPM=yes, HAVE_XPM=no, [
3399 #define FOR_MSW 1])
3400   fi
3402   if test "${HAVE_XPM}" = "yes"; then
3403     AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
3404   fi
3407 AC_SUBST(LIBXPM)
3409 ### Use -ljpeg if available, unless '--with-jpeg=no'.
3410 HAVE_JPEG=no
3411 LIBJPEG=
3412 if test "${with_jpeg}" != "no"; then
3413   AC_CACHE_CHECK([for jpeglib 6b or later],
3414     [emacs_cv_jpeglib],
3415     [OLD_LIBS=$LIBS
3416      for emacs_cv_jpeglib in yes -ljpeg no; do
3417        case $emacs_cv_jpeglib in
3418          yes) ;;
3419          no) break;;
3420          *) LIBS="$LIBS $emacs_cv_jpeglib";;
3421        esac
3422        AC_LINK_IFELSE(
3423          [AC_LANG_PROGRAM(
3424             [[#undef HAVE_STDLIB_H /* Avoid config.h/jpeglib.h collision.  */
3425               #include <stdio.h> /* jpeglib.h needs FILE and size_t.  */
3426               #include <jpeglib.h>
3427               #include <jerror.h>
3428               char verify[JPEG_LIB_VERSION < 62 ? -1 : 1];
3429               struct jpeg_decompress_struct cinfo;
3430             ]],
3431             [[
3432               jpeg_create_decompress (&cinfo);
3433               WARNMS (&cinfo, JWRN_JPEG_EOF);
3434               jpeg_destroy_decompress (&cinfo);
3435             ]])],
3436          [emacs_link_ok=yes],
3437          [emacs_link_ok=no])
3438        LIBS=$OLD_LIBS
3439        test $emacs_link_ok = yes && break
3440      done])
3441   if test "$emacs_cv_jpeglib" != no; then
3442     HAVE_JPEG=yes
3443     AC_DEFINE([HAVE_JPEG], 1,
3444       [Define to 1 if you have the jpeg library (typically -ljpeg).])
3445     ### mingw32 doesn't use -ljpeg, since it loads the library
3446     ### dynamically when needed, and doesn't want a run-time
3447     ### dependency on the jpeglib DLL.
3448     test "$emacs_cv_jpeglib" != yes && test "${opsys}" != "mingw32" \
3449     && LIBJPEG=$emacs_cv_jpeglib
3450   fi
3452 AC_SUBST(LIBJPEG)
3454 HAVE_ZLIB=no
3455 LIBZ=
3456 if test "${with_zlib}" != "no"; then
3457   OLIBS=$LIBS
3458   AC_SEARCH_LIBS([inflateEnd], [z], [HAVE_ZLIB=yes])
3459   LIBS=$OLIBS
3460   case $ac_cv_search_inflateEnd in
3461     -*) LIBZ=$ac_cv_search_inflateEnd ;;
3462   esac
3464 if test "${HAVE_ZLIB}" = "yes"; then
3465   AC_DEFINE([HAVE_ZLIB], 1, [Define to 1 if you have the zlib library (-lz).])
3466   ### mingw32 doesn't use -lz, since it loads the library dynamically.
3467   if test "${opsys}" = "mingw32"; then
3468      LIBZ=
3469   fi
3471 AC_SUBST(LIBZ)
3473 ### Dynamic modules support
3474 LIBMODULES=
3475 HAVE_MODULES=no
3476 MODULES_OBJ=
3477 case $opsys in
3478   cygwin|mingw32) MODULES_SUFFIX=".dll" ;;
3479   *) MODULES_SUFFIX=".so" ;;
3480 esac
3481 if test "${with_modules}" != "no"; then
3482   case $opsys in
3483     gnu|gnu-linux)
3484       LIBMODULES="-ldl"
3485       HAVE_MODULES=yes
3486       ;;
3487     cygwin|mingw32|darwin)
3488       HAVE_MODULES=yes
3489       ;;
3490     *)
3491       # BSD systems have dlopen in libc.
3492       AC_CHECK_FUNC([dlopen], [HAVE_MODULES=yes])
3493       ;;
3494   esac
3496   if test "${HAVE_MODULES}" = no; then
3497     AC_MSG_ERROR([Dynamic modules are not supported on your system])
3498   else
3499     SAVE_LIBS=$LIBS
3500     LIBS="$LIBS $LIBMODULES"
3501     AC_CHECK_FUNCS([dladdr dlfunc])
3502     LIBS=$SAVE_LIBS
3503   fi
3506 if test "${HAVE_MODULES}" = yes; then
3507    MODULES_OBJ="dynlib.o emacs-module.o"
3508    AC_DEFINE(HAVE_MODULES, 1, [Define to 1 if dynamic modules are enabled])
3509    AC_DEFINE_UNQUOTED(MODULES_SUFFIX, "$MODULES_SUFFIX",
3510      [System extension for dynamic libraries])
3512 AC_SUBST(MODULES_OBJ)
3513 AC_SUBST(LIBMODULES)
3514 AC_SUBST(HAVE_MODULES)
3515 AC_SUBST(MODULES_SUFFIX)
3517 AC_CONFIG_FILES([src/emacs-module.h])
3518 AC_SUBST_FILE([module_env_snippet_25])
3519 AC_SUBST_FILE([module_env_snippet_26])
3520 module_env_snippet_25="$srcdir/src/module-env-25.h"
3521 module_env_snippet_26="$srcdir/src/module-env-26.h"
3523 ### Use -lpng if available, unless '--with-png=no'.
3524 HAVE_PNG=no
3525 LIBPNG=
3526 PNG_CFLAGS=
3527 if test "${NS_IMPL_COCOA}" = yes; then
3528   : # Nothing to do
3529 elif test "${with_png}" != no; then
3530   # mingw32 loads the library dynamically.
3531   if test "$opsys" = mingw32; then
3532     AC_CHECK_HEADER([png.h], [HAVE_PNG=yes])
3533   elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
3534     AC_MSG_CHECKING([for png])
3535     png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` &&
3536     png_ldflags=`(libpng-config --ldflags) 2>&AS_MESSAGE_LOG_FD` || {
3537       # libpng-config does not work; configure by hand.
3538       # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
3539       # in /usr/include/libpng.
3540       if test -r /usr/include/libpng/png.h &&
3541          test ! -r /usr/include/png.h; then
3542         png_cflags=-I/usr/include/libpng
3543       else
3544         png_cflags=
3545       fi
3546       png_ldflags='-lpng'
3547     }
3548     SAVE_CFLAGS=$CFLAGS
3549     SAVE_LIBS=$LIBS
3550     CFLAGS="$CFLAGS $png_cflags"
3551     LIBS="$png_ldflags -lz -lm $LIBS"
3552     AC_LINK_IFELSE(
3553       [AC_LANG_PROGRAM([[#include <png.h>]],
3554          [[return !png_get_channels (0, 0);]])],
3555       [HAVE_PNG=yes
3556        PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"`
3557        LIBPNG=$png_ldflags
3558        # $LIBPNG requires explicit -lz in some cases.
3559        # We don't know what those cases are, exactly, so play it safe and
3560        # append -lz to any nonempty $LIBPNG, unless we're already using LIBZ.
3561        if test -n "$LIBPNG" && test -z "$LIBZ"; then
3562          LIBPNG="$LIBPNG -lz"
3563        fi])
3564     CFLAGS=$SAVE_CFLAGS
3565     LIBS=$SAVE_LIBS
3566     AC_MSG_RESULT([$HAVE_PNG])
3567   fi
3569 if test $HAVE_PNG = yes; then
3570   AC_DEFINE([HAVE_PNG], [1], [Define to 1 if you have the png library.])
3572   SAVE_CFLAGS=$CFLAGS
3573   CFLAGS="$CFLAGS $PNG_CFLAGS"
3574   AC_CHECK_DECL([png_longjmp],
3575     [],
3576     [AC_DEFINE([PNG_DEPSTRUCT], [],
3577        [Define to empty to suppress deprecation warnings when building
3578         with --enable-gcc-warnings and with libpng versions before 1.5,
3579         which lack png_longjmp.])],
3580     [[#include <png.h>
3581     ]])
3582   CFLAGS=$SAVE_CFLAGS
3584 AC_SUBST(LIBPNG)
3585 AC_SUBST(PNG_CFLAGS)
3587 ### Use -ltiff if available, unless '--with-tiff=no'.
3588 ### mingw32 doesn't use -ltiff, since it loads the library dynamically.
3589 HAVE_TIFF=no
3590 LIBTIFF=
3591 if test "${opsys}" = "mingw32"; then
3592   if test "${with_tiff}" != "no"; then
3593     AC_CHECK_HEADER(tiffio.h, HAVE_TIFF=yes, HAVE_TIFF=no)
3594   fi
3595   if test "${HAVE_TIFF}" = "yes"; then
3596     AC_DEFINE(HAVE_TIFF, 1, [Define to 1 if you have the tiff library (-ltiff).])
3597   fi
3598 elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
3599   if test "${with_tiff}" != "no"; then
3600     AC_CHECK_HEADER(tiffio.h,
3601       [tifflibs="-lz -lm"
3602       # At least one tiff package requires the jpeg library.
3603       if test "${HAVE_JPEG}" = yes; then tifflibs="-ljpeg $tifflibs"; fi
3604       AC_CHECK_LIB(tiff, TIFFGetVersion, HAVE_TIFF=yes, , $tifflibs)])
3605   fi
3607   if test "${HAVE_TIFF}" = "yes"; then
3608     AC_DEFINE(HAVE_TIFF, 1, [Define to 1 if you have the tiff library (-ltiff).])
3609     dnl FIXME -lz -lm, as per libpng?
3610     LIBTIFF=-ltiff
3611   fi
3613 AC_SUBST(LIBTIFF)
3615 ### Use -lgif or -lungif if available, unless '--with-gif=no'.
3616 ### mingw32 doesn't use -lgif/-lungif, since it loads the library dynamically.
3617 HAVE_GIF=no
3618 LIBGIF=
3619 if test "${opsys}" = "mingw32"; then
3620   if test "${with_gif}" != "no"; then
3621     AC_CHECK_HEADER(gif_lib.h, HAVE_GIF=yes, HAVE_GIF=no)
3622   fi
3623   if test "${HAVE_GIF}" = "yes"; then
3624     AC_DEFINE(HAVE_GIF, 1, [Define to 1 if you have a gif (or ungif) library.])
3625   fi
3626 elif test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no" \
3627         || test "${HAVE_W32}" = "yes"; then
3628   AC_CHECK_HEADER(gif_lib.h,
3629 # EGifPutExtensionLast only exists from version libungif-4.1.0b1.
3630 # Earlier versions can crash Emacs, but version 5.0 removes EGifPutExtensionLast.
3631     [AC_CHECK_LIB(gif, GifMakeMapObject, HAVE_GIF=yes,
3632         [AC_CHECK_LIB(gif, EGifPutExtensionLast, HAVE_GIF=yes, HAVE_GIF=maybe)])])
3634   if test "$HAVE_GIF" = yes; then
3635     LIBGIF=-lgif
3636   elif test "$HAVE_GIF" = maybe; then
3637 # If gif_lib.h but no libgif, try libungif.
3638     AC_CHECK_LIB(ungif, EGifPutExtensionLast, HAVE_GIF=yes, HAVE_GIF=no)
3639     test "$HAVE_GIF" = yes && LIBGIF=-lungif
3640   fi
3642   if test "${HAVE_GIF}" = "yes"; then
3643     AC_DEFINE(HAVE_GIF, 1, [Define to 1 if you have a gif (or ungif) library.])
3644   fi
3646 AC_SUBST(LIBGIF)
3648 dnl Check for required libraries.
3649 MISSING=
3650 WITH_NO=
3651 if test "${HAVE_X11}" = "yes"; then
3652   test "${with_xpm}" != "no" && test "${HAVE_XPM}" != "yes" &&
3653     MISSING="libXpm" && WITH_NO="--with-xpm=no"
3654   test "${with_jpeg}" != "no" && test "${HAVE_JPEG}" != "yes" &&
3655     MISSING="$MISSING libjpeg" && WITH_NO="$WITH_NO --with-jpeg=no"
3656   test "${with_png}" != "no" && test "${HAVE_PNG}" != "yes" &&
3657     MISSING="$MISSING libpng" && WITH_NO="$WITH_NO --with-png=no"
3658   test "${with_gif}" != "no" && test "${HAVE_GIF}" != "yes" &&
3659     MISSING="$MISSING libgif/libungif" && WITH_NO="$WITH_NO --with-gif=no"
3660   test "${with_tiff}" != "no" && test "${HAVE_TIFF}" != "yes" &&
3661     MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no"
3663 test "${with_gnutls}" != "no" && test "${HAVE_GNUTLS}" != "yes" &&
3664   MISSING="$MISSING gnutls" && WITH_NO="$WITH_NO --with-gnutls=no"
3665 if test "X${MISSING}" != X; then
3666   AC_MSG_ERROR([The following required libraries were not found:
3667     $MISSING
3668 Maybe some development libraries/packages are missing?
3669 If you don't want to link with them give
3670     $WITH_NO
3671 as options to configure])
3674 ### Use -lgpm if available, unless '--with-gpm=no'.
3675 HAVE_GPM=no
3676 LIBGPM=
3677 if test "${with_gpm}" != "no"; then
3678   AC_CHECK_HEADER(gpm.h,
3679     [AC_CHECK_LIB(gpm, Gpm_Open, HAVE_GPM=yes)])
3681   if test "${HAVE_GPM}" = "yes"; then
3682     AC_DEFINE(HAVE_GPM, 1, [Define to 1 if you have the gpm library (-lgpm).])
3683     LIBGPM=-lgpm
3684   fi
3686 AC_SUBST(LIBGPM)
3688 dnl Check for malloc/malloc.h on darwin
3689 AC_CHECK_HEADERS_ONCE(malloc/malloc.h)
3691 GNUSTEP_CFLAGS=
3692 ### Use NeXTstep API to implement GUI.
3693 if test "${HAVE_NS}" = "yes"; then
3694   AC_DEFINE(HAVE_NS, 1, [Define to 1 if you are using the NeXTstep API, either GNUstep or Cocoa on macOS.])
3695   if test "${NS_IMPL_COCOA}" = "yes"; then
3696     AC_DEFINE(NS_IMPL_COCOA, 1, [Define to 1 if you are using NS windowing under macOS.])
3697   fi
3698   if test "${NS_IMPL_GNUSTEP}" = "yes"; then
3699     AC_DEFINE(NS_IMPL_GNUSTEP, 1, [Define to 1 if you are using NS windowing under GNUstep.])
3700     if test $NS_GNUSTEP_CONFIG != yes; then
3701       # See also .m.o rule in src/Makefile.in.  */
3702       # FIXME: are all these flags really needed?  Document here why.  */
3703       GNUSTEP_CFLAGS="-D_REENTRANT -fPIC -fno-strict-aliasing -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
3704       ## Extra CFLAGS applied to src/*.m files.
3705       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"
3706     fi
3707   fi
3708   OTHER_FILES=ns-app
3711 ### Use session management (-lSM -lICE) if available
3712 HAVE_X_SM=no
3713 LIBXSM=
3714 if test "${HAVE_X11}" = "yes"; then
3715   AC_CHECK_HEADER(X11/SM/SMlib.h,
3716     [AC_CHECK_LIB(SM, SmcOpenConnection, HAVE_X_SM=yes, , -lICE)])
3718   if test "${HAVE_X_SM}" = "yes"; then
3719     AC_DEFINE(HAVE_X_SM, 1, [Define to 1 if you have the SM library (-lSM).])
3720     LIBXSM="-lSM -lICE"
3721   fi
3723 AC_SUBST(LIBXSM)
3725 ### Use XRandr (-lXrandr) if available
3726 HAVE_XRANDR=no
3727 if test "${HAVE_X11}" = "yes"; then
3728   XRANDR_REQUIRED=1.2.2
3729   XRANDR_MODULES="xrandr >= $XRANDR_REQUIRED"
3730   EMACS_CHECK_MODULES([XRANDR], [$XRANDR_MODULES])
3731   if test $HAVE_XRANDR = no; then
3732     # Test old way in case pkg-config doesn't have it (older machines).
3733     # Include Xrender.h by hand to work around bug in older Xrandr.h
3734     # (e.g. RHEL5) and silence (harmless) configure warning (bug#18465).
3735     AC_CHECK_HEADER(X11/extensions/Xrandr.h,
3736       [AC_CHECK_LIB(Xrandr, XRRGetScreenResources, HAVE_XRANDR=yes)],
3737       [], [AC_INCLUDES_DEFAULT
3738 #include <X11/extensions/Xrender.h>])
3739     if test $HAVE_XRANDR = yes; then
3740       XRANDR_LIBS=-lXrandr
3741     fi
3742   fi
3743   if test $HAVE_XRANDR = yes; then
3744     AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you have the XRandr extension.])
3745   fi
3747 AC_SUBST(XRANDR_CFLAGS)
3748 AC_SUBST(XRANDR_LIBS)
3750 ### Use Xinerama (-lXinerama) if available
3751 HAVE_XINERAMA=no
3752 if test "${HAVE_X11}" = "yes"; then
3753   XINERAMA_REQUIRED=1.0.2
3754   XINERAMA_MODULES="xinerama >= $XINERAMA_REQUIRED"
3755   EMACS_CHECK_MODULES([XINERAMA], [$XINERAMA_MODULES])
3756   if test $HAVE_XINERAMA = no; then
3757     # Test old way in case pkg-config doesn't have it (older machines).
3758     AC_CHECK_HEADER(X11/extensions/Xinerama.h,
3759       [AC_CHECK_LIB(Xinerama, XineramaQueryExtension, HAVE_XINERAMA=yes)])
3760     if test $HAVE_XINERAMA = yes; then
3761       XINERAMA_LIBS=-lXinerama
3762     fi
3763   fi
3764   if test $HAVE_XINERAMA = yes; then
3765     AC_DEFINE(HAVE_XINERAMA, 1, [Define to 1 if you have the Xinerama extension.])
3766   fi
3768 AC_SUBST(XINERAMA_CFLAGS)
3769 AC_SUBST(XINERAMA_LIBS)
3771 ### Use Xfixes (-lXfixes) if available
3772 HAVE_XFIXES=no
3773 if test "${HAVE_X11}" = "yes"; then
3774   XFIXES_REQUIRED=4.0.0
3775   XFIXES_MODULES="xfixes >= $XFIXES_REQUIRED"
3776   EMACS_CHECK_MODULES([XFIXES], [$XFIXES_MODULES])
3777   if test $HAVE_XFIXES = no; then
3778     # Test old way in case pkg-config doesn't have it (older machines).
3779     AC_CHECK_HEADER(X11/extensions/Xfixes.h,
3780       [AC_CHECK_LIB(Xfixes, XFixesHideCursor, HAVE_XFIXES=yes)])
3781     if test $HAVE_XFIXES = yes; then
3782       XFIXES_LIBS=-lXfixes
3783     fi
3784   fi
3785   if test $HAVE_XFIXES = yes; then
3786     AC_DEFINE(HAVE_XFIXES, 1, [Define to 1 if you have the Xfixes extension.])
3787   fi
3789 AC_SUBST(XFIXES_CFLAGS)
3790 AC_SUBST(XFIXES_LIBS)
3792 ### Use Xdbe (-lXdbe) if available
3793 HAVE_XDBE=no
3794 if test "${HAVE_X11}" = "yes"; then
3795   AC_CHECK_HEADER(X11/extensions/Xdbe.h,
3796     [AC_CHECK_LIB(Xext, XdbeAllocateBackBufferName, HAVE_XDBE=yes)],
3797     [],
3798     [#include <X11/Xlib.h>
3799     ])
3800   if test $HAVE_XDBE = yes; then
3801     XDBE_LIBS=-lXext
3802   fi
3803   if test $HAVE_XDBE = yes; then
3804     AC_DEFINE(HAVE_XDBE, 1, [Define to 1 if you have the Xdbe extension.])
3805   fi
3807 AC_SUBST(XDBE_CFLAGS)
3808 AC_SUBST(XDBE_LIBS)
3810 ### Use libxml (-lxml2) if available
3811 ### mingw32 doesn't use -lxml2, since it loads the library dynamically.
3812 HAVE_LIBXML2=no
3813 if test "${with_xml2}" != "no"; then
3814   ### I'm not sure what the version number should be, so I just guessed.
3815   EMACS_CHECK_MODULES([LIBXML2], [libxml-2.0 > 2.6.17])
3816   # Built-in libxml2 on OS X 10.8 lacks libxml-2.0.pc.
3817   if test "${HAVE_LIBXML2}" != "yes" && test "$opsys" = "darwin"; then
3818     SAVE_CPPFLAGS="$CPPFLAGS"
3819     if test -z "$xcsdkdir" -a -n "$XCRUN" -a ! -d /usr/include; then
3820       dnl /usr/include is not found.  Try Xcode SDK dir if it is sane.
3821       xcsdkdir=`$XCRUN --show-sdk-path 2>/dev/null`
3822       case $xcsdkdir in
3823         *[[\\\"\#\$\&\'\`$am_lf\ \      ]]*)
3824         xcsdkdir="" ;;
3825       esac
3826     fi
3827     CPPFLAGS="$CPPFLAGS -I$xcsdkdir/usr/include/libxml2"
3828     AC_CHECK_HEADER(libxml/HTMLparser.h,
3829       [AC_CHECK_DECL(HTML_PARSE_RECOVER, HAVE_LIBXML2=yes, ,
3830                      [#include <libxml/HTMLparser.h>])])
3831     CPPFLAGS="$SAVE_CPPFLAGS"
3832     if test "${HAVE_LIBXML2}" = "yes"; then
3833       LIBXML2_CFLAGS="-I'$xcsdkdir/usr/include/libxml2'"
3834       LIBXML2_LIBS="-lxml2"
3835     fi
3836   fi
3837   if test "${HAVE_LIBXML2}" = "yes"; then
3838     if test "${opsys}" != "mingw32"; then
3839       AC_CHECK_LIB(xml2, htmlReadMemory, HAVE_LIBXML2=yes, HAVE_LIBXML2=no,
3840         [$LIBXML2_LIBS])
3841     else
3842       LIBXML2_LIBS=""
3843     fi
3844     if test "${HAVE_LIBXML2}" = "yes"; then
3845       AC_DEFINE(HAVE_LIBXML2, 1, [Define to 1 if you have the libxml library (-lxml2).])
3846     else
3847       LIBXML2_LIBS=""
3848       LIBXML2_CFLAGS=""
3849     fi
3850   fi
3852 AC_SUBST(LIBXML2_LIBS)
3853 AC_SUBST(LIBXML2_CFLAGS)
3855 BLESSMAIL_TARGET=
3856 LIBS_MAIL=
3857 if test ! "$with_mailutils"; then
3858   # Check for mail-locking functions in a "mail" library.  Probably this should
3859   # have the same check as for liblockfile below.
3860   AC_CHECK_LIB([mail], [maillock], [have_mail=yes], [have_mail=no])
3861   if test $have_mail = yes; then
3862     LIBS_MAIL=-lmail
3863     AC_DEFINE([HAVE_LIBMAIL], [1],
3864       [Define to 1 if you have the 'mail' library (-lmail).])
3866     OLD_LIBS=$LIBS
3867     LIBS="$LIBS_MAIL $LIBS"
3868     AC_CHECK_FUNCS([touchlock])
3869     LIBS=$OLD_LIBS
3870   fi
3871   dnl Debian, at least:
3872   AC_CHECK_LIB([lockfile], [maillock], [have_lockfile=yes], [have_lockfile=no])
3873   if test $have_lockfile = yes; then
3874      LIBS_MAIL=-llockfile
3875      AC_DEFINE([HAVE_LIBLOCKFILE], [1],
3876        [Define to 1 if you have the 'lockfile' library (-llockfile).])
3877   else
3878     # If we have the shared liblockfile, assume we must use it for mail
3879     # locking (e.g. Debian).  If we couldn't link against liblockfile
3880     # (no liblockfile.a installed), ensure that we don't need to.
3881     dnl This works for files generally, not just executables.
3882     dnl Should we look elsewhere for it?  Maybe examine /etc/ld.so.conf?
3883     AC_CHECK_PROG([liblockfile], [liblockfile.so], [yes], [no],
3884                   [/usr/lib:/lib:/usr/local/lib:$LD_LIBRARY_PATH])
3885     if test "$ac_cv_prog_liblockfile" = yes; then
3886       AC_MSG_ERROR([Shared liblockfile found but can't link against it.
3887 This probably means that movemail could lose mail.
3888 There may be a 'development' package to install containing liblockfile.])
3889     fi
3890   fi
3891   AC_CHECK_HEADERS([maillock.h])
3893   ## Define MAIL_USE_FLOCK (or LOCKF) if the mailer uses flock (or lockf) to
3894   ## interlock access to the mail spool.  The alternative is a lock file named
3895   ## /usr/spool/mail/$USER.lock.
3896   mail_lock=no
3897   case $opsys in
3898     aix4-2) mail_lock="lockf" ;;
3900     gnu|freebsd|dragonfly|netbsd|openbsd|darwin) mail_lock="flock" ;;
3902     ## On GNU/Linux systems, both methods are used by various mail programs.
3903     ## I assume most people are using newer mailers that have heard of flock.
3904     ## Change this if you need to.
3905     ## Debian contains a patch which says: "On Debian/GNU/Linux systems,
3906     ## configure gets the right answers, and that means *NOT* using flock.
3907     ## Using flock is guaranteed to be the wrong thing. See Debian Policy
3908     ## for details." and then uses '#ifdef DEBIAN'.  Unfortunately the
3909     ## Debian maintainer hasn't provided a clean fix for Emacs.
3910     ## movemail.c will use 'maillock' when MAILDIR, HAVE_LIBMAIL and
3911     ## HAVE_MAILLOCK_H are defined, so the following appears to be the
3912     ## correct logic.  -- fx
3913     ## We must check for HAVE_LIBLOCKFILE too, as movemail does.
3914     ## liblockfile is a Free Software replacement for libmail, used on
3915     ## Debian systems and elsewhere. -rfr.
3916     gnu-*)
3917       mail_lock="flock"
3918       if test $have_mail = yes || test $have_lockfile = yes; then
3919         test $ac_cv_header_maillock_h = yes && mail_lock=no
3920       fi ;;
3922     mingw32)
3923       mail_lock="none-needed" ;;
3924   esac
3926   case $mail_lock in
3927     flock) AC_DEFINE([MAIL_USE_FLOCK], [1],
3928              [Define if the mailer uses flock to interlock the mail spool.]);;
3930     lockf) AC_DEFINE([MAIL_USE_LOCKF], [1],
3931              [Define if the mailer uses lockf to interlock the mail spool.]);;
3933     none-needed) ;;
3935     *) BLESSMAIL_TARGET="need-blessmail" ;;
3936   esac
3938 AC_SUBST([BLESSMAIL_TARGET])
3939 AC_SUBST([LIBS_MAIL])
3941 OLD_LIBS=$LIBS
3942 LIBS="$LIB_PTHREAD $LIB_MATH $LIBS"
3943 AC_CHECK_FUNCS(accept4 fchdir gethostname \
3944 getrusage get_current_dir_name \
3945 lrand48 random rint trunc \
3946 select getpagesize setlocale newlocale \
3947 getrlimit setrlimit shutdown \
3948 pthread_sigmask strsignal setitimer \
3949 sendto recvfrom getsockname getifaddrs freeifaddrs \
3950 gai_strerror sync \
3951 getpwent endpwent getgrent endgrent \
3952 cfmakeraw cfsetspeed __executable_start log2 prctl)
3953 LIBS=$OLD_LIBS
3955 dnl No need to check for posix_memalign if aligned_alloc works.
3956 AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break])
3957 AC_CHECK_DECLS([aligned_alloc], [], [], [[#include <stdlib.h>]])
3959 dnl Cannot use AC_CHECK_FUNCS
3960 AC_CACHE_CHECK([for __builtin_frame_address],
3961   [emacs_cv_func___builtin_frame_address],
3962   [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_frame_address (0);])],
3963      [emacs_cv_func___builtin_frame_address=yes],
3964      [emacs_cv_func___builtin_frame_address=no])])
3965 if test $emacs_cv_func___builtin_frame_address = yes; then
3966   AC_DEFINE([HAVE___BUILTIN_FRAME_ADDRESS], 1,
3967             [Define to 1 if you have the '__builtin_frame_address' function.])
3969 AC_CACHE_CHECK([for __builtin_unwind_init],
3970                emacs_cv_func___builtin_unwind_init,
3971 [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_unwind_init ();])],
3972                 emacs_cv_func___builtin_unwind_init=yes,
3973                 emacs_cv_func___builtin_unwind_init=no)])
3974 if test $emacs_cv_func___builtin_unwind_init = yes; then
3975   AC_DEFINE(HAVE___BUILTIN_UNWIND_INIT, 1,
3976             [Define to 1 if you have the '__builtin_unwind_init' function.])
3979 AC_CHECK_HEADERS_ONCE(sys/un.h)
3981 AC_FUNC_FSEEKO
3983 # UNIX98 PTYs.
3984 AC_CHECK_FUNCS(grantpt)
3986 # PTY-related GNU extensions.
3987 AC_CHECK_FUNCS(getpt posix_openpt)
3989 dnl Run a test program that contains a call to tputs, a call that is
3990 dnl never executed.  This tests whether a pre-'main' dynamic linker
3991 dnl works with the library.  It's too much trouble to actually call
3992 dnl tputs in the test program, due to portability hassles.  When
3993 dnl cross-compiling, assume the test program will run if it links.
3994 AC_DEFUN([tputs_link_source], [
3995   AC_LANG_SOURCE(
3996      [[extern void tputs (const char *, int, int (*)(int));
3997        int main (int argc, char **argv)
3998        {
3999           if (argc == 10000)
4000             tputs (argv[0], 0, 0);
4001           return 0;
4002        }]])
4004 # Check this now, so that we will NOT find the above functions in ncurses.
4005 # That is because we have not set up to link ncurses in lib-src.
4006 # It's better to believe a function is not available
4007 # than to expect to find it in ncurses.
4008 # Also we need tputs and friends to be able to build at all.
4009 AC_CACHE_CHECK([for library containing tputs], [emacs_cv_tputs_lib],
4010 [if test "${opsys}" = "mingw32"; then
4011   emacs_cv_tputs_lib='none required'
4012 else
4013   # Maybe curses should be tried earlier?
4014   # See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9736#35
4015   for tputs_library in '' tinfo ncurses terminfo termcap curses; do
4016     OLIBS=$LIBS
4017     if test -z "$tputs_library"; then
4018       emacs_cv_tputs_lib='none required'
4019     else
4020       emacs_cv_tputs_lib=-l$tputs_library
4021       LIBS="$emacs_cv_tputs_lib $LIBS"
4022     fi
4023     AC_RUN_IFELSE([tputs_link_source], [], [emacs_cv_tputs_lib=no],
4024       [AC_LINK_IFELSE([tputs_link_source], [], [emacs_cv_tputs_lib=no])])
4025     LIBS=$OLIBS
4026     if test "X$emacs_cv_tputs_lib" != Xno; then
4027       break
4028     fi
4029   done
4030 fi])
4031 AS_CASE(["$emacs_cv_tputs_lib"],
4032   [no], [AC_MSG_ERROR([The required function 'tputs' was not found in any library.
4033 The following libraries were tried (in order):
4034   libtinfo, libncurses, libterminfo, libtermcap, libcurses
4035 Please try installing whichever of these libraries is most appropriate
4036 for your system, together with its header files.
4037 For example, a libncurses-dev(el) or similar package.])],
4038   [-l*], [LIBS_TERMCAP=$emacs_cv_tputs_lib],
4039   [*], [LIBS_TERMCAP=])
4041 ## Use termcap instead of terminfo?
4042 ## Only true for: freebsd < 40000, ms-w32, msdos, netbsd < 599002500.
4043 TERMINFO=yes
4044 ## FIXME?  In the cases below where we unconditionally set
4045 ## LIBS_TERMCAP="-lncurses", this overrides LIBS_TERMCAP = -ltinfo,
4046 ## if that was found above to have tputs.
4047 ## Should we use the gnu* logic everywhere?
4048 case "$opsys" in
4049   ## darwin: Prevents crashes when running Emacs in Terminal.app under 10.2.
4050   ##  The ncurses library has been moved out of the System framework in
4051   ##  Mac OS X 10.2.  So if configure detects it, set the command-line
4052   ##  option to use it.
4053   darwin) LIBS_TERMCAP="-lncurses" ;;
4055   gnu*) test -z "$LIBS_TERMCAP" && LIBS_TERMCAP="-lncurses" ;;
4057   freebsd)
4058     AC_MSG_CHECKING([whether FreeBSD is new enough to use terminfo])
4059     AC_CACHE_VAL(emacs_cv_freebsd_terminfo,
4060     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <osreldate.h>]],
4061 [[#if __FreeBSD_version < 400000
4062 fail;
4063 #endif
4064 ]])], emacs_cv_freebsd_terminfo=yes, emacs_cv_freebsd_terminfo=no)])
4066     AC_MSG_RESULT($emacs_cv_freebsd_terminfo)
4068     if test $emacs_cv_freebsd_terminfo = yes; then
4069       LIBS_TERMCAP="-lncurses"
4070     else
4071       TERMINFO=no
4072       LIBS_TERMCAP="-ltermcap"
4073     fi
4074     ;;
4076   mingw32)
4077     TERMINFO=no
4078     LIBS_TERMCAP=
4079     ;;
4081   netbsd)
4082     if test "x$LIBS_TERMCAP" != "x-lterminfo"; then
4083       TERMINFO=no
4084       LIBS_TERMCAP="-ltermcap"
4085     fi
4086     ;;
4088   openbsd | dragonfly) LIBS_TERMCAP="-lncurses" ;;
4090   ## hpux: Make sure we get select from libc rather than from libcurses
4091   ##  because libcurses on HPUX 10.10 has a broken version of select.
4092   ##  We used to use -lc -lcurses, but this may be cleaner.
4093   ## FIXME?  But TERMINFO = yes on hpux (it used to be explicitly
4094   # set that way, now it uses the default).  Isn't this a contradiction?
4095   hpux*) LIBS_TERMCAP="-ltermcap" ;;
4097 esac
4099 TERMCAP_OBJ=tparam.o
4100 if test $TERMINFO = yes; then
4101   AC_DEFINE(TERMINFO, 1, [Define to 1 if you use terminfo instead of termcap.])
4102   TERMCAP_OBJ=terminfo.o
4104 if test "X$LIBS_TERMCAP" = "X-lncurses"; then
4105   AC_DEFINE(USE_NCURSES, 1, [Define to 1 if you use ncurses.])
4107 AC_SUBST(LIBS_TERMCAP)
4108 AC_SUBST(TERMCAP_OBJ)
4110 # GNU/Linux-specific timer functions.
4111 AC_CACHE_CHECK([for timerfd interface], [emacs_cv_have_timerfd],
4112   [AC_COMPILE_IFELSE(
4113      [AC_LANG_PROGRAM([[#include <sys/timerfd.h>
4114                       ]],
4115                       [[timerfd_create (CLOCK_REALTIME,
4116                                         TFD_CLOEXEC | TFD_NONBLOCK);
4117                         timerfd_settime (0, TFD_TIMER_ABSTIME, 0, 0);]])],
4118      [emacs_cv_have_timerfd=yes],
4119      [emacs_cv_have_timerfd=no])])
4120 if test "$emacs_cv_have_timerfd" = yes; then
4121   AC_DEFINE([HAVE_TIMERFD], 1,
4122     [Define to 1 if timerfd functions are supported as in GNU/Linux.])
4125 # Alternate stack for signal handlers.
4126 AC_CACHE_CHECK([whether signals can be handled on alternate stack],
4127                [emacs_cv_alternate_stack],
4128   [AC_COMPILE_IFELSE(
4129      [AC_LANG_PROGRAM([[#include <signal.h>
4130                       ]],
4131                       [[stack_t ss;
4132                         struct sigaction sa;
4133                         ss.ss_sp = malloc (SIGSTKSZ);
4134                         ss.ss_size = SIGSTKSZ;
4135                         sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
4136                         sigaltstack (&ss, 0);
4137                         sigaction (SIGSEGV, &sa, 0);]])],
4138      [emacs_cv_alternate_stack=yes],
4139      [emacs_cv_alternate_stack=no])])
4141 # Do we need the Hesiod library to provide the support routines?
4142 dnl FIXME?  Should we be skipping this on Darwin too?
4143 LIBHESIOD=
4144 LIBRESOLV=
4145 if test "$with_hesiod" != no ; then
4146   # Don't set $LIBS here -- see comments above.  FIXME which comments?
4147   resolv=no
4148   AC_CHECK_FUNC(res_send, , [AC_CHECK_FUNC(__res_send, ,
4149      [AC_CHECK_LIB(resolv, res_send, resolv=yes,
4150                   [AC_CHECK_LIB(resolv, __res_send, resolv=yes)])])])
4151   if test "$resolv" = yes ; then
4152     RESOLVLIB=-lresolv
4153   else
4154     RESOLVLIB=
4155   fi
4156   hesiod=no
4157   AC_CHECK_FUNC(hes_getmailhost, , [AC_CHECK_LIB(hesiod, hes_getmailhost,
4158         hesiod=yes, :, $RESOLVLIB)])
4160   if test x"$hesiod" = xyes; then
4161     LIBHESIOD=-lhesiod
4162     LIBRESOLV=$RESOLVLIB
4163   fi
4165 AC_SUBST(LIBHESIOD)
4166 AC_SUBST(LIBRESOLV)
4168 # These tell us which Kerberos-related libraries to use.
4169 COM_ERRLIB=
4170 CRYPTOLIB=
4171 KRB5LIB=
4172 DESLIB=
4173 KRB4LIB=
4175 if test "${with_kerberos}" != no; then
4176   OLD_LIBS=$LIBS
4177   AC_CHECK_LIB(com_err, com_err, have_com_err=yes, have_com_err=no)
4178   if test $have_com_err = yes; then
4179     COM_ERRLIB=-lcom_err
4180     LIBS="$COM_ERRLIB $LIBS"
4181   fi
4182   AC_CHECK_LIB(crypto, mit_des_cbc_encrypt, have_crypto=yes, have_crypto=no)
4183   if test $have_crypto = yes; then
4184     CRYPTOLIB=-lcrypto
4185     LIBS="$CRYPTOLIB $LIBS"
4186   fi
4187   AC_CHECK_LIB(k5crypto, mit_des_cbc_encrypt, have_k5crypto=yes, have_k5crypto=no)
4188   if test $have_k5crypto = yes; then
4189     CRYPTOLIB=-lk5crypto
4190     LIBS="$CRYPTOLIB $LIBS"
4191   fi
4192   AC_CHECK_LIB(krb5, krb5_init_context, have_krb5=yes, have_krb5=no)
4193   if test $have_krb5=yes; then
4194     KRB5LIB=-lkrb5
4195     LIBS="$KRB5LIB $LIBS"
4196   fi
4197   dnl FIXME Simplify.  Does not match 22 logic, thanks to default_off?
4198   if test "${with_kerberos5}" = no; then
4199     AC_CHECK_LIB(des425, des_cbc_encrypt, have_des425=yes, have_des425=no )
4200     if test $have_des425 = yes; then
4201       DESLIB=-ldes425
4202       LIBS="$DESLIB $LIBS"
4203     else
4204       AC_CHECK_LIB(des, des_cbc_encrypt, have_des=yes, have_des=no)
4205       if test $have_des = yes; then
4206         DESLIB=-ldes
4207         LIBS="$DESLIB $LIBS"
4208       fi
4209     fi
4210     AC_CHECK_LIB(krb4, krb_get_cred, have_krb4=yes, have_krb4=no)
4211     if test $have_krb4 = yes; then
4212       KRB4LIB=-lkrb4
4213       LIBS="$KRB4LIB $LIBS"
4214     else
4215       AC_CHECK_LIB(krb, krb_get_cred, have_krb=yes, have_krb=no)
4216       if test $have_krb = yes; then
4217         KRB4LIB=-lkrb
4218         LIBS="$KRB4LIB $LIBS"
4219       fi
4220     fi
4221   fi
4223   if test "${with_kerberos5}" != no; then
4224     AC_CHECK_HEADERS(krb5.h,
4225       [AC_CHECK_MEMBERS([krb5_error.text, krb5_error.e_text],,,
4226                         [#include <krb5.h>])])
4227   else
4228     AC_CHECK_HEADERS(krb.h,,
4229                      [AC_CHECK_HEADERS(kerberosIV/krb.h,,
4230                                        [AC_CHECK_HEADERS(kerberos/krb.h)])])
4231   fi
4232   AC_CHECK_HEADERS(com_err.h)
4233   LIBS=$OLD_LIBS
4236 AC_SUBST(COM_ERRLIB)
4237 AC_SUBST(CRYPTOLIB)
4238 AC_SUBST(KRB5LIB)
4239 AC_SUBST(DESLIB)
4240 AC_SUBST(KRB4LIB)
4242 AC_CHECK_HEADERS(valgrind/valgrind.h)
4244 AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]])
4246 AC_CHECK_FUNCS_ONCE([sbrk])
4248 ok_so_far=yes
4249 AC_CHECK_FUNC(socket, , ok_so_far=no)
4250 if test $ok_so_far = yes; then
4251   AC_CHECK_HEADER(netinet/in.h, , ok_so_far=no)
4253 if test $ok_so_far = yes; then
4254   AC_CHECK_HEADER(arpa/inet.h, , ok_so_far=no)
4256 if test $ok_so_far = yes; then
4257 dnl Fixme: Not used.  Should this be HAVE_SOCKETS?
4258   AC_DEFINE(HAVE_INET_SOCKETS, 1,
4259             [Define to 1 if you have inet sockets.])
4262 AC_FUNC_FORK
4264 AC_CHECK_FUNCS(snprintf)
4266 dnl Check for glib.  This differs from other library checks in that
4267 dnl Emacs need not link to glib unless some other library is already
4268 dnl linking to glib.  Although glib provides no facilities that Emacs
4269 dnl needs for its own purposes, when glib is present Emacs needs to
4270 dnl use primitives like g_main_context_query to avoid clashing with
4271 dnl glib at a low level.
4273 dnl Check this late, since it depends on $GTK_CFLAGS etc.
4274 XGSELOBJ=
4275 AC_CACHE_CHECK([whether GLib is linked in], [emacs_cv_links_glib],
4276 [OLDCFLAGS="$CFLAGS"
4277 OLDLIBS="$LIBS"
4278 CFLAGS="$CFLAGS $GTK_CFLAGS $RSVG_CFLAGS $DBUS_CFLAGS $SETTINGS_CFLAGS"
4279 LIBS="$LIBS $GTK_LIBS $RSVG_LIBS $DBUS_LIBS $SETTINGS_LIBS"
4280 CFLAGS="$CFLAGS $NOTIFY_CFLAGS $CAIRO_CFLAGS"
4281 LIBS="$LIBS $NOTIFY_LIBS $CAIRO_LIBS"
4282 AC_LINK_IFELSE([AC_LANG_PROGRAM(
4283         [[#include <glib.h>
4284         ]],
4285         [[g_print ("Hello world");]])],
4286      [emacs_cv_links_glib=yes],
4287      [emacs_cv_links_glib=no])
4288 CFLAGS="$OLDCFLAGS"
4289 LIBS="$OLDLIBS"])
4290 if test "${emacs_cv_links_glib}" = "yes"; then
4291   AC_DEFINE(HAVE_GLIB, 1, [Define to 1 if GLib is linked in.])
4292   if test "$HAVE_NS" = no;then
4293     XGSELOBJ=xgselect.o
4294   fi
4296 AC_SUBST(XGSELOBJ)
4298 dnl Adapted from Haible's version.
4299 AC_CACHE_CHECK([for nl_langinfo and CODESET], emacs_cv_langinfo_codeset,
4300   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
4301     [[char* cs = nl_langinfo(CODESET);]])],
4302     emacs_cv_langinfo_codeset=yes,
4303     emacs_cv_langinfo_codeset=no)
4304   ])
4305 if test $emacs_cv_langinfo_codeset = yes; then
4306   AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
4307     [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
4310 AC_TYPE_MBSTATE_T
4312 dnl Fixme: AC_SYS_POSIX_TERMIOS should probably be used, but it's not clear
4313 dnl how the tty code is related to POSIX and/or other versions of termios.
4314 dnl The following looks like a useful start.
4316 dnl AC_SYS_POSIX_TERMIOS
4317 dnl if test $ac_cv_sys_posix_termios = yes; then
4318 dnl    AC_DEFINE(HAVE_TERMIOS, 1, [Define to 1 if you have POSIX-style functions
4319 dnl                                and macros for terminal control.])
4320 dnl    AC_DEFINE(HAVE_TCATTR, 1, [Define to 1 if you have tcgetattr and tcsetattr.])
4321 dnl fi
4323 dnl Turned on June 1996 supposing nobody will mind it.
4324 dnl MinGW emulates passwd database, so this feature doesn't make sense there.
4325 if test "${opsys}" != "mingw32"; then
4326    AC_DEFINE(AMPERSAND_FULL_NAME, 1, [Define to use the convention that &
4327      in the full name stands for the login id.])
4330 dnl Everybody supports this, except MS.
4331 dnl Seems like the kind of thing we should be testing for, though.
4332 ## Note: PTYs are broken on darwin <6.  Use at your own risk.
4333 if test "${opsys}" != "mingw32"; then
4334   AC_DEFINE(HAVE_PTYS, 1, [Define if the system supports pty devices.])
4337 dnl Everybody supports this, except MS-DOS.
4338 dnl Seems like the kind of thing we should be testing for, though.
4339 dnl Compare with HAVE_INET_SOCKETS (which is unused...) above.
4340 AC_DEFINE(HAVE_SOCKETS, 1, [Define if the system supports
4341   4.2-compatible sockets.])
4343 AH_TEMPLATE(INTERNAL_TERMINAL, [This is substituted when $TERM is "internal".])
4345 AH_TEMPLATE(NULL_DEVICE, [Name of the file to open to get
4346   a null file, or a data sink.])
4347 if test "${opsys}" = "mingw32"; then
4348   AC_DEFINE(NULL_DEVICE, ["NUL:"])
4349 else
4350   AC_DEFINE(NULL_DEVICE, ["/dev/null"])
4353 if test "${opsys}" = "mingw32"; then
4354   SEPCHAR=';'
4355 else
4356   SEPCHAR=':'
4358 AC_DEFINE_UNQUOTED(SEPCHAR, ['$SEPCHAR'], [Character that separates PATH elements.])
4359 dnl This is for MinGW, and is used in test/Makefile.in.
4360 dnl The MSYS Bash has heuristics for replacing ':' with ';' when it
4361 dnl decides that a command-line argument to be passed to a MinGW program
4362 dnl is a PATH-style list of directories.  But that heuristics plays it
4363 dnl safe, and only does the replacement when it is _absolutely_ sure it
4364 dnl sees a colon-separated list of file names; e.g. ":." is left alone,
4365 dnl which breaks in-tree builds.  So we do this manually instead.
4366 dnl Note that we cannot rely on PATH_SEPARATOR, as that one will always
4367 dnl be computed as ':' in MSYS Bash.
4368 AC_SUBST(SEPCHAR)
4370 dnl Everybody supports this, except MS-DOS.
4371 AC_DEFINE(subprocesses, 1, [Define to enable asynchronous subprocesses.])
4373 AC_DEFINE(USER_FULL_NAME, [pw->pw_gecos], [How to get a user's full name.])
4376 AC_DEFINE(DIRECTORY_SEP, ['/'],
4377   [Character that separates directories in a file name.])
4379 if test "${opsys}" = "mingw32"; then
4380   AC_DEFINE(IS_DEVICE_SEP(_c_), [((_c_) == ':')],
4381     [Returns true if character is a device separator.])
4383   AC_DEFINE(IS_DIRECTORY_SEP(_c_), [((_c_) == '/' || (_c_) == '\\')],
4384     [Returns true if character is a directory separator.])
4386   AC_DEFINE(IS_ANY_SEP(_c_), [(IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP(_c_))],
4387     [Returns true if character is any form of separator.])
4388 else
4389   AC_DEFINE(IS_DEVICE_SEP(_c_), 0,
4390     [Returns true if character is a device separator.])
4392   AC_DEFINE(IS_DIRECTORY_SEP(_c_), [((_c_) == DIRECTORY_SEP)],
4393     [Returns true if character is a directory separator.])
4395   AC_DEFINE(IS_ANY_SEP(_c_), [(IS_DIRECTORY_SEP (_c_))],
4396     [Returns true if character is any form of separator.])
4399 if test "$USE_X_TOOLKIT" != "none"; then
4400   have_editres=yes
4401   case $opsys in
4402     hpux*)
4403       dnl Assar Westerlund <assar@sics.se> says this is necessary
4404       dnl for HP-UX 10.20, and that it works for HP-UX 0 as well.
4405       have_editres=no
4406     ;;
4407   esac
4408   if test "$have_editres" != no && test ! -z "$LIBXMU"; then
4409     OLDLIBS="$LIBS"
4410     dnl See libXmu.a check above.
4411     if test x$HAVE_X11XTR6 = xyes; then
4412       LIBS="-lXt -lSM -lICE $LIBXMU"
4413     else
4414       OTHERLIBS="-lXt -$LIBXMU"
4415     fi
4416     AC_TRY_LINK(
4417       [#include <X11/Intrinsic.h>
4418        #include <X11/Xmu/Editres.h>],
4419       [_XEditResCheckMessages (0, 0, 0, 0);],
4420       [AC_DEFINE([X_TOOLKIT_EDITRES], 1,
4421         [Define to 1 if we should use XEditRes.])])
4422     LIBS=$OLDLIBS
4423   fi
4426 case $opsys in
4427   sol2* | unixware )
4428     dnl Some SVr4s don't define NSIG in sys/signal.h for ANSI environments;
4429     dnl instead, there's a system variable _sys_nsig.  Unfortunately, we
4430     dnl need the constant to dimension an array.  So wire in the appropriate
4431     dnl value here.
4432     AC_DEFINE(NSIG_MINIMUM, 32, [Minimum value of NSIG.])
4433     ;;
4434 esac
4436 emacs_broken_SIGIO=no
4438 case $opsys in
4439   dnl SIGIO exists, but the feature doesn't work in the way Emacs needs.
4440   dnl See eg <http://article.gmane.org/gmane.os.openbsd.ports/46831>.
4441   hpux* | nacl | openbsd | sol2* | unixware )
4442     emacs_broken_SIGIO=yes
4443     ;;
4445   aix4-2)
4446     dnl On AIX Emacs uses the gmalloc.c malloc implementation.  But given
4447     dnl the way this system works, libc functions that return malloced
4448     dnl memory use the libc malloc implementation. Calling xfree or
4449     dnl xrealloc on the results of such functions results in a crash.
4450     dnl
4451     dnl One solution for this could be to define SYSTEM_MALLOC in configure,
4452     dnl but that does not currently work on this system.
4453     dnl
4454     dnl It is possible to completely override the malloc implementation on
4455     dnl AIX, but that involves putting the malloc functions in a shared
4456     dnl library and setting the MALLOCTYPE environment variable to point to
4457     dnl that shared library.
4458     dnl
4459     dnl Emacs currently calls xrealloc on the results of get_current_dir name,
4460     dnl to avoid a crash just use the Emacs implementation for that function.
4461     dnl
4462     dnl FIXME We could change the AC_CHECK_FUNCS call near the start
4463     dnl of this file, so that we do not check for get_current_dir_name
4464     dnl on AIX.  But that might be fragile if something else ends
4465     dnl up testing for get_current_dir_name as a dependency.
4466     AC_DEFINE(BROKEN_GET_CURRENT_DIR_NAME, 1, [Define if
4467       get_current_dir_name should not be used.])
4468     ;;
4470   freebsd)
4471     dnl Circumvent a bug in FreeBSD.  In the following sequence of
4472     dnl writes/reads on a PTY, read(2) returns bogus data:
4473     dnl
4474     dnl write(2)  1022 bytes
4475     dnl write(2)   954 bytes, get EAGAIN
4476     dnl read(2)   1024 bytes in process_read_output
4477     dnl read(2)     11 bytes in process_read_output
4478     dnl
4479     dnl That is, read(2) returns more bytes than have ever been written
4480     dnl successfully.  The 1033 bytes read are the 1022 bytes written
4481     dnl successfully after processing (for example with CRs added if the
4482     dnl terminal is set up that way which it is here).  The same bytes will
4483     dnl be seen again in a later read(2), without the CRs.
4484     AC_DEFINE(BROKEN_PTY_READ_AFTER_EAGAIN, 1, [Define on FreeBSD to
4485       work around an issue when reading from a PTY.])
4486     ;;
4487 esac
4489 case $opsys in
4490   gnu-* | sol2-10 )
4491     dnl FIXME Can't we test if this exists (eg /proc/$$)?
4492     AC_DEFINE(HAVE_PROCFS, 1, [Define if you have the /proc filesystem.])
4493   ;;
4494 esac
4496 case $opsys in
4497   darwin | dragonfly | freebsd | netbsd | openbsd )
4498     AC_DEFINE(DONT_REOPEN_PTY, 1, [Define if process.c does not need to
4499       close a pty to make it a controlling terminal (it is already a
4500       controlling terminal of the subprocess, because we did ioctl TIOCSCTTY).])
4501   ;;
4502 esac
4504 dnl FIXME Surely we can test for this rather than hard-code it.
4505 case $opsys in
4506   netbsd | openbsd) sound_device="/dev/audio" ;;
4507   *) sound_device="/dev/dsp" ;;
4508 esac
4510 dnl Used in sound.c
4511 AC_DEFINE_UNQUOTED(DEFAULT_SOUND_DEVICE, "$sound_device",
4512   [Name of the default sound device.])
4515 dnl Emacs can read input using SIGIO and buffering characters itself,
4516 dnl or using CBREAK mode and making C-g cause SIGINT.
4517 dnl The choice is controlled by the variable interrupt_input.
4519 dnl Define INTERRUPT_INPUT to make interrupt_input = 1 the default (use SIGIO)
4521 dnl Emacs uses the presence of the USABLE_SIGIO macro
4522 dnl to indicate whether or not signal-driven I/O is possible.  It uses
4523 dnl INTERRUPT_INPUT to decide whether to use it by default.
4525 dnl SIGIO can be used only on systems that implement it (4.2 and 4.3).
4526 dnl CBREAK mode has two disadvantages
4527 dnl 1) At least in 4.2, it is impossible to handle the Meta key properly.
4528 dnl I hear that in system V this problem does not exist.
4529 dnl 2) Control-G causes output to be discarded.
4530 dnl I do not know whether this can be fixed in system V.
4532 dnl Another method of doing input is planned but not implemented.
4533 dnl It would have Emacs fork off a separate process
4534 dnl to read the input and send it to the true Emacs process
4535 dnl through a pipe.
4536 case $opsys in
4537   darwin | gnu-linux | gnu-kfreebsd )
4538     AC_DEFINE(INTERRUPT_INPUT, 1, [Define to read input using SIGIO.])
4539   ;;
4540 esac
4543 dnl If the system's imake configuration file defines 'NeedWidePrototypes'
4544 dnl as 'NO', we must define NARROWPROTO manually.  Such a define is
4545 dnl generated in the Makefile generated by 'xmkmf'.  If we don't define
4546 dnl NARROWPROTO, we will see the wrong function prototypes for X functions
4547 dnl taking float or double parameters.
4548 case $opsys in
4549   cygwin|gnu|gnu-linux|gnu-kfreebsd|freebsd|netbsd|openbsd)
4550     AC_DEFINE(NARROWPROTO, 1, [Define if system's imake configuration
4551       file defines 'NeedWidePrototypes' as 'NO'.])
4552   ;;
4553 esac
4556 dnl Used in process.c, this must be a loop, even if it only runs once.
4557 AH_TEMPLATE(PTY_ITERATION, [How to iterate over PTYs.])
4558 dnl Only used if !PTY_ITERATION.  Iterate from FIRST_PTY_LETTER to z,
4559 dnl trying suffixes 0-16.
4560 AH_TEMPLATE(FIRST_PTY_LETTER, [Letter to use in finding device name of
4561   first PTY, if PTYs are supported.])
4562 AH_TEMPLATE(PTY_OPEN, [How to open a PTY, if non-standard.])
4563 AH_TEMPLATE(PTY_NAME_SPRINTF, [How to get the device name of the control
4564   end of a PTY, if non-standard.])
4565 AH_TEMPLATE(PTY_TTY_NAME_SPRINTF, [How to get device name of the tty
4566   end of a PTY, if non-standard.])
4568 case $opsys in
4569   aix4-2 )
4570     AC_DEFINE(PTY_ITERATION, [int c; for (c = 0; !c ; c++)])
4571     dnl You allocate a pty by opening /dev/ptc to get the master side.
4572     dnl To get the name of the slave side, you just ttyname() the master side.
4573     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");])
4574     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [strcpy (pty_name, ttyname (fd));])
4575     ;;
4577   cygwin )
4578     AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
4579     dnl multi-line AC_DEFINEs are hard. :(
4580     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)])
4581     AC_DEFINE(PTY_NAME_SPRINTF, [])
4582     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
4583     ;;
4585   gnu | openbsd )
4586     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
4587     ;;
4589   gnu-linux | gnu-kfreebsd | dragonfly | freebsd | netbsd | darwin | nacl )
4590     dnl if HAVE_GRANTPT
4591     if test "x$ac_cv_func_grantpt" = xyes; then
4592       AC_DEFINE(UNIX98_PTYS, 1, [Define if the system has Unix98 PTYs.])
4593       AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
4594       dnl Note that grantpt and unlockpt may fork.  We must block SIGCHLD
4595       dnl to prevent sigchld_handler from intercepting the child's death.
4596       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); }])
4597       dnl if HAVE_POSIX_OPENPT
4598       if test "x$ac_cv_func_posix_openpt" = xyes; then
4599         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)])
4600         AC_DEFINE(PTY_NAME_SPRINTF, [])
4601       dnl if HAVE_GETPT
4602       elif test "x$ac_cv_func_getpt" = xyes; then
4603         AC_DEFINE(PTY_OPEN, [fd = getpt ()])
4604         AC_DEFINE(PTY_NAME_SPRINTF, [])
4605       else
4606         AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");])
4607       fi
4608     else
4609       AC_DEFINE(FIRST_PTY_LETTER, ['p'])
4610     fi
4611     ;;
4613   hpux*)
4614     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
4615     AC_DEFINE(PTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);])
4616     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/pty/tty%c%x", c, i);])
4617     ;;
4619   sol2* )
4620     dnl On SysVr4, grantpt(3) forks a subprocess, so do not use
4621     dnl O_CLOEXEC when opening the pty, and keep the SIGCHLD handler
4622     dnl from intercepting that death.  If any child but grantpt's should die
4623     dnl within, it should be caught after sigrelse(2).
4624     AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)])
4625     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); }])
4626     ;;
4628   unixware )
4629     dnl Comments are as per sol2*.
4630     AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)])
4631     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); }])
4632     ;;
4633 esac
4636 case $opsys in
4637   sol2* | unixware )
4638     dnl This change means that we don't loop through allocate_pty too
4639     dnl many times in the (rare) event of a failure.
4640     AC_DEFINE(FIRST_PTY_LETTER, ['z'])
4641     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");])
4642     dnl Push various streams modules onto a PTY channel.  Used in process.c.
4643     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.])
4644     ;;
4645 esac
4648 AH_TEMPLATE(SIGNALS_VIA_CHARACTERS, [Make process_send_signal work by
4649 "typing" a signal character on the pty.])
4651 case $opsys in
4652   dnl Perry Smith <pedz@ddivt1.austin.ibm.com> says this is correct for AIX.
4653   aix4-2 | cygwin | gnu | dragonfly | freebsd | netbsd | openbsd | darwin )
4654     AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1)
4655     ;;
4657   dnl 21 Jun 06: Eric Hanchrow <offby1@blarg.net> says this works.
4658   dnl FIXME Does gnu-kfreebsd have linux/version.h?  It seems unlikely...
4659   gnu-linux | gnu-kfreebsd )
4661     AC_CACHE_CHECK([for signals via characters], [emacs_cv_signals_via_chars],
4662     [AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4663 #include <linux/version.h>
4664 #if LINUX_VERSION_CODE < 0x20400
4665 # error "Linux version too old"
4666 #endif
4667       ]], [[]])], emacs_cv_signals_via_chars=yes, emacs_cv_signals_via_chars=no)])
4669     test "$emacs_cv_signals_via_chars" = yes && AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1)
4670     ;;
4671 esac
4674 AH_TEMPLATE(TAB3, [Undocumented.])
4676 case $opsys in
4677   darwin) AC_DEFINE(TAB3, OXTABS) ;;
4679   gnu | dragonfly | freebsd | netbsd | openbsd )
4680     AC_DEFINE(TABDLY, OXTABS, [Undocumented.])
4681     AC_DEFINE(TAB3, OXTABS)
4682     ;;
4684   gnu-linux | gnu-kfreebsd )
4685     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4686 #ifndef __ia64__
4687 # error "not ia64"
4688 #endif
4689       ]], [[]])], AC_DEFINE(GC_MARK_SECONDARY_STACK(),
4690         [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)],
4691         [Mark a secondary stack, like the register stack on the ia64.]), [])
4692     ;;
4694   hpux*)
4695     AC_DEFINE(RUN_TIME_REMAP, 1, [Define if emacs.c needs to call
4696       run_time_remap; for HPUX.])
4697     ;;
4698 esac
4701 dnl This won't be used automatically yet.  We also need to know, at least,
4702 dnl that the stack is continuous.
4703 AH_TEMPLATE(GC_SETJMP_WORKS, [Define if setjmp is known to save all
4704   registers relevant for conservative garbage collection in the jmp_buf.])
4707 case $opsys in
4708   dnl Not all the architectures are tested, but there are Debian packages
4709   dnl for SCM and/or Guile on them, so the technique must work.  See also
4710   dnl comments in alloc.c concerning setjmp and gcc.
4711   dnl Fixme: it's probably safe to just use the GCC conditional below.
4712   gnu-linux | gnu-kfreebsd )
4713     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4714 #if defined __i386__ || defined __sparc__ || defined __mc68000__ \
4715   || defined __alpha__ || defined __mips__ || defined __s390__ \
4716   || defined __arm__ || defined __powerpc__ || defined __amd64__ \
4717   || defined __ia64__ || defined __sh__
4718 /* ok */
4719 #else
4720 # error "setjmp not known to work on this arch"
4721 #endif
4722     ]], [[]])], AC_DEFINE(GC_SETJMP_WORKS, 1))
4723     ;;
4724 esac
4727 if test x$GCC = xyes; then
4728    dnl GC_SETJMP_WORKS is nearly always appropriate for GCC.
4729    AC_DEFINE(GC_SETJMP_WORKS, 1)
4730 else
4731   case $opsys in
4732     aix* | dragonfly | freebsd | netbsd | openbsd | sol2* )
4733       AC_DEFINE(GC_SETJMP_WORKS, 1)
4734       ;;
4735   esac
4736 fi                              dnl GCC?
4738 dnl In a weird quirk, MS runtime uses _setjmp and longjmp.
4739 AC_CACHE_CHECK([for _setjmp], [emacs_cv_func__setjmp],
4740   [AC_LINK_IFELSE(
4741      [AC_LANG_PROGRAM(
4742        [[#include <setjmp.h>
4743          #ifdef __MINGW32__
4744          # define _longjmp longjmp
4745          #endif
4746        ]],
4747        [[jmp_buf j;
4748          if (! _setjmp (j))
4749            _longjmp (j, 1);]])],
4750      [emacs_cv_func__setjmp=yes],
4751      [emacs_cv_func__setjmp=no])])
4752 if test $emacs_cv_func__setjmp = yes; then
4753   AC_DEFINE([HAVE__SETJMP], 1, [Define to 1 if _setjmp and _longjmp work.])
4756 # We need to preserve signal mask to handle C stack overflows.
4757 AC_CACHE_CHECK([for sigsetjmp], [emacs_cv_func_sigsetjmp],
4758   [AC_LINK_IFELSE(
4759      [AC_LANG_PROGRAM(
4760        [[#include <setjmp.h>
4761        ]],
4762        [[sigjmp_buf j;
4763          if (! sigsetjmp (j, 1))
4764            siglongjmp (j, 1);]])],
4765      [emacs_cv_func_sigsetjmp=yes],
4766      [emacs_cv_func_sigsetjmp=no])])
4767 if test $emacs_cv_func_sigsetjmp = yes; then
4768   AC_DEFINE([HAVE_SIGSETJMP], 1,
4769     [Define to 1 if sigsetjmp and siglongjmp work.])
4772 case $emacs_cv_func_sigsetjmp,$emacs_cv_alternate_stack,$opsys in
4773   yes,yes,* | *,*,mingw32)
4774     AC_DEFINE([HAVE_STACK_OVERFLOW_HANDLING], 1,
4775       [Define to 1 if C stack overflow can be handled in some cases.]);;
4776 esac
4778 case $opsys in
4779   sol2* | unixware )
4780     dnl TIOCGPGRP is broken in SysVr4, so we can't send signals to PTY
4781     dnl subprocesses the usual way.  But TIOCSIGNAL does work for PTYs,
4782     dnl and this is all we need.
4783     AC_DEFINE(TIOCSIGSEND, TIOCSIGNAL, [Some platforms redefine this.])
4784     ;;
4785 esac
4788 case $opsys in
4789   hpux* | sol2* )
4790     dnl Used in xfaces.c.
4791     AC_DEFINE(XOS_NEEDS_TIME_H, 1, [Compensate for a bug in Xos.h on
4792       some systems, where it requires time.h.])
4793     ;;
4794 esac
4797 dnl Define symbols to identify the version of Unix this is.
4798 dnl Define all the symbols that apply correctly.
4799 AH_TEMPLATE(DOS_NT, [Define if the system is MS DOS or MS Windows.])
4800 AH_TEMPLATE(MSDOS, [Define if the system is MS DOS.])
4801 AH_TEMPLATE(USG, [Define if the system is compatible with System III.])
4802 AH_TEMPLATE(USG5_4, [Define if the system is compatible with System V Release 4.])
4804 case $opsys in
4805   aix4-2)
4806     AC_DEFINE(USG, [])
4807     dnl This symbol should be defined on AIX Version 3  ???????
4808     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4809 #ifndef _AIX
4810 # error "_AIX not defined"
4811 #endif
4812     ]], [[]])], [], AC_DEFINE(_AIX, [], [Define if the system is AIX.]))
4813     ;;
4815   cygwin)
4816     AC_DEFINE(CYGWIN, 1, [Define if the system is Cygwin.])
4817     ;;
4819   darwin)
4820     dnl Not __APPLE__, as this may not be defined on non-macOS Darwin.
4821     dnl Not DARWIN, because Panther and lower CoreFoundation.h use DARWIN to
4822     dnl distinguish macOS from pure Darwin.
4823     AC_DEFINE(DARWIN_OS, [], [Define if the system is Darwin.])
4824     ;;
4826   gnu-linux | gnu-kfreebsd )
4827     AC_DEFINE(USG, [])
4828     AC_DEFINE(GNU_LINUX, [], [Define if ths system is compatible with GNU/Linux.])
4829     ;;
4831   hpux*)
4832     AC_DEFINE(USG, [])
4833     AC_DEFINE(HPUX, [], [Define if the system is HPUX.])
4834     ;;
4836   mingw32)
4837     AC_DEFINE(DOS_NT, [])
4838     AC_DEFINE(WINDOWSNT, 1, [Define if compiling for native MS Windows.])
4839     if test "x$ac_enable_checking" != "x" ; then
4840       AC_DEFINE(EMACSDEBUG, 1, [Define to 1 to enable w32 debug facilities.])
4841     fi
4842     ;;
4844   sol2*)
4845     AC_DEFINE(USG, [])
4846     AC_DEFINE(USG5_4, [])
4847     AC_DEFINE(SOLARIS2, [], [Define if the system is Solaris.])
4848     ;;
4850   unixware)
4851     AC_DEFINE(USG, [])
4852     AC_DEFINE(USG5_4, [])
4853     ;;
4854 esac
4856 AC_CACHE_CHECK([for usable FIONREAD], [emacs_cv_usable_FIONREAD],
4857   [case $opsys in
4858      aix4-2 | nacl)
4859        dnl BUILD 9008 - FIONREAD problem still exists in X-Windows.
4860        emacs_cv_usable_FIONREAD=no
4861        ;;
4863      mingw32)
4864        emacs_cv_usable_FIONREAD=yes
4865        ;;
4867      *)
4868        AC_COMPILE_IFELSE(
4869          [AC_LANG_PROGRAM([[#include <sys/types.h>
4870                             #include <sys/ioctl.h>
4871                             #ifdef USG5_4
4872                             # include <sys/filio.h>
4873                             #endif
4874                           ]],
4875                           [[int foo = ioctl (0, FIONREAD, &foo);]])],
4876          [emacs_cv_usable_FIONREAD=yes],
4877          [emacs_cv_usable_FIONREAD=no])
4878        ;;
4879    esac])
4880 if test $emacs_cv_usable_FIONREAD = yes; then
4881   AC_DEFINE([USABLE_FIONREAD], [1], [Define to 1 if FIONREAD is usable.])
4883   if test $emacs_broken_SIGIO = no; then
4884     AC_CACHE_CHECK([for usable SIGIO], [emacs_cv_usable_SIGIO],
4885       [AC_COMPILE_IFELSE(
4886          [AC_LANG_PROGRAM([[#include <fcntl.h>
4887                             #include <signal.h>
4888                           ]],
4889                           [[int foo = SIGIO | F_SETFL | FASYNC;]])],
4890          [emacs_cv_usable_SIGIO=yes],
4891          [emacs_cv_usable_SIGIO=no])],
4892       [emacs_cv_usable_SIGIO=yes],
4893       [emacs_cv_usable_SIGIO=no])
4894     if test $emacs_cv_usable_SIGIO = yes; then
4895       AC_DEFINE([USABLE_SIGIO], [1], [Define to 1 if SIGIO is usable.])
4896     fi
4897   fi
4900 case $opsys in
4901   hpux11)
4902     dnl It works to open the pty's tty in the parent (Emacs), then
4903     dnl close and reopen it in the child.
4904     AC_DEFINE(USG_SUBTTY_WORKS, 1, [Define for USG systems where it
4905       works to open a pty's tty in the parent process, then close and
4906       reopen it in the child.])
4907     ;;
4909   sol2-10)
4910     AC_DEFINE(_STRUCTURED_PROC, 1, [Needed for system_process_attributes
4911       on Solaris.])
4912     ;;
4913 esac
4915 # Set up the CFLAGS for real compilation, so we can substitute it.
4916 CFLAGS="$REAL_CFLAGS"
4917 CPPFLAGS="$REAL_CPPFLAGS"
4918 LIBS="$REAL_LIBS"
4920 ## Hack to detect a buggy GCC version.
4921 if test "$GCC" = yes && \
4922    $CC --version 2> /dev/null | grep 'gcc.* 4.5.0' >/dev/null; then
4923   case $CFLAGS in
4924     *-fno-optimize-sibling-calls*) ;;
4925     *-O@<:@23@:>@*)
4926       AC_MSG_ERROR([GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS.]);;
4927   esac
4930 version=$PACKAGE_VERSION
4932 copyright="Copyright (C) 2017 Free Software Foundation, Inc."
4933 AC_DEFINE_UNQUOTED(COPYRIGHT, ["$copyright"],
4934   [Short copyright string for this version of Emacs.])
4935 AC_SUBST(copyright)
4937 ### Specify what sort of things we'll be editing into Makefile and config.h.
4938 ### Use configuration here uncanonicalized to avoid exceeding size limits.
4939 AC_SUBST(version)
4940 AC_SUBST(configuration)
4941 ## Unused?
4942 AC_SUBST(canonical)
4943 AC_SUBST(srcdir)
4944 AC_SUBST(prefix)
4945 AC_SUBST(exec_prefix)
4946 AC_SUBST(bindir)
4947 AC_SUBST(datadir)
4948 AC_SUBST(sharedstatedir)
4949 AC_SUBST(libexecdir)
4950 AC_SUBST(mandir)
4951 AC_SUBST(infodir)
4952 AC_SUBST(lispdir)
4953 AC_SUBST(standardlisppath)
4954 AC_SUBST(locallisppath)
4955 AC_SUBST(lisppath)
4956 AC_SUBST(x_default_search_path)
4957 AC_SUBST(etcdir)
4958 AC_SUBST(archlibdir)
4959 AC_SUBST(etcdocdir)
4960 AC_SUBST(bitmapdir)
4961 AC_SUBST(gamedir)
4962 AC_SUBST(gameuser)
4963 AC_SUBST(gamegroup)
4964 ## FIXME? Nothing uses @LD_SWITCH_X_SITE@.
4965 ## src/Makefile.in did add LD_SWITCH_X_SITE (as a cpp define) to the
4966 ## end of LIBX_BASE, but nothing ever set it.
4967 AC_SUBST(LD_SWITCH_X_SITE)
4968 AC_SUBST(C_SWITCH_X_SITE)
4969 AC_SUBST(GNUSTEP_CFLAGS)
4970 AC_SUBST(CFLAGS)
4971 ## Used in lwlib/Makefile.in.
4972 AC_SUBST(X_TOOLKIT_TYPE)
4973 AC_SUBST(ns_appdir)
4974 AC_SUBST(ns_appbindir)
4975 AC_SUBST(ns_appresdir)
4976 AC_SUBST(ns_appsrc)
4977 AC_SUBST(GNU_OBJC_CFLAGS)
4978 AC_SUBST(OTHER_FILES)
4980 if test -n "${term_header}"; then
4981     AC_DEFINE_UNQUOTED(TERM_HEADER, "${term_header}",
4982         [Define to the header for the built-in window system.])
4985 AC_DEFINE_UNQUOTED(EMACS_CONFIGURATION,  "${canonical}",
4986                    [Define to the canonical Emacs configuration name.])
4987 AC_DEFINE_UNQUOTED(EMACS_CONFIG_OPTIONS, "${emacs_config_options}",
4988                    [Define to the options passed to configure.])
4990 XMENU_OBJ=
4991 XOBJ=
4992 FONT_OBJ=
4993 if test "${HAVE_X_WINDOWS}" = "yes" ; then
4994   AC_DEFINE(HAVE_X_WINDOWS, 1,
4995             [Define to 1 if you want to use the X window system.])
4996   XMENU_OBJ=xmenu.o
4997   XOBJ="xterm.o xfns.o xselect.o xrdb.o xsmfns.o xsettings.o"
4998   FONT_OBJ=xfont.o
4999   if test "$HAVE_CAIRO" = "yes"; then
5000     FONT_OBJ="ftfont.o ftcrfont.o"
5001   elif test "$HAVE_XFT" = "yes"; then
5002     FONT_OBJ="$FONT_OBJ ftfont.o xftfont.o ftxfont.o"
5003   elif test "$HAVE_FREETYPE" = "yes"; then
5004     FONT_OBJ="$FONT_OBJ ftfont.o ftxfont.o"
5005   fi
5006   AC_SUBST(FONT_OBJ)
5008 AC_SUBST(XMENU_OBJ)
5009 AC_SUBST(XOBJ)
5010 AC_SUBST(FONT_OBJ)
5012 WIDGET_OBJ=
5013 MOTIF_LIBW=
5014 if test "${USE_X_TOOLKIT}" != "none" ; then
5015   WIDGET_OBJ=widget.o
5016   AC_DEFINE(USE_X_TOOLKIT, 1, [Define to 1 if using an X toolkit.])
5017   if test "${USE_X_TOOLKIT}" = "LUCID"; then
5018     AC_DEFINE(USE_LUCID, 1, [Define to 1 if using the Lucid X toolkit.])
5019   elif test "${USE_X_TOOLKIT}" = "MOTIF"; then
5020     AC_DEFINE(USE_MOTIF, 1, [Define to 1 if using the Motif X toolkit.])
5021     MOTIF_LIBW=-lXm
5022     case "$opsys" in
5023       gnu-linux)
5024         ## Paul Abrahams <abrahams at equinox.shaysnet.com> says this is needed.
5025         MOTIF_LIBW="$MOTIF_LIBW -lXpm"
5026         ;;
5028       unixware)
5029         ## Richard Anthony Ryan <ryanr at ellingtn.ftc.nrcs.usda.gov>
5030         ## says -lXimp is needed in UNIX_SV ... 4.2 1.1.2.
5031         MOTIF_LIBW="MOTIF_LIBW -lXimp"
5032         ;;
5034       aix4-2)
5035         ## olson@mcs.anl.gov says -li18n is needed by -lXm.
5036         MOTIF_LIBW="$MOTIF_LIBW -li18n"
5037         ;;
5038     esac
5039     MOTIF_LIBW="$MOTIF_LIBW $LIBXP"
5040   fi
5042 AC_SUBST(WIDGET_OBJ)
5044 TOOLKIT_LIBW=
5045 case "$USE_X_TOOLKIT" in
5046   MOTIF) TOOLKIT_LIBW="$MOTIF_LIBW" ;;
5047   LUCID) TOOLKIT_LIBW="$LUCID_LIBW" ;;
5048   none) test "x$HAVE_GTK" = "xyes" && TOOLKIT_LIBW="$GTK_LIBS" ;;
5049 esac
5050 if test "$HAVE_XWIDGETS" = "yes"; then
5051   TOOLKIT_LIBW="$TOOLKIT_LIBW -lXcomposite"
5053 AC_SUBST(TOOLKIT_LIBW)
5055 if test "${opsys}" != "mingw32"; then
5056   if test "$USE_X_TOOLKIT" = "none"; then
5057     LIBXT_OTHER="\$(LIBXSM)"
5058   else
5059     LIBXT_OTHER="\$(LIBXMU) -lXt \$(LIBXTR6) -lXext"
5060   fi
5062 AC_SUBST(LIBXT_OTHER)
5064 if test "${HAVE_X11}" = "yes" ; then
5065   AC_DEFINE(HAVE_X11, 1,
5066             [Define to 1 if you want to use version 11 of X windows.])
5067   LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
5068 else
5069   LIBX_OTHER=
5071 AC_SUBST(LIBX_OTHER)
5073 HAVE_OLDXMENU=no
5074 if test "$HAVE_GTK" = yes || test "$HAVE_X11" != yes; then
5075   LIBXMENU=
5076 elif test "$USE_X_TOOLKIT" = none; then
5077   HAVE_OLDXMENU=yes
5078   LIBXMENU='$(oldXMenudir)/libXMenu11.a'
5079   AUTODEPEND_PARENTS="$AUTODEPEND_PARENTS oldXMenu"
5080 else
5081   LIBXMENU='$(lwlibdir)/liblw.a'
5082   AUTODEPEND_PARENTS="$AUTODEPEND_PARENTS lwlib"
5084 AC_SUBST(LIBXMENU)
5086 AC_CACHE_CHECK([for struct alignment],
5087   [emacs_cv_struct_alignment],
5088   [AC_COMPILE_IFELSE(
5089      [AC_LANG_PROGRAM([[#include <stddef.h>
5090                         struct __attribute__ ((aligned (8))) s { char c; };
5091                         struct t { char c; struct s s; };
5092                         char verify[offsetof (struct t, s) == 8 ? 1 : -1];
5093                       ]])],
5094      [emacs_cv_struct_alignment=yes],
5095      [emacs_cv_struct_alignment=no])])
5096 if test "$emacs_cv_struct_alignment" = yes; then
5097   AC_DEFINE([HAVE_STRUCT_ATTRIBUTE_ALIGNED], 1,
5098     [Define to 1 if 'struct __attribute__ ((aligned (N)))' aligns the
5099      structure to an N-byte boundary.])
5102 if test "${GNU_MALLOC}" = "yes" ; then
5103   AC_DEFINE(GNU_MALLOC, 1,
5104             [Define to 1 if you want to use the GNU memory allocator.])
5107 RALLOC_OBJ=
5108 if test "${REL_ALLOC}" = "yes" ; then
5109   AC_DEFINE(REL_ALLOC, 1,
5110             [Define REL_ALLOC if you want to use the relocating allocator for
5111              buffer space.])
5113   test "$system_malloc" != "yes" && RALLOC_OBJ=ralloc.o
5115 AC_SUBST(RALLOC_OBJ)
5117 if test "$opsys" = "cygwin"; then
5118   CYGWIN_OBJ="cygw32.o"
5119   ## Cygwin differs because of its unexec().
5120   PRE_ALLOC_OBJ=
5121   POST_ALLOC_OBJ=lastfile.o
5122 elif test "$opsys" = "mingw32"; then
5123   CYGWIN_OBJ=
5124   PRE_ALLOC_OBJ=
5125   POST_ALLOC_OBJ=lastfile.o
5126 else
5127   CYGWIN_OBJ=
5128   PRE_ALLOC_OBJ=lastfile.o
5129   POST_ALLOC_OBJ=
5131 AC_SUBST(CYGWIN_OBJ)
5132 AC_SUBST(PRE_ALLOC_OBJ)
5133 AC_SUBST(POST_ALLOC_OBJ)
5135 dnl Call this 'FORTIFY_SOUR' so that it sorts before the 'FORTIFY_SOURCE'
5136 dnl verbatim defined above.  The tricky name is apropos, as this hack
5137 dnl makes Fortify go sour!
5138 AH_VERBATIM([FORTIFY_SOUR],
5139 [/* Without the following workaround, Emacs runs slowly on OS X 10.8.
5140    The workaround disables some useful run-time checking, so it
5141    should be conditional to the platforms with the performance bug.
5142    Perhaps Apple will fix this some day; also see m4/extern-inline.m4.  */
5143 #if defined __APPLE__ && defined __GNUC__
5144 # ifndef _DONT_USE_CTYPE_INLINE_
5145 #  define _DONT_USE_CTYPE_INLINE_
5146 # endif
5147 # ifndef _FORTIFY_SOURCE
5148 #  define _FORTIFY_SOURCE 0
5149 # endif
5150 #endif
5153 # If user asks to omit features, disable optional features that gnulib
5154 # might otherwise enable.
5155 if test "$with_features" = no && test "$enable_acl" != yes; then
5156   enable_acl=no
5159 # Configure gnulib.  Although this does not affect CFLAGS or LIBS permanently.
5160 # it temporarily reverts them to their pre-pkg-config values,
5161 # because gnulib needs to work with both src (which uses the
5162 # pkg-config stuff) and lib-src (which does not).  For example, gnulib
5163 # may need to determine whether LIB_CLOCK_GETTIME should contain -lrt,
5164 # and it therefore needs to run in an environment where LIBS does not
5165 # already contain -lrt merely because 'pkg-config --libs' printed '-lrt'
5166 # for some package unrelated to lib-src.
5167 SAVE_CFLAGS=$CFLAGS
5168 SAVE_LIBS=$LIBS
5169 CFLAGS=$pre_PKG_CONFIG_CFLAGS
5170 LIBS="$LIB_PTHREAD $pre_PKG_CONFIG_LIBS"
5171 gl_ASSERT_NO_GNULIB_POSIXCHECK
5172 gl_ASSERT_NO_GNULIB_TESTS
5173 gl_INIT
5174 CFLAGS=$SAVE_CFLAGS
5175 LIBS=$SAVE_LIBS
5177 if test "${opsys}" = "mingw32"; then
5178   CPPFLAGS="$CPPFLAGS -DUSE_CRT_DLL=1 -I \${abs_top_srcdir}/nt/inc"
5179   # Remove unneeded switches from the value of CC that goes to Makefiles
5180   CC=`AS_ECHO(["$CC"]) | sed -e "s,$GCC_TEST_OPTIONS,,"`
5183 case "$opsys" in
5184   aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;;
5186   cygwin) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000" ;;
5188   darwin)
5189    ## The -headerpad option tells ld (see man page) to leave room at the
5190    ## end of the header for adding load commands.  Needed for dumping.
5191    ## 0x1000 is enough for roughly 52 load commands on the x86_64
5192    ## architecture (where they are 78 bytes each). The actual number of
5193    ## load commands added is not consistent but normally ranges from
5194    ## about 14 to about 34. Setting it high gets us plenty of slop and
5195    ## only costs about 1.5K of wasted binary space.
5196    headerpad_extra=1000
5197    if test "$HAVE_NS" = "yes"; then
5198      libs_nsgui="-framework AppKit"
5199      if test "$NS_IMPL_COCOA" = "yes"; then
5200         libs_nsgui="$libs_nsgui -framework IOKit"
5201      fi
5202    else
5203      libs_nsgui=
5204    fi
5205    LD_SWITCH_SYSTEM_TEMACS="-fno-pie -prebind $libs_nsgui -Xlinker -headerpad -Xlinker $headerpad_extra"
5207    ## This is here because src/Makefile.in did some extra fiddling around
5208    ## with LD_SWITCH_SYSTEM.  It seems cleaner to put this in
5209    ## LD_SWITCH_SYSTEM_TEMACS instead,
5210    test "x$LD_SWITCH_SYSTEM" = "x" && test "x$GCC" != "xyes" && \
5211      LD_SWITCH_SYSTEM_TEMACS="-X $LD_SWITCH_SYSTEM_TEMACS"
5212    ;;
5214   ## LD_SWITCH_X_SITE_RPATH is a -rpath option saying where to
5215   ## find X at run-time.
5216   ## When handled by cpp, this was in LD_SWITCH_SYSTEM.  However, at the
5217   ## point where configure sourced the s/*.h file, LD_SWITCH_X_SITE_RPATH
5218   ## had not yet been defined and was expanded to null.  Hence LD_SWITCH_SYSTEM
5219   ## had different values in configure (in ac_link) and src/Makefile.in.
5220   ## It seems clearer therefore to put this piece in LD_SWITCH_SYSTEM_TEMACS.
5221   gnu*) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_RPATH)" ;;
5223   mingw32)
5224    ## Is it any better under MinGW64 to relocate emacs into higher addresses?
5225    case "$canonical" in
5226      x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x400000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
5227      *) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
5228    esac
5229    ;;
5231   *) LD_SWITCH_SYSTEM_TEMACS= ;;
5232 esac
5234 # -no-pie or -nopie fixes a temacs segfault on Gentoo, OpenBSD,
5235 # Ubuntu, and other systems with "hardened" GCC configurations for
5236 # some reason (Bug#18784).  We don't know why this works, but not
5237 # segfaulting is better than segfaulting.  Use ac_c_werror_flag=yes
5238 # when trying the option, otherwise clang keeps warning that it does
5239 # not understand it, and pre-4.6 GCC has a similar problem
5240 # (Bug#20338).  Prefer -no-pie to -nopie, as -no-pie is the
5241 # spelling used by GCC 6.1.0 and later (Bug#24682).
5242 AC_CACHE_CHECK(
5243   [for $CC option to disable position independent executables],
5244   [emacs_cv_prog_cc_no_pie],
5245   [emacs_save_c_werror_flag=$ac_c_werror_flag
5246    emacs_save_LDFLAGS=$LDFLAGS
5247    ac_c_werror_flag=yes
5248    for emacs_cv_prog_cc_no_pie in -no-pie -nopie no; do
5249      test $emacs_cv_prog_cc_no_pie = no && break
5250      LDFLAGS="$emacs_save_LDFLAGS $emacs_cv_prog_cc_no_pie"
5251      AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [break])
5252    done
5253    ac_c_werror_flag=$emacs_save_c_werror_flag
5254    LDFLAGS=$emacs_save_LDFLAGS])
5255 if test "$emacs_cv_prog_cc_no_pie" != no; then
5256   LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS $emacs_cv_prog_cc_no_pie"
5259 if test x$ac_enable_profiling != x ; then
5260   case $opsys in
5261     *freebsd | gnu-linux) ;;
5262     *) LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS -pg" ;;
5263   esac
5266 LD_SWITCH_SYSTEM_TEMACS="$LDFLAGS_NOCOMBRELOC $LD_SWITCH_SYSTEM_TEMACS"
5268 AC_SUBST(LD_SWITCH_SYSTEM_TEMACS)
5270 ## Common for all window systems
5271 if test "$window_system" != "none"; then
5272   AC_DEFINE(HAVE_WINDOW_SYSTEM, 1, [Define if you have a window system.])
5273   AC_DEFINE(POLL_FOR_INPUT, 1, [Define if you poll periodically to detect C-g.])
5274   WINDOW_SYSTEM_OBJ="fontset.o fringe.o image.o"
5277 AC_SUBST(WINDOW_SYSTEM_OBJ)
5279 AH_TOP([/* GNU Emacs site configuration template file.
5281 Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2017
5282   Free Software Foundation, Inc.
5284 This file is part of GNU Emacs.
5286 GNU Emacs is free software: you can redistribute it and/or modify
5287 it under the terms of the GNU General Public License as published by
5288 the Free Software Foundation, either version 3 of the License, or (at
5289 your option) any later version.
5291 GNU Emacs is distributed in the hope that it will be useful,
5292 but WITHOUT ANY WARRANTY; without even the implied warranty of
5293 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5294 GNU General Public License for more details.
5296 You should have received a copy of the GNU General Public License
5297 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
5300 /* No code in Emacs #includes config.h twice, but some bits of code
5301    intended to work with other packages as well (like gmalloc.c)
5302    think they can include it as many times as they like.  */
5303 #ifndef EMACS_CONFIG_H
5304 #define EMACS_CONFIG_H
5305 ])dnl
5307 AH_BOTTOM([#include <conf_post.h>
5309 #endif /* EMACS_CONFIG_H */
5312 Local Variables:
5313 mode: c
5314 End:
5316 ])dnl
5318 #### Report on what we decided to do.
5319 #### Report GTK as a toolkit, even if it doesn't use Xt.
5320 #### It makes printing result more understandable as using GTK sets
5321 #### toolkit_scroll_bars to yes by default.
5322 if test "${HAVE_GTK}" = "yes"; then
5323   USE_X_TOOLKIT="$USE_GTK_TOOLKIT"
5326 if test $USE_ACL -ne 0; then
5327   ACL_SUMMARY="yes $LIB_ACL"
5328 else
5329   ACL_SUMMARY=no
5332 emacs_standard_dirs='Standard dirs'
5333 AS_ECHO(["
5334 Configured for '${canonical}'.
5336   Where should the build process find the source code?    ${srcdir}
5337   What compiler should emacs be built with?               ${CC} ${CFLAGS}
5338   Should Emacs use the GNU version of malloc?             ${GNU_MALLOC}${GNU_MALLOC_reason}
5339   Should Emacs use a relocating allocator for buffers?    ${REL_ALLOC}
5340   Should Emacs use mmap(2) for buffer allocation?         $use_mmap_for_buffers
5341   What window system should Emacs use?                    ${window_system}
5342   What toolkit should Emacs use?                          ${USE_X_TOOLKIT}
5343   Where do we find X Windows header files?                ${x_includes:-$emacs_standard_dirs}
5344   Where do we find X Windows libraries?                   ${x_libraries:-$emacs_standard_dirs}"])
5346 optsep=
5347 emacs_config_features=
5348 for opt in XAW3D XPM JPEG TIFF GIF PNG RSVG CAIRO IMAGEMAGICK SOUND GPM DBUS \
5349   GCONF GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT \
5350   LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS X_TOOLKIT OLDXMENU X11 NS MODULES \
5351   XWIDGETS LIBSYSTEMD CANNOT_DUMP; do
5353     case $opt in
5354       CANNOT_DUMP) eval val=\${$opt} ;;
5355       NOTIFY|ACL) eval val=\${${opt}_SUMMARY} ;;
5356       TOOLKIT_SCROLL_BARS|X_TOOLKIT) eval val=\${USE_$opt} ;;
5357       *) eval val=\${HAVE_$opt} ;;
5358     esac
5359     case x$val in
5360       xno|xnone|x) continue ;;
5361     esac
5362     case $opt in
5363       X_TOOLKIT)
5364         case $val in
5365           GTK*|LUCID|MOTIF) opt=$val ;;
5366           *) continue ;;
5367         esac
5368       ;;
5369     esac
5370     AS_VAR_APPEND([emacs_config_features], ["$optsep$opt"])
5371     optsep=' '
5372 done
5373 AC_DEFINE_UNQUOTED(EMACS_CONFIG_FEATURES, "${emacs_config_features}",
5374   [Summary of some of the main features enabled by configure.])
5376 AS_ECHO(["  Does Emacs use -lXaw3d?                                 ${HAVE_XAW3D}
5377   Does Emacs use -lXpm?                                   ${HAVE_XPM}
5378   Does Emacs use -ljpeg?                                  ${HAVE_JPEG}
5379   Does Emacs use -ltiff?                                  ${HAVE_TIFF}
5380   Does Emacs use a gif library?                           ${HAVE_GIF} $LIBGIF
5381   Does Emacs use a png library?                           ${HAVE_PNG} $LIBPNG
5382   Does Emacs use -lrsvg-2?                                ${HAVE_RSVG}
5383   Does Emacs use cairo?                                   ${HAVE_CAIRO}
5384   Does Emacs use imagemagick (version 6)?                 ${HAVE_IMAGEMAGICK}
5385   Does Emacs support sound?                               ${HAVE_SOUND}
5386   Does Emacs use -lgpm?                                   ${HAVE_GPM}
5387   Does Emacs use -ldbus?                                  ${HAVE_DBUS}
5388   Does Emacs use -lgconf?                                 ${HAVE_GCONF}
5389   Does Emacs use GSettings?                               ${HAVE_GSETTINGS}
5390   Does Emacs use a file notification library?             ${NOTIFY_SUMMARY}
5391   Does Emacs use access control lists?                    ${ACL_SUMMARY}
5392   Does Emacs use -lselinux?                               ${HAVE_LIBSELINUX}
5393   Does Emacs use -lgnutls?                                ${HAVE_GNUTLS}
5394   Does Emacs use -lxml2?                                  ${HAVE_LIBXML2}
5395   Does Emacs use -lfreetype?                              ${HAVE_FREETYPE}
5396   Does Emacs use -lm17n-flt?                              ${HAVE_M17N_FLT}
5397   Does Emacs use -lotf?                                   ${HAVE_LIBOTF}
5398   Does Emacs use -lxft?                                   ${HAVE_XFT}
5399   Does Emacs use -lsystemd?                               ${HAVE_LIBSYSTEMD}
5400   Does Emacs directly use zlib?                           ${HAVE_ZLIB}
5401   Does Emacs have dynamic modules support?                ${HAVE_MODULES}
5402   Does Emacs use toolkit scroll bars?                     ${USE_TOOLKIT_SCROLL_BARS}
5403   Does Emacs support Xwidgets (requires gtk3)?            ${HAVE_XWIDGETS}
5404   Does Emacs have threading support in lisp?              ${threads_enabled}
5407 if test -n "${EMACSDATA}"; then
5408    AS_ECHO(["  Environment variable EMACSDATA set to:                  $EMACSDATA"])
5410 if test -n "${EMACSDOC}"; then
5411    AS_ECHO(["  Environment variable EMACSDOC set to:                   $EMACSDOC"])
5414 echo
5416 if test "$HAVE_NS" = "yes"; then
5417    echo
5418    AS_ECHO(["You must run \"${MAKE-make} install\" in order to test the built application.
5419 The installed application will go to nextstep/Emacs.app and can be
5420 run or moved from there."])
5421    if test "$EN_NS_SELF_CONTAINED" = "yes"; then
5422       echo "The application will be fully self-contained."
5423     else
5424       AS_ECHO(["The lisp resources for the application will be installed under ${prefix}.
5425 You may need to run \"${MAKE-make} install\" with sudo.  The application will fail
5426 to run if these resources are not installed."])
5427    fi
5428    echo
5431 case $opsys,$emacs_uname_r in
5432   cygwin,1.5.*)
5433     AC_MSG_WARN([[building Emacs on Cygwin 1.5 is not supported.]])
5434            echo
5435            ;;
5436 esac
5438 # Remove any trailing slashes in these variables.
5439 case $prefix in
5440   */) prefix=`AS_DIRNAME(["$prefix."])`;;
5441 esac
5442 case $exec_prefix in
5443   */) exec_prefix=`AS_DIRNAME(["$exec_prefix."])`;;
5444 esac
5446 if test "$HAVE_NS" = "yes"; then
5447   if test "$NS_IMPL_GNUSTEP" = yes; then
5448     AC_CONFIG_FILES([nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist:nextstep/templates/Info-gnustep.plist.in \
5449       nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop:nextstep/templates/Emacs.desktop.in])
5450     ns_check_file=Resources/Info-gnustep.plist
5451   else
5452     AC_CONFIG_FILES([nextstep/Cocoa/Emacs.base/Contents/Info.plist:nextstep/templates/Info.plist.in \
5453       nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings:nextstep/templates/InfoPlist.strings.in])
5454     ns_check_file=Contents/Info.plist
5455   fi
5456   AC_SUBST(ns_check_file)
5459 AC_CONFIG_FILES([Makefile lib/gnulib.mk])
5461 dnl config.status treats $srcdir specially, so I think this is ok...
5462 AC_CONFIG_FILES([$srcdir/doc/man/emacs.1])
5464 m4_define([subdir_makefiles],
5465   [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])
5466 SUBDIR_MAKEFILES="subdir_makefiles"
5467 AC_CONFIG_FILES(subdir_makefiles)
5469 dnl test/ is not present in release tarfiles.
5470 opt_makefile=test/Makefile
5472 if test -f "$srcdir/$opt_makefile.in"; then
5473   SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
5474   dnl Again, it's best not to use a variable.  Though you can add
5475   dnl ", [], [opt_makefile='$opt_makefile']" and it should work.
5476   AC_CONFIG_FILES([test/Makefile])
5480 dnl The admin/ directory used to be excluded from tarfiles.
5481 if test -d $srcdir/admin; then
5482   SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES admin/charsets/Makefile admin/unidata/Makefile admin/grammars/Makefile"
5483   AC_CONFIG_FILES([admin/charsets/Makefile])
5484   AC_CONFIG_FILES([admin/unidata/Makefile])
5485   AC_CONFIG_FILES([admin/grammars/Makefile])
5486 fi                              dnl -d admin
5489 SUBDIR_MAKEFILES_IN=`echo " ${SUBDIR_MAKEFILES}" | sed -e 's| | $(srcdir)/|g' -e 's|Makefile|Makefile.in|g'`
5491 AC_SUBST(SUBDIR_MAKEFILES_IN)
5493 dnl You might wonder (I did) why epaths.h is generated by running make,
5494 dnl rather than just letting configure generate it from epaths.in.
5495 dnl One reason is that the various paths are not fully expanded (see above);
5496 dnl e.g., gamedir='${localstatedir}/games/emacs'.
5497 dnl Secondly, the GNU Coding standards require that one should be able
5498 dnl to run 'make prefix=/some/where/else' and override the values set
5499 dnl by configure.  This also explains the 'move-if-change' test and
5500 dnl the use of force in the 'epaths-force' rule in Makefile.in.
5501 AC_CONFIG_COMMANDS([src/epaths.h], [
5502 if test "${opsys}" = "mingw32"; then
5503   ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-w32
5504 else
5505   ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force
5506 fi || AC_MSG_ERROR(['src/epaths.h' could not be made.])
5507 ], [GCC="$GCC" CPPFLAGS="$CPPFLAGS" opsys="$opsys"])
5509 dnl NB we have to cheat and use the ac_... version because abs_top_srcdir
5510 dnl is not yet set, sigh.  Or we could use ../$srcdir/src/.gdbinit,
5511 dnl or a symlink?
5512 AC_CONFIG_COMMANDS([src/.gdbinit], [
5513 if test ! -f src/.gdbinit && test -f "$srcdir/src/.gdbinit"; then
5514   AS_ECHO(["source $ac_abs_top_srcdir/src/.gdbinit"]) > src/.gdbinit
5518 dnl Perhaps this would be better named doc-emacs-emacsver.texi?
5519 dnl See comments for etc-refcards-emacsver.tex.
5520 dnl Since we get a doc/emacs directory generated anyway, for the Makefile,
5521 dnl it is not quite the same.  But we are generating in $srcdir.
5522 AC_CONFIG_COMMANDS([doc/emacs/emacsver.texi], [
5523 ${MAKE-make} -s --no-print-directory -C doc/emacs doc-emacsver || \
5524 AC_MSG_ERROR(['doc/emacs/emacsver.texi' could not be made.])
5527 dnl If we give this the more natural name, etc/refcards/emacsver.texi,
5528 dnl then a directory etc/refcards is created in the build directory,
5529 dnl which is probably harmless, but confusing (in out-of-tree builds).
5530 dnl (If we were to generate etc/refcards/Makefile, this might change.)
5531 dnl It is really $srcdir/etc/refcards/emacsver.tex that we generate.
5532 AC_CONFIG_COMMANDS([etc-refcards-emacsver.tex], [
5533 ${MAKE-make} -s MAKEFILE_NAME=do-not-make-Makefile etc-emacsver || \
5534 AC_MSG_ERROR(['etc/refcards/emacsver.tex' could not be made.])
5537 if test $AUTO_DEPEND = yes; then
5538    for dir in $AUTODEPEND_PARENTS; do
5539      AS_MKDIR_P([$dir/deps])
5540    done
5543 AC_OUTPUT
5545 if test ! "$with_mailutils"; then
5546   if test "$with_pop" = yes; then
5547     AC_MSG_WARN([This configuration installs a 'movemail' program
5548 that retrieves POP3 email via only insecure channels.
5549 To omit insecure POP3, you can use '$0 --without-pop'.])
5550   fi
5552   case $opsys in
5553     mingw32)
5554       # Don't suggest GNU Mailutils, as it hasn't been ported.
5555       ;;
5556     *)
5557       emacs_fix_movemail="use '$0 --with-mailutils'"
5558       case `(movemail --version) 2>/dev/null` in
5559         *Mailutils*) ;;
5560         *) emacs_fix_movemail="install GNU Mailutils
5561 <http://mailutils.org> and $emacs_fix_movemail";;
5562       esac
5563       AC_MSG_NOTICE([You might want to $emacs_fix_movemail.]);;
5564   esac
5567 test "$MAKE" = make || AC_MSG_NOTICE([Now you can run '$MAKE'.])