Skip to content
acinclude.m4 47.8 KiB
Newer Older
#***************************************************************************
#                                  _   _ ____  _
#  Project                     ___| | | |  _ \| |
#                             / __| | | | |_) | |
#                            | (__| |_| |  _ <| |___
#                             \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://curl.haxx.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# $Id$
###########################################################################

dnl CURL_CHECK_HEADERS_ONCE
dnl -------------------------------------------------
dnl Check for headers if check not already done.

Yang Tse's avatar
Yang Tse committed
AC_DEFUN([CURL_CHECK_HEADERS_ONCE], [
  for f_hdr in $1
  do
Yang Tse's avatar
Yang Tse committed
    u_hdr=`echo "$f_hdr" | sed 'y/.\/-/___/'`
Yang Tse's avatar
Yang Tse committed
    eval prev_check_res=\$ac_cv_header_$u_hdr
Yang Tse's avatar
Yang Tse committed
        AC_CHECK_HEADERS($f_hdr)
dnl CURL_CHECK_HEADER_WINDOWS
dnl -------------------------------------------------
Yang Tse's avatar
Yang Tse committed
dnl Check for compilable and valid windows.h header 

AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
  AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
    AC_COMPILE_IFELSE([
      AC_LANG_PROGRAM([
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
      ],[
#ifdef __CYGWIN__
        HAVE_WINDOWS_H shall not be defined.
#else
        int dummy=2*WINVER;
      ])
    ],[
      ac_cv_header_windows_h="yes"
    ],[
      ac_cv_header_windows_h="no"
    ])
  ])
  if test "x$ac_cv_header_windows_h" = "xyes"; then
Yang Tse's avatar
Yang Tse committed
    AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
      [Define to 1 if you have the windows.h header file.])
Yang Tse's avatar
Yang Tse committed
    AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
      [Define to avoid automatic inclusion of winsock.h])
  fi
])


dnl CURL_CHECK_HEADER_WINSOCK
dnl -------------------------------------------------
Yang Tse's avatar
Yang Tse committed
dnl Check for compilable and valid winsock.h header 

AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
  AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
    AC_COMPILE_IFELSE([
      AC_LANG_PROGRAM([
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock.h>
      ],[
#ifdef __CYGWIN__
        HAVE_WINSOCK_H shall not be defined.
#else
        int dummy=WSACleanup();
      ])
    ],[
      ac_cv_header_winsock_h="yes"
    ],[
      ac_cv_header_winsock_h="no"
    ])
  ])
  if test "x$ac_cv_header_winsock_h" = "xyes"; then
Yang Tse's avatar
Yang Tse committed
    AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
      [Define to 1 if you have the winsock.h header file.])
  fi
])


dnl CURL_CHECK_HEADER_WINSOCK2
dnl -------------------------------------------------
Yang Tse's avatar
Yang Tse committed
dnl Check for compilable and valid winsock2.h header 

AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
  AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
  AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
    AC_COMPILE_IFELSE([
      AC_LANG_PROGRAM([
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
      ],[
#ifdef __CYGWIN__
        HAVE_WINSOCK2_H shall not be defined.
#else
        int dummy=2*IPPROTO_ESP;
      ])
    ],[
      ac_cv_header_winsock2_h="yes"
    ],[
      ac_cv_header_winsock2_h="no"
    ])
  ])
  if test "x$ac_cv_header_winsock2_h" = "xyes"; then
Yang Tse's avatar
Yang Tse committed
    AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
      [Define to 1 if you have the winsock2.h header file.])
  fi
])


dnl CURL_CHECK_HEADER_WS2TCPIP
dnl -------------------------------------------------
Yang Tse's avatar
Yang Tse committed
dnl Check for compilable and valid ws2tcpip.h header

AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
  AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
    AC_COMPILE_IFELSE([
      AC_LANG_PROGRAM([
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
      ],[
#ifdef __CYGWIN__
        HAVE_WS2TCPIP_H shall not be defined.
#else
        int dummy=2*IP_PKTINFO;
      ])
    ],[
      ac_cv_header_ws2tcpip_h="yes"
    ],[
      ac_cv_header_ws2tcpip_h="no"
    ])
  ])
  if test "x$ac_cv_header_ws2tcpip_h" = "xyes"; then
Yang Tse's avatar
Yang Tse committed
    AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
      [Define to 1 if you have the ws2tcpip.h header file.])
  fi
])


dnl CURL_CHECK_TYPE_SOCKLEN_T
dnl -------------------------------------------------
Yang Tse's avatar
Yang Tse committed
dnl Check for existing socklen_t type, and provide
dnl an equivalent type if socklen_t not available

AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
  AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
  AC_CHECK_TYPE([socklen_t], ,[
Yang Tse's avatar
Yang Tse committed
    AC_CACHE_CHECK([for socklen_t equivalent], 
      [curl_cv_socklen_t_equiv], [
Yang Tse's avatar
Yang Tse committed
      curl_cv_socklen_t_equiv="unknown"
Yang Tse's avatar
Yang Tse committed
      for arg2 in "struct sockaddr" void; do
        for t in int size_t unsigned long "unsigned long"; do
          AC_COMPILE_IFELSE([
            AC_LANG_PROGRAM([
Loading
Loading full blame…