aboutsummaryrefslogtreecommitdiffstats
path: root/m4/libmemcache.m4
blob: 95e630bbc9701dd6e18375a1f207fc9565840b25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
dnl Check for memcache client libraries
dnl CHECK_MEMCACHE(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN([CHECK_MEMCACHE],
[dnl

AC_ARG_WITH(
    memcache,
    [AC_HELP_STRING([--with-memcache=PATH],[Path memcache libraries])],
    mc_path="$withval",
    :)

dnl # Determine memcache lib directory
if test -z $mc_path; then
    test_paths="/usr/lib /usr/local/lib"
else
    test_paths="${mc_path}/lib"
fi

for x in $test_paths ; do
    AC_MSG_CHECKING([for memcache library in ${x}])
    if test -f ${x}/libmemcache.so.1.0; then
        AC_MSG_RESULT([yes])
        save_CFLAGS=$CFLAGS
        save_LDFLAGS=$LDFLAGS
        CFLAGS="$CFLAGS"
        LDFLAGS="-L$x $LDFLAGS"
        AC_CHECK_LIB(memcache, mc_server_add,
            LIBMEMCACHE_LIBS="-L$x -lmemcache")
        CFLAGS=$save_CFLAGS
        LDFLAGS=$save_LDFLAGS
        break
    else
        AC_MSG_RESULT([no])
    fi
done

AC_SUBST(LIBMEMCACHE_LIBS)

if test -z "${LIBMEMCACHE_LIBS}"; then
  AC_MSG_NOTICE([*** memcache library not found.])
  ifelse([$2], , AC_MSG_ERROR([memcache library is required]), $2)
else
  AC_MSG_NOTICE([using '${LIBMEMCACHE_LIBS}' for memcache])
  ifelse([$1], , , $1) 
fi 
])