AUTOMAKE_OPTIONS = gnu
-SUBDIRS = catta src doc test examples
+if CATTA
+MAYBE_CATTA = catta
+endif
+
+SUBDIRS = $(MAYBE_CATTA) src doc test examples
+
+DIST_SUBDIRS = $(SUBDIRS)
ACLOCAL_AMFLAGS = -I m4
AM_INIT_AUTOMAKE([std-options subdir-objects nostdinc silent-rules -Wall])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_SUBDIRS([catta])
AM_SILENT_RULES([yes])
# Enable GNU extensions.
]
);
+dnl Allow building without Catta
+AC_ARG_ENABLE([catta], AS_HELP_STRING([--disable-catta], [disable linking with the Catta library]))
+AS_IF([test "x$enable_catta" != "xno"],
+ AC_DEFINE(HAVE_CATTA, 1, [Link with Catta])
+ AC_CONFIG_SUBDIRS([catta])
+)
+AM_CONDITIONAL(CATTA, test "x$enable_catta" != "xno")
+
dnl UTCP debug flags
AC_ARG_ENABLE([utcp_debug], AS_HELP_STRING([--enable-utcp-debug], [compile utcp with debug output]))
AS_IF([test "x$enable_utcp_debug" = "xyes"],
AM_LDFLAGS = $(PTHREAD_LIBS)
meshlinkapp_SOURCES = meshlinkapp.c
-meshlinkapp_LDADD = ${top_builddir}/src/libmeshlink.la ${top_builddir}/catta/src/libcatta.la
+meshlinkapp_LDADD = ${top_builddir}/src/libmeshlink.la
chat_SOURCES = chat.c
-chat_LDADD = ${top_builddir}/src/libmeshlink.la ${top_builddir}/catta/src/libcatta.la
+chat_LDADD = ${top_builddir}/src/libmeshlink.la
chatpp_SOURCES = chatpp.cc
-chatpp_LDADD = ${top_builddir}/src/libmeshlink.la ${top_builddir}/catta/src/libcatta.la
+chatpp_LDADD = ${top_builddir}/src/libmeshlink.la
manynodes_SOURCES = manynodes.c
-manynodes_LDADD = ${top_builddir}/src/libmeshlink.la ${top_builddir}/catta/src/libcatta.la
+manynodes_LDADD = ${top_builddir}/src/libmeshlink.la
channels_SOURCES = channels.c
-channels_LDADD = ${top_builddir}/src/libmeshlink.la ${top_builddir}/catta/src/libcatta.la
+channels_LDADD = ${top_builddir}/src/libmeshlink.la
ed25519_SOURCES = \
ed25519/add_scalar.c \
+ ed25519/ecdh.c \
+ ed25519/ecdsa.c \
+ ed25519/ecdsagen.c \
ed25519/ed25519.h \
ed25519/fe.c ed25519/fe.h \
ed25519/fixedint.h \
conf.c conf.h \
connection.c connection.h \
crypto.c crypto.h \
- discovery.c discovery.h \
dropin.c dropin.h \
ecdh.h \
ecdsa.h \
$(chacha_poly1305_SOURCES) \
$(utcp_SOURCES)
-libmeshlink_la_CFLAGS = $(PTHREAD_CFLAGS) -fPIC -I${top_srcdir}/catta/include/ -iquote.
+libmeshlink_la_CFLAGS = $(PTHREAD_CFLAGS) -fPIC -iquote.
+libmeshlink_la_LDFLAGS += $(PTHREAD_LIBS)
+
+if CATTA
+libmeshlink_la_SOURCES += \
+ discovery.c discovery.h
+
+libmeshlink_la_CFLAGS += -I${top_srcdir}/catta/include/
if MINGW
libmeshlink_la_CFLAGS += -I${top_srcdir}/catta/src/compat/windows/include/
endif
-libmeshlink_la_LDFLAGS += $(PTHREAD_LIBS)
libmeshlink_la_LIBADD = ${top_builddir}/catta/src/libcatta.la
-
-libmeshlink_la_SOURCES += \
- ed25519/ecdh.c \
- ed25519/ecdsa.c \
- ed25519/ecdsagen.c
+endif
/*
meshlink.c -- Implementation of the MeshLink API.
- Copyright (C) 2014, 2017 Guus Sliepen <guus@meshlink.io>
+ Copyright (C) 2014-2018 Guus Sliepen <guus@meshlink.io>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
mesh->threadstarted = true;
+#if HAVE_CATTA
if(mesh->discovery) {
discovery_start(mesh);
}
+#endif
pthread_mutex_unlock(&(mesh->mesh_mutex));
return true;
pthread_mutex_lock(&(mesh->mesh_mutex));
logger(mesh, MESHLINK_DEBUG, "meshlink_stop called\n");
+#if HAVE_CATTA
// Stop discovery
if(mesh->discovery) {
discovery_stop(mesh);
}
+#endif
// Shut down the main thread
event_loop_stop(&mesh->loop);
}
void meshlink_enable_discovery(meshlink_handle_t *mesh, bool enable) {
+#if HAVE_CATTA
if(!mesh) {
meshlink_errno = MESHLINK_EINVAL;
return;
end:
pthread_mutex_unlock(&mesh->mesh_mutex);
+#else
+ (void)mesh;
+ (void)enable;
+ meshlink_errno = MESHLINK_ENOTSUP;
+#endif
}
static void __attribute__((constructor)) meshlink_init(void) {
/*
meshlink.h -- MeshLink API
- Copyright (C) 2014, 2017 Guus Sliepen <guus@meshlink.io>
+ Copyright (C) 2014-2018 Guus Sliepen <guus@meshlink.io>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
MESHLINK_ESTORAGE, ///< MeshLink coud not load or write data from/to disk
MESHLINK_ENETWORK, ///< MeshLink encountered a network error
MESHLINK_EPEER, ///< A peer caused an error
+ MESHLINK_ENOTSUP, ///< The operation is not supported in the current configuration of MeshLink
} meshlink_errno_t;
/// Device class