diff --git a/Makefile b/Makefile
index 72cd30b25..d590ac2b3 100644
--- a/Makefile
+++ b/Makefile
@@ -69,7 +69,7 @@ endif
# Common flags
LDLIBS =
CFLAGS += -std=c11 -MMD -mcx16 -I$(BUILDDIR)/include -I$(SRCDIR)/include
-CFLAGS += -Wall -Werror -fdiagnostics-color=auto
+CFLAGS += -Wall -Werror -fdiagnostics-color=auto -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1
LDFLAGS += -L$(BUILDDIR)
diff --git a/include/villas/config.h b/include/villas/config.h.in
similarity index 81%
rename from include/villas/config.h
rename to include/villas/config.h.in
index 7039eeeb5..68d56ee8c 100644
--- a/include/villas/config.h
+++ b/include/villas/config.h.in
@@ -14,12 +14,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*********************************************************************************/
@@ -56,19 +56,3 @@
/* Required kernel version */
#define KERNEL_VERSION_MAJ 3
#define KERNEL_VERSION_MIN 6
-
-/** PCIe BAR number of VILLASfpga registers */
-#define FPGA_PCI_BAR 0
-#define FPGA_PCI_VID_XILINX 0x10ee
-#define FPGA_PCI_PID_VFPGA 0x7022
-
-/** AXI Bus frequency for all components
- * except RTDS AXI Stream bridge which runs at RTDS_HZ (100 Mhz) */
-#define FPGA_AXI_HZ 125000000 // 125 MHz
-
-#define _POSIX_C_SOURCE 200809L
-#define _GNU_SOURCE 1
-
-#if defined(__APPLE__)
- #define _DARWIN_C_SOURCE
-#endif
diff --git a/include/villas/kernel/if.h b/include/villas/kernel/if.h
index 258c7ff6e..4a6068ad5 100644
--- a/include/villas/kernel/if.h
+++ b/include/villas/kernel/if.h
@@ -31,7 +31,7 @@
#include
#include
-#include "list.h"
+#include
#define IF_IRQ_MAX 3 /**< Maxmimal number of IRQs of an interface */
diff --git a/include/villas/nodes/loopback.h b/include/villas/nodes/loopback.h
index 95572c6d6..cfbb5d33a 100644
--- a/include/villas/nodes/loopback.h
+++ b/include/villas/nodes/loopback.h
@@ -29,8 +29,8 @@
#pragma once
-#include "queue_signalled.h"
-#include "pool.h"
+#include
+#include
/* Forward declarations */
struct node;
diff --git a/include/villas/nodes/mqtt.h b/include/villas/nodes/mqtt.h
index 1bcbe9ac8..07ef84957 100644
--- a/include/villas/nodes/mqtt.h
+++ b/include/villas/nodes/mqtt.h
@@ -31,9 +31,9 @@
#pragma once
-#include "node.h"
-#include "pool.h"
-#include "queue_signalled.h"
+#include
+#include
+#include
/* Forward declarations */
struct io_format;
@@ -67,7 +67,7 @@ struct mqtt {
};
/** @see node_type::reverse */
-char * mqtt_reverse(struct node *n);
+int mqtt_reverse(struct node *n);
/** @see node_type::print */
char * mqtt_print(struct node *n);
diff --git a/include/villas/nodes/socket.h b/include/villas/nodes/socket.h
index 6ac518b88..b7d4c3680 100644
--- a/include/villas/nodes/socket.h
+++ b/include/villas/nodes/socket.h
@@ -39,6 +39,8 @@
#include
#endif
+#include
+
#ifdef WITH_LIBNL_ROUTE_30
#include
#include
diff --git a/include/villas/utils.h b/include/villas/utils.h
index 9f405931d..ac753be84 100644
--- a/include/villas/utils.h
+++ b/include/villas/utils.h
@@ -30,7 +30,8 @@
#include
#include
-#include "log.h"
+#include
+#include
#ifdef __GNUC__
#define LIKELY(x) __builtin_expect((x),1)
diff --git a/lib/Makefile.inc b/lib/Makefile.inc
index 524622a47..000c75b35 100644
--- a/lib/Makefile.inc
+++ b/lib/Makefile.inc
@@ -26,17 +26,21 @@ LIBS = $(patsubst %, lib%, $(SONAMES))
LIB_CFLAGS += $(CFLAGS) -fPIC
+ifeq ($(shell uname),Darwin)
+ LIB_CFLAGS += -D_DARWIN_C_SOURCE=1
+endif
+
include $(patsubst %, lib/Makefile.%.inc, $(SONAMES))
-$(BUILDDIR)/include/villas/config.h: include/villas/config.h Makefile.config | $$(dir $$@)
+$(BUILDDIR)/include/villas/config.h: include/villas/config.h.in Makefile.config | $$(dir $$@)
cp $< $@
- echo -e "\n\n" >> $@
+ echo -e "\n" >> $@
echo "#define BUILDID \"$(BUILDID)\"" >> $@
echo "#define V $(V)" >> $@
echo "#define PREFIX \"$(PREFIX)\"" >> $@
- echo -e "\n\n" >> $@
+ echo -e "\n" >> $@
echo "/* Available Features */" >> $@
if (( $(WITH_WEB) )); then echo "#define WITH_WEB 1" >> $@; fi
@@ -47,6 +51,7 @@ $(BUILDDIR)/include/villas/config.h: include/villas/config.h Makefile.config | $
for NODE in $(call escape,$(LIB_NODES)); do echo "#define WITH_NODE_$${NODE} 1" >> $@; done
for FORMAT in $(call escape,$(LIB_FORMATS)); do echo "#define WITH_FORMAT_$${FORMAT} 1" >> $@; done
+ for PKG in $(call escape,$(LIB_PKGS)); do echo "#define WITH_$${PKG} 1" >> $@; done
# Compile
$(BUILDDIR)/lib/%.o: lib/%.c | $$(dir $$@)
diff --git a/lib/config_helper.c b/lib/config_helper.c
index c5e469668..320e759f1 100644
--- a/lib/config_helper.c
+++ b/lib/config_helper.c
@@ -22,9 +22,9 @@
#include
+#include
#include
#include
-#include
#ifdef WITH_CONFIG
diff --git a/lib/io/Makefile.inc b/lib/io/Makefile.inc
index 88bf15021..8bd7ee23e 100644
--- a/lib/io/Makefile.inc
+++ b/lib/io/Makefile.inc
@@ -24,7 +24,7 @@ LIB_FORMATS += json villas_binary villas_human csv raw
LIB_SRCS += lib/io/msg.c
# Enable Google Protobuf IO format
-ifeq ($(WITH_PROTOBUF),1)
+ifeq ($(WITH_FORMAT_PROTOBUF),1)
ifeq ($(shell $(PKGCONFIG) libprotobuf-c; echo $$?),0)
LIB_SRCS += lib/io/protobuf.c lib/io/villas.pb-c.c
LIB_PKGS += libprotobuf-c
@@ -35,5 +35,7 @@ endif
%.pb-c.c %.pb-c.h: %.proto
protoc-c --proto_path=$(SRCDIR) --c_out=$(SRCDIR) $(realpath $^)
-lib/io/protobuf.c: | lib/io/villas.pb-c.h
+$(BUILDDIR)/%.pb-c.o: LIB_CFLAGS += -I$(SRCDIR)
+
+$(BUILDDIR)/lib/io/protobuf.o: lib/io/villas.pb-c.h
diff --git a/lib/io/protobuf.c b/lib/io/protobuf.c
index 75e97715c..6f86fc244 100644
--- a/lib/io/protobuf.c
+++ b/lib/io/protobuf.c
@@ -23,9 +23,9 @@
// Generated message descriptors by protoc
#include "villas.pb-c.h"
-#include "sample.h"
-#include "plugin.h"
-#include "io/protobuf.h"
+#include "villas/sample.h"
+#include "villas/plugin.h"
+#include "villas/io/protobuf.h"
int protobuf_sprint(char *buf, size_t len, size_t *wbytes, struct sample *smps[], unsigned cnt, int flags)
{
diff --git a/lib/kernel/if.c b/lib/kernel/if.c
index 2211a2a20..d72e09e93 100644
--- a/lib/kernel/if.c
+++ b/lib/kernel/if.c
@@ -27,15 +27,16 @@
#include
-#include "kernel/if.h"
-#include "kernel/tc.h"
-#include "kernel/tc_netem.h"
-#include "kernel/nl.h"
-#include "kernel/kernel.h"
+#include
+#include
-#include "nodes/socket.h"
+#include
+#include
+#include
+#include
+#include
-#include "utils.h"
+#include
int if_init(struct interface *i, struct rtnl_link *link)
{
diff --git a/lib/kernel/nl.c b/lib/kernel/nl.c
index 433ff8e77..ae111d90b 100644
--- a/lib/kernel/nl.c
+++ b/lib/kernel/nl.c
@@ -27,9 +27,8 @@
#include
#include
-#include "kernel/nl.h"
-
-#include "utils.h"
+#include
+#include
/** Singleton for global netlink socket */
static struct nl_sock *sock = NULL;
diff --git a/lib/kernel/tc.c b/lib/kernel/tc.c
index 531bd551c..fd74a6b83 100644
--- a/lib/kernel/tc.c
+++ b/lib/kernel/tc.c
@@ -27,12 +27,12 @@
#include
-#include "kernel/kernel.h"
-#include "kernel/if.h"
-#include "kernel/tc.h"
-#include "kernel/nl.h"
+#include
-#include "utils.h"
+#include
+#include
+#include
+#include
int tc_prio(struct interface *i, struct rtnl_qdisc **qd, tc_hdl_t handle, tc_hdl_t parent, int bands)
{
diff --git a/lib/kernel/tc_netem.c b/lib/kernel/tc_netem.c
index 288a600cd..fa3e38eb6 100644
--- a/lib/kernel/tc_netem.c
+++ b/lib/kernel/tc_netem.c
@@ -26,12 +26,12 @@
#include
-#include "kernel/if.h"
-#include "kernel/nl.h"
-#include "kernel/nl-private.h"
-#include "kernel/tc_netem.h"
-#include "kernel/kernel.h"
-#include "utils.h"
+#include
+#include
+#include
+#include
+#include
+#include
int tc_netem_parse(struct rtnl_qdisc **netem, json_t *cfg)
diff --git a/lib/node.c b/lib/node.c
index 27b4c3c5a..9ceb8b2c2 100644
--- a/lib/node.c
+++ b/lib/node.c
@@ -22,6 +22,7 @@
#include
+#include
#include
#include
#include
@@ -87,7 +88,7 @@ int node_init2(struct node *n)
#ifdef WITH_HOOKS
/* We sort the hooks according to their priority before starting the path */
list_sort(&n->hooks, hook_cmp_priority);
-#endif
+#endif /* WITH_HOOKS */
return 0;
}
diff --git a/lib/nodes/Makefile.inc b/lib/nodes/Makefile.inc
index 6959cf591..5ace53ad1 100644
--- a/lib/nodes/Makefile.inc
+++ b/lib/nodes/Makefile.inc
@@ -158,7 +158,8 @@ endif
ifeq ($(WITH_NODE_MQTT),1)
ifneq ($(wildcard /usr/include/mosquitto.h),)
LIB_SRCS += lib/nodes/mqtt.c
- LIB_CFLAGS += -DWITH_MQTT
+ LIB_NODES += mqtt
LIB_LDLIBS += -lmosquitto
+ WITH_IO = 1
endif
endif
diff --git a/lib/nodes/cbuilder.c b/lib/nodes/cbuilder.c
index 5a15c1825..bf0ecaf2e 100644
--- a/lib/nodes/cbuilder.c
+++ b/lib/nodes/cbuilder.c
@@ -6,12 +6,12 @@
#include
-#include "node.h"
-#include "log.h"
-#include "plugin.h"
-#include "utils.h"
+#include
+#include
+#include
+#include
-#include "nodes/cbuilder.h"
+#include
int cbuilder_parse(struct node *n, json_t *cfg)
{
diff --git a/lib/nodes/loopback.c b/lib/nodes/loopback.c
index 1c9cbd7fa..e25efcd67 100644
--- a/lib/nodes/loopback.c
+++ b/lib/nodes/loopback.c
@@ -20,11 +20,11 @@
* along with this program. If not, see .
*********************************************************************************/
-#include "node.h"
-#include "plugin.h"
-#include "config.h"
-#include "nodes/loopback.h"
-#include "memory.h"
+#include
+#include
+#include
+#include
+#include
int loopback_parse(struct node *n, json_t *cfg)
{
diff --git a/lib/nodes/mqtt.c b/lib/nodes/mqtt.c
index 33dca1117..5043db59e 100644
--- a/lib/nodes/mqtt.c
+++ b/lib/nodes/mqtt.c
@@ -23,10 +23,10 @@
#include
#include
-#include "nodes/mqtt.h"
-#include "plugin.h"
-#include "utils.h"
-#include "io_format.h"
+#include
+#include
+#include
+#include
#ifdef MQTT_THREAD
#include
diff --git a/lib/super_node.c b/lib/super_node.c
index 657d3c7bb..3c14d45e7 100644
--- a/lib/super_node.c
+++ b/lib/super_node.c
@@ -25,6 +25,7 @@
#include
#include
+#include
#include
#include
#include
diff --git a/lib/web.c b/lib/web.c
index 1ce342381..216b09e2c 100644
--- a/lib/web.c
+++ b/lib/web.c
@@ -23,6 +23,7 @@
#include
#include
+#include
#include
#include
#include
@@ -57,14 +58,14 @@ lws_callback_function websocket_protocol_cb;
.rx_buffer_size = 0
},
#endif /* WITH_API */
-#ifdef WITH_WEBSOCKET
+#ifdef WITH_NODE_WEBSOCKET
{
.name = "live",
.callback = websocket_protocol_cb,
.per_session_data_size = sizeof(struct websocket_connection),
.rx_buffer_size = 0
},
-#endif /* WITH_WEBSOCKET */
+#endif /* WITH_NODE_WEBSOCKET */
#if 0 /* not supported yet */
{
.name = "log",
@@ -111,7 +112,7 @@ static struct lws_http_mount mounts[] = {
.cache_intermediaries = 0,
.origin_protocol = LWSMPRO_CALLBACK,
.mountpoint_len = 7,
-#endif
+#endif /* WITH_API */
.mount_next = NULL
}
};
diff --git a/src/node.c b/src/node.c
index 3d69e98ed..2d264160c 100644
--- a/src/node.c
+++ b/src/node.c
@@ -23,6 +23,7 @@
#include
#include
+#include
#include
#include
#include
@@ -76,7 +77,7 @@ static void usage()
printf("Usage: villas-node OPAL_ASYNC_SHMEM_NAME OPAL_ASYNC_SHMEM_SIZE OPAL_PRINT_SHMEM_NAME\n");
printf(" This type of invocation is used by OPAL-RT Asynchronous processes.\n");
printf(" See in the RT-LAB User Guide for more information.\n\n");
-#endif
+#endif /* ENABLE_OPAL_ASYNC */
printf("Supported node-types:\n");
plugin_dump(PLUGIN_TYPE_NODE);
@@ -86,7 +87,7 @@ static void usage()
printf("Supported hooks:\n");
plugin_dump(PLUGIN_TYPE_HOOK);
printf("\n");
-#endif
+#endif /* WITH_HOOKS */
printf("Supported API commands:\n");
plugin_dump(PLUGIN_TYPE_API);
diff --git a/src/pipe.c b/src/pipe.c
index 59015f0d5..b08a41e6f 100644
--- a/src/pipe.c
+++ b/src/pipe.c
@@ -30,6 +30,8 @@
#include
#include
+#include
+#include
#include
#include
#include
@@ -38,12 +40,9 @@
#include
#include
#include
-#include
#include
-#include
-
static struct super_node sn = { .state = STATE_DESTROYED }; /**< The global configuration */
static struct io io = { .state = STATE_DESTROYED };
@@ -321,13 +320,13 @@ check: if (optarg == endptr)
if (!node)
error("Node '%s' does not exist!", nodestr);
-#ifdef WITH_WEBSOCKET
+#ifdef WITH_NODE_WEBSOCKET
/* Only start web subsystem if villas-pipe is used with a websocket node */
if (node->_vt->start == websocket_start) {
web_start(&sn.web);
api_start(&sn.api);
}
-#endif
+#endif /* WITH_NODE_WEBSOCKET */
if (reverse)
node_reverse(node);
diff --git a/tests/unit/io.c b/tests/unit/io.c
index 270ecf43c..b8db0efc0 100644
--- a/tests/unit/io.c
+++ b/tests/unit/io.c
@@ -39,8 +39,11 @@
#define NUM_VALUES 10
static char formats[][32] = {
-#ifdef WITH_HDF5
+#ifdef WITH_FORMAT_HDF5
"hdf5",
+#endif
+#ifdef WITH_FORMAT_PROTOBUF
+ "protobuf",
#endif
"raw-int8",
"raw-int16-be",