From 8ca98d57fff8b5fa61c01f18eeb103aac2d1591d Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Thu, 28 Feb 2013 23:39:06 +0100 Subject: [PATCH] setup: add --version --- Makefile | 1 + src/setup/setup.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 30ec9a3..95f3a98 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,7 @@ gummiboot: src/setup/setup.c src/setup/efivars.h src/setup/efivars.c Makefile $(E) " CCLD " $@ $(Q) $(CC) -O0 -g -Wall -Wextra \ -Wno-unused-parameter -D_GNU_SOURCE \ + -DVERSION=$(VERSION) \ -DMACHINE_TYPE_NAME=\"$(MACHINE_TYPE_NAME)\" \ src/setup/setup.c \ src/setup/efivars.c \ diff --git a/src/setup/setup.c b/src/setup/setup.c index d36aad5..214aa6e 100644 --- a/src/setup/setup.c +++ b/src/setup/setup.c @@ -40,6 +40,9 @@ #include "efivars.h" +#define _stringify(s) #s +#define stringify(s) _stringify(s) + #define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0])) #define streq(a,b) (strcmp((a),(b)) == 0) @@ -1246,6 +1249,7 @@ static int help(void) { "\n" "Install, update or remove the Gummiboot EFI boot loader.\n\n" " -h --help Show this help\n" + " --version Print version\n" " --path=PATH Path to the EFI System Partition (ESP)\n" " --no-variables Don't touch EFI variables\n" "\n" @@ -1265,11 +1269,13 @@ static bool arg_touch_variables = true; static int parse_argv(int argc, char *argv[]) { enum { ARG_PATH = 0x100, - ARG_NO_VARIABLES + ARG_VERSION, + ARG_NO_VARIABLES, }; static const struct option options[] = { { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, ARG_VERSION }, { "path", required_argument, NULL, ARG_PATH }, { "no-variables", no_argument, NULL, ARG_NO_VARIABLES }, { NULL, 0, NULL, 0 } @@ -1287,6 +1293,10 @@ static int parse_argv(int argc, char *argv[]) { help(); return 0; + case ARG_VERSION: + printf(stringify(VERSION) "\n"); + return 0; + case ARG_PATH: arg_path = optarg; break; -- 2.7.4