From e16f9eefe02966c5410c71cb6a9fa771bb95a914 Mon Sep 17 00:00:00 2001
From: Akim Demaille <akim@epita.fr>
Date: Fri, 28 Sep 2001 11:56:26 +0000
Subject: [PATCH] * lib/emacs/autoconf-mode.el, lib/emacs/autotest-mode.el:
 New. * configure.ac: Adjust.

---
 ChangeLog                  |   5 +
 NEWS                       |   3 +
 aclocal.m4                 |   1 +
 configure                  | 101 ++++++++++++++++-
 configure.ac               |  19 +++-
 lib/Makefile.am            |   2 +-
 lib/Makefile.in            |   2 +-
 lib/emacs/.cvsignore       |   2 +
 lib/emacs/Makefile.am      |  20 ++++
 lib/emacs/Makefile.in      | 227 +++++++++++++++++++++++++++++++++++++
 lib/emacs/autoconf-mode.el |  82 ++++++++++++++
 lib/emacs/autotest-mode.el |  84 ++++++++++++++
 lib/emacs/elisp-comp       |  54 +++++++++
 m4/Makefile.am             |   1 +
 m4/Makefile.in             |   1 +
 m4/lispdir.m4              |  49 ++++++++
 16 files changed, 641 insertions(+), 12 deletions(-)
 create mode 100644 lib/emacs/.cvsignore
 create mode 100644 lib/emacs/Makefile.am
 create mode 100644 lib/emacs/Makefile.in
 create mode 100644 lib/emacs/autoconf-mode.el
 create mode 100644 lib/emacs/autotest-mode.el
 create mode 100755 lib/emacs/elisp-comp
 create mode 100644 m4/lispdir.m4

diff --git a/ChangeLog b/ChangeLog
index 2b2acc44..2efe4624 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-09-28  Akim Demaille  <akim@epita.fr>
+
+	* lib/emacs/autoconf-mode.el, lib/emacs/autotest-mode.el: New.
+	* configure.ac: Adjust.
+
 2001-09-28  Akim Demaille  <akim@epita.fr>
 
 	* lib/autotest/general.m4 (AT_VICTIMS): Rename as...
diff --git a/NEWS b/NEWS
index 7cdb205e..bdf98bd9 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,9 @@
   @builddir@, @top_builddir@, @srcpath@, @top_srcpath@, @buildpath@,
   @top_buildpath@.
 
+** Emacs
+  Autoconf and Autotest modes are provided.
+
 ** autom4te
   New executable, used by the Autoconf suite to cache and speed up
   most processing.
diff --git a/aclocal.m4 b/aclocal.m4
index 47b142c6..ca64df6d 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -4,6 +4,7 @@ m4_include([m4/depend.m4])
 m4_include([m4/init.m4])
 m4_include([m4/install-sh.m4])
 m4_include([m4/m4.m4])
+m4_include([m4/lispdir.m4])
 m4_include([m4/missing.m4])
 m4_include([m4/sanity.m4])
 m4_include([m4/strip.m4])
diff --git a/configure b/configure
index 8ce9b83f..377f7339 100755
--- a/configure
+++ b/configure
@@ -693,6 +693,11 @@ Optional Features:
   --disable-dependency-tracking Speeds up one-time builds
   --enable-dependency-tracking  Do not reject slow dependency extractors
 
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+   --with-lispdir            Override the default lisp directory
+
 Report bugs to <bug-autoconf@gnu.org>.
 _ACEOF
 fi
@@ -1017,6 +1022,8 @@ ac_config_guess="$SHELL $ac_aux_dir/config.guess"
 ac_config_sub="$SHELL $ac_aux_dir/config.sub"
 ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
 
+ac_config_files="$ac_config_files config/Makefile"
+
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
 # incompatible versions:
@@ -1316,6 +1323,8 @@ if test -f $srcdir/tests/atlocal.in; then
 
 fi
 
+ac_config_files="$ac_config_files tests/Makefile"
+
 ac_config_files="$ac_config_files tests/autoconf:tests/wrapsh.in"
 
 ac_config_files="$ac_config_files tests/autoheader:tests/wrappl.in"
@@ -1440,7 +1449,8 @@ fi
 # This is needed because Automake does not seem to realize there is
 # a AC-SUBST inside AC-PROG-GNU-M4.  Grmph!
 
-# Generating man pages.
+# Man pages.
+ac_config_files="$ac_config_files man/Makefile"
 
 HELP2MAN=${HELP2MAN-"${am_missing_run}help2man"}
 
@@ -1496,10 +1506,88 @@ echo "$as_me: error: Perl 5.005 or better is required" >&2;}
    { (exit 1); exit 1; }; }
 }
 
+# Emacs modes.
+ac_config_files="$ac_config_files lib/emacs/Makefile"
+
+# Check whether --with-lispdir or --without-lispdir was given.
+if test "${with_lispdir+set}" = set; then
+  withval="$with_lispdir"
+   lispdir="$withval"
+    echo "$as_me:$LINENO: checking where .elc files should go" >&5
+echo $ECHO_N "checking where .elc files should go... $ECHO_C" >&6
+    echo "$as_me:$LINENO: result: $lispdir" >&5
+echo "${ECHO_T}$lispdir" >&6
+else
+
+  # If set to t, that means we are running in a shell under Emacs.
+  # If you have an Emacs named "t", then use the full path.
+  test x"$EMACS" = xt && EMACS=
+  for ac_prog in emacs xemacs
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_EMACS+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$EMACS"; then
+  ac_cv_prog_EMACS="$EMACS" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_EMACS="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+EMACS=$ac_cv_prog_EMACS
+if test -n "$EMACS"; then
+  echo "$as_me:$LINENO: result: $EMACS" >&5
+echo "${ECHO_T}$EMACS" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$EMACS" && break
+done
+test -n "$EMACS" || EMACS="no"
+
+  if test $EMACS != "no"; then
+    if test x${lispdir+set} != xset; then
+      echo "$as_me:$LINENO: checking where .elc files should go" >&5
+echo $ECHO_N "checking where .elc files should go... $ECHO_C" >&6
+if test "${am_cv_lispdir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  	am_cv_lispdir=`$EMACS -batch -q -eval '(while load-path (princ (concat (car load-path) "\n")) (setq load-path (cdr load-path)))' | sed -n -e 's,/$,,' -e '/.*\/lib\/\(x\?emacs\/site-lisp\)$/{s,,${libdir}/\1,;p;q;}' -e '/.*\/share\/\(x\?emacs\/site-lisp\)$/{s,,${datadir}/\1,;p;q;}'`
+	if test -z "$am_cv_lispdir"; then
+	  am_cv_lispdir='${datadir}/emacs/site-lisp'
+	fi
+
+fi
+echo "$as_me:$LINENO: result: $am_cv_lispdir" >&5
+echo "${ECHO_T}$am_cv_lispdir" >&6
+      lispdir="$am_cv_lispdir"
+    fi
+  fi
+
+fi;
+
 # Automake can't see inner AC_SUBSTS (`aclocal' is bypassed), so we tag the
 # AC_SUBSTS here too.
 
-ac_config_files="$ac_config_files Makefile m4/Makefile man/Makefile doc/Makefile config/Makefile lib/Makefile lib/Autom4te/Makefile lib/autoscan/Makefile lib/m4sugar/Makefile lib/autoconf/Makefile lib/autotest/Makefile bin/Makefile tests/Makefile"
+ac_config_files="$ac_config_files Makefile m4/Makefile doc/Makefile lib/Makefile lib/Autom4te/Makefile lib/autoscan/Makefile lib/m4sugar/Makefile lib/autoconf/Makefile lib/autotest/Makefile bin/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -1942,7 +2030,9 @@ for ac_config_target in $ac_config_targets
 do
   case "$ac_config_target" in
   # Handling of arguments.
+  "config/Makefile" ) CONFIG_FILES="$CONFIG_FILES config/Makefile" ;;
   "tests/atlocal" ) CONFIG_FILES="$CONFIG_FILES tests/atlocal" ;;
+  "tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
   "tests/autoconf" ) CONFIG_FILES="$CONFIG_FILES tests/autoconf:tests/wrapsh.in" ;;
   "tests/autoheader" ) CONFIG_FILES="$CONFIG_FILES tests/autoheader:tests/wrappl.in" ;;
   "tests/autom4te" ) CONFIG_FILES="$CONFIG_FILES tests/autom4te" ;;
@@ -1950,11 +2040,11 @@ do
   "tests/autoscan" ) CONFIG_FILES="$CONFIG_FILES tests/autoscan:tests/wrappl.in" ;;
   "tests/autoupdate" ) CONFIG_FILES="$CONFIG_FILES tests/autoupdate" ;;
   "tests/ifnames" ) CONFIG_FILES="$CONFIG_FILES tests/ifnames:tests/wrappl.in" ;;
+  "man/Makefile" ) CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
+  "lib/emacs/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/emacs/Makefile" ;;
   "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
   "m4/Makefile" ) CONFIG_FILES="$CONFIG_FILES m4/Makefile" ;;
-  "man/Makefile" ) CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
   "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
-  "config/Makefile" ) CONFIG_FILES="$CONFIG_FILES config/Makefile" ;;
   "lib/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
   "lib/Autom4te/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/Autom4te/Makefile" ;;
   "lib/autoscan/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/autoscan/Makefile" ;;
@@ -1962,7 +2052,6 @@ do
   "lib/autoconf/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/autoconf/Makefile" ;;
   "lib/autotest/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/autotest/Makefile" ;;
   "bin/Makefile" ) CONFIG_FILES="$CONFIG_FILES bin/Makefile" ;;
-  "tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
   "tests/package.m4" ) CONFIG_COMMANDS="$CONFIG_COMMANDS tests/package.m4" ;;
   "tests/atconfig" ) CONFIG_COMMANDS="$CONFIG_COMMANDS tests/atconfig" ;;
   *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
@@ -2069,6 +2158,8 @@ s,@EXPR@,$EXPR,;t t
 s,@M4@,$M4,;t t
 s,@HELP2MAN@,$HELP2MAN,;t t
 s,@PERL@,$PERL,;t t
+s,@EMACS@,$EMACS,;t t
+s,@lispdir@,$lispdir,;t t
 CEOF
 
 _ACEOF
diff --git a/configure.ac b/configure.ac
index 6907da21..f21a44e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,15 +20,19 @@
 # 02111-1307, USA.
 
 # We need AC_CONFIG_TESTDIR.
-AC_PREREQ(2.52d)
+AC_PREREQ(2.52e)
 
 AC_INIT(GNU Autoconf, 2.52e, bug-autoconf@gnu.org)
 AC_CONFIG_SRCDIR(ChangeLog)
+
 AC_CONFIG_AUX_DIR(config)
+AC_CONFIG_FILES(config/Makefile)
+
 AM_INIT_AUTOMAKE(autoconf, 2.52e)
 
 # Initialize the test suite and build position independent wrappers.
 AC_CONFIG_TESTDIR(tests)
+AC_CONFIG_FILES(tests/Makefile)
 AC_CONFIG_FILES([tests/autoconf:tests/wrapsh.in],
                 [chmod +x tests/autoconf])
 AC_CONFIG_FILES([tests/autoheader:tests/wrappl.in],
@@ -45,6 +49,7 @@ AC_CONFIG_FILES([tests/ifnames:tests/wrappl.in],
                 [chmod +x tests/ifnames])
 AC_PATH_PROG(EXPR, expr)
 
+
 # We use a path for GNU m4 so even if users have another m4 first in
 # their path, the installer can configure with a path that has GNU m4
 # first and get that path embedded in the installed autoconf and
@@ -57,7 +62,8 @@ fi
 # a AC-SUBST inside AC-PROG-GNU-M4.  Grmph!
 AC_SUBST(M4)
 
-# Generating man pages.
+# Man pages.
+AC_CONFIG_FILES(man/Makefile)
 AM_MISSING_PROG(HELP2MAN, help2man)
 
 # We use a path for perl so the #! line in autoscan will work.
@@ -70,18 +76,21 @@ $PERL -e 'require 5.005;' || {
    AC_MSG_ERROR([Perl 5.005 or better is required])
 }
 
+# Emacs modes.
+AC_CONFIG_FILES(lib/emacs/Makefile)
+AM_PATH_LISPDIR
+
 # Automake can't see inner AC_SUBSTS (`aclocal' is bypassed), so we tag the
 # AC_SUBSTS here too.
 AC_SUBST(PACKAGE_NAME)
 AC_SUBST(PACKAGE)
 AC_SUBST(VERSION)
 
-AC_CONFIG_FILES(Makefile m4/Makefile man/Makefile doc/Makefile config/Makefile
+AC_CONFIG_FILES(Makefile m4/Makefile doc/Makefile
                 lib/Makefile lib/Autom4te/Makefile lib/autoscan/Makefile
                 lib/m4sugar/Makefile
                 lib/autoconf/Makefile lib/autotest/Makefile
-                bin/Makefile
-                tests/Makefile)
+                bin/Makefile)
 
 AC_OUTPUT
 # Report the state of this version of Autoconf if this is a beta.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 50a110f8..2d18d3a5 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 
-SUBDIRS = Autom4te m4sugar autoconf autotest autoscan
+SUBDIRS = Autom4te m4sugar autoconf autotest autoscan emacs
 nodist_pkgdata_DATA = autom4te.cfg
 EXTRA_DIST = autom4te.in
 
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 07cffe4c..ed96f9cc 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -63,7 +63,7 @@ PACKAGE_NAME = @PACKAGE_NAME@
 PERL = @PERL@
 VERSION = @VERSION@
 
-SUBDIRS = Autom4te m4sugar autoconf autotest autoscan
+SUBDIRS = Autom4te m4sugar autoconf autotest autoscan emacs
 nodist_pkgdata_DATA = autom4te.cfg
 EXTRA_DIST = autom4te.in
 
diff --git a/lib/emacs/.cvsignore b/lib/emacs/.cvsignore
new file mode 100644
index 00000000..d9d4688e
--- /dev/null
+++ b/lib/emacs/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+*.elc
diff --git a/lib/emacs/Makefile.am b/lib/emacs/Makefile.am
new file mode 100644
index 00000000..5b9aa75e
--- /dev/null
+++ b/lib/emacs/Makefile.am
@@ -0,0 +1,20 @@
+## Process this file with automake to create Makefile.in
+
+## Copyright 2001 Free Software Foundation, Inc.
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+## 02111-1307, USA.
+
+dist_lisp_LISP = autoconf-mode.el autotest-mode.el
diff --git a/lib/emacs/Makefile.in b/lib/emacs/Makefile.in
new file mode 100644
index 00000000..ebd0ffef
--- /dev/null
+++ b/lib/emacs/Makefile.in
@@ -0,0 +1,227 @@
+# Makefile.in generated automatically by automake 1.5 from Makefile.am.
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ../..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = @program_transform_name@
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+EXPR = @EXPR@
+HELP2MAN = @HELP2MAN@
+M4 = @M4@
+PACKAGE = @PACKAGE@
+PACKAGE_NAME = @PACKAGE_NAME@
+PERL = @PERL@
+VERSION = @VERSION@
+
+dist_lisp_LISP = autoconf-mode.el autotest-mode.el
+subdir = lib/emacs
+mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
+CONFIG_CLEAN_FILES =
+DIST_SOURCES =
+LISP = $(dist_lisp_LISP)
+
+ELCFILES = autoconf-mode.elc autotest-mode.elc
+DIST_COMMON = $(dist_lisp_LISP) Makefile.am Makefile.in elisp-comp
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .el .elc
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.ac $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  lib/emacs/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && \
+	  CONFIG_HEADERS= CONFIG_LINKS= \
+	  CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status
+uninstall-info-am:
+
+EMACS = @EMACS@
+lispdir = @lispdir@
+
+.el.elc:
+	@echo 'WARNING: Warnings can be ignored. :-)'
+	if test $(EMACS) != no; then \
+	  EMACS=$(EMACS) $(SHELL) $(srcdir)/elisp-comp $<; \
+	else : ; fi
+install-dist_lispLISP: $(dist_lisp_LISP) $(ELCFILES)
+	@$(NORMAL_INSTALL)
+	@if test -n "$(lispdir)"; then \
+	  $(mkinstalldirs) $(DESTDIR)$(lispdir); \
+	  list='$(dist_lisp_LISP)'; for p in $$list; do \
+	    if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	    f="`echo $$p | sed -e 's|^.*/||'`"; \
+	    echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(lispdir)/$$f"; \
+	    $(INSTALL_DATA) $$d$$p $(DESTDIR)$(lispdir)/$$f; \
+	    if test -f $${p}c; then \
+	      echo " $(INSTALL_DATA) $${p}c $(DESTDIR)$(lispdir)/$${f}c"; \
+	      $(INSTALL_DATA) $${p}c $(DESTDIR)$(lispdir)/$${f}c; \
+	    else : ; fi; \
+	  done; \
+	else : ; fi
+
+uninstall-dist_lispLISP:
+	@$(NORMAL_UNINSTALL)
+	@if test -n "$(lispdir)"; then \
+	  list='$(dist_lisp_LISP)'; for p in $$list; do \
+	    f="`echo $$p | sed -e 's|^.*/||'`"; \
+	    echo " rm -f $(DESTDIR)$(lispdir)/$$f $(DESTDIR)$(lispdir)/$${f}c"; \
+	    rm -f $(DESTDIR)$(lispdir)/$$f $(DESTDIR)$(lispdir)/$${f}c; \
+	  done; \
+	else : ; fi
+
+clean-lisp:
+	-test -z "$(ELCFILES)" || rm -f $(ELCFILES)
+tags: TAGS
+TAGS:
+
+
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+top_distdir = ../..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+
+distdir: $(DISTFILES)
+	@for file in $(DISTFILES); do \
+	  if test -f $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    $(mkinstalldirs) "$(distdir)/$$dir"; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    cp -pR $$d/$$file $(distdir) \
+	    || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LISP) $(ELCFILES)
+
+installdirs:
+	$(mkinstalldirs) $(DESTDIR)$(lispdir)
+
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-lisp mostlyclean-am
+
+distclean: distclean-am
+
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-dist_lispLISP
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic
+
+uninstall-am: uninstall-dist_lispLISP uninstall-info-am
+
+.PHONY: all all-am check check-am clean clean-generic clean-lisp \
+	distclean distclean-generic distdir dvi dvi-am info info-am \
+	install install-am install-data install-data-am \
+	install-dist_lispLISP install-exec install-exec-am install-info \
+	install-info-am install-man install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	uninstall uninstall-am uninstall-dist_lispLISP \
+	uninstall-info-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/lib/emacs/autoconf-mode.el b/lib/emacs/autoconf-mode.el
new file mode 100644
index 00000000..e8fa46ca
--- /dev/null
+++ b/lib/emacs/autoconf-mode.el
@@ -0,0 +1,82 @@
+;;; autoconf-mode.el --- autoconf code editing commands for Emacs
+
+;; Author: Martin Buchholz (martin@xemacs.org)
+;; Maintainer: Martin Buchholz
+;; Keywords: languages, faces, m4, configure
+
+;; This file is part of Autoconf
+
+;; Copyright 2001 Free Software Foundation, Inc.
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+;; 02111-1307, USA.
+
+;; A major mode for editing autoconf input (like configure.in).
+;; Derived from m4-mode.el by Andrew Csillag (drew@staff.prodigy.com)
+
+;;; Code:
+
+;;thank god for make-regexp.el!
+(defvar autoconf-font-lock-keywords
+  `(("\\bdnl \\(.*\\)"  1 font-lock-comment-face t)
+    ("\\$[0-9*#@]" . font-lock-variable-name-face)
+    ("\\b\\(m4_\\)?\\(builtin\\|change\\(com\\|quote\\|word\\)\\|d\\(e\\(bug\\(file\\|mode\\)\\|cr\\|f\\(ine\\|n\\)\\)\\|iv\\(ert\\|num\\)\\|nl\\|umpdef\\)\\|e\\(rrprint\\|syscmd\\|val\\)\\|f\\(ile\\|ormat\\)\\|gnu\\|i\\(f\\(def\\|else\\)\\|n\\(c\\(lude\\|r\\)\\|d\\(ex\\|ir\\)\\)\\)\\|l\\(en\\|ine\\)\\|m\\(4\\(exit\\|wrap\\)\\|aketemp\\)\\|p\\(atsubst\\|opdef\\|ushdef\\)\\|regexp\\|s\\(hift\\|include\\|ubstr\\|ys\\(cmd\\|val\\)\\)\\|tra\\(ceo\\(ff\\|n\\)\\|nslit\\)\\|un\\(d\\(efine\\|ivert\\)\\|ix\\)\\)\\b" . font-lock-keyword-face)
+    ("^\\(\\(m4_\\)?define\\|A._DEFUN\\)(\\[?\\([A-Za-z0-9_]+\\)" 3 font-lock-function-name-face)
+    "default font-lock-keywords")
+)
+
+(defvar autoconf-mode-syntax-table nil
+  "syntax table used in autoconf mode")
+(setq autoconf-mode-syntax-table (make-syntax-table))
+(modify-syntax-entry ?\" "\""  autoconf-mode-syntax-table)
+;;(modify-syntax-entry ?\' "\""  autoconf-mode-syntax-table)
+(modify-syntax-entry ?#  "<\n" autoconf-mode-syntax-table)
+(modify-syntax-entry ?\n ">#"  autoconf-mode-syntax-table)
+(modify-syntax-entry ?\( "()"   autoconf-mode-syntax-table)
+(modify-syntax-entry ?\) ")("   autoconf-mode-syntax-table)
+(modify-syntax-entry ?\[ "(]"  autoconf-mode-syntax-table)
+(modify-syntax-entry ?\] ")["  autoconf-mode-syntax-table)
+(modify-syntax-entry ?*  "."   autoconf-mode-syntax-table)
+(modify-syntax-entry ?_  "_"   autoconf-mode-syntax-table)
+
+(defvar autoconf-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\C-c\C-c" 'comment-region)
+    map))
+
+;;;###autoload
+(defun autoconf-mode ()
+  "A major-mode to edit autoconf input files like configure.in
+\\{autoconf-mode-map}
+"
+  (interactive)
+  (kill-all-local-variables)
+  (use-local-map autoconf-mode-map)
+
+  (make-local-variable 'comment-start)
+  (setq comment-start "dnl")
+  (make-local-variable 'parse-sexp-ignore-comments)
+  (setq parse-sexp-ignore-comments t)
+
+  (make-local-variable	'font-lock-defaults)
+  (setq major-mode 'autoconf-mode)
+  (setq mode-name "Autoconf")
+  (setq font-lock-defaults `(autoconf-font-lock-keywords nil))
+  (set-syntax-table autoconf-mode-syntax-table)
+  (run-hooks 'autoconf-mode-hook))
+
+(provide 'autoconf-mode)
+
+;;; autoconf-mode.el ends here
diff --git a/lib/emacs/autotest-mode.el b/lib/emacs/autotest-mode.el
new file mode 100644
index 00000000..44dce2c6
--- /dev/null
+++ b/lib/emacs/autotest-mode.el
@@ -0,0 +1,84 @@
+;;; autotest-mode.el --- autotest code editing commands for Emacs
+
+;; Author: Akim Demaille (akim@freefriends.org)
+;; Keywords: languages, faces, m4, Autotest
+
+;; This file is part of Autoconf
+
+;; Copyright 2001 Free Software Foundation, Inc.
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+;; 02111-1307, USA.
+
+;;; Commentary:
+
+;; A major mode for editing autotest input (like testsuite.at).
+;; Derived from autoconf-mode.el, by Martin Buchholz (martin@xemacs.org).
+
+;;; Code:
+
+(defvar autotest-font-lock-keywords
+  `(("\\bdnl\\b\\(.*\\)"  1 font-lock-comment-face t)
+    ("\\$[0-9*#@]" . font-lock-variable-name-face)
+    ("^\\(m4_define\\|m4_defun\\)(\\[*\\([A-Za-z0-9_]+\\)" 2 font-lock-function-name-face)
+    ("^AT_SETUP(\\[+\\([^]]+\\)" 1 font-lock-function-name-face)
+    ("^AT_DATA(\\[+\\([^]]+\\)" 1 font-lock-variable-name-face)
+    ("\\b\\(_?m4_[_a-z0-9]*\\|_?A[ST]_[_A-Z0-9]+\\)\\b" . font-lock-keyword-face)
+    "default font-lock-keywords")
+)
+
+(defvar autotest-mode-syntax-table nil
+  "syntax table used in autotest mode")
+(setq autotest-mode-syntax-table (make-syntax-table))
+(modify-syntax-entry ?\" "\""  autotest-mode-syntax-table)
+;;(modify-syntax-entry ?\' "\""  autotest-mode-syntax-table)
+(modify-syntax-entry ?#  "<\n" autotest-mode-syntax-table)
+(modify-syntax-entry ?\n ">#"  autotest-mode-syntax-table)
+(modify-syntax-entry ?\( "()"   autotest-mode-syntax-table)
+(modify-syntax-entry ?\) ")("   autotest-mode-syntax-table)
+(modify-syntax-entry ?\[ "(]"  autotest-mode-syntax-table)
+(modify-syntax-entry ?\] ")["  autotest-mode-syntax-table)
+(modify-syntax-entry ?*  "."   autotest-mode-syntax-table)
+(modify-syntax-entry ?_  "_"   autotest-mode-syntax-table)
+
+(defvar autotest-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map '[(control c) (\;)] 'comment-region)
+    map))
+
+;;;###autoload
+(defun autotest-mode ()
+  "A major-mode to edit Autotest input files like testsuite.at
+\\{autotest-mode-map}
+"
+  (interactive)
+  (kill-all-local-variables)
+  (use-local-map autotest-mode-map)
+
+  (make-local-variable 'comment-start)
+  (setq comment-start "# ")
+  (make-local-variable 'parse-sexp-ignore-comments)
+  (setq parse-sexp-ignore-comments t)
+
+  (make-local-variable	'font-lock-defaults)
+  (setq major-mode 'autotest-mode)
+  (setq mode-name "Autotest")
+  (setq font-lock-defaults `(autotest-font-lock-keywords nil))
+  (set-syntax-table autotest-mode-syntax-table)
+  (run-hooks 'autotest-mode-hook))
+
+(provide 'autotest-mode)
+
+;;; autotest-mode.el ends here
diff --git a/lib/emacs/elisp-comp b/lib/emacs/elisp-comp
new file mode 100755
index 00000000..dc7d7ca6
--- /dev/null
+++ b/lib/emacs/elisp-comp
@@ -0,0 +1,54 @@
+#!/bin/sh
+# Copyright 1995 Free Software Foundation, Inc.
+# Fran�ois Pinard <pinard@iro.umontreal.ca>, 1995.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This script byte-compiles all `.el' files which are part of its
+# arguments, using GNU Emacs, and put the resulting `.elc' files into
+# the current directory, so disregarding the original directories used
+# in `.el' arguments.
+#
+# This script manages in such a way that all Emacs LISP files to
+# be compiled are made visible between themselves, in the event
+# they require or load-library one another.
+
+if test $# = 0; then
+   echo 1>&2 "No files given to $0"
+   exit 1
+else
+   if test -z "$EMACS" || test "$EMACS" = "t"; then
+      # Value of "t" means we are running in a shell under Emacs.
+      # Just assume Emacs is called "emacs".
+      EMACS=emacs
+   fi
+
+   tempdir=elc.$$
+   mkdir $tempdir
+   cp $* $tempdir
+   cd $tempdir
+
+   echo "(setq load-path (cons nil load-path))" > script
+   $EMACS -batch -q -l script -f batch-byte-compile *.el
+   mv *.elc ..
+
+   cd ..
+   rm -fr $tempdir
+fi
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 8fb55c61..5a7b2065 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -25,6 +25,7 @@ depend.m4					\
 init.m4						\
 install-sh.m4					\
 m4.m4						\
+lispdir.m4					\
 missing.m4					\
 sanity.m4					\
 strip.m4
diff --git a/m4/Makefile.in b/m4/Makefile.in
index 6ba27387..d16512f6 100644
--- a/m4/Makefile.in
+++ b/m4/Makefile.in
@@ -70,6 +70,7 @@ depend.m4					\
 init.m4						\
 install-sh.m4					\
 m4.m4						\
+lispdir.m4					\
 missing.m4					\
 sanity.m4					\
 strip.m4
diff --git a/m4/lispdir.m4 b/m4/lispdir.m4
new file mode 100644
index 00000000..9022b802
--- /dev/null
+++ b/m4/lispdir.m4
@@ -0,0 +1,49 @@
+## ------------------------
+## Emacs LISP file handling
+## From Ulrich Drepper
+## Almost entirely rewritten by Alexandre Oliva
+## ------------------------
+
+# Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 3
+
+AC_DEFUN([AM_PATH_LISPDIR],
+ [AC_ARG_WITH(lispdir, 
+  [   --with-lispdir            Override the default lisp directory ],
+  [ lispdir="$withval" 
+    AC_MSG_CHECKING([where .elc files should go])
+    AC_MSG_RESULT([$lispdir])],
+  [
+  # If set to t, that means we are running in a shell under Emacs.
+  # If you have an Emacs named "t", then use the full path.
+  test x"$EMACS" = xt && EMACS=
+  AC_CHECK_PROGS(EMACS, emacs xemacs, no)
+  if test $EMACS != "no"; then
+    if test x${lispdir+set} != xset; then
+      AC_CACHE_CHECK([where .elc files should go], [am_cv_lispdir], [dnl
+	am_cv_lispdir=`$EMACS -batch -q -eval '(while load-path (princ (concat (car load-path) "\n")) (setq load-path (cdr load-path)))' | sed -n -e 's,/$,,' -e '/.*\/lib\/\(x\?emacs\/site-lisp\)$/{s,,${libdir}/\1,;p;q;}' -e '/.*\/share\/\(x\?emacs\/site-lisp\)$/{s,,${datadir}/\1,;p;q;}'`
+	if test -z "$am_cv_lispdir"; then
+	  am_cv_lispdir='${datadir}/emacs/site-lisp'
+	fi
+      ])
+      lispdir="$am_cv_lispdir"
+    fi
+  fi
+ ])
+ AC_SUBST(lispdir)])