From 59af90b08c705a66bdca7551b43257781db47711 Mon Sep 17 00:00:00 2001 From: Timotej S <6674623+underhood@users.noreply.github.com> Date: Mon, 14 Jun 2021 10:38:58 +0200 Subject: Allows ACLK NG and Legacy to coexist (#11225) --- configure.ac | 153 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 81 insertions(+), 72 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 108056d959..9d0865e15a 100644 --- a/configure.ac +++ b/configure.ac @@ -193,12 +193,20 @@ AC_ARG_ENABLE( [ enable_cloud="detect" ] ) +AC_ARG_WITH( + [aclk-legacy], + [AS_HELP_STRING([--with-aclk-legacy], + [Requires Legacy ACLK to be used even in case ACLK-NG can run on this system])], + [aclk_legacy="$withval"], + [aclk_legacy="detect"] +) + AC_ARG_WITH( [aclk-ng], [AS_HELP_STRING([--with-aclk-ng], [Requires ACLK-NG to be used even in case ACLK Legacy can run on this system])], [aclk_ng="$withval"], - [aclk_ng="fallback"] + [aclk_ng="detect"] ) if test "${enable_cloud}" = "no"; then @@ -634,11 +642,64 @@ AM_CONDITIONAL([ENABLE_CAPABILITY], [test "${with_libcap}" = "yes"]) # ----------------------------------------------------------------------------- # ACLK -AC_MSG_CHECKING([if cloud functionality should be enabled]) +AC_MSG_CHECKING([if Cloud functionality should be enabled]) AC_MSG_RESULT([${enable_cloud}]) -if test "$enable_cloud" != "no" -a "$aclk_ng" != "yes"; then - # just to have all messages that can fail ACLK build in one place - # so it is easier to see why it can't be built +if test "$aclk_ng" = "no"; then + AC_DEFINE([ACLK_NG_DISABLED], [1], [ACLK NG was disabled by user request]) +fi +if test "$aclk_legacy" = "no"; then + AC_DEFINE([ACLK_LEGACY_DISABLED], [1], [ACLK Legacy was disabled by user request]) +fi + +if test "$enable_cloud" = "no" -a "$aclk_legacy" = "yes"; then + AC_MSG_ERROR([--disable-cloud && --with-aclk-legacy not allowed together (such configuration is self contradicting)]) +fi + +if test "$enable_cloud" = "no" -a "$aclk_ng" = "yes"; then + AC_MSG_ERROR([--disable-cloud && --with-aclk-ng not allowed together (such configuration is self contradicting)]) +fi + +if test "$enable_cloud" != "no" -a "$aclk_ng" != "no"; then + AC_MSG_NOTICE([Checking if ACLK Next Generation can be built]) + can_enable_ng="yes" + AC_MSG_CHECKING([if git submodules present for ACLK Next Generation]) + if test -f "mqtt_websockets/src/mqtt_wss_client.c"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + can_enable_ng="no" + fi + AC_MSG_CHECKING([if SSL available for ACLK Next Generation]) + if test -n "${SSL_LIBS}"; then + AC_MSG_RESULT([yes]) + OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}" + OPTIONAL_SSL_LIBS="${SSL_LIBS}" + else + AC_MSG_RESULT([no]) + fi + AC_MSG_CHECKING([if JSON-C available for ACLK Next Generation]) + if test "$enable_jsonc" != "yes"; then + AC_MSG_RESULT([no]) + can_enable_ng="no" + else + AC_MSG_RESULT([yes]) + fi + AC_MSG_CHECKING([ACLK Next Generation can be built]) + AC_MSG_RESULT([${can_enable_ng}]) + if test "$can_enable_ng" = "no" -a "$aclk_ng" = "yes"; then + AC_MSG_ERROR([You have requested --with-aclk-ng but it can't be built. See reasons in lines above]) + fi + if test "$can_enable_ng" = "yes"; then + aclk_ng="yes" + enable_aclk="yes" + AC_DEFINE([ACLK_NG], [1], [ACLK Next Generation Should be used]) + AC_DEFINE([ENABLE_ACLK], [1], [netdata ACLK]) + OPTIONAL_ACLK_NG_CFLAGS="-I \$(abs_top_srcdir)/mqtt_websockets/src/include -I \$(abs_top_srcdir)/mqtt_websockets/c-rbuf/include -I \$(abs_top_srcdir)/mqtt_websockets/MQTT-C/include" + fi +fi + +if test "$enable_cloud" != "no" -a "$aclk_legacy" != "no"; then + AC_MSG_NOTICE([Checking if ACLK Legacy can be built]) if test -n "${SSL_LIBS}"; then OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}" OPTIONAL_SSL_LIBS="${SSL_LIBS}" @@ -665,7 +726,7 @@ if test "$enable_cloud" != "no" -a "$aclk_ng" != "yes"; then AC_MSG_RESULT([${HAVE_libmosquitto_a}]) if test "${with_bundled_lws}" = "yes"; then - AC_MSG_CHECKING([if libwebsockets static lib is present]) + AC_MSG_CHECKING([if libwebsockets static lib is present for ACLK Legacy]) if test -f "externaldeps/libwebsockets/libwebsockets.a"; then LWS_CFLAGS="-I \$(abs_top_srcdir)/externaldeps/libwebsockets/include" OPTIONAL_LWS_LIBS="\$(abs_top_srcdir)/externaldeps/libwebsockets/libwebsockets.a" @@ -677,7 +738,7 @@ if test "$enable_cloud" != "no" -a "$aclk_ng" != "yes"; then # as currently this is default we prefer building netdata without ACLK # instead of error fail AC_MSG_RESULT([no]) - AC_MSG_WARN([You required static libwebsockets to be used but we can't use it. Disabling ACLK]) + AC_MSG_WARN([You required static libwebsockets to be used but we can't use it. Disabling ACLK Legacy]) fi else AC_CHECK_LIB([websockets], @@ -686,7 +747,7 @@ if test "$enable_cloud" != "no" -a "$aclk_ng" != "yes"; then [AC_DEFINE([ACLK_NO_LWS], [1], [usable system libwebsockets was not found during build.])]) fi - if test "${build_target}" = "linux" -a "${enable_cloud}" != "no"; then + if test "${build_target}" = "linux"; then if test "${have_libcap}" = "yes" -a "${with_libcap}" = "no"; then AC_MSG_ERROR([agent-cloud-link can't be built without libcap. Disable it by --disable-cloud or enable libcap]) fi @@ -696,85 +757,33 @@ if test "$enable_cloud" != "no" -a "$aclk_ng" != "yes"; then fi # next 2 lines are just to have info for ACLK dependencies in common place - AC_MSG_CHECKING([if json-c available for ACLK]) + AC_MSG_CHECKING([if json-c available for ACLK Legacy]) AC_MSG_RESULT([${enable_jsonc}]) - test "${enable_cloud}" = "yes" -a "${enable_jsonc}" = "no" && \ - AC_MSG_ERROR([You have asked for ACLK to be built but no json-c available. ACLK requires json-c]) - - AC_MSG_CHECKING([if netdata agent-cloud-link can be enabled]) + AC_MSG_CHECKING([if netdata ACLK Legacy can be built]) if test "${HAVE_libmosquitto_a}" = "yes" -a -n "${OPTIONAL_LWS_LIBS}" -a -n "${SSL_LIBS}" -a "${enable_jsonc}" = "yes"; then - can_enable_aclk="yes" + can_build_legacy="yes" else - can_enable_aclk="no" + can_build_legacy="no" fi - AC_MSG_RESULT([${can_enable_aclk}]) - -# TODO fix this (you need to try fallback) - test "${enable_cloud}" = "yes" -a "${can_enable_aclk}" = "no" && \ - AC_MSG_ERROR([User required agent-cloud-link but it can't be built!]) + AC_MSG_RESULT([${can_build_legacy}]) - AC_MSG_CHECKING([if netdata agent-cloud-link should/will be enabled]) - if test "${enable_cloud}" = "detect"; then - enable_aclk=$can_enable_aclk - else - enable_aclk=$enable_cloud + if test "$can_build_legacy" = "no" -a "$aclk_legacy" = "yes"; then + AC_MSG_ERROR([You have requested --with-aclk-legacy but it can't be built. See reasons in lines above]) fi - if test "${enable_aclk}" = "yes"; then - AC_DEFINE([ENABLE_ACLK], [1], [netdata ACLK]) - fi - - AC_MSG_RESULT([${enable_aclk}]) -fi - -if test "$enable_cloud" = "no" -a "$aclk_ng" = "yes"; then - AC_MSG_ERROR([--disable-cloud && --aclk-ng not allowed together (such configuration is self contradicting)]) -fi - -if test "$enable_cloud" != "no" -a "$aclk_ng" != "no"; then - can_enable_ng="yes" - AC_MSG_CHECKING([if git submodules present for ACLK Next Generation]) - if test -f "mqtt_websockets/src/mqtt_wss_client.c"; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - can_enable_ng="no" - fi - AC_MSG_CHECKING([if SSL available for ACLK Next Generation]) - if test -n "${SSL_LIBS}"; then - AC_MSG_RESULT([yes]) - OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}" - OPTIONAL_SSL_LIBS="${SSL_LIBS}" - else - AC_MSG_RESULT([no]) - fi - AC_MSG_CHECKING([if JSON-C available for ACLK Next Generation]) - if test "$enable_jsonc" != "yes"; then - AC_MSG_RESULT([no]) - can_enable_ng="no" - else - AC_MSG_RESULT([yes]) - fi - AC_MSG_CHECKING([ACLK Next Generation can be built]) - AC_MSG_RESULT([${can_enable_ng}]) - if test "$aclk_ng" = "yes" -a "$can_enable_ng" != "yes"; then - AC_MSG_ERROR([ACLK-NG requested but can't be built]) - fi - if test "$aclk_ng" != "yes" -a "$enable_aclk" == "no" -a "$can_enable_ng" = "yes"; then #default "fallback" - AC_MSG_NOTICE([ACLK Legacy could not be built. Trying ACLK-NG as fallback.]) - aclk_ng="yes" - fi - if test "$aclk_ng" = "yes"; then - AC_DEFINE([ACLK_NG], [1], [ACLK Next Generation Should be used]) + if test "$can_build_legacy" = "yes"; then + AC_DEFINE([ACLK_LEGACY], [1], [ACLK Legacy Should be used]) AC_DEFINE([ENABLE_ACLK], [1], [netdata ACLK]) + aclk_legacy="yes" enable_aclk="yes" - OPTIONAL_ACLK_NG_CFLAGS="-I \$(abs_top_srcdir)/mqtt_websockets/src/include -I \$(abs_top_srcdir)/mqtt_websockets/c-rbuf/include -I \$(abs_top_srcdir)/mqtt_websockets/MQTT-C/include" fi fi + AC_SUBST([enable_cloud]) AC_SUBST([enable_aclk]) AM_CONDITIONAL([ACLK_NG], [test "${aclk_ng}" = "yes"]) +AM_CONDITIONAL([ACLK_LEGACY], [test "${aclk_legacy}" = "yes"]) AM_CONDITIONAL([ENABLE_ACLK], [test "${enable_aclk}" = "yes"]) # ----------------------------------------------------------------------------- -- cgit v1.2.3