Subject: [PATCH 2/2] gnu: Put autoconf-related phases immediately after the 'unpack phase.

From: Kei Kebreau <[email-masked]>
Date: Tue, 1 Aug 2017 03:21:53 -0400

* gnu/packages/audio.scm (audacity, rtmidi)[arguments]: Correct phases
accordingly.
* gnu/packages/bioinformatics.scm (mash, seek, vsearch, emboss,
htslib-for-sambamba)[arguments]: Likewise.
* gnu/packages/ci.scm (cuirass)[arguments]: Likewise.
* gnu/packages/compression.scm (minizip, xdelta)[arguments]: Likewise.
* gnu/packages/cpp.scm (libzen)[arguments]: Likewise.
* gnu/packages/crypto.scm (opendht)[arguments]: Likewise.
* gnu/packages/databases.scm (4store, mdbtools)[arguments]: Likewise.
* gnu/packages/debug.scm (stress-make)[arguments]: Likewise.
* gnu/packages/dns.scm (dnscrypt-proxy, dnscrypt-wrapper)[arguments]:
Likewise.
* gnu/packages/emacs.scm (emacs-pdf-tools)[arguments]: Likewise.
* gnu/packages/embedded.scm (libjaylink, openocd)[arguments]: Likewise.
* gnu/packages/engineering.scm (gerbv)[arguments]: Likewise.
* gnu/packages/erlang.scm (erlang)[arguments]: Likewise.
* gnu/packages/ftp.scm (weex)[arguments]: Likewise.
* gnu/packages/gnome.scm (dia)[arguments]: Likewise.
* gnu/packages/gnunet.scm (gnurl, guile-gnunet)[arguments]: Likewise.
* gnu/packages/gtk.scm (guile-rsvg, graphene)[arguments]: Likewise.
* gnu/packages/guile.scm (guildhall, guile-ics, guile-sqlite3)[arguments]:
Likewise.
* gnu/packages/ibus.scm (ibus-libpinyin)[arguments]: Likewise.
* gnu/packages/irc.scm (weechat)[arguments]: Likewise.
* gnu/packages/java.scm (classpath-devel)[arguments]: Likewise.
* gnu/packages/libreoffice.scm (libetonyek)[arguments]: Likewise.
* gnu/packages/libusb.scm (hidapi)[arguments]: Likewise.
* gnu/packages/linux.scm (gpm)[arguments]: Likewise.
* gnu/packages/logging.scm (glog)[arguments]: Likewise.
* gnu/packages/machine-learning.scm (ghmm)[arguments]: Likewise.
* gnu/packages/mail.scm (dovecot-trees, dovecot-libsodium-plugin, esmtp)
[arguments]: Likewise.
* gnu/packages/maths.scm (wxmaxima)[arguments]: Likewise.
* gnu/packages/messaging.scm (freetalk, libmesode, libstrophe)[arguments]:
Likewise.
* gnu/packages/microcom.scm (microcom)[arguments]: Likewise.
* gnu/packages/ocaml.scm (ocaml-ssl)[arguments]: Likewise.
* gnu/packages/parallel.scm (slurm)[arguments]: Likewise.
* gnu/packages/pdf.scm (libharu)[arguments]: Likewise.
* gnu/packages/samba.scm (cifs-utils)[arguments]: Likewise.
* gnu/packages/serialization.scm (msgpack)[arguments]: Likewise.
* gnu/packages/shells.scm (scsh)[arguments]: Likewise.
* gnu/packages/telephony.scm (libiax2)[arguments]: Likewise.
* gnu/packages/textutils.scm (dotconf)[arguments]: Likewise.
* gnu/packages/version-control.scm (findnewest)[arguments]: Likewise.
* gnu/packages/video.scm (vlc, libmediainfo, mediainfo)[arguments]: Likewise.
---
 gnu/packages/audio.scm            |  6 ++---
 gnu/packages/bioinformatics.scm   | 20 +++++++++-------
 gnu/packages/ci.scm               |  7 ++++--
 gnu/packages/compression.scm      |  4 ++--
 gnu/packages/cpp.scm              |  8 +++----
 gnu/packages/crypto.scm           |  2 +-
 gnu/packages/databases.scm        |  6 ++---
 gnu/packages/debug.scm            |  2 +-
 gnu/packages/dns.scm              |  4 ++--
 gnu/packages/emacs.scm            |  2 +-
 gnu/packages/embedded.scm         |  4 ++--
 gnu/packages/engineering.scm      |  2 +-
 gnu/packages/erlang.scm           |  8 +++++--
 gnu/packages/ftp.scm              |  2 +-
 gnu/packages/gnome.scm            |  2 +-
 gnu/packages/gnunet.scm           |  6 ++---
 gnu/packages/gtk.scm              |  6 ++---
 gnu/packages/guile.scm            | 16 ++++++-------
 gnu/packages/ibus.scm             |  4 ++--
 gnu/packages/irc.scm              |  6 +++--
 gnu/packages/java.scm             |  2 +-
 gnu/packages/libreoffice.scm      |  4 ++--
 gnu/packages/libusb.scm           |  2 +-
 gnu/packages/linux.scm            |  4 ++--
 gnu/packages/logging.scm          |  2 +-
 gnu/packages/machine-learning.scm |  8 +++----
 gnu/packages/mail.scm             | 12 +++++-----
 gnu/packages/maths.scm            | 49 +++++++++++++++++++--------------------
 gnu/packages/messaging.scm        | 10 ++++----
 gnu/packages/microcom.scm         |  2 +-
 gnu/packages/ocaml.scm            |  4 ++--
 gnu/packages/parallel.scm         |  4 ++--
 gnu/packages/pdf.scm              |  2 +-
 gnu/packages/samba.scm            |  2 +-
 gnu/packages/serialization.scm    |  2 +-
 gnu/packages/shells.scm           |  2 +-
 gnu/packages/telephony.scm        |  2 +-
 gnu/packages/textutils.scm        |  2 +-
 gnu/packages/version-control.scm  |  2 +-
 gnu/packages/video.scm            | 18 ++++++--------
 40 files changed, 128 insertions(+), 124 deletions(-)

diff --git a/gnu/packages/audio.scm b/gnu/packages/audio.scm
index e756fbf7c..08095e16d 100644
--- a/gnu/packages/audio.scm
+++ b/gnu/packages/audio.scm
@@ -328,7 +328,7 @@ engineers, musicians, soundtrack editors and composers.")
        #:phases
        (modify-phases %standard-phases
          ;; FFmpeg is only detected if autoreconf runs.
-         (add-before 'configure 'autoreconf
+         (add-after 'unpack 'autoreconf
            (lambda _
              (zero? (system* "autoreconf" "-vfi")))))
        ;; The test suite is not "well exercised" according to the developers,
@@ -1975,8 +1975,8 @@ tempo and pitch of an audio recording independently of one another.")
     (arguments
      `(#:tests? #f ;no "check" target
        #:phases (modify-phases %standard-phases
-                  (add-before
-                   'configure 'autoconf
+                  (add-after
+                   'unpack 'autoconf
                    (lambda _ (zero? (system* "autoreconf" "-vfi"))))
                   (add-before
                    'build 'fix-makefile
diff --git a/gnu/packages/bioinformatics.scm b/gnu/packages/bioinformatics.scm
index 02250dfaf..d205e296f 100644
--- a/gnu/packages/bioinformatics.scm
+++ b/gnu/packages/bioinformatics.scm
@@ -3444,7 +3444,7 @@ sequences).")
                (("^#include \"kseq\\.h\"")
                 "#include \"htslib/kseq.h\""))
              #t))
-         (add-before 'configure 'autoconf
+         (add-after 'unpack 'autoconf
            (lambda _ (zero? (system* "autoconf")))))))
     (native-inputs
      `(("autoconf" ,autoconf)
@@ -4479,9 +4479,11 @@ distribution, coverage uniformity, strand specificity, etc.")
                        "Data2DB"
                        "PCL2Bin")))
            (modify-phases %standard-phases
-             (add-before 'configure 'bootstrap
+             (add-after 'unpack 'bootstrap
                (lambda _
-                 (zero? (system* "bash" "gen_auto"))))
+                 (substitute* "gen_tools_am"
+                   (("/usr/bin/env perl") (which "perl")))
+                 (zero? (system* "sh" "gen_auto"))))
              (add-after 'build 'build-additional-tools
                (lambda* (#:key make-flags #:allow-other-keys)
                  (every (lambda (dir)
@@ -6095,8 +6097,8 @@ track.  The database is exposed as a @code{TxDb} object.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'autogen
-                     (lambda _ (zero? (system* "autoreconf" "-vif")))))))
+         (add-after 'unpack 'autogen
+           (lambda _ (zero? (system* "autoreconf" "-vif")))))))
     (inputs
      `(("zlib" ,zlib)
        ("bzip2" ,bzip2)
@@ -8274,6 +8276,8 @@ the available RAM.")
                             (assoc-ref %build-inputs "libharu")))
        #:phases
        (modify-phases %standard-phases
+         (add-after 'unpack 'autogen
+           (lambda _ (zero? (system* "autoreconf" "-vif"))))
          (add-after 'unpack 'fix-checks
            (lambda _
              ;; The PNGDRIVER tests check for the presence of libgd, libpng
@@ -8291,9 +8295,7 @@ AM_CONDITIONAL(AMPNG, true)"))
              ;; looking for updates will not work.
              (substitute* "Makefile.am"
                (("\\$\\(bindir\\)/embossupdate") ""))
-             #t))
-         (add-before 'configure 'autogen
-           (lambda _ (zero? (system* "autoreconf" "-vif")))))))
+             #t)))))
     (inputs
      `(("perl" ,perl)
        ("libpng" ,libpng)
@@ -9191,7 +9193,7 @@ global-scaling and full-quantile normalization.")
        (substitute-keyword-arguments (package-arguments htslib)
          ((#:phases phases)
           `(modify-phases  ,phases
-             (add-before 'configure 'bootstrap
+             (add-after 'unpack 'bootstrap
                (lambda _
                  (zero? (system* "autoreconf" "-vif"))))))))
       (native-inputs
diff --git a/gnu/packages/ci.scm b/gnu/packages/ci.scm
index e2cb712bf..32e7e6e16 100644
--- a/gnu/packages/ci.scm
+++ b/gnu/packages/ci.scm
@@ -215,8 +215,11 @@ their dependencies.")
                (substitute* "Makefile.am"
                  (("tests/repo.scm \\\\") "\\"))
                #t))
-           (add-before 'configure 'bootstrap
-             (lambda _ (zero? (system* "sh" "bootstrap"))))
+           (add-after 'disable-repo-tests 'bootstrap
+             (lambda _
+               (substitute* "build-aux/git-version-gen"
+                 (("/bin/sh") (which "sh")))
+               (zero? (system* "sh" "bootstrap"))))
            (add-after 'install 'wrap-program
              (lambda* (#:key inputs outputs #:allow-other-keys)
                ;; Wrap the 'cuirass' command to refer to the right modules.
diff --git a/gnu/packages/compression.scm b/gnu/packages/compression.scm
index 2a9ccd167..a28a31572 100644
--- a/gnu/packages/compression.scm
+++ b/gnu/packages/compression.scm
@@ -114,7 +114,7 @@ in compression.")
        (modify-phases %standard-phases
          (add-after 'unpack 'enter-source
            (lambda _ (chdir "contrib/minizip") #t))
-         (add-before 'configure 'autoreconf
+         (add-after 'enter-source 'autoreconf
            (lambda _
              (zero? (system* "autoreconf" "-vif")))))))
     (native-inputs
@@ -960,7 +960,7 @@ respectively, based on the reference implementation from Google.")
        (modify-phases %standard-phases
          (add-after 'unpack 'enter-build-directory
            (lambda _ (chdir "xdelta3")))
-         (add-before 'configure 'autoconf
+         (add-after 'enter-build-directory 'autoconf
            (lambda _ (zero? (system* "autoreconf" "-vfi")))))))
     (home-page "http://xdelta.com")
     (synopsis "Delta encoder for binary files")
diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index da192553a..a1289ec21 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -45,12 +45,10 @@
      '(#:phases
        ;; build scripts not in root of archive
        (modify-phases %standard-phases
-         (add-before 'configure 'pre-configure
+         (add-after 'unpack 'autogen
            (lambda _
-             (chdir "Project/GNU/Library")))
-         (add-before 'configure 'autogen
-           (lambda _
-             (zero? (system* "./autogen.sh")))))))
+             (chdir "Project/GNU/Library")
+             (zero? (system* "sh" "autogen.sh")))))))
     (home-page "https://github.com/MediaArea/ZenLib")
     (synopsis "C++ utility library")
     (description "ZenLib is a C++ utility library.  It includes classes for handling
diff --git a/gnu/packages/crypto.scm b/gnu/packages/crypto.scm
index d02bc20f2..fa8ecf831 100644
--- a/gnu/packages/crypto.scm
+++ b/gnu/packages/crypto.scm
@@ -160,7 +160,7 @@ OpenBSD tool of the same name.")
     (arguments
      `(#:configure-flags '("--disable-tools" "--disable-python")
        #:phases (modify-phases %standard-phases
-                  (add-before 'configure 'autoconf
+                  (add-after 'unpack 'autoconf
                     (lambda _
                       (zero? (system* "autoreconf" "-vfi")))))))
     (home-page "https://github.com/savoirfairelinux/opendht/")
diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index 655c6db18..4d231a045 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -114,9 +114,9 @@
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'generate-configure
+         (add-after 'unpack 'autogen
            (lambda _
-             (zero? (system* "./autogen.sh")))))))
+             (zero? (system* "sh" "autogen.sh")))))))
     ;; http://www.4store.org has been down for a while now.
     (home-page "https://github.com/garlik/4store")
     (synopsis "Clustered RDF storage and query engine")
@@ -1559,7 +1559,7 @@ for ODBC.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'autoreconf
+         (add-after 'unpack 'autoreconf
            (lambda _
              (zero? (system* "autoreconf" "-vfi")))))))
     (home-page "http://mdbtools.sourceforge.net/")
diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
index 1dab0085c..017e81656 100644
--- a/gnu/packages/debug.scm
+++ b/gnu/packages/debug.scm
@@ -300,7 +300,7 @@ down the road.")
                (zero? (system* "tar" "cJf" "./make.tar.xz"
                                (string-append "make-"
                                               ,(package-version gnu-make))))))
-           (add-before 'configure 'bootstrap
+           (add-after 'unpack 'bootstrap
              (lambda _
                (zero? (system* "autoreconf" "-vfi")))))))
       (home-page "https://github.com/losalamos/stress-make")
diff --git a/gnu/packages/dns.scm b/gnu/packages/dns.scm
index 64fdc9c3e..ce2f4d81b 100644
--- a/gnu/packages/dns.scm
+++ b/gnu/packages/dns.scm
@@ -181,7 +181,7 @@ high-volume and high-reliability applications. The name BIND stands for
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'autoreconf
+         (add-after 'unpack 'autoreconf
            (lambda _
              ;; Re-generate build files due to unbundling ltdl.
              ;; TODO: Prevent generating new libltdl and building it.
@@ -229,7 +229,7 @@ servers is included, and an up-to-date version is available at
        #:tests? #f
        #:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'create-configure
+         (add-after 'unpack 'create-configure
            (lambda _
              (zero? (system* "make" "configure")))))))
     (native-inputs
diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index b77abc778..11eebc063 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -1274,7 +1274,7 @@ single buffer.")
          ;; Build server side using 'gnu-build-system'.
          (add-after 'unpack 'enter-server-dir
            (lambda _ (chdir "server") #t))
-         (add-before 'configure 'autogen
+         (add-after 'enter-server-dir 'autogen
            (lambda _
              (zero? (system* "bash" "autogen.sh"))))
 
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index e509647ea..d3bd99274 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -316,7 +316,7 @@ languages are C and C++.")
       (arguments
        `(#:phases
          (modify-phases %standard-phases
-           (add-before 'configure 'autoreconf
+           (add-after 'unpack 'autoreconf
              (lambda _
                (zero? (system* "autoreconf" "-vfi")))))))
       (home-page "http://repo.or.cz/w/libjaylink.git")
@@ -400,7 +400,7 @@ language.")
                         "presto" "openjtag")))
          #:phases
          (modify-phases %standard-phases
-           (add-before 'configure 'autoreconf
+           (add-after 'unpack 'autoreconf
              (lambda _
                (zero? (system* "autoreconf" "-vfi")))))))
       (home-page "http://openocd.org")
diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index 28d9a718e..1d133b966 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -483,7 +483,7 @@ ready for production.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'autoconf
+         (add-after 'unpack 'autoconf
           (lambda _
             ;; Build rules contain references to Russian translation, but the
             ;; needed files are missing; see
diff --git a/gnu/packages/erlang.scm b/gnu/packages/erlang.scm
index a400e712d..519100849 100644
--- a/gnu/packages/erlang.scm
+++ b/gnu/packages/erlang.scm
@@ -124,6 +124,12 @@
                  (("\\{H,Mi,S\\} = time\\(\\),")
                   (date->string source-date-epoch
                                 "{H,Mi,S} = {~H,~M,~S},"))))))
+         (add-after 'unpack 'autoconf
+           (lambda _
+             (substitute* '("erts/autoconf/config.guess"
+                            "erts/autoconf/install-sh")
+               (("/bin/sh") (which "sh")))
+             (zero? (system* "sh" "otp_build" "autoconf"))))
          (add-after 'patch-source-shebangs 'patch-source-env
            (lambda _
              (let ((escripts
@@ -143,8 +149,6 @@
          (add-before 'configure 'set-erl-top
            (lambda _
              (setenv "ERL_TOP" (getcwd))))
-         (add-before 'configure 'autoconf
-           (lambda _ (zero? (system* "./otp_build" "autoconf"))))
          (add-after 'install 'patch-erl
            ;; This only works after install.
            (lambda _
diff --git a/gnu/packages/ftp.scm b/gnu/packages/ftp.scm
index 49e721499..5563b6473 100644
--- a/gnu/packages/ftp.scm
+++ b/gnu/packages/ftp.scm
@@ -159,7 +159,7 @@ FTP browser, as well as non-interactive commands such as 'ncftpput' and
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'bootstrap
+         (add-after 'unpack 'bootstrap
            (lambda _ (zero? (system* "autoreconf" "-vfi")))))))
     (home-page "http://weex.sourceforge.net/")
     (synopsis "Non-interactive client for FTP synchronization")
diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index f40381498..7f5fadb79 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -310,7 +310,7 @@ either on a local, or remote machine via a number of methods.")
       (arguments
        `(#:phases
          (modify-phases %standard-phases
-           (add-before 'configure 'run-autogen
+           (add-after 'unpack 'run-autogen
              (lambda _
                (system* "sh" "autogen.sh"))))))
       (home-page "https://wiki.gnome.org/Apps/Dia")
diff --git a/gnu/packages/gnunet.scm b/gnu/packages/gnunet.scm
index 9ca2d9502..6902461e4 100644
--- a/gnu/packages/gnunet.scm
+++ b/gnu/packages/gnunet.scm
@@ -234,10 +234,10 @@ and support for SSL3 and TLS.")
               (rename-file (string-append out "/share/man/man3")
                            (string-append doc "/share/man/man3"))
               #t)))
-        (add-before 'configure 'autoconf
+        (add-after 'unpack 'autoconf
           ;; Clear artifacts left (shebangs) from release preparation.
           (lambda _
-            (zero? (system* "./buildconf"))))
+            (zero? (system* "sh" "buildconf"))))
         (replace 'check
           (lambda _
             ;; It is unclear why test1026 fails, however the content of it
@@ -345,7 +345,7 @@ kinds of basic applications for the foundation of a GNU internet.")
       (build-system gnu-build-system)
       (arguments
        '(#:phases (modify-phases %standard-phases
-                    (add-before 'configure 'bootstrap
+                    (add-after 'unpack 'bootstrap
                       (lambda _
                         (zero? (system* "autoreconf" "-vfi")))))))
       (native-inputs `(("pkg-config" ,pkg-config)
diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm
index 11e2ace98..12319ac76 100644
--- a/gnu/packages/gtk.scm
+++ b/gnu/packages/gtk.scm
@@ -839,7 +839,7 @@ exceptions, macros, and a dynamic programming environment.")
       (build-system gnu-build-system)
       (arguments
        `(#:phases (modify-phases %standard-phases
-                    (add-before 'configure 'bootstrap
+                    (add-after 'unpack 'bootstrap
                       (lambda _
                         (zero? (system* "autoreconf" "-vfi")))))))
       (native-inputs `(("pkg-config" ,pkg-config)
@@ -1464,9 +1464,9 @@ Parcellite and adds bugfixes and features.")
      `(#:configure-flags '("--enable-introspection=yes")
        #:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'autogen
+         (add-after 'unpack 'autogen
            (lambda _
-             (zero? (system* "./autogen.sh")))))))
+             (zero? (system* "sh" "autogen.sh")))))))
     (native-inputs
      `(("autoconf" ,autoconf)
        ("which" ,which)
diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
index f377d83b1..85482b865 100644
--- a/gnu/packages/guile.scm
+++ b/gnu/packages/guile.scm
@@ -353,7 +353,7 @@ AM_SCM_LOG_FLAGS =  --no-auto-compile -s")
                  ;; reasons.  It does not fail when run outside of Guix.
                  (("tests/database.scm") ""))
                #t))
-           (add-before 'configure 'autogen
+           (add-after 'fix-bug-22 'autogen
              (lambda _
                (zero? (system* "sh" "autogen.sh")))))))
       (inputs
@@ -616,12 +616,12 @@ format is also supported.")
     (build-system gnu-build-system)
     (arguments
      '(#:phases (modify-phases %standard-phases
-                  (add-before 'configure 'autoreconf
-                              (lambda _
-                                ;; Repository comes with a broken symlink
-                                (delete-file "README")
-                                (symlink "README.org" "README")
-                                (zero? (system* "autoreconf" "-fi")))))))
+                  (add-after 'unpack 'autoreconf
+                    (lambda _
+                      ;; Repository comes with a broken symlink
+                      (delete-file "README")
+                      (symlink "README.org" "README")
+                      (zero? (system* "autoreconf" "-fi")))))))
     (native-inputs
      `(("autoconf" ,(autoconf-wrapper))
        ("automake" ,automake)
@@ -1088,7 +1088,7 @@ Guile's foreign function interface.")
          ("sqlite" ,sqlite)))
       (arguments
        '(#:phases (modify-phases %standard-phases
-                    (add-before 'configure 'autoreconf
+                    (add-after 'unpack 'autoreconf
                       (lambda _
                         (zero? (system* "autoreconf" "-vfi"))))
                     (add-before 'build 'set-sqlite3-file-name
diff --git a/gnu/packages/ibus.scm b/gnu/packages/ibus.scm
index 2200b6663..4c0d6e219 100644
--- a/gnu/packages/ibus.scm
+++ b/gnu/packages/ibus.scm
@@ -148,7 +148,7 @@ may also simplify input method development.")
    (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'autogen
+         (add-after 'unpack 'autogen
           (lambda _ (and (zero? (system* "intltoolize"))
                          (zero? (system* "autoreconf" "-vif")))))
          (add-after 'wrap-program 'wrap-with-additional-paths
@@ -204,7 +204,7 @@ ZhuYin (Bopomofo) input method based on libpinyin for IBus.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'autogen
+         (add-after 'unpack 'autogen
            (lambda _ (zero? (system* "autoreconf" "-vif"))))
          (add-after 'unpack 'unpack-model
            (lambda* (#:key inputs #:allow-other-keys)
diff --git a/gnu/packages/irc.scm b/gnu/packages/irc.scm
index 1d6ac82e5..b38336c46 100644
--- a/gnu/packages/irc.scm
+++ b/gnu/packages/irc.scm
@@ -180,9 +180,11 @@ SILC and ICB protocols via plugins.")
                                 "--with-tclconfig="
                                 (assoc-ref %build-inputs "tcl") "/lib"))
        #:phases (modify-phases %standard-phases
-                  (add-before 'configure 'autogen
+                  (add-after 'unpack 'autogen
                     (lambda _
-                      (zero? (system* "./autogen.sh"))))
+                      (substitute* "version.sh"
+                        (("/bin/sh") (which "sh")))
+                      (zero? (system* "sh" "autogen.sh"))))
                   (add-after 'install 'wrap
                     (lambda* (#:key inputs outputs #:allow-other-keys)
                       (let ((out (assoc-ref outputs "out"))
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 5744db6eb..a4200e4de 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -684,7 +684,7 @@ the standard javac executable.  The tool runs on JamVM instead of SableVM.")))
                "--disable-gjdoc")
          #:phases
          (modify-phases %standard-phases
-           (add-before 'configure 'bootstrap
+           (add-after 'unpack 'bootstrap
              (lambda _
                (zero? (system* "autoreconf" "-vif"))))
            (add-after 'unpack 'remove-unsupported-annotations
diff --git a/gnu/packages/libreoffice.scm b/gnu/packages/libreoffice.scm
index f7775ff4a..000396100 100644
--- a/gnu/packages/libreoffice.scm
+++ b/gnu/packages/libreoffice.scm
@@ -362,8 +362,8 @@ CorelDRAW documents of all versions.")
     (arguments
      `(#:configure-flags '("--with-mdds=1.2")
        #:phases (modify-phases %standard-phases
-                  (add-before 'configure 'autoreconf
-                              (lambda _ (system* "autoreconf"))))))
+                  (add-after 'unpack 'autoreconf
+                    (lambda _ (system* "autoreconf"))))))
     (native-inputs
      `(("cppunit" ,cppunit)
        ("doxygen" ,doxygen)
diff --git a/gnu/packages/libusb.scm b/gnu/packages/libusb.scm
index ed97ed9de..f1d75220a 100644
--- a/gnu/packages/libusb.scm
+++ b/gnu/packages/libusb.scm
@@ -332,7 +332,7 @@ devices.")
     (arguments
      '(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'bootstrap
+         (add-after 'unpack 'bootstrap
            (lambda _
              (zero? (system* "autoreconf" "-vfi")))))))
     (inputs
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 7f44ea789..4fff74c34 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -3066,11 +3066,11 @@ write access to exFAT devices.")
     (build-system gnu-build-system)
     (arguments
      '(#:phases (modify-phases %standard-phases
-                  (add-before 'configure 'bootstrap
+                  (add-after 'unpack 'bootstrap
                     (lambda _
                       ;; The tarball was not generated with 'make dist' so we
                       ;; need to bootstrap things ourselves.
-                      (and (zero? (system* "./autogen.sh"))
+                      (and (zero? (system* "sh" "autogen.sh"))
                            (begin
                              (patch-makefile-SHELL "Makefile.include.in")
                              #t)))))
diff --git a/gnu/packages/logging.scm b/gnu/packages/logging.scm
index eecfe4558..deaaffd31 100644
--- a/gnu/packages/logging.scm
+++ b/gnu/packages/logging.scm
@@ -75,7 +75,7 @@ staying as close to their API as is reasonable.")
        ("libtool" ,libtool)))
     (arguments
      '(#:phases (modify-phases %standard-phases
-                  (add-before 'configure 'add-automake-files
+                  (add-after 'unpack 'add-automake-files
                     (lambda _
                       ;; The 'test-driver' file is a dangling symlink to
                       ;; /usr/share/automake; replace it.  We can't just run
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 91fab8ccf..134303362 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -142,6 +142,9 @@ classification.")
          (modify-phases %standard-phases
            (add-after 'unpack 'enter-dir
              (lambda _ (chdir "ghmm") #t))
+           (add-after 'enter-dir 'autogen
+             (lambda _
+               (zero? (system* "bash" "./autogen.sh"))))
            (delete 'check)
            (add-after 'install 'check
              (assoc-ref %standard-phases 'check))
@@ -188,10 +191,7 @@ classification.")
                   (string-append indent
                                  "@unittest.skip(\"Disabled by Guix\")\n"
                                  line)))
-               #t))
-           (add-before 'configure 'autogen
-             (lambda _
-               (zero? (system* "bash" "./autogen.sh")))))))
+               #t)))))
       (inputs
        `(("python" ,python-2) ; only Python 2 is supported
          ("libxml2" ,libxml2)))
diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index af8690dda..c1350cc99 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -1169,9 +1169,9 @@ It supports mbox/Maildir and its own dbox/mdbox formats.")
                                               "/lib/dovecot"))
        #:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'autogen
+         (add-after 'unpack 'autogen
            (lambda _
-             (zero? (system* "./autogen.sh")))))))
+             (zero? (system* "sh" "autogen.sh")))))))
     (home-page "https://0xacab.org/riseuplabs/trees")
     (synopsis "NaCL-based Dovecot email storage encryption plugin")
     (description
@@ -1225,9 +1225,9 @@ using lidsodium sealed boxes.
                                                 "/lib/dovecot"))
          #:phases
          (modify-phases %standard-phases
-           (add-before 'configure 'autogen
+           (add-after 'unpack 'autogen
              (lambda _
-               (zero? (system* "./autogen.sh")))))))
+               (zero? (system* "sh" "autogen.sh")))))))
       (home-page "https://github.com/LuckyFellow/dovecot-libsodium-plugin")
       (synopsis "Libsodium password hashing schemes plugin for Dovecot")
       (description
@@ -1506,8 +1506,8 @@ program's primary purpose.")
        (file-name (string-append name "-" version "-checkout"))))
     (arguments
      `(#:phases (modify-phases %standard-phases
-                  (add-before
-                   'configure 'autoconf
+                  (add-after
+                   'unpack 'autoconf
                    (lambda _ (zero? (system* "autoreconf" "-vfi")))))))
     (build-system gnu-build-system)
     (native-inputs
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 31ed4a49d..8655dd7c8 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -2174,31 +2174,30 @@ point numbers.")
        ("gtk+" ,gtk+)
        ("shared-mime-info" ,shared-mime-info)))
     (arguments
-     `(#:phases (modify-phases %standard-phases
-                  (add-before
-                   'configure 'autoconf
-                   (lambda _
-                     (zero? (system* "./bootstrap"))))
-                  (add-after
-                   'install 'wrap-program
-                   (lambda* (#:key inputs outputs #:allow-other-keys)
-                     (wrap-program (string-append (assoc-ref outputs "out")
-                                                  "/bin/wxmaxima")
-                       `("PATH" ":" prefix
-                         (,(string-append (assoc-ref inputs "maxima")
-                                          "/bin")))
-                       ;; For GtkFileChooserDialog.
-                       `("GSETTINGS_SCHEMA_DIR" =
-                         (,(string-append (assoc-ref inputs "gtk+")
-                                          "/share/glib-2.0/schemas")))
-                       `("XDG_DATA_DIRS" ":" prefix
-                         (;; Needed by gdk-pixbuf to know supported icon formats.
-                          ,(string-append
-                            (assoc-ref inputs "shared-mime-info") "/share")
-                          ;; The default icon theme of GTK+.
-                          ,(string-append
-                            (assoc-ref inputs "adwaita-icon-theme") "/share"))))
-                     #t)))))
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'autoconf
+           (lambda _
+             (zero? (system* "sh" "bootstrap"))))
+         (add-after 'install 'wrap-program
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (wrap-program (string-append (assoc-ref outputs "out")
+                                          "/bin/wxmaxima")
+               `("PATH" ":" prefix
+                 (,(string-append (assoc-ref inputs "maxima")
+                                  "/bin")))
+               ;; For GtkFileChooserDialog.
+               `("GSETTINGS_SCHEMA_DIR" =
+                 (,(string-append (assoc-ref inputs "gtk+")
+                                  "/share/glib-2.0/schemas")))
+               `("XDG_DATA_DIRS" ":" prefix
+                 (;; Needed by gdk-pixbuf to know supported icon formats.
+                  ,(string-append
+                    (assoc-ref inputs "shared-mime-info") "/share")
+                  ;; The default icon theme of GTK+.
+                  ,(string-append
+                    (assoc-ref inputs "adwaita-icon-theme") "/share"))))
+             #t)))))
     (home-page "https://andrejv.github.io/wxmaxima/")
     (synopsis "Graphical user interface for the Maxima computer algebra system")
     (description
diff --git a/gnu/packages/messaging.scm b/gnu/packages/messaging.scm
index adb7b938f..23eedac71 100644
--- a/gnu/packages/messaging.scm
+++ b/gnu/packages/messaging.scm
@@ -1208,7 +1208,7 @@ support, and more.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'autogen
+         (add-after 'unpack 'autogen
            (lambda _
              (zero? (system* "sh" "autogen.sh"))))
          ;; For 'system' commands in Scheme code.
@@ -1261,9 +1261,9 @@ is also scriptable and extensible via Guile.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'bootstrap
+         (add-after 'unpack 'bootstrap
            (lambda _
-             (zero? (system* "./bootstrap.sh")))))))
+             (zero? (system* "sh" "bootstrap.sh")))))))
     (inputs
      `(("expat" ,expat)
        ("openssl" ,openssl)))
@@ -1296,9 +1296,9 @@ manual SSL certificate verification.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'bootstrap
+         (add-after 'unpack 'bootstrap
            (lambda _
-             (zero? (system* "./bootstrap.sh")))))))
+             (zero? (system* "sh" "bootstrap.sh")))))))
     (inputs
      `(("expat" ,expat)
        ("openssl" ,openssl)))
diff --git a/gnu/packages/microcom.scm b/gnu/packages/microcom.scm
index cfa2518f1..afadbecf1 100644
--- a/gnu/packages/microcom.scm
+++ b/gnu/packages/microcom.scm
@@ -42,7 +42,7 @@
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'bootstrap
+         (add-after 'unpack 'bootstrap
            (lambda _
              (zero? (system* "autoreconf" "-i")))))))
     (inputs `(("readline" ,readline)))
diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 43bbdcd6e..ecf113925 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -1591,9 +1591,9 @@ lets the client choose the concrete timeline.")
                  #:make-flags (list "OCAMLFIND_LDCONF=ignore")
                  #:phases
                  (modify-phases %standard-phases
-                   (add-before 'configure 'bootstrap
+                   (add-after 'unpack 'bootstrap
                      (lambda* (#:key #:allow-other-keys)
-                       (system* "./bootstrap")
+                       (system* "sh" "bootstrap")
                        (substitute* "src/OCamlMakefile"
                          (("/bin/sh") (which "bash")))
                        (substitute* "configure"
diff --git a/gnu/packages/parallel.scm b/gnu/packages/parallel.scm
index 179fa7ed3..e0e6bba7b 100644
--- a/gnu/packages/parallel.scm
+++ b/gnu/packages/parallel.scm
@@ -136,8 +136,8 @@ and they are executed on lists of files, hosts, users or other items.")
             (string-append "--with-ssl=" (assoc-ref %build-inputs "openssl")))
       #:phases
       (modify-phases %standard-phases
-       (add-before
-        'configure 'autogen
+       (add-after
+        'unpack 'autogen
         (lambda _ (zero? (system* "autoconf"))))))) ; configure.ac was patched
    (home-page "http://slurm.schedmd.com/")
    (synopsis "Workload manager for cluster computing")
diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index 20dfdafb9..59ed691ec 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -263,7 +263,7 @@ Poppler PDF rendering library.")
                            (assoc-ref %build-inputs "libpng")))
       #:phases
       (modify-phases %standard-phases
-        (add-before 'configure 'autogen
+        (add-after 'unpack 'autogen
           (lambda _ (zero? (system* "autoreconf" "-vif")))))))
    (inputs
     `(("zlib" ,zlib)
diff --git a/gnu/packages/samba.scm b/gnu/packages/samba.scm
index 4a7880cfe..2d0f78016 100644
--- a/gnu/packages/samba.scm
+++ b/gnu/packages/samba.scm
@@ -71,7 +71,7 @@
      `(#:phases
        (modify-phases %standard-phases
          ;; The 6.7 tarball is missing ‘install.sh’. Create it.
-         (add-before 'configure 'autoreconf
+         (add-after 'unpack 'autoreconf
            (lambda _
              (zero? (system* "autoreconf" "-i"))))
          (add-before 'configure 'set-root-sbin
diff --git a/gnu/packages/serialization.scm b/gnu/packages/serialization.scm
index 3994191bd..3743ca8f3 100644
--- a/gnu/packages/serialization.scm
+++ b/gnu/packages/serialization.scm
@@ -127,7 +127,7 @@ such as compact binary encodings, XML, or JSON.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'autoconf
+         (add-after 'unpack 'autoconf
            (lambda _
              (system* "autoreconf" "-vfi"))))))
     (home-page "http://www.msgpack.org")
diff --git a/gnu/packages/shells.scm b/gnu/packages/shells.scm
index 8d2a957ea..d918c091d 100644
--- a/gnu/packages/shells.scm
+++ b/gnu/packages/shells.scm
@@ -430,7 +430,7 @@ use of experts and novices alike.")
                  (delete-file-recursively "rx")
                  (symlink rxpath "rx"))
                #t))
-           (add-before 'configure 'autoreconf
+           (add-after 'unpack 'autoreconf
              (lambda _
                (zero? (system* "autoreconf")))))))
       (inputs
diff --git a/gnu/packages/telephony.scm b/gnu/packages/telephony.scm
index 5207bd241..5df5e9e4a 100644
--- a/gnu/packages/telephony.scm
+++ b/gnu/packages/telephony.scm
@@ -272,7 +272,7 @@ and a supporting cryptographic kernel.")
          ("libtool" ,libtool)))
       (arguments
        `(#:phases (modify-phases %standard-phases
-                    (add-before 'configure 'autoconf
+                    (add-after 'unpack 'autoconf
                       (lambda _
                         (zero? (system* "autoreconf" "-vfi")))))))
       (home-page "https://gitlab.savoirfairelinux.com/sflphone/libiax2")
diff --git a/gnu/packages/textutils.scm b/gnu/packages/textutils.scm
index 479527a5f..45cef19d0 100644
--- a/gnu/packages/textutils.scm
+++ b/gnu/packages/textutils.scm
@@ -576,7 +576,7 @@ categories.")
      `(#:tests? #f ; FIXME maketest.sh does not work.
        #:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'autoreconf
+         (add-after 'unpack 'autoreconf
            (lambda _
              (zero? (system* "autoreconf" "-vif")))))))
     (native-inputs
diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index 9667b2f3e..75d7eba20 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -1227,7 +1227,7 @@ output of the 'git' command.")
     (build-system gnu-build-system)
     (arguments
      '(#:phases (modify-phases %standard-phases
-                  (add-before 'configure 'bootstrap
+                  (add-after 'unpack 'bootstrap
                     (lambda _
                       (zero? (system* "autoreconf" "-vfi")))))))
     (native-inputs `(("autoconf" ,autoconf)
diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm
index 19a5e24ed..1f0467b1e 100644
--- a/gnu/packages/video.scm
+++ b/gnu/packages/video.scm
@@ -840,7 +840,7 @@ audio/video codec library.")
 
        #:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'bootstrap
+         (add-after 'unpack 'bootstrap
            (lambda _ (zero? (system* "sh" "bootstrap"))))
          (add-before 'bootstrap 'fix-livemedia-utils-prefix
            (lambda* (#:key inputs #:allow-other-keys)
@@ -2258,12 +2258,10 @@ practically any type of media.")
        #:phases
        ;; build scripts not in root of archive
        (modify-phases %standard-phases
-         (add-before 'configure 'pre-configure
+         (add-after 'unpack 'autogen
            (lambda _
-             (chdir "Project/GNU/Library")))
-         (add-before 'configure 'autogen
-           (lambda _
-             (zero? (system* "./autogen.sh")))))))
+             (chdir "Project/GNU/Library")
+             (zero? (system* "sh" "autogen.sh")))))))
     (home-page "https://mediaarea.net/en/MediaInfo")
     (synopsis "Library for retrieving media metadata")
     (description "MediaInfo is a library used for retrieving technical
@@ -2316,12 +2314,10 @@ MPEG-2, MPEG-4, DVD (VOB)...
        #:phases
        ;; build scripts not in root of archive
        (modify-phases %standard-phases
-         (add-before 'configure 'pre-configure
-           (lambda _
-             (chdir "Project/GNU/CLI")))
-         (add-before 'configure 'autogen
+         (add-after 'unpack 'autogen
            (lambda _
-             (zero? (system* "./autogen.sh")))))))
+             (chdir "Project/GNU/CLI")
+             (zero? (system* "sh" "autogen.sh")))))))
     (home-page "https://mediaarea.net/en/MediaInfo")
     (synopsis "Utility for reading media metadata")
     (description "MediaInfo is a utility used for retrieving technical
-- 
2.13.3