krista@2637: damiano@1960: # Copyright 2017, pEp Foundation damiano@1958: # This file is part of pEpEngine damiano@1958: # This file may be used under the terms of the GNU General Public License version 3 vb@1517: # see LICENSE.txt vb@1517: damiano@2210: include ../default.conf vb@1422: krista@2645: PY_ENV := $(shell command -v python3 2> /dev/null) krista@2642: krista@2637: HERE:=$(CURDIR) krista@2639: TEST_HOME=$(HERE)/pEp_test_home krista@2637: krista@2638: TARGET=TestDriver krista@2638: krista@2639: SRCS := $(wildcard src/*.cc) $(wildcard src/*/*.cc) krista@2637: OBJS := $(addsuffix .o,$(basename $(SRCS))) krista@2637: DEPS := $(OBJS:.o=.d) damiano@1970: krista@2639: INC_DIRS := ./include /usr/local/include krista@2637: INC_FLAGS := $(addprefix -I,$(INC_DIRS)) krista@2637: krista@2637: LDFLAGS += -L/usr/local/lib krista@2637: krista@2637: CFLAGS += -Wno-deprecated krista@2637: CXXFLAGS += -Wno-deprecated damiano@1970: damiano@1970: LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src damiano@1970: LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1 damiano@1970: krista@1989: ifeq ($(BUILD_FOR),Linux) krista@2637: LDLIBS+= -luuid krista@1989: endif krista@1988: damiano@1972: ifeq ($(OPENPGP),NETPGP) krista@2637: LDLIBS+= -lnetpgp Edouard@178: endif Edouard@178: damiano@2002: ifdef SQLITE3_FROM_OS krista@2637: LDLIBS+= -lsqlite3 damiano@2002: endif damiano@2002: damiano@1970: ifeq ($(shell uname),Darwin) krista@2637: LIBPATH=DYLD_LIBRARY_PATH krista@2637: LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb damiano@1970: else krista@2637: LIBPATH=LD_LIBRARY_PATH krista@2637: LLDB_BIN=lldb Edouard@178: endif Edouard@178: krista@2637: LDLIBS += -lcpptest krista@2637: krista@2637: damiano@1972: # Create a list of the extra library paths for the loader. I do not assume that the engine (and its dependencies) are installed for testing. damiano@1970: # Note that += can not be used here, as it changes the amount of whitespace damiano@1970: EXTRA_LIB_PATHS=../src: damiano@1970: ifdef ETPAN_LIB krista@2637: EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)): damiano@1970: endif damiano@1970: ifdef GPGME_LIB krista@2637: EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)): damiano@1970: endif damiano@1970: ifdef NETPGP_LIB krista@2637: EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)): damiano@1970: endif krista@2637: damiano@1970: # Remove trailing ':' damiano@1970: EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=) damiano@1970: damiano@2074: CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS)) damiano@2063: ifneq ($(MAKECMDGOALS),clean) krista@2637: ifneq (,$(findstring -DNDEBUG,$(CFLAGS))) krista@2637: $(error The macro NDEBUG must not be defined for test compilation.) krista@2637: endif damiano@2062: endif damiano@2062: damiano@2075: CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS)) damiano@2075: ifneq ($(MAKECMDGOALS),clean) krista@2637: ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS))) krista@2637: $(error The macro NDEBUG must not be defined for test compilation.) krista@2637: endif damiano@2075: endif damiano@2075: krista@2637: CPPFLAGS += $(INC_FLAGS) -MMD -MP roker@1659: krista@2696: all: suitemaker $(TARGET) test_home_ scripts krista@2639: krista@2637: $(TARGET): $(OBJS) krista@2639: $(CXX) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@ krista@2639: krista@2642: .PHONY: suitemaker krista@2642: suitemaker: krista@2642: ifndef PY_ENV krista@2642: @echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3." krista@2642: else krista@2642: $(PY_ENV) gensuitemaker.py krista@2642: endif krista@2642: krista@2639: .PHONY: test_home_ krista@2639: test_home_: krista@2696: krista@2696: krista@2696: .PHONY: test_home_ krista@2696: scripts: krista@2696: ifdef PY_ENV krista@2696: $(PY_ENV) genscripts.py krista@2696: endif edouard@1844: krista@2639: .PHONY: test krista@2639: test: all krista@2645: ./$(TARGET) krista@2639: damiano@1970: .PHONY: clean vb@2: clean: krista@2637: $(RM) $(TARGET) $(OBJS) $(DEPS) krista@2696: $(RM) $(HERE)/*Tests vb@2: roker@1656: roker@1656: krista@2639: -include $(DEPS) krista@2639: