2016-10-06 17:55:35 -04:00
|
|
|
# Libraries
|
|
|
|
LIBS = $(BUILDDIR)/libvillas.so
|
|
|
|
|
|
|
|
# Object files for libvillas
|
|
|
|
LIB_SRCS = $(addprefix lib/nodes/, file.c cbuilder.c) \
|
|
|
|
$(addprefix lib/kernel/, kernel.c rt.c) \
|
2017-01-19 23:12:52 -02:00
|
|
|
$(addprefix lib/, sample.c path.c node.c hooks.c \
|
2016-10-06 17:55:35 -04:00
|
|
|
log.c utils.c cfg.c hist.c timing.c pool.c list.c \
|
2017-01-19 23:12:52 -02:00
|
|
|
queue.c memory.c advio.c \
|
2016-10-06 17:55:35 -04:00
|
|
|
) \
|
|
|
|
|
|
|
|
LIB_CFLAGS = $(CFLAGS) -fPIC
|
|
|
|
LIB_LDFLAGS = -shared
|
|
|
|
LIB_LDLIBS = $(LDLIBS) -ldl -lrt
|
|
|
|
|
2017-02-15 17:54:52 -03:00
|
|
|
-include lib/hooks/Makefile.inc
|
|
|
|
-include lib/apis/Makefile.inc
|
|
|
|
-include lib/fpga/Makefile.inc
|
|
|
|
|
2016-10-06 17:55:35 -04:00
|
|
|
######## Node types ########
|
|
|
|
|
|
|
|
# Enable Socket node type when libnl3 is available
|
2016-10-14 01:33:07 -04:00
|
|
|
ifndef WITHOUT_SOCKET
|
2016-10-06 17:55:35 -04:00
|
|
|
ifeq ($(shell pkg-config 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
|
2016-10-14 01:33:07 -04:00
|
|
|
endif
|
2016-10-06 17:55:35 -04:00
|
|
|
|
2016-10-13 22:15:28 -04:00
|
|
|
# Enable VILLASfpga support when libxil is available
|
2016-10-14 01:33:07 -04:00
|
|
|
ifndef WITHOUT_FPGA
|
2016-10-13 22:15:28 -04:00
|
|
|
ifeq ($(shell pkg-config libxil; echo $$?),0)
|
2016-10-06 17:55:35 -04:00
|
|
|
LIB_SRCS += $(addprefix lib/nodes/, fpga.c)
|
|
|
|
LIB_SRCS += $(addprefix lib/kernel/, pci.c vfio.c)
|
2016-10-13 22:15:28 -04:00
|
|
|
PKGS += libxil
|
2016-10-06 17:55:35 -04:00
|
|
|
endif
|
2016-10-14 01:33:07 -04:00
|
|
|
endif
|
2016-10-06 17:55:35 -04:00
|
|
|
|
|
|
|
# Enable NGSI support
|
2016-10-14 01:33:07 -04:00
|
|
|
ifndef WITHOUT_NGSI
|
2016-10-08 01:10:12 -04:00
|
|
|
ifeq ($(shell pkg-config libcurl jansson; echo $$?),0)
|
2016-10-06 17:55:35 -04:00
|
|
|
LIB_SRCS += lib/nodes/ngsi.c
|
2016-10-08 01:10:12 -04:00
|
|
|
LIB_PKGS += libcurl jansson
|
2016-10-06 17:55:35 -04:00
|
|
|
endif
|
2016-10-14 01:33:07 -04:00
|
|
|
endif
|
2016-10-06 17:55:35 -04:00
|
|
|
|
|
|
|
# Enable WebSocket support
|
2016-10-14 01:33:07 -04:00
|
|
|
ifndef WITHOUT_WEBSOCKETS
|
2016-10-06 17:55:35 -04:00
|
|
|
ifeq ($(shell pkg-config libwebsockets jansson; echo $$?),0)
|
|
|
|
LIB_SRCS += lib/nodes/websocket.c
|
|
|
|
LIB_PKGS += libwebsockets jansson
|
|
|
|
endif
|
2016-10-14 01:33:07 -04:00
|
|
|
endif
|
2016-10-06 17:55:35 -04:00
|
|
|
|
|
|
|
# Enable OPAL-RT Asynchronous Process support (will result in 32bit binary!!!)
|
|
|
|
ifdef WITH_OPAL
|
|
|
|
ifneq (,$(wildcard thirdparty/opal/include/AsyncApi.h))
|
|
|
|
LIB_OBJS += opal.o
|
|
|
|
|
|
|
|
LIB_CFLAGS += -I thirdparty/opal/include
|
|
|
|
LIB_LDFLAGS += -L/lib/i386-linux-gnu/ -L/usr/lib/i386-linux-gnu/ -Lthirdparty/opal/lib/redhawk/
|
|
|
|
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)32
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Add flags by pkg-config
|
|
|
|
LIB_CFLAGS += $(addprefix -DWITH_, $(shell echo ${LIB_PKGS} | tr a-z- A-Z_ | tr -dc ' A-Z0-9_' ))
|
|
|
|
LIB_CFLAGS += $(shell pkg-config --cflags ${LIB_PKGS})
|
|
|
|
LIB_LDLIBS += $(shell pkg-config --libs ${LIB_PKGS})
|
|
|
|
|
|
|
|
LIB_OBJS = $(patsubst %.c, $(BUILDDIR)/%.o, $(LIB_SRCS))
|
|
|
|
|
|
|
|
lib: $(LIBS)
|
|
|
|
|
|
|
|
# Compile
|
|
|
|
$(BUILDDIR)/lib/%.o: lib/%.c | $$(dir $$@)
|
|
|
|
$(CC) $(LIB_CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
# Link
|
|
|
|
$(LIBS): $(LIB_OBJS)
|
|
|
|
$(CC) $(LIB_LDFLAGS) -o $@ $^ $(LIB_LDLIBS)
|
|
|
|
|
|
|
|
# Install
|
2016-10-13 19:53:30 -04:00
|
|
|
install-lib: lib
|
2016-10-06 17:55:35 -04:00
|
|
|
install -m 0644 $(LIBS) $(PREFIX)/lib
|
|
|
|
install -m 0755 -d $(PREFIX)/include/villas/
|
|
|
|
install -m 0644 include/villas/*.h $(PREFIX)/include/villas/
|
2016-10-13 22:13:49 -04:00
|
|
|
ldconfig
|
2016-10-13 19:53:30 -04:00
|
|
|
|
|
|
|
clean-lib:
|
|
|
|
rm -rf $(BUILDDIR)/lib $(LIBS)
|
|
|
|
|
|
|
|
.PHONY: lib lib-tests lib-tests
|