Makefile 1.86 KB
Newer Older
1
# Defaults
2
PYTHON ?= python3
Marek Vavruša's avatar
Marek Vavruša committed
3 4 5 6 7 8 9 10
LIBEXT := .so
PLATFORM := $(shell uname -s)
ifeq ($(PLATFORM),Darwin)
	LIBEXT := .dylib
endif

# Dependencies
include platform.mk
11 12 13
libcwrap_DIR := contrib/libswrap
libcwrap_cmake_DIR := $(libcwrap_DIR)/obj
libcwrap=$(abspath $(libcwrap_cmake_DIR))/src/libsocket_wrapper$(LIBEXT).0
14 15 16
ifeq ($(PLATFORM),Darwin)
	libcwrap=$(abspath $(libcwrap_cmake_DIR))/src/libsocket_wrapper.0$(LIBEXT)
endif
Marek Vavruša's avatar
Marek Vavruša committed
17 18 19 20 21 22
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)
23
	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
24 25 26 27
else
	preload_syms := LD_PRELOAD="$(libfaketime):$(libcwrap)"
endif

28

29
# Targets
30
all:
31 32 33
	@echo "Deckard is now run using *run.sh scripts in its root directory."
	@echo "To build the dependencies (libfaketime and libcwrap) run 'make depend'."
	exit 1
Marek Vavruša's avatar
Marek Vavruša committed
34
depend: $(libfaketime) $(libcwrap)
35 36
	@echo "export DONT_FAKE_MONOTONIC=1" > env.sh
	@echo "export $(preload_syms)" >> env.sh
37

Marek Vavruša's avatar
Marek Vavruša committed
38
# Synchronize submodules
39
submodules: .gitmodules
40
	@git submodule update --init
41 42 43
# 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
44
$(libfaketime): $(libfaketime_DIR)/Makefile
45
	@CFLAGS="-O0 -g" $(MAKE) -s -C $(libfaketime_DIR)
46 47 48
$(libcwrap_cmake_DIR):$(libcwrap_DIR)/CMakeLists.txt
	@mkdir -p $(libcwrap_cmake_DIR)
$(libcwrap_cmake_DIR)/Makefile: $(libcwrap_cmake_DIR)
49 50
	@cd $(libcwrap_cmake_DIR); cmake ..
$(libcwrap): $(libcwrap_cmake_DIR)/Makefile
51
	@CFLAGS="-O0 -g" $(MAKE) -s -C $(libcwrap_cmake_DIR)
52

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

54
.PHONY: submodules depend all
55 56 57

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