Renamed
[gnupg.git] / acinclude.m4
index f6bbae7..b8af932 100644 (file)
@@ -20,7 +20,7 @@ dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
 dnl Check whether a typedef exists and create a #define $2 if it exists
 dnl
-AC_DEFUN(GNUPG_CHECK_TYPEDEF,
+AC_DEFUN([GNUPG_CHECK_TYPEDEF],
   [ AC_MSG_CHECKING(for $1 typedef)
     AC_CACHE_VAL(gnupg_cv_typedef_$1,
     [AC_TRY_COMPILE([#define _GNU_SOURCE 1
@@ -38,7 +38,7 @@ AC_DEFUN(GNUPG_CHECK_TYPEDEF,
 
 dnl GNUPG_CHECK_GNUMAKE
 dnl
-AC_DEFUN(GNUPG_CHECK_GNUMAKE,
+AC_DEFUN([GNUPG_CHECK_GNUMAKE],
   [ 
     if ${MAKE-make} --version 2>/dev/null | grep '^GNU ' >/dev/null 2>&1; then
         :
@@ -55,7 +55,7 @@ AC_DEFUN(GNUPG_CHECK_GNUMAKE,
 
 dnl GNUPG_CHECK_FAQPROG
 dnl
-AC_DEFUN(GNUPG_CHECK_FAQPROG,
+AC_DEFUN([GNUPG_CHECK_FAQPROG],
   [ AC_MSG_CHECKING(for faqprog.pl)
     if faqprog.pl -V 2>/dev/null | grep '^faqprog.pl ' >/dev/null 2>&1; then
         working_faqprog=yes
@@ -82,7 +82,7 @@ dnl     fi
 
 dnl GNUPG_CHECK_DOCBOOK_TO_TEXI
 dnl
-AC_DEFUN(GNUPG_CHECK_DOCBOOK_TO_TEXI,
+AC_DEFUN([GNUPG_CHECK_DOCBOOK_TO_TEXI],
   [
     AC_CHECK_PROG(DOCBOOK_TO_TEXI, docbook2texi, yes, no)
     AC_MSG_CHECKING(for sgml to texi tools)
@@ -101,7 +101,7 @@ AC_DEFUN(GNUPG_CHECK_DOCBOOK_TO_TEXI,
 dnl GNUPG_CHECK_ENDIAN
 dnl define either LITTLE_ENDIAN_HOST or BIG_ENDIAN_HOST
 dnl
-define(GNUPG_CHECK_ENDIAN,
+AC_DEFUN([GNUPG_CHECK_ENDIAN],
   [
     tmp_assumed_endian=big
     if test "$cross_compiling" = yes; then
@@ -158,7 +158,7 @@ define(GNUPG_CHECK_ENDIAN,
 
 
 # Check for the getsockopt SO_PEERCRED
-AC_DEFUN(GNUPG_SYS_SO_PEERCRED,
+AC_DEFUN([GNUPG_SYS_SO_PEERCRED],
   [ AC_MSG_CHECKING(for SO_PEERCRED)
     AC_CACHE_VAL(gnupg_cv_sys_so_peercred,
       [AC_TRY_COMPILE([#include <sys/socket.h>], 
@@ -183,7 +183,7 @@ AC_DEFUN(GNUPG_SYS_SO_PEERCRED,
 # either be "yes" or "no" and decided on the default value for
 # build_NAME and whether --enable-NAME or --disable-NAME is shown with 
 # ./configure --help
-AC_DEFUN(GNUPG_BUILD_PROGRAM,
+AC_DEFUN([GNUPG_BUILD_PROGRAM],
   [build_$1=$2
    m4_if([$2],[yes],[
       AC_ARG_ENABLE([$1], AC_HELP_STRING([--disable-$1],
@@ -210,10 +210,12 @@ AC_DEFUN(GNUPG_BUILD_PROGRAM,
 # If the version is sufficient, HAVE_PTH will be set to yes.
 #
 # Taken form the m4 macros which come with Pth
-AC_DEFUN(GNUPG_PTH_VERSION_CHECK,
+AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
   [
     _pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'`
     _req_version="ifelse([$1],,1.2.0,$1)"
+
+    AC_MSG_CHECKING(for PTH - version >= $_req_version)
     for _var in _pth_version _req_version; do
         eval "_val=\"\$${_var}\""
         _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
@@ -237,23 +239,44 @@ AC_DEFUN(GNUPG_PTH_VERSION_CHECK,
             fi
         fi
     fi
-    if test $have_pth = no; then
-       AC_MSG_WARN([[
-***
-*** Found Pth version $_pth_version, but require at least
-*** version $_req_version.  Please upgrade Pth first.
-***]])
+    if test $have_pth = yes; then
+       AC_MSG_RESULT(yes)
+       AC_MSG_CHECKING([whether PTH installation is sane])
+       AC_CACHE_VAL(gnupg_cv_pth_is_sane,[
+         _gnupg_pth_save_cflags=$CFLAGS
+         _gnupg_pth_save_ldflags=$LDFLAGS
+         _gnupg_pth_save_libs=$LIBS
+         CFLAGS="$CFLAGS `$PTH_CONFIG --cflags`"
+         LDFLAGS="$LDFLAGS `$PTH_CONFIG --ldflags`"
+         LIBS="$LIBS `$PTH_CONFIG --libs`"
+         AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pth.h>
+                                         ],
+                                         [[ pth_init ();]])],
+                        gnupg_cv_pth_is_sane=yes,
+                        gnupg_cv_pth_is_sane=no)
+         CFLAGS=$_gnupg_pth_save_cflags
+         LDFLAGS=$_gnupg_pth_save_ldflags
+         LIBS=$_gnupg_pth_save_libs
+       ])
+       if test $gnupg_cv_pth_is_sane != yes; then
+          have_pth=no
+       fi
+       AC_MSG_RESULT($gnupg_cv_pth_is_sane)
+    else
+       AC_MSG_RESULT(no)
     fi    
   ])
 
 
+
+
 # Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
 # is not called from uid 0 (not tested whether uid 0 works)
 # For DECs Tru64 we have also to check whether mlock is in librt
 # mlock is there a macro using memlk()
 dnl GNUPG_CHECK_MLOCK
 dnl
-define(GNUPG_CHECK_MLOCK,
+AC_DEFUN([GNUPG_CHECK_MLOCK],
   [ AC_CHECK_FUNCS(mlock)
     if test "$ac_cv_func_mlock" = "no"; then
         AC_CHECK_HEADERS(sys/mman.h)
@@ -343,7 +366,7 @@ define(GNUPG_CHECK_MLOCK,
 dnl Stolen from gcc
 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
 dnl of the usual 2.
-AC_DEFUN(GNUPG_FUNC_MKDIR_TAKES_ONE_ARG,
+AC_DEFUN([GNUPG_FUNC_MKDIR_TAKES_ONE_ARG],
 [AC_CHECK_HEADERS(sys/stat.h unistd.h direct.h)
 AC_CACHE_CHECK([if mkdir takes one argument], gnupg_cv_mkdir_takes_one_arg,
 [AC_TRY_COMPILE([
@@ -367,70 +390,3 @@ fi
 
 
 
-dnl AM_PATH_OPENSC([MINIMUM-VERSION,
-dnl               [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
-dnl Test for OpenSC and define OPENSC_CFLAGS and OPENSC_LIBS
-dnl
-AC_DEFUN(AM_PATH_OPENSC,
-[ AC_ARG_WITH(opensc-prefix,
-            AC_HELP_STRING([--with-opensc-prefix=PFX],
-                           [prefix where OpenSC is installed (optional)]),
-     opensc_config_prefix="$withval", opensc_config_prefix="")
-  if test x$opensc_config_prefix != x ; then
-     opensc_config_args="$opensc_config_args --prefix=$opensc_config_prefix"
-     if test x${OPENSC_CONFIG+set} != xset ; then
-        OPENSC_CONFIG=$opensc_config_prefix/bin/opensc-config
-     fi
-  fi
-
-  AC_PATH_PROG(OPENSC_CONFIG, opensc-config, no)
-  min_opensc_version=ifelse([$1], ,0.7.0,$1)
-  AC_MSG_CHECKING(for OpenSC - version >= $min_opensc_version)
-  ok=no
-  if test "$OPENSC_CONFIG" != "no" ; then
-    req_major=`echo $min_opensc_version | \
-               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
-    req_minor=`echo $min_opensc_version | \
-               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
-    req_micro=`echo $min_opensc_version | \
-               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
-    opensc_config_version=`$OPENSC_CONFIG $opensc_config_args --version 2>/dev/null || echo 0.0.0`
-    major=`echo $opensc_config_version | \
-               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
-    minor=`echo $opensc_config_version | \
-               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
-    micro=`echo $opensc_config_version | \
-               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
-    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
-  fi
-  if test $ok = yes; then
-    OPENSC_CFLAGS=`$OPENSC_CONFIG $opensc_config_args --cflags`
-    OPENSC_LIBS=`$OPENSC_CONFIG $opensc_config_args --libs`
-    OPENSC_LIBS="$OPENSC_LIBS -lpcsclite -lpthread"
-    AC_MSG_RESULT(yes)
-    ifelse([$2], , :, [$2])
-  else
-    OPENSC_CFLAGS=""
-    OPENSC_LIBS=""
-    AC_MSG_RESULT(no)
-    ifelse([$3], , :, [$3])
-  fi
-  AC_SUBST(OPENSC_CFLAGS)
-  AC_SUBST(OPENSC_LIBS)
-])
-
-