* acinclude.m4 (AC_PATH_GPG): New macro.
authorueno <ueno>
Thu, 13 Jul 2006 03:49:13 +0000 (03:49 +0000)
committerueno <ueno>
Thu, 13 Jul 2006 03:49:13 +0000 (03:49 +0000)
* configure.ac: Check gpg version.
Suggested by Max Froumentin <max@lapin-bleu.net>

ChangeLog
acinclude.m4
configure.ac

index 27ddb45..f93833b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-07-13  Daiki Ueno  <ueno@unixuser.org>
+
+       * acinclude.m4 (AC_PATH_GPG): New macro.
+       * configure.ac: Check gpg version.
+       Suggested by Max Froumentin <max@lapin-bleu.net>
+
 2006-07-10  Daiki Ueno  <ueno@unixuser.org>
 
        * epg.el (epg--status-ERRSIG): Don't remove the last verify-result.
index ad09542..e39c972 100644 (file)
@@ -357,3 +357,65 @@ AC_DEFUN([AC_ADD_LOAD_PATH],
     fi],
     ADDITIONAL_LOAD_PATH=)
   AC_SUBST(ADDITIONAL_LOAD_PATH)])
+
+AC_DEFUN([AC_PATH_GPG],
+ [AC_PATH_PROG(GPG, gpg)
+  AC_ARG_WITH(gpg,
+  AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]),
+       GPG=$withval, NO_OVERRIDE=yes)
+  AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.])
+  AC_SUBST(GPG)
+  dnl Check for GnuPG version requirement.
+  GPG_VERSION=unknown
+  ok=maybe
+  if test -z "$GPG" -o "x$GPG" = "xno"; then
+    ok=no
+  else
+    if test ! -x "$GPG"; then
+      AC_MSG_WARN([GnuPG not executable, version check disabled])
+      ok=no
+    fi
+  fi
+  if test "$ok" = "maybe"; then
+    AC_MSG_CHECKING(for GnuPG >= $1)
+    req_major=`echo $1 | \
+               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+    req_minor=`echo $1 | \
+            sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+    req_micro=`echo $1 | \
+            sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+    gpg_version=`$GPG --version | grep ^gpg`
+    major=`echo $gpg_version | \
+        sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+    minor=`echo $gpg_version | \
+        sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+    micro=`echo $gpg_version | \
+        sed 's/^gpg (GnuPG) \([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
+    GPG_VERSION=`echo $gpg_version | sed 's/^gpg (GnuPG) //'`
+
+    if test "$major" -gt "$req_major"; then
+      ok=yes
+    else
+      if test "$major" -eq "$req_major"; then
+        if test "$minor" -gt "$req_minor"; then
+          ok=yes
+        else
+          if test "$minor" -eq "$req_minor"; then
+            if test "$micro" -ge "$req_micro"; then
+              ok=yes
+         fi
+          fi
+        fi
+      fi
+    fi
+    if test "$ok" = "yes"; then
+      AC_MSG_RESULT(yes)
+      ifelse([$2], , :, [$2])
+    else
+      AC_MSG_RESULT(no)
+      AC_MSG_WARN([GnuPG must be at least version $1])
+      ifelse([$3], , :, [$3])
+    fi
+  fi
+  AM_CONDITIONAL(RUN_GPG_TESTS, test "$ok" = "yes")
+  AC_SUBST(GPG_PATH)])
\ No newline at end of file
index 5f13102..c871887 100644 (file)
@@ -9,5 +9,7 @@ AC_PATH_PACKAGEDIR
 
 AM_CONDITIONAL(XEMACS, test ${EMACS_FLAVOR} = xemacs)
 
+AC_PATH_GPG(1.4.3,,AC_MSG_ERROR([No suitable version of gpg]))
+
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT