1dnl RACOON_PATH_LIBS(FUNCTION, LIB, SEARCH-PATHS [, ACTION-IF-FOUND 2dnl [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]]) 3dnl Search for a library defining FUNC, if it's not already available. 4 5AC_DEFUN(RACOON_PATH_LIBS, 6[AC_PREREQ([2.13]) 7AC_CACHE_CHECK([for $2 containing $1], [ac_cv_search_$1], 8[ac_func_search_save_LIBS="$LIBS" 9ac_cv_search_$1="no" 10AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"], 11 [LIBS="-l$2 $LIBS" 12 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="-l$2"], [])]) 13LIBS="$ac_func_search_save_LIBS" 14test "$ac_cv_search_$1" = "no" && for i in $3; do 15LIBS="-L$i -l$2 $ac_func_search_save_LIBS" 16AC_TRY_LINK_FUNC([$1], 17[ac_cv_search_$1="-L$i -l$2" 18break]) 19done 20LIBS="$ac_func_search_save_LIBS"]) 21if test "$ac_cv_search_$1" != "no"; then 22 test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS" 23 $4 24else : 25 $5 26fi]) 27 28AC_DEFUN(RACOON_SEARCH_HEADER, 29[AC_PREREQ([2.13]) 30AC_MSG_CHECKING(for $1) 31AC_TRY_CPP([#include <$1>], [], [ 32ac_func_search_save_CPPFLAGS="$CPPFLAGS" 33ac_add_path="no" 34for i in $2; do 35 CPPFLAGS="-I$i $CPPFLAGS" 36 AC_TRY_CPP([#include <$1>], 37 [ac_add_path=$i]) 38 CPPFLAGS="$ac_func_search_save_CPPFLAGS" 39 if test "$ac_add_path" != "no"; then 40 break 41 fi 42done 43if test "$ac_add_path" != "no"; then 44 CPPFLAGS="-I$ac_add_path $CPPFLAGS" 45fi 46AC_MSG_RESULT($ac_add_path) 47])]) 48 49dnl 50dnl openssl 0.94 or higher recommends user to include header files as 51dnl openssl/foo.h, not foo.h with -Ipath/openssl. 52dnl RACOON_SEARCH_OPENSSL copes with this. 53dnl 54AC_DEFUN(RACOON_SEARCH_OPENSSL, 55[AC_PREREQ([2.13]) 56AC_MSG_CHECKING(for openssl include path) 57AC_TRY_CPP([#include <openssl/opensslv.h>], 58 [AC_EGREP_CPP(yes, [#include <openssl/opensslv.h> 59#if OPENSSL_VERSION_NUMBER >= 0x00904100L 60yes 61#endif], [include_path_openssl=yes])], [ 62ac_func_search_save_CPPFLAGS="$CPPFLAGS" 63ac_add_path="no" 64for i in $1; do 65 CPPFLAGS="-I$i $CPPFLAGS" 66 AC_TRY_CPP([#include <openssl/opensslv.h>], 67 [AC_EGREP_CPP(yes, [#include <openssl/opensslv.h> 68#if OPENSSL_VERSION_NUMBER >= 0x00904100L 69yes 70#endif], [ac_add_path=$i])]) 71 CPPFLAGS="$ac_func_search_save_CPPFLAGS" 72 if test "$ac_add_path" != "no"; then 73 break 74 fi 75done 76if test "$ac_add_path" != "no"; then 77 CPPFLAGS="-I$ac_add_path $CPPFLAGS" 78 include_path_openssl=yes 79fi 80]) 81if test "x$include_path_openssl" = "xyes"; then 82 AC_MSG_RESULT(include path needs openssl) 83 AC_DEFINE(INCLUDE_PATH_OPENSSL) 84else 85 AC_MSG_RESULT(pre-0.94 include path) 86fi 87]) 88