mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
reworked Makefiles
This commit is contained in:
parent
bb6b68a8c8
commit
3206f918c1
22 changed files with 315 additions and 203 deletions
28
Makefile
28
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
|
||||
|
|
|
@ -76,4 +76,4 @@ clean:
|
|||
$(TARGET): $(OBJS)
|
||||
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
|
||||
|
||||
-include $(wildcard *.d)
|
||||
include $(wildcard *.d)
|
|
@ -76,4 +76,4 @@ clean:
|
|||
$(TARGET): $(OBJS)
|
||||
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
|
||||
|
||||
-include $(wildcard *.d)
|
||||
include $(wildcard *.d)
|
|
@ -20,26 +20,26 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -22,4 +22,4 @@
|
|||
|
||||
LIB_SRCS += $(wildcard lib/api/*.c)
|
||||
|
||||
-include lib/api/actions/Makefile.inc
|
||||
include lib/api/actions/Makefile.inc
|
23
lib/kernel/Makefile.inc
Normal file
23
lib/kernel/Makefile.inc
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Makefile.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @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 <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
LIB_SRCS += $(addprefix lib/kernel/, kernel.c rt.c)
|
|
@ -20,4 +20,77 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
LIB_SRC += $(wildcard lib/nodes/*.c)
|
||||
# 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
|
23
lib/rtds/Makefile.inc
Normal file
23
lib/rtds/Makefile.inc
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Makefile.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @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 <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
LIB_SRCS += $(wildcard lib/rtds/*.c)
|
39
packaging/Makefile.dist.inc
Normal file
39
packaging/Makefile.dist.inc
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Makefile.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @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 <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
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
|
44
packaging/Makefile.docker.inc
Normal file
44
packaging/Makefile.docker.inc
Normal file
|
@ -0,0 +1,44 @@
|
|||
# Makefile.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @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 <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
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
|
|
@ -20,56 +20,20 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
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
|
||||
.PHONY: packaging install-packaging clean-packaging deploy
|
|
@ -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
|
||||
|
|
|
@ -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.*
|
||||
|
|
|
@ -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 $$@)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -20,15 +20,17 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
-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
|
||||
|
|
|
@ -23,4 +23,8 @@
|
|||
integration-tests: src tools
|
||||
|
||||
run-integration-tests: integration-tests
|
||||
@$(SRCDIR)/tests/integration-tests.sh
|
||||
@$(SRCDIR)/tests/integration-tests.sh
|
||||
|
||||
clean-integration-tests:
|
||||
|
||||
.PHONY: integration-tests run-integration-tests clean-integration-tests
|
|
@ -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
|
27
thirdparty/Makefile.inc
vendored
27
thirdparty/Makefile.inc
vendored
|
@ -20,10 +20,10 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
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
|
||||
.PHONY: $(REQS) thirdparty clean-thirdparty install-thirdparty
|
|
@ -20,30 +20,34 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue