1# AC_PREREQ(2.57) 2AC_INIT(libssh2, [-], libssh2-devel@cool.haxx.se) 3AC_CONFIG_MACRO_DIR([m4]) 4AC_CONFIG_SRCDIR([src]) 5AC_CONFIG_HEADERS([src/libssh2_config.h]) 6AM_MAINTAINER_MODE 7m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 8 9dnl SED is needed by some of the tools 10AC_PATH_PROG( SED, sed, sed-was-not-found-by-configure, 11 $PATH:/usr/bin:/usr/local/bin) 12AC_SUBST(SED) 13 14if test "x$SED" = "xsed-was-not-found-by-configure"; then 15 AC_MSG_WARN([sed was not found, this may ruin your chances to build fine]) 16fi 17 18dnl figure out the libssh2 version 19LIBSSH2VER=`$SED -ne 's/^#define LIBSSH2_VERSION *"\(.*\)"/\1/p' ${srcdir}/include/libssh2.h` 20AM_INIT_AUTOMAKE 21AC_MSG_CHECKING([libssh2 version]) 22AC_MSG_RESULT($LIBSSH2VER) 23 24AC_SUBST(LIBSSH2VER) 25 26AB_VERSION=$LIBSSH2VER 27 28AB_INIT 29 30# Check for the OS. 31# Daniel's note: this should not be necessary and we need to work to 32# get this removed. 33AC_CANONICAL_HOST 34case "$host" in 35 *-mingw*) 36 CFLAGS="$CFLAGS -DLIBSSH2_WIN32" 37 LIBS="$LIBS -lws2_32" 38 ;; 39 *-cygwin) 40 CFLAGS="$CFLAGS -DLIBSSH2_WIN32" 41 ;; 42 *darwin*) 43 CFLAGS="$CFLAGS -DLIBSSH2_DARWIN" 44 ;; 45 *hpux*) 46 ;; 47 *osf*) 48 CFLAGS="$CFLAGS -D_POSIX_PII_SOCKET" 49 ;; 50 *) 51 ;; 52esac 53 54AC_CHECK_TYPE(long long, 55 [AC_DEFINE(HAVE_LONGLONG, 1, 56 [Define to 1 if the compiler supports the 'long long' data type.])] 57 longlong="yes" 58) 59 60dnl Our configure and build reentrant settings 61CURL_CONFIGURE_REENTRANT 62 63# Some systems (Solaris?) have socket() in -lsocket. 64AC_SEARCH_LIBS(socket, socket) 65 66# Solaris has inet_addr() in -lnsl. 67AC_SEARCH_LIBS(inet_addr, nsl) 68 69AC_SUBST(LIBS) 70 71AC_PROG_CC 72AC_PROG_INSTALL 73AC_PROG_LN_S 74AC_PROG_MAKE_SET 75AC_PATH_PROGS(SSHD, [sshd], [], 76 [$PATH$PATH_SEPARATOR/usr/libexec$PATH_SEPARATOR]dnl 77 [/usr/sbin$PATH_SEPARATOR/usr/etc$PATH_SEPARATOR/etc]) 78AM_CONDITIONAL(SSHD, test -n "$SSHD") 79AC_LIBTOOL_WIN32_DLL 80AC_PROG_LIBTOOL 81AC_C_BIGENDIAN 82 83dnl check for how to do large files 84AC_SYS_LARGEFILE 85 86# Crypto backends 87 88found_crypto=none 89found_crypto_str="" 90support_clear_memory=no 91crypto_errors="" 92 93m4_set_add([crypto_backends], [openssl]) 94m4_set_add([crypto_backends], [libgcrypt]) 95m4_set_add([crypto_backends], [mbedtls]) 96m4_set_add([crypto_backends], [wincng]) 97 98AC_ARG_WITH([crypto], 99 AC_HELP_STRING([--with-crypto=auto|]m4_set_contents([crypto_backends], [|]), 100 [Select crypto backend (default: auto)]), 101 use_crypto=$withval, 102 use_crypto=auto 103) 104 105case "${use_crypto}" in 106 auto|m4_set_contents([crypto_backends], [|])) 107 m4_set_map([crypto_backends], [LIBSSH2_CHECK_CRYPTO]) 108 ;; 109 yes|"") 110 crypto_errors="No crypto backend specified!" 111 ;; 112 *) 113 crypto_errors="Unknown crypto backend '${use_crypto}' specified!" 114 ;; 115esac 116 117if test "$found_crypto" = "none"; then 118 crypto_errors="${crypto_errors} 119Specify --with-crypto=\$backend and/or the neccessary library search prefix. 120 121Known crypto backends: auto, m4_set_contents([crypto_backends], [, ])" 122 AS_MESSAGE([ERROR: ${crypto_errors}]) 123else 124 test "$found_crypto_str" = "" && found_crypto_str="$found_crypto" 125fi 126 127m4_set_foreach([crypto_backends], [backend], 128 [AM_CONDITIONAL(m4_toupper(backend), test "$found_crypto" = "backend")] 129) 130m4_undefine([backend]) 131 132 133# libz 134 135AC_ARG_WITH([libz], 136 AC_HELP_STRING([--with-libz],[Use libz for compression]), 137 use_libz=$withval, 138 use_libz=auto) 139 140found_libz=no 141libz_errors="" 142 143if test "$use_libz" != no; then 144 AC_LIB_HAVE_LINKFLAGS([z], [], [#include <zlib.h>]) 145 if test "$ac_cv_libz" != yes; then 146 if test "$use_libz" = auto; then 147 AC_MSG_NOTICE([Cannot find libz, disabling compression]) 148 found_libz="disabled; no libz found" 149 else 150 libz_errors="No libz found! 151Try --with-libz-prefix=PATH if you know that you have it." 152 AS_MESSAGE([ERROR: $libz_errors]) 153 fi 154 else 155 AC_DEFINE(LIBSSH2_HAVE_ZLIB, 1, [Compile in zlib support]) 156 LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }zlib" 157 found_libz="yes" 158 fi 159fi 160 161AC_SUBST(LIBSREQUIRED) 162 163# 164# Optional Settings 165# 166AC_ARG_ENABLE(crypt-none, 167 AC_HELP_STRING([--enable-crypt-none],[Permit "none" cipher -- NOT RECOMMENDED]), 168 [AC_DEFINE(LIBSSH2_CRYPT_NONE, 1, [Enable "none" cipher -- NOT RECOMMENDED])]) 169 170AC_ARG_ENABLE(mac-none, 171 AC_HELP_STRING([--enable-mac-none],[Permit "none" MAC -- NOT RECOMMENDED]), 172 [AC_DEFINE(LIBSSH2_MAC_NONE, 1, [Enable "none" MAC -- NOT RECOMMENDED])]) 173 174AC_ARG_ENABLE(gex-new, 175 AC_HELP_STRING([--disable-gex-new],[Disable "new" diffie-hellman-group-exchange-sha1 method]), 176 [GEX_NEW=$enableval]) 177if test "$GEX_NEW" != "no"; then 178 AC_DEFINE(LIBSSH2_DH_GEX_NEW, 1, [Enable newer diffie-hellman-group-exchange-sha1 syntax]) 179fi 180 181AC_ARG_ENABLE(clear-memory, 182 AC_HELP_STRING([--disable-clear-memory],[Disable clearing of memory before being freed]), 183 [CLEAR_MEMORY=$enableval]) 184if test "$CLEAR_MEMORY" != "no"; then 185 if test "$support_clear_memory" = "yes"; then 186 AC_DEFINE(LIBSSH2_CLEAR_MEMORY, 1, [Enable clearing of memory before being freed]) 187 enable_clear_memory=yes 188 else 189 if test "$CLEAR_MEMORY" = "yes"; then 190 AC_MSG_ERROR([secure clearing/zeroing of memory is not supported by the selected crypto backend]) 191 else 192 AC_MSG_WARN([secure clearing/zeroing of memory is not supported by the selected crypto backend]) 193 fi 194 enable_clear_memory=unsupported 195 fi 196else 197 if test "$support_clear_memory" = "yes"; then 198 enable_clear_memory=no 199 else 200 AC_MSG_WARN([secure clearing/zeroing of memory is not supported by the selected crypto backend]) 201 enable_clear_memory=unsupported 202 fi 203fi 204 205dnl ************************************************************ 206dnl option to switch on compiler debug options 207dnl 208AC_MSG_CHECKING([whether to enable pedantic and debug compiler options]) 209AC_ARG_ENABLE(debug, 210AC_HELP_STRING([--enable-debug],[Enable pedantic and debug options]) 211AC_HELP_STRING([--disable-debug],[Disable debug options]), 212[ case "$enable_debug" in 213 no) 214 AC_MSG_RESULT(no) 215 CPPFLAGS="$CPPFLAGS -DNDEBUG" 216 ;; 217 *) AC_MSG_RESULT(yes) 218 enable_debug=yes 219 CPPFLAGS="$CPPFLAGS -DLIBSSH2DEBUG" 220 CFLAGS="$CFLAGS -g" 221 222 dnl set compiler "debug" options to become more picky, and remove 223 dnl optimize options from CFLAGS 224 CURL_CC_DEBUG_OPTS 225 ;; 226 esac 227 ], 228 enable_debug=no 229 AC_MSG_RESULT(no) 230) 231 232dnl ************************************************************ 233dnl Enable hiding of internal symbols in library to reduce its size and 234dnl speed dynamic linking of applications. This currently is only supported 235dnl on gcc >= 4.0 and SunPro C. 236dnl 237AC_MSG_CHECKING([whether to enable hidden symbols in the library]) 238AC_ARG_ENABLE(hidden-symbols, 239AC_HELP_STRING([--enable-hidden-symbols],[Hide internal symbols in library]) 240AC_HELP_STRING([--disable-hidden-symbols],[Leave all symbols with default visibility in library]), 241[ case "$enableval" in 242 no) 243 AC_MSG_RESULT(no) 244 ;; 245 *) 246 AC_MSG_CHECKING([whether $CC supports it]) 247 if test "$GCC" = yes ; then 248 if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then 249 AC_MSG_RESULT(yes) 250 AC_DEFINE(LIBSSH2_API, [__attribute__ ((visibility ("default")))], [to make a symbol visible]) 251 CFLAGS="$CFLAGS -fvisibility=hidden" 252 else 253 AC_MSG_RESULT(no) 254 fi 255 256 else 257 dnl Test for SunPro cc 258 if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then 259 AC_MSG_RESULT(yes) 260 AC_DEFINE(LIBSSH2_API, [__global], [to make a symbol visible]) 261 CFLAGS="$CFLAGS -xldscope=hidden" 262 else 263 AC_MSG_RESULT(no) 264 fi 265 fi 266 ;; 267 esac ], 268 AC_MSG_RESULT(no) 269) 270 271# Checks for header files. 272# AC_HEADER_STDC 273AC_CHECK_HEADERS([errno.h fcntl.h stdio.h stdlib.h unistd.h sys/uio.h]) 274AC_CHECK_HEADERS([sys/select.h sys/socket.h sys/ioctl.h sys/time.h]) 275AC_CHECK_HEADERS([arpa/inet.h netinet/in.h]) 276AC_CHECK_HEADERS([sys/un.h], [have_sys_un_h=yes], [have_sys_un_h=no]) 277AM_CONDITIONAL([HAVE_SYS_UN_H], test "x$have_sys_un_h" = xyes) 278 279case $host in 280 *-*-cygwin* | *-*-cegcc*) 281 # These are POSIX-like systems using BSD-like sockets API. 282 ;; 283 *) 284 AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h]) 285 ;; 286esac 287 288case $host in 289 *darwin*|*interix*) 290 dnl poll() does not work on these platforms 291 dnl Interix: "does provide poll(), but the implementing developer must 292 dnl have been in a bad mood, because poll() only works on the /proc 293 dnl filesystem here" 294 dnl Mac OS X's poll has funny behaviors, like: 295 dnl not being able to do poll on no fildescriptors (10.3?) 296 dnl not being able to poll on some files (like anything in /dev) 297 dnl not having reliable timeout support 298 dnl inconsistent return of POLLHUP where other implementations give POLLIN 299 AC_MSG_NOTICE([poll use is disabled on this platform]) 300 ;; 301 *) 302 AC_CHECK_FUNCS(poll) 303 ;; 304esac 305 306AC_CHECK_FUNCS(gettimeofday select strtoll memset_s) 307 308dnl Check for select() into ws2_32 for Msys/Mingw 309if test "$ac_cv_func_select" != "yes"; then 310 AC_MSG_CHECKING([for select in ws2_32]) 311 AC_TRY_LINK([ 312#ifdef HAVE_WINSOCK2_H 313#ifndef WIN32_LEAN_AND_MEAN 314#define WIN32_LEAN_AND_MEAN 315#endif 316#include <winsock2.h> 317#endif 318 ],[ 319 select(0,(fd_set *)NULL,(fd_set *)NULL,(fd_set *)NULL,(struct timeval *)NULL); 320 ],[ 321 AC_MSG_RESULT([yes]) 322 HAVE_SELECT="1" 323 AC_DEFINE_UNQUOTED(HAVE_SELECT, 1, 324 [Define to 1 if you have the select function.]) 325 ],[ 326 AC_MSG_RESULT([no]) 327 ]) 328fi 329 330AC_FUNC_ALLOCA 331 332# Checks for typedefs, structures, and compiler characteristics. 333AC_C_CONST 334AC_C_INLINE 335 336CURL_CHECK_NONBLOCKING_SOCKET 337 338missing_required_deps=0 339 340if test "${libz_errors}" != ""; then 341 AS_MESSAGE([ERROR: ${libz_errors}]) 342 missing_required_deps=1 343fi 344 345if test "$found_crypto" = "none"; then 346 AS_MESSAGE([ERROR: ${crypto_errors}]) 347 missing_required_deps=1 348fi 349 350if test $missing_required_deps = 1; then 351 AC_MSG_ERROR([Required dependencies are missing!]) 352fi 353 354# Configure parameters 355LIBSSH2_CHECK_OPTION_WERROR 356 357AC_CONFIG_FILES([Makefile 358 src/Makefile 359 libssh2.pc]) 360AC_OUTPUT 361 362AC_MSG_NOTICE([summary of build options: 363 364 version: ${LIBSSH2VER} 365 Host type: ${host} 366 Install prefix: ${prefix} 367 Compiler: ${CC} 368 Compiler flags: ${CFLAGS} 369 Library types: Shared=${enable_shared}, Static=${enable_static} 370 Crypto library: ${found_crypto_str} 371 Clear memory: $enable_clear_memory 372 Debug build: $enable_debug 373 Path to sshd: $ac_cv_path_SSHD (only for self-tests) 374 zlib compression: ${found_libz} 375]) 376