zap until-condition
[emacs.git] / configure.ac
blob6b22cd0cfab3410122014f4069d44deb898114bb
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-2013 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 AC_INIT(emacs, 24.3.50)
27 dnl Set emacs_config_options to the options of 'configure', quoted for the shell,
28 dnl and then quoted again for a C string.  Separate options with spaces.
29 dnl Add some environment variables, if they were passed via the environment
30 dnl rather than on the command-line.
31 emacs_config_options=
32 optsep=
33 dnl This is the documented way to record the args passed to configure,
34 dnl rather than $ac_configure_args.
35 for opt in ${1+"$@"} CFLAGS CPPFLAGS LDFLAGS; do
36   case $opt in
37     -n | --no-create | --no-recursion)
38       continue ;;
39     CFLAGS | CPPFLAGS | LDFLAGS)
40       eval 'test "${'$opt'+set}" = set' || continue
41       case " $*" in
42         *" $opt="*) continue ;;
43       esac
44       eval opt=$opt=\$$opt ;;
45   esac
47   emacs_shell_specials=$IFS\''"#$&()*;<>?@<:@\\`{|~'
48   case $opt in
49     *[["$emacs_shell_specials"]]*)
50       case $opt in
51         *\'*)
52           emacs_quote_apostrophes="s/'/'\\\\''/g"
53           opt=`AS_ECHO(["$opt"]) | sed "$emacs_quote_apostrophes"` ;;
54       esac
55       opt="'$opt'"
56       case $opt in
57         *[['"\\']]*)
58           emacs_quote_for_c='s/[["\\]]/\\&/g; $!s/$/\\n\\/'
59           opt=`AS_ECHO(["$opt"]) | sed "$emacs_quote_for_c"` ;;
60       esac ;;
61   esac
62   AS_VAR_APPEND([emacs_config_options], ["$optsep$opt"])
63   optsep=' '
64 done
66 AC_CONFIG_HEADER(src/config.h:src/config.in)
67 AC_CONFIG_SRCDIR(src/lisp.h)
68 AC_CONFIG_AUX_DIR(build-aux)
69 dnl Fairly arbitrary, older versions might work too.
70 AM_INIT_AUTOMAKE(1.11)
72 dnl Support for --program-prefix, --program-suffix and
73 dnl --program-transform-name options
74 AC_ARG_PROGRAM
76 dnl It is important that variables on the RHS not be expanded here,
77 dnl hence the single quotes.  This is per the GNU coding standards, see
78 dnl (autoconf) Installation Directory Variables
79 dnl See also epaths.h below.
80 lispdir='${datadir}/emacs/${version}/lisp'
81 leimdir='${datadir}/emacs/${version}/leim'
82 standardlisppath='${lispdir}:${leimdir}'
83 locallisppath='${datadir}/emacs/${version}/site-lisp:'\
84 '${datadir}/emacs/site-lisp'
85 lisppath='${locallisppath}:${standardlisppath}'
86 etcdir='${datadir}/emacs/${version}/etc'
87 archlibdir='${libexecdir}/emacs/${version}/${configuration}'
88 etcdocdir='${datadir}/emacs/${version}/etc'
89 gamedir='${localstatedir}/games/emacs'
91 dnl Special option to disable the most of other options.
92 AC_ARG_WITH(all,
93 [AS_HELP_STRING([--without-all],
94                 [omit almost all features and build
95                 small executable with minimal dependencies])],
96   with_features=$withval,
97   with_features=yes)
99 dnl OPTION_DEFAULT_OFF(NAME, HELP-STRING)
100 dnl Create a new --with option that defaults to being disabled.
101 dnl NAME is the base name of the option.  The shell variable with_NAME
102 dnl   will be set to either the user's value (if the option is
103 dnl   specified; 'yes' for a plain --with-NAME) or to 'no' (if the
104 dnl   option is not specified).  Note that the shell variable name is
105 dnl   constructed as autoconf does, by replacing non-alphanumeric
106 dnl   characters with "_".
107 dnl HELP-STRING is the help text for the option.
108 AC_DEFUN([OPTION_DEFAULT_OFF], [dnl
109   AC_ARG_WITH([$1],[AS_HELP_STRING([--with-$1],[$2])],[],[dnl
110     m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=no])dnl
111 ])dnl
113 dnl OPTION_DEFAULT_ON(NAME, HELP-STRING)
114 dnl Create a new --with option that defaults to $with_features.
115 dnl NAME is the base name of the option.  The shell variable with_NAME
116 dnl   will be set either to 'no' (for a plain --without-NAME) or to
117 dnl   'yes' (if the option is not specified).  Note that the shell
118 dnl   variable name is constructed as autoconf does, by replacing
119 dnl   non-alphanumeric characters with "_".
120 dnl HELP-STRING is the help text for the option.
121 AC_DEFUN([OPTION_DEFAULT_ON], [dnl
122   AC_ARG_WITH([$1],[AS_HELP_STRING([--without-$1],[$2])],[],[dnl
123    m4_bpatsubst([with_$1], [[^0-9a-z]], [_])=$with_features])dnl
124 ])dnl
126 OPTION_DEFAULT_ON([pop],[don't support POP mail retrieval with movemail])
127 if test "$with_pop" = yes; then
128    AC_DEFINE(MAIL_USE_POP)
130 AH_TEMPLATE(MAIL_USE_POP, [Define to support POP mail retrieval.])dnl
132 OPTION_DEFAULT_OFF([kerberos],[support Kerberos-authenticated POP])
133 if test "$with_kerberos" != no; then
134    AC_DEFINE(KERBEROS)
136 AH_TEMPLATE(KERBEROS,
137             [Define to support Kerberos-authenticated POP mail retrieval.])dnl
139 OPTION_DEFAULT_OFF([kerberos5],[support Kerberos version 5 authenticated POP])
140 if test "${with_kerberos5}" != no; then
141   if test "${with_kerberos}" = no; then
142     with_kerberos=yes
143     AC_DEFINE(KERBEROS)
144   fi
145   AC_DEFINE(KERBEROS5, 1, [Define to use Kerberos 5 instead of Kerberos 4.])
148 OPTION_DEFAULT_OFF([hesiod],[support Hesiod to get the POP server host])
149 dnl FIXME hesiod support may not be present, so it seems like an error
150 dnl to define, or at least use, this unconditionally.
151 if test "$with_hesiod" != no; then
152   AC_DEFINE(HESIOD, 1, [Define to support using a Hesiod database to find the POP server.])
155 OPTION_DEFAULT_OFF([mmdf],[support MMDF mailboxes])
156 if test "$with_mmdf" != no; then
157    AC_DEFINE(MAIL_USE_MMDF, 1, [Define to support MMDF mailboxes in movemail.])
160 OPTION_DEFAULT_OFF([mail-unlink],[unlink, rather than empty, mail spool after reading])
161 if test "$with_mail_unlink" != no; then
162    AC_DEFINE(MAIL_UNLINK_SPOOL, 1, [Define to unlink, rather than empty, mail spool after reading.])
165 AC_ARG_WITH([mailhost],[AS_HELP_STRING([--with-mailhost=HOSTNAME],
166     [string giving default POP mail host])],
167     AC_DEFINE_UNQUOTED(MAILHOST, ["$withval"], [String giving fallback POP mail host.]))
169 AC_ARG_WITH([sound],[AS_HELP_STRING([--with-sound=VALUE],
170   [compile with sound support (VALUE one of: yes, ossaudio, alsa, no;
171 default yes).  Only for GNU/Linux, FreeBSD, NetBSD, MinGW.])],
172   [ case "${withval}" in
173       yes|no|ossaudio|alsa) val=$withval ;;
174       *) AC_MSG_ERROR([`--with-sound=$withval' is invalid;
175 this option's value should be `yes', `no', `ossaudio', or `alsa'.])
176       ;;
177     esac
178     with_sound=$val
179   ],
180   [with_sound=$with_features])
182 dnl FIXME currently it is not the last.
183 dnl This should be the last --with option, because --with-x is
184 dnl added later on when we find the file name of X, and it's best to
185 dnl keep them together visually.
186 AC_ARG_WITH([x-toolkit],[AS_HELP_STRING([--with-x-toolkit=KIT],
187  [use an X toolkit (KIT one of: yes or gtk, gtk2, gtk3, lucid or athena, motif, no)])],
188 [         case "${withval}" in
189             y | ye | yes )      val=gtk ;;
190             n | no )            val=no  ;;
191             l | lu | luc | luci | lucid )       val=lucid ;;
192             a | at | ath | athe | athen | athena )      val=athena ;;
193             m | mo | mot | moti | motif )       val=motif ;;
194             g | gt | gtk  )     val=gtk ;;
195             gtk2  )     val=gtk2 ;;
196             gtk3  )     val=gtk3 ;;
197             * )
198 AC_MSG_ERROR([`--with-x-toolkit=$withval' is invalid;
199 this option's value should be `yes', `no', `lucid', `athena', `motif', `gtk',
200 `gtk2' or `gtk3'.  `yes' and `gtk' are synonyms.
201 `athena' and `lucid' are synonyms.])
202             ;;
203           esac
204           with_x_toolkit=$val
207 OPTION_DEFAULT_OFF([wide-int], [prefer wide Emacs integers (typically 62-bit)])
208 if test "$with_wide_int" = yes; then
209   AC_DEFINE([WIDE_EMACS_INT], 1, [Use long long for EMACS_INT if available.])
212 dnl _ON results in a '--without' option in the --help output, so
213 dnl the help text should refer to "don't compile", etc.
214 OPTION_DEFAULT_ON([xpm],[don't compile with XPM image support])
215 OPTION_DEFAULT_ON([jpeg],[don't compile with JPEG image support])
216 OPTION_DEFAULT_ON([tiff],[don't compile with TIFF image support])
217 OPTION_DEFAULT_ON([gif],[don't compile with GIF image support])
218 OPTION_DEFAULT_ON([png],[don't compile with PNG image support])
219 OPTION_DEFAULT_ON([rsvg],[don't compile with SVG image support])
220 OPTION_DEFAULT_ON([xml2],[don't compile with XML parsing support])
221 OPTION_DEFAULT_ON([imagemagick],[don't compile with ImageMagick image support])
223 OPTION_DEFAULT_ON([xft],[don't use XFT for anti aliased fonts])
224 OPTION_DEFAULT_ON([libotf],[don't use libotf for OpenType font support])
225 OPTION_DEFAULT_ON([m17n-flt],[don't use m17n-flt for text shaping])
227 OPTION_DEFAULT_ON([toolkit-scroll-bars],[don't use Motif or Xaw3d scroll bars])
228 OPTION_DEFAULT_ON([xaw3d],[don't use Xaw3d])
229 OPTION_DEFAULT_ON([xim],[don't use X11 XIM])
230 OPTION_DEFAULT_OFF([ns],[use NeXTstep (Cocoa or GNUstep) windowing system])
231 OPTION_DEFAULT_OFF([w32], [use native MS Windows GUI in a Cygwin build])
233 OPTION_DEFAULT_ON([gpm],[don't use -lgpm for mouse support on a GNU/Linux console])
234 OPTION_DEFAULT_ON([dbus],[don't compile with D-Bus support])
235 OPTION_DEFAULT_ON([gconf],[don't compile with GConf support])
236 OPTION_DEFAULT_ON([gsettings],[don't compile with GSettings support])
237 OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support])
238 OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support])
239 OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support])
240 OPTION_DEFAULT_ON([threads],[don't compile with elisp threading support])
242 AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB],
243  [use a file notification library (LIB one of: yes, gfile, inotify, w32, no)])],
244  [ case "${withval}" in
245     y | ye | yes )      val=yes ;;
246     n | no )            val=no  ;;
247     g | gf | gfi | gfil | gfile )       val=gfile ;;
248     i | in | ino | inot | inoti | inotif | inotify )    val=inotify ;;
249     w | w3 | w32 )      val=w32 ;;
250     * ) AC_MSG_ERROR([`--with-file-notification=$withval' is invalid;
251 this option's value should be `yes', `no', `gfile', `inotify' or `w32'.
252 `yes' is a synonym for `w32' on MS-Windows, for `no' on Nextstep,
253 otherwise for the first of `gfile' or `inotify' that is usable.])
254     ;;
255    esac
256    with_file_notification=$val
257  ],
258  [with_file_notification=$with_features])
260 ## For the times when you want to build Emacs but don't have
261 ## a suitable makeinfo, and can live without the manuals.
262 dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html
263 OPTION_DEFAULT_ON([makeinfo],[don't require makeinfo for building manuals])
265 ## Makefile.in needs the cache file name.
266 AC_SUBST(cache_file)
268 ## This is an option because I do not know if all info/man support
269 ## compressed files, nor how to test if they do so.
270 OPTION_DEFAULT_ON([compress-info],[don't compress the installed Info pages])
271 if test $with_compress_info = yes; then
272    GZIP_INFO=yes
273 else
274    GZIP_INFO=
276 AC_SUBST(GZIP_INFO)
278 AC_ARG_WITH([pkg-config-prog],dnl
279 [AS_HELP_STRING([--with-pkg-config-prog=FILENAME],
280                   [file name of pkg-config for finding GTK and librsvg])])
281 if test "X${with_pkg_config_prog}" != X; then
282    if test "${with_pkg_config_prog}" != yes; then
283       PKG_CONFIG="${with_pkg_config_prog}"
284    fi
287 AC_ARG_WITH(gameuser,dnl
288 [AS_HELP_STRING([--with-gameuser=USER],[user for shared game score files])])
289 test "X${with_gameuser}" != X && test "${with_gameuser}" != yes \
290   && gameuser="${with_gameuser}"
291 test "X$gameuser" = X && gameuser=games
293 AC_ARG_WITH([gnustep-conf],dnl
294 [AS_HELP_STRING([--with-gnustep-conf=FILENAME],
295    [name of GNUstep.conf; default $GNUSTEP_CONFIG_FILE, or /etc/GNUstep/GNUstep.conf])])
296 test "X${with_gnustep_conf}" != X && test "${with_gnustep_conf}" != yes && \
297   GNUSTEP_CONFIG_FILE="${with_gnustep_conf}"
298 test "X$GNUSTEP_CONFIG_FILE" = "X" && \
299      GNUSTEP_CONFIG_FILE=/etc/GNUstep/GNUstep.conf
301 AC_ARG_ENABLE(ns-self-contained,
302 [AS_HELP_STRING([--disable-ns-self-contained],
303                 [disable self contained build under NeXTstep])],
304    EN_NS_SELF_CONTAINED=$enableval,
305    EN_NS_SELF_CONTAINED=yes)
307 AC_ARG_ENABLE(locallisppath,
308 [AS_HELP_STRING([--enable-locallisppath=PATH],
309                 [directories Emacs should search for lisp files specific
310                  to this site])],
311 if test "${enableval}" = "no"; then
312   locallisppath=
313 elif test "${enableval}" != "yes"; then
314   locallisppath=${enableval}
317 AC_ARG_ENABLE(checking,
318 [AS_HELP_STRING([--enable-checking@<:@=LIST@:>@],
319                 [enable expensive run-time checks.  With LIST,
320                  enable only specific categories of checks.
321                  Categories are: all,yes,no.
322                  Flags are: stringbytes, stringoverrun, stringfreelist,
323                  xmallocoverrun, conslist, glyphs])],
324 [ac_checking_flags="${enableval}"],[])
325 IFS="${IFS=     }"; ac_save_IFS="$IFS"; IFS="$IFS,"
326 for check in $ac_checking_flags
328         case $check in
329         # these set all the flags to specific states
330         yes)            ac_enable_checking=1 ;;
331         no)             ac_enable_checking= ;
332                         ac_gc_check_stringbytes= ;
333                         ac_gc_check_string_overrun= ;
334                         ac_gc_check_string_free_list= ;
335                         ac_xmalloc_overrun= ;
336                         ac_gc_check_cons_list= ;
337                         ac_glyphs_debug= ;;
338         all)            ac_enable_checking=1 ;
339                         ac_gc_check_stringbytes=1 ;
340                         ac_gc_check_string_overrun=1 ;
341                         ac_gc_check_string_free_list=1 ;
342                         ac_xmalloc_overrun=1 ;
343                         ac_gc_check_cons_list=1 ;
344                         ac_glyphs_debug=1 ;;
345         # these enable particular checks
346         stringbytes)    ac_gc_check_stringbytes=1 ;;
347         stringoverrun)  ac_gc_check_string_overrun=1 ;;
348         stringfreelist) ac_gc_check_string_free_list=1 ;;
349         xmallocoverrun) ac_xmalloc_overrun=1 ;;
350         conslist)       ac_gc_check_cons_list=1 ;;
351         glyphs)         ac_glyphs_debug=1 ;;
352         *)      AC_MSG_ERROR(unknown check category $check) ;;
353         esac
354 done
355 IFS="$ac_save_IFS"
357 if test x$ac_enable_checking != x ; then
358   AC_DEFINE(ENABLE_CHECKING, 1,
359 [Define to 1 if expensive run-time data type and consistency checks are enabled.])
361 if test x$ac_gc_check_stringbytes != x ; then
362   AC_DEFINE(GC_CHECK_STRING_BYTES, 1,
363 [Define this temporarily to hunt a bug.  If defined, the size of
364    strings is redundantly recorded in sdata structures so that it can
365    be compared to the sizes recorded in Lisp strings.])
367 if test x$ac_gc_check_string_overrun != x ; then
368   AC_DEFINE(GC_CHECK_STRING_OVERRUN, 1,
369 [Define this to check for short string overrun.])
371 if test x$ac_gc_check_string_free_list != x ; then
372   AC_DEFINE(GC_CHECK_STRING_FREE_LIST, 1,
373 [Define this to check the string free list.])
375 if test x$ac_xmalloc_overrun != x ; then
376   AC_DEFINE(XMALLOC_OVERRUN_CHECK, 1,
377 [Define this to check for malloc buffer overrun.])
379 if test x$ac_gc_check_cons_list != x ; then
380   AC_DEFINE(GC_CHECK_CONS_LIST, 1,
381 [Define this to check for errors in cons list.])
383 if test x$ac_glyphs_debug != x ; then
384   AC_DEFINE(GLYPH_DEBUG, 1,
385 [Define this to enable glyphs debugging code.])
388 AC_ARG_ENABLE(check-lisp-object-type,
389 [AS_HELP_STRING([--enable-check-lisp-object-type],
390                 [enable compile time checks for the Lisp_Object data type.
391                 This is useful for development for catching certain types of bugs.])],
392 if test "${enableval}" != "no"; then
393    AC_DEFINE(CHECK_LISP_OBJECT_TYPE, 1,
394    [Define this to enable compile time checks for the Lisp_Object data type.])
398 dnl The name of this option is unfortunate.  It predates, and has no
399 dnl relation to, the "sampling-based elisp profiler" added in 24.3.
400 dnl Actually, it stops it working.
401 dnl http://lists.gnu.org/archive/html/emacs-devel/2012-11/msg00393.html
402 AC_ARG_ENABLE(profiling,
403 [AS_HELP_STRING([--enable-profiling],
404                 [build emacs with low-level, gprof profiling support.
405                 Mainly useful for debugging Emacs itself.  May not work on
406                 all platforms.  Stops profiler.el working.])],
407 [ac_enable_profiling="${enableval}"],[])
408 if test x$ac_enable_profiling != x ; then
409    PROFILING_CFLAGS="-DPROFILING=1 -pg"
410 else
411    PROFILING_CFLAGS=
413 AC_SUBST(PROFILING_CFLAGS)
415 AC_ARG_ENABLE(autodepend,
416 [AS_HELP_STRING([--enable-autodepend],
417                 [automatically generate dependencies to .h-files.
418                  Requires GNU Make and Gcc. Enabled if GNU Make and Gcc is
419                  found])],
420 [ac_enable_autodepend="${enableval}"],[ac_enable_autodepend=yes])
422 AC_ARG_ENABLE(gtk-deprecation-warnings,
423 [AS_HELP_STRING([--enable-gtk-deprecation-warnings],
424                 [Show Gtk+/Gdk deprecation warnings for Gtk+ >= 3.0])],
425 [ac_enable_gtk_deprecation_warnings="${enableval}"],[])
427 #### Make srcdir absolute, if it isn't already.  It's important to
428 #### avoid running the file name through pwd unnecessarily, since pwd can
429 #### give you automounter prefixes, which can go away.  We do all this
430 #### so Emacs can find its files when run uninstalled.
431 ## Make sure CDPATH doesn't affect cd (in case PWD is relative).
432 unset CDPATH
433 case "${srcdir}" in
434   [[\\/]]* | ?:[[\\/]]*) ;;
435   . )
436     ## We may be able to use the $PWD environment variable to make this
437     ## absolute.  But sometimes PWD is inaccurate.
438     ## Note: we used to use $PWD at the end instead of `pwd`,
439     ## but that tested only for a well-formed and valid PWD,
440     ## it did not object when PWD was well-formed and valid but just wrong.
441     if test ".$PWD" != "." && test ".`(cd "$PWD" ; sh -c pwd)`" = ".`pwd`"  ;
442     then
443       srcdir="$PWD"
444     else
445       srcdir=`(cd "$srcdir"; pwd)`
446     fi
447   ;;
448   *  ) srcdir=`(cd "$srcdir"; pwd)` ;;
449 esac
451 ### Canonicalize the configuration name.
453 AC_CANONICAL_HOST
454 canonical=$host
455 configuration=${host_alias-${build_alias-$host}}
457 dnl This used to use changequote, but, apart from `changequote is evil'
458 dnl per the autoconf manual, we can speed up autoconf somewhat by quoting
459 dnl the great gob of text.  Thus it's not processed for possible expansion.
460 dnl Just make sure the brackets remain balanced.
462 dnl Since Emacs can't find matching pairs of quotes, boundaries are
463 dnl indicated by comments.
464 dnl quotation begins
467 ### If you add support for a new configuration, add code to this
468 ### switch statement to recognize your configuration name and select
469 ### the appropriate operating system file.
471 ### You would hope that you could choose an s/*.h
472 ### file based on the operating system portion.  However, it turns out
473 ### that each s/*.h file is pretty manufacturer-specific.
474 ### So we basically have to have a special case for each
475 ### configuration name.
477 ### As far as handling version numbers on operating systems is
478 ### concerned, make sure things will fail in a fixable way.  If
479 ### /etc/MACHINES doesn't say anything about version numbers, be
480 ### prepared to handle anything reasonably.  If version numbers
481 ### matter, be sure /etc/MACHINES says something about it.
483 opsys='' unported=no
484 case "${canonical}" in
486   ## GNU/Linux and similar ports
487   *-*-linux* )
488     opsys=gnu-linux
489   ;;
491   ## FreeBSD ports
492   *-*-freebsd* )
493     opsys=freebsd
494   ;;
496   ## DragonFly ports
497   *-*-dragonfly* )
498     opsys=dragonfly
499   ;;
501   ## FreeBSD kernel + glibc based userland
502   *-*-kfreebsd*gnu* )
503     opsys=gnu-kfreebsd
504   ;;
506   ## NetBSD ports
507   *-*-netbsd* )
508     opsys=netbsd
509   ;;
511   ## OpenBSD ports
512   *-*-openbsd* )
513     opsys=openbsd
514   ;;
516   ## Apple Darwin / Mac OS X
517   *-apple-darwin* )
518     case "${canonical}" in
519       i[3456]86-* )  ;;
520       powerpc-* )    ;;
521       x86_64-* )     ;;
522       * )            unported=yes ;;
523     esac
524     opsys=darwin
525     ## Use fink packages if available.
526     ## FIXME find a better way to do this: http://debbugs.gnu.org/11507
527 ##    if test -d /sw/include && test -d /sw/lib; then
528 ##      GCC_TEST_OPTIONS="-I/sw/include -L/sw/lib"
529 ##      NON_GCC_TEST_OPTIONS=${GCC_TEST_OPTIONS}
530 ##    fi
531   ;;
533   ## Cygwin ports
534   *-*-cygwin )
535     opsys=cygwin
536   ;;
538   ## HP 9000 series 700 and 800, running HP/UX
539   hppa*-hp-hpux10.2* )
540     opsys=hpux10-20
541   ;;
542   hppa*-hp-hpux1[1-9]* )
543     opsys=hpux11
544     CFLAGS="-D_INCLUDE__STDC_A1_SOURCE $CFLAGS"
545   ;;
547   ## IBM machines
548   rs6000-ibm-aix4.[23]* )
549     opsys=aix4-2
550   ;;
551   powerpc-ibm-aix4.[23]*  )
552     opsys=aix4-2
553   ;;
554   rs6000-ibm-aix[56]* )
555     opsys=aix4-2
556   ;;
557   powerpc-ibm-aix[56]*  )
558     opsys=aix4-2
559   ;;
561   ## Silicon Graphics machines
562   ## Iris 4D
563   mips-sgi-irix6.5 )
564     opsys=irix6-5
565     # Without defining _LANGUAGE_C, things get masked out in the headers
566     # so that, for instance, grepping for `free' in stdlib.h fails and
567     # AC_HEADER_STD_C fails.   (MIPSPro 7.2.1.2m compilers, Irix 6.5.3m).
568     NON_GCC_TEST_OPTIONS="-D_LANGUAGE_C"
569   ;;
571   ## Suns
572   *-sun-solaris* \
573     | i[3456]86-*-solaris2* | i[3456]86-*-sunos5* \
574     | x86_64-*-solaris2*    | x86_64-*-sunos5*)
575     case "${canonical}" in
576       i[3456]86-*-* )   ;;
577       amd64-*-*|x86_64-*-*) ;;
578       sparc* )          ;;
579       * )               unported=yes ;;
580     esac
581     case "${canonical}" in
582       *-sunos5.6* | *-solaris2.6* )
583                 opsys=sol2-6
584                 RANLIB="ar -ts"
585                 ;;
586       *-sunos5.[7-9]* | *-solaris2.[7-9]* )
587                 opsys=sol2-6
588                 emacs_check_sunpro_c=yes
589                 ;;
590       *-sunos5* | *-solaris* )
591                 opsys=sol2-10
592                 emacs_check_sunpro_c=yes
593                 ;;
594     esac
595     ## Watch out for a compiler that we know will not work.
596     case "${canonical}" in
597      *-solaris* | *-sunos5* )
598                 if [ "x$CC" = x/usr/ucb/cc ]; then
599                   ## /usr/ucb/cc doesn't work;
600                   ## we should find some other compiler that does work.
601                   unset CC
602                 fi
603                 ;;
604       *) ;;
605     esac
606   ;;
608   ## Intel 386 machines where we don't care about the manufacturer.
609   i[3456]86-*-* )
610     case "${canonical}" in
611       *-darwin* )               opsys=darwin ;;
612       *-mingw32 )
613                 opsys=mingw32
614                 # MinGW overrides and adds some system headers in nt/inc.
615                 GCC_TEST_OPTIONS="-I $srcdir/nt/inc"
616                 ;;
617       *-sysv4.2uw* )            opsys=unixware ;;
618       *-sysv5uw* )              opsys=unixware ;;
619       *-sysv5OpenUNIX* )        opsys=unixware ;;
620       ## Otherwise, we'll fall through to the generic opsys code at the bottom.
621     esac
622   ;;
624   * )
625     unported=yes
626   ;;
627 esac
629 ### If the code above didn't choose an operating system, just choose
630 ### an operating system based on the configuration name.  You really
631 ### only want to use this when you have no idea what the right
632 ### operating system is; if you know what operating systems a machine
633 ### runs, it's cleaner to make it explicit in the case statement
634 ### above.
635 if test x"${opsys}" = x; then
636   case "${canonical}" in
637     *-gnu* )                            opsys=gnu ;;
638     * )
639       unported=yes
640     ;;
641   esac
645 dnl quotation ends
647 if test $unported = yes; then
648   AC_MSG_ERROR([Emacs hasn't been ported to `${canonical}' systems.
649 Check `etc/MACHINES' for recognized configuration names.])
653 #### Choose a compiler.
655 dnl Sets GCC=yes if using gcc.
656 AC_PROG_CC
657 AM_PROG_CC_C_O
659 if test x$GCC = xyes; then
660   test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
661 else
662   test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS"
665 dnl This is used in lib/Makefile.am to use nt/gnulib.mk, the
666 dnl alternative to lib/gnulib.mk, so as to avoid generating header files
667 dnl that clash with MinGW.
668 AM_CONDITIONAL([BUILDING_FOR_WINDOWSNT], [test "x$opsys" = "xmingw32"])
670 # Avoid gnulib's tests for HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW,
671 # as we don't use them.
672 AC_DEFUN([gl_FCNTL_O_FLAGS])
673 # Avoid gnulib's threadlib module, as we do threads our own way.
674 AC_DEFUN([gl_THREADLIB])
676 # Initialize gnulib right after choosing the compiler.
677 dnl Amongst other things, this sets AR and ARFLAGS.
678 gl_EARLY
680 if test "$ac_test_CFLAGS" != set; then
681   # It's helpful to have C macros available to GDB, so prefer -g3 to -g
682   # if -g3 works and the user does not specify CFLAGS.
683   # This test must follow gl_EARLY; otherwise AC_LINK_IFELSE complains.
684   case $CFLAGS in
685     '-g')
686       emacs_g3_CFLAGS='-g3';;
687     '-g -O2')
688       emacs_g3_CFLAGS='-g3 -O2';;
689     *)
690       emacs_g3_CFLAGS='';;
691   esac
692   if test -n "$emacs_g3_CFLAGS"; then
693     emacs_save_CFLAGS=$CFLAGS
694     CFLAGS=$emacs_g3_CFLAGS
695     AC_CACHE_CHECK([whether $CC accepts $emacs_g3_CFLAGS],
696       [emacs_cv_prog_cc_g3],
697       [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
698          [emacs_cv_prog_cc_g3=yes],
699          [emacs_cv_prog_cc_g3=no])])
700     if test $emacs_cv_prog_cc_g3 != yes; then
701       CFLAGS=$emacs_save_CFLAGS
702     fi
703     if test $opsys = mingw32; then
704       CFLAGS="$CFLAGS -gdwarf-2"
705     fi
706   fi
708   case $CFLAGS in
709     *-O*) ;;
710     *)
711       # No optimization flag was inferred for this non-GCC compiler.
712       # Try -O.  This is needed for xlc on AIX; see Bug#14258.
713       emacs_save_CFLAGS=$CFLAGS
714       test -z "$CFLAGS" || CFLAGS="$CFLAGS "
715       CFLAGS=${CFLAGS}-O
716       AC_CACHE_CHECK([whether $CC accepts -O],
717         [emacs_cv_prog_cc_o],
718         [AC_LINK_IFELSE([AC_LANG_PROGRAM()],
719            [emacs_cv_prog_cc_o=yes],
720            [emacs_cv_prog_cc_o=no])])
721       if test $emacs_cv_prog_cc_o != yes; then
722         CFLAGS=$emacs_save_CFLAGS
723       fi ;;
724   esac
727 AC_ARG_ENABLE([gcc-warnings],
728   [AS_HELP_STRING([--enable-gcc-warnings],
729                   [turn on lots of GCC warnings/errors. This is intended for
730                    developers, and may generate false alarms when used
731                    with older or non-GNU development tools.])],
732   [case $enableval in
733      yes|no) ;;
734      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
735    esac
736    gl_gcc_warnings=$enableval],
737   [gl_gcc_warnings=no]
740 AC_ARG_ENABLE(link-time-optimization,
741 [AS_HELP_STRING([--enable-link-time-optimization],
742                 [build emacs with link-time optimization.
743                  This is supported only for GCC since 4.5.0.])],
744 if test "${enableval}" != "no"; then
745    AC_MSG_CHECKING([whether link-time optimization is supported])
746    ac_lto_supported=no
747    if test x$GCC = xyes; then
748       CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
749       if test x$CPUS != x; then
750          LTO="-flto=$CPUS"
751       else
752          LTO="-flto"
753       fi
754       old_CFLAGS=$CFLAGS
755       CFLAGS="$CFLAGS $LTO"
756       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
757         [ac_lto_supported=yes], [ac_lto_supported=no])
758       CFLAGS="$old_CFLAGS"
759    fi
760    AC_MSG_RESULT([$ac_lto_supported])
761    if test "$ac_lto_supported" = "yes"; then
762       CFLAGS="$CFLAGS $LTO"
763    fi
766 # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
767 # ------------------------------------------------
768 # If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
769 # Otherwise, run RUN-IF-NOT-FOUND.
770 AC_DEFUN([gl_GCC_VERSION_IFELSE],
771   [AC_PREPROC_IFELSE(
772     [AC_LANG_PROGRAM(
773       [[
774 #if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
775 /* ok */
776 #else
777 # error "your version of gcc is older than $1.$2"
778 #endif
779       ]]),
780     ], [$3], [$4])
781   ]
784 # When compiling with GCC, prefer -isystem to -I when including system
785 # include files, to avoid generating useless diagnostics for the files.
786 if test "$gl_gcc_warnings" != yes; then
787   isystem='-I'
788 else
789   isystem='-isystem '
791   # This, $nw, is the list of warnings we disable.
792   nw=
794   case $with_x_toolkit in
795     lucid | athena | motif)
796        # Old toolkits mishandle 'const'.
797        nw="$nw -Wwrite-strings"
798        ;;
799     *)
800        gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
801        ;;
802   esac
803   AC_SUBST([WERROR_CFLAGS])
805   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
806   nw="$nw -Woverlength-strings"     # Not a problem these days
807   nw="$nw -Wlogical-op"             # any use of fwrite provokes this
808   nw="$nw -Wformat-nonliteral"      # we do this a lot
809   nw="$nw -Wvla"                    # warnings in gettext.h
810   nw="$nw -Wnested-externs"         # use of XARGMATCH/verify_function__
811   nw="$nw -Wswitch-default"         # Too many warnings for now
812   nw="$nw -Winline"                 # OK to ignore 'inline'
813   nw="$nw -Wjump-misses-init"       # We sometimes safely jump over init.
814   nw="$nw -Wstrict-overflow"        # OK to optimize assuming that
815                                     # signed overflow has undefined behavior
816   nw="$nw -Wsync-nand"              # irrelevant here, and provokes ObjC warning
817   nw="$nw -Wunsafe-loop-optimizations" # OK to suppress unsafe optimizations
818   nw="$nw -Wbad-function-cast"      # These casts are no worse than others.
820   # Emacs doesn't care about shadowing; see
821   # <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
822   nw="$nw -Wshadow"
824   # Emacs's use of alloca inhibits protecting the stack.
825   nw="$nw -Wstack-protector"
827   # The following line should be removable at some point.
828   nw="$nw -Wsuggest-attribute=pure"
830   # clang is unduly picky about some things.
831   AC_CACHE_CHECK([whether the compiler is clang], [emacs_cv_clang],
832     [AC_COMPILE_IFELSE(
833        [AC_LANG_PROGRAM([[
834             #ifndef __clang__
835               #error "not clang"
836             #endif
837           ]])],
838        [emacs_cv_clang=yes],
839        [emacs_cv_clang=no])])
840   if test $emacs_cv_clang = yes; then
841     nw="$nw -Wcast-align"
842   fi
844   gl_MANYWARN_ALL_GCC([ws])
845   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
846   for w in $ws; do
847     gl_WARN_ADD([$w])
848   done
849   gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
850   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
851   gl_WARN_ADD([-Wno-type-limits])      # Too many warnings for now
852   gl_WARN_ADD([-Wno-switch])           # Too many warnings for now
853   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
854   gl_WARN_ADD([-Wno-format-nonliteral])
856   # In spite of excluding -Wlogical-op above, it is enabled, as of
857   # gcc 4.5.0 20090517.
858   gl_WARN_ADD([-Wno-logical-op])
860   # More things that clang is unduly picky about.
861   if test $emacs_cv_clang = yes; then
862     gl_WARN_ADD([-Wno-format-extra-args])
863     gl_WARN_ADD([-Wno-tautological-constant-out-of-range-compare])
864     gl_WARN_ADD([-Wno-unused-command-line-argument])
865     gl_WARN_ADD([-Wno-unused-value])
866   fi
868   gl_WARN_ADD([-fdiagnostics-show-option])
869   gl_WARN_ADD([-funit-at-a-time])
871   AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
872   AH_VERBATIM([FORTIFY_SOURCE],
873   [/* Enable compile-time and run-time bounds-checking, and some warnings,
874       without upsetting glibc 2.15+. */
875    #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__
876    # define _FORTIFY_SOURCE 2
877    #endif
878   ])
879   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
881   # We use a slightly smaller set of warning options for lib/.
882   # Remove the following and save the result in GNULIB_WARN_CFLAGS.
883   nw=
884   nw="$nw -Wunused-macros"
886   gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
887   AC_SUBST([GNULIB_WARN_CFLAGS])
892 dnl Some other nice autoconf tests.
893 dnl These are commented out, since gl_EARLY and/or Autoconf already does them.
894 dnl AC_PROG_INSTALL
895 dnl AC_PROG_MKDIR_P
896 dnl if test "x$RANLIB" = x; then
897 dnl   AC_PROG_RANLIB
898 dnl fi
901 dnl Sadly, AC_PROG_LN_S is too restrictive.  It also tests whether links
902 dnl can be made to directories.  This is not relevant for our usage, and
903 dnl excludes some cases that work fine for us.  Eg MS Windows or files
904 dnl hosted on AFS, both examples where simple links work, but links to
905 dnl directories fail.  We use a cut-down version instead.
906 dnl AC_PROG_LN_S
908 AC_MSG_CHECKING([whether ln -s works for files in the same directory])
909 rm -f conf$$ conf$$.file
911 LN_S_FILEONLY='cp -p'
913 if (echo >conf$$.file) 2>/dev/null; then
914   if ln -s conf$$.file conf$$ 2>/dev/null; then
915     LN_S_FILEONLY='ln -s'
916   elif ln conf$$.file conf$$ 2>/dev/null; then
917     LN_S_FILEONLY=ln
918   fi
921 rm -f conf$$ conf$$.file
923 if test "$LN_S_FILEONLY" = "ln -s"; then
924    AC_MSG_RESULT([yes])
925 else
926    AC_MSG_RESULT([no, using $LN_S_FILEONLY])
929 AC_SUBST(LN_S_FILEONLY)
932 dnl AC_PROG_LN_S sets LN_S to 'cp -pR' for MinGW, on the premise that 'ln'
933 dnl doesn't support links to directories, as in "ln file dir".  But that
934 dnl use is non-portable, and OTOH MinGW wants to use hard links for Emacs
935 dnl executables at "make install" time.
936 dnl See http://lists.gnu.org/archive/html/emacs-devel/2013-04/msg00475.html
937 dnl for more details.
938 if test "$opsys" = "mingw32"; then
939   LN_S="ln"
942 AC_PATH_PROG(INSTALL_INFO, install-info, :,
943   $PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin)
944 dnl Don't use GZIP, which is used by gzip for additional parameters.
945 AC_PATH_PROG(GZIP_PROG, gzip)
947 if test $opsys = gnu-linux; then
948   AC_PATH_PROG(PAXCTL, paxctl,,
949     [$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin])
950   if test "X$PAXCTL" != X; then
951     AC_MSG_CHECKING([whether binaries have a PT_PAX_FLAGS header])
952     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
953       [if $PAXCTL -v conftest$EXEEXT >/dev/null 2>&1; then AC_MSG_RESULT(yes)
954       else AC_MSG_RESULT(no); PAXCTL=""; fi])
955   fi
958 ## Need makeinfo >= 4.7 (?) to build the manuals.
959 AC_PATH_PROG(MAKEINFO, makeinfo, no)
960 dnl By this stage, configure has already checked for egrep and set EGREP,
961 dnl or exited with an error if no egrep was found.
962 if test "$MAKEINFO" != "no"; then
963   case `
964     $MAKEINFO --version 2> /dev/null |
965     $EGREP 'texinfo[[^0-9]]*([[1-4]][[0-9]]+|[[5-9]]|4\.[[7-9]]|4\.[[1-6]][[0-9]]+)'
966   ` in
967     '') MAKEINFO=no;;
968   esac
971 ## Makeinfo is unusual.  For a released Emacs, the manuals are
972 ## pre-built, and not deleted by the normal clean rules.  makeinfo is
973 ## therefore in the category of "special tools" not normally required, which
974 ## configure does not have to check for (eg autoconf itself).
975 ## In a Bazaar checkout on the other hand, the manuals are not included.
976 ## So makeinfo is a requirement to build from Bazaar, and configure
977 ## should test for it as it does for any other build requirement.
978 ## We use the presence of $srcdir/info/emacs to distinguish a release,
979 ## with pre-built manuals, from a Bazaar checkout.
980 HAVE_MAKEINFO=yes
982 if test "$MAKEINFO" = "no"; then
983   MAKEINFO=makeinfo
984   if test "x${with_makeinfo}" = "xno"; then
985     HAVE_MAKEINFO=no
986   elif test ! -e "$srcdir/info/emacs" && test ! -e "$srcdir/info/emacs.info"; then
987     AC_MSG_ERROR( [You do not seem to have makeinfo >= 4.7, and your
988 source tree does not seem to have pre-built manuals in the `info' directory.
989 Either install a suitable version of makeinfo, or re-run configure
990 with the `--without-makeinfo' option to build without the manuals.] )
991   fi
993 AC_SUBST(HAVE_MAKEINFO)
995 dnl Just so that there is only a single place we need to edit.
996 INFO_EXT=.info
997 INFO_OPTS=--no-split
998 AC_SUBST(INFO_EXT)
999 AC_SUBST(INFO_OPTS)
1001 dnl Add our options to ac_link now, after it is set up.
1003 if test x$GCC = xyes; then
1004   test "x$GCC_LINK_TEST_OPTIONS" != x && \
1005     ac_link="$ac_link $GCC_LINK_TEST_OPTIONS"
1006 else
1007   test "x$NON_GCC_LINK_TEST_OPTIONS" != x && \
1008     ac_link="$ac_link $NON_GCC_LINK_TEST_OPTIONS"
1011 dnl We need -znocombreloc if we're using a relatively recent GNU ld.
1012 dnl If we can link with the flag, it shouldn't do any harm anyhow.
1013 dnl (Don't use `-z nocombreloc' as -z takes no arg on Irix.)
1014 dnl Treat GCC specially since it just gives a non-fatal `unrecognized option'
1015 dnl if not built to support GNU ld.
1017 late_LDFLAGS=$LDFLAGS
1018 if test x$GCC = xyes; then
1019   LDFLAGS="$LDFLAGS -Wl,-znocombreloc"
1020 else
1021   LDFLAGS="$LDFLAGS -znocombreloc"
1024 AC_MSG_CHECKING([for -znocombreloc])
1025 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
1026   [AC_MSG_RESULT(yes)],
1027   LDFLAGS=$late_LDFLAGS
1028   [AC_MSG_RESULT(no)])
1031 dnl The function dump-emacs will not be defined and temacs will do
1032 dnl (load "loadup") automatically unless told otherwise.
1033 test "x$CANNOT_DUMP" = "x" && CANNOT_DUMP=no
1034 case "$opsys" in
1035   your-opsys-here) CANNOT_DUMP=yes ;;
1036 esac
1038 test "$CANNOT_DUMP" = "yes" && \
1039   AC_DEFINE(CANNOT_DUMP, 1, [Define if Emacs cannot be dumped on your system.])
1041 AC_SUBST(CANNOT_DUMP)
1044 UNEXEC_OBJ=unexelf.o
1045 case "$opsys" in
1046   # MSDOS uses unexcoff.o
1047   aix4-2)
1048    UNEXEC_OBJ=unexaix.o
1049    ;;
1050   cygwin)
1051    UNEXEC_OBJ=unexcw.o
1052    ;;
1053   darwin)
1054    UNEXEC_OBJ=unexmacosx.o
1055    ;;
1056   hpux10-20 | hpux11)
1057    UNEXEC_OBJ=unexhp9k800.o
1058    ;;
1059   mingw32)
1060    UNEXEC_OBJ=unexw32.o
1061    ;;
1062   sol2-10)
1063    # Use the Solaris dldump() function, called from unexsol.c, to dump
1064    # emacs, instead of the generic ELF dump code found in unexelf.c.
1065    # The resulting binary has a complete symbol table, and is better
1066    # for debugging and other observability tools (debuggers, pstack, etc).
1067    #
1068    # If you encounter a problem using dldump(), please consider sending
1069    # a message to the OpenSolaris tools-linking mailing list:
1070    #      http://mail.opensolaris.org/mailman/listinfo/tools-linking
1071    #
1072    # It is likely that dldump() works with older Solaris too, but this has
1073    # not been tested, so for now this change is for Solaris 10 or newer.
1074    UNEXEC_OBJ=unexsol.o
1075    ;;
1076 esac
1078 LD_SWITCH_SYSTEM=
1079 case "$opsys" in
1080   freebsd|dragonfly)
1081    ## Let `ld' find image libs and similar things in /usr/local/lib.
1082    ## The system compiler, GCC, has apparently been modified to not
1083    ## look there, contrary to what a stock GCC would do.
1084 ### It's not our place to do this.  See bug#10313#17.
1085 ###   LD_SWITCH_SYSTEM=-L/usr/local/lib
1086       :
1087    ;;
1089   gnu-linux)
1090    ## cpp test was "ifdef __mips__", but presumably this is equivalent...
1091    case $host_cpu in mips*) LD_SWITCH_SYSTEM="-G 0";; esac
1092    ;;
1094   netbsd)
1095 ### It's not our place to do this.  See bug#10313#17.
1096 ###   LD_SWITCH_SYSTEM="-Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib"
1097       :
1098    ;;
1100   openbsd)
1101    ## Han Boetes <han@boetes.org> says this is necessary,
1102    ## otherwise Emacs dumps core on elf systems.
1103    LD_SWITCH_SYSTEM="-Z"
1104    ;;
1105 esac
1106 AC_SUBST(LD_SWITCH_SYSTEM)
1108 ac_link="$ac_link $LD_SWITCH_SYSTEM"
1110 ## This setting of LD_SWITCH_SYSTEM references LD_SWITCH_X_SITE_RPATH,
1111 ## which has not been defined yet.  When this was handled with cpp,
1112 ## it was expanded to null when configure sourced the s/*.h file.
1113 ## Thus LD_SWITCH_SYSTEM had different values in configure and the Makefiles.
1114 ## FIXME it would be cleaner to put this in LD_SWITCH_SYSTEM_TEMACS
1115 ## (or somesuch), but because it is supposed to go at the _front_
1116 ## of LD_SWITCH_SYSTEM, we cannot do that in exactly the same way.
1117 ## Compare with the gnu-linux case below, which added to the end
1118 ## of LD_SWITCH_SYSTEM, and so can instead go at the front of
1119 ## LD_SWITCH_SYSTEM_TEMACS.
1120 case "$opsys" in
1121   netbsd|openbsd)
1122    LD_SWITCH_SYSTEM="\$(LD_SWITCH_X_SITE_RPATH) $LD_SWITCH_SYSTEM" ;;
1123 esac
1126 C_SWITCH_MACHINE=
1127 case $canonical in
1128  alpha*)
1129   AC_CHECK_DECL([__ELF__])
1130   if test "$ac_cv_have_decl___ELF__" = "yes"; then
1131     ## With ELF, make sure that all common symbols get allocated to in the
1132     ## data section.  Otherwise, the dump of temacs may miss variables in
1133     ## the shared library that have been initialized.  For example, with
1134     ## GNU libc, __malloc_initialized would normally be resolved to the
1135     ## shared library's .bss section, which is fatal.
1136     if test "x$GCC" = "xyes"; then
1137       C_SWITCH_MACHINE="-fno-common"
1138     else
1139       AC_MSG_ERROR([What gives?  Fix me if DEC Unix supports ELF now.])
1140     fi
1141   else
1142     UNEXEC_OBJ=unexalpha.o
1143   fi
1144   ;;
1145 esac
1146 AC_SUBST(C_SWITCH_MACHINE)
1148 AC_SUBST(UNEXEC_OBJ)
1150 C_SWITCH_SYSTEM=
1151 ## Some programs in src produce warnings saying certain subprograms
1152 ## are too complex and need a MAXMEM value greater than 2000 for
1153 ## additional optimization.  --nils@exp-math.uni-essen.de
1154 test "$opsys" = "aix4.2" && test "x$GCC" != "xyes" && \
1155   C_SWITCH_SYSTEM="-ma -qmaxmem=4000"
1156 test "$opsys" = "mingw32" && C_SWITCH_SYSTEM="-mtune=pentium4"
1157 ## gnu-linux might need -D_BSD_SOURCE on old libc5 systems.
1158 ## It is redundant in glibc2, since we define _GNU_SOURCE.
1159 AC_SUBST(C_SWITCH_SYSTEM)
1162 LIBS_SYSTEM=
1163 case "$opsys" in
1164   ## IBM's X11R5 uses -lIM and -liconv in AIX 3.2.2.
1165   aix4-2) LIBS_SYSTEM="-lrts -lIM -liconv" ;;
1167   freebsd|dragonfly) LIBS_SYSTEM="-lutil" ;;
1169   hpux*) LIBS_SYSTEM="-l:libdld.sl" ;;
1171   sol2*) LIBS_SYSTEM="-lsocket -lnsl" ;;
1173   ## Motif needs -lgen.
1174   unixware) LIBS_SYSTEM="-lsocket -lnsl -lelf -lgen" ;;
1175 esac
1177 AC_SUBST(LIBS_SYSTEM)
1179 ### Make sure subsequent tests use flags consistent with the build flags.
1181 if test x"${OVERRIDE_CPPFLAGS}" != x; then
1182   CPPFLAGS="${OVERRIDE_CPPFLAGS}"
1183 else
1184   CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
1187 # Suppress obsolescent Autoconf test for size_t; Emacs assumes C89 or better.
1188 AC_DEFUN([AC_TYPE_SIZE_T])
1189 # Likewise for obsolescent test for uid_t, gid_t; Emacs assumes them.
1190 AC_DEFUN([AC_TYPE_UID_T])
1193 LIB_MATH=-lm
1194 dnl Current possibilities handled by sed (aix4-2 -> aix,
1195 dnl gnu-linux -> gnu/linux, etc.):
1196 dnl gnu, gnu/linux, gnu/kfreebsd, aix, cygwin, darwin, hpux, irix.
1197 dnl And special cases: berkeley-unix, usg-unix-v, ms-dos, windows-nt.
1198 SYSTEM_TYPE=`echo $opsys | sed -e 's/[[0-9]].*//' -e 's|-|/|'`
1200 case $opsys in
1201   cygwin )
1202     LIB_MATH=
1203     ;;
1204   darwin )
1205     ## Adding -lm confuses the dynamic linker, so omit it.
1206     LIB_MATH=
1207     ;;
1208   freebsd | dragonfly )
1209     SYSTEM_TYPE=berkeley-unix
1210     ;;
1211   gnu-linux | gnu-kfreebsd )
1212     ;;
1213   hpux10-20 | hpux11 )
1214     ;;
1215   mingw32 )
1216     LIB_MATH=
1217     SYSTEM_TYPE=windows-nt
1218     ;;
1219   dnl NB this may be adjusted below.
1220   netbsd | openbsd )
1221     SYSTEM_TYPE=berkeley-unix
1222     ;;
1224   sol2* | unixware )
1225     SYSTEM_TYPE=usg-unix-v
1226     ;;
1228 esac
1230 AC_SUBST(LIB_MATH)
1231 AC_DEFINE_UNQUOTED(SYSTEM_TYPE, "$SYSTEM_TYPE",
1232   [The type of system you are compiling for; sets `system-type'.])
1235 pre_PKG_CONFIG_CFLAGS=$CFLAGS
1236 pre_PKG_CONFIG_LIBS=$LIBS
1238 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1240 dnl This function definition taken from Gnome 2.0
1241 dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
1242 dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
1243 dnl also defines GSTUFF_PKG_ERRORS on error
1244 AC_DEFUN([PKG_CHECK_MODULES], [
1245   succeeded=no
1247   if test "$PKG_CONFIG" = "no" ; then
1248      ifelse([$4], , [AC_MSG_ERROR([
1249       *** The pkg-config script could not be found. Make sure it is in your path, or give the full name of pkg-config with the PKG_CONFIG environment variable or --with-pkg-config-prog.  Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config.])], [$4])
1250   else
1251      PKG_CONFIG_MIN_VERSION=0.9.0
1252      if "$PKG_CONFIG" --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
1253         AC_MSG_CHECKING(for $2)
1255         if "$PKG_CONFIG" --exists "$2" 2>&AS_MESSAGE_LOG_FD &&
1256            $1_CFLAGS=`"$PKG_CONFIG" --cflags "$2" 2>&AS_MESSAGE_LOG_FD` &&
1257            $1_LIBS=`"$PKG_CONFIG" --libs "$2" 2>&AS_MESSAGE_LOG_FD`; then
1258             edit_cflags="
1259               s,///*,/,g
1260               s/^/ /
1261               s/ -I/ $isystem/g
1262               s/^ //
1263             "
1264             $1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"`
1265             $1_LIBS=`AS_ECHO(["$$1_LIBS"]) | sed -e 's,///*,/,g'`
1266             AC_MSG_RESULT([yes CFLAGS='$$1_CFLAGS' LIBS='$$1_LIBS'])
1267             succeeded=yes
1268         else
1269             AC_MSG_RESULT(no)
1270             $1_CFLAGS=""
1271             $1_LIBS=""
1272             ## If we have a custom action on failure, don't print errors, but
1273             ## do set a variable so people can do so.  Do it in a subshell
1274             ## to capture any diagnostics in invoking pkg-config.
1275             $1_PKG_ERRORS=`("$PKG_CONFIG" --print-errors "$2") 2>&1`
1276             ifelse([$4], ,echo "$$1_PKG_ERRORS",)
1277         fi
1279         AC_SUBST($1_CFLAGS)
1280         AC_SUBST($1_LIBS)
1281      else
1282         echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
1283         echo "*** See http://www.freedesktop.org/software/pkgconfig"
1284      fi
1285   fi
1287   if test $succeeded = yes; then
1288      ifelse([$3], , :, [$3])
1289   else
1290      ifelse([$4], , [AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.])], [$4])
1291   fi
1294 HAVE_SOUND=no
1295 if test "${with_sound}" != "no"; then
1296   # Sound support for GNU/Linux, the free BSDs, and MinGW.
1297   AC_CHECK_HEADERS([machine/soundcard.h sys/soundcard.h soundcard.h],
1298     have_sound_header=yes, [], [
1299     #ifdef __MINGW32__
1300     #define WIN32_LEAN_AND_MEAN
1301     #include <windows.h>
1302     #endif
1303     ])
1304   if test "${with_sound}" = "ossaudio" || test "${with_sound}" = "yes"; then
1305     # Emulation library used on NetBSD.
1306     AC_CHECK_LIB(ossaudio, _oss_ioctl, LIBSOUND=-lossaudio, LIBSOUND=)
1307     test "${with_sound}" = "ossaudio" && test -z "$LIBSOUND" && \
1308       AC_MSG_ERROR([ossaudio sound support requested but not found.])
1309     dnl FIXME?  If we did find ossaudio, should we set with_sound=ossaudio?
1310     dnl Traditionally, we go on to check for alsa too.  Does that make sense?
1311   fi
1312   AC_SUBST(LIBSOUND)
1314   if test "${with_sound}" = "alsa" || test "${with_sound}" = "yes"; then
1315     ALSA_REQUIRED=1.0.0
1316     ALSA_MODULES="alsa >= $ALSA_REQUIRED"
1317     PKG_CHECK_MODULES(ALSA, $ALSA_MODULES, HAVE_ALSA=yes, HAVE_ALSA=no)
1318     if test $HAVE_ALSA = yes; then
1319       SAVE_CFLAGS="$CFLAGS"
1320       SAVE_LIBS="$LIBS"
1321       CFLAGS="$ALSA_CFLAGS $CFLAGS"
1322       LIBS="$ALSA_LIBS $LIBS"
1323       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <asoundlib.h>]], [[snd_lib_error_set_handler (0);]])],
1324                       emacs_alsa_normal=yes,
1325                     emacs_alsa_normal=no)
1326       if test "$emacs_alsa_normal" != yes; then
1327         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <alsa/asoundlib.h>]],
1328                        [[snd_lib_error_set_handler (0);]])],
1329                        emacs_alsa_subdir=yes,
1330                      emacs_alsa_subdir=no)
1331         if test "$emacs_alsa_subdir" != yes; then
1332           AC_MSG_ERROR([pkg-config found alsa, but it does not compile.  See config.log for error messages.])
1333         fi
1334         ALSA_CFLAGS="$ALSA_CFLAGS -DALSA_SUBDIR_INCLUDE"
1335       fi
1337       CFLAGS="$SAVE_CFLAGS"
1338       LIBS="$SAVE_LIBS"
1339       LIBSOUND="$LIBSOUND $ALSA_LIBS"
1340       CFLAGS_SOUND="$CFLAGS_SOUND $ALSA_CFLAGS"
1341       AC_DEFINE(HAVE_ALSA, 1, [Define to 1 if ALSA is available.])
1342     elif test "${with_sound}" = "alsa"; then
1343       AC_MSG_ERROR([ALSA sound support requested but not found.])
1344     fi
1345   fi                            dnl with_sound = alsa|yes
1347   dnl Define HAVE_SOUND if we have sound support.  We know it works and
1348   dnl compiles only on the specified platforms.  For others, it
1349   dnl probably doesn't make sense to try.
1350   dnl FIXME So surely we should bypass this whole section if not using
1351   dnl one of these platforms?
1352   if test x$have_sound_header = xyes || test $HAVE_ALSA = yes; then
1353      case "$opsys" in
1354        dnl defined __FreeBSD__ || defined __NetBSD__ || defined __linux__
1355        dnl Adjust the --with-sound help text if you change this.
1356        gnu-linux|freebsd|netbsd|mingw32)
1357          AC_DEFINE(HAVE_SOUND, 1, [Define to 1 if you have sound support.])
1358          HAVE_SOUND=yes
1359          ;;
1360      esac
1361   fi
1363   AC_SUBST(CFLAGS_SOUND)
1366 dnl checks for header files
1367 AC_CHECK_HEADERS_ONCE(
1368   sys/systeminfo.h
1369   coff.h pty.h
1370   sys/resource.h
1371   sys/utsname.h pwd.h utmp.h util.h sys/prctl.h)
1373 AC_MSG_CHECKING(if personality LINUX32 can be set)
1374 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/personality.h>]], [[personality (PER_LINUX32)]])],
1375                emacs_cv_personality_linux32=yes,
1376                emacs_cv_personality_linux32=no)
1377 AC_MSG_RESULT($emacs_cv_personality_linux32)
1379 if test $emacs_cv_personality_linux32 = yes; then
1380   AC_DEFINE(HAVE_PERSONALITY_LINUX32, 1,
1381             [Define to 1 if personality LINUX32 can be set.])
1384 dnl On Solaris 8 there's a compilation warning for term.h because
1385 dnl it doesn't define `bool'.
1386 AC_CHECK_HEADERS(term.h, , , -)
1387 AC_HEADER_TIME
1388 AC_CHECK_DECLS([sys_siglist], [], [], [[#include <signal.h>
1389                                       ]])
1390 if test $ac_cv_have_decl_sys_siglist != yes; then
1391   # For Tru64, at least:
1392   AC_CHECK_DECLS([__sys_siglist], [], [], [[#include <signal.h>
1393                                           ]])
1395 AC_HEADER_SYS_WAIT
1397 AC_CHECK_HEADERS_ONCE(sys/socket.h)
1398 AC_CHECK_HEADERS(net/if.h, , , [AC_INCLUDES_DEFAULT
1399 #if HAVE_SYS_SOCKET_H
1400 #include <sys/socket.h>
1401 #endif])
1402 AC_CHECK_HEADERS(ifaddrs.h, , , [AC_INCLUDES_DEFAULT
1403 #if HAVE_SYS_SOCKET_H
1404 #include <sys/socket.h>
1405 #endif])
1406 AC_CHECK_HEADERS(net/if_dl.h, , , [AC_INCLUDES_DEFAULT
1407 #if HAVE_SYS_SOCKET_H
1408 #include <sys/socket.h>
1409 #endif])
1411 dnl checks for structure members
1412 AC_CHECK_MEMBERS([struct ifreq.ifr_flags, struct ifreq.ifr_hwaddr,
1413                   struct ifreq.ifr_netmask, struct ifreq.ifr_broadaddr,
1414                   struct ifreq.ifr_addr,
1415                   struct ifreq.ifr_addr.sa_len], , ,
1416                  [AC_INCLUDES_DEFAULT
1417 #if HAVE_SYS_SOCKET_H
1418 #include <sys/socket.h>
1419 #endif
1420 #if HAVE_NET_IF_H
1421 #include <net/if.h>
1422 #endif])
1424 dnl Check for endianness.
1425 dnl AC_C_BIGENDIAN is done by gnulib.
1427 dnl check for Make feature
1428 dnl AC_PROG_MAKE_SET is done by Automake.
1430 DEPFLAGS=
1431 MKDEPDIR=":"
1432 deps_frag=deps.mk
1433 dnl check for GNU Make if we have GCC and autodepend is on.
1434 if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
1435    AC_MSG_CHECKING([whether we are using GNU Make])
1436    HAVE_GNU_MAKE=no
1437    testval=`${MAKE-make} --version 2>/dev/null | grep 'GNU Make'`
1438    if test "x$testval" != x; then
1439       HAVE_GNU_MAKE=yes
1440    else
1441       ac_enable_autodepend=no
1442    fi
1443    AC_MSG_RESULT([$HAVE_GNU_MAKE])
1444    if test $HAVE_GNU_MAKE = yes; then
1445       AC_MSG_CHECKING([whether gcc understands -MMD -MF])
1446       SAVE_CFLAGS="$CFLAGS"
1447       CFLAGS="$CFLAGS -MMD -MF deps.d -MP"
1448       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], , ac_enable_autodepend=no)
1449       CFLAGS="$SAVE_CFLAGS"
1450       test -f deps.d || ac_enable_autodepend=no
1451       rm -rf deps.d
1452       AC_MSG_RESULT([$ac_enable_autodepend])
1453    fi
1454    if test $ac_enable_autodepend = yes; then
1455       DEPFLAGS='-MMD -MF ${DEPDIR}/$*.d -MP'
1456       ## MKDIR_P is documented (see AC_PROG_MKDIR_P) to be parallel-safe.
1457       MKDEPDIR='${MKDIR_P} ${DEPDIR}'
1458       deps_frag=autodeps.mk
1459    fi
1461 deps_frag=$srcdir/src/$deps_frag
1462 AC_SUBST(MKDEPDIR)
1463 AC_SUBST(DEPFLAGS)
1464 AC_SUBST_FILE(deps_frag)
1467 lisp_frag=$srcdir/src/lisp.mk
1468 AC_SUBST_FILE(lisp_frag)
1471 dnl checks for operating system services
1472 AC_SYS_LONG_FILE_NAMES
1474 #### Choose a window system.
1476 ## We leave window_system equal to none if
1477 ## we end up building without one.  Any new window system should
1478 ## set window_system to an appropriate value and add objects to
1479 ## window-system-specific substs.
1481 window_system=none
1482 AC_PATH_X
1483 if test "$no_x" != yes; then
1484   window_system=x11
1487 LD_SWITCH_X_SITE_RPATH=
1488 if test "${x_libraries}" != NONE; then
1489   if test -n "${x_libraries}"; then
1490     LD_SWITCH_X_SITE=-L`echo ${x_libraries} | sed -e "s/:/ -L/g"`
1491     LD_SWITCH_X_SITE_RPATH=-Wl,-rpath,`echo ${x_libraries} | sed -e "s/:/ -Wl,-rpath,/g"`
1492   fi
1493   x_default_search_path=""
1494   x_search_path=${x_libraries}
1495   if test -z "${x_search_path}"; then
1496     x_search_path=/usr/lib
1497   fi
1498   for x_library in `echo ${x_search_path}: | \
1499                     sed -e "s/:/ /g" -e p -e "s:/lib[[^ /]]* :/share :g"`; do
1500     x_search_path="\
1501 ${x_library}/X11/%L/%T/%N%C%S:\
1502 ${x_library}/X11/%l/%T/%N%C%S:\
1503 ${x_library}/X11/%T/%N%C%S:\
1504 ${x_library}/X11/%L/%T/%N%S:\
1505 ${x_library}/X11/%l/%T/%N%S:\
1506 ${x_library}/X11/%T/%N%S"
1507     if test x"${x_default_search_path}" = x; then
1508       x_default_search_path=${x_search_path}
1509     else
1510       x_default_search_path="${x_search_path}:${x_default_search_path}"
1511     fi
1512   done
1514 AC_SUBST(LD_SWITCH_X_SITE_RPATH)
1516 if test "${x_includes}" != NONE && test -n "${x_includes}"; then
1517   C_SWITCH_X_SITE="$isystem"`echo ${x_includes} | sed -e "s/:/ $isystem/g"`
1520 if test x"${x_includes}" = x; then
1521   bitmapdir=/usr/include/X11/bitmaps
1522 else
1523   # accumulate include directories that have X11 bitmap subdirectories
1524   bmd_acc="dummyval"
1525   for bmd in `echo ${x_includes} | sed -e "s/:/ /g"`; do
1526     if test -d "${bmd}/X11/bitmaps"; then
1527       bmd_acc="${bmd_acc}:${bmd}/X11/bitmaps"
1528     fi
1529     if test -d "${bmd}/bitmaps"; then
1530       bmd_acc="${bmd_acc}:${bmd}/bitmaps"
1531     fi
1532   done
1533   if test ${bmd_acc} != "dummyval"; then
1534     bitmapdir=`echo ${bmd_acc} | sed -e "s/^dummyval://"`
1535   fi
1538 HAVE_NS=no
1539 NS_IMPL_COCOA=no
1540 NS_IMPL_GNUSTEP=no
1541 tmp_CPPFLAGS="$CPPFLAGS"
1542 tmp_CFLAGS="$CFLAGS"
1543 CPPFLAGS="$CPPFLAGS -x objective-c"
1544 CFLAGS="$CFLAGS -x objective-c"
1545 GNU_OBJC_CFLAGS=
1546 LIBS_GNUSTEP=
1547 if test "${with_ns}" != no; then
1548   if test "${opsys}" = darwin; then
1549      NS_IMPL_COCOA=yes
1550      ns_appdir=`pwd`/nextstep/Emacs.app
1551      ns_appbindir=${ns_appdir}/Contents/MacOS
1552      ns_appresdir=${ns_appdir}/Contents/Resources
1553      ns_appsrc=Cocoa/Emacs.base
1554   elif test -f $GNUSTEP_CONFIG_FILE; then
1555      NS_IMPL_GNUSTEP=yes
1556      ns_appdir=`pwd`/nextstep/Emacs.app
1557      ns_appbindir=${ns_appdir}
1558      ns_appresdir=${ns_appdir}/Resources
1559      ns_appsrc=GNUstep/Emacs.base
1560      dnl FIXME sourcing this several times in subshells seems inefficient.
1561      GNUSTEP_SYSTEM_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_HEADERS)"
1562      GNUSTEP_SYSTEM_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_LIBRARIES)"
1563      dnl I seemed to need these as well with GNUstep-startup 0.25.
1564      GNUSTEP_LOCAL_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_LOCAL_HEADERS)"
1565      GNUSTEP_LOCAL_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_LOCAL_LIBRARIES)"
1566      test "x${GNUSTEP_LOCAL_HEADERS}" != "x" && \
1567        GNUSTEP_LOCAL_HEADERS="-I${GNUSTEP_LOCAL_HEADERS}"
1568      test "x${GNUSTEP_LOCAL_LIBRARIES}" != "x" && \
1569        GNUSTEP_LOCAL_LIBRARIES="-L${GNUSTEP_LOCAL_LIBRARIES}"
1570      CPPFLAGS="$CPPFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
1571      CFLAGS="$CFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
1572      LDFLAGS="$LDFLAGS -L${GNUSTEP_SYSTEM_LIBRARIES} ${GNUSTEP_LOCAL_LIBRARIES}"
1573      LIBS_GNUSTEP="-lgnustep-gui -lgnustep-base -lobjc -lpthread"
1574      dnl GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS to 0 or 1.
1575      dnl If they had chosen to either define it or not, we could have
1576      dnl just used AC_CHECK_DECL here.
1577      AC_CACHE_CHECK(if GNUstep defines BASE_NATIVE_OBJC_EXCEPTIONS,
1578        emacs_cv_objc_exceptions,
1579 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <GNUstepBase/GSConfig.h>]],
1580 [[#if defined BASE_NATIVE_OBJC_EXCEPTIONS && BASE_NATIVE_OBJC_EXCEPTIONS > 0
1582 #else
1583 fail;
1584 #endif]])], emacs_cv_objc_exceptions=yes, emacs_cv_objc_exceptions=no ) )
1585      if test $emacs_cv_objc_exceptions = yes; then
1586        dnl _NATIVE_OBJC_EXCEPTIONS is used by the GNUstep headers.
1587        AC_DEFINE(_NATIVE_OBJC_EXCEPTIONS, 1,
1588          [Define if GNUstep uses ObjC exceptions.])
1589        GNU_OBJC_CFLAGS="-fobjc-exceptions"
1590      fi
1591   fi
1593   dnl This is only used while we test the NS headers, it gets reset below.
1594   CFLAGS="$CFLAGS $GNU_OBJC_CFLAGS"
1596   AC_CHECK_HEADER([AppKit/AppKit.h], [HAVE_NS=yes],
1597                   [AC_MSG_ERROR([`--with-ns' was specified, but the include
1598   files are missing or cannot be compiled.])])
1600   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <AppKit/AppKit.h>],
1601                                      [
1602 #ifdef MAC_OS_X_VERSION_MAX_ALLOWED
1603 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
1604  ; /* OK */
1605 #else
1606 #error "OSX 10.4 or newer required"
1607 #endif
1608 #endif
1609                     ])],
1610                     ns_osx_have_104=yes,
1611                     ns_osx_have_104=no)
1612   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <Foundation/NSObjCRuntime.h>],
1613                                      [NSInteger i;])],
1614                     ns_have_nsinteger=yes,
1615                     ns_have_nsinteger=no)
1616   if test $ns_osx_have_104 = no; then
1617      AC_MSG_ERROR([`OSX 10.4 or newer is required']);
1618   fi
1619   if test $ns_have_nsinteger = yes; then
1620     AC_DEFINE(NS_HAVE_NSINTEGER, 1, [Define to 1 if `NSInteger' is defined.])
1621   fi
1624 AC_SUBST(LIBS_GNUSTEP)
1626 INSTALL_ARCH_INDEP_EXTRA=install-etc
1627 ns_self_contained=no
1628 NS_OBJ=
1629 NS_OBJC_OBJ=
1630 if test "${HAVE_NS}" = yes; then
1631   if test "$with_toolkit_scroll_bars" = "no"; then
1632     AC_MSG_ERROR([Non-toolkit scroll bars are not implemented for Nextstep.])
1633   fi
1635   window_system=nextstep
1636   # set up packaging dirs
1637   if test "${EN_NS_SELF_CONTAINED}" = yes; then
1638      ns_self_contained=yes
1639      prefix=${ns_appresdir}
1640      exec_prefix=${ns_appbindir}
1641      dnl This one isn't really used, only archlibdir is.
1642      libexecdir="\${ns_appbindir}/libexec"
1643      archlibdir="\${ns_appbindir}/libexec"
1644      etcdocdir="\${ns_appresdir}/etc"
1645      etcdir="\${ns_appresdir}/etc"
1646      dnl FIXME maybe set datarootdir instead.
1647      dnl That would also get applications, icons, man.
1648      infodir="\${ns_appresdir}/info"
1649      mandir="\${ns_appresdir}/man"
1650      lispdir="\${ns_appresdir}/lisp"
1651      leimdir="\${ns_appresdir}/leim"
1652      INSTALL_ARCH_INDEP_EXTRA=
1653   fi
1654   NS_OBJC_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o"
1656 CFLAGS="$tmp_CFLAGS"
1657 CPPFLAGS="$tmp_CPPFLAGS"
1658 AC_SUBST(INSTALL_ARCH_INDEP_EXTRA)
1659 AC_SUBST(ns_self_contained)
1660 AC_SUBST(NS_OBJ)
1661 AC_SUBST(NS_OBJC_OBJ)
1663 HAVE_W32=no
1664 W32_OBJ=
1665 W32_LIBS=
1666 EMACSRES=
1667 CLIENTRES=
1668 CLIENTW=
1669 W32_RES_LINK=
1670 EMACS_MANIFEST=
1671 UPDATE_MANIFEST=
1672 if test "${with_w32}" != no; then
1673   case "${opsys}" in
1674     cygwin)
1675       AC_CHECK_HEADER([windows.h], [HAVE_W32=yes],
1676              [AC_MSG_ERROR([`--with-w32' was specified, but windows.h
1677                    cannot be found.])])
1678     ;;
1679     mingw32)
1680     ## Using --with-w32 with MinGW is a no-op, but we allow it.
1681     ;;
1682     *)
1683       AC_MSG_ERROR([Using w32 with an autotools build is only supported for Cygwin and MinGW32.])
1684     ;;
1685   esac
1688 if test "${opsys}" = "mingw32"; then
1689   AC_MSG_CHECKING([whether Windows API headers are recent enough])
1690   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1691      #include <windows.h>
1692      #include <usp10.h>]],
1693    [[PIMAGE_NT_HEADERS pHeader;
1694      PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader)]])],
1695    [emacs_cv_w32api=yes
1696     HAVE_W32=yes],
1697    emacs_cv_w32api=no)
1698   AC_MSG_RESULT($emacs_cv_w32api)
1699   if test "${emacs_cv_w32api}" = "no"; then
1700     AC_MSG_ERROR([the Windows API headers are too old to support this build.])
1701   fi
1704 FIRSTFILE_OBJ=
1705 NTDIR=
1706 LIBS_ECLIENT=
1707 LIB_WSOCK32=
1708 NTLIB=
1709 CM_OBJ="cm.o"
1710 XARGS_LIMIT=
1711 if test "${HAVE_W32}" = "yes"; then
1712   AC_DEFINE(HAVE_NTGUI, 1, [Define to use native MS Windows GUI.])
1713   AC_CHECK_TOOL(WINDRES, [windres],
1714                 [AC_MSG_ERROR([No resource compiler found.])])
1715   W32_OBJ="w32fns.o w32menu.o w32reg.o w32font.o w32term.o"
1716   W32_OBJ="$W32_OBJ w32xfns.o w32select.o w32uniscribe.o"
1717   EMACSRES="emacs.res"
1718   case "$canonical" in
1719     x86_64-*-*) EMACS_MANIFEST="emacs-x64.manifest" ;;
1720     *) EMACS_MANIFEST="emacs-x86.manifest" ;;
1721   esac
1722   UPDATE_MANIFEST=update-game-score.exe.manifest
1723   if test "${opsys}" = "cygwin"; then
1724     W32_LIBS="$W32_LIBS -lkernel32 -luser32 -lgdi32 -lole32 -lcomdlg32"
1725     W32_LIBS="$W32_LIBS -lusp10 -lcomctl32 -lwinspool"
1726     # Tell the linker that emacs.res is an object (which we compile from
1727     # the rc file), not a linker script.
1728     W32_RES_LINK="-Wl,emacs.res"
1729   else
1730     W32_OBJ="$W32_OBJ w32.o w32console.o w32heap.o w32inevt.o w32proc.o"
1731     W32_LIBS="$W32_LIBS -lwinmm -lgdi32 -lcomdlg32"
1732     W32_LIBS="$W32_LIBS -lmpr -lwinspool -lole32 -lcomctl32 -lusp10"
1733     W32_RES_LINK="\$(EMACSRES)"
1734     CLIENTRES="emacsclient.res"
1735     CLIENTW="emacsclientw\$(EXEEXT)"
1736     FIRSTFILE_OBJ=firstfile.o
1737     NTDIR=nt
1738     CM_OBJ=
1739     LIBS_ECLIENT="-lcomctl32"
1740     LIB_WSOCK32="-lwsock32"
1741     NTLIB="ntlib.$ac_objext"
1742     XARGS_LIMIT="-s 10000"
1743   fi
1745 AC_SUBST(W32_OBJ)
1746 AC_SUBST(W32_LIBS)
1747 AC_SUBST(EMACSRES)
1748 AC_SUBST(EMACS_MANIFEST)
1749 AC_SUBST(UPDATE_MANIFEST)
1750 AC_SUBST(CLIENTRES)
1751 AC_SUBST(CLIENTW)
1752 AC_SUBST(W32_RES_LINK)
1753 AC_SUBST(FIRSTFILE_OBJ)
1754 AC_SUBST(NTDIR)
1755 AC_SUBST(CM_OBJ)
1756 AC_SUBST(LIBS_ECLIENT)
1757 AC_SUBST(LIB_WSOCK32)
1758 AC_SUBST(NTLIB)
1759 AC_SUBST(XARGS_LIMIT)
1761 if test "${HAVE_W32}" = "yes"; then
1762   window_system=w32
1763   with_xft=no
1766 ## $window_system is now set to the window system we will
1767 ## ultimately use.
1769 term_header=
1770 HAVE_X_WINDOWS=no
1771 HAVE_X11=no
1772 USE_X_TOOLKIT=none
1774 case "${window_system}" in
1775   x11 )
1776     HAVE_X_WINDOWS=yes
1777     HAVE_X11=yes
1778     term_header=xterm.h
1779     case "${with_x_toolkit}" in
1780       athena | lucid ) USE_X_TOOLKIT=LUCID ;;
1781       motif ) USE_X_TOOLKIT=MOTIF ;;
1782       gtk ) with_gtk=yes
1783             term_header=gtkutil.h
1784 dnl Don't set this for GTK.  A lot of tests below assumes Xt when
1785 dnl USE_X_TOOLKIT is set.
1786             USE_X_TOOLKIT=none ;;
1787       gtk2 ) with_gtk2=yes
1788              term_header=gtkutil.h
1789              USE_X_TOOLKIT=none ;;
1790       gtk3 ) with_gtk3=yes
1791              term_header=gtkutil.h
1792              USE_X_TOOLKIT=none ;;
1793       no ) USE_X_TOOLKIT=none ;;
1794 dnl If user did not say whether to use a toolkit, make this decision later:
1795 dnl use the toolkit if we have gtk, or X11R5 or newer.
1796       * ) USE_X_TOOLKIT=maybe ;;
1797     esac
1798   ;;
1799   nextstep )
1800     term_header=nsterm.h
1801   ;;
1802   w32 )
1803     term_header=w32term.h
1804   ;;
1805 esac
1807 if test "$window_system" = none && test "X$with_x" != "Xno"; then
1808    AC_CHECK_PROG(HAVE_XSERVER, X, true, false)
1809    if test "$HAVE_XSERVER" = true ||
1810       test -n "$DISPLAY" ||
1811       test "`echo /usr/lib/libX11.*`" != "/usr/lib/libX11.*"; then
1812         AC_MSG_ERROR([You seem to be running X, but no X development libraries
1813 were found.  You should install the relevant development files for X
1814 and for the toolkit you want, such as Gtk+, Lesstif or Motif.  Also make
1815 sure you have development files for image handling, i.e.
1816 tiff, gif, jpeg, png and xpm.
1817 If you are sure you want Emacs compiled without X window support, pass
1818   --without-x
1819 to configure.])
1820    fi
1823 ### If we're using X11, we should use the X menu package.
1824 HAVE_MENUS=no
1825 case ${HAVE_X11} in
1826   yes ) HAVE_MENUS=yes ;;
1827 esac
1829 # Does the opsystem file prohibit the use of the GNU malloc?
1830 # Assume not, until told otherwise.
1831 GNU_MALLOC=yes
1833 AC_CACHE_CHECK(
1834   [whether malloc is Doug Lea style],
1835   [emacs_cv_var_doug_lea_malloc],
1836   [AC_LINK_IFELSE(
1837      [AC_LANG_PROGRAM(
1838         [[#include <malloc.h>
1839           static void hook (void) {}]],
1840         [[malloc_set_state (malloc_get_state ());
1841           __after_morecore_hook = hook;
1842           __malloc_initialize_hook = hook;]])],
1843      [emacs_cv_var_doug_lea_malloc=yes],
1844      [emacs_cv_var_doug_lea_malloc=no])])
1845 doug_lea_malloc=$emacs_cv_var_doug_lea_malloc
1848 dnl See comments in aix4-2.h about maybe using system malloc there.
1849 system_malloc=no
1850 case "$opsys" in
1851   ## darwin ld insists on the use of malloc routines in the System framework.
1852   darwin|sol2-10) system_malloc=yes ;;
1853 esac
1855 if test "${system_malloc}" = "yes"; then
1856   AC_DEFINE(SYSTEM_MALLOC, 1, [Define to use system malloc.])
1857   GNU_MALLOC=no
1858   GNU_MALLOC_reason="
1859     (The GNU allocators don't work with this system configuration.)"
1860   GMALLOC_OBJ=
1861   VMLIMIT_OBJ=
1862 else
1863   test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
1864   VMLIMIT_OBJ=vm-limit.o
1866   AC_CHECK_HEADERS([sys/vlimit.h])
1867   AC_CACHE_CHECK([for data_start], [emacs_cv_data_start],
1868     [AC_LINK_IFELSE(
1869        [AC_LANG_PROGRAM(
1870          [[extern char data_start[]; char ch;]],
1871          [[return data_start < &ch;]])],
1872        [emacs_cv_data_start=yes],
1873        [emacs_cv_data_start=no])])
1874   if test $emacs_cv_data_start = yes; then
1875     AC_DEFINE([HAVE_DATA_START], 1,
1876       [Define to 1 if data_start is the address of the start
1877        of the main data segment.])
1878   fi
1880 AC_SUBST(GMALLOC_OBJ)
1881 AC_SUBST(VMLIMIT_OBJ)
1883 if test "$doug_lea_malloc" = "yes" ; then
1884   if test "$GNU_MALLOC" = yes ; then
1885     GNU_MALLOC_reason="
1886       (Using Doug Lea's new malloc from the GNU C Library.)"
1887   fi
1888   AC_DEFINE(DOUG_LEA_MALLOC, 1,
1889             [Define to 1 if you are using the GNU C Library.])
1891   ## Use mmap directly for allocating larger buffers.
1892   ## FIXME this comes from src/s/{gnu,gnu-linux}.h:
1893   ## #ifdef DOUG_LEA_MALLOC; #undef REL_ALLOC; #endif
1894   ## Does the AC_FUNC_MMAP test below make this check unnecessary?
1895   case "$opsys" in
1896     gnu*) REL_ALLOC=no ;;
1897   esac
1900 if test x"${REL_ALLOC}" = x; then
1901   REL_ALLOC=${GNU_MALLOC}
1904 use_mmap_for_buffers=no
1905 case "$opsys" in
1906   cygwin|freebsd|irix6-5) use_mmap_for_buffers=yes ;;
1907 esac
1909 AC_FUNC_MMAP
1910 if test $use_mmap_for_buffers = yes; then
1911   AC_DEFINE(USE_MMAP_FOR_BUFFERS, 1, [Define to use mmap to allocate buffer text.])
1912   REL_ALLOC=no
1915 LIBS="$LIBS_SYSTEM $LIBS"
1917 dnl If found, this adds -ldnet to LIBS, which Autoconf uses for checks.
1918 AC_CHECK_LIB(dnet, dnet_ntoa)
1919 dnl This causes -lresolv to get used in subsequent tests,
1920 dnl which causes failures on some systems such as HPUX 9.
1921 dnl AC_CHECK_LIB(resolv, gethostbyname)
1923 dnl FIXME replace main with a function we actually want from this library.
1924 AC_CHECK_LIB(Xbsd, main, LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -lXbsd")
1926 dnl Check if pthreads is available.
1927 LIB_PTHREAD=
1928 AC_CHECK_HEADERS_ONCE(pthread.h)
1929 if test "$ac_cv_header_pthread_h"; then
1930   dnl gmalloc.c uses pthread_atfork, which is not available on older-style
1931   dnl hosts such as MirBSD 10, so test for pthread_atfork instead of merely
1932   dnl testing for pthread_self if Emacs uses gmalloc.c.
1933   if test "$GMALLOC_OBJ" = gmalloc.o; then
1934     emacs_pthread_function=pthread_atfork
1935   else
1936     emacs_pthread_function=pthread_self
1937   fi
1938   AC_CHECK_LIB(pthread, $emacs_pthread_function, HAVE_PTHREAD=yes)
1940 if test "$HAVE_PTHREAD" = yes; then
1941   case "${canonical}" in
1942     *-hpux*) ;;
1943     *) LIB_PTHREAD="-lpthread"
1944        LIBS="$LIB_PTHREAD $LIBS" ;;
1945   esac
1946   AC_DEFINE(HAVE_PTHREAD, 1, [Define to 1 if you have pthread (-lpthread).])
1948 AC_SUBST([LIB_PTHREAD])
1950 AC_CHECK_LIB(pthreads, cma_open)
1952 AC_MSG_CHECKING([for thread support])
1953 threads_enabled=no
1954 if test "$with_threads" = yes; then
1955    if test "$HAVE_PTHREAD" = yes; then
1956       AC_DEFINE(THREADS_ENABLED, 1,
1957                 [Define to 1 if you want elisp thread support.])
1958       threads_enabled=yes
1959    fi
1961 AC_MSG_RESULT([$threads_enabled])
1963 ## Note: when using cpp in s/aix4.2.h, this definition depended on
1964 ## HAVE_LIBPTHREADS.  That was not defined earlier in configure when
1965 ## the system file was sourced.  Hence the value of LIBS_SYSTEM
1966 ## added to LIBS in configure would never contain the pthreads part,
1967 ## but the value used in Makefiles might.  FIXME?
1969 ## -lpthreads seems to be necessary for Xlib in X11R6, and should
1970 ## be harmless on older versions of X where it happens to exist.
1971 test "$opsys" = "aix4-2" && \
1972   test $ac_cv_lib_pthreads_cma_open = yes && \
1973   LIBS_SYSTEM="$LIBS_SYSTEM -lpthreads"
1975 dnl Check for need for bigtoc support on IBM AIX
1977 case ${host_os} in
1978 aix*)
1979   AC_CACHE_CHECK([for -bbigtoc option], [gdb_cv_bigtoc], [
1980     case $GCC in
1981     yes) gdb_cv_bigtoc=-Wl,-bbigtoc ;;
1982     *) gdb_cv_bigtoc=-bbigtoc ;;
1983     esac
1985     LDFLAGS=$LDFLAGS\ $gdb_cv_bigtoc
1986     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])], [], [gdb_cv_bigtoc=])
1987   ])
1988   ;;
1989 esac
1991 # Change CFLAGS and CPPFLAGS temporarily so that C_SWITCH_X_SITE gets
1992 # used for the tests that follow.  We set them back to REAL_CFLAGS and
1993 # REAL_CPPFLAGS later on.
1995 REAL_CFLAGS="$CFLAGS"
1996 REAL_CPPFLAGS="$CPPFLAGS"
1998 if test "${HAVE_X11}" = "yes"; then
1999   DEFS="$C_SWITCH_X_SITE $DEFS"
2000   LDFLAGS="$LDFLAGS $LD_SWITCH_X_SITE"
2001   LIBS="-lX11 $LIBS"
2002   CFLAGS="$C_SWITCH_X_SITE $CFLAGS"
2003   CPPFLAGS="$C_SWITCH_X_SITE $CPPFLAGS"
2005   # On Solaris, arrange for LD_RUN_PATH to point to the X libraries for tests.
2006   # This is handled by LD_SWITCH_X_SITE_RPATH during the real build,
2007   # but it's more convenient here to set LD_RUN_PATH since this
2008   # also works on hosts that don't understand LD_SWITCH_X_SITE_RPATH.
2009   if test "${x_libraries}" != NONE && test -n "${x_libraries}"; then
2010     LD_RUN_PATH=$x_libraries${LD_RUN_PATH+:}$LD_RUN_PATH
2011     export LD_RUN_PATH
2012   fi
2014   if test "${opsys}" = "gnu-linux"; then
2015     AC_MSG_CHECKING(whether X on GNU/Linux needs -b to link)
2016     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
2017      [[XOpenDisplay ("foo");]])],
2018      [xgnu_linux_first_failure=no],
2019      [xgnu_linux_first_failure=yes])
2020     if test "${xgnu_linux_first_failure}" = "yes"; then
2021       OLD_LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE"
2022       OLD_C_SWITCH_X_SITE="$C_SWITCH_X_SITE"
2023       OLD_CPPFLAGS="$CPPFLAGS"
2024       OLD_LIBS="$LIBS"
2025       LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -b i486-linuxaout"
2026       C_SWITCH_X_SITE="$C_SWITCH_X_SITE -b i486-linuxaout"
2027       CPPFLAGS="$CPPFLAGS -b i486-linuxaout"
2028       LIBS="$LIBS -b i486-linuxaout"
2029       AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
2030        [[XOpenDisplay ("foo");]])],
2031        [xgnu_linux_second_failure=no],
2032        [xgnu_linux_second_failure=yes])
2033       if test "${xgnu_linux_second_failure}" = "yes"; then
2034         # If we get the same failure with -b, there is no use adding -b.
2035         # So take it out.  This plays safe.
2036         LD_SWITCH_X_SITE="$OLD_LD_SWITCH_X_SITE"
2037         C_SWITCH_X_SITE="$OLD_C_SWITCH_X_SITE"
2038         CPPFLAGS="$OLD_CPPFLAGS"
2039         LIBS="$OLD_LIBS"
2040         AC_MSG_RESULT(no)
2041       else
2042         AC_MSG_RESULT(yes)
2043       fi
2044     else
2045       AC_MSG_RESULT(no)
2046     fi
2047   fi
2049   # Reportedly, some broken Solaris systems have XKBlib.h but are missing
2050   # header files included from there.
2051   AC_MSG_CHECKING(for Xkb)
2052   AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>
2053 #include <X11/XKBlib.h>]],
2054         [[XkbDescPtr kb = XkbGetKeyboard (0, XkbAllComponentsMask, XkbUseCoreKbd);]])],
2055         emacs_xkb=yes, emacs_xkb=no)
2056   AC_MSG_RESULT($emacs_xkb)
2057   if test $emacs_xkb = yes; then
2058     AC_DEFINE(HAVE_XKB, 1, [Define to 1 if you have the Xkb extension.])
2059   fi
2061   AC_CHECK_FUNCS(XrmSetDatabase XScreenResourceString \
2062 XScreenNumberOfScreen)
2065 if test "${window_system}" = "x11"; then
2066   AC_MSG_CHECKING(X11 version 6)
2067   AC_CACHE_VAL(emacs_cv_x11_version_6,
2068   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
2069 [[#if XlibSpecificationRelease < 6
2070 fail;
2071 #endif
2072 ]])], emacs_cv_x11_version_6=yes, emacs_cv_x11_version_6=no)])
2073   if test $emacs_cv_x11_version_6 = yes; then
2074     AC_MSG_RESULT(6 or newer)
2075     AC_DEFINE(HAVE_X11R6, 1,
2076               [Define to 1 if you have the X11R6 or newer version of Xlib.])
2077     AC_DEFINE(HAVE_X_I18N, 1, [Define if you have usable i18n support.])
2078     ## inoue@ainet.or.jp says Solaris has a bug related to X11R6-style
2079     ## XIM support.
2080     case "$opsys" in
2081       sol2-*) : ;;
2082       *) AC_DEFINE(HAVE_X11R6_XIM, 1,
2083            [Define if you have usable X11R6-style XIM support.])
2084          ;;
2085     esac
2086   else
2087     AC_MSG_RESULT(before 6)
2088   fi
2092 ### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified.
2093 HAVE_RSVG=no
2094 if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
2095   if test "${with_rsvg}" != "no"; then
2096     RSVG_REQUIRED=2.11.0
2097     RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
2099     PKG_CHECK_MODULES(RSVG, $RSVG_MODULE, HAVE_RSVG=yes, :)
2100     AC_SUBST(RSVG_CFLAGS)
2101     AC_SUBST(RSVG_LIBS)
2103     if test $HAVE_RSVG = yes; then
2104       AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
2105       CFLAGS="$CFLAGS $RSVG_CFLAGS"
2106       LIBS="$RSVG_LIBS $LIBS"
2107     fi
2108   fi
2111 HAVE_IMAGEMAGICK=no
2112 if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes"; then
2113   if test "${with_imagemagick}" != "no"; then
2114     ## 6.2.8 is the earliest version known to work, but earlier versions
2115     ## might work - let us know if you find one.
2116     ## 6.0.7 does not work.  See bug#7955.
2117     ## 6.8.2 makes Emacs crash; see Bug#13867.
2118     IMAGEMAGICK_MODULE="Wand >= 6.2.8 Wand != 6.8.2"
2119     PKG_CHECK_MODULES(IMAGEMAGICK, $IMAGEMAGICK_MODULE, HAVE_IMAGEMAGICK=yes, :)
2120     AC_SUBST(IMAGEMAGICK_CFLAGS)
2121     AC_SUBST(IMAGEMAGICK_LIBS)
2123     if test $HAVE_IMAGEMAGICK = yes; then
2124       AC_DEFINE(HAVE_IMAGEMAGICK, 1, [Define to 1 if using imagemagick.])
2125       CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS"
2126       LIBS="$IMAGEMAGICK_LIBS $LIBS"
2127       AC_CHECK_FUNCS(MagickExportImagePixels MagickMergeImageLayers)
2128     fi
2129   fi
2133 HAVE_GTK=no
2134 GTK_OBJ=
2135 gtk_term_header=$term_header
2136 check_gtk2=no
2137 gtk3_pkg_errors=
2138 if test "${opsys}" != "mingw32"; then
2139   if test "${with_gtk3}" = "yes" || test "${with_gtk}" = "yes" || test "$USE_X_TOOLKIT" = "maybe"; then
2140     GLIB_REQUIRED=2.28
2141     GTK_REQUIRED=3.0
2142     GTK_MODULES="gtk+-3.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
2144     dnl Checks for libraries.
2145     PKG_CHECK_MODULES(GTK, $GTK_MODULES, pkg_check_gtk=yes, pkg_check_gtk=no)
2146     if test "$pkg_check_gtk" = "no" && test "$with_gtk3" = "yes"; then
2147        AC_MSG_ERROR($GTK_PKG_ERRORS)
2148     fi
2149     if test "$pkg_check_gtk" = "yes"; then
2150        AC_DEFINE(HAVE_GTK3, 1, [Define to 1 if using GTK 3 or later.])
2151        GTK_OBJ=emacsgtkfixed.o
2152        gtk_term_header=gtkutil.h
2153        USE_GTK_TOOLKIT="GTK3"
2154        if test "x$ac_enable_gtk_deprecation_warnings" = x; then
2155           GTK_CFLAGS="$GTK_CFLAGS -DGDK_DISABLE_DEPRECATION_WARNINGS"
2156           GTK_CFLAGS="$GTK_CFLAGS -DGLIB_DISABLE_DEPRECATION_WARNINGS"
2157        fi
2158     else
2159        check_gtk2=yes
2160        gtk3_pkg_errors="$GTK_PKG_ERRORS "
2161     fi
2162   fi
2164   if test "${with_gtk2}" = "yes" || test "$check_gtk2" = "yes"; then
2165     GLIB_REQUIRED=2.10
2166     GTK_REQUIRED=2.10
2167     GTK_MODULES="gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
2169     dnl Checks for libraries.
2170     PKG_CHECK_MODULES(GTK, $GTK_MODULES, pkg_check_gtk=yes, pkg_check_gtk=no)
2171     if test "$pkg_check_gtk" = "no" &&
2172        { test "$with_gtk" = yes || test "$with_gtk2" = "yes"; }
2173     then
2174       AC_MSG_ERROR($gtk3_pkg_errors$GTK_PKG_ERRORS)
2175     fi
2176     test "$pkg_check_gtk" = "yes" && USE_GTK_TOOLKIT="GTK2"
2177   fi
2180 if test x"$pkg_check_gtk" = xyes; then
2182   AC_SUBST(GTK_CFLAGS)
2183   AC_SUBST(GTK_LIBS)
2184   C_SWITCH_X_SITE="$C_SWITCH_X_SITE $GTK_CFLAGS"
2185   CFLAGS="$CFLAGS $GTK_CFLAGS"
2186   LIBS="$GTK_LIBS $LIBS"
2187   dnl Try to compile a simple GTK program.
2188   AC_MSG_CHECKING([whether GTK compiles])
2189   GTK_COMPILES=no
2190   AC_LINK_IFELSE(
2191     [AC_LANG_PROGRAM(
2192        [[/* Check the Gtk and Glib APIs.  */
2193          #include <gtk/gtk.h>
2194          #include <glib-object.h>
2195          static void
2196          callback (GObject *go, GParamSpec *spec, gpointer user_data)
2197          {}
2198        ]],
2199        [[
2200          GtkSettings *gs = 0;
2201          /* Use G_CALLBACK to make sure function pointers can be cast to void *;
2202             strict C prohibits this.  Use gtk_main_iteration to test that the
2203             libraries are there.  */
2204          if (g_signal_handler_find (G_OBJECT (gs), G_SIGNAL_MATCH_FUNC,
2205                                     0, 0, 0, G_CALLBACK (callback), 0))
2206            gtk_main_iteration ();
2207        ]])],
2208     [GTK_COMPILES=yes])
2209   AC_MSG_RESULT([$GTK_COMPILES])
2210   if test "${GTK_COMPILES}" != "yes"; then
2211     GTK_OBJ=
2212     if test "$USE_X_TOOLKIT" != "maybe"; then
2213       AC_MSG_ERROR([Gtk+ wanted, but it does not compile, see config.log.  Maybe some x11-devel files missing?]);
2214     fi
2215   else
2216     HAVE_GTK=yes
2217     AC_DEFINE(USE_GTK, 1, [Define to 1 if using GTK.])
2218     GTK_OBJ="gtkutil.o $GTK_OBJ"
2219     term_header=$gtk_term_header
2220     USE_X_TOOLKIT=none
2221     if "$PKG_CONFIG" --atleast-version=2.10 gtk+-2.0; then
2222       :
2223     else
2224       AC_MSG_WARN([[Your version of Gtk+ will have problems with
2225        closing open displays.  This is no problem if you just use
2226        one display, but if you use more than one and close one of them
2227        Emacs may crash.]])
2228       sleep 3
2229     fi
2230   fi
2233 AC_SUBST(GTK_OBJ)
2236 if test "${HAVE_GTK}" = "yes"; then
2238   dnl  GTK scrollbars resemble toolkit scrollbars a lot, so to avoid
2239   dnl  a lot if #ifdef:s, say we have toolkit scrollbars.
2240   if test "$with_toolkit_scroll_bars" != no; then
2241     with_toolkit_scroll_bars=yes
2242   fi
2244   dnl  Check if we have the old file selection dialog declared and
2245   dnl  in the link library.  In 2.x it may be in the library,
2246   dnl  but not declared if deprecated featured has been selected out.
2247   dnl  AC_CHECK_DECL checks for a macro, so check for GTK_TYPE_FILE_SELECTION.
2248   HAVE_GTK_FILE_SELECTION=no
2249   AC_CHECK_DECL(GTK_TYPE_FILE_SELECTION, HAVE_GTK_FILE_SELECTION=yes,
2250                    HAVE_GTK_FILE_SELECTION=no, [AC_INCLUDES_DEFAULT
2251 #include <gtk/gtk.h>])
2252   if test "$HAVE_GTK_FILE_SELECTION" = yes; then
2253     AC_CHECK_FUNCS(gtk_file_selection_new)
2254   fi
2256   dnl Same as above for gtk_handle_box.
2257   HAVE_GTK_HANDLE_BOX=no
2258   AC_CHECK_DECL(GTK_TYPE_HANDLE_BOX, HAVE_GTK_HANDLE_BOX=yes,
2259                    HAVE_GTK_HANDLE_BOX=no, [AC_INCLUDES_DEFAULT
2260 #include <gtk/gtk.h>])
2261   if test "$HAVE_GTK_HANDLE_BOX" = yes; then
2262     AC_CHECK_FUNCS(gtk_handle_box_new)
2263   fi
2265   dnl Same as above for gtk_tearoff_menu_item.
2266   HAVE_GTK_TEAROFF_MENU_ITEM=no
2267   AC_CHECK_DECL(GTK_TYPE_TEAROFF_MENU_ITEM, HAVE_GTK_TEAROFF_MENU_ITEM=yes,
2268                    HAVE_GTK_TEAROFF_MENU_ITEM=no, [AC_INCLUDES_DEFAULT
2269 #include <gtk/gtk.h>])
2270   if test "$HAVE_GTK_TEAROFF_MENU_ITEM" = yes; then
2271     AC_CHECK_FUNCS(gtk_tearoff_menu_item_new)
2272   fi
2274   dnl Check for functions introduced in 2.14 and later.
2275   AC_CHECK_FUNCS(gtk_widget_get_window gtk_widget_set_has_window \
2276                  gtk_dialog_get_action_area gtk_widget_get_sensitive \
2277                  gtk_widget_get_mapped gtk_adjustment_get_page_size \
2278                  gtk_orientable_set_orientation \
2279                  gtk_window_set_has_resize_grip)
2281  term_header=gtkutil.h
2284 dnl D-Bus has been tested under GNU/Linux only.  Must be adapted for
2285 dnl other platforms.
2286 HAVE_DBUS=no
2287 DBUS_OBJ=
2288 if test "${with_dbus}" = "yes"; then
2289    PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.0, HAVE_DBUS=yes, HAVE_DBUS=no)
2290    if test "$HAVE_DBUS" = yes; then
2291      LIBS="$LIBS $DBUS_LIBS"
2292      AC_DEFINE(HAVE_DBUS, 1, [Define to 1 if using D-Bus.])
2293      dnl dbus_watch_get_unix_fd has been introduced in D-Bus 1.1.1.
2294      dnl dbus_type_is_valid and dbus_validate_* have been introduced in
2295      dnl D-Bus 1.5.12.
2296      AC_CHECK_FUNCS(dbus_watch_get_unix_fd \
2297                     dbus_type_is_valid \
2298                     dbus_validate_bus_name \
2299                     dbus_validate_path \
2300                     dbus_validate_interface \
2301                     dbus_validate_member)
2302      DBUS_OBJ=dbusbind.o
2303    fi
2305 AC_SUBST(DBUS_OBJ)
2307 dnl GSettings has been tested under GNU/Linux only.
2308 HAVE_GSETTINGS=no
2309 if test "${HAVE_X11}" = "yes" && test "${with_gsettings}" = "yes"; then
2310    PKG_CHECK_MODULES(GSETTINGS, gio-2.0 >= 2.26, HAVE_GSETTINGS=yes, HAVE_GSETTINGS=no)
2311    if test "$HAVE_GSETTINGS" = "yes"; then
2312       AC_DEFINE(HAVE_GSETTINGS, 1, [Define to 1 if using GSettings.])
2313       SETTINGS_CFLAGS="$GSETTINGS_CFLAGS"
2314       SETTINGS_LIBS="$GSETTINGS_LIBS"
2315    fi
2318 dnl GConf has been tested under GNU/Linux only.
2319 dnl The version is really arbitrary, it is about the same age as Gtk+ 2.6.
2320 HAVE_GCONF=no
2321 if test "${HAVE_X11}" = "yes" && test "${with_gconf}" = "yes"; then
2322    PKG_CHECK_MODULES(GCONF, gconf-2.0 >= 2.13, HAVE_GCONF=yes, HAVE_GCONF=no)
2323    if test "$HAVE_GCONF" = yes; then
2324       AC_DEFINE(HAVE_GCONF, 1, [Define to 1 if using GConf.])
2325       dnl Newer GConf doesn't link with g_objects, so this is not defined.
2326       SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GCONF_CFLAGS"
2327       SETTINGS_LIBS="$SETTINGS_LIBS $GCONF_LIBS"
2328    fi
2331 if test "$HAVE_GSETTINGS" = "yes" || test "$HAVE_GCONF" = "yes"; then
2332     PKG_CHECK_MODULES(GOBJECT, gobject-2.0 >= 2.0, HAVE_GOBJECT=yes, HAVE_GOBJECT=no)
2333     if test "$HAVE_GOBJECT" = "yes"; then
2334        SETTINGS_CFLAGS="$SETTINGS_CFLAGS $GOBJECT_CFLAGS"
2335        SETTINGS_LIBS="$SETTINGS_LIBS $GOBJECT_LIBS"
2336     fi
2337     SAVE_CFLAGS="$CFLAGS"
2338     SAVE_LIBS="$LIBS"
2339     CFLAGS="$SETTINGS_CFLAGS $CFLAGS"
2340     LIBS="$SETTINGS_LIBS $LIBS"
2341     AC_CHECK_FUNCS([g_type_init])
2342     CFLAGS="$SAVE_CFLAGS"
2343     LIBS="$SAVE_LIBS"
2345 AC_SUBST(SETTINGS_CFLAGS)
2346 AC_SUBST(SETTINGS_LIBS)
2349 dnl SELinux is available for GNU/Linux only.
2350 HAVE_LIBSELINUX=no
2351 LIBSELINUX_LIBS=
2352 if test "${with_selinux}" = "yes"; then
2353    AC_CHECK_LIB([selinux], [lgetfilecon], HAVE_LIBSELINUX=yes, HAVE_LIBSELINUX=no)
2354    if test "$HAVE_LIBSELINUX" = yes; then
2355       AC_DEFINE(HAVE_LIBSELINUX, 1, [Define to 1 if using SELinux.])
2356       LIBSELINUX_LIBS=-lselinux
2357    fi
2359 AC_SUBST(LIBSELINUX_LIBS)
2361 HAVE_GNUTLS=no
2362 if test "${with_gnutls}" = "yes" ; then
2363   PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.6.6], HAVE_GNUTLS=yes, HAVE_GNUTLS=no)
2364   if test "${HAVE_GNUTLS}" = "yes"; then
2365     AC_DEFINE(HAVE_GNUTLS, 1, [Define if using GnuTLS.])
2366   fi
2368   # Windows loads GnuTLS dynamically
2369   if test "${opsys}" = "mingw32"; then
2370     LIBGNUTLS_LIBS=
2371   else
2372     CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
2373     LIBS="$LIBGNUTLS_LIBS $LIBS"
2374   fi
2377 AC_SUBST(LIBGNUTLS_LIBS)
2378 AC_SUBST(LIBGNUTLS_CFLAGS)
2380 NOTIFY_OBJ=
2381 NOTIFY_SUMMARY=no
2383 dnl FIXME?  Don't auto-detect on NS, but do allow someone to specify
2384 dnl a particular library.  This doesn't make much sense?
2385 if test "${with_ns}" = yes && test ${with_file_notification} = yes; then
2386   with_file_notification=no
2389 dnl MS Windows native file monitor is available for mingw32 only.
2390 case $with_file_notification,$opsys in
2391   w32,* | yes,mingw32)
2392     AC_CHECK_HEADER(windows.h)
2393     if test "$ac_cv_header_windows_h" = yes ; then
2394        AC_DEFINE(HAVE_W32NOTIFY, 1, [Define to 1 to use w32notify.])
2395        NOTIFY_OBJ=w32notify.o
2396        NOTIFY_SUMMARY="yes (w32)"
2397     fi ;;
2398 esac
2400 dnl g_file_monitor exists since glib 2.18.  G_FILE_MONITOR_EVENT_MOVED
2401 dnl has been added in glib 2.24.  It has been tested under
2402 dnl GNU/Linux only.  We take precedence over inotify, but this makes
2403 dnl only sense when glib has been compiled with inotify support.  How
2404 dnl to check?
2405 case $with_file_notification,$NOTIFY_OBJ in
2406   gfile, | yes,)
2407     PKG_CHECK_MODULES(GFILENOTIFY, gio-2.0 >= 2.24, HAVE_GFILENOTIFY=yes, HAVE_GFILENOTIFY=no)
2408     if test "$HAVE_GFILENOTIFY" = "yes"; then
2409        AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.])
2410        NOTIFY_OBJ=gfilenotify.o
2411        NOTIFY_SUMMARY="yes -lgio (gfile)"
2412     fi ;;
2413 esac
2415 dnl inotify is only available on GNU/Linux.
2416 case $with_file_notification,$NOTIFY_OBJ in
2417   inotify, | yes,)
2418     AC_CHECK_HEADER(sys/inotify.h)
2419     if test "$ac_cv_header_sys_inotify_h" = yes ; then
2420         AC_CHECK_FUNC(inotify_init1)
2421         if test "$ac_cv_func_inotify_init1" = yes; then
2422           AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 to use inotify.])
2423           NOTIFY_OBJ=inotify.o
2424           NOTIFY_SUMMARY="yes -lglibc (inotify)"
2425        fi
2426     fi ;;
2427 esac
2429 case $with_file_notification,$NOTIFY_OBJ in
2430   yes,* | no,* | *,?*) ;;
2431   *) AC_MSG_ERROR([File notification `$with_file_notification' requested but requirements not found.]) ;;
2432 esac
2434 if test -n "$NOTIFY_OBJ"; then
2435    AC_DEFINE(USE_FILE_NOTIFY, 1, [Define to 1 if using file notifications.])
2437 AC_SUBST(NOTIFY_OBJ)
2438 AC_SUBST(GFILENOTIFY_CFLAGS)
2439 AC_SUBST(GFILENOTIFY_LIBS)
2441 dnl Do not put whitespace before the #include statements below.
2442 dnl Older compilers (eg sunos4 cc) choke on it.
2443 HAVE_XAW3D=no
2444 LUCID_LIBW=
2445 if test x"${USE_X_TOOLKIT}" = xmaybe || test x"${USE_X_TOOLKIT}" = xLUCID; then
2446   if test "$with_xaw3d" != no; then
2447     AC_CACHE_VAL(emacs_cv_xaw3d,
2448     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2449 #include <X11/Intrinsic.h>
2450 #include <X11/Xaw3d/Simple.h>]],
2451       [[]])],
2452       [AC_CHECK_LIB(Xaw3d, XawScrollbarSetThumb,
2453                     emacs_cv_xaw3d=yes, emacs_cv_xaw3d=no)],
2454       emacs_cv_xaw3d=no)])
2455   else
2456     emacs_cv_xaw3d=no
2457   fi
2458   if test $emacs_cv_xaw3d = yes; then
2459     AC_MSG_CHECKING(for xaw3d)
2460     AC_MSG_RESULT([yes; using Lucid toolkit])
2461     USE_X_TOOLKIT=LUCID
2462     HAVE_XAW3D=yes
2463     LUCID_LIBW=-lXaw3d
2464     AC_DEFINE(HAVE_XAW3D, 1,
2465               [Define to 1 if you have the Xaw3d library (-lXaw3d).])
2466   else
2467     AC_MSG_CHECKING(for xaw3d)
2468     AC_MSG_RESULT(no)
2469     AC_MSG_CHECKING(for libXaw)
2470     AC_CACHE_VAL(emacs_cv_xaw,
2471     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2472 #include <X11/Intrinsic.h>
2473 #include <X11/Xaw/Simple.h>]],
2474       [[]])],
2475       emacs_cv_xaw=yes,
2476       emacs_cv_xaw=no)])
2477     if test $emacs_cv_xaw = yes; then
2478       AC_MSG_RESULT([yes; using Lucid toolkit])
2479       USE_X_TOOLKIT=LUCID
2480       LUCID_LIBW=-lXaw
2481     elif test x"${USE_X_TOOLKIT}" = xLUCID; then
2482       AC_MSG_ERROR([Lucid toolkit requires X11/Xaw include files])
2483     else
2484       AC_MSG_ERROR([No X toolkit could be found.
2485 If you are sure you want Emacs compiled without an X toolkit, pass
2486   --with-x-toolkit=no
2487 to configure.  Otherwise, install the development libraries for the toolkit
2488 that you want to use (e.g. Gtk+) and re-run configure.])
2489     fi
2490   fi
2493 X_TOOLKIT_TYPE=$USE_X_TOOLKIT
2495 LIBXTR6=
2496 if test "${USE_X_TOOLKIT}" != "none"; then
2497   AC_MSG_CHECKING(X11 toolkit version)
2498   AC_CACHE_VAL(emacs_cv_x11_toolkit_version_6,
2499   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Intrinsic.h>]],
2500 [[#if XtSpecificationRelease < 6
2501 fail;
2502 #endif
2503 ]])], emacs_cv_x11_toolkit_version_6=yes, emacs_cv_x11_toolkit_version_6=no)])
2504   HAVE_X11XTR6=$emacs_cv_x11_toolkit_version_6
2505   if test $emacs_cv_x11_toolkit_version_6 = yes; then
2506     AC_MSG_RESULT(6 or newer)
2507     AC_DEFINE(HAVE_X11XTR6, 1,
2508               [Define to 1 if you have the X11R6 or newer version of Xt.])
2509     LIBXTR6="-lSM -lICE"
2510     case "$opsys" in
2511       ## Use libw.a along with X11R6 Xt.
2512       unixware) LIBXTR6="$LIBXTR6 -lw" ;;
2513     esac
2514   else
2515     AC_MSG_RESULT(before 6)
2516   fi
2518 dnl If using toolkit, check whether libXmu.a exists.
2519 dnl tranle@intellicorp.com says libXmu.a can need XtMalloc in libXt.a to link.
2520   OLDLIBS="$LIBS"
2521   if test x$HAVE_X11XTR6 = xyes; then
2522     LIBS="-lXt -lSM -lICE $LIBS"
2523   else
2524     LIBS="-lXt $LIBS"
2525   fi
2526   AC_CHECK_LIB(Xmu, XmuConvertStandardSelection)
2527   test $ac_cv_lib_Xmu_XmuConvertStandardSelection = no && LIBS="$OLDLIBS"
2528   dnl ac_cv_lib_Xmu_XmuConvertStandardSelection is also referenced below.
2530 AC_SUBST(LIBXTR6)
2532 dnl FIXME the logic here seems weird, but this is what cpp was doing.
2533 dnl Why not just test for libxmu in the normal way?
2534 LIBXMU=-lXmu
2535 case $opsys in
2536   ## These systems don't supply Xmu.
2537   hpux* | aix4-2 )
2538     test "X$ac_cv_lib_Xmu_XmuConvertStandardSelection" != "Xyes" && LIBXMU=
2539     ;;
2540   mingw32 )
2541     LIBXMU=
2542     ;;
2543 esac
2544 AC_SUBST(LIBXMU)
2546 # On Irix 6.5, at least, we need XShapeQueryExtension from -lXext for Xaw3D.
2547 if test "${HAVE_X11}" = "yes"; then
2548   if test "${USE_X_TOOLKIT}" != "none"; then
2549     AC_CHECK_LIB(Xext, XShapeQueryExtension)
2550   fi
2553 LIBXP=
2554 if test "${USE_X_TOOLKIT}" = "MOTIF"; then
2555   # OpenMotif may be installed in such a way on some GNU/Linux systems.
2556   if test -d /usr/include/openmotif; then
2557     CPPFLAGS="-I/usr/include/openmotif $CPPFLAGS"
2558     emacs_cv_openmotif=yes
2559     case "$canonical" in
2560       x86_64-*-linux-gnu* | powerpc64-*-linux-gnu* | sparc64-*-linux-gnu*)
2561       test -d /usr/lib64/openmotif && LDFLAGS="-L/usr/lib64/openmotif $LDFLAGS"
2562       ;;
2563       *)
2564       test -d /usr/lib/openmotif && LDFLAGS="-L/usr/lib/openmotif $LDFLAGS"
2565     esac
2566   else
2567     emacs_cv_openmotif=no
2568   fi
2569   AC_CACHE_CHECK(for (Open)Motif version 2.1, emacs_cv_motif_version_2_1,
2570   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <Xm/Xm.h>]],
2571     [[#if XmVERSION > 2 || (XmVERSION == 2 && XmREVISION >= 1)
2572 int x = 5;
2573 #else
2574 Motif version prior to 2.1.
2575 #endif]])],
2576     emacs_cv_motif_version_2_1=yes, emacs_cv_motif_version_2_1=no)])
2577   if test $emacs_cv_motif_version_2_1 = yes; then
2578     AC_CHECK_LIB(Xp, XpCreateContext, LIBXP=-lXp)
2579     if test x$emacs_cv_openmotif = xyes; then
2580       REAL_CPPFLAGS="-I/usr/include/openmotif $REAL_CPPFLAGS"
2581     fi
2582   else
2583     AC_CACHE_CHECK(for LessTif where some systems put it, emacs_cv_lesstif,
2584     # We put this in CFLAGS temporarily to precede other -I options
2585     # that might be in CFLAGS temporarily.
2586     # We put this in CPPFLAGS where it precedes the other -I options.
2587     OLD_CPPFLAGS=$CPPFLAGS
2588     OLD_CFLAGS=$CFLAGS
2589     CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CPPFLAGS"
2590     CFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $CFLAGS"
2591     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include </usr/X11R6/LessTif/Motif1.2/include/Xm/Xm.h>]],
2592       [[int x = 5;]])],
2593       emacs_cv_lesstif=yes, emacs_cv_lesstif=no)])
2594     if test $emacs_cv_lesstif = yes; then
2595       # Make sure this -I option remains in CPPFLAGS after it is set
2596       # back to REAL_CPPFLAGS.
2597       # There is no need to change REAL_CFLAGS, because REAL_CFLAGS does not
2598       # have those other -I options anyway.  Ultimately, having this
2599       # directory ultimately in CPPFLAGS will be enough.
2600       REAL_CPPFLAGS="-I/usr/X11R6/LessTif/Motif1.2/include $REAL_CPPFLAGS"
2601       LDFLAGS="-L/usr/X11R6/LessTif/Motif1.2/lib $LDFLAGS"
2602     else
2603       CFLAGS=$OLD_CFLAGS
2604       CPPFLAGS=$OLD_CPPFLAGS
2605     fi
2606   fi
2607   AC_CHECK_HEADER([Xm/BulletinB.h], [],
2608     [AC_MSG_ERROR([Motif toolkit requested but requirements not found.])])
2611 dnl Use toolkit scroll bars if configured for GTK or X toolkit and either
2612 dnl using Motif or Xaw3d is available, and unless
2613 dnl --with-toolkit-scroll-bars=no was specified.
2615 AH_TEMPLATE(USE_TOOLKIT_SCROLL_BARS,
2616             [Define to 1 if we should use toolkit scroll bars.])dnl
2617 USE_TOOLKIT_SCROLL_BARS=no
2618 if test "${with_toolkit_scroll_bars}" != "no"; then
2619   if test "${USE_X_TOOLKIT}" != "none"; then
2620     if test "${USE_X_TOOLKIT}" = "MOTIF"; then
2621       AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2622       HAVE_XAW3D=no
2623       USE_TOOLKIT_SCROLL_BARS=yes
2624     elif test "${HAVE_XAW3D}" = "yes" || test "${USE_X_TOOLKIT}" = "LUCID"; then
2625       AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2626       USE_TOOLKIT_SCROLL_BARS=yes
2627     fi
2628   elif test "${HAVE_GTK}" = "yes"; then
2629     AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2630     USE_TOOLKIT_SCROLL_BARS=yes
2631   elif test "${HAVE_NS}" = "yes"; then
2632     AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2633     USE_TOOLKIT_SCROLL_BARS=yes
2634   elif test "${HAVE_W32}" = "yes"; then
2635     AC_DEFINE(USE_TOOLKIT_SCROLL_BARS)
2636     USE_TOOLKIT_SCROLL_BARS=yes
2637   fi
2640 dnl See if XIM is available.
2641 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2642           #include <X11/Xlib.h>
2643           #include <X11/Xresource.h>]],
2644          [[XIMProc  callback;]])],
2645          [HAVE_XIM=yes
2646          AC_DEFINE(HAVE_XIM, 1, [Define to 1 if XIM is available])],
2647          HAVE_XIM=no)
2649 dnl `--with-xim' now controls only the initial value of use_xim at run time.
2651 if test "${with_xim}" != "no"; then
2652   AC_DEFINE(USE_XIM, 1,
2653             [Define to 1 if we should use XIM, if it is available.])
2657 if test "${HAVE_XIM}" != "no"; then
2658   late_CFLAGS=$CFLAGS
2659   if test "$GCC" = yes; then
2660     CFLAGS="$CFLAGS --pedantic-errors"
2661   fi
2662   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2663 #include <X11/Xlib.h>
2664 #include <X11/Xresource.h>]],
2665 [[Display *display;
2666 XrmDatabase db;
2667 char *res_name;
2668 char *res_class;
2669 XIMProc  callback;
2670 XPointer *client_data;
2671 #ifndef __GNUC__
2672 /* If we're not using GCC, it's probably not XFree86, and this is
2673    probably right, but we can't use something like --pedantic-errors.  */
2674 extern Bool XRegisterIMInstantiateCallback(Display*, XrmDatabase, char*,
2675                                            char*, XIMProc, XPointer*);
2676 #endif
2677 (void)XRegisterIMInstantiateCallback(display, db, res_name, res_class, callback,
2678    client_data);]])],
2679     [emacs_cv_arg6_star=yes])
2680   AH_TEMPLATE(XRegisterIMInstantiateCallback_arg6,
2681          [Define to the type of the 6th arg of XRegisterIMInstantiateCallback,
2682 either XPointer or XPointer*.])dnl
2683   if test "$emacs_cv_arg6_star" = yes; then
2684     AC_DEFINE(XRegisterIMInstantiateCallback_arg6, [XPointer*])
2685   else
2686     AC_DEFINE(XRegisterIMInstantiateCallback_arg6, [XPointer])
2687   fi
2688   CFLAGS=$late_CFLAGS
2691 ### Start of font-backend (under any platform) section.
2692 # (nothing here yet -- this is a placeholder)
2693 ### End of font-backend (under any platform) section.
2695 ### Start of font-backend (under X11) section.
2696 if test "${HAVE_X11}" = "yes"; then
2697    PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.2.0, HAVE_FC=yes, HAVE_FC=no)
2699    ## Use -lXft if available, unless `--with-xft=no'.
2700    HAVE_XFT=maybe
2701     if test "${HAVE_FC}" = "no" || test "x${with_x}" = "xno"; then
2702       with_xft="no";
2703     fi
2704     if test "x${with_xft}" != "xno"; then
2706       PKG_CHECK_MODULES(XFT, xft >= 0.13.0, , HAVE_XFT=no)
2707       ## Because xftfont.c uses XRenderQueryExtension, we also
2708       ## need to link to -lXrender.
2709       HAVE_XRENDER=no
2710       AC_CHECK_LIB(Xrender, XRenderQueryExtension, HAVE_XRENDER=yes)
2711       if test "$HAVE_XFT" != no && test "$HAVE_XRENDER" != no; then
2712         OLD_CPPFLAGS="$CPPFLAGS"
2713         OLD_CFLAGS="$CFLAGS"
2714         OLD_LIBS="$LIBS"
2715         CPPFLAGS="$CPPFLAGS $XFT_CFLAGS"
2716         CFLAGS="$CFLAGS $XFT_CFLAGS"
2717         XFT_LIBS="-lXrender $XFT_LIBS"
2718         LIBS="$XFT_LIBS $LIBS"
2719         AC_CHECK_HEADER(X11/Xft/Xft.h,
2720           AC_CHECK_LIB(Xft, XftFontOpen, HAVE_XFT=yes, , $XFT_LIBS) , ,
2721           [[#include <X11/X.h>]])
2723         if test "${HAVE_XFT}" = "yes"; then
2724           AC_DEFINE(HAVE_XFT, 1, [Define to 1 if you have the Xft library.])
2725             AC_SUBST(XFT_LIBS)
2726           C_SWITCH_X_SITE="$C_SWITCH_X_SITE $XFT_CFLAGS"
2727         else
2728           CPPFLAGS="$OLD_CPPFLAGS"
2729           CFLAGS="$OLD_CFLAGS"
2730           LIBS="$OLD_LIBS"
2731         fi                        # "${HAVE_XFT}" = "yes"
2732       fi                          # "$HAVE_XFT" != no
2733     fi                            # "x${with_xft}" != "xno"
2735     ## We used to allow building with FreeType and without Xft.
2736     ## However, the ftx font backend driver is not in good shape.
2737     if test "$HAVE_XFT" != "yes"; then
2738        dnl For the "Does Emacs use" message at the end.
2739        HAVE_XFT=no
2740        HAVE_FREETYPE=no
2741     else
2742        dnl Strict linkers fail with
2743        dnl ftfont.o: undefined reference to symbol 'FT_New_Face'
2744        dnl if -lfreetype is not specified.
2745        dnl The following is needed to set FREETYPE_LIBS.
2746        PKG_CHECK_MODULES(FREETYPE, freetype2, HAVE_FREETYPE=yes,
2747                          HAVE_FREETYPE=no)
2749        test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(libxft requires libfreetype)
2750     fi
2752     HAVE_LIBOTF=no
2753     if test "${HAVE_FREETYPE}" = "yes"; then
2754       AC_DEFINE(HAVE_FREETYPE, 1,
2755                 [Define to 1 if using the freetype and fontconfig libraries.])
2756       if test "${with_libotf}" != "no"; then
2757         PKG_CHECK_MODULES(LIBOTF, libotf, HAVE_LIBOTF=yes,
2758                           HAVE_LIBOTF=no)
2759         if test "$HAVE_LIBOTF" = "yes"; then
2760           AC_DEFINE(HAVE_LIBOTF, 1, [Define to 1 if using libotf.])
2761           AC_CHECK_LIB(otf, OTF_get_variation_glyphs,
2762                        HAVE_OTF_GET_VARIATION_GLYPHS=yes,
2763                        HAVE_OTF_GET_VARIATION_GLYPHS=no)
2764           if test "${HAVE_OTF_GET_VARIATION_GLYPHS}" = "yes"; then
2765             AC_DEFINE(HAVE_OTF_GET_VARIATION_GLYPHS, 1,
2766                       [Define to 1 if libotf has OTF_get_variation_glyphs.])
2767           fi
2768         fi
2769       fi
2770     dnl FIXME should there be an error if HAVE_FREETYPE != yes?
2771     dnl Does the new font backend require it, or can it work without it?
2772     fi
2774     HAVE_M17N_FLT=no
2775     if test "${HAVE_LIBOTF}" = yes; then
2776       if test "${with_m17n_flt}" != "no"; then
2777         PKG_CHECK_MODULES(M17N_FLT, m17n-flt, HAVE_M17N_FLT=yes, HAVE_M17N_FLT=no)
2778         if test "$HAVE_M17N_FLT" = "yes"; then
2779           AC_DEFINE(HAVE_M17N_FLT, 1, [Define to 1 if using libm17n-flt.])
2780         fi
2781       fi
2782     fi
2783 else
2784     HAVE_XFT=no
2785     HAVE_FREETYPE=no
2786     HAVE_LIBOTF=no
2787     HAVE_M17N_FLT=no
2790 ### End of font-backend (under X11) section.
2792 AC_SUBST(FREETYPE_CFLAGS)
2793 AC_SUBST(FREETYPE_LIBS)
2794 AC_SUBST(FONTCONFIG_CFLAGS)
2795 AC_SUBST(FONTCONFIG_LIBS)
2796 AC_SUBST(LIBOTF_CFLAGS)
2797 AC_SUBST(LIBOTF_LIBS)
2798 AC_SUBST(M17N_FLT_CFLAGS)
2799 AC_SUBST(M17N_FLT_LIBS)
2801 ### Use -lXpm if available, unless `--with-xpm=no'.
2802 ### mingw32 doesn't use -lXpm, since it loads the library dynamically.
2803 HAVE_XPM=no
2804 LIBXPM=
2805 if test "${HAVE_W32}" = "yes" && test "${opsys}" = "cygwin"; then
2806   if test "${with_xpm}" != "no"; then
2807     SAVE_CPPFLAGS="$CPPFLAGS"
2808     SAVE_LDFLAGS="$LDFLAGS"
2809     CPPFLAGS="$CPPFLAGS -I/usr/include/noX"
2810     LDFLAGS="$LDFLAGS -L/usr/lib/noX"
2811     AC_CHECK_HEADER(X11/xpm.h,
2812       [AC_CHECK_LIB(Xpm, XpmReadFileToImage, HAVE_XPM=yes)])
2813     if test "${HAVE_XPM}" = "yes"; then
2814       AC_MSG_CHECKING(for XpmReturnAllocPixels preprocessor define)
2815       AC_EGREP_CPP(no_return_alloc_pixels,
2816       [#include "X11/xpm.h"
2817 #ifndef XpmReturnAllocPixels
2818 no_return_alloc_pixels
2819 #endif
2820       ], HAVE_XPM=no, HAVE_XPM=yes)
2822       if test "${HAVE_XPM}" = "yes"; then
2823         REAL_CPPFLAGS="$REAL_CPPFLAGS -I/usr/include/noX"
2824         AC_MSG_RESULT(yes)
2825       else
2826         AC_MSG_RESULT(no)
2827         CPPFLAGS="$SAVE_CPPFLAGS"
2828         LDFLAGS="$SAVE_LDFLAGS"
2829       fi
2830     fi
2831   fi
2833   if test "${HAVE_XPM}" = "yes"; then
2834     AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
2835     LIBXPM=-lXpm
2836   fi
2839 if test "${HAVE_X11}" = "yes"; then
2840   if test "${with_xpm}" != "no"; then
2841     AC_CHECK_HEADER(X11/xpm.h,
2842       [AC_CHECK_LIB(Xpm, XpmReadFileToPixmap, HAVE_XPM=yes, , -lX11)])
2843     if test "${HAVE_XPM}" = "yes"; then
2844       AC_MSG_CHECKING(for XpmReturnAllocPixels preprocessor define)
2845       AC_EGREP_CPP(no_return_alloc_pixels,
2846       [#include "X11/xpm.h"
2847 #ifndef XpmReturnAllocPixels
2848 no_return_alloc_pixels
2849 #endif
2850       ], HAVE_XPM=no, HAVE_XPM=yes)
2852       if test "${HAVE_XPM}" = "yes"; then
2853         AC_MSG_RESULT(yes)
2854       else
2855         AC_MSG_RESULT(no)
2856       fi
2857     fi
2858   fi
2860   if test "${HAVE_XPM}" = "yes"; then
2861     AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
2862     LIBXPM=-lXpm
2863   fi
2866 ### FIXME: Perhaps regroup to minimize code duplication due to MinGW's
2867 ### slightly different requirements wrt image libraries (it doesn't
2868 ### use -lXpm because it loads the xpm shared library dynamically at
2869 ### run time).
2870 if test "${opsys}" = "mingw32"; then
2871   if test "${with_xpm}" != "no"; then
2872     AC_CHECK_HEADER(X11/xpm.h, HAVE_XPM=yes, HAVE_XPM=no, [
2873 #define FOR_MSW 1])
2874   fi
2876   if test "${HAVE_XPM}" = "yes"; then
2877     AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
2878   fi
2881 AC_SUBST(LIBXPM)
2883 ### Use -ljpeg if available, unless `--with-jpeg=no'.
2884 ### mingw32 doesn't use -ljpeg, since it loads the library dynamically.
2885 HAVE_JPEG=no
2886 LIBJPEG=
2887 if test "${opsys}" = "mingw32"; then
2888   if test "${with_jpeg}" != "no"; then
2889     dnl Checking for jpeglib.h can lose because of a redefinition of
2890     dnl HAVE_STDLIB_H.
2891     AC_CHECK_HEADER(jerror.h, HAVE_JPEG=yes, HAVE_JPEG=no)
2892   fi
2893   AH_TEMPLATE(HAVE_JPEG, [Define to 1 if you have the jpeg library (-ljpeg).])dnl
2894   if test "${HAVE_JPEG}" = "yes"; then
2895     AC_DEFINE(HAVE_JPEG)
2896     AC_EGREP_CPP([version= *(6[2-9]|[7-9][0-9])],
2897         [#include <jpeglib.h>
2898          version=JPEG_LIB_VERSION
2900         [AC_DEFINE(HAVE_JPEG)],
2901         [AC_MSG_WARN([libjpeg found, but not version 6b or later])
2902         HAVE_JPEG=no])
2903   fi
2904 elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
2905   if test "${with_jpeg}" != "no"; then
2906     dnl Checking for jpeglib.h can lose because of a redefinition of
2907     dnl  HAVE_STDLIB_H.
2908     AC_CHECK_HEADER(jerror.h,
2909       [AC_CHECK_LIB(jpeg, jpeg_destroy_compress, HAVE_JPEG=yes)])
2910   fi
2912   AH_TEMPLATE(HAVE_JPEG, [Define to 1 if you have the jpeg library (-ljpeg).])dnl
2913   if test "${HAVE_JPEG}" = "yes"; then
2914     AC_DEFINE(HAVE_JPEG)
2915     AC_EGREP_CPP([version= *(6[2-9]|[7-9][0-9])],
2916         [#include <jpeglib.h>
2917          version=JPEG_LIB_VERSION
2919         [AC_DEFINE(HAVE_JPEG)],
2920         [AC_MSG_WARN([libjpeg found, but not version 6b or later])
2921         HAVE_JPEG=no])
2922   fi
2923   if test "${HAVE_JPEG}" = "yes"; then
2924     LIBJPEG=-ljpeg
2925   fi
2927 AC_SUBST(LIBJPEG)
2929 ### Use -lpng if available, unless `--with-png=no'.
2930 ### mingw32 doesn't use -lpng, since it loads the library dynamically.
2931 HAVE_PNG=no
2932 LIBPNG=
2933 if test "${opsys}" = "mingw32"; then
2934   if test "${with_png}" != "no"; then
2935     AC_CHECK_HEADER(png.h, HAVE_PNG=yes, HAVE_PNG=no)
2936   fi
2937   if test "${HAVE_PNG}" = "yes"; then
2938     AC_DEFINE(HAVE_PNG, 1, [Define to 1 if you have the png library (-lpng).])
2940     AC_CHECK_DECL(png_longjmp,
2941       [],
2942       [AC_DEFINE(PNG_DEPSTRUCT, [],
2943          [Define to empty to suppress deprecation warnings when building
2944           with --enable-gcc-warnings and with libpng versions before 1.5,
2945           which lack png_longjmp.])],
2946       [[#ifdef HAVE_LIBPNG_PNG_H
2947         # include <libpng/png.h>
2948         #else
2949         # include <png.h>
2950         #endif
2951       ]])
2952   fi
2953 elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
2954   if test "${with_png}" != "no"; then
2955     # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
2956     # in /usr/include/libpng.
2957     AC_CHECK_HEADERS(png.h libpng/png.h, break)
2958     if test "$ac_cv_header_png_h" = yes || test "$ac_cv_header_libpng_png_h" = yes ; then
2959       AC_CHECK_LIB(png, png_get_channels, HAVE_PNG=yes, , -lz -lm)
2960     fi
2961   fi
2963   if test "${HAVE_PNG}" = "yes"; then
2964     AC_DEFINE(HAVE_PNG, 1, [Define to 1 if you have the png library (-lpng).])
2965     LIBPNG="-lpng -lz -lm"
2967     AC_CHECK_DECL(png_longjmp,
2968       [],
2969       [AC_DEFINE(PNG_DEPSTRUCT, [],
2970          [Define to empty to suppress deprecation warnings when building
2971           with --enable-gcc-warnings and with libpng versions before 1.5,
2972           which lack png_longjmp.])],
2973       [[#ifdef HAVE_LIBPNG_PNG_H
2974         # include <libpng/png.h>
2975         #else
2976         # include <png.h>
2977         #endif
2978       ]])
2979   fi
2981 AC_SUBST(LIBPNG)
2983 HAVE_ZLIB=no
2984 LIBZ=
2985 if test "${with_zlib}" != "no"; then
2986   OLIBS=$LIBS
2987   AC_SEARCH_LIBS([inflateEnd], [z], [HAVE_ZLIB=yes])
2988   LIBS=$OLIBS
2989   case $ac_cv_search_inflateEnd in
2990     -*) LIBZ=$ac_cv_search_inflateEnd ;;
2991   esac
2993 if test "${HAVE_ZLIB}" = "yes"; then
2994   AC_DEFINE([HAVE_ZLIB], 1, [Define to 1 if you have the zlib library (-lz).])
2995   ### mingw32 doesn't use -lz, since it loads the library dynamically.
2996   if test "${opsys}" = "mingw32"; then
2997      LIBZ=
2998   fi
3000 AC_SUBST(LIBZ)
3003 ### Use -ltiff if available, unless `--with-tiff=no'.
3004 ### mingw32 doesn't use -ltiff, since it loads the library dynamically.
3005 HAVE_TIFF=no
3006 LIBTIFF=
3007 if test "${opsys}" = "mingw32"; then
3008   if test "${with_tiff}" != "no"; then
3009     AC_CHECK_HEADER(tiffio.h, HAVE_TIFF=yes, HAVE_TIFF=no)
3010   fi
3011   if test "${HAVE_TIFF}" = "yes"; then
3012     AC_DEFINE(HAVE_TIFF, 1, [Define to 1 if you have the tiff library (-ltiff).])
3013   fi
3014 elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
3015   if test "${with_tiff}" != "no"; then
3016     AC_CHECK_HEADER(tiffio.h,
3017       [tifflibs="-lz -lm"
3018       # At least one tiff package requires the jpeg library.
3019       if test "${HAVE_JPEG}" = yes; then tifflibs="-ljpeg $tifflibs"; fi
3020       AC_CHECK_LIB(tiff, TIFFGetVersion, HAVE_TIFF=yes, , $tifflibs)])
3021   fi
3023   if test "${HAVE_TIFF}" = "yes"; then
3024     AC_DEFINE(HAVE_TIFF, 1, [Define to 1 if you have the tiff library (-ltiff).])
3025     dnl FIXME -lz -lm, as per libpng?
3026     LIBTIFF=-ltiff
3027   fi
3029 AC_SUBST(LIBTIFF)
3031 ### Use -lgif or -lungif if available, unless `--with-gif=no'.
3032 ### mingw32 doesn't use -lgif/-lungif, since it loads the library dynamically.
3033 HAVE_GIF=no
3034 LIBGIF=
3035 if test "${opsys}" = "mingw32"; then
3036   if test "${with_gif}" != "no"; then
3037     AC_CHECK_HEADER(gif_lib.h, HAVE_GIF=yes, HAVE_GIF=no)
3038   fi
3039   if test "${HAVE_GIF}" = "yes"; then
3040     AC_DEFINE(HAVE_GIF, 1, [Define to 1 if you have a gif (or ungif) library.])
3041   fi
3042 elif test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no" \
3043         || test "${HAVE_W32}" = "yes"; then
3044   AC_CHECK_HEADER(gif_lib.h,
3045 # EGifPutExtensionLast only exists from version libungif-4.1.0b1.
3046 # Earlier versions can crash Emacs.
3047     [AC_CHECK_LIB(gif, EGifPutExtensionLast, HAVE_GIF=yes, HAVE_GIF=maybe)])
3049   if test "$HAVE_GIF" = yes; then
3050     LIBGIF=-lgif
3051   elif test "$HAVE_GIF" = maybe; then
3052 # If gif_lib.h but no libgif, try libungif.
3053     AC_CHECK_LIB(ungif, EGifPutExtensionLast, HAVE_GIF=yes, HAVE_GIF=no)
3054     test "$HAVE_GIF" = yes && LIBGIF=-lungif
3055   fi
3057   if test "${HAVE_GIF}" = "yes"; then
3058     AC_DEFINE(HAVE_GIF, 1, [Define to 1 if you have a gif (or ungif) library.])
3059   fi
3061 AC_SUBST(LIBGIF)
3063 dnl Check for required libraries.
3064 if test "${HAVE_X11}" = "yes"; then
3065   MISSING=""
3066   WITH_NO=""
3067   test "${with_xpm}" != "no" && test "${HAVE_XPM}" != "yes" &&
3068     MISSING="libXpm" && WITH_NO="--with-xpm=no"
3069   test "${with_jpeg}" != "no" && test "${HAVE_JPEG}" != "yes" &&
3070     MISSING="$MISSING libjpeg" && WITH_NO="$WITH_NO --with-jpeg=no"
3071   test "${with_png}" != "no" && test "${HAVE_PNG}" != "yes" &&
3072     MISSING="$MISSING libpng" && WITH_NO="$WITH_NO --with-png=no"
3073   test "${with_gif}" != "no" && test "${HAVE_GIF}" != "yes" &&
3074     MISSING="$MISSING libgif/libungif" && WITH_NO="$WITH_NO --with-gif=no"
3075   test "${with_tiff}" != "no" && test "${HAVE_TIFF}" != "yes" &&
3076     MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no"
3078   if test "X${MISSING}" != X; then
3079     AC_MSG_ERROR([The following required libraries were not found:
3080     $MISSING
3081 Maybe some development libraries/packages are missing?
3082 If you don't want to link with them give
3083     $WITH_NO
3084 as options to configure])
3085   fi
3088 ### Use -lgpm if available, unless `--with-gpm=no'.
3089 HAVE_GPM=no
3090 LIBGPM=
3091 if test "${with_gpm}" != "no"; then
3092   AC_CHECK_HEADER(gpm.h,
3093     [AC_CHECK_LIB(gpm, Gpm_Open, HAVE_GPM=yes)])
3095   if test "${HAVE_GPM}" = "yes"; then
3096     AC_DEFINE(HAVE_GPM, 1, [Define to 1 if you have the gpm library (-lgpm).])
3097     LIBGPM=-lgpm
3098   fi
3100 AC_SUBST(LIBGPM)
3102 dnl Check for malloc/malloc.h on darwin
3103 AC_CHECK_HEADERS_ONCE(malloc/malloc.h)
3105 GNUSTEP_CFLAGS=
3106 ### Use NeXTstep API to implement GUI.
3107 if test "${HAVE_NS}" = "yes"; then
3108   AC_DEFINE(HAVE_NS, 1, [Define to 1 if you are using the NeXTstep API, either GNUstep or Cocoa on Mac OS X.])
3109   if test "${NS_IMPL_COCOA}" = "yes"; then
3110     AC_DEFINE(NS_IMPL_COCOA, 1, [Define to 1 if you are using NS windowing under MacOS X.])
3111   fi
3112   if test "${NS_IMPL_GNUSTEP}" = "yes"; then
3113     AC_DEFINE(NS_IMPL_GNUSTEP, 1, [Define to 1 if you are using NS windowing under GNUstep.])
3114     # See also .m.o rule in Makefile.in */
3115     # FIXME: are all these flags really needed?  Document here why.  */
3116     GNUSTEP_CFLAGS="-D_REENTRANT -fPIC -fno-strict-aliasing -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
3117     ## Extra CFLAGS applied to src/*.m files.
3118     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"
3119   fi
3120   # We also have mouse menus.
3121   HAVE_MENUS=yes
3122   OTHER_FILES=ns-app
3125 if test "${HAVE_W32}" = "yes"; then
3126   HAVE_MENUS=yes
3129 ### Use session management (-lSM -lICE) if available
3130 HAVE_X_SM=no
3131 LIBXSM=
3132 if test "${HAVE_X11}" = "yes"; then
3133   AC_CHECK_HEADER(X11/SM/SMlib.h,
3134     [AC_CHECK_LIB(SM, SmcOpenConnection, HAVE_X_SM=yes, , -lICE)])
3136   if test "${HAVE_X_SM}" = "yes"; then
3137     AC_DEFINE(HAVE_X_SM, 1, [Define to 1 if you have the SM library (-lSM).])
3138     LIBXSM="-lSM -lICE"
3139     case "$LIBS" in
3140       *-lSM*) ;;
3141       *)      LIBS="$LIBXSM $LIBS" ;;
3142     esac
3143   fi
3145 AC_SUBST(LIBXSM)
3147 ### Use XRandr (-lXrandr) if available
3148 HAVE_XRANDR=no
3149 if test "${HAVE_X11}" = "yes"; then
3150   XRANDR_REQUIRED=1.2.2
3151   XRANDR_MODULES="xrandr >= $XRANDR_REQUIRED"
3152   PKG_CHECK_MODULES(XRANDR, $XRANDR_MODULES, HAVE_XRANDR=yes, HAVE_XRANDR=no)
3153   if test $HAVE_XRANDR = no; then
3154     # Test old way in case pkg-config doesn't have it (older machines).
3155     AC_CHECK_HEADER(X11/extensions/Xrandr.h,
3156       [AC_CHECK_LIB(Xrandr, XRRGetScreenResources, HAVE_XRANDR=yes)])
3157     if test $HAVE_XRANDR = yes; then
3158       XRANDR_LIBS=-lXrandr
3159       AC_SUBST(XRANDR_LIBS)
3160     fi
3161   fi
3162   if test $HAVE_XRANDR = yes; then
3163     SAVE_CFLAGS="$CFLAGS"
3164     SAVE_LIBS="$LIBS"
3165     CFLAGS="$XRANDR_CFLAGS $CFLAGS"
3166     LIBS="$XRANDR_LIBS $LIBS"
3167     AC_CHECK_FUNCS(XRRGetOutputPrimary XRRGetScreenResourcesCurrent)
3168     CFLAGS="$SAVE_CFLAGS"
3169     LIBS="$SAVE_LIBS"
3171     AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you have the XRandr extension.])
3172   fi
3175 ### Use Xinerama (-lXinerama) if available
3176 HAVE_XINERAMA=no
3177 if test "${HAVE_X11}" = "yes"; then
3178   XINERAMA_REQUIRED=1.0.2
3179   XINERAMA_MODULES="xinerama >= $XINERAMA_REQUIRED"
3180   PKG_CHECK_MODULES(XINERAMA, $XINERAMA_MODULES, HAVE_XINERAMA=yes,
3181                     HAVE_XINERAMA=no)
3182   if test $HAVE_XINERAMA = no; then
3183     # Test old way in case pkg-config doesn't have it (older machines).
3184     AC_CHECK_HEADER(X11/extensions/Xinerama.h,
3185       [AC_CHECK_LIB(Xinerama, XineramaQueryExtension, HAVE_XINERAMA=yes)])
3186     if test $HAVE_XINERAMA = yes; then
3187       XINERAMA_LIBS=-lXinerama
3188       AC_SUBST(XINERAMA_LIBS)
3189     fi
3190   fi
3191   if test $HAVE_XINERAMA = yes; then
3192     AC_DEFINE(HAVE_XINERAMA, 1, [Define to 1 if you have the Xinerama extension.])
3193   fi
3197 ### Use libxml (-lxml2) if available
3198 ### mingw32 doesn't use -lxml2, since it loads the library dynamically.
3199 HAVE_LIBXML2=no
3200 if test "${with_xml2}" != "no"; then
3201   ### I'm not sure what the version number should be, so I just guessed.
3202   PKG_CHECK_MODULES(LIBXML2, libxml-2.0 > 2.6.17, HAVE_LIBXML2=yes, HAVE_LIBXML2=no)
3203   # Built-in libxml2 on OS X 10.8 lacks libxml-2.0.pc.
3204   if test "${HAVE_LIBXML2}" != "yes" -a "$opsys" = "darwin"; then
3205     SAVE_CPPFLAGS="$CPPFLAGS"
3206     CPPFLAGS="$CPPFLAGS -I/usr/include/libxml2"
3207     AC_CHECK_HEADER(libxml/HTMLparser.h,
3208       [AC_CHECK_DECL(HTML_PARSE_RECOVER, HAVE_LIBXML2=yes, ,
3209                      [#include <libxml/HTMLparser.h>])])
3210     CPPFLAGS="$SAVE_CPPFLAGS"
3211     if test "${HAVE_LIBXML2}" = "yes"; then
3212       LIBXML2_LIBS="-lxml2"
3213       LIBXML2_CFLAGS="-I/usr/include/libxml2"
3214     fi
3215   fi
3216   if test "${HAVE_LIBXML2}" = "yes"; then
3217     if test "${opsys}" != "mingw32"; then
3218       LIBS="$LIBXML2_LIBS $LIBS"
3219       AC_CHECK_LIB(xml2, htmlReadMemory, HAVE_LIBXML2=yes, HAVE_LIBXML2=no)
3220     else
3221       LIBXML2_LIBS=""
3222     fi
3223     if test "${HAVE_LIBXML2}" = "yes"; then
3224       AC_DEFINE(HAVE_LIBXML2, 1, [Define to 1 if you have the libxml library (-lxml2).])
3225     else
3226       LIBXML2_LIBS=""
3227       LIBXML2_CFLAGS=""
3228     fi
3229   fi
3231 AC_SUBST(LIBXML2_LIBS)
3232 AC_SUBST(LIBXML2_CFLAGS)
3234 # If netdb.h doesn't declare h_errno, we must declare it by hand.
3235 # On MinGW, that is provided by nt/inc/sys/socket.h and w32.c.
3236 if test "${opsys}" = "mingw32"; then
3237   emacs_cv_netdb_declares_h_errno=yes
3239 AC_CACHE_CHECK(whether netdb declares h_errno,
3240                emacs_cv_netdb_declares_h_errno,
3241 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
3242   [[return h_errno;]])],
3243   emacs_cv_netdb_declares_h_errno=yes, emacs_cv_netdb_declares_h_errno=no)])
3244 if test $emacs_cv_netdb_declares_h_errno = yes; then
3245   AC_DEFINE(HAVE_H_ERRNO, 1, [Define to 1 if netdb.h declares h_errno.])
3248 # sqrt and other floating-point functions such as fmod and frexp
3249 # are found in -lm on most systems, but mingw32 doesn't use -lm.
3250 if test "${opsys}" != "mingw32"; then
3251   AC_CHECK_LIB(m, sqrt)
3254 # Check for mail-locking functions in a "mail" library.  Probably this should
3255 # have the same check as for liblockfile below.
3256 AC_CHECK_LIB(mail, maillock, have_mail=yes, have_mail=no)
3257 if test $have_mail = yes; then
3258   LIBS_MAIL=-lmail
3259   LIBS="$LIBS_MAIL $LIBS"
3260   AC_DEFINE(HAVE_LIBMAIL, 1, [Define to 1 if you have the `mail' library (-lmail).])
3261 else
3262   LIBS_MAIL=
3264 dnl Debian, at least:
3265 AC_CHECK_LIB(lockfile, maillock, have_lockfile=yes, have_lockfile=no)
3266 if test $have_lockfile = yes; then
3267    LIBS_MAIL=-llockfile
3268    LIBS="$LIBS_MAIL $LIBS"
3269    AC_DEFINE(HAVE_LIBLOCKFILE, 1, [Define to 1 if you have the `lockfile' library (-llockfile).])
3270 else
3271 # If we have the shared liblockfile, assume we must use it for mail
3272 # locking (e.g. Debian).  If we couldn't link against liblockfile
3273 # (no liblockfile.a installed), ensure that we don't need to.
3274   dnl This works for files generally, not just executables.
3275   dnl Should we look elsewhere for it?  Maybe examine /etc/ld.so.conf?
3276   AC_CHECK_PROG(liblockfile, liblockfile.so, yes, no,
3277                 /usr/lib:/lib:/usr/local/lib:$LD_LIBRARY_PATH)
3278   if test $ac_cv_prog_liblockfile = yes; then
3279     AC_MSG_ERROR([Shared liblockfile found but can't link against it.
3280 This probably means that movemail could lose mail.
3281 There may be a `development' package to install containing liblockfile.])
3282   fi
3284 AC_CHECK_HEADERS_ONCE(maillock.h)
3285 AC_SUBST(LIBS_MAIL)
3287 ## Define MAIL_USE_FLOCK (or LOCKF) if the mailer uses flock (or lockf) to
3288 ## interlock access to the mail spool.  The alternative is a lock file named
3289 ## /usr/spool/mail/$USER.lock.
3290 mail_lock=no
3291 case "$opsys" in
3292   aix4-2) mail_lock="lockf" ;;
3294   gnu|freebsd|dragonfly|netbsd|openbsd|darwin|irix6-5) mail_lock="flock" ;;
3296   ## On GNU/Linux systems, both methods are used by various mail programs.
3297   ## I assume most people are using newer mailers that have heard of flock.
3298   ## Change this if you need to.
3299   ## Debian contains a patch which says: ``On Debian/GNU/Linux systems,
3300   ## configure gets the right answers, and that means *NOT* using flock.
3301   ## Using flock is guaranteed to be the wrong thing. See Debian Policy
3302   ## for details.'' and then uses `#ifdef DEBIAN'.  Unfortunately the
3303   ## Debian maintainer hasn't provided a clean fix for Emacs.
3304   ## movemail.c will use `maillock' when MAILDIR, HAVE_LIBMAIL and
3305   ## HAVE_MAILLOCK_H are defined, so the following appears to be the
3306   ## correct logic.  -- fx
3307   ## We must check for HAVE_LIBLOCKFILE too, as movemail does.
3308   ## liblockfile is a Free Software replacement for libmail, used on
3309   ## Debian systems and elsewhere. -rfr.
3310   gnu-*)
3311     mail_lock="flock"
3312     if test $have_mail = yes || test $have_lockfile = yes; then
3313       test $ac_cv_header_maillock_h = yes && mail_lock=no
3314     fi
3315     ;;
3317   mingw32)
3318     mail_lock="none-needed" ;;
3319 esac
3321 BLESSMAIL_TARGET=
3322 case "$mail_lock" in
3323   flock) AC_DEFINE(MAIL_USE_FLOCK, 1, [Define if the mailer uses flock to interlock the mail spool.]) ;;
3325   lockf) AC_DEFINE(MAIL_USE_LOCKF, 1, [Define if the mailer uses lockf to interlock the mail spool.]) ;;
3327   none-needed) ;;
3329   *) BLESSMAIL_TARGET="need-blessmail" ;;
3330 esac
3331 AC_SUBST(BLESSMAIL_TARGET)
3334 AC_CHECK_FUNCS(accept4 gethostname \
3335 getrusage get_current_dir_name \
3336 lrand48 \
3337 select getpagesize setlocale \
3338 getrlimit setrlimit shutdown getaddrinfo \
3339 strsignal setitimer \
3340 sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \
3341 gai_strerror getline getdelim sync \
3342 difftime posix_memalign \
3343 getpwent endpwent getgrent endgrent \
3344 touchlock \
3345 cfmakeraw cfsetspeed copysign __executable_start log2 prctl)
3347 ## Eric Backus <ericb@lsid.hp.com> says, HP-UX 9.x on HP 700 machines
3348 ## has a broken `rint' in some library versions including math library
3349 ## version number A.09.05.
3350 ## You can fix the math library by installing patch number PHSS_4630.
3351 ## But we can fix it more reliably for Emacs by just not using rint.
3352 ## We also skip HAVE_RANDOM - see comments in src/conf_post.h.
3353 case $opsys in
3354    hpux*) : ;;
3355    *) AC_CHECK_FUNCS(random rint) ;;
3356 esac
3358 dnl Cannot use AC_CHECK_FUNCS
3359 AC_CACHE_CHECK([for __builtin_unwind_init],
3360                emacs_cv_func___builtin_unwind_init,
3361 [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_unwind_init ();])],
3362                 emacs_cv_func___builtin_unwind_init=yes,
3363                 emacs_cv_func___builtin_unwind_init=no)])
3364 if test $emacs_cv_func___builtin_unwind_init = yes; then
3365   AC_DEFINE(HAVE___BUILTIN_UNWIND_INIT, 1,
3366             [Define to 1 if you have the `__builtin_unwind_init' function.])
3369 AC_CHECK_HEADERS_ONCE(sys/un.h)
3371 AC_FUNC_FSEEKO
3373 # UNIX98 PTYs.
3374 AC_CHECK_FUNCS(grantpt)
3376 # PTY-related GNU extensions.
3377 AC_CHECK_FUNCS(getpt posix_openpt)
3379 # Check this now, so that we will NOT find the above functions in ncurses.
3380 # That is because we have not set up to link ncurses in lib-src.
3381 # It's better to believe a function is not available
3382 # than to expect to find it in ncurses.
3383 # Also we need tputs and friends to be able to build at all.
3384 AC_MSG_CHECKING([for library containing tputs])
3385 # Run a test program that contains a call to tputs, a call that is
3386 # never executed.  This tests whether a pre-'main' dynamic linker
3387 # works with the library.  It's too much trouble to actually call
3388 # tputs in the test program, due to portability hassles.  When
3389 # cross-compiling, assume the test program will run if it links.
3390 AC_DEFUN([tputs_link_source], [
3391   AC_LANG_SOURCE(
3392      [[extern void tputs (const char *, int, int (*)(int));
3393        int main (int argc, char **argv)
3394        {
3395           if (argc == 10000)
3396             tputs (argv[0], 0, 0);
3397           return 0;
3398        }]])
3400 if test "${opsys}" = "mingw32"; then
3401   msg='none required'
3402 else
3403   # Maybe curses should be tried earlier?
3404   # See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9736#35
3405   for tputs_library in '' tinfo ncurses terminfo termcap curses; do
3406     OLIBS=$LIBS
3407     if test -z "$tputs_library"; then
3408       LIBS_TERMCAP=
3409       msg='none required'
3410     else
3411       LIBS_TERMCAP=-l$tputs_library
3412       msg=$LIBS_TERMCAP
3413       LIBS="$LIBS_TERMCAP $LIBS"
3414     fi
3415     AC_RUN_IFELSE([tputs_link_source], [], [msg=no],
3416       [AC_LINK_IFELSE([tputs_link_source], [], [msg=no])])
3417     LIBS=$OLIBS
3418     if test "X$msg" != Xno; then
3419       break
3420     fi
3421   done
3423 AC_MSG_RESULT([$msg])
3424 if test "X$msg" = Xno; then
3425   AC_MSG_ERROR([The required function `tputs' was not found in any library.
3426 The following libraries were tried (in order):
3427   libtinfo, libncurses, libterminfo, libtermcap, libcurses
3428 Please try installing whichever of these libraries is most appropriate
3429 for your system, together with its header files.
3430 For example, a libncurses-dev(el) or similar package.])
3433 ## Use termcap instead of terminfo?
3434 ## Only true for: freebsd < 40000, ms-w32, msdos, netbsd < 599002500.
3435 TERMINFO=yes
3436 ## FIXME?  In the cases below where we unconditionally set
3437 ## LIBS_TERMCAP="-lncurses", this overrides LIBS_TERMCAP = -ltinfo,
3438 ## if that was found above to have tputs.
3439 ## Should we use the gnu* logic everywhere?
3440 case "$opsys" in
3441   ## darwin: Prevents crashes when running Emacs in Terminal.app under 10.2.
3442   ##  The ncurses library has been moved out of the System framework in
3443   ##  Mac OS X 10.2.  So if configure detects it, set the command-line
3444   ##  option to use it.
3445   darwin) LIBS_TERMCAP="-lncurses" ;;
3447   gnu*) test -z "$LIBS_TERMCAP" && LIBS_TERMCAP="-lncurses" ;;
3449   freebsd)
3450     AC_MSG_CHECKING([whether FreeBSD is new enough to use terminfo])
3451     AC_CACHE_VAL(emacs_cv_freebsd_terminfo,
3452     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <osreldate.h>]],
3453 [[#if __FreeBSD_version < 400000
3454 fail;
3455 #endif
3456 ]])], emacs_cv_freebsd_terminfo=yes, emacs_cv_freebsd_terminfo=no)])
3458     AC_MSG_RESULT($emacs_cv_freebsd_terminfo)
3460     if test $emacs_cv_freebsd_terminfo = yes; then
3461       LIBS_TERMCAP="-lncurses"
3462     else
3463       TERMINFO=no
3464       LIBS_TERMCAP="-ltermcap"
3465     fi
3466     ;;
3468   mingw32)
3469     TERMINFO=no
3470     LIBS_TERMCAP=
3471     ;;
3473   netbsd)
3474     if test "x$LIBS_TERMCAP" != "x-lterminfo"; then
3475       TERMINFO=no
3476       LIBS_TERMCAP="-ltermcap"
3477     fi
3478     ;;
3480   openbsd | dragonfly) LIBS_TERMCAP="-lncurses" ;;
3482   ## hpux: Make sure we get select from libc rather than from libcurses
3483   ##  because libcurses on HPUX 10.10 has a broken version of select.
3484   ##  We used to use -lc -lcurses, but this may be cleaner.
3485   ## FIXME?  But TERMINFO = yes on hpux (it used to be explicitly
3486   # set that way, now it uses the default).  Isn't this a contradiction?
3487   hpux*) LIBS_TERMCAP="-ltermcap" ;;
3489 esac
3491 TERMCAP_OBJ=tparam.o
3492 if test $TERMINFO = yes; then
3493   AC_DEFINE(TERMINFO, 1, [Define to 1 if you use terminfo instead of termcap.])
3494   TERMCAP_OBJ=terminfo.o
3496 if test "X$LIBS_TERMCAP" = "X-lncurses"; then
3497   AC_DEFINE(USE_NCURSES, 1, [Define to 1 if you use ncurses.])
3499 AC_SUBST(LIBS_TERMCAP)
3500 AC_SUBST(TERMCAP_OBJ)
3503 # Do we have res_init, for detecting changes in /etc/resolv.conf?
3504 # On Darwin, res_init appears not to be useful: see bug#562 and
3505 # http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01467.html
3506 resolv=no
3508 if test $opsys != darwin; then
3510   AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>
3511 #include <arpa/nameser.h>
3512 #include <resolv.h>]],
3513     [[return res_init();]])],
3514     have_res_init=yes, have_res_init=no)
3515   if test "$have_res_init" = no; then
3516     OLIBS="$LIBS"
3517     LIBS="$LIBS -lresolv"
3518     AC_MSG_CHECKING(for res_init with -lresolv)
3519     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>
3520 #include <arpa/nameser.h>
3521 #include <resolv.h>]],
3522       [[return res_init();]])],
3523       have_res_init=yes, have_res_init=no)
3524     AC_MSG_RESULT($have_res_init)
3525     if test "$have_res_init" = yes ; then
3526       resolv=yes
3527     fi
3528     LIBS="$OLIBS"
3529   fi
3531   if test "$have_res_init" = yes; then
3532     AC_DEFINE(HAVE_RES_INIT, 1, [Define to 1 if res_init is available.])
3533   fi
3534 fi                              dnl !darwin
3536 # Do we need the Hesiod library to provide the support routines?
3537 dnl FIXME?  Should we be skipping this on Darwin too?
3538 LIBHESIOD=
3539 if test "$with_hesiod" != no ; then
3540   # Don't set $LIBS here -- see comments above.  FIXME which comments?
3541   AC_CHECK_FUNC(res_send, , [AC_CHECK_FUNC(__res_send, ,
3542      [AC_CHECK_LIB(resolv, res_send, resolv=yes,
3543                   [AC_CHECK_LIB(resolv, __res_send, resolv=yes)])])])
3544   if test "$resolv" = yes ; then
3545     RESOLVLIB=-lresolv
3546   else
3547     RESOLVLIB=
3548   fi
3549   AC_CHECK_FUNC(hes_getmailhost, , [AC_CHECK_LIB(hesiod, hes_getmailhost,
3550         hesiod=yes, :, $RESOLVLIB)])
3552   if test x"$hesiod" = xyes; then
3553     LIBHESIOD=-lhesiod
3554   fi
3556 AC_SUBST(LIBHESIOD)
3558 # Do we need libresolv (due to res_init or Hesiod)?
3559 if test "$resolv" = yes && test $opsys != darwin; then
3560   LIBRESOLV=-lresolv
3561 else
3562   LIBRESOLV=
3564 AC_SUBST(LIBRESOLV)
3566 # These tell us which Kerberos-related libraries to use.
3567 COM_ERRLIB=
3568 CRYPTOLIB=
3569 KRB5LIB=
3570 DESLIB=
3571 KRB4LIB=
3573 if test "${with_kerberos}" != no; then
3574   AC_CHECK_LIB(com_err, com_err, have_com_err=yes, have_com_err=no)
3575   if test $have_com_err = yes; then
3576     COM_ERRLIB=-lcom_err
3577     LIBS="$COM_ERRLIB $LIBS"
3578   fi
3579   AC_CHECK_LIB(crypto, mit_des_cbc_encrypt, have_crypto=yes, have_crypto=no)
3580   if test $have_crypto = yes; then
3581     CRYPTOLIB=-lcrypto
3582     LIBS="$CRYPTOLIB $LIBS"
3583   fi
3584   AC_CHECK_LIB(k5crypto, mit_des_cbc_encrypt, have_k5crypto=yes, have_k5crypto=no)
3585   if test $have_k5crypto = yes; then
3586     CRYPTOLIB=-lk5crypto
3587     LIBS="$CRYPTOLIB $LIBS"
3588   fi
3589   AC_CHECK_LIB(krb5, krb5_init_context, have_krb5=yes, have_krb5=no)
3590   if test $have_krb5=yes; then
3591     KRB5LIB=-lkrb5
3592     LIBS="$KRB5LIB $LIBS"
3593   fi
3594   dnl FIXME Simplify.  Does not match 22 logic, thanks to default_off?
3595   if test "${with_kerberos5}" = no; then
3596     AC_CHECK_LIB(des425, des_cbc_encrypt, have_des425=yes, have_des425=no )
3597     if test $have_des425 = yes; then
3598       DESLIB=-ldes425
3599       LIBS="$DESLIB $LIBS"
3600     else
3601       AC_CHECK_LIB(des, des_cbc_encrypt, have_des=yes, have_des=no)
3602       if test $have_des = yes; then
3603         DESLIB=-ldes
3604         LIBS="$DESLIB $LIBS"
3605       fi
3606     fi
3607     AC_CHECK_LIB(krb4, krb_get_cred, have_krb4=yes, have_krb4=no)
3608     if test $have_krb4 = yes; then
3609       KRB4LIB=-lkrb4
3610       LIBS="$KRB4LIB $LIBS"
3611     else
3612       AC_CHECK_LIB(krb, krb_get_cred, have_krb=yes, have_krb=no)
3613       if test $have_krb = yes; then
3614         KRB4LIB=-lkrb
3615         LIBS="$KRB4LIB $LIBS"
3616       fi
3617     fi
3618   fi
3620   if test "${with_kerberos5}" != no; then
3621     AC_CHECK_HEADERS(krb5.h,
3622       [AC_CHECK_MEMBERS([krb5_error.text, krb5_error.e_text],,,
3623                         [#include <krb5.h>])])
3624   else
3625     AC_CHECK_HEADERS(krb.h,,
3626                      [AC_CHECK_HEADERS(kerberosIV/krb.h,,
3627                                        [AC_CHECK_HEADERS(kerberos/krb.h)])])
3628   fi
3629   AC_CHECK_HEADERS(com_err.h)
3632 AC_SUBST(COM_ERRLIB)
3633 AC_SUBST(CRYPTOLIB)
3634 AC_SUBST(KRB5LIB)
3635 AC_SUBST(DESLIB)
3636 AC_SUBST(KRB4LIB)
3638 AC_CHECK_FUNCS_ONCE(tzset)
3639 AC_MSG_CHECKING(whether localtime caches TZ)
3640 AC_CACHE_VAL(emacs_cv_localtime_cache,
3641 [if test x$ac_cv_func_tzset = xyes; then
3642 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <time.h>
3643 char TZ_GMT0[] = "TZ=GMT0";
3644 char TZ_PST8[] = "TZ=PST8";
3645 main()
3647   time_t now = time ((time_t *) 0);
3648   int hour_GMT0, hour_unset;
3649   if (putenv (TZ_GMT0) != 0)
3650     exit (1);
3651   hour_GMT0 = localtime (&now)->tm_hour;
3652   unsetenv("TZ");
3653   hour_unset = localtime (&now)->tm_hour;
3654   if (putenv (TZ_PST8) != 0)
3655     exit (1);
3656   if (localtime (&now)->tm_hour == hour_GMT0)
3657     exit (1);
3658   unsetenv("TZ");
3659   if (localtime (&now)->tm_hour != hour_unset)
3660     exit (1);
3661   exit (0);
3662 }]])], emacs_cv_localtime_cache=no, emacs_cv_localtime_cache=yes,
3663 [# If we have tzset, assume the worst when cross-compiling.
3664 emacs_cv_localtime_cache=yes])
3665 else
3666         # If we lack tzset, report that localtime does not cache TZ,
3667         # since we can't invalidate the cache if we don't have tzset.
3668         emacs_cv_localtime_cache=no
3669 fi])dnl
3670 AC_MSG_RESULT($emacs_cv_localtime_cache)
3671 if test $emacs_cv_localtime_cache = yes; then
3672   AC_DEFINE(LOCALTIME_CACHE, 1,
3673             [Define to 1 if localtime caches TZ.])
3676 ok_so_far=yes
3677 AC_CHECK_FUNC(socket, , ok_so_far=no)
3678 if test $ok_so_far = yes; then
3679   AC_CHECK_HEADER(netinet/in.h, , ok_so_far=no)
3681 if test $ok_so_far = yes; then
3682   AC_CHECK_HEADER(arpa/inet.h, , ok_so_far=no)
3684 if test $ok_so_far = yes; then
3685 dnl Fixme: Not used.  Should this be HAVE_SOCKETS?
3686   AC_DEFINE(HAVE_INET_SOCKETS, 1,
3687             [Define to 1 if you have inet sockets.])
3690 dnl Check for a Solaris 2.4 vfork bug that Autoconf misses (through 2.69).
3691 dnl This can be removed once we assume Autoconf 2.70.
3692 case $canonical in
3693   *-solaris2.4 | *-solaris2.4.*)
3694     dnl Disable the Autoconf-generated vfork test.
3695     : ${ac_cv_func_vfork_works=no};;
3696 esac
3698 AC_FUNC_FORK
3700 AC_CHECK_FUNCS(snprintf)
3702 dnl Check this late.  It depends on what other libraries (lrsvg, Gtk+ etc)
3703 dnl Emacs uses.
3704 XGSELOBJ=
3705 AC_MSG_CHECKING([whether GLib is linked in])
3706 AC_LINK_IFELSE([AC_LANG_PROGRAM(
3707         [[#include <glib.h>
3708         ]],
3709         [[g_print ("Hello world");]])],
3710      [links_glib=yes],
3711      [links_glib=no])
3712 AC_MSG_RESULT([$links_glib])
3713 if test "${links_glib}" = "yes"; then
3714   AC_DEFINE(HAVE_GLIB, 1, [Define to 1 if GLib is linked in.])
3715   if test "$HAVE_NS" = no;then
3716     XGSELOBJ=xgselect.o
3717   fi
3719 AC_SUBST(XGSELOBJ)
3721 dnl Adapted from Haible's version.
3722 AC_CACHE_CHECK([for nl_langinfo and CODESET], emacs_cv_langinfo_codeset,
3723   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
3724     [[char* cs = nl_langinfo(CODESET);]])],
3725     emacs_cv_langinfo_codeset=yes,
3726     emacs_cv_langinfo_codeset=no)
3727   ])
3728 if test $emacs_cv_langinfo_codeset = yes; then
3729   AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
3730     [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
3733 AC_TYPE_MBSTATE_T
3735 AC_CACHE_CHECK([for C restricted array declarations], emacs_cv_c_restrict_arr,
3736   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void fred (int x[__restrict]);]], [[]])],
3737                   emacs_cv_c_restrict_arr=yes, emacs_cv_c_restrict_arr=no)])
3738 if test "$emacs_cv_c_restrict_arr" = yes; then
3739   AC_DEFINE(__restrict_arr, __restrict,
3740     [Define to compiler's equivalent of C99 restrict keyword in array
3741      declarations.  Define as empty for no equivalent.])
3744 dnl Fixme: AC_SYS_POSIX_TERMIOS should probably be used, but it's not clear
3745 dnl how the tty code is related to POSIX and/or other versions of termios.
3746 dnl The following looks like a useful start.
3748 dnl AC_SYS_POSIX_TERMIOS
3749 dnl if test $ac_cv_sys_posix_termios = yes; then
3750 dnl    AC_DEFINE(HAVE_TERMIOS, 1, [Define to 1 if you have POSIX-style functions
3751 dnl                                and macros for terminal control.])
3752 dnl    AC_DEFINE(HAVE_TCATTR, 1, [Define to 1 if you have tcgetattr and tcsetattr.])
3753 dnl fi
3755 dnl Turned on June 1996 supposing nobody will mind it.
3756 dnl MinGW emulates passwd database, so this feature doesn't make sense there.
3757 if test "${opsys}" != "mingw32"; then
3758    AC_DEFINE(AMPERSAND_FULL_NAME, 1, [Define to use the convention that &
3759      in the full name stands for the login id.])
3762 dnl Every platform that uses configure supports this.
3763 dnl There is a create-lockfiles option you can
3764 dnl customize if you do not want the lock files to be written.
3765 dnl So it is not clear that this #define still needs to exist.
3766 AC_DEFINE(CLASH_DETECTION, 1, [Define if you want lock files to be written,
3767   so that Emacs can tell instantly when you try to modify a file that
3768   someone else has modified in his/her Emacs.])
3770 dnl Everybody supports this, except MS.
3771 dnl Seems like the kind of thing we should be testing for, though.
3772 ## Note: PTYs are broken on darwin <6.  Use at your own risk.
3773 if test "${opsys}" != "mingw32"; then
3774   AC_DEFINE(HAVE_PTYS, 1, [Define if the system supports pty devices.])
3777 dnl Everybody supports this, except MS-DOS.
3778 dnl Seems like the kind of thing we should be testing for, though.
3779 dnl Compare with HAVE_INET_SOCKETS (which is unused...) above.
3780 AC_DEFINE(HAVE_SOCKETS, 1, [Define if the system supports
3781   4.2-compatible sockets.])
3783 AH_TEMPLATE(INTERNAL_TERMINAL, [This is substituted when $TERM is "internal".])
3785 AH_TEMPLATE(NULL_DEVICE, [Name of the file to open to get
3786   a null file, or a data sink.])
3787 if test "${opsys}" = "mingw32"; then
3788   AC_DEFINE(NULL_DEVICE, ["NUL:"])
3789 else
3790   AC_DEFINE(NULL_DEVICE, ["/dev/null"])
3793 AH_TEMPLATE(SEPCHAR, [Character that separates PATH elements.])
3794 if test "${opsys}" = "mingw32"; then
3795   AC_DEFINE(SEPCHAR, [';'])
3796 else
3797   AC_DEFINE(SEPCHAR, [':'])
3800 dnl Everybody supports this, except MS-DOS.
3801 AC_DEFINE(subprocesses, 1, [Define to enable asynchronous subprocesses.])
3803 AC_DEFINE(USER_FULL_NAME, [pw->pw_gecos], [How to get a user's full name.])
3806 AC_DEFINE(DIRECTORY_SEP, ['/'],
3807   [Character that separates directories in a file name.])
3809 if test "${opsys}" = "mingw32"; then
3810   AC_DEFINE(IS_DEVICE_SEP(_c_), [((_c_) == ':')],
3811     [Returns true if character is a device separator.])
3813   AC_DEFINE(IS_DIRECTORY_SEP(_c_), [((_c_) == '/' || (_c_) == '\\')],
3814     [Returns true if character is a directory separator.])
3816   AC_DEFINE(IS_ANY_SEP(_c_), [(IS_DIRECTORY_SEP (_c_) || IS_DEVICE_SEP(_c_))],
3817     [Returns true if character is any form of separator.])
3818 else
3819   AC_DEFINE(IS_DEVICE_SEP(_c_), 0,
3820     [Returns true if character is a device separator.])
3822   AC_DEFINE(IS_DIRECTORY_SEP(_c_), [((_c_) == DIRECTORY_SEP)],
3823     [Returns true if character is a directory separator.])
3825   AC_DEFINE(IS_ANY_SEP(_c_), [(IS_DIRECTORY_SEP (_c_))],
3826     [Returns true if character is any form of separator.])
3829 AH_TEMPLATE(NO_EDITRES, [Define if XEditRes should not be used.])
3831 case $opsys in
3832   aix4-2)
3833     dnl Unfortunately without libXmu we cannot support EditRes.
3834     if test x$ac_cv_lib_Xmu_XmuConvertStandardSelection != xyes; then
3835       AC_DEFINE(NO_EDITRES, 1)
3836     fi
3837     ;;
3839   hpux*)
3840     dnl Assar Westerlund <assar@sics.se> says this is necessary for
3841     dnl HP-UX 10.20, and that it works for HP-UX 0 as well.
3842     AC_DEFINE(NO_EDITRES, 1)
3843     ;;
3844 esac
3847 case $opsys in
3848   irix6-5 | sol2* | unixware )
3849     dnl Some SVr4s don't define NSIG in sys/signal.h for ANSI environments;
3850     dnl instead, there's a system variable _sys_nsig.  Unfortunately, we
3851     dnl need the constant to dimension an array.  So wire in the appropriate
3852     dnl value here.
3853     AC_DEFINE(NSIG_MINIMUM, 32, [Minimum value of NSIG.])
3854     ;;
3855 esac
3857 emacs_broken_SIGIO=no
3859 case $opsys in
3860   dnl SIGIO exists, but the feature doesn't work in the way Emacs needs.
3861   dnl See eg <http://article.gmane.org/gmane.os.openbsd.ports/46831>.
3862   hpux* | irix6-5 | openbsd | sol2* | unixware | gnu-kfreebsd )
3863     emacs_broken_SIGIO=yes
3864     ;;
3866   aix4-2)
3867     dnl On AIX Emacs uses the gmalloc.c malloc implementation.  But given
3868     dnl the way this system works, libc functions that return malloced
3869     dnl memory use the libc malloc implementation. Calling xfree or
3870     dnl xrealloc on the results of such functions results in a crash.
3871     dnl
3872     dnl One solution for this could be to define SYSTEM_MALLOC in configure,
3873     dnl but that does not currently work on this system.
3874     dnl
3875     dnl It is possible to completely override the malloc implementation on
3876     dnl AIX, but that involves putting the malloc functions in a shared
3877     dnl library and setting the MALLOCTYPE environment variable to point to
3878     dnl that shared library.
3879     dnl
3880     dnl Emacs currently calls xrealloc on the results of get_current_dir name,
3881     dnl to avoid a crash just use the Emacs implementation for that function.
3882     dnl
3883     dnl FIXME We could change the AC_CHECK_FUNCS call near the start
3884     dnl of this file, so that we do not check for get_current_dir_name
3885     dnl on AIX.  But that might be fragile if something else ends
3886     dnl up testing for get_current_dir_name as a dependency.
3887     AC_DEFINE(BROKEN_GET_CURRENT_DIR_NAME, 1, [Define if
3888       get_current_dir_name should not be used.])
3889     ;;
3891   freebsd)
3892     dnl Circumvent a bug in FreeBSD.  In the following sequence of
3893     dnl writes/reads on a PTY, read(2) returns bogus data:
3894     dnl
3895     dnl write(2)  1022 bytes
3896     dnl write(2)   954 bytes, get EAGAIN
3897     dnl read(2)   1024 bytes in process_read_output
3898     dnl read(2)     11 bytes in process_read_output
3899     dnl
3900     dnl That is, read(2) returns more bytes than have ever been written
3901     dnl successfully.  The 1033 bytes read are the 1022 bytes written
3902     dnl successfully after processing (for example with CRs added if the
3903     dnl terminal is set up that way which it is here).  The same bytes will
3904     dnl be seen again in a later read(2), without the CRs.
3905     AC_DEFINE(BROKEN_PTY_READ_AFTER_EAGAIN, 1, [Define on FreeBSD to
3906       work around an issue when reading from a PTY.])
3907     ;;
3908 esac
3910 case $opsys in
3911   gnu-* | sol2-10 )
3912     dnl FIXME Can't we test if this exists (eg /proc/$$)?
3913     AC_DEFINE(HAVE_PROCFS, 1, [Define if you have the /proc filesystem.])
3914   ;;
3915 esac
3917 case $opsys in
3918   darwin | dragonfly | freebsd | netbsd | openbsd )
3919     AC_DEFINE(DONT_REOPEN_PTY, 1, [Define if process.c does not need to
3920       close a pty to make it a controlling terminal (it is already a
3921       controlling terminal of the subprocess, because we did ioctl TIOCSCTTY).])
3922   ;;
3923 esac
3925 dnl FIXME Surely we can test for this rather than hard-code it.
3926 case $opsys in
3927   netbsd | openbsd) sound_device="/dev/audio" ;;
3928   *) sound_device="/dev/dsp" ;;
3929 esac
3931 dnl Used in sound.c
3932 AC_DEFINE_UNQUOTED(DEFAULT_SOUND_DEVICE, "$sound_device",
3933   [Name of the default sound device.])
3936 dnl Emacs can read input using SIGIO and buffering characters itself,
3937 dnl or using CBREAK mode and making C-g cause SIGINT.
3938 dnl The choice is controlled by the variable interrupt_input.
3940 dnl Define INTERRUPT_INPUT to make interrupt_input = 1 the default (use SIGIO)
3942 dnl Emacs uses the presence of the USABLE_SIGIO macro
3943 dnl to indicate whether or not signal-driven I/O is possible.  It uses
3944 dnl INTERRUPT_INPUT to decide whether to use it by default.
3946 dnl SIGIO can be used only on systems that implement it (4.2 and 4.3).
3947 dnl CBREAK mode has two disadvantages
3948 dnl 1) At least in 4.2, it is impossible to handle the Meta key properly.
3949 dnl I hear that in system V this problem does not exist.
3950 dnl 2) Control-G causes output to be discarded.
3951 dnl I do not know whether this can be fixed in system V.
3953 dnl Another method of doing input is planned but not implemented.
3954 dnl It would have Emacs fork off a separate process
3955 dnl to read the input and send it to the true Emacs process
3956 dnl through a pipe.
3957 case $opsys in
3958   darwin | gnu-linux | gnu-kfreebsd )
3959     AC_DEFINE(INTERRUPT_INPUT, 1, [Define to read input using SIGIO.])
3960   ;;
3961 esac
3964 dnl If the system's imake configuration file defines `NeedWidePrototypes'
3965 dnl as `NO', we must define NARROWPROTO manually.  Such a define is
3966 dnl generated in the Makefile generated by `xmkmf'.  If we don't define
3967 dnl NARROWPROTO, we will see the wrong function prototypes for X functions
3968 dnl taking float or double parameters.
3969 case $opsys in
3970   cygwin|gnu|gnu-linux|gnu-kfreebsd|irix6-5|freebsd|netbsd|openbsd)
3971     AC_DEFINE(NARROWPROTO, 1, [Define if system's imake configuration
3972       file defines `NeedWidePrototypes' as `NO'.])
3973   ;;
3974 esac
3977 dnl Used in process.c, this must be a loop, even if it only runs once.
3978 dnl (Except on SGI; see below.  Take that, clarity and consistency!)
3979 AH_TEMPLATE(PTY_ITERATION, [How to iterate over PTYs.])
3980 dnl Only used if !PTY_ITERATION.  Iterate from FIRST_PTY_LETTER to z,
3981 dnl trying suffixes 0-16.
3982 AH_TEMPLATE(FIRST_PTY_LETTER, [Letter to use in finding device name of
3983   first PTY, if PTYs are supported.])
3984 AH_TEMPLATE(PTY_OPEN, [How to open a PTY, if non-standard.])
3985 AH_TEMPLATE(PTY_NAME_SPRINTF, [How to get the device name of the control
3986   end of a PTY, if non-standard.])
3987 AH_TEMPLATE(PTY_TTY_NAME_SPRINTF, [How to get device name of the tty
3988   end of a PTY, if non-standard.])
3990 case $opsys in
3991   aix4-2 )
3992     AC_DEFINE(PTY_ITERATION, [int c; for (c = 0; !c ; c++)])
3993     dnl You allocate a pty by opening /dev/ptc to get the master side.
3994     dnl To get the name of the slave side, you just ttyname() the master side.
3995     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptc");])
3996     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [strcpy (pty_name, ttyname (fd));])
3997     ;;
3999   cygwin )
4000     AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
4001     dnl multi-line AC_DEFINEs are hard. :(
4002     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 (0)])
4003     AC_DEFINE(PTY_NAME_SPRINTF, [])
4004     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
4005     ;;
4007   dnl FIXME?  Maybe use same as freebsd - see bug#12040.
4008   darwin )
4009     AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
4010     dnl Not used, because PTY_ITERATION is defined.
4011     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
4012     dnl Note that openpty may fork via grantpt on Mac OS X 10.4/Darwin 8.
4013     dnl But we don't have to block SIGCHLD because it is blocked in the
4014     dnl implementation of grantpt.
4015     AC_DEFINE(PTY_OPEN, [ do { int slave; if (openpty (&fd, &slave, pty_name, NULL, NULL) == -1) fd = -1; else emacs_close (slave); } while (0)])
4016     AC_DEFINE(PTY_NAME_SPRINTF, [])
4017     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
4018     ;;
4020   gnu | openbsd )
4021     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
4022     ;;
4024   gnu-linux | gnu-kfreebsd | dragonfly | freebsd | netbsd )
4025     dnl if HAVE_GRANTPT
4026     if test "x$ac_cv_func_grantpt" = xyes; then
4027       AC_DEFINE(UNIX98_PTYS, 1, [Define if the system has Unix98 PTYs.])
4028       AC_DEFINE(PTY_ITERATION, [int i; for (i = 0; i < 1; i++)])
4029       dnl Note that grantpt and unlockpt may fork.  We must block SIGCHLD
4030       dnl to prevent sigchld_handler from intercepting the child's death.
4031       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); }])
4032       dnl if HAVE_POSIX_OPENPT
4033       if test "x$ac_cv_func_posix_openpt" = xyes; then
4034         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 (0)])
4035         AC_DEFINE(PTY_NAME_SPRINTF, [])
4036       dnl if HAVE_GETPT
4037       elif test "x$ac_cv_func_getpt" = xyes; then
4038         AC_DEFINE(PTY_OPEN, [fd = getpt ()])
4039         AC_DEFINE(PTY_NAME_SPRINTF, [])
4040       else
4041         AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");])
4042       fi
4043     else
4044       AC_DEFINE(FIRST_PTY_LETTER, ['p'])
4045     fi
4046     ;;
4048   hpux*)
4049     AC_DEFINE(FIRST_PTY_LETTER, ['p'])
4050     AC_DEFINE(PTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);])
4051     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [sprintf (pty_name, "/dev/pty/tty%c%x", c, i);])
4052     ;;
4054   irix6-5 )
4055     dnl It looks like this cannot be right, because it is not a loop.
4056     dnl However, process.c actually does this:
4057     dnl # ifndef __sgi
4058     dnl   continue;
4059     dnl # else
4060     dnl   return -1;
4061     dnl # endif
4062     dnl which presumably makes it OK, since irix == sgi (?).
4063     dnl FIXME it seems like this special treatment is unnecessary?
4064     dnl Why can't irix use a single-trip loop like eg cygwin?
4065     AC_DEFINE(PTY_ITERATION, [])
4066     dnl Not used, because PTY_ITERATION is defined.
4067     AC_DEFINE(FIRST_PTY_LETTER, ['q'])
4068     AC_DEFINE(PTY_OPEN, [ { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCHLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCHLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }])
4069     dnl No need to get the pty name at all.
4070     AC_DEFINE(PTY_NAME_SPRINTF, [])
4071     dnl No need to use sprintf to get the tty name--we get that from _getpty.
4072     AC_DEFINE(PTY_TTY_NAME_SPRINTF, [])
4073     ;;
4075   sol2* )
4076     dnl On SysVr4, grantpt(3) forks a subprocess, so keep sigchld_handler()
4077     dnl from intercepting that death.  If any child but grantpt's should die
4078     dnl within, it should be caught after sigrelse(2).
4079     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); }])
4080     ;;
4082   unixware )
4083     dnl Comments are as per sol2*.
4084     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); }])
4085     ;;
4086 esac
4089 case $opsys in
4090   sol2* | unixware )
4091     dnl This change means that we don't loop through allocate_pty too
4092     dnl many times in the (rare) event of a failure.
4093     AC_DEFINE(FIRST_PTY_LETTER, ['z'])
4094     AC_DEFINE(PTY_NAME_SPRINTF, [strcpy (pty_name, "/dev/ptmx");])
4095     dnl Push various streams modules onto a PTY channel.  Used in process.c.
4096     AC_DEFINE(SETUP_SLAVE_PTY, [if (ioctl (xforkin, I_PUSH, "ptem") == -1) fatal ("ioctl I_PUSH ptem"); if (ioctl (xforkin, I_PUSH, "ldterm") == -1) fatal ("ioctl I_PUSH ldterm"); if (ioctl (xforkin, I_PUSH, "ttcompat") == -1) fatal ("ioctl I_PUSH ttcompat");], [How to set up a slave PTY, if needed.])
4097     ;;
4098 esac
4101 AH_TEMPLATE(SIGNALS_VIA_CHARACTERS, [Make process_send_signal work by
4102 "typing" a signal character on the pty.])
4104 case $opsys in
4105   dnl Perry Smith <pedz@ddivt1.austin.ibm.com> says this is correct for AIX.
4106   dnl thomas@mathematik.uni-bremen.de says this is needed for IRIX.
4107   aix4-2 | cygwin | gnu | irix6-5 | dragonfly | freebsd | netbsd | openbsd | darwin )
4108     AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1)
4109     ;;
4111   dnl 21 Jun 06: Eric Hanchrow <offby1@blarg.net> says this works.
4112   dnl FIXME Does gnu-kfreebsd have linux/version.h?  It seems unlikely...
4113   gnu-linux | gnu-kfreebsd )
4115     AC_MSG_CHECKING([for signals via characters])
4116     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4117 #include <linux/version.h>
4118 #if LINUX_VERSION_CODE < 0x20400
4119 # error "Linux version too old"
4120 #endif
4121       ]], [[]])], emacs_signals_via_chars=yes, emacs_signals_via_chars=no)
4123     AC_MSG_RESULT([$emacs_signals_via_chars])
4124     test $emacs_signals_via_chars = yes && AC_DEFINE(SIGNALS_VIA_CHARACTERS, 1)
4125     ;;
4126 esac
4129 dnl Used in lisp.h, emacs.c, vm-limit.c
4130 dnl NEWS.18 describes this as "a number which contains
4131 dnl the high bits to be inclusive or'ed with pointers that are unpacked."
4132 AH_TEMPLATE(DATA_SEG_BITS, [Extra bits to be or'd in with any pointers
4133 stored in a Lisp_Object.])
4134 dnl if Emacs uses fewer than 32 bits for the value field of a LISP_OBJECT.
4136 case $opsys in
4137   aix*)
4138     dnl This works with 32-bit executables; Emacs doesn't support 64-bit.
4139     AC_DEFINE(DATA_SEG_BITS, [0x20000000])
4140     ;;
4141   hpux*)
4142     dnl The data segment on this machine always starts at address 0x40000000.
4143     AC_DEFINE(DATA_SEG_BITS, [0x40000000])
4144     ;;
4145   irix6-5)
4146     AC_DEFINE(DATA_SEG_BITS, [0x10000000])
4147     ;;
4148 esac
4151 AH_TEMPLATE(TAB3, [Undocumented.])
4153 case $opsys in
4154   darwin) AC_DEFINE(TAB3, OXTABS) ;;
4156   gnu | dragonfly | freebsd | netbsd | openbsd )
4157     AC_DEFINE(TABDLY, OXTABS, [Undocumented.])
4158     AC_DEFINE(TAB3, OXTABS)
4159     ;;
4161   gnu-linux | gnu-kfreebsd )
4162     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4163 #ifndef __ia64__
4164 # error "not ia64"
4165 #endif
4166       ]], [[]])], AC_DEFINE(GC_MARK_SECONDARY_STACK(),
4167         [do { extern void *__libc_ia64_register_backing_store_base; __builtin_ia64_flushrs (); mark_memory (__libc_ia64_register_backing_store_base, __builtin_ia64_bsp ());} while (0)],
4168         [Mark a secondary stack, like the register stack on the ia64.]), [])
4169     ;;
4171   hpux*)
4172     AC_DEFINE(RUN_TIME_REMAP, 1, [Define if emacs.c needs to call
4173       run_time_remap; for HPUX.])
4174     ;;
4175 esac
4178 dnl This won't be used automatically yet.  We also need to know, at least,
4179 dnl that the stack is continuous.
4180 AH_TEMPLATE(GC_SETJMP_WORKS, [Define if setjmp is known to save all
4181   registers relevant for conservative garbage collection in the jmp_buf.])
4184 case $opsys in
4185   dnl Not all the architectures are tested, but there are Debian packages
4186   dnl for SCM and/or Guile on them, so the technique must work.  See also
4187   dnl comments in alloc.c concerning setjmp and gcc.
4188   dnl Fixme: it's probably safe to just use the GCC conditional below.
4189   gnu-linux | gnu-kfreebsd )
4190     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4191 #if defined __i386__ || defined __sparc__ || defined __mc68000__ \
4192   || defined __alpha__ || defined __mips__ || defined __s390__ \
4193   || defined __arm__ || defined __powerpc__ || defined __amd64__ \
4194   || defined __ia64__ || defined __sh__
4195 /* ok */
4196 #else
4197 # error "setjmp not known to work on this arch"
4198 #endif
4199     ]], [[]])], AC_DEFINE(GC_SETJMP_WORKS, 1))
4200     ;;
4201 esac
4204 if test x$GCC = xyes; then
4205    dnl GC_SETJMP_WORKS is nearly always appropriate for GCC.
4206    AC_DEFINE(GC_SETJMP_WORKS, 1)
4207 else
4208   case $opsys in
4209     dnl irix: Tested on Irix 6.5.  SCM worked on earlier versions.
4210     dragonfly | freebsd | netbsd | openbsd | irix6-5 | sol2* )
4211       AC_DEFINE(GC_SETJMP_WORKS, 1)
4212       ;;
4213   esac
4214 fi                              dnl GCC?
4216 dnl In a weird quirk, MS runtime uses _setjmp and longjmp.
4217 AC_CACHE_CHECK([for _setjmp], [emacs_cv_func__setjmp],
4218   [AC_LINK_IFELSE(
4219      [AC_LANG_PROGRAM(
4220        [[#include <setjmp.h>
4221          #ifdef __MINGW32__
4222          # define _longjmp longjmp
4223          #endif
4224        ]],
4225        [[jmp_buf j;
4226          if (! _setjmp (j))
4227            _longjmp (j, 1);]])],
4228      [emacs_cv_func__setjmp=yes],
4229      [emacs_cv_func__setjmp=no])])
4230 if test $emacs_cv_func__setjmp = yes; then
4231   AC_DEFINE([HAVE__SETJMP], 1, [Define to 1 if _setjmp and _longjmp work.])
4232 else
4233   AC_CACHE_CHECK([for sigsetjmp], [emacs_cv_func_sigsetjmp],
4234     [AC_LINK_IFELSE(
4235        [AC_LANG_PROGRAM(
4236          [[#include <setjmp.h>
4237          ]],
4238          [[sigjmp_buf j;
4239            if (! sigsetjmp (j, 1))
4240              siglongjmp (j, 1);]])],
4241        [emacs_cv_func_sigsetjmp=yes],
4242        [emacs_cv_func_sigsetjmp=no])])
4243   if test $emacs_cv_func_sigsetjmp = yes; then
4244     AC_DEFINE([HAVE_SIGSETJMP], 1,
4245       [Define to 1 if sigsetjmp and siglongjmp work.
4246        The value of this symbol is irrelevant if HAVE__SETJMP is defined.])
4247   fi
4250 case $opsys in
4251   sol2* | unixware )
4252     dnl TIOCGPGRP is broken in SysVr4, so we can't send signals to PTY
4253     dnl subprocesses the usual way.  But TIOCSIGNAL does work for PTYs,
4254     dnl and this is all we need.
4255     AC_DEFINE(TIOCSIGSEND, TIOCSIGNAL, [Some platforms redefine this.])
4256     ;;
4257 esac
4260 case $opsys in
4261   hpux* | sol2* )
4262     dnl Used in xfaces.c.
4263     AC_DEFINE(XOS_NEEDS_TIME_H, 1, [Compensate for a bug in Xos.h on
4264       some systems, where it requires time.h.])
4265     ;;
4266 esac
4269 dnl Define symbols to identify the version of Unix this is.
4270 dnl Define all the symbols that apply correctly.
4271 AH_TEMPLATE(DOS_NT, [Define if the system is MS DOS or MS Windows.])
4272 AH_TEMPLATE(MSDOS, [Define if the system is MS DOS.])
4273 AH_TEMPLATE(USG, [Define if the system is compatible with System III.])
4274 AH_TEMPLATE(USG5_4, [Define if the system is compatible with System V Release 4.])
4276 case $opsys in
4277   aix4-2)
4278     AC_DEFINE(USG, [])
4279     dnl This symbol should be defined on AIX Version 3  ???????
4280     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
4281 #ifndef _AIX
4282 # error "_AIX not defined"
4283 #endif
4284     ]], [[]])], [], AC_DEFINE(_AIX, [], [Define if the system is AIX.]))
4285     ;;
4287   cygwin)
4288     AC_DEFINE(CYGWIN, 1, [Define if the system is Cygwin.])
4289     ;;
4291   darwin)
4292     dnl Not __APPLE__, as this may not be defined on non-OSX Darwin.
4293     dnl Not DARWIN, because Panther and lower CoreFoundation.h use DARWIN to
4294     dnl distinguish OS X from pure Darwin.
4295     AC_DEFINE(DARWIN_OS, [], [Define if the system is Darwin.])
4296     ;;
4298   gnu-linux | gnu-kfreebsd )
4299     AC_DEFINE(USG, [])
4300     AC_DEFINE(GNU_LINUX, [], [Define if ths system is compatible with GNU/Linux.])
4301     ;;
4303   hpux*)
4304     AC_DEFINE(USG, [])
4305     AC_DEFINE(HPUX, [], [Define if the system is HPUX.])
4306     ;;
4308   irix6-5)
4309     AC_DEFINE(USG, [])
4310     AC_DEFINE(USG5_4, [])
4311     AC_DEFINE(IRIX6_5, [], [Define if the system is IRIX.])
4312     ;;
4314   mingw32)
4315     AC_DEFINE(DOS_NT, [])
4316     AC_DEFINE(WINDOWSNT, 1, [Define if compiling for native MS Windows.])
4317     if test "x$ac_enable_checking" != "x" ; then
4318       AC_DEFINE(EMACSDEBUG, 1, [Define to 1 to enable w32 debug facilities.])
4319     fi
4320     ;;
4322   sol2*)
4323     AC_DEFINE(USG, [])
4324     AC_DEFINE(USG5_4, [])
4325     AC_DEFINE(SOLARIS2, [], [Define if the system is Solaris.])
4326     ;;
4328   unixware)
4329     AC_DEFINE(USG, [])
4330     AC_DEFINE(USG5_4, [])
4331     ;;
4332 esac
4334 AC_CACHE_CHECK([for usable FIONREAD], [emacs_cv_usable_FIONREAD],
4335   [case $opsys in
4336      aix4-2)
4337        dnl BUILD 9008 - FIONREAD problem still exists in X-Windows.
4338        emacs_cv_usable_FIONREAD=no
4339        ;;
4341      mingw32)
4342        emacs_cv_usable_FIONREAD=yes
4343        ;;
4345      *)
4346        AC_COMPILE_IFELSE(
4347          [AC_LANG_PROGRAM([[#include <sys/types.h>
4348                             #include <sys/ioctl.h>
4349                             #ifdef USG5_4
4350                             # include <sys/filio.h>
4351                             #endif
4352                           ]],
4353                           [[int foo = ioctl (0, FIONREAD, &foo);]])],
4354          [emacs_cv_usable_FIONREAD=yes],
4355          [emacs_cv_usable_FIONREAD=no])
4356        ;;
4357    esac])
4358 if test $emacs_cv_usable_FIONREAD = yes; then
4359   AC_DEFINE([USABLE_FIONREAD], [1], [Define to 1 if FIONREAD is usable.])
4361   if test $emacs_broken_SIGIO = no; then
4362     AC_CACHE_CHECK([for usable SIGIO], [emacs_cv_usable_SIGIO],
4363       [AC_COMPILE_IFELSE(
4364          [AC_LANG_PROGRAM([[#include <fcntl.h>
4365                             #include <signal.h>
4366                           ]],
4367                           [[int foo = SIGIO | F_SETFL | FASYNC;]])],
4368          [emacs_cv_usable_SIGIO=yes],
4369          [emacs_cv_usable_SIGIO=no])],
4370       [emacs_cv_usable_SIGIO=yes],
4371       [emacs_cv_usable_SIGIO=no])
4372     if test $emacs_cv_usable_SIGIO = yes; then
4373       AC_DEFINE([USABLE_SIGIO], [1], [Define to 1 if SIGIO is usable.])
4374     fi
4375   fi
4379 case $opsys in
4380   dnl Emacs supplies its own malloc, but glib calls posix_memalign,
4381   dnl and on Cygwin prior to version 1.7.24 that becomes the
4382   dnl Cygwin-supplied posix_memalign.  As malloc is not the Cygwin
4383   dnl malloc, the Cygwin posix_memalign always returns ENOSYS.  A
4384   dnl workaround is to set G_SLICE=always-malloc.  This is no longer
4385   dnl needed starting with cygwin-1.7.24, and it is no longer
4386   dnl effective starting with glib-2.36. */
4387   cygwin)
4388     AC_DEFINE(G_SLICE_ALWAYS_MALLOC, 1, [Define to set the
4389       G_SLICE environment variable to "always-malloc" at startup.])
4390     ;;
4392   hpux11)
4393     dnl It works to open the pty's tty in the parent (Emacs), then
4394     dnl close and reopen it in the child.
4395     AC_DEFINE(USG_SUBTTY_WORKS, 1, [Define for USG systems where it
4396       works to open a pty's tty in the parent process, then close and
4397       reopen it in the child.])
4398     ;;
4400   irix6-5)
4401     AC_DEFINE(PREFER_VSUSP, 1, [Define if process_send_signal should
4402       use VSUSP instead of VSWTCH.])
4403     ;;
4405   sol2-10)
4406     AC_DEFINE(_STRUCTURED_PROC, 1, [Needed for system_process_attributes
4407       on Solaris.])
4408     ;;
4409 esac
4411 # Set up the CFLAGS for real compilation, so we can substitute it.
4412 CFLAGS="$REAL_CFLAGS"
4413 CPPFLAGS="$REAL_CPPFLAGS"
4415 ## Hack to detect a buggy GCC version.
4416 if test "x$GCC" = xyes \
4417    && test x"`$CC --version 2> /dev/null | grep 'gcc.* 4.5.0'`" != x \
4418    && test x"`echo $CFLAGS | grep '\-O@<:@23@:>@'`" != x \
4419    && test x"`echo $CFLAGS | grep '\-fno-optimize-sibling-calls'`" = x; then
4420    AC_MSG_ERROR([GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS'.])
4423 version=$PACKAGE_VERSION
4425 copyright="Copyright (C) 2013 Free Software Foundation, Inc."
4426 AC_DEFINE_UNQUOTED(COPYRIGHT, ["$copyright"],
4427   [Short copyright string for this version of Emacs.])
4428 AC_SUBST(copyright)
4430 ### Specify what sort of things we'll be editing into Makefile and config.h.
4431 ### Use configuration here uncanonicalized to avoid exceeding size limits.
4432 AC_SUBST(version)
4433 AC_SUBST(configuration)
4434 ## Unused?
4435 AC_SUBST(canonical)
4436 AC_SUBST(srcdir)
4437 AC_SUBST(prefix)
4438 AC_SUBST(exec_prefix)
4439 AC_SUBST(bindir)
4440 AC_SUBST(datadir)
4441 AC_SUBST(sharedstatedir)
4442 AC_SUBST(libexecdir)
4443 AC_SUBST(mandir)
4444 AC_SUBST(infodir)
4445 AC_SUBST(lispdir)
4446 AC_SUBST(leimdir)
4447 AC_SUBST(standardlisppath)
4448 AC_SUBST(locallisppath)
4449 AC_SUBST(lisppath)
4450 AC_SUBST(x_default_search_path)
4451 AC_SUBST(etcdir)
4452 AC_SUBST(archlibdir)
4453 AC_SUBST(etcdocdir)
4454 AC_SUBST(bitmapdir)
4455 AC_SUBST(gamedir)
4456 AC_SUBST(gameuser)
4457 ## FIXME? Nothing uses @LD_SWITCH_X_SITE@.
4458 ## src/Makefile.in did add LD_SWITCH_X_SITE (as a cpp define) to the
4459 ## end of LIBX_BASE, but nothing ever set it.
4460 AC_SUBST(LD_SWITCH_X_SITE)
4461 AC_SUBST(C_SWITCH_X_SITE)
4462 AC_SUBST(GNUSTEP_CFLAGS)
4463 AC_SUBST(CFLAGS)
4464 ## Used in lwlib/Makefile.in.
4465 AC_SUBST(X_TOOLKIT_TYPE)
4466 AC_SUBST(ns_appdir)
4467 AC_SUBST(ns_appbindir)
4468 AC_SUBST(ns_appresdir)
4469 AC_SUBST(ns_appsrc)
4470 AC_SUBST(GNU_OBJC_CFLAGS)
4471 AC_SUBST(OTHER_FILES)
4473 if test -n "${term_header}"; then
4474     AC_DEFINE_UNQUOTED(TERM_HEADER, "${term_header}",
4475         [Define to the header for the built-in window system.])
4478 AC_DEFINE_UNQUOTED(EMACS_CONFIGURATION,  "${canonical}",
4479                    [Define to the canonical Emacs configuration name.])
4480 AC_DEFINE_UNQUOTED(EMACS_CONFIG_OPTIONS, "${emacs_config_options}",
4481                    [Define to the options passed to configure.])
4482 AH_TEMPLATE(config_opsysfile, [Some platforms that do not use configure
4483   define this to include extra configuration information.])
4485 case $opsys in
4486   mingw32)
4487     AC_DEFINE(config_opsysfile, <ms-w32.h>, [])
4488     ;;
4489 esac
4491 XMENU_OBJ=
4492 XOBJ=
4493 FONT_OBJ=
4494 if test "${HAVE_X_WINDOWS}" = "yes" ; then
4495   AC_DEFINE(HAVE_X_WINDOWS, 1,
4496             [Define to 1 if you want to use the X window system.])
4497   XMENU_OBJ=xmenu.o
4498   XOBJ="xterm.o xfns.o xselect.o xrdb.o xsmfns.o xsettings.o"
4499   FONT_OBJ=xfont.o
4500   if test "$HAVE_XFT" = "yes"; then
4501     FONT_OBJ="$FONT_OBJ ftfont.o xftfont.o ftxfont.o"
4502   elif test "$HAVE_FREETYPE" = "yes"; then
4503     FONT_OBJ="$FONT_OBJ ftfont.o ftxfont.o"
4504   fi
4505   AC_SUBST(FONT_OBJ)
4507 AC_SUBST(XMENU_OBJ)
4508 AC_SUBST(XOBJ)
4509 AC_SUBST(FONT_OBJ)
4511 WIDGET_OBJ=
4512 MOTIF_LIBW=
4513 if test "${USE_X_TOOLKIT}" != "none" ; then
4514   WIDGET_OBJ=widget.o
4515   AC_DEFINE(USE_X_TOOLKIT, 1, [Define to 1 if using an X toolkit.])
4516   if test "${USE_X_TOOLKIT}" = "LUCID"; then
4517     AC_DEFINE(USE_LUCID, 1, [Define to 1 if using the Lucid X toolkit.])
4518   elif test "${USE_X_TOOLKIT}" = "MOTIF"; then
4519     AC_DEFINE(USE_MOTIF, 1, [Define to 1 if using the Motif X toolkit.])
4520     MOTIF_LIBW=-lXm
4521     case "$opsys" in
4522       gnu-linux)
4523         ## Paul Abrahams <abrahams at equinox.shaysnet.com> says this is needed.
4524         MOTIF_LIBW="$MOTIF_LIBW -lXpm"
4525         ;;
4527       unixware)
4528         ## Richard Anthony Ryan <ryanr at ellingtn.ftc.nrcs.usda.gov>
4529         ## says -lXimp is needed in UNIX_SV ... 4.2 1.1.2.
4530         MOTIF_LIBW="MOTIF_LIBW -lXimp"
4531         ;;
4533       aix4-2)
4534         ## olson@mcs.anl.gov says -li18n is needed by -lXm.
4535         MOTIF_LIBW="$MOTIF_LIBW -li18n"
4536         ;;
4537     esac
4538     MOTIF_LIBW="$MOTIF_LIBW $LIBXP"
4539   fi
4541 AC_SUBST(WIDGET_OBJ)
4543 TOOLKIT_LIBW=
4544 case "$USE_X_TOOLKIT" in
4545   MOTIF) TOOLKIT_LIBW="$MOTIF_LIBW" ;;
4546   LUCID) TOOLKIT_LIBW="$LUCID_LIBW" ;;
4547   none) test "x$HAVE_GTK" = "xyes" && TOOLKIT_LIBW="$GTK_LIBS" ;;
4548 esac
4549 AC_SUBST(TOOLKIT_LIBW)
4551 if test "${opsys}" != "mingw32"; then
4552   if test "$USE_X_TOOLKIT" = "none"; then
4553     LIBXT_OTHER="\$(LIBXSM)"
4554     OLDXMENU_TARGET="really-oldXMenu"
4555   else
4556     LIBXT_OTHER="\$(LIBXMU) -lXt \$(LIBXTR6) -lXext"
4557     OLDXMENU_TARGET="really-lwlib"
4558   fi
4560 AC_SUBST(LIBXT_OTHER)
4562 ## The X Menu stuff is present in the X10 distribution, but missing
4563 ## from X11.  If we have X10, just use the installed library;
4564 ## otherwise, use our own copy.
4565 if test "${HAVE_X11}" = "yes" ; then
4566   AC_DEFINE(HAVE_X11, 1,
4567             [Define to 1 if you want to use version 11 of X windows.
4568              Otherwise, Emacs expects to use version 10.])
4570   if test "$USE_X_TOOLKIT" = "none"; then
4571     OLDXMENU="\${oldXMenudir}/libXMenu11.a"
4572   else
4573     OLDXMENU="\${lwlibdir}/liblw.a"
4574   fi
4575   LIBXMENU="\$(OLDXMENU)"
4576   LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
4577   OLDXMENU_DEPS="\${OLDXMENU} ../src/\${OLDXMENU}"
4578 else
4579   ## For a syntactically valid Makefile; not actually used for anything.
4580   ## See comments in src/Makefile.in.
4581   OLDXMENU=nothing
4582   ## FIXME This case (!HAVE_X11 && HAVE_X_WINDOWS) is no longer possible(?).
4583   if test "${HAVE_X_WINDOWS}" = "yes"; then
4584     LIBXMENU="-lXMenu"
4585   else
4586     LIBXMENU=
4587   fi
4588   LIBX_OTHER=
4589   OLDXMENU_DEPS=
4592 if test "$HAVE_GTK" = "yes" || test "$HAVE_MENUS" != "yes"; then
4593   OLDXMENU_TARGET=
4594   OLDXMENU=nothing
4595   LIBXMENU=
4596   OLDXMENU_DEPS=
4599 AC_SUBST(OLDXMENU_TARGET)
4600 AC_SUBST(OLDXMENU)
4601 AC_SUBST(LIBXMENU)
4602 AC_SUBST(LIBX_OTHER)
4603 AC_SUBST(OLDXMENU_DEPS)
4605 if test "${HAVE_MENUS}" = "yes" ; then
4606   AC_DEFINE(HAVE_MENUS, 1,
4607             [Define to 1 if you have mouse menus.
4608              (This is automatic if you use X, but the option to specify it remains.)
4609              It is also defined with other window systems that support xmenu.c.])
4612 if test "${GNU_MALLOC}" = "yes" ; then
4613   AC_DEFINE(GNU_MALLOC, 1,
4614             [Define to 1 if you want to use the GNU memory allocator.])
4617 RALLOC_OBJ=
4618 if test "${REL_ALLOC}" = "yes" ; then
4619   AC_DEFINE(REL_ALLOC, 1,
4620             [Define REL_ALLOC if you want to use the relocating allocator for
4621              buffer space.])
4623   test "$system_malloc" != "yes" && RALLOC_OBJ=ralloc.o
4625 AC_SUBST(RALLOC_OBJ)
4627 if test "$opsys" = "cygwin"; then
4628   CYGWIN_OBJ="sheap.o cygw32.o"
4629   ## Cygwin differs because of its unexec().
4630   PRE_ALLOC_OBJ=
4631   POST_ALLOC_OBJ=lastfile.o
4632 elif test "$opsys" = "mingw32"; then
4633   CYGWIN_OBJ=
4634   PRE_ALLOC_OBJ=
4635   POST_ALLOC_OBJ=lastfile.o
4636 else
4637   CYGWIN_OBJ=
4638   PRE_ALLOC_OBJ=lastfile.o
4639   POST_ALLOC_OBJ=
4641 AC_SUBST(CYGWIN_OBJ)
4642 AC_SUBST(PRE_ALLOC_OBJ)
4643 AC_SUBST(POST_ALLOC_OBJ)
4645 # Configure gnulib.  Although this does not affect CFLAGS or LIBS permanently.
4646 # it temporarily reverts them to their pre-pkg-config values,
4647 # because gnulib needs to work with both src (which uses the
4648 # pkg-config stuff) and lib-src (which does not).  For example, gnulib
4649 # may need to determine whether LIB_CLOCK_GETTIME should contain -lrt,
4650 # and it therefore needs to run in an environment where LIBS does not
4651 # already contain -lrt merely because 'pkg-config --libs' printed '-lrt'
4652 # for some package unrelated to lib-src.
4653 SAVE_CFLAGS=$CFLAGS
4654 SAVE_LIBS=$LIBS
4655 CFLAGS=$pre_PKG_CONFIG_CFLAGS
4656 LIBS="$LIB_PTHREAD $pre_PKG_CONFIG_LIBS"
4657 gl_ASSERT_NO_GNULIB_POSIXCHECK
4658 gl_ASSERT_NO_GNULIB_TESTS
4659 gl_INIT
4660 CFLAGS=$SAVE_CFLAGS
4661 LIBS=$SAVE_LIBS
4663 if test "${opsys}" = "mingw32"; then
4664   CPPFLAGS="$CPPFLAGS -DUSE_CRT_DLL=1 -I $srcdir/nt/inc"
4665   # Remove unneeded switches from the value of CC that goes to Makefiles
4666   CC=`echo $CC | sed -e "s,$GCC_TEST_OPTIONS,,"`
4669 case "$opsys" in
4670   aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;;
4672   darwin)
4673    ## The -headerpad option tells ld (see man page) to leave room at the
4674    ## end of the header for adding load commands.  Needed for dumping.
4675    ## 0x690 is the total size of 30 segment load commands (at 56
4676    ## each); under Cocoa 31 commands are required.
4677    if test "$HAVE_NS" = "yes"; then
4678      libs_nsgui="-framework AppKit"
4679      if test "$NS_IMPL_COCOA" = "yes"; then
4680         libs_nsgui="$libs_nsgui -framework IOKit"
4681      fi
4682      headerpad_extra=6C8
4683    else
4684      libs_nsgui=
4685      headerpad_extra=690
4686    fi
4687    LD_SWITCH_SYSTEM_TEMACS="-fno-pie -prebind $libs_nsgui -Xlinker -headerpad -Xlinker $headerpad_extra"
4689    ## This is here because src/Makefile.in did some extra fiddling around
4690    ## with LD_SWITCH_SYSTEM.  It seems cleaner to put this in
4691    ## LD_SWITCH_SYSTEM_TEMACS instead,
4692    test "x$LD_SWITCH_SYSTEM" = "x" && test "x$GCC" != "xyes" && \
4693      LD_SWITCH_SYSTEM_TEMACS="-X $LD_SWITCH_SYSTEM_TEMACS"
4694    ;;
4696   ## LD_SWITCH_X_SITE_RPATH is a -rpath option saying where to
4697   ## find X at run-time.
4698   ## When handled by cpp, this was in LD_SWITCH_SYSTEM.  However, at the
4699   ## point where configure sourced the s/*.h file, LD_SWITCH_X_SITE_RPATH
4700   ## had not yet been defined and was expanded to null.  Hence LD_SWITCH_SYSTEM
4701   ## had different values in configure (in ac_link) and src/Makefile.in.
4702   ## It seems clearer therefore to put this piece in LD_SWITCH_SYSTEM_TEMACS.
4703   gnu*) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_RPATH)" ;;
4705   mingw32)
4706    ## MinGW64 does not prepend an underscore to symbols, so we must
4707    ## pass a different -entry switch to linker.  FIXME: It is better
4708    ## to make the entry points the same by changing unexw32.c.
4709    case "$canonical" in
4710      x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,_start -Wl,-Map,./temacs.map" ;;
4711      *) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
4712    esac
4713    ;;
4715   openbsd) LD_SWITCH_SYSTEM_TEMACS='-nopie' ;;
4717   *) LD_SWITCH_SYSTEM_TEMACS= ;;
4718 esac
4720 if test x$ac_enable_profiling != x ; then
4721   case $opsys in
4722     *freebsd | gnu-linux) ;;
4723     *) LD_SWITCH_SYSTEM_TEMACS="$LD_SWITCH_SYSTEM_TEMACS -pg" ;;
4724   esac
4727 AC_SUBST(LD_SWITCH_SYSTEM_TEMACS)
4729 ## MinGW-specific post-link processing of temacs.
4730 TEMACS_POST_LINK=":"
4731 ADDSECTION=
4732 EMACS_HEAPSIZE=
4733 if test "${opsys}" = "mingw32"; then
4734   TEMACS_POST_LINK="\$(MINGW_TEMACS_POST_LINK)"
4735   ADDSECTION="../nt/addsection\$(EXEEXT)"
4736   ## Preload heap size of temacs.exe in MB.
4737   case "$canonical" in
4738     x86_64-*-*) EMACS_HEAPSIZE=42 ;;
4739     *) EMACS_HEAPSIZE=27 ;;
4740   esac
4743 AC_SUBST(ADDSECTION)
4744 AC_SUBST(TEMACS_POST_LINK)
4745 AC_SUBST(EMACS_HEAPSIZE)
4747 ## Common for all window systems
4748 if test "$window_system" != "none"; then
4749   AC_DEFINE(HAVE_WINDOW_SYSTEM, 1, [Define if you have a window system.])
4750   WINDOW_SYSTEM_OBJ="fontset.o fringe.o image.o"
4753 AC_SUBST(WINDOW_SYSTEM_OBJ)
4755 AH_TOP([/* GNU Emacs site configuration template file.
4757 Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2013
4758   Free Software Foundation, Inc.
4760 This file is part of GNU Emacs.
4762 GNU Emacs is free software: you can redistribute it and/or modify
4763 it under the terms of the GNU General Public License as published by
4764 the Free Software Foundation, either version 3 of the License, or
4765 (at your option) any later version.
4767 GNU Emacs is distributed in the hope that it will be useful,
4768 but WITHOUT ANY WARRANTY; without even the implied warranty of
4769 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4770 GNU General Public License for more details.
4772 You should have received a copy of the GNU General Public License
4773 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
4776 /* No code in Emacs #includes config.h twice, but some bits of code
4777    intended to work with other packages as well (like gmalloc.c)
4778    think they can include it as many times as they like.  */
4779 #ifndef EMACS_CONFIG_H
4780 #define EMACS_CONFIG_H
4781 ])dnl
4783 AH_BOTTOM([#include <conf_post.h>
4785 #endif /* EMACS_CONFIG_H */
4788 Local Variables:
4789 mode: c
4790 End:
4792 ])dnl
4794 #### Report on what we decided to do.
4795 #### Report GTK as a toolkit, even if it doesn't use Xt.
4796 #### It makes printing result more understandable as using GTK sets
4797 #### toolkit_scroll_bars to yes by default.
4798 if test "${HAVE_GTK}" = "yes"; then
4799   USE_X_TOOLKIT="$USE_GTK_TOOLKIT"
4802 if test $USE_ACL -ne 0; then
4803   acl_summary="yes $LIB_ACL"
4804 else
4805   acl_summary=no
4808 echo "
4809 Configured for \`${canonical}'.
4811   Where should the build process find the source code?    ${srcdir}
4812   What compiler should emacs be built with?               ${CC} ${CFLAGS}
4813   Should Emacs use the GNU version of malloc?             ${GNU_MALLOC}${GNU_MALLOC_reason}
4814   Should Emacs use a relocating allocator for buffers?    ${REL_ALLOC}
4815   Should Emacs use mmap(2) for buffer allocation?         $use_mmap_for_buffers
4816   What window system should Emacs use?                    ${window_system}
4817   What toolkit should Emacs use?                          ${USE_X_TOOLKIT}"
4819 if test -n "${x_includes}"; then
4820 echo "  Where do we find X Windows header files?                ${x_includes}"
4821 else
4822 echo "  Where do we find X Windows header files?                Standard dirs"
4824 if test -n "${x_libraries}"; then
4825 echo "  Where do we find X Windows libraries?                   ${x_libraries}"
4826 else
4827 echo "  Where do we find X Windows libraries?                   Standard dirs"
4830 echo "  Does Emacs use -lXaw3d?                                 ${HAVE_XAW3D}"
4831 echo "  Does Emacs use -lXpm?                                   ${HAVE_XPM}"
4832 echo "  Does Emacs use -ljpeg?                                  ${HAVE_JPEG}"
4833 echo "  Does Emacs use -ltiff?                                  ${HAVE_TIFF}"
4834 echo "  Does Emacs use a gif library?                           ${HAVE_GIF} $LIBGIF"
4835 echo "  Does Emacs use -lpng?                                   ${HAVE_PNG}"
4836 echo "  Does Emacs use -lrsvg-2?                                ${HAVE_RSVG}"
4837 echo "  Does Emacs use imagemagick?                             ${HAVE_IMAGEMAGICK}"
4839 echo "  Does Emacs support sound?                               ${HAVE_SOUND}"
4841 echo "  Does Emacs use -lgpm?                                   ${HAVE_GPM}"
4842 echo "  Does Emacs use -ldbus?                                  ${HAVE_DBUS}"
4843 echo "  Does Emacs use -lgconf?                                 ${HAVE_GCONF}"
4844 echo "  Does Emacs use GSettings?                               ${HAVE_GSETTINGS}"
4845 echo "  Does Emacs use a file notification library?             ${NOTIFY_SUMMARY}"
4846 echo "  Does Emacs use access control lists?                    ${acl_summary}"
4847 echo "  Does Emacs use -lselinux?                               ${HAVE_LIBSELINUX}"
4848 echo "  Does Emacs use -lgnutls?                                ${HAVE_GNUTLS}"
4849 echo "  Does Emacs use -lxml2?                                  ${HAVE_LIBXML2}"
4851 echo "  Does Emacs use -lfreetype?                              ${HAVE_FREETYPE}"
4852 echo "  Does Emacs use -lm17n-flt?                              ${HAVE_M17N_FLT}"
4853 echo "  Does Emacs use -lotf?                                   ${HAVE_LIBOTF}"
4854 echo "  Does Emacs use -lxft?                                   ${HAVE_XFT}"
4855 echo "  Does Emacs directly use zlib?                           ${HAVE_ZLIB}"
4857 echo "  Does Emacs use toolkit scroll bars?                     ${USE_TOOLKIT_SCROLL_BARS}"
4858 echo "  Does Emacs have threading support in elisp?             ${threads_enabled}"
4859 echo
4861 if test -n "${EMACSDATA}"; then
4862    echo "  Environment variable EMACSDATA set to:                  $EMACSDATA"
4864 if test -n "${EMACSDOC}"; then
4865    echo "  Environment variable EMACSDOC set to:                   $EMACSDOC"
4868 echo
4870 if test "$HAVE_NS" = "yes"; then
4871    echo
4872    echo "You must run \"${MAKE-make} install\" in order to test the built application.
4873 The installed application will go to nextstep/Emacs.app and can be
4874 run or moved from there."
4875    if test "$EN_NS_SELF_CONTAINED" = "yes"; then
4876       echo "The application will be fully self-contained."
4877     else
4878       echo "The lisp resources for the application will be installed under ${prefix}.
4879 You may need to run \"${MAKE-make} install\" with sudo.  The application will fail
4880 to run if these resources are not installed."
4881    fi
4882    echo
4885 if test "${opsys}" = "cygwin"; then
4886   case `uname -r` in
4887     1.5.*) AC_MSG_WARN([[building Emacs on Cygwin 1.5 is not supported.]])
4888            echo
4889            ;;
4890   esac
4893 # Remove any trailing slashes in these variables.
4894 [test "${prefix}" != NONE &&
4895   prefix=`echo "${prefix}" | sed 's,\([^/]\)/*$,\1,'`
4896 test "${exec_prefix}" != NONE &&
4897   exec_prefix=`echo "${exec_prefix}" | sed 's,\([^/]\)/*$,\1,'`]
4899 if test "$HAVE_NS" = "yes"; then
4900   if test "$NS_IMPL_GNUSTEP" = yes; then
4901     AC_CONFIG_FILES([nextstep/GNUstep/Emacs.base/Resources/Info-gnustep.plist:nextstep/templates/Info-gnustep.plist.in \
4902       nextstep/GNUstep/Emacs.base/Resources/Emacs.desktop:nextstep/templates/Emacs.desktop.in])
4903   else
4904     AC_CONFIG_FILES([nextstep/Cocoa/Emacs.base/Contents/Info.plist:nextstep/templates/Info.plist.in \
4905       nextstep/Cocoa/Emacs.base/Contents/Resources/English.lproj/InfoPlist.strings:nextstep/templates/InfoPlist.strings.in])
4906   fi
4909 dnl Obviously there is duplication here wrt $SUBDIR_MAKEFILES.
4910 dnl You _can_ use that variable in AC_CONFIG_FILES, so long as any directory
4911 dnl using automake (ie lib/) is explicitly listed and not "hidden" in a variable
4912 dnl (else you get "no `Makefile.am' found for any configure output").
4913 dnl This will work, but you get a config.status that is not quite right
4914 dnl (see http://lists.gnu.org/archive/html/bug-autoconf/2008-08/msg00028.html).
4915 dnl That doesn't have any obvious consequences for Emacs, but on the whole
4916 dnl it seems better to just live with the duplication.
4917 SUBDIR_MAKEFILES="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"
4919 AC_CONFIG_FILES([Makefile lib/Makefile lib-src/Makefile oldXMenu/Makefile \
4920        doc/emacs/Makefile doc/misc/Makefile doc/lispintro/Makefile \
4921        doc/lispref/Makefile src/Makefile lwlib/Makefile lisp/Makefile \
4922        leim/Makefile nextstep/Makefile nt/Makefile])
4924 dnl test/ is not present in release tarfiles.
4925 opt_makefile=test/automated/Makefile
4927 if test -f "$srcdir/$opt_makefile.in"; then
4928   SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
4929   dnl Again, it's best not to use a variable.  Though you can add
4930   dnl ", [], [opt_makefile='$opt_makefile']" and it should work.
4931   AC_CONFIG_FILES([test/automated/Makefile])
4935 dnl admin/ may or may not be present.
4936 opt_makefile=admin/unidata/Makefile
4938 if test -f "$srcdir/$opt_makefile.in"; then
4939   SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
4940   AC_CONFIG_FILES([admin/unidata/Makefile])
4944 SUBDIR_MAKEFILES_IN=`echo " ${SUBDIR_MAKEFILES}" | sed -e 's| | $(srcdir)/|g' -e 's|Makefile|Makefile.in|g'`
4946 AC_SUBST(SUBDIR_MAKEFILES_IN)
4948 dnl You might wonder (I did) why epaths.h is generated by running make,
4949 dnl rather than just letting configure generate it from epaths.in.
4950 dnl One reason is that the various paths are not fully expanded (see above);
4951 dnl eg gamedir=${prefix}/var/games/emacs.
4952 dnl Secondly, the GNU Coding standards require that one should be able
4953 dnl to run `make prefix=/some/where/else' and override the values set
4954 dnl by configure.  This also explains the `move-if-change' test and
4955 dnl the use of force in the `epaths-force' rule in Makefile.in.
4956 AC_CONFIG_COMMANDS([src/epaths.h], [
4957 if test "${opsys}" = "mingw32"; then
4958   ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-w32
4959 else
4960   ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force
4962 ], [GCC="$GCC" CPPFLAGS="$CPPFLAGS" opsys="$opsys"])
4964 AC_CONFIG_COMMANDS([src/.gdbinit], [
4965 if test ! -f src/.gdbinit && test -f "$srcdir/src/.gdbinit"; then
4966   echo "source $srcdir/src/.gdbinit" > src/.gdbinit
4970 AC_OUTPUT