declare smobs in alloc.c
[bpt/emacs.git] / configure.ac
index 5e30c49..2445db4 100644 (file)
@@ -25,22 +25,6 @@ AC_PREREQ(2.65)
 dnl Note this is parsed by (at least) make-dist and lisp/cedet/ede/emacs.el.
 AC_INIT(GNU Emacs, 24.4.50, bug-gnu-emacs@gnu.org)
 
-dnl We get MINGW64 with MSYS2
-if test "x$MSYSTEM" = "xMINGW32" -o "x$MSYSTEM" = "xMINGW64"
-then
-  . $srcdir/nt/mingw-cfg.site
-
-  case $srcdir in
-    /* | ?:*)
-      # srcdir is an absolute path.  In this case, force the format
-      # "/c/foo/bar", to simplify later conversions to native Windows
-      # format ("c:/foo/bar")
-      srcdir=`cd "${srcdir}" && pwd -W`
-      srcdir="/${srcdir:0:1}${srcdir:2}"
-      ;;
-  esac
-fi
-
 dnl Set emacs_config_options to the options of 'configure', quoted for the shell,
 dnl and then quoted again for a C string.  Separate options with spaces.
 dnl Add some environment variables, if they were passed via the environment
@@ -92,7 +76,7 @@ AC_CHECK_PROGS(XCRUN, [xcrun])
 if test -n "$XCRUN"; then
   if test -z "$MAKE"; then
     dnl Call the variable MAKE_PROG, not MAKE, to avoid confusion with
-    dnl SET_MAKE and with the usual MAKE variable that 'make' itself uses.
+    dnl the usual MAKE variable that 'make' itself uses.
     AC_CHECK_PROG([MAKE_PROG], [make], [yes])
     if test -z "$MAKE_PROG"; then
       MAKE="$XCRUN MAKE"
@@ -102,9 +86,75 @@ if test -n "$XCRUN"; then
   fi
 fi
 
+dnl GNU Make is required, so don't test for its individual features.
+am_cv_make_support_nested_variables=yes
+AC_DEFUN([AC_PROG_MAKE_SET],
+  [SET_MAKE=
+   AC_SUBST([SET_MAKE])])
+
+dnl Check for GNU Make and possibly set MAKE before running AM_INIT_AUTOMAKE.
+[emacs_check_gnu_make ()
+{
+  emacs_makeout=`($1 --version) 2>/dev/null` &&
+  case $emacs_makeout in
+    'GNU Make '3.8[1-9]* | 'GNU Make '3.9[0-9]* | \
+    'GNU Make '3.[1-9][0-9][0-9]* | 'GNU Make '[4-9]* | 'GNU Make '[1-9][0-9]* )
+       ac_path_MAKE_found=:;;
+  esac
+}]
+AC_CACHE_CHECK([for GNU Make], [ac_cv_path_MAKE],
+  [ac_path_MAKE_found=false
+   if test -n "$MAKE"; then
+     emacs_check_gnu_make "$MAKE"
+     ac_cv_path_MAKE=$MAKE
+   else
+     emacs_tried_make=false
+     emacs_tried_gmake=false
+     emacs_tried_gnumake=false
+     AC_PATH_PROGS_FEATURE_CHECK([MAKE], [make gmake gnumake],
+       [[emacs_check_gnu_make "$ac_path_MAKE"
+        if $ac_path_MAKE_found; then
+          # Use the fully-qualified program name only if the basename
+          # would not resolve to it.
+          if eval \$emacs_tried_$ac_prog; then
+            ac_cv_path_MAKE=$ac_path_MAKE
+          else
+            ac_cv_path_MAKE=$ac_prog
+          fi
+        fi
+        eval emacs_tried_$ac_prog=:]])
+   fi])
+$ac_path_MAKE_found || {
+AC_MSG_ERROR([[Building Emacs requires GNU Make, at least version 3.81.
+If you have it installed under another name, configure with 'MAKE=...'.
+For example, run '$0 MAKE=gnu-make'.]])
+}
+MAKE=$ac_cv_path_MAKE
+
 dnl Fairly arbitrary, older versions might work too.
 AM_INIT_AUTOMAKE(1.11)
 
+dnl Canonicalize the configuration name.
+AC_CANONICAL_HOST
+canonical=$host
+configuration=${host_alias-${build_alias-$host}}
+
+dnl We get MINGW64 with MSYS2.
+case $canonical in
+ *-mingw*)
+  . $srcdir/nt/mingw-cfg.site
+
+  case $srcdir in
+    /* | ?:*)
+      # srcdir is an absolute path.  In this case, force the format
+      # "/c/foo/bar", to simplify later conversions to native Windows
+      # format ("c:/foo/bar").
+      srcdir=`cd "${srcdir}" && pwd -W`
+      srcdir="/${srcdir:0:1}${srcdir:2}"
+      ;;
+  esac;;
+esac
+
 dnl Support for --program-prefix, --program-suffix and
 dnl --program-transform-name options
 AC_ARG_PROGRAM
@@ -246,6 +296,7 @@ fi
 
 dnl _ON results in a '--without' option in the --help output, so
 dnl the help text should refer to "don't compile", etc.
+with_xpm_set=${with_xpm+set}
 OPTION_DEFAULT_ON([xpm],[don't compile with XPM image support])
 OPTION_DEFAULT_ON([jpeg],[don't compile with JPEG image support])
 OPTION_DEFAULT_ON([tiff],[don't compile with TIFF image support])
@@ -296,7 +347,7 @@ otherwise for the first of `gfile' or `inotify' that is usable.])
 dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html
 OPTION_DEFAULT_ON([makeinfo],[don't require makeinfo for building manuals])
 
-## This might be a 'configure' arg, e.g., autogen.sh might set it.
+## This might be a 'configure' arg.
 AC_SUBST([ACLOCAL_PATH])
 
 ## Makefile.in needs the cache file name.
@@ -340,11 +391,7 @@ fi)
 
 AC_ARG_ENABLE(checking,
 [AS_HELP_STRING([--enable-checking@<:@=LIST@:>@],
-               [enable expensive run-time checks.  With LIST,
-                enable only specific categories of checks.
-                Categories are: all,yes,no.
-                Flags are: stringbytes, stringoverrun, stringfreelist,
-                xmallocoverrun, conslist, glyphs])],
+               [enable expensive run-time checks])]
 [ac_checking_flags="${enableval}"],[])
 IFS="${IFS=    }"; ac_save_IFS="$IFS"; IFS="$IFS,"
 for check in $ac_checking_flags
@@ -352,27 +399,7 @@ do
        case $check in
        # these set all the flags to specific states
        yes)            ac_enable_checking=1 ;;
-       no)             ac_enable_checking= ;
-                       ac_gc_check_stringbytes= ;
-                       ac_gc_check_string_overrun= ;
-                       ac_gc_check_string_free_list= ;
-                       ac_xmalloc_overrun= ;
-                       ac_gc_check_cons_list= ;
-                       ac_glyphs_debug= ;;
-       all)            ac_enable_checking=1 ;
-                       ac_gc_check_stringbytes=1 ;
-                       ac_gc_check_string_overrun=1 ;
-                       ac_gc_check_string_free_list=1 ;
-                       ac_xmalloc_overrun=1 ;
-                       ac_gc_check_cons_list=1 ;
-                       ac_glyphs_debug=1 ;;
-       # these enable particular checks
-       stringbytes)    ac_gc_check_stringbytes=1 ;;
-       stringoverrun)  ac_gc_check_string_overrun=1 ;;
-       stringfreelist) ac_gc_check_string_free_list=1 ;;
-       xmallocoverrun) ac_xmalloc_overrun=1 ;;
-       conslist)       ac_gc_check_cons_list=1 ;;
-       glyphs)         ac_glyphs_debug=1 ;;
+       all)            ac_enable_checking=1 ;;
        *)      AC_MSG_ERROR(unknown check category $check) ;;
        esac
 done
@@ -382,32 +409,6 @@ if test x$ac_enable_checking != x ; then
   AC_DEFINE(ENABLE_CHECKING, 1,
 [Define to 1 if expensive run-time data type and consistency checks are enabled.])
 fi
-if test x$ac_gc_check_stringbytes != x ; then
-  AC_DEFINE(GC_CHECK_STRING_BYTES, 1,
-[Define this temporarily to hunt a bug.  If defined, the size of
-   strings is redundantly recorded in sdata structures so that it can
-   be compared to the sizes recorded in Lisp strings.])
-fi
-if test x$ac_gc_check_string_overrun != x ; then
-  AC_DEFINE(GC_CHECK_STRING_OVERRUN, 1,
-[Define this to check for short string overrun.])
-fi
-if test x$ac_gc_check_string_free_list != x ; then
-  AC_DEFINE(GC_CHECK_STRING_FREE_LIST, 1,
-[Define this to check the string free list.])
-fi
-if test x$ac_xmalloc_overrun != x ; then
-  AC_DEFINE(XMALLOC_OVERRUN_CHECK, 1,
-[Define this to check for malloc buffer overrun.])
-fi
-if test x$ac_gc_check_cons_list != x ; then
-  AC_DEFINE(GC_CHECK_CONS_LIST, 1,
-[Define this to check for errors in cons list.])
-fi
-if test x$ac_glyphs_debug != x ; then
-  AC_DEFINE(GLYPH_DEBUG, 1,
-[Define this to enable glyphs debugging code.])
-fi
 
 AC_ARG_ENABLE(check-lisp-object-type,
 [AS_HELP_STRING([--enable-check-lisp-object-type],
@@ -447,12 +448,6 @@ AC_ARG_ENABLE(gtk-deprecation-warnings,
                [Show Gtk+/Gdk deprecation warnings for Gtk+ >= 3.0])],
 [ac_enable_gtk_deprecation_warnings="${enableval}"],[])
 
-### Canonicalize the configuration name.
-
-AC_CANONICAL_HOST
-canonical=$host
-configuration=${host_alias-${build_alias-$host}}
-
 dnl This used to use changequote, but, apart from `changequote is evil'
 dnl per the autoconf manual, we can speed up autoconf somewhat by quoting
 dnl the great gob of text.  Thus it's not processed for possible expansion.
@@ -547,7 +542,7 @@ case "${canonical}" in
   rs6000-ibm-aix[56]* )
     opsys=aix4-2
   ;;
-  powerpc-ibm-aix[56]*  )
+  powerpc-ibm-aix[5-9]* | powerpc-ibm-aix[1-9][0-9]* )
     opsys=aix4-2
   ;;
 
@@ -576,10 +571,13 @@ case "${canonical}" in
                opsys=sol2-10
                emacs_check_sunpro_c=yes
                ;;
+      *-sunos5.[1-5]* | *-solaris2.[1-5]* ) unported=yes ;;
+      ## Note that Emacs 23.1's NEWS said the following would be dropped.
       *-sunos5.6* | *-solaris2.6* )
                opsys=sol2-6
                RANLIB="ar -ts"
                ;;
+      ## 5.7 EOL Aug 2008, 5.8 EOL Mar 2012.
       *-sunos5.[7-9]* | *-solaris2.[7-9]* )
                opsys=sol2-6
                emacs_check_sunpro_c=yes
@@ -656,20 +654,11 @@ Check `etc/MACHINES' for recognized configuration names.])
 fi
 
 
-AC_MSG_CHECKING([whether we are using GNU Make])
-testval=`${MAKE-make} --version 2>/dev/null | grep 'GNU Make'`
-if test "x$testval" != x; then
-  AC_MSG_RESULT([yes])
-else
-  AC_MSG_RESULT([no])
-  AC_MSG_ERROR([Building Emacs requires GNU make.
-If you have it installed under another name, configure with 'MAKE=...'.
-For example, run './configure MAKE=gmake'.])
-fi
-
-
 #### Choose a compiler.
 
+dnl Don't bother to test for C89.
+AC_DEFUN([_AC_PROG_CC_C89], [$2])
+
 dnl Sets GCC=yes if using gcc.
 AC_PROG_CC([gcc cc cl clang "$XCRUN gcc" "$XCRUN clang"])
 if test -n "$XCRUN"; then
@@ -677,6 +666,9 @@ if test -n "$XCRUN"; then
   test -n "$AR" && export AR
 fi
 
+dnl Emacs needs C99 or later.
+gl_PROG_CC_C99
+
 AM_PROG_CC_C_O
 
 if test x$GCC = xyes; then
@@ -695,8 +687,6 @@ AC_DEFUN([gl_CRYPTO_CHECK])
 # Avoid gnulib's tests for HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW,
 # as we don't use them.
 AC_DEFUN([gl_FCNTL_O_FLAGS])
-# Avoid gnulib's threadlib module, as we do threads our own way.
-AC_DEFUN([gl_THREADLIB])
 
 # Initialize gnulib right after choosing the compiler.
 dnl Amongst other things, this sets AR and ARFLAGS.
@@ -842,6 +832,7 @@ else
   for w in $ws; do
     gl_WARN_ADD([$w])
   done
+  gl_WARN_ADD([-Wredundant-decls])     # Prefer this, as we don't use Bison.
   gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
   gl_WARN_ADD([-Wno-type-limits])      # Too many warnings for now
@@ -890,8 +881,11 @@ edit_cflags="
 AC_ARG_ENABLE(link-time-optimization,
 [AS_HELP_STRING([--enable-link-time-optimization],
                 [build emacs with link-time optimization.
-                This is supported for gcc since 4.5.0 and clang.
-                Note that clang support is experimental - see INSTALL])],
+                This requires GCC 4.5.0 or later, or clang.
+                (Note that clang support is experimental - see INSTALL.)
+                It also makes Emacs harder to debug, and when we tried it
+                with GCC 4.9.0 x86-64 it made Emacs slower, so it's not
+                recommended for typical use.])],
 if test "${enableval}" != "no"; then
    ac_lto_supported=no
    if test $emacs_cv_clang = yes; then
@@ -929,6 +923,13 @@ if test "${enableval}" != "no"; then
         # command, so plugin name is appended to ARFLAGS.
         ARFLAGS="cru --plugin $GOLD_PLUGIN"
         RANLIB="$RANLIB --plugin $GOLD_PLUGIN"
+      else
+        dnl The following is needed for GCC 4.9.0.  The GCC 4.9.0 release notes
+        dnl suggest that instead of -ffat-lto-objects we should use gcc-ar and
+        dnl gcc-ranlib in place of ar and ranlib, but gcc-ar makes /usr/bin/ar
+        dnl dump core on Fedora 20, so play it safe for now.
+        gl_COMPILER_OPTION_IF([-ffat-lto-objects],
+          [CFLAGS="$CFLAGS -ffat-lto-objects"])
       fi
    fi
 fi)
@@ -993,6 +994,15 @@ if test "$opsys" = "mingw32"; then
   LN_S="/bin/ln"
 fi
 
+dnl On some Debian versions, "install-info" prints irritating messages
+dnl "This is not dpkg install-info anymore, but GNU install-info"
+dnl if called via an absolute file name.
+dnl Use the entirely-identical-but-quieter ginstall-info instead if present.
+dnl Sadly some people may have an old ginstall-info installed on
+dnl non-Debian systems, so we can't use this.
+dnl AC_PATH_PROGS(INSTALL_INFO, [ginstall-info install-info], :,
+dnl   $PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin)
+
 AC_PATH_PROG(INSTALL_INFO, install-info, :,
   $PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin)
 dnl Don't use GZIP, which is used by gzip for additional parameters.
@@ -1067,12 +1077,6 @@ with the `--without-makeinfo' option to build without the manuals.] )
 fi
 AC_SUBST(HAVE_MAKEINFO)
 
-dnl Just so that there is only a single place we need to edit.
-INFO_EXT=.info
-INFO_OPTS=--no-split
-AC_SUBST(INFO_EXT)
-AC_SUBST(INFO_OPTS)
-
 if test $opsys = mingw32; then
    DOCMISC_W32=efaq-w32
 else
@@ -1138,19 +1142,8 @@ AC_CACHE_CHECK([whether addresses are sanitized],
 
 dnl The function dump-emacs will not be defined and temacs will do
 dnl (load "loadup") automatically unless told otherwise.
-test "x$CANNOT_DUMP" = "x" && CANNOT_DUMP=no
-case "$opsys" in
-  your-opsys-here) CANNOT_DUMP=yes ;;
-esac
-
-if test "$CANNOT_DUMP" = "yes"; then
-  AC_DEFINE(CANNOT_DUMP, 1, [Define if Emacs cannot be dumped on your system.])
-elif test "$emacs_cv_sanitize_address" = yes; then
-  AC_MSG_WARN([[Addresses are sanitized; suggest CANNOT_DUMP=yes]])
-fi
-
-AC_SUBST(CANNOT_DUMP)
-
+AC_DEFINE(CANNOT_DUMP, 1, [Define if Emacs cannot be dumped on your system.])
+AC_SUBST(CANNOT_DUMP, yes)
 
 UNEXEC_OBJ=unexelf.o
 case "$opsys" in
@@ -1303,7 +1296,7 @@ else
   CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS"
 fi
 
-# Suppress obsolescent Autoconf test for size_t; Emacs assumes C89 or better.
+# Suppress obsolescent Autoconf test for size_t; Emacs assumes C99 or better.
 AC_DEFUN([AC_TYPE_SIZE_T])
 # Likewise for obsolescent test for uid_t, gid_t; Emacs assumes them.
 AC_DEFUN([AC_TYPE_UID_T])
@@ -1359,10 +1352,6 @@ AC_SUBST(LIB_MATH)
 AC_DEFINE_UNQUOTED(SYSTEM_TYPE, "$SYSTEM_TYPE",
   [The type of system you are compiling for; sets `system-type'.])
 
-m4_pattern_forbid([^PKG_])
-
-AC_ARG_VAR(PKG_CONFIG_PATH, [Colon-separated list of directories
-searched by pkg-config])
 
 pre_PKG_CONFIG_CFLAGS=$CFLAGS
 pre_PKG_CONFIG_LIBS=$LIBS
@@ -1372,31 +1361,27 @@ PKG_PROG_PKG_CONFIG(0.9.0)
 dnl EMACS_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4)
 dnl acts like PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4,
 dnl HAVE_GSTUFF=yes, HAVE_GSTUFF=no) -- see pkg-config man page --
-dnl except that it works around older pkg-config bugs and
-dnl it postprocesses CFLAGS as needed for --enable-gcc-warnings.
+dnl except that it postprocesses CFLAGS as needed for --enable-gcc-warnings.
 dnl EMACS_CHECK_MODULES accepts optional 3rd and 4th arguments that
 dnl can take the place of the default HAVE_GSTUFF=yes and HAVE_GSTUFF=no
 dnl actions.
 AC_DEFUN([EMACS_CHECK_MODULES],
-  [dnl pkg-config before 0.26 doesn't check exit status properly; see:
-   dnl https://bugs.freedesktop.org/show_bug.cgi?id=29801
-   dnl Work around the bug by checking the status ourselves.
-   emacs_check_module_ok=false
-   AS_IF([test -n "$PKG_CONFIG" &&
-         { $PKG_CONFIG --atleast-pkgconfig-version 0.26 ||
-           { $PKG_CONFIG --cflags "$2" && $PKG_CONFIG --libs "$2"; }
-         } >/dev/null 2>&AS_MESSAGE_LOG_FD],
-     [PKG_CHECK_MODULES([$1], [$2],
-       [$1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"`
-        emacs_check_module_ok=:],
-       [:])])
-   if $emacs_check_module_ok; then
-     m4_default([$3], [HAVE_$1=yes])
-   else
-     m4_default([$4], [HAVE_$1=no])
-   fi])
+  [PKG_CHECK_MODULES([$1], [$2],
+     [$1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"`
+      m4_default([$3], [HAVE_$1=yes])],
+     [m4_default([$4], [HAVE_$1=no])])])
+
+PKG_CHECK_MODULES([GUILE], [guile-2.2])
+AC_SUBST(GUILE_CFLAGS)
+AC_SUBST(GUILE_LIBS)
+
+AC_PATH_PROG(GUILE_SNARF, guile-snarf, no)
+if test "$GUILE_SNARF" = "no"; then
+   AC_MSG_ERROR([guile-snarf not found])
+fi
 
 HAVE_SOUND=no
+
 if test "${with_sound}" != "no"; then
   # Sound support for GNU/Linux, the free BSDs, and MinGW.
   AC_CHECK_HEADERS([machine/soundcard.h sys/soundcard.h soundcard.h],
@@ -1533,7 +1518,6 @@ dnl Check for endianness.
 dnl AC_C_BIGENDIAN is done by gnulib.
 
 dnl check for Make feature
-dnl AC_PROG_MAKE_SET is done by Automake.
 
 DEPFLAGS=
 MKDEPDIR=":"
@@ -1555,11 +1539,14 @@ if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
       deps_frag=autodeps.mk
    fi
 fi
+lwlib_deps_frag=$srcdir/lwlib/$deps_frag
+oldxmenu_deps_frag=$srcdir/oldXMenu/$deps_frag
 deps_frag=$srcdir/src/$deps_frag
 AC_SUBST(MKDEPDIR)
 AC_SUBST(DEPFLAGS)
 AC_SUBST_FILE(deps_frag)
-
+AC_SUBST_FILE(lwlib_deps_frag)
+AC_SUBST_FILE(oldxmenu_deps_frag)
 
 lisp_frag=$srcdir/src/lisp.mk
 AC_SUBST_FILE(lisp_frag)
@@ -1976,7 +1963,7 @@ doug_lea_malloc=$emacs_cv_var_doug_lea_malloc
 system_malloc=$emacs_cv_sanitize_address
 case "$opsys" in
   ## darwin ld insists on the use of malloc routines in the System framework.
-  darwin|sol2-10) system_malloc=yes ;;
+  darwin|mingw32|sol2-10) system_malloc=yes ;;
 esac
 
 GMALLOC_OBJ=
@@ -2023,7 +2010,7 @@ if test "$doug_lea_malloc" = "yes" ; then
   ## #ifdef DOUG_LEA_MALLOC; #undef REL_ALLOC; #endif
   ## Does the AC_FUNC_MMAP test below make this check unnecessary?
   case "$opsys" in
-    gnu*) REL_ALLOC=no ;;
+    mingw32|gnu*) REL_ALLOC=no ;;
   esac
 fi
 
@@ -2033,7 +2020,7 @@ fi
 
 use_mmap_for_buffers=no
 case "$opsys" in
-  cygwin|freebsd|irix6-5) use_mmap_for_buffers=yes ;;
+  cygwin|mingw32|freebsd|irix6-5) use_mmap_for_buffers=yes ;;
 esac
 
 AC_FUNC_MMAP
@@ -2049,6 +2036,7 @@ AC_CHECK_LIB(Xbsd, main, LD_SWITCH_X_SITE="$LD_SWITCH_X_SITE -lXbsd")
 
 dnl Check for the POSIX thread library.
 LIB_PTHREAD=
+if test "$opsys" != "mingw32"; then
 AC_CHECK_HEADERS_ONCE(pthread.h)
 if test "$ac_cv_header_pthread_h"; then
   dnl gmalloc.c uses pthread_atfork, which is not available on older-style
@@ -2062,13 +2050,25 @@ if test "$ac_cv_header_pthread_h"; then
   OLD_LIBS=$LIBS
   AC_SEARCH_LIBS([$emacs_pthread_function], [pthread],
     [AC_DEFINE([HAVE_PTHREAD], [1],
-       [Define to 1 if you have pthread (-lpthread).])])
-  if test "X$LIBS" != "X$OLD_LIBS"; then
+       [Define to 1 if you have pthread (-lpthread).])
+     # Some systems optimize for single-threaded programs by default, and
+     # need special flags to disable these optimizations. For example, the
+     # definition of 'errno' in <errno.h>.
+     case $opsys in
+       sol*)
+         AC_DEFINE([_REENTRANT], 1,
+       [Define to 1 if your system requires this in multithreaded code.]);;
+       aix4-2)
+         AC_DEFINE([_THREAD_SAFE], 1,
+       [Define to 1 if your system requires this in multithreaded code.]);;
+     esac])
+ if test "X$LIBS" != "X$OLD_LIBS"; then
     eval LIB_PTHREAD=\$ac_cv_search_$emacs_pthread_function
   fi
   LIBS=$OLD_LIBS
 fi
 AC_SUBST([LIB_PTHREAD])
+fi
 
 dnl Check for need for bigtoc support on IBM AIX
 
@@ -2817,14 +2817,17 @@ fi
 
 ### Start of font-backend (under X11) section.
 if test "${HAVE_X11}" = "yes"; then
-   EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0],
-     [HAVE_FC=yes], [HAVE_FC=no])
-
-   ## Use -lXft if available, unless `--with-xft=no'.
-   HAVE_XFT=maybe
-    if test "${HAVE_FC}" = "no" || test "x${with_x}" = "xno"; then
+    ## Use -lXft if available, unless `--with-xft=no'.
+    HAVE_XFT=maybe
+    if test "x${with_x}" = "xno"; then
       with_xft="no";
     fi
+
+    if test "$with_xft" != no; then
+      EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
+      with_xft=$HAVE_FONTCONFIG
+    fi
+
     if test "x${with_xft}" != "xno"; then
 
       EMACS_CHECK_MODULES([XFT], [xft >= 0.13.0], [], [HAVE_XFT=no])
@@ -2958,6 +2961,9 @@ no_return_alloc_pixels
 fi
 
 if test "${HAVE_X11}" = "yes"; then
+  dnl Avoid Xpm on AIX unless requested, as it crashes; see Bug#17598.
+  test "$opsys$with_xpm_set" = aix4-2 && with_xpm=no
+
   if test "${with_xpm}" != "no"; then
     AC_CHECK_HEADER(X11/xpm.h,
       [AC_CHECK_LIB(Xpm, XpmReadFileToPixmap, HAVE_XPM=yes, , -lX11)])
@@ -2981,6 +2987,9 @@ no_return_alloc_pixels
   if test "${HAVE_XPM}" = "yes"; then
     AC_DEFINE(HAVE_XPM, 1, [Define to 1 if you have the Xpm library (-lXpm).])
     LIBXPM=-lXpm
+  elif test "$opsys,$LUCID_LIBW" = aix4-2,-lXaw; then
+    dnl AIX -lXaw needs -lXpm linked too; see Bug#17598 Message#152.
+    LIBXPM=-lXpm
   fi
 fi
 
@@ -3076,31 +3085,40 @@ elif test "${with_png}" != no; then
   # mingw32 loads the library dynamically.
   if test "$opsys" = mingw32; then
     AC_CHECK_HEADER([png.h], [HAVE_PNG=yes])
-  elif png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` &&
-       png_libs=`(libpng-config --libs) 2>&AS_MESSAGE_LOG_FD`
-  then
-    HAVE_PNG=yes
-    PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"`
-    LIBPNG=$png_libs
-  else
-    # libpng-config does not work; configure by hand.
-    # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
-    # in /usr/include/libpng.
-    AC_CHECK_HEADERS([png.h libpng/png.h],
-      [AC_CHECK_LIB([png], [png_get_channels],
-        [HAVE_PNG=yes
-         LIBPNG='-lpng'
-         if test "$ac_cv_header_png_h" != yes; then
-           PNG_CFLAGS=-I/usr/include/libpng
-         fi
-         break],
-         [], [-lz -lm])])
-  fi
-  # $LIBPNG requires explicit -lz in some cases.
-  # We don't know what those cases are, exactly, so play it safe and
-  # append -lz to any nonempty $LIBPNG, unless we're already using LIBZ.
-  if test -n "$LIBPNG" && test -z "$LIBZ"; then
-    LIBPNG="$LIBPNG -lz"
+  elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes"; then
+    AC_MSG_CHECKING([for png])
+    png_cflags=`(libpng-config --cflags) 2>&AS_MESSAGE_LOG_FD` &&
+    png_libs=`(libpng-config --libs) 2>&AS_MESSAGE_LOG_FD` || {
+      # libpng-config does not work; configure by hand.
+      # Debian unstable as of July 2003 has multiple libpngs, and puts png.h
+      # in /usr/include/libpng.
+      if test -r /usr/include/libpng/png.h &&
+        test ! -r /usr/include/png.h; then
+       png_cflags=-I/usr/include/libpng
+      else
+       png_cflags=
+      fi
+      png_libs='-lpng'
+    }
+    SAVE_CFLAGS=$CFLAGS
+    SAVE_LIBS=$LIBS
+    CFLAGS="$CFLAGS $png_cflags"
+    LIBS="$png_libs -lz -lm $LIBS"
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM([[#include <png.h>]],
+        [[return !png_get_channels (0, 0);]])],
+      [HAVE_PNG=yes
+       PNG_CFLAGS=`AS_ECHO(["$png_cflags"]) | sed -e "$edit_cflags"`
+       LIBPNG=$png_libs
+       # $LIBPNG requires explicit -lz in some cases.
+       # We don't know what those cases are, exactly, so play it safe and
+       # append -lz to any nonempty $LIBPNG, unless we're already using LIBZ.
+       if test -n "$LIBPNG" && test -z "$LIBZ"; then
+        LIBPNG="$LIBPNG -lz"
+       fi])
+    CFLAGS=$SAVE_CFLAGS
+    LIBS=$SAVE_LIBS
+    AC_MSG_RESULT([$HAVE_PNG])
   fi
 fi
 if test $HAVE_PNG = yes; then
@@ -3461,15 +3479,15 @@ esac
 AC_SUBST(BLESSMAIL_TARGET)
 
 OLD_LIBS=$LIBS
-LIBS="$LIB_MATH $LIBS"
+LIBS="$LIB_PTHREAD $LIB_MATH $LIBS"
 AC_CHECK_FUNCS(accept4 gethostname \
 getrusage get_current_dir_name \
 lrand48 random rint \
 select getpagesize setlocale \
 getrlimit setrlimit shutdown getaddrinfo \
-strsignal setitimer \
+pthread_sigmask strsignal setitimer \
 sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \
-gai_strerror getline getdelim sync \
+gai_strerror sync \
 getpwent endpwent getgrent endgrent \
 cfmakeraw cfsetspeed copysign __executable_start log2)
 LIBS=$OLD_LIBS
@@ -3817,14 +3835,6 @@ dnl Fixme: Not used.  Should this be HAVE_SOCKETS?
            [Define to 1 if you have inet sockets.])
 fi
 
-dnl Check for a Solaris 2.4 vfork bug that Autoconf misses (through 2.69).
-dnl This can be removed once we assume Autoconf 2.70.
-case $canonical in
-  *-solaris2.4 | *-solaris2.4.*)
-    dnl Disable the Autoconf-generated vfork test.
-    : ${ac_cv_func_vfork_works=no};;
-esac
-
 AC_FUNC_FORK
 
 AC_CHECK_FUNCS(snprintf)
@@ -4331,7 +4341,7 @@ if test x$GCC = xyes; then
 else
   case $opsys in
     dnl irix: Tested on Irix 6.5.  SCM worked on earlier versions.
-    dragonfly | freebsd | netbsd | openbsd | irix6-5 | sol2* )
+    aix* | dragonfly | freebsd | netbsd | openbsd | irix6-5 | sol2* )
       AC_DEFINE(GC_SETJMP_WORKS, 1)
       ;;
   esac
@@ -4750,6 +4760,12 @@ AH_VERBATIM([FORTIFY_SOUR],
 #endif
 ])
 
+# If user asks to omit features, disable optional features that gnulib
+# might otherwise enable.
+if test "$with_features" = no && test "$enable_acl" != yes; then
+  enable_acl=no
+fi
+
 # Configure gnulib.  Although this does not affect CFLAGS or LIBS permanently.
 # it temporarily reverts them to their pre-pkg-config values,
 # because gnulib needs to work with both src (which uses the
@@ -4811,11 +4827,9 @@ case "$opsys" in
   gnu*) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_RPATH)" ;;
 
   mingw32)
-   ## MinGW64 does not prepend an underscore to symbols, so we must
-   ## pass a different -entry switch to linker.  FIXME: It is better
-   ## to make the entry points the same by changing unexw32.c.
+   ## Is it any better under MinGW64 to relocate emacs into higher addresses?
    case "$canonical" in
-     x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
+     x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x400000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
      *) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;;
    esac
    ;;
@@ -4836,27 +4850,10 @@ LD_SWITCH_SYSTEM_TEMACS="$LDFLAGS_NOCOMBRELOC $LD_SWITCH_SYSTEM_TEMACS"
 
 AC_SUBST(LD_SWITCH_SYSTEM_TEMACS)
 
-## MinGW-specific post-link processing of temacs.
-TEMACS_POST_LINK=":"
-ADDSECTION=
-EMACS_HEAPSIZE=
-if test "${opsys}" = "mingw32"; then
-  TEMACS_POST_LINK="\$(MINGW_TEMACS_POST_LINK)"
-  ADDSECTION="../nt/addsection\$(EXEEXT)"
-  ## Preload heap size of temacs.exe in MB.
-  case "$canonical" in
-    x86_64-*-*) EMACS_HEAPSIZE=42 ;;
-    *) EMACS_HEAPSIZE=27 ;;
-  esac
-fi
-
-AC_SUBST(ADDSECTION)
-AC_SUBST(TEMACS_POST_LINK)
-AC_SUBST(EMACS_HEAPSIZE)
-
 ## Common for all window systems
 if test "$window_system" != "none"; then
   AC_DEFINE(HAVE_WINDOW_SYSTEM, 1, [Define if you have a window system.])
+  AC_DEFINE(POLL_FOR_INPUT, 1, [Define if you poll periodically to detect C-g.])
   WINDOW_SYSTEM_OBJ="fontset.o fringe.o image.o"
 fi
 
@@ -5086,7 +5083,7 @@ if test "${opsys}" = "mingw32"; then
   ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-w32
 else
   ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force
-fi
+fi || AC_MSG_ERROR(['src/epaths.h' could not be made.])
 ], [GCC="$GCC" CPPFLAGS="$CPPFLAGS" opsys="$opsys"])
 
 dnl NB we have to cheat and use the ac_... version because abs_top_srcdir
@@ -5099,3 +5096,5 @@ fi
 ])
 
 AC_OUTPUT
+
+test "$MAKE" = make || AC_MSG_NOTICE([Now you can run '$MAKE'.])