Makefile 2.41 KB
Newer Older
1
# Defaults
Marek Vavruša's avatar
Marek Vavruša committed
2
TESTS ?= sets/resolver
3
DAEMON ?= kresd
Marek Vavrusa's avatar
Marek Vavrusa committed
4
TEMPLATE ?= template/kresd.j2
5
CONFIG ?= config
6
ADDITIONAL ?= -f 1
7
OPTS ?=
8

9
PYTHON ?= python3
Marek Vavruša's avatar
Marek Vavruša committed
10 11 12 13 14 15
LIBEXT := .so
PLATFORM := $(shell uname -s)
ifeq ($(PLATFORM),Darwin)
	LIBEXT := .dylib
endif

16 17 18 19 20 21
# Find all sub-targets
TARGETS := $(TESTS)
ifeq (,$(findstring .rpl,$(TESTS)))
TARGETS := $(wildcard $(TESTS)/*.rpl)
endif
SOURCES := $(TARGETS)
22
TARGETS := $(sort $(patsubst %.rpl,%.out-qmin,$(SOURCES))) $(sort $(patsubst %.rpl,%.out-noqmin,$(SOURCES)))
23

Marek Vavruša's avatar
Marek Vavruša committed
24 25
# Dependencies
include platform.mk
26 27 28
libcwrap_DIR := contrib/libswrap
libcwrap_cmake_DIR := $(libcwrap_DIR)/obj
libcwrap=$(abspath $(libcwrap_cmake_DIR))/src/libsocket_wrapper$(LIBEXT).0
29 30 31
ifeq ($(PLATFORM),Darwin)
	libcwrap=$(abspath $(libcwrap_cmake_DIR))/src/libsocket_wrapper.0$(LIBEXT)
endif
Marek Vavruša's avatar
Marek Vavruša committed
32 33 34 35 36 37
libfaketime_DIR := contrib/libfaketime
libfaketime := $(abspath $(libfaketime_DIR))/src/libfaketime$(LIBEXT).1

# Platform-specific targets
ifeq ($(PLATFORM),Darwin)
	libfaketime := $(abspath $(libfaketime_DIR))/src/libfaketime.1$(LIBEXT)
38
	preload_syms := DYLD_LIBRARY_PATH=$(DYLD_LIBRARY_PATH) DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES="$(libfaketime):$(libcwrap)"
Marek Vavruša's avatar
Marek Vavruša committed
39 40 41 42
else
	preload_syms := LD_PRELOAD="$(libfaketime):$(libcwrap)"
endif

43 44
# Targets
all: $(TARGETS)
Marek Vavruša's avatar
Marek Vavruša committed
45 46
depend: $(libfaketime) $(libcwrap)

47 48
# Generic rule to run test
$(SOURCES): depend
49 50 51 52 53 54 55
%.out-qmin: %.rpl
	@test "$${QMIN:-true}" == "true" || exit 0 && \
	$(preload_syms) $(PYTHON) $(abspath ./deckard.py) --qmin true $(OPTS) $< one $(DAEMON) $(TEMPLATE) $(CONFIG) -- $(ADDITIONAL)

%.out-noqmin: %.rpl
	@test "$${QMIN:-false}" == "false" || exit 0 && \
	$(preload_syms) $(PYTHON) $(abspath ./deckard.py) --qmin false $(OPTS) $< one $(DAEMON) $(TEMPLATE) $(CONFIG) -- $(ADDITIONAL)
56

Marek Vavruša's avatar
Marek Vavruša committed
57
# Synchronize submodules
58
submodules: .gitmodules
59
	@git submodule update --init
60 61 62
# indirection through submodules target is necessary
# to prevent make from running "git submodule" commands in parallel
$(libfaketime_DIR)/Makefile $(libcwrap_DIR)/CMakeLists.txt: submodules
Marek Vavruša's avatar
Marek Vavruša committed
63
$(libfaketime): $(libfaketime_DIR)/Makefile
64
	@CFLAGS="-O0 -g" $(MAKE) -s -C $(libfaketime_DIR)
65 66 67
$(libcwrap_cmake_DIR):$(libcwrap_DIR)/CMakeLists.txt
	@mkdir -p $(libcwrap_cmake_DIR)
$(libcwrap_cmake_DIR)/Makefile: $(libcwrap_cmake_DIR)
68 69
	@cd $(libcwrap_cmake_DIR); cmake ..
$(libcwrap): $(libcwrap_cmake_DIR)/Makefile
70
	@CFLAGS="-O0 -g" $(MAKE) -s -C $(libcwrap_cmake_DIR)
71

Marek Vavruša's avatar
Marek Vavruša committed
72

73
.PHONY: submodules depend all
74 75 76

check:
	@echo Running unittests using pytest
77
	${PYTHON} -m pytest