From 3206f918c1d14c5402807be5e8530dd814285e15 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 13 Jun 2017 02:51:11 +0200 Subject: [PATCH] reworked Makefiles --- Makefile | 28 +++--- .../models/send_receive/Makefile.mk | 2 +- .../models/send_receive/Makefile.mk | 2 +- lib/Makefile.inc | 22 ++--- lib/Makefile.villas-ext.inc | 12 ++- lib/Makefile.villas.inc | 96 ++----------------- lib/api/Makefile.inc | 2 +- lib/kernel/Makefile.inc | 23 +++++ lib/nodes/Makefile.inc | 75 ++++++++++++++- lib/rtds/Makefile.inc | 23 +++++ packaging/Makefile.dist.inc | 39 ++++++++ packaging/Makefile.docker.inc | 44 +++++++++ packaging/Makefile.inc | 46 +-------- packaging/rpm/Makefile.inc | 6 +- packaging/rpm/villas-node.spec | 2 - plugins/Makefile.inc | 2 +- src/Makefile.inc | 34 ++++--- tests/Makefile.inc | 8 +- tests/integration/Makefile.inc | 6 +- tests/unit/Makefile.inc | 7 +- thirdparty/Makefile.inc | 27 +++--- tools/Makefile.inc | 12 ++- 22 files changed, 315 insertions(+), 203 deletions(-) create mode 100644 lib/kernel/Makefile.inc create mode 100644 lib/rtds/Makefile.inc create mode 100644 packaging/Makefile.dist.inc create mode 100644 packaging/Makefile.docker.inc diff --git a/Makefile b/Makefile index 4dbdbb6bf..882b55dea 100644 --- a/Makefile +++ b/Makefile @@ -112,14 +112,19 @@ CFLAGS += $(shell $(PKGCONFIG) --cflags ${PKGS}) LDLIBS += $(shell $(PKGCONFIG) --libs ${PKGS}) all: src plugins tools -src plugins tools tests: lib # Build all variants: debug, coverage, ... everything: - $(MAKE) RELEASE=1 - $(MAKE) DEBUG=1 - $(MAKE) COVERAGE=1 - $(MAKE) PROFILE=1 + $(MAKE) RELEASE=1 tools run-tests + $(MAKE) DEBUG=1 tools run-tests + $(MAKE) COVERAGE=1 tools run-tests + $(MAKE) PROFILE=1 tools run-tests + +clean-everything: + $(MAKE) RELEASE=1 clean + $(MAKE) DEBUG=1 clean + $(MAKE) COVERAGE=1 clean + $(MAKE) PROFILE=1 clean # Create non-existent directories .SECONDEXPANSION: @@ -141,15 +146,16 @@ define DEFINES endef export DEFINES +include $(wildcard $(BUILDDIR)/**/*.d) +include $(addsuffix /Makefile.inc,$(MODULES)) + $(BUILDDIR)/defines: | $$(dir $$@) echo "$${DEFINES}" > $@ echo -e "$(addprefix \n-DWITH_, $(shell echo ${PKGS} | tr a-z- A-Z_ | tr -dc ' A-Z0-9_' ))" >> $@ echo -e "$(addprefix \n-DWITH_, $(shell echo ${LIB_PKGS} | tr a-z- A-Z_ | tr -dc ' A-Z0-9_' ))" >> $@ -install: $(addprefix install-,$(filter-out thirdparty doc clients,$(MODULES))) -clean: $(addprefix clean-,$(filter-out thirdparty doc clients,$(MODULES))) +install: $(addprefix install-,$(filter-out thirdparty,$(MODULES))) +clean: $(addprefix clean-,$(MODULES)) + rm -f $(BUILDDIR)/defines -.PHONY: all everything clean install - --include $(wildcard $(BUILDDIR)/**/*.d) --include $(addsuffix /Makefile.inc,$(MODULES)) +.PHONY: all clean install everything clean-everything diff --git a/clients/opal/villas_udp/models/send_receive/Makefile.mk b/clients/opal/villas_udp/models/send_receive/Makefile.mk index 3097e25c8..a0e5df0a2 100644 --- a/clients/opal/villas_udp/models/send_receive/Makefile.mk +++ b/clients/opal/villas_udp/models/send_receive/Makefile.mk @@ -76,4 +76,4 @@ clean: $(TARGET): $(OBJS) $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) --include $(wildcard *.d) \ No newline at end of file +include $(wildcard *.d) \ No newline at end of file diff --git a/clients/opal/villas_udp_Matlab2011b/models/send_receive/Makefile.mk b/clients/opal/villas_udp_Matlab2011b/models/send_receive/Makefile.mk index 3097e25c8..a0e5df0a2 100644 --- a/clients/opal/villas_udp_Matlab2011b/models/send_receive/Makefile.mk +++ b/clients/opal/villas_udp_Matlab2011b/models/send_receive/Makefile.mk @@ -76,4 +76,4 @@ clean: $(TARGET): $(OBJS) $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) --include $(wildcard *.d) \ No newline at end of file +include $(wildcard *.d) \ No newline at end of file diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 8287b49ac..3dfb72bb0 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -20,26 +20,26 @@ # along with this program. If not, see . ################################################################################### -SONAMES = villas villas-ext - -LIBS = $(patsubst %, $(BUILDDIR)/lib%.so, $(SONAMES)) - LIB_CFLAGS = $(CFLAGS) -fPIC --include lib/hooks/Makefile.inc --include lib/api/Makefile.inc --include lib/web/Makefile.inc +include lib/hooks/Makefile.inc +include lib/api/Makefile.inc +include lib/web/Makefile.inc +include lib/kernel/Makefile.inc +include lib/nodes/Makefile.inc +include lib/rtds/Makefile.inc --include $(patsubst %, lib/Makefile.%.inc, $(SONAMES)) +include lib/Makefile.villas.inc +include lib/Makefile.villas-ext.inc # Compile $(BUILDDIR)/lib/%.o: lib/%.c $(BUILDDIR)/defines | $$(dir $$@) $(CC) $(LIB_CFLAGS) -c $< -o $@ -lib: $(patsubst %, lib%, $(SONAMES)) +lib: $(LIBS) -install-lib: $(patsubst %, install-lib%, $(SONAMES)) +install-lib: install-libvillas install-libvillas-ext -clean-lib: $(patsubst %, clean-lib%, $(SONAMES)) +clean-lib: clean-libvillas clean-libvillas-ext .PHONY: lib install-lib clean-lib diff --git a/lib/Makefile.villas-ext.inc b/lib/Makefile.villas-ext.inc index 1168f2fe2..b96d7c0a1 100644 --- a/lib/Makefile.villas-ext.inc +++ b/lib/Makefile.villas-ext.inc @@ -24,6 +24,8 @@ LIBEXT_NAME = libvillas-ext LIBEXT_ABI_VERSION = 1 LIBEXT = $(BUILDDIR)/$(LIBEXT_NAME).so.$(LIBEXT_ABI_VERSION) +LIBS += $(LIBEXT) + LIBEXT_SRCS += $(addprefix lib/, sample.c queue.c queue_signalled.c \ memory.c log.c shmem.c utils.c kernel/kernel.c list.c \ timing.c pool.c \ @@ -40,11 +42,11 @@ $(LIBEXT): $(LIBEXT_OBJS) $(CC) $(LIBEXT_LDFLAGS) -o $@ $^ $(LIBEXT_LDLIBS) ln -srf $@ $(BUILDDIR)/$(LIBEXT_NAME).so -install-libvillas-ext: libvillas-ext +install-$(LIBEXT_NAME): $(LIBEXT) install -m 0755 -D -T $(LIBEXT) $(DESTDIR)$(PREFIX)/lib/$(LIBEXT_NAME).so.$(LIBEXT_ABI_VERSION) - ln -srf $(DESTDIR)$(PREFIX)/lib/$(LIBEXT_NAME).so.$(LIBEXT_ABI_VERSION) $(DESTDIR)$(PREFIX)/lib/$(LIBEXT_NAME).so + ln -srf $(DESTDIR)$(PREFIX)/lib/$(LIBEXT_NAME).so $(DESTDIR)$(PREFIX)/lib/$(LIBEXT_NAME).so.$(LIBEXT_ABI_VERSION) -clean-libvillas-ext: - rm -rf $(BUILDDIR)/lib $(LIBEXT) +clean-$(LIBEXT_NAME): + rm -f $(LIBEXT_OBJS) $(LIBEXT) -.PHONY: install-libvillas-ext clean-libvillas-ext $(LIBEXT_NAME) +.PHONY: install-$(LIBEXT_NAME) clean-$(LIBEXT_NAME) $(LIBEXT_NAME) diff --git a/lib/Makefile.villas.inc b/lib/Makefile.villas.inc index 6e848127a..d92ff9eea 100644 --- a/lib/Makefile.villas.inc +++ b/lib/Makefile.villas.inc @@ -24,14 +24,15 @@ LIB_NAME = libvillas LIB_ABI_VERSION = 1 LIB = $(BUILDDIR)/$(LIB_NAME).so.$(LIB_ABI_VERSION) +LIBS += $(LIB) + # Object files for libvillas LIB_SRCS += $(addprefix lib/nodes/, file.c cbuilder.c shmem.c) \ - $(addprefix lib/kernel/, kernel.c rt.c) \ $(addprefix lib/, sample.c path.c node.c hook.c \ log.c log_config.c utils.c super_node.c hist.c timing.c pool.c \ list.c queue.c queue_signalled.c memory.c advio.c web.c api.c \ plugin.c node_type.c stats.c mapping.c sample_io.c shmem.c \ - json.c crypt.c compat.c rscad.c \ + json.c crypt.c compat.c \ ) LIB_LDFLAGS = -shared @@ -39,105 +40,26 @@ LIB_LDLIBS = $(LDLIBS) -ldl -lrt -Wl,-soname,$(LIB_NAME).so.$(LIB_ABI_VERSION) LIB_PKGS += libwebsockets openssl -######## Node types ######## - -# Enable Socket node type when libnl3 is available -ifndef WITHOUT_SOCKET -ifeq ($(shell $(PKGCONFIG) libnl-route-3.0; echo $$?),0) - LIB_SRCS += $(addprefix lib/nodes/, socket.c) - LIB_SRCS += $(addprefix lib/kernel/, nl.c tc.c if.c) - LIB_SRCS += $(addprefix lib/, msg.c) - LIB_PKGS += libnl-route-3.0 -endif -endif - -# Enable GTWIF node type -ifndef WITHOUT_GTWIF - LIB_SRCS += lib/nodes/gtwif.c -endif - -# Enable nanomsg node type when libnanomsg is available -ifndef WITHOUT_NANOMSG -ifeq ($(shell $(PKGCONFIG) nanomsg; echo $$?),0) - LIB_SRCS += lib/nodes/nanomsg.c - LIB_PKGS += nanomsg -else ifeq ($(shell $(PKGCONFIG) libnanomsg; echo $$?),0) - LIB_SRCS += lib/nodes/nanomsg.c - LIB_PKGS += libnanomsg -endif -endif - -# Enable ZeroMQ node type when libzmq is available -ifndef WITHOUT_ZMQ -ifeq ($(shell $(PKGCONFIG) libzmq; echo $$?),0) - LIB_SRCS += $(addprefix lib/nodes/, zeromq.c) - LIB_PKGS += libzmq -endif -endif - -# Enable VILLASfpga support when libxil is available -ifndef WITHOUT_FPGA -ifeq ($(shell $(PKGCONFIG) libxil; echo $$?),0) - LIB_SRCS += $(addprefix lib/nodes/, fpga.c) \ - $(addprefix lib/kernel/, pci.c vfio.c) \ - $(wildcard lib/fpga/*.c) \ - $(wildcard lib/fpga/ips/*.c) - - LIB_PKGS += libxil -endif -endif - -# Enable NGSI support -ifndef WITHOUT_NGSI -ifeq ($(shell $(PKGCONFIG) libcurl jansson; echo $$?),0) - LIB_SRCS += lib/nodes/ngsi.c - LIB_PKGS += libcurl jansson -endif -endif - -# Enable WebSocket support -ifeq ($(shell $(PKGCONFIG) libwebsockets jansson; echo $$?),0) - LIB_SRCS += lib/nodes/websocket.c lib/webmsg.c - LIB_PKGS += libwebsockets jansson -endif - -# Enable OPAL-RT Asynchronous Process support (will result in 32bit binary!!!) -ifdef WITH_OPAL -ifneq ($(wildcard thirdparty/libopal/include/opal/AsyncApi.h),) - LIB_OBJS += opal.o - - LIB_CFLAGS += -I thirdparty/libopal/include/opal/ - LIB_LDFLAGS += -L/lib/i386-linux-gnu/ -L/usr/lib/i386-linux-gnu/ -Lthirdparty/libopal/ - LIB_LDLIBS += -lOpalAsyncApiCore -lOpalCore -lOpalUtils -lirc - - # libOpalAsyncApi is a 32bit library. So we need to build everything in 32bit - CFLAGS += -m32 - LDFLAGS += -m32 - BUILDDIR := $(BUILDDIR) -endif -endif - # Add flags by pkg-config LIB_LDLIBS += $(shell $(PKGCONFIG) --libs $(LIB_PKGS)) LIB_CFLAGS += $(shell $(PKGCONFIG) --cflags $(LIB_PKGS)) LIB_OBJS = $(patsubst %.c, $(BUILDDIR)/%.o, $(LIB_SRCS)) +LIB_DEPS = $(patsubst %.c, $(BUILDDIR)/%.d, $(LIB_SRCS)) $(LIB_NAME): $(LIB) -# Link $(LIB): $(LIB_OBJS) $(CC) $(LIB_LDFLAGS) -o $@ $^ $(LIB_LDLIBS) ln -srf $@ $(BUILDDIR)/$(LIB_NAME).so -# Install -install-libvillas: libvillas +install-$(LIB_NAME): $(LIB_NAME) install -m 0755 -D -T $(LIB) $(DESTDIR)$(PREFIX)/lib/$(LIB_NAME).so.$(LIB_ABI_VERSION) install -m 0644 -D -t $(DESTDIR)$(PREFIX)/include/villas/ include/villas/*.h - ln -srf $(DESTDIR)$(PREFIX)/lib/$(LIB_NAME).so.$(LIB_ABI_VERSION) $(DESTDIR)$(PREFIX)/lib/$(LIB_NAME).so + ln -srf $(DESTDIR)$(PREFIX)/lib/$(LIB_NAME).so $(DESTDIR)$(PREFIX)/lib/$(LIB_NAME).so.$(LIB_ABI_VERSION) ldconfig -clean-libvillas: - rm -rf $(BUILDDIR)/lib $(LIB) +clean-$(LIB_NAME): + rm -f $(LIB_OBJS) $(LIB_DEPS) $(LIB) -.PHONY: install-libvillas clean-libvillas $(LIB_NAME) +.PHONY: install-$(LIB_NAME) clean-$(LIB_NAME) $(LIB) diff --git a/lib/api/Makefile.inc b/lib/api/Makefile.inc index 6084e13b8..5d981ae15 100644 --- a/lib/api/Makefile.inc +++ b/lib/api/Makefile.inc @@ -22,4 +22,4 @@ LIB_SRCS += $(wildcard lib/api/*.c) --include lib/api/actions/Makefile.inc \ No newline at end of file +include lib/api/actions/Makefile.inc \ No newline at end of file diff --git a/lib/kernel/Makefile.inc b/lib/kernel/Makefile.inc new file mode 100644 index 000000000..56b17f8f3 --- /dev/null +++ b/lib/kernel/Makefile.inc @@ -0,0 +1,23 @@ +# Makefile. +# +# @author Steffen Vogel +# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# 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 +# 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 . +################################################################################### + +LIB_SRCS += $(addprefix lib/kernel/, kernel.c rt.c) \ No newline at end of file diff --git a/lib/nodes/Makefile.inc b/lib/nodes/Makefile.inc index 8c3ee6254..bc874272c 100644 --- a/lib/nodes/Makefile.inc +++ b/lib/nodes/Makefile.inc @@ -20,4 +20,77 @@ # along with this program. If not, see . ################################################################################### -LIB_SRC += $(wildcard lib/nodes/*.c) \ No newline at end of file +# Enable Socket node type when libnl3 is available +ifndef WITHOUT_SOCKET +ifeq ($(shell $(PKGCONFIG) libnl-route-3.0; echo $$?),0) + LIB_SRCS += $(addprefix lib/nodes/, socket.c) + LIB_SRCS += $(addprefix lib/kernel/, nl.c tc.c if.c) + LIB_SRCS += $(addprefix lib/, msg.c) + LIB_PKGS += libnl-route-3.0 +endif +endif + +# Enable GTWIF node type +ifndef WITHOUT_GTWIF + LIB_SRCS += lib/nodes/gtwif.c +endif + +# Enable nanomsg node type when libnanomsg is available +ifndef WITHOUT_NANOMSG +ifeq ($(shell $(PKGCONFIG) nanomsg; echo $$?),0) + LIB_SRCS += lib/nodes/nanomsg.c + LIB_PKGS += nanomsg +else ifeq ($(shell $(PKGCONFIG) libnanomsg; echo $$?),0) + LIB_SRCS += lib/nodes/nanomsg.c + LIB_PKGS += libnanomsg +endif +endif + +# Enable ZeroMQ node type when libzmq is available +ifndef WITHOUT_ZMQ +ifeq ($(shell $(PKGCONFIG) libzmq; echo $$?),0) + LIB_SRCS += $(addprefix lib/nodes/, zeromq.c) + LIB_PKGS += libzmq +endif +endif + +# Enable VILLASfpga support when libxil is available +ifndef WITHOUT_FPGA +ifeq ($(shell $(PKGCONFIG) libxil; echo $$?),0) + LIB_SRCS += $(addprefix lib/nodes/, fpga.c) \ + $(addprefix lib/kernel/, pci.c vfio.c) \ + $(wildcard lib/fpga/*.c) \ + $(wildcard lib/fpga/ips/*.c) + LIB_PKGS += libxil +endif +endif + +# Enable NGSI support +ifndef WITHOUT_NGSI +ifeq ($(shell $(PKGCONFIG) libcurl jansson; echo $$?),0) + LIB_SRCS += lib/nodes/ngsi.c + LIB_PKGS += libcurl jansson +endif +endif + +# Enable WebSocket support +ifeq ($(shell $(PKGCONFIG) libwebsockets jansson; echo $$?),0) + LIB_SRCS += lib/nodes/websocket.c lib/webmsg.c + LIB_PKGS += libwebsockets jansson +endif + +# Enable OPAL-RT Asynchronous Process support (will result in 32bit binary!!!) +ifdef WITH_OPAL +ifneq ($(wildcard thirdparty/libopal/include/opal/AsyncApi.h),) + LIB_OBJS += opal.o + + LIB_CFLAGS += -I thirdparty/libopal/include/opal/ + LIB_LDFLAGS += -L/lib/i386-linux-gnu/ -L/usr/lib/i386-linux-gnu/ -Lthirdparty/libopal/ + LIB_LDLIBS += -lOpalAsyncApiCore -lOpalCore -lOpalUtils -lirc + + # libOpalAsyncApi is a 32bit library. So we need to build everything in 32bit + CFLAGS += -m32 + LDFLAGS += -m32 + BUILDDIR := $(BUILDDIR) +endif +endif \ No newline at end of file diff --git a/lib/rtds/Makefile.inc b/lib/rtds/Makefile.inc new file mode 100644 index 000000000..958f2b92e --- /dev/null +++ b/lib/rtds/Makefile.inc @@ -0,0 +1,23 @@ +# Makefile. +# +# @author Steffen Vogel +# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# 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 +# 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 . +################################################################################### + +LIB_SRCS += $(wildcard lib/rtds/*.c) \ No newline at end of file diff --git a/packaging/Makefile.dist.inc b/packaging/Makefile.dist.inc new file mode 100644 index 000000000..e6d83b050 --- /dev/null +++ b/packaging/Makefile.dist.inc @@ -0,0 +1,39 @@ +# Makefile. +# +# @author Steffen Vogel +# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# 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 +# 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 . +################################################################################### + +TAROPTS = --exclude-ignore-recursive=.distignore --transform='s|^\.|villas-node-$(VERSION_NUM)|' --show-transformed-names + +TAR_VILLAS = $(BUILDDIR)/packaging/villas-node-$(VERSION_NUM)-1.$(GIT_BRANCH)_$(subst -,_,$(VARIANT)).$(shell date +%Y%m%d)git$(GIT_REV).tar.gz + +# Source tarballs +dist: $(TAR_VILLAS) + +$(TAR_VILLAS): | $$(dir $$@) + tar $(TAROPTS) -C $(SRCDIR) -czf $@ . + +deploy-dist: $(TAR_VILLAS) + rsync $(TAR_VILLAS) $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/src + +clean-dist: + rm -f $(TAR_VILLAS) + +.PHONY: dist clean-dist deploy-dist \ No newline at end of file diff --git a/packaging/Makefile.docker.inc b/packaging/Makefile.docker.inc new file mode 100644 index 000000000..aa6b8addf --- /dev/null +++ b/packaging/Makefile.docker.inc @@ -0,0 +1,44 @@ +# Makefile. +# +# @author Steffen Vogel +# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# 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 +# 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 . +################################################################################### + +DOCKER_IMAGE ?= villas/node +DOCKER_OPTS ?= -it -p 80:80 -p 443:443 -p 1234:1234 -p 12000:12000/udp -p 12001:12001/udp --privileged --security-opt seccomp:unconfined -v "$(PWD):/villas" + +deploy-docker-dev: DOCKER_IMAGE := $(DOCKER_IMAGE)-dev +docker-dev: DOCKER_IMAGE := $(DOCKER_IMAGE)-dev + +deploy-docker deploy-docker-dev: + docker push $(DOCKER_IMAGE):$(GIT_BRANCH) + +# Docker targets +run-docker-dev: docker-dev + docker run $(DOCKER_OPTS) $(DOCKER_IMAGE)-dev:$(GIT_BRANCH) + +docker-dev: + docker pull fedora:25 + docker build -f Dockerfile.dev -t $(DOCKER_IMAGE):$(GIT_BRANCH) $(SRCDIR) + +docker: + docker pull fedora:25 + docker build -f Dockerfile -t $(DOCKER_IMAGE):$(GIT_BRANCH) $(SRCDIR) + +.PHONY: docker deploy-docker docker-dev run-docker-dev \ No newline at end of file diff --git a/packaging/Makefile.inc b/packaging/Makefile.inc index c52132ce9..60a973c8d 100644 --- a/packaging/Makefile.inc +++ b/packaging/Makefile.inc @@ -20,56 +20,20 @@ # along with this program. If not, see . ################################################################################### -TAROPTS = --exclude-ignore-recursive=.distignore --transform='s|^\.|villas-node-$(VERSION_NUM)|' --show-transformed-names - -TAR_VILLAS = $(BUILDDIR)/packaging/villas-node-$(VERSION_NUM)-1.$(GIT_BRANCH)_$(subst -,_,$(VARIANT)).$(shell date +%Y%m%d)git$(GIT_REV).tar.gz - DEPLOY_USER ?= root DEPLOY_HOST ?= villas.fein-aachen.org DEPLOY_PATH ?= /var/www/villas/node -DOCKER_IMAGE ?= villas/node - -deploy-docker-dev: DOCKER_IMAGE := $(DOCKER_IMAGE)-dev -docker-dev: DOCKER_IMAGE := $(DOCKER_IMAGE)-dev +include packaging/rpm/Makefile.inc +include packaging/Makefile.docker.inc +include packaging/Makefile.dist.inc packaging: rpm dist deploy: deploy-dist deploy-rpm deploy-docker -# Source tarballs -dist: $(TAR_VILLAS) - -$(TAR_VILLAS): | $$(dir $$@) - tar $(TAROPTS) -C $(SRCDIR) -czf $@ . - -deploy-dist: $(TAR_VILLAS) - rsync $(TAR_VILLAS) $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/src - -deploy-rpm: - rsync -a --progress $(RPMDIR)/RPMS/ $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/../packages/ - ssh $(DEPLOY_USER)@$(DEPLOY_HOST) createrepo $(DEPLOY_PATH)/../packages - -deploy-docker deploy-docker-dev: - docker push $(DOCKER_IMAGE):$(GIT_BRANCH) - -# Docker targets -run-docker-dev: docker-dev - docker run -it -p 80:80 -p 443:443 -p 1234:1234 -p 12000:12000/udp -p 12001:12001/udp --privileged --security-opt seccomp:unconfined -v "$(SRCDIR):/villas" $(DOCKER_IMAGE)-dev:$(GIT_BRANCH) - -docker-dev: - docker pull fedora:25 - docker build -f Dockerfile.dev -t $(DOCKER_IMAGE):$(GIT_BRANCH) $(SRCDIR) - -docker: - docker pull fedora:25 - docker build -f Dockerfile -t $(DOCKER_IMAGE):$(GIT_BRANCH) $(SRCDIR) - -clean-packaging: - rm -f $(BUILDDIR)/packaging/villas-node-$(VERSION_NUM).tar.gz +clean-packaging: clean-rpm clean-dist install-packaging: -.PHONY: packaging install-packaging clean-packaging deploy deploy-dist deploy-rpm dist docker docker-dev run-docker-dev $(TAR_VILLAS) - --include packaging/rpm/Makefile.inc \ No newline at end of file +.PHONY: packaging install-packaging clean-packaging deploy \ No newline at end of file diff --git a/packaging/rpm/Makefile.inc b/packaging/rpm/Makefile.inc index e9fb10b4f..8e088b699 100644 --- a/packaging/rpm/Makefile.inc +++ b/packaging/rpm/Makefile.inc @@ -61,7 +61,11 @@ $(SPEC_VILLAS): $(SRCDIR)/packaging/rpm/villas-node.spec | $$(dir $$@) sign-rpm: rpmsign $(RPMDIR)/RPMS/*/.rpm +deploy-rpm: + rsync -a --progress $(RPMDIR)/RPMS/ $(DEPLOY_USER)@$(DEPLOY_HOST):$(DEPLOY_PATH)/../packages/ + ssh $(DEPLOY_USER)@$(DEPLOY_HOST) createrepo $(DEPLOY_PATH)/../packages + clean-rpm: rm -rf $(RPMDIR) -.PHONY: rpm clean-rpm rpm-libwebsockets rpm-libxil +.PHONY: rpm clean-rpm deploy-rpm sign-rpm rpm-libwebsockets rpm-libxil diff --git a/packaging/rpm/villas-node.spec b/packaging/rpm/villas-node.spec index 73dfdcfe2..d3b2eb932 100644 --- a/packaging/rpm/villas-node.spec +++ b/packaging/rpm/villas-node.spec @@ -56,8 +56,6 @@ rm -rf %{?buildroot} %files /usr/bin/villas /usr/bin/villas-* -/usr/bin/conf2json -/usr/bin/zmq-keygen /usr/lib/libvillas.so /usr/lib/libvillas.so.* diff --git a/plugins/Makefile.inc b/plugins/Makefile.inc index c1eb531f4..38a94b55d 100644 --- a/plugins/Makefile.inc +++ b/plugins/Makefile.inc @@ -30,7 +30,7 @@ PLUGIN_CFLAGS = -fPIC -DVILLAS -I../include/villas $(BUILDDIR)/example_hook.so: $(BUILDDIR)/plugins/hooks/example_hook.o $(BUILDDIR)/simple_circuit.so: $(BUILDDIR)/plugins/models/simple_circuit.o -plugins: $(PLUGINS) +plugins: $(PLUGINS) lib # Compile $(BUILDDIR)/plugins/%.o: plugins/%.c | $$(dir $$@) diff --git a/src/Makefile.inc b/src/Makefile.inc index c88b73c5c..02721af43 100644 --- a/src/Makefile.inc +++ b/src/Makefile.inc @@ -21,13 +21,13 @@ ################################################################################### # Executables -TARGETS = $(BUILDDIR)/villas-node \ - $(BUILDDIR)/villas-pipe \ - $(BUILDDIR)/villas-signal \ - $(BUILDDIR)/villas-test-rtt \ - $(BUILDDIR)/villas-test-cmp \ - $(BUILDDIR)/villas-test-shmem \ - $(BUILDDIR)/villas-hook +SRCS = src/node.c \ + src/pipe.c \ + src/signal.c \ + src/test-rtt.c \ + src/test-cmp.c \ + src/test-shmem.c \ + src/hook.c SRC_LDLIBS = $(LDLIBS) -pthread -lm -lvillas SRC_CFLAGS = $(CFLAGS) @@ -38,7 +38,7 @@ ifeq ($(shell $(PKGCONFIG) libxil; echo $$?),0) LIB_SRCS += $(addprefix lib/nodes/, fpga.c) LIB_SRCS += $(addprefix lib/kernel/, pci.c vfio.c) LIB_SRCS += $(wildcard lib/fpga/*.c) - TARGETS += $(BUILDDIR)/villas-fpga + SRCS += src/fpga.c PKGS += libxil # Add support for LAPACK / BLAS benchmarks / solvers @@ -48,9 +48,13 @@ ifeq ($(shell $(PKGCONFIG) libxil; echo $$?),0) endif endif -src: $(TARGETS) +BINS = $(patsubst src/%.c, $(BUILDDIR)/villas-%, $(SRCS)) +OBJS = $(patsubst src/%.c, $(BUILDDIR)/src/%.o, $(SRCS)) +DEPS = $(patsubst src/%.c, $(BUILDDIR)/src/%.d, $(SRCS)) -$(TARGETS): $(BUILDDIR)/villas-%: $(BUILDDIR)/src/%.o +src: $(BINS) lib + +$(BINS): $(BUILDDIR)/villas-%: $(BUILDDIR)/src/%.o # Some additional prereqs for individual binaries $(BUILDDIR)/villas-fpga: $(addprefix $(BUILDDIR)/src/,fpga-bench.o $(BENCH_OBJS)) @@ -64,14 +68,14 @@ $(BUILDDIR)/villas-shmem: $(BUILDDIR)/src/shmem.o libvillas-ext $(CC) $(SRC_LDFLAGS) $(BUILDDIR)/src/shmem.o $(filter-out -lvillas,$(SRC_LDLIBS)) -lvillas-ext -o $@ # Link target executables -$(TARGETS): | $(LIBS) +$(BINS): | $(LIBS) $(CC) $(SRC_LDFLAGS) $^ $(SRC_LDLIBS) -o $@ # Install -install-src: src - install -m 0755 -D -t $(DESTDIR)$(PREFIX)/bin $(TARGETS) +install-src: src install-lib + install -m 0755 -D -t $(DESTDIR)$(PREFIX)/bin $(BINS) clean-src: - rm -rf $(BUILDDIR)/src $(TARGETS) + rm -f $(DEPS) $(OBJS) $(BINS) -.PHONY: src src-tests src-tests +.PHONY: src install-src clean-src diff --git a/tests/Makefile.inc b/tests/Makefile.inc index 7a5cb54cf..cf4410cb5 100644 --- a/tests/Makefile.inc +++ b/tests/Makefile.inc @@ -20,15 +20,17 @@ # along with this program. If not, see . ################################################################################### --include tests/unit/Makefile.inc --include tests/integration/Makefile.inc +include tests/unit/Makefile.inc +include tests/integration/Makefile.inc tests: unit-tests integration-tests run-tests: run-unit-tests run-integration-tests run-valgrind +clean-tests: clean-unit-tests clean-integration-tests + run-valgrind: src valgrind --leak-check=full --show-leak-kinds=all --suppressions=$(SRCDIR)/tests/valgrind.supp $(BUILDDIR)/villas-node & sleep 2; kill $$!; sleep 1; kill $$! valgrind --leak-check=full --show-leak-kinds=all --suppressions=$(SRCDIR)/tests/valgrind.supp $(BUILDDIR)/villas-pipe $(SRCDIR)/etc/websocket-loopback.conf ws1 & sleep 2; kill $$!; sleep 1; kill $$! -.PHONY: tests run-tests run-valgrind +.PHONY: tests run-tests run-valgrind clean-tests diff --git a/tests/integration/Makefile.inc b/tests/integration/Makefile.inc index bf531b329..da50d603e 100644 --- a/tests/integration/Makefile.inc +++ b/tests/integration/Makefile.inc @@ -23,4 +23,8 @@ integration-tests: src tools run-integration-tests: integration-tests - @$(SRCDIR)/tests/integration-tests.sh \ No newline at end of file + @$(SRCDIR)/tests/integration-tests.sh + +clean-integration-tests: + +.PHONY: integration-tests run-integration-tests clean-integration-tests \ No newline at end of file diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc index 40fae311e..4fa5ceb7d 100644 --- a/tests/unit/Makefile.inc +++ b/tests/unit/Makefile.inc @@ -22,6 +22,7 @@ TEST_SRCS = $(wildcard tests/unit/*.c) TEST_OBJS = $(patsubst %.c,$(BUILDDIR)/%.o,$(TEST_SRCS)) +TEST_DEPS = $(patsubst %.c,$(BUILDDIR)/%.d,$(TEST_SRCS)) TEST_CFLAGS = $(CFLAGS) TEST_LDFLAGS = $(LDFLAGS) -Wl,-rpath,'$$ORIGIN' @@ -41,13 +42,13 @@ $(BUILDDIR)/unit-tests: $(TEST_OBJS) $(LIB) $(CC) $(TEST_LDFLAGS) $^ $(TEST_LDLIBS) -o $@ ifdef COVERAGE --include tests/unit/Makefile.gcov.inc +include tests/unit/Makefile.gcov.inc endif # Tests are not installed install-tests: -clean-tests: - rm -rf $(BUILDDIR)/tests $(BUILDDIR)/testsuite +clean-unit-tests: + rm -f $(TEST_OBJS) $(TEST_DEPS) $(BUILDDIR)/unit-tests .PHONY: unit-tests install-unit-tests clean-unit-tests run-unit-tests \ No newline at end of file diff --git a/thirdparty/Makefile.inc b/thirdparty/Makefile.inc index 757a8ac0c..1f5cd038e 100644 --- a/thirdparty/Makefile.inc +++ b/thirdparty/Makefile.inc @@ -20,10 +20,10 @@ # along with this program. If not, see . ################################################################################### -DEPS_CMAKE = libxil libwebsockets criterion jansson nanomsg -DEPS_AUTOCONF = libnl libconfig libcurl libzmq +REQS_CMAKE = libxil libwebsockets criterion jansson nanomsg +REQS_AUTOCONF = libnl libconfig libcurl libzmq -DEPS = $(DEPS_CMAKE) $(DEPS_AUTOCONF) +REQS = $(REQS_CMAKE) $(REQS_AUTOCONF) ifdef DEBUG CMAKE_OPTS += -DCMAKE_BUILD_TYPE=DEBUG @@ -38,30 +38,29 @@ CONFIGURE_OPTS = --prefix=$(PREFIX) thirdparty: # Install & compile autotools based projects -$(DEPS_AUTOCONF): CPPFLAGS=$(AC_CPPFLAGS) CFLAGS=$(AC_CFLAGS) CXXFLAGS=$(AC_CXXFLAGS) -$(DEPS_AUTOCONF): | $(BUILDDIR)/thirdparty/$$@/ +$(REQS_AUTOCONF): CPPFLAGS=$(AC_CPPFLAGS) CFLAGS=$(AC_CFLAGS) CXXFLAGS=$(AC_CXXFLAGS) +$(REQS_AUTOCONF): | $(BUILDDIR)/thirdparty/$$@/ autoreconf -fi $(SRCDIR)/thirdparty/$@ cd $(BUILDDIR)/thirdparty/$@ && $(SRCDIR)/thirdparty/$@/configure $(CONFIGURE_OPTS) && make # Install & compile CMake based projects -$(DEPS_CMAKE): | $(BUILDDIR)/thirdparty/$$@/ +$(REQS_CMAKE): | $(BUILDDIR)/thirdparty/$$@/ cmake -DCMAKE_INSTALL_PREFIX:PATH=$(PREFIX) \ -DCMAKE_INSTALL_LIBDIR=$(PREFIX)/lib64 -DLIB_SUFFIX=64 \ -H$(SRCDIR)/thirdparty/$@ \ -B$(BUILDDIR)/thirdparty/$@ $(CMAKE_OPTS) make -C$(BUILDDIR)/thirdparty/$@ -$(addprefix install-,$(DEPS)): install-%: % +$(addprefix install-,$(REQS)): install-%: % make -C$(BUILDDIR)/thirdparty/$(@:install-%=%) install ldconfig -$(addprefix clean-,$(DEPS)): - rm -rf $(BUILDDIR)/thirdparty/$(@:clean-%=%) +$(addprefix clean-,$(REQS)): + if [ -d $(BUILDDIR)/thirdparty/$(@:clean-%=%) ]; then make -C$(BUILDDIR)/thirdparty/$(@:clean-%=%) clean; fi -install-thirdparty: $(addprefix install-,$(DEPS)) +install-thirdparty: $(addprefix install-,$(REQS)) -clean-thirdparty: $(addprefix clean-,$(DEPS)) - rm -rf $(BUILDDIR)/thirdparty +clean-thirdparty: $(addprefix clean-,$(REQS)) # libconfig's build system is currently broken. # This is a workaround for: https://github.com/hyperrealm/libconfig/issues/53 @@ -70,6 +69,6 @@ libconfig-fix: rm -f $(SRCDIR)/thirdparty/libconfig/lib/scanner.[hc] libwebsockets: CMAKE_OPTS += -DLWS_IPV6=1 -DLWS_WITH_STATIC=0 -DLWS_WITHOUT_TESTAPPS=1 -DLWS_WITH_HTTP2=1 -libzmq: CONFIGURE_OPTS += --with-libsodium --with-pgm --enable-drafts +libzmq: CONFIGURE_OPTS += --with-libsodium --with-pgm --enable-drafts -.PHONY: $(DEPS) thirdparty clean-thirdparty install-thirdparty \ No newline at end of file +.PHONY: $(REQS) thirdparty clean-thirdparty install-thirdparty \ No newline at end of file diff --git a/tools/Makefile.inc b/tools/Makefile.inc index 6f2392176..220997872 100644 --- a/tools/Makefile.inc +++ b/tools/Makefile.inc @@ -20,30 +20,34 @@ # along with this program. If not, see . ################################################################################### -TOOLS = $(BUILDDIR)/conf2json +TOOLS_SRCS = tools/conf2json.c TOOLS_CFLAGS = $(CFLAGS) TOOLS_LDLIBS = -lconfig -ljansson -lvillas TOOLS_LDFLAGS = $(LDFLAGS) -Wl,-rpath,'$$ORIGIN' ifeq ($(shell $(PKGCONFIG) libzmq; echo $$?),0) - TOOLS += $(BUILDDIR)/zmq-keygen + TOOLS_SRCS += tools/zmq-keygen.c TOOLS_CFLAGS += $(shell $(PKGCONFIG) --cflags libzmq) TOOLS_LDLIBS += $(shell $(PKGCONFIG) --libs libzmq) endif +TOOLS_BINS = $(patsubst tools/%.c, $(BUILDDIR)/villas-%, $(TOOLS_SRCS)) +TOOLS_DEPS = $(patsubst tools/%.c, $(BUILDDIR)/tools/%.d, $(TOOLS_SRCS)) +TOOLS_OBJS = $(patsubst tools/%.c, $(BUILDDIR)/tools/%.o, $(TOOLS_SRCS)) + # Compile executable objects $(BUILDDIR)/tools/%.o: tools/%.c $(BUILDDIR)/defines | $$(dir $$@) $(CC) $(TOOLS_CFLAGS) -c $< -o $@ # Link target executables -$(TOOLS): $(BUILDDIR)/%: $(BUILDDIR)/tools/%.o | $(LIBS) +$(TOOLS): $(BUILDDIR)/villas-%: $(BUILDDIR)/tools/%.o | $(LIBS) $(CC) $(TOOLS_LDFLAGS) $^ $(TOOLS_LDLIBS) -o $@ tools: $(TOOLS) clean-tools: - rm -rf $(BUILDDIR)/tools $(TOOLS) + rm -f $(TOOLS_BINS) $(TOOLS_OBJS) $(TOOLS_DEPS) install-tools: $(TOOLS) install -m 0755 tools/villas.sh $(DESTDIR)$(PREFIX)/bin/villas