test/Makefile
author Damiano Boppart <damiano.boppart@pep.security>
Mon, 24 Dec 2018 15:22:55 +0100
branchmake-cleanup
changeset 3206 48f8fec4b7d1
parent 3205 eb1093486582
child 3208 204ff09a2787
permissions -rw-r--r--
Use LD_LIBRARY_PATH for running test binary
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@1513
     4
# see LICENSE.txt
vb@1513
     5
damiano@3202
     6
HERE:=$(CURDIR)
damiano@3202
     7
damiano@3201
     8
include ../Makefile.conf
vb@2
     9
damiano@3202
    10
# User's without python3 will skip the generated parts of the test suite. That's OK.
krista@3200
    11
PY_ENV:=$(shell command -v python3 2> /dev/null)
krista@2642
    12
krista@2639
    13
TEST_HOME=$(HERE)/pEp_test_home
damiano@1970
    14
krista@2638
    15
TARGET=TestDriver
krista@2638
    16
damiano@3202
    17
SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
damiano@3202
    18
OBJS:=$(addsuffix .o,$(basename $(SRCS)))
damiano@3202
    19
DEPS:=$(OBJS:.o=.d)
krista@2637
    20
krista@2637
    21
damiano@3202
    22
LDFLAGS+= -L../asn.1 -L../src $(ETPAN_LIB) $(CPPUNIT_LIB)
krista@2637
    23
damiano@3202
    24
ifeq ($(OPENPGP),GPG)
damiano@3202
    25
    LDFLAGS+= $(GPGME_LIB)
damiano@3202
    26
else ifeq ($(OPENPGP),NETPGP)
damiano@3202
    27
    LDFLAGS+= $(NETGPG_LIB)
Edouard@178
    28
endif
Edouard@178
    29
damiano@3202
    30
damiano@3202
    31
LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1 -lcpptest
damiano@3202
    32
krista@3164
    33
ifeq ($(BUILD_FOR),Linux)
damiano@3202
    34
    LDLIBS+= -luuid
edouard@1939
    35
endif
edouard@1939
    36
damiano@2002
    37
ifdef SQLITE3_FROM_OS
damiano@3202
    38
    LDLIBS+= -lsqlite3
damiano@2002
    39
endif
damiano@2002
    40
damiano@3202
    41
ifeq ($(OPENPGP),GPG)
damiano@3202
    42
    #LDLIBS+= -lgpgme
damiano@3202
    43
else ifeq ($(OPENPGP),NETPGP)
damiano@3202
    44
    LDLIBS+= -lnetpgp
damiano@3202
    45
    ifeq ($(BUILD_FOR),Linux)
damiano@3202
    46
        LDLIBS+= -ltre
damiano@3202
    47
    endif
damiano@1970
    48
endif
damiano@1970
    49
krista@2637
    50
damiano@3202
    51
CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
damiano@3202
    52
damiano@3202
    53
# FIXME Possibly missing incdirs: ASN1C_INC
damiano@3202
    54
CXXFLAGS+= -I./include -I../sync $(CPPUNIT_INC) -Wno-deprecated
damiano@3202
    55
damiano@3202
    56
ifeq ($(OPENPGP),GPG)
damiano@3202
    57
    CXXFLAGS+= -DUSE_GPG $(GPGME_INC)
damiano@3202
    58
else ifeq ($(OPENPGP),NETPGP)
damiano@3202
    59
    CXXFLAGS+= -DUSE_NETPGP $(NETPGP_INC)
damiano@1970
    60
endif
krista@2637
    61
damiano@1970
    62
damiano@3206
    63
EXTRA_LIB_PATHS=.:
damiano@3206
    64
ifdef ETPAN_LIB
damiano@3206
    65
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
damiano@3206
    66
endif
damiano@3206
    67
ifdef GPGME_LIB
damiano@3206
    68
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
damiano@3206
    69
endif
damiano@3206
    70
ifdef NETPGP_LIB
damiano@3206
    71
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
damiano@3206
    72
endif
damiano@3206
    73
ifdef CPPUNIT_LIB
damiano@3206
    74
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(CPPUNIT_LIB)):
damiano@3206
    75
endif
damiano@3206
    76
damiano@3206
    77
# Remove trailing ':'
damiano@3206
    78
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
damiano@3206
    79
damiano@3206
    80
ifeq ($(BUILD_FOR),Darwin)
damiano@3206
    81
    LIBPATH=DYLD_LIBRARY_PATH
damiano@3206
    82
else
damiano@3206
    83
    LIBPATH=LD_LIBRARY_PATH
damiano@3206
    84
endif
damiano@3206
    85
damiano@3206
    86
TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS)
damiano@3206
    87
damiano@3206
    88
damiano@3202
    89
.PHONY: all
damiano@3202
    90
all: suitemaker $(TARGET) scripts
damiano@2062
    91
damiano@3202
    92
%.d: %.cc
damiano@3202
    93
	$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
krista@3170
    94
krista@2637
    95
$(TARGET): $(OBJS)
damiano@3205
    96
	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@
edouard@1844
    97
krista@2642
    98
.PHONY: suitemaker
krista@2642
    99
suitemaker:
krista@2642
   100
ifndef PY_ENV
krista@2642
   101
	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
krista@2642
   102
else
krista@2941
   103
ifndef EXCLUDE
krista@2642
   104
	$(PY_ENV) gensuitemaker.py
krista@2941
   105
else
krista@2941
   106
	# Comma-separated list, no spaces
krista@2941
   107
	$(PY_ENV) gensuitemaker.py --exclude=$(EXCLUDE)
krista@2941
   108
endif
krista@2642
   109
endif
krista@2696
   110
vb@2750
   111
.PHONY: scripts
damiano@3202
   112
scripts:
krista@2696
   113
ifdef PY_ENV
krista@2696
   114
	$(PY_ENV) genscripts.py
krista@2696
   115
endif
krista@2639
   116
krista@2639
   117
.PHONY: test
krista@2639
   118
test: all
damiano@3206
   119
	$(TEST_CMD_PFX) $(TEST_DEBUGGER) ./$(TARGET)
damiano@3202
   120
damiano@1970
   121
.PHONY: clean
vb@2
   122
clean:
damiano@3204
   123
	$(RM) $(TARGET) $(TARGET).o $(OBJS) $(notdir $(basename $(OBJS))) $(DEPS)
damiano@3205
   124
	$(RM) $(HERE)/*Tests msg_2.0.asc $(HERE)/pEp_test_home
vb@2
   125
damiano@3202
   126
# If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
damiano@3202
   127
ifneq ($(MAKECMDGOALS),clean)
damiano@3202
   128
    -include $(DEPS)
damiano@3202
   129
endif