Backed out changeset 7f450536254c. Thanks for the head up Daniano.
1 # Copyright 2017, pEp Foundation
2 # This file is part of pEpEngine
3 # This file may be used under the terms of the GNU General Public License version 3
8 include ../Makefile.conf
13 TEST_HOME=$(HERE)/test_home
14 TEST_GNUPGHOME=$(TEST_HOME)/gnupg
16 LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src
17 LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
19 ifeq ($(BUILD_FOR),Linux)
23 ifeq ($(OPENPGP),NETPGP)
31 ifeq ($(shell uname),Darwin)
32 LIBPATH=DYLD_LIBRARY_PATH
33 LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
35 LIBPATH=LD_LIBRARY_PATH
39 # 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.
40 # Note that += can not be used here, as it changes the amount of whitespace
41 EXTRA_LIB_PATHS=../src:
43 EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
46 EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
49 EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
52 EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
54 TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS) HOME=$(TEST_HOME) GNUPGHOME=$(TEST_GNUPGHOME)
56 UNIT_TESTS_SOURCE=$(wildcard *_test.cc)
57 UNIT_TESTS=$(subst .cc,,$(UNIT_TESTS_SOURCE))
58 UNIT_TESTS_RUN=$(subst .cc,_run,$(UNIT_TESTS_SOURCE))
60 CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
61 ifneq ($(MAKECMDGOALS),clean)
62 ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
63 $(error The macro NDEBUG must not be defined for test compilation.)
67 CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
68 ifneq ($(MAKECMDGOALS),clean)
69 ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
70 $(error The macro NDEBUG must not be defined for test compilation.)
75 all: $(TARGET) $(UNIT_TESTS)
77 # don't delete .o files!
82 -GNUPGHOME=$(TEST_GNUPGHOME) gpgconf --kill gpg-agent
84 mkdir -p $(TEST_GNUPGHOME)/private-keys-v1.d
85 $(GPG_CMD) --import --batch --homedir $(TEST_GNUPGHOME) 0x*.asc *_sec.asc
89 rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
90 rm -Rf *.dSYM $(TEST_HOME) pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
93 test: $(TARGET) test_home_
96 %_test : %_test.o test_util.o
97 $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)
102 %_lldb : % test_home_
103 $(TEST_CMD_PFX) $(LLDB_BIN) ./$<
105 %_valgrind : % test_home_
106 $(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
109 $(TEST_CMD_PFX) gdb ./$<
112 unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
115 compile: $(UNIT_TESTS) $(TARGET)
117 # Installs the engine, not the test binaries
120 $(MAKE) -C .. install