From patchwork Wed Jun 1 01:31:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 9145869 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B7B8F60752 for ; Wed, 1 Jun 2016 01:31:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB98A1FEDE for ; Wed, 1 Jun 2016 01:31:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9ED452675C; Wed, 1 Jun 2016 01:31:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA9451FEDE for ; Wed, 1 Jun 2016 01:31:52 +0000 (UTC) Received: from localhost ([::1]:39136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7v0i-0002RP-50 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 31 May 2016 21:31:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7v0H-0002Nn-O7 for qemu-devel@nongnu.org; Tue, 31 May 2016 21:31:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7v0G-0007Qr-At for qemu-devel@nongnu.org; Tue, 31 May 2016 21:31:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41455) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7v0C-0007Pv-9L; Tue, 31 May 2016 21:31:20 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C94587F080; Wed, 1 Jun 2016 01:31:19 +0000 (UTC) Received: from lemon.redhat.com (vpn1-5-15.pek2.redhat.com [10.72.5.15]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u511VAnQ010986; Tue, 31 May 2016 21:31:17 -0400 From: Fam Zheng To: lersek@redhat.com Date: Wed, 1 Jun 2016 09:31:39 +0800 Message-Id: <20160601013139.29790-3-famz@redhat.com> In-Reply-To: <20160601013139.29790-1-famz@redhat.com> References: <967bcc3b-e1d5-38db-eb7d-2d07e92c2e19@redhat.com> <20160601013139.29790-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 01 Jun 2016 01:31:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] Makefile: Derive "PKGVERSION" from "git describe" by default X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: famz@redhat.com, Paolo Bonzini , qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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-unclean" 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 --- 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 1548b3f..7b4c019 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fa endif endif -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 @@ -169,6 +169,26 @@ endif all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules +qemu-version.h: FORCE + $(call quiet-command, \ + (cd $(SRC_PATH); \ + echo -n '#define QEMU_PKGVERSION '; \ + if test -n "$(PKGVERSION)"; then \ + echo '"$(PKGVERSION)"'; \ + else \ + echo -n '"-'; \ + if ! git status &>/dev/null; then \ + echo -n "no-git"; \ + else \ + git describe 2>/dev/null | tr -d '\n'; \ + if ! git diff-index --quiet HEAD &>/dev/null; then \ + echo -n '-unclean'; \ + fi \ + fi; \ + echo '"'; \ + fi) > $@.tmp) + $(call quiet-command, cmp --quiet $@ $@.tmp || mv $@.tmp $@) + 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 . */ #include "qemu/osdep.h" +#include "qemu-version.h" #include #include #include 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 18d1423..97cad71 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"