Install a self-contained NS build's libexec directly into the right place
[bpt/emacs.git] / configure.in
index 091edbb..8c3b322 100644 (file)
@@ -4,7 +4,7 @@ dnl     autoconf
 dnl in the directory containing this script.
 dnl If you changed any AC_DEFINES, also run autoheader.
 dnl
-dnl Copyright (C) 1994-1996, 1999-2012  Free Software Foundation, Inc.
+dnl Copyright (C) 1994-1996, 1999-2012 Free Software Foundation, Inc.
 dnl
 dnl  This file is part of GNU Emacs.
 dnl
@@ -22,7 +22,7 @@ dnl  You should have received a copy of the GNU General Public License
 dnl  along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 AC_PREREQ(2.65)
-AC_INIT(emacs, 24.0.96)
+AC_INIT(emacs, 24.1.50)
 AC_CONFIG_HEADER(src/config.h:src/config.in)
 AC_CONFIG_SRCDIR(src/lisp.h)
 AC_CONFIG_AUX_DIR(build-aux)
@@ -492,12 +492,10 @@ case "${canonical}" in
       * )            unported=yes ;;
     esac
     opsys=darwin
-    # Define CPP as follows to make autoconf work correctly.
-    CPP="${CC-cc} -E -no-cpp-precomp"
     # Use fink packages if available.
+    # FIXME?  Is it really our business to decide this for the user?
     if test -d /sw/include && test -d /sw/lib; then
       GCC_TEST_OPTIONS="-I/sw/include -L/sw/lib"
-      CPP="${CPP} ${GCC_TEST_OPTIONS}"
       NON_GCC_TEST_OPTIONS=${GCC_TEST_OPTIONS}
     fi
   ;;
@@ -532,7 +530,6 @@ case "${canonical}" in
     # Without defining _LANGUAGE_C, things get masked out in the headers
     # so that, for instance, grepping for `free' in stdlib.h fails and
     # AC_HEADER_STD_C fails.   (MIPSPro 7.2.1.2m compilers, Irix 6.5.3m).
-    NON_GNU_CPP="/lib/cpp -D_LANGUAGE_C"
     NON_GCC_TEST_OPTIONS="-D_LANGUAGE_C"
   ;;
 
@@ -549,18 +546,15 @@ case "${canonical}" in
     case "${canonical}" in
       *-sunos5.6* | *-solaris2.6* )
                opsys=sol2-6
-               NON_GNU_CPP=/usr/ccs/lib/cpp
                RANLIB="ar -ts"
                ;;
       *-sunos5.[7-9]* | *-solaris2.[7-9]* )
                opsys=sol2-6
                emacs_check_sunpro_c=yes
-               NON_GNU_CPP=/usr/ccs/lib/cpp
                ;;
       *-sunos5* | *-solaris* )
                opsys=sol2-10
                emacs_check_sunpro_c=yes
-               NON_GNU_CPP=/usr/ccs/lib/cpp
                ;;
     esac
     ## Watch out for a compiler that we know will not work.
@@ -581,12 +575,10 @@ case "${canonical}" in
     machine=intel386
     case "${canonical}" in
       *-cygwin )                opsys=cygwin ;;
-      *-darwin* )               opsys=darwin
-                                CPP="${CC-cc} -E -no-cpp-precomp"
-                               ;;
-      *-sysv4.2uw* )           opsys=unixware; NON_GNU_CPP=/lib/cpp ;;
-      *-sysv5uw* )             opsys=unixware; NON_GNU_CPP=/lib/cpp ;;
-      *-sysv5OpenUNIX* )       opsys=unixware; NON_GNU_CPP=/lib/cpp ;;
+      *-darwin* )               opsys=darwin ;;
+      *-sysv4.2uw* )           opsys=unixware ;;
+      *-sysv5uw* )             opsys=unixware ;;
+      *-sysv5OpenUNIX* )       opsys=unixware ;;
       ## Otherwise, we'll fall through to the generic opsys code at the bottom.
     esac
   ;;
@@ -628,116 +620,145 @@ opsysfile="s/${opsys}.h"
 
 
 #### Choose a compiler.
-test -n "$CC" && cc_specified=yes
-
-# Save the value of CFLAGS that the user specified.
-SPECIFIED_CFLAGS="$CFLAGS"
 
 dnl Sets GCC=yes if using gcc.
 AC_PROG_CC
 AM_PROG_CC_C_O
 
-# Initialize gnulib right after verifying that the C compiler works.
-gl_EARLY
-
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
-fi
-
-## If not using gcc, and on Solaris, and no CPP specified, see if
-## using a Sun compiler, which needs -Xs to prevent whitespace.
-if test x"$GCC" != xyes && test x"$emacs_check_sunpro_c" = xyes && \
- test x"$CPP" = x; then
-  AC_MSG_CHECKING([whether we are using a Sun C compiler])
-  AC_CACHE_VAL(emacs_cv_sunpro_c,
-  [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
-[[#ifndef __SUNPRO_C
-fail;
-#endif
-]])], emacs_cv_sunpro_c=yes, emacs_cv_sunpro_c=no)])
-  AC_MSG_RESULT($emacs_cv_sunpro_c)
-
-  if test x"$emacs_cv_sunpro_c" = xyes; then
-    NON_GNU_CPP="$CC -E -Xs"
-  fi
-fi
-
-#### Some systems specify a CPP to use unless we are using GCC.
-#### Now that we know whether we are using GCC, we can decide whether
-#### to use that one.
-if test "x$NON_GNU_CPP" != x && test x$GCC != xyes && test "x$CPP" = x
-then
-  CPP="$NON_GNU_CPP"
-fi
-
-#### Some systems specify a CC to use unless we are using GCC.
-#### Now that we know whether we are using GCC, we can decide whether
-#### to use that one.
-if test "x$NON_GNU_CC" != x && test x$GCC != xyes &&
-  test x$cc_specified != xyes
-then
-  CC="$NON_GNU_CC"
-fi
-
 if test x$GCC = xyes; then
   test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
 else
   test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS"
 fi
 
-### Use -Wdeclaration-after-statement if the compiler supports it
-AC_MSG_CHECKING([whether gcc understands -Wdeclaration-after-statement])
-SAVE_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wdeclaration-after-statement"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], has_option=yes, has_option=no)
-if test $has_option = yes; then
-   C_WARNINGS_SWITCH="-Wdeclaration-after-statement $C_WARNINGS_SWITCH"
-fi
-AC_MSG_RESULT($has_option)
-CFLAGS="$SAVE_CFLAGS"
-unset has_option
-unset SAVE_CFLAGS
+# Initialize gnulib right after choosing the compiler.
+gl_EARLY
 
-### Use -Wold-style-definition if the compiler supports it
-# This can be removed when conversion to standard C is finished.
-AC_MSG_CHECKING([whether gcc understands -Wold-style-definition])
-SAVE_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wold-style-definition"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], has_option=yes, has_option=no)
-if test $has_option = yes; then
-   C_WARNINGS_SWITCH="-Wold-style-definition $C_WARNINGS_SWITCH"
-fi
-AC_MSG_RESULT($has_option)
-CFLAGS="$SAVE_CFLAGS"
-unset has_option
-unset SAVE_CFLAGS
+AC_ARG_ENABLE([gcc-warnings],
+  [AS_HELP_STRING([--enable-gcc-warnings],
+                  [turn on lots of GCC warnings (for developers)])],
+  [case $enableval in
+     yes|no) ;;
+     *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
+   esac
+   gl_gcc_warnings=$enableval],
+  [gl_gcc_warnings=no]
+)
+
+# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
+# ------------------------------------------------
+# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
+# Otherwise, run RUN-IF-NOT-FOUND.
+AC_DEFUN([gl_GCC_VERSION_IFELSE],
+  [AC_PREPROC_IFELSE(
+    [AC_LANG_PROGRAM(
+      [[
+#if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
+/* ok */
+#else
+# error "your version of gcc is older than $1.$2"
+#endif
+      ]]),
+    ], [$3], [$4])
+  ]
+)
+
+# When compiling with GCC, prefer -isystem to -I when including system
+# include files, to avoid generating useless diagnostics for the files.
+if test "$gl_gcc_warnings" != yes; then
+  isystem='-I'
+else
+  isystem='-isystem '
+
+  # This, $nw, is the list of warnings we disable.
+  nw=
+
+  case $with_x_toolkit in
+    lucid | athena | motif)
+       # Old toolkits mishandle 'const'.
+       nw="$nw -Wwrite-strings"
+       ;;
+    *)
+       gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
+       ;;
+  esac
+  AC_SUBST([WERROR_CFLAGS])
+
+  nw="$nw -Waggregate-return"       # anachronistic
+  nw="$nw -Wlong-long"              # C90 is anachronistic
+  nw="$nw -Wc++-compat"             # We don't care about C++ compilers
+  nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
+  nw="$nw -Wtraditional"            # Warns on #elif which we use often
+  nw="$nw -Wcast-qual"              # Too many warnings for now
+  nw="$nw -Wconversion"             # Too many warnings for now
+  nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
+  nw="$nw -Wsign-conversion"        # Too many warnings for now
+  nw="$nw -Woverlength-strings"     # Not a problem these days
+  nw="$nw -Wtraditional-conversion" # Too many warnings for now
+  nw="$nw -Wpadded"                 # Our structs are not padded
+  nw="$nw -Wredundant-decls"        # We regularly (re)declare getenv etc.
+  nw="$nw -Wlogical-op"             # any use of fwrite provokes this
+  nw="$nw -Wformat-nonliteral"      # Emacs does this a lot
+  nw="$nw -Wvla"                    # warnings in gettext.h
+  nw="$nw -Wnested-externs"         # use of XARGMATCH/verify_function__
+  nw="$nw -Wswitch-enum"            # Too many warnings for now
+  nw="$nw -Wswitch-default"         # Too many warnings for now
+  nw="$nw -Wfloat-equal"            # e.g., ftoastr.c
+  nw="$nw -Winline"                 # e.g., dispnew.c's inlining of row_equal_p
+
+  # Emacs doesn't care about shadowing; see
+  # <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
+  nw="$nw -Wshadow"
+
+  # The following lines should be removable at some point.
+  nw="$nw -Wstack-protector"
+  nw="$nw -Wstrict-overflow"
+  nw="$nw -Wsuggest-attribute=const"
+  nw="$nw -Wsuggest-attribute=pure"
+
+  gl_MANYWARN_ALL_GCC([ws])
+  gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
+  for w in $ws; do
+    gl_WARN_ADD([$w])
+  done
+  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
+  gl_WARN_ADD([-Wno-switch])           # Too many warnings for now
+  gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
+  gl_WARN_ADD([-Wno-format-nonliteral])
 
-### Use -Wimplicit-function-declaration if the compiler supports it
-AC_MSG_CHECKING([whether gcc understands -Wimplicit-function-declaration])
-SAVE_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wimplicit-function-declaration"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], has_option=yes, has_option=no)
-if test $has_option = yes; then
-   C_WARNINGS_SWITCH="-Wimplicit-function-declaration $C_WARNINGS_SWITCH"
-fi
-AC_MSG_RESULT($has_option)
-CFLAGS="$SAVE_CFLAGS"
-unset has_option
-unset SAVE_CFLAGS
+  # In spite of excluding -Wlogical-op above, it is enabled, as of
+  # gcc 4.5.0 20090517.
+  gl_WARN_ADD([-Wno-logical-op])
 
-AC_SUBST(C_WARNINGS_SWITCH)
+  gl_WARN_ADD([-fdiagnostics-show-option])
+  gl_WARN_ADD([-funit-at-a-time])
 
+  AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
+  AC_DEFINE([_FORTIFY_SOURCE], [2],
+    [enable compile-time and run-time bounds-checking, and some warnings])
+  AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
 
-#### Some other nice autoconf tests.
+  # We use a slightly smaller set of warning options for lib/.
+  # Remove the following and save the result in GNULIB_WARN_CFLAGS.
+  nw=
+  nw="$nw -Wunused-macros"
 
-dnl checks for programs
-AC_PROG_CPP
-AC_PROG_INSTALL
-if test "x$RANLIB" = x; then
-  AC_PROG_RANLIB
+  gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
+  AC_SUBST([GNULIB_WARN_CFLAGS])
 fi
 
+
+
+dnl Some other nice autoconf tests.
+dnl These are commented out, since gl_EARLY and/or Autoconf already does them.
+dnl AC_PROG_INSTALL
+dnl AC_PROG_MKDIR_P
+dnl if test "x$RANLIB" = x; then
+dnl   AC_PROG_RANLIB
+dnl fi
+
 ## Although we're running on an amd64 kernel, we're actually compiling for
 ## the x86 architecture.  The user should probably have provided an
 ## explicit --build to `configure', but if everything else than the kernel
@@ -758,12 +779,12 @@ dnl Don't use GZIP, which is used by gzip for additional parameters.
 AC_PATH_PROG(GZIP_PROG, gzip)
 
 
-## Need makeinfo >= 4.6 (?) to build the manuals.
+## Need makeinfo >= 4.7 (?) to build the manuals.
 AC_PATH_PROG(MAKEINFO, makeinfo, no)
 dnl By this stage, configure has already checked for egrep and set EGREP,
 dnl or exited with an error if no egrep was found.
 if test "$MAKEINFO" != "no" && \
-  test x"`$MAKEINFO --version 2> /dev/null | $EGREP 'texinfo[[^0-9]]*([[1-4]][[0-9]]+|[[5-9]]|4\.[[6-9]]|4\.[[1-5]][[0-9]]+)'`" = x; then
+  test x"`$MAKEINFO --version 2> /dev/null | $EGREP 'texinfo[[^0-9]]*([[1-4]][[0-9]]+|[[5-9]]|4\.[[7-9]]|4\.[[1-6]][[0-9]]+)'`" = x; then
    MAKEINFO=no
 fi
 
@@ -783,7 +804,7 @@ if test "$MAKEINFO" = "no"; then
   if test "x${with_makeinfo}" = "xno"; then
     HAVE_MAKEINFO=no
   elif test ! -e $srcdir/info/emacs; then
-    AC_MSG_ERROR( [You do not seem to have makeinfo >= 4.6, and your
+    AC_MSG_ERROR( [You do not seem to have makeinfo >= 4.7, and your
 source tree does not seem to have pre-built manuals in the `info' directory.
 Either install a suitable version of makeinfo, or re-run configure
 with the `--without-makeinfo' option to build without the manuals.] )
@@ -791,6 +812,12 @@ 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)
+
 dnl Add our options to ac_link now, after it is set up.
 
 if test x$GCC = xyes; then
@@ -821,11 +848,6 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
   [AC_MSG_RESULT(no)])
 
 
-# The value of CPP is a quoted variable reference, so we need to do this
-# to get its actual value...
-CPP=`eval "echo $CPP"`
-
-
 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
@@ -877,7 +899,9 @@ case "$opsys" in
    ## Let `ld' find image libs and similar things in /usr/local/lib.
    ## The system compiler, GCC, has apparently been modified to not
    ## look there, contrary to what a stock GCC would do.
-   LD_SWITCH_SYSTEM=-L/usr/local/lib
+### It's not our place to do this.  See bug#10313#17.
+###   LD_SWITCH_SYSTEM=-L/usr/local/lib
+      :
    ;;
 
   gnu-linux)
@@ -886,7 +910,9 @@ case "$opsys" in
    ;;
 
   netbsd)
-   LD_SWITCH_SYSTEM="-Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib"
+### It's not our place to do this.  See bug#10313#17.
+###   LD_SWITCH_SYSTEM="-Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib"
+      :
    ;;
 
   openbsd)
@@ -899,7 +925,7 @@ AC_SUBST(LD_SWITCH_SYSTEM)
 
 ac_link="$ac_link $LD_SWITCH_SYSTEM"
 
-## This setting of LD_SWITCH_SYSTEM references LD_SWITCH_X_SITE_AUX,
+## This setting of LD_SWITCH_SYSTEM references LD_SWITCH_X_SITE_RPATH,
 ## which has not been defined yet.  When this was handled with cpp,
 ## it was expanded to null when configure sourced the s/*.h file.
 ## Thus LD_SWITCH_SYSTEM had different values in configure and the Makefiles.
@@ -911,8 +937,7 @@ ac_link="$ac_link $LD_SWITCH_SYSTEM"
 ## LD_SWITCH_SYSTEM_TEMACS.
 case "$opsys" in
   netbsd|openbsd)
-   ## _AUX_RPATH is like _AUX, but uses -rpath instead of -R.
-   LD_SWITCH_SYSTEM="\$(LD_SWITCH_X_SITE_AUX_RPATH) $LD_SWITCH_SYSTEM" ;;
+   LD_SWITCH_SYSTEM="\$(LD_SWITCH_X_SITE_RPATH) $LD_SWITCH_SYSTEM" ;;
 esac
 
 
@@ -1124,17 +1149,19 @@ AC_DEFUN([PKG_CHECK_MODULES], [
      if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
         AC_MSG_CHECKING(for $2)
 
-        if $PKG_CONFIG --exists "$2" 2>&AS_MESSAGE_LOG_FD; then
-            AC_MSG_RESULT(yes)
+        if $PKG_CONFIG --exists "$2" 2>&AS_MESSAGE_LOG_FD &&
+          $1_CFLAGS=`$PKG_CONFIG --cflags "$2" 2>&AS_MESSAGE_LOG_FD` &&
+          $1_LIBS=`$PKG_CONFIG --libs "$2" 2>&AS_MESSAGE_LOG_FD`; then
+           edit_cflags="
+             s,///*,/,g
+             s/^/ /
+             s/ -I/ $isystem/g
+             s/^ //
+           "
+           $1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"`
+           $1_LIBS=`AS_ECHO(["$$1_LIBS"]) | sed -e 's,///*,/,g'`
+            AC_MSG_RESULT([yes CFLAGS='$$1_CFLAGS' LIBS='$$1_LIBS'])
             succeeded=yes
-
-            AC_MSG_CHECKING($1_CFLAGS)
-            $1_CFLAGS=`$PKG_CONFIG --cflags "$2"|sed -e 's,///*,/,g'`
-            AC_MSG_RESULT($$1_CFLAGS)
-
-            AC_MSG_CHECKING($1_LIBS)
-            $1_LIBS=`$PKG_CONFIG --libs "$2"|sed -e 's,///*,/,g'`
-            AC_MSG_RESULT($$1_LIBS)
         else
             AC_MSG_RESULT(no)
             $1_CFLAGS=""
@@ -1395,10 +1422,8 @@ if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
    fi
    if test $ac_enable_autodepend = yes; then
       DEPFLAGS='-MMD -MF ${DEPDIR}/$*.d -MP'
-      ## In parallel builds, another make might create depdir between
-      ## the first test and mkdir, so stick another test on the end.
-      ## Or use install-sh -d?  mkdir -p is not portable.
-      MKDEPDIR='test -d ${DEPDIR} || mkdir ${DEPDIR} || test -d ${DEPDIR}'
+      ## MKDIR_P is documented (see AC_PROG_MKDIR_P) to be parallel-safe.
+      MKDEPDIR='${MKDIR_P} ${DEPDIR}'
       deps_frag=autodeps.mk
    fi
 fi
@@ -1424,22 +1449,11 @@ else
   window_system=x11
 fi
 
-## Workaround for bug in autoconf <= 2.62.
-## http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01551.html
-## No need to do anything special for these standard directories.
-if test -n "${x_libraries}" && test x"${x_libraries}" != xNONE; then
-
-   x_libraries=`echo :${x_libraries}: | sed -e 's|:/usr/lib64:|:|g' -e 's|:/lib64:|:|g' -e 's|^:||' -e 's|:$||'`
-
-fi
-
-LD_SWITCH_X_SITE_AUX=
-LD_SWITCH_X_SITE_AUX_RPATH=
+LD_SWITCH_X_SITE_RPATH=
 if test "${x_libraries}" != NONE; then
   if test -n "${x_libraries}"; then
     LD_SWITCH_X_SITE=-L`echo ${x_libraries} | sed -e "s/:/ -L/g"`
-    LD_SWITCH_X_SITE_AUX=-R`echo ${x_libraries} | sed -e "s/:/ -R/g"`
-    LD_SWITCH_X_SITE_AUX_RPATH=`echo ${LD_SWITCH_X_SITE_AUX} | sed -e 's/-R/-Wl,-rpath,/'`
+    LD_SWITCH_X_SITE_RPATH=-Wl,-rpath,`echo ${x_libraries} | sed -e "s/:/ -Wl,-rpath,/g"`
   fi
   x_default_search_path=""
   x_search_path=${x_libraries}
@@ -1462,11 +1476,10 @@ ${x_library}/X11/%T/%N%S"
     fi
   done
 fi
-AC_SUBST(LD_SWITCH_X_SITE_AUX)
-AC_SUBST(LD_SWITCH_X_SITE_AUX_RPATH)
+AC_SUBST(LD_SWITCH_X_SITE_RPATH)
 
 if test "${x_includes}" != NONE && test -n "${x_includes}"; then
-  C_SWITCH_X_SITE=-I`echo ${x_includes} | sed -e "s/:/ -I/g"`
+  C_SWITCH_X_SITE="$isystem"`echo ${x_includes} | sed -e "s/:/ $isystem/g"`
 fi
 
 if test x"${x_includes}" = x; then
@@ -1496,20 +1509,17 @@ CPPFLAGS="$CPPFLAGS -x objective-c"
 CFLAGS="$CFLAGS -x objective-c"
 TEMACS_LDFLAGS2="\${LDFLAGS}"
 GNU_OBJC_CFLAGS=
-dnl I don't think it's especially important, but src/Makefile.in
-dnl (now the only user of ns_appdir) used to go to the trouble of adding a
-dnl trailing "/" to it, so now we do it here.
 if test "${with_ns}" != no; then
   if test "${opsys}" = darwin; then
      NS_IMPL_COCOA=yes
      ns_appdir=`pwd`/nextstep/Emacs.app
-     ns_appbindir=${ns_appdir}/Contents/MacOS/
+     ns_appbindir=${ns_appdir}/Contents/MacOS
      ns_appresdir=${ns_appdir}/Contents/Resources
      ns_appsrc=${srcdir}/nextstep/Cocoa/Emacs.base
   elif test -f $GNUSTEP_CONFIG_FILE; then
      NS_IMPL_GNUSTEP=yes
      ns_appdir=`pwd`/nextstep/Emacs.app
-     ns_appbindir=${ns_appdir}/
+     ns_appbindir=${ns_appdir}
      ns_appresdir=${ns_appdir}/Resources
      ns_appsrc=${srcdir}/nextstep/GNUstep/Emacs.base
      dnl FIXME sourcing this several times in subshells seems inefficient.
@@ -1553,17 +1563,17 @@ fail;
   AC_CHECK_HEADER([AppKit/AppKit.h], [HAVE_NS=yes],
                  [AC_MSG_ERROR([`--with-ns' was specified, but the include
   files are missing or cannot be compiled.])])
-  NS_HAVE_NSINTEGER=yes
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <Foundation/NSObjCRuntime.h>],
                                      [NSInteger i;])],
                    ns_have_nsinteger=yes,
                    ns_have_nsinteger=no)
-  if test $ns_have_nsinteger = no; then
-    NS_HAVE_NSINTEGER=no
+  if test $ns_have_nsinteger = yes; then
+    AC_DEFINE(NS_HAVE_NSINTEGER, 1, [Define to 1 if `NSInteger' is defined.])
   fi
 fi
 AC_SUBST(TEMACS_LDFLAGS2)
 
+LEIM_INSTALLDIR="\${install_prefix}/leim"
 ns_frag=/dev/null
 NS_OBJ=
 NS_OBJC_OBJ=
@@ -1578,7 +1588,10 @@ if test "${HAVE_NS}" = yes; then
   if test "${EN_NS_SELF_CONTAINED}" = yes; then
      prefix=${ns_appresdir}
      exec_prefix=${ns_appbindir}
-     libexecdir=${ns_appbindir}/libexec
+     dnl This one isn't really used, only archlibdir is.
+     libexecdir="\${ns_appbindir}/libexec"
+     archlibdir="\${ns_appbindir}/libexec"
+     LEIM_INSTALLDIR="\${ns_appresdir}/leim"
   fi
   ns_frag=$srcdir/src/ns.mk
   NS_OBJ="fontset.o fringe.o image.o"
@@ -1586,6 +1599,7 @@ if test "${HAVE_NS}" = yes; then
 fi
 CFLAGS="$tmp_CFLAGS"
 CPPFLAGS="$tmp_CPPFLAGS"
+AC_SUBST(LEIM_INSTALLDIR)
 AC_SUBST(NS_OBJ)
 AC_SUBST(NS_OBJC_OBJ)
 AC_SUBST(LIB_STANDARD)
@@ -1642,17 +1656,20 @@ esac
 # Do the opsystem or machine files prohibit the use of the GNU malloc?
 # Assume not, until told otherwise.
 GNU_MALLOC=yes
-doug_lea_malloc=yes
-AC_CHECK_FUNC(malloc_get_state, ,doug_lea_malloc=no)
-AC_CHECK_FUNC(malloc_set_state, ,doug_lea_malloc=no)
-AC_CACHE_CHECK(whether __after_morecore_hook exists,
-              emacs_cv_var___after_morecore_hook,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern void (* __after_morecore_hook)();]],[[__after_morecore_hook = 0]])],
-  emacs_cv_var___after_morecore_hook=yes,
-  emacs_cv_var___after_morecore_hook=no)])
-if test $emacs_cv_var___after_morecore_hook = no; then
-  doug_lea_malloc=no
-fi
+
+AC_CACHE_CHECK(
+  [whether malloc is Doug Lea style],
+  [emacs_cv_var_doug_lea_malloc],
+  [AC_LINK_IFELSE(
+     [AC_LANG_PROGRAM(
+        [[#include <malloc.h>
+         static void hook (void) {}]],
+        [[malloc_set_state (malloc_get_state ());
+         __after_morecore_hook = hook;
+         __malloc_initialize_hook = hook;]])],
+     [emacs_cv_var_doug_lea_malloc=yes],
+     [emacs_cv_var_doug_lea_malloc=no])])
+doug_lea_malloc=$emacs_cv_var_doug_lea_malloc
 
 
 dnl See comments in aix4-2.h about maybe using system malloc there.
@@ -1789,9 +1806,9 @@ if test "${HAVE_X11}" = "yes"; then
   CPPFLAGS="$C_SWITCH_X_SITE $CPPFLAGS"
 
   # On Solaris, arrange for LD_RUN_PATH to point to the X libraries for tests.
-  # This is handled by LD_SWITCH_X_SITE_AUX during the real build,
-  # but it's more convenient here to set LD_RUN_PATH
-  # since this also works on hosts that don't understand LD_SWITCH_X_SITE_AUX.
+  # This is handled by LD_SWITCH_X_SITE_RPATH during the real build,
+  # but it's more convenient here to set LD_RUN_PATH since this
+  # also works on hosts that don't understand LD_SWITCH_X_SITE_RPATH.
   if test "${x_libraries}" != NONE && test -n "${x_libraries}"; then
     LD_RUN_PATH=$x_libraries${LD_RUN_PATH+:}$LD_RUN_PATH
     export LD_RUN_PATH
@@ -2010,8 +2027,7 @@ if test "${HAVE_GTK}" = "yes"; then
 fi
 
 dnl D-Bus has been tested under GNU/Linux only.  Must be adapted for
-dnl other platforms.  Support for higher D-Bus versions than 1.0 is
-dnl also not configured.
+dnl other platforms.
 HAVE_DBUS=no
 DBUS_OBJ=
 if test "${with_dbus}" = "yes"; then
@@ -2019,7 +2035,13 @@ if test "${with_dbus}" = "yes"; then
    if test "$HAVE_DBUS" = yes; then
      LIBS="$LIBS $DBUS_LIBS"
      AC_DEFINE(HAVE_DBUS, 1, [Define to 1 if using D-Bus.])
-     AC_CHECK_FUNCS([dbus_watch_get_unix_fd])
+     dnl dbus_watch_get_unix_fd has been introduced in D-Bus 1.1.1.
+     dnl dbus_validate_* have been introduced in D-Bus 1.5.12.
+     AC_CHECK_FUNCS(dbus_watch_get_unix_fd \
+                   dbus_validate_bus_name \
+                    dbus_validate_path \
+                   dbus_validate_interface \
+                   dbus_validate_member)
      DBUS_OBJ=dbusbind.o
    fi
 fi
@@ -2592,7 +2614,7 @@ AC_SUBST(LIBGPM)
 dnl Check for malloc/malloc.h on darwin
 AC_CHECK_HEADER(malloc/malloc.h, [AC_DEFINE(HAVE_MALLOC_MALLOC_H, 1, [Define to 1 if you have the <malloc/malloc.h> header file.])])
 
-C_SWITCH_X_SYSTEM=
+GNUSTEP_CFLAGS=
 ### Use NeXTstep API to implement GUI.
 if test "${HAVE_NS}" = "yes"; then
   AC_DEFINE(HAVE_NS, 1, [Define to 1 if you are using the NeXTstep API, either GNUstep or Cocoa on Mac OS X.])
@@ -2603,15 +2625,10 @@ if test "${HAVE_NS}" = "yes"; then
     AC_DEFINE(NS_IMPL_GNUSTEP, 1, [Define to 1 if you are using NS windowing under GNUstep.])
     # See also .m.o rule in Makefile.in */
     # FIXME: are all these flags really needed?  Document here why.  */
-    dnl FIXME this should be renamed to GNUSTEP_CFLAGS, and only
-    dnl used in src/Makefile.in.
-    C_SWITCH_X_SYSTEM="-D_REENTRANT -fPIC -fno-strict-aliasing -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
+    GNUSTEP_CFLAGS="-D_REENTRANT -fPIC -fno-strict-aliasing -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
     ## Extra CFLAGS applied to src/*.m files.
     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"
   fi
-  if test "${NS_HAVE_NSINTEGER}" = "yes"; then
-    AC_DEFINE(NS_HAVE_NSINTEGER, 1, [Define to 1 if `NSInteger' is defined.])
-  fi
   # We also have mouse menus.
   HAVE_MENUS=yes
   OTHER_FILES=ns-app
@@ -2754,6 +2771,7 @@ __fpending mblen mbrlen mbsinit strsignal setitimer ualarm \
 sendto recvfrom getsockopt setsockopt getsockname getpeername \
 gai_strerror mkstemp getline getdelim mremap fsync sync \
 difftime mempcpy mblen mbrlen posix_memalign \
+getpwent endpwent getgrent endgrent \
 cfmakeraw cfsetspeed copysign __executable_start)
 
 dnl Cannot use AC_CHECK_FUNCS
@@ -2802,7 +2820,7 @@ AC_DEFUN([tputs_link_source], [
 ])
 # Maybe curses should be tried earlier?
 # See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9736#35
-for tputs_library in '' ncurses terminfo termcap curses; do
+for tputs_library in '' tinfo ncurses terminfo termcap curses; do
   OLIBS=$LIBS
   if test -z "$tputs_library"; then
     LIBS_TERMCAP=
@@ -2822,41 +2840,28 @@ done
 AC_MSG_RESULT([$msg])
 if test "X$msg" = Xno; then
   AC_MSG_ERROR([The required function `tputs' was not found in any library.
-These libraries were tried: libncurses, libterminfo, libtermcap, libcurses.
+The following libraries were tried (in order):
+  libtinfo, libncurses, libterminfo, libtermcap, libcurses
 Please try installing whichever of these libraries is most appropriate
 for your system, together with its header files.
 For example, a libncurses-dev(el) or similar package.])
 fi
-# Must define this when any termcap library is found.
-AC_DEFINE(HAVE_LIBNCURSES, 1,
-          [Define to 1 if you have the `ncurses' library (-lncurses).])
-## FIXME This was the cpp logic, but I am not sure it is right.
-## The above test has not necessarily found libncurses.
-HAVE_LIBNCURSES=yes
-
-## Use terminfo instead of termcap?
-## Note only system files NOT using terminfo are:
-## freebsd < 40000, ms-w32, msdos, netbsd < 599002500, and
-## darwin|gnu without ncurses.
-TERMINFO=no
-case "$opsys" in
-  ## cygwin: Fewer environment variables to go wrong, more terminal types.
-  ## hpux10-20: Use the system provided termcap(3) library.
-  ## openbsd: David Mazieres <dm@reeducation-labor.lcs.mit.edu> says this
-  ##  is necessary.  Otherwise Emacs dumps core when run -nw.
-  aix4-2|cygwin|hpux*|irix6-5|openbsd|sol2*|unixware) TERMINFO=yes ;;
 
+## Use termcap instead of terminfo?
+## Only true for: freebsd < 40000, ms-w32, msdos, netbsd < 599002500.
+TERMINFO=yes
+## FIXME?  In the cases below where we unconditionally set
+## LIBS_TERMCAP="-lncurses", this overrides LIBS_TERMCAP = -ltinfo,
+## if that was found above to have tputs.
+## Should we use the gnu* logic everywhere?
+case "$opsys" in
   ## darwin: Prevents crashes when running Emacs in Terminal.app under 10.2.
   ##  The ncurses library has been moved out of the System framework in
   ##  Mac OS X 10.2.  So if configure detects it, set the command-line
   ##  option to use it.
-  darwin|gnu*)
-    ## (HAVE_LIBNCURSES was not always true, but is since 2010-03-18.)
-    if test "x$HAVE_LIBNCURSES" = "xyes"; then
-      TERMINFO=yes
-      LIBS_TERMCAP="-lncurses"
-    fi
-    ;;
+  darwin) LIBS_TERMCAP="-lncurses" ;;
+
+  gnu*) test -z "$LIBS_TERMCAP" && LIBS_TERMCAP="-lncurses" ;;
 
   freebsd)
     AC_MSG_CHECKING([whether FreeBSD is new enough to use terminfo])
@@ -2870,34 +2875,29 @@ fail;
     AC_MSG_RESULT($emacs_cv_freebsd_terminfo)
 
     if test $emacs_cv_freebsd_terminfo = yes; then
-      TERMINFO=yes
       LIBS_TERMCAP="-lncurses"
     else
+      TERMINFO=no
       LIBS_TERMCAP="-ltermcap"
     fi
     ;;
 
   netbsd)
-    if test $ac_cv_search_tputs = -lterminfo; then
-      TERMINFO=yes
-      LIBS_TERMCAP="-lterminfo"
-    else
+    if test "x$LIBS_TERMCAP" != "x-lterminfo"; then
+      TERMINFO=no
       LIBS_TERMCAP="-ltermcap"
     fi
     ;;
 
-esac
+  openbsd) LIBS_TERMCAP="-lncurses" ;;
 
-case "$opsys" in
   ## hpux: Make sure we get select from libc rather than from libcurses
   ##  because libcurses on HPUX 10.10 has a broken version of select.
   ##  We used to use -lc -lcurses, but this may be cleaner.
+  ## FIXME?  But TERMINFO = yes on hpux (it used to be explicitly
+  # set that way, now it uses the default).  Isn't this a contradiction?
   hpux*) LIBS_TERMCAP="-ltermcap" ;;
 
-  openbsd) LIBS_TERMCAP="-lncurses" ;;
-
-  ## Must use system termcap, if we use any termcap.  It does special things.
-  sol2*) test "$TERMINFO" != yes && LIBS_TERMCAP="-ltermcap" ;;
 esac
 
 TERMCAP_OBJ=tparam.o
@@ -3225,7 +3225,7 @@ AC_SUBST(gameuser)
 ## end of LIBX_BASE, but nothing ever set it.
 AC_SUBST(LD_SWITCH_X_SITE)
 AC_SUBST(C_SWITCH_X_SITE)
-AC_SUBST(C_SWITCH_X_SYSTEM)
+AC_SUBST(GNUSTEP_CFLAGS)
 AC_SUBST(CFLAGS)
 ## Used in lwlib/Makefile.in.
 AC_SUBST(X_TOOLKIT_TYPE)
@@ -3440,13 +3440,14 @@ case "$opsys" in
      LD_SWITCH_SYSTEM_TEMACS="-X $LD_SWITCH_SYSTEM_TEMACS"
    ;;
 
-  ## LD_SWITCH_X_SITE_AUX is a -R option saying where to find X at run-time.
-  ## When handled by cpp, this was in LD_SWITCH_SYSTEM.  However, at
-  ## the point where configure sourced the s/*.h file, LD_SWITCH_X_SITE_AUX
+  ## LD_SWITCH_X_SITE_RPATH is a -rpath option saying where to
+  ## find X at run-time.
+  ## When handled by cpp, this was in LD_SWITCH_SYSTEM.  However, at the
+  ## point where configure sourced the s/*.h file, LD_SWITCH_X_SITE_RPATH
   ## had not yet been defined and was expanded to null.  Hence LD_SWITCH_SYSTEM
   ## had different values in configure (in ac_link) and src/Makefile.in.
   ## It seems clearer therefore to put this piece in LD_SWITCH_SYSTEM_TEMACS.
-  gnu*) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_AUX_RPATH)" ;;
+  gnu*) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_RPATH)" ;;
 
   *) LD_SWITCH_SYSTEM_TEMACS= ;;
 esac
@@ -3805,6 +3806,13 @@ to run if these resources are not installed."
    echo
 fi
 
+if test "${opsys}" = "cygwin"; then
+  case `uname -r` in
+    1.5.*) AC_MSG_WARN([[building Emacs on Cygwin 1.5 is not supported.]])
+           echo
+          ;;
+  esac
+fi
 
 # Remove any trailing slashes in these variables.
 [test "${prefix}" != NONE &&
@@ -3837,6 +3845,16 @@ if test -f $srcdir/${opt_makefile}.in; then
   AC_CONFIG_FILES([test/automated/Makefile])
 fi
 
+
+dnl admin/ may or may not be present.
+opt_makefile=admin/unidata/Makefile
+
+if test -f $srcdir/${opt_makefile}.in; then
+  SUBDIR_MAKEFILES="$SUBDIR_MAKEFILES $opt_makefile"
+  AC_CONFIG_FILES([admin/unidata/Makefile])
+fi
+
+
 SUBDIR_MAKEFILES_IN=`echo " ${SUBDIR_MAKEFILES}" | sed -e 's| | $(srcdir)/|g' -e 's|Makefile|Makefile.in|g'`
 
 AC_SUBST(SUBDIR_MAKEFILES_IN)
@@ -3859,7 +3877,7 @@ dnl the use of force in the `epaths-force' rule in Makefile.in.
 AC_CONFIG_COMMANDS([epaths], [
 echo creating src/epaths.h
 ${MAKE-make} epaths-force
-], [GCC="$GCC" NON_GNU_CPP="$NON_GNU_CPP" CPP="$CPP" CPPFLAGS="$CPPFLAGS"])
+], [GCC="$GCC" CPPFLAGS="$CPPFLAGS"])
 
 AC_CONFIG_COMMANDS([gdbinit], [
 if test ! -f src/.gdbinit && test -f $srcdir/src/.gdbinit; then