summaryrefslogtreecommitdiffstats
path: root/SoftHSMv2/m4/acx_botan.m4
blob: ed93786c11fc490cdec21e977787fcf72b2dc0a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
AC_DEFUN([ACX_BOTAN],[
	AC_ARG_WITH(botan,
        	AC_HELP_STRING([--with-botan=PATH],[Specify prefix of path of Botan]),
		[
			BOTAN_PATH="$withval"
		],
		[
			BOTAN_PATH="/usr/local"
		])

	BOTAN_VERSION_MAJOR=2
	BOTAN_VERSION_MINOR=0
	AC_CHECK_FILE($BOTAN_PATH/include/botan-2/botan/version.h,
		      BOTAN_VERSION_MAJOR=2
		      BOTAN_VERSION_MINOR=0,
		      AC_CHECK_FILE($BOTAN_PATH/include/botan-1.11/botan/version.h,
				    BOTAN_VERSION_MAJOR=1
				    BOTAN_VERSION_MINOR=11,
				    AC_CHECK_FILE($BOTAN_PATH/include/botan-1.10/botan/version.h,
						  BOTAN_VERSION_MAJOR=1
						  BOTAN_VERSION_MINOR=10,
						  AC_MSG_ERROR([Cannot find Botan includes]))))
	AC_MSG_CHECKING(what are the Botan includes)
	if test "x${BOTAN_VERSION_MAJOR}" = "x2"; then
		BOTAN_INCLUDES="-I$BOTAN_PATH/include/botan-2"
	else
		BOTAN_INCLUDES="-I$BOTAN_PATH/include/botan-1.$BOTAN_VERSION_MINOR"
	fi
	AC_MSG_RESULT($BOTAN_INCLUDES)

	AC_MSG_CHECKING(what are the Botan libs)
	if test "x${BOTAN_VERSION_MAJOR}" = "x2"; then
		BOTAN_LIBS="-L$BOTAN_PATH/lib -lbotan-2"
	else
		BOTAN_LIBS="-L$BOTAN_PATH/lib -lbotan-1.$BOTAN_VERSION_MINOR"
	fi
	AC_MSG_RESULT($BOTAN_LIBS)

	if test "x${BOTAN_VERSION_MAJOR}" != "x1" -o "x${BOTAN_VERSION_MINOR}" != "x10"; then
		AX_CXX_COMPILE_STDCXX_11([noext],[mandatory])
	fi

	tmp_CPPFLAGS=$CPPFLAGS
	tmp_LIBS=$LIBS

	CPPFLAGS="$CPPFLAGS $BOTAN_INCLUDES"
	LIBS="$LIBS $BOTAN_LIBS"

	AC_LANG_PUSH([C++])
	AC_LINK_IFELSE(
		[AC_LANG_PROGRAM(
			[#include <botan/init.h>
			#include <botan/version.h>],
			[using namespace Botan;
			LibraryInitializer::initialize();
			#if BOTAN_VERSION_CODE < BOTAN_VERSION_CODE_FOR($1,$2,$3)
			#error "Botan version too old";
			#endif])],
		[AC_MSG_RESULT([checking for Botan >= v$1.$2.$3 ... yes])],
		[AC_MSG_RESULT([checking for Botan >= v$1.$2.$3 ... no])
		 AC_MSG_ERROR([Missing the correct version of the Botan library])]
	)
	AC_LANG_POP([C++])

	CPPFLAGS=$tmp_CPPFLAGS
	LIBS=$tmp_LIBS

	AC_SUBST(BOTAN_INCLUDES)
	AC_SUBST(BOTAN_LIBS)
	AC_SUBST(BOTAN_VERSION_MAJOR)
	AC_SUBST(BOTAN_VERSION_MINOR)
])