[Skiboot] [PATCH 1/2] external/opal-prd: Add --version option
Jeremy Kerr
jk at ozlabs.org
Fri Jun 19 13:11:51 AEST 2015
This change adds a --version option to opal-prd, and the make_version
infrastructure to support it.
Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
---
external/opal-prd/Makefile | 17 ++++++++++++++++-
external/opal-prd/opal-prd.c | 10 ++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/external/opal-prd/Makefile b/external/opal-prd/Makefile
index 18bc164..9ccc6f6 100644
--- a/external/opal-prd/Makefile
+++ b/external/opal-prd/Makefile
@@ -16,13 +16,15 @@ ifndef V
Q_MKDIR=@echo ' MKDIR ' $@;
endif
-OBJS = opal-prd.o thunk.o pnor.o i2c.o module.o \
+OBJS = opal-prd.o thunk.o pnor.o i2c.o module.o version.o \
blocklevel.o libffs.o libflash.o ecc.o
all: opal-prd
LINKS = ccan
+SKIBOOT_VERSION ?= $(shell ../../make_version.sh skiboot)
+
ifdef KERNEL_DIR
LINKS += asm/opal-prd.h
endif
@@ -49,6 +51,19 @@ $(OBJS): $(LINKS)
opal-prd: $(OBJS)
$(Q_LINK)$(LINK.o) -o $@ $^
+version.c: ../../make_version.sh .version
+ @(if [ "a$(SKIBOOT_VERSION)" = "a" ]; then \
+ echo "#error You need to set SKIBOOT_VERSION environment variable" > $@ ;\
+ else \
+ echo "const char version[] = \"$(SKIBOOT_VERSION)\";" ;\
+ fi) > $@
+
+.PHONY: VERSION-always
+.version: VERSION-always
+ @echo $(SKIBOOT_VERSION) > $@.tmp
+ @cmp -s $@ $@.tmp || cp $@.tmp $@
+ @rm -f $@.tmp
+
test: test/test_pnor
test/test_pnor: test/test_pnor.o pnor.o libflash/libflash.o libflash/libffs.o
diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c
index 84aca89..bf8f2ae 100644
--- a/external/opal-prd/opal-prd.c
+++ b/external/opal-prd/opal-prd.c
@@ -1336,11 +1336,18 @@ static void usage(const char *progname)
"\t--stdio log to stdio, instead of syslog\n");
}
+static void print_version(void)
+{
+ extern const char version[];
+ printf("opal-prd %s\n", version);
+}
+
static struct option opal_diag_options[] = {
{"file", required_argument, NULL, 'f'},
{"pnor", required_argument, NULL, 'p'},
{"debug", no_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'},
+ {"version", no_argument, NULL, 'v'},
{"stdio", no_argument, NULL, 's'},
{ 0 },
};
@@ -1401,6 +1408,9 @@ int main(int argc, char *argv[])
case 'h':
usage(argv[0]);
return EXIT_SUCCESS;
+ case 'v':
+ print_version();
+ return EXIT_SUCCESS;
case '?':
default:
usage(argv[0]);
More information about the Skiboot
mailing list