Fix bug inhibiting the use of the sentinel attribute.
[libgcrypt.git] / acinclude.m4
index d538210..0791b84 100644 (file)
@@ -1,6 +1,7 @@
 dnl macros to configure Libgcrypt
 dnl Copyright (C) 1998, 1999, 2000, 2001, 2002,
 dnl               2003 Free Software Foundation, Inc.
+dnl Copyright (C) 2013 g10 Code GmbH
 dnl
 dnl This file is part of Libgcrypt.
 dnl
@@ -18,13 +19,43 @@ dnl You should have received a copy of the GNU Lesser General Public
 dnl License along with this program; if not, write to the Free Software
 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
-dnl GNUPG_MSG_PRINT(STRING)
-dnl print a message
+dnl GCRY_MSG_SHOW(PREFIX,STRING)
+dnl Print a message with a prefix.
 dnl
-define([GNUPG_MSG_PRINT],
-  [ echo $ac_n "$1"" $ac_c" 1>&AS_MESSAGE_FD([])
+define([GCRY_MSG_SHOW],
+  [
+     echo "        $1 $2" 1>&AS_MESSAGE_FD([])
+  ])
+
+dnl GCRY_MSG_WRAP(PREFIX, ALGOLIST)
+dnl Print a nicely formatted list of algorithms
+dnl with an approriate line wrap.
+dnl
+define([GCRY_MSG_WRAP],
+  [
+    tmp="        $1"
+    tmpi="abc"
+    if test "${#tmpi}" -ne 3 >/dev/null 2>&1 ; then
+      dnl Without a POSIX shell, we don't botter to wrap it
+      echo "$tmp $2" 1>&AS_MESSAGE_FD([])
+    else
+      tmpi=`echo "$tmp"| sed 's/./ /g'`
+      echo $2 EOF | tr ' ' '\n' | \
+        while read word; do
+          if test "${#tmp}" -gt 70 ; then
+            echo "$tmp" 1>&AS_MESSAGE_FD([])
+            tmp="$tmpi"
+          fi
+          if test "$word" = "EOF" ; then
+            echo "$tmp" 1>&AS_MESSAGE_FD([])
+          else
+            tmp="$tmp $word"
+          fi
+        done
+    fi
   ])
 
+
 dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
 dnl Check whether a typedef exists and create a #define $2 if it exists
 dnl
@@ -69,13 +100,18 @@ AC_DEFUN([GNUPG_CHECK_GNUMAKE],
 # Taken from GnuPG 1.2 and modified to use the libtool macros.
 AC_DEFUN([GNUPG_SYS_SYMBOL_UNDERSCORE],
 [tmp_do_check="no"
-case "${target}" in
+case "${host}" in
+    *-mingw32*)
+        ac_cv_sys_symbol_underscore=yes
+        ;;
     i386-emx-os2 | i[3456]86-pc-os2*emx | i386-pc-msdosdjgpp)
         ac_cv_sys_symbol_underscore=yes
         ;;
     *)
       if test "$cross_compiling" = yes; then
-         ac_cv_sys_symbol_underscore=yes
+        if test "x$ac_cv_sys_symbol_underscore" = x ; then
+           ac_cv_sys_symbol_underscore=yes
+        fi
       else
          tmp_do_check="yes"
       fi
@@ -88,12 +124,12 @@ if test "$tmp_do_check" = "yes"; then
   [ac_cv_sys_symbol_underscore=no
    cat > conftest.$ac_ext <<EOF
       void nm_test_func(){}
-      int main(){nm_test_func;return 0;
+      int main(){nm_test_func;return 0;}
 EOF
   if AC_TRY_EVAL(ac_compile); then
     # Now try to grab the symbols.
     ac_nlist=conftest.nm
-    if AC_TRY_EVAL(NM conftest.$ac_objext \| $global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
+    if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \| cut -d \' \' -f 2 \> $ac_nlist) && test -s "$ac_nlist"; then
       # See whether the symbols have a leading underscore.
       if egrep '^_nm_test_func' "$ac_nlist" >/dev/null; then
         ac_cv_sys_symbol_underscore=yes
@@ -105,7 +141,7 @@ EOF
         fi
       fi
     else
-      echo "configure: cannot run $global_symbol_pipe" >&AC_FD_CC
+      echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AC_FD_CC
     fi
   else
     echo "configure: failed program was:" >&AC_FD_CC
@@ -147,18 +183,18 @@ define(GNUPG_CHECK_MLOCK,
                     #include <sys/mman.h>
                     #endif
                 ], [
-                    int i;
-                    
-                    /* glibc defines this for functions which it implements
                    * to always fail with ENOSYS.  Some functions are actually
                    * named something starting with __ and the normal name
                    * is an alias.  */
-                    #if defined (__stub_mlock) || defined (__stub___mlock)
-                    choke me
-                    #else
-                    mlock(&i, 4);
-                    #endif
-                    ; return 0;
+int i;
+
+/* glibc defines this for functions which it implements
+ * to always fail with ENOSYS.  Some functions are actually
+ * named something starting with __ and the normal name
+ * is an alias.  */
+#if defined (__stub_mlock) || defined (__stub___mlock)
+choke me
+#else
+mlock(&i, 4);
+#endif
+; return 0;
                 ],
                 gnupg_cv_mlock_is_in_sys_mman=yes,
                 gnupg_cv_mlock_is_in_sys_mman=no)])
@@ -169,33 +205,45 @@ define(GNUPG_CHECK_MLOCK,
         fi
     fi
     if test "$ac_cv_func_mlock" = "yes"; then
+        AC_CHECK_FUNCS(sysconf getpagesize)
         AC_MSG_CHECKING(whether mlock is broken)
           AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
              AC_TRY_RUN([
-                #include <stdlib.h>
-                #include <unistd.h>
-                #include <errno.h>
-                #include <sys/mman.h>
-                #include <sys/types.h>
-                #include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+int main()
+{
+    char *pool;
+    int err;
+    long int pgsize;
 
-                int main()
-                {
-                    char *pool;
-                    int err;
-                    long int pgsize = getpagesize();
+#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
+    pgsize = sysconf (_SC_PAGESIZE);
+#elif defined (HAVE_GETPAGESIZE)
+    pgsize = getpagesize();
+#else
+    pgsize = -1;
+#endif
 
-                    pool = malloc( 4096 + pgsize );
-                    if( !pool )
-                        return 2;
-                    pool += (pgsize - ((long int)pool % pgsize));
+    if (pgsize == -1)
+      pgsize = 4096;
 
-                    err = mlock( pool, 4096 );
-                    if( !err || errno == EPERM )
-                        return 0; /* okay */
+    pool = malloc( 4096 + pgsize );
+    if( !pool )
+        return 2;
+    pool += (pgsize - ((long int)pool % pgsize));
 
-                    return 1;  /* hmmm */
-                }
+    err = mlock( pool, 4096 );
+    if( !err || errno == EPERM )
+        return 0; /* okay */
+
+    return 1;  /* hmmm */
+}
 
             ],
             gnupg_cv_have_broken_mlock="no",
@@ -239,62 +287,6 @@ for n in $list; do
 done
 ])
 
-dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION,
-dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
-dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS
-dnl
-AC_DEFUN([AM_PATH_GPG_ERROR],
-[ AC_ARG_WITH(gpg-error-prefix,
-            AC_HELP_STRING([--with-gpg-error-prefix=PFX],
-                           [prefix where GPG Error is installed (optional)]),
-     gpg_error_config_prefix="$withval", gpg_error_config_prefix="")
-  if test x$gpg_error_config_prefix != x ; then
-     if test x${GPG_ERROR_CONFIG+set} != xset ; then
-        GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config
-     fi
-  fi
-
-  AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no)
-  min_gpg_error_version=ifelse([$1], ,0.0,$1)
-  AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
-  ok=no
-  if test "$GPG_ERROR_CONFIG" != "no" ; then
-    req_major=`echo $min_gpg_error_version | \
-               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
-    req_minor=`echo $min_gpg_error_version | \
-               sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
-    gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version`
-    if test "$gpg_error_config_version"; then
-      major=`echo $gpg_error_config_version | \
-                 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
-      minor=`echo $gpg_error_config_version | \
-                 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
-      if test "$major" -gt "$req_major"; then
-          ok=yes
-      else 
-          if test "$major" -eq "$req_major"; then
-              if test "$minor" -ge "$req_minor"; then
-                 ok=yes
-              fi
-          fi
-      fi
-    fi
-  fi
-  if test $ok = yes; then
-    GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
-    GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
-    AC_MSG_RESULT(yes)
-    ifelse([$2], , :, [$2])
-  else
-    GPG_ERROR_CFLAGS=""
-    GPG_ERROR_LIBS=""
-    AC_MSG_RESULT(no)
-    ifelse([$3], , :, [$3])
-  fi
-  AC_SUBST(GPG_ERROR_CFLAGS)
-  AC_SUBST(GPG_ERROR_LIBS)
-])
-
 
 dnl Check for socklen_t: historically on BSD it is an int, and in
 dnl POSIX 1g it is a type of its own, but some platforms use different
@@ -312,10 +304,10 @@ AC_DEFUN([TYPE_SOCKLEN_T],
          for arg2 in "struct sockaddr" void; do
             for t in int size_t unsigned long "unsigned long"; do
                AC_TRY_COMPILE([
-                  #include <sys/types.h>
-                  #include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/socket.h>
 
-                  int getpeername (int, $arg2 *, $t *);
+int getpeername (int, $arg2 *, $t *);
                ],[
                   $t len;
                   getpeername(0,0,&len);
@@ -339,7 +331,7 @@ AC_DEFUN([TYPE_SOCKLEN_T],
 
 
 # GNUPG_PTH_VERSION_CHECK(REQUIRED)
-# 
+#
 # If the version is sufficient, HAVE_PTH will be set to yes.
 #
 # Taken form the m4 macros which come with Pth
@@ -397,7 +389,5 @@ AC_DEFUN([GNUPG_PTH_VERSION_CHECK],
        AC_MSG_RESULT($gnupg_cv_pth_is_sane)
     else
        AC_MSG_RESULT(no)
-    fi    
+    fi
   ])
-
-