ZIL: Assert record sizes in different places
[zfs.git] / config / user-libfetch.m4
blobd961c6ca77a197e85151a06c935842fd16ff5038
1 dnl #
2 dnl # Check for a libfetch - either fetch(3) or libcurl.
3 dnl #
4 dnl # There are two configuration dimensions:
5 dnl #   * fetch(3) vs libcurl
6 dnl #   * static vs dynamic
7 dnl #
8 dnl # fetch(3) is only dynamic.
9 dnl # We use sover 6, which first appeared in FreeBSD 8.0-RELEASE.
10 dnl #
11 dnl # libcurl development packages include curl-config(1) – we want:
12 dnl #   * HTTPS support
13 dnl #   * version at least 7.16 (October 2006), for sover 4
14 dnl #   * to decide if it's static or not
15 dnl #
16 AC_DEFUN([ZFS_AC_CONFIG_USER_LIBFETCH], [
17         AC_MSG_CHECKING([for libfetch])
18         LIBFETCH_LIBS=
19         LIBFETCH_IS_FETCH=0
20         LIBFETCH_IS_LIBCURL=0
21         LIBFETCH_DYNAMIC=0
22         LIBFETCH_SONAME=
23         have_libfetch=
25         saved_libs="$LIBS"
26         LIBS="$LIBS -lfetch"
27         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
28                 #include <sys/param.h>
29                 #include <stdio.h>
30                 #include <fetch.h>
31         ]], [fetchGetURL("", "");])], [
32                 have_libfetch=1
33                 LIBFETCH_IS_FETCH=1
34                 LIBFETCH_DYNAMIC=1
35                 LIBFETCH_SONAME="libfetch.so.6"
36                 LIBFETCH_LIBS="-ldl"
37                 AC_MSG_RESULT([fetch(3)])
38         ], [])
39         LIBS="$saved_libs"
41         if test -z "$have_libfetch"; then
42                 if curl-config --protocols 2>/dev/null | grep -q HTTPS &&
43                     test "$(printf "%u" "0x$(curl-config --vernum)")" -ge "$(printf "%u" "0x071000")"; then
44                         have_libfetch=1
45                         LIBFETCH_IS_LIBCURL=1
46                         if test "$(curl-config --built-shared)" = "yes"; then
47                                 LIBFETCH_DYNAMIC=1
48                                 LIBFETCH_SONAME="libcurl.so.4"
49                                 LIBFETCH_LIBS="-ldl"
50                                 AC_MSG_RESULT([libcurl])
51                         else
52                                 LIBFETCH_LIBS="$(curl-config --libs)"
53                                 AC_MSG_RESULT([libcurl (static)])
54                         fi
56                         CCFLAGS="$CCFLAGS $(curl-config --cflags)"
57                 fi
58         fi
60         if test -z "$have_libfetch"; then
61                 AC_MSG_RESULT([none])
62         fi
64         AC_SUBST([LIBFETCH_LIBS])
65         AC_SUBST([LIBFETCH_DYNAMIC])
66         AC_SUBST([LIBFETCH_SONAME])
67         AC_DEFINE_UNQUOTED([LIBFETCH_IS_FETCH], [$LIBFETCH_IS_FETCH], [libfetch is fetch(3)])
68         AC_DEFINE_UNQUOTED([LIBFETCH_IS_LIBCURL], [$LIBFETCH_IS_LIBCURL], [libfetch is libcurl])
69         AC_DEFINE_UNQUOTED([LIBFETCH_DYNAMIC], [$LIBFETCH_DYNAMIC], [whether the chosen libfetch is to be loaded at run-time])
70         AC_DEFINE_UNQUOTED([LIBFETCH_SONAME], ["$LIBFETCH_SONAME"], [soname of chosen libfetch])