Browse Source

Check if ACLK can be built (#8030)

* if ACLK enabled require libwebsockets.a
Timo 5 years ago
parent
commit
d06af6600a
3 changed files with 55 additions and 10 deletions
  1. 1 1
      Makefile.am
  2. 1 1
      aclk/mqtt.h
  3. 53 8
      configure.ac

+ 1 - 1
Makefile.am

@@ -594,7 +594,7 @@ netdata_SOURCES = $(NETDATA_FILES)
 
 if ENABLE_ACLK
 netdata_LDADD = \
-    mosquitto/lib/libmosquitto.a \
+    externaldeps/mosquitto/libmosquitto.a \
     $(NETDATA_COMMON_LIBS) \
     $(NULL)
 else

+ 1 - 1
aclk/mqtt.h

@@ -4,7 +4,7 @@
 #define NETDATA_MQTT_H
 
 #ifdef ENABLE_ACLK
-#include "mosquitto/lib/mosquitto.h"
+#include "externaldeps/mosquitto/mosquitto.h"
 #endif
 
 void _show_mqtt_info();

+ 53 - 8
configure.ac

@@ -161,6 +161,14 @@ AC_ARG_ENABLE(
     ,
     [enable_jsonc="detect"]
 )
+if test "${ACLK}" = "yes"; then
+AC_ARG_ENABLE(
+    [aclk],
+    ,
+    [aclk_required="${enableval}"],
+    [aclk_required="detect"]
+)
+fi
 
 # -----------------------------------------------------------------------------
 # netdata required checks
@@ -295,6 +303,17 @@ AC_CHECK_LIB(
     [LZ4_LIBS="-llz4"]
 )
 
+# -----------------------------------------------------------------------------
+# libwebsockets pure C library for implementing modern network protocols
+
+if test "${ACLK}" = "yes"; then
+    AC_CHECK_LIB(
+        [websockets],
+        [lws_set_timer_usecs],
+        [LWS_LIBS="-lwebsockets"]
+    )
+fi
+
 
 # -----------------------------------------------------------------------------
 # Judy General purpose dynamic array
@@ -409,15 +428,41 @@ AM_CONDITIONAL([ENABLE_HTTPS], [test "${enable_https}" = "yes"])
 
 # -----------------------------------------------------------------------------
 # ACLK
-AC_MSG_CHECKING([if netdata ACLK should be enabled])
+
+#currenlty env var ACLK must be set to 'yes' to even consider building ACLK
 if test "${ACLK}" = "yes"; then
-    enable_aclk="yes"
-    AC_DEFINE([ENABLE_ACLK], [1], [netdata ACLK])
-    CFLAGS="${CFLAGS} -DENABLE_ACLK"
-else
-    enable_aclk="no"
+    AC_MSG_CHECKING([if libmosquitto static lib is present])
+    if test -f "externaldeps/mosquitto/libmosquitto.a"; then
+        HAVE_libmosquitto_a="yes"
+    else 
+        HAVE_libmosquitto_a="no"
+    fi
+    AC_MSG_RESULT([${HAVE_libmosquitto_a}])
+
+    AC_MSG_CHECKING([if netdata agent-cloud-link can be enabled])
+    if test "${HAVE_libmosquitto_a}" = "yes" -a -n "${LWS_LIBS}"; then
+        can_enable_aclk="yes"
+    else
+        can_enable_aclk="no"
+    fi
+    AC_MSG_RESULT([${can_enable_aclk}])
+
+    test "${aclk_required}" = "yes" -a "${can_enable_aclk}" = "no" && \
+        AC_MSG_ERROR([User required agent-cloud-link but it can't be built!])
+
+    AC_MSG_CHECKING([if netdata agent-cloud-link should/will be enabled])
+    if test "${aclk_required}" = "detect"; then
+        enable_aclk=$can_enable_aclk
+    else
+        enable_aclk=$aclk_required
+    fi
+
+    if test "${enable_aclk}" = "yes"; then
+        AC_DEFINE([ENABLE_ACLK], [1], [netdata ACLK])
+    fi
+
+    AC_MSG_RESULT([${enable_aclk}])
 fi
-AC_MSG_RESULT([${enable_aclk}])
 AM_CONDITIONAL([ENABLE_ACLK], [test "${enable_aclk}" = "yes"])
 
 # -----------------------------------------------------------------------------
@@ -1129,7 +1174,7 @@ AC_SUBST([webdir])
 
 CFLAGS="${CFLAGS} ${OPTIONAL_MATH_CFLAGS} ${OPTIONAL_NFACCT_CFLAGS} ${OPTIONAL_ZLIB_CFLAGS} ${OPTIONAL_UUID_CFLAGS} \
     ${OPTIONAL_LIBCAP_CFLAGS} ${OPTIONAL_IPMIMONITORING_CFLAGS} ${OPTIONAL_CUPS_CFLAGS} ${OPTIONAL_XENSTAT_FLAGS} \
-    ${OPTIONAL_KINESIS_CFLAGS} ${OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS} ${OPTIONAL_MONGOC_CFLAGS}"
+    ${OPTIONAL_KINESIS_CFLAGS} ${OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS} ${OPTIONAL_MONGOC_CFLAGS} ${LWS_LIBS}"
 
 CXXFLAGS="${CFLAGS} ${CXX11FLAG}"