From 17bc32ad895dadf2bb2c0eb07161509c1a45d572 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 13 Oct 2016 22:15:28 -0400 Subject: [PATCH] more improvement for our build system --- Dockerfile | 2 +- Makefile | 5 ++--- lib/Makefile.inc | 7 +++--- src/Makefile.inc | 49 +++++++++++++++++++++-------------------- tests/Makefile.inc | 12 +++++----- thirdparty/Makefile.inc | 30 ++++++++++++------------- 6 files changed, 52 insertions(+), 53 deletions(-) diff --git a/Dockerfile b/Dockerfile index aee38416c..48ba1fe52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -79,4 +79,4 @@ RUN rm -rf /tmp WORKDIR /villas -ENTRYPOINT /bin/bash +ENTRYPOINT make clean && make install && villas node; bash diff --git a/Makefile b/Makefile index d53959a15..8b505509b 100644 --- a/Makefile +++ b/Makefile @@ -84,9 +84,8 @@ CFLAGS += $(addprefix -DWITH_, $(shell echo ${PKGS} | tr a-z- A-Z_ | tr -dc ' A- CFLAGS += $(shell pkg-config --cflags ${PKGS}) LDLIBS += $(shell pkg-config --libs ${PKGS}) -# Default target: build everything; no tests, docs -all: src - +all: src plugins | lib + everything: $(MAKE) DEBUG=1 $(MAKE) COVERAGE=1 diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 9a5f11b34..d7874fe03 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -24,13 +24,12 @@ ifeq ($(shell pkg-config libnl-route-3.0; echo $$?),0) LIB_PKGS += libnl-route-3.0 endif -# Enable VILLASfpga support when libpci is available -ifeq ($(shell pkg-config libpci; echo $$?),0) +# Enable VILLASfpga support when libxil is available +ifeq ($(shell pkg-config 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) - LIB_PKGS += libpci - LIB_LDLIBS += -lxil + PKGS += libxil endif # Enable NGSI support diff --git a/src/Makefile.inc b/src/Makefile.inc index 26ea1f62c..280efdbe2 100644 --- a/src/Makefile.inc +++ b/src/Makefile.inc @@ -1,30 +1,35 @@ # Executables -TARGETS = $(BUILDDIR)/node \ - $(BUILDDIR)/pipe \ - $(BUILDDIR)/signal \ - $(BUILDDIR)/test \ - $(BUILDDIR)/fpga +TARGETS = $(BUILDDIR)/villas-node \ + $(BUILDDIR)/villas-pipe \ + $(BUILDDIR)/villas-signal \ + $(BUILDDIR)/villas-test -SRC_LDLIBS = $(LDLIBS) -pthread -lm -lvillas -lxil +SRC_LDLIBS = $(LDLIBS) -pthread -lm -lvillas SRC_CFLAGS = $(CFLAGS) -SRC_LDFLAGS = $(LDFLAGS) +SRC_LDFLAGS = $(LDFLAGS) -Wl,-rpath,'$$ORIGIN' -src: $(TARGETS) +# Enable VILLASfpga support when libxil is available +ifeq ($(shell pkg-config 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 + PKGS += libxil -# Add support for LAPACK / BLAS benchmarks / solvers -ifeq ($(shell pkg-config blas lapack; echo $$?),0) - PKGS += blas lapack - BENCH_OBJS += fpga-bench-overruns.o + # Add support for LAPACK / BLAS benchmarks / solvers + ifeq ($(shell pkg-config blas lapack; echo $$?),0) + PKGS += blas lapack + BENCH_OBJS += fpga-bench-overruns.o + endif endif src: $(TARGETS) -# Dependencies for individual binaries -$(BUILDDIR)/fpga: $(addprefix $(BUILDDIR)/src/,fpga.o fpga-tests.o fpga-bench.o $(BENCH_OBJS)) -$(BUILDDIR)/node: $(BUILDDIR)/src/node.o -$(BUILDDIR)/pipe: $(BUILDDIR)/src/pipe.o -$(BUILDDIR)/signal: $(BUILDDIR)/src/signal.o -$(BUILDDIR)/test: $(BUILDDIR)/src/test.o +$(TARGETS): $(BUILDDIR)/villas-%: $(BUILDDIR)/src/%.o + +# Some additional prereqs for individual binaries +$(BUILDDIR)/villas-fpga: $(addprefix $(BUILDDIR)/src/,fpga-tests.o fpga-bench.o $(BENCH_OBJS)) + # Compile executable objects $(BUILDDIR)/src/%.o: src/%.c | $$(dir $$@) @@ -35,12 +40,8 @@ $(TARGETS): | $(LIBS) $(CC) $(SRC_LDFLAGS) $^ $(SRC_LDLIBS) -o $@ # Install -install-src: - install -m 0755 $(BUILDDIR)/node -T $(PREFIX)/bin/villas-node - install -m 0755 $(BUILDDIR)/fpga -T $(PREFIX)/bin/villas-fpga - install -m 0755 $(BUILDDIR)/signal -T $(PREFIX)/bin/villas-signal - install -m 0755 $(BUILDDIR)/pipe -T $(PREFIX)/bin/villas-pipe - install -m 0755 $(BUILDDIR)/test -T $(PREFIX)/bin/villas-test +install-src: src + install -m 0755 $(TARGETS) $(PREFIX)/bin clean-src: rm -rf $(BUILDDIR)/src $(TARGETS) diff --git a/tests/Makefile.inc b/tests/Makefile.inc index cfc6120a7..121ba1360 100644 --- a/tests/Makefile.inc +++ b/tests/Makefile.inc @@ -1,19 +1,19 @@ -TARGETS += $(BUILDDIR)/tests - TEST_SRCS = $(wildcard tests/*.c) TEST_OBJS = $(patsubst %.c,$(BUILDDIR)/%.o,$(TEST_SRCS)) TEST_CFLAGS = $(CFLAGS) -TEST_LDFLAGS = $(LDFLAGS) -TEST_LDLIBS = $(LDLIBS) -l criterion +TEST_LDFLAGS = $(LDFLAGS) -Wl,-rpath,'$$ORIGIN' +TEST_LDLIBS = $(LDLIBS) -lcriterion -lvillas + +tests: $(BUILDDIR)/testsuite # Compile $(BUILDDIR)/tests/%.o: tests/%.c | $$(dir $$@) $(CC) $(TEST_CFLAGS) -c $< -o $@ # Link -$(BUILDDIR)/tests: $(TEST_OBJS) | $(LIBS) - $(CC) $(TEST_LDFLAGS) $(TEST_LDLIBS) $^ -o $@# +$(BUILDDIR)/testsuite: $(TEST_OBJS) | $(LIBS) + $(CC) $(TEST_LDFLAGS) $(TEST_LDLIBS) $^ -o $@ ifdef COVERAGE -include Makefile.gcov.inc diff --git a/thirdparty/Makefile.inc b/thirdparty/Makefile.inc index 8ef65afc5..7fc108858 100644 --- a/thirdparty/Makefile.inc +++ b/thirdparty/Makefile.inc @@ -3,36 +3,36 @@ DEPS_AUTOCONF = libnl libconfig libcurl DEPS = $(DEPS_CMAKE) $(DEPS_AUTOCONF) -.PHONY: $(DEPS) - -# Install all dependencies -thirdparty: libxil +thirdparty: # Install & compile autotools based projects $(DEPS_AUTOCONF): | $(BUILDDIR)/thirdparty/$$@/ autoreconf -fi $(SRCDIR)/thirdparty/$@ - cd $(BUILDDIR)/thirdparty/$@ && $(SRCDIR)/thirdparty/$@/configure --prefix=$(PREFIX) && make install + cd $(BUILDDIR)/thirdparty/$@ && $(SRCDIR)/thirdparty/$@/configure --prefix=$(PREFIX) && make # Install & compile CMake based projects $(DEPS_CMAKE): | $(BUILDDIR)/thirdparty/$$@/ cmake -DCMAKE_INSTALL_PREFIX:PATH=$(PREFIX) \ -H$(SRCDIR)/thirdparty/$@ \ -B$(BUILDDIR)/thirdparty/$@ - make -C$(BUILDDIR)/thirdparty/$@ install + make -C$(BUILDDIR)/thirdparty/$@ + +$(addprefix install-,$(DEPS)): install-%: % + make -C$(BUILDDIR)/thirdparty/$(@:install-%=%) install + ldconfig + +$(addprefix clean-,$(DEPS)): + rm -rf $(BUILDDIR)/thirdparty/$(@:clean-%=%) + +install-thirdparty: clean-thirdparty: - for DEP in $(DEPS); do \ - pushd $$DEP; \ - git checkout . ; \ - git clean -dxf $$DEP . ; \ - popd; \ - done + rm -rf $(BUILDDIR)/thirdparty -install-thirdparty: $(addprefix install-,$(DEPS)) +.PHONY: $(DEPS) thirdparty clean-thirdparty install-thirdparty -clean-thirdparty: $(addprefix clean-,$(DEPS)) -.PHONY: $(DEPS) thirdparty clean-thirdparty install-thirdparty# libconfig's build system is currently broken. +# libconfig's build system is currently broken. # This is a workaround for: https://github.com/hyperrealm/libconfig/issues/53 libconfig: | libconfig-fix libconfig-fix: