Skip to content
configure.ac 95.7 KiB
Newer Older

      AC_CHECK_LIB(cyassl, InitCyaSSL,
       [
       AC_DEFINE(USE_CYASSL, 1, [if CyaSSL is enabled])
       AC_SUBST(USE_CYASSL, [1])
       CYASSL_ENABLED=1
       USE_CYASSL="yes"
       curl_ssl_msg="enabled (CyaSSL)"
       ],
       [
         CPPFLAGS=$_cppflags
         LDFLAGS=$_ldflags
       ])
    fi

    if test "x$USE_CYASSL" = "xyes"; then
      AC_MSG_NOTICE([detected CyaSSL])

      CURL_LIBS="$CURL_LIBS -lcyassl -lm"
      LIBS="$LIBS -lcyassl -lm"

      if test -n "$cyassllib"; then
        dnl when shared libs were found in a path that the run-time
        dnl linker doesn't search through, we need to add it to
        dnl LD_LIBRARY_PATH to prevent further configure tests to fail
        dnl due to this
        if test "x$cross_compiling" != "xyes"; then
          LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$cyassllib"
          export LD_LIBRARY_PATH
          AC_MSG_NOTICE([Added $cyassllib to LD_LIBRARY_PATH])
        fi
dnl ----------------------------------------------------
dnl NSS. Only check if GnuTLS and OpenSSL are not enabled
dnl ----------------------------------------------------

dnl Default to compiler & linker defaults for NSS files & libraries.
OPT_NSS=no

AC_ARG_WITH(nss,dnl
AC_HELP_STRING([--with-nss=PATH],[where to look for NSS, PATH points to the installation root])
AC_HELP_STRING([--without-nss], [disable NSS detection]),
  OPT_NSS=$withval)

if test "$OPENSSL_ENABLED" != "1" -a "$GNUTLS_ENABLED" != "1"; then

  if test X"$OPT_NSS" != Xno; then
    if test "x$OPT_NSS" = "xyes"; then

      CURL_CHECK_PKGCONFIG(nss)

      if test "$PKGCONFIG" != "no" ; then
        addlib=`$PKGCONFIG --libs nss`
        addcflags=`$PKGCONFIG --cflags nss`
        version=`$PKGCONFIG --modversion nss`
        nssprefix=`$PKGCONFIG --variable=prefix nss`
      else
        dnl Without pkg-config, we check for nss-config

        check=`nss-config --version 2>/dev/null`
        if test -n "$check"; then
          addlib=`nss-config --libs`
          addcflags=`nss-config --cflags`
          version=`nss-config --version`
          nssprefix=`nss-config --prefix`
        else
          addlib="-lnss3"
          addcflags=""
          version="unknown"
        fi
    else
        # Without pkg-config, we'll kludge in some defaults
        addlib="-L$OPT_NSS/lib -lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl"
        addcflags="-I$OPT_NSS/include"
        version="unknown"
    dnl Check for functionPK11_CreateGenericObject
    dnl this is needed for using the PEM PKCS#11 module
    AC_CHECK_LIB(nss3, PK11_CreateGenericObject,
     [
     AC_DEFINE(HAVE_PK11_CREATEGENERICOBJECT, 1, [if you have the function PK11_CreateGenericObject])
     AC_SUBST(HAVE_PK11_CREATEGENERICOBJECT, [1])
     ])
    if test -n "$addlib"; then

      CLEANLIBS="$LIBS"
      CLEANCPPFLAGS="$CPPFLAGS"
      LIBS="$LIBS $addlib"
      if test "$addcflags" != "-I/usr/include"; then
         CPPFLAGS="$CPPFLAGS $addcflags"
      fi
      AC_CHECK_LIB(nss3, NSS_Initialize,
       [
       AC_DEFINE(USE_NSS, 1, [if NSS is enabled])
       AC_SUBST(USE_NSS, [1])
       USE_NSS="yes"
       NSS_ENABLED=1
       curl_ssl_msg="enabled (NSS)"
       ],
       [
         LIBS="$CLEANLIBS"
         CPPFLAGS="$CLEANCPPFLAGS"
       ])
      if test "x$USE_NSS" = "xyes"; then
        AC_MSG_NOTICE([detected NSS version $version])

        dnl when shared libs were found in a path that the run-time
        dnl linker doesn't search through, we need to add it to
        dnl LD_LIBRARY_PATH to prevent further configure tests to fail
        dnl due to this
        if test "x$cross_compiling" != "xyes"; then
          LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$nssprefix/lib$libsuff"
          export LD_LIBRARY_PATH
          AC_MSG_NOTICE([Added $nssprefix/lib$libsuff to LD_LIBRARY_PATH])
        fi
      fi

    fi

  fi dnl NSS not disabled

fi dnl OPENSSL != 1 -a GNUTLS_ENABLED != 1

OPT_AXTLS=off

AC_ARG_WITH(axtls,dnl
AC_HELP_STRING([--with-axtls=PATH],[Where to look for axTLS, PATH points to the axTLS installation prefix (default: /usr/local).  Ignored if another SSL engine is selected.])
AC_HELP_STRING([--without-axtls], [disable axTLS]),
  OPT_AXTLS=$withval)

if test "$curl_ssl_msg" = "$init_ssl_msg"; then
  if test X"$OPT_AXTLS" != Xno; then
    dnl backup the pre-axtls variables
    CLEANLDFLAGS="$LDFLAGS"
    CLEANCPPFLAGS="$CPPFLAGS"
    CLEANLIBS="$LIBS"

    case "$OPT_AXTLS" in
    yes)
      dnl --with-axtls (without path) used
      PREFIX_AXTLS=/usr/local
      LIB_AXTLS="$PREFIX_AXTLS/lib"
      LDFLAGS="$LDFLAGS -L$LIB_AXTLS"
      CPPFLAGS="$CPPFLAGS -I$PREFIX_AXTLS/include"
      ;;
    off)
      dnl no --with-axtls option given, just check default places
      PREFIX_AXTLS=
      ;;
    *)
      dnl check the given --with-axtls spot
      PREFIX_AXTLS=$OPT_AXTLS
      LIB_AXTLS="$PREFIX_AXTLS/lib"
      LDFLAGS="$LDFLAGS -L$LIB_AXTLS"
      CPPFLAGS="$CPPFLAGS -I$PREFIX_AXTLS/include"
      ;;
    esac

    AC_CHECK_LIB(axtls, ssl_version,[
      LIBS="-laxtls $LIBS"
      AC_DEFINE(USE_AXTLS, 1, [if axTLS is enabled])
      AC_SUBST(USE_AXTLS, [1])
      AXTLS_ENABLED=1
      USE_AXTLS="yes"
      curl_ssl_msg="enabled (axTLS)"


      LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LIB_AXTLS"
      export LD_LIBRARY_PATH
      AC_MSG_NOTICE([Added $LIB_AXTLS to LD_LIBRARY_PATH])
      ],[
      LDFLAGS="$CLEANLDFLAGS"
      CPPFLAGS="$CLEANCPPFLAGS"
      LIBS="$CLEANLIBS"
    ])
  fi
fi

if test "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED$POLARSSL_ENABLED$AXTLS_ENABLED$CYASSL_ENABLED" = "x"; then
  AC_MSG_WARN([SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.])
  AC_MSG_WARN([Use --with-ssl, --with-gnutls, --with-polarssl, --with-cyassl, --with-nss or --with-axtls to address this.])
else
  # SSL is enabled, genericly
  AC_SUBST(SSL_ENABLED)
  SSL_ENABLED="1"
dnl **********************************************************************
dnl Check for the CA bundle
dnl **********************************************************************

dnl **********************************************************************
dnl Check for the presence of LIBSSH2 libraries and headers
dnl **********************************************************************

dnl Default to compiler & linker defaults for LIBSSH2 files & libraries.
OPT_LIBSSH2=off
AC_ARG_WITH(libssh2,dnl
AC_HELP_STRING([--with-libssh2=PATH],[Where to look for libssh2, PATH points to the LIBSSH2 installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
AC_HELP_STRING([--without-libssh2], [disable LIBSSH2]),
  OPT_LIBSSH2=$withval)

if test X"$OPT_LIBSSH2" != Xno; then
  dnl backup the pre-libssh2 variables
  CLEANLDFLAGS="$LDFLAGS"
  CLEANCPPFLAGS="$CPPFLAGS"
  CLEANLIBS="$LIBS"

  case "$OPT_LIBSSH2" in
  yes)
    dnl --with-libssh2 (without path) used
    CURL_CHECK_PKGCONFIG(libssh2)

    if test "$PKGCONFIG" != "no" ; then
      LIB_SSH2=`$PKGCONFIG --libs-only-l libssh2`
      LD_SSH2=`$PKGCONFIG --libs-only-L libssh2`
      CPP_SSH2=`$PKGCONFIG --cflags-only-I libssh2`
      version=`$PKGCONFIG --modversion libssh2`
      DIR_SSH2=`echo $LD_SSH2 | $SED -e 's/-L//'`
    fi
    ;;
  off)
    dnl no --with-libssh2 option given, just check default places
    ;;
  *)
    dnl use the given --with-libssh2 spot
  dnl if given with a prefix, we set -L and -I based on that
  if test -n "$PREFIX_SSH2"; then
  fi

  LDFLAGS="$LDFLAGS $LD_SSH2"
  CPPFLAGS="$CPPFLAGS $CPP_SSH2"
  LIBS="$LIBS $LIB_SSH2"

  AC_CHECK_LIB(ssh2, libssh2_channel_open_ex)

  AC_CHECK_HEADERS(libssh2.h,
    curl_ssh_msg="enabled (libSSH2)"
    LIBSSH2_ENABLED=1
    AC_DEFINE(USE_LIBSSH2, 1, [if libSSH2 is in use])
    AC_SUBST(USE_LIBSSH2, [1])
  )

  if test X"$OPT_LIBSSH2" != Xoff &&
     test "$LIBSSH2_ENABLED" != "1"; then
    AC_MSG_ERROR([libSSH2 libs and/or directories were not found where specified!])
  fi

  if test "$LIBSSH2_ENABLED" = "1"; then
       dnl when the libssh2 shared libs were found in a path that the run-time
       dnl linker doesn't search through, we need to add it to LD_LIBRARY_PATH
       dnl to prevent further configure tests to fail due to this

       dnl libssh2_version is a post 1.0 addition
       dnl libssh2_init and libssh2_exit were added in 1.2.5
       dnl libssh2_scp_send64 was added in 1.2.6
       dnl libssh2_session_handshake was added in 1.2.8
       AC_CHECK_FUNCS( libssh2_version libssh2_init libssh2_exit \
                       libssh2_scp_send64 libssh2_session_handshake)
       if test "x$cross_compiling" != "xyes"; then
         LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DIR_SSH2"
         export LD_LIBRARY_PATH
         AC_MSG_NOTICE([Added $DIR_SSH2 to LD_LIBRARY_PATH])
       fi
    fi
  else
    dnl no libssh2, revert back to clean variables
    LDFLAGS=$CLEANLDFLAGS
    CPPFLAGS=$CLEANCPPFLAGS
    LIBS=$CLEANLIBS
  fi
fi

dnl **********************************************************************
dnl Check for the presence of LIBRTMP libraries and headers
dnl **********************************************************************

dnl Default to compiler & linker defaults for LIBRTMP files & libraries.
OPT_LIBRTMP=off
AC_ARG_WITH(librtmp,dnl
AC_HELP_STRING([--with-librtmp=PATH],[Where to look for librtmp, PATH points to the LIBRTMP installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
AC_HELP_STRING([--without-librtmp], [disable LIBRTMP]),
  OPT_LIBRTMP=$withval)

if test X"$OPT_LIBRTMP" != Xno; then
  dnl backup the pre-librtmp variables
  CLEANLDFLAGS="$LDFLAGS"
  CLEANCPPFLAGS="$CPPFLAGS"
  CLEANLIBS="$LIBS"

  case "$OPT_LIBRTMP" in
  yes)
    dnl --with-librtmp (without path) used
    CURL_CHECK_PKGCONFIG(librtmp)

    if test "$PKGCONFIG" != "no" ; then
      LIB_RTMP=`$PKGCONFIG --libs-only-l librtmp`
      LD_RTMP=`$PKGCONFIG --libs-only-L librtmp`
      CPP_RTMP=`$PKGCONFIG --cflags-only-I librtmp`
      version=`$PKGCONFIG --modversion librtmp`
      DIR_RTMP=`echo $LD_RTMP | $SED -e 's/-L//'`
    else
      dnl To avoid link errors, we do not allow --librtmp without
      dnl a pkgconfig file
      AC_MSG_ERROR([--librtmp was specified but could not find librtmp pkgconfig file.])
    fi

    ;;
  off)
    dnl no --with-librtmp option given, just check default places
    ;;
  *)
    dnl use the given --with-librtmp spot
    PREFIX_RTMP=$OPT_LIBRTMP
    ;;
  esac

  dnl if given with a prefix, we set -L and -I based on that
  if test -n "$PREFIX_RTMP"; then
    LD_RTMP=-L${PREFIX_RTMP}/lib$libsuff
    CPP_RTMP=-I${PREFIX_RTMP}/include
    DIR_RTMP=${PREFIX_RTMP}/lib$libsuff
  fi

  LDFLAGS="$LDFLAGS $LD_RTMP"
  CPPFLAGS="$CPPFLAGS $CPP_RTMP"
  LIBS="$LIBS $LIB_RTMP"

  AC_CHECK_LIB(rtmp, RTMP_Init,
    [
     AC_CHECK_HEADERS(librtmp/rtmp.h,
        curl_rtmp_msg="enabled (librtmp)"
        LIBRTMP_ENABLED=1
        AC_DEFINE(USE_LIBRTMP, 1, [if librtmp is in use])
        AC_SUBST(USE_LIBRTMP, [1])
     )
    ],
      dnl not found, revert back to clean variables
      LDFLAGS=$CLEANLDFLAGS
      CPPFLAGS=$CLEANCPPFLAGS
      LIBS=$CLEANLIBS
  )

  if test X"$OPT_LIBRTMP" != Xoff &&
     test "$LIBRTMP_ENABLED" != "1"; then
    AC_MSG_ERROR([librtmp libs and/or directories were not found where specified!])
  fi

fi

dnl **********************************************************************
dnl Check for linker switch for versioned symbols
dnl **********************************************************************

AC_MSG_CHECKING([if libraries can be versioned])
GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
if test -z "$GLD"; then
    versioned_symbols_flavour=
    AC_MSG_RESULT(no)
    AC_MSG_WARN(***
*** You need an ld version supporting the --version-script option.
)
else
    AC_MSG_RESULT(yes)

AC_MSG_CHECKING([whether versioned symbols are wanted])
versioned_symbols_flavour=

AC_ARG_ENABLE(versioned-symbols,
AC_HELP_STRING([--enable-versioned-symbols], [Enable versioned symbols in shared library])
AC_HELP_STRING([--disable-versioned-symbols], [Disable versioned symbols in shared library]),
[ case "$enableval" in
  yes) AC_MSG_RESULT(yes)
    if test "x$OPENSSL_ENABLED" = "x1"; then
      versioned_symbols_flavour="OPENSSL_"
    elif test "x$GNUTLS_ENABLED" == "x1"; then
      versioned_symbols_flavour="GNUTLS_"
    elif test "x$NSS_ENABLED" == "x1"; then
      versioned_symbols_flavour="NSS_"
    elif test "x$POLARSSL_ENABLED" == "x1"; then
      versioned_symbols_flavour="POLARSSL_"
    elif test "x$CYASSL_ENABLED" == "x1"; then
      versioned_symbols_flavour="CYASSL_"
    elif test "x$AXTLS_ENABLED" == "x1"; then
      versioned_symbols_flavour="AXTLS_"
    else
      versioned_symbols_flavour=""
    fi
    versioned_symbols="yes"
    ;;

  *)   AC_MSG_RESULT(no)
    ;;
  esac
], [
AC_MSG_RESULT(no)
]
)
fi

AC_SUBST(VERSIONED_FLAVOUR, ["$versioned_symbols_flavour"])
AM_CONDITIONAL(VERSIONED_SYMBOLS, test "x$versioned_symbols" = "xyes")


dnl **********************************************************************
dnl Check for the presence of IDN libraries and headers
dnl **********************************************************************

Daniel Stenberg's avatar
Daniel Stenberg committed
AC_MSG_CHECKING([whether to build with libidn])
OPT_IDN="default"
AC_ARG_WITH(libidn,
Daniel Stenberg's avatar
Daniel Stenberg committed
AC_HELP_STRING([--with-libidn=PATH],[Enable libidn usage])
AC_HELP_STRING([--without-libidn],[Disable libidn usage]),
  [OPT_IDN=$withval])
case "$OPT_IDN" in
Daniel Stenberg's avatar
Daniel Stenberg committed
  no)
    dnl --without-libidn option used
    want_idn="no"
    AC_MSG_RESULT([no])
    ;;
  default)
    dnl configure option not specified
    want_idn="yes"
    want_idn_path="default"
    AC_MSG_RESULT([(assumed) yes])
    ;;
  yes)
    dnl --with-libidn option used without path
    want_idn="yes"
    want_idn_path="default"
    AC_MSG_RESULT([yes])
    ;;
  *)
    dnl --with-libidn option used with path
    want_idn="yes"
    want_idn_path="$withval"
    AC_MSG_RESULT([yes ($withval)])
    ;;
if test "$want_idn" = "yes"; then
  dnl idn library support has been requested
  clean_CPPFLAGS="$CPPFLAGS"
  clean_LDFLAGS="$LDFLAGS"
  clean_LIBS="$LIBS"
  PKGCONFIG="no"
  #
  if test "$want_idn_path" != "default"; then
    dnl path has been specified
    IDN_PCDIR="$want_idn_path/lib$libsuff/pkgconfig"
    CURL_CHECK_PKGCONFIG(libidn, [$IDN_PCDIR])
    if test "$PKGCONFIG" != "no"; then
      IDN_LIBS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
        $PKGCONFIG --libs-only-l libidn 2>/dev/null`
      IDN_LDFLAGS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
        $PKGCONFIG --libs-only-L libidn 2>/dev/null`
      IDN_CPPFLAGS=`CURL_EXPORT_PCDIR([$IDN_PCDIR]) dnl
        $PKGCONFIG --cflags-only-I libidn 2>/dev/null`
      IDN_DIR=`echo $IDN_LDFLAGS | $SED -e 's/-L//'`
    else
      dnl pkg-config not available or provides no info
      IDN_LIBS="-lidn"
      IDN_LDFLAGS="-L$want_idn_path/lib$libsuff"
      IDN_CPPFLAGS="-I$want_idn_path/include"
      IDN_DIR="$want_idn_path/lib$libsuff"
    fi
  else
    dnl path not specified
    CURL_CHECK_PKGCONFIG(libidn)
    if test "$PKGCONFIG" != "no"; then
      IDN_LIBS=`$PKGCONFIG --libs-only-l libidn 2>/dev/null`
      IDN_LDFLAGS=`$PKGCONFIG --libs-only-L libidn 2>/dev/null`
      IDN_CPPFLAGS=`$PKGCONFIG --cflags-only-I libidn 2>/dev/null`
      IDN_DIR=`echo $IDN_LDFLAGS | $SED -e 's/-L//'`
    else
      dnl pkg-config not available or provides no info
      IDN_LIBS="-lidn"
    fi
  fi
  #
  if test "$PKGCONFIG" != "no"; then
    AC_MSG_NOTICE([pkg-config: IDN_LIBS: "$IDN_LIBS"])
    AC_MSG_NOTICE([pkg-config: IDN_LDFLAGS: "$IDN_LDFLAGS"])
    AC_MSG_NOTICE([pkg-config: IDN_CPPFLAGS: "$IDN_CPPFLAGS"])
    AC_MSG_NOTICE([pkg-config: IDN_DIR: "$IDN_DIR"])
  else
    AC_MSG_NOTICE([IDN_LIBS: "$IDN_LIBS"])
    AC_MSG_NOTICE([IDN_LDFLAGS: "$IDN_LDFLAGS"])
    AC_MSG_NOTICE([IDN_CPPFLAGS: "$IDN_CPPFLAGS"])
    AC_MSG_NOTICE([IDN_DIR: "$IDN_DIR"])
  fi
  #
  CPPFLAGS="$IDN_CPPFLAGS $CPPFLAGS"
  LDFLAGS="$IDN_LDFLAGS $LDFLAGS"
  LIBS="$IDN_LIBS $LIBS"
  #
  AC_MSG_CHECKING([if idna_to_ascii_4i can be linked])
  AC_LINK_IFELSE([
    AC_LANG_FUNC_LINK_TRY([idna_to_ascii_4i])
  ],[
    AC_MSG_RESULT([yes])
    tst_links_libidn="yes"
  ],[
    AC_MSG_RESULT([no])
    tst_links_libidn="no"
  ])
  if test "$tst_links_libidn" = "no"; then
    AC_MSG_CHECKING([if idna_to_ascii_lz can be linked])
    AC_LINK_IFELSE([
      AC_LANG_FUNC_LINK_TRY([idna_to_ascii_lz])
    ],[
      AC_MSG_RESULT([yes])
      tst_links_libidn="yes"
    ],[
      AC_MSG_RESULT([no])
      tst_links_libidn="no"
    ])
  fi
  #
  if test "$tst_links_libidn" = "yes"; then
    AC_DEFINE(HAVE_LIBIDN, 1, [Define to 1 if you have the `idn' library (-lidn).])
    dnl different versions of libidn have different setups of these:
    AC_CHECK_FUNCS( idn_free idna_strerror tld_strerror )
    AC_CHECK_HEADERS( idn-free.h tld.h )
    if test "x$ac_cv_header_tld_h" = "xyes"; then
      AC_SUBST([IDN_ENABLED], [1])
      curl_idn_msg="enabled"
      if test -n "$IDN_DIR"; then
        LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$IDN_DIR"
        export LD_LIBRARY_PATH
        AC_MSG_NOTICE([Added $IDN_DIR to LD_LIBRARY_PATH])
      fi
    else
      AC_MSG_WARN([Libraries for IDN support too old: IDN disabled])
      CPPFLAGS="$clean_CPPFLAGS"
      LDFLAGS="$clean_LDFLAGS"
      LIBS="$clean_LIBS"
    fi
  else
    AC_MSG_WARN([Cannot find libraries for IDN support: IDN disabled])
    CPPFLAGS="$clean_CPPFLAGS"
    LDFLAGS="$clean_LDFLAGS"
    LIBS="$clean_LIBS"
  fi
fi


dnl Let's hope this split URL remains working:
dnl http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/ \
dnl genprogc/thread_quick_ref.htm
Daniel Stenberg's avatar
Daniel Stenberg committed
dnl **********************************************************************
dnl Back to "normal" configuring
dnl **********************************************************************

dnl Checks for header files.
AC_HEADER_STDC

dnl Now check for the very most basic headers. Then we can use these
dnl ones as default-headers when checking for the rest!
AC_CHECK_HEADERS(
        sys/types.h \
        sys/time.h \
        sys/select.h \
        sys/socket.h \
        sys/ioctl.h \
Daniel Stenberg's avatar
Daniel Stenberg committed
        assert.h \
Daniel Stenberg's avatar
Daniel Stenberg committed
        unistd.h \
        limits.h \
Daniel Stenberg's avatar
Daniel Stenberg committed
        arpa/inet.h \
        net/if.h \
        netinet/in.h \
Daniel Stenberg's avatar
Daniel Stenberg committed
        netdb.h \
        sys/sockio.h \
        sys/stat.h \
        sys/param.h \
        termios.h \
        termio.h \
        sgtty.h \
        fcntl.h \
        alloca.h \
        time.h \
        io.h \
Daniel Stenberg's avatar
Daniel Stenberg committed
        utime.h \
Daniel Stenberg's avatar
Daniel Stenberg committed
        sys/poll.h \
Yang Tse's avatar
 
Yang Tse committed
        socket.h \
Daniel Stenberg's avatar
Daniel Stenberg committed
        errno.h \
        sys/wait.h \
        setjmp.h,
dnl to do if not found
[],
dnl to do if found
[],
dnl default includes
[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
Daniel Stenberg's avatar
Daniel Stenberg committed
)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
Daniel Stenberg's avatar
Daniel Stenberg committed
AC_TYPE_SIZE_T
AC_HEADER_TIME
CURL_CHECK_STRUCT_TIMEVAL
Daniel Stenberg's avatar
Daniel Stenberg committed

AC_CHECK_SIZEOF(size_t)
Yang Tse's avatar
 
Yang Tse committed
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(short)
Daniel Stenberg's avatar
Daniel Stenberg committed

if test x"$ac_cv_native_windows" != "xyes" &&
   test $ac_cv_sizeof_off_t -ne $curl_sizeof_curl_off_t; then
  AC_MSG_WARN([This libcurl built is probably not ABI compatible with previous])
  AC_MSG_WARN([builds! You MUST read lib/README.curl_off_t to figure it out.])
  soname_bump=yes
fi


Daniel Stenberg's avatar
Daniel Stenberg committed
AC_CHECK_TYPE(long long,
   [AC_DEFINE(HAVE_LONGLONG, 1,
      [Define to 1 if the compiler supports the 'long long' data type.])]
Guenter Knauf's avatar
Guenter Knauf committed
   longlong="yes"
)

if test "xyes" = "x$longlong"; then
  AC_MSG_CHECKING([if numberLL works])
  AC_COMPILE_IFELSE([
    AC_LANG_PROGRAM([[
    ]],[[
      long long val = 1000LL;
    ]])
  ],[
    AC_MSG_RESULT([yes])
    AC_DEFINE(HAVE_LL, 1, [if your compiler supports LL])
  ],[
    AC_MSG_RESULT([no])
  ])
Daniel Stenberg's avatar
Daniel Stenberg committed

Daniel Stenberg's avatar
Daniel Stenberg committed
# check for ssize_t
Daniel Stenberg's avatar
Daniel Stenberg committed
AC_CHECK_TYPE(ssize_t, ,
   AC_DEFINE(ssize_t, int, [the signed version of size_t]))
Daniel Stenberg's avatar
Daniel Stenberg committed

# check for bool type
AC_CHECK_TYPE([bool],[
  AC_DEFINE(HAVE_BOOL_T, 1,
    [Define to 1 if bool is an available type.])
], ,[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#endif
])

TYPE_IN_ADDR_T
CURL_CHECK_FUNC_SELECT
Yang Tse's avatar
 
Yang Tse committed
CURL_CHECK_FUNC_BASENAME
Yang Tse's avatar
 
Yang Tse committed
CURL_CHECK_FUNC_CLOSESOCKET
CURL_CHECK_FUNC_CLOSESOCKET_CAMEL
Yang Tse's avatar
 
Yang Tse committed
CURL_CHECK_FUNC_CONNECT
CURL_CHECK_FUNC_FDOPEN
CURL_CHECK_FUNC_FREEADDRINFO
CURL_CHECK_FUNC_FTRUNCATE
CURL_CHECK_FUNC_GAI_STRERROR
CURL_CHECK_FUNC_GETHOSTBYADDR_R
CURL_CHECK_FUNC_GETHOSTBYNAME_R
CURL_CHECK_FUNC_GETHOSTNAME
CURL_CHECK_FUNC_GETSERVBYPORT_R
CURL_CHECK_FUNC_GMTIME_R
CURL_CHECK_FUNC_INET_NTOA_R
CURL_CHECK_FUNC_IOCTL
CURL_CHECK_FUNC_IOCTLSOCKET
CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL
CURL_CHECK_FUNC_LOCALTIME_R
CURL_CHECK_FUNC_MEMRCHR
CURL_CHECK_FUNC_POLL
CURL_CHECK_FUNC_SIGACTION
CURL_CHECK_FUNC_SIGINTERRUPT
CURL_CHECK_FUNC_SIGNAL
CURL_CHECK_FUNC_SIGSETJMP
Yang Tse's avatar
 
Yang Tse committed
CURL_CHECK_FUNC_SOCKET
CURL_CHECK_FUNC_SOCKETPAIR
Yang Tse's avatar
Yang Tse committed
CURL_CHECK_FUNC_STRCASECMP
CURL_CHECK_FUNC_STRCASESTR
CURL_CHECK_FUNC_STRCMPI
CURL_CHECK_FUNC_STRDUP
CURL_CHECK_FUNC_STRERROR_R
Yang Tse's avatar
Yang Tse committed
CURL_CHECK_FUNC_STRICMP
CURL_CHECK_FUNC_STRLCAT
CURL_CHECK_FUNC_STRNCASECMP
CURL_CHECK_FUNC_STRNCMPI
CURL_CHECK_FUNC_STRNICMP
CURL_CHECK_FUNC_STRTOK_R
CURL_CHECK_FUNC_STRTOLL
case $host in
  *msdosdjgpp)
     ac_cv_func_pipe=no
     skipcheck_pipe=yes
     AC_MSG_NOTICE([skip check for pipe on msdosdjgpp])
    ;;
esac
Yang Tse's avatar
 
Yang Tse committed
AC_CHECK_FUNCS([fork \
  geteuid \
  getpass_r \
  getppid \
  getprotobyname \
  getpwuid \
  getrlimit \
  gettimeofday \
  inet_addr \
  perror \
  pipe \
  setlocale \
  setmode \
  setrlimit \
  uname \
  utime
],[
],[
  func="$ac_func"
  eval skipcheck=\$skipcheck_$func
  if test "x$skipcheck" != "xyes"; then
    AC_MSG_CHECKING([deeper for $func])
    AC_LINK_IFELSE([
      AC_LANG_PROGRAM([[
      ]],[[
        $func ();
      ]])
    ],[
      AC_MSG_RESULT([yes])
      eval "ac_cv_func_$func=yes"
      AC_DEFINE_UNQUOTED(XC_SH_TR_CPP([HAVE_$func]), [1],
        [Define to 1 if you have the $func function.])
    ],[
      AC_MSG_RESULT([but still no])
    ])
  fi
])

dnl Check if the getnameinfo function is available
dnl and get the types of five of its arguments.
CURL_CHECK_FUNC_GETNAMEINFO
if test "$ipv6" = "yes"; then
  if test "$ac_cv_func_getaddrinfo" = "yes"; then
    AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
    IPV6_ENABLED=1
    AC_SUBST(IPV6_ENABLED)
  fi
dnl ************************************************************
dnl enable non-blocking communications
dnl
CURL_CHECK_OPTION_NONBLOCKING
CURL_CHECK_NONBLOCKING_SOCKET

dnl ************************************************************
dnl nroff tool stuff
dnl
Guenter Knauf's avatar
Guenter Knauf committed
AC_PATH_PROG( PERL, perl, ,
  $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin )
AC_SUBST(PERL)
Daniel Stenberg's avatar
Daniel Stenberg committed

Guenter Knauf's avatar
Guenter Knauf committed
AC_PATH_PROGS( NROFF, gnroff nroff, ,
Daniel Stenberg's avatar
Daniel Stenberg committed
  $PATH:/usr/bin/:/usr/local/bin )
AC_SUBST(NROFF)
Daniel Stenberg's avatar
Daniel Stenberg committed

if test -n "$NROFF"; then
  dnl only check for nroff options if an nroff command was found

  AC_MSG_CHECKING([how to use *nroff to get plain text from man pages])
  MANOPT="-man"
  mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
  if test -z "$mancheck"; then
    MANOPT="-mandoc"
   mancheck=`echo foo | $NROFF $MANOPT 2>/dev/null`
    if test -z "$mancheck"; then
      MANOPT=""
      AC_MSG_RESULT([failed])
      AC_MSG_WARN([found no *nroff option to get plaintext from man pages])
    else
      AC_MSG_RESULT([$MANOPT])
    fi
  AC_SUBST(MANOPT)
fi

if test -z "$MANOPT"
then
  dnl if no nroff tool was found, or no option that could convert man pages
  dnl was found, then disable the built-in manual stuff
  AC_MSG_WARN([disabling built-in manual])
  USE_MANUAL="no";
dnl *************************************************************************
dnl If the manual variable still is set, then we go with providing a built-in
dnl manual

if test "$USE_MANUAL" = "1"; then
  AC_DEFINE(USE_MANUAL, 1, [If you want to build curl with the built-in manual])
Daniel Stenberg's avatar
Daniel Stenberg committed
  curl_manual_msg="enabled"
fi

dnl set variable for use in automakefile(s)
AM_CONDITIONAL(USE_MANUAL, test x"$USE_MANUAL" = x1)

CURL_CHECK_LIB_ARES
AM_CONDITIONAL(USE_EMBEDDED_ARES, test x$embedded_ares = xyes)
Yang Tse's avatar
 
Yang Tse committed

if test "x$ac_cv_native_windows" != "xyes" &&
   test "x$enable_shared" = "xyes"; then
  build_libhostname=yes
else
  build_libhostname=no
fi
Yang Tse's avatar
Yang Tse committed
AM_CONDITIONAL(BUILD_LIBHOSTNAME, test x$build_libhostname = xyes)
CURL_CHECK_OPTION_THREADED_RESOLVER

if test "x$want_thres" = xyes && test "x$want_ares" = xyes; then
  AC_MSG_ERROR(
[Options --enable-threaded-resolver and --enable-ares are mutually exclusive])
fi

if test "$want_thres" = "yes"; then
  AC_CHECK_HEADER(pthread.h,
    [ AC_DEFINE(HAVE_PTHREAD_H, 1, [if you have <pthread.h>])
      save_CFLAGS="$CFLAGS"
      CFLAGS="$CFLAGS -pthread"
      AC_CHECK_LIB(pthread, pthread_create,
        [ AC_MSG_NOTICE([using POSIX threaded DNS lookup])
          AC_DEFINE(USE_THREADS_POSIX, 1, [if you want POSIX threaded DNS lookup])
          USE_THREADS_POSIX=1
          curl_res_msg="threaded"
        ],
        [ CFLAGS="$save_CFLAGS"])
  ])
fi

dnl ************************************************************
dnl disable verbose text strings
dnl
AC_MSG_CHECKING([whether to enable verbose strings])
AC_ARG_ENABLE(verbose,
AC_HELP_STRING([--enable-verbose],[Enable verbose strings])
AC_HELP_STRING([--disable-verbose],[Disable verbose strings]),
[ case "$enableval" in
  no)
       AC_MSG_RESULT(no)
       AC_DEFINE(CURL_DISABLE_VERBOSE_STRINGS, 1, [to disable verbose strings])
       curl_verbose_msg="no"
       ;;
  *)   AC_MSG_RESULT(yes)
       ;;
  esac ],
       AC_MSG_RESULT(yes)
)

dnl ************************************************************
dnl enable SSPI support
dnl
AC_MSG_CHECKING([whether to enable SSPI support (Windows native builds only)])
AC_ARG_ENABLE(sspi,
AC_HELP_STRING([--enable-sspi],[Enable SSPI])
AC_HELP_STRING([--disable-sspi],[Disable SSPI]),
[ case "$enableval" in
  yes)
       if test "$ac_cv_native_windows" = "yes"; then
         AC_MSG_RESULT(yes)
         AC_DEFINE(USE_WINDOWS_SSPI, 1, [to enable SSPI support])
         AC_SUBST(USE_WINDOWS_SSPI, [1])
       else
         AC_MSG_RESULT(no)
         AC_MSG_WARN([--enable-sspi Ignored. Only supported on native Windows builds.])
       fi
dnl ************************************************************
dnl disable cryptographic authentication
dnl
AC_MSG_CHECKING([whether to enable cryptographic authentication methods])
AC_ARG_ENABLE(crypto-auth,
AC_HELP_STRING([--enable-crypto-auth],[Enable cryptographic authentication])
AC_HELP_STRING([--disable-crypto-auth],[Disable cryptographic authentication]),
[ case "$enableval" in
  no)
       AC_MSG_RESULT(no)
       AC_DEFINE(CURL_DISABLE_CRYPTO_AUTH, 1, [to disable cryptographic authentication])