[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/2] Makefile: Derive "PKGVERSION" from "git des
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [PATCH 2/2] Makefile: Derive "PKGVERSION" from "git describe" by default |
Date: |
Wed, 1 Jun 2016 11:17:16 +0800 |
User-agent: |
Mutt/1.6.1 (2016-04-27) |
On Tue, 05/31 21:05, Eric Blake wrote:
> 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 <address@hidden>
> > ---
>
> > +qemu-version.h: FORCE
> > + $(call quiet-command, \
> > + (cd $(SRC_PATH); \
>
> Can CDPATH interfere with this one?
I think SRC_PATH is either an absolute path, or is ".". Both cases are fine.
>
> > + echo -n '#define QEMU_PKGVERSION '; \
>
> 'echo -n' is non-portable, use printf instead.
Will fix.
>
> > + 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?
The non-native speaker can fix that.
>
> > + fi \
> > + fi; \
> > + echo '"'; \
> > + fi) > address@hidden)
> > + $(call quiet-command, cmp --quiet $@ address@hidden || mv
> > address@hidden $@)
> > +
>
>
> --
> Eric Blake eblake redhat com +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
>
Thanks,
Fam