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 <f...@redhat.com> > > --- > > > +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) > $@.tmp) > > + $(call quiet-command, cmp --quiet $@ $@.tmp || mv $@.tmp $@) > > + > > > -- > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org > Thanks, Fam