New protocol: PKCS#1 (rfc2313 pplus some extra oid's)
[obnox/wireshark/wip.git] / acinclude.m4
index 4f263ac2d7593cc84a7f16fb6f0df03a99066d22..0c425681a4227e937542daf84d95ce28c989ddcf 100644 (file)
@@ -2,7 +2,7 @@ dnl Macros that test for specific features.
 dnl This file is part of the Autoconf packaging for Ethereal.
 dnl Copyright (C) 1998-2000 by Gerald Combs.
 dnl
-dnl $Id: acinclude.m4,v 1.72 2004/04/22 20:02:58 obiot Exp $
+dnl $Id$
 dnl
 dnl This program is free software; you can redistribute it and/or modify
 dnl it under the terms of the GNU General Public License as published by
@@ -92,6 +92,49 @@ if test $ac_cv_ethereal_struct_sa_len = yes; then
 fi
 ])
 
+
+dnl
+dnl Check whether a given format can be used to print 64-bit integers
+dnl
+AC_DEFUN([AC_ETHEREAL_CHECK_64BIT_FORMAT],
+[
+  AC_MSG_CHECKING([whether %$1x can be used to format 64-bit integers])
+  AC_RUN_IFELSE(
+    [
+      AC_LANG_SOURCE(
+       [[
+#        ifdef HAVE_INTTYPES_H
+         #include <inttypes.h>
+#        endif
+         #include <glib.h>
+         #include <stdio.h>
+         #include <sys/types.h>
+
+         main()
+         {
+           guint64 t = 1;
+           char strbuf[16+1];
+           sprintf(strbuf, "%016$1x", t << 32);
+           if (strcmp(strbuf, "0000000100000000") == 0)
+             exit(0);
+           else
+             exit(1);
+         }
+       ]])
+    ],
+    [
+      AC_DEFINE(PRId64, "$1d", [Format for printing 64-bit signed decimal numbers])
+      AC_DEFINE(PRIo64, "$1o", [Format for printing 64-bit unsigned octal numbers])
+      AC_DEFINE(PRIx64, "$1x", [Format for printing 64-bit unsigned hexadecimal numbers])
+      AC_DEFINE(PRIu64, "$1u", [Format for printing 64-bit unsigned decimal numbers])
+      AC_MSG_RESULT(yes)
+    ],
+    [
+      AC_MSG_RESULT(no)
+      $2
+    ])
+])
+
 #
 # AC_ETHEREAL_IPV6_STACK
 #
@@ -689,23 +732,40 @@ AC_DEFUN([AC_ETHEREAL_UCDSNMP_CHECK],
                # needed after the library *and* to cache all that
                # information.
                #
+               ac_save_LIBS="$LIBS"
                for extras in "" "-L/usr/kerberos/lib -ldes425" "-lkstat"
                do
-                       AC_CHECK_LIB(snmp, sprint_realloc_objid,
-                         [
-                               SNMP_LIBS="-lsnmp $extras"; break
-                         ],
-                         [
-                               #
-                               # Throw away the cached "we didn't find it"
-                               # answer, so that if we rerun "configure",
-                               # we still do all these checks and don't
-                               # just blithely assume we don't need
-                               # the extra libraries.
-                               #
-                               unset ac_cv_lib_snmp_sprint_realloc_objid
-                         ], $SOCKET_LIBS $NSL_LIBS $SSL_LIBS $extras)
+                       LIBS="-lsnmp $extras $SOCKET_LIBS $NSL_LIBS $SSL_LIBS"
+                       AC_TRY_LINK(
+                       [
+                       ],
+                       [
+                       sprint_realloc_objid();
+                       ],
+                       [
+                       SNMP_LIBS="-lsnmp $extras"; break;
+                       ],
+                       [
+                       ])
+                       
+#        int sprint_realloc_objid(u_char **buf, size_t *buf_len, size_t *out_len, int allow_realloc, const oid *objid, size_t objidlen);
+#        AC_TRY_LINK(includes, body, [if-found], [if-not-found])
+#                      AC_CHECK_LIB(snmp, sprint_realloc_objid,
+#                        [
+#                              SNMP_LIBS="-lsnmp $extras"; break
+#                        ],
+#                        [
+#                              #
+#                              # Throw away the cached "we didn't find it"
+#                              # answer, so that if we rerun "configure",
+#                              # we still do all these checks and don't
+#                              # just blithely assume we don't need
+#                              # the extra libraries.
+#                              #
+#                              unset ac_cv_lib_snmp_sprint_realloc_objid
+#                        ], $SOCKET_LIBS $NSL_LIBS $SSL_LIBS $extras)
                done
+               LIBS=$ac_save_LIBS
 
                #
                # If we didn't find "sprint_realloc_objid()", fail.
@@ -739,11 +799,11 @@ AC_DEFUN([AC_ETHEREAL_UCDSNMP_CHECK],
 #
 AC_DEFUN([AC_ETHEREAL_SSL_CHECK],
 [
-       want_ssl=defaultyes
+       want_ssl=defaultno
 
        AC_ARG_WITH(ssl,
 changequote(<<, >>)dnl
-<<  --with-ssl[=DIR]        use SSL crypto library (located in directory DIR, if supplied).   [default=yes, if present]>>,
+<<  --with-ssl[=DIR]        use SSL crypto library (located in directory DIR, if supplied).   [default=no]>>,
 changequote([, ])dnl
        [
        if   test "x$withval" = "xno";  then
@@ -765,11 +825,23 @@ changequote([, ])dnl
        fi
 
        if test "x$want_ssl" = "xyes"; then
-               AC_CHECK_LIB(crypto, EVP_md5,
-                 [
-                   SSL_LIBS=-lcrypto
-                 ],,
-               )
+           LIBS="-lcrypto"
+            AC_TRY_LINK(
+                [
+               void EVP_md5();
+                ],
+                [
+               EVP_md5();
+                ],
+                [
+               AC_MSG_RESULT([yes])
+               SSL_LIBS=-lcrypto
+                ],
+                [
+                AC_MSG_RESULT([no])
+                AC_MSG_ERROR([libcrypto failed link test.])
+                ])
+
        else
                AC_MSG_RESULT(not required)
        fi
@@ -878,18 +950,19 @@ AC_DEFUN([AC_ETHEREAL_KRB5_CHECK],
          CFLAGS="$CFLAGS -I$krb5_dir/include"
          ethereal_save_CPPFLAGS="$CPPFLAGS"
          CPPFLAGS="$CPPFLAGS -I$krb5_dir/include"
-         ethereal_save_LIBS="$LIBS"
-         LIBS="$LIBS -lkrb5 -lasn1 -lcrypto -lroken -lcrypt -lresolv"
+         KRB5_LIBS="-lkrb5 -lasn1 $SSL_LIBS -lroken -lcrypt -lresolv"
          ethereal_save_LDFLAGS="$LDFLAGS"
          LDFLAGS="$LDFLAGS -L$krb5_dir/lib"
+         ac_krb5_version=`grep -i heimdal $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*heimdal.*$/HEIMDAL/i'` 
        else
          AC_PATH_PROG(KRB5_CONFIG, krb5-config) 
-         if test -x $KRB5_CONFIG
+         if test -x "$KRB5_CONFIG"
          then
-           KRB5_FLAGS=`$KRB5_CONFIG --cflags`
+           KRB5_FLAGS=`"$KRB5_CONFIG" --cflags`
            CFLAGS="$CFLAGS $KRB5_FLAGS"
             CPPFLAGS="$CPPFLAGS $KRB5_FLAGS"
-           KRB5_LIBS=`$KRB5_CONFIG --libs`
+           KRB5_LIBS=`"$KRB5_CONFIG" --libs | sed 's/-lcrypto//'`
+           KRB5_LIBS="$KRB5_LIBS $SSL_LIBS"
            # Looks like krb5-config is lacking -lresolv on some systems
            AC_MSG_CHECKING(whether library list looks OK)
            if echo "$KRB5_LIBS" | grep resolv >/dev/null
@@ -900,8 +973,8 @@ AC_DEFUN([AC_ETHEREAL_KRB5_CHECK],
                AC_MSG_RESULT(Adding -lresolv to libs)
            fi
 
-           LIBS="$LIBS $KRB5_LIBS"
-           ac_krb5_version=`$KRB5_CONFIG --version | head -n 1 | sed 's/^.*heimdal.*$/HEIMDAL/i'`
+           #LIBS="$LIBS $KRB5_LIBS"
+           ac_krb5_version=`"$KRB5_CONFIG" --version | head -n 1 | sed 's/^.*heimdal.*$/HEIMDAL/i'`
          fi
        fi
 
@@ -949,7 +1022,7 @@ AC_DEFUN([AC_ETHEREAL_KRB5_CHECK],
                        if test "x$krb5_dir" != "x"
                        then
                                #
-                               # Put the "-I" and "-L" flags for pcre at
+                               # Put the "-I" and "-L" flags for krb5 at
                                # the beginning of CFLAGS, CPPFLAGS,
                                # LDFLAGS, and LIBS.
                                #
@@ -969,14 +1042,15 @@ AC_DEFUN([AC_ETHEREAL_KRB5_CHECK],
                                CFLAGS="$ethereal_save_CFLAGS"
                                CPPFLAGS="$ethereal_save_CPPFLAGS"
                                LDFLAGS="$ethereal_save_LDFLAGS"
-                               LIBS="$ethereal_save_LIBS"
+                               #LIBS="$ethereal_save_LIBS"
                                KRB5_LIBS=""
                        fi
                        want_krb5=no
-               ])
-               AC_SUBST(KRB5_LIBS)
+               ], $KRB5_LIBS)
        else
+               KRB5_LIBS=""
                want_krb5=no
        fi
+       AC_SUBST(KRB5_LIBS)
 ])