* lib-src/fakemail.c (action): Convert function definitions to standard C.
[bpt/emacs.git] / configure.in
index a3ce499..673674b 100644 (file)
@@ -2,9 +2,11 @@ dnl  Autoconf script for GNU Emacs
 dnl To rebuild the `configure' script from this, execute the command
 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,
-dnl    2004, 2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+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
 dnl  This file is part of GNU Emacs.
 dnl
@@ -21,7 +23,7 @@ dnl
 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.62)
+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)
@@ -30,6 +32,10 @@ dnl Support for --program-prefix, --program-suffix and
 dnl --program-transform-name options
 AC_ARG_PROGRAM
 
+dnl It is important that variables on the RHS not be expanded here,
+dnl hence the single quotes.  This is per the GNU coding standards, see
+dnl (autoconf) Installation Directory Variables
+dnl See also epaths.h below.
 lispdir='${datadir}/emacs/${version}/lisp'
 locallisppath='${datadir}/emacs/${version}/site-lisp:'\
 '${datadir}/emacs/site-lisp'
@@ -123,7 +129,7 @@ dnl This should be the last --with option, because --with-x is
 dnl added later on when we find the path of X, and it's best to
 dnl keep them together visually.
 AC_ARG_WITH([x-toolkit],[AS_HELP_STRING([--with-x-toolkit=KIT],
- [use an X toolkit (KIT one of: yes or gtk, lucid or athena, motif, no)])],
+ [use an X toolkit (KIT one of: yes or gtk, gtk3, lucid or athena, motif, no)])],
 [        case "${withval}" in
            y | ye | yes )      val=gtk ;;
            n | no )            val=no  ;;
@@ -131,10 +137,11 @@ AC_ARG_WITH([x-toolkit],[AS_HELP_STRING([--with-x-toolkit=KIT],
            a | at | ath | athe | athen | athena )      val=athena ;;
            m | mo | mot | moti | motif )       val=motif ;;
            g | gt | gtk  )     val=gtk ;;
+           gtk3  )     val=gtk3 ;;
            * )
 AC_MSG_ERROR([`--with-x-toolkit=$withval' is invalid;
-this option's value should be `yes', `no', `lucid', `athena', `motif' or `gtk'.
-`yes' and `gtk' are synonyms. `athena' and `lucid' are synonyms.])
+this option's value should be `yes', `no', `lucid', `athena', `motif', `gtk' or
+`gtk3'.  `yes' and `gtk' are synonyms. `athena' and `lucid' are synonyms.])
            ;;
          esac
          with_x_toolkit=$val
@@ -168,14 +175,15 @@ OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support])
 dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html
 OPTION_DEFAULT_ON([makeinfo],[don't require makeinfo for building manuals])
 
-dnl Can remove these in Emacs 24.
-AC_ARG_WITH([gtk],,
-  [AC_MSG_ERROR([--with-gtk has been removed.  Use --with-x-toolkit to
-specify a toolkit.])],,)
-
-AC_ARG_WITH([gcc],,
-  [AC_MSG_ERROR([--with-gcc has been removed.  Set the `CC' environment
-variable to specify a compiler.])],,)
+## This is an option because I do not know if all info/man support
+## compressed files, nor how to test if they do so.
+OPTION_DEFAULT_ON([compress-info],[don't compress the installed Info pages])
+if test $with_compress_info = yes; then
+   GZIP_INFO=yes
+else
+   GZIP_INFO=
+fi
+AC_SUBST(GZIP_INFO)
 
 AC_ARG_WITH([pkg-config-prog],dnl
 [AS_HELP_STRING([--with-pkg-config-prog=PATH],
@@ -297,6 +305,16 @@ if test x$ac_gc_check_cons_list != x ; then
 [Define this to check for errors in cons list.])
 fi
 
+AC_ARG_ENABLE(use-lisp-union-type,
+[AS_HELP_STRING([--enable-use-lisp-union-type],
+                [use a union for the Lisp_Object data type.
+               This is only useful for development for catching certain types of bugs.])],
+if test "${enableval}" != "no"; then
+   AC_DEFINE(USE_LISP_UNION_TYPE, 1,
+   [Define this to use a lisp union for the Lisp_Object data type.])
+fi)
+
+
 AC_ARG_ENABLE(profiling,
 [AS_HELP_STRING([--enable-profiling],
                [build emacs with profiling support.
@@ -376,7 +394,7 @@ dnl quotation begins
 ### the appropriate operating system and machine description files.
 
 ### You would hope that you could choose an m/*.h file pretty much
-### based on the machine portion of the configuration name, and an s-
+### based on the machine portion of the configuration name, and an s/*.h
 ### file based on the operating system portion.  However, it turns out
 ### that each m/*.h file is pretty manufacturer-specific - for
 ### example mips.h is MIPS
@@ -388,10 +406,6 @@ dnl quotation begins
 ### /etc/MACHINES doesn't say anything about version numbers, be
 ### prepared to handle anything reasonably.  If version numbers
 ### matter, be sure /etc/MACHINES says something about it.
-###
-### Eric Raymond says we should accept strings like "sysvr4" to mean
-### "System V Release 4"; he writes, "The old convention encouraged
-### confusion between `system' and `release' levels'."
 
 machine='' opsys='' unported=no
 case "${canonical}" in
@@ -400,14 +414,14 @@ case "${canonical}" in
   *-*-freebsd* )
     opsys=freebsd
     case "${canonical}" in
-      alpha*-*-freebsd*)       machine=alpha ;;
-      arm*-*-freebsd*)          machine=arm ;;
-      ia64-*-freebsd*)         machine=ia64 ;;
-      sparc-*-freebsd*)         machine=sparc ;;
-      sparc64-*-freebsd*)      machine=sparc ;;
-      powerpc-*-freebsd*)      machine=macppc ;;
-      i[3456]86-*-freebsd*)    machine=intel386 ;;
-      amd64-*-freebsd*|x86_64-*-freebsd*) machine=amdx86-64 ;;
+      alpha*)           machine=alpha ;;
+      amd64-*|x86_64-*) machine=amdx86-64 ;;
+      arm*)             machine=arm ;;
+      ia64-*)           machine=ia64 ;;
+      i[3456]86-*)      machine=intel386 ;;
+      powerpc-*)        machine=macppc ;;
+      sparc-*)          machine=sparc ;;
+      sparc64-*)        machine=sparc ;;
     esac
   ;;
 
@@ -415,13 +429,13 @@ case "${canonical}" in
   *-*-kfreebsd*gnu* )
     opsys=gnu-kfreebsd
     case "${canonical}" in
-      alpha*-*-kfreebsd*)      machine=alpha ;;
-      ia64-*-kfreebsd*)                machine=ia64 ;;
-      sparc-*-kfreebsd*)       machine=sparc ;;
-      sparc64-*-kfreebsd*)     machine=sparc ;;
-      powerpc-*-kfreebsd*)     machine=macppc ;;
-      i[3456]86-*-kfreebsd*)   machine=intel386 ;;
-      amd64-*-kfreebsd*|x86_64-*-kfreebsd*) machine=amdx86-64 ;;
+      alpha*)           machine=alpha ;;
+      amd64-*|x86_64-*) machine=amdx86-64 ;;
+      ia64-*)           machine=ia64 ;;
+      i[3456]86-*)      machine=intel386 ;;
+      powerpc-*)        machine=macppc ;;
+      sparc-*)          machine=sparc ;;
+      sparc64-*)        machine=sparc ;;
     esac
   ;;
 
@@ -429,18 +443,17 @@ case "${canonical}" in
   *-*-netbsd* )
     opsys=netbsd
     case "${canonical}" in
-      alpha*-*-netbsd*)        machine=alpha ;;
-      i[3456]86-*-netbsd*) machine=intel386 ;;
-      mips-*-netbsd*)  machine=mips ;;
-      mipsel-*-netbsd*)        machine=mips ;;
-      mipseb-*-netbsd*)        machine=mips ;;
-      powerpc-*-netbsd*) machine=macppc ;;
-      sparc*-*-netbsd*)        machine=sparc ;;
-      vax-*-netbsd*)   machine=vax ;;
-      arm-*-netbsd*)   machine=arm ;;
-      x86_64-*-netbsd*)        machine=amdx86-64 ;;
-      hppa-*-netbsd*)  machine=hp800 ;;
-      m68k-*-netbsd*)  machine=m68k ;;
+      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
   ;;
 
@@ -448,14 +461,14 @@ case "${canonical}" in
   *-*-openbsd* )
     opsys=openbsd
     case "${canonical}" in
-      alpha*-*-openbsd*)       machine=alpha ;;
-      arm-*-openbsd*)          machine=arm ;;
-      i386-*-openbsd*)         machine=intel386 ;;
-      powerpc-*-openbsd*)      machine=macppc ;;
-      sparc*-*-openbsd*)       machine=sparc ;;
-      vax-*-openbsd*)          machine=vax ;;
-      x86_64-*-openbsd*)       machine=amdx86-64 ;;
-      hppa-*-openbsd*)         machine=hp800 ;;
+      alpha*)    machine=alpha ;;
+      x86_64-*)  machine=amdx86-64 ;;
+      arm-*)     machine=arm ;;
+      hppa-*)    machine=hp800 ;;
+      i386-*)    machine=intel386 ;;
+      powerpc-*) machine=macppc ;;
+      sparc*)    machine=sparc ;;
+      vax-*)     machine=vax ;;
     esac
   ;;
 
@@ -506,16 +519,16 @@ case "${canonical}" in
   s390x-*-linux-gnu* )
     machine=ibms390x opsys=gnu-linux
   ;;
-  rs6000-ibm-aix4.2* | powerpc-ibm-aix4.2*  )
+  rs6000-ibm-aix4.[23]* )
     machine=ibmrs6000 opsys=aix4-2
   ;;
-  rs6000-ibm-aix4.3* | powerpc-ibm-aix4.3*  )
+  powerpc-ibm-aix4.[23]*  )
     machine=ibmrs6000 opsys=aix4-2
   ;;
-  rs6000-ibm-aix5* | powerpc-ibm-aix5*  )
+  rs6000-ibm-aix[56]* )
     machine=ibmrs6000 opsys=aix4-2
   ;;
-  rs6000-ibm-aix6* | powerpc-ibm-aix6*  )
+  powerpc-ibm-aix[56]*  )
     machine=ibmrs6000 opsys=aix4-2
   ;;
 
@@ -584,7 +597,7 @@ case "${canonical}" in
     machine=ia64 opsys=gnu-linux
   ;;
 
-  ## Intel 386 machines where we don't care about the manufacturer
+  ## Intel 386 machines where we don't care about the manufacturer.
   i[3456]86-*-* )
     machine=intel386
     case "${canonical}" in
@@ -707,14 +720,12 @@ then
   CC="$NON_GNU_CC"
 fi
 
-if test x$GCC = xyes && test "x$GCC_TEST_OPTIONS" != x
-then
-  CC="$CC $GCC_TEST_OPTIONS"
-fi
-
-if test x$GCC = x && test "x$NON_GCC_TEST_OPTIONS" != x
-then
-  CC="$CC $NON_GCC_TEST_OPTIONS"
+if test x$GCC = xyes; then
+  C_OPTIMIZE_SWITCH=-O2
+  test "x$GCC_TEST_OPTIONS" != x && CC="$CC $GCC_TEST_OPTIONS"
+else
+  C_OPTIMIZE_SWITCH=-O
+  test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS"
 fi
 
 dnl checks for Unix variants
@@ -835,96 +846,78 @@ AC_LINK_IFELSE([main(){return 0;}],
   LDFLAGS=$late_LDFLAGS
   [AC_MSG_RESULT(no)])
 
-#### Extract some information from the operating system and machine files.
+LDFLAGS="${LDFLAGS} ${PROFILING_LDFLAGS}"
+
+
+# The value of CPP is a quoted variable reference, so we need to do this
+# to get its actual value...
+CPP=`eval "echo $CPP"`
 
-AC_CHECKING([the machine- and system-dependent files to find out
- - which libraries the lib-src programs will want, and
- - whether the GNU malloc routines are usable])
 
 ### First figure out CFLAGS (which we use for running the compiler here)
 ### and REAL_CFLAGS (which we use for real compilation).
-### The two are the same except on a few systems, where they are made
-### different to work around various lossages.  For example,
-### GCC 2.5 on GNU/Linux needs them to be different because it treats -g
-### as implying static linking.
+### The two are the same except when using GCC where we might use
+### extra warning and profiling flags.
 
 ### If the CFLAGS env var is specified, we use that value
 ### instead of the default.
 
-### It's not important that this name contain the PID; you can't run
-### two configures in the same directory and have anything work
-### anyway.
-tempcname="conftest.c"
-
-echo '
-#include "'${srcdir}'/src/'${opsysfile}'"
-#include "'${srcdir}'/src/'${machfile}'"
-
-configure___ LIBX=-lX11
-
-configure___ unexec=UNEXEC
-
-#ifdef SYSTEM_MALLOC
-configure___ system_malloc=yes
-#else
-configure___ system_malloc=no
-#endif
-
-#ifdef USE_MMAP_FOR_BUFFERS
-configure___ use_mmap_for_buffers=yes
-#else
-configure___ use_mmap_for_buffers=no
-#endif
-
-#ifndef C_OPTIMIZE_SWITCH
-#ifdef __GNUC__
-#define C_OPTIMIZE_SWITCH -O2
-#else
-#define C_OPTIMIZE_SWITCH -O
-#endif
-#endif
-
-#ifndef C_WARNINGS_SWITCH
-#define C_WARNINGS_SWITCH ${C_WARNINGS_SWITCH}
-#endif
-
-#ifdef THIS_IS_CONFIGURE
-
-/* Get the CFLAGS for tests in configure.  */
-#ifdef __GNUC__
-configure___ CFLAGS=-g C_OPTIMIZE_SWITCH '${SPECIFIED_CFLAGS}'
-#else
-configure___ CFLAGS='${SPECIFIED_CFLAGS}'
-#endif
-
-#else /* not THIS_IS_CONFIGURE */
-
-/* Get the CFLAGS for real compilation.  */
-#ifdef __GNUC__
-configure___ REAL_CFLAGS=-g C_OPTIMIZE_SWITCH C_WARNINGS_SWITCH ${PROFILING_CFLAGS} '${SPECIFIED_CFLAGS}'
-#else
-configure___ REAL_CFLAGS='${SPECIFIED_CFLAGS}'
-#endif
-
-#endif /* not THIS_IS_CONFIGURE */
-' > ${tempcname}
-
-LDFLAGS="${LDFLAGS} ${PROFILING_LDFLAGS}"
-
-# The value of CPP is a quoted variable reference, so we need to do this
-# to get its actual value...
-CPP=`eval "echo $CPP"`
-[eval `${CPP} -Isrc ${tempcname} \
-       | sed -n -e 's/^configure___ \([^=]*=\)\(.*\)$/\1"\2"/p'`
+dnl Note AC_PROG_CC sets CFLAGS to -g -O2 for gcc anyway.
 if test "x$SPECIFIED_CFLAGS" = x; then
-  eval `${CPP} -Isrc -DTHIS_IS_CONFIGURE ${tempcname} \
-        | sed -n -e 's/^configure___ \([^=]*=\)\(.*\)$/\1"\2"/p'`
+  CFLAGS="-g $C_OPTIMIZE_SWITCH"
+  if test x$GCC = xyes; then
+    REAL_CFLAGS="$CFLAGS $C_WARNINGS_SWITCH $PROFILING_CFLAGS"
+  else
+    REAL_CFLAGS="$CFLAGS"
+  fi
 else
   REAL_CFLAGS="$CFLAGS"
-fi]
-rm ${tempcname}
+fi
 
 
+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
+case "$opsys" in
+  your-opsys-here)
+   CANNOT_DUMP=yes
+   AC_DEFINE(CANNOT_DUMP, 1, [Define if Emacs cannot be dumped on your system.])
+  ;;
+esac
+AC_SUBST(CANNOT_DUMP)
+
+
+UNEXEC_OBJ=unexelf.o
+case "$opsys" in
+  aix4-2)
+   UNEXEC_OBJ=unexaix.o
+   ;;
+  cygwin)
+   UNEXEC_OBJ=unexcw.o
+   ;;
+  darwin)
+   UNEXEC_OBJ=unexmacosx.o
+   ;;
+  hpux10-20 | hpux11)
+   UNEXEC_OBJ=unexhp9k800.o
+   ;;
+  sol2-10)
+   # Use the Solaris dldump() function, called from unexsol.c, to dump
+   # 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
+   ;;
+esac
+
 LD_SWITCH_SYSTEM=
 case "$opsys" in
   freebsd)
@@ -953,16 +946,17 @@ AC_SUBST(LD_SWITCH_SYSTEM)
 
 ac_link="$ac_link $LD_SWITCH_SYSTEM"
 
-## This is fun.  Some settings of LD_SWITCH_SYSTEM reference
-## LD_SWITCH_X_SITE_AUX, which has not been defined yet.  When using
-## cpp, it was expanded to null.  Thus LD_SWITCH_SYSTEM had different
-## values in configure and the Makefiles.  How helpful.
-## FIXME why not use LD_SWITCH_SYSTEM_TEMACS (or somesuch) instead?
+## This setting of LD_SWITCH_SYSTEM references LD_SWITCH_X_SITE_AUX,
+## 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.
+## FIXME it would be cleaner to put this in LD_SWITCH_SYSTEM_TEMACS
+## (or somesuch), but because it is supposed to go at the _front_
+## of LD_SWITCH_SYSTEM, we cannot do that in exactly the same way.
+## Compare with the gnu-linux case below, which added to the end
+## of LD_SWITCH_SYSTEM, and so can instead go at the front of
+## LD_SWITCH_SYSTEM_TEMACS.
 case "$opsys" in
-  gnu-linux)
-   ## LD_SWITCH_X_SITE_AUX is a -R option saying where to find X at run-time.
-   LD_SWITCH_SYSTEM="$LD_SWITCH_SYSTEM \$(LD_SWITCH_X_SITE_AUX)" ;;
-
   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" ;;
@@ -983,10 +977,13 @@ if test "$machine" = "alpha"; then
     else
       AC_MSG_ERROR([What gives?  Fix me if DEC Unix supports ELF now.])
     fi
+  else
+    UNEXEC_OBJ=unexalpha.o 
   fi
 fi
 AC_SUBST(C_SWITCH_MACHINE)
 
+AC_SUBST(UNEXEC_OBJ)
 
 C_SWITCH_SYSTEM=
 ## Some programs in src produce warnings saying certain subprograms
@@ -1163,7 +1160,8 @@ 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=)
   AC_SUBST(LIBSOUND)
@@ -1196,6 +1194,19 @@ if test "${with_sound}" != "no"; then
     CFLAGS_SOUND="$CFLAGS_SOUND $ALSA_CFLAGS"
     AC_DEFINE(HAVE_ALSA, 1, [Define to 1 if ALSA is available.])
   fi
+
+  dnl Define HAVE_SOUND if we have sound support.  We know it works and
+  dnl compiles only on the specified platforms.  For others, it
+  dnl probably doesn't make sense to try.
+  if test x$have_sound_header = xyes || test $HAVE_ALSA = yes; then
+     case "$opsys" in
+       dnl defined __FreeBSD__ || defined __NetBSD__ || defined __linux__
+       gnu-linux|freebsd|netbsd)
+         AC_DEFINE(HAVE_SOUND, 1, [Define to 1 if you have sound support.])
+         ;;
+     esac
+  fi
+
   AC_SUBST(CFLAGS_SOUND)
 fi
 
@@ -1348,6 +1359,9 @@ dnl AC_C_BIGENDIAN
 dnl check for Make feature
 AC_PROG_MAKE_SET
 
+DEPFLAGS=
+MKDEPDIR=":"
+deps_frag=deps.mk
 dnl check for GNU Make if we have GCC and autodepend is on.
 if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
    AC_MSG_CHECKING([whether we are using GNU Make])
@@ -1370,9 +1384,19 @@ if test "$GCC" = yes && test "$ac_enable_autodepend" = yes; then
       AC_MSG_RESULT([$ac_enable_autodepend])
    fi
    if test $ac_enable_autodepend = yes; then
-      AC_DEFINE(AUTO_DEPEND, 1, [Generate dependencies with gcc.])
+      DEPFLAGS='-MMD -MF ${DEPDIR}/$*.d'
+      ## In parallel builds, another make might create depdir between
+      ## the first test and mkdir, so stick another test on the end.
+      ## Or use mkinstalldirs?  mkdir -p is not portable.
+      MKDEPDIR='test -d ${DEPDIR} || mkdir ${DEPDIR} || test -d ${DEPDIR}'
+      deps_frag=autodeps.mk
    fi
 fi
+deps_frag=$srcdir/src/$deps_frag
+AC_SUBST(MKDEPDIR)
+AC_SUBST(DEPFLAGS)
+AC_SUBST_FILE(deps_frag)
+
 
 dnl checks for operating system services
 AC_SYS_LONG_FILE_NAMES
@@ -1452,8 +1476,6 @@ fi
 HAVE_NS=no
 NS_IMPL_COCOA=no
 NS_IMPL_GNUSTEP=no
-NS_IMPL_GNUSTEP_INC=
-NS_IMPL_GNUSTEP_TEMACS_LDFLAGS=
 tmp_CPPFLAGS="$CPPFLAGS"
 tmp_CFLAGS="$CFLAGS"
 CPPFLAGS="$CPPFLAGS -x objective-c"
@@ -1466,32 +1488,29 @@ if test "${with_ns}" != no; then
   if test "${opsys}" = darwin; then
      NS_IMPL_COCOA=yes
      ns_appdir=`pwd`/nextstep/Emacs.app/
-     ns_appbindir=`pwd`/nextstep/Emacs.app/Contents/MacOS/
-     ns_appresdir=`pwd`/nextstep/Emacs.app/Contents/Resources
+     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=`pwd`/nextstep/Emacs.app/
-     ns_appresdir=`pwd`/nextstep/Emacs.app/Resources
+     ns_appbindir=${ns_appdir}
+     ns_appresdir=${ns_appdir}Resources
      ns_appsrc=${srcdir}/nextstep/GNUstep/Emacs.base
-     dnl FIXME sourcing this 3 times in subshells seems inefficient.
-     GNUSTEP_MAKEFILES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_MAKEFILES)"
+     dnl FIXME sourcing this several times in subshells seems inefficient.
      GNUSTEP_SYSTEM_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_HEADERS)"
      GNUSTEP_SYSTEM_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_SYSTEM_LIBRARIES)"
-     ## Pull in stuff from GNUstep-make.
-     NS_IMPL_GNUSTEP_INC="FOUNDATION_LIB=gnu
-GUI_LIB=gnu
-include $GNUSTEP_MAKEFILES/Additional/base.make
-include $GNUSTEP_MAKEFILES/Additional/gui.make
-shared=no
-"
-     dnl Presumably ${CONFIG_SYSTEM_LIBS} is defined by above includes.
-     NS_IMPL_GNUSTEP_TEMACS_LDFLAGS="-L${GNUSTEP_SYSTEM_LIBRARIES} -lgnustep-gui -lgnustep-base -lobjc \${CONFIG_SYSTEM_LIBS} -lpthread"
-     CPPFLAGS="$CPPFLAGS -I${GNUSTEP_SYSTEM_HEADERS}"
-     CFLAGS="$CFLAGS -I${GNUSTEP_SYSTEM_HEADERS}"
-     REAL_CFLAGS="$REAL_CFLAGS -I${GNUSTEP_SYSTEM_HEADERS}"
-     LDFLAGS="$LDFLAGS -L${GNUSTEP_SYSTEM_LIBRARIES}"
+     dnl I seemed to need these as well with GNUstep-startup 0.25.
+     GNUSTEP_LOCAL_HEADERS="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_LOCAL_HEADERS)"
+     GNUSTEP_LOCAL_LIBRARIES="$(. $GNUSTEP_CONFIG_FILE; echo $GNUSTEP_LOCAL_LIBRARIES)"
+     test "x${GNUSTEP_LOCAL_HEADERS}" != "x" && \
+       GNUSTEP_LOCAL_HEADERS="-I${GNUSTEP_LOCAL_HEADERS}"
+     test "x${GNUSTEP_LOCAL_LIBRARIES}" != "x" && \
+       GNUSTEP_LOCAL_LIBRARIES="-L${GNUSTEP_LOCAL_LIBRARIES}"
+     CPPFLAGS="$CPPFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
+     CFLAGS="$CFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
+     REAL_CFLAGS="$REAL_CFLAGS -I${GNUSTEP_SYSTEM_HEADERS} ${GNUSTEP_LOCAL_HEADERS}"
+     LDFLAGS="$LDFLAGS -L${GNUSTEP_SYSTEM_LIBRARIES} ${GNUSTEP_LOCAL_LIBRARIES}"
      LIB_STANDARD=
      START_FILES=
      TEMACS_LDFLAGS2=
@@ -1508,10 +1527,9 @@ shared=no
     NS_HAVE_NSINTEGER=no
   fi
 fi
-AC_SUBST(NS_IMPL_GNUSTEP_INC)
-AC_SUBST(NS_IMPL_GNUSTEP_TEMACS_LDFLAGS)
 AC_SUBST(TEMACS_LDFLAGS2)
 
+ns_frag=/dev/null
 NS_OBJ=
 NS_SUPPORT=
 if test "${HAVE_NS}" = yes; then
@@ -1523,6 +1541,7 @@ if test "${HAVE_NS}" = yes; then
   if test "${EN_NS_SELF_CONTAINED}" = yes; then
      prefix=${ns_appresdir}
   fi
+  ns_frag=$srcdir/src/ns.mk
   NS_OBJ="nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o fontset.o fringe.o image.o"
   NS_SUPPORT="\${lispsource}emacs-lisp/easymenu.elc \${lispsource}term/ns-win.elc"
 fi
@@ -1531,6 +1550,7 @@ CPPFLAGS="$tmp_CPPFLAGS"
 AC_SUBST(NS_OBJ)
 AC_SUBST(NS_SUPPORT)
 AC_SUBST(LIB_STANDARD)
+AC_SUBST_FILE(ns_frag)
 
 case "${window_system}" in
   x11 )
@@ -1543,6 +1563,8 @@ case "${window_system}" in
 dnl Dont set this for GTK.  A lot of tests below assumes Xt when
 dnl USE_X_TOOLKIT is set.
             USE_X_TOOLKIT=none ;;
+      gtk3 ) with_gtk3=yes
+             USE_X_TOOLKIT=none ;;
       no ) USE_X_TOOLKIT=none ;;
 dnl If user did not say whether to use a toolkit, make this decision later:
 dnl use the toolkit if we have gtk, or X11R5 or newer.
@@ -1592,11 +1614,29 @@ AC_CACHE_CHECK(whether __after_morecore_hook exists,
 if test $emacs_cv_var___after_morecore_hook = no; then
   doug_lea_malloc=no
 fi
+
+
+dnl See comments in aix4-2.h about maybe using system malloc there.
+system_malloc=no
+case "$opsys" in
+  ## darwin ld insists on the use of malloc routines in the System framework.
+  darwin|sol2-10) system_malloc=yes ;;
+esac
+
 if test "${system_malloc}" = "yes"; then
+  AC_DEFINE(SYSTEM_MALLOC, 1, [Define to use system malloc.])
   GNU_MALLOC=no
   GNU_MALLOC_reason="
     (The GNU allocators don't work with this system configuration.)"
+  GMALLOC_OBJ=
+  VMLIMIT_OBJ=
+else
+  test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
+  VMLIMIT_OBJ=vm-limit.o
 fi
+AC_SUBST(GMALLOC_OBJ)
+AC_SUBST(VMLIMIT_OBJ)
+
 if test "$doug_lea_malloc" = "yes" ; then
   if test "$GNU_MALLOC" = yes ; then
     GNU_MALLOC_reason="
@@ -1604,18 +1644,28 @@ if test "$doug_lea_malloc" = "yes" ; then
   fi
   AC_DEFINE(DOUG_LEA_MALLOC, 1,
            [Define to 1 if you are using the GNU C Library.])
+
+  ## Use mmap directly for allocating larger buffers.
+  ## FIXME this comes from src/s/{gnu,gnu-linux}.h:
+  ## #ifdef DOUG_LEA_MALLOC; #undef REL_ALLOC; #endif
+  ## Does the AC_FUNC_MMAP test below make this check unecessary?
+  case "$opsys" in
+    gnu*) REL_ALLOC=no ;;
+  esac
 fi
 
 if test x"${REL_ALLOC}" = x; then
   REL_ALLOC=${GNU_MALLOC}
 fi
 
-dnl For now, need to use an explicit `#define USE_MMAP_FOR_BUFFERS 1'
-dnl the system configuration file (s/*.h) to turn the use of mmap
-dnl in the relocating allocator on.
+use_mmap_for_buffers=no
+case "$opsys" in
+  freebsd|irix6-5) use_mmap_for_buffers=yes ;;
+esac
 
 AC_FUNC_MMAP
 if test $use_mmap_for_buffers = yes; then
+  AC_DEFINE(USE_MMAP_FOR_BUFFERS, 1, [Define to use mmap to allocate buffer text.])
   REL_ALLOC=no
 fi
 
@@ -1670,7 +1720,7 @@ REAL_CPPFLAGS="$CPPFLAGS"
 if test "${HAVE_X11}" = "yes"; then
   DEFS="$C_SWITCH_X_SITE $DEFS"
   LDFLAGS="$LDFLAGS $LD_SWITCH_X_SITE"
-  LIBS="$LIBX $LIBS"
+  LIBS="-lX11 $LIBS"
   CFLAGS="$C_SWITCH_X_SITE $CFLAGS"
   CPPFLAGS="$C_SWITCH_X_SITE $CPPFLAGS"
 
@@ -1746,6 +1796,15 @@ fail;
     AC_MSG_RESULT(6 or newer)
     AC_DEFINE(HAVE_X11R6, 1,
              [Define to 1 if you have the X11R6 or newer version of Xlib.])
+    AC_DEFINE(HAVE_X_I18N, 1, [Define if you have usable i18n support.])
+    ## inoue@ainet.or.jp says Solaris has a bug related to X11R6-style
+    ## XIM support.
+    case "$opsys" in
+      sol2-*) : ;;
+      *) AC_DEFINE(HAVE_X11R6_XIM, 1,
+           [Define if you have usable X11R6-style XIM support.])
+         ;;
+    esac
   else
     AC_MSG_RESULT(before 6)
   fi
@@ -1774,6 +1833,20 @@ fi
 
 
 HAVE_GTK=no
+if test "${with_gtk3}" = "yes"; then
+  GLIB_REQUIRED=2.6
+  GTK_REQUIRED=2.90
+  GTK_MODULES="gtk+-3.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
+
+  dnl Checks for libraries.
+  PKG_CHECK_MODULES(GTK, $GTK_MODULES, pkg_check_gtk=yes, pkg_check_gtk=no)
+  if test "$pkg_check_gtk" = "no" && test "$USE_X_TOOLKIT" != "maybe"; then
+     AC_MSG_ERROR($GTK_PKG_ERRORS)
+  fi
+fi
+
+if test "$pkg_check_gtk" != "yes"; then
+  HAVE_GTK=no
 if test "${with_gtk}" = "yes" || test "$USE_X_TOOLKIT" = "maybe"; then
   GLIB_REQUIRED=2.6
   GTK_REQUIRED=2.6
@@ -1785,7 +1858,7 @@ if test "${with_gtk}" = "yes" || test "$USE_X_TOOLKIT" = "maybe"; then
      AC_MSG_ERROR($GTK_PKG_ERRORS)
   fi
 fi
-
+fi
 
 GTK_OBJ=
 if test x"$pkg_check_gtk" = xyes; then
@@ -1830,15 +1903,6 @@ if test "${HAVE_GTK}" = "yes"; then
     with_toolkit_scroll_bars=yes
   fi
 
-  dnl  Check if we can use multiple displays with this GTK version.
-  dnl  If gdk_display_open exists, assume all others are there also.
-  HAVE_GTK_MULTIDISPLAY=no
-  AC_CHECK_FUNCS(gdk_display_open, HAVE_GTK_MULTIDISPLAY=yes)
-  if test "${HAVE_GTK_MULTIDISPLAY}" = "yes"; then
-    AC_DEFINE(HAVE_GTK_MULTIDISPLAY, 1,
-              [Define to 1 if GTK can handle more than one display.])
-  fi
-
   dnl  Check if we have the old file selection dialog declared and
   dnl  in the link library.  In 2.x it may be in the library,
   dnl  but not declared if deprecated featured has been selected out.
@@ -1848,29 +1912,11 @@ if test "${HAVE_GTK}" = "yes"; then
                    HAVE_GTK_FILE_SELECTION=no, [AC_INCLUDES_DEFAULT
 #include <gtk/gtk.h>])
   if test "$HAVE_GTK_FILE_SELECTION" = yes; then
-    AC_CHECK_FUNCS(gtk_file_selection_new, HAVE_GTK_FILE_SELECTION=yes,
-                   HAVE_GTK_FILE_SELECTION=no)
-  fi
-
-  dnl  Check if we have the new file chooser dialog
-  HAVE_GTK_FILE_CHOOSER=no
-  AC_CHECK_DECL(GTK_TYPE_FILE_CHOOSER, HAVE_GTK_FILE_CHOOSER=yes,
-                HAVE_GTK_FILE_CHOOSER=no, [AC_INCLUDES_DEFAULT
-#include <gtk/gtk.h>])
-  if test "$HAVE_GTK_FILE_CHOOSER" = yes; then
-    AC_CHECK_FUNCS(gtk_file_chooser_dialog_new, HAVE_GTK_FILE_CHOOSER=yes,
-                   HAVE_GTK_FILE_CHOOSER=no)
-  fi
-
-  if test "$HAVE_GTK_FILE_SELECTION" = yes \
-     && test "$HAVE_GTK_FILE_CHOOSER" = yes;  then
-    AC_DEFINE(HAVE_GTK_FILE_BOTH, 1,
-              [Define to 1 if GTK has both file selection and chooser dialog.])
+    AC_CHECK_FUNCS(gtk_file_selection_new)
   fi
 
   dnl Check if pthreads are available.  Emacs only needs this when using
   dnl gtk_file_chooser under Gnome.
-  if test "$HAVE_GTK_FILE_CHOOSER" = yes; then
     HAVE_GTK_AND_PTHREAD=no
     AC_CHECK_HEADERS(pthread.h)
     if test "$ac_cv_header_pthread_h"; then
@@ -1884,7 +1930,13 @@ if test "${HAVE_GTK}" = "yes"; then
       AC_DEFINE(HAVE_GTK_AND_PTHREAD, 1,
                [Define to 1 if you have GTK and pthread (-lpthread).])
     fi
-  fi
+
+  dnl Check for functions introduced in 2.14 and later.
+  AC_CHECK_FUNCS(gtk_widget_get_window gtk_widget_set_has_window \
+                 gtk_dialog_get_action_area gtk_widget_get_sensitive \
+                 gtk_widget_get_mapped gtk_adjustment_get_page_size \
+                 gtk_orientable_set_orientation)
+
 fi
 
 dnl D-Bus has been tested under GNU/Linux only.  Must be adapted for
@@ -2623,7 +2675,7 @@ HAVE_LIBNCURSES=yes
 
 ## Use terminfo instead of termcap?
 ## Note only system files NOT using terminfo are:
-## freebsd < 40000, ms-w32, msdos, netbsd, and
+## freebsd < 40000, ms-w32, msdos, netbsd < 599002500, and
 ## darwin|gnu without ncurses.
 TERMINFO=no
 LIBS_TERMCAP=
@@ -2665,13 +2717,22 @@ fail;
     fi
     ;;
 
+  netbsd)
+    if test $ac_cv_search_tputs = -lterminfo; then
+      TERMINFO=yes
+      LIBS_TERMCAP="-lterminfo"
+    else
+      LIBS_TERMCAP="-ltermcap"
+    fi
+    ;;
+
 esac
 
 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.
-  hpux*|netbsd) LIBS_TERMCAP="-ltermcap" ;;
+  hpux*) LIBS_TERMCAP="-ltermcap" ;;
 
   openbsd) LIBS_TERMCAP="-lncurses" ;;
 
@@ -3045,7 +3106,6 @@ AC_SUBST(docdir)
 AC_SUBST(bitmapdir)
 AC_SUBST(gamedir)
 AC_SUBST(gameuser)
-AC_SUBST(unexec)
 ## FIXME? Nothing uses @LD_SWITCH_X_SITE@.
 ## src/Makefile.in did add LD_SWITCH_X_SITE (as a cpp define) to the
 ## end of LIBX_BASE, but nothing ever set it.
@@ -3142,7 +3202,6 @@ else
   OLDXMENU_TARGET="really-lwlib"
 fi
 AC_SUBST(LIBXT_OTHER)
-AC_SUBST(OLDXMENU_TARGET)
 
 ## The X Menu stuff is present in the X10 distribution, but missing
 ## from X11.  If we have X10, just use the installed library;
@@ -3159,8 +3218,11 @@ if test "${HAVE_X11}" = "yes" ; then
   fi
   LIBXMENU="\$(OLDXMENU)"
   LIBX_OTHER="\$(LIBXT) \$(LIBX_EXTRA)"
+  OLDXMENU_DEPS="\${OLDXMENU} ../src/\${OLDXMENU}"
 else
-  OLDXMENU=
+  ## For a syntactically valid Makefile; not actually used for anything.
+  ## See comments in src/Makefile.in.
+  OLDXMENU=nothing
   ## FIXME This case (!HAVE_X11 && HAVE_X_WINDOWS) is no longer possible(?).
   if test "${HAVE_X_WINDOWS}" = "yes"; then
     LIBXMENU="-lXMenu"
@@ -3168,16 +3230,21 @@ else
     LIBXMENU=
   fi
   LIBX_OTHER=
+  OLDXMENU_DEPS=
 fi
 
 if test "$HAVE_GTK" = "yes" || test "$HAVE_MENUS" != "yes"; then
-  OLDXMENU=
+  OLDXMENU_TARGET=
+  OLDXMENU=nothing  
   LIBXMENU=
+  OLDXMENU_DEPS=
 fi
 
+AC_SUBST(OLDXMENU_TARGET)
 AC_SUBST(OLDXMENU)
 AC_SUBST(LIBXMENU)
 AC_SUBST(LIBX_OTHER)
+AC_SUBST(OLDXMENU_DEPS)
 
 if test "${HAVE_MENUS}" = "yes" ; then
   AC_DEFINE(HAVE_MENUS, 1,
@@ -3185,26 +3252,31 @@ if test "${HAVE_MENUS}" = "yes" ; then
             (This is automatic if you use X, but the option to specify it remains.)
             It is also defined with other window systems that support xmenu.c.])
 fi
+
 if test "${GNU_MALLOC}" = "yes" ; then
   AC_DEFINE(GNU_MALLOC, 1,
            [Define to 1 if you want to use the GNU memory allocator.])
 fi
+
+RALLOC_OBJ=
 if test "${REL_ALLOC}" = "yes" ; then
   AC_DEFINE(REL_ALLOC, 1,
            [Define REL_ALLOC if you want to use the relocating allocator for
             buffer space.])
-fi
 
+  test "$system_malloc" != "yes" && RALLOC_OBJ=ralloc.o
+fi
+AC_SUBST(RALLOC_OBJ)
 
 if test "$opsys" = "cygwin"; then
   CYGWIN_OBJ="sheap.o"
   ## Cygwin differs because of its unexec().
   PRE_ALLOC_OBJ=
-  POST_ALLOC_OBJ="lastfile.o vm-limit.o"
+  POST_ALLOC_OBJ=lastfile.o
 else
   CYGWIN_OBJ=
   PRE_ALLOC_OBJ=lastfile.o
-  POST_ALLOC_OBJ="\$(vmlimitobj)"
+  POST_ALLOC_OBJ=
 fi
 AC_SUBST(CYGWIN_OBJ)
 AC_SUBST(PRE_ALLOC_OBJ)
@@ -3215,44 +3287,121 @@ case "$opsys" in
   aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;;
 
   darwin)
-  ## The -headerpad option tells ld (see man page) to leave room at the
-  ## end of the header for adding load commands.  Needed for dumping.
-  ## 0x690 is the total size of 30 segment load commands (at 56
-  ## each); under Cocoa 31 commands are required.
-  if test "$HAVE_NS" = "yes"; then
-    libs_nsgui="-framework AppKit"
-    headerpad_extra=6C8
-  else
-    libs_nsgui=
-    headerpad_extra=690
-  fi
-  LD_SWITCH_SYSTEM_TEMACS="-prebind $libs_nsgui -Xlinker -headerpad -Xlinker $headerpad_extra"
-  ;;
+   ## The -headerpad option tells ld (see man page) to leave room at the
+   ## end of the header for adding load commands.  Needed for dumping.
+   ## 0x690 is the total size of 30 segment load commands (at 56
+   ## each); under Cocoa 31 commands are required.
+   if test "$HAVE_NS" = "yes"; then
+     libs_nsgui="-framework AppKit"
+     headerpad_extra=6C8
+   else
+     libs_nsgui=
+     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
+   ##   #if !defined (__GNUC__) && ((defined (BSD_SYSTEM) && !defined (COFF)))
+   ## Since all the *bsds define LD_SWITCH_SYSTEM, this simplifies to:
+   ## not using gcc, darwin system not on an alpha (ie darwin, since
+   ## darwin + alpha does not occur).
+   ## Because this was done in src/Makefile.in, the resulting part of
+   ## LD_SWITCH_SYSTEM was not used in configure (ie, in ac_link).
+   ## It therefore seems cleaner to put this in LD_SWITCH_SYSTEM_TEMACS,
+   ## rather than LD_SWITCH_SYSTEM.
+   test "x$LD_SWITCH_SYSTEM" = "x" && test "x$GCC" != "xyes" && \
+     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
+  ## 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-linux) LD_SWITCH_SYSTEM_TEMACS="\$(LD_SWITCH_X_SITE_AUX)" ;;
 
   *) LD_SWITCH_SYSTEM_TEMACS= ;;
 esac
+
+if test "$NS_IMPL_GNUSTEP" = "yes"; then
+  LD_SWITCH_SYSTEM_TEMACS="${LD_SWITCH_SYSTEM_TEMACS} -L${GNUSTEP_SYSTEM_LIBRARIES} ${GNUSTEP_LOCAL_LIBRARIES} -lgnustep-gui -lgnustep-base -lobjc -lpthread"
+fi
+
 AC_SUBST(LD_SWITCH_SYSTEM_TEMACS)
 
 
-## This exists because src/Makefile.in did some extra fiddling around
-## with LD_SWITCH_SYSTEM.  The cpp logic was:
-##   #ifndef LD_SWITCH_SYSTEM
-##   #if !defined (__GNUC__) && ((defined (BSD_SYSTEM) && !defined (COFF)))
-## Since all the *bsds define LD_SWITCH_SYSTEM, this simplifies to:
-## not using gcc, darwin system not on an alpha (ie darwin, since
-## darwin + alpha does not occur).
-## Note that unlike L_S_S, this is not used in ac_link.
-if test "x$LD_SWITCH_SYSTEM" = "x" && test "x$GCC" != "xyes" && \
-   test "$opsys" = "darwin"; then
-  LD_SWITCH_SYSTEM_EXTRA="-X"
-else
-  LD_SWITCH_SYSTEM_EXTRA=
-fi
-AC_SUBST(LD_SWITCH_SYSTEM_EXTRA)
+LINKER=
+ORDINARY_LINK=
+case "$opsys" in
+  ## gnu: GNU needs its own crt0.
+  aix4-2|darwin|gnu|usg5-4|irix6-5|sol2*|unixware) ORDINARY_LINK=yes ;;
 
+  cygwin) LINKER="\$(CC)" ;;
 
+  ## On post 1.3 releases of NetBSD, gcc -nostdlib also clears the
+  ## library search parth, i.e. it won't search /usr/lib for libc and
+  ## friends.  Using -nostartfiles instead avoids this problem, and
+  ## will also work on earlier NetBSD releases.
+  netbsd|openbsd) LINKER="\$(CC) -nostartfiles" ;;
+
+  ## macpcc: NAKAJI Hiroyuki <nakaji@tutrp.tut.ac.jp> says
+  ##   MkLinux/LinuxPPC needs this.
+  ## ibms390x only supports opsys = gnu-linux so it can be added here.
+  gnu-*)
+    case "$machine" in
+      macppc|ibms390x) LINKER="\$(CC) -nostdlib" ;;
+    esac
+    ;;
+esac
+
+
+PRE_EDIT_LDFLAGS=
+POST_EDIT_LDFLAGS=
+if test "x$ORDINARY_LINK" = "xyes"; then
+
+  LINKER="\$(CC)"
+  AC_DEFINE(ORDINARY_LINK, 1, [Define if the C compiler is the linker.])
+
+## The system files defining neither ORDINARY_LINK nor LINKER are:
+## (bsd-common), freebsd, gnu-* not on macppc|ibms390x, hpux*.
+elif test "x$GCC" = "xyes" && test "x$LINKER" = "x"; then
+
+  ## Versions of GCC >= 2.0 put their library, libgcc.a, in obscure
+  ## places that are difficult to figure out at make time.  Fortunately,
+  ## these same versions allow you to pass arbitrary flags on to the
+  ## linker, so there is no reason not to use it as a linker.
+  ##
+  ## Well, it is not quite perfect.  The "-nostdlib" keeps GCC from
+  ## searching for libraries in its internal directories, so we have to
+  ## ask GCC explicitly where to find libgcc.a (LIB_GCC below).
+  LINKER="\$(CC) -nostdlib"
+  ## GCC passes any argument prefixed with -Xlinker directly to the linker.
+  ## See prefix-args.c for an explanation of why we do not do this with the
+  ## shell''s ``for'' construct.  Note that sane people do not have '.' in
+  ## their paths, so we must use ./prefix-args.
+  ## TODO either make prefix-args check ORDINARY_LINK internally,
+  ## or remove it altogether (bug#6184), removing the need for this hack.
+  PRE_EDIT_LDFLAGS='`./prefix-args -Xlinker'
+  POST_EDIT_LDFLAGS='`'
+fi
+AC_SUBST(PRE_EDIT_LDFLAGS)
+AC_SUBST(POST_EDIT_LDFLAGS)
+
+test "x$LINKER" = "x" && LINKER=ld
+## FIXME? What setting of EDIT_LDFLAGS should this have?
+test "$NS_IMPL_GNUSTEP" = "yes" && LINKER="\$(CC) -rdynamic"
+
+AC_SUBST(LINKER)
+
+
+## FIXME? The logic here is not precisely the same as that above.
+## There is no check here for a pre-defined LINKER.
+## Should we only be setting LIB_GCC if LD ~ -nostdlib?
 LIB_GCC=
-if test "x$GCC" = "xyes"; then
+if test "x$GCC" = "xyes" && test "x$ORDINARY_LINK" != "xyes"; then
 
   case "$opsys" in
     ## cygwin: don't link against static libgcc.
@@ -3332,25 +3481,6 @@ AH_BOTTOM([
 /* Turned on June 1996 supposing nobody will mind it.  */
 #define AMPERSAND_FULL_NAME
 
-/* Define HAVE_SOUND if we have sound support.  We know it works
-   and compiles only on the specified platforms.   For others,
-   it probably doesn't make sense to try.  */
-
-#if defined __FreeBSD__ || defined __NetBSD__ || defined __linux__
-#ifdef HAVE_MACHINE_SOUNDCARD_H
-#define HAVE_SOUND 1
-#endif
-#ifdef HAVE_SYS_SOUNDCARD_H
-#define HAVE_SOUND 1
-#endif
-#ifdef HAVE_SOUNDCARD_H
-#define HAVE_SOUND 1
-#endif
-#ifdef HAVE_ALSA
-#define HAVE_SOUND 1
-#endif
-#endif /* __FreeBSD__ || __NetBSD__ || __linux__  */
-
 /* If using GNU, then support inline function declarations.  */
 /* Don't try to switch on inline handling as detected by AC_C_INLINE
    generally, because even if non-gcc compilers accept `inline', they
@@ -3410,23 +3540,10 @@ SYSTEM_PURESIZE_EXTRA seems like the least likely to cause problems.  */
 
 #define my_strftime nstrftime  /* for strftime.c */
 
-/* The rest of the code currently tests the CPP symbol BSTRING.
-   Override any claims made by the system-description files.
-   Note that on some SCO version it is possible to have bcopy and not bcmp.  */
-#undef BSTRING
-#if defined (HAVE_BCOPY) && defined (HAVE_BCMP)
-#define BSTRING
-#endif
-
 /* Some of the files of Emacs which are intended for use with other
    programs assume that if you have a config.h file, you must declare
-   the type of getenv.
-
-   This declaration shouldn't appear when alloca.s or Makefile.in
-   includes config.h.  */
-#ifndef NOT_C_CODE
+   the type of getenv.  */
 extern char *getenv ();
-#endif
 
 /* These default definitions are good for almost all machines.
    The exceptions override them in m/MACHINE.h.  */
@@ -3454,54 +3571,38 @@ extern char *getenv ();
 #endif
 #endif
 
-/* Define if the compiler supports function prototypes.  It may do so
-   but not define __STDC__ (e.g. DEC C by default) or may define it as
-   zero.  */
+/* Define if the compiler supports function prototypes.  It may do so but
+   not define __STDC__ (e.g. DEC C by default) or may define it as zero.  */
 #undef PROTOTYPES
-/* For mktime.c:  */
-#ifndef __P
-# if defined PROTOTYPES
-#  define __P(args) args
-# else
-#  define __P(args) ()
-# endif  /* GCC.  */
-#endif /* __P */
-
-/* Don't include "string.h" or <stdlib.h> in non-C code.  */
-#ifndef NOT_C_CODE
+
 #ifdef HAVE_STRING_H
-#include "string.h"
+#include <string.h>
 #endif
+
 #ifdef HAVE_STRINGS_H
-#include "strings.h"  /* May be needed for bcopy & al.  */
+#include <strings.h>  /* May be needed for bcopy & al.  */
 #endif
+
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
-#ifndef __GNUC__
-# ifdef HAVE_ALLOCA_H
-#  include <alloca.h>
-# else /* AIX files deal with #pragma.  */
-#  ifndef alloca /* predefined by HP cc +Olibcalls */
-char *alloca ();
-#  endif
-# endif /* HAVE_ALLOCA_H */
-#endif /* __GNUC__ */
-#ifndef HAVE_SIZE_T
-typedef unsigned size_t;
-#endif
-#endif /* NOT_C_CODE */
-
-/* Define HAVE_X_I18N if we have usable i18n support.  */
 
-#ifdef HAVE_X11R6
-#define HAVE_X_I18N
+#ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+#elif defined __GNUC__
+# define alloca __builtin_alloca
+#elif defined _AIX
+# define alloca __alloca
+#else
+# include <stddef.h>
+# ifdef  __cplusplus
+extern "C"
+# endif
+void *alloca (size_t);
 #endif
 
-/* Define HAVE_X11R6_XIM if we have usable X11R6-style XIM support.  */
-
-#if defined HAVE_X11R6 && !defined INHIBIT_X11R6_XIM
-#define HAVE_X11R6_XIM
+#ifndef HAVE_SIZE_T
+typedef unsigned size_t;
 #endif
 
 #if defined __GNUC__ && (__GNUC__ > 2 \
@@ -3628,32 +3729,17 @@ fi
 test "${exec_prefix}" != NONE &&
   exec_prefix=`echo "${exec_prefix}" | sed 's,\([^/]\)/*$,\1,'`]
 
-# Now get this: Some word that is part of the ${srcdir} directory name
-# or the ${configuration} value might, just might, happen to be an
-# identifier like `sun4' or `i386' or something, and be predefined by
-# the C preprocessor to some helpful value like 1, or maybe the empty
-# string.  Needless to say consequent macro substitutions are less
-# than conducive to the makefile finding the correct directory.
-# src/Makefile.in used to treat X11 as equivalent to HAVE_X11.
-# But nothing in Emacs defines X11, and everywhere else uses HAVE_X11,
-# so that cannot have been doing anything.
-[cpp_undefs="`echo $srcdir $configuration $canonical unix mktime register X11 |
-  sed -e 's/[^a-zA-Z0-9_]/ /g' -e 's/^/ /' -e 's/  *$//' \
-  -e 's/  */ -U/g' -e 's/-U[0-9][^ ]*//g'`"]
-
-## Check if the C preprocessor will convert `..' to `. .'.  If so, set
-## CPP_NEED_TRADITIONAL to `yes' so that the code to generate Makefile
-## from Makefile.c can correctly provide the arg `-traditional' to the
-## C preprocessor.
-
-AC_EGREP_CPP(yes..yes,
-       [yes..yes],
-       CPP_NEED_TRADITIONAL=no,
-       CPP_NEED_TRADITIONAL=yes)
-
+dnl You might wonder (I did) why epaths.h is generated by running make,
+dnl rather than just letting configure generate it from epaths.in.
+dnl One reason is that the various paths are not fully expanded (see above);
+dnl eg gamedir=${prefix}/var/games/emacs.
+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 \
        doc/emacs/Makefile doc/misc/Makefile doc/lispintro/Makefile \
-       doc/lispref/Makefile src/Makefile.c:src/Makefile.in \
+       doc/lispref/Makefile src/Makefile \
        lwlib/Makefile lisp/Makefile leim/Makefile, [
 
 ### Make the necessary directories, if they don't exist.
@@ -3661,42 +3747,15 @@ for dir in etc lisp ; do
   test -d ${dir} || mkdir ${dir}
 done
 
-# Build src/Makefile from ${srcdir}/src/Makefile.c
-# and lib-src/Makefile from ${srcdir}/lib-src/Makefile.c
-# This must be done after src/config.h is built, since we rely on that file.
-
 echo creating src/epaths.h
 ${MAKE-make} epaths-force
 
-# As of 2000-11-19, newest development versions of GNU cpp preprocess
-# `..' to `. .'  unless invoked with -traditional
-
-if test "x$GCC" = xyes && test "x$CPP_NEED_TRADITIONAL" = xyes; then
-  CPPFLAGS="$CPPFLAGS -traditional"
-fi
-
-echo creating src/Makefile
-( cd src
-  rm -f junk.c junk1.c junk2.c
-  sed -e '/start of cpp stuff/q' \
-      < Makefile.c > junk1.c
-  sed -e '1,/start of cpp stuff/d'\
-      -e 's,/\*\*/#\(.*\)$,/* \1 */,' \
-      < Makefile.c > junk.c
-  $CPP -P $cpp_undefs -I. -I$srcdir/src $CPPFLAGS junk.c | \
-      sed -e 's/^ /    /' -e '/^#/d' -e '/^[   \f]*$/d' > junk2.c
-  cat junk1.c junk2.c > Makefile.new
-  rm -f junk.c junk1.c junk2.c
-  chmod 444 Makefile.new
-  mv -f Makefile.new Makefile
-)
-
 if test ! -f src/.gdbinit && test -f $srcdir/src/.gdbinit; then
   echo creating src/.gdbinit
   echo source $srcdir/src/.gdbinit > src/.gdbinit
 fi
 
-], [GCC="$GCC" NON_GNU_CPP="$NON_GNU_CPP" CPP="$CPP" CPP_NEED_TRADITIONAL="$CPP_NEED_TRADITIONAL" CPPFLAGS="$CPPFLAGS" cpp_undefs="$cpp_undefs"])
+], [GCC="$GCC" NON_GNU_CPP="$NON_GNU_CPP" CPP="$CPP" CPPFLAGS="$CPPFLAGS"])
 
 m4_if(dnl      Do not change this comment
    arch-tag: 156a4dd5-bddc-4d18-96ac-f37742cf6a5e