xiph_curl.m4 1.73 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
dnl XIPH_PATH_CURL([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Test for libcurl, and define CURL_CFLAGS and CURL_LIBS
dnl
AC_DEFUN(XIPH_PATH_CURL,
[dnl 
dnl Get the cflags and libraries
dnl
AC_ARG_WITH(curl,
    AC_HELP_STRING([--with-curl=PFX],[Prefix where libcurl is installed (optional)]),
    curl_prefix="$withval", curl_prefix="")
AC_ARG_WITH(curl-config,
    AC_HELP_STRING([--with-curl-config=curl-config],[Use curl-config to find libcurl]),
    CURL_CONFIG="$withval", [AC_PATH_PROGS(CURL_CONFIG, [curl-config], "")])

if test "x$curl_prefix" != "x"; then
    CURL_LIBS="-L$curl_prefix/lib -lcurl"
    CURL_CFLAGS="-I$curl_prefix/include"
elif test "x$CURL_CONFIG" != "x"; then
    if ! test -x "$CURL_CONFIG"; then
        AC_MSG_ERROR([$CURL_CONFIG cannot be executed])
    fi
    CURL_LIBS="$($CURL_CONFIG --libs)"
    CURL_CFLAGS="$($CURL_CONFIG --cflags)"
else
25 26 27 28
    if test "x$prefix" = "xNONE"; then
        curl_prefix="/usr/local"
    else
        curl_prefix="$prefix"
29
    fi
30 31
    CURL_LIBS="-L$curl_prefix/lib -lcurl"
    CURL_CFLAGS="-I$curl_prefix/include"
32 33 34 35
fi

curl_ok="yes"

36
ac_curl_CPPFLAGS="$CPPFLAGS"
37
ac_curl_LIBS="$LIBS"
38 39
CPPFLAGS="$CPPFLAGS $CURL_CFLAGS"
LIBS="$CURL_LIBS $LIBS"
40 41 42 43 44 45
dnl
dnl Now check if the installed libcurl is sufficiently new.
dnl
AC_CHECK_HEADERS([curl/curl.h],, curl_ok="no") 
AC_MSG_CHECKING(for libcurl)
if test "$curl_ok" = "yes"; then
46
    AC_RUN_IFELSE([
47 48 49 50 51 52 53
#include <curl/curl.h>
int main()
{
    return 0;
}
],,[curl_ok="no"])
fi
54
CPPFLAGS="$ac_curl_CPPFLAGS"
55 56 57 58 59 60 61 62
LIBS="$ac_curl_LIBS"

if test "$curl_ok" = "yes"; then
    AC_MSG_RESULT(yes)
    AC_DEFINE(HAVE_CURL, 1, [Define if you have libcurl.])
    ifelse([$1], , :, [$1])     
else
    AC_MSG_RESULT(no)
63 64
    CURL_LIBS=""
    CURL_CFLAGS=""
65 66 67
    ifelse([$2], , :, [$2])
fi
])