Makefile 1.74 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 6
CONFIG ?= config

Marek Vavruša's avatar
Marek Vavruša committed
7 8 9 10 11 12
LIBEXT := .so
PLATFORM := $(shell uname -s)
ifeq ($(PLATFORM),Darwin)
	LIBEXT := .dylib
endif

13 14 15 16 17 18 19 20
# Find all sub-targets
TARGETS := $(TESTS)
ifeq (,$(findstring .rpl,$(TESTS)))
TARGETS := $(wildcard $(TESTS)/*.rpl)
endif
SOURCES := $(TARGETS)
TARGETS := $(patsubst %.rpl,%.out,$(SOURCES))

Marek Vavruša's avatar
Marek Vavruša committed
21 22
# Dependencies
include platform.mk
23 24 25
libcwrap_DIR := contrib/libswrap
libcwrap_cmake_DIR := $(libcwrap_DIR)/obj
libcwrap=$(abspath $(libcwrap_cmake_DIR))/src/libsocket_wrapper$(LIBEXT).0
26 27 28
ifeq ($(PLATFORM),Darwin)
	libcwrap=$(abspath $(libcwrap_cmake_DIR))/src/libsocket_wrapper.0$(LIBEXT)
endif
Marek Vavruša's avatar
Marek Vavruša committed
29 30 31 32 33 34
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)
35
	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
36 37 38 39
else
	preload_syms := LD_PRELOAD="$(libfaketime):$(libcwrap)"
endif

40 41
# Targets
all: $(TARGETS)
Marek Vavruša's avatar
Marek Vavruša committed
42 43
depend: $(libfaketime) $(libcwrap)

44 45 46 47 48
# Generic rule to run test
$(SOURCES): depend
%.out: %.rpl
	@$(preload_syms) python $(abspath ./deckard.py) $< $(DAEMON) $(TEMPLATE) $(CONFIG) $(ADDITIONAL)

Marek Vavruša's avatar
Marek Vavruša committed
49
# Synchronize submodules
50 51
$(libfaketime_DIR)/Makefile: .gitmodules
	@git submodule update --init && mkdir $(libcwrap_cmake_DIR) > /dev/null
Marek Vavruša's avatar
Marek Vavruša committed
52
$(libfaketime): $(libfaketime_DIR)/Makefile
53
	@CFLAGS="-O0 -g" $(MAKE) -s -C $(libfaketime_DIR)
Marek Vavrusa's avatar
Marek Vavrusa committed
54
$(libcwrap_cmake_DIR)/Makefile: $(libfaketime)
55 56
	@cd $(libcwrap_cmake_DIR); cmake ..
$(libcwrap): $(libcwrap_cmake_DIR)/Makefile
57
	@CFLAGS="-O0 -g" $(MAKE) -s -C $(libcwrap_cmake_DIR)
58

Marek Vavruša's avatar
Marek Vavruša committed
59 60

.PHONY: depend all