From db0be82d65656d311e8e08b1de09e3fd63c66541 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 17 Jul 2012 10:08:17 +0200 Subject: [PATCH] Add --version/-v support. Patch by Matt Newsome. --- Makefile | 3 ++- VERSION | 1 + dwz.1 | 3 +++ dwz.c | 25 ++++++++++++++++++++++--- 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 VERSION diff --git a/Makefile b/Makefile index c8275a1..fbac9b5 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ CFLAGS = -O2 -g -override CFLAGS += -Wall -W -D_FILE_OFFSET_BITS=64 +DWZ_VERSION := $(shell cat VERSION) +override CFLAGS += -Wall -W -D_FILE_OFFSET_BITS=64 -DDWZ_VERSION='"$(DWZ_VERSION)"' prefix = /usr exec_prefix = $(prefix) bindir = $(exec_prefix)/bin diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..2eb3c4f --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.5 diff --git a/dwz.1 b/dwz.1 index 345605e..f3c38fc 100644 --- a/dwz.1 +++ b/dwz.1 @@ -89,6 +89,9 @@ containing more than .TP .B \-? \-\-help Print short help and exit. +.TP +.B \-v \-\-version +Print version number and short licensing notice and exit. .SH ARGUMENTS Command-line arguments should be the executables, shared libraries or their stripped to file separate debug information objects. diff --git a/dwz.c b/dwz.c index 932760a..6db55ac 100644 --- a/dwz.c +++ b/dwz.c @@ -11582,6 +11582,7 @@ static struct option dwz_options[] = { "max-die-limit", required_argument, 0, 'L' }, { "multifile-name", required_argument, 0, 'M' }, { "relative", no_argument, 0, 'r' }, + { "version", no_argument, 0, 'v' }, { NULL, no_argument, 0, 0 } }; @@ -11591,8 +11592,22 @@ usage (void) { error (1, 0, "Usage:\n" - " dwz [-q] [-h] [-l COUNT] [-L COUNT] [-m COMMONFILE] [-M NAME] [-r] [FILES]\n" - " dwz [-q] [-l COUNT] [-L COUNT] -o OUTFILE FILE\n"); + " dwz [-v] [-q] [-h] [-l COUNT] [-L COUNT] [-m COMMONFILE] [-M NAME] [-r] [FILES]\n" + " dwz [-v] [-q] [-l COUNT] [-L COUNT] -o OUTFILE FILE\n"); +} + +/* Print version and exit. */ +static void +version (void) +{ + fprintf (stderr, + "dwz version " DWZ_VERSION "\n" + "Copyright (C) 2001-2012 Red Hat, Inc.\n" + "Copyright (C) 2003 Free Software Foundation, Inc.\n" + "This program is free software; you may redistribute it under the terms of\n" + "the GNU General Public License version 3 or (at your option) any later version.\n" + "This program has absolutely no warranty.\n"); + exit (0); } int @@ -11612,7 +11627,7 @@ main (int argc, char *argv[]) while (1) { int option_index; - int c = getopt_long (argc, argv, "m:o:qhl:L:M:r?", dwz_options, &option_index); + int c = getopt_long (argc, argv, "m:o:qhl:L:M:r?v", dwz_options, &option_index); if (c == -1) break; switch (c) @@ -11659,6 +11674,10 @@ main (int argc, char *argv[]) error (1, 0, "invalid argument -L %s", optarg); max_die_limit = l; break; + + case 'v': + version (); + break; } } -- 2.43.5