From 0b18bd2ae2db1e6fd15e859b00b23bb39886f528 Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Wed, 19 Nov 2014 12:15:07 +1100 Subject: Implement skiboot versioning We grab a version from git tags (or SKIBOOT_VERSION environment variable), optionally tack on EXTRA_VERSION (if from git) as well as add things to the git version number if we're ahead of the most recent tag or the tree is dirty. Also fix-up makefiles so that we don't have to rebuild version.c every time you run make. fsp attn area needed updating as we can have >40 character version strings. We also export the version string via device tree rather than just the gitid. For buildroot builds, setting SKIBOOT_VERSION environment variable to the tag you grab will do the correct thing. Signed-off-by: Stewart Smith --- Makefile.main | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'Makefile.main') diff --git a/Makefile.main b/Makefile.main index 4df3cfd..b584eb8 100644 --- a/Makefile.main +++ b/Makefile.main @@ -108,13 +108,15 @@ OBJS := $(ASM) $(CORE) $(HW) $(PLATFORMS) $(LIBFDT) $(LIBFLASH) ifeq ($(PORE),1) OBJS += $(LIBPORE) endif -OBJS += $(LIBC) $(CCAN) $(DEVSRC_OBJ) gitid.o +OBJS += $(LIBC) $(CCAN) $(DEVSRC_OBJ) +OBJS_NO_VER = $(OBJS) +ALL_OBJS = $(OBJS) version.o $(TARGET).lid: $(TARGET).elf $(call Q,OBJCOPY, $(OBJCOPY) -O binary -S $^ $@, $@) -$(TARGET).elf: $(OBJS) $(TARGET).lds $(KERNEL) - $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(OBJS) -o $@, $@) +$(TARGET).elf: $(ALL_OBJS) $(TARGET).lds $(KERNEL) + $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS) -o $@, $@) $(TARGET).map: $(TARGET).elf $(call Q,NM, $(NM) -n $< | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > $@, $@) @@ -128,10 +130,16 @@ $(SUBDIRS): # Set V=1 if you want to see everything. include $(SRC)/Makefile.rules -GIT_SHA ?= $(shell cd $(SRC); GIT_DIR=$(SRC)/.git git describe --always --dirty 2> /dev/null) +VERSION ?= $(shell cd $(SRC); GIT_DIR=$(SRC)/.git $(SRC)/make_version.sh) -gitid.c: - @echo "const char gitid[] = \"$(GIT_SHA)\";" > $@ +.PHONY: VERSION-always +.version: VERSION-always + @echo $(VERSION) > $@.tmp + @cmp -s $@ $@.tmp || cp $@.tmp $@ + @rm -f $@.tmp + +version.c: make_version.sh $(OBJS_NO_VER) .version + @echo "const char version[] = \"$(VERSION)\";" > $@ .PHONY: coverage include $(shell find $(SRC)/* -name Makefile.check) @@ -149,7 +157,7 @@ tags: TAGS: find . -name '*.[chS]' | xargs etags -.PHONY: tags TAGS check gitid.c +.PHONY: tags TAGS check cscope: find . -name '*.[chS]' | xargs cscope @@ -157,7 +165,7 @@ cscope: clean: $(RM) *.[odsa] $(SUBDIRS:%=%/*.[odsa]) $(RM) $(TARGET).elf $(TARGET).lid $(TARGET).map $(TARGET).lds - $(RM) include/asm-offsets.h gitid.c + $(RM) include/asm-offsets.h version.c distclean: clean $(RM) *~ $(SUBDIRS:%=%/*~) include/*~ -- cgit v1.1 From 149b8bc4d058fc6acb6e2efb390e8e41c010d0d7 Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Wed, 19 Nov 2014 14:44:57 +1100 Subject: Fail build when SKIBOOT_VERSION not set and not in git tree Signed-off-by: Stewart Smith --- Makefile.main | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Makefile.main') diff --git a/Makefile.main b/Makefile.main index b584eb8..b212998 100644 --- a/Makefile.main +++ b/Makefile.main @@ -139,7 +139,12 @@ VERSION ?= $(shell cd $(SRC); GIT_DIR=$(SRC)/.git $(SRC)/make_version.sh) @rm -f $@.tmp version.c: make_version.sh $(OBJS_NO_VER) .version - @echo "const char version[] = \"$(VERSION)\";" > $@ + @echo $(VERSION) + @(if [ "a$(VERSION)" = "a" ]; then \ + echo "#error You need to set SKIBOOT_VERSION environment variable" > $@ ;\ + else \ + echo "const char version[] = \"$(VERSION)\";" ;\ + fi) > $@ .PHONY: coverage include $(shell find $(SRC)/* -name Makefile.check) -- cgit v1.1 From 23f147ea00fbc246106040cb95b1b6f0dfe4e961 Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Wed, 19 Nov 2014 14:53:52 +1100 Subject: don't echo version during make. whoops Signed-off-by: Stewart Smith --- Makefile.main | 1 - 1 file changed, 1 deletion(-) (limited to 'Makefile.main') diff --git a/Makefile.main b/Makefile.main index b212998..2b5a686 100644 --- a/Makefile.main +++ b/Makefile.main @@ -139,7 +139,6 @@ VERSION ?= $(shell cd $(SRC); GIT_DIR=$(SRC)/.git $(SRC)/make_version.sh) @rm -f $@.tmp version.c: make_version.sh $(OBJS_NO_VER) .version - @echo $(VERSION) @(if [ "a$(VERSION)" = "a" ]; then \ echo "#error You need to set SKIBOOT_VERSION environment variable" > $@ ;\ else \ -- cgit v1.1