@@ -6,7 +6,7 @@ include ../../external/common/rules.mk
all: $(EXE)
.PHONY: links
-links: libflash ccan common
+links: libflash ccan common make_version.sh
libflash:
ln -sf ../../libflash .
@@ -17,17 +17,27 @@ ccan:
common:
ln -sf ../common .
-check: all
+make_version.sh:
+ ln -sf ../../make_version.sh
+
+#Rebuild version.o so that the the version always matches
+#what the test suite will get from ./make_version.sh
+check: version.o all
@ln -sf ../../test/test.sh test/test.sh
@test/test-gard
$(OBJS): | links arch_links
+.PHONY: VERSION-always
+.version: VERSION-always
+ @echo $(GARD_VERSION) > $@.tmp
+ @cmp -s $@ $@.tmp || cp $@.tmp $@
+ @rm -f $@.tmp
+
clean: arch_clean
- rm -f $(OBJS) $(EXE) *.o *.d
+ rm -f $(OBJS) $(EXE) *.o *.d .version .version.tmp
distclean: clean
rm -f *.c~ *.h~ *.sh~ Makefile~ config.mk~ libflash/*.c~ libflash/*.h~
- rm -f libflash ccan .version .version.tmp
- rm -f common io.h make_version.sh
+ rm -f libflash ccan common io.h make_version.sh
@@ -44,6 +44,9 @@
#define SYSFS_MTD_PATH "/sys/class/mtd/"
#define FLASH_GARD_PART "GUARD"
+/* Full gard version number (possibly includes gitid). */
+extern const char version[];
+
struct gard_ctx {
bool ecc;
uint32_t f_size;
@@ -637,10 +640,16 @@ struct {
{ "clear", "Clear GARD records", do_clear },
};
+static void print_version(void)
+{
+ printf("Open-Power GARD tool %s\n", version);
+}
+
static void usage(const char *progname)
{
unsigned int i;
+ print_version();
fprintf(stderr, "Usage: %s [-a -e -f <file> -p] <command> [<args>]\n\n",
progname);
fprintf(stderr, "-e --ecc\n\tForce reading/writing with ECC bytes.\n\n");
@@ -1,7 +1,7 @@
.DEFAULT_GOAL := all
override CFLAGS += -O2 -Wall -Werror -I.
-OBJS = gard.o
+OBJS = version.o gard.o
OBJS += libflash/file.o libflash/libflash.o libflash/libffs.o libflash/ecc.o libflash/blocklevel.o
OBJS += common/arch_flash.o
EXE = gard
@@ -13,6 +13,15 @@ sbindir = $(prefix)/sbin
datadir = $(prefix)/share
mandir = $(datadir)/man
+GARD_VERSION ?= $(shell ./make_version.sh $(EXE))
+
+version.c: make_version.sh .version
+ @(if [ "a$(GARD_VERSION)" = "a" ]; then \
+ echo "#error You need to set GARD_VERSION environment variable" > $@ ;\
+ else \
+ echo "const char version[] = \"$(GARD_VERSION)\";" ;\
+ fi) > $@
+
%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
@@ -0,0 +1 @@
+Open-Power GARD tool VERSION
@@ -5,6 +5,8 @@ if [ "$?" -ne 1 ] ; then
fail_test
fi
+strip_version_from_result "gard"
+
diff_with_result
pass_test
Method for recording version is identical to pflash. Uses the current skiboot version and any current repository state. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> --- external/gard/Makefile | 20 +++++++++++++++----- external/gard/gard.c | 9 +++++++++ external/gard/rules.mk | 11 ++++++++++- external/gard/test/results/02-usage.out | 1 + external/gard/test/tests/02-usage | 2 ++ 5 files changed, 37 insertions(+), 6 deletions(-)