]> git.meshlink.io Git - meshlink/commitdiff
Allow compiling without support for Catta.
authorGuus Sliepen <guus@meshlink.io>
Sat, 21 Jul 2018 15:52:07 +0000 (17:52 +0200)
committerGuus Sliepen <guus@meshlink.io>
Sat, 21 Jul 2018 15:56:34 +0000 (17:56 +0200)
Configuring with --disable-catta will cause MeshLink to not be linked to
the Catta library, and local discovery will not be available.

Makefile.am
configure.ac
examples/Makefile.am
src/Makefile.am
src/meshlink.c
src/meshlink.h

index 8b39f753612a04034b55d40da4e84204a7af5cd4..93bc963224fc5a73a60df159c2d42d7874e6dfa2 100644 (file)
@@ -2,7 +2,13 @@
 
 AUTOMAKE_OPTIONS = gnu
 
 
 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 
 
 
 ACLOCAL_AMFLAGS = -I m4 
 
index 8ef1e9ff8cc050dbb05270453ff2a3cec794731d..47656d7378987cba35eda1d7e0c16c93ad760829 100644 (file)
@@ -5,7 +5,6 @@ AC_INIT([MeshLink], [0.1])
 AM_INIT_AUTOMAKE([std-options subdir-objects nostdinc silent-rules -Wall])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_MACRO_DIR([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.
 AM_SILENT_RULES([yes])
 
 # Enable GNU extensions.
@@ -79,6 +78,14 @@ AS_IF([test "x$enable_hardening" != "xno"],
   ]
 );
 
   ]
 );
 
+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"],
 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"],
index 5c7f27186b18ca0f4e6288a6f41f500dd5d9aacd..4d363657bfe1f2d754baedd7d61478d31c1310cb 100644 (file)
@@ -4,16 +4,16 @@ AM_CPPFLAGS = $(PTHREAD_CFLAGS) -I${top_srcdir}/src -iquote. -Wall
 AM_LDFLAGS = $(PTHREAD_LIBS)
 
 meshlinkapp_SOURCES = meshlinkapp.c
 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_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_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_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_SOURCES = channels.c
-channels_LDADD = ${top_builddir}/src/libmeshlink.la ${top_builddir}/catta/src/libcatta.la
+channels_LDADD = ${top_builddir}/src/libmeshlink.la
index 1e2037788b665222ea0e79931d1eb4c1b1a69539..ef0d8d9e800f9d663e2fa9c95fad41d546db7569 100644 (file)
@@ -4,6 +4,9 @@ AM_CPPFLAGS = -Wall
 
 ed25519_SOURCES = \
        ed25519/add_scalar.c \
 
 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 \
        ed25519/ed25519.h \
        ed25519/fe.c ed25519/fe.h \
        ed25519/fixedint.h \
@@ -37,7 +40,6 @@ libmeshlink_la_SOURCES = \
        conf.c conf.h \
        connection.c connection.h \
        crypto.c crypto.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 \
        dropin.c dropin.h \
        ecdh.h \
        ecdsa.h \
@@ -80,16 +82,18 @@ libmeshlink_la_SOURCES = \
        $(chacha_poly1305_SOURCES) \
        $(utcp_SOURCES)
 
        $(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
 
 
 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_LIBADD = ${top_builddir}/catta/src/libcatta.la
-
-libmeshlink_la_SOURCES += \
-       ed25519/ecdh.c \
-       ed25519/ecdsa.c \
-       ed25519/ecdsagen.c
+endif
index 573dfe498cd6969fcb789a571403a576f2743c0b..c720c766e48deda084ad42a03b22eddff4f410f8 100644 (file)
@@ -1,6 +1,6 @@
 /*
     meshlink.c -- Implementation of the MeshLink API.
 /*
     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
 
     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
@@ -1215,9 +1215,11 @@ bool meshlink_start(meshlink_handle_t *mesh) {
 
        mesh->threadstarted = true;
 
 
        mesh->threadstarted = true;
 
+#if HAVE_CATTA
        if(mesh->discovery) {
                discovery_start(mesh);
        }
        if(mesh->discovery) {
                discovery_start(mesh);
        }
+#endif
 
        pthread_mutex_unlock(&(mesh->mesh_mutex));
        return true;
 
        pthread_mutex_unlock(&(mesh->mesh_mutex));
        return true;
@@ -1232,10 +1234,12 @@ void meshlink_stop(meshlink_handle_t *mesh) {
        pthread_mutex_lock(&(mesh->mesh_mutex));
        logger(mesh, MESHLINK_DEBUG, "meshlink_stop called\n");
 
        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);
        }
        // Stop discovery
        if(mesh->discovery) {
                discovery_stop(mesh);
        }
+#endif
 
        // Shut down the main thread
        event_loop_stop(&mesh->loop);
 
        // Shut down the main thread
        event_loop_stop(&mesh->loop);
@@ -2653,6 +2657,7 @@ void update_node_status(meshlink_handle_t *mesh, node_t *n) {
 }
 
 void meshlink_enable_discovery(meshlink_handle_t *mesh, bool enable) {
 }
 
 void meshlink_enable_discovery(meshlink_handle_t *mesh, bool enable) {
+#if HAVE_CATTA
        if(!mesh) {
                meshlink_errno = MESHLINK_EINVAL;
                return;
        if(!mesh) {
                meshlink_errno = MESHLINK_EINVAL;
                return;
@@ -2676,6 +2681,11 @@ void meshlink_enable_discovery(meshlink_handle_t *mesh, bool enable) {
 
 end:
        pthread_mutex_unlock(&mesh->mesh_mutex);
 
 end:
        pthread_mutex_unlock(&mesh->mesh_mutex);
+#else
+       (void)mesh;
+       (void)enable;
+       meshlink_errno = MESHLINK_ENOTSUP;
+#endif
 }
 
 static void __attribute__((constructor)) meshlink_init(void) {
 }
 
 static void __attribute__((constructor)) meshlink_init(void) {
index a0cb11877a1d6190ace6d69f903561e80ffa9980..37eeac81ed0b74a43ebb1ae981bffb2042c46c79 100644 (file)
@@ -3,7 +3,7 @@
 
 /*
     meshlink.h -- MeshLink API
 
 /*
     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
 
     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
@@ -63,6 +63,7 @@ typedef enum {
        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_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
 } meshlink_errno_t;
 
 /// Device class