Makefile: Derive "PKGVERSION" from "git describe" by default
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 <famz@redhat.com> Message-Id: <1464774261-648-3-git-send-email-famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
077de81a4c
commit
67a1de0d19
22
Makefile
22
Makefile
@ -50,7 +50,7 @@ endif
|
|||||||
|
|
||||||
include $(SRC_PATH)/rules.mak
|
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_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_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c
|
||||||
GENERATED_HEADERS += qmp-introspect.h
|
GENERATED_HEADERS += qmp-introspect.h
|
||||||
@ -167,6 +167,26 @@ endif
|
|||||||
|
|
||||||
all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
|
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) > $@.tmp)
|
||||||
|
$(call quiet-command, cmp --quiet $@ $@.tmp || mv $@.tmp $@)
|
||||||
|
|
||||||
config-host.h: config-host.h-timestamp
|
config-host.h: config-host.h-timestamp
|
||||||
config-host.h-timestamp: config-host.mak
|
config-host.h-timestamp: config-host.mak
|
||||||
qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
|
qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu-version.h"
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu-version.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qapi-visit.h"
|
#include "qapi-visit.h"
|
||||||
#include "qapi/qmp-output-visitor.h"
|
#include "qapi/qmp-output-visitor.h"
|
||||||
|
1
qmp.c
1
qmp.c
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu-version.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
#include "monitor/monitor.h"
|
#include "monitor/monitor.h"
|
||||||
#include "sysemu/sysemu.h"
|
#include "sysemu/sysemu.h"
|
||||||
|
@ -9,10 +9,6 @@ case $line in
|
|||||||
version=${line#*=}
|
version=${line#*=}
|
||||||
echo "#define QEMU_VERSION \"$version\""
|
echo "#define QEMU_VERSION \"$version\""
|
||||||
;;
|
;;
|
||||||
PKGVERSION=*) # configuration
|
|
||||||
pkgversion=${line#*=}
|
|
||||||
echo "#define QEMU_PKGVERSION \"$pkgversion\""
|
|
||||||
;;
|
|
||||||
qemu_*dir=*) # qemu-specific directory configuration
|
qemu_*dir=*) # qemu-specific directory configuration
|
||||||
name=${line%=*}
|
name=${line%=*}
|
||||||
value=${line#*=}
|
value=${line#*=}
|
||||||
|
Loading…
Reference in New Issue
Block a user