Fix an autogen.sh failure (regression from 2016-12-04).
diff --git a/ChangeLog b/ChangeLog
index 1d96da6..8d93447 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2020-04-05  Bruno Haible  <bruno@clisp.org>
+
+	Fix an autogen.sh failure (regression from 2016-12-04).
+	Reported by Petr Ovtchenkov <ptr@void-ptr.info> in
+	<https://lists.gnu.org/archive/html/bug-gnu-libiconv/2020-04/msg00003.html>.
+	* autogen.sh: Invoke also the Makefile target srclib/Makefile.in, so as
+	to get build-aux/install-sh. Finish the "copy files" phase before recursing
+	through the subpackages tree through Makefile.devel.
+	* Makefile.devel: Reorder targets.
+
 2020-04-04  Bruno Haible  <bruno@clisp.org>
 
 	Don't use LGPLv3.
diff --git a/Makefile.devel b/Makefile.devel
index dfdcbdd..4183025 100644
--- a/Makefile.devel
+++ b/Makefile.devel
@@ -72,14 +72,6 @@
 	    --import $(GNULIB_MODULES); \
 	fi
 
-srclib/Makefile.in : srclib/Makefile.am srclib/Makefile.gnulib aclocal.m4
-	if test -n "$$GNULIB_TOOL"; then \
-	  $$GNULIB_TOOL --copy-file build-aux/compile; \
-	fi
-# Make sure we get new versions of files brought in by automake.
-	(cd build-aux && rm -f compile depcomp install-sh mdate-sh missing test-driver)
-	$(AUTOMAKE) --gnits --add-missing --copy srclib/Makefile && rm -rf autom4te.cache
-
 gnulib-imported-files : force
 	if test -n "$$GNULIB_TOOL"; then \
 	  for file in config.guess config.sub; do \
@@ -88,6 +80,14 @@
 	  done; \
 	fi
 
+srclib/Makefile.in : srclib/Makefile.am srclib/Makefile.gnulib aclocal.m4
+	if test -n "$$GNULIB_TOOL"; then \
+	  $$GNULIB_TOOL --copy-file build-aux/compile; \
+	fi
+# Make sure we get new versions of files brought in by automake.
+	(cd build-aux && rm -f compile depcomp install-sh mdate-sh missing test-driver)
+	$(AUTOMAKE) --gnits --add-missing --copy srclib/Makefile && rm -rf autom4te.cache
+
 
 CONFIGURES = configure
 CONFIGURES_IN = configure.ac
diff --git a/autogen.sh b/autogen.sh
index e9a8a50..03f7fc3 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -11,7 +11,7 @@
 # It also requires
 #   - the gperf program.
 
-# Copyright (C) 2003-2012, 2016, 2018-2019 Free Software Foundation, Inc.
+# Copyright (C) 2003-2012, 2016, 2018-2020 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
@@ -36,6 +36,8 @@
   esac
 done
 
+# ========== Copy files from gnulib, automake, or the internet. ==========
+
 if test $skip_gnulib = false; then
   if test -n "$GNULIB_SRCDIR"; then
     test -d "$GNULIB_SRCDIR" || {
@@ -58,12 +60,10 @@
   $GNULIB_TOOL --copy-file build-aux/ar-lib || exit $?
   chmod a+x build-aux/ar-lib || exit $?
   make -f Makefile.devel \
-       gnulib-clean srclib/Makefile.gnulib gnulib-imported-files \
+       gnulib-clean srclib/Makefile.gnulib gnulib-imported-files srclib/Makefile.in \
        GNULIB_TOOL="$GNULIB_TOOL"
 fi
 
-make -f Makefile.devel totally-clean all || exit $?
-
 # Copy files into the libcharset subpackage, so that libcharset/autogen.sh
 # does not need to invoke gnulib-tool nor automake.
 for file in INSTALL.generic; do
@@ -76,6 +76,10 @@
   cp -p srcm4/$file libcharset/m4/$file || exit $?
 done
 
+# ========== Generate files. ==========
+
+make -f Makefile.devel totally-clean all || exit $?
+
 (cd libcharset
  ./autogen.sh || exit $?
 )