1 # Macro to check if websockets support was enabled. This macro also
2 # takes care of detecting older versions of libwebsockets (lacking
3 # pkg-config support, no per-context userdata) and propagating this
4 # information to config.h and the compilation process.
7 AC_DEFUN([CHECK_WEBSOCKETS],
10 AC_ARG_ENABLE(websockets,
11 [ --enable-websockets enable websockets support],
12 [enable_websockets=$enableval], [enable_websockets=auto])
14 # Check if we have properly packaged libwebsockets (json-c is now mandatory
15 # and already has been tested for).
16 if test "$enable_websockets" != "no"; then
17 PKG_CHECK_MODULES(WEBSOCKETS, [libwebsockets],
18 [have_websockets=yes], [have_websockets=no])
20 # Now check for older websockets.
21 saved_LDFLAGS="$LDFLAGS"
22 LDFLAGS="-lwebsockets"
23 AC_MSG_CHECKING([for WEBSOCKETS without pkg-config support])
27 #include <libwebsockets.h>]],
28 [[struct libwebsocket_context *ctx;
29 ctx = libwebsocket_create_context(0, NULL, NULL, NULL,
31 -1, -1, 0, NULL);]])],
32 [have_websockets=yes],
34 AC_MSG_RESULT([$have_websockets])
36 # If still no luck, check for a really old libwebsockets
37 # still without per-context user data.
38 if test "$have_websockets" = "no"; then
39 AC_MSG_CHECKING([for really old WEBSOCKETS])
43 #include <libwebsockets.h>]],
44 [[struct libwebsocket_context *ctx;
45 ctx = libwebsocket_create_context(0, NULL, NULL, NULL,
48 [have_websockets=yes;old_websockets=yes],
50 AC_MSG_RESULT([$have_websockets])
54 WEBSOCKETS_LIBS="-lwebsockets"
55 if test "$old_websockets" = "yes"; then
56 WEBSOCKETS_CFLAGS="$WEBSOCKET_CFLAGS -DWEBSOCKETS_OLD"
58 LDFLAGS="$saved_LDFLAGS"
60 AC_MSG_NOTICE([libwebsockets support is disabled.])
63 # Bail out if we lack mandatory support.
64 if test "$enable_websockets" = "yes" -a "$have_websockets" = "no"; then
65 AC_MSG_ERROR([libwebsockets development libraries not found.])
68 # Enable if found and autosupport requested.
69 if test "$enable_websockets" = "auto"; then
70 enable_websockets=$have_websockets
73 # If enabled, set up our autoconf variables accordingly.
74 if test "$enable_websockets" = "yes"; then
75 AC_DEFINE([WEBSOCKETS_ENABLED], 1, [Enable websockets support ?])
76 if test "$old_websockets" = "yes"; then
77 AC_DEFINE([WEBSOCKETS_OLD], 1, [No per-context userdata ?])
81 # Finally substitute everything.
82 AM_CONDITIONAL(WEBSOCKETS_ENABLED, [test "$enable_websockets" = "yes"])
83 AM_CONDITIONAL(WEBSOCKETS_OLD, [test "$old_websockets" = "yes"])
84 AC_SUBST(WEBSOCKETS_ENABLED)
85 AC_SUBST(WEBSOCKETS_CFLAGS)
86 AC_SUBST(WEBSOCKETS_LIBS)
87 AC_SUBST(WEBSOCKETS_OLD)