# [PATCH 1/7] autoconf: GIT_CONF_APPEND_LINE: change signature

31 messages from 2012-07-18 to 2012-07-23. Participants: Stefano Lattarini, Junio C Hamano, Matthieu Moy.
Thread: https://gitlist.dev/t/31050

## Stefano Lattarini, 2012-07-18 22:34

Subject: [PATCH 0/7] build system: support automatic reconfiguration for autotools user
Message-ID: <cover.1342649928.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/cover.1342649928.git.stefano.lattarini%40gmail.com

```
This series aims at improving the user experience for those people who
(like me) use that Autotools-based interface to the build system of Git.

The two actual improvements (equipped with proper explanations and
rationales) are implemented in the last two patches.  The other five
patches are just preparatory changes.

The series as general or as clean as it could actually be, but it's
enough to scratch the itch that motivated me to write it.

Thanks,
  Stefano

Stefano Lattarini (7):
  autoconf: GIT_CONF_APPEND_LINE: change signature
  autoconf: GIT_CONF_APPEND_LINE -> GIT_CONF_SUBST
  autoconf: remove some redundant shell indirections
  autoconf: remove few redundant semicolons
  autoconf: use AC_CONFIG_COMMANDS instead of ad-hoc 'config.mak.append'
  build: "make clean" should not remove configure-generated files
  build: reconfigure automatically if configure.ac changes

 Makefile     | 17 +++++++++++++++--
 configure.ac | 53 ++++++++++++++++++++++++++++++-----------------------
 2 files changed, 45 insertions(+), 25 deletions(-)

-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-18 22:34

Subject: [PATCH 1/7] autoconf: GIT_CONF_APPEND_LINE: change signature
Message-ID: <eb5c979d7334a2fb8f0bd1d6bedf7c21b811cbb3.1342649928.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/eb5c979d7334a2fb8f0bd1d6bedf7c21b811cbb3.1342649928.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342649928.git.stefano.lattarini@gmail.com>

```
From:

   GIT_CONF_APPEND_LINE([VAR=VAL])

to:

   GIT_CONF_APPEND_LINE([VAR], [VAL])

This is only a preparatory change in view of future refactorings.
No semantic change is intended.  In fact, the generated configure
file doesn't change at all.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 configure.ac | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4e9012f..14c7960 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,7 @@
 # --------------------------
 # Append LINE to file ${config_append}
 AC_DEFUN([GIT_CONF_APPEND_LINE],
-         [echo "$1" >> "${config_append}"])
+         [echo "$1=$2" >> "${config_append}"])
 
 # GIT_ARG_SET_PATH(PROGRAM)
 # -------------------------
@@ -34,8 +34,8 @@ AC_DEFUN([GIT_CONF_APPEND_PATH],
 	if test -n "$2"; then
 		GIT_UC_PROGRAM[]_PATH=$withval
 		AC_MSG_NOTICE([Disabling use of ${PROGRAM}])
-		GIT_CONF_APPEND_LINE(NO_${PROGRAM}=YesPlease)
-		GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=)
+		GIT_CONF_APPEND_LINE([NO_${PROGRAM}], [YesPlease])
+		GIT_CONF_APPEND_LINE([${PROGRAM}_PATH], [])
 	else
 		AC_MSG_ERROR([You cannot use git without $1])
 	fi
@@ -45,7 +45,7 @@ AC_DEFUN([GIT_CONF_APPEND_PATH],
 	else
 		GIT_UC_PROGRAM[]_PATH=$withval
 		AC_MSG_NOTICE([Setting GIT_UC_PROGRAM[]_PATH to $withval])
-		GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=$withval)
+		GIT_CONF_APPEND_LINE([${PROGRAM}_PATH], [$withval])
 	fi
     fi
     m4_popdef([GIT_UC_PROGRAM])])
@@ -67,7 +67,7 @@ AC_DEFUN([GIT_PARSE_WITH],
 	NO_[]GIT_UC_PACKAGE=
 	GIT_UC_PACKAGE[]DIR=$withval
 	AC_MSG_NOTICE([Setting GIT_UC_PACKAGE[]DIR to $withval])
-	GIT_CONF_APPEND_LINE(${PACKAGE}DIR=$withval)
+	GIT_CONF_APPEND_LINE([${PACKAGE}DIR], [$withval])
     fi
     m4_popdef([GIT_UC_PACKAGE])])
 
@@ -87,7 +87,7 @@ AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
 		     [a value for $1 ($2).  Maybe you do...?])
   fi
   AC_MSG_NOTICE([Setting $2 to $withval])
-  GIT_CONF_APPEND_LINE($2=$withval)
+  GIT_CONF_APPEND_LINE([$2], [$withval])
  fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
 
 #
@@ -150,7 +150,7 @@ AC_ARG_WITH([sane-tool-path],
   else
     AC_MSG_NOTICE([Setting SANE_TOOL_PATH to '$withval'])
   fi
-  GIT_CONF_APPEND_LINE([SANE_TOOL_PATH=$withval])],
+  GIT_CONF_APPEND_LINE([SANE_TOOL_PATH], [$withval])],
   [# If the "--with-sane-tool-path" option was not given, don't touch
    # SANE_TOOL_PATH here, but let defaults in Makefile take care of it.
    # This should minimize spurious differences in the behaviour of the
@@ -169,7 +169,7 @@ AC_ARG_WITH([lib],
   else
 	lib=$withval
 	AC_MSG_NOTICE([Setting lib to '$lib'])
-	GIT_CONF_APPEND_LINE(lib=$withval)
+	GIT_CONF_APPEND_LINE([lib], [$withval])
   fi])
 
 if test -z "$lib"; then
@@ -205,7 +205,7 @@ AC_ARG_ENABLE([jsmin],
 [
   JSMIN=$enableval;
   AC_MSG_NOTICE([Setting JSMIN to '$JSMIN' to enable JavaScript minifying])
-  GIT_CONF_APPEND_LINE(JSMIN=$enableval);
+  GIT_CONF_APPEND_LINE([JSMIN], [$enableval]);
 ])
 
 # Define option to enable CSS minification
@@ -215,7 +215,7 @@ AC_ARG_ENABLE([cssmin],
 [
   CSSMIN=$enableval;
   AC_MSG_NOTICE([Setting CSSMIN to '$CSSMIN' to enable CSS minifying])
-  GIT_CONF_APPEND_LINE(CSSMIN=$enableval);
+  GIT_CONF_APPEND_LINE([CSSMIN], [$enableval]);
 ])
 
 ## Site configuration (override autodetection)
@@ -256,7 +256,7 @@ AS_HELP_STRING([],           [ARG can be also prefix for libpcre library and hea
 	USE_LIBPCRE=YesPlease
 	LIBPCREDIR=$withval
 	AC_MSG_NOTICE([Setting LIBPCREDIR to $withval])
-	GIT_CONF_APPEND_LINE(LIBPCREDIR=$withval)
+	GIT_CONF_APPEND_LINE([LIBPCREDIR], [$withval])
     fi)
 #
 # Define NO_CURL if you do not have curl installed.  git-http-pull and
-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-18 22:34

Subject: [PATCH 2/7] autoconf: GIT_CONF_APPEND_LINE -> GIT_CONF_SUBST
Message-ID: <5c4e73c3bed1a7c9135a6229d8d66aa2c61e319a.1342649928.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/5c4e73c3bed1a7c9135a6229d8d66aa2c61e319a.1342649928.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342649928.git.stefano.lattarini@gmail.com>

```
The new name fits better with the macro signature, and underlines the
similarities with the autoconf-provided macro AC_SUBST (which will be
made even more pronounced in planned future commits).

Once again, no semantic change is intended, and indeed no change to the
generated configure script is expected.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 configure.ac | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/configure.ac b/configure.ac
index 14c7960..789926f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,10 +3,10 @@
 
 ## Definitions of private macros.
 
-# GIT_CONF_APPEND_LINE(LINE)
+# GIT_CONF_SUBST(LINE)
 # --------------------------
 # Append LINE to file ${config_append}
-AC_DEFUN([GIT_CONF_APPEND_LINE],
+AC_DEFUN([GIT_CONF_SUBST],
          [echo "$1=$2" >> "${config_append}"])
 
 # GIT_ARG_SET_PATH(PROGRAM)
@@ -34,8 +34,8 @@ AC_DEFUN([GIT_CONF_APPEND_PATH],
 	if test -n "$2"; then
 		GIT_UC_PROGRAM[]_PATH=$withval
 		AC_MSG_NOTICE([Disabling use of ${PROGRAM}])
-		GIT_CONF_APPEND_LINE([NO_${PROGRAM}], [YesPlease])
-		GIT_CONF_APPEND_LINE([${PROGRAM}_PATH], [])
+		GIT_CONF_SUBST([NO_${PROGRAM}], [YesPlease])
+		GIT_CONF_SUBST([${PROGRAM}_PATH], [])
 	else
 		AC_MSG_ERROR([You cannot use git without $1])
 	fi
@@ -45,7 +45,7 @@ AC_DEFUN([GIT_CONF_APPEND_PATH],
 	else
 		GIT_UC_PROGRAM[]_PATH=$withval
 		AC_MSG_NOTICE([Setting GIT_UC_PROGRAM[]_PATH to $withval])
-		GIT_CONF_APPEND_LINE([${PROGRAM}_PATH], [$withval])
+		GIT_CONF_SUBST([${PROGRAM}_PATH], [$withval])
 	fi
     fi
     m4_popdef([GIT_UC_PROGRAM])])
@@ -67,7 +67,7 @@ AC_DEFUN([GIT_PARSE_WITH],
 	NO_[]GIT_UC_PACKAGE=
 	GIT_UC_PACKAGE[]DIR=$withval
 	AC_MSG_NOTICE([Setting GIT_UC_PACKAGE[]DIR to $withval])
-	GIT_CONF_APPEND_LINE([${PACKAGE}DIR], [$withval])
+	GIT_CONF_SUBST([${PACKAGE}DIR], [$withval])
     fi
     m4_popdef([GIT_UC_PACKAGE])])
 
@@ -87,7 +87,7 @@ AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
 		     [a value for $1 ($2).  Maybe you do...?])
   fi
   AC_MSG_NOTICE([Setting $2 to $withval])
-  GIT_CONF_APPEND_LINE([$2], [$withval])
+  GIT_CONF_SUBST([$2], [$withval])
  fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
 
 #
@@ -150,7 +150,7 @@ AC_ARG_WITH([sane-tool-path],
   else
     AC_MSG_NOTICE([Setting SANE_TOOL_PATH to '$withval'])
   fi
-  GIT_CONF_APPEND_LINE([SANE_TOOL_PATH], [$withval])],
+  GIT_CONF_SUBST([SANE_TOOL_PATH], [$withval])],
   [# If the "--with-sane-tool-path" option was not given, don't touch
    # SANE_TOOL_PATH here, but let defaults in Makefile take care of it.
    # This should minimize spurious differences in the behaviour of the
@@ -169,7 +169,7 @@ AC_ARG_WITH([lib],
   else
 	lib=$withval
 	AC_MSG_NOTICE([Setting lib to '$lib'])
-	GIT_CONF_APPEND_LINE([lib], [$withval])
+	GIT_CONF_SUBST([lib], [$withval])
   fi])
 
 if test -z "$lib"; then
@@ -205,7 +205,7 @@ AC_ARG_ENABLE([jsmin],
 [
   JSMIN=$enableval;
   AC_MSG_NOTICE([Setting JSMIN to '$JSMIN' to enable JavaScript minifying])
-  GIT_CONF_APPEND_LINE([JSMIN], [$enableval]);
+  GIT_CONF_SUBST([JSMIN], [$enableval]);
 ])
 
 # Define option to enable CSS minification
@@ -215,7 +215,7 @@ AC_ARG_ENABLE([cssmin],
 [
   CSSMIN=$enableval;
   AC_MSG_NOTICE([Setting CSSMIN to '$CSSMIN' to enable CSS minifying])
-  GIT_CONF_APPEND_LINE([CSSMIN], [$enableval]);
+  GIT_CONF_SUBST([CSSMIN], [$enableval]);
 ])
 
 ## Site configuration (override autodetection)
@@ -256,7 +256,7 @@ AS_HELP_STRING([],           [ARG can be also prefix for libpcre library and hea
 	USE_LIBPCRE=YesPlease
 	LIBPCREDIR=$withval
 	AC_MSG_NOTICE([Setting LIBPCREDIR to $withval])
-	GIT_CONF_APPEND_LINE([LIBPCREDIR], [$withval])
+	GIT_CONF_SUBST([LIBPCREDIR], [$withval])
     fi)
 #
 # Define NO_CURL if you do not have curl installed.  git-http-pull and
-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-18 22:34

Subject: [PATCH 3/7] autoconf: remove some redundant shell indirections
Message-ID: <4392b87d8e6c73cfa06459a24b1721b8a8e13a81.1342649928.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/4392b87d8e6c73cfa06459a24b1721b8a8e13a81.1342649928.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342649928.git.stefano.lattarini@gmail.com>

```
They are merely useless now, but would get in the way of future changes.

No semantic change is intended.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 configure.ac | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index 789926f..9472f6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,13 +29,12 @@ AC_DEFUN([GIT_ARG_SET_PATH],
 # --without-PROGRAM is used.
 AC_DEFUN([GIT_CONF_APPEND_PATH],
     [m4_pushdef([GIT_UC_PROGRAM], m4_toupper([$1]))dnl
-    PROGRAM=GIT_UC_PROGRAM
     if test "$withval" = "no"; then
 	if test -n "$2"; then
 		GIT_UC_PROGRAM[]_PATH=$withval
-		AC_MSG_NOTICE([Disabling use of ${PROGRAM}])
-		GIT_CONF_SUBST([NO_${PROGRAM}], [YesPlease])
-		GIT_CONF_SUBST([${PROGRAM}_PATH], [])
+		AC_MSG_NOTICE([Disabling use of GIT_UC_PROGRAM])
+		GIT_CONF_SUBST([NO_]GIT_UC_PROGRAM, [YesPlease])
+		GIT_CONF_SUBST(GIT_UC_PROGRAM[_PATH], [])
 	else
 		AC_MSG_ERROR([You cannot use git without $1])
 	fi
@@ -45,7 +44,7 @@ AC_DEFUN([GIT_CONF_APPEND_PATH],
 	else
 		GIT_UC_PROGRAM[]_PATH=$withval
 		AC_MSG_NOTICE([Setting GIT_UC_PROGRAM[]_PATH to $withval])
-		GIT_CONF_SUBST([${PROGRAM}_PATH], [$withval])
+		GIT_CONF_SUBST(GIT_UC_PROGRAM[_PATH], [$withval])
 	fi
     fi
     m4_popdef([GIT_UC_PROGRAM])])
@@ -58,7 +57,6 @@ AC_DEFUN([GIT_CONF_APPEND_PATH],
 # * Unset NO_PACKAGE for --with-PACKAGE without ARG
 AC_DEFUN([GIT_PARSE_WITH],
     [m4_pushdef([GIT_UC_PACKAGE], m4_toupper([$1]))dnl
-    PACKAGE=GIT_UC_PACKAGE
     if test "$withval" = "no"; then
 	NO_[]GIT_UC_PACKAGE=YesPlease
     elif test "$withval" = "yes"; then
@@ -67,7 +65,7 @@ AC_DEFUN([GIT_PARSE_WITH],
 	NO_[]GIT_UC_PACKAGE=
 	GIT_UC_PACKAGE[]DIR=$withval
 	AC_MSG_NOTICE([Setting GIT_UC_PACKAGE[]DIR to $withval])
-	GIT_CONF_SUBST([${PACKAGE}DIR], [$withval])
+	GIT_CONF_SUBST(GIT_UC_PACKAGE[DIR], [$withval])
     fi
     m4_popdef([GIT_UC_PACKAGE])])
 
-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-18 22:34

Subject: [PATCH 4/7] autoconf: remove few redundant semicolons
Message-ID: <1913417f049bb2cb4786aa82ec49af5ae1238a5b.1342649928.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/1913417f049bb2cb4786aa82ec49af5ae1238a5b.1342649928.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342649928.git.stefano.lattarini@gmail.com>

```
They are merely useless now, but would get in the way of future changes.

No semantic change is intended.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9472f6b..5fb9734 100644
--- a/configure.ac
+++ b/configure.ac
@@ -203,7 +203,7 @@ AC_ARG_ENABLE([jsmin],
 [
   JSMIN=$enableval;
   AC_MSG_NOTICE([Setting JSMIN to '$JSMIN' to enable JavaScript minifying])
-  GIT_CONF_SUBST([JSMIN], [$enableval]);
+  GIT_CONF_SUBST([JSMIN], [$enableval])
 ])
 
 # Define option to enable CSS minification
@@ -213,7 +213,7 @@ AC_ARG_ENABLE([cssmin],
 [
   CSSMIN=$enableval;
   AC_MSG_NOTICE([Setting CSSMIN to '$CSSMIN' to enable CSS minifying])
-  GIT_CONF_SUBST([CSSMIN], [$enableval]);
+  GIT_CONF_SUBST([CSSMIN], [$enableval])
 ])
 
 ## Site configuration (override autodetection)
-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-18 22:35

Subject: [PATCH 5/7] autoconf: use AC_CONFIG_COMMANDS instead of ad-hoc 'config.mak.append'
Message-ID: <ab3ac81e8e3d40a18390b5be4915a0f3ee24a73e.1342649928.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/ab3ac81e8e3d40a18390b5be4915a0f3ee24a73e.1342649928.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342649928.git.stefano.lattarini@gmail.com>

```
This will allow "./config.status --recheck; ./config.status" to work
correctly as a mean of reconfiguring the tree with the same configure
argument used in the previous "./configure" invocation.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 configure.ac | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5fb9734..64eecbc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,21 @@
 # --------------------------
 # Append LINE to file ${config_append}
 AC_DEFUN([GIT_CONF_SUBST],
-         [echo "$1=$2" >> "${config_append}"])
+   [AC_REQUIRE([GIT_CONF_SUBST_INIT])
+   config_appended_defs="$config_appended_defs${newline}$1=$2"])
+
+
+# GIT_CONF_SUBST_INIT
+# -------------------
+# Prepare shell variables and autoconf machine required by later calls
+# to GIT_CONF_SUBST.
+AC_DEFUN([GIT_CONF_SUBST_INIT], 
+    [config_appended_defs=; newline='
+'
+    AC_CONFIG_COMMANDS([$config_file],
+                       [echo "$config_appended_defs" >> "$config_file"],
+                       [config_file=$config_file
+                        config_appended_defs="$config_appended_defs"])])
 
 # GIT_ARG_SET_PATH(PROGRAM)
 # -------------------------
@@ -133,11 +147,8 @@ AC_INIT([git], [@@GIT_VERSION@@], [git@vger.kernel.org])
 AC_CONFIG_SRCDIR([git.c])
 
 config_file=config.mak.autogen
-config_append=config.mak.append
 config_in=config.mak.in
 
-echo "# ${config_append}.  Generated by configure." > "${config_append}"
-
 # Directories holding "saner" versions of common or POSIX binaries.
 AC_ARG_WITH([sane-tool-path],
   [AS_HELP_STRING(
@@ -1041,9 +1052,5 @@ AC_SUBST(PTHREAD_LIBS)
 AC_SUBST(NO_PTHREADS)
 
 ## Output files
-AC_CONFIG_FILES(["${config_file}":"${config_in}":"${config_append}"])
+AC_CONFIG_FILES(["${config_file}":"${config_in}"])
 AC_OUTPUT
-
-
-## Cleanup
-rm -f "${config_append}"
-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-18 22:35

Subject: [PATCH 6/7] build: "make clean" should not remove configure-generated files
Message-ID: <e763e7f466efa34f48589f8353a7316fff469145.1342649928.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/e763e7f466efa34f48589f8353a7316fff469145.1342649928.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342649928.git.stefano.lattarini@gmail.com>

```
Those filed hold variables, settings and information set by the
configuration process run by './configure'; in Autotools-based
build system that kind of stuff should only be removed by
"make distclean".  Having it removed by "make clean" is not only
inconsistent, but causes real confusion for that part of the Git
audience that is used to the Autotools semantics; for example,
an autotools old-timer that has run:

    ./configure --prefix /opt/git

in the past, without running "make distclean" afterwards, would
expect a "make install" issued after a "make clean" to rebuild and
install git in '/opt/git'; but with the current behaviour, the
"make clean" invocation removes (among the other things) the file
'config.mak.autogen', so that the "make install" falls back to the
default prefix of '$HOME', thus installing git in the user's home
directory -- definitely unexpected.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 285c660..88a76a3 100644
--- a/Makefile
+++ b/Makefile
@@ -2742,6 +2742,9 @@ dist-doc:
 
 distclean: clean
 	$(RM) configure
+	$(RM) config.log config.status config.cache
+	$(RM) config.mak.autogen config.mak.append
+	$(RM) -r autom4te.cache
 
 profile-clean:
 	$(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
@@ -2756,8 +2759,6 @@ clean: profile-clean
 	$(RM) -r $(dep_dirs)
 	$(RM) -r po/build/
 	$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h $(ETAGS_TARGET) tags cscope*
-	$(RM) -r autom4te.cache
-	$(RM) config.log config.mak.autogen config.mak.append config.status config.cache
 	$(RM) -r $(GIT_TARNAME) .doc-tmp-dir
 	$(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
 	$(RM) $(htmldocs).tar.gz $(manpages).tar.gz
-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-18 22:35

Subject: [PATCH 7/7] build: reconfigure automatically if configure.ac changes
Message-ID: <553d16eabb655a82d76b1fa73b78e1f4a86122d9.1342649928.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/553d16eabb655a82d76b1fa73b78e1f4a86122d9.1342649928.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342649928.git.stefano.lattarini@gmail.com>

```
This provides a reduced but still useful sibling of the Automake's
"automatic Makefile rebuild" feature.  It's important to note that
we take care to enable the new rules only if the tree that has already
be configured with './configure', so that users relying on manual
configuration won't be negatively impacted.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 Makefile     | 12 ++++++++++++
 configure.ac |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/Makefile b/Makefile
index 88a76a3..f4e8fac 100644
--- a/Makefile
+++ b/Makefile
@@ -2158,6 +2158,18 @@ configure: configure.ac GIT-VERSION-FILE
 	autoconf -o $@ $<+ && \
 	$(RM) $<+
 
+ifdef AUTOCONFIGURED
+config.status: configure
+	$(QUIET_GEN)if test -f config.status; then \
+	  ./config.status --recheck; \
+	else \
+	  ./configure; \
+	fi
+reconfigure config.mak.autogen: config.status
+	$(QUIET_GEN)./config.status
+.PHONY: reconfigure # This is a convenience target.
+endif
+
 XDIFF_OBJS += xdiff/xdiffi.o
 XDIFF_OBJS += xdiff/xprepare.o
 XDIFF_OBJS += xdiff/xutils.o
diff --git a/configure.ac b/configure.ac
index 64eecbc..8949935 100644
--- a/configure.ac
+++ b/configure.ac
@@ -149,6 +149,8 @@ AC_CONFIG_SRCDIR([git.c])
 config_file=config.mak.autogen
 config_in=config.mak.in
 
+GIT_CONF_SUBST([AUTOCONFIGURED], [YesPlease])
+
 # Directories holding "saner" versions of common or POSIX binaries.
 AC_ARG_WITH([sane-tool-path],
   [AS_HELP_STRING(
-- 
1.7.10.2.1067.g553d16e

```

## Junio C Hamano, 2012-07-19 00:13

Subject: Re: [PATCH 2/7] autoconf: GIT_CONF_APPEND_LINE -> GIT_CONF_SUBST
Message-ID: <7v7gu0wqtk.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v7gu0wqtk.fsf%40alter.siamese.dyndns.org
In-Reply-To: <5c4e73c3bed1a7c9135a6229d8d66aa2c61e319a.1342649928.git.stefano.lattarini@gmail.com>

```
Stefano Lattarini <stefano.lattarini@gmail.com> writes:

> The new name fits better with the macro signature, and underlines the
> similarities with the autoconf-provided macro AC_SUBST (which will be
> made even more pronounced in planned future commits).
>
> Once again, no semantic change is intended, and indeed no change to the
> generated configure script is expected.
>
> Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
> ---
>  configure.ac | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 14c7960..789926f 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -3,10 +3,10 @@
>  
>  ## Definitions of private macros.
>  
> -# GIT_CONF_APPEND_LINE(LINE)
> +# GIT_CONF_SUBST(LINE)

I see that [PATCH 1/7] needs to be updated so that it describes the
new two-argument form of GIT_CONF_APPEND_LINE(VAR, VAL), and this
patch needs to be updated for GIT_CONF_SUBST() with the same.

>  # --------------------------
>  # Append LINE to file ${config_append}

Also the description definitely wants to be updated; it is no longer
LINEness that matters.

Other than that, 1 & 2 looked very nice and sensible.

```

## Junio C Hamano, 2012-07-19 00:29

Subject: Re: [PATCH 3/7] autoconf: remove some redundant shell indirections
Message-ID: <7v394owq3l.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v394owq3l.fsf%40alter.siamese.dyndns.org
In-Reply-To: <4392b87d8e6c73cfa06459a24b1721b8a8e13a81.1342649928.git.stefano.lattarini@gmail.com>

```
Stefano Lattarini <stefano.lattarini@gmail.com> writes:

> diff --git a/configure.ac b/configure.ac
> index 789926f..9472f6b 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -29,13 +29,12 @@ AC_DEFUN([GIT_ARG_SET_PATH],
>  # --without-PROGRAM is used.
>  AC_DEFUN([GIT_CONF_APPEND_PATH],
>      [m4_pushdef([GIT_UC_PROGRAM], m4_toupper([$1]))dnl
>      if test "$withval" = "no"; then
>  	if test -n "$2"; then
>  		GIT_UC_PROGRAM[]_PATH=$withval
> +		AC_MSG_NOTICE([Disabling use of GIT_UC_PROGRAM])
> +		GIT_CONF_SUBST([NO_]GIT_UC_PROGRAM, [YesPlease])
> +		GIT_CONF_SUBST(GIT_UC_PROGRAM[_PATH], [])

Nice.

The inconsistency between the existing one that does not quote the
string that is not substituted, i.e.

	GIT_UC_PROGRAM[]_PATH=$withval

and the new one that quotes _PATH, i.e.

	GIT_CONF_SUBST(GIT_UC_PROGRAM[_PATH], [])

looks somewhat strange, though.

```

## Junio C Hamano, 2012-07-19 00:36

Subject: Re: [PATCH 0/7] build system: support automatic reconfiguration for autotools user
Message-ID: <7vy5mgvb6f.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy5mgvb6f.fsf%40alter.siamese.dyndns.org
In-Reply-To: <cover.1342649928.git.stefano.lattarini@gmail.com>

```
Except for miniscule nits in the the bottom two, I didn't find
anything objectionable---nicely done.

```

## Matthieu Moy, 2012-07-19 06:56

Subject: Re: [PATCH 6/7] build: "make clean" should not remove configure-generated files
Message-ID: <vpqy5mgdyro.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqy5mgdyro.fsf%40bauges.imag.fr
In-Reply-To: <e763e7f466efa34f48589f8353a7316fff469145.1342649928.git.stefano.lattarini@gmail.com>

```
Stefano Lattarini <stefano.lattarini@gmail.com> writes:

> for example, an autotools old-timer that has run:
>
>     ./configure --prefix /opt/git
>
> in the past, without running "make distclean" afterwards, would
> expect a "make install" issued after a "make clean" to rebuild and
> install git in '/opt/git';

I've been hit by that behavior once. Thanks for fixing it. The patch
looks good.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Stefano Lattarini, 2012-07-19 07:30

Subject: Re: [PATCH 6/7] build: "make clean" should not remove configure-generated files
Message-ID: <5007B780.7010500@gmail.com>
URL: https://gitlist.dev/e/5007B780.7010500%40gmail.com
In-Reply-To: <vpqy5mgdyro.fsf@bauges.imag.fr>

```
On 07/19/2012 08:56 AM, Matthieu Moy wrote:
> Stefano Lattarini <stefano.lattarini@gmail.com> writes:
> 
>> for example, an autotools old-timer that has run:
>>
>>     ./configure --prefix /opt/git
>>
>> in the past, without running "make distclean" afterwards, would
>> expect a "make install" issued after a "make clean" to rebuild and
>> install git in '/opt/git';
> 
> I've been hit by that behavior once. Thanks for fixing it. The patch
> looks good.
> 
Should I add "Acked-by: Matthieu Moy" then?  (Sorry if it's a dumb
question, but I'm not sure which the preferred policy is around here).

Thanks,
  Stefano

```

## Stefano Lattarini, 2012-07-19 07:30

Subject: Re: [PATCH 3/7] autoconf: remove some redundant shell indirections
Message-ID: <5007B7B1.8000909@gmail.com>
URL: https://gitlist.dev/e/5007B7B1.8000909%40gmail.com
In-Reply-To: <7v394owq3l.fsf@alter.siamese.dyndns.org>

```
On 07/19/2012 02:29 AM, Junio C Hamano wrote:
> 
> The inconsistency between the existing one that does not quote the
> string that is not substituted, i.e.
> 
> 	GIT_UC_PROGRAM[]_PATH=$withval
> 
> and the new one that quotes _PATH, i.e.
> 
> 	GIT_CONF_SUBST(GIT_UC_PROGRAM[_PATH], [])
> 
> looks somewhat strange, though.
>
Will fix that in the re-roll.

Thanks,
  Stefano

```

## Stefano Lattarini, 2012-07-19 07:32

Subject: Re: [PATCH 2/7] autoconf: GIT_CONF_APPEND_LINE -> GIT_CONF_SUBST
Message-ID: <5007B825.3040609@gmail.com>
URL: https://gitlist.dev/e/5007B825.3040609%40gmail.com
In-Reply-To: <7v7gu0wqtk.fsf@alter.siamese.dyndns.org>

```
On 07/19/2012 02:13 AM, Junio C Hamano wrote:
> Stefano Lattarini <stefano.lattarini@gmail.com> writes:
> 
>> The new name fits better with the macro signature, and underlines the
>> similarities with the autoconf-provided macro AC_SUBST (which will be
>> made even more pronounced in planned future commits).
>>
>> Once again, no semantic change is intended, and indeed no change to the
>> generated configure script is expected.
>>
>> Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
>> ---
>>  configure.ac | 24 ++++++++++++------------
>>  1 file changed, 12 insertions(+), 12 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 14c7960..789926f 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -3,10 +3,10 @@
>>  
>>  ## Definitions of private macros.
>>  
>> -# GIT_CONF_APPEND_LINE(LINE)
>> +# GIT_CONF_SUBST(LINE)
> 
> I see that [PATCH 1/7] needs to be updated so that it describes the
> new two-argument form of GIT_CONF_APPEND_LINE(VAR, VAL), and this
> patch needs to be updated for GIT_CONF_SUBST() with the same.
>
Oops, you're right.  I will fix that in the re-roll.

>>  # --------------------------
>>  # Append LINE to file ${config_append}
> 
> Also the description definitely wants to be updated; it is no longer
> LINEness that matters.
> 
> Other than that, 1 & 2 looked very nice and sensible.
>
Thanks!

Regards,
  Stefano

```

## Matthieu Moy, 2012-07-19 07:43

Subject: Re: [PATCH 6/7] build: "make clean" should not remove configure-generated files
Message-ID: <vpqpq7sdwmd.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqpq7sdwmd.fsf%40bauges.imag.fr
In-Reply-To: <5007B780.7010500@gmail.com>

```
Stefano Lattarini <stefano.lattarini@gmail.com> writes:

> Should I add "Acked-by: Matthieu Moy" then?  (Sorry if it's a dumb
> question, but I'm not sure which the preferred policy is around here).

Not necessarily needed if the patch is not otherwise controversial. The
email discussions are usually sufficient for that. I'd say you may add
it if you need to resend.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Stefano Lattarini, 2012-07-19 07:49

Subject: [PATCH v2 0/7] build system: support automatic reconfiguration for autotools user
Message-ID: <cover.1342683786.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/cover.1342683786.git.stefano.lattarini%40gmail.com
In-Reply-To: <7vy5mgvb6f.fsf@alter.siamese.dyndns.org>

```
> Except for miniscule nits in the the bottom two, I didn't find
> anything objectionable---nicely done.
>
Thanks.

Here is the re-roll, which should address all the reported nits.

Stefano Lattarini (7):
  autoconf: GIT_CONF_APPEND_LINE: change signature
  autoconf: GIT_CONF_APPEND_LINE -> GIT_CONF_SUBST
  autoconf: remove some redundant shell indirections
  autoconf: remove few redundant semicolons
  autoconf: use AC_CONFIG_COMMANDS instead of ad-hoc 'config.mak.append'
  build: "make clean" should not remove configure-generated files
  build: reconfigure automatically if configure.ac changes

 Makefile     | 17 +++++++++++++++--
 configure.ac | 56 +++++++++++++++++++++++++++++++-------------------------
 2 files changed, 46 insertions(+), 27 deletions(-)

-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-19 07:49

Subject: [PATCH v2 1/7] autoconf: GIT_CONF_APPEND_LINE: change signature
Message-ID: <bed901f25e6e9b6c6c3e5b9e13fc1e3605ce08ef.1342683786.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/bed901f25e6e9b6c6c3e5b9e13fc1e3605ce08ef.1342683786.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342683786.git.stefano.lattarini@gmail.com>

```
From:

   GIT_CONF_APPEND_LINE([VAR=VAL])

to:

   GIT_CONF_APPEND_LINE([VAR], [VAL])

This is only a preparatory change in view of future refactorings.
No semantic change is intended.  In fact, the generated configure
file doesn't change at all.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 configure.ac | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4e9012f..5f63269 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,11 +3,11 @@
 
 ## Definitions of private macros.
 
-# GIT_CONF_APPEND_LINE(LINE)
-# --------------------------
-# Append LINE to file ${config_append}
+# GIT_CONF_APPEND_LINE(VAL, VAR)
+# ------------------------------
+# Append the line "VAR=VAL" to file ${config_append}
 AC_DEFUN([GIT_CONF_APPEND_LINE],
-         [echo "$1" >> "${config_append}"])
+         [echo "$1=$2" >> "${config_append}"])
 
 # GIT_ARG_SET_PATH(PROGRAM)
 # -------------------------
@@ -34,8 +34,8 @@ AC_DEFUN([GIT_CONF_APPEND_PATH],
 	if test -n "$2"; then
 		GIT_UC_PROGRAM[]_PATH=$withval
 		AC_MSG_NOTICE([Disabling use of ${PROGRAM}])
-		GIT_CONF_APPEND_LINE(NO_${PROGRAM}=YesPlease)
-		GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=)
+		GIT_CONF_APPEND_LINE([NO_${PROGRAM}], [YesPlease])
+		GIT_CONF_APPEND_LINE([${PROGRAM}_PATH], [])
 	else
 		AC_MSG_ERROR([You cannot use git without $1])
 	fi
@@ -45,7 +45,7 @@ AC_DEFUN([GIT_CONF_APPEND_PATH],
 	else
 		GIT_UC_PROGRAM[]_PATH=$withval
 		AC_MSG_NOTICE([Setting GIT_UC_PROGRAM[]_PATH to $withval])
-		GIT_CONF_APPEND_LINE(${PROGRAM}_PATH=$withval)
+		GIT_CONF_APPEND_LINE([${PROGRAM}_PATH], [$withval])
 	fi
     fi
     m4_popdef([GIT_UC_PROGRAM])])
@@ -67,7 +67,7 @@ AC_DEFUN([GIT_PARSE_WITH],
 	NO_[]GIT_UC_PACKAGE=
 	GIT_UC_PACKAGE[]DIR=$withval
 	AC_MSG_NOTICE([Setting GIT_UC_PACKAGE[]DIR to $withval])
-	GIT_CONF_APPEND_LINE(${PACKAGE}DIR=$withval)
+	GIT_CONF_APPEND_LINE([${PACKAGE}DIR], [$withval])
     fi
     m4_popdef([GIT_UC_PACKAGE])])
 
@@ -87,7 +87,7 @@ AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
 		     [a value for $1 ($2).  Maybe you do...?])
   fi
   AC_MSG_NOTICE([Setting $2 to $withval])
-  GIT_CONF_APPEND_LINE($2=$withval)
+  GIT_CONF_APPEND_LINE([$2], [$withval])
  fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
 
 #
@@ -150,7 +150,7 @@ AC_ARG_WITH([sane-tool-path],
   else
     AC_MSG_NOTICE([Setting SANE_TOOL_PATH to '$withval'])
   fi
-  GIT_CONF_APPEND_LINE([SANE_TOOL_PATH=$withval])],
+  GIT_CONF_APPEND_LINE([SANE_TOOL_PATH], [$withval])],
   [# If the "--with-sane-tool-path" option was not given, don't touch
    # SANE_TOOL_PATH here, but let defaults in Makefile take care of it.
    # This should minimize spurious differences in the behaviour of the
@@ -169,7 +169,7 @@ AC_ARG_WITH([lib],
   else
 	lib=$withval
 	AC_MSG_NOTICE([Setting lib to '$lib'])
-	GIT_CONF_APPEND_LINE(lib=$withval)
+	GIT_CONF_APPEND_LINE([lib], [$withval])
   fi])
 
 if test -z "$lib"; then
@@ -205,7 +205,7 @@ AC_ARG_ENABLE([jsmin],
 [
   JSMIN=$enableval;
   AC_MSG_NOTICE([Setting JSMIN to '$JSMIN' to enable JavaScript minifying])
-  GIT_CONF_APPEND_LINE(JSMIN=$enableval);
+  GIT_CONF_APPEND_LINE([JSMIN], [$enableval]);
 ])
 
 # Define option to enable CSS minification
@@ -215,7 +215,7 @@ AC_ARG_ENABLE([cssmin],
 [
   CSSMIN=$enableval;
   AC_MSG_NOTICE([Setting CSSMIN to '$CSSMIN' to enable CSS minifying])
-  GIT_CONF_APPEND_LINE(CSSMIN=$enableval);
+  GIT_CONF_APPEND_LINE([CSSMIN], [$enableval]);
 ])
 
 ## Site configuration (override autodetection)
@@ -256,7 +256,7 @@ AS_HELP_STRING([],           [ARG can be also prefix for libpcre library and hea
 	USE_LIBPCRE=YesPlease
 	LIBPCREDIR=$withval
 	AC_MSG_NOTICE([Setting LIBPCREDIR to $withval])
-	GIT_CONF_APPEND_LINE(LIBPCREDIR=$withval)
+	GIT_CONF_APPEND_LINE([LIBPCREDIR], [$withval])
     fi)
 #
 # Define NO_CURL if you do not have curl installed.  git-http-pull and
-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-19 07:49

Subject: [PATCH v2 2/7] autoconf: GIT_CONF_APPEND_LINE -> GIT_CONF_SUBST
Message-ID: <c3181a04d19136962968efd59a3e5b1b70535474.1342683786.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/c3181a04d19136962968efd59a3e5b1b70535474.1342683786.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342683786.git.stefano.lattarini@gmail.com>

```
The new name fits better with the macro signature, and underlines the
similarities with the autoconf-provided macro AC_SUBST (which will be
made even more pronounced in planned future commits).

Once again, no semantic change is intended, and indeed no change to the
generated configure script is expected.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 configure.ac | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5f63269..02b9a49 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,8 +3,8 @@
 
 ## Definitions of private macros.
 
-# GIT_CONF_APPEND_LINE(VAL, VAR)
-# ------------------------------
+# GIT_CONF_SUBST(VAL, VAR)
+# ------------------------
 # Append the line "VAR=VAL" to file ${config_append}
 AC_DEFUN([GIT_CONF_APPEND_LINE],
          [echo "$1=$2" >> "${config_append}"])
@@ -34,8 +34,8 @@ AC_DEFUN([GIT_CONF_APPEND_PATH],
 	if test -n "$2"; then
 		GIT_UC_PROGRAM[]_PATH=$withval
 		AC_MSG_NOTICE([Disabling use of ${PROGRAM}])
-		GIT_CONF_APPEND_LINE([NO_${PROGRAM}], [YesPlease])
-		GIT_CONF_APPEND_LINE([${PROGRAM}_PATH], [])
+		GIT_CONF_SUBST([NO_${PROGRAM}], [YesPlease])
+		GIT_CONF_SUBST([${PROGRAM}_PATH], [])
 	else
 		AC_MSG_ERROR([You cannot use git without $1])
 	fi
@@ -45,7 +45,7 @@ AC_DEFUN([GIT_CONF_APPEND_PATH],
 	else
 		GIT_UC_PROGRAM[]_PATH=$withval
 		AC_MSG_NOTICE([Setting GIT_UC_PROGRAM[]_PATH to $withval])
-		GIT_CONF_APPEND_LINE([${PROGRAM}_PATH], [$withval])
+		GIT_CONF_SUBST([${PROGRAM}_PATH], [$withval])
 	fi
     fi
     m4_popdef([GIT_UC_PROGRAM])])
@@ -67,7 +67,7 @@ AC_DEFUN([GIT_PARSE_WITH],
 	NO_[]GIT_UC_PACKAGE=
 	GIT_UC_PACKAGE[]DIR=$withval
 	AC_MSG_NOTICE([Setting GIT_UC_PACKAGE[]DIR to $withval])
-	GIT_CONF_APPEND_LINE([${PACKAGE}DIR], [$withval])
+	GIT_CONF_SUBST([${PACKAGE}DIR], [$withval])
     fi
     m4_popdef([GIT_UC_PACKAGE])])
 
@@ -87,7 +87,7 @@ AC_DEFUN([GIT_PARSE_WITH_SET_MAKE_VAR],
 		     [a value for $1 ($2).  Maybe you do...?])
   fi
   AC_MSG_NOTICE([Setting $2 to $withval])
-  GIT_CONF_APPEND_LINE([$2], [$withval])
+  GIT_CONF_SUBST([$2], [$withval])
  fi)])# GIT_PARSE_WITH_SET_MAKE_VAR
 
 #
@@ -150,7 +150,7 @@ AC_ARG_WITH([sane-tool-path],
   else
     AC_MSG_NOTICE([Setting SANE_TOOL_PATH to '$withval'])
   fi
-  GIT_CONF_APPEND_LINE([SANE_TOOL_PATH], [$withval])],
+  GIT_CONF_SUBST([SANE_TOOL_PATH], [$withval])],
   [# If the "--with-sane-tool-path" option was not given, don't touch
    # SANE_TOOL_PATH here, but let defaults in Makefile take care of it.
    # This should minimize spurious differences in the behaviour of the
@@ -169,7 +169,7 @@ AC_ARG_WITH([lib],
   else
 	lib=$withval
 	AC_MSG_NOTICE([Setting lib to '$lib'])
-	GIT_CONF_APPEND_LINE([lib], [$withval])
+	GIT_CONF_SUBST([lib], [$withval])
   fi])
 
 if test -z "$lib"; then
@@ -205,7 +205,7 @@ AC_ARG_ENABLE([jsmin],
 [
   JSMIN=$enableval;
   AC_MSG_NOTICE([Setting JSMIN to '$JSMIN' to enable JavaScript minifying])
-  GIT_CONF_APPEND_LINE([JSMIN], [$enableval]);
+  GIT_CONF_SUBST([JSMIN], [$enableval]);
 ])
 
 # Define option to enable CSS minification
@@ -215,7 +215,7 @@ AC_ARG_ENABLE([cssmin],
 [
   CSSMIN=$enableval;
   AC_MSG_NOTICE([Setting CSSMIN to '$CSSMIN' to enable CSS minifying])
-  GIT_CONF_APPEND_LINE([CSSMIN], [$enableval]);
+  GIT_CONF_SUBST([CSSMIN], [$enableval]);
 ])
 
 ## Site configuration (override autodetection)
@@ -256,7 +256,7 @@ AS_HELP_STRING([],           [ARG can be also prefix for libpcre library and hea
 	USE_LIBPCRE=YesPlease
 	LIBPCREDIR=$withval
 	AC_MSG_NOTICE([Setting LIBPCREDIR to $withval])
-	GIT_CONF_APPEND_LINE([LIBPCREDIR], [$withval])
+	GIT_CONF_SUBST([LIBPCREDIR], [$withval])
     fi)
 #
 # Define NO_CURL if you do not have curl installed.  git-http-pull and
-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-19 07:49

Subject: [PATCH v2 3/7] autoconf: remove some redundant shell indirections
Message-ID: <edc192e0d37b96c3c7727bd19e4cd3979b579574.1342683786.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/edc192e0d37b96c3c7727bd19e4cd3979b579574.1342683786.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342683786.git.stefano.lattarini@gmail.com>

```
They are merely useless now, but would get in the way of future changes.

No semantic change is intended.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 configure.ac | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index 02b9a49..200776f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,13 +29,12 @@ AC_DEFUN([GIT_ARG_SET_PATH],
 # --without-PROGRAM is used.
 AC_DEFUN([GIT_CONF_APPEND_PATH],
     [m4_pushdef([GIT_UC_PROGRAM], m4_toupper([$1]))dnl
-    PROGRAM=GIT_UC_PROGRAM
     if test "$withval" = "no"; then
 	if test -n "$2"; then
 		GIT_UC_PROGRAM[]_PATH=$withval
-		AC_MSG_NOTICE([Disabling use of ${PROGRAM}])
-		GIT_CONF_SUBST([NO_${PROGRAM}], [YesPlease])
-		GIT_CONF_SUBST([${PROGRAM}_PATH], [])
+		AC_MSG_NOTICE([Disabling use of GIT_UC_PROGRAM])
+		GIT_CONF_SUBST([NO_]GIT_UC_PROGRAM, [YesPlease])
+		GIT_CONF_SUBST(GIT_UC_PROGRAM[]_PATH, [])
 	else
 		AC_MSG_ERROR([You cannot use git without $1])
 	fi
@@ -45,7 +44,7 @@ AC_DEFUN([GIT_CONF_APPEND_PATH],
 	else
 		GIT_UC_PROGRAM[]_PATH=$withval
 		AC_MSG_NOTICE([Setting GIT_UC_PROGRAM[]_PATH to $withval])
-		GIT_CONF_SUBST([${PROGRAM}_PATH], [$withval])
+		GIT_CONF_SUBST(GIT_UC_PROGRAM[]_PATH, [$withval])
 	fi
     fi
     m4_popdef([GIT_UC_PROGRAM])])
@@ -58,7 +57,6 @@ AC_DEFUN([GIT_CONF_APPEND_PATH],
 # * Unset NO_PACKAGE for --with-PACKAGE without ARG
 AC_DEFUN([GIT_PARSE_WITH],
     [m4_pushdef([GIT_UC_PACKAGE], m4_toupper([$1]))dnl
-    PACKAGE=GIT_UC_PACKAGE
     if test "$withval" = "no"; then
 	NO_[]GIT_UC_PACKAGE=YesPlease
     elif test "$withval" = "yes"; then
@@ -67,7 +65,7 @@ AC_DEFUN([GIT_PARSE_WITH],
 	NO_[]GIT_UC_PACKAGE=
 	GIT_UC_PACKAGE[]DIR=$withval
 	AC_MSG_NOTICE([Setting GIT_UC_PACKAGE[]DIR to $withval])
-	GIT_CONF_SUBST([${PACKAGE}DIR], [$withval])
+	GIT_CONF_SUBST(GIT_UC_PACKAGE[DIR], [$withval])
     fi
     m4_popdef([GIT_UC_PACKAGE])])
 
-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-19 07:49

Subject: [PATCH v2 4/7] autoconf: remove few redundant semicolons
Message-ID: <836c08e3c00035f41aee320dc166eb259ec747a6.1342683786.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/836c08e3c00035f41aee320dc166eb259ec747a6.1342683786.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342683786.git.stefano.lattarini@gmail.com>

```
They are merely useless now, but would get in the way of future changes.

No semantic change is intended.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 200776f..b453ba5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -203,7 +203,7 @@ AC_ARG_ENABLE([jsmin],
 [
   JSMIN=$enableval;
   AC_MSG_NOTICE([Setting JSMIN to '$JSMIN' to enable JavaScript minifying])
-  GIT_CONF_SUBST([JSMIN], [$enableval]);
+  GIT_CONF_SUBST([JSMIN], [$enableval])
 ])
 
 # Define option to enable CSS minification
@@ -213,7 +213,7 @@ AC_ARG_ENABLE([cssmin],
 [
   CSSMIN=$enableval;
   AC_MSG_NOTICE([Setting CSSMIN to '$CSSMIN' to enable CSS minifying])
-  GIT_CONF_SUBST([CSSMIN], [$enableval]);
+  GIT_CONF_SUBST([CSSMIN], [$enableval])
 ])
 
 ## Site configuration (override autodetection)
-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-19 07:50

Subject: [PATCH v2 5/7] autoconf: use AC_CONFIG_COMMANDS instead of ad-hoc 'config.mak.append'
Message-ID: <3f038563bcf4aea6bc882e4d565c02976c460cef.1342683786.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/3f038563bcf4aea6bc882e4d565c02976c460cef.1342683786.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342683786.git.stefano.lattarini@gmail.com>

```
This will allow "./config.status --recheck; ./config.status" to work
correctly as a mean of reconfiguring the tree with the same configure
argument used in the previous "./configure" invocation.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 configure.ac | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index b453ba5..a63fe77 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,9 +5,22 @@
 
 # GIT_CONF_SUBST(VAL, VAR)
 # ------------------------
-# Append the line "VAR=VAL" to file ${config_append}
-AC_DEFUN([GIT_CONF_APPEND_LINE],
-         [echo "$1=$2" >> "${config_append}"])
+# Cause the line "VAR=VAL" to be eventually appended to ${config_file}.
+AC_DEFUN([GIT_CONF_SUBST],
+   [AC_REQUIRE([GIT_CONF_SUBST_INIT])
+   config_appended_defs="$config_appended_defs${newline}$1=$2"])
+
+# GIT_CONF_SUBST_INIT
+# -------------------
+# Prepare shell variables and autoconf machine required by later calls
+# to GIT_CONF_SUBST.
+AC_DEFUN([GIT_CONF_SUBST_INIT],
+    [config_appended_defs=; newline='
+'
+    AC_CONFIG_COMMANDS([$config_file],
+                       [echo "$config_appended_defs" >> "$config_file"],
+                       [config_file=$config_file
+                        config_appended_defs="$config_appended_defs"])])
 
 # GIT_ARG_SET_PATH(PROGRAM)
 # -------------------------
@@ -133,11 +146,8 @@ AC_INIT([git], [@@GIT_VERSION@@], [git@vger.kernel.org])
 AC_CONFIG_SRCDIR([git.c])
 
 config_file=config.mak.autogen
-config_append=config.mak.append
 config_in=config.mak.in
 
-echo "# ${config_append}.  Generated by configure." > "${config_append}"
-
 # Directories holding "saner" versions of common or POSIX binaries.
 AC_ARG_WITH([sane-tool-path],
   [AS_HELP_STRING(
@@ -1041,9 +1051,5 @@ AC_SUBST(PTHREAD_LIBS)
 AC_SUBST(NO_PTHREADS)
 
 ## Output files
-AC_CONFIG_FILES(["${config_file}":"${config_in}":"${config_append}"])
+AC_CONFIG_FILES(["${config_file}":"${config_in}"])
 AC_OUTPUT
-
-
-## Cleanup
-rm -f "${config_append}"
-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-19 07:50

Subject: [PATCH v2 6/7] build: "make clean" should not remove configure-generated files
Message-ID: <904eb7b0b17805b5265ab70709241b7da382a0cb.1342683786.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/904eb7b0b17805b5265ab70709241b7da382a0cb.1342683786.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342683786.git.stefano.lattarini@gmail.com>

```
Those filed hold variables, settings and information set by the
configuration process run by './configure'; in Autotools-based
build system that kind of stuff should only be removed by
"make distclean".  Having it removed by "make clean" is not only
inconsistent, but causes real confusion for that part of the Git
audience that is used to the Autotools semantics; for example,
an autotools old-timer that has run:

    ./configure --prefix /opt/git

in the past, without running "make distclean" afterwards, would
expect a "make install" issued after a "make clean" to rebuild and
install git in '/opt/git'; but with the current behaviour, the
"make clean" invocation removes (among the other things) the file
'config.mak.autogen', so that the "make install" falls back to the
default prefix of '$HOME', thus installing git in the user's home
directory -- definitely unexpected.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 285c660..88a76a3 100644
--- a/Makefile
+++ b/Makefile
@@ -2742,6 +2742,9 @@ dist-doc:
 
 distclean: clean
 	$(RM) configure
+	$(RM) config.log config.status config.cache
+	$(RM) config.mak.autogen config.mak.append
+	$(RM) -r autom4te.cache
 
 profile-clean:
 	$(RM) $(addsuffix *.gcda,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
@@ -2756,8 +2759,6 @@ clean: profile-clean
 	$(RM) -r $(dep_dirs)
 	$(RM) -r po/build/
 	$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h $(ETAGS_TARGET) tags cscope*
-	$(RM) -r autom4te.cache
-	$(RM) config.log config.mak.autogen config.mak.append config.status config.cache
 	$(RM) -r $(GIT_TARNAME) .doc-tmp-dir
 	$(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
 	$(RM) $(htmldocs).tar.gz $(manpages).tar.gz
-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-19 07:50

Subject: [PATCH v2 7/7] build: reconfigure automatically if configure.ac changes
Message-ID: <173104dd1ddba55bca09e89ba090ebb852bdf1b7.1342683786.git.stefano.lattarini@gmail.com>
URL: https://gitlist.dev/e/173104dd1ddba55bca09e89ba090ebb852bdf1b7.1342683786.git.stefano.lattarini%40gmail.com
In-Reply-To: <cover.1342683786.git.stefano.lattarini@gmail.com>

```
This provides a reduced but still useful sibling of the Automake's
"automatic Makefile rebuild" feature.  It's important to note that
we take care to enable the new rules only if the tree that has already
be configured with './configure', so that users relying on manual
configuration won't be negatively impacted.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 Makefile     | 12 ++++++++++++
 configure.ac |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/Makefile b/Makefile
index 88a76a3..f4e8fac 100644
--- a/Makefile
+++ b/Makefile
@@ -2158,6 +2158,18 @@ configure: configure.ac GIT-VERSION-FILE
 	autoconf -o $@ $<+ && \
 	$(RM) $<+
 
+ifdef AUTOCONFIGURED
+config.status: configure
+	$(QUIET_GEN)if test -f config.status; then \
+	  ./config.status --recheck; \
+	else \
+	  ./configure; \
+	fi
+reconfigure config.mak.autogen: config.status
+	$(QUIET_GEN)./config.status
+.PHONY: reconfigure # This is a convenience target.
+endif
+
 XDIFF_OBJS += xdiff/xdiffi.o
 XDIFF_OBJS += xdiff/xprepare.o
 XDIFF_OBJS += xdiff/xutils.o
diff --git a/configure.ac b/configure.ac
index a63fe77..df7e376 100644
--- a/configure.ac
+++ b/configure.ac
@@ -148,6 +148,8 @@ AC_CONFIG_SRCDIR([git.c])
 config_file=config.mak.autogen
 config_in=config.mak.in
 
+GIT_CONF_SUBST([AUTOCONFIGURED], [YesPlease])
+
 # Directories holding "saner" versions of common or POSIX binaries.
 AC_ARG_WITH([sane-tool-path],
   [AS_HELP_STRING(
-- 
1.7.10.2.1067.g553d16e

```

## Stefano Lattarini, 2012-07-19 07:59

Subject: Re: [PATCH 6/7] build: "make clean" should not remove configure-generated files
Message-ID: <5007BE48.809@gmail.com>
URL: https://gitlist.dev/e/5007BE48.809%40gmail.com
In-Reply-To: <vpqpq7sdwmd.fsf@bauges.imag.fr>

```
On 07/19/2012 09:43 AM, Matthieu Moy wrote:
> Stefano Lattarini <stefano.lattarini@gmail.com> writes:
> 
>> Should I add "Acked-by: Matthieu Moy" then?  (Sorry if it's a dumb
>> question, but I'm not sure which the preferred policy is around here).
> 
> Not necessarily needed if the patch is not otherwise controversial. The
> email discussions are usually sufficient for that. I'd say you may add
> it if you need to resend.
> 
OK, thanks for the info.  In light of this, since I've already send a re-roll
without any "Acked-by:" line added, I won't bother sending a further re-roll
just to add such lines.

Thanks,
  Stefano

```

## Junio C Hamano, 2012-07-19 17:24

Subject: Re: [PATCH 3/7] autoconf: remove some redundant shell indirections
Message-ID: <7vfw8nvf3u.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vfw8nvf3u.fsf%40alter.siamese.dyndns.org
In-Reply-To: <5007B7B1.8000909@gmail.com>

```
Stefano Lattarini <stefano.lattarini@gmail.com> writes:

> On 07/19/2012 02:29 AM, Junio C Hamano wrote:
>> 
>> The inconsistency between the existing one that does not quote the
>> string that is not substituted, i.e.
>> 
>> 	GIT_UC_PROGRAM[]_PATH=$withval
>> 
>> and the new one that quotes _PATH, i.e.
>> 
>> 	GIT_CONF_SUBST(GIT_UC_PROGRAM[_PATH], [])
>> 
>> looks somewhat strange, though.
>>
> Will fix that in the re-roll.

I see you already used the []_PATH in your reroll, and I do not
think it matters either way in pracice, but I suspect that it is
technically more correct to have _PATH part inside the bra-ket
quotes (of course, changing the style to maximally quote like that
is a totally different topic, and should be done as a separate
patch, so I think your reroll is the right thing to do within the
scope of this series).

Thanks.

```

## Junio C Hamano, 2012-07-19 17:27

Subject: Re: [PATCH 6/7] build: "make clean" should not remove configure-generated files
Message-ID: <7vbojbveyn.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vbojbveyn.fsf%40alter.siamese.dyndns.org
In-Reply-To: <5007B780.7010500@gmail.com>

```
Stefano Lattarini <stefano.lattarini@gmail.com> writes:

> On 07/19/2012 08:56 AM, Matthieu Moy wrote:
>> Stefano Lattarini <stefano.lattarini@gmail.com> writes:
>> 
>>> for example, an autotools old-timer that has run:
>>>
>>>     ./configure --prefix /opt/git
>>>
>>> in the past, without running "make distclean" afterwards, would
>>> expect a "make install" issued after a "make clean" to rebuild and
>>> install git in '/opt/git';
>> 
>> I've been hit by that behavior once. Thanks for fixing it. The patch
>> looks good.
>> 
> Should I add "Acked-by: Matthieu Moy" then?

Given that we see nothing in the ouptut from

 $ git shortlog --no-merges --author='Matthieu Moy' -- Makefile configure.ac

that remotely relates to the current state of affairs in this area,
I do not think we can say Matthieu _owns_ autoconf-related part of
the code in any way, so I do not think it is needed.

Thanks.

```

## Stefano Lattarini, 2012-07-19 17:50

Subject: Re: [PATCH 3/7] autoconf: remove some redundant shell indirections
Message-ID: <500848FB.8060907@gmail.com>
URL: https://gitlist.dev/e/500848FB.8060907%40gmail.com
In-Reply-To: <7vfw8nvf3u.fsf@alter.siamese.dyndns.org>

```
On 07/19/2012 07:24 PM, Junio C Hamano wrote:
> Stefano Lattarini <stefano.lattarini@gmail.com> writes:
> 
>> On 07/19/2012 02:29 AM, Junio C Hamano wrote:
>>>
>>> The inconsistency between the existing one that does not quote the
>>> string that is not substituted, i.e.
>>>
>>> 	GIT_UC_PROGRAM[]_PATH=$withval
>>>
>>> and the new one that quotes _PATH, i.e.
>>>
>>> 	GIT_CONF_SUBST(GIT_UC_PROGRAM[_PATH], [])
>>>
>>> looks somewhat strange, though.
>>>
>> Will fix that in the re-roll.
> 
> I see you already used the []_PATH in your reroll, and I do not
> think it matters either way in pracice, but I suspect that it is
> technically more correct to have _PATH part inside the bra-ket
> quotes (of course, changing the style to maximally quote like that
> is a totally different topic, and should be done as a separate
> patch,
>
Yep, that's what I thought.  Glad I got it right, saved another
re-roll :-)

>so I think your reroll is the right thing to do within the
> scope of this series).
>
And as an aside, if we'd somehow got '_PATH' to be a defined macro,
I say that something would be very, very wrong with the current setup
(Autoconf strives to be very namespace-clean these days, apart from
some old m4 builtins, which must remain available out of the 'm4_'
and 'AC_' namespaces for sake of backward-compatibility).

Today, excluding few exceptions, I'd say that the main reason to
properly quote macro arguments is to avoid commas or quoting characters
in macro invocations or expansion, or even quoting characters themselves,
to be spuriously considered as metacharacters and thus processed.

> Thanks.
>
Thanks to you for the quick feedback.

Regards,
  Stefano

```

## Stefano Lattarini, 2012-07-23 23:15

Subject: Re: [PATCH v2 6/7] build: "make clean" should not remove configure-generated files
Message-ID: <500DDB07.6050006@gmail.com>
URL: https://gitlist.dev/e/500DDB07.6050006%40gmail.com
In-Reply-To: <904eb7b0b17805b5265ab70709241b7da382a0cb.1342683786.git.stefano.lattarini@gmail.com>

```
Hi Junio.

On 07/19/2012 09:50 AM, Stefano Lattarini wrote:
> Those filed
>
Oops, this should read "files", not "filed" ...

> hold variables, settings and information set by the
> configuration process run by './configure'; in Autotools-based
> build system that kind of stuff should only be removed by
> "make distclean".  Having it removed by "make clean" is not only
> inconsistent, but causes real confusion for that part of the Git
> audience that is used to the Autotools semantics; for example,
> an autotools old-timer that has run:
> 
>     ./configure --prefix /opt/git
> 
> in the past, without running "make distclean" afterwards, would
> expect a "make install" issued after a "make clean" to rebuild and
> install git in '/opt/git'; but with the current behaviour, the
> "make clean" invocation removes (among the other things) the file
> 'config.mak.autogen', so that the "make install"
>
... and here we should add "invocation":

    ... the "make install" invocation ...

> falls back to the default prefix of '$HOME', thus installing git
> in the user's home directory -- definitely unexpected.

Can you fix those nits locally before merging to 'next', or should
I send a re-roll?

Thanks, and sorry for the confusion,
  Stefano

```

## Stefano Lattarini, 2012-07-23 23:16

Subject: Re: [PATCH v2 7/7] build: reconfigure automatically if configure.ac changes
Message-ID: <500DDB38.3050805@gmail.com>
URL: https://gitlist.dev/e/500DDB38.3050805%40gmail.com
In-Reply-To: <173104dd1ddba55bca09e89ba090ebb852bdf1b7.1342683786.git.stefano.lattarini@gmail.com>

```
Hi Junio.  I've just noticed a minor typo in the commit message ...

On 07/19/2012 09:50 AM, Stefano Lattarini wrote:
> This provides a reduced but still useful sibling of the Automake's
> "automatic Makefile rebuild" feature.  It's important to note that
> we take care to enable the new rules only if the tree that has already
> be
>
... here, it should read "been", not "be".  Can you fix that locally
before merging to 'next', or should I send a re-roll?

> configured with './configure', so that users relying on manual
> configuration won't be negatively impacted.

Thanks,
  Stefano

```

## Junio C Hamano, 2012-07-23 23:28

Subject: Re: [PATCH v2 6/7] build: "make clean" should not remove configure-generated files
Message-ID: <7vk3xuhxad.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vk3xuhxad.fsf%40alter.siamese.dyndns.org
In-Reply-To: <500DDB07.6050006@gmail.com>

```
Stefano Lattarini <stefano.lattarini@gmail.com> writes:

> ... and here we should add "invocation":
>
>     ... the "make install" invocation ...
>
>> falls back to the default prefix of '$HOME', thus installing git
>> in the user's home directory -- definitely unexpected.
>
> Can you fix those nits locally before merging to 'next', or should
> I send a re-roll?

Too late X-<.

```
