1# SPDX-License-Identifier: FSFAP
2#
3# ===========================================================================
4#      https://gitlab.isc.org/isc-projects/autoconf-archive/ax_lib_lmdb.html
5# ===========================================================================
6#
7# SYNOPSIS
8#
9#   AX_LIB_LMDB(PATH[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
10#
11# DESCRIPTION
12#
13#   Test for the LMDB library in a path
14#
15#   This macro takes only one argument, a path to the lmdb headers and library.
16#
17# LICENSE
18#
19#   Copyright (c) 2020 Internet Systems Consortium
20#
21#   Copying and distribution of this file, with or without modification, are
22#   permitted in any medium without royalty provided the copyright notice
23#   and this notice are preserved. This file is offered as-is, without any
24#   warranty.
25
26#serial 19
27
28#
29AC_DEFUN([AX_LIB_LMDB],
30	 [AS_IF([test -z "$1"],
31		[AC_MSG_ERROR([Path cannot be empty])])
32	  AC_MSG_CHECKING([for lmdb header in $1])
33	  AS_IF([test -r "$1/include/lmdb.h"],
34		[AC_MSG_RESULT([yes])
35		 LMDB_CFLAGS="-I$1/include"
36		 LMDB_LIBS="-L$1/lib"
37		 AX_SAVE_FLAGS([lmdb])
38		 CFLAGS="$CFLAGS $LMDB_CFLAGS"
39		 LIBS="$LIBS $LMDB_LIBS"
40		 AC_SEARCH_LIBS([mdb_env_create], [lmdb],
41				[LMDB_LIBS="$LMDB_LIBS $ac_cv_search_mdb_env_create"
42				 AX_RESTORE_FLAGS([lmdb])
43				 $2
44				],
45				[AC_MSG_RESULT([no])
46				 LMDB_CFLAGS=""
47				 LMDB_LIBS=""
48				 AX_RESTORE_FLAGS([lmdb])
49				 $3
50				])
51		],
52		[AC_MSG_RESULT([no])])])
53