aclocal.glob, m4/: Split the monster into separate `aclocal'-ish files.
[cfd] / m4 / mdw-auto-version.m4
diff --git a/m4/mdw-auto-version.m4 b/m4/mdw-auto-version.m4
new file mode 100644 (file)
index 0000000..bdc48cf
--- /dev/null
@@ -0,0 +1,24 @@
+dnl -*-autoconf-*-
+
+dnl --- *@-mdw_AUTO_VERSION-@* ---
+dnl
+dnl Author:    Mark Wooding
+dnl
+dnl Synopsis:  mdw_AUTO_VERSION
+dnl
+dnl Arguments: ---
+dnl
+dnl Use:       Defines an m4 macro AUTO_VERSION which contains the current
+dnl            version number, worked out in some clever way.
+
+AC_DEFUN([mdw_AUTO_VERSION], [nobody cares...])
+m4_define([mdw_AUTO_VERSION], [m4_define([AUTO_VERSION], m4_esyscmd([
+  ver=UNKNOWN
+  for pre in ./ config/; do
+    for post in "" .in; do
+      try=${pre}auto-version${post}
+      if test -x $try; then ver=$("$try"); break; fi
+    done
+  done
+  echo -n "$ver"
+]))])