From 6846d805786f702ff28b6b2d370330bf2c16cc46 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 11 Jan 2017 09:06:46 +0100 Subject: [PATCH] Implement -v to display the current version and exit --- configure | 2 ++ main.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/configure b/configure index adf9eb4..e80cf68 100755 --- a/configure +++ b/configure @@ -40,6 +40,7 @@ UTF8_LOCALE= CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | env -i make -sf -` CFLAGS="-g -W -Wall -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings" CFLAGS="${CFLAGS} -Wno-unused-parameter" +CPPFLAGS="-DVERSION=\\\"\${VERSION}\\\"" LDADD= LDFLAGS= LD_NANOSLEEP= @@ -438,6 +439,7 @@ BUILD_TARGETS = ${BUILD_TARGETS} INSTALL_TARGETS = ${INSTALL_TARGETS} CC = ${CC} CFLAGS = ${CFLAGS} +CPPFLAGS = ${CPPFLAGS} LDADD = ${LDADD} LDFLAGS = ${LDFLAGS} STATIC = ${STATIC} diff --git a/main.c b/main.c index b64b3be..fcfb27f 100644 --- a/main.c +++ b/main.c @@ -195,7 +195,7 @@ main(int argc, char *argv[]) outmode = OUTMODE_DEF; while (-1 != (c = getopt(argc, argv, - "aC:cfhI:iK:klM:m:O:S:s:T:VW:w"))) { + "aC:cfhI:iK:klM:m:O:S:s:T:vVW:w"))) { switch (c) { case 'a': outmode = OUTMODE_ALL; @@ -261,6 +261,10 @@ main(int argc, char *argv[]) if ( ! toptions(&curp, optarg)) return (int)MANDOCLEVEL_BADARG; break; + case 'v': + printf("mandoc %s\n", VERSION); + exit(0); + break; case 'W': if ( ! woptions(&curp, optarg)) return (int)MANDOCLEVEL_BADARG; -- 2.11.0