damiano@1960
|
1 |
# Copyright 2017, pEp Foundation
|
damiano@1958
|
2 |
# This file is part of pEpEngine
|
damiano@1958
|
3 |
# This file may be used under the terms of the GNU General Public License version 3
|
vb@1517
|
4 |
# see LICENSE.txt
|
vb@1517
|
5 |
|
damiano@1958
|
6 |
HERE:=$(CURDIR)
|
vb@2
|
7 |
|
edouard@1844
|
8 |
include ../Makefile.conf
|
vb@1422
|
9 |
|
damiano@1970
|
10 |
TARGET=pEpEngineTest
|
damiano@1970
|
11 |
|
damiano@1970
|
12 |
unexport GNUPGHOME
|
damiano@1970
|
13 |
TEST_HOME=$(HERE)/test_home
|
krista@2144
|
14 |
TEST_GNUPGHOME=$(TEST_HOME)/gnupg
|
damiano@1970
|
15 |
|
damiano@1970
|
16 |
LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src
|
damiano@1970
|
17 |
LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
|
damiano@1970
|
18 |
|
krista@1989
|
19 |
ifeq ($(BUILD_FOR),Linux)
|
damiano@1970
|
20 |
LDLIBS+= -luuid
|
krista@1989
|
21 |
endif
|
krista@1988
|
22 |
|
damiano@1972
|
23 |
ifeq ($(OPENPGP),NETPGP)
|
damiano@1970
|
24 |
LDLIBS+= -lnetpgp
|
Edouard@178
|
25 |
endif
|
Edouard@178
|
26 |
|
damiano@2002
|
27 |
ifdef SQLITE3_FROM_OS
|
damiano@2002
|
28 |
LDLIBS+= -lsqlite3
|
damiano@2002
|
29 |
endif
|
damiano@2002
|
30 |
|
damiano@1970
|
31 |
ifeq ($(shell uname),Darwin)
|
damiano@1970
|
32 |
LIBPATH=DYLD_LIBRARY_PATH
|
damiano@1970
|
33 |
LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
|
damiano@1970
|
34 |
else
|
damiano@1970
|
35 |
LIBPATH=LD_LIBRARY_PATH
|
damiano@1970
|
36 |
LLDB_BIN=lldb
|
Edouard@178
|
37 |
endif
|
Edouard@178
|
38 |
|
damiano@1972
|
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.
|
damiano@1970
|
40 |
# Note that += can not be used here, as it changes the amount of whitespace
|
damiano@1970
|
41 |
EXTRA_LIB_PATHS=../src:
|
damiano@1970
|
42 |
ifdef ETPAN_LIB
|
damiano@1970
|
43 |
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
|
damiano@1970
|
44 |
endif
|
damiano@1970
|
45 |
ifdef GPGME_LIB
|
damiano@1970
|
46 |
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
|
damiano@1970
|
47 |
endif
|
damiano@1970
|
48 |
ifdef NETPGP_LIB
|
damiano@1970
|
49 |
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
|
damiano@1970
|
50 |
endif
|
damiano@1970
|
51 |
# Remove trailing ':'
|
damiano@1970
|
52 |
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
|
damiano@1970
|
53 |
|
krista@2144
|
54 |
TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS) HOME=$(TEST_HOME) GNUPGHOME=$(TEST_GNUPGHOME)
|
vb@2
|
55 |
|
vb@50
|
56 |
UNIT_TESTS_SOURCE=$(wildcard *_test.cc)
|
vb@50
|
57 |
UNIT_TESTS=$(subst .cc,,$(UNIT_TESTS_SOURCE))
|
krista@1617
|
58 |
UNIT_TESTS_RUN=$(subst .cc,_run,$(UNIT_TESTS_SOURCE))
|
vb@2
|
59 |
|
damiano@2074
|
60 |
CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
|
damiano@2063
|
61 |
ifneq ($(MAKECMDGOALS),clean)
|
damiano@2064
|
62 |
ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
|
damiano@2063
|
63 |
$(error The macro NDEBUG must not be defined for test compilation.)
|
damiano@2063
|
64 |
endif
|
damiano@2062
|
65 |
endif
|
damiano@2062
|
66 |
|
damiano@2075
|
67 |
CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
|
damiano@2075
|
68 |
ifneq ($(MAKECMDGOALS),clean)
|
damiano@2075
|
69 |
ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
|
damiano@2075
|
70 |
$(error The macro NDEBUG must not be defined for test compilation.)
|
damiano@2075
|
71 |
endif
|
damiano@2075
|
72 |
endif
|
damiano@2075
|
73 |
|
damiano@1970
|
74 |
.PHONY: all
|
vb@48
|
75 |
all: $(TARGET) $(UNIT_TESTS)
|
vb@2
|
76 |
|
roker@1659
|
77 |
# don't delete .o files!
|
roker@1659
|
78 |
.PRECIOUS: %.o
|
roker@1659
|
79 |
|
damiano@1970
|
80 |
.PHONY: test_home_
|
edouard@1934
|
81 |
test_home_:
|
krista@2144
|
82 |
-GNUPGHOME=$(TEST_GNUPGHOME) gpgconf --kill gpg-agent
|
edouard@1934
|
83 |
rm -rf $(TEST_HOME)
|
edouard@1934
|
84 |
mkdir -p $(TEST_GNUPGHOME)/private-keys-v1.d
|
edouard@1934
|
85 |
$(GPG_CMD) --import --batch --homedir $(TEST_GNUPGHOME) 0x*.asc *_sec.asc
|
edouard@1844
|
86 |
|
damiano@1970
|
87 |
.PHONY: clean
|
vb@2
|
88 |
clean:
|
damiano@2244
|
89 |
rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc msg_encrypt_for_self.asc
|
edouard@1934
|
90 |
rm -Rf *.dSYM $(TEST_HOME) pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
|
vb@2
|
91 |
|
damiano@1970
|
92 |
.PHONY: test
|
damiano@1970
|
93 |
test: $(TARGET) test_home_
|
damiano@1970
|
94 |
$(TEST_CMD_PFX) ./$<
|
vb@2
|
95 |
|
roker@1656
|
96 |
%_test : %_test.o test_util.o
|
damiano@1994
|
97 |
$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)
|
roker@1656
|
98 |
|
edouard@1844
|
99 |
%_run : % test_home_
|
edouard@1844
|
100 |
$(TEST_CMD_PFX) ./$<
|
Edouard@699
|
101 |
|
edouard@1844
|
102 |
%_lldb : % test_home_
|
edouard@1851
|
103 |
$(TEST_CMD_PFX) $(LLDB_BIN) ./$<
|
roker@1656
|
104 |
|
edouard@1844
|
105 |
%_valgrind : % test_home_
|
edouard@1844
|
106 |
$(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
|
Edouard@745
|
107 |
|
edouard@1844
|
108 |
%_gdb : % test_home_
|
edouard@1844
|
109 |
$(TEST_CMD_PFX) gdb ./$<
|
Edouard@770
|
110 |
|
damiano@1970
|
111 |
.PHONY: unit_tests
|
Edouard@699
|
112 |
unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
|
vb@142
|
113 |
|
damiano@1994
|
114 |
.PHONY: compile
|
damiano@1994
|
115 |
compile: $(UNIT_TESTS) $(TARGET)
|
damiano@1994
|
116 |
|
damiano@1970
|
117 |
# Installs the engine, not the test binaries
|
damiano@1970
|
118 |
.PHONY: install
|
vb@142
|
119 |
install:
|
damiano@1970
|
120 |
$(MAKE) -C .. install
|