All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Fam Zheng <famz@redhat.com>, lersek@redhat.com
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/2] Makefile: Derive "PKGVERSION" from "git describe" by default
Date: Tue, 31 May 2016 21:05:13 -0600	[thread overview]
Message-ID: <574E50E9.3030007@redhat.com> (raw)
In-Reply-To: <20160601013139.29790-3-famz@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1522 bytes --]

On 05/31/2016 07:31 PM, Fam Zheng wrote:
> 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 <famz@redhat.com>
> ---

> +qemu-version.h: FORCE
> +	$(call quiet-command, \
> +		(cd $(SRC_PATH); \

Can CDPATH interfere with this one?

> +		echo -n '#define QEMU_PKGVERSION '; \

'echo -n' is non-portable, use printf instead.

> +		if test -n "$(PKGVERSION)"; then \
> +			echo '"$(PKGVERSION)"'; \
> +		else \
> +			echo -n '"-'; \

And again

> +			if ! git status &>/dev/null; then \
> +				echo -n "no-git"; \

and again

> +			else \
> +				git describe 2>/dev/null | tr -d '\n'; \
> +				if ! git diff-index --quiet HEAD &>/dev/null; then \
> +					echo -n '-unclean'; \

and again

Why -unclean instead of -dirty?

> +				fi \
> +			fi; \
> +			echo '"'; \
> +		fi) > $@.tmp)
> +	$(call quiet-command, cmp --quiet $@ $@.tmp || mv $@.tmp $@)
> +


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2016-06-01  3:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-31 11:16 [Qemu-devel] including the "git describe" output in the QEMU binaries? Laszlo Ersek
2016-05-31 11:32 ` Daniel P. Berrange
2016-05-31 12:16   ` Laszlo Ersek
2016-05-31 13:19   ` Daniel P. Berrange
2016-05-31 13:26     ` Laszlo Ersek
2016-06-01  1:31 ` [Qemu-devel] [PATCH 0/2] Let PKGVERSION include the "git describe" output Fam Zheng
2016-06-01  1:31   ` [Qemu-devel] [PATCH 1/2] Makefile: Add a "FORCE" target Fam Zheng
2016-06-01  1:31   ` [Qemu-devel] [PATCH 2/2] Makefile: Derive "PKGVERSION" from "git describe" by default Fam Zheng
2016-06-01  3:05     ` Eric Blake [this message]
2016-06-01  3:17       ` Fam Zheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=574E50E9.3030007@redhat.com \
    --to=eblake@redhat.com \
    --cc=famz@redhat.com \
    --cc=lersek@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.