m4: merge TangentOrg/ddm4
[awesomized/libmemcached] / m4 / ax_libuv.m4
1 # https://github.com/BrianAker/ddm4
2 # ===========================================================================
3 #
4 # SYNOPSIS
5 #
6 # AX_LIBUV([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
7 #
8 # DESCRIPTION
9 #
10 # libuv library
11 #
12 # LICENSE
13 #
14 # Copyright (c) 2012 Brian Aker <brian@tangent.org>
15 # Copyright (c) 2014 Andrew Hutchings <andrew@linuxjedi.co.uk>
16 #
17 # Copying and distribution of this file, with or without modification, are
18 # permitted in any medium without royalty provided the copyright notice
19 # and this notice are preserved. This file is offered as-is, without any
20 # warranty.
21
22 #serial 1
23
24 AC_DEFUN([AX_LIBUV],
25 [AC_PREREQ([2.63])dnl
26 AC_CACHE_CHECK([test for a working libuv],[ax_cv_libuv],
27 [AX_SAVE_FLAGS
28 LIBS="-luv $LIBS"
29 AC_LANG_PUSH([C])
30 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
31 #include <uv.h>
32 ]],[[
33 uv_loop_t *loop;
34 loop = uv_loop_new();
35 ]])],
36 [ax_cv_libuv=yes],
37 [ax_cv_libuv=no],
38 [AC_MSG_WARN([test program execution failed])])
39 AC_LANG_POP
40 AX_RESTORE_FLAGS
41 ])
42
43 AS_IF([test "x$ax_cv_libuv" = "xyes"],
44 [AC_SUBST([LIBUV_LIB],[-luv])
45 AC_DEFINE([HAVE_LIBUV],[1],[Define if uv_loop_new is present in uv.h.])],
46 [AC_DEFINE([HAVE_LIBUV],[0],[Define if uv_loop_new is present in uv.h.])])
47
48 AM_CONDITIONAL(HAVE_LIBUV, test "x$ax_cv_libuv" = "xyes")
49 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
50 AS_IF([test "x$ax_cv_libuv" = xyes],
51 [$1],
52 [$2])
53 ])