Skip to contentSkip to conversation

configure: Add config.status to recreate the current configuration

PATCH In review Stefan Weil 2 participants 3 messages Oct 20, 2013 – Oct 29, 2013 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure: Add config.status to recreate the current configuration

The latest configure invocation was saved in config-host.mak and could be extracted from that file to recreate the configuration.

Now it is saved in a new file config.status which can be directly executed to recreate the configuration. The file name and the comments were copied from GNU autoconf.

Makefile now uses config.status, but also includes transitional code for the old mechanism.

---

This patch still does not escape special characters in the command line. I expect that most users don't use such characters, so they have no problem.

It's easy to fix that for hosts with bash: simply replace %s by %q. If required, this can be done in a later patch.

Regards,
Stefan Weil

 Makefile  |    9 ++++++++-
 configure |   15 +++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)
Makefile +8 -1
index b15003f..073f18b 100644
@@ -28,7 +28,14 @@ CONFIG_ALL=y
 include $(SRC_PATH)/rules.mak
 config-host.mak: $(SRC_PATH)/configure
 	@echo $@ is out-of-date, running configure
-	@sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
+	@# TODO: The next lines include code which supports a smooth
+	@# transition from old configurations without config.status.
+	@# This code can be removed after QEMU 1.7.
+	@if test -x config.status; then \
+	    ./config.status; \
+        else \
+	    sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh; \
+	fi
 else
 config-host.mak:
 ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
configure +13 -2
index 57ee62a..125d0c5 100755
@@ -27,6 +27,19 @@ printf " '%s'" "$0" "$@" >> config.log
 echo >> config.log
 echo "#" >> config.log
 
+# Save the configure command line for later reuse.
+cat <<EOD >config.status
+#!/bin/sh
+# Generated by configure.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+EOD
+printf "exec" >>config.status
+printf " '%s'" "$0" "$@" >>config.status
+echo >>config.status
+chmod +x config.status
+
 error_exit() {
     echo
     echo "ERROR: $1"
@@ -3765,8 +3778,6 @@ config_host_mak="config-host.mak"
 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
 
 echo "# Automatically generated by configure - do not modify" > $config_host_mak
-printf "# Configured with:" >> $config_host_mak
-printf " '%s'" "$0" "$@" >> $config_host_mak
 echo >> $config_host_mak
 
 echo all: >> $config_host_mak
Signature · 1 line
1.7.10.4
#1 lore raw

Am 20.10.2013 18:39, schrieb Stefan Weil:

Quoted 71 lines

The latest configure invocation was saved in config-host.mak and could be extracted from that file to recreate the configuration.

Now it is saved in a new file config.status which can be directly executed to recreate the configuration. The file name and the comments were copied from GNU autoconf.

Makefile now uses config.status, but also includes transitional code for the old mechanism.

---

This patch still does not escape special characters in the command line. I expect that most users don't use such characters, so they have no problem.

It's easy to fix that for hosts with bash: simply replace %s by %q. If required, this can be done in a later patch.

Regards,
Stefan Weil

 Makefile  |    9 ++++++++-
 configure |   15 +++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)
Makefile +8 -1
index b15003f..073f18b 100644
@@ -28,7 +28,14 @@ CONFIG_ALL=y
 include $(SRC_PATH)/rules.mak
 config-host.mak: $(SRC_PATH)/configure
 	@echo $@ is out-of-date, running configure
-	@sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
+	@# TODO: The next lines include code which supports a smooth
+	@# transition from old configurations without config.status.
+	@# This code can be removed after QEMU 1.7.
+	@if test -x config.status; then \
+	    ./config.status; \
+        else \
+	    sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh; \
+	fi
 else
 config-host.mak:
 ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
configure +13 -0
index 57ee62a..125d0c5 100755
@@ -27,6 +27,19 @@ printf " '%s'" "$0" "$@" >> config.log
 echo >> config.log
 echo "#" >> config.log
 
+# Save the configure command line for later reuse.
+cat <<EOD >config.status
+#!/bin/sh
+# Generated by configure.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+EOD
+printf "exec" >>config.status
+printf " '%s'" "$0" "$@" >>config.status
+echo >>config.status
+chmod +x config.status
+
 error_exit() {
     echo
     echo "ERROR: $1"

configure config_host_mak="config-host.mak" · line 3783

Quoted 8 lines
configure +0 -2
@@ -3765,8 +3778,6 @@ config_host_mak="config-host.mak"
 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
 
 echo "# Automatically generated by configure - do not modify" > $config_host_mak
-printf "# Configured with:" >> $config_host_mak
-printf " '%s'" "$0" "$@" >> $config_host_mak
 echo >> $config_host_mak
 
 echo all: >> $config_host_mak

ping?

Reviewed-by on v1 1/1
#2 lore raw
In reply to Stefan Weil
Quoted 71 lines · Stefan Weil

The latest configure invocation was saved in config-host.mak and could be extracted from that file to recreate the configuration.

Now it is saved in a new file config.status which can be directly executed to recreate the configuration. The file name and the comments were copied from GNU autoconf.

Makefile now uses config.status, but also includes transitional code for the old mechanism.

---

This patch still does not escape special characters in the command line. I expect that most users don't use such characters, so they have no problem.

It's easy to fix that for hosts with bash: simply replace %s by %q. If required, this can be done in a later patch.

Regards,
Stefan Weil

 Makefile  |    9 ++++++++-
 configure |   15 +++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)
Makefile +8 -1
index b15003f..073f18b 100644
@@ -28,7 +28,14 @@ CONFIG_ALL=y
 include $(SRC_PATH)/rules.mak
 config-host.mak: $(SRC_PATH)/configure
 	@echo $@ is out-of-date, running configure
-	@sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
+	@# TODO: The next lines include code which supports a smooth
+	@# transition from old configurations without config.status.
+	@# This code can be removed after QEMU 1.7.
+	@if test -x config.status; then \
+	    ./config.status; \
+        else \
+	    sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh; \
+	fi
 else
 config-host.mak:
 ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
configure +13 -0
index 57ee62a..125d0c5 100755
@@ -27,6 +27,19 @@ printf " '%s'" "$0" "$@" >> config.log
 echo >> config.log
 echo "#" >> config.log
 
+# Save the configure command line for later reuse.
+cat <<EOD >config.status
+#!/bin/sh
+# Generated by configure.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+EOD
+printf "exec" >>config.status
+printf " '%s'" "$0" "$@" >>config.status
+echo >>config.status
+chmod +x config.status
+
 error_exit() {
     echo
     echo "ERROR: $1"

configure config_host_mak="config-host.mak" · line 3783

Quoted 8 lines
configure +0 -2
@@ -3765,8 +3778,6 @@ config_host_mak="config-host.mak"
 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
 
 echo "# Automatically generated by configure - do not modify" > $config_host_mak
-printf "# Configured with:" >> $config_host_mak
-printf " '%s'" "$0" "$@" >> $config_host_mak
 echo >> $config_host_mak
 
 echo all: >> $config_host_mak