Get rid of autom4te.cache directories, as far as possible.
diff --git a/ChangeLog b/ChangeLog
index e991248..53bb9d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-07-15  Bruno Haible  <bruno@clisp.org>
+
+	Get rid of autom4te.cache directories, as far as possible.
+	* Makefile.devel (srclib/Makefile.in, aclocal.m4, configure,
+	config.h.in): Remove autom4te.cache after invoking aclocal, autoconf,
+	autoheader, automake.
+	* preload/Makefile.devel (aclocal, configure): Likewise.
+
 2017-05-18  Bruno Haible  <bruno@clisp.org>
 
 	* lib/relocatable.h: Update from gnulib.
diff --git a/Makefile.devel b/Makefile.devel
index 2ed8e63..ed9c3a1 100644
--- a/Makefile.devel
+++ b/Makefile.devel
@@ -78,7 +78,7 @@
 	fi
 # Make sure we get new versions of files brought in by automake.
 	(cd build-aux && rm -f ar-lib compile depcomp install-sh mdate-sh missing test-driver)
-	$(AUTOMAKE) --gnits --add-missing --copy srclib/Makefile
+	$(AUTOMAKE) --gnits --add-missing --copy srclib/Makefile && rm -rf autom4te.cache
 
 gnulib-imported-files : force
 	if test -n "$$GNULIB_TOOL"; then \
@@ -93,20 +93,20 @@
 CONFIGURES_IN = configure.ac
 
 aclocal.m4 : $(CONFIGURES_IN) srclib/Makefile.gnulib $(wildcard m4/*.m4) $(wildcard srcm4/*.m4)
-	$(ACLOCAL) -I m4 -I srcm4 --output=$@ && touch $@
+	$(ACLOCAL) -I m4 -I srcm4 --output=$@ && touch $@ && rm -rf autom4te.cache
 
 configures : $(CONFIGURES)
 
 AUTOCONF_FILES = aclocal.m4 $(wildcard m4/*.m4) $(wildcard srcm4/*.m4)
 
 configure : configure.ac $(AUTOCONF_FILES)
-	$(AUTOCONF)
+	$(AUTOCONF) && rm -rf autom4te.cache
 
 check-configures : $(CONFIGURES)
 	set -e; for f in $(CONFIGURES); do bash -x -n $$f; done
 
 config.h.in : configure.ac $(AUTOCONF_FILES)
-	$(AUTOHEADER)
+	$(AUTOHEADER) && rm -rf autom4te.cache
 	touch $@
 
 
diff --git a/libcharset/ChangeLog b/libcharset/ChangeLog
index c29477f..b6736d5 100644
--- a/libcharset/ChangeLog
+++ b/libcharset/ChangeLog
@@ -1,3 +1,9 @@
+2017-07-15  Bruno Haible  <bruno@clisp.org>
+
+	Get rid of autom4te.cache directories, as far as possible.
+	* Makefile.devel (autoconf/aclocal.m4, configure, config.h.in): Remove
+	autom4te.cache after invoking aclocal, autoconf, autoheader.
+
 2016-12-14  Bruno Haible  <bruno@clisp.org>
 
 	Avoid error during initial autogen.sh invocation.
diff --git a/libcharset/Makefile.devel b/libcharset/Makefile.devel
index 25e61e4..50f7bfe 100644
--- a/libcharset/Makefile.devel
+++ b/libcharset/Makefile.devel
@@ -13,15 +13,15 @@
 
 autoconf/aclocal.m4 : $(wildcard m4/*.m4)
 	test -d autoconf || mkdir autoconf
-	$(ACLOCAL) -I m4 --output=$@
+	$(ACLOCAL) -I m4 --output=$@ && rm -rf autom4te.cache
 
 configures : configure config.h.in
 
 configure : configure.ac autoconf/aclocal.m4
-	$(AUTOCONF) --include autoconf
+	$(AUTOCONF) --include autoconf && rm -rf autom4te.cache
 
 config.h.in : configure.ac autoconf/aclocal.m4
-	$(AUTOHEADER) --include autoconf
+	$(AUTOHEADER) --include autoconf && rm -rf autom4te.cache
 	touch config.h.in
 
 include/localcharset.h.build.in : include/localcharset.h.in include/export.h
diff --git a/preload/Makefile.devel b/preload/Makefile.devel
index 30b8fda..e3f0bd8 100644
--- a/preload/Makefile.devel
+++ b/preload/Makefile.devel
@@ -11,12 +11,12 @@
 all : configures
 
 aclocal.m4 : $(wildcard ../m4/*.m4)
-	$(ACLOCAL) -I ../m4 -I ../srcm4 --output=$@
+	$(ACLOCAL) -I ../m4 -I ../srcm4 --output=$@ && rm -rf autom4te.cache
 
 configures : configure
 
 configure : configure.ac aclocal.m4
-	$(AUTOCONF)
+	$(AUTOCONF) && rm -rf autom4te.cache
 
 totally-clean : all
 	rm -f aclocal.m4 configure