1 dnl Run this if we are using the bundled hcrypto for everything
2 AC_DEFUN([_OPENAFS_HCRYPTO_INTERNAL], [
4 LDFLAGS_hcrypto="-L\$(TOP_LIBDIR)"
5 LIB_hcrypto="-lafshcrypto"
6 hcrypto_all_target="all-internal"
7 hcrypto_install_target="install-internal"
10 dnl _OPENAFS_HCRYPTO_PATHS()
11 dnl Set LDFLAGS_hcrypto and LIB_hcrypto based on the values of hcrypto_root,
12 dnl hcrypto_libdir, and hcrypto_includedir
13 AC_DEFUN([_OPENAFS_HCRYPTO_PATHS], [
14 AS_IF([test x"$hcrypto_libdir" != x],
15 [LDFLAGS_hcrypto="-L$hcrypto_libdir"],
16 [AS_IF([test x"$hcrypto_root" != x],
17 [LDFLAGS_hcrypto="-L$hcrypto_root/lib"])])
18 AS_IF([test x"$hcrypto_includedir" != x],
19 [CPPFLAGS_hcrypto="-I$hcrypto_includedir -I$hcrypto_includedir/hcrypto"],
20 [AS_IF([test x"$hcrypto_root" != x],
21 [CPPFLAGS_hcrypto="-I$hcrypto_root/include -I$hcrypto_root/include/hcrypto"])])
22 LIB_hcrypto="-lhcrypto"
23 hcrypto_all_target="all-lwp"
24 hcrypto_install_target=
28 dnl _OPENAFS_HCRYPTO_CHECK($action-if-found,
29 dnl $action-if-not-found)
30 dnl Find an hcrypto library using $hcrypto_root, $hcrypto_libdir, and
31 dnl $hcrypto_includedir (global variables)
33 dnl If no paths were given and no usable hcrypto is found in the standard
34 dnl search paths, fall back to the built-in one. Otherwise, if no usable
35 dnl hcrypto is found, bail out.
36 AC_DEFUN([_OPENAFS_HCRYPTO_CHECK], [
38 _OPENAFS_HCRYPTO_PATHS()
39 save_CPPFLAGS=$CPPFLAGS
42 AS_IF([test x"$CPPFLAGS_hcrypto" != x],
43 [CPPFLAGS="$CPPFLAGS_hcrypto $CPPFLAGS"])
44 AS_IF([test x"$LDFLAGS_hcrypto" != x],
45 [LDFLAGS="$LDFLAGS_hcrypto $LDFLAGS"])
46 AS_IF([test x"$LIB_hcrypto" != x],
47 [LIBS="$LIB_hcrypto $LIBS"])
48 AS_IF([test x"$hcrypto_libdir" != x || test x"$hcrypto_includedir" != x],
49 [checkstr=" with specified include and lib paths"],
50 [AS_IF([test x"$hcrypto_root" != x],
51 [checkstr=" in $hcrypto_root"])])
53 AC_MSG_CHECKING([for usable system libhcrypto$checkstr])
55 dnl Could probably be more clever about what to check for here, but
56 dnl what we need from hcrypto should be pretty stable.
59 [[#include <sys/types.h>
64 HMAC_Init_ex(NULL, NULL, 0, NULL, NULL);
65 RAND_bytes(NULL, 0);]])],
67 AC_MSG_RESULT([yes])],
68 [AC_MSG_RESULT([no])])
70 CPPFLAGS=$save_CPPFLAGS
74 AS_IF([test x"$hcrypto_found" = xtrue],
78 AC_DEFUN([OPENAFS_HCRYPTO], [
79 AC_SUBST(CPPFLAGS_hcrypto)
80 AC_SUBST(LDFLAGS_hcrypto)
82 AC_SUBST(hcrypto_all_target)
83 AC_SUBST(hcrypto_install_target)
85 AC_ARG_WITH([hcrypto],
86 [AC_HELP_STRING([--with-hcrypto=DIR],
87 [Location of the hcrypto library, or 'internal'])],
88 [AS_IF([test x"$withval" = xno],
89 [AC_ERROR("OpenAFS requires hcrypto to build")],
90 [AS_IF([test x"$withval" != xyes],
91 [hcrypto_root="$withval"])])]
93 AC_ARG_WITH([hcrypto-include],
94 [AC_HELP_STRING([--with-hcrypto-include=DIR],
95 [Location of hcrypto headers])],
96 [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
97 [hcrypto_includedir=$withval])])
98 AC_ARG_WITH([hcrypto-lib],
99 [AC_HELP_STRING([--with-hcrypto-lib=DIR],
100 [Location of the hcrypto library])],
101 [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
102 [hcrypto_libdir=$withval])])
104 AS_IF([test x"$hcrypto_root" = xinternal],
105 [_OPENAFS_HCRYPTO_INTERNAL()],
106 [AS_IF([test x"$hcrypto_root" = x && test x"$hcrypto_libdir" = x &&
107 test x"$hcrypto_includedir" = x],
108 [_OPENAFS_HCRYPTO_CHECK([], [_OPENAFS_HCRYPTO_INTERNAL])],
109 [_OPENAFS_HCRYPTO_CHECK([],
110 [AC_MSG_ERROR([Cannot find hcrypto at that location])])]