[Skiboot] [PATCH 3/4] pflash: Use git tag versioning from make_version.sh

Cyril Bur cyril.bur at au1.ibm.com
Fri May 22 13:52:58 AEST 2015


In order to be able to create distribution tarballs of pflash there needs to
be some saneish versioning scheme.

Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
So that PFLASH_VERSION gets set correctly, there is going to need to at least
1 pflash-* git tag at or before this commit.

 external/pflash/Makefile | 20 ++++++++++++++++++--
 external/pflash/pflash.c |  5 +++--
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/external/pflash/Makefile b/external/pflash/Makefile
index f951a58..73f5ed6 100644
--- a/external/pflash/Makefile
+++ b/external/pflash/Makefile
@@ -12,7 +12,7 @@ endif
 
 CFLAGS  = -O2 -Wall -I.
 LDFLAGS	= -lrt
-OBJS    = pflash.o progress.o ast-sf-ctrl.o
+OBJS    = pflash.o progress.o ast-sf-ctrl.o version.o
 OBJS	+= libflash/libflash.o libflash/libffs.o libflash/ecc.o
 OBJS	+= $(ARCH_OBJS)
 EXE     = pflash
@@ -30,6 +30,22 @@ links:
 	ln -sf ../../ccan .
 	ln -sf ../../hw/sfc-ctrl.c .
 	ln -sf ../../hw/ast-bmc/ast-sf-ctrl.c
+	ln -sf ../../make_version.sh
+
+PFLASH_VERSION ?= $(shell ./make_version.sh $(EXE))
+
+.PHONY: VERSION-always
+.version: VERSION-always
+	@echo $(PFLASH_VERSION) > $@.tmp
+	@cmp -s $@ $@.tmp || cp $@.tmp $@
+	@rm -f $@.tmp
+
+version.c: make_version.sh .version
+	@(if [ "a$(PFLASH_VERSION)" = "a" ]; then \
+	echo "#error You need to set SKIBOOT_VERSION environment variable" > $@ ;\
+	else \
+	echo "const char version[] = \"$(PFLASH_VERSION)\";" ;\
+	fi) > $@
 
 $(OBJS) : links
 
@@ -40,4 +56,4 @@ clean:
 	rm -f $(OBJS) $(EXE) *.o *.d libflash/test/test_flash libflash/test/*.o
 distclean: clean
 	rm -f *.c~ *.h~ *.sh~ Makefile~ config.mk~ libflash/*.c~ libflash/*.h~
-	rm -f libflash ccan sfc-ctrl.c ast-sf-ctrl.c
+	rm -f libflash ccan sfc-ctrl.c ast-sf-ctrl.c .version .version.tmp
diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index fb783a2..6a6f284 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -23,7 +23,8 @@
 
 #define __aligned(x)			__attribute__((aligned(x)))
 
-#define PFLASH_VERSION	"0.8.6"
+/* Full pflash version number (possibly includes gitid). */
+extern const char version[];
 
 static bool must_confirm = true;
 static bool dummy_run;
@@ -437,7 +438,7 @@ static void flash_access_setup_pnor(bool use_lpc, bool use_sfc, bool need_write)
 
 static void print_version(void)
 {
-	printf("Palmetto Flash tool " PFLASH_VERSION "\n");
+	printf("Open-Power Flash tool %s\n", version);
 }
 
 static void print_help(const char *pname)
-- 
1.9.1



More information about the Skiboot mailing list