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