diff --git a/.gitignore b/.gitignore index 4cefe3ed..ec6d2882 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,6 @@ stamp-h1* /ChangeLog /INSTALL /mtr +/version.h +/version.h.tmp diff --git a/Makefile.am b/Makefile.am index 013ef42f..a42ce362 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,11 +17,24 @@ mtr_SOURCES = mtr.c \ select.c select.h \ mtr-curses.h \ mtr-gtk.h +nodist_mtr_SOURCES = version.h EXTRA_mtr_SOURCES = curses.c \ gtk.c mtr_DEPENDENCIES = $(GTK_OBJ) $(CURSES_OBJ) mtr_LDFLAGS = $(GTK_OBJ) $(CURSES_OBJ) +CLEANFILES = version.h +BUILT_SOURCES = version.h + +version.h: version.h.tmp Makefile $(mtr_SOURCES) + @cat $< > $@; \ + if [ -d .git ] && [ -n "$$(which git)" ]; then \ + xver="+git-$$(git rev-list -n1 --abbrev=8 --abbrev-commit HEAD)"; \ + sed \ + -e "/#define *MTR_VERSION */{s/\"\([^\"]*\)\"/\"\1$$xver\"/;}" \ + $< > $@; \ + fi; + EXTRA_DIST = SECURITY mtr.8 Makefile Makefile.dist distclean-local: (sleep 3; cp Makefile.dist Makefile) & diff --git a/configure.in b/configure.in index 4b81c444..43eed030 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,7 @@ AC_INIT(mtr.c) AM_INIT_AUTOMAKE(mtr, 0.83) +AC_CONFIG_FILES([version.h.tmp:version.h.in]) AC_SUBST(GTK_OBJ) AC_SUBST(CURSES_OBJ) diff --git a/curses.c b/curses.c index 0652e874..5d6c4831 100644 --- a/curses.c +++ b/curses.c @@ -64,6 +64,7 @@ #include "net.h" #include "dns.h" #include "asn.h" +#include "version.h" #include #endif @@ -565,7 +566,7 @@ void mtr_curses_redraw(void) move(0, 0); attron(A_BOLD); - pwcenter("My traceroute [v" VERSION "]"); + pwcenter("My traceroute [v" MTR_VERSION "]"); attroff(A_BOLD); mvprintw(1, 0, "%s (%s)", LocalHostname, net_localaddr()); diff --git a/gtk.c b/gtk.c index 5a04b3ee..60867cb0 100644 --- a/gtk.c +++ b/gtk.c @@ -36,6 +36,7 @@ #include "net.h" #include "dns.h" #include "mtr-gtk.h" +#include "version.h" #include "img/mtr_icon.xpm" #endif @@ -167,7 +168,7 @@ gint About_clicked(UNUSED GtkWidget *Button, UNUSED gpointer data) }; gtk_show_about_dialog(GTK_WINDOW(main_window) - , "version", VERSION + , "version", MTR_VERSION , "copyright", "Copyright \xc2\xa9 1997,1998 Matt Kimball" , "website", "http://www.bitwizard.nl/mtr/" , "authors", authors diff --git a/mtr.c b/mtr.c index 044fac57..9246bb1a 100644 --- a/mtr.c +++ b/mtr.c @@ -35,6 +35,7 @@ #include "report.h" #include "net.h" #include "asn.h" +#include "version.h" #ifdef ENABLE_IPV6 @@ -387,7 +388,7 @@ int main(int argc, char **argv) } if (PrintVersion) { - printf ("mtr " VERSION "\n"); + printf ("mtr " MTR_VERSION "\n"); exit(0); } diff --git a/version.h.in b/version.h.in new file mode 100644 index 00000000..d39e6a4c --- /dev/null +++ b/version.h.in @@ -0,0 +1,20 @@ +/* + mtr -- a network diagnostic tool + Copyright (C) 1997,1998 Matt Kimball + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#define MTR_VERSION "@VERSION@" +