]> code.delx.au - gnu-emacs/blobdiff - configure.in
merge from upstream. currently seems to have bitroted and i get segfaults
[gnu-emacs] / configure.in
index ea844262833634bff7609755a5d1a50b7410656f..6fd9c76530e277633b0f1369cafc109de2eb000c 100644 (file)
@@ -4,9 +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, 1995, 1996, 1999, 2000, 2001, 2002, 2003, 2004,
-dnl    2005, 2006, 2007, 2008, 2009, 2010
-dnl    Free Software Foundation, Inc.
+dnl Copyright (C) 1994-1996, 1999-2011  Free Software Foundation, Inc.
 dnl
 dnl  This file is part of GNU Emacs.
 dnl
@@ -27,6 +25,7 @@ AC_PREREQ(2.65)
 AC_INIT(emacs, 24.0.50)
 AC_CONFIG_HEADER(src/config.h:src/config.in)
 AC_CONFIG_SRCDIR(src/lisp.h)
+AM_INIT_AUTOMAKE
 
 dnl Support for --program-prefix, --program-suffix and
 dnl --program-transform-name options
@@ -45,8 +44,6 @@ archlibdir='${libexecdir}/emacs/${version}/${configuration}'
 docdir='${datadir}/emacs/${version}/etc'
 gamedir='${localstatedir}/games/emacs'
 
-gameuser=games
-
 dnl OPTION_DEFAULT_OFF(NAME, HELP-STRING)
 dnl Create a new --with option that defaults to being disabled.
 dnl NAME is the base name of the option.  The shell variable with_NAME
@@ -203,6 +200,12 @@ AC_ARG_WITH([crt-dir],dnl
 The default is /usr/lib, or /usr/lib64 on some platforms.])])
 CRT_DIR="${with_crt_dir}"
 
+AC_ARG_WITH(gameuser,dnl
+[AS_HELP_STRING([--with-gameuser=USER],[user for shared game score files])])
+test "X${with_gameuser}" != X && test "${with_gameuser}" != yes \
+  && gameuser="${with_gameuser}"
+test "X$gameuser" = X && gameuser=games
+
 AC_ARG_WITH([gnustep-conf],dnl
 [AS_HELP_STRING([--with-gnustep-conf=PATH],[path to GNUstep.conf; default $GNUSTEP_CONFIG_FILE, or /etc/GNUstep/GNUstep.conf])])
 test "X${with_gnustep_conf}" != X && test "${with_gnustep_conf}" != yes && \
@@ -412,13 +415,27 @@ dnl quotation begins
 machine='' opsys='' unported=no
 case "${canonical}" in
 
+  ## GNU/Linux ports
+  *-*-linux-gnu*)
+    opsys=gnu-linux
+    case ${canonical} in
+      alpha*)  machine=alpha ;;
+      s390-*)  machine=ibms390 ;;
+      s390x-*) machine=ibms390x ;;
+      powerpc*)        machine=macppc ;;
+      sparc*)  machine=sparc ;;
+      ia64*)   machine=ia64 ;;
+      m68k*)   machine=m68k ;;
+      x86_64*) machine=amdx86-64 ;;
+    esac
+  ;;
+
   ## FreeBSD ports
   *-*-freebsd* )
     opsys=freebsd
     case "${canonical}" in
       alpha*)           machine=alpha ;;
       amd64-*|x86_64-*) machine=amdx86-64 ;;
-      arm*)             machine=arm ;;
       ia64-*)           machine=ia64 ;;
       i[3456]86-*)      machine=intel386 ;;
       powerpc-*)        machine=macppc ;;
@@ -447,13 +464,9 @@ case "${canonical}" in
     case "${canonical}" in
       alpha*)      machine=alpha ;;
       x86_64-*)    machine=amdx86-64 ;;
-      arm-*)       machine=arm ;;
-      hppa-*)      machine=hp800 ;;
       i[3456]86-*) machine=intel386 ;;
       m68k-*)      machine=m68k ;;
       powerpc-*)   machine=macppc ;;
-      mips-*)      machine=mips ;;
-      mipse[bl]-*) machine=mips ;;
       sparc*-)     machine=sparc ;;
       vax-*)       machine=vax ;;
     esac
@@ -465,8 +478,6 @@ case "${canonical}" in
     case "${canonical}" in
       alpha*)    machine=alpha ;;
       x86_64-*)  machine=amdx86-64 ;;
-      arm-*)     machine=arm ;;
-      hppa-*)    machine=hp800 ;;
       i386-*)    machine=intel386 ;;
       powerpc-*) machine=macppc ;;
       sparc*)    machine=sparc ;;
@@ -474,14 +485,6 @@ case "${canonical}" in
     esac
   ;;
 
-  alpha*-*-linux-gnu* )
-    machine=alpha opsys=gnu-linux
-  ;;
-
-  arm*-*-linux-gnu* )
-    machine=arm opsys=gnu-linux
-  ;;
-
   ## Apple Darwin / Mac OS X
   *-apple-darwin* )
     case "${canonical}" in
@@ -503,24 +506,25 @@ case "${canonical}" in
 
   ## HP 9000 series 700 and 800, running HP/UX
   hppa*-hp-hpux10.2* )
-    machine=hp800 opsys=hpux10-20
+    opsys=hpux10-20
   ;;
   hppa*-hp-hpux1[1-9]* )
-    machine=hp800 opsys=hpux11
+    opsys=hpux11
     CFLAGS="-D_INCLUDE__STDC_A1_SOURCE $CFLAGS"
   ;;
 
+  ia64*-hp-hpux1[1-9]* )
+    machine=hp800 opsys=hpux11
+    ## FIXME.  Peter O'Gorman reports that dumping using unexelf.o doesn't
+    ## work either: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=6811
+    CANNOT_DUMP=yes
+  ;;
+
   hppa*-*-linux-gnu* )
     machine=hp800 opsys=gnu-linux
   ;;
 
   ## IBM machines
-  s390-*-linux-gnu* )
-    machine=ibms390 opsys=gnu-linux
-  ;;
-  s390x-*-linux-gnu* )
-    machine=ibms390x opsys=gnu-linux
-  ;;
   rs6000-ibm-aix4.[23]* )
     machine=ibmrs6000 opsys=aix4-2
   ;;
@@ -534,11 +538,6 @@ case "${canonical}" in
     machine=ibmrs6000 opsys=aix4-2
   ;;
 
-  ## Macintosh PowerPC
-  powerpc*-*-linux-gnu* )
-    machine=macppc opsys=gnu-linux
-  ;;
-
   ## Silicon Graphics machines
   ## Iris 4D
   mips-sgi-irix6.5 )
@@ -551,10 +550,6 @@ case "${canonical}" in
   ;;
 
   ## Suns
-  sparc-*-linux-gnu* | sparc64-*-linux-gnu* )
-    machine=sparc opsys=gnu-linux
-  ;;
-
   *-sun-solaris* \
     | i[3456]86-*-solaris2* | i[3456]86-*-sunos5* \
     | x86_64-*-solaris2*    | x86_64-*-sunos5*)
@@ -594,11 +589,6 @@ case "${canonical}" in
     esac
   ;;
 
-  ## IA-64
-  ia64*-*-linux* )
-    machine=ia64 opsys=gnu-linux
-  ;;
-
   ## Intel 386 machines where we don't care about the manufacturer.
   i[3456]86-*-* )
     machine=intel386
@@ -607,7 +597,6 @@ case "${canonical}" in
       *-darwin* )               opsys=darwin
                                 CPP="${CC-cc} -E -no-cpp-precomp"
                                ;;
-      *-linux-gnu* )           opsys=gnu-linux ;;
       *-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 ;;
@@ -615,32 +604,6 @@ case "${canonical}" in
     esac
   ;;
 
-  ## m68k Linux-based GNU system
-  m68k-*-linux-gnu* )
-    machine=m68k opsys=gnu-linux
-  ;;
-
-  ## Mips Linux-based GNU system
-  mips-*-linux-gnu* | mipsel-*-linux-gnu* \
-    | mips64-*-linux-gnu* | mips64el-*-linux-gnu* )
-    machine=mips opsys=gnu-linux
-  ;;
-
-  ## AMD x86-64 Linux-based GNU system
-  x86_64-*-linux-gnu* )
-    machine=amdx86-64 opsys=gnu-linux
-  ;;
-
-  ## Tensilica Xtensa Linux-based GNU system
-  xtensa*-*-linux-gnu* )
-    machine=xtensa opsys=gnu-linux
-    ;;
-
-  ## SuperH Linux-based GNU system
-  sh[34]*-*-linux-gnu* )
-    machine=sh3 opsys=gnu-linux
-  ;;
-
   * )
     unported=yes
   ;;
@@ -669,7 +632,11 @@ if test $unported = yes; then
 Check `etc/MACHINES' for recognized configuration names.])
 fi
 
-machfile="m/${machine}.h"
+if test -n "$machine"; then
+  machfile="m/${machine}.h"
+else
+  machfile=
+fi
 opsysfile="s/${opsys}.h"
 
 
@@ -681,6 +648,10 @@ 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
@@ -728,9 +699,6 @@ else
   test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS"
 fi
 
-dnl checks for Unix variants
-AC_USE_SYSTEM_EXTENSIONS
-
 ### Use -Wno-pointer-sign if the compiler supports it
 AC_MSG_CHECKING([whether gcc understands -Wno-pointer-sign])
 SAVE_CFLAGS="$CFLAGS"
@@ -834,9 +802,12 @@ fi
 ## should test for it as it does for any other build requirement.
 ## We use the presence of $srcdir/info/emacs to distinguish a release,
 ## with pre-built manuals, from a Bazaar checkout.
+HAVE_MAKEINFO=yes
+
 if test "$MAKEINFO" = "no"; then
+  MAKEINFO=makeinfo
   if test "x${with_makeinfo}" = "xno"; then
-    MAKEINFO=off
+    HAVE_MAKEINFO=no
   elif test ! -e $srcdir/info/emacs; then
     AC_MSG_ERROR( [You do not seem to have makeinfo >= 4.6, and your
 source tree does not seem to have pre-built manuals in the `info' directory.
@@ -844,6 +815,7 @@ Either install a suitable version of makeinfo, or re-run configure
 with the `--without-makeinfo' option to build without the manuals.] )
   fi
 fi
+AC_SUBST(HAVE_MAKEINFO)
 
 dnl Add our options to ac_link now, after it is set up.
 
@@ -869,7 +841,7 @@ else
 fi
 
 AC_MSG_CHECKING([for -znocombreloc])
-AC_LINK_IFELSE([main(){return 0;}],
+AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
   [AC_MSG_RESULT(yes)],
   LDFLAGS=$late_LDFLAGS
   [AC_MSG_RESULT(no)])
@@ -880,16 +852,16 @@ AC_LINK_IFELSE([main(){return 0;}],
 CPP=`eval "echo $CPP"`
 
 
-dnl Not used by any currently supported platform.
 dnl The function dump-emacs will not be defined and temacs will do
 dnl (load "loadup") automatically unless told otherwise.
-CANNOT_DUMP=no
+test "x$CANNOT_DUMP" = "x" && CANNOT_DUMP=no
 case "$opsys" in
-  your-opsys-here)
-   CANNOT_DUMP=yes
-   AC_DEFINE(CANNOT_DUMP, 1, [Define if Emacs cannot be dumped on your system.])
-  ;;
+  your-opsys-here) CANNOT_DUMP=yes ;;
 esac
+
+test "$CANNOT_DUMP" = "yes" && \
+  AC_DEFINE(CANNOT_DUMP, 1, [Define if Emacs cannot be dumped on your system.])
+
 AC_SUBST(CANNOT_DUMP)
 
 
@@ -914,11 +886,11 @@ case "$opsys" in
    # emacs, instead of the generic ELF dump code found in unexelf.c.
    # The resulting binary has a complete symbol table, and is better
    # for debugging and other observability tools (debuggers, pstack, etc).
-   # 
+   #
    # If you encounter a problem using dldump(), please consider sending
    # a message to the OpenSolaris tools-linking mailing list:
    #      http://mail.opensolaris.org/mailman/listinfo/tools-linking
-   # 
+   #
    # It is likely that dldump() works with older Solaris too, but this has
    # not been tested, so for now this change is for Solaris 10 or newer.
    UNEXEC_OBJ=unexsol.o
@@ -936,7 +908,7 @@ case "$opsys" in
 
   gnu-linux)
    ## cpp test was "ifdef __mips__", but presumably this is equivalent...
-   test "$machine" = "mips" && LD_SWITCH_SYSTEM="-G 0"
+   case $host_cpu in mips*) LD_SWITCH_SYSTEM="-G 0";; esac
    ;;
 
   netbsd)
@@ -985,7 +957,7 @@ if test "$machine" = "alpha"; then
       AC_MSG_ERROR([What gives?  Fix me if DEC Unix supports ELF now.])
     fi
   else
-    UNEXEC_OBJ=unexalpha.o 
+    UNEXEC_OBJ=unexalpha.o
   fi
 fi
 AC_SUBST(C_SWITCH_MACHINE)
@@ -1167,7 +1139,7 @@ AC_DEFUN([PKG_CHECK_MODULES], [
 
 if test "${with_sound}" != "no"; then
   # Sound support for GNU/Linux and the free BSDs.
-  AC_CHECK_HEADERS(machine/soundcard.h sys/soundcard.h soundcard.h, 
+  AC_CHECK_HEADERS(machine/soundcard.h sys/soundcard.h soundcard.h,
     have_sound_header=yes)
   # Emulation library used on NetBSD.
   AC_CHECK_LIB(ossaudio, _oss_ioctl, LIBSOUND=-lossaudio, LIBSOUND=)
@@ -1218,10 +1190,10 @@ if test "${with_sound}" != "no"; then
 fi
 
 dnl checks for header files
-AC_CHECK_HEADERS(sys/select.h sys/timeb.h sys/time.h unistd.h utime.h \
-  linux/version.h sys/systeminfo.h termios.h limits.h string.h stdlib.h \
-  stdio_ext.h fcntl.h strings.h coff.h pty.h sys/mman.h \
-  sys/param.h sys/vlimit.h sys/resource.h locale.h sys/_mbstate_t.h \
+AC_CHECK_HEADERS(sys/select.h sys/time.h unistd.h utime.h \
+  linux/version.h sys/systeminfo.h limits.h \
+  stdio_ext.h fcntl.h coff.h pty.h sys/mman.h \
+  sys/vlimit.h sys/resource.h locale.h sys/_mbstate_t.h \
   sys/utsname.h pwd.h utmp.h dirent.h util.h)
 
 AC_MSG_CHECKING(if personality LINUX32 can be set)
@@ -1360,6 +1332,19 @@ AH_TEMPLATE(POINTER_TYPE,
 dnl Check for endianess
 AC_C_BIGENDIAN
 
+AC_CACHE_CHECK([for  __attribute__ ((__aligned__ (expr)))],
+  [emacs_cv_attribute_aligned],
+  [AC_COMPILE_IFELSE(
+     [AC_LANG_PROGRAM(
+       [[char __attribute__ ((__aligned__ (1 << 3))) c;]],
+       [[]])],
+     [emacs_cv_attribute_aligned=yes],
+     [emacs_cv_attribute_aligned=no])])
+if test $emacs_cv_attribute_aligned = yes; then
+  AC_DEFINE([HAVE_ATTRIBUTE_ALIGNED], 1,
+    [Define to 1 if GCC-style __attribute__ ((__aligned__ (expr))) works.])
+fi
+
 dnl check for Make feature
 AC_PROG_MAKE_SET
 
@@ -1498,7 +1483,7 @@ if test "${with_ns}" != no; then
   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.
@@ -1841,7 +1826,7 @@ if test "${HAVE_X11}" = "yes"; then
     PKG_CHECK_MODULES(IMAGEMAGICK, $IMAGEMAGICK_MODULE, HAVE_IMAGEMAGICK=yes, :)
     AC_SUBST(IMAGEMAGICK_CFLAGS)
     AC_SUBST(IMAGEMAGICK_LIBS)
-  
+
     if test $HAVE_IMAGEMAGICK = yes; then
       AC_DEFINE(HAVE_IMAGEMAGICK, 1, [Define to 1 if using imagemagick.])
       CFLAGS="$CFLAGS $IMAGEMAGICK_CFLAGS"
@@ -1982,6 +1967,8 @@ if test "${HAVE_X11}" = "yes" && test "${with_gconf}" = "yes"; then
    PKG_CHECK_MODULES(GCONF, gconf-2.0 >= 2.13, HAVE_GCONF=yes, HAVE_GCONF=no)
    if test "$HAVE_GCONF" = yes; then
       AC_DEFINE(HAVE_GCONF, 1, [Define to 1 if using GConf.])
+      dnl Newer GConf doesn't link with g_objects, so this is not defined.
+      AC_CHECK_FUNCS([g_type_init])
    fi
 fi
 
@@ -2019,7 +2006,8 @@ if test x"${USE_X_TOOLKIT}" = xmaybe || test x"${USE_X_TOOLKIT}" = xLUCID; then
 #include <X11/Intrinsic.h>
 #include <X11/Xaw3d/Simple.h>],
       [],
-      emacs_cv_xaw3d=yes,
+      [AC_CHECK_LIB(Xaw3d, XawScrollbarSetThumb,
+                    emacs_cv_xaw3d=yes, emacs_cv_xaw3d=no)],
       emacs_cv_xaw3d=no)])
   else
     emacs_cv_xaw3d=no
@@ -2095,8 +2083,8 @@ AC_SUBST(LIBXTR6)
 dnl FIXME the logic here seems weird, but this is what cpp was doing.
 dnl Why not just test for libxmu in the normal way?
 LIBXMU=-lXmu
-case "$machine" in
-  ## These machines don't supply Xmu.
+case $opsys in
+  ## These systems don't supply Xmu.
   hpux* | aix4-2 )
     test "X$ac_cv_lib_Xmu_XmuConvertStandardSelection" != "Xyes" && LIBXMU=
     ;;
@@ -2274,17 +2262,9 @@ if test "${HAVE_X11}" = "yes"; then
        HAVE_XFT=no
     fi
 
-
-    HAVE_FREETYPE=no
     ## We used to allow building with FreeType and without Xft.
     ## However, the ftx font backend driver is not in good shape.
-    if test "${HAVE_XFT}" = "yes"; then
-      dnl As we use Xft, we anyway use freetype.
-      dnl There's no need for additional CFLAGS and LIBS.
-      HAVE_FREETYPE=yes
-      FONTCONFIG_CFLAGS=
-      FONTCONFIG_LIBS=
-    fi
+    HAVE_FREETYPE=$HAVE_XFT
 
     HAVE_LIBOTF=no
     if test "${HAVE_FREETYPE}" = "yes"; then
@@ -2547,7 +2527,7 @@ AC_SUBST(LIBXSM)
 ### Use libxml (-lxml2) if available
 if test "${with_xml2}" != "no"; then
   ### I'm not sure what the version number should be, so I just guessed.
-  PKG_CHECK_MODULES(LIBXML2, libxml-2.0 > 2.2.0, HAVE_LIBXML2=yes, HAVE_LIBXML2=no)
+  PKG_CHECK_MODULES(LIBXML2, libxml-2.0 > 2.6.17, HAVE_LIBXML2=yes, HAVE_LIBXML2=no)
   if test "${HAVE_LIBXML2}" = "yes"; then
     LIBS="$LIBXML2_LIBS $LIBS"
     AC_CHECK_LIB(xml2, htmlReadMemory, HAVE_LIBXML2=yes, HAVE_LIBXML2=no)
@@ -2664,7 +2644,7 @@ AC_SUBST(BLESSMAIL_TARGET)
 AC_CHECK_FUNCS(gethostname getdomainname dup2 \
 rename closedir mkdir rmdir sysinfo getrusage get_current_dir_name \
 random lrand48 logb frexp fmod rint cbrt ftime setsid \
-strerror fpathconf select mktime euidaccess getpagesize tzset setlocale \
+strerror fpathconf select euidaccess getpagesize tzset setlocale \
 utimes getrlimit setrlimit setpgid getcwd getwd shutdown getaddrinfo \
 __fpending mblen mbrlen mbsinit strsignal setitimer ualarm strchr strrchr \
 sendto recvfrom getsockopt setsockopt getsockname getpeername \
@@ -2672,29 +2652,29 @@ gai_strerror mkstemp getline getdelim mremap memmove fsync sync \
 memset memcmp difftime memcpy mempcpy mblen mbrlen posix_memalign \
 cfmakeraw cfsetspeed isnan copysign __executable_start)
 
-AC_CHECK_HEADERS(sys/un.h)
-
-AC_FUNC_MKTIME
-if test "$ac_cv_func_working_mktime" = no; then
-  AC_DEFINE(BROKEN_MKTIME, 1, [Define to 1 if the mktime function is broken.])
+dnl Cannot use AC_CHECK_FUNCS
+AC_CACHE_CHECK([for __builtin_unwind_init],
+              emacs_cv_func___builtin_unwind_init,
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_unwind_init ();])],
+               emacs_cv_func___builtin_unwind_init=yes,
+               emacs_cv_func___builtin_unwind_init=no)])
+if test $emacs_cv_func___builtin_unwind_init = yes; then
+  AC_DEFINE(HAVE___BUILTIN_UNWIND_INIT, 1,
+           [Define to 1 if you have the `__builtin_unwind_init' function.])
 fi
 
+AC_CHECK_HEADERS(sys/un.h)
+
 AC_FUNC_GETLOADAVG
 
 AC_FUNC_FSEEKO
 
-# Configure getopt.
-m4_include([m4/getopt.m4])
-gl_GETOPT_IFELSE([
-  gl_GETOPT_SUBSTITUTE_HEADER
-  gl_PREREQ_GETOPT
-  GETOPTOBJS='getopt.o getopt1.o'
-])
-AC_SUBST(GETOPTOBJS)
-
 AC_FUNC_GETPGRP
 
-AC_FUNC_STRFTIME
+# Configure gnulib.
+gl_ASSERT_NO_GNULIB_POSIXCHECK
+gl_ASSERT_NO_GNULIB_TESTS
+gl_INIT
 
 # UNIX98 PTYs.
 AC_CHECK_FUNCS(grantpt)
@@ -2952,14 +2932,6 @@ AC_MSG_CHECKING(whether localtime caches TZ)
 AC_CACHE_VAL(emacs_cv_localtime_cache,
 [if test x$ac_cv_func_tzset = xyes; then
 AC_TRY_RUN([#include <time.h>
-extern char **environ;
-unset_TZ ()
-{
-  char **from, **to;
-  for (to = from = environ; (*to = *from); from++)
-    if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
-      to++;
-}
 char TZ_GMT0[] = "TZ=GMT0";
 char TZ_PST8[] = "TZ=PST8";
 main()
@@ -2969,13 +2941,13 @@ main()
   if (putenv (TZ_GMT0) != 0)
     exit (1);
   hour_GMT0 = localtime (&now)->tm_hour;
-  unset_TZ ();
+  unsetenv("TZ");
   hour_unset = localtime (&now)->tm_hour;
   if (putenv (TZ_PST8) != 0)
     exit (1);
   if (localtime (&now)->tm_hour == hour_GMT0)
     exit (1);
-  unset_TZ ();
+  unsetenv("TZ");
   if (localtime (&now)->tm_hour != hour_unset)
     exit (1);
   exit (0);
@@ -3034,8 +3006,6 @@ dnl Fixme: Not used.  Should this be HAVE_SOCKETS?
            [Define to 1 if you have inet sockets.])
 fi
 
-AC_CHECK_HEADERS(sys/ioctl.h)
-
 if test -f /usr/lpp/X11/bin/smt.exp; then
   AC_DEFINE(HAVE_AIX_SMT_EXP, 1,
            [Define to 1 if the file /usr/lpp/X11/bin/smt.exp exists.])
@@ -3067,24 +3037,6 @@ AC_CHECK_TYPES(size_t)
 
 AC_TYPE_MBSTATE_T
 
-dnl Restrict could probably be used effectively other than in regex.c.
-AC_CACHE_CHECK([for C restrict keyword], emacs_cv_c_restrict,
-  [AC_TRY_COMPILE([void fred (int *restrict x);], [],
-                  emacs_cv_c_restrict=yes,
-                  [AC_TRY_COMPILE([void fred (int *__restrict x);], [],
-                                  emacs_cv_c_restrict=__restrict,
-                                 emacs_cv_c_restrict=no)])])
-case "$emacs_cv_c_restrict" in
-  yes) emacs_restrict=restrict;;
-  no) emacs_restrict="";;
-  *) emacs_restrict="$emacs_cv_c_restrict";;
-esac
-if test "$emacs_restrict" != __restrict; then
-  AC_DEFINE_UNQUOTED(__restrict, $emacs_restrict,
-    [Define to compiler's equivalent of C99 restrict keyword.
-     Don't define if equivalent is `__restrict'.])
-fi
-
 AC_CACHE_CHECK([for C restricted array declarations], emacs_cv_c_restrict_arr,
   [AC_TRY_COMPILE([void fred (int x[__restrict]);], [],
                   emacs_cv_c_restrict_arr=yes, emacs_cv_c_restrict_arr=no)])
@@ -3119,15 +3071,7 @@ if test "x$GCC" = xyes \
    AC_MSG_ERROR([GCC 4.5.0 has problems compiling Emacs; see etc/PROBLEMS'.])
 fi
 
-#### Find out which version of Emacs this is.
-[version=`grep 'const char emacs_version' ${srcdir}/src/emacs.c \
-        | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`]
-if test x"${version}" = x; then
-  AC_MSG_ERROR([can't find current emacs version in `${srcdir}/src/emacs.c'.])
-fi
-if test x"${version}" != x"$PACKAGE_VERSION"; then
-  AC_MSG_WARN([version mismatch between `${srcdir}/configure.in' and `${srcdir}/src/emacs.c'.])
-fi
+version=$PACKAGE_VERSION
 
 ### Specify what sort of things we'll be editing into Makefile and config.h.
 ### Use configuration here uncanonicalized to avoid exceeding size limits.
@@ -3163,8 +3107,14 @@ AC_SUBST(C_SWITCH_X_SYSTEM)
 AC_SUBST(CFLAGS)
 ## Used in lwlib/Makefile.in.
 AC_SUBST(X_TOOLKIT_TYPE)
-AC_SUBST(machfile)
-AC_SUBST(opsysfile)
+if test -n "${machfile}"; then
+  M_FILE="\$(srcdir)/${machfile}"
+else
+  M_FILE=
+fi
+S_FILE="\$(srcdir)/${opsysfile}"
+AC_SUBST(M_FILE)
+AC_SUBST(S_FILE)
 AC_SUBST(GETLOADAVG_LIBS)
 AC_SUBST(ns_appdir)
 AC_SUBST(ns_appbindir)
@@ -3177,8 +3127,10 @@ AC_DEFINE_UNQUOTED(EMACS_CONFIGURATION,  "${canonical}",
                   [Define to the canonical Emacs configuration name.])
 AC_DEFINE_UNQUOTED(EMACS_CONFIG_OPTIONS, "${ac_configure_args}",
                   [Define to the options passed to configure.])
-AC_DEFINE_UNQUOTED(config_machfile,  "${machfile}",
-                  [Define to the used machine dependent file.])
+if test -n "$machfile"; then
+  AC_DEFINE_UNQUOTED(config_machfile,  "${machfile}",
+                    [Define to the used machine dependent file.])
+fi
 AC_DEFINE_UNQUOTED(config_opsysfile, "${opsysfile}",
                   [Define to the used os dependent file.])
 
@@ -3283,7 +3235,7 @@ fi
 
 if test "$HAVE_GTK" = "yes" || test "$HAVE_MENUS" != "yes"; then
   OLDXMENU_TARGET=
-  OLDXMENU=nothing  
+  OLDXMENU=nothing
   LIBXMENU=
   OLDXMENU_DEPS=
 fi
@@ -3347,7 +3299,7 @@ case "$opsys" in
      headerpad_extra=690
    fi
    LD_SWITCH_SYSTEM_TEMACS="-prebind $libs_nsgui -Xlinker -headerpad -Xlinker $headerpad_extra"
+
    ## This is here because src/Makefile.in did some extra fiddling around
    ## with LD_SWITCH_SYSTEM.  The cpp logic was:
    ##   #ifndef LD_SWITCH_SYSTEM
@@ -3442,16 +3394,18 @@ if test "x$GCC" = "xyes" && test "x$ORDINARY_LINK" != "xyes"; then
     gnu-*)
       ## armin76@gentoo.org reported that the lgcc_s flag is necessary to
       ## build on ARM EABI under GNU/Linux.  (Bug#5518)
-      ## Note that m/arm.h never bothered to undefine LIB_GCC first.
-      if test "$machine" = "arm"; then
+      case $host_cpu in
+      arm*)
         LIB_GCC="-lgcc_s"
-      else
+       ;;
+      *)
         ## FIXME? s/gnu-linux.h used to define LIB_GCC as below, then
         ## immediately undefine it again and redefine it to empty.
         ## Was the C_SWITCH_X_SITE part really necessary?
 ##      LIB_GCC=`$CC $C_SWITCH_X_SITE -print-libgcc-file-name`
         LIB_GCC=
-      fi
+       ;;
+      esac
       ;;
 
     ## Ask GCC where to find libgcc.a.
@@ -3481,8 +3435,9 @@ AC_SUBST(WINDOW_SUPPORT)
 
 
 AH_TOP([/* GNU Emacs site configuration template file.
-   Copyright (C) 1988, 1993, 1994, 1999, 2000, 2001, 2002, 2004, 2005,
-     2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+
+Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2011
+  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -3517,7 +3472,7 @@ AH_BOTTOM([
 /* Don't try to switch on inline handling as detected by AC_C_INLINE
    generally, because even if non-gcc compilers accept `inline', they
    may reject `extern inline'.  */
-#if defined (__GNUC__) && defined (OPTIMIZE)
+#if defined (__GNUC__)
 #define INLINE __inline__
 #else
 #define INLINE
@@ -3533,7 +3488,9 @@ AH_BOTTOM([
 
 /* Include the os and machine dependent files.  */
 #include config_opsysfile
-#include config_machfile
+#ifdef config_machfile
+# include config_machfile
+#endif
 
 /* GNUstep needs a bit more pure memory.  Of the existing knobs,
    SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems.
@@ -3562,13 +3519,6 @@ AH_BOTTOM([
 #endif
 #endif
 
-/* Avoid link-time collision with system mktime if we will use our own.  */
-#if ! HAVE_MKTIME || BROKEN_MKTIME
-#define mktime emacs_mktime
-#endif
-
-#define my_strftime nstrftime  /* for strftime.c */
-
 /* These default definitions are good for almost all machines.
    The exceptions override them in m/MACHINE.h.  */
 
@@ -3641,6 +3591,12 @@ typedef unsigned size_t;
 #define NO_INLINE
 #endif
 
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
+#define EXTERNALLY_VISIBLE __attribute__((externally_visible))
+#else
+#define EXTERNALLY_VISIBLE
+#endif
+
 /* Some versions of GNU/Linux define noinline in their headers.  */
 #ifdef noinline
 #undef noinline
@@ -3675,12 +3631,17 @@ if test "${HAVE_GTK}" = "yes"; then
   USE_X_TOOLKIT=GTK
 fi
 
+and_machfile=
+if test -n "$machfile"; then
+  and_machfile=" and \`${machfile}'"
+fi
+
 echo "
 Configured for \`${canonical}'.
 
   Where should the build process find the source code?    ${srcdir}
   What operating system and machine description files should Emacs use?
-        \`${opsysfile}' and \`${machfile}'
+        \`${opsysfile}'${and_machfile}
   What compiler should emacs be built with?               ${CC} ${CFLAGS}
   Should Emacs use the GNU version of malloc?             ${GNU_MALLOC}${GNU_MALLOC_reason}
   Should Emacs use a relocating allocator for buffers?    ${REL_ALLOC}
@@ -3712,7 +3673,7 @@ echo "  Does Emacs use -lgpm?                                   ${HAVE_GPM}"
 echo "  Does Emacs use -ldbus?                                  ${HAVE_DBUS}"
 echo "  Does Emacs use -lgconf?                                 ${HAVE_GCONF}"
 echo "  Does Emacs use -lselinux?                               ${HAVE_LIBSELINUX}"
-echo "  Does Emacs use -lgnutls (BROKEN)?                       ${HAVE_GNUTLS}"
+echo "  Does Emacs use -lgnutls?                                ${HAVE_GNUTLS}"
 echo "  Does Emacs use -lxml2?                                  ${HAVE_LIBXML2}"
 
 echo "  Does Emacs use -lfreetype?                              ${HAVE_FREETYPE}"
@@ -3745,11 +3706,6 @@ to run if these resources are not installed."
    echo
 fi
 
-if test "$HAVE_DBUS" = yes && test "${opsys}" != "gnu-linux"; then
-  echo "D-Bus integration has been tested for GNU/Linux only."
-  echo
-fi
-
 
 # Remove any trailing slashes in these variables.
 [test "${prefix}" != NONE &&
@@ -3765,10 +3721,10 @@ dnl Secondly, the GNU Coding standards require that one should be able
 dnl to run `make prefix=/some/where/else' and override the values set
 dnl by configure.  This also explains the `move-if-change' test and
 dnl the use of force in the `epaths-force' rule in Makefile.in.
-AC_OUTPUT(Makefile lib-src/Makefile oldXMenu/Makefile \
+AC_OUTPUT(Makefile 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, [
+       lwlib/Makefile lisp/Makefile leim/Makefile test/automated/Makefile, [
 
 ### Make the necessary directories, if they don't exist.
 for dir in etc lisp ; do
@@ -3784,4 +3740,3 @@ if test ! -f src/.gdbinit && test -f $srcdir/src/.gdbinit; then
 fi
 
 ], [GCC="$GCC" NON_GNU_CPP="$NON_GNU_CPP" CPP="$CPP" CPPFLAGS="$CPPFLAGS"])
-