blob: f4f51fdf04148d5decbdc2be99ca0342897179e6 [file] [log] [blame]
Alexander Afanasyevc5bb2ad2014-01-06 16:03:34 -08001# SYNOPSIS
2#
3# AX_LIB_CRYPTOPP([ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
4#
5# DESCRIPTION
6#
7# Test for the Crypto++ library
8#
9# If no intallation prefix to the installed Crypto++ library is given the
10# macro searches under /usr, /usr/local, and /opt.
11#
12# This macro calls:
13#
14# AC_SUBST(CRYPTOPP_INCLUDES)
15# AC_SUBST(CRYPTOPP_LDFLAGS)
16# AC_SUBST(CRYPTOPP_LIBS)
17#
18# And sets:
19#
20# HAVE_CRYPTOPP
21
22AC_DEFUN([AX_LIB_CRYPTOPP],
23[
24 AC_ARG_WITH([cryptopp],
25 AS_HELP_STRING(
26 [--with-cryptopp=@<:@ARG@:>@],
27 [use Crypto++ library @<:@default=yes@:>@, optionally specify the prefix for the library]
28 ),
29 [
30 if test "$withval" = "no"; then
31 WANT_CRYPTOPP="no"
32 elif test "$withval" = "yes"; then
33 WANT_CRYPTOPP="yes"
34 ac_cryptopp_path=""
35 else
36 WANT_CRYPTOPP="yes"
37 ac_cryptopp_path="$withval"
38 fi
39 ],
40 [WANT_CRYPTOPP="yes"]
41 )
42
43 CRYPTOPP_CFLAGS=""
44 CRYPTOPP_LDFLAGS=""
45 CRYPTOPP_LIBS=""
46
47 if test "x$WANT_CRYPTOPP" = "xyes"; then
48
49 AC_MSG_CHECKING([for Crypto++ library])
50
51 ac_cryptopp_header="cryptopp/cryptlib.h"
52 ac_cryptopp_libs="-lcryptopp"
53
54 if test "$ac_cryptopp_path" != ""; then
55 ac_cryptopp_ldflags="-L$ac_cryptopp_path/lib"
56 ac_cryptopp_cppflags="-I$ac_cryptopp_path/include"
57 else
58 for ac_cryptopp_path_tmp in /usr /usr/local /opt ; do
59 if test -f "$ac_cryptopp_path_tmp/include/$ac_cryptopp_header" \
60 && test -r "$ac_cryptopp_path_tmp/include/$ac_cryptopp_header"; then
61 ac_cryptopp_path=$ac_cryptopp_path_tmp
62 ac_cryptopp_cppflags="-I$ac_cryptopp_path_tmp/include"
63 ac_cryptopp_ldflags="-L$ac_cryptopp_path_tmp/lib"
64 break;
65 fi
66 done
67 fi
68
69 CRYPTOPP_INCLUDES="$ac_cryptopp_cppflags"
70 CRYPTOPP_LDFLAGS="$ac_cryptopp_ldflags"
71 CRYPTOPP_LIBS="$ac_cryptopp_libs"
72
73 save_LIBS="$LIBS"
74 save_LDFLAGS="$LDFLAGS"
75 save_CPPFLAGS="$CPPFLAGS"
76
77 LDFLAGS="$LDFLAGS $CRYPTOPP_LDFLAGS"
78 LIBS="$CRYPTOPP_LIBS $LIBS"
79 CPPFLAGS="$CRYPTOPP_INCLUDES $CPPFLAGS"
80 AC_LANG_PUSH(C++)
81 AC_LINK_IFELSE(
82 [AC_LANG_PROGRAM([#include <cryptopp/cryptlib.h>], [])],
83 [
84 AC_MSG_RESULT([yes])
85 $1
86 ], [
87 AC_MSG_RESULT([no])
88 $2
89 ])
90 AC_LANG_POP([C++])
91 CPPFLAGS="$save_CPPFLAGS"
92 LDFLAGS="$save_LDFLAGS"
93 LIBS="$save_LIBS"
94
95 AC_SUBST(CRYPTOPP_INCLUDES)
96 AC_SUBST(CRYPTOPP_LDFLAGS)
97 AC_SUBST(CRYPTOPP_LIBS)
98
99 AC_DEFINE([HAVE_CRYPTOPP], [], [Have the Crypto++ library])
100 fi
101])