1# LIBSSH2_CHECK_CONFIG ([DEFAULT-ACTION]) 2# ---------------------------------------------------------- 3# Alexander Vladishev Oct-26-2009 4# Dmitry Borovikov Feb-13-2010 5# --version control added (1.0.0) 6# 7# Checks for ssh2. DEFAULT-ACTION is the string yes or no to 8# specify whether to default to --with-ssh2 or --without-ssh2. 9# If not supplied, DEFAULT-ACTION is no. 10# 11# The minimal supported SSH2 library version is 1.0.0. 12# 13# This macro #defines HAVE_SSH2 if a required header files are 14# found, and sets @SSH2_LDFLAGS@, @SSH2_CFLAGS@ and @SSH2_LIBS@ 15# to the necessary values. 16# 17# Users may override the detected values by doing something like: 18# SSH2_LIBS="-lssh2" SSH2_CFLAGS="-I/usr/myinclude" ./configure 19# 20# This macro is distributed in the hope that it will be useful, 21# but WITHOUT ANY WARRANTY; without even the implied warranty of 22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 23 24AC_DEFUN([LIBSSH2_TRY_LINK], 25[ 26AC_TRY_LINK( 27[ 28#include <libssh2.h> 29], 30[ 31 LIBSSH2_SESSION *session; 32 session = libssh2_session_init(); 33], 34found_ssh2="yes",) 35])dnl 36 37AC_DEFUN([LIBSSH2_ACCEPT_VERSION], 38[ 39 # Zabbix minimal major supported version of libssh2: 40 minimal_libssh2_major_version=1 41 42 # get the major version 43 found_ssh2_version_major=`cat $1 | $EGREP \#define.*LIBSSH2_VERSION_MAJOR | $AWK '{print @S|@3;}'` 44 45 accept_ssh2_version="no" 46 47 if test $found_ssh2_version_major -ge $minimal_libssh2_major_version; then 48 accept_ssh2_version="yes" 49 fi; 50])dnl 51 52AC_DEFUN([LIBSSH2_CHECK_CONFIG], 53[ 54 AC_ARG_WITH(ssh2,[If you want to use SSH2 based checks: 55AC_HELP_STRING([--with-ssh2@<:@=DIR@:>@],[use SSH2 package @<:@default=no@:>@, DIR is the SSH2 library install directory.])], 56 [ 57 if test "$withval" = "no"; then 58 want_ssh2="no" 59 _libssh2_dir="no" 60 elif test "$withval" = "yes"; then 61 want_ssh2="yes" 62 _libssh2_dir="no" 63 else 64 want_ssh2="yes" 65 _libssh2_dir=$withval 66 fi 67 accept_ssh2_version="no" 68 ],[want_ssh2=ifelse([$1],,[no],[$1])] 69 ) 70 71 if test "x$want_ssh2" = "xyes"; then 72 AC_MSG_CHECKING(for SSH2 support) 73 if test "x$_libssh2_dir" = "xno"; then 74 if test -f /usr/include/libssh2.h; then 75 SSH2_CFLAGS=-I/usr/include 76 SSH2_LDFLAGS=-L/usr/lib 77 SSH2_LIBS="-lssh2" 78 found_ssh2="yes" 79 LIBSSH2_ACCEPT_VERSION([/usr/include/libssh2.h]) 80 elif test -f /usr/local/include/libssh2.h; then 81 SSH2_CFLAGS=-I/usr/local/include 82 SSH2_LDFLAGS=-L/usr/local/lib 83 SSH2_LIBS="-lssh2" 84 found_ssh2="yes" 85 LIBSSH2_ACCEPT_VERSION([/usr/local/include/libssh2.h]) 86 else #libraries are not found in default directories 87 found_ssh2="no" 88 AC_MSG_RESULT(no) 89 fi # test -f /usr/include/libssh2.h; then 90 else # test "x$_libssh2_dir" = "xno"; then 91 if test -f $_libssh2_dir/include/libssh2.h; then 92 SSH2_CFLAGS=-I$_libssh2_dir/include 93 SSH2_LDFLAGS=-L$_libssh2_dir/lib 94 SSH2_LIBS="-lssh2" 95 found_ssh2="yes" 96 LIBSSH2_ACCEPT_VERSION([$_libssh2_dir/include/libssh2.h]) 97 else #if test -f $_libssh2_dir/include/libssh2.h; then 98 found_ssh2="no" 99 AC_MSG_RESULT(no) 100 fi #test -f $_libssh2_dir/include/libssh2.h; then 101 fi #if test "x$_libssh2_dir" = "xno"; then 102 fi # if test "x$want_ssh2" != "xno"; then 103 104 if test "x$found_ssh2" = "xyes"; then 105 am_save_cflags="$CFLAGS" 106 am_save_ldflags="$LDFLAGS" 107 am_save_libs="$LIBS" 108 109 CFLAGS="$CFLAGS $SSH2_CFLAGS" 110 LDFLAGS="$LDFLAGS $SSH2_LDFLAGS" 111 LIBS="$LIBS $SSH2_LIBS" 112 113 found_ssh2="no" 114 LIBSSH2_TRY_LINK([no]) 115 116 CFLAGS="$am_save_cflags" 117 LDFLAGS="$am_save_ldflags" 118 LIBS="$am_save_libs" 119 120 if test "x$found_ssh2" = "xyes"; then 121 AC_DEFINE([HAVE_SSH2], 1, [Define to 1 if you have the 'libssh2' library (-lssh2)]) 122 AC_MSG_RESULT(yes) 123 else 124 AC_MSG_RESULT(no) 125 SSH2_CFLAGS="" 126 SSH2_LDFLAGS="" 127 SSH2_LIBS="" 128 fi 129 fi 130 131 AC_SUBST(SSH2_CFLAGS) 132 AC_SUBST(SSH2_LDFLAGS) 133 AC_SUBST(SSH2_LIBS) 134 135])dnl 136