From f3073bbe5dafb892ce0c1c93dd246233eaa73309 Mon Sep 17 00:00:00 2001 From: john hood Date: Mon, 18 May 2015 18:56:40 -0400 Subject: [PATCH] Add git commit version info --- Makefile.am | 21 +++++++++++++++++++++ scripts/Makefile.am | 8 ++++++-- scripts/{mosh => mosh.pl} | 4 +--- src/frontend/mosh-client.cc | 3 ++- src/frontend/mosh-server.cc | 3 ++- 5 files changed, 32 insertions(+), 7 deletions(-) rename scripts/{mosh => mosh.pl} (99%) diff --git a/Makefile.am b/Makefile.am index c6e9142..930fcfa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,24 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = src scripts man conf EXTRA_DIST = autogen.sh ocb-license.html README.md COPYING.iOS +nodist_noinst_HEADERS = version.h +BUILT_SOURCES = version.h + +.PHONY: VERSION + +VERSION: + @-[ -f VERSION ] || echo @PACKAGE_STRING@ > VERSION + @-git status > /dev/null 2>&1 && \ + git describe --dirty > VERSION.new && \ + ! diff -q VERSION VERSION.new > /dev/null && \ + mv VERSION.new VERSION + @rm -f VERSION.new + +version.h: VERSION + @printf '#define BUILD_VERSION "%s"\n' "$$(cat VERSION)" > version.h.new + @-! diff -q version.h version.h.new > /dev/null && \ + mv version.h.new version.h + @rm -f version.h.new + +clean-local: + @rm -f version.h VERSION diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 2f5825a..1baa2a9 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -1,4 +1,8 @@ -EXTRA_DIST = wrap-compiler-for-flag-check +EXTRA_DIST = wrap-compiler-for-flag-check mosh.pl if BUILD_CLIENT - dist_bin_SCRIPTS = mosh + bin_SCRIPTS = mosh endif +CLEANFILES = $(bin_SCRIPTS) + +mosh: mosh.pl ../VERSION Makefile + @sed -e "s/\@VERSION\@/`cat ../VERSION`/" -e "s/\@PACKAGE_STRING\@/@PACKAGE_STRING@/" $(srcdir)/mosh.pl > mosh diff --git a/scripts/mosh b/scripts/mosh.pl similarity index 99% rename from scripts/mosh rename to scripts/mosh.pl index f13de81..9b801e0 100755 --- a/scripts/mosh +++ b/scripts/mosh.pl @@ -30,8 +30,6 @@ # this exception statement from all source files in the program, then # also delete it here. -my $MOSH_VERSION = '1.2.4a'; - use warnings; use strict; use Getopt::Long; @@ -89,7 +87,7 @@ qq{Usage: $0 [options] [--] [user@]host [command...] Please report bugs to mosh-devel\@mit.edu. Mosh home page: http://mosh.mit.edu\n}; -my $version_message = qq{mosh $MOSH_VERSION +my $version_message = qq{@PACKAGE_STRING@ [build @VERSION@] Copyright 2012 Keith Winstein License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. diff --git a/src/frontend/mosh-client.cc b/src/frontend/mosh-client.cc index 03ec32b..fcf8b7a 100644 --- a/src/frontend/mosh-client.cc +++ b/src/frontend/mosh-client.cc @@ -31,6 +31,7 @@ */ #include "config.h" +#include "version.h" #include #include @@ -71,7 +72,7 @@ #endif void usage( const char *argv0 ) { - fprintf( stderr, "mosh-client (%s)\n", PACKAGE_STRING ); + fprintf( stderr, "mosh-client (%s) [build %s]\n", PACKAGE_STRING, BUILD_VERSION ); fprintf( stderr, "Copyright 2012 Keith Winstein \n" ); fprintf( stderr, "License GPLv3+: GNU GPL version 3 or later .\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\n" ); diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index 84cf7b6..6b9443e 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -31,6 +31,7 @@ */ #include "config.h" +#include "version.h" #include #include @@ -368,7 +369,7 @@ int run_server( const char *desired_ip, const char *desired_port, _exit( 0 ); } - fprintf( stderr, "\nmosh-server (%s)\n", PACKAGE_STRING ); + fprintf( stderr, "\nmosh-server (%s) [build %s]\n", PACKAGE_STRING, BUILD_VERSION ); fprintf( stderr, "Copyright 2012 Keith Winstein \n" ); fprintf( stderr, "License GPLv3+: GNU GPL version 3 or later .\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n\n" );