[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 07/11] Makefile: Derive "PKGVERSION" from "git descri
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 07/11] Makefile: Derive "PKGVERSION" from "git describe" by default |
Date: |
Mon, 6 Jun 2016 19:35:16 +0200 |
From: Fam Zheng <address@hidden>
Currently, if not specified in "./configure", QEMU_PKGVERSION will be
empty. Write a rule in Makefile to generate a value from "git describe"
combined with a possible git tree cleanness suffix, and write into a new
header.
$ cat qemu-version.h
#define QEMU_PKGVERSION "-v2.6.0-557-gd6550e9-dirty"
Include the header in .c files where the macro is referenced. It's not
necessary to include it in all files, otherwise each time the content of
the file changes, all sources have to be recompiled.
Signed-off-by: Fam Zheng <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
Makefile | 22 +++++++++++++++++++++-
linux-user/main.c | 1 +
qemu-img.c | 1 +
qmp.c | 1 +
scripts/create_config | 4 ----
vl.c | 1 +
6 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 59af636..fa85628 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,7 @@ endif
include $(SRC_PATH)/rules.mak
-GENERATED_HEADERS = config-host.h qemu-options.def
+GENERATED_HEADERS = qemu-version.h config-host.h qemu-options.def
GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h
GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c
GENERATED_HEADERS += qmp-introspect.h
@@ -167,6 +167,26 @@ endif
all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
+qemu-version.h: FORCE
+ $(call quiet-command, \
+ (cd $(SRC_PATH); \
+ printf '#define QEMU_PKGVERSION '; \
+ if test -n "$(PKGVERSION)"; then \
+ printf '"$(PKGVERSION)"\n'; \
+ else \
+ if test -d .git; then \
+ printf '" ('; \
+ git describe --match 'v*' 2>/dev/null | tr -d
'\n'; \
+ if ! git diff-index --quiet HEAD &>/dev/null;
then \
+ printf -- '-dirty'; \
+ fi; \
+ printf ')"\n'; \
+ else \
+ printf '""\n'; \
+ fi; \
+ fi) > address@hidden)
+ $(call quiet-command, cmp --quiet $@ address@hidden || mv
address@hidden $@)
+
config-host.h: config-host.h-timestamp
config-host.h-timestamp: config-host.mak
qemu-options.def: $(SRC_PATH)/qemu-options.hx
diff --git a/linux-user/main.c b/linux-user/main.c
index b2bc6ab..8a11d02 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -17,6 +17,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
+#include "qemu-version.h"
#include <sys/mman.h>
#include <sys/syscall.h>
#include <sys/resource.h>
diff --git a/qemu-img.c b/qemu-img.c
index 4b56ad3..32e307c 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
+#include "qemu-version.h"
#include "qapi/error.h"
#include "qapi-visit.h"
#include "qapi/qmp-output-visitor.h"
diff --git a/qmp.c b/qmp.c
index 3165f87..7df6543 100644
--- a/qmp.c
+++ b/qmp.c
@@ -14,6 +14,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu-version.h"
#include "qemu/cutils.h"
#include "monitor/monitor.h"
#include "sysemu/sysemu.h"
diff --git a/scripts/create_config b/scripts/create_config
index b2d2ebb..d47057b 100755
--- a/scripts/create_config
+++ b/scripts/create_config
@@ -9,10 +9,6 @@ case $line in
version=${line#*=}
echo "#define QEMU_VERSION \"$version\""
;;
- PKGVERSION=*) # configuration
- pkgversion=${line#*=}
- echo "#define QEMU_PKGVERSION \"$pkgversion\""
- ;;
qemu_*dir=*) # qemu-specific directory configuration
name=${line%=*}
value=${line#*=}
diff --git a/vl.c b/vl.c
index 2f74fe8..9539f92 100644
--- a/vl.c
+++ b/vl.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
+#include "qemu-version.h"
#include "qemu/cutils.h"
#include "qemu/help_option.h"
--
2.5.5
- [Qemu-devel] [PULL 00/11] Misc changes for 2016-06-06, Paolo Bonzini, 2016/06/06
- [Qemu-devel] [PULL 02/11] pc: allow raising low memory via max-ram-below-4g option, Paolo Bonzini, 2016/06/06
- [Qemu-devel] [PULL 03/11] hw/char: QOM'ify escc.c (fix), Paolo Bonzini, 2016/06/06
- [Qemu-devel] [PULL 05/11] scsi: mark TYPE_SCSI_DISK_BASE as abstract, Paolo Bonzini, 2016/06/06
- [Qemu-devel] [PULL 04/11] scsi: esp: check TI buffer index before read/write, Paolo Bonzini, 2016/06/06
- [Qemu-devel] [PULL 01/11] tests: Rename tests/Makefile to tests/Makefile.include, Paolo Bonzini, 2016/06/06
- [Qemu-devel] [PULL 09/11] vnc: list the 'to' parameter of '-vnc' in the qemu man page, Paolo Bonzini, 2016/06/06
- [Qemu-devel] [PULL 10/11] Make avx2 configure test work with -O2, Paolo Bonzini, 2016/06/06
- [Qemu-devel] [PULL 07/11] Makefile: Derive "PKGVERSION" from "git describe" by default,
Paolo Bonzini <=
- [Qemu-devel] [PULL 06/11] Makefile: Add a "FORCE" target, Paolo Bonzini, 2016/06/06
- [Qemu-devel] [PULL 11/11] avx2 configure: Use primitives in test, Paolo Bonzini, 2016/06/06
- [Qemu-devel] [PULL 08/11] scsi-disk: add missing break, Paolo Bonzini, 2016/06/06
- Re: [Qemu-devel] [PULL 00/11] Misc changes for 2016-06-06, Peter Maydell, 2016/06/06