test/Makefile
author Damiano Boppart <damiano@pep-security.net>
Mon, 14 Aug 2017 02:26:09 +0200
branchENGINE-228
changeset 1958 433df9ee336d
parent 1955 8ec0b81a659f
child 1959 fe4d994a1105
permissions -rw-r--r--
More Makefile cleanup
damiano@1958
     1
# Copyright 2017, pEp Security SA
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@1958
    10
LD=$(CXX)
damiano@1958
    11
LDFLAGS+= $(ETPAN_LIB) -L../asn.1
damiano@1958
    12
LDLIBS?=-letpan -lpEpEngine -lstdc++ -lasn1
vb@1304
    13
ifeq ($(BUILD_FOR),Linux)
vb@1310
    14
	LDLIBS+= -luuid
vb@1304
    15
endif
vb@2
    16
Edouard@178
    17
ifeq ("$(OPENPGP)","NETPGP")
Edouard@178
    18
	LDLIBS+= -lnetpgp
Edouard@178
    19
endif
Edouard@178
    20
vb@2
    21
TARGET=pEpEngineTest
vb@2
    22
vb@50
    23
UNIT_TESTS_SOURCE=$(wildcard *_test.cc)
vb@50
    24
UNIT_TESTS=$(subst .cc,,$(UNIT_TESTS_SOURCE))
krista@1617
    25
UNIT_TESTS_RUN=$(subst .cc,_run,$(UNIT_TESTS_SOURCE))
vb@2
    26
vb@48
    27
all: $(TARGET) $(UNIT_TESTS)
vb@2
    28
vb@2
    29
.PHONY: clean
vb@2
    30
roker@1659
    31
# don't delete .o files!
roker@1659
    32
.PRECIOUS: %.o
roker@1659
    33
edouard@1844
    34
unexport GNUPGHOME;
edouard@1844
    35
TEST_HOME=$(HERE)/test_home
edouard@1934
    36
TEST_GNUPGHOME=$(TEST_HOME)/.gnupg
edouard@1844
    37
edouard@1929
    38
ifeq ($(shell which gpg2), )
edouard@1929
    39
    GPG_CMD = gpg
edouard@1929
    40
else
edouard@1929
    41
    GPG_CMD = gpg2
edouard@1929
    42
endif
edouard@1929
    43
edouard@1844
    44
ifeq ($(shell uname), Darwin)
edouard@1844
    45
    LIBPATH = DYLD_LIBRARY_PATH
edouard@1851
    46
    LLDB_BIN = /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
edouard@1844
    47
else
edouard@1844
    48
    LIBPATH = LD_LIBRARY_PATH
edouard@1851
    49
    LLDB_BIN = lldb
edouard@1844
    50
endif
edouard@1844
    51
edouard@1844
    52
TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
edouard@1844
    53
edouard@1934
    54
test_home_: 
edouard@1941
    55
	-gpgconf --kill gpg-agent
edouard@1941
    56
	-HOME=$(TEST_HOME) gpgconf --kill gpg-agent
edouard@1941
    57
	-killall gpg-agent
edouard@1934
    58
	rm -rf $(TEST_HOME)
edouard@1934
    59
	mkdir -p $(TEST_GNUPGHOME)/private-keys-v1.d
edouard@1934
    60
	$(GPG_CMD) --import --batch --homedir $(TEST_GNUPGHOME) 0x*.asc *_sec.asc
edouard@1844
    61
vb@2
    62
clean:
vb@458
    63
	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
edouard@1934
    64
	rm -Rf *.dSYM $(TEST_HOME) pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
vb@2
    65
edouard@1844
    66
test: pEpEngineTest test_home_
edouard@1844
    67
	$(TEST_CMD_PFX) ./pEpEngineTest
vb@2
    68
roker@1656
    69
%_test : %_test.o test_util.o
roker@1656
    70
	 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
roker@1656
    71
edouard@1844
    72
%_run : % test_home_
edouard@1844
    73
	$(TEST_CMD_PFX) ./$<
Edouard@699
    74
edouard@1844
    75
%_lldb : % test_home_
edouard@1851
    76
	$(TEST_CMD_PFX) $(LLDB_BIN) ./$<
roker@1656
    77
edouard@1844
    78
%_valgrind : % test_home_
edouard@1844
    79
	$(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
Edouard@745
    80
edouard@1844
    81
%_gdb : % test_home_
edouard@1844
    82
	$(TEST_CMD_PFX) gdb ./$<
Edouard@770
    83
Edouard@699
    84
unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
vb@142
    85
vb@142
    86
install:
vb@142
    87
	make -C .. install