From 72da49fdf05285169a9465b34f7869dafc4715ec Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Tue, 3 Nov 2015 21:49:14 +0000
Subject: Retrieved the revision number using M4 instead of shell.

git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@603 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
---
 ChangeLog                   | 21 +++++++++++++++++++++
 Makefile.am                 | 12 +-----------
 configure.ac                | 10 ++++++----
 plugins/pychrysa/pychrysa.c |  1 -
 revision.h.in               | 31 -------------------------------
 src/dialogs/about.c         |  2 +-
 src/main.c                  |  1 -
 svnrev.m4                   |  9 +++++++++
 8 files changed, 38 insertions(+), 49 deletions(-)
 delete mode 100644 revision.h.in
 create mode 100644 svnrev.m4

diff --git a/ChangeLog b/ChangeLog
index df3c77c..006f6ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+15-11-03  Cyrille Bagard <nocbos@gmail.com>
+
+	* configure.ac:
+	Include the 'svnrev.m4' file and update code.
+
+	* Makefile.am:
+	Delete all references to revision.h*.
+
+	* plugins/pychrysa/pychrysa.c:
+	Update code.
+
+	* revision.h.in:
+	Deleted entry.
+
+	* src/dialogs/about.c:
+	* src/main.c:
+	Update code.
+
+	* svnrev.m4:
+	New entry: retrieve the revision number using M4 instead of shell.
+
 15-11-01  Cyrille Bagard <nocbos@gmail.com>
 
 	* src/glibext/gbufferline.c:
diff --git a/Makefile.am b/Makefile.am
index 34a6b88..747cd30 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,15 +1,5 @@
 
-BUILT_SOURCES = revision.h
-
-.svn:
-	@[ -d $@ ] || touch $@
-
-revision.h: .svn
-	@nb=`LANG=C svn info | grep 'Revision:' | cut -d ' ' -f 2 | tr -d 'r'` ; \
-	cat $@.in | sed "s/#define REVISION .*$$/#define REVISION $$nb/" > $@ ; \
-	[ -f $< ] && rm $< || true
-
-EXTRA_DIST = config.rpath  ChangeLog
+EXTRA_DIST = config.rpath ChangeLog
 
 SUBDIRS = tools pixmaps src plugins po themes
 
diff --git a/configure.ac b/configure.ac
index 3f0478f..1476908 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,8 +4,10 @@
 # Autoconf requirements
 ############################################################
 
+m4_include([svnrev.m4])
+
 AC_PREREQ(2.59)
-AC_INIT([chrysalide], [0.3.78], [nocbos@gmail.com])
+AC_INIT([chrysalide], [svnversion], [nocbos@gmail.com])
 
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_MACRO_DIR([m4])
@@ -89,14 +91,14 @@ AC_CHECK_FUNCS([strrchr])
 
 #--- Autoheader Macros
 
-AH_TEMPLATE([VERSION], [Define the version number of the program for the about box.])
+AH_TEMPLATE([REVISION], [Define the version number of the program for the about box.])
 AH_TEMPLATE([PACKAGE_DATA_DIR], [Define the directory where the associated data will be installed.])
 AH_TEMPLATE([PACKAGE_SOURCE_DIR], [Define the directory where the code source is waiting for being compiled.])
 AH_TEMPLATE([PLUGINS_DIR], [Define the directory where the plugins are installed.])
 AH_TEMPLATE([LOCALE_DIR], [Define the directory where the message catalogs are installed.])
 
 
-AC_DEFINE_UNQUOTED(VERSION, AC_PACKAGE_VERSION)
+AC_DEFINE_UNQUOTED(REVISION, AC_PACKAGE_VERSION)
 
 if test "x${datadir}" = 'x${prefix}/share'; then
    if test "x${prefix}" = "xNONE"; then
@@ -363,7 +365,7 @@ AC_OUTPUT
 
 
 echo
-echo $PACKAGE $VERSION
+echo $PACKAGE REVISION
 
 echo
 echo The GNU Image Manipulation Program Toolkit... : $libgtk_version
diff --git a/plugins/pychrysa/pychrysa.c b/plugins/pychrysa/pychrysa.c
index d241b92..f3acec3 100644
--- a/plugins/pychrysa/pychrysa.c
+++ b/plugins/pychrysa/pychrysa.c
@@ -237,7 +237,6 @@ bool init_plugin(GPluginModule *plugin, GObject *ref)
 
 #include "plugin.h"
 #include "quirks.h"
-#include "../../revision.h"
 
 
 
diff --git a/revision.h.in b/revision.h.in
deleted file mode 100644
index 10234d0..0000000
--- a/revision.h.in
+++ /dev/null
@@ -1,31 +0,0 @@
-
-/* OpenIDA - Outil d'analyse de fichiers binaires
- * revision.h - inscription du numéro de révision SVN
- *
- * Copyright (C) 2010 Cyrille Bagard
- *
- *  This file is part of OpenIDA.
- *
- *  OpenIDA is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  OpenIDA 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef _DIALOGS_REVISION_H
-#define _DIALOGS_REVISION_H
-
-
-#define REVISION XXX
-
-
-#endif  /* _DIALOGS_REVISION_H */
diff --git a/src/dialogs/about.c b/src/dialogs/about.c
index e3424ac..70062cc 100644
--- a/src/dialogs/about.c
+++ b/src/dialogs/about.c
@@ -29,12 +29,12 @@
 #include <gdk/gdkkeysyms.h>
 
 
+#include <config.h>
 #include <i18n.h>
 
 
 #include "../gtkext/easygtk.h"
 #include "../gtkext/support.h"
-#include "../../revision.h"
 
 
 
diff --git a/src/main.c b/src/main.c
index 85e0908..2ab0c5c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -38,7 +38,6 @@
 #include "glibext/gbinportion.h"
 #include "gtkext/theme.h"
 #include "plugins/pglist.h"
-#include "../revision.h"
 
 
 // TODO : remme!
diff --git a/svnrev.m4 b/svnrev.m4
new file mode 100644
index 0000000..311f1b7
--- /dev/null
+++ b/svnrev.m4
@@ -0,0 +1,9 @@
+
+define([REPO], [svn://svn.gna.org/svn/chrysalide/trunk])
+
+
+define([svnrepo], esyscmd([bash -c "svnversion2 | tr -cd '[0-9]'" 2> /dev/null]))
+
+define([onlinerepo], esyscmd(LANG=C svn info REPO | awk -v ORS= '/Revision:/ { print $2 }'))
+
+define([svnversion], ifelse(svnrepo, , ifelse(onlinerepo, , 000, onlinerepo), svnrepo))
-- 
cgit v0.11.2-87-g4458