Skip to content
configure.ac 102 KiB
Newer Older
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]),
if test "$curl_ssl_msg" = "$init_ssl_msg"; then

    addld=""
    addlib=""
    addcflags=""
    nssprefix=""
    version=""


      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"
    if test -n "$addlib"; then

      CLEANLIBS="$LIBS"
      CLEANCPPFLAGS="$CPPFLAGS"
      if test "$addcflags" != "-I/usr/include"; then
         CPPFLAGS="$CPPFLAGS $addcflags"
      fi
      dnl The function SSL_VersionRangeSet() is needed to enable TLS > 1.0
      AC_CHECK_LIB(nss3, SSL_VersionRangeSet,
       [
       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 dnl curl_ssl_msg = init_ssl_msg
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$WINSSL_ENABLED$DARWINSSL_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, --with-axtls, --with-winssl, or --with-darwinssl to address this.])
else
  # SSL is enabled, genericly
  AC_SUBST(SSL_ENABLED)
  SSL_ENABLED="1"
dnl **********************************************************************
dnl Check for the CA bundle
dnl **********************************************************************

Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
dnl **********************************************************************
dnl Check for libmetalink
dnl **********************************************************************

OPT_LIBMETALINK=no

AC_ARG_WITH(libmetalink,dnl
AC_HELP_STRING([--with-libmetalink=PATH],[where to look for libmetalink, PATH points to the installation root])
AC_HELP_STRING([--without-libmetalink], [disable libmetalink detection]),
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
  OPT_LIBMETALINK=$withval)

if test X"$OPT_LIBMETALINK" != Xno; then

  addld=""
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
  addcflags=""
  version=""
  libmetalinklib=""
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
  PKGTEST="no"
  if test "x$OPT_LIBMETALINK" = "xyes"; then
    dnl this is with no partiular path given
    PKGTEST="yes"
    CURL_CHECK_PKGCONFIG(libmetalink)
  else
    dnl When particular path is given, set PKG_CONFIG_LIBDIR using the path.
    LIBMETALINK_PCDIR="$OPT_LIBMETALINK/lib/pkgconfig"
    AC_MSG_NOTICE([PKG_CONFIG_LIBDIR will be set to "$LIBMETALINK_PCDIR"])
    if test -f "$LIBMETALINK_PCDIR/libmetalink.pc"; then
      PKGTEST="yes"
    fi
    if test "$PKGTEST" = "yes"; then
      CURL_CHECK_PKGCONFIG(libmetalink, [$LIBMETALINK_PCDIR])
    fi
  fi
  if test "$PKGTEST" = "yes" && test "$PKGCONFIG" != "no"; then
    addlib=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
      $PKGCONFIG --libs-only-l libmetalink`
    addld=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
      $PKGCONFIG --libs-only-L libmetalink`
    addcflags=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
      $PKGCONFIG --cflags-only-I libmetalink`
    version=`CURL_EXPORT_PCDIR([$LIBMETALINK_PCDIR]) dnl
      $PKGCONFIG --modversion libmetalink`
Tatsuhiro Tsujikawa's avatar
Tatsuhiro Tsujikawa committed
    libmetalinklib=`echo $addld | $SED -e 's/-L//'`
  fi
  if test -n "$addlib"; then

    clean_CPPFLAGS="$CPPFLAGS"
    clean_LDFLAGS="$LDFLAGS"
    clean_LIBS="$LIBS"
    CPPFLAGS="$addcflags $clean_CPPFLAGS"
    LDFLAGS="$addld $clean_LDFLAGS"
    LIBS="$addlib $clean_LIBS"
    AC_MSG_CHECKING([if libmetalink is recent enough])
    AC_LINK_IFELSE([
      AC_LANG_PROGRAM([[
#       include <metalink/metalink.h>
      ]],[[
        if(0 != metalink_strerror(0)) /* added in 0.1.0 */
          return 1;
      ]])
    ],[
      AC_MSG_RESULT([yes ($version)])
      want_metalink="yes"
    ],[
      AC_MSG_RESULT([no ($version)])
      AC_MSG_NOTICE([libmetalink library defective or too old])
      want_metalink="no"
    ])
    CPPFLAGS="$clean_CPPFLAGS"
    LDFLAGS="$clean_LDFLAGS"
    LIBS="$clean_LIBS"
    if test "$want_metalink" = "yes"; then
      dnl finally libmetalink will be used
      AC_DEFINE(USE_METALINK, 1, [Define to enable metalink support])
      LIBMETALINK_LIBS=$addlib
      LIBMETALINK_LDFLAGS=$addld
      LIBMETALINK_CPPFLAGS=$addcflags
      AC_SUBST([LIBMETALINK_LIBS])
      AC_SUBST([LIBMETALINK_LDFLAGS])
      AC_SUBST([LIBMETALINK_CPPFLAGS])
      curl_mtlnk_msg="enabled"
    fi
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"
  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"
  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 **********************************************************************

versioned_symbols_flavour=
AC_MSG_CHECKING([whether versioned symbols are wanted])
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)
    AC_MSG_CHECKING([if libraries can be versioned])
    GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
    if test -z "$GLD"; then
        AC_MSG_RESULT(no)
        AC_MSG_WARN([You need an ld version supporting the --version-script option])
        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_"
        elif test "x$WINSSL_ENABLED" == "x1"; then
          versioned_symbols_flavour="WINSSL_"
        elif test "x$DARWINSSL_ENABLED" == "x1"; then
          versioned_symbols_flavour="DARWINSSL_"
        else
          versioned_symbols_flavour=""
        fi
        versioned_symbols="yes"
AC_SUBST([CURL_LT_SHLIB_VERSIONED_FLAVOUR],
  ["$versioned_symbols_flavour"])
AM_CONDITIONAL([CURL_LT_SHLIB_USE_VERSIONED_SYMBOLS],
  [test "x$versioned_symbols" = 'xyes'])
dnl -------------------------------------------------
dnl check winidn option before other IDN libraries
dnl -------------------------------------------------

AC_MSG_CHECKING([whether to enable Windows native IDN (Windows native builds only)])
OPT_WINIDN="default"
AC_ARG_WITH(winidn,
AC_HELP_STRING([--with-winidn=PATH],[enable Windows native IDN])
AC_HELP_STRING([--without-winidn], [disable Windows native IDN]),
  OPT_WINIDN=$withval)
case "$OPT_WINIDN" in
  no|default)
    dnl --without-winidn option used or configure option not specified
    want_winidn="no"
    AC_MSG_RESULT([no])
    ;;
  yes)
    dnl --with-winidn option used without path
    want_winidn="yes"
    want_winidn_path="default"
    AC_MSG_RESULT([yes])
    ;;
  *)
    dnl --with-winidn option used with path
    want_winidn="yes"
    want_winidn_path="$withval"
    AC_MSG_RESULT([yes ($withval)])
    ;;
esac

if test "$want_winidn" = "yes"; then
  dnl winidn library support has been requested
  clean_CPPFLAGS="$CPPFLAGS"
  clean_LDFLAGS="$LDFLAGS"
  clean_LIBS="$LIBS"
  WINIDN_LIBS="-lnormaliz"
  #
  if test "$want_winidn_path" != "default"; then
    dnl path has been specified
    dnl pkg-config not available or provides no info
    WINIDN_LDFLAGS="-L$want_winidn_path/lib$libsuff"
    WINIDN_CPPFLAGS="-I$want_winidn_path/include"
    WINIDN_DIR="$want_winidn_path/lib$libsuff"
  fi
  #
  CPPFLAGS="$WINIDN_CPPFLAGS $CPPFLAGS"
  LDFLAGS="$WINIDN_LDFLAGS $LDFLAGS"
  LIBS="$WINIDN_LIBS $LIBS"
  #
  AC_MSG_CHECKING([if IdnToUnicode can be linked])
  AC_LINK_IFELSE([
    AC_LANG_FUNC_LINK_TRY([IdnToUnicode])
  ],[
    AC_MSG_RESULT([yes])
    tst_links_winidn="yes"
  ],[
    AC_MSG_RESULT([no])
    tst_links_winidn="no"
  ])
  #
  if test "$tst_links_winidn" = "yes"; then
    AC_DEFINE(USE_WIN32_IDN, 1, [Define to 1 if you have the `normaliz' (WinIDN) library (-lnormaliz).])
    AC_DEFINE(WANT_IDN_PROTOTYPES, 1, [Define to 1 to provide own prototypes.])
    AC_SUBST([IDN_ENABLED], [1])
    curl_idn_msg="enabled (Windows-native)"
  else
    AC_MSG_WARN([Cannot find libraries for IDN support: IDN disabled])
    CPPFLAGS="$clean_CPPFLAGS"
    LDFLAGS="$clean_LDFLAGS"
    LIBS="$clean_LIBS"
  fi
fi
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,
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
dnl **********************************************************************
dnl Check for nghttp2
dnl **********************************************************************

AC_MSG_CHECKING([whether to build with nghttp2])
OPT_H2="no"
AC_ARG_WITH(nghttp2,
AC_HELP_STRING([--with-nghttp2=PATH],[Enable nghttp2 usage])
AC_HELP_STRING([--without-nghttp2],[Disable nghttp2 usage]),
  [OPT_H2=$withval])
case "$OPT_H2" in
  no)
    dnl --without-nghttp2 option used
    want_idn="no"
    AC_MSG_RESULT([no])
    ;;
  default)
    dnl configure option not specified
    want_h2="no"
    want_h2_path="default"
    AC_MSG_RESULT([no])
    ;;
  yes)
    dnl --with-nghttp2 option used without path
    want_h2="yes"
    want_h2_path=""
    AC_MSG_RESULT([yes])
    ;;
  *)
    dnl --with-nghttp2 option used with path
    want_h2="yes"
    want_h2_path="$withval"
    AC_MSG_RESULT([yes ($withval)])
    ;;
esac

curl_h2_msg="disabled (--with-nghttp2)"
if test X"$OPT_H2" != Xno; then
  dnl backup the pre-librtmp variables
  CLEANLDFLAGS="$LDFLAGS"
  CLEANCPPFLAGS="$CPPFLAGS"
  CLEANLIBS="$LIBS"

  h2pcdir=${want_h2_path}/lib/pkgconfig
  CURL_CHECK_PKGCONFIG(libnghttp2, $h2pcdir)

  if test "$PKGCONFIG" != "no" ; then
    LIB_H2=`CURL_EXPORT_PCDIR([$h2pcdir])
      $PKGCONFIG --libs-only-l libnghttp2`
    AC_MSG_NOTICE([-l is $LIB_H2])

    CPP_H2=`CURL_EXPORT_PCDIR([$h2pcdir]) dnl
      $PKGCONFIG --cflags-only-I libnghttp2`
    AC_MSG_NOTICE([-I is $CPP_H2])

    LD_H2=`CURL_EXPORT_PCDIR([$h2pcdir])
      $PKGCONFIG --libs-only-L libnghttp2`
    AC_MSG_NOTICE([-L is $LD_H2])

  else
    dnl To avoid link errors, we do not allow --libnghttp2 without
    dnl a pkgconfig file
    AC_MSG_ERROR([--with-nghttp2 was specified but could not find libnghttp2 pkg-config file.])
  fi

  LDFLAGS="$LDFLAGS $LD_H2"
  CPPFLAGS="$CPPFLAGS $CPP_H2"
  LIBS="$LIB_H2 $LIBS"

  AC_CHECK_LIB(nghttp2, nghttp2_session_client_new,
    [
     AC_CHECK_HEADERS(nghttp2/nghttp2.h,
        curl_h2_msg="enabled (nghttp2)"
        NGHTTP2_ENABLED=1
        AC_DEFINE(USE_NGHTTP2, 1, [if nghttp2 is in use])
        AC_SUBST(USE_NGHTTP2, [1])
     )
    ],
      dnl not found, revert back to clean variables
      LDFLAGS=$CLEANLDFLAGS
      CPPFLAGS=$CLEANCPPFLAGS
      LIBS=$CLEANLIBS
  )

fi

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
])

CURL_CONFIGURE_PULL_SYS_POLL

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_STRCMPI
CURL_CHECK_FUNC_STRDUP
CURL_CHECK_FUNC_STRERROR_R